apply FSL(Flora Software License)
authorKim Kibum <kb0929.kim@samsung.com>
Fri, 8 Jun 2012 05:54:07 +0000 (14:54 +0900)
committerKim Kibum <kb0929.kim@samsung.com>
Fri, 8 Jun 2012 05:54:07 +0000 (14:54 +0900)
468 files changed:
AUTHORS [new file with mode: 0755]
CMakeLists.txt [new file with mode: 0755]
LICENSE [new file with mode: 0755]
SLP_MessagingFW_PG.h [new file with mode: 0755]
TC/_export_env.sh [new file with mode: 0755]
TC/_export_target_env.sh [new file with mode: 0755]
TC/build.sh [new file with mode: 0755]
TC/execute.sh [new file with mode: 0755]
TC/making_new_tet_scen.py [new file with mode: 0755]
TC/msgTC/MapiControl/Makefile [new file with mode: 0755]
TC/msgTC/MapiControl/tslist [new file with mode: 0755]
TC/msgTC/MapiControl/utc_msg_close_msg_handle.c [new file with mode: 0755]
TC/msgTC/MapiControl/utc_msg_close_msg_handle.h [new file with mode: 0755]
TC/msgTC/MapiControl/utc_msg_open_msg_handle.c [new file with mode: 0755]
TC/msgTC/MapiControl/utc_msg_open_msg_handle.h [new file with mode: 0755]
TC/msgTC/MapiMessage/Makefile [new file with mode: 0755]
TC/msgTC/MapiMessage/tslist [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_add_address.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_add_address.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_address_count.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_address_count.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_dest_port.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_dest_port.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_direction_info.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_direction_info.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_encode_type.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_encode_type.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_folder_id.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_folder_id.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_ith_address.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_ith_address.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_ith_contact_id.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_ith_contact_id.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_ith_name.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_ith_name.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_ith_recipient_type.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_ith_recipient_type.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_ith_thread_id.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_ith_thread_id.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_message_body_size.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_message_body_size.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_message_id.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_message_id.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_message_type.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_message_type.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_network_status.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_network_status.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_priority_info.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_priority_info.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_scheduled_time.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_scheduled_time.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_src_port.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_src_port.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_storage_id.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_storage_id.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_subject.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_subject.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_time.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_get_time.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_is_in_sim.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_is_in_sim.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_is_mms.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_is_mms.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_is_protected.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_is_protected.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_is_read.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_is_read.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_is_sms.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_is_sms.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_add_attachment.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_add_attachment.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_add_media.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_add_media.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_add_meta.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_add_meta.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_add_page.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_add_page.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_add_region.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_add_region.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_add_transition.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_add_transition.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_create_message.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_create_message.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_destroy_message.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_destroy_message.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_attachment.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_attachment.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_media.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_media.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_message_body.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_message_body.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_meta.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_meta.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_page.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_page.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_smil_region.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_smil_region.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_transition.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_get_transition.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_set_message_body.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_set_message_body.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_set_rootlayout.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_mms_set_rootlayout.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_new_message.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_new_message.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_release_message.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_release_message.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_reset_address.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_reset_address.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_direction_info.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_direction_info.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_encode_type.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_encode_type.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_folder_id.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_folder_id.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_message_id.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_message_id.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_message_type.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_message_type.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_network_status.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_network_status.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_port.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_port.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_priority_info.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_priority_info.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_protect_status.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_protect_status.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_read_status.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_read_status.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_scheduled_time.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_scheduled_time.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_storage_id.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_storage_id.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_subject.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_subject.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_time.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_set_time.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_sms_get_message_body.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_sms_get_message_body.h [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_sms_set_message_body.c [new file with mode: 0755]
TC/msgTC/MapiMessage/utc_msg_sms_set_message_body.h [new file with mode: 0755]
TC/msgTC/MapiSetting/Makefile [new file with mode: 0755]
TC/msgTC/MapiSetting/tslist [new file with mode: 0755]
TC/msgTC/MapiSetting/utc_msg_get_config.c [new file with mode: 0755]
TC/msgTC/MapiSetting/utc_msg_get_config.h [new file with mode: 0755]
TC/msgTC/MapiSetting/utc_msg_set_config.c [new file with mode: 0755]
TC/msgTC/MapiSetting/utc_msg_set_config.h [new file with mode: 0755]
TC/msgTC/MapiStorage/Makefile [new file with mode: 0755]
TC/msgTC/MapiStorage/tslist [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_add_folder.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_add_folder.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_add_message.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_add_message.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_add_syncml_message.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_add_syncml_message.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_count_message.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_count_message.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_count_msg_by_contact.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_count_msg_by_contact.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_count_msg_by_type.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_count_msg_by_type.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_delete_all_msgs_in_folder.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_delete_all_msgs_in_folder.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_delete_folder.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_delete_folder.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_delete_message.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_delete_message.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_delete_thread_message_list.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_delete_thread_message_list.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_generate_message.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_generate_message.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_conversation_view_list.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_conversation_view_list.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_folder_list.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_folder_list.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_folder_view_list.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_folder_view_list.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_mem_size.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_mem_size.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_message.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_message.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_quick_panel_data.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_quick_panel_data.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_thread_view_list.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_get_thread_view_list.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_move_msg_to_folder.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_move_msg_to_folder.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_move_msg_to_storage.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_move_msg_to_storage.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_release_folder_list.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_release_folder_list.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_release_thread_view_list.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_release_thread_view_list.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_reset_database.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_reset_database.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_address.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_address.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_contact_id.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_contact_id.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_data.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_data.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_direction.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_direction.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_image_path.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_image_path.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_mms_cnt.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_mms_cnt.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_name.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_name.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_sms_cnt.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_sms_cnt.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_thread_id.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_thread_id.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_time.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_time.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_unread_cnt.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_thread_view_get_unread_cnt.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_update_folder.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_update_folder.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_update_message.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_update_message.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_update_protected_status.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_update_protected_status.h [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_update_read_status.c [new file with mode: 0755]
TC/msgTC/MapiStorage/utc_msg_update_read_status.h [new file with mode: 0755]
TC/msgTC/MapiTransport/Makefile [new file with mode: 0755]
TC/msgTC/MapiTransport/tslist [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_mms_forward_message.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_mms_forward_message.h [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_mms_reject_message.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_mms_reject_message.h [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_mms_retrieve_message.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_mms_retrieve_message.h [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_mms_send_message.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_mms_send_message.h [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_mms_send_read_report.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_mms_send_read_report.h [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_reg_lbs_message_callback.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_reg_lbs_message_callback.h [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_reg_mms_conf_message_callback.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_reg_mms_conf_message_callback.h [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_reg_sent_status_callback.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_reg_sent_status_callback.h [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_reg_sms_message_callback.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_reg_sms_message_callback.h [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_reg_syncml_message_callback.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_reg_syncml_message_callback.h [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_sms_send.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_sms_send.h [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_sms_send_message.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_sms_send_message.h [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_submit_req.c [new file with mode: 0755]
TC/msgTC/MapiTransport/utc_msg_submit_req.h [new file with mode: 0755]
TC/tet_scen [new file with mode: 0755]
TC/tetbuild.cfg [new file with mode: 0644]
TC/tetclean.cfg [new file with mode: 0644]
TC/tetexec.cfg [new file with mode: 0644]
TC/tslist.txt [new file with mode: 0755]
config/.msg_service.db [new file with mode: 0755]
config/.msg_service.db-journal [new file with mode: 0755]
config/alert_on_call.mp3 [new file with mode: 0755]
config/kdb-setting.sh [new file with mode: 0755]
config/message_tone/Sherbet.wav [new file with mode: 0755]
config/plugin.cfg [new file with mode: 0755]
debian/changelog [new file with mode: 0755]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0755]
debian/dirs [new file with mode: 0644]
debian/docs [new file with mode: 0644]
debian/libslp-mms-plugin.install.in [new file with mode: 0755]
debian/libslp-msg-service-0.install.in [new file with mode: 0755]
debian/libslp-msg-service-dev.install.in [new file with mode: 0755]
debian/libslp-sms-plugin.install.in [new file with mode: 0755]
debian/msg-service-tools.install.in [new file with mode: 0755]
debian/msg-service-tools.postinst [new file with mode: 0755]
debian/rules [new file with mode: 0755]
framework/CMakeLists.txt [new file with mode: 0755]
framework/deliver-handler/MsgDeliverHandler.cpp [new file with mode: 0755]
framework/main.cpp [new file with mode: 0755]
framework/plugin-manager/MsgPluginConfig.cpp [new file with mode: 0755]
framework/plugin-manager/MsgPluginManager.cpp [new file with mode: 0755]
framework/setting-handler/MsgSettingHandler.cpp [new file with mode: 0755]
framework/storage-handler/MsgStorageFolder.cpp [new file with mode: 0755]
framework/storage-handler/MsgStorageManager.cpp [new file with mode: 0755]
framework/storage-handler/MsgStorageMessage.cpp [new file with mode: 0755]
framework/storage-handler/MsgStorageMms.cpp [new file with mode: 0755]
framework/storage-handler/MsgStorageSim.cpp [new file with mode: 0755]
framework/storage-handler/MsgStorageUtil.cpp [new file with mode: 0755]
framework/submit-handler/MsgSubmitHandler.cpp [new file with mode: 0755]
framework/transaction-manager/MsgCmdHandlerSetting.cpp [new file with mode: 0755]
framework/transaction-manager/MsgCmdHandlerStorage.cpp [new file with mode: 0755]
framework/transaction-manager/MsgCmdHandlerTransport.cpp [new file with mode: 0755]
framework/transaction-manager/MsgTransManager.cpp [new file with mode: 0755]
image/messaging_image001.png [new file with mode: 0755]
include/common/MsgCmdTypes.h [new file with mode: 0755]
include/common/MsgCppTypes.h [new file with mode: 0755]
include/common/MsgInternalTypes.h [new file with mode: 0755]
include/common/MsgMmsTypes.h [new file with mode: 0755]
include/common/MsgPluginInterface.h [new file with mode: 0755]
include/common/MsgQueue.h [new file with mode: 0755]
include/common/MsgSettingTypes.h [new file with mode: 0755]
include/common/MsgStorageTypes.h [new file with mode: 0755]
include/common/MsgThread.h [new file with mode: 0755]
include/common/MsgTransportTypes.h [new file with mode: 0755]
include/common/MsgTypes.h [new file with mode: 0755]
include/framework/MsgCmdHandler.h [new file with mode: 0755]
include/framework/MsgDeliverHandler.h [new file with mode: 0755]
include/framework/MsgPluginConfig.h [new file with mode: 0755]
include/framework/MsgPluginManager.h [new file with mode: 0755]
include/framework/MsgSettingHandler.h [new file with mode: 0755]
include/framework/MsgStorageHandler.h [new file with mode: 0755]
include/framework/MsgSubmitHandler.h [new file with mode: 0755]
include/framework/MsgTransManager.h [new file with mode: 0755]
include/mapi/MapiControl.h [new file with mode: 0755]
include/mapi/MapiMessage.h [new file with mode: 0755]
include/mapi/MapiSetting.h [new file with mode: 0755]
include/mapi/MapiStorage.h [new file with mode: 0755]
include/mapi/MapiTransport.h [new file with mode: 0755]
include/msg_helper/MsgHelper.h [new file with mode: 0755]
include/proxy/MsgHandle.h [new file with mode: 0755]
include/proxy/MsgProxyListener.h [new file with mode: 0755]
include/utils/MsgContact.h [new file with mode: 0755]
include/utils/MsgDebug.h [new file with mode: 0755]
include/utils/MsgDrmWrapper.h [new file with mode: 0755]
include/utils/MsgException.h [new file with mode: 0755]
include/utils/MsgGconfWrapper.h [new file with mode: 0755]
include/utils/MsgIpcSocket.h [new file with mode: 0755]
include/utils/MsgMemory.h [new file with mode: 0755]
include/utils/MsgMmsMessage.h [new file with mode: 0755]
include/utils/MsgMutex.h [new file with mode: 0755]
include/utils/MsgNotificationWrapper.h [new file with mode: 0755]
include/utils/MsgSoundPlayer.h [new file with mode: 0755]
include/utils/MsgSqliteWrapper.h [new file with mode: 0755]
include/utils/MsgUtilFile.h [new file with mode: 0755]
include/utils/MsgUtilFunction.h [new file with mode: 0755]
include/utils/MsgUtilStorage.h [new file with mode: 0755]
mapi/CMakeLists.txt [new file with mode: 0755]
mapi/MapiControl.cpp [new file with mode: 0755]
mapi/MapiMessage.cpp [new file with mode: 0755]
mapi/MapiSetting.cpp [new file with mode: 0755]
mapi/MapiStorage.cpp [new file with mode: 0755]
mapi/MapiTransport.cpp [new file with mode: 0755]
msg-server [new file with mode: 0755]
msg-service.pc.in [new file with mode: 0755]
msg_helper/CMakeLists.txt [new file with mode: 0755]
msg_helper/MsgSoundPlayer.cpp [new file with mode: 0755]
msg_helper/main.cpp [new file with mode: 0755]
packaging/msg-service.spec [new file with mode: 0755]
plugin/mms_plugin/CMakeLists.txt [new file with mode: 0755]
plugin/mms_plugin/LanguagePack/MmsPluginWmLngLatinUni.cpp [new file with mode: 0755]
plugin/mms_plugin/LanguagePack/MmsPluginWmLngString.cpp [new file with mode: 0755]
plugin/mms_plugin/LanguagePack/MmsPluginWmLngUTF8Uni.cpp [new file with mode: 0755]
plugin/mms_plugin/LanguagePack/MmsPluginWmLngUniUTF8.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginAvCodec.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginCodec.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginConnManWrapper.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginContentCodec.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginDebug.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginDecode.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginDrm.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginEncode.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginEventHandler.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginHttp.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginInternal.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginMIME.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginMain.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginMessage.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginSMILValidate.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginSmil.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginStorage.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginTransport.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginUserAgent.cpp [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginAvCodec.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginCodec.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginConnManWrapper.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginData.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginDebug.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginDrm.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginEventHandler.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginHttp.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginInternal.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginMIME.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginMain.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginMessage.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginSMILValidate.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginSetup.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginSmil.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginStorage.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginTransport.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginTypes.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginUserAgent.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginWmLngPack.h [new file with mode: 0755]
plugin/sms_plugin/CMakeLists.txt [new file with mode: 0755]
plugin/sms_plugin/SmsPluginCallback.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginCbMsgHandler.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginConcatHandler.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginEventHandler.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginMain.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginParamCodec.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginSatHandler.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginSetting.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginSimMsg.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginStorage.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginTextConvert.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginTpduCodec.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginTransport.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginUAManager.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginUDCodec.cpp [new file with mode: 0755]
plugin/sms_plugin/SmsPluginWapPushHandler.cpp [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginCallback.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginCbMsgHandler.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginConcatHandler.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginEventHandler.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginMain.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginParamCodec.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginSatHandler.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginSetting.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginSimMsg.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginStorage.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginTextConvert.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginTpduCodec.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginTransport.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginTypes.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginUAManager.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginUDCodec.h [new file with mode: 0755]
plugin/sms_plugin/include/SmsPluginWapPushHandler.h [new file with mode: 0755]
proxy/CMakeLists.txt [new file with mode: 0755]
proxy/MsgHandleControl.cpp [new file with mode: 0755]
proxy/MsgHandleSetting.cpp [new file with mode: 0755]
proxy/MsgHandleStorage.cpp [new file with mode: 0755]
proxy/MsgHandleTransport.cpp [new file with mode: 0755]
proxy/MsgProxyListener.cpp [new file with mode: 0755]
test_app/CMakeLists.txt [new file with mode: 0755]
test_app/MsgTestConvert.cpp [new file with mode: 0755]
test_app/MsgTestConvert.h [new file with mode: 0755]
test_app/MsgTestSetting.cpp [new file with mode: 0755]
test_app/MsgTestSetting.h [new file with mode: 0755]
test_app/MsgTestStorage.cpp [new file with mode: 0755]
test_app/MsgTestStorage.h [new file with mode: 0755]
test_app/MsgTestThreadView.cpp [new file with mode: 0755]
test_app/MsgTestThreadView.h [new file with mode: 0755]
test_app/MsgTestTransport.cpp [new file with mode: 0755]
test_app/MsgTestTransport.h [new file with mode: 0755]
test_app/main.cpp [new file with mode: 0755]
test_app/main.h [new file with mode: 0755]
test_app/mms_files/A.smi [new file with mode: 0755]
test_app/mms_files/P091120_104633.jpg [new file with mode: 0755]
test_app/mms_files/Temp0_2.txt [new file with mode: 0755]
test_app/mms_files/Temp1_0.txt [new file with mode: 0755]
test_app/mms_files/V091120_104905.3gp [new file with mode: 0755]
test_app/mms_files/audio.amr [new file with mode: 0755]
utils/CMakeLists.txt [new file with mode: 0755]
utils/MsgContact.cpp [new file with mode: 0755]
utils/MsgDebug.cpp [new file with mode: 0755]
utils/MsgDrmWrapper.cpp [new file with mode: 0755]
utils/MsgException.cpp [new file with mode: 0755]
utils/MsgGconfWrapper.cpp [new file with mode: 0755]
utils/MsgIpcSocket.cpp [new file with mode: 0755]
utils/MsgMemory.cpp [new file with mode: 0755]
utils/MsgMmsMessage.cpp [new file with mode: 0755]
utils/MsgMutex.cpp [new file with mode: 0755]
utils/MsgNotificationWrapper.cpp [new file with mode: 0755]
utils/MsgSoundPlayer.cpp [new file with mode: 0755]
utils/MsgSqliteWrapper.cpp [new file with mode: 0755]
utils/MsgUtilFile.cpp [new file with mode: 0755]
utils/MsgUtilFunction.cpp [new file with mode: 0755]
utils/MsgUtilStorage.cpp [new file with mode: 0755]
version.sh [new file with mode: 0755]

diff --git a/AUTHORS b/AUTHORS
new file mode 100755 (executable)
index 0000000..6ce40ef
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,6 @@
+Jaeyun Jeong <jyjeong@samsung.com>\r
+Sangkoo Kim <sangkoo.kim@samsung.com>\r
+Seunghwan Lee <sh.cat.lee@samsung.com>\r
+SoonMin Jung <sm0415.jung@samsung.com>\r
+Jae-Young Lee <jy4710.lee@samsung.com>\r
+KeeBum Kim <keebum.kim@samsung.com>
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..16400fd
--- /dev/null
@@ -0,0 +1,76 @@
+
+##########################################################
+# Set Variables
+##########################################################
+SET(UTILS-LIB msg_utils)
+SET(PLUGIN-MANAGER-LIB msg_plugin_manager)
+SET(FW-HANDLER-LIB msg_framework_handler)
+SET(TRANS-MANAGER-LIB msg_transaction_manager)
+SET(TRANS-PROXY-LIB msg_transaction_proxy)
+SET(MAPI-LIB msg_mapi)
+SET(SMS-PLUGIN-LIB msg_sms_plugin)
+SET(MMS-PLUGIN-LIB msg_mms_plugin)
+SET(MMS-LANGUAGE-PACK-LIB msg_mms_language_pack)
+
+##########################################################
+# Add Subdirectories
+##########################################################
+ADD_SUBDIRECTORY(utils)
+ADD_SUBDIRECTORY(framework)
+ADD_SUBDIRECTORY(proxy)
+ADD_SUBDIRECTORY(mapi)
+ADD_SUBDIRECTORY(test_app)
+ADD_SUBDIRECTORY(plugin/sms_plugin)
+ADD_SUBDIRECTORY(plugin/mms_plugin)
+ADD_SUBDIRECTORY(msg_helper)
+
+
+##########################################################
+# Install Header Files
+##########################################################
+SET(MAPI-HEADERS
+       ${CMAKE_CURRENT_SOURCE_DIR}/include/mapi/MapiControl.h
+       ${CMAKE_CURRENT_SOURCE_DIR}/include/mapi/MapiSetting.h
+       ${CMAKE_CURRENT_SOURCE_DIR}/include/mapi/MapiStorage.h
+       ${CMAKE_CURRENT_SOURCE_DIR}/include/mapi/MapiTransport.h
+       ${CMAKE_CURRENT_SOURCE_DIR}/include/mapi/MapiMessage.h
+       ${CMAKE_CURRENT_SOURCE_DIR}/include/common/MsgTypes.h
+       ${CMAKE_CURRENT_SOURCE_DIR}/include/common/MsgMmsTypes.h
+       ${CMAKE_CURRENT_SOURCE_DIR}/include/common/MsgSettingTypes.h
+       ${CMAKE_CURRENT_SOURCE_DIR}/include/common/MsgStorageTypes.h
+       ${CMAKE_CURRENT_SOURCE_DIR}/include/common/MsgTransportTypes.h
+       ${CMAKE_CURRENT_SOURCE_DIR}/SLP_MessagingFW_PG.h )
+INSTALL(FILES ${MAPI-HEADERS} DESTINATION include/msg-service)
+
+
+##########################################################
+# Install etc Files
+##########################################################
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config/plugin.cfg DESTINATION /usr/share/msg-service)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config/alert_on_call.mp3 DESTINATION /opt/etc/msg-service)
+
+SET(MMS-FILES
+       ${CMAKE_CURRENT_SOURCE_DIR}/test_app/mms_files/A.smi
+       ${CMAKE_CURRENT_SOURCE_DIR}/test_app/mms_files/audio.amr
+       ${CMAKE_CURRENT_SOURCE_DIR}/test_app/mms_files/P091120_104633.jpg
+       ${CMAKE_CURRENT_SOURCE_DIR}/test_app/mms_files/Temp0_2.txt
+       ${CMAKE_CURRENT_SOURCE_DIR}/test_app/mms_files/Temp1_0.txt
+       ${CMAKE_CURRENT_SOURCE_DIR}/test_app/mms_files/V091120_104905.3gp
+)
+
+INSTALL(FILES ${MMS-FILES} DESTINATION /opt/etc/msg-service)
+
+SET(RINGTONE-FILES
+       ${CMAKE_CURRENT_SOURCE_DIR}/config/message_tone/Sherbet.wav
+)
+
+INSTALL(FILES ${RINGTONE-FILES} DESTINATION /usr/share/media/)
+
+CONFIGURE_FILE(msg-service.pc.in msg-service.pc @ONLY)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/msg-service.pc DESTINATION lib/pkgconfig)
+
+SET(RC_LOCAL_SCRIPT msg-server)
+INSTALL(PROGRAMS ${RC_LOCAL_SCRIPT} DESTINATION /etc/rc.d/init.d)
+
diff --git a/LICENSE b/LICENSE
new file mode 100755 (executable)
index 0000000..7ccb5b5
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,75 @@
+Flora License
+
+Version 1.0, May, 2012
+
+http://www.tizenopensource.org/license
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+"Tizen Certified Platform" shall mean a software platform that complies with the standards set forth in the Compatibility Definition Document and passes the Compatibility Test Suite as defined from time to time by the Tizen Technical Steering Group and certified by the Tizen Association or its designated agent.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work solely as incorporated into a Tizen Certified Platform, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work solely as incorporated into a Tizen Certified Platform to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof pursuant to the copyright license above, in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+  1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
+
+  2. You must cause any modified files to carry prominent notices stating that You changed the files; and
+
+  3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+
+  4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Flora License to your work
+
+To apply the Flora License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Flora License, Version 1.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.tizenopensource.org/license
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/SLP_MessagingFW_PG.h b/SLP_MessagingFW_PG.h
new file mode 100755 (executable)
index 0000000..fababac
--- /dev/null
@@ -0,0 +1,884 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+/**
+ *
+ * @ingroup   SLP_PG
+ * @defgroup   MESSAGE MessagingFW
+@{
+<h1 class="pg">Introduction</h1>
+       <h2 class="pg">Purpose</h2>
+The purpose of this document is to describe how applications can use the Messaging Framework APIs to send and receive SMS and MMS messages. This document gives programming guidelines to application engineers.
+
+       <h2 class="pg">Scope</h2>
+The scope of this document is limited to Messaging Framework APIs usage.
+
+       <h2 class="pg">Abbreviations</h2>
+<table>
+<tr><td>API</td><td>Application Programming Interface</td></tr>
+</table>
+@}
+
+@defgroup Message_Architecture 1.Archtecture
+@ingroup MESSAGE
+@{
+<h1>Messaging Framework Architecture</h1>
+The Messaging framework supports various messaging services such as SMS, MMS, Cell Broadcast, WAP Push, and Provisioning message. The Messaging framework architecture consists of a Messaging daemon and a library. The messaging library works on application process and provides various APIs to support transport, control, storage, filter and setting services for application. The messaging daemon has three components (transaction manager, transaction handler, and plug-in manager) to provide message services. The socket IPC is used to communicate (request & event) between Messaging daemon and library.
+@image html messaging_image001.png
+
+- Transaction Manager
+       - Receive the IPC message (request) on socket.
+       - Manage list of pairs (request ID, transaction proxy) for synchronous return.
+       - Determine the transaction flow based on request/event information. (Mapping the request to one of the handlers)
+       - Store the transaction information for asynchronous events (Find which transaction proxy want to receive SMS)
+- Transaction Handler
+       - Submit handler deals with submit requests.
+       - Deliver handler deals with the incoming message from plug-ins.
+       - Storage handler deals with the messages, accounts and folder requests
+       - Filter handler deals with the filter requests
+       - Setting handler deals with the service-specific attributes
+- Plug-in Manager
+       - Initialize all plug-ins after loading plug-in configuration files
+       - Holding the list of plug-ins and the state of plug-ins
+       - Providing the interface between handlers and plug-ins
+- Transaction Handlers
+       - Initialize all plug-ins after loading plug-in configuration files
+       - Receiving IPC messages from messaging daemon.
+       - Handling synchronous calls
+               - Condition variable is used for waiting the return from msg. server)
+       - Handling asynchronous calls or events
+               - Proxy listener is a component of transaction proxy
+               - Proxy listener is waiting for the event
+               - Invoking callback function in the msg. handle list
+               - i.e. calling incoming callback function of MSG APP handle, when incoming msg
+       - Holding list of message handles
+               - Message handle is created by MsgOpenMsgHandle(msgHandle)
+               - Message handle holds some info such as callback func
+- Message API
+       - Transport & control API
+       - Storage API
+       - Filter API
+       - Setting API
+@}
+
+@defgroup Message_Feature 2.Feature
+@ingroup MESSAGE
+@{
+       <h2 class="pg">Messaging Framework Features</h2>
+-# Message Control Features:
+       -# Open/Close message handle
+-# Message Transport Features:
+       -# Submit request to send, forward, reply, retrieve message.
+       -# Register callback functions to listen to invoked events from messaging daemon. (message status callback, incoming message callback)
+-# Message Storage Features:
+       -# Add / Update / Move / Delete / Count / Get message or message list.
+       -# Add / Update / Delete / Get folder or folder list.
+-# Message Filter Features:
+       -# Add / Update / Delete filter or filter list.
+-# Message Setting Features:
+       -# Set / Get various message setting (i.e. whether to send read/delivery report or not)
+@}
+
+@defgroup MESSAGE_USECASES_1 Initialize/Finalization
+@ingroup MESSAGE_USECASES
+@{
+       <h2 class="pg">Messaging Framework Functions</h2>
+
+               <h3 class="pg">Initialization / Finalization to use Messaging Service </h3>
+- int msg_open_msg_handle(MSG_HANDLE_T *handle);
+@n msg_open_msg_handle() should be called before using the messaging service. This function opens a channel between the application and the messaging framework.
+- int msg_close_msg_handle(MSG_HANDLE_T *handle);
+@n msg_close_msg_handle() should be called after using the messaging service. This function closes a channel between the application and the messaging framework.
+- int msg_reg_sent_status_callback(MSG_HANDLE_T handle, msg_sent_status_cb cb);
+@n Application should implement a msg_sent_status_cb function and register it into message handle. If the application sends a message, this callback function will be called to report its sending status. msg_reg_set_status_callback function should be called after creation of message handle.
+- int msg_reg_sms_message_callback(MSG_HANDLE_T handle, msg_sms_incoming_cb cb, unsigned short port);
+@n Application should implement a msg_sms_incoming_cb function and register it into message handle. It’s used to listen to the SMS incoming event invoked by messaging daemon. The incoming message information structure (MSG_MESSAGE_S) can be delivered as a parameter of the callback function.
+- int msg_reg_mms_conf_message_callback(MSG_HANDLE_T handle, msg_mms_conf_msg_incoming_cb cb, char *app_id);
+@n Application should implement a msg_mms_conf_msg_incoming_cb function and register it into message handle. It’s used to listen to the MMS incoming event invoked by messaging daemon. The incoming message information structure (MSG_MESSAGE_S) can be delivered as a parameter of the callback function.
+@code
+#include <stdio.h>
+#include <glib.h>
+#include <MapiControl.h>
+#include <MapiTransport.h>
+
+void sentStatusCB(MSG_HANDLE_T hMsgHandle, MSG_SENT_STATUS_S *pMsgStatus, void *user_param)
+{
+       // Application can handle message sent status event
+}
+
+void incomingSmsMessageCB (MSG_HANDLE_T hMsgHandle, msg_message_t msg, void *user_param)
+{
+       // Application can handle SMS incoming message.
+}
+
+void incomingMmsConfMessageCB(MSG_HANDLE_T hMsgHandle, msg_message_t msg, void *user_param)
+{
+       // Application can handle MMS incoming message.
+}
+
+int main(void)
+{
+       MSG_HANDLE_T msgHandle = NULL;
+
+       err = msg_open_msg_handle(&msgHandle);
+
+       if (err != MSG_SUCCESS)
+       {
+               printf("msg_open_msg_handle() Fail [%d]", err);
+               return err;
+       }
+
+       // Register sent status handler
+       err = msg_reg_sent_status_callback(msgHandle, &sentStatusCB, NULL);
+
+       if (err != MSG_SUCCESS)
+       {
+               printf("msg_reg_sent_status_callback() Fail [%d]", err);
+               return err;
+       }
+
+       // Register SMS incoming message handler
+       err = msg_reg_sms_message_callback(msgHandle, &incomingSmsMessageCB, 0, NULL);
+
+       if (err != MSG_SUCCESS)
+       {
+               printf("msg_reg_sms_message_callback() Fail [%d]", err);
+               return err;
+       }
+
+       // Register MMS incoming message handler
+       err = msg_reg_mms_conf_message_callback(msgHandle, &incomingMmsConfMessageCB, NULL, NULL);
+
+       if (err != MSG_SUCCESS)
+       {
+               printf("msg_reg_mms_conf_message_callback() Fail [%d]", err);
+               return err;
+       }
+
+       // g_main_loop should be used to listen CB event from messaging daemon
+       mainloop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(mainloop);
+
+       msg_close_msg_handle(&msgHandle);
+
+       return err;
+}
+@endcode
+@}
+
+@defgroup MESSAGE_USECASES_2 Adding a SMS Message
+@ingroup MESSAGE_USECASES
+@{
+               <h3 class="pg">Adding a SMS Message</h3>
+- msg_message_t msg_new_message();
+@n msg_new_message() is a function to create a message object which can store the message information. You should call this function to set the message that you want to add or send.
+- int msg_set_message_type(msg_message_t msg, MSG_MESSAGE_TYPE_T msg_type);
+@n msg_set_message_type() is a function to set the message type such as SMS or MMS. The first parameter is the message object which is created by msg_new_message(). The second parameter is the message type you want to set. It should be one of enum type ( _MSG_MESSAGE_TYPE_E). If setting is successful, the function returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E).
+- int msg_sms_set_message_body(msg_message_t msg, const char* mdata, int size);
+@n msg_sms_set_message_body() is a function to set the SMS body data. The first parameter is the message object which is created by msg_new_message(). The second parameter is the SMS body data you want to set. The third parameter is the length of SMS body data. If setting is successful, the function returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E).
+- int msg_add_address(msg_message_t msg, const char* phone_num_list, MSG_RECIPIENT_TYPE_T to_type);
+@n msg_add_address() is a function to add the phone numbers for the message. The first parameter is the message object which is created by msg_new_message(). The second parameter is the list of phone number you want to set. You can add several phone numbers at once. The phone numbers should be separated by ','. The third parameter is the recipient type of phone number. It should be one of enum type (_MSG_RECIPIENT_TYPE_E). If setting is successful, the function returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E).
+- int msg_add_message(MSG_HANDLE_T handle, const msg_message_t msg, const MSG_SENDINGOPT_S *send_opt);
+@n msg_add_message() is a function to add a composed message into the database of messaging framework. Before calling this function, the application should set the message object and the sending option structure and then pass them as parameters. If you don't want to change the current sending option, set the variable 'bSetting' to false. If saving a message is successful, the function returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E).
+- int msg_release_message(msg_message_t *msg);
+@n msg_release_message() is a function to free the memory of a message object which is create by msg_new_message(). If freeing the memory is successful, the function returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E).
+@code
+#include <string.h>
+#include <MapiStorage.h>
+#include <MapiMessage.h>
+
+void test_add_sms_message(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_SENDINGOPT_S sendOpt = {0, };
+       sendOpt.bSetting = false;
+
+       msg_message_t msgInfo = msg_new_message();
+
+       // Set Message Type
+       err = msg_set_message_type(msgInfo, MSG_TYPE_SMS);
+
+       if (err != MSG_SUCCESS) goto free_memory;
+
+       char msgText[1024];
+
+       memset(msgText, 0x00, 1024);
+       strncpy(msgText, "Test SMS Message", sizeof(msgText)-1);
+       int dataSize = strlen(msgText);
+
+       // Set SMS text
+       err = msg_sms_set_message_body(msgInfo, msgText, dataSize);
+
+       if (err != MSG_SUCCESS) goto free_memory;
+
+       char number[MAX_ADDRESS_VAL_LEN];
+
+       memset(number, 0x00, MAX_ADDRESS_VAL_LEN);
+       strncpy(number, "+821030011234", sizeof(number)-1);
+
+       // Set Recipient Address
+       err = msg_add_address(msgInfo, number, MSG_RECIPIENTS_TYPE_TO);
+
+       if (err != MSG_SUCCESS) goto free_memory;
+
+       err = msg_add_message(hMsgHandle, msgInfo, &sendOpt);
+
+       if (err == MSG_SUCCESS)
+               printf("Saving Message is OK!");
+       else
+               printf("Saving Message is failed!");
+
+free_memory:
+       msg_release_message(&msgInfo);
+}
+@endcode
+@}
+
+@defgroup MESSAGE_USECASES_3 Adding a MMS Message
+@ingroup MESSAGE_USECASES
+@{
+               <h3 class="pg">Adding a MMS Message</h3>
+- int msg_set_subject(msg_message_t msg, const char* subject);
+@n msg_set_subject() is a function to set the subject of MMS. The first parameter is the message object which is created by msg_new_message(). The second parameter is the subject you want to set. If setting is successful, the function returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E).
+
+- MMS_MESSAGE_DATA_S* msg_mms_create_message(void);
+@n msg_mms_create_message() allocates a MMS_MESSAGE_DATA_S structure and returns it’s address. MMS_MESSAGE_DATA_S is needed to represent mms specific data and transfer it to the messaging daemon in the pData parameter of the MSG_MESSAGE_S structure.
+
+- MMS_SMIL_ROOTLAYOUT* msg_mms_set_rootlayout(MMS_MESSAGE_DATA_S* msg, const int width, const int height, const int bgcolor);
+@n msg_mms_set_rootlayout() is a function to set smil root layout. The parameters representing the size and background color of smil root layout should be set.
+
+- MMS_SMIL_REGION* msg_mms_add_region(MMS_MESSAGE_DATA_S *msg_data, const char* szID, const int x, const int y, const int width, const int height, const int bgcolor);
+@n msg_mms_add_region() is a function to add a smil region. Smil region is needed to display text message, image, and video data (Each content has its own region). This function is called to allocate a region for each contents.
+
+- MMS_PAGE_S* msg_mms_add_page(MMS_MESSAGE_DATA_S *msg_data, const int duration);
+@n msg_mms_add_page() is a function to add a smil page.
+
+- MMS_MEDIA_S* msg_mms_add_media(MMS_PAGE_S *page, const MmsSmilMediaType mediatype, const char* regionid, char* filepath);
+@n msg_mms_add_media() is a function to add multimedia content to a mms message. If some content should be played with smil player, this function can be used.
+
+- MMS_ATTACH_S* msg_mms_add_attachment(MMS_MESSAGE_DATA_S *msg_data, char *filepath);
+@n msg_mms_add_attachment() is a function to add a content as an attached file. With this function a content might be attached as a multipart mixed type.
+
+- int msg_mms_set_message_body(msg_message_t msg, const MMS_MESSAGE_DATA_S *msg_data);
+@n msg_mms_set_message_body() is a function to set the MMS body data. The first parameter is the message object which is created by msg_new_message(). The second parameter is the structure which is allocated by msg_mms_create_message() and is set by the APIs for MMS.
+
+- int msg_mms_destroy_message(MMS_MESSAGE_DATA_S* msg);
+@n msg_mms_destroy_message() should be called to deallocate the MMS_MESSAGE_DATA_S structure and internal region, page, media, and attach list.
+@code
+#include <string.h>
+#include <MapiStorage.h>
+#include <MapiMessage.h>
+
+void test_add_mms_message(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_SENDINGOPT_S sendOpt = {0, };
+       sendOpt.bSetting = false;
+
+       msg_message_t msgInfo = msg_new_message();
+
+       // Set Message Type
+       err = msg_set_message_type(msgInfo, MSG_TYPE_MMS);
+
+       if (err != MSG_SUCCESS) goto free_memory;
+
+       MMS_MESSAGE_DATA_S* data;
+       MMS_PAGE_S* page;
+       MMS_MEDIA_S* media[3];
+       MMS_ATTACH_S* attach;
+       int nSize = 0;
+
+       // Set MMS subject
+       char subject[MAX_SUBJECT_LEN];
+
+       memset(subject, 0x00, MAX_SUBJECT_LEN);
+       strncpy(subject, "hello mms", sizeof(subject)-1);
+
+       err = msg_set_subject(msgInfo, subject);
+
+       if (err != MSG_SUCCESS) goto free_memory;
+
+       // Set MMS Body data
+       data = msg_mms_create_message();
+       msg_mms_set_rootlayout(data, 100, 100, 0xffffff);
+       msg_mms_add_region(data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(data, "Text", 0, 0, 100, 50, 0xffffff);
+       page = msg_mms_add_page(data, 5000);
+       media[0] = msg_mms_add_media(page, MMS_SMIL_MEDIA_IMG, "Image", "/tmp/image.jpg");
+       media[1] = msg_mms_add_media(page, MMS_SMIL_MEDIA_AUDIO, NULL, "/tmp/audio.amr");
+       media[2] = msg_mms_add_media(page, MMS_SMIL_MEDIA_TEXT, "Text", "/tmp/message.txt");
+       attach = msg_mms_add_attachment(data, "attachment.3gp");
+
+       err = msg_mms_set_message_body(msgInfo, data);
+
+       if (err != MSG_SUCCESS)
+       {
+               msg_mms_destroy_message(data);
+               goto free_memory;
+       }
+
+       msg_mms_destroy_message(data);
+
+       // Set Recipient Address
+       char number[MAX_ADDRESS_VAL_LEN];
+
+       memset(number, 0x00, MAX_ADDRESS_VAL_LEN);
+       strncpy(number, "+821030011234", sizeof(number)-1);
+
+       err = msg_add_address(msgInfo, number, MSG_RECIPIENTS_TYPE_TO);
+
+       if (err != MSG_SUCCESS) goto free_memory;
+
+       err = msg_add_message(hMsgHandle, msgInfo, &sendOpt);
+
+       if (err == MSG_SUCCESS)
+               printf("Saving Message is OK!");
+       else
+               printf("Saving Message is failed!");
+
+free_memory:
+       msg_release_message(&msgInfo);
+}
+@endcode
+@}
+
+@defgroup MESSAGE_USECASES_4 Sending a SMS/MMS Message
+@ingroup MESSAGE_USECASES
+@{
+               <h3 class="pg">Sending a SMS/MMS Message</h3>
+
+- bool msg_is_sms(msg_message_t msg);
+@n msg_is_sms() is a function to check whether the message type of message object is SMS or not. The first parameter is the message object which is created by msg_new_message(). The function returns true if the message object is a SMS message. Otherwise, it returns false.
+
+- bool msg_is_mms(msg_message_t msg);
+@n msg_is_mms() is a function to check whether the message type of message object is MMS or not. The first parameter is the message object which is created by msg_new_message(). The function returns true if the message object is a MMS message. Otherwise, it returns false.
+
+- int msg_sms_send_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req);
+@n msg_sms_send_message() is a function to send SMS through messaging framework. The first parameter is the handle which is created by msg_open_msg_handle (). The second parameter is the structure that includes the message information to send. You can get the result of sending on sent status callback.
+
+- int msg_mms_send_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req);
+@n msg_sms_send_message() is a function to send SMS through messaging framework. The first parameter is the handle which is created by msg_open_msg_handle (). The second parameter is the structure that includes the message information to send. You can get the result of sending on sent status callback.
+@code
+#include <MapiTransport.h>
+#include <MapiMessage.h>
+
+int MsgTestSendMsg(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg)
+{
+       if (hMsgHandle == NULL)
+       {
+               printf("Handle is NULL\n");
+               return MSG_ERR_NULL_MSGHANDLE;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_REQUEST_S req = {0};
+
+       if (pMsg == NULL)
+       {
+               printf("Message is NULL\n");
+               return MSG_ERR_NULL_MESSAGE;
+       }
+
+       req.msg = pMsg;
+
+       if (msg_is_sms(req.msg))
+               err = msg_sms_send_message(hMsgHandle, &req);
+       else if (msg_is_mms(req.msg))
+               err = msg_mms_send_message(hMsgHandle, &req);
+
+       if (err == MSG_SUCCESS)
+               printf("Request to Send Message is successful!!!");
+       else
+               printf("Request to Send Message is failed!!!");
+
+       return err;
+}
+@endcode
+@}
+
+@defgroup MESSAGE_USECASES_5 Sending Simple SMS Message
+@ingroup MESSAGE_USECASES
+@{
+               <h3 class="pg">Simple SMS Sending</h3>
+- int msg_sms_send(const char *phone_num_list, const char *sms_text, msg_simple_sent_status_cb cb, void *user_param);
+@n msg_sms_send() is a simple function to send an SMS message. Without this API, in order to send a message the application should allocate a channel with messaging daemon for IPC, register sent-status callback function to monitor the sending result, and fulfill many member variables of MSG_MESSAGE_S. This function implicitly makes a connection with messaging daemon and registers the callback function. In addition, member variables of the MSG_MESSAGE_S structure are filled with default values except for the recipient phone_number and sms_text.
+@code
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <MapiTransport.h>
+
+GMainLoop *mainloop;
+
+typedef struct {
+       char number[256];
+       char text[256];
+       char userdata[256];
+} send_data;
+
+void sent_status_cb(MSG_SENT_STATUS_S *pMsgStatus, void *userData)
+{
+       if (pMsgStatus->status == MSG_NETWORK_SEND_SUCCESS)
+               printf("reqId : %d  MSG SENT SUCCESS !!!\n", pMsgStatus->reqId);
+       else
+               printf("reqId : %d  MSG SENT FAIL !!! [%d]\n", pMsgStatus->reqId, pMsgStatus->status);
+}
+
+// count from here
+gboolean send_func(gpointer data)
+{
+       send_data* sms_input = (send_data*)data;
+
+       printf("Begin to send [%s] to [%s]\n", sms_input->number, sms_input->text);
+       MSG_ERROR_T err = msg_sms_send(sms_input->number, sms_input->text, &sent_status_cb, (void*)sms_input->userdata);
+
+       if (err != MSG_SUCCESS)
+               printf("Send failed [%d]\n", err);
+
+       return FALSE;
+}
+// end
+
+int main(int argc, char* argv[])
+{
+       if (argc != 3 && argc != 4)
+       {
+               printf("Usage: %s  {phone_num_list} {sms_text} [user_data]\n", argv[0]);
+               printf("phone_num_list: phone_num1, phone_num2, ..., phone_numN\n");
+               return 0;
+       }
+
+       // Set sms input parameters : phone numbers and text
+       send_data sms_input = {};
+       strncpy(sms_input.number, argv[1], sizeof(sms_input.number)-1);
+       strncpy(sms_input.text, argv[2], sizeof(sms_input.text)-1);
+       if (argc == 4)
+               strncpy(sms_input.userdata, argv[3], sizeof(sms_input.userdata)-1);
+
+       // Add Sending Function to GMainLoop
+       g_idle_add(&send_func, (gpointer) &sms_input);
+
+       // start GMainLoop
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       printf("Entering GMain Loop to Receive Notifications in Thread...\n");
+
+       g_main_loop_run(mainloop);
+
+       printf("==== End Test App. Bye...===\n");
+
+       return 0;
+}
+@endcode
+@}
+
+@defgroup MESSAGE_USECASES_6 Retrieving a MMS Message
+@ingroup MESSAGE_USECASES
+@{
+               <h3 class="pg">Retrieving a MMS Message</h3>
+- int msg_mms_retrieve_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req);
+@n msg_mms_retrieve_message() is a function to submit a retrieve MMS request.
+@code
+void MsgTestRetrieveMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
+{
+       if (hMsgHandle == NULL)
+       {
+               printf("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       msg_message_t msg = msg_new_message();
+       MSG_SENDINGOPT_S sendOpt = {0, };
+
+       err = msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)nMsgId, msg, &sendOpt);
+
+       if (err != MSG_SUCCESS)
+               printf("Get Message Failed!");
+
+       MSG_REQUEST_S req = {0, msg, sendOpt};
+
+       err = msg_mms_retrieve_message(hMsgHandle, &req);
+
+       if (err != MSG_SUCCESS)
+               printf("Retrieve MMS Message Failed!");
+
+       msg_release_message(&msg);
+}
+@endcode
+@}
+
+@defgroup MESSAGE_USECASES_7 Getting a SMS Message
+@ingroup MESSAGE_USECASES
+@{
+               <h3 class="pg">Getting a SMS Message</h3>
+- int msg_get_message(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, msg_message_t msg, MSG_SENDINGOPT_S *send_opt);
+@n msg_get_message() is a function to get a message. The first parameter is the handle which is created by msg_open_msg_handle (). The second parameter is the message ID you want to get. The third parameter is the message object to receive the message information. The last parameter is the structure to receive the message sending options.
+
+- int msg_get_message_id(msg_message_t msg);
+@n msg_get_message_id() is a function to get the message ID. The parameter is the message object. If the function is successful, it returns the message ID. Otherwise it returns an error in enum type (_MSG_ERROR_E).
+
+- int msg_get_folder_id(msg_message_t msg);
+@n msg_get_folder_id() is a function to get the ID of the folder  that the message is saved within. The parameter is the message object. If the function is successful, it returns one of the enum type in (_MSG_FOLDER_ID_E) . Otherwise it returns an error in enum type (_MSG_ERROR_E).
+
+- int msg_get_message_type(msg_message_t msg);
+@n msg_get_message_type() is a function to get the message type. The parameter is the message object. If the function is successful, it returns one of the enum type in (_MSG_MESSAGE_TYPE_E). Otherwise it returns an error in enum type (_MSG_ERROR_E).
+
+- int msg_get_address_count(msg_message_t msg);
+@n msg_get_address_count() is a function to get the number of addresses. The parameter is the message object. If the function is successful, it returns the number of addresses. Otherwise it returns an error in enum type (_MSG_ERROR_E).
+
+- const char* msg_get_ith_address(msg_message_t msg, int ith);
+@n msg_get_ith_address() is a function to get the ith address of message. The first parameter is the message object. The second parameter is the index of address you want to get. If the function is successful, it returns the address string. Otherwise it returns NULL.
+
+- time_t* msg_get_time(msg_message_t msg);
+@n msg_get_time() is a function to get the time value of message. The parameter is the message object. If the function is successful, it returns the time value. Otherwise it returns NULL.
+
+- int msg_get_network_status(msg_message_t msg);
+@n msg_get_network_status() is a function to get the network status of message. The parameter is the message object. If the function is successful, it returns one of the enum type in (_MSG_NETWORK_STATUS_E). Otherwise it returns an error in enum type (_MSG_ERROR_E).
+
+- bool msg_is_read(msg_message_t msg);
+@n msg_is_read() is a function to check whether the message was read or not. The parameter is the message object. If the message was read, it returns true. Otherwise it returns false.
+
+- bool msg_is_protected(msg_message_t msg);
+@n msg_is_protected() is a function to check whether the message is protected or not. The parameter is the message object. If the the message was protected, it returns true. Otherwise it returns false.
+
+- int msg_get_message_body_size(msg_message_t msg);
+@n msg_get_message_body_size() is a function to get the byte size of message. The parameter is the message object. If the function is successful, it returns the byte size of message. Otherwise it returns an error in enum type (_MSG_ERROR_E).
+
+- const char* msg_sms_get_message_body(msg_message_t msg);
+@n msg_sms_get_message_body() is a function to get the body data of message. The first parameter is the message object. If the function is successful, it returns the body data. Otherwise it returns NULL.
+@code
+void MsgTestGetSmsMessage(MSG_HANDLE_T hMsgHandle, int MsgId)
+{
+       if (hMsgHandle == NULL)
+       {
+               printf("Handle is NULL\n");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       msg_message_t msg = msg_new_message();
+       MSG_SENDINGOPT_S sendOpt = {0, };
+
+       // Get Message
+       err = msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)MsgId, msg, &sendOpt);
+
+       if (err != MSG_SUCCESS) goto free_memory;
+
+       printf("msgId = %d\n", msg_get_message_id(msg));
+       printf("folderId = %d\n", msg_get_folder_id(msg));
+       printf("msgType = %d\n", msg_get_message_type(msg));
+       printf("phone number = %s\n", msg_get_ith_address(msg, 0));
+       printf("displayTime = %s\n", ctime(msg_get_time(msg)));
+       printf("networkStatus = %d\n", msg_get_network_status(msg));
+       printf("bRead = %d\n", msg_is_read(msg));
+       printf("bProtected = %d\n", msg_is_protected(msg));
+       printf("dataSize = %d\n", msg_get_message_body_size(msg));
+       printf("msgData = %s\n", msg_sms_get_message_body(msg));
+
+free_memory:
+       msg_release_message(&msg);
+}
+@endcode
+@}
+
+@defgroup MESSAGE_USECASES_8 Getting a MMS Message
+@ingroup MESSAGE_USECASES
+@{
+               <h3 class="pg">Getting a MMS Message</h3>
+- int msg_mms_get_message_body(msg_message_t msg, MMS_MESSAGE_DATA_S *body);
+@n msg_get_address_count. The parameter is the message object. The second parameter is the structure to receive MMS data as output. If the function is successful, it returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E).
+- MMS_SMIL_REGION* msg_mms_get_smil_region(MMS_MESSAGE_DATA_S msgBody, int region_idx);
+@n msg_mms_get_smil_region() is a function to get a SMIL region information. The first parameter is the structure of MMS data. The second parameter is the index of SMIL region you want to get. If the function is successful, it returns the structure which contains the SMIL region information. Otherwise it returns NULL.
+- MMS_PAGE_S* msg_mms_get_page(MMS_MESSAGE_DATA_S msgBody, int page_idx);
+@n msg_mms_get_page() is a function to get a SMIL page information. The first parameter is the structure of MMS data. The second parameter is the index of SMIL page you want to get. If the function is successful, it returns the structure which contains the SMIL page information. Otherwise it returns NULL.
+- MMS_MEDIA_S* msg_mms_get_media(MMS_PAGE_S *page, int media_idx);
+@n msg_mms_get_media() is a function to get a media information in a SMIL page. The first parameter is the structure of SMIL page you want to get the media from. The second parameter is the index of media you want to get. If the function is successful, it returns the structure which contains the media information. Otherwise it returns NULL.
+- MMS_ATTACH_S* msg_mms_get_attachment(MMS_MESSAGE_DATA_S msgBody, int attach_idx);
+@n msg_mms_get_attachment() is a function to get the file information of  an attachment. The first parameter is the structure of MMS data. The second parameter is the index of attachment you want to get. If the function is successful, it returns the structure which contains the attachment file information. Otherwise it returns NULL.
+- const char* msg_get_subject(msg_message_t msg);
+@n msg_get_subject() is a function to get the subject of MMS. The parameter is the message object. If the function is successful, it returns the subject string. Otherwise it returns NULL.
+@code
+void MsgTestGetMmsMessage(MSG_HANDLE_T hMsgHandle, int MsgId)
+{
+       if (hMsgHandle == NULL)
+       {
+               printf("Handle is NULL\n");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       msg_message_t msg = msg_new_message();
+       MSG_SENDINGOPT_S sendOpt = {0, };
+
+       // Get Message
+       err = msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)MsgId, msg, &sendOpt);
+
+       if (err != MSG_SUCCESS) goto free_memory;
+
+       if (msg_is_mms(msg) == false)
+       {
+               printf("It is not MMS Message!");
+               goto free_memory;
+       }
+
+       MMS_MESSAGE_DATA_S* msgBody = msg_mms_create_message();
+
+       // Get MMS Body Data
+       msg_mms_get_message_body(msg, msgBody);
+
+       //Print root-layout info
+       printf("width: %d \n
+               height: %d \n
+               nbgColor:%x \n",
+               msgBody->rootlayout.width.value,
+               msgBody->rootlayout.height.value,
+               msgBody->rootlayout.bgColor);
+
+       // Print Region Info
+       for (int i = 0; i < msgBody->regionCnt; ++i)
+       {
+               MMS_SMIL_REGION* pRegion = msg_mms_get_smil_region(msgBody, i);
+
+               printf("region id: %s\n
+                       region left : %d\n
+                       region top : %d\n
+                       region width : %d\n
+                       region height : %d\n
+                       region bgColor : %x\n
+                       region fit : %d\n",
+                       pRegion->szID,pRegion->nLeft.value,
+                       pRegion->nTop.value,pRegion->width.value,
+                       pRegion->height.value, pRegion->bgColor,
+                       pRegion->fit);
+       }
+
+       // Print Page info
+       for (int i = 0; i< msgBody->pageCnt; ++i)
+       {
+               MMS_PAGE_S* pPage = msg_mms_get_page(msgBody, i);
+
+               printf("page's duration: %d msec\n
+                       page's media count: %d\n",
+                       pPage->nDur, pPage->mediaCnt);
+
+               // Print Contents Info
+               for(int j = 0; j < pPage->mediaCnt; ++j)
+               {
+                       MMS_MEDIA_S* pMedia = msg_mms_get_media(pPage, j);
+                       printf("media's filename: %s\n
+                               media's filepath: %s\n
+                               media's regionId: %s\n
+                               Bold: %d Italic: %d\n",
+                               pMedia->szFileName,
+                               pMedia->szFilePath,
+                               pMedia->regionId,
+                               pMedia->sMedia.sText.bBold,
+                               pMedia->sMedia.sText.bItalic);
+
+                       if(pMedia->drmType != MSG_DRM_TYPE_NONE)
+                       {
+                               printf("media's drmtype: %d\n
+                                       media's drmpath: %s\n",
+                                       pMedia->drmType, pMedia->szDrm2FullPath);
+                       }
+               }
+       }
+
+       for (int i = 0; i < msgBody->attachCnt; ++i)
+       {
+               MMS_ATTACH_S* pAttach = msg_mms_get_attachment(msgBody, i);
+
+               printf("Attachment file Name: %s\n
+                       Attachment file Path: %s\n
+                       Attached file size: %d\n",
+                       pAttach->szFileName,
+                       pAttach->szFilePath,
+                       pAttach->fileSize);
+
+               if(pAttach->drmType != MSG_DRM_TYPE_NONE)
+                       printf("media's drmtype: %d\n
+                               media's drmpath: %s\n",
+                               pAttach->drmType, pAttach->szDrm2FullPath);
+       }
+
+       printf("Subject: %s\n", msg_get_subject(pMsg));
+
+       printf("msgId = %d", msg_get_message_id(msg));
+       printf("folderId = %d", msg_get_folder_id(msg));
+       printf("phone number = %s", msg_get_ith_address(msg, 0));
+       printf("displayTime = %s", ctime(msg_get_time(msg)));
+       printf("networkStatus = %d", msg_get_network_status(msg));
+       printf("bRead = %d", msg_is_read(msg));
+       printf("bProtected = %d", msg_is_protected(msg));
+
+free_memory:
+       msg_mms_destroy_message(msgBody);
+
+       msg_release_message(&msg);
+}
+@endcode
+@}
+
+@defgroup MESSAGE_USECASES_9 Delete a Message
+@ingroup MESSAGE_USECASES
+@{
+               <h3 class="pg">Delete a Message</h3>
+- int msg_delete_message(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id);
+@n msg_delete_message() is a function to delete a message from message box by msg_id.
+@code
+void MsgTestDeleteMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
+{
+       MSG_ERROR_T err;
+
+       if (msg_delete_message(hMsgHandle, nMsgId) != MSG_SUCCESS)
+               printf("Failed to delete Message");
+
+}
+@endcode
+@}
+
+@defgroup MESSAGE_USECASES_10 Set/Get Message Setting
+@ingroup MESSAGE_USECASES
+@{
+               <h3 class="pg">Set / Get Message setting</h3>
+msg_set_config() and msg_get_cofig() is used to set or to get the message setting options. MSG_SETTING_S structure includes various setting information and is shared between message application and messaging daemon.
+
+- int msg_set_config(MSG_HANDLE_T handle, const MSG_SETTING_S *setting);
+@n msg_set_config() sets a message option.
+- int msg_get_config(MSG_HANDLE_T handle, MSG_SETTING_S *setting);
+@n msg_get_config() gets a message option.
+@code
+void MsgTestSetGeneralOpt(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SETTING_S setting = {0, };
+
+       setting.type = MSG_GENERAL_OPT;
+
+       setting.option.generalOpt.bKeepCopy = true;
+       setting.option.generalOpt.alertTone = MSG_ALERT_TONE_ONCE;
+
+       err = msg_set_config(hMsgHandle, &setting);
+
+       if (err == MSG_SUCCESS)
+               printf("Setting Config Data is OK!");
+       else
+               printf("Setting Config Data is failed!");
+}
+
+void MsgTestGetGeneralOpt(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SETTING_S setting = {0, };
+
+       err = msg_get_config(hMsgHandle, &setting);
+
+       if (err == MSG_SUCCESS)
+       {
+               printf("Setting Config Data is OK!\n");
+               printf("bKeepCopy : [%d], AlertTone : [%d]\n", setting.option.generalOpt.bKeepCopy, setting.option.generalOpt.alertTone);
+       }
+       else
+               printf("Setting Config Data is failed!\n");
+}
+@endcode
+@}
+
+@defgroup MESSAGE_USECASES_11 Filtering a Message
+@ingroup MESSAGE_USECASES
+@{
+               <h3 class="pg">Filtering a Message</h3>
+Messaging framework provides a filtering function for incoming message. New incoming message can be blocked (Move to spam-box or discard) by adding a filtering rule. A incoming message can be blocked by its originating address or by subject matching. If address matching filter rule is applied, only messages with exactly the same phone number can be blocked. Whereas, if a subject matching filter rule is applied, all messages that include the registered subject string might be blocked. An application can add or remove a filtering rule by calling msg_add_filter() or msg_delete_filter().
+
+- int msg_add_filter(MSG_HANDLE_T handle, const MSG_FILTER_S *filter);
+@n msg_add_filter() inserts a filtering rule to filter list and returns filter id.
+- int msg_delete_filter(MSG_HANDLE_T handle, MSG_FILTER_ID_T filter_id);
+@n msg_delete_filter()removes a filtering rule from filter list by filter id
+@code
+void MsgTestAddFilter(MSG_HANDLE_T hMsgHandle)
+{
+       if (hMsgHandle == NULL)
+       {
+               printf("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_FILTER_S filter[2]= {0, };
+
+       // Add filter by address
+       filter[0].filterType = MSG_FILTER_BY_ADDRESS;
+       strncpy(filter[0].filterValue, "+821234567890", MAX_FILTER_VALUE_LEN);
+
+       err = msg_add_filter(hMsgHandle, &filter[0]);
+
+       if (err == MSG_SUCCESS)
+               printf("msg_add_filter success");
+       else
+               printf("msg_add_filter fail - err [%d]", err);
+
+       // Add filter by subject
+       filter[1].filterType = MSG_FILTER_BY_SUBJECT;
+       strncpy(filter[1].filterValue, "test filter", MAX_FILTER_VALUE_LEN);
+
+       err = msg_add_filter(hMsgHandle, &filter[1]);
+
+       if (err == MSG_SUCCESS)
+               printf("msg_add_filter success");
+       else
+               printf("msg_add_filter fail - err [%d]", err);
+
+       return;
+}
+
+void MsgTestDeleteFilter(MSG_HANDLE_T hMsgHandle, MSG_FILTER_ID_T filterId)
+{
+       if (hMsgHandle == NULL)
+       {
+               printf("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+       err = msg_delete_filter(hMsgHandle, filterId);
+
+       if (MSG_SUCCESS == err)
+       {
+               printf("msg_delete_filter success");
+       }
+       else
+       {
+               printf("msg_delete_filter fail - err [%d]", err);
+       }
+
+       return;
+}
+@endcode
+@}
+*/
+
+/**
+@addtogroup MESSAGE
+@{
+       @defgroup MESSAGE_USECASES Use Cases
+@}
+*/
diff --git a/TC/_export_env.sh b/TC/_export_env.sh
new file mode 100755 (executable)
index 0000000..6dd507a
--- /dev/null
@@ -0,0 +1,15 @@
+export ARCH=target
+
+export TET_INSTALL_PATH=/home/givme/share/tetware/TETware  # tetware root path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+set $(pwd)
+export TET_SUITE_ROOT=$1
+
+set $(date +%s)
+FILE_NAME_EXTENSION=$1
+
diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh
new file mode 100755 (executable)
index 0000000..89ea16c
--- /dev/null
@@ -0,0 +1,16 @@
+
+export ARCH=target
+
+export TET_INSTALL_PATH=/opt/slp/TETware  # path to mount
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+set $(pwd)
+export TET_SUITE_ROOT=$1
+
+set $(date +%s)
+FILE_NAME_EXTENSION=$1
+
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755 (executable)
index 0000000..ce8f642
--- /dev/null
@@ -0,0 +1,18 @@
+. ./_export_env.sh                              # setting environment variables
+
+echo PATH=$PATH
+echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
+echo TET_ROOT=$TET_ROOT
+echo TET_SUITE_ROOT=$TET_SUITE_ROOT
+echo ARCH=$ARCH
+
+RESULT_DIR=results-$ARCH
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir $RESULT_DIR
+
+tcc -c -p ./                                # executing tcc, with clean option (-c)
+tcc -b -j $JOURNAL_RESULT -p ./            # executing tcc to build test cases (-b)
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT  # reporting the result
+
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755 (executable)
index 0000000..e1ed207
--- /dev/null
@@ -0,0 +1,17 @@
+. ./_export_target_env.sh                    # setting environment variables
+
+echo PATH=$PATH
+echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
+echo TET_ROOT=$TET_ROOT
+echo TET_SUITE_ROOT=$TET_SUITE_ROOT
+echo ARCH=$ARCH
+
+RESULT_DIR=results-$ARCH
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./             # executing tcc, with \96e option
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT # reporting the result
+
diff --git a/TC/making_new_tet_scen.py b/TC/making_new_tet_scen.py
new file mode 100755 (executable)
index 0000000..6c5b845
--- /dev/null
@@ -0,0 +1,69 @@
+#!/usr/bin/python
+
+#############################################
+# tet_scen  auto generator
+#
+# ** argv[1] = TC root
+#############################################
+
+import sys,string,os
+
+
+write_file = open("tet_scen", 'w')
+
+#
+# making new tet_scen
+#
+def making_tet_scen (filename):
+       #tmp_list = filename.strip().split('/')
+       n_filename = filename.replace(' ', '\\ ')
+       #print n_filename
+       #new_path = "/"+ sys.argv[1] +"/"+n_filename[2:-6]
+       new_path = "/"+n_filename[:-6]
+       #print new_path
+       file = open(filename, 'r')
+       lines = file.readlines()
+       for line in lines:
+               if len(line.strip()) > 1:
+                       list = line.strip().split('/')
+                       #print new_path + list[-1]
+                       write_file.write("\t"+new_path+list[-1]+"\n")
+
+#
+# usage()
+#
+def usage():
+       print(" ")
+       print("./making_new_tet_scen.py tc_root")
+       print("Put the Test Case's root directory.")
+       print("Do not include '/' at the end")
+       print(" ")
+
+#
+# main()
+#
+def main():
+       if len(sys.argv) < 2:
+               usage()
+               sys.exit(0)
+               
+       os.system('find '+ sys.argv[1] +' -name "tslist" > tslist.txt')
+       
+       #write_file = open("tetscen", w)
+       write_file.write("# auto generated tet_scen\n")
+       write_file.write("all\n")
+       write_file.write("\t\"Starting Full Test Suite\"\n")
+       
+       for file in open("tslist.txt", 'r'):
+               #print file.strip()
+               making_tet_scen(file.strip())
+                       
+       write_file.write("\t\"Completed Full Test Suite\"\n")
+       write_file.write("# EOF\n")
+       write_file.close()
+       print(" ")
+       print("==============================")
+       print("New tet_scen file is made~~~~")
+       print("==============================")
+       print(" ")
+main()
diff --git a/TC/msgTC/MapiControl/Makefile b/TC/msgTC/MapiControl/Makefile
new file mode 100755 (executable)
index 0000000..40d0ec2
--- /dev/null
@@ -0,0 +1,53 @@
+###################################################
+# add your TestCase List Here
+#
+# e.g.,
+# TC1 = utc_frameworkName_apiName_func
+# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
+TC1 = utc_msg_open_msg_handle
+TC2 = utc_msg_close_msg_handle
+       
+###################################################
+# add your Package Config Info Here
+#
+# e.g.,
+# PKGS=calendar
+PKGS=msg-service
+
+LIBS  = `pkg-config --libs $(PKGS)` 
+LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
+LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
+LIBS +=-L$(TET_ROOT)/lib/tet3 -lapi_s
+
+INCS  =  -I. `pkg-config --cflags $(PKGS)`
+INCS  += -I$(TET_ROOT)/inc/tet3 
+
+CFLAGS = $(INCS)
+CFLAGS += -D_TETWARE_MODE
+#CC +=$(CFLAGS)
+LDFLAGS = $(LIBS)
+
+###################################################
+# Modify here 
+# depending on the Test Case you want to build
+# 
+# e.g.,
+# TCLIST = $(TC1) $(TC2)
+TCLIST = $(TC1) $(TC2)
+all :
+       for testcase in $(TCLIST) do\
+               $(CC) -o $$(testcase) $$(testcase).c  $(LDFLAGS) $(CFLAGS)
+       done
+
+clean :
+       rm -rf *~ *.o $(TCLIST)
+
+
+$(TC1) : 
+       $(CC) -o $(TC1) $(TC1).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC2) :
+       $(CC) -o $(TC2) $(TC2).c  $(CFLAGS) $(LDFLAGS)
+
diff --git a/TC/msgTC/MapiControl/tslist b/TC/msgTC/MapiControl/tslist
new file mode 100755 (executable)
index 0000000..b2d987c
--- /dev/null
@@ -0,0 +1,2 @@
+utc_msg_open_msg_handle\r
+utc_msg_close_msg_handle
\ No newline at end of file
diff --git a/TC/msgTC/MapiControl/utc_msg_close_msg_handle.c b/TC/msgTC/MapiControl/utc_msg_close_msg_handle.c
new file mode 100755 (executable)
index 0000000..61a43de
--- /dev/null
@@ -0,0 +1,62 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+#include "utc_msg_close_msg_handle.h"
+
+void startup(void)
+{
+}
+void cleanup(void)
+{
+}
+
+void utc_msg_close_msg_handle_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_HANDLE_T msgHandle = NULL;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       err = msg_close_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_close_msg_handle_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_HANDLE_T msgHandle = NULL;
+
+       err = msg_close_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiControl/utc_msg_close_msg_handle.h b/TC/msgTC/MapiControl/utc_msg_close_msg_handle.h
new file mode 100755 (executable)
index 0000000..0349166
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiControl.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_close_msg_handle_001(void);
+ static void utc_msg_close_msg_handle_001(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_close_msg_handle_001,1},
+                       { utc_msg_close_msg_handle_001,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiControl/utc_msg_open_msg_handle.c b/TC/msgTC/MapiControl/utc_msg_open_msg_handle.c
new file mode 100755 (executable)
index 0000000..c1169b8
--- /dev/null
@@ -0,0 +1,63 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+#include "utc_msg_open_msg_handle.h"
+
+void startup(void)
+{
+}
+void cleanup(void)
+{
+}
+
+void utc_msg_open_msg_handle_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_HANDLE_T msgHandle = NULL;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_printf("utc_msg_open_msg_handle_001 failed");
+               tet_result(TET_FAIL);
+       }
+       else
+       {
+               tet_printf("utc_msg_open_msg_handle_001 passed");
+               tet_result(TET_PASS);
+       }
+
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_open_msg_handle_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(NULL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_printf("utc_msg_open_msg_handle_001 passed");
+               tet_result(TET_PASS);
+       }
+       else
+       {
+               tet_printf("utc_msg_open_msg_handle_001 failed");
+               tet_result(TET_FAIL);
+       }
+
+}
diff --git a/TC/msgTC/MapiControl/utc_msg_open_msg_handle.h b/TC/msgTC/MapiControl/utc_msg_open_msg_handle.h
new file mode 100755 (executable)
index 0000000..45dc31a
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiControl.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_open_msg_handle_001(void);
+ static void utc_msg_open_msg_handle_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_open_msg_handle_001,1},
+                       { utc_msg_open_msg_handle_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/Makefile b/TC/msgTC/MapiMessage/Makefile
new file mode 100755 (executable)
index 0000000..5ceb348
--- /dev/null
@@ -0,0 +1,296 @@
+###################################################
+# add your TestCase List Here
+#
+# e.g.,
+# TC1 = utc_frameworkName_apiName_func
+# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
+TC1 = utc_msg_add_address
+TC2 = utc_msg_get_time
+TC3 = utc_msg_new_message
+TC4 = utc_msg_mms_create_message
+TC5 = utc_msg_is_in_sim
+TC6 = utc_msg_release_message
+TC7 = utc_msg_get_address_count
+TC8 = utc_msg_is_mms
+TC9 = utc_msg_reset_address
+TC10 = utc_msg_get_dest_port
+TC11 = utc_msg_is_protected
+TC12 = utc_msg_set_direction_info
+TC13 = utc_msg_get_direction_info
+TC14 = utc_msg_is_read
+TC15 = utc_msg_set_encode_type
+TC16 = utc_msg_get_encode_type
+TC17 = utc_msg_is_sms
+TC18 = utc_msg_set_folder_id
+TC19 = utc_msg_get_folder_id
+TC10 = utc_msg_mms_add_attachment
+TC21 = utc_msg_set_message_id
+TC22 = utc_msg_get_ith_address
+TC23 = utc_msg_mms_add_media
+TC24 = utc_msg_set_message_type
+TC25 = utc_msg_get_ith_contact_id
+TC26 = utc_msg_mms_add_page
+TC27 = utc_msg_set_network_status
+TC28 = utc_msg_get_ith_name
+TC29 = utc_msg_mms_add_region
+TC30 = utc_msg_set_port
+TC31 = utc_msg_get_ith_recipient_type
+TC32 = utc_msg_mms_add_transition
+TC33 = utc_msg_set_priority_info
+TC34 = utc_msg_get_ith_thread_id
+TC35 = utc_msg_mms_destroy_message
+TC36 = utc_msg_set_protect_status
+TC37 = utc_msg_get_message_body_size
+TC38 = utc_msg_mms_get_attachment
+TC39 = utc_msg_set_read_status
+TC40 = utc_msg_get_message_id
+TC41 = utc_msg_mms_get_media
+TC42 = utc_msg_set_scheduled_time
+TC43 = utc_msg_get_message_type
+TC44 = utc_msg_mms_get_message_body
+TC45 = utc_msg_set_storage_id
+TC46 = utc_msg_get_network_status
+TC47 = utc_msg_mms_get_meta
+TC48 = utc_msg_set_subject
+TC49 = utc_msg_get_priority_info
+TC50 = utc_msg_mms_get_page
+TC51 = utc_msg_set_time
+TC52 = utc_msg_get_scheduled_time
+TC53 = utc_msg_mms_get_smil_region
+TC54 = utc_msg_sms_get_message_body
+TC55 = utc_msg_get_src_port
+TC56 = utc_msg_mms_get_transition
+TC57 = utc_msg_sms_set_message_body
+TC58 = utc_msg_get_storage_id
+TC59 = utc_msg_mms_set_message_body
+TC60 = utc_msg_get_subject
+TC61 = utc_msg_mms_set_rootlayout
+TC62 = utc_msg_mms_add_meta
+TC63 = utc_msg_get_dest_port
+
+
+###################################################
+# add your Package Config Info Here
+#
+# e.g.,
+# PKGS=calendar
+PKGS=msg-service
+
+LIBS  = `pkg-config --libs $(PKGS)`
+LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
+LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
+LIBS +=-L$(TET_ROOT)/lib/tet3 -lapi_s
+
+INCS  =  -I. `pkg-config --cflags $(PKGS)`
+INCS  += -I$(TET_ROOT)/inc/tet3
+
+CFLAGS = $(INCS)
+CFLAGS += -D_TETWARE_MODE
+#CC +=$(CFLAGS)
+LDFLAGS = $(LIBS)
+
+###################################################
+# Modify here
+# depending on the Test Case you want to build
+#
+# e.g.,
+# TCLIST = $(TC1) $(TC2)
+TCLIST = $(TC1) $(TC2) $(TC3) $(TC4) $(TC5) $(TC6) $(TC7) $(TC8) $(TC9) $(TC10) $(TC11) $(TC12) $(TC13) $(TC14) $(TC15) $(TC16) $(TC17) $(TC18) $(TC19) $(TC20) $(TC21) $(TC22) $(TC23) $(TC24) $(TC25) $(TC26) $(TC27) $(TC28) $(TC29) $(TC30) $(TC31) $(TC32) $(TC33) $(TC34) $(TC35) $(TC36) $(TC37) $(TC38) $(TC39) $(TC40) $(TC41) $(TC42) $(TC43) $(TC44) $(TC45) $(TC46) $(TC47) $(TC48) $(TC49) $(TC50) $(TC51) $(TC52) $(TC53) $(TC54) $(TC55) $(TC56) $(TC57) $(TC58) $(TC59) $(TC60) $(TC61) $(TC62) $(TC63)
+
+all :
+       for testcase in $(TCLIST) do\
+               $(CC) -o $$(testcase) $$(testcase).c $(CFLAGS) $(LDFLAGS)
+       done
+
+clean :
+       rm -rf *~ *.o $(TCLIST)
+
+
+$(TC1) :
+       $(CC) -o $(TC1) $(TC1).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC2) :
+       $(CC) -o $(TC2) $(TC2).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC3) :
+       $(CC) -o $(TC3) $(TC3).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC4) :
+       $(CC) -o $(TC4) $(TC4).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC5) :
+       $(CC) -o $(TC5) $(TC5).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC6) :
+       $(CC) -o $(TC6) $(TC6).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC7) :
+       $(CC) -o $(TC7) $(TC7).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC8) :
+       $(CC) -o $(TC8) $(TC8).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC9) :
+       $(CC) -o $(TC9) $(TC9).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC10) :
+       $(CC) -o $(TC10) $(TC10).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC11) :
+       $(CC) -o $(TC11) $(TC11).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC12) :
+       $(CC) -o $(TC12) $(TC12).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC13) :
+       $(CC) -o $(TC13) $(TC13).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC14) :
+       $(CC) -o $(TC14) $(TC14).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC15) :
+       $(CC) -o $(TC15) $(TC15).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC16) :
+       $(CC) -o $(TC16) $(TC16).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC17) :
+       $(CC) -o $(TC17) $(TC17).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC18) :
+       $(CC) -o $(TC18) $(TC18).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC19) :
+       $(CC) -o $(TC19) $(TC19).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC20) :
+       $(CC) -o $(TC20) $(TC20).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC21) :
+       $(CC) -o $(TC21) $(TC21).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC22) :
+       $(CC) -o $(TC22) $(TC22).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC23) :
+       $(CC) -o $(TC23) $(TC23).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC24) :
+       $(CC) -o $(TC24) $(TC24).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC25) :
+       $(CC) -o $(TC25) $(TC25).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC26) :
+       $(CC) -o $(TC26) $(TC26).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC27) :
+       $(CC) -o $(TC27) $(TC27).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC28) :
+       $(CC) -o $(TC28) $(TC28).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC29) :
+       $(CC) -o $(TC29) $(TC29).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC30) :
+       $(CC) -o $(TC30) $(TC30).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC31) :
+       $(CC) -o $(TC31) $(TC31).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC32) :
+       $(CC) -o $(TC32) $(TC32).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC33) :
+       $(CC) -o $(TC33) $(TC33).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC34) :
+       $(CC) -o $(TC34) $(TC34).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC35) :
+       $(CC) -o $(TC35) $(TC35).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC36) :
+       $(CC) -o $(TC36) $(TC36).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC37) :
+       $(CC) -o $(TC37) $(TC37).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC38) :
+       $(CC) -o $(TC38) $(TC38).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC39) :
+       $(CC) -o $(TC39) $(TC39).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC40) :
+       $(CC) -o $(TC40) $(TC40).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC41) :
+       $(CC) -o $(TC41) $(TC41).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC42) :
+       $(CC) -o $(TC42) $(TC42).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC43) :
+       $(CC) -o $(TC43) $(TC43).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC44) :
+       $(CC) -o $(TC44) $(TC44).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC45) :
+       $(CC) -o $(TC45) $(TC45).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC46) :
+       $(CC) -o $(TC46) $(TC46).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC47) :
+       $(CC) -o $(TC47) $(TC47).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC48) :
+       $(CC) -o $(TC48) $(TC48).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC49) :
+       $(CC) -o $(TC49) $(TC49).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC50) :
+       $(CC) -o $(TC50) $(TC50).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC51) :
+       $(CC) -o $(TC51) $(TC51).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC52) :
+       $(CC) -o $(TC52) $(TC52).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC53) :
+       $(CC) -o $(TC53) $(TC53).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC54) :
+       $(CC) -o $(TC54) $(TC54).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC55) :
+       $(CC) -o $(TC55) $(TC55).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC56) :
+       $(CC) -o $(TC56) $(TC56).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC57) :
+       $(CC) -o $(TC57) $(TC57).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC58) :
+       $(CC) -o $(TC58) $(TC58).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC59) :
+       $(CC) -o $(TC59) $(TC59).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC60) :
+       $(CC) -o $(TC60) $(TC60).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC61) :
+       $(CC) -o $(TC61) $(TC61).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC62) :
+       $(CC) -o $(TC62) $(TC62).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC63) :
+       $(CC) -o $(TC63) $(TC63).c  $(CFLAGS) $(LDFLAGS)
\ No newline at end of file
diff --git a/TC/msgTC/MapiMessage/tslist b/TC/msgTC/MapiMessage/tslist
new file mode 100755 (executable)
index 0000000..8127178
--- /dev/null
@@ -0,0 +1,62 @@
+utc_msg_add_address\r
+utc_msg_get_time\r
+utc_msg_new_message\r
+utc_msg_mms_create_message\r
+utc_msg_is_in_sim\r
+utc_msg_release_message\r
+utc_msg_get_address_count\r
+utc_msg_is_mms\r
+utc_msg_reset_address\r
+utc_msg_get_dest_port\r
+utc_msg_is_protected\r
+utc_msg_set_direction_info\r
+utc_msg_get_direction_info\r
+utc_msg_is_read\r
+utc_msg_set_encode_type\r
+utc_msg_get_encode_type\r
+utc_msg_is_sms\r
+utc_msg_set_folder_id\r
+utc_msg_get_folder_id\r
+utc_msg_mms_add_attachment\r
+utc_msg_set_message_id\r
+utc_msg_get_ith_address\r
+utc_msg_mms_add_media\r
+utc_msg_set_message_type\r
+utc_msg_get_ith_contact_id\r
+utc_msg_mms_add_page\r
+utc_msg_set_network_status\r
+utc_msg_get_ith_name\r
+utc_msg_mms_add_region\r
+utc_msg_set_port\r
+utc_msg_get_ith_recipient_type\r
+utc_msg_mms_add_transition\r
+utc_msg_mms_add_meta\r
+utc_msg_set_priority_info\r
+utc_msg_get_ith_thread_id\r
+utc_msg_mms_destroy_message\r
+utc_msg_set_protect_status\r
+utc_msg_get_message_body_size\r
+utc_msg_mms_get_attachment\r
+utc_msg_set_read_status\r
+utc_msg_get_message_id\r
+utc_msg_mms_get_media\r
+utc_msg_set_scheduled_time\r
+utc_msg_get_message_type\r
+utc_msg_mms_get_message_body\r
+utc_msg_set_storage_id\r
+utc_msg_get_network_status\r
+utc_msg_mms_get_meta\r
+utc_msg_set_subject\r
+utc_msg_get_priority_info\r
+utc_msg_mms_get_page\r
+utc_msg_set_time\r
+utc_msg_get_scheduled_time\r
+utc_msg_mms_get_smil_region\r
+utc_msg_sms_get_message_body\r
+utc_msg_get_src_port\r
+utc_msg_mms_get_transition\r
+utc_msg_sms_set_message_body\r
+utc_msg_get_storage_id\r
+utc_msg_mms_set_message_body\r
+utc_msg_get_subject\r
+utc_msg_mms_set_rootlayout\r
diff --git a/TC/msgTC/MapiMessage/utc_msg_add_address.c b/TC/msgTC/MapiMessage/utc_msg_add_address.c
new file mode 100755 (executable)
index 0000000..2b26c61
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_add_address.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_add_address_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_add_address(msgInfo, "01030015078", MSG_RECIPIENTS_TYPE_TO);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_add_address_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_add_address(NULL, "01030015078", MSG_RECIPIENTS_TYPE_TO);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_add_address.h b/TC/msgTC/MapiMessage/utc_msg_add_address.h
new file mode 100755 (executable)
index 0000000..26e274b
--- /dev/null
@@ -0,0 +1,35 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_add_address_001(void);
+static void utc_msg_add_address_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_add_address_001,1},
+                       { utc_msg_add_address_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_address_count.c b/TC/msgTC/MapiMessage/utc_msg_get_address_count.c
new file mode 100755 (executable)
index 0000000..e4bdf2d
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_address_count.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_address_count_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_address_count(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_address_count_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_address_count(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_address_count.h b/TC/msgTC/MapiMessage/utc_msg_get_address_count.h
new file mode 100755 (executable)
index 0000000..2a4a5d1
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_address_count_001(void);
+ static void utc_msg_get_address_count_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_address_count_001,1},
+                       { utc_msg_get_address_count_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_dest_port.c b/TC/msgTC/MapiMessage/utc_msg_get_dest_port.c
new file mode 100755 (executable)
index 0000000..f062abc
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_dest_port.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_dest_port_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_dest_port(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_dest_port_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_dest_port(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_dest_port.h b/TC/msgTC/MapiMessage/utc_msg_get_dest_port.h
new file mode 100755 (executable)
index 0000000..9370812
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_dest_port_001(void);
+ static void utc_msg_get_dest_port_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_dest_port_001,1},
+                       { utc_msg_get_dest_port_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_direction_info.c b/TC/msgTC/MapiMessage/utc_msg_get_direction_info.c
new file mode 100755 (executable)
index 0000000..4a26aeb
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_direction_info.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_direction_info_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_direction_info(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_direction_info_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_direction_info(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_direction_info.h b/TC/msgTC/MapiMessage/utc_msg_get_direction_info.h
new file mode 100755 (executable)
index 0000000..2326c3d
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_direction_info_001(void);
+ static void utc_msg_get_direction_info_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_direction_info_001,1},
+                       { utc_msg_get_direction_info_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_encode_type.c b/TC/msgTC/MapiMessage/utc_msg_get_encode_type.c
new file mode 100755 (executable)
index 0000000..20d2743
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_encode_type.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_encode_type_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_encode_type(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_encode_type_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_encode_type(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_encode_type.h b/TC/msgTC/MapiMessage/utc_msg_get_encode_type.h
new file mode 100755 (executable)
index 0000000..463c5ee
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_encode_type_001(void);
+ static void utc_msg_get_encode_type_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_encode_type_001,1},
+                       { utc_msg_get_encode_type_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_folder_id.c b/TC/msgTC/MapiMessage/utc_msg_get_folder_id.c
new file mode 100755 (executable)
index 0000000..8e3f605
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_folder_id.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_folder_id_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_folder_id(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_folder_id_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_folder_id(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_folder_id.h b/TC/msgTC/MapiMessage/utc_msg_get_folder_id.h
new file mode 100755 (executable)
index 0000000..4dd61cc
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_folder_id_001(void);
+ static void utc_msg_get_folder_id_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_folder_id_001,1},
+                       { utc_msg_get_folder_id_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_ith_address.c b/TC/msgTC/MapiMessage/utc_msg_get_ith_address.c
new file mode 100755 (executable)
index 0000000..c088bd9
--- /dev/null
@@ -0,0 +1,70 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_ith_address.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       msg_add_address(msgInfo, "01030015078", MSG_RECIPIENTS_TYPE_TO);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_ith_address_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       char * address = NULL;
+
+       address = msg_get_ith_address(msgInfo, 0);
+       if (address == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_ith_address_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       char * address = NULL;
+
+       address = msg_get_ith_address(NULL, 0);
+       if (address == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_ith_address.h b/TC/msgTC/MapiMessage/utc_msg_get_ith_address.h
new file mode 100755 (executable)
index 0000000..2528b9c
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_ith_address_001(void);
+ static void utc_msg_get_ith_address_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_ith_address_001,1},
+                       { utc_msg_get_ith_address_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_ith_contact_id.c b/TC/msgTC/MapiMessage/utc_msg_get_ith_contact_id.c
new file mode 100755 (executable)
index 0000000..d067bbb
--- /dev/null
@@ -0,0 +1,68 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_ith_contact_id.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       msg_add_address(msgInfo, "01030015078", MSG_RECIPIENTS_TYPE_TO);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_ith_contact_id_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_ith_contact_id(msgInfo, 0);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_ith_contact_id_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_ith_contact_id(NULL, 0);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_ith_contact_id.h b/TC/msgTC/MapiMessage/utc_msg_get_ith_contact_id.h
new file mode 100755 (executable)
index 0000000..dfd8302
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_ith_contact_id_001(void);
+ static void utc_msg_get_ith_contact_id_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_ith_contact_id_001,1},
+                       { utc_msg_get_ith_contact_id_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_ith_name.c b/TC/msgTC/MapiMessage/utc_msg_get_ith_name.c
new file mode 100755 (executable)
index 0000000..5878f21
--- /dev/null
@@ -0,0 +1,70 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_ith_name.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       msg_add_address(msgInfo, "01030015078", MSG_RECIPIENTS_TYPE_TO);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_ith_name_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       char * address = NULL;
+
+       address = msg_get_ith_name(msgInfo, 0);
+       if (address == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_ith_name_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       char * address = NULL;
+
+       address = msg_get_ith_name(NULL, 0);
+       if (address == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_ith_name.h b/TC/msgTC/MapiMessage/utc_msg_get_ith_name.h
new file mode 100755 (executable)
index 0000000..00c2dee
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_ith_name_001(void);
+ static void utc_msg_get_ith_name_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_ith_name_001,1},
+                       { utc_msg_get_ith_name_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_ith_recipient_type.c b/TC/msgTC/MapiMessage/utc_msg_get_ith_recipient_type.c
new file mode 100755 (executable)
index 0000000..e607fe3
--- /dev/null
@@ -0,0 +1,68 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_ith_recipient_type.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       msg_add_address(msgInfo, "01030015078", MSG_RECIPIENTS_TYPE_TO);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_ith_recipient_type_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_ith_recipient_type(msgInfo, 0);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_ith_recipient_type_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_ith_recipient_type(NULL, 0);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_ith_recipient_type.h b/TC/msgTC/MapiMessage/utc_msg_get_ith_recipient_type.h
new file mode 100755 (executable)
index 0000000..6c01dae
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_ith_recipient_type_001(void);
+ static void utc_msg_get_ith_recipient_type_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_ith_recipient_type_001,1},
+                       { utc_msg_get_ith_recipient_type_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_ith_thread_id.c b/TC/msgTC/MapiMessage/utc_msg_get_ith_thread_id.c
new file mode 100755 (executable)
index 0000000..ccb0e7c
--- /dev/null
@@ -0,0 +1,68 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_ith_thread_id.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       msg_add_address(msgInfo, "01030015078", MSG_RECIPIENTS_TYPE_TO);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_ith_thread_id_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_ith_thread_id(msgInfo, 0);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_ith_thread_id_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_ith_thread_id(NULL, 0);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_ith_thread_id.h b/TC/msgTC/MapiMessage/utc_msg_get_ith_thread_id.h
new file mode 100755 (executable)
index 0000000..fae0136
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_ith_thread_id_001(void);
+ static void utc_msg_get_ith_thread_id_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_ith_thread_id_001,1},
+                       { utc_msg_get_ith_thread_id_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_message_body_size.c b/TC/msgTC/MapiMessage/utc_msg_get_message_body_size.c
new file mode 100755 (executable)
index 0000000..6c4cd75
--- /dev/null
@@ -0,0 +1,68 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_message_body_size.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       msg_sms_set_message_body(msgInfo, "test message", 12);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_message_id_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_message_body_size(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_message_id_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_message_body_size(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_message_body_size.h b/TC/msgTC/MapiMessage/utc_msg_get_message_body_size.h
new file mode 100755 (executable)
index 0000000..a9de554
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_message_id_001(void);
+ static void utc_msg_get_message_id_001(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_message_id_001,1},
+                       { utc_msg_get_message_id_001,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_message_id.c b/TC/msgTC/MapiMessage/utc_msg_get_message_id.c
new file mode 100755 (executable)
index 0000000..d8501e6
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_message_id.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_message_id_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_message_id(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_message_id_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_message_id(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_message_id.h b/TC/msgTC/MapiMessage/utc_msg_get_message_id.h
new file mode 100755 (executable)
index 0000000..f8aa1b0
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_message_id_001(void);
+ static void utc_msg_get_message_id_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_message_id_001,1},
+                       { utc_msg_get_message_id_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_message_type.c b/TC/msgTC/MapiMessage/utc_msg_get_message_type.c
new file mode 100755 (executable)
index 0000000..37d81e1
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_message_type.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_message_type_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_message_type(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_message_type_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_message_type(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_message_type.h b/TC/msgTC/MapiMessage/utc_msg_get_message_type.h
new file mode 100755 (executable)
index 0000000..3bc88dc
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_message_type_001(void);
+ static void utc_msg_get_message_type_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_message_type_001,1},
+                       { utc_msg_get_message_type_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_network_status.c b/TC/msgTC/MapiMessage/utc_msg_get_network_status.c
new file mode 100755 (executable)
index 0000000..e066953
--- /dev/null
@@ -0,0 +1,68 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_network_status.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       msg_set_network_status(msgInfo, MSG_NETWORK_SEND_SUCCESS);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_network_status_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_network_status(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_network_status_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_network_status(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_network_status.h b/TC/msgTC/MapiMessage/utc_msg_get_network_status.h
new file mode 100755 (executable)
index 0000000..65a3baf
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_network_status_001(void);
+ static void utc_msg_get_network_status_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_network_status_001,1},
+                       { utc_msg_get_network_status_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_priority_info.c b/TC/msgTC/MapiMessage/utc_msg_get_priority_info.c
new file mode 100755 (executable)
index 0000000..2d86631
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_priority_info.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_priority_info_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_priority_info(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_priority_info_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_priority_info(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_priority_info.h b/TC/msgTC/MapiMessage/utc_msg_get_priority_info.h
new file mode 100755 (executable)
index 0000000..3739886
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_priority_info_001(void);
+ static void utc_msg_get_priority_info_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_priority_info_001,1},
+                       { utc_msg_get_priority_info_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_scheduled_time.c b/TC/msgTC/MapiMessage/utc_msg_get_scheduled_time.c
new file mode 100755 (executable)
index 0000000..6bc65fa
--- /dev/null
@@ -0,0 +1,70 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_scheduled_time.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_scheduled_time_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       time_t scheduledTime = NULL;
+
+       scheduledTime = msg_get_scheduled_time(msgInfo);
+       if (scheduledTime == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_scheduled_time_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       time_t scheduledTime = NULL;
+
+       scheduledTime = msg_get_scheduled_time(NULL);
+       if (scheduledTime == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_scheduled_time.h b/TC/msgTC/MapiMessage/utc_msg_get_scheduled_time.h
new file mode 100755 (executable)
index 0000000..d9a6530
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_scheduled_time_001(void);
+ static void utc_msg_get_scheduled_time_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_scheduled_time_001,1},
+                       { utc_msg_get_scheduled_time_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_src_port.c b/TC/msgTC/MapiMessage/utc_msg_get_src_port.c
new file mode 100755 (executable)
index 0000000..9b58f14
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_src_port.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_src_port_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_src_port(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_src_port_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_src_port(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_src_port.h b/TC/msgTC/MapiMessage/utc_msg_get_src_port.h
new file mode 100755 (executable)
index 0000000..fdaa744
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_src_port_001(void);
+ static void utc_msg_get_src_port_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_src_port_001,1},
+                       { utc_msg_get_src_port_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_storage_id.c b/TC/msgTC/MapiMessage/utc_msg_get_storage_id.c
new file mode 100755 (executable)
index 0000000..a581125
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_storage_id.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_storage_id_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_storage_id(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_storage_id_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_storage_id(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_storage_id.h b/TC/msgTC/MapiMessage/utc_msg_get_storage_id.h
new file mode 100755 (executable)
index 0000000..06f9aa9
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_storage_id_001(void);
+ static void utc_msg_get_storage_id_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_storage_id_001,1},
+                       { utc_msg_get_storage_id_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_subject.c b/TC/msgTC/MapiMessage/utc_msg_get_subject.c
new file mode 100755 (executable)
index 0000000..47b6963
--- /dev/null
@@ -0,0 +1,70 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_subject.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       msg_set_subject(msgInfo, "test subject");
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_subject_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       char* subject = NULL;
+
+       subject = msg_get_subject(msgInfo);
+       if (subject == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_subject_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       char* subject = NULL;
+
+       subject = msg_get_subject(NULL);
+       if (subject == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_subject.h b/TC/msgTC/MapiMessage/utc_msg_get_subject.h
new file mode 100755 (executable)
index 0000000..32e738b
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_subject_001(void);
+ static void utc_msg_get_subject_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_subject_001,1},
+                       { utc_msg_get_subject_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_time.c b/TC/msgTC/MapiMessage/utc_msg_get_time.c
new file mode 100755 (executable)
index 0000000..7030168
--- /dev/null
@@ -0,0 +1,69 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_time.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       time_t curTime = time(NULL);
+       msg_set_time(msgInfo, curTime);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_time_001()
+{
+       time_t* curTime;
+
+       curTime = msg_get_time(msgInfo);
+       if (curTime == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_time_002()
+{
+       time_t* curTime;
+
+       curTime = msg_get_time(NULL);
+       if (curTime == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_get_time.h b/TC/msgTC/MapiMessage/utc_msg_get_time.h
new file mode 100755 (executable)
index 0000000..847115d
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_time_001(void);
+ static void utc_msg_get_time_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_time_001,1},
+                       { utc_msg_get_time_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_is_in_sim.c b/TC/msgTC/MapiMessage/utc_msg_is_in_sim.c
new file mode 100755 (executable)
index 0000000..c52189d
--- /dev/null
@@ -0,0 +1,68 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_is_in_sim.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_is_in_sim_001()
+{
+       bool bIsInSim = false;
+
+       msg_set_storage_id(msgInfo, MSG_STORAGE_SIM);
+
+       bIsInSim = msg_is_in_sim(msgInfo);
+       if (!bIsInSim)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_is_in_sim_002()
+{
+       bool bIsInSim = false;
+
+       bIsInSim = msg_is_in_sim(NULL);
+       if (!bIsInSim)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_is_in_sim.h b/TC/msgTC/MapiMessage/utc_msg_is_in_sim.h
new file mode 100755 (executable)
index 0000000..c7b01c1
--- /dev/null
@@ -0,0 +1,35 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MsgStorageTypes.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_is_in_sim_001(void);
+ static void utc_msg_is_in_sim_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_is_in_sim_001,1},
+                       { utc_msg_is_in_sim_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_is_mms.c b/TC/msgTC/MapiMessage/utc_msg_is_mms.c
new file mode 100755 (executable)
index 0000000..757479f
--- /dev/null
@@ -0,0 +1,68 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_is_mms.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       msg_set_message_type(msgInfo, MSG_TYPE_MMS);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_is_mms_001()
+{
+       bool bIsMMS = true;
+
+       bIsMMS = msg_is_mms(msgInfo);
+       if (!bIsMMS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_is_mms_002()
+{
+       bool bIsMMS = true;
+
+       bIsMMS = msg_is_mms(NULL);
+       if (!bIsMMS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_is_mms.h b/TC/msgTC/MapiMessage/utc_msg_is_mms.h
new file mode 100755 (executable)
index 0000000..0085d3a
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_is_mms_001(void);
+ static void utc_msg_is_mms_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_is_mms_001,1},
+                       { utc_msg_is_mms_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_is_protected.c b/TC/msgTC/MapiMessage/utc_msg_is_protected.c
new file mode 100755 (executable)
index 0000000..8a2a007
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_is_protected.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_is_protected_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_is_protected(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_is_protected_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_is_protected(NULL);
+       if (err <= MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_is_protected.h b/TC/msgTC/MapiMessage/utc_msg_is_protected.h
new file mode 100755 (executable)
index 0000000..3d1c896
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_is_protected_001(void);
+ static void utc_msg_is_protected_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_is_protected_001,1},
+                       { utc_msg_is_protected_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_is_read.c b/TC/msgTC/MapiMessage/utc_msg_is_read.c
new file mode 100755 (executable)
index 0000000..3825c17
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_is_read.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_is_read_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_is_read(msgInfo);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_is_read_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_is_read(NULL);
+       if (err <= MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_is_read.h b/TC/msgTC/MapiMessage/utc_msg_is_read.h
new file mode 100755 (executable)
index 0000000..4dadde5
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_is_read_001(void);
+ static void utc_msg_is_read_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_is_read_001,1},
+                       { utc_msg_is_read_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_is_sms.c b/TC/msgTC/MapiMessage/utc_msg_is_sms.c
new file mode 100755 (executable)
index 0000000..3b87c40
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_is_sms.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_is_sms_001()
+{
+       bool bIsSMS = false;
+
+       bIsSMS = msg_is_sms(msgInfo);
+       if (!bIsSMS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_is_sms_002()
+{
+       bool bIsSMS = false;
+
+       bIsSMS = msg_is_sms(NULL);
+       if (!bIsSMS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_is_sms.h b/TC/msgTC/MapiMessage/utc_msg_is_sms.h
new file mode 100755 (executable)
index 0000000..bb45a0f
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_is_sms_001(void);
+ static void utc_msg_is_sms_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_is_sms_001,1},
+                       { utc_msg_is_sms_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_add_attachment.c b/TC/msgTC/MapiMessage/utc_msg_mms_add_attachment.c
new file mode 100755 (executable)
index 0000000..43f4c50
--- /dev/null
@@ -0,0 +1,75 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_add_attachment.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+       MMS_ATTACH_S*   attachment[5];
+       int                             nSize;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_add_attachment_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_ATTACH_S*   attach = NULL;
+
+       attach = msg_mms_add_attachment(mms_data, (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       if (attach == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_add_attachment_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_ATTACH_S*   attach = NULL;
+
+       attach = msg_mms_add_attachment(NULL, (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       if (attach == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_add_attachment.h b/TC/msgTC/MapiMessage/utc_msg_mms_add_attachment.h
new file mode 100755 (executable)
index 0000000..d7f95a0
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_add_attachment_001(void);
+ static void utc_msg_mms_add_attachment_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_add_attachment_001,1},
+                       { utc_msg_mms_add_attachment_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_add_media.c b/TC/msgTC/MapiMessage/utc_msg_mms_add_media.c
new file mode 100755 (executable)
index 0000000..7716fb9
--- /dev/null
@@ -0,0 +1,77 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_add_media.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+MMS_PAGE_S* page = NULL;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MEDIA_S*    media[5];
+       MMS_ATTACH_S*   attachment[5];
+       int                             nSize;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       page = msg_mms_add_page(mms_data, 5440);
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_add_media_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MEDIA_S*    media = NULL;
+
+       media = msg_mms_add_media(page, MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       if (media == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_add_media_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MEDIA_S*    media = NULL;
+
+       media = msg_mms_add_media(NULL, MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       if (media == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_add_media.h b/TC/msgTC/MapiMessage/utc_msg_mms_add_media.h
new file mode 100755 (executable)
index 0000000..4fdbedc
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_add_media_001(void);
+ static void utc_msg_mms_add_media_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_add_media_001,1},
+                       { utc_msg_mms_add_media_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_add_meta.c b/TC/msgTC/MapiMessage/utc_msg_mms_add_meta.c
new file mode 100755 (executable)
index 0000000..48955e0
--- /dev/null
@@ -0,0 +1,79 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_add_meta.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+MMS_SMIL_META meta;
+MMS_PAGE_S* page = NULL;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MEDIA_S*    media[5];
+       MMS_ATTACH_S*   attachment[5];
+       int                             nSize;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       memset(&meta, 0x00, sizeof(MMS_SMIL_META));
+
+       page = msg_mms_add_page(mms_data, 5440);
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_add_meta_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_mms_add_meta(mms_data, &meta);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_add_meta_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MEDIA_S*    media = NULL;
+
+       err = msg_mms_add_meta(NULL, &meta);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_add_meta.h b/TC/msgTC/MapiMessage/utc_msg_mms_add_meta.h
new file mode 100755 (executable)
index 0000000..0043839
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_add_meta_001(void);
+ static void utc_msg_mms_add_meta_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_add_meta_001,1},
+                       { utc_msg_mms_add_meta_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_add_page.c b/TC/msgTC/MapiMessage/utc_msg_mms_add_page.c
new file mode 100755 (executable)
index 0000000..80b1427
--- /dev/null
@@ -0,0 +1,71 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_add_page.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_set_message_body_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*             page;
+
+       page = msg_mms_add_page(mms_data, 5440);
+       if (page == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_set_message_body_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*             page;
+
+       page = msg_mms_add_page(NULL, 5440);
+       if (page == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_add_page.h b/TC/msgTC/MapiMessage/utc_msg_mms_add_page.h
new file mode 100755 (executable)
index 0000000..8c2da09
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_set_message_body_001(void);
+ static void utc_msg_mms_set_message_body_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_set_message_body_001,1},
+                       { utc_msg_mms_set_message_body_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_add_region.c b/TC/msgTC/MapiMessage/utc_msg_mms_add_region.c
new file mode 100755 (executable)
index 0000000..ac744e9
--- /dev/null
@@ -0,0 +1,75 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_add_region.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+       MMS_ATTACH_S*   attachment[5];
+       int                             nSize;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_add_region_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_SMIL_REGION* region = NULL;
+
+       region = msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       if (region == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_add_region_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_SMIL_REGION* region = NULL;
+
+       region = msg_mms_add_region(NULL, "Image", 0, 50, 100, 50, 0xffffff);
+       if (region == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_add_region.h b/TC/msgTC/MapiMessage/utc_msg_mms_add_region.h
new file mode 100755 (executable)
index 0000000..5d7f49f
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_add_region_001(void);
+ static void utc_msg_mms_add_region_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_add_region_001,1},
+                       { utc_msg_mms_add_region_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_add_transition.c b/TC/msgTC/MapiMessage/utc_msg_mms_add_transition.c
new file mode 100755 (executable)
index 0000000..11eeae6
--- /dev/null
@@ -0,0 +1,79 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_add_transition.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+       MMS_ATTACH_S*   attachment[5];
+       int                             nSize;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_add_transition_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_SMIL_TRANSITION transition;
+
+       memset(&transition, 0x00, sizeof(transition));
+
+       err = msg_mms_add_transition(mms_data, &transition);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_add_transition_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_SMIL_TRANSITION transition;
+
+       memset(&transition, 0x00, sizeof(transition));
+
+       err = msg_mms_add_transition(NULL, &transition);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_add_transition.h b/TC/msgTC/MapiMessage/utc_msg_mms_add_transition.h
new file mode 100755 (executable)
index 0000000..12d547e
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_add_transition_001(void);
+ static void utc_msg_mms_add_transition_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_add_transition_001,1},
+                       { utc_msg_mms_add_transition_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_create_message.c b/TC/msgTC/MapiMessage/utc_msg_mms_create_message.c
new file mode 100755 (executable)
index 0000000..74360e0
--- /dev/null
@@ -0,0 +1,72 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_create_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_create_message_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MESSAGE_DATA_S*      mms_data = NULL;
+
+       mms_data = msg_mms_create_message();
+       if (mms_data == NULL)
+       {
+               tet_result(TET_FAIL);
+               msg_mms_destroy_message(mms_data);
+               return;
+       }
+
+       tet_result(TET_PASS);
+       msg_mms_destroy_message(mms_data);
+}
+
+void utc_msg_mms_create_message_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MESSAGE_DATA_S*      mms_data = NULL;
+
+       //mms_data = msg_mms_create_message();
+       if (mms_data == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_create_message.h b/TC/msgTC/MapiMessage/utc_msg_mms_create_message.h
new file mode 100755 (executable)
index 0000000..4f776f3
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_create_message_001(void);
+ static void utc_msg_mms_create_message_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_create_message_001,1},
+                       { utc_msg_mms_create_message_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_destroy_message.c b/TC/msgTC/MapiMessage/utc_msg_mms_destroy_message.c
new file mode 100755 (executable)
index 0000000..a399ad3
--- /dev/null
@@ -0,0 +1,70 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_destroy_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_destroy_message_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_mms_destroy_message(mms_data);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_destroy_message_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_mms_destroy_message(NULL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_destroy_message.h b/TC/msgTC/MapiMessage/utc_msg_mms_destroy_message.h
new file mode 100755 (executable)
index 0000000..c36cda2
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_destroy_message_001(void);
+ static void utc_msg_mms_destroy_message_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_destroy_message_001,1},
+                       { utc_msg_mms_destroy_message_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_attachment.c b/TC/msgTC/MapiMessage/utc_msg_mms_get_attachment.c
new file mode 100755 (executable)
index 0000000..e02d7ba
--- /dev/null
@@ -0,0 +1,98 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_get_attachment.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+       //------------>  1st Slide Composing
+       page[0] = msg_mms_add_page(mms_data, 5440);
+
+       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+       media[2]->sMedia.sText.nColor = 0x000000;
+       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[2]->sMedia.sText.bBold = true;
+
+       //------------>  2nd Slide Composing
+       page[1] = msg_mms_add_page(mms_data, 4544);
+
+       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+       media[3]->sMedia.sText.nColor = 0x000000;
+       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[3]->sMedia.sText.bItalic = true;
+       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+
+       msg_mms_add_attachment(mms_data, "/opt/etc/msg-service/Temp1_0.txt");
+
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_get_attachment_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MMS_ATTACH_S*   pAttach = msg_mms_get_attachment(mms_data, 0);
+       if (pAttach == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_get_attachment_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MMS_ATTACH_S*   pAttach = msg_mms_get_attachment(mms_data, -1);
+       if (pAttach == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_attachment.h b/TC/msgTC/MapiMessage/utc_msg_mms_get_attachment.h
new file mode 100755 (executable)
index 0000000..f8d658a
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_get_attachment_001(void);
+ static void utc_msg_mms_get_attachment_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_get_attachment_001,1},
+                       { utc_msg_mms_get_attachment_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_media.c b/TC/msgTC/MapiMessage/utc_msg_mms_get_media.c
new file mode 100755 (executable)
index 0000000..806a988
--- /dev/null
@@ -0,0 +1,99 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_get_media.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+MMS_PAGE_S*    page[2];
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+       //------------>  1st Slide Composing
+       page[0] = msg_mms_add_page(mms_data, 5440);
+
+       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+       media[2]->sMedia.sText.nColor = 0x000000;
+       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[2]->sMedia.sText.bBold = true;
+
+       //------------>  2nd Slide Composing
+       page[1] = msg_mms_add_page(mms_data, 4544);
+
+       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+       media[3]->sMedia.sText.nColor = 0x000000;
+       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[3]->sMedia.sText.bItalic = true;
+       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+
+       msg_set_message_type(msgInfo, MSG_TYPE_MMS);
+
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_get_media_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MEDIA_S* tmpMedia = NULL;
+
+       tmpMedia = msg_mms_get_media(page[0], 0);
+       if (tmpMedia == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_get_media_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MEDIA_S* tmpMedia = NULL;
+
+       tmpMedia = msg_mms_get_media(page[0], -1);
+       if (tmpMedia == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_media.h b/TC/msgTC/MapiMessage/utc_msg_mms_get_media.h
new file mode 100755 (executable)
index 0000000..fc3f338
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_get_media_001(void);
+ static void utc_msg_mms_get_media_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_get_media_001,1},
+                       { utc_msg_mms_get_media_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_message_body.c b/TC/msgTC/MapiMessage/utc_msg_mms_get_message_body.c
new file mode 100755 (executable)
index 0000000..e159279
--- /dev/null
@@ -0,0 +1,105 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_get_message_body.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+       MMS_ATTACH_S*   attachment[5];
+       int                             nSize;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       mms_data = msg_mms_create_message();
+
+       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+       //------------>  1st Slide Composing
+       page[0] = msg_mms_add_page(mms_data, 5440);
+
+       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+       media[2]->sMedia.sText.nColor = 0x000000;
+       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[2]->sMedia.sText.bBold = true;
+
+       //------------>  2nd Slide Composing
+       page[1] = msg_mms_add_page(mms_data, 4544);
+
+       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+       media[3]->sMedia.sText.nColor = 0x000000;
+       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[3]->sMedia.sText.bItalic = true;
+       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+
+       msg_set_message_type(msgInfo, MSG_TYPE_MMS);
+
+       msg_mms_set_message_body(msgInfo, mms_data);
+
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_message_id_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MESSAGE_DATA_S body;
+
+       err = msg_mms_get_message_body(msgInfo, &body);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_message_id_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MESSAGE_DATA_S body;
+
+       err = msg_mms_get_message_body(NULL, &body);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_message_body.h b/TC/msgTC/MapiMessage/utc_msg_mms_get_message_body.h
new file mode 100755 (executable)
index 0000000..f8aa1b0
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_message_id_001(void);
+ static void utc_msg_get_message_id_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_message_id_001,1},
+                       { utc_msg_get_message_id_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_meta.c b/TC/msgTC/MapiMessage/utc_msg_mms_get_meta.c
new file mode 100755 (executable)
index 0000000..5baaf29
--- /dev/null
@@ -0,0 +1,99 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_get_meta.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+       //------------>  1st Slide Composing
+       page[0] = msg_mms_add_page(mms_data, 5440);
+
+       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+       media[2]->sMedia.sText.nColor = 0x000000;
+       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[2]->sMedia.sText.bBold = true;
+
+       //------------>  2nd Slide Composing
+       page[1] = msg_mms_add_page(mms_data, 4544);
+
+       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+       media[3]->sMedia.sText.nColor = 0x000000;
+       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[3]->sMedia.sText.bItalic = true;
+       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+
+       MMS_SMIL_META meta = {"id", "name", "content"};
+       msg_mms_add_meta(mms_data, &meta);
+
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_get_meta_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MMS_SMIL_META* pMeta = msg_mms_get_meta(mms_data, 0);
+       if(pMeta == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_get_meta_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MMS_SMIL_META* pMeta = msg_mms_get_meta(mms_data, -1);
+       if(pMeta == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_meta.h b/TC/msgTC/MapiMessage/utc_msg_mms_get_meta.h
new file mode 100755 (executable)
index 0000000..caba6d9
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_get_meta_001(void);
+ static void utc_msg_mms_get_meta_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_get_meta_001,1},
+                       { utc_msg_mms_get_meta_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_page.c b/TC/msgTC/MapiMessage/utc_msg_mms_get_page.c
new file mode 100755 (executable)
index 0000000..f5924a4
--- /dev/null
@@ -0,0 +1,104 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_get_page.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+       //------------>  1st Slide Composing
+       page[0] = msg_mms_add_page(mms_data, 5440);
+
+       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+       media[2]->sMedia.sText.nColor = 0x000000;
+       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[2]->sMedia.sText.bBold = true;
+
+       //------------>  2nd Slide Composing
+       page[1] = msg_mms_add_page(mms_data, 4544);
+
+       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+       media[3]->sMedia.sText.nColor = 0x000000;
+       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[3]->sMedia.sText.bItalic = true;
+       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+}
+
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_get_page_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S* tmpPage = NULL;
+       MMS_MESSAGE_DATA_S msgBody;
+
+       msg_mms_get_message_body(msgInfo, &msgBody);
+
+       tmpPage = msg_mms_get_page(mms_data, 0);
+       if (tmpPage == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_get_page_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S* tmpPage = NULL;
+       MMS_MESSAGE_DATA_S msgBody;
+
+       msg_mms_get_message_body(NULL, &msgBody);
+
+       tmpPage = msg_mms_get_page(mms_data, -1);
+       if (tmpPage == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_page.h b/TC/msgTC/MapiMessage/utc_msg_mms_get_page.h
new file mode 100755 (executable)
index 0000000..045196c
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_get_page_001(void);
+ static void utc_msg_mms_get_page_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_get_page_001,1},
+                       { utc_msg_mms_get_page_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_smil_region.c b/TC/msgTC/MapiMessage/utc_msg_mms_get_smil_region.c
new file mode 100755 (executable)
index 0000000..c799a8b
--- /dev/null
@@ -0,0 +1,95 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_get_smil_region.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+       //------------>  1st Slide Composing
+       page[0] = msg_mms_add_page(mms_data, 5440);
+
+       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+       media[2]->sMedia.sText.nColor = 0x000000;
+       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[2]->sMedia.sText.bBold = true;
+
+       //------------>  2nd Slide Composing
+       page[1] = msg_mms_add_page(mms_data, 4544);
+
+       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+       media[3]->sMedia.sText.nColor = 0x000000;
+       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[3]->sMedia.sText.bItalic = true;
+       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_get_smil_region_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MMS_SMIL_REGION* pRegion = msg_mms_get_smil_region(mms_data, 0);
+       if (pRegion == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_get_smil_region_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MMS_SMIL_REGION* pRegion = msg_mms_get_smil_region(mms_data, -1);
+       if (pRegion == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_smil_region.h b/TC/msgTC/MapiMessage/utc_msg_mms_get_smil_region.h
new file mode 100755 (executable)
index 0000000..f7dbd19
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_get_smil_region_001(void);
+ static void utc_msg_mms_get_smil_region_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_get_smil_region_001,1},
+                       { utc_msg_mms_get_smil_region_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_transition.c b/TC/msgTC/MapiMessage/utc_msg_mms_get_transition.c
new file mode 100755 (executable)
index 0000000..7c03eeb
--- /dev/null
@@ -0,0 +1,101 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_get_transition.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+       //------------>  1st Slide Composing
+       page[0] = msg_mms_add_page(mms_data, 5440);
+
+       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+       media[2]->sMedia.sText.nColor = 0x000000;
+       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[2]->sMedia.sText.bBold = true;
+
+       //------------>  2nd Slide Composing
+       page[1] = msg_mms_add_page(mms_data, 4544);
+
+       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+       media[3]->sMedia.sText.nColor = 0x000000;
+       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[3]->sMedia.sText.bItalic = true;
+       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+
+       MMS_SMIL_TRANSITION transition;
+
+       memset(&transition, 0x00, sizeof(transition));
+
+       msg_mms_add_transition(mms_data, &transition);
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_get_transition_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MMS_SMIL_TRANSITION* pTrans = msg_mms_get_transition(mms_data, 0);
+       if (pTrans == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_get_transition_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MMS_SMIL_TRANSITION* pTrans = msg_mms_get_transition(mms_data, -1);
+       if (pTrans == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_get_transition.h b/TC/msgTC/MapiMessage/utc_msg_mms_get_transition.h
new file mode 100755 (executable)
index 0000000..440f77a
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_get_transition_001(void);
+ static void utc_msg_mms_get_transition_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_get_transition_001,1},
+                       { utc_msg_mms_get_transition_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_set_message_body.c b/TC/msgTC/MapiMessage/utc_msg_mms_set_message_body.c
new file mode 100755 (executable)
index 0000000..b1637e6
--- /dev/null
@@ -0,0 +1,97 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_set_message_body.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+       //------------>  1st Slide Composing
+       page[0] = msg_mms_add_page(mms_data, 5440);
+
+       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+       media[2]->sMedia.sText.nColor = 0x000000;
+       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[2]->sMedia.sText.bBold = true;
+
+       //------------>  2nd Slide Composing
+       page[1] = msg_mms_add_page(mms_data, 4544);
+
+       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+       media[3]->sMedia.sText.nColor = 0x000000;
+       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[3]->sMedia.sText.bItalic = true;
+       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+
+       msg_set_message_type(msgInfo, MSG_TYPE_MMS);
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_set_message_body_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_mms_set_message_body(msgInfo, mms_data);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_set_message_body_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_mms_set_message_body(NULL, mms_data);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_set_message_body.h b/TC/msgTC/MapiMessage/utc_msg_mms_set_message_body.h
new file mode 100755 (executable)
index 0000000..4c8201b
--- /dev/null
@@ -0,0 +1,33 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_set_message_body_001(void);
+ static void utc_msg_mms_set_message_body_002(void);
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_set_message_body_001,1},
+                       { utc_msg_mms_set_message_body_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_set_rootlayout.c b/TC/msgTC/MapiMessage/utc_msg_mms_set_rootlayout.c
new file mode 100755 (executable)
index 0000000..f4c9372
--- /dev/null
@@ -0,0 +1,71 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_set_rootlayout.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MMS_MESSAGE_DATA_S*     mms_data;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+}
+void cleanup(void)
+{
+       msg_mms_destroy_message(mms_data);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_set_rootlayout_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MMS_SMIL_ROOTLAYOUT* pLayout = msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       if (pLayout == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_set_rootlayout_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MMS_SMIL_ROOTLAYOUT* pLayout = msg_mms_set_rootlayout(NULL, 100, 100, 0xffffff);
+       if (pLayout == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_mms_set_rootlayout.h b/TC/msgTC/MapiMessage/utc_msg_mms_set_rootlayout.h
new file mode 100755 (executable)
index 0000000..9bd5632
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_mms_set_rootlayout_001(void);
+ static void utc_msg_mms_set_rootlayout_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_mms_set_rootlayout_001,1},
+                       { utc_msg_mms_set_rootlayout_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_new_message.c b/TC/msgTC/MapiMessage/utc_msg_new_message.c
new file mode 100755 (executable)
index 0000000..c233775
--- /dev/null
@@ -0,0 +1,64 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_new_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_new_message_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       msgInfo = msg_new_message();
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_new_message_002()
+{
+       MSG_ERROR_T err = -1;
+
+       msgInfo = msg_new_message();
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_new_message.h b/TC/msgTC/MapiMessage/utc_msg_new_message.h
new file mode 100755 (executable)
index 0000000..9a9c81f
--- /dev/null
@@ -0,0 +1,35 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_new_message_001(void);
+static void utc_msg_new_message_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_new_message_001,1},
+                       { utc_msg_new_message_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiMessage/utc_msg_release_message.c b/TC/msgTC/MapiMessage/utc_msg_release_message.c
new file mode 100755 (executable)
index 0000000..af43669
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_release_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_release_message_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_release_message(msgInfo);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_release_message_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_release_message(NULL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_release_message.h b/TC/msgTC/MapiMessage/utc_msg_release_message.h
new file mode 100755 (executable)
index 0000000..f4d9a63
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_release_message_001(void);
+ static void utc_msg_release_message_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_release_message_001,1},
+                       { utc_msg_release_message_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_reset_address.c b/TC/msgTC/MapiMessage/utc_msg_reset_address.c
new file mode 100755 (executable)
index 0000000..a2cc4c2
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_reset_address.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_reset_address_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_reset_address(msgInfo);
+       if (err)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_reset_address_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_reset_address(NULL);
+       if (err)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_reset_address.h b/TC/msgTC/MapiMessage/utc_msg_reset_address.h
new file mode 100755 (executable)
index 0000000..ba7d677
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_reset_address_001(void);
+ static void utc_msg_reset_address_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_reset_address_001,1},
+                       { utc_msg_reset_address_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_direction_info.c b/TC/msgTC/MapiMessage/utc_msg_set_direction_info.c
new file mode 100755 (executable)
index 0000000..56e1c50
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_direction_info.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_direction_info_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_direction_info(msgInfo, MSG_DIRECTION_TYPE_MT);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_direction_info_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_direction_info(NULL, MSG_DIRECTION_TYPE_MT);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_direction_info.h b/TC/msgTC/MapiMessage/utc_msg_set_direction_info.h
new file mode 100755 (executable)
index 0000000..9e337bd
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_direction_info_001(void);
+ static void utc_msg_set_direction_info_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_direction_info_001,1},
+                       { utc_msg_set_direction_info_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_encode_type.c b/TC/msgTC/MapiMessage/utc_msg_set_encode_type.c
new file mode 100755 (executable)
index 0000000..235136e
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_encode_type.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_encode_type_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_encode_type(msgInfo, MSG_ENCODE_GSM7BIT);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_encode_type_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_encode_type(NULL, MSG_ENCODE_GSM7BIT);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_encode_type.h b/TC/msgTC/MapiMessage/utc_msg_set_encode_type.h
new file mode 100755 (executable)
index 0000000..78ca9f6
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_encode_type_001(void);
+ static void utc_msg_set_encode_type_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_encode_type_001,1},
+                       { utc_msg_set_encode_type_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_folder_id.c b/TC/msgTC/MapiMessage/utc_msg_set_folder_id.c
new file mode 100755 (executable)
index 0000000..4477be0
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_folder_id.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_folder_id_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_folder_id(msgInfo, MSG_INBOX_ID);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_folder_id_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_folder_id(NULL, MSG_INBOX_ID);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_folder_id.h b/TC/msgTC/MapiMessage/utc_msg_set_folder_id.h
new file mode 100755 (executable)
index 0000000..141ad03
--- /dev/null
@@ -0,0 +1,35 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MsgStorageTypes.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_folder_id_001(void);
+ static void utc_msg_set_folder_id_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_folder_id_001,1},
+                       { utc_msg_set_folder_id_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_message_id.c b/TC/msgTC/MapiMessage/utc_msg_set_message_id.c
new file mode 100755 (executable)
index 0000000..c57a5c4
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_message_id.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_message_id_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_message_id(msgInfo, 1);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_message_id_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_message_id(NULL, 1);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_message_id.h b/TC/msgTC/MapiMessage/utc_msg_set_message_id.h
new file mode 100755 (executable)
index 0000000..5fc1f6f
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_message_id_001(void);
+ static void utc_msg_set_message_id_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_message_id_001,1},
+                       { utc_msg_set_message_id_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_message_type.c b/TC/msgTC/MapiMessage/utc_msg_set_message_type.c
new file mode 100755 (executable)
index 0000000..6fcf782
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_message_type.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_message_type_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_message_type(msgInfo, MSG_TYPE_SMS);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_message_type_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_message_type(NULL, MSG_TYPE_SMS);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_message_type.h b/TC/msgTC/MapiMessage/utc_msg_set_message_type.h
new file mode 100755 (executable)
index 0000000..1b400d6
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_message_type_001(void);
+ static void utc_msg_set_message_type_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_message_type_001,1},
+                       { utc_msg_set_message_type_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_network_status.c b/TC/msgTC/MapiMessage/utc_msg_set_network_status.c
new file mode 100755 (executable)
index 0000000..5cab121
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_network_status.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_network_status_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_network_status(msgInfo, MSG_NETWORK_SEND_SUCCESS);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_network_status_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_network_status(NULL, MSG_NETWORK_SEND_SUCCESS);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_network_status.h b/TC/msgTC/MapiMessage/utc_msg_set_network_status.h
new file mode 100755 (executable)
index 0000000..7418f95
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_network_status_001(void);
+ static void utc_msg_set_network_status_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_network_status_001,1},
+                       { utc_msg_set_network_status_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_port.c b/TC/msgTC/MapiMessage/utc_msg_set_port.c
new file mode 100755 (executable)
index 0000000..4c90148
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_port.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_port_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_port(msgInfo, 656, 656);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_port_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_port(NULL, 656, 656);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_port.h b/TC/msgTC/MapiMessage/utc_msg_set_port.h
new file mode 100755 (executable)
index 0000000..3d71a1c
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_port_001(void);
+ static void utc_msg_set_port_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_port_001,1},
+                       { utc_msg_set_port_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_priority_info.c b/TC/msgTC/MapiMessage/utc_msg_set_priority_info.c
new file mode 100755 (executable)
index 0000000..8d01de0
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_priority_info.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_priority_info_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_priority_info(msgInfo, MSG_MESSAGE_PRIORITY_NORMAL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_priority_info_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_priority_info(NULL, MSG_MESSAGE_PRIORITY_NORMAL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_priority_info.h b/TC/msgTC/MapiMessage/utc_msg_set_priority_info.h
new file mode 100755 (executable)
index 0000000..b95c18d
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_priority_info_001(void);
+ static void utc_msg_set_priority_info_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_priority_info_001,1},
+                       { utc_msg_set_priority_info_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_protect_status.c b/TC/msgTC/MapiMessage/utc_msg_set_protect_status.c
new file mode 100755 (executable)
index 0000000..e69d84d
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_protect_status.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_protect_status_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_protect_status(msgInfo, true);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_protect_status_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_protect_status(NULL, true);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_protect_status.h b/TC/msgTC/MapiMessage/utc_msg_set_protect_status.h
new file mode 100755 (executable)
index 0000000..b6e797a
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_protect_status_001(void);
+ static void utc_msg_set_protect_status_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_protect_status_001,1},
+                       { utc_msg_set_protect_status_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_read_status.c b/TC/msgTC/MapiMessage/utc_msg_set_read_status.c
new file mode 100755 (executable)
index 0000000..cd92d34
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_read_status.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_read_status_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_read_status(msgInfo, true);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_read_status_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_read_status(NULL, true);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_read_status.h b/TC/msgTC/MapiMessage/utc_msg_set_read_status.h
new file mode 100755 (executable)
index 0000000..89c9392
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_read_status_001(void);
+ static void utc_msg_set_read_status_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_read_status_001,1},
+                       { utc_msg_set_read_status_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_scheduled_time.c b/TC/msgTC/MapiMessage/utc_msg_set_scheduled_time.c
new file mode 100755 (executable)
index 0000000..77c4b6e
--- /dev/null
@@ -0,0 +1,72 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_scheduled_time.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_scheduled_time_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       time_t scheduledTime;
+       time(&scheduledTime);
+
+       err = msg_set_scheduled_time(msgInfo, scheduledTime);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_scheduled_time_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       time_t scheduledTime;
+       time(&scheduledTime);
+
+       err = msg_set_scheduled_time(NULL, scheduledTime);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_scheduled_time.h b/TC/msgTC/MapiMessage/utc_msg_set_scheduled_time.h
new file mode 100755 (executable)
index 0000000..8e0051c
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_scheduled_time_001(void);
+ static void utc_msg_set_scheduled_time_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_scheduled_time_001,1},
+                       { utc_msg_set_scheduled_time_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_storage_id.c b/TC/msgTC/MapiMessage/utc_msg_set_storage_id.c
new file mode 100755 (executable)
index 0000000..f835cbc
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_storage_id.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_storage_id_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_storage_id(msgInfo, MSG_STORAGE_PHONE);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_storage_id_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_storage_id(NULL, MSG_STORAGE_PHONE);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_storage_id.h b/TC/msgTC/MapiMessage/utc_msg_set_storage_id.h
new file mode 100755 (executable)
index 0000000..5942c72
--- /dev/null
@@ -0,0 +1,35 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MsgStorageTypes.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_storage_id_001(void);
+ static void utc_msg_set_storage_id_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_storage_id_001,1},
+                       { utc_msg_set_storage_id_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_subject.c b/TC/msgTC/MapiMessage/utc_msg_set_subject.c
new file mode 100755 (executable)
index 0000000..66eaac1
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_subject.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_subject_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_subject(msgInfo, "test subject");
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_subject_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_subject(NULL, "test subject");
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_subject.h b/TC/msgTC/MapiMessage/utc_msg_set_subject.h
new file mode 100755 (executable)
index 0000000..7485c75
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_subject_001(void);
+ static void utc_msg_set_subject_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_subject_001,1},
+                       { utc_msg_set_subject_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_time.c b/TC/msgTC/MapiMessage/utc_msg_set_time.c
new file mode 100755 (executable)
index 0000000..884e4df
--- /dev/null
@@ -0,0 +1,70 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_time.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_time_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       time_t curTime = time(NULL);
+
+       err = msg_set_time(msgInfo, curTime);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_time_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       time_t curTime = time(NULL);
+
+       err = msg_set_time(NULL, curTime);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_set_time.h b/TC/msgTC/MapiMessage/utc_msg_set_time.h
new file mode 100755 (executable)
index 0000000..1a6f132
--- /dev/null
@@ -0,0 +1,33 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_time_001(void);
+ static void utc_msg_set_time_002(void);
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_time_001,1},
+                       { utc_msg_set_time_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_sms_get_message_body.c b/TC/msgTC/MapiMessage/utc_msg_sms_get_message_body.c
new file mode 100755 (executable)
index 0000000..bdb5e5d
--- /dev/null
@@ -0,0 +1,70 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_sms_get_message_body.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       msg_sms_set_message_body(msgInfo, "test message", 12);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_sms_get_message_body_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       char * address = NULL;
+
+       address = msg_sms_get_message_body(msgInfo);
+       if (address == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_sms_get_message_body_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       char * address = NULL;
+
+       address = msg_sms_get_message_body(NULL);
+       if (address == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_sms_get_message_body.h b/TC/msgTC/MapiMessage/utc_msg_sms_get_message_body.h
new file mode 100755 (executable)
index 0000000..8756de0
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_sms_get_message_body_001(void);
+ static void utc_msg_sms_get_message_body_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_sms_get_message_body_001,1},
+                       { utc_msg_sms_get_message_body_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiMessage/utc_msg_sms_set_message_body.c b/TC/msgTC/MapiMessage/utc_msg_sms_set_message_body.c
new file mode 100755 (executable)
index 0000000..4169921
--- /dev/null
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_sms_set_message_body.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_sms_set_message_body_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_sms_set_message_body(msgInfo, "test message", 12);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_sms_set_message_body_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_sms_set_message_body(NULL, "test message", 12);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiMessage/utc_msg_sms_set_message_body.h b/TC/msgTC/MapiMessage/utc_msg_sms_set_message_body.h
new file mode 100755 (executable)
index 0000000..f2fdb2b
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_sms_set_message_body_001(void);
+ static void utc_msg_sms_set_message_body_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_sms_set_message_body_001,1},
+                       { utc_msg_sms_set_message_body_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiSetting/Makefile b/TC/msgTC/MapiSetting/Makefile
new file mode 100755 (executable)
index 0000000..1be4616
--- /dev/null
@@ -0,0 +1,52 @@
+###################################################
+# add your TestCase List Here
+#
+# e.g.,
+# TC1 = utc_frameworkName_apiName_func
+# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
+TC1 = utc_msg_get_config
+TC2 = utc_msg_set_config
+       
+###################################################
+# add your Package Config Info Here
+#
+# e.g.,
+# PKGS=calendar
+PKGS=msg-service
+
+LIBS  = `pkg-config --libs $(PKGS)` 
+LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
+LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
+LIBS +=-L$(TET_ROOT)/lib/tet3 -lapi_s
+
+INCS  =  -I. `pkg-config --cflags $(PKGS)`
+INCS  += -I$(TET_ROOT)/inc/tet3 
+
+CFLAGS = $(INCS)
+CFLAGS += -D_TETWARE_MODE
+#CC +=$(CFLAGS)
+LDFLAGS = $(LIBS)
+
+###################################################
+# Modify here 
+# depending on the Test Case you want to build
+# 
+# e.g.,
+# TCLIST = $(TC1) $(TC2)
+TCLIST = $(TC1) $(TC2) 
+all :
+       for testcase in $(TCLIST) do\
+               $(CC) -o $$(testcase) $$(testcase).c $(CFLAGS) $(LDFLAGS)
+       done
+
+clean :
+       rm -rf *~ *.o $(TCLIST)
+
+
+$(TC1) : 
+       $(CC) -o $(TC1) $(TC1).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC2) : 
+       $(CC) -o $(TC2) $(TC2).c  $(CFLAGS) $(LDFLAGS)
diff --git a/TC/msgTC/MapiSetting/tslist b/TC/msgTC/MapiSetting/tslist
new file mode 100755 (executable)
index 0000000..00c37f8
--- /dev/null
@@ -0,0 +1,2 @@
+utc_msg_get_config\r
+utc_msg_set_config
\ No newline at end of file
diff --git a/TC/msgTC/MapiSetting/utc_msg_get_config.c b/TC/msgTC/MapiSetting/utc_msg_get_config.c
new file mode 100755 (executable)
index 0000000..b431a2c
--- /dev/null
@@ -0,0 +1,67 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_config.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+MSG_SETTING_S setting;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       memset(&setting, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_GENERAL_OPT_S));
+
+       setting.type = MSG_GENERAL_OPT;
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_config_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_config(msgHandle, &setting);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_config_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_config(NULL, &setting);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiSetting/utc_msg_get_config.h b/TC/msgTC/MapiSetting/utc_msg_get_config.h
new file mode 100755 (executable)
index 0000000..30acbcf
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiSetting.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_get_config_001(void);
+ static void utc_msg_get_config_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_get_config_001,1},
+                       { utc_msg_get_config_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiSetting/utc_msg_set_config.c b/TC/msgTC/MapiSetting/utc_msg_set_config.c
new file mode 100755 (executable)
index 0000000..1b1ab5d
--- /dev/null
@@ -0,0 +1,69 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_set_config.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+MSG_SETTING_S setting;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       memset(&setting, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_GENERAL_OPT_S));
+
+       setting.type = MSG_GENERAL_OPT;
+
+       msg_get_config(msgHandle, &setting);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_set_config_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_config(msgHandle, &setting);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_set_config_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_set_config(NULL, &setting);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiSetting/utc_msg_set_config.h b/TC/msgTC/MapiSetting/utc_msg_set_config.h
new file mode 100755 (executable)
index 0000000..71560ce
--- /dev/null
@@ -0,0 +1,34 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiSetting.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ static void utc_msg_set_config_001(void);
+ static void utc_msg_set_config_002(void);
+
+
+
+ struct tet_testlist tet_testlist[] =  {
+                       { utc_msg_set_config_001,1},
+                       { utc_msg_set_config_002,2},
+                       {NULL,0}
+ };
diff --git a/TC/msgTC/MapiStorage/Makefile b/TC/msgTC/MapiStorage/Makefile
new file mode 100755 (executable)
index 0000000..c2ce1d9
--- /dev/null
@@ -0,0 +1,195 @@
+###################################################
+# add your TestCase List Here
+#
+# e.g.,
+# TC1 = utc_frameworkName_apiName_func
+# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
+TC1 = utc_msg_add_folder
+TC2 = utc_msg_add_message
+TC3 = utc_msg_get_conversation_view_list
+TC4 = utc_msg_add_syncml_message
+TC5 = utc_msg_get_folder_list
+TC7 = utc_msg_get_folder_view_list
+TC8 = utc_msg_get_mem_size
+TC9 = utc_msg_get_message
+TC10 = utc_msg_get_quick_panel_data
+TC11 = utc_msg_get_thread_view_list
+TC12 = utc_msg_move_msg_to_folder
+TC13 = utc_msg_move_msg_to_storage
+TC14 = utc_msg_release_folder_list
+TC15 = utc_msg_release_thread_view_list
+TC16 = utc_msg_reset_database
+TC17 = utc_msg_count_message
+TC19 = utc_msg_count_msg_by_contact
+TC20 = utc_msg_thread_view_get_address
+TC21 = utc_msg_count_msg_by_type
+TC22 = utc_msg_thread_view_get_contact_id
+TC23 = utc_msg_delete_all_msgs_in_folder
+TC24 = utc_msg_thread_view_get_data
+TC25 = utc_msg_delete_folder
+TC26 = utc_msg_thread_view_get_direction
+TC27 = utc_msg_delete_message
+TC28 = utc_msg_thread_view_get_image_path
+TC29 = utc_msg_delete_thread_message_list
+TC30 = utc_msg_thread_view_get_mms_cnt
+TC31 = utc_msg_thread_view_get_name
+TC32 = utc_msg_thread_view_get_sms_cnt
+TC33 = utc_msg_thread_view_get_thread_id
+TC34 = utc_msg_thread_view_get_time
+TC35 = utc_msg_thread_view_get_unread_cnt
+TC36 = utc_msg_update_folder
+TC37 = utc_msg_update_message
+TC38 = utc_msg_update_protected_status
+TC39 = utc_msg_update_read_status
+TC40 = utc_msg_generate_message
+       
+###################################################
+# add your Package Config Info Here
+#
+# e.g.,
+# PKGS=calendar
+PKGS=msg-service
+
+LIBS  = `pkg-config --libs $(PKGS)` 
+LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
+LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
+LIBS +=-L$(TET_ROOT)/lib/tet3 -lapi_s
+
+INCS  =  -I. `pkg-config --cflags $(PKGS)`
+INCS  += -I$(TET_ROOT)/inc/tet3 
+
+CFLAGS = $(INCS)
+CFLAGS += -D_TETWARE_MODE
+#CC +=$(CFLAGS)
+LDFLAGS = $(LIBS)
+
+###################################################
+# Modify here 
+# depending on the Test Case you want to build
+# 
+# e.g.,
+# TCLIST = $(TC1) $(TC2)
+TCLIST = $(TC1) $(TC2) $(TC3) $(TC4) $(TC5) $(TC7) $(TC8) $(TC9) $(TC10) $(TC11) $(TC12) $(TC13) $(TC14) $(TC15) $(TC16) $(TC17) $(TC19) $(TC20) $(TC21) $(TC22) $(TC23) $(TC24) $(TC25) $(TC26) $(TC27) $(TC28) $(TC29) $(TC30) $(TC31) $(TC32) $(TC33) $(TC34) $(TC35) $(TC36) $(TC37) $(TC38) $(TC39) $(TC40)
+all :
+       for testcase in $(TCLIST) do\
+               $(CC) -o $$(testcase) $$(testcase).c $(CFLAGS) $(LDFLAGS)
+       done
+
+clean :
+       rm -rf *~ *.o $(TCLIST)
+
+
+$(TC1) : 
+       $(CC) -o $(TC1) $(TC1).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC2) : 
+       $(CC) -o $(TC2) $(TC2).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC3) : 
+       $(CC) -o $(TC3) $(TC3).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC4) : 
+       $(CC) -o $(TC4) $(TC4).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC5) : 
+       $(CC) -o $(TC5) $(TC5).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC7) : 
+       $(CC) -o $(TC7) $(TC7).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC8) : 
+       $(CC) -o $(TC8) $(TC8).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC9) : 
+       $(CC) -o $(TC9) $(TC9).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC10) : 
+       $(CC) -o $(TC10) $(TC10).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC11) : 
+       $(CC) -o $(TC11) $(TC11).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC12) : 
+       $(CC) -o $(TC12) $(TC12).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC13) : 
+       $(CC) -o $(TC13) $(TC13).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC14) : 
+       $(CC) -o $(TC14) $(TC14).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC15) : 
+       $(CC) -o $(TC15) $(TC15).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC16) : 
+       $(CC) -o $(TC16) $(TC16).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC17) : 
+       $(CC) -o $(TC17) $(TC17).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC19) : 
+       $(CC) -o $(TC19) $(TC19).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC20) : 
+       $(CC) -o $(TC20) $(TC20).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC21) : 
+       $(CC) -o $(TC21) $(TC21).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC22) : 
+       $(CC) -o $(TC22) $(TC22).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC23) : 
+       $(CC) -o $(TC23) $(TC23).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC24) : 
+       $(CC) -o $(TC24) $(TC24).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC25) : 
+       $(CC) -o $(TC25) $(TC25).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC26) : 
+       $(CC) -o $(TC26) $(TC26).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC27) : 
+       $(CC) -o $(TC27) $(TC27).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC28) : 
+       $(CC) -o $(TC28) $(TC28).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC29) : 
+       $(CC) -o $(TC29) $(TC29).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC30) : 
+       $(CC) -o $(TC30) $(TC30).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC31) : 
+       $(CC) -o $(TC31) $(TC31).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC32) : 
+       $(CC) -o $(TC32) $(TC32).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC33) : 
+       $(CC) -o $(TC33) $(TC33).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC34) : 
+       $(CC) -o $(TC34) $(TC34).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC35) : 
+       $(CC) -o $(TC35) $(TC35).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC36) : 
+       $(CC) -o $(TC36) $(TC36).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC37) : 
+       $(CC) -o $(TC37) $(TC37).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC38) : 
+       $(CC) -o $(TC38) $(TC38).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC39) : 
+       $(CC) -o $(TC39) $(TC39).c  $(CFLAGS) $(LDFLAGS)
+
+$(TC40) : 
+       $(CC) -o $(TC40) $(TC40).c  $(CFLAGS) $(LDFLAGS)
diff --git a/TC/msgTC/MapiStorage/tslist b/TC/msgTC/MapiStorage/tslist
new file mode 100755 (executable)
index 0000000..b515aea
--- /dev/null
@@ -0,0 +1,40 @@
+utc_msg_add_folder                        \r
+utc_msg_add_message                       \r
+utc_msg_get_conversation_view_list\r
+utc_msg_add_syncml_message                \r
+utc_msg_get_folder_list\r
+utc_msg_backup_message                    \r
+utc_msg_get_folder_view_list\r
+utc_msg_get_mem_size\r
+utc_msg_get_message\r
+utc_msg_get_quick_panel_data\r
+utc_msg_get_thread_view_list\r
+utc_msg_move_msg_to_folder\r
+utc_msg_move_msg_to_storage\r
+utc_msg_release_folder_list\r
+utc_msg_release_thread_view_list\r
+utc_msg_reset_database\r
+utc_msg_generate_message   \r
+utc_msg_count_message                     \r
+utc_msg_restore_message\r
+utc_msg_count_msg_by_contact              \r
+utc_msg_thread_view_get_address\r
+utc_msg_count_msg_by_type                 \r
+utc_msg_thread_view_get_contact_id\r
+utc_msg_delete_all_msgs_in_folder         \r
+utc_msg_thread_view_get_data\r
+utc_msg_delete_folder                     \r
+utc_msg_thread_view_get_direction\r
+utc_msg_delete_message                    \r
+utc_msg_thread_view_get_image_path\r
+utc_msg_delete_thread_message_list        \r
+utc_msg_thread_view_get_mms_cnt\r
+utc_msg_thread_view_get_name\r
+utc_msg_thread_view_get_sms_cnt\r
+utc_msg_thread_view_get_thread_id\r
+utc_msg_thread_view_get_time\r
+utc_msg_thread_view_get_unread_cnt\r
+utc_msg_update_folder\r
+utc_msg_update_message\r
+utc_msg_update_protected_status\r
+utc_msg_update_read_status
\ No newline at end of file
diff --git a/TC/msgTC/MapiStorage/utc_msg_add_folder.c b/TC/msgTC/MapiStorage/utc_msg_add_folder.c
new file mode 100755 (executable)
index 0000000..0fd5791
--- /dev/null
@@ -0,0 +1,91 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_add_folder.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_add_folder_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_FOLDER_INFO_S folderInfo;
+
+       memset(&folderInfo, 0x00, sizeof(folderInfo));
+
+       folderInfo.folderId = 10;
+       folderInfo.folderType = MSG_FOLDER_TYPE_USER_DEF;
+
+       strncpy(folderInfo.folderName, "Test folder", MAX_FOLDER_NAME_SIZE);
+
+       err = msg_add_folder(msgHandle, &folderInfo);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_add_folder_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_FOLDER_INFO_S folderInfo;
+
+       memset(&folderInfo, 0x00, sizeof(folderInfo));
+
+       folderInfo.folderId = 10;
+       folderInfo.folderType = MSG_FOLDER_TYPE_USER_DEF;
+
+       strncpy(folderInfo.folderName, "Test folder", MAX_FOLDER_NAME_SIZE);
+
+       err = msg_add_folder(NULL, &folderInfo);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_add_folder.h b/TC/msgTC/MapiStorage/utc_msg_add_folder.h
new file mode 100755 (executable)
index 0000000..0859539
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_add_folder_001(void);
+static void utc_msg_add_folder_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_add_folder_001,1},
+                       { utc_msg_add_folder_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_add_message.c b/TC/msgTC/MapiStorage/utc_msg_add_message.c
new file mode 100755 (executable)
index 0000000..ab6bebf
--- /dev/null
@@ -0,0 +1,73 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_add_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_add_message_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_add_message(msgHandle, msgInfo, &sendOpt);
+       if (err < MSG_SUCCESS)
+       {
+               tet_printf("msg_add_message fail [%d]", err);
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_add_message_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_add_message(NULL, msgInfo, &sendOpt);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_printf("msg_add_message success [%d]", err);
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_add_message.h b/TC/msgTC/MapiStorage/utc_msg_add_message.h
new file mode 100755 (executable)
index 0000000..2ce5083
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_add_message_001(void);
+static void utc_msg_add_message_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_add_message_001,1},
+                       { utc_msg_add_message_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_add_syncml_message.c b/TC/msgTC/MapiStorage/utc_msg_add_syncml_message.c
new file mode 100755 (executable)
index 0000000..8fc5131
--- /dev/null
@@ -0,0 +1,84 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_add_syncml_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SYNCML_MESSAGE_S syncMLMsg;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&syncMLMsg, 0x00, sizeof(MSG_SYNCML_MESSAGE_S));
+
+       syncMLMsg.extId = 11;
+       syncMLMsg.pinCode = 1111;
+
+       syncMLMsg.msg = msg_new_message();
+
+       msg_set_folder_id(syncMLMsg.msg, MSG_INBOX_ID);
+       msg_set_message_type(syncMLMsg.msg, MSG_TYPE_SMS_SYNCML);
+       msg_set_network_status(syncMLMsg.msg, MSG_NETWORK_RECEIVED);
+       msg_set_direction_info(syncMLMsg.msg, MSG_DIRECTION_TYPE_MT);
+
+       msg_add_address(syncMLMsg.msg, "+1004", MSG_RECIPIENTS_TYPE_TO);
+
+       char msg_body[]="SyncML Message";
+       msg_sms_set_message_body(syncMLMsg.msg, msg_body, strlen(msg_body));
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_add_syncml_message_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_add_syncml_message(msgHandle, &syncMLMsg);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_add_syncml_message_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_add_syncml_message(NULL, &syncMLMsg);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_add_syncml_message.h b/TC/msgTC/MapiStorage/utc_msg_add_syncml_message.h
new file mode 100755 (executable)
index 0000000..ab23564
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_add_syncml_message_001(void);
+static void utc_msg_add_syncml_message_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_add_syncml_message_001,1},
+                       { utc_msg_add_syncml_message_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_count_message.c b/TC/msgTC/MapiStorage/utc_msg_count_message.c
new file mode 100755 (executable)
index 0000000..31eb04a
--- /dev/null
@@ -0,0 +1,77 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_count_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_COUNT_INFO_S count_info;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+       memset(&count_info, 0x00, sizeof(count_info));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_count_message_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_count_message(msgHandle, MSG_DRAFT_ID, &count_info);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_count_message_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_count_message(NULL, MSG_DRAFT_ID, &count_info);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_count_message.h b/TC/msgTC/MapiStorage/utc_msg_count_message.h
new file mode 100755 (executable)
index 0000000..f2ec68a
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_count_message_001(void);
+static void utc_msg_count_message_001(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_count_message_001,1},
+                       { utc_msg_count_message_001,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_count_msg_by_contact.c b/TC/msgTC/MapiStorage/utc_msg_count_msg_by_contact.c
new file mode 100755 (executable)
index 0000000..0ef1233
--- /dev/null
@@ -0,0 +1,85 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_count_msg_by_contact.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_count_msg_by_contact_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_THREAD_LIST_INDEX_S addr_info;
+       MSG_THREAD_COUNT_INFO_S msg_thread_count_list;
+
+       memset(&addr_info, 0x00, sizeof(addr_info));
+       memset(&msg_thread_count_list, 0x00, sizeof(msg_thread_count_list));
+
+       err = msg_count_msg_by_contact(msgHandle, &addr_info, &msg_thread_count_list);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_count_msg_by_contact_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_THREAD_LIST_INDEX_S addr_info;
+       MSG_THREAD_COUNT_INFO_S msg_thread_count_list;
+
+       memset(&addr_info, 0x00, sizeof(addr_info));
+       memset(&msg_thread_count_list, 0x00, sizeof(msg_thread_count_list));
+
+       err = msg_count_msg_by_contact(NULL, &addr_info, &msg_thread_count_list);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_count_msg_by_contact.h b/TC/msgTC/MapiStorage/utc_msg_count_msg_by_contact.h
new file mode 100755 (executable)
index 0000000..24d8c97
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_count_msg_by_contact_001(void);
+static void utc_msg_count_msg_by_contact_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_count_msg_by_contact_001,1},
+                       { utc_msg_count_msg_by_contact_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_count_msg_by_type.c b/TC/msgTC/MapiStorage/utc_msg_count_msg_by_type.c
new file mode 100755 (executable)
index 0000000..8fff138
--- /dev/null
@@ -0,0 +1,77 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_count_msg_by_type.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_update_message_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       int count = 0;
+
+       err = msg_count_msg_by_type(msgHandle, MSG_TYPE_SMS, &count);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_update_message_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       int count = 0;
+
+       err = msg_count_msg_by_type(NULL, MSG_TYPE_SMS, &count);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_count_msg_by_type.h b/TC/msgTC/MapiStorage/utc_msg_count_msg_by_type.h
new file mode 100755 (executable)
index 0000000..2eb70cc
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_update_message_001(void);
+static void utc_msg_update_message_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_update_message_001,1},
+                       { utc_msg_update_message_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_delete_all_msgs_in_folder.c b/TC/msgTC/MapiStorage/utc_msg_delete_all_msgs_in_folder.c
new file mode 100755 (executable)
index 0000000..92e4931
--- /dev/null
@@ -0,0 +1,75 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_delete_all_msgs_in_folder.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_delete_all_msgs_in_folder_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_delete_all_msgs_in_folder(msgHandle, MSG_DRAFT_ID, true);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_delete_all_msgs_in_folder_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_delete_all_msgs_in_folder(NULL, MSG_DRAFT_ID, true);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_delete_all_msgs_in_folder.h b/TC/msgTC/MapiStorage/utc_msg_delete_all_msgs_in_folder.h
new file mode 100755 (executable)
index 0000000..13a43bb
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_delete_all_msgs_in_folder_001(void);
+static void utc_msg_delete_all_msgs_in_folder_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_delete_all_msgs_in_folder_001,1},
+                       { utc_msg_delete_all_msgs_in_folder_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_delete_folder.c b/TC/msgTC/MapiStorage/utc_msg_delete_folder.c
new file mode 100755 (executable)
index 0000000..342308f
--- /dev/null
@@ -0,0 +1,75 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_delete_folder.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_delete_folder_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_delete_folder(msgHandle, 10);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_delete_folder_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_delete_folder(NULL, 10);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_delete_folder.h b/TC/msgTC/MapiStorage/utc_msg_delete_folder.h
new file mode 100755 (executable)
index 0000000..315faf2
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_delete_folder_001(void);
+static void utc_msg_delete_folder_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_delete_folder_001,1},
+                       { utc_msg_delete_folder_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_delete_message.c b/TC/msgTC/MapiStorage/utc_msg_delete_message.c
new file mode 100755 (executable)
index 0000000..c0acaa5
--- /dev/null
@@ -0,0 +1,82 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_delete_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+int msgId = 0;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_LIST_S folder_list;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       msg_get_folder_view_list(msgHandle, MSG_DRAFT_ID, NULL, &folder_list);
+
+       msgId = msg_get_message_id(folder_list.msgInfo[0]);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_delete_message_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_delete_message(msgHandle, msgId);
+       if (err != MSG_SUCCESS)
+       {
+               tet_printf("err is [%d]", err);
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_delete_message_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_delete_message(NULL, msgId);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_delete_message.h b/TC/msgTC/MapiStorage/utc_msg_delete_message.h
new file mode 100755 (executable)
index 0000000..7c473a9
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_delete_message_001(void);
+static void utc_msg_delete_message_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_delete_message_001,1},
+                       { utc_msg_delete_message_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_delete_thread_message_list.c b/TC/msgTC/MapiStorage/utc_msg_delete_thread_message_list.c
new file mode 100755 (executable)
index 0000000..e3030bd
--- /dev/null
@@ -0,0 +1,75 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_delete_thread_message_list.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_delete_thread_message_list_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_delete_thread_message_list(msgHandle, 0);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_delete_thread_message_list_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_delete_thread_message_list(NULL, 0);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_delete_thread_message_list.h b/TC/msgTC/MapiStorage/utc_msg_delete_thread_message_list.h
new file mode 100755 (executable)
index 0000000..882be33
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_delete_thread_message_list_001(void);
+static void utc_msg_delete_thread_message_list_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_delete_thread_message_list_001,1},
+                       { utc_msg_delete_thread_message_list_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_generate_message.c b/TC/msgTC/MapiStorage/utc_msg_generate_message.c
new file mode 100755 (executable)
index 0000000..4a11c7e
--- /dev/null
@@ -0,0 +1,65 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_generate_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_generate_message_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_generate_message(msgHandle, MSG_TYPE_SMS, MSG_DRAFT_ID, 10);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_generate_message_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_generate_message(NULL, MSG_TYPE_SMS, MSG_DRAFT_ID, 10);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_generate_message.h b/TC/msgTC/MapiStorage/utc_msg_generate_message.h
new file mode 100755 (executable)
index 0000000..a155a78
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_generate_message_001(void);
+static void utc_msg_generate_message_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_generate_message_001,1},
+                       { utc_msg_generate_message_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_conversation_view_list.c b/TC/msgTC/MapiStorage/utc_msg_get_conversation_view_list.c
new file mode 100755 (executable)
index 0000000..5d3ebe8
--- /dev/null
@@ -0,0 +1,82 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_conversation_view_list.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_conversation_view_list_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_LIST_S msg_conv_view_list;
+
+       memset(&msg_conv_view_list, 0x00, sizeof(msg_conv_view_list));
+
+       err = msg_get_conversation_view_list(msgHandle, 0, &msg_conv_view_list);
+       msg_release_message_list(&msg_conv_view_list);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_conversation_view_list_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_LIST_S msg_conv_view_list;
+
+       memset(&msg_conv_view_list, 0x00, sizeof(msg_conv_view_list));
+
+       err = msg_get_conversation_view_list(NULL, 0, &msg_conv_view_list);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_conversation_view_list.h b/TC/msgTC/MapiStorage/utc_msg_get_conversation_view_list.h
new file mode 100755 (executable)
index 0000000..03bd68c
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_get_conversation_view_list_001(void);
+static void utc_msg_get_conversation_view_list_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_get_conversation_view_list_001,1},
+                       { utc_msg_get_conversation_view_list_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_folder_list.c b/TC/msgTC/MapiStorage/utc_msg_get_folder_list.c
new file mode 100755 (executable)
index 0000000..013d0a1
--- /dev/null
@@ -0,0 +1,83 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_folder_list.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_folder_list_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_FOLDER_LIST_S folder_list;
+
+       memset(&folder_list, 0x00, sizeof(folder_list));
+
+       err = msg_get_folder_list(msgHandle, &folder_list);
+       msg_release_folder_list(&folder_list);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_folder_list_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_FOLDER_LIST_S folder_list;
+
+       memset(&folder_list, 0x00, sizeof(folder_list));
+
+       err = msg_get_folder_list(NULL, &folder_list);
+       msg_release_folder_list(&folder_list);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_folder_list.h b/TC/msgTC/MapiStorage/utc_msg_get_folder_list.h
new file mode 100755 (executable)
index 0000000..d5ab1c6
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_get_folder_list_001(void);
+static void utc_msg_get_folder_list_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_get_folder_list_001,1},
+                       { utc_msg_get_folder_list_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_folder_view_list.c b/TC/msgTC/MapiStorage/utc_msg_get_folder_view_list.c
new file mode 100755 (executable)
index 0000000..27385ea
--- /dev/null
@@ -0,0 +1,86 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_folder_view_list.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_folder_view_list_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+       MSG_LIST_S msg_folder_view_list;
+
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+       memset(&msg_folder_view_list, 0x00, sizeof(msg_folder_view_list));
+
+       err = msg_get_folder_view_list(msgHandle, MSG_DRAFT_ID, &sort_rule, &msg_folder_view_list);
+       msg_release_message_list(&msg_folder_view_list);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_folder_view_list_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+       MSG_LIST_S msg_folder_view_list;
+
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+       memset(&msg_folder_view_list, 0x00, sizeof(msg_folder_view_list));
+
+       err = msg_get_folder_view_list(NULL, MSG_DRAFT_ID, &sort_rule, &msg_folder_view_list);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_folder_view_list.h b/TC/msgTC/MapiStorage/utc_msg_get_folder_view_list.h
new file mode 100755 (executable)
index 0000000..1583443
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_get_folder_view_list_001(void);
+static void utc_msg_get_folder_view_list_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_get_folder_view_list_001,1},
+                       { utc_msg_get_folder_view_list_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_mem_size.c b/TC/msgTC/MapiStorage/utc_msg_get_mem_size.c
new file mode 100755 (executable)
index 0000000..b37bd32
--- /dev/null
@@ -0,0 +1,77 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_mem_size.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_mem_size_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       int memsize = 0;
+
+       err = msg_get_mem_size(msgHandle, &memsize);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_mem_size_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       int memsize = 0;
+
+       err = msg_get_mem_size(NULL, &memsize);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_mem_size.h b/TC/msgTC/MapiStorage/utc_msg_get_mem_size.h
new file mode 100755 (executable)
index 0000000..3240db4
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_get_mem_size_001(void);
+static void utc_msg_get_mem_size_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_get_mem_size_001,1},
+                       { utc_msg_get_mem_size_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_message.c b/TC/msgTC/MapiStorage/utc_msg_get_message.c
new file mode 100755 (executable)
index 0000000..c970350
--- /dev/null
@@ -0,0 +1,82 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+int msgId = 0;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_LIST_S folder_list;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       msg_get_folder_view_list(msgHandle, MSG_DRAFT_ID, NULL, &folder_list);
+
+       msgId = msg_get_message_id(folder_list.msgInfo[0]);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_message_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_message(msgHandle, msgId, msgInfo, &sendOpt);
+       if (err != MSG_SUCCESS)
+       {
+               tet_printf("err is [%d]", err);
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_message_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_message(NULL, msgId, msgInfo, &sendOpt);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_message.h b/TC/msgTC/MapiStorage/utc_msg_get_message.h
new file mode 100755 (executable)
index 0000000..ca306f0
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_get_message_001(void);
+static void utc_msg_get_message_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_get_message_001,1},
+                       { utc_msg_get_message_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_quick_panel_data.c b/TC/msgTC/MapiStorage/utc_msg_get_quick_panel_data.c
new file mode 100755 (executable)
index 0000000..bdee02b
--- /dev/null
@@ -0,0 +1,76 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_quick_panel_data.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_quick_panel_data_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       //err = msg_get_quick_panel_data(msgHandle, MSG_QUICKPANEL_SMS, msgInfo);
+       if (err != MSG_SUCCESS)
+       {
+               tet_printf("err is [%d]", err);
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_quick_panel_data_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_get_quick_panel_data(NULL, MSG_QUICKPANEL_SMS, msgInfo);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_quick_panel_data.h b/TC/msgTC/MapiStorage/utc_msg_get_quick_panel_data.h
new file mode 100755 (executable)
index 0000000..fb9eb92
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_get_quick_panel_data_001(void);
+static void utc_msg_get_quick_panel_data_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_get_quick_panel_data_001,1},
+                       { utc_msg_get_quick_panel_data_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_thread_view_list.c b/TC/msgTC/MapiStorage/utc_msg_get_thread_view_list.c
new file mode 100755 (executable)
index 0000000..966f122
--- /dev/null
@@ -0,0 +1,87 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_get_thread_view_list.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_get_thread_view_list_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+       MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+
+       err = msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+       msg_release_thread_view_list(&msg_thread_view_list);
+       if (err != MSG_SUCCESS)
+       {
+               tet_printf("err is [%d]", err);
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_get_thread_view_list_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+       MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+
+       err = msg_get_thread_view_list(NULL, &sort_rule, &msg_thread_view_list);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_get_thread_view_list.h b/TC/msgTC/MapiStorage/utc_msg_get_thread_view_list.h
new file mode 100755 (executable)
index 0000000..202eb0a
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_get_thread_view_list_001(void);
+static void utc_msg_get_thread_view_list_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_get_thread_view_list_001,1},
+                       { utc_msg_get_thread_view_list_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_move_msg_to_folder.c b/TC/msgTC/MapiStorage/utc_msg_move_msg_to_folder.c
new file mode 100755 (executable)
index 0000000..cc8cf47
--- /dev/null
@@ -0,0 +1,75 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_move_msg_to_folder.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_move_msg_to_folder_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_move_msg_to_folder(msgHandle, 0, MSG_DRAFT_ID);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_move_msg_to_folder_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_move_msg_to_folder(NULL, 0, MSG_DRAFT_ID);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_move_msg_to_folder.h b/TC/msgTC/MapiStorage/utc_msg_move_msg_to_folder.h
new file mode 100755 (executable)
index 0000000..0094958
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_move_msg_to_folder_001(void);
+static void utc_msg_move_msg_to_folder_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_move_msg_to_folder_001,1},
+                       { utc_msg_move_msg_to_folder_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_move_msg_to_storage.c b/TC/msgTC/MapiStorage/utc_msg_move_msg_to_storage.c
new file mode 100755 (executable)
index 0000000..14ed023
--- /dev/null
@@ -0,0 +1,75 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_move_msg_to_storage.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_move_msg_to_storage_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_update_message(msgHandle, msgInfo, &sendOpt);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_move_msg_to_storage_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_update_message(NULL, msgInfo, &sendOpt);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_move_msg_to_storage.h b/TC/msgTC/MapiStorage/utc_msg_move_msg_to_storage.h
new file mode 100755 (executable)
index 0000000..8e7d49d
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_move_msg_to_storage_001(void);
+static void utc_msg_move_msg_to_storage_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_move_msg_to_storage_001,1},
+                       { utc_msg_move_msg_to_storage_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_release_folder_list.c b/TC/msgTC/MapiStorage/utc_msg_release_folder_list.c
new file mode 100755 (executable)
index 0000000..1bd42b5
--- /dev/null
@@ -0,0 +1,83 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_release_folder_list.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_release_folder_list_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_FOLDER_LIST_S folder_list;
+
+       memset(&folder_list, 0x00, sizeof(folder_list));
+
+       msg_get_folder_list(msgHandle, &folder_list);
+       msg_release_folder_list(&folder_list);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_release_folder_list_002()
+{
+       MSG_ERROR_T err = -1;
+       MSG_FOLDER_LIST_S folder_list;
+
+       memset(&folder_list, 0x00, sizeof(folder_list));
+
+       //err = msg_get_folder_list(NULL, &folder_list);
+       //msg_release_folder_list(&folder_list);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_release_folder_list.h b/TC/msgTC/MapiStorage/utc_msg_release_folder_list.h
new file mode 100755 (executable)
index 0000000..c863572
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_release_folder_list_001(void);
+static void utc_msg_release_folder_list_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_release_folder_list_001,1},
+                       { utc_msg_release_folder_list_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_release_thread_view_list.c b/TC/msgTC/MapiStorage/utc_msg_release_thread_view_list.c
new file mode 100755 (executable)
index 0000000..8708f37
--- /dev/null
@@ -0,0 +1,83 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_release_thread_view_list.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+
+       msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+}
+void cleanup(void)
+{
+       msg_release_thread_view_list(&msg_thread_view_list);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_release_thread_view_list_001()
+{
+       int err = MSG_SUCCESS;
+
+       //msg_release_thread_view_list(&msg_thread_view_list);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_release_thread_view_list_002()
+{
+       int err = -1;
+
+       //msg_release_thread_view_list(&msg_thread_view_list);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_release_thread_view_list.h b/TC/msgTC/MapiStorage/utc_msg_release_thread_view_list.h
new file mode 100755 (executable)
index 0000000..2186269
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_release_thread_view_list_001(void);
+static void utc_msg_release_thread_view_list_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_release_thread_view_list_001,1},
+                       { utc_msg_release_thread_view_list_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_reset_database.c b/TC/msgTC/MapiStorage/utc_msg_reset_database.c
new file mode 100755 (executable)
index 0000000..d4ae485
--- /dev/null
@@ -0,0 +1,75 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_reset_database.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_reset_database_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_reset_database(msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_reset_database_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_reset_database(NULL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_reset_database.h b/TC/msgTC/MapiStorage/utc_msg_reset_database.h
new file mode 100755 (executable)
index 0000000..6e06586
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_reset_database_001(void);
+static void utc_msg_reset_database_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_reset_database_001,1},
+                       { utc_msg_reset_database_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_address.c b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_address.c
new file mode 100755 (executable)
index 0000000..eda8e45
--- /dev/null
@@ -0,0 +1,91 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_thread_view_get_address.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+
+       msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+}
+void cleanup(void)
+{
+       msg_release_thread_view_list(&msg_thread_view_list);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_thread_view_get_address_001()
+{
+       int err = MSG_SUCCESS;
+       char* addr = NULL;
+
+       if(msg_thread_view_list.nCount == 0)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       addr = msg_thread_view_get_address(msg_thread_view_list.msgThreadInfo[0]);
+       if (addr == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_thread_view_get_address_002()
+{
+       int err = MSG_SUCCESS;
+       char* addr = NULL;
+
+       addr =  msg_thread_view_get_address(NULL);
+       if (addr == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_address.h b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_address.h
new file mode 100755 (executable)
index 0000000..cdc7d89
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_thread_view_get_address_001(void);
+static void utc_msg_thread_view_get_address_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_thread_view_get_address_001,1},
+                       { utc_msg_thread_view_get_address_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_contact_id.c b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_contact_id.c
new file mode 100755 (executable)
index 0000000..85c3953
--- /dev/null
@@ -0,0 +1,89 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_thread_view_get_contact_id.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+
+       msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+}
+void cleanup(void)
+{
+       msg_release_thread_view_list(&msg_thread_view_list);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_thread_view_get_contact_id_001()
+{
+       int err = MSG_SUCCESS;
+
+       if(msg_thread_view_list.nCount == 0)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       err = msg_thread_view_get_contact_id(msg_thread_view_list.msgThreadInfo[0]);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_thread_view_get_contact_id_002()
+{
+       int err = MSG_SUCCESS;
+
+       err =  msg_thread_view_get_contact_id(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_contact_id.h b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_contact_id.h
new file mode 100755 (executable)
index 0000000..76f23dc
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_thread_view_get_contact_id_001(void);
+static void utc_msg_thread_view_get_contact_id_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_thread_view_get_contact_id_001,1},
+                       { utc_msg_thread_view_get_contact_id_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_data.c b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_data.c
new file mode 100755 (executable)
index 0000000..84d2f11
--- /dev/null
@@ -0,0 +1,91 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_thread_view_get_data.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+
+       msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+}
+void cleanup(void)
+{
+       msg_release_thread_view_list(&msg_thread_view_list);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_thread_view_get_data_001()
+{
+       int err = MSG_SUCCESS;
+       char* data = NULL;
+
+       if(msg_thread_view_list.nCount == 0)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       data = msg_thread_view_get_data(msg_thread_view_list.msgThreadInfo[0]);
+       if (data == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_thread_view_get_data_002()
+{
+       int err = MSG_SUCCESS;
+       char* data = NULL;
+
+       data =  msg_thread_view_get_data(NULL);
+       if (data == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_data.h b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_data.h
new file mode 100755 (executable)
index 0000000..8827b32
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_thread_view_get_data_001(void);
+static void utc_msg_thread_view_get_data_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_thread_view_get_data_001,1},
+                       { utc_msg_thread_view_get_data_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_direction.c b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_direction.c
new file mode 100755 (executable)
index 0000000..c6a1911
--- /dev/null
@@ -0,0 +1,89 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_thread_view_get_direction.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+
+       msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+}
+void cleanup(void)
+{
+       msg_release_thread_view_list(&msg_thread_view_list);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_thread_view_get_direction_001()
+{
+       int err = MSG_SUCCESS;
+
+       if(msg_thread_view_list.nCount == 0)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       err = msg_thread_view_get_direction(msg_thread_view_list.msgThreadInfo[0]);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_thread_view_get_direction_002()
+{
+       int err = MSG_SUCCESS;
+
+       err =  msg_thread_view_get_direction(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_direction.h b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_direction.h
new file mode 100755 (executable)
index 0000000..a6617e9
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_thread_view_get_direction_001(void);
+static void utc_msg_thread_view_get_direction_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_thread_view_get_direction_001,1},
+                       { utc_msg_thread_view_get_direction_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_image_path.c b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_image_path.c
new file mode 100755 (executable)
index 0000000..c69409f
--- /dev/null
@@ -0,0 +1,91 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_thread_view_get_image_path.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+
+       msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+}
+void cleanup(void)
+{
+       msg_release_thread_view_list(&msg_thread_view_list);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_thread_view_get_image_path_001()
+{
+       int err = MSG_SUCCESS;
+       char* path = NULL;
+
+       if(msg_thread_view_list.nCount == 0)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       path = msg_thread_view_get_image_path(msg_thread_view_list.msgThreadInfo[0]);
+       if (path == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_thread_view_get_image_path_002()
+{
+       int err = MSG_SUCCESS;
+       char* path = NULL;
+
+       path =  msg_thread_view_get_image_path(NULL);
+       if (path == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_image_path.h b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_image_path.h
new file mode 100755 (executable)
index 0000000..9838046
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_thread_view_get_image_path_001(void);
+static void utc_msg_thread_view_get_image_path_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_thread_view_get_image_path_001,1},
+                       { utc_msg_thread_view_get_image_path_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_mms_cnt.c b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_mms_cnt.c
new file mode 100755 (executable)
index 0000000..919942c
--- /dev/null
@@ -0,0 +1,89 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_thread_view_get_mms_cnt.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+
+       msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+}
+void cleanup(void)
+{
+       msg_release_thread_view_list(&msg_thread_view_list);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_thread_view_get_mms_cnt_001()
+{
+       int err = MSG_SUCCESS;
+
+       if(msg_thread_view_list.nCount == 0)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       err = msg_thread_view_get_mms_cnt(msg_thread_view_list.msgThreadInfo[0]);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_thread_view_get_mms_cnt_002()
+{
+       int err = MSG_SUCCESS;
+
+       err =  msg_thread_view_get_mms_cnt(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_mms_cnt.h b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_mms_cnt.h
new file mode 100755 (executable)
index 0000000..6b1242b
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_thread_view_get_mms_cnt_001(void);
+static void utc_msg_thread_view_get_mms_cnt_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_thread_view_get_mms_cnt_001,1},
+                       { utc_msg_thread_view_get_mms_cnt_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_name.c b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_name.c
new file mode 100755 (executable)
index 0000000..8ab0924
--- /dev/null
@@ -0,0 +1,91 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_thread_view_get_name.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+
+       msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+}
+void cleanup(void)
+{
+       msg_release_thread_view_list(&msg_thread_view_list);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_thread_view_get_name_001()
+{
+       int err = MSG_SUCCESS;
+       char* name = NULL;
+
+       if(msg_thread_view_list.nCount == 0)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       name = msg_thread_view_get_name(msg_thread_view_list.msgThreadInfo[0]);
+       if (name == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_thread_view_get_name_002()
+{
+       int err = MSG_SUCCESS;
+       char* name = NULL;
+
+       name =  msg_thread_view_get_name(NULL);
+       if (name == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_name.h b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_name.h
new file mode 100755 (executable)
index 0000000..9ee322f
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_thread_view_get_name_001(void);
+static void utc_msg_thread_view_get_name_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_thread_view_get_name_001,1},
+                       { utc_msg_thread_view_get_name_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_sms_cnt.c b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_sms_cnt.c
new file mode 100755 (executable)
index 0000000..7fec174
--- /dev/null
@@ -0,0 +1,89 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_thread_view_get_sms_cnt.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+
+       msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+}
+void cleanup(void)
+{
+       msg_release_thread_view_list(&msg_thread_view_list);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_thread_view_get_sms_cnt_001()
+{
+       int err = MSG_SUCCESS;
+
+       if(msg_thread_view_list.nCount == 0)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       err = msg_thread_view_get_sms_cnt(msg_thread_view_list.msgThreadInfo[0]);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_thread_view_get_sms_cnt_002()
+{
+       int err = MSG_SUCCESS;
+
+       err =  msg_thread_view_get_sms_cnt(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_sms_cnt.h b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_sms_cnt.h
new file mode 100755 (executable)
index 0000000..b678862
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_thread_view_get_sms_cnt_001(void);
+static void utc_msg_thread_view_get_sms_cnt_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_thread_view_get_sms_cnt_001,1},
+                       { utc_msg_thread_view_get_sms_cnt_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_thread_id.c b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_thread_id.c
new file mode 100755 (executable)
index 0000000..75e4ac6
--- /dev/null
@@ -0,0 +1,89 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_thread_view_get_thread_id.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+
+       msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+}
+void cleanup(void)
+{
+       msg_release_thread_view_list(&msg_thread_view_list);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_thread_view_get_thread_id_001()
+{
+       int err = MSG_SUCCESS;
+
+       if(msg_thread_view_list.nCount == 0)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       err = msg_thread_view_get_thread_id(msg_thread_view_list.msgThreadInfo[0]);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_thread_view_get_thread_id_002()
+{
+       int err = MSG_SUCCESS;
+
+       err =  msg_thread_view_get_thread_id(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_thread_id.h b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_thread_id.h
new file mode 100755 (executable)
index 0000000..a1b3587
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_thread_view_get_thread_id_001(void);
+static void utc_msg_thread_view_get_thread_id_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_thread_view_get_thread_id_001,1},
+                       { utc_msg_thread_view_get_thread_id_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_time.c b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_time.c
new file mode 100755 (executable)
index 0000000..2759293
--- /dev/null
@@ -0,0 +1,91 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_thread_view_get_time.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+
+       msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+}
+void cleanup(void)
+{
+       msg_release_thread_view_list(&msg_thread_view_list);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_thread_view_get_time_001()
+{
+       int err = MSG_SUCCESS;
+       time_t* time = NULL;
+
+       if(msg_thread_view_list.nCount == 0)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       time = msg_thread_view_get_time(msg_thread_view_list.msgThreadInfo[0]);
+       if (time == NULL)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_thread_view_get_time_002()
+{
+       int err = MSG_SUCCESS;
+       time_t* time = NULL;
+
+       time =  msg_thread_view_get_time(NULL);
+       if (time == NULL)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_time.h b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_time.h
new file mode 100755 (executable)
index 0000000..8b5e190
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_thread_view_get_time_001(void);
+static void utc_msg_thread_view_get_time_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_thread_view_get_time_001,1},
+                       { utc_msg_thread_view_get_time_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_unread_cnt.c b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_unread_cnt.c
new file mode 100755 (executable)
index 0000000..d2d87d9
--- /dev/null
@@ -0,0 +1,89 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_thread_view_get_unread_cnt.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+MSG_THREAD_VIEW_LIST_S msg_thread_view_list;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+
+       memset(&msg_thread_view_list, 0x00, sizeof(msg_thread_view_list));
+       memset(&sort_rule, 0x00, sizeof(sort_rule));
+
+       msg_get_thread_view_list(msgHandle, NULL, &msg_thread_view_list);
+}
+void cleanup(void)
+{
+       msg_release_thread_view_list(&msg_thread_view_list);
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_thread_view_get_unread_cnt_001()
+{
+       int err = MSG_SUCCESS;
+
+       if(msg_thread_view_list.nCount == 0)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       err = msg_thread_view_get_unread_cnt(msg_thread_view_list.msgThreadInfo[0]);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_thread_view_get_unread_cnt_002()
+{
+       int err = MSG_SUCCESS;
+
+       err =  msg_thread_view_get_unread_cnt(NULL);
+       if (err < MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_thread_view_get_unread_cnt.h b/TC/msgTC/MapiStorage/utc_msg_thread_view_get_unread_cnt.h
new file mode 100755 (executable)
index 0000000..0bc8c6b
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_thread_view_get_unread_cnt_001(void);
+static void utc_msg_thread_view_get_unread_cnt_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_thread_view_get_unread_cnt_001,1},
+                       { utc_msg_thread_view_get_unread_cnt_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_update_folder.c b/TC/msgTC/MapiStorage/utc_msg_update_folder.c
new file mode 100755 (executable)
index 0000000..de1bda3
--- /dev/null
@@ -0,0 +1,91 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_update_folder.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_update_folder_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_FOLDER_INFO_S folderInfo;
+
+       memset(&folderInfo, 0x00, sizeof(folderInfo));
+
+       folderInfo.folderId = 0;
+       folderInfo.folderType = MSG_FOLDER_TYPE_USER_DEF;
+
+       strncpy(folderInfo.folderName, "Test folder", MAX_FOLDER_NAME_SIZE);
+
+       err = msg_update_folder(msgHandle, &folderInfo);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_update_folder_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_FOLDER_INFO_S folderInfo;
+
+       memset(&folderInfo, 0x00, sizeof(folderInfo));
+
+       folderInfo.folderId = 0;
+       folderInfo.folderType = MSG_FOLDER_TYPE_USER_DEF;
+
+       strncpy(folderInfo.folderName, "Test folder", MAX_FOLDER_NAME_SIZE);
+
+       err = msg_update_folder(NULL, &folderInfo);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_update_folder.h b/TC/msgTC/MapiStorage/utc_msg_update_folder.h
new file mode 100755 (executable)
index 0000000..79d66de
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_update_folder_001(void);
+static void utc_msg_update_folder_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_update_folder_001,1},
+                       { utc_msg_update_folder_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_update_message.c b/TC/msgTC/MapiStorage/utc_msg_update_message.c
new file mode 100755 (executable)
index 0000000..27cee62
--- /dev/null
@@ -0,0 +1,75 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_update_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_update_message_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_update_message(msgHandle, msgInfo, &sendOpt);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_update_message_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_update_message(NULL, msgInfo, &sendOpt);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_update_message.h b/TC/msgTC/MapiStorage/utc_msg_update_message.h
new file mode 100755 (executable)
index 0000000..2eb70cc
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_update_message_001(void);
+static void utc_msg_update_message_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_update_message_001,1},
+                       { utc_msg_update_message_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_update_protected_status.c b/TC/msgTC/MapiStorage/utc_msg_update_protected_status.c
new file mode 100755 (executable)
index 0000000..94889f2
--- /dev/null
@@ -0,0 +1,75 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_update_protected_status.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       msg_set_message_id(msgInfo, 0);
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_update_protected_status_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_update_protected_status(msgHandle, 0, true);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_update_protected_status_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_update_protected_status(NULL, 0, true);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_update_protected_status.h b/TC/msgTC/MapiStorage/utc_msg_update_protected_status.h
new file mode 100755 (executable)
index 0000000..a53b18f
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_update_protected_status_001(void);
+static void utc_msg_update_protected_status_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_update_protected_status_001,1},
+                       { utc_msg_update_protected_status_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiStorage/utc_msg_update_read_status.c b/TC/msgTC/MapiStorage/utc_msg_update_read_status.c
new file mode 100755 (executable)
index 0000000..a529c4c
--- /dev/null
@@ -0,0 +1,84 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_update_read_status.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+int msgId = 0;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msgInfo = msg_new_message();
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+
+       msg_add_address(msgInfo, "01000000000", MSG_RECIPIENTS_TYPE_TO);
+
+       msgId = msg_add_message(msgHandle, msgInfo, &sendOpt);
+
+       tet_printf("msgId is [%d]", msgId);
+
+       //msg_get_folder_view_list(msgHandle, MSG_DRAFT_ID, NULL, &folder_list);
+
+       //msgId = msg_folder_view_get_message_id(folder_list.msgCommInfo[0]);
+
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_update_read_status_001()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_update_read_status(msgHandle, msgId, true);
+       if (err != MSG_SUCCESS)
+       {
+               tet_printf("err is [%d]", err);
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_update_read_status_002()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_update_read_status(NULL, msgId, true);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiStorage/utc_msg_update_read_status.h b/TC/msgTC/MapiStorage/utc_msg_update_read_status.h
new file mode 100755 (executable)
index 0000000..93b8af3
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_update_read_status_001(void);
+static void utc_msg_update_read_status_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_update_read_status_001,1},
+                       { utc_msg_update_read_status_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/Makefile b/TC/msgTC/MapiTransport/Makefile
new file mode 100755 (executable)
index 0000000..50ea736
--- /dev/null
@@ -0,0 +1,108 @@
+###################################################
+# add your TestCase List Here
+#
+# e.g.,
+# TC1 = utc_frameworkName_apiName_func
+# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
+TC1 = utc_msg_mms_forward_message
+TC2 = utc_msg_reg_lbs_message_callback
+TC3 = utc_msg_sms_send
+TC4 = utc_msg_mms_reject_message
+TC5 = utc_msg_reg_mms_conf_message_callback
+TC6 = utc_msg_sms_send_message
+TC7 = utc_msg_mms_retrieve_message
+TC8 = utc_msg_reg_sent_status_callback
+TC9 = utc_msg_submit_req
+TC10 = utc_msg_mms_send_message
+TC11 = utc_msg_reg_sms_message_callback
+TC12 = utc_msg_mms_send_read_report
+TC13 = utc_msg_reg_syncml_message_callback
+
+       
+###################################################
+# add your Package Config Info Here
+#
+# e.g.,
+# PKGS=calendar
+PKGS=msg-service
+
+LIBS  = `pkg-config --libs $(PKGS)` 
+LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
+LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
+LIBS +=-L$(TET_ROOT)/lib/tet3 -lapi_s
+
+INCS  =  -I. `pkg-config --cflags $(PKGS)`
+INCS  += -I$(TET_ROOT)/inc/tet3 
+
+CFLAGS = $(INCS)
+CFLAGS += -D_TETWARE_MODE
+#CC +=$(CFLAGS)
+LDFLAGS = $(LIBS)
+
+###################################################
+# Modify here 
+# depending on the Test Case you want to build
+# 
+# e.g.,
+# TCLIST = $(TC1) $(TC2)
+TCLIST = $(TC1) $(TC2) $(TC3) $(TC4) $(TC5) $(TC6) $(TC7) $(TC8) $(TC9) $(TC10) $(TC11) $(TC12) $(TC13)
+all :
+       for testcase in $(TCLIST) do\
+               $(CC) -o $$(testcase) $$(testcase).c $(CFLAGS) $(LDFLAGS)
+       done
+
+clean :
+       rm -rf *~ *.o $(TCLIST)
+
+
+$(TC1) : 
+       $(CC) -o $(TC1) $(TC1).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC2) : 
+       $(CC) -o $(TC2) $(TC2).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC3) : 
+       $(CC) -o $(TC3) $(TC3).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC4) : 
+       $(CC) -o $(TC4) $(TC4).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC5) : 
+       $(CC) -o $(TC5) $(TC5).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC6) : 
+       $(CC) -o $(TC6) $(TC6).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC7) : 
+       $(CC) -o $(TC7) $(TC7).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC8) : 
+       $(CC) -o $(TC8) $(TC8).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC9) : 
+       $(CC) -o $(TC9) $(TC9).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC10) : 
+       $(CC) -o $(TC10) $(TC10).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC11) : 
+       $(CC) -o $(TC11) $(TC11).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC12) : 
+       $(CC) -o $(TC12) $(TC12).c  $(CFLAGS) $(LDFLAGS)
+
+
+$(TC13) : 
+       $(CC) -o $(TC13) $(TC13).c  $(CFLAGS) $(LDFLAGS)
\ No newline at end of file
diff --git a/TC/msgTC/MapiTransport/tslist b/TC/msgTC/MapiTransport/tslist
new file mode 100755 (executable)
index 0000000..46d803f
--- /dev/null
@@ -0,0 +1,13 @@
+utc_msg_mms_forward_message   \r
+utc_msg_reg_lbs_message_callback       \r
+utc_msg_sms_send\r
+utc_msg_mms_reject_message    \r
+utc_msg_reg_mms_conf_message_callback  \r
+utc_msg_sms_send_message\r
+utc_msg_mms_retrieve_message  \r
+utc_msg_reg_sent_status_callback       \r
+utc_msg_submit_req\r
+utc_msg_mms_send_message      \r
+utc_msg_reg_sms_message_callback\r
+utc_msg_mms_send_read_report  \r
+utc_msg_reg_syncml_message_callback\r
diff --git a/TC/msgTC/MapiTransport/utc_msg_mms_forward_message.c b/TC/msgTC/MapiTransport/utc_msg_mms_forward_message.c
new file mode 100755 (executable)
index 0000000..799719f
--- /dev/null
@@ -0,0 +1,126 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_forward_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam)
+{
+       return;
+}
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MESSAGE_DATA_S*      mms_data;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msg_reg_sent_status_callback(msgHandle, &sentStatusCB, (void*)"sent status callback");
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+       //------------>  1st Slide Composing
+       page[0] = msg_mms_add_page(mms_data, 5440);
+
+       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+       media[2]->sMedia.sText.nColor = 0x000000;
+       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[2]->sMedia.sText.bBold = true;
+
+       //------------>  2nd Slide Composing
+       page[1] = msg_mms_add_page(mms_data, 4544);
+
+       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+       media[3]->sMedia.sText.nColor = 0x000000;
+       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[3]->sMedia.sText.bItalic = true;
+       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+
+       msg_set_message_type(msgInfo, MSG_TYPE_MMS);
+
+       msg_mms_set_message_body(msgInfo, mms_data);
+
+       msg_mms_destroy_message(mms_data);
+
+       msg_add_address(msgInfo, "01000000000", MSG_RECIPIENTS_TYPE_TO);
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_forward_message_001()
+{
+       int err = MSG_SUCCESS;
+       MSG_REQUEST_S req;
+
+       memset(&req, 0x00, sizeof(req));
+
+       req.msg = msgInfo;
+       req.sendOpt = sendOpt;
+
+       err = msg_mms_forward_message(msgHandle, &req);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_forward_message_002()
+{
+       int err = MSG_SUCCESS;
+       MSG_REQUEST_S req;
+
+       memset(&req, 0x00, sizeof(req));
+
+       req.msg = msgInfo;
+       req.sendOpt = sendOpt;
+
+       err = msg_mms_forward_message(NULL, &req);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_mms_forward_message.h b/TC/msgTC/MapiTransport/utc_msg_mms_forward_message.h
new file mode 100755 (executable)
index 0000000..fc4a885
--- /dev/null
@@ -0,0 +1,37 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam);
+static void utc_msg_mms_forward_message_001(void);
+static void utc_msg_mms_forward_message_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_mms_forward_message_001,1},
+                       { utc_msg_mms_forward_message_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/utc_msg_mms_reject_message.c b/TC/msgTC/MapiTransport/utc_msg_mms_reject_message.c
new file mode 100755 (executable)
index 0000000..a48878a
--- /dev/null
@@ -0,0 +1,124 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_reject_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam)
+{
+       return;
+}
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MESSAGE_DATA_S*      mms_data;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msg_reg_sent_status_callback(msgHandle, &sentStatusCB, (void*)"sent status callback");
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+       //------------>  1st Slide Composing
+       page[0] = msg_mms_add_page(mms_data, 5440);
+
+       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+       media[2]->sMedia.sText.nColor = 0x000000;
+       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[2]->sMedia.sText.bBold = true;
+
+       //------------>  2nd Slide Composing
+       page[1] = msg_mms_add_page(mms_data, 4544);
+
+       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+       media[3]->sMedia.sText.nColor = 0x000000;
+       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[3]->sMedia.sText.bItalic = true;
+       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+
+       msg_mms_set_message_body(msgInfo, mms_data);
+
+       msg_mms_destroy_message(mms_data);
+
+       msg_add_address(msgInfo, "01000000000", MSG_RECIPIENTS_TYPE_TO);
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_reject_message_001()
+{
+       int err = MSG_SUCCESS;
+       MSG_REQUEST_S req;
+
+       memset(&req, 0x00, sizeof(req));
+
+       req.msg = msgInfo;
+       req.sendOpt = sendOpt;
+
+       //err = msg_mms_reject_message(msgHandle, &req);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_reject_message_002()
+{
+       int err = MSG_SUCCESS;
+       MSG_REQUEST_S req;
+
+       memset(&req, 0x00, sizeof(req));
+
+       req.msg = msgInfo;
+       req.sendOpt = sendOpt;
+
+       err = msg_mms_reject_message(NULL, &req);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_mms_reject_message.h b/TC/msgTC/MapiTransport/utc_msg_mms_reject_message.h
new file mode 100755 (executable)
index 0000000..456eae5
--- /dev/null
@@ -0,0 +1,37 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam);
+static void utc_msg_mms_reject_message_001(void);
+static void utc_msg_mms_reject_message_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_mms_reject_message_001,1},
+                       { utc_msg_mms_reject_message_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/utc_msg_mms_retrieve_message.c b/TC/msgTC/MapiTransport/utc_msg_mms_retrieve_message.c
new file mode 100755 (executable)
index 0000000..693931c
--- /dev/null
@@ -0,0 +1,124 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_retrieve_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam)
+{
+       return;
+}
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MESSAGE_DATA_S*      mms_data;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msg_reg_sent_status_callback(msgHandle, &sentStatusCB, (void*)"sent status callback");
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+       //------------>  1st Slide Composing
+       page[0] = msg_mms_add_page(mms_data, 5440);
+
+       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+       media[2]->sMedia.sText.nColor = 0x000000;
+       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[2]->sMedia.sText.bBold = true;
+
+       //------------>  2nd Slide Composing
+       page[1] = msg_mms_add_page(mms_data, 4544);
+
+       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+       media[3]->sMedia.sText.nColor = 0x000000;
+       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[3]->sMedia.sText.bItalic = true;
+       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+
+       msg_mms_set_message_body(msgInfo, mms_data);
+
+       msg_mms_destroy_message(mms_data);
+
+       msg_add_address(msgInfo, "01000000000", MSG_RECIPIENTS_TYPE_TO);
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_retrieve_message_001()
+{
+       int err = MSG_SUCCESS;
+       MSG_REQUEST_S req;
+
+       memset(&req, 0x00, sizeof(req));
+
+       req.msg = msgInfo;
+       req.sendOpt = sendOpt;
+
+       //err = msg_mms_retrieve_message(msgHandle, &req);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_retrieve_message_002()
+{
+       int err = MSG_SUCCESS;
+       MSG_REQUEST_S req;
+
+       memset(&req, 0x00, sizeof(req));
+
+       req.msg = msgInfo;
+       req.sendOpt = sendOpt;
+
+       err = msg_mms_retrieve_message(NULL, &req);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_mms_retrieve_message.h b/TC/msgTC/MapiTransport/utc_msg_mms_retrieve_message.h
new file mode 100755 (executable)
index 0000000..77ecfb4
--- /dev/null
@@ -0,0 +1,37 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam);
+static void utc_msg_mms_retrieve_message_001(void);
+static void utc_msg_mms_retrieve_message_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_mms_retrieve_message_001,1},
+                       { utc_msg_mms_retrieve_message_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/utc_msg_mms_send_message.c b/TC/msgTC/MapiTransport/utc_msg_mms_send_message.c
new file mode 100755 (executable)
index 0000000..6016f03
--- /dev/null
@@ -0,0 +1,126 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_send_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam)
+{
+       return;
+}
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_MESSAGE_DATA_S*      mms_data;
+       MMS_PAGE_S*     page[2];
+       MMS_MEDIA_S*    media[5];
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msg_reg_sent_status_callback(msgHandle, &sentStatusCB, (void*)"sent status callback");
+
+       msgInfo = msg_new_message();
+       mms_data = msg_mms_create_message();
+
+       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+       //------------>  1st Slide Composing
+       page[0] = msg_mms_add_page(mms_data, 5440);
+
+       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+       media[2]->sMedia.sText.nColor = 0x000000;
+       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[2]->sMedia.sText.bBold = true;
+
+       //------------>  2nd Slide Composing
+       page[1] = msg_mms_add_page(mms_data, 4544);
+
+       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+       media[3]->sMedia.sText.nColor = 0x000000;
+       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+       media[3]->sMedia.sText.bItalic = true;
+       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+
+       msg_set_message_type(msgInfo, MSG_TYPE_MMS);
+
+       msg_mms_set_message_body(msgInfo, mms_data);
+
+       msg_mms_destroy_message(mms_data);
+
+       msg_add_address(msgInfo, "01000000000", MSG_RECIPIENTS_TYPE_TO);
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_send_message_001()
+{
+       int err = MSG_SUCCESS;
+       MSG_REQUEST_S req;
+
+       memset(&req, 0x00, sizeof(req));
+
+       req.msg = msgInfo;
+       req.sendOpt = sendOpt;
+
+       err = msg_mms_send_message(msgHandle, &req);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_send_message_002()
+{
+       int err = MSG_SUCCESS;
+       MSG_REQUEST_S req;
+
+       memset(&req, 0x00, sizeof(req));
+
+       req.msg = msgInfo;
+       req.sendOpt = sendOpt;
+
+       err = msg_mms_send_message(NULL, &req);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_mms_send_message.h b/TC/msgTC/MapiTransport/utc_msg_mms_send_message.h
new file mode 100755 (executable)
index 0000000..a4d1335
--- /dev/null
@@ -0,0 +1,37 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam);
+static void utc_msg_mms_send_message_001(void);
+static void utc_msg_mms_send_message_001(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_mms_send_message_001,1},
+                       { utc_msg_mms_send_message_001,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/utc_msg_mms_send_read_report.c b/TC/msgTC/MapiTransport/utc_msg_mms_send_read_report.c
new file mode 100755 (executable)
index 0000000..f058f95
--- /dev/null
@@ -0,0 +1,65 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_mms_send_read_report.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_mms_send_read_report_001()
+{
+       int err = MSG_SUCCESS;
+
+       //err = msg_mms_send_read_report(msgHandle, 0, MSG_READ_REPORT_IS_READ);
+       if (err != MSG_SUCCESS)
+       {
+               tet_printf("err is [%d]", err);
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_mms_send_read_report_002()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_mms_send_read_report(NULL, 0, MSG_READ_REPORT_IS_READ);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_mms_send_read_report.h b/TC/msgTC/MapiTransport/utc_msg_mms_send_read_report.h
new file mode 100755 (executable)
index 0000000..81a816d
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_msg_mms_send_read_report_001(void);
+static void utc_msg_mms_send_read_report_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_mms_send_read_report_001,1},
+                       { utc_msg_mms_send_read_report_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/utc_msg_reg_lbs_message_callback.c b/TC/msgTC/MapiTransport/utc_msg_reg_lbs_message_callback.c
new file mode 100755 (executable)
index 0000000..bae0855
--- /dev/null
@@ -0,0 +1,69 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_reg_lbs_message_callback.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+
+void lbsCB(MSG_HANDLE_T hMsgHandle, const char* pPushHeader, const char* pPushBody, int pushBodyLen, void *pUserParam)
+{
+       return;
+}
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_reg_lbs_message_callback_001()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_reg_lbs_message_callback(msgHandle, &lbsCB, NULL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_reg_lbs_message_callback_002()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_reg_lbs_message_callback(NULL, &lbsCB, NULL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_reg_lbs_message_callback.h b/TC/msgTC/MapiTransport/utc_msg_reg_lbs_message_callback.h
new file mode 100755 (executable)
index 0000000..21c15cc
--- /dev/null
@@ -0,0 +1,37 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void lbsCB(MSG_HANDLE_T hMsgHandle, const char* pPushHeader, const char* pPushBody, int pushBodyLen, void *pUserParam);
+static void utc_msg_reg_lbs_message_callback_001(void);
+static void utc_msg_reg_lbs_message_callback_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_reg_lbs_message_callback_001,1},
+                       { utc_msg_reg_lbs_message_callback_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/utc_msg_reg_mms_conf_message_callback.c b/TC/msgTC/MapiTransport/utc_msg_reg_mms_conf_message_callback.c
new file mode 100755 (executable)
index 0000000..1210a8b
--- /dev/null
@@ -0,0 +1,69 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_reg_mms_conf_message_callback.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+
+void incomingMmsConfCB(MSG_HANDLE_T Handle, msg_message_t msg, void *pUserParam)
+{
+       return;
+}
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_reg_mms_conf_message_callback_001()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_reg_mms_conf_message_callback(msgHandle, &incomingMmsConfCB, NULL, NULL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_reg_mms_conf_message_callback_002()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_reg_mms_conf_message_callback(NULL, &incomingMmsConfCB, NULL, NULL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_reg_mms_conf_message_callback.h b/TC/msgTC/MapiTransport/utc_msg_reg_mms_conf_message_callback.h
new file mode 100755 (executable)
index 0000000..aca4584
--- /dev/null
@@ -0,0 +1,37 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void incomingMmsConfCB(MSG_HANDLE_T Handle, msg_message_t msg, void *pUserParam);
+static void utc_msg_reg_mms_conf_message_callback_001(void);
+static void utc_msg_reg_mms_conf_message_callback_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_reg_mms_conf_message_callback_001,1},
+                       { utc_msg_reg_mms_conf_message_callback_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/utc_msg_reg_sent_status_callback.c b/TC/msgTC/MapiTransport/utc_msg_reg_sent_status_callback.c
new file mode 100755 (executable)
index 0000000..61c6429
--- /dev/null
@@ -0,0 +1,69 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_reg_sent_status_callback.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam)
+{
+       return;
+}
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_reg_sent_status_callback_001()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_reg_sent_status_callback(msgHandle, &sentStatusCB, (void*)"sent status callback");
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_reg_sent_status_callback_002()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_reg_sent_status_callback(NULL, &sentStatusCB, (void*)"sent status callback");
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_reg_sent_status_callback.h b/TC/msgTC/MapiTransport/utc_msg_reg_sent_status_callback.h
new file mode 100755 (executable)
index 0000000..300a5b8
--- /dev/null
@@ -0,0 +1,37 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam);
+static void utc_msg_reg_sent_status_callback_001(void);
+static void utc_msg_reg_sent_status_callback_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_reg_sent_status_callback_001,1},
+                       { utc_msg_reg_sent_status_callback_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/utc_msg_reg_sms_message_callback.c b/TC/msgTC/MapiTransport/utc_msg_reg_sms_message_callback.c
new file mode 100755 (executable)
index 0000000..ce8a0ce
--- /dev/null
@@ -0,0 +1,70 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_reg_sms_message_callback.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+
+void incomingSmsCB(MSG_HANDLE_T Handle, msg_message_t msg, void *pUserParam)
+{
+       return;
+}
+
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_reg_sms_message_callback_001()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_reg_sms_message_callback(msgHandle, &incomingSmsCB, 0, (void*)"sms message callback");
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_reg_sms_message_callback_002()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_reg_sms_message_callback(NULL, &incomingSmsCB, 0, (void*)"sms message callback");
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_reg_sms_message_callback.h b/TC/msgTC/MapiTransport/utc_msg_reg_sms_message_callback.h
new file mode 100755 (executable)
index 0000000..644ccd9
--- /dev/null
@@ -0,0 +1,37 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void incomingSmsCB(MSG_HANDLE_T Handle, msg_message_t msg, void *pUserParam);
+static void utc_msg_reg_sms_message_callback_001(void);
+static void utc_msg_reg_sms_message_callback_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_reg_sms_message_callback_001,1},
+                       { utc_msg_reg_sms_message_callback_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/utc_msg_reg_syncml_message_callback.c b/TC/msgTC/MapiTransport/utc_msg_reg_syncml_message_callback.c
new file mode 100755 (executable)
index 0000000..1fa579f
--- /dev/null
@@ -0,0 +1,69 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_reg_syncml_message_callback.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+
+void syncMLCB(MSG_HANDLE_T hMsgHandle, MSG_SYNCML_MESSAGE_TYPE_T msgType, const char* pPushHeader, int PushHeaderLen, const char* pPushBody, int PushBodyLen, void *pUserParam)
+{
+       return;
+}
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_reg_syncml_message_callback_001()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_reg_syncml_message_callback(msgHandle, &syncMLCB, NULL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_reg_syncml_message_callback_002()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_reg_syncml_message_callback(NULL, &syncMLCB, NULL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_reg_syncml_message_callback.h b/TC/msgTC/MapiTransport/utc_msg_reg_syncml_message_callback.h
new file mode 100755 (executable)
index 0000000..c89c842
--- /dev/null
@@ -0,0 +1,37 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam);
+static void utc_msg_reg_syncml_message_callback_001(void);
+static void utc_msg_reg_syncml_message_callback_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_reg_syncml_message_callback_001,1},
+                       { utc_msg_reg_syncml_message_callback_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/utc_msg_sms_send.c b/TC/msgTC/MapiTransport/utc_msg_sms_send.c
new file mode 100755 (executable)
index 0000000..5496b9c
--- /dev/null
@@ -0,0 +1,61 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_sms_send.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+
+void sentStatusCB(MSG_SENT_STATUS_S *pStatus, void *pUserParam)
+{
+       return;
+}
+
+void startup(void)
+{
+
+}
+void cleanup(void)
+{
+
+}
+
+void utc_msg_sms_send_001()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_sms_send("01000000000,01000000000", "1234567890", sentStatusCB, NULL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_sms_send_002()
+{
+       int err = MSG_SUCCESS;
+
+       err = msg_sms_send(NULL, "1234567890", sentStatusCB, NULL);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_sms_send.h b/TC/msgTC/MapiTransport/utc_msg_sms_send.h
new file mode 100755 (executable)
index 0000000..9c76a4d
--- /dev/null
@@ -0,0 +1,37 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void sentStatusCB(MSG_SENT_STATUS_S *pStatus, void *pUserParam);
+static void utc_msg_sms_send_001(void);
+static void utc_msg_sms_send_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_sms_send_001,1},
+                       { utc_msg_sms_send_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/utc_msg_sms_send_message.c b/TC/msgTC/MapiTransport/utc_msg_sms_send_message.c
new file mode 100755 (executable)
index 0000000..da1ead3
--- /dev/null
@@ -0,0 +1,97 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_sms_send_message.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam)
+{
+       return;
+}
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msg_reg_sent_status_callback(msgHandle, &sentStatusCB, (void*)"sent status callback");
+
+       msgInfo = msg_new_message();
+
+       msg_set_message_type(msgInfo, MSG_TYPE_SMS);
+
+       msg_sms_set_message_body(msgInfo, "1234567890", 10);
+
+       msg_add_address(msgInfo, "01000000000", MSG_RECIPIENTS_TYPE_TO);
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_sms_send_message_001()
+{
+       int err = MSG_SUCCESS;
+       MSG_REQUEST_S req;
+
+       memset(&req, 0x00, sizeof(req));
+
+       req.msg = msgInfo;
+       req.sendOpt = sendOpt;
+
+       err = msg_sms_send_message(msgHandle, &req);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_sms_send_message_002()
+{
+       int err = MSG_SUCCESS;
+       MSG_REQUEST_S req;
+
+       memset(&req, 0x00, sizeof(req));
+
+       req.msg = msgInfo;
+       req.sendOpt = sendOpt;
+
+       err = msg_sms_send_message(NULL, &req);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_sms_send_message.h b/TC/msgTC/MapiTransport/utc_msg_sms_send_message.h
new file mode 100755 (executable)
index 0000000..aab36ca
--- /dev/null
@@ -0,0 +1,37 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam);
+static void utc_msg_sms_send_message_001(void);
+static void utc_msg_sms_send_message_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_sms_send_message_001,1},
+                       { utc_msg_sms_send_message_002,2},
+                       {NULL,0}
+};
diff --git a/TC/msgTC/MapiTransport/utc_msg_submit_req.c b/TC/msgTC/MapiTransport/utc_msg_submit_req.c
new file mode 100755 (executable)
index 0000000..723b3c7
--- /dev/null
@@ -0,0 +1,98 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "utc_msg_submit_req.h"
+
+static MSG_HANDLE_T msgHandle = NULL;
+msg_message_t msgInfo;
+MSG_SENDINGOPT_S sendOpt;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam)
+{
+       return;
+}
+
+void startup(void)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sort_rule;
+
+       err = msg_open_msg_handle(&msgHandle);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       msg_reg_sent_status_callback(msgHandle, &sentStatusCB, (void*)"sent status callback");
+
+       msgInfo = msg_new_message();
+
+       msg_set_message_type(msgInfo, MSG_TYPE_SMS);
+
+       msg_sms_set_message_body(msgInfo, "1234567890", 10);
+
+       msg_add_address(msgInfo, "01000000000", MSG_RECIPIENTS_TYPE_TO);
+
+       memset(&sendOpt, 0x00, sizeof(sendOpt));
+
+       sendOpt.bSetting = false;
+}
+void cleanup(void)
+{
+       msg_close_msg_handle(&msgHandle);
+}
+
+void utc_msg_submit_req_001()
+{
+       int err = MSG_SUCCESS;
+       MSG_REQUEST_S req;
+
+       memset(&req, 0x00, sizeof(req));
+
+       req.msg = msgInfo;
+       req.sendOpt = sendOpt;
+
+       err = msg_submit_req(msgHandle, &req);
+       if (err != MSG_SUCCESS)
+       {
+               tet_printf("err is [%d]", err);
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+void utc_msg_submit_req_002()
+{
+       int err = MSG_SUCCESS;
+       MSG_REQUEST_S req;
+
+       memset(&req, 0x00, sizeof(req));
+
+       req.msg = msgInfo;
+       req.sendOpt = sendOpt;
+
+       err = msg_submit_req(NULL, &req);
+       if (err != MSG_SUCCESS)
+       {
+               tet_result(TET_PASS);
+               return;
+       }
+
+       tet_result(TET_FAIL);
+}
diff --git a/TC/msgTC/MapiTransport/utc_msg_submit_req.h b/TC/msgTC/MapiTransport/utc_msg_submit_req.h
new file mode 100755 (executable)
index 0000000..8f15484
--- /dev/null
@@ -0,0 +1,37 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <tet_api.h>
+
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam);
+static void utc_msg_submit_req_001(void);
+static void utc_msg_submit_req_002(void);
+
+
+
+struct tet_testlist tet_testlist[] =
+{
+                       { utc_msg_submit_req_001,1},
+                       { utc_msg_submit_req_002,2},
+                       {NULL,0}
+};
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100755 (executable)
index 0000000..29ef78e
--- /dev/null
@@ -0,0 +1,126 @@
+# auto generated tet_scen
+all
+       "Starting Full Test Suite"
+       /msgTC/MapiSetting/utc_msg_get_config
+       /msgTC/MapiSetting/utc_msg_set_config
+       /msgTC/MapiFilter/utc_msg_add_filter
+       /msgTC/MapiFilter/utc_msg_delete_filter
+       /msgTC/MapiFilter/utc_msg_get_filter_list
+       /msgTC/MapiFilter/utc_msg_update_filter
+       /msgTC/MapiStorage/utc_msg_add_folder
+       /msgTC/MapiStorage/utc_msg_add_message
+       /msgTC/MapiStorage/utc_msg_get_conversation_view_list
+       /msgTC/MapiStorage/utc_msg_add_syncml_message
+       /msgTC/MapiStorage/utc_msg_get_folder_list
+       /msgTC/MapiStorage/utc_msg_get_folder_view_list
+       /msgTC/MapiStorage/utc_msg_get_mem_size
+       /msgTC/MapiStorage/utc_msg_get_message
+       /msgTC/MapiStorage/utc_msg_get_quick_panel_data
+       /msgTC/MapiStorage/utc_msg_get_thread_view_list
+       /msgTC/MapiStorage/utc_msg_move_msg_to_folder
+       /msgTC/MapiStorage/utc_msg_move_msg_to_storage
+       /msgTC/MapiStorage/utc_msg_release_folder_list
+       /msgTC/MapiStorage/utc_msg_release_thread_view_list
+       /msgTC/MapiStorage/utc_msg_reset_database
+       /msgTC/MapiStorage/utc_msg_generate_message
+       /msgTC/MapiStorage/utc_msg_count_message
+       /msgTC/MapiStorage/utc_msg_count_msg_by_contact
+       /msgTC/MapiStorage/utc_msg_thread_view_get_address
+       /msgTC/MapiStorage/utc_msg_count_msg_by_type
+       /msgTC/MapiStorage/utc_msg_thread_view_get_contact_id
+       /msgTC/MapiStorage/utc_msg_delete_all_msgs_in_folder
+       /msgTC/MapiStorage/utc_msg_thread_view_get_data
+       /msgTC/MapiStorage/utc_msg_delete_folder
+       /msgTC/MapiStorage/utc_msg_thread_view_get_direction
+       /msgTC/MapiStorage/utc_msg_delete_message
+       /msgTC/MapiStorage/utc_msg_thread_view_get_image_path
+       /msgTC/MapiStorage/utc_msg_delete_thread_message_list
+       /msgTC/MapiStorage/utc_msg_thread_view_get_mms_cnt
+       /msgTC/MapiStorage/utc_msg_thread_view_get_name
+       /msgTC/MapiStorage/utc_msg_thread_view_get_sms_cnt
+       /msgTC/MapiStorage/utc_msg_thread_view_get_thread_id
+       /msgTC/MapiStorage/utc_msg_thread_view_get_time
+       /msgTC/MapiStorage/utc_msg_thread_view_get_unread_cnt
+       /msgTC/MapiStorage/utc_msg_update_folder
+       /msgTC/MapiStorage/utc_msg_update_message
+       /msgTC/MapiStorage/utc_msg_update_protected_status
+       /msgTC/MapiStorage/utc_msg_update_read_status
+       /msgTC/MapiControl/utc_msg_open_msg_handle
+       /msgTC/MapiControl/utc_msg_close_msg_handle
+       /msgTC/MapiTransport/utc_msg_mms_forward_message
+       /msgTC/MapiTransport/utc_msg_reg_lbs_message_callback
+       /msgTC/MapiTransport/utc_msg_sms_send
+       /msgTC/MapiTransport/utc_msg_mms_reject_message
+       /msgTC/MapiTransport/utc_msg_reg_mms_conf_message_callback
+       /msgTC/MapiTransport/utc_msg_sms_send_message
+       /msgTC/MapiTransport/utc_msg_mms_retrieve_message
+       /msgTC/MapiTransport/utc_msg_reg_sent_status_callback
+       /msgTC/MapiTransport/utc_msg_submit_req
+       /msgTC/MapiTransport/utc_msg_mms_send_message
+       /msgTC/MapiTransport/utc_msg_reg_sms_message_callback
+       /msgTC/MapiTransport/utc_msg_mms_send_read_report
+       /msgTC/MapiTransport/utc_msg_reg_syncml_message_callback
+       /msgTC/MapiMessage/utc_msg_add_address
+       /msgTC/MapiMessage/utc_msg_get_time
+       /msgTC/MapiMessage/utc_msg_new_message
+       /msgTC/MapiMessage/utc_msg_mms_create_message
+       /msgTC/MapiMessage/utc_msg_is_in_sim
+       /msgTC/MapiMessage/utc_msg_release_message
+       /msgTC/MapiMessage/utc_msg_get_address_count
+       /msgTC/MapiMessage/utc_msg_is_mms
+       /msgTC/MapiMessage/utc_msg_reset_address
+       /msgTC/MapiMessage/utc_msg_get_dest_port
+       /msgTC/MapiMessage/utc_msg_is_protected
+       /msgTC/MapiMessage/utc_msg_set_direction_info
+       /msgTC/MapiMessage/utc_msg_get_direction_info
+       /msgTC/MapiMessage/utc_msg_is_read
+       /msgTC/MapiMessage/utc_msg_set_encode_type
+       /msgTC/MapiMessage/utc_msg_get_encode_type
+       /msgTC/MapiMessage/utc_msg_is_sms
+       /msgTC/MapiMessage/utc_msg_set_folder_id
+       /msgTC/MapiMessage/utc_msg_get_folder_id
+       /msgTC/MapiMessage/utc_msg_mms_add_attachment
+       /msgTC/MapiMessage/utc_msg_set_message_id
+       /msgTC/MapiMessage/utc_msg_get_ith_address
+       /msgTC/MapiMessage/utc_msg_mms_add_media
+       /msgTC/MapiMessage/utc_msg_set_message_type
+       /msgTC/MapiMessage/utc_msg_get_ith_contact_id
+       /msgTC/MapiMessage/utc_msg_mms_add_page
+       /msgTC/MapiMessage/utc_msg_set_network_status
+       /msgTC/MapiMessage/utc_msg_get_ith_name
+       /msgTC/MapiMessage/utc_msg_mms_add_region
+       /msgTC/MapiMessage/utc_msg_set_port
+       /msgTC/MapiMessage/utc_msg_get_ith_recipient_type
+       /msgTC/MapiMessage/utc_msg_mms_add_transition
+       /msgTC/MapiMessage/utc_msg_mms_add_meta
+       /msgTC/MapiMessage/utc_msg_set_priority_info
+       /msgTC/MapiMessage/utc_msg_get_ith_thread_id
+       /msgTC/MapiMessage/utc_msg_mms_destroy_message
+       /msgTC/MapiMessage/utc_msg_set_protect_status
+       /msgTC/MapiMessage/utc_msg_get_message_body_size
+       /msgTC/MapiMessage/utc_msg_mms_get_attachment
+       /msgTC/MapiMessage/utc_msg_set_read_status
+       /msgTC/MapiMessage/utc_msg_get_message_id
+       /msgTC/MapiMessage/utc_msg_mms_get_media
+       /msgTC/MapiMessage/utc_msg_set_scheduled_time
+       /msgTC/MapiMessage/utc_msg_get_message_type
+       /msgTC/MapiMessage/utc_msg_mms_get_message_body
+       /msgTC/MapiMessage/utc_msg_set_storage_id
+       /msgTC/MapiMessage/utc_msg_get_network_status
+       /msgTC/MapiMessage/utc_msg_mms_get_meta
+       /msgTC/MapiMessage/utc_msg_set_subject
+       /msgTC/MapiMessage/utc_msg_get_priority_info
+       /msgTC/MapiMessage/utc_msg_mms_get_page
+       /msgTC/MapiMessage/utc_msg_set_time
+       /msgTC/MapiMessage/utc_msg_get_scheduled_time
+       /msgTC/MapiMessage/utc_msg_mms_get_smil_region
+       /msgTC/MapiMessage/utc_msg_sms_get_message_body
+       /msgTC/MapiMessage/utc_msg_get_src_port
+       /msgTC/MapiMessage/utc_msg_mms_get_transition
+       /msgTC/MapiMessage/utc_msg_sms_set_message_body
+       /msgTC/MapiMessage/utc_msg_get_storage_id
+       /msgTC/MapiMessage/utc_msg_mms_set_message_body
+       /msgTC/MapiMessage/utc_msg_get_subject
+       /msgTC/MapiMessage/utc_msg_mms_set_rootlayout
+       "Completed Full Test Suite"
+# EOF
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100644 (file)
index 0000000..f7eda55
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option for build operation checking
+TET_BUILD_TOOL=make # build with using make command
+TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build
+TET_API_COMPLIANT=True # use TET API in Test Case ?
+TET_PASS_TC_NAME=True # report passed TC name in Journal file?
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100644 (file)
index 0000000..7b613aa
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option
+TET_CLEAN_TOOL=make clean # clean tool
+TET_CLEAN_FILE=Makefile # file for clean
+TET_API_COMPLIANT=True # TET API useage 
+TET_PASS_TC_NAME=True # showing name , passed TC
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100644 (file)
index 0000000..ef3e452
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capturing execution or not
+TET_EXEC_TOOL=  # ex) exec : execution tool set up/ Optional
+TET_EXEC_FILE=   # ex) exectool : execution file/ Optional
+TET_API_COMPLIANT=True # Test case or Tool usesTET API?
+TET_PASS_TC_NAME=True # showing Passed TC name ?
diff --git a/TC/tslist.txt b/TC/tslist.txt
new file mode 100755 (executable)
index 0000000..e592151
--- /dev/null
@@ -0,0 +1,5 @@
+msgTC/MapiSetting/tslist
+msgTC/MapiStorage/tslist
+msgTC/MapiControl/tslist
+msgTC/MapiTransport/tslist
+msgTC/MapiMessage/tslist
diff --git a/config/.msg_service.db b/config/.msg_service.db
new file mode 100755 (executable)
index 0000000..1eeb234
Binary files /dev/null and b/config/.msg_service.db differ
diff --git a/config/.msg_service.db-journal b/config/.msg_service.db-journal
new file mode 100755 (executable)
index 0000000..dd46069
Binary files /dev/null and b/config/.msg_service.db-journal differ
diff --git a/config/alert_on_call.mp3 b/config/alert_on_call.mp3
new file mode 100755 (executable)
index 0000000..c7c77d1
Binary files /dev/null and b/config/alert_on_call.mp3 differ
diff --git a/config/kdb-setting.sh b/config/kdb-setting.sh
new file mode 100755 (executable)
index 0000000..8358c02
--- /dev/null
@@ -0,0 +1,54 @@
+vconftool set -t bool db/msg/general/keep_copy 1
+vconftool set -t int db/msg/general/alert_tone 0
+vconftool set -t bool db/msg/general/auto_erase 0
+
+vconftool set -t int db/msg/sms_send/dcs 3
+vconftool set -t int db/msg/network_mode 4
+vconftool set -t bool db/msg/sms_send/reply_path 0
+vconftool set -t bool db/msg/sms_send/delivery_report 0
+vconftool set -t int db/msg/sms_send/save_storage 1
+
+vconftool set -t int db/msg/mms_send/msg_class 0
+vconftool set -t int db/msg/mms_send/priority 1
+vconftool set -t int db/msg/mms_send/expiry 0
+vconftool set -t bool db/msg/mms_send/custom_delivery 0
+vconftool set -t bool db/msg/mms_send/sender_visibility 0
+vconftool set -t bool db/msg/mms_send/delivery_report 1
+vconftool set -t bool db/msg/mms_send/read_reply 1
+vconftool set -t bool db/msg/mms_send/keep_copy 0
+vconftool set -t bool db/msg/mms_send/body_replying 0
+vconftool set -t bool db/msg/mms_send/hide_recipients 0
+vconftool set -t bool db/msg/mms_send/report_allowed 1
+vconftool set -t int db/msg/mms_send/reply_charging 0
+vconftool set -t int db/msg/mms_send/reply_charging_deadline 0
+vconftool set -t int db/msg/mms_send/reply_charging_size 0
+vconftool set -t int db/msg/mms_send/delivery_time 0
+vconftool set -t int db/msg/mms_send/creation_mode 2
+
+vconftool set -t int db/msg/mms_recv/home_network 0
+vconftool set -t int db/msg/mms_recv/abroad_network 0
+vconftool set -t bool db/msg/mms_recv/read_receipt 1
+vconftool set -t bool db/msg/mms_recv/delivery_receipt 1
+vconftool set -t bool db/msg/mms_recv/reject_unknown 0
+vconftool set -t bool db/msg/mms_recv/reject_advertisement 0
+
+vconftool set -t bool db/msg/push_msg/recv_option 1
+vconftool set -t int db/msg/push_msg/service_load 1
+
+vconftool set -t bool db/msg/cb_msg/receive 0
+vconftool set -t bool db/msg/cb_msg/all_channel 0
+vconftool set -t int db/msg/cb_msg/max_sim_count 0
+vconftool set -t int db/msg/cb_msg/channel_count 0
+vconftool set -t bool db/msg/cb_msg/language/0 0
+vconftool set -t bool db/msg/cb_msg/language/1 0
+vconftool set -t bool db/msg/cb_msg/language/2 0
+vconftool set -t bool db/msg/cb_msg/language/3 0
+vconftool set -t bool db/msg/cb_msg/language/4 0
+vconftool set -t bool db/msg/cb_msg/language/5 0
+vconftool set -t bool db/msg/cb_msg/language/6 0
+vconftool set -t bool db/msg/cb_msg/language/7 0
+vconftool set -t bool db/msg/cb_msg/language/8 0
+vconftool set -t bool db/msg/cb_msg/language/9 0
+
+vconftool set -t int db/msg/size_opt/msg_size 300
+
diff --git a/config/message_tone/Sherbet.wav b/config/message_tone/Sherbet.wav
new file mode 100755 (executable)
index 0000000..3d352e4
Binary files /dev/null and b/config/message_tone/Sherbet.wav differ
diff --git a/config/plugin.cfg b/config/plugin.cfg
new file mode 100755 (executable)
index 0000000..498d80d
--- /dev/null
@@ -0,0 +1,7 @@
+[sms-plugin]
+type=sms
+path=/usr/lib/libmsg_sms_plugin.so
+
+[mms-plugin]
+type=mms
+path=/usr/lib/libmsg_mms_plugin.so
diff --git a/debian/changelog b/debian/changelog
new file mode 100755 (executable)
index 0000000..039e295
--- /dev/null
@@ -0,0 +1,8 @@
+msg-service (0.8.7-5) unstable; urgency=low
+
+  * Add #include <sys/stat.h> to support chmod related defines.
+  * Fix DRM content issue(unregistered mo content)
+  * Git : public/pkgs/m/msg-service
+  * Tag : msg-service_0.8.7-5
+
+ -- Jaeyun Jeong <jyjeong@samsung.com>  Fri, 16 Mar 2012 17:54:21 +0900
\ No newline at end of file
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100755 (executable)
index 0000000..61c0577
--- /dev/null
@@ -0,0 +1,44 @@
+Source: msg-service
+Section: libs
+Priority: extra
+Maintainer: Jaeyun Jeong <jyjeong@samsung.com>, Sangkoo Kim <sangkoo.kim@samsung.com>, Seunghwan Lee <sh.cat.lee@samsung.com>, SoonMin Jung <sm0415.jung@samsung.com>, Jae-Young Lee <jy4710.lee@samsung.com>, KeeBum Kim <keebum.kim@samsung.com>
+Build-Depends: debhelper (>= 5), libnetwork-dev, libslp-setting-dev, libglib2.0-dev, libslp-tapi-dev, libslp-db-util-dev, libwbxml2-dev, libxml2-dev, libmm-player-dev, dlog-dev, libcontacts-service-dev, drm-client-dev, drm-trusted-dev, libslp-pm-dev, libmm-fileinfo-dev, libdevman-haptic-dev, libalarm-dev, capi-appfw-application-dev, libmm-session-sdk-dev, libmm-session-dev, libcurl-dev, libnotification-dev, libsecurity-server-client-dev, libmm-utility-dev, libsvi-dev, libmedia-thumbnail-dev
+Standards-Version: 0.1.0
+Homepage: N/A
+
+Package: libslp-msg-service-dev
+XB-Generate-Docs: yes
+Section: libdevel
+Architecture: any
+Depends: libslp-msg-service-0 (= ${Source-Version}), libglib2.0-dev
+Description: Messaging Framework Library (development)
+
+Package: libslp-msg-service-0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Messaging Framework Library (Library)
+
+Package: msg-service-tools
+Section: utils
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libslp-msg-service-0 (= ${Source-Version})
+Description: messaging server application
+
+Package: libslp-sms-plugin
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libslp-msg-service-0 (= ${Source-Version})
+Description: SMS Plugin Library
+
+Package: libslp-mms-plugin
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libslp-msg-service-0 (= ${Source-Version})
+Description: MMS Plugin Library
+
+Package: libslp-msg-service-0-dbg
+Section: debug
+Architecture: any
+Depends: libslp-msg-service-0 (= ${Source-Version}), msg-service-tools (= ${Source-Version}), ${shlibs:Depends}
+Description: Messaging Framework Library (unstripped)
diff --git a/debian/dirs b/debian/dirs
new file mode 100644 (file)
index 0000000..ca882bb
--- /dev/null
@@ -0,0 +1,2 @@
+usr/bin
+usr/sbin
diff --git a/debian/docs b/debian/docs
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/debian/libslp-mms-plugin.install.in b/debian/libslp-mms-plugin.install.in
new file mode 100755 (executable)
index 0000000..059a1a3
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/lib/libmsg_mms_language_pack.so
+@PREFIX@/lib/libmsg_mms_plugin.so
diff --git a/debian/libslp-msg-service-0.install.in b/debian/libslp-msg-service-0.install.in
new file mode 100755 (executable)
index 0000000..fa9615e
--- /dev/null
@@ -0,0 +1,9 @@
+@PREFIX@/lib/libmsg_utils.so
+@PREFIX@/lib/libmsg_plugin_manager.so
+@PREFIX@/lib/libmsg_framework_handler.so
+@PREFIX@/lib/libmsg_transaction_manager.so
+@PREFIX@/lib/libmsg_transaction_proxy.so
+@PREFIX@/lib/libmsg_mapi.so
+@PREFIX@/lib/libmsg_mapi.so.*
+@PREFIX@/share/msg-service/plugin.cfg
+etc/*
diff --git a/debian/libslp-msg-service-dev.install.in b/debian/libslp-msg-service-dev.install.in
new file mode 100755 (executable)
index 0000000..3683e76
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/include/msg-service/*.h
+@PREFIX@/lib/pkgconfig/*.pc
diff --git a/debian/libslp-sms-plugin.install.in b/debian/libslp-sms-plugin.install.in
new file mode 100755 (executable)
index 0000000..b2d564e
--- /dev/null
@@ -0,0 +1 @@
+@PREFIX@/lib/libmsg_sms_plugin.so
diff --git a/debian/msg-service-tools.install.in b/debian/msg-service-tools.install.in
new file mode 100755 (executable)
index 0000000..5962ca9
--- /dev/null
@@ -0,0 +1,5 @@
+@PREFIX@/bin/*
+@PREFIX@/share/media/*
+@DATADIR@/etc/msg-service/*
+#@DATADIR@/dbspace/.msg_service.db
+#@DATADIR@/dbspace/.msg_service.db-journal
diff --git a/debian/msg-service-tools.postinst b/debian/msg-service-tools.postinst
new file mode 100755 (executable)
index 0000000..894e954
--- /dev/null
@@ -0,0 +1,208 @@
+#!/bin/sh
+set -e
+# Automatically added by dh_makeshlibs
+if [ "$1" = "configure" ]; then
+       ldconfig
+fi
+# End automatically added section
+
+#. /etc/ipkg/functions
+
+#PATH=$PATH:/usr/bin
+#CURRENT_PATH=$PWD
+
+#cd /usr/bin
+
+#initDB
+#rm /opt/dbspace/.msg_service.db*
+
+if [ ! -f /opt/dbspace/.msg_service.db ]
+then
+       sqlite3 /opt/dbspace/.msg_service.db "PRAGMA journal_mode = PERSIST;
+
+       CREATE TABLE MSG_ADDRESS_TABLE(ADDRESS_ID INTEGER PRIMARY KEY, ADDRESS_TYPE INTEGER, RECIPIENT_TYPE INTEGER, ADDRESS_VAL TEXT, CONTACT_ID INTEGER, DISPLAY_NAME TEXT, FIRST_NAME TEXT, LAST_NAME TEXT, IMAGE_PATH TEXT, SYNC_TIME DATETIME, UNREAD_CNT INTEGER DEFAULT 0, SMS_CNT INTEGER DEFAULT 0, MMS_CNT INTEGER DEFAULT 0, MAIN_TYPE INTEGER NOT NULL, SUB_TYPE INTEGER NOT NULL, MSG_DIRECTION INTEGER NOT NULL, MSG_TIME DATETIME, MSG_TEXT TEXT);
+       CREATE TABLE MSG_FOLDER_TABLE(FOLDER_ID INTEGER PRIMARY KEY, FOLDER_NAME TEXT NOT NULL, FOLDER_TYPE INTEGER DEFAULT 0);
+       CREATE TABLE MSG_MESSAGE_TABLE(MSG_ID INTEGER PRIMARY KEY, ADDRESS_ID INTEGER, FOLDER_ID INTEGER, REFERENCE_ID INTEGER, STORAGE_ID INTEGER NOT NULL, MAIN_TYPE INTEGER NOT NULL, SUB_TYPE INTEGER NOT NULL, DISPLAY_TIME DATETIME, DATA_SIZE INTEGER DEFAULT 0, NETWORK_STATUS INTEGER DEFAULT 0, READ_STATUS INTEGER DEFAULT 0, PROTECTED INTEGER DEFAULT 0, PRIORITY INTEGER DEFAULT 0, MSG_DIRECTION INTEGER NOT NULL, SCHEDULED_TIME DATETIME, BACKUP INTEGER DEFAULT 0, SUBJECT TEXT, MSG_DATA TEXT, THUMB_PATH TEXT, MSG_TEXT TEXT, DELIVERY_REPORT_STATUS INTEGER DEFAULT 0, DELIVERY_REPORT_TIME DATETIME, READ_REPORT_STATUS INTEGER DEFAULT 0, READ_REPORT_TIME DATETIME, ATTACHMENT_COUNT INTEGER DEFAULT 0, FOREIGN KEY(ADDRESS_ID) REFERENCES MSG_ADDRESS_TABLE(ADDRESS_ID), FOREIGN KEY(FOLDER_ID) REFERENCES MSG_FOLDER_TABLE(FOLDER_ID));
+       CREATE TABLE MSG_SIM_TABLE(MSG_ID INTEGER, SIM_ID INTEGER NOT NULL, FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));
+       CREATE TABLE MSG_PUSH_TABLE(MSG_ID INTEGER, ACTION INTEGER, CREATED INTEGER, EXPIRES INTEGER, ID TEXT, HREF TEXT, CONTENT TEXT, FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));
+       CREATE TABLE MSG_CBMSG_TABLE(MSG_ID INTEGER, CB_MSG_ID INTEGER NOT NULL, FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));
+       CREATE TABLE MSG_SYNCML_TABLE(MSG_ID INTEGER, EXT_ID INTEGER NOT NULL, PINCODE INTEGER NOT NULL, FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));
+       CREATE TABLE MSG_SCHEDULED_TABLE(MSG_ID INTEGER, ALARM_ID INTEGER NOT NULL, LISTENER_FD INTEGER NOT NULL, FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));
+       CREATE TABLE MSG_SMS_SENDOPT_TABLE(MSG_ID INTEGER, DELREP_REQ INTEGER NOT NULL, KEEP_COPY INTEGER NOT NULL, REPLY_PATH INTEGER NOT NULL, FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));
+       CREATE TABLE MSG_FILTER_TABLE(FILTER_ID INTEGER PRIMARY KEY, FILTER_TYPE INTEGER NOT NULL, FILTER_VALUE TEXT NOT NULL);
+       CREATE TABLE MSG_MMS_MESSAGE_TABLE(REFERENCE_ID INTEGER, TRANSACTION_ID TEXT, MESSAGE_ID TEXT, FWD_MESSAGE_ID TEXT, CONTENTS_LOCATION TEXT, FILE_PATH TEXT, FOREIGN KEY(REFERENCE_ID) REFERENCES MSG_MESSAGE_TABLE(REFERENCE_ID));
+       CREATE TABLE MSG_MMS_ATTR_TABLE(REFERENCE_ID INTEGER, VERSION INTEGER NOT NULL, DATA_TYPE INTEGER DEFAULT -1, DATE DATETIME, HIDE_ADDRESS INTEGER DEFAULT 0, ASK_DELIVERY_REPORT INTEGER DEFAULT 0, REPORT_ALLOWED INTEGER DEFAULT 0, READ_REPORT_ALLOWED_TYPE INTEGER DEFAULT 0, ASK_READ_REPLY INTEGER DEFAULT 0, READ INTEGER DEFAULT 0, READ_REPORT_SEND_STATUS     INTEGER DEFAULT 0, READ_REPORT_SENT INTEGER DEFAULT 0, PRIORITY INTEGER DEFAULT 0, KEEP_COPY INTEGER DEFAULT 0, MSG_SIZE INTEGER NOT NULL, MSG_CLASS INTEGER DEFAULT -1, EXPIRY_TIME DATETIME, CUSTOM_DELIVERY_TIME INTEGER DEFAULT 0, DELIVERY_TIME DATETIME, MSG_STATUS INTEGER DEFAULT -1, FOREIGN KEY(REFERENCE_ID) REFERENCES MSG_MESSAGE_TABLE(REFERENCE_ID));
+
+       CREATE INDEX MSG_ADDRESS_INDEX ON MSG_ADDRESS_TABLE(ADDRESS_ID);
+       CREATE INDEX MSG_FOLDER_INDEX ON MSG_FOLDER_TABLE(FOLDER_ID);
+       CREATE INDEX MSG_MESSAGE_INDEX ON MSG_MESSAGE_TABLE(MSG_ID, ADDRESS_ID, FOLDER_ID);
+
+       INSERT INTO MSG_FOLDER_TABLE VALUES (1, 'INBOX', 1);
+       INSERT INTO MSG_FOLDER_TABLE VALUES (2, 'OUTBOX', 2);
+       INSERT INTO MSG_FOLDER_TABLE VALUES (3, 'SENTBOX', 2);
+       INSERT INTO MSG_FOLDER_TABLE VALUES (4, 'DRAFT', 3);
+       INSERT INTO MSG_FOLDER_TABLE VALUES (5, 'CBMSGBOX', 1);
+
+       INSERT INTO MSG_ADDRESS_TABLE VALUES (0, 0, 0, '', 0, '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '');"
+#      INSERT INTO MSG_ADDRESS_TABLE VALUES (1, 1, 1, '01030016057', 0, '', '', '', '', 0, 0, 2, 0, 1, 0, 1, 1284036008, 'Welcome to SLP world');
+
+#      INSERT INTO MSG_MESSAGE_TABLE VALUES (1, 1, 3, 1, 1, 1, 0, 1284035928, 6, 2, 1, 0, 1, 0, 0, 0, '', '', '', 'Hello.', -1, 0, -1, 0, 0);
+#      INSERT INTO MSG_MESSAGE_TABLE VALUES (2, 1, 1, 2, 1, 1, 0, 1284036008, 20, 6, 1, 0, 1, 1, 0, 0, '', '', '', 'Welcome to SLP world', -1, 0, -1, 0, 0);"
+fi
+
+########## Setting Permission and Owner ###########
+
+if [ ${USER} == "root" ]
+then
+       # 1. executable
+        #chown root:root /usr/bin/msg-server
+       #chown root:root /usr/bin/msg-test-app
+
+       # 2. configuration
+       chown root:root /usr/share/msg-service/plugin.cfg
+#      chown root:root /opt/etc/msg-service/mms_plugin.cfg
+#      chown root:root /opt/etc/msg-service/kdb-setting.sh
+
+       # 3. database
+       chown :6011 /opt/dbspace/.msg_service.db
+       chown :6011 /opt/dbspace/.msg_service.db-journal
+
+       # 4. other files
+       chown root:root /opt/etc/msg-service/A.smi
+       chown root:root /opt/etc/msg-service/P091120_104633.jpg
+       chown root:root /opt/etc/msg-service/Temp0_2.txt
+       chown root:root /opt/etc/msg-service/Temp1_0.txt
+       chown root:root /opt/etc/msg-service/V091120_104905.3gp
+       chown root:root /opt/etc/msg-service/alert_on_call.mp3
+       chown root:root /opt/etc/msg-service/audio.amr
+       chown root:root /usr/share/media/Sherbet.wav
+fi
+
+# Change File Permission
+# 1. executable
+#chmod 700 /usr/bin/msg-server
+#chmod 700 /usr/bin/msg-test-app
+
+# 2. configuration
+chmod 644 /usr/share/msg-service/plugin.cfg
+#chmod 644 /opt/etc/msg-service/mms_plugin.cfg
+#chmod 644 /opt/etc/msg-service/kdb-setting.sh
+
+# 3. database
+chmod 660 /opt/dbspace/.msg_service.db
+chmod 660 /opt/dbspace/.msg_service.db-journal
+
+# 4. other files
+chmod 644 /opt/etc/msg-service/A.smi
+chmod 644 /opt/etc/msg-service/P091120_104633.jpg
+chmod 644 /opt/etc/msg-service/Temp0_2.txt
+chmod 644 /opt/etc/msg-service/Temp1_0.txt
+chmod 644 /opt/etc/msg-service/V091120_104905.3gp
+chmod 644 /opt/etc/msg-service/alert_on_call.mp3
+chmod 644 /opt/etc/msg-service/audio.amr
+chmod 644 /usr/share/media/Sherbet.wav
+
+
+########## Setting Config Value ##########
+
+# General Options
+vconftool set -t bool db/msg/general/keep_copy 1
+vconftool set -t int db/msg/general/alert_tone 0
+vconftool set -t bool db/msg/general/auto_erase 0
+vconftool set -t bool db/msg/general/block_msg 0
+vconftool set -t int db/msg/general/contact_sync_time 0
+
+# SMS Send Options
+vconftool set -t int db/msg/sms_send/dcs 3
+vconftool set -t int db/msg/network_mode 2
+vconftool set -t bool db/msg/sms_send/reply_path 0
+vconftool set -t bool db/msg/sms_send/delivery_report 0
+vconftool set -t int db/msg/sms_send/save_storage 1
+
+# MMS Send Options
+vconftool set -t int db/msg/mms_send/msg_class 0
+vconftool set -t int db/msg/mms_send/priority 1
+vconftool set -t int db/msg/mms_send/expiry_time 0
+vconftool set -t int db/msg/mms_send/custom_delivery 0
+vconftool set -t bool db/msg/mms_send/sender_visibility 0
+vconftool set -t bool db/msg/mms_send/delivery_report 1
+vconftool set -t bool db/msg/mms_send/read_reply 1
+vconftool set -t bool db/msg/mms_send/keep_copy 0
+vconftool set -t bool db/msg/mms_send/body_replying 0
+vconftool set -t bool db/msg/mms_send/hide_recipients 0
+vconftool set -t bool db/msg/mms_send/report_allowed 1
+vconftool set -t int db/msg/mms_send/reply_charging 0
+vconftool set -t int db/msg/mms_send/reply_charging_deadline 0
+vconftool set -t int db/msg/mms_send/reply_charging_size 0
+vconftool set -t int db/msg/mms_send/delivery_time 0
+vconftool set -t int db/msg/mms_send/creation_mode 2
+
+# MMS Receive Options
+vconftool set -t int db/msg/mms_recv/home_network 0
+vconftool set -t int db/msg/mms_recv/abroad_network 0
+vconftool set -t bool db/msg/mms_recv/read_receipt 1
+vconftool set -t bool db/msg/mms_recv/delivery_receipt 1
+vconftool set -t bool db/msg/mms_recv/reject_unknown 0
+vconftool set -t bool db/msg/mms_recv/reject_advertisement 0
+
+# MMS Receive Options
+vconftool set -t int db/msg/mms_style/font_size 30
+vconftool set -t bool db/msg/mms_style/font_style/bold 0
+vconftool set -t bool db/msg/mms_style/font_style/italic 0
+vconftool set -t bool db/msg/mms_style/font_style/underline 0
+vconftool set -t int db/msg/mms_style/font_color/red 0
+vconftool set -t int db/msg/mms_style/font_color/green 0
+vconftool set -t int db/msg/mms_style/font_color/blue 0
+vconftool set -t int db/msg/mms_style/font_color/hue 255
+vconftool set -t int db/msg/mms_style/bg_color/red 255
+vconftool set -t int db/msg/mms_style/bg_color/green 255
+vconftool set -t int db/msg/mms_style/bg_color/blue 255
+vconftool set -t int db/msg/mms_style/bg_color/hue 255
+vconftool set -t int db/msg/mms_style/page_dur 2
+vconftool set -t int db/msg/mms_style/page_custom_dur 0
+vconftool set -t int db/msg/mms_style/page_dur_manual 0
+
+# Push Msg Options
+vconftool set -t bool db/msg/push_msg/recv_option 1
+vconftool set -t int db/msg/push_msg/service_load 1
+
+# CB Msg Options
+vconftool set -t bool db/msg/cb_msg/receive 0
+vconftool set -t bool db/msg/cb_msg/all_channel 0
+vconftool set -t int db/msg/cb_msg/max_sim_count 0
+vconftool set -t int db/msg/cb_msg/channel_count 0
+vconftool set -t bool db/msg/cb_msg/language/0 0
+vconftool set -t bool db/msg/cb_msg/language/1 0
+vconftool set -t bool db/msg/cb_msg/language/2 0
+vconftool set -t bool db/msg/cb_msg/language/3 0
+vconftool set -t bool db/msg/cb_msg/language/4 0
+vconftool set -t bool db/msg/cb_msg/language/5 0
+vconftool set -t bool db/msg/cb_msg/language/6 0
+vconftool set -t bool db/msg/cb_msg/language/7 0
+vconftool set -t bool db/msg/cb_msg/language/8 0
+vconftool set -t bool db/msg/cb_msg/language/9 0
+
+# Voice Mail Options
+vconftool set -t string db/msg/voice_mail/voice_mail_number "12345678"
+
+# MMS Size Options
+vconftool set -t int db/msg/size_opt/msg_size 300
+
+vconftool set -t int db/badge/org.tizen.message 0
+
+if [ ${USER} == "root" ]
+then
+
+       # Msg Count
+       vconftool set -t int db/msg/recv_sms 0 -u 0
+       vconftool set -t int db/msg/recv_mms 0 -u 0
+fi
+
+
+#cd $CURRENT_PATH
+
+
+#mkdir /opt/system/msg-service
+
+#config "msg-service-@MACHINE@"
+
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..9f1794c
--- /dev/null
@@ -0,0 +1,132 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+CFLAGS = -Wall -g
+CXXFLAGS ?=  -Wall -g
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+MACHINE=aquila
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+       CXXFLAGS += -O0
+else
+       CFLAGS += -O2
+       CXXFLAGS += -O2
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+
+CMAKE_TMP_DIR = $(CURDIR)/cmake_tmp
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       # Add here commands to configure the package.
+
+       mkdir -p $(CMAKE_TMP_DIR);
+       cd $(CMAKE_TMP_DIR); CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+       touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp 
+       dh_testdir
+
+       # Add here commands to compile the package.
+       cd $(CMAKE_TMP_DIR) && $(MAKE)
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               cat $$f > $${f%.in}; \
+               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+               sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+       done
+
+
+       touch $@
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       -$(MAKE) clean
+       rm -rf CMakeCache.txt
+       rm -rf CMakeFiles
+       rm -rf cmake_install.cmake
+       rm -rf Makefile
+       rm -rf install_manifest.txt
+       rm -rf *.so
+       rm -rf $(CMAKE_TMP_DIR)
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               rm -f $${f%.in}; \
+       done
+
+       dh_clean 
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       # Add here commands to install the package into debian/msg-service.
+       cd $(CMAKE_TMP_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+       mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/
+       ln -s ../init.d/msg-server $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S70msg-server
+       mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/
+       ln -s ../init.d/msg-server $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/S70msg-server
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs 
+       dh_installdocs
+       dh_installexamples
+       dh_install --sourcedir debian/tmp
+#      dh_install
+#      dh_installmenu
+#      dh_installdebconf       
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_python
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+       dh_installman
+       dh_link
+       dh_strip --dbg-package=libslp-msg-service-0-dbg
+       dh_compress
+       dh_fixperms
+#      dh_perl
+       dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..3abb9e5
--- /dev/null
@@ -0,0 +1,152 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(msg-server CXX)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Debug")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall")
+
+#########################################################
+# Define Plugin Manager
+##########################################################
+
+SET(PLUGIN-MANAGER-SRCS
+       ${CMAKE_SOURCE_DIR}/framework/plugin-manager/MsgPluginManager.cpp
+       ${CMAKE_SOURCE_DIR}/framework/plugin-manager/MsgPluginConfig.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include/common
+       ${CMAKE_SOURCE_DIR}/include/framework
+       ${CMAKE_SOURCE_DIR}/include/utils
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(plugin_manager_pkgs REQUIRED glib-2.0 dlog vconf)
+
+FOREACH(flag ${plugin_manager_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${PLUGIN-MANAGER-LIB} SHARED ${PLUGIN-MANAGER-SRCS})
+TARGET_LINK_LIBRARIES(${PLUGIN-MANAGER-LIB} ${plugin_manager_pkgs_LDFLAGS} ${UTILS-LIB} dl)
+
+INSTALL(TARGETS ${PLUGIN-MANAGER-LIB} LIBRARY DESTINATION lib)
+
+##########################################################
+# Define Messaging Framework Handler
+##########################################################
+
+SET(FW-HANDLER-SRCS
+       ${CMAKE_SOURCE_DIR}/framework/setting-handler/MsgSettingHandler.cpp
+       ${CMAKE_SOURCE_DIR}/framework/storage-handler/MsgStorageManager.cpp
+       ${CMAKE_SOURCE_DIR}/framework/storage-handler/MsgStorageMessage.cpp
+       ${CMAKE_SOURCE_DIR}/framework/storage-handler/MsgStorageMms.cpp
+       ${CMAKE_SOURCE_DIR}/framework/storage-handler/MsgStorageFolder.cpp
+       ${CMAKE_SOURCE_DIR}/framework/storage-handler/MsgStorageSim.cpp
+       ${CMAKE_SOURCE_DIR}/framework/storage-handler/MsgStorageUtil.cpp
+       ${CMAKE_SOURCE_DIR}/framework/submit-handler/MsgSubmitHandler.cpp
+       ${CMAKE_SOURCE_DIR}/framework/deliver-handler/MsgDeliverHandler.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include/common
+       ${CMAKE_SOURCE_DIR}/include/framework
+       ${CMAKE_SOURCE_DIR}/include/utils
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(fw_handler_pkgs REQUIRED glib-2.0 dlog vconf capi-appfw-application)
+
+FOREACH(flag ${fw_handler_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -std=c++0x")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${FW-HANDLER-LIB} SHARED ${FW-HANDLER-SRCS})
+TARGET_LINK_LIBRARIES(${FW-HANDLER-LIB} ${fw_handler_pkgs_LDFLAGS} ${UTILS-LIB} ${PLUGIN-MANAGER-LIB})
+
+INSTALL(TARGETS ${FW-HANDLER-LIB} DESTINATION lib COMPONENT RuntimeLibraries)
+
+##########################################################
+# Define Transaction Manager
+##########################################################
+
+SET(TRANS-MANAGER-SRCS
+       ${CMAKE_SOURCE_DIR}/framework/transaction-manager/MsgCmdHandlerSetting.cpp
+       ${CMAKE_SOURCE_DIR}/framework/transaction-manager/MsgCmdHandlerStorage.cpp
+       ${CMAKE_SOURCE_DIR}/framework/transaction-manager/MsgCmdHandlerTransport.cpp
+       ${CMAKE_SOURCE_DIR}/framework/transaction-manager/MsgTransManager.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include/common
+       ${CMAKE_SOURCE_DIR}/include/framework
+       ${CMAKE_SOURCE_DIR}/include/utils
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(trans_manager_pkgs REQUIRED glib-2.0 security-server dlog vconf)
+
+FOREACH(flag ${trans_manager_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${TRANS-MANAGER-LIB} SHARED ${TRANS-MANAGER-SRCS})
+TARGET_LINK_LIBRARIES(${TRANS-MANAGER-LIB} ${trans_manager_pkgs_LDFLAGS} ${UTILS-LIB} ${FW-HANDLER-LIB})
+
+INSTALL(TARGETS ${TRANS-MANAGER-LIB} DESTINATION lib COMPONENT RuntimeLibraries)
+
+##########################################################
+# Define Execute File
+##########################################################
+
+SET(MAIN-SRCS
+       ${CMAKE_SOURCE_DIR}/framework/main.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include/common
+       ${CMAKE_SOURCE_DIR}/include/framework
+       ${CMAKE_SOURCE_DIR}/include/utils
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(main_pkgs REQUIRED glib-2.0 dbus-glib-1 dlog vconf)
+
+FOREACH(flag ${main_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${MAIN-SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${main_pkgs_LDFLAGS} ${UTILS-LIB} ${PLUGIN-MANAGER-LIB} ${TRANS-MANAGER-LIB} ${FW-HANDLER-LIB})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+
diff --git a/framework/deliver-handler/MsgDeliverHandler.cpp b/framework/deliver-handler/MsgDeliverHandler.cpp
new file mode 100755 (executable)
index 0000000..3353791
--- /dev/null
@@ -0,0 +1,339 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+// for sl message browser launch
+#include <app_service.h>
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgContact.h"
+#include "MsgUtilStorage.h"
+#include "MsgGconfWrapper.h"
+#include "MsgSoundPlayer.h"
+#include "MsgPluginManager.h"
+#include "MsgStorageHandler.h"
+#include "MsgDeliverHandler.h"
+#include "MsgNotificationWrapper.h"
+
+/*==================================================================================================
+                                     VARIABLES
+==================================================================================================*/
+extern MsgDbHandler dbHandle;
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_ID_T reqID)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_DEBUG(" msgtype subtype is [%d]", pMsgInfo->msgType.subType);
+
+       if (pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) {
+               // keep origianl subType
+               MSG_SUB_TYPE_T subType = pMsgInfo->msgType.subType;
+
+               /* If Retrieve Failed, Msg SubType is remained as Notification Ind */
+               if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_FAIL)
+                       pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS;
+
+               err = MsgStoUpdateMMSMessage(pMsgInfo);
+
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("Command Handle Success : MsgStoUpdateMessage()");
+
+               if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS) {
+                       MSG_DEBUG("### MSG_NETWORK_RETRIEVE_SUCCESS ###");
+                       //Update Mms Message to MMS Plugin DB
+
+                       // MMS Received Ind Process Func
+                       MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(pMsgInfo->msgType.mainType);
+
+                       //Contents of msg Data was removed and replaced to retrievedFilePath
+                       // NOTICE:: now it was moved to handleEvent in MsgListnerThread
+                       err = plg->updateMessage(pMsgInfo, NULL, NULL);
+                       if (err != MSG_SUCCESS)
+                               return MSG_ERR_STORAGE_ERROR;
+               }
+
+               MSG_DEBUG(" ######################### MESSAGE UPDATE COMPLETED!!! ######################");
+
+               bool readStatus = false;
+
+               MsgStoGetReadStatus(pMsgInfo->msgId, &readStatus);
+               MSG_DEBUG("### readStatus = %d ###", readStatus);
+
+               //Update Read Status to Unread beacaus Noti is Read
+               if (subType == MSG_RETRIEVE_MANUALCONF_MMS && pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS) {
+                       MSG_DEBUG("###2. subType = %d ###", pMsgInfo->msgType.subType);
+
+                       if (readStatus == true)
+                               MsgStoSetReadStatus(&dbHandle, pMsgInfo->msgId, false);
+               }
+
+               // update badge
+               if (subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS) {
+                       int smsCnt = 0;
+                       int mmsCnt = 0;
+
+                       smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE);
+                       mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
+
+                       MsgSettingHandleNewMsg(smsCnt, mmsCnt);
+               }
+
+               if (subType == MSG_RETRIEVE_AUTOCONF_MMS) {
+                       // play message-tone when MMS retrieved
+                       MsgSoundPlayStart();
+                       MsgInsertNoti(&dbHandle, pMsgInfo);
+               }  else if (subType == MSG_RETRIEVE_MANUALCONF_MMS) {
+                       if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS) {
+                               MSG_DEBUG("Manual success");
+                               MsgInsertTicker("Message Retrieved", MESSAGE_RETRIEVED);
+                       } else if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_FAIL) {
+                               MSG_DEBUG("Manual failed");
+                               MsgInsertTicker("Retrieving message failed", RETRIEVING_MESSAGE_FAILED);
+                       }
+               }
+       }
+       else if (pMsgInfo->msgType.subType == MSG_SENDREQ_MMS || pMsgInfo->msgType.subType == MSG_SENDCONF_MMS)
+       {
+               MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(pMsgInfo->msgType.mainType);
+               // change subType for storage update
+               pMsgInfo->msgType.subType = MSG_SENDCONF_MMS;
+
+               err = MsgStoUpdateMMSMessage(pMsgInfo);
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("Command Handle Success : MsgStoUpdateMMSMessage()");
+
+               err = plg->updateMessage(pMsgInfo, NULL, NULL);
+               if (err != MSG_SUCCESS)
+                       return MSG_ERR_STORAGE_ERROR;
+
+               MSG_DEBUG("pMsg->networkStatus : %d", pMsgInfo->networkStatus);
+               err = MsgStoUpdateNetworkStatus(pMsgInfo, pMsgInfo->networkStatus);
+               if (err != MSG_SUCCESS)
+                       return MSG_ERR_STORAGE_ERROR;
+
+               if (pMsgInfo->networkStatus == MSG_NETWORK_SEND_SUCCESS)
+               {
+                       err = MsgStoMoveMessageToFolder(pMsgInfo->msgId, MSG_SENTBOX_ID);
+                       if (err != MSG_SUCCESS)
+                               return MSG_ERR_STORAGE_ERROR;
+               }
+
+               // Get subject and text
+               MsgStoGetText(pMsgInfo->msgId, pMsgInfo->subject, pMsgInfo->msgText);
+
+               MSG_DEBUG(" ######################### MESSAGE UPDATE COMPLETED!!! ######################");
+       }
+       return err;
+}
+
+MSG_ERROR_T MsgHandleIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       if (pMsgInfo->msgType.mainType == MSG_SMS_TYPE)
+       {
+               if (pMsgInfo->msgPort.valid == true)
+                       return MSG_SUCCESS;
+
+               err = MsgHandleSMS(pMsgInfo, pSendNoti);
+
+               if (err == MSG_SUCCESS && *pSendNoti == true)
+               {
+                       MsgSoundPlayStart();
+
+//                     if (pMsgInfo->msgType.subType != MSG_STATUS_REPORT_SMS)
+                       {
+                               int smsCnt = 0, mmsCnt = 0;
+
+                               smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE);
+                               mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
+
+                               MsgSettingHandleNewMsg(smsCnt, mmsCnt);
+                               MsgInsertNoti(&dbHandle, pMsgInfo);
+                       }
+               }
+       }
+       else if (pMsgInfo->msgType.mainType == MSG_MMS_TYPE)
+       {
+               err = MsgHandleMMS(pMsgInfo, pSendNoti);
+       }
+
+       MSG_END();
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       if ((pMsgInfo->msgType.subType >= MSG_WAP_SI_SMS) && (pMsgInfo->msgType.subType <= MSG_WAP_CO_SMS))
+       {
+               MSG_DEBUG("Starting WAP Message Incoming.");
+
+               MSG_PUSH_SERVICE_TYPE_T serviceType = (MSG_PUSH_SERVICE_TYPE_T)MsgSettingGetInt(PUSH_SERVICE_TYPE);
+               service_h svc_handle = NULL;
+
+               switch (pMsgInfo->msgType.subType)
+               {
+                       case MSG_WAP_SL_SMS:
+                       {
+                               *pSendNoti = false;
+
+                               if (serviceType == MSG_PUSH_SERVICE_ALWAYS) {
+                                       if (service_create(&svc_handle) < 0) {
+                                               MSG_DEBUG("Fail to create service handle");
+                                               break;
+                                       }
+                                       if (!svc_handle) {
+                                               MSG_DEBUG("Service handle is NULL");
+                                               break;
+                                       }
+                                       if (service_set_operation(svc_handle, SERVICE_OPERATION_VIEW) < 0) {
+                                               MSG_DEBUG("Fail to create service handle");
+                                               service_destroy(svc_handle);
+                                               break;
+                                       }
+                                       if (service_set_uri(svc_handle, pMsgInfo->msgText) < 0) {
+                                               MSG_DEBUG("Fail to set uri");
+                                               service_destroy(svc_handle);
+                                               break;
+                                       }
+                                       if (service_set_package(svc_handle, MSG_SVC_PKG_NAME_BROWSER) < 0) {
+                                               MSG_DEBUG("Fail to set package");
+                                               service_destroy(svc_handle);
+                                               break;
+                                       }
+                                       if (service_send_launch_request(svc_handle, NULL, NULL) < 0) {
+                                               MSG_DEBUG("Fail to launch browser");
+                                               service_destroy(svc_handle);
+                                               break;
+                                       }
+
+                                       service_destroy(svc_handle);
+
+                               } else if (serviceType == MSG_PUSH_SERVICE_PROMPT) {
+                                       char urlString[MAX_COMMAND_LEN+1];
+                                       memset(urlString, 0x00, sizeof(urlString));
+
+                                       snprintf(urlString, MAX_COMMAND_LEN, "message-dialog -m PUSH_MSG_ALWAYS_ASK -u %s &", pMsgInfo->msgText);
+
+                                       system(urlString);
+                               }
+
+                       }
+                       break;
+
+                       case MSG_WAP_SI_SMS:
+                       case MSG_WAP_CO_SMS:
+                       {
+                               *pSendNoti = false;
+                       }
+                       break;
+               }
+       }
+       else if (pMsgInfo->msgType.subType == MSG_STATUS_REPORT_SMS)
+       {
+               unsigned int addrId = 0;
+
+               // Get Address ID
+               MsgExistAddress(&dbHandle, pMsgInfo->addressList[0].addressVal, &addrId);
+
+               MSG_DEBUG("address ID : [%d], Value : [%s]", addrId, pMsgInfo->addressList[0].addressVal);
+
+               pMsgInfo->addressList[0].threadId = (MSG_THREAD_ID_T)addrId;
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo,  bool *pSendNoti)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_REQUEST_INFO_S request = {0};
+       bool bReject = false;
+
+       // MMS Received Ind Process Func
+       MSG_MAIN_TYPE_T msgMainType = pMsgInfo->msgType.mainType;
+       MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(msgMainType);
+
+       // Need to process m-delivery-ind, m-notification-ind, m-read-orig-ind
+       err = plg->processReceivedInd(pMsgInfo, &request, &bReject);
+
+       if (err == MSG_SUCCESS) {
+               MSG_DEBUG("Process Message Success : processReceivedInd(), btextsms %d", pMsgInfo->bTextSms);
+       } else {
+               MSG_DEBUG("Process Message Fail : processReceivedInd()");
+               return err;
+       }
+
+       // Add into DB
+       if ((pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) && bReject == false) {
+
+               err = MsgStoAddMessage(pMsgInfo, NULL);
+
+               if (err != MSG_SUCCESS) {
+                       MSG_DEBUG("MsgStoAddMessage() Error: [%d]", err);
+                       return err;
+               }
+       } else if (pMsgInfo->msgType.subType == MSG_READORGIND_MMS || pMsgInfo->msgType.subType == MSG_DELIVERYIND_MMS) {
+               MsgSoundPlayStart();
+               *pSendNoti = false;
+       }
+
+       //In the case of m-notification-ind, we should decide whether to send m-notify-response-ind or http 'Get'
+       //submit request
+       if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) {
+               if (request.msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS && bReject == false) {
+                       MsgSoundPlayStart();
+
+                       int smsCnt = 0;
+                       int mmsCnt = 0;
+
+                       smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE);
+                       mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
+
+                       MsgSettingHandleNewMsg(smsCnt, mmsCnt);
+                       MsgInsertNoti(&dbHandle, pMsgInfo);
+               }
+
+               request.msgInfo.msgId = pMsgInfo->msgId;
+
+               MSG_DEBUG("-=====================[[[ %s ]]]] =========================", pMsgInfo->msgData);
+               err = plg->submitReq(&request, false);
+
+               if (err == MSG_SUCCESS) {
+                       MSG_DEBUG("Process Message Success : processReceivedInd()");
+               } else {
+                       MSG_DEBUG("Process Message Fail : processReceivedInd()");
+               }
+       }
+
+       return err;
+}
+
diff --git a/framework/main.cpp b/framework/main.cpp
new file mode 100755 (executable)
index 0000000..8f73c0a
--- /dev/null
@@ -0,0 +1,324 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MsgContact.h"
+#include "MsgMemory.h"
+#include "MsgGconfWrapper.h"
+#include "MsgPluginManager.h"
+#include "MsgSettingHandler.h"
+#include "MsgStorageHandler.h"
+#include "MsgSubmitHandler.h"
+#include "MsgDeliverHandler.h"
+#include "MsgTransManager.h"
+#include "MsgStorageTypes.h"
+
+#include <errno.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <sys/stat.h>
+#include <wait.h>
+
+static GMainLoop* mainloop = NULL;
+
+
+/*==================================================================================================
+                                     DEFINES
+==================================================================================================*/
+#define MSG_MOBILE_TRACKER_MSG "Mobile Tracker Alert"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T InitMmsDir()
+{
+       if (mkdir(MSG_DATA_ROOT_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0)
+       {
+               if (errno == EEXIST)
+               {
+                       MSG_DEBUG("The %s already exists", MSG_DATA_ROOT_PATH);
+               }
+               else
+               {
+                       MSG_DEBUG("Error while mkdir %s", MSG_DATA_ROOT_PATH);
+                       return MSG_ERR_DB_MAKE_DIR;
+               }
+       }
+
+       if (mkdir(MSG_SMIL_FILE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0)
+       {
+               if (errno == EEXIST)
+               {
+                       MSG_DEBUG("The %s already exists", MSG_SMIL_FILE_PATH);
+               }
+               else
+               {
+                       MSG_DEBUG("Error while mkdir %s", MSG_SMIL_FILE_PATH);
+                       return MSG_ERR_DB_MAKE_DIR;
+               }
+       }
+
+       if (mkdir(MSG_DATA_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0)
+       {
+               if (errno == EEXIST)
+               {
+                       MSG_DEBUG("The %s already exists", MSG_DATA_PATH);
+               }
+               else
+               {
+                       MSG_DEBUG("Error while mkdir %s", MSG_DATA_PATH);
+                       return MSG_ERR_DB_MAKE_DIR;
+               }
+       }
+
+       if (mkdir(MSG_THUMBNAIL_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
+               if (errno == EEXIST) {
+                       MSG_DEBUG("The %s already exists.", MSG_THUMBNAIL_PATH);
+               } else {
+                       MSG_DEBUG(" Error while mkdir %s", MSG_THUMBNAIL_PATH);
+                       return MSG_ERR_DB_MAKE_DIR;
+               }
+       }
+
+       if (mkdir(MSG_IPC_DATA_PATH, S_IRWXU ) < 0)
+       {
+               if (errno == EEXIST)
+               {
+                       MSG_DEBUG("The %s already exists", MSG_IPC_DATA_PATH);
+
+                       // if IPC data path is already exist, clear all files in folder.
+                       char exeStr[1024];
+                       snprintf(exeStr, 1024, "rm %s*.DATA", MSG_IPC_DATA_PATH);
+                       system(exeStr);
+               }
+               else
+               {
+                       MSG_DEBUG("Error while mkdir %s", MSG_IPC_DATA_PATH);
+                       return MSG_ERR_DB_MAKE_DIR;
+               }
+       }
+
+       chmod( MSG_IPC_DATA_PATH, S_IRWXU | S_IRWXG ); //public shared file: pass data by file
+       chown( MSG_IPC_DATA_PATH, 0, 6502 );
+
+       return MSG_SUCCESS;
+}
+
+
+void* StartMsgServer(void*)
+{
+       try
+       {
+               MsgTransactionManager::instance()->run();
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+       }
+       catch (exception& e)
+       {
+               MSG_FATAL("%s", e.what());
+       }
+
+       if (g_main_loop_is_running(mainloop))
+               g_main_loop_quit(mainloop);
+
+       return (void*)0;
+}
+
+
+void* InitMsgServer(void*)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_MAIN_TYPE_T mainType = MSG_SMS_TYPE;
+       MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType);
+
+       // storage handler initialize
+       err = MsgStoInitDB(false);
+
+       if (err != MSG_SUCCESS) {
+               MSG_DEBUG("FAIL TO INITIALIZE STORAGE HANDLER [%d]", err);
+       }
+
+       if (plg == NULL) {
+               MSG_DEBUG("No plugin for %d type", mainType);
+
+               MsgReleaseMemory();
+
+               // Set Msg FW Ready Flag
+               MsgSettingSetBool(VCONFKEY_MSG_SERVER_READY, true);
+
+               return (void*)0;
+       }
+
+       MSG_SIM_STATUS_T simStatus = MSG_SIM_STATUS_NORMAL;
+
+       // Check Sim Status
+       if (plg->checkSimStatus(&simStatus) == MSG_SUCCESS) {
+
+               // Add the change of SIM to vconf
+               if (MsgSettingSetInt(MSG_SIM_CHANGED, (int)simStatus) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MSG_SIM_CHANGED);
+               }
+
+               if (simStatus != MSG_SIM_STATUS_NOT_FOUND) {
+                       // Check Device Status
+                       if (plg->checkDeviceStatus() != MSG_SUCCESS) {
+                               MSG_DEBUG("checkDeviceStatus() error");
+
+                               MsgReleaseMemory();
+
+                               // Set Msg FW Ready Flag
+                               MsgSettingSetBool(VCONFKEY_MSG_SERVER_READY, true);
+
+                               return (void*)0;
+                       }
+               }
+
+               // Init SIM Message
+               if (MsgInitSimMessage(simStatus) != MSG_SUCCESS) {
+                       MSG_DEBUG("Fail to Initialize SIM Message");
+               }
+
+               // Init SIM Configuration
+               if (MsgInitSimConfig(simStatus) != MSG_SUCCESS) {
+                       MSG_DEBUG("Fail to Initialize SIM Configuration");
+               }
+       } else {
+               MSG_DEBUG("checkSimStatus() error");
+       }
+
+       MsgReleaseMemory();
+
+       // Try to connect contact server  if it is not opened.
+       MsgOpenContactSvc();
+
+       // Register Callback to get the change of contact
+       MsgInitContactSvc(&MsgContactChangedCallback);
+
+       // Set Msg FW Ready Flag
+       MsgSettingSetBool(VCONFKEY_MSG_SERVER_READY, true);
+
+       return (void*)0;
+}
+
+
+static gboolean InitThreadFunc(void* pData)
+{
+       MSG_BEGIN();
+
+       pthread_t initThreadId;
+
+       // initialize msg fw
+       if (pthread_create(&initThreadId, NULL, InitMsgServer, NULL) != 0)
+       {
+               MSG_DEBUG("InitMsgFw not invoked: %s", strerror(errno));
+               return -1;
+       }
+
+       pthread_detach(initThreadId);
+
+       MSG_END();
+
+       return FALSE;
+}
+
+
+int main(void)
+{
+       g_thread_init(NULL);
+       dbus_g_thread_init();
+
+////////////////////////////////////
+
+/// set to ignore child process terminated signal.
+signal( SIGCHLD, SIG_IGN );
+
+////////////////////////////////////
+
+
+       MSG_DEBUG("===========START MESSAGING FRAMEWORK==========");
+
+       // Reset message server ready flag
+       MsgSettingSetBool(VCONFKEY_MSG_SERVER_READY, false);
+
+       // Connect to DB
+       //      MsgStoConnectDB();
+
+       // Open Contact Service
+       MsgOpenContactSvc();
+
+       // Clean up mms dir
+       InitMmsDir();
+
+       try
+       {
+               // plugin manager initialize
+               MsgPluginManager::instance()->initialize();
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+       }
+       catch (exception& e)
+       {
+               MSG_FATAL("%s", e.what());
+       }
+
+       pthread_t startThreadId;
+
+       // start transaction manager
+       if (pthread_create(&startThreadId, NULL, StartMsgServer, NULL) != 0)
+       {
+               MSG_DEBUG("StartMsgServer not invoked: %s", strerror(errno));
+               return -1;
+       }
+
+       MsgTransactionManager::instance()->getTMStatus();
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       g_type_init();
+
+       g_idle_add(InitThreadFunc, NULL);
+
+       if (mainloop != NULL)
+       {
+               MSG_DEBUG("Start Messaging Framework!!!");
+
+               // Run GMainLoop
+               g_main_loop_run(mainloop);
+       }
+       else
+       {
+               MSG_DEBUG("Fail to start Messaging Framework!!!");
+       }
+
+       // Close Contact Sevice
+       MsgCloseContactSvc();
+
+       // Disconnect to DB
+       MsgStoDisconnectDB();
+
+       return 0;
+}
+
diff --git a/framework/plugin-manager/MsgPluginConfig.cpp b/framework/plugin-manager/MsgPluginConfig.cpp
new file mode 100755 (executable)
index 0000000..247bdd8
--- /dev/null
@@ -0,0 +1,237 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgPluginConfig.h"
+#include "MsgException.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgPlgToken - Member Functions
+==================================================================================================*/
+int MsgPlgToken::tokenize(char *pStr)
+{
+       MSG_BEGIN();
+
+       if (pStr == NULL)
+               THROW(MsgException::INVALID_PARAM, "pstr is NULL");
+
+       char *pFirst = index(pStr, '[');
+
+       if (pFirst) // title is enclosed by [ ]
+       {
+               pFirst++; // excluding '['
+
+               char *pEnd = index(pStr, ']');
+
+               if (pEnd)
+               {
+                       pEnd--;
+
+                       tokenType = TOK_PLG_TITLE;
+                       int len = pEnd-pFirst+1;
+
+                       memcpy(tokenVal, pFirst, len);
+                       tokenVal[len] = '\0';
+
+                       MSG_DEBUG("%s", tokenVal);
+               }
+               else
+                       THROW(MsgException::INVALID_RESULT, "']' not found");
+       }
+       else // (attribute, value) pair
+       {
+               char tokStr[strlen(pStr)+1];
+               strncpy(tokStr, pStr, strlen(pStr));
+
+               char *attr = strtok(tokStr, "=");
+               char *val = strtok(NULL, "=");
+
+               if (!attr || !val)
+               {
+                       tokenType = TOK_UNDEFINED;
+               }
+               else
+               {
+                       // trimming enter key
+                       char *tmp = index(val,'\n');
+
+                       if (tmp)
+                               *tmp = '\0';
+
+                       MSG_DEBUG("attr \"%s\", val \"%s\" ", attr, val);
+
+                       // classifying the attribute
+                       if (strcmp(attr, "type") == 0)
+                       {
+                               tokenType = TOK_PLG_TYPE;
+                               strncpy(tokenVal, val, 255);
+                       }
+                       else if (strcmp(attr, "path") == 0)
+                       {
+                               tokenType = TOK_PLG_PATH;
+                               strncpy(tokenVal, val, 255);
+                       }
+                       else
+                       {
+                               tokenType = TOK_UNDEFINED;
+                       }
+               }
+       }
+
+       MSG_END();
+
+       return tokenType;
+}
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgPlgConfig - Member Functions
+==================================================================================================*/
+MsgPlgConfig::MsgPlgConfig(FILE* fp)
+{
+       MSG_BEGIN();
+
+       if (fp == NULL)
+               THROW(MsgException::INVALID_PARAM, "fp is NULL");
+
+       MsgPlgToken tokTitle, tokMsgType, tokLibPath;
+
+       char str[256];
+       memset(str, 0x00, sizeof(str));
+
+       MsgPlgToken tok = MsgPlgToken();
+
+       while (fgets(str, 255, fp))
+       {
+               tok.tokenize(str); // parsing the line into tokens
+
+               switch ( tok.getType() )
+               {
+                       case MsgPlgToken::TOK_PLG_TITLE:
+                               // processing previous items
+                               if( tokTitle && tokMsgType && tokLibPath )
+                               {
+                                       insert(tokTitle, tokMsgType, tokLibPath);
+                               }
+
+                               tokTitle = tok;
+                               tokMsgType.reset();
+                               tokLibPath.reset();
+
+                               break;
+
+                       case MsgPlgToken::TOK_PLG_TYPE:
+                               tokMsgType = tok;
+                               break;
+
+                       case MsgPlgToken::TOK_PLG_PATH:
+                               tokLibPath = tok;
+                               break;
+
+                       default:
+                               MSG_DEBUG("the line \"%s\" is not accecpted", str);
+                               break;
+               }
+       }
+
+       if (tokTitle && tokMsgType && tokLibPath)
+       {
+               insert(tokTitle, tokMsgType, tokLibPath);
+       }
+
+       MSG_END();
+}
+
+
+void MsgPlgConfig::insert(const MsgPlgToken& tokTitle, const MsgPlgToken& tokMsgType, const MsgPlgToken& tokLibPath)
+{
+       MSG_BEGIN();
+
+       MsgPlgTokenVec item2add;
+       item2add.push_back(tokMsgType);
+       item2add.push_back(tokLibPath);
+
+       CharVector titleVec;
+       tokTitle.getVal(titleVec);
+       MsgConfigMap::iterator it=configMap.find(titleVec);
+
+       if (it == configMap.end())
+               configMap.insert(std::make_pair(titleVec, item2add));
+       else
+               THROW(MsgException::PLUGIN_ERROR, "duplicated plugin title");
+
+       MSG_DEBUG("item inserted");
+       MSG_DEBUG("token:%d,value:%s", tokTitle.getType(), tokTitle.getVal());
+       MSG_DEBUG("token:%d,value:%s", tokMsgType.getType(), tokMsgType.getVal());
+       MSG_DEBUG("token:%d,value:%s", tokLibPath.getType(), tokLibPath.getVal());
+
+       MSG_END();
+}
+
+
+const CharVector& MsgPlgConfig::title(unsigned int pos)
+{
+       if (pos >= configMap.size() || pos < 0)
+               THROW(MsgException::OUT_OF_RANGE, "Input Parameter is not valid [%d]", pos);
+
+       MsgConfigMap::iterator it = configMap.begin();
+
+       unsigned int i=0;
+
+       while (it != configMap.end())
+       {
+               if (i++ == pos) break;
+               it++;
+       }
+
+       if (it == configMap.end())
+               THROW(MsgException::INVALID_RESULT, "no title");
+
+       MSG_DEBUG("searched title:%s", &(it->first)[0]);
+
+       return it->first;
+}
+
+
+void MsgPlgConfig::token(const CharVector& key, unsigned int pos, MsgPlgToken& retTok)
+{
+       MsgConfigMap::iterator it = configMap.find(key);
+
+       if (it != configMap.end()) //found
+       {
+               MSG_DEBUG("searched title:%s", &(it->first)[0]);
+
+               MsgPlgTokenVec tokVec = it->second;
+               retTok = tokVec[pos];
+
+               MSG_DEBUG("searched token:%d,value:%s", retTok.getType(), retTok.getVal());
+       }
+       else
+       {
+               THROW(MsgException::INVALID_RESULT, "no title");
+       }
+}
+
+
+void MsgPlgConfig::token(int i, unsigned int pos, MsgPlgToken& retTok)
+{
+       const CharVector& key = title(i);
+
+       token(key, pos, retTok);
+
+       MSG_DEBUG("returned token:%d,value:%s", retTok.getType(), retTok.getVal());
+}
+
diff --git a/framework/plugin-manager/MsgPluginManager.cpp b/framework/plugin-manager/MsgPluginManager.cpp
new file mode 100755 (executable)
index 0000000..b7b062c
--- /dev/null
@@ -0,0 +1,713 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <dlfcn.h>
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgException.h"
+#include "MsgIpcSocket.h"
+#include "MsgCmdTypes.h"
+#include "MsgGconfWrapper.h"
+#include "MsgPluginManager.h"
+#include "MsgMmsTypes.h"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+void MsgSentStatusListener(MSG_SENT_STATUS_S *pSentStatus)
+{
+       MSG_BEGIN();
+
+       MSG_DEBUG("SENT STATUS %d, %d", pSentStatus->reqId, pSentStatus->status);
+
+       // establish connection to msgfw daemon
+       MsgIpcClientSocket client;
+       client.connect(MSG_SOCKET_PATH);
+
+       // composing command
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_SENT_STATUS_S); // cmd type, MSG_SENT_STATUS
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_PLG_SENT_STATUS_CNF;
+
+       memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
+
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pSentStatus, sizeof(MSG_SENT_STATUS_S));
+
+       // Send Command to Transaction Manager
+       client.write(cmdBuf, cmdSize);
+
+       // Receive result from Transaction Manager
+       MSG_DEBUG("Waiting result for SENT STATUS");
+
+       char *temp = NULL;
+       AutoPtr<char> wrap(&temp);
+       int len;
+       client.read(&temp, &len);
+
+       // close connection to msgfw daemon
+       client.close();
+
+       MSG_END();
+}
+
+
+void MsgStorageChangeListener(MSG_STORAGE_CHANGE_TYPE_T storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_BEGIN();
+
+       MSG_DEBUG("StorageChangeType : [%d], msg ID : [%d]", storageChangeType, pMsgInfo->msgId);
+
+       // establish connection to msgfw daemon
+       MsgIpcClientSocket client;
+       client.connect(MSG_SOCKET_PATH);
+
+       // composing command
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(MSG_STORAGE_CHANGE_TYPE_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_PLG_STORAGE_CHANGE_IND;
+
+       memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
+
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), &storageChangeType, sizeof(MSG_STORAGE_CHANGE_TYPE_T));
+
+       // Send Command to Transaction Manager
+       client.write(cmdBuf, cmdSize);
+
+       // Receive result from Transaction Manager
+       MSG_DEBUG("Waiting result for STORAGE CHANGE");
+
+       char *temp = NULL;
+       AutoPtr<char> wrap(&temp);
+       int len;
+       client.read(&temp, &len);
+
+       // close connection to msgfw daemon
+       client.close();
+
+       MSG_END();
+}
+
+
+MSG_ERROR_T MsgIncomingMessageListener(MSG_MESSAGE_INFO_S *pMsg)
+{
+       MSG_BEGIN();
+
+       // establish connection to msgfw daemon
+       MsgIpcClientSocket client;
+       client.connect(MSG_SOCKET_PATH);
+
+       // Check Invalid Message Structure
+       if (pMsg == NULL)
+       {
+               MSG_DEBUG("pMsg is NULL !!");
+
+               return MSG_ERR_NULL_MESSAGE;
+       }
+
+       // composing command
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S); // cmd type, MSG_MESSAGE_INFO_S
+
+       MSG_DEBUG("cmdSize: %d", cmdSize);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_PLG_INCOMING_MSG_IND;
+
+       memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
+
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsg, sizeof(MSG_MESSAGE_INFO_S));
+
+       // Send Command to Messaging FW
+       client.write(cmdBuf, cmdSize);
+
+       char* retBuf = NULL;
+       AutoPtr<char> wrap(&retBuf);
+       int retSize;
+
+       client.read(&retBuf, &retSize);
+
+       // close connection to msgfw daemon
+       client.close();
+
+       // Decoding the result from FW and Returning it to plugin
+       // the result is used for making delivery report
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
+
+       if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_MSG_IND)
+               THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
+
+       MSG_END();
+
+       return (pEvent->result);
+}
+
+
+MSG_ERROR_T MsgIncomingSyncMLMessageListener(MSG_SYNCML_MESSAGE_DATA_S *pSyncMLData)
+{
+       MSG_BEGIN();
+
+       // establish connection to msgfw daemon
+       MsgIpcClientSocket client;
+       client.connect(MSG_SOCKET_PATH);
+
+       // composing command
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_SYNCML_MESSAGE_DATA_S); // cmd type, MSG_SYNCML_MESSAGE_DATA_S
+
+       MSG_DEBUG("cmdSize: %d", cmdSize);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_PLG_INCOMING_SYNCML_IND;
+
+       memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
+
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pSyncMLData, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
+
+       // Send Command to Messaging FW
+       client.write(cmdBuf, cmdSize);
+
+       // Receive result from Transaction Manager
+       char* retBuf = NULL;
+       AutoPtr<char> wrap(&retBuf);
+       int retSize;
+       client.read(&retBuf, &retSize);
+
+       // close connection to msgfw daemon
+       client.close();
+
+       // Decoding the result from FW and Returning it to plugin
+       // the result is used for making delivery report
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
+
+       if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND)
+               THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
+
+       MSG_END();
+
+       return (pEvent->result);
+}
+
+
+MSG_ERROR_T MsgIncomingLBSMessageListener(MSG_LBS_MESSAGE_DATA_S *pLBSData)
+{
+       MSG_BEGIN();
+
+       // establish connection to msgfw daemon
+       MsgIpcClientSocket client;
+       client.connect(MSG_SOCKET_PATH);
+
+       // composing command
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_LBS_MESSAGE_DATA_S); // cmd type, MSG_LBS_MESSAGE_DATA_S
+
+       MSG_DEBUG("cmdSize: %d", cmdSize);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_PLG_INCOMING_LBS_IND;
+
+       memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
+
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pLBSData, sizeof(MSG_LBS_MESSAGE_DATA_S));
+
+       // Send Command to Messaging FW
+       client.write(cmdBuf, cmdSize);
+
+       // Receive result from Transaction Manager
+       char* retBuf = NULL;
+       AutoPtr<char> wrap(&retBuf);
+       int retSize;
+       client.read(&retBuf, &retSize);
+
+       // close connection to msgfw daemon
+       client.close();
+
+       // Decoding the result from FW and Returning it to plugin
+       // the result is used for making delivery report
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
+
+       if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_LBS_MSG_IND)
+               THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
+
+       MSG_END();
+
+       return (pEvent->result);
+}
+
+
+MSG_ERROR_T MsgInitSimBySatListener()
+{
+       MSG_BEGIN();
+
+       // establish connection to msgfw daemon
+       MsgIpcClientSocket client;
+       client.connect(MSG_SOCKET_PATH);
+
+       // composing command
+       int cmdSize = sizeof(MSG_CMD_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_PLG_INIT_SIM_BY_SAT;
+
+       // Send Command to Transaction Manager
+       client.write(cmdBuf, cmdSize);
+
+       // Receive result from Transaction Manager
+       char* retBuf = NULL;
+       AutoPtr<char> wrap(&retBuf);
+       int retSize;
+       client.read(&retBuf, &retSize);
+
+       // close connection to msgfw daemon
+       client.close();
+
+       // Decoding the result from FW and Returning it to plugin
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
+
+       if (pEvent->eventType != MSG_EVENT_PLG_INIT_SIM_BY_SAT)
+               THROW(MsgException::INVALID_RESULT, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
+
+       MSG_END();
+
+       return (pEvent->result);
+}
+
+/* MMS_Incoming_listener */
+MSG_ERROR_T MsgMmsConfIncomingListener(MSG_MESSAGE_INFO_S *pMsg, MSG_REQUEST_ID_T *pReqId)
+{
+       MSG_BEGIN();
+       MSG_DEBUG("pMsg = %s, pReqId = %d ", pMsg->msgData, *pReqId);
+
+       // establish connection to msgfw daemon
+       MsgIpcClientSocket client;
+       client.connect(MSG_SOCKET_PATH);
+
+       // composing command
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(MSG_REQUEST_ID_T); // cmd type, MSG_MESSAGE_INFO_S, MSG_REQUEST_ID_T
+       MSG_DEBUG("cmdSize : %d", cmdSize);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+
+       MSG_CMD_S *pCmd = (MSG_CMD_S *)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_PLG_INCOMING_MMS_CONF; // cmd type
+
+       memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN); // cmd cookie
+
+       // cmd data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsg, sizeof(MSG_MESSAGE_INFO_S));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), pReqId, sizeof(MSG_REQUEST_ID_T));
+
+       // Send Command to Messaging FW
+       client.write(cmdBuf, cmdSize);
+
+       // Receive result from Transaction Manager
+       char *retBuf = NULL;
+       AutoPtr<char> wrap(&retBuf);
+       int retSize = 0;
+       client.read(&retBuf, &retSize);
+
+       // close connection to msgfw daemon
+       client.close();
+
+       //Decoding the result from FW and Returning it to plugin
+       // the result is used for making delivery report
+       MSG_EVENT_S *pEvent = (MSG_EVENT_S *)retBuf;
+
+       if(pEvent->eventType != MSG_EVENT_PLG_INCOMING_MMS_CONF && pEvent->eventType != MSG_EVENT_PLG_SENT_STATUS_CNF)
+               THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
+
+       MSG_END();
+
+       return (pEvent->result);
+}
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgPlugin - Member Functions
+==================================================================================================*/
+MsgPlugin::MsgPlugin(MSG_MAIN_TYPE_T mainType, const char *libPath): mSupportedMsg(mainType)
+{
+       MSG_DEBUG("msg type : [%d] library path : [%s]", mainType, libPath);
+
+       bzero(&mPlgHandler, sizeof(mPlgHandler));
+
+       if (libPath == NULL)
+               THROW(MsgException::INVALID_PARAM, "libPath NULL");
+
+        void* libHandle = NULL;
+
+       libHandle = dlopen(libPath, RTLD_NOW);
+
+       if (!libHandle)
+               THROW(MsgException::PLUGIN_ERROR, "ERROR dlopen library : [%s] [%s]", libPath, dlerror());
+
+       // Clear Error
+       dlerror();
+
+       // assign the c function pointers
+       MSG_ERROR_T(*pFunc)(MSG_PLUGIN_HANDLER_S*) = NULL;
+
+       pFunc = (MSG_ERROR_T(*)(MSG_PLUGIN_HANDLER_S*))dlsym(libHandle, "MsgPlgCreateHandle");
+
+       char *error = dlerror();
+
+       if (error != NULL)
+               THROW(MsgException::PLUGIN_ERROR, "ERROR dlsym library : [%s]", dlerror());
+
+       if ((*pFunc)(&mPlgHandler) != MSG_SUCCESS)
+               THROW(MsgException::PLUGIN_ERROR, "ERROR to create plugin handle");
+
+       // Initialize Plug-in
+       if (initialize() != MSG_SUCCESS)
+               THROW(MsgException::PLUGIN_ERROR, "ERROR to initialize plugin");
+
+       MSG_PLUGIN_LISTENER_S fwListener = {0};
+       fwListener.pfSentStatusCb                       = &MsgSentStatusListener;
+       fwListener.pfStorageChangeCb            = &MsgStorageChangeListener;
+       fwListener.pfMsgIncomingCb              = &MsgIncomingMessageListener;
+       fwListener.pfInitSimBySatCb                     = &MsgInitSimBySatListener;
+       fwListener.pfSyncMLMsgIncomingCb        = &MsgIncomingSyncMLMessageListener;
+       fwListener.pfLBSMsgIncomingCb           = &MsgIncomingLBSMessageListener;
+       fwListener.pfMmsConfIncomingCb = &MsgMmsConfIncomingListener;
+
+       if (registerListener(&fwListener) != MSG_SUCCESS)
+               THROW(MsgException::PLUGIN_ERROR, "ERROR to register listener");
+
+//     dlclose(libHandle);
+}
+
+
+MsgPlugin::~MsgPlugin()
+{
+
+
+}
+
+
+MSG_ERROR_T MsgPlugin::initialize()
+{
+       if ( mPlgHandler.pfInitialize != NULL)
+               return mPlgHandler.pfInitialize();
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+void MsgPlugin::finalize()
+{
+       if (mPlgHandler.pfFinalize != NULL)
+               mPlgHandler.pfFinalize();
+}
+
+
+MSG_ERROR_T MsgPlugin::submitReq(MSG_REQUEST_INFO_S *pReqInfo, bool bReqCb)
+{
+       if (mPlgHandler.pfSubmitRequest != NULL)
+               return mPlgHandler.pfSubmitRequest(pReqInfo, bReqCb);
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+MSG_ERROR_T MsgPlugin::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
+{
+       if (mPlgHandler.pfRegisterListener != NULL)
+               return mPlgHandler.pfRegisterListener(pListener);
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+MSG_ERROR_T MsgPlugin::checkSimStatus(MSG_SIM_STATUS_T *pStatus)
+{
+       if (mPlgHandler.pfRegisterListener != NULL)
+               return mPlgHandler.pfCheckSimStatus(pStatus);
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+MSG_ERROR_T MsgPlugin::checkDeviceStatus()
+{
+       if (mPlgHandler.pfRegisterListener != NULL)
+               return mPlgHandler.pfCheckDeviceStatus();
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+MSG_ERROR_T MsgPlugin::initSimMessage()
+{
+       if (mPlgHandler.pfInitSimMessage != NULL)
+               return mPlgHandler.pfInitSimMessage();
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+MSG_ERROR_T MsgPlugin::saveSimMessage(MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList)
+{
+       if (mPlgHandler.pfSaveSimMessage != NULL)
+               return mPlgHandler.pfSaveSimMessage(pMsgInfo, pSimIdList);
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+MSG_ERROR_T MsgPlugin::deleteSimMessage(MSG_SIM_ID_T SimMsgId)
+{
+       if (mPlgHandler.pfDeleteSimMessage != NULL)
+               return mPlgHandler.pfDeleteSimMessage(SimMsgId);
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+MSG_ERROR_T MsgPlugin::setReadStatus(MSG_SIM_ID_T SimMsgId)
+{
+       if (mPlgHandler.pfSetReadStatus != NULL)
+               return mPlgHandler.pfSetReadStatus(SimMsgId);
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+MSG_ERROR_T MsgPlugin::setMemoryStatus(MSG_ERROR_T Error)
+{
+       if (mPlgHandler.pfSetMemoryStatus != NULL)
+               return mPlgHandler.pfSetMemoryStatus(Error);
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+MSG_ERROR_T MsgPlugin::initConfigData(MSG_SIM_STATUS_T SimStatus)
+{
+       if (mPlgHandler.pfInitConfigData != NULL)
+               return mPlgHandler.pfInitConfigData(SimStatus);
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+MSG_ERROR_T MsgPlugin::setConfigData(const MSG_SETTING_S *pSetting)
+{
+       if (mPlgHandler.pfSetConfigData != NULL)
+               return mPlgHandler.pfSetConfigData(pSetting);
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+MSG_ERROR_T MsgPlugin::getConfigData(MSG_SETTING_S *pSetting)
+{
+       if (mPlgHandler.pfGetConfigData != NULL)
+               return mPlgHandler.pfGetConfigData(pSetting);
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+MSG_ERROR_T MsgPlugin::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
+{
+       if (mPlgHandler.pfAddMessage != NULL) {
+               return mPlgHandler.pfAddMessage(pMsgInfo, pSendOptInfo, pFileData);
+       } else {
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+       }
+}
+
+MSG_ERROR_T MsgPlugin::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
+{
+       if (mPlgHandler.pfUpdateMessage != NULL) {
+               return mPlgHandler.pfUpdateMessage(pMsgInfo, pSendOptInfo, pFileData);
+       } else {
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+       }
+}
+
+
+MSG_ERROR_T MsgPlugin::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject)
+{
+       if (mPlgHandler.pfProcessReceivedInd != NULL) {
+               return mPlgHandler.pfProcessReceivedInd(pMsgInfo, pRequest, bReject);
+       } else {
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+       }
+}
+
+
+MSG_ERROR_T MsgPlugin::getMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo,  MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg)
+{
+       if (mPlgHandler.pfGetMmsMessage != NULL) {
+               return mPlgHandler.pfGetMmsMessage(pMsg, pSendOptInfo, pMmsMsg, pDestMsg);
+       } else {
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+       }
+}
+
+
+MSG_ERROR_T MsgPlugin::updateRejectStatus(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       if (mPlgHandler.pfUpdateRejectStatus != NULL) {
+               return mPlgHandler.pfUpdateRejectStatus(pMsgInfo);
+       } else {
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+       }
+}
+
+
+MSG_ERROR_T MsgPlugin::composeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       if (mPlgHandler.pfComposeReadReport != NULL) {
+               return mPlgHandler.pfComposeReadReport(pMsgInfo);
+       } else {
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+       }
+}
+
+
+MSG_ERROR_T MsgPlugin::restoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char* pRecvBody, int rcvdBodyLen, char* filePath)
+{
+       if (mPlgHandler.pfRestoreMsg != NULL)
+               return mPlgHandler.pfRestoreMsg(pMsgInfo,pRecvBody, rcvdBodyLen, filePath);
+       else
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+}
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgPluginManager - Member Functions
+==================================================================================================*/
+MsgPluginManager* MsgPluginManager::pInstance = NULL;
+
+
+MsgPluginManager* MsgPluginManager::instance()
+{
+       if (pInstance == NULL)
+               pInstance = new MsgPluginManager();
+
+       return pInstance;
+}
+
+
+MsgPluginManager::MsgPluginManager()
+{
+
+}
+
+
+void MsgPluginManager::initialize()
+{
+       char path[64];
+
+       memset(path, 0x00, sizeof(path));
+       snprintf(path, sizeof(path), "%s%s", MSG_PLUGIN_CFG_PATH, MSG_PLUGIN_CFG_NAME);
+
+       loadPlugins(path);
+}
+
+
+void MsgPluginManager::finalize()
+{
+       MsgPluginMap::iterator it;
+
+       for (it = plgMap.begin(); it != plgMap.end(); it++)
+       {
+               MsgPlugin temp = it->second;
+               temp.finalize();
+       }
+
+       plgMap.clear();
+}
+
+
+void MsgPluginManager::loadPlugins(const char* path)
+{
+       /* read plugins from configuration file */
+       FILE* fp = MsgOpenFile(path, "rt");
+
+       MsgPlgConfig plgConf = MsgPlgConfig(fp);
+
+       for (int i=0; i < plgConf.titleCount(); i++)
+       {
+               MsgPlgToken tok;
+
+               plgConf.token(i, 0, tok);
+               const char* content = tok.getVal();
+
+               MSG_MAIN_TYPE_T mainType = strstr(content,"sms")? MSG_SMS_TYPE:
+                                                       (strstr(content,"mms")? MSG_MMS_TYPE: MSG_UNKNOWN_TYPE);
+
+               plgConf.token(i, 1, tok);
+               const char* libPath = tok.getVal();
+
+               MsgPlugin* pDupPlgCheck = getPlugin(mainType);
+
+               if (pDupPlgCheck)
+                       THROW(MsgException::PLUGIN_ERROR, "Plugin for type %d is duplicated", mainType);
+
+               MsgPlugin newPlg(mainType, libPath);
+
+               plgMap.insert(make_pair(mainType, newPlg));
+       }
+
+       MsgCloseFile(fp);
+}
+
+
+MsgPlugin* MsgPluginManager::getPlugin(MSG_MAIN_TYPE_T mainType)
+{
+       /* Implementing the content */
+       MsgPluginMap::iterator it = plgMap.find(mainType);
+
+       if (it == plgMap.end())
+               return NULL;
+
+       return &(it->second);
+}
+
diff --git a/framework/setting-handler/MsgSettingHandler.cpp b/framework/setting-handler/MsgSettingHandler.cpp
new file mode 100755 (executable)
index 0000000..746da31
--- /dev/null
@@ -0,0 +1,1090 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgPluginManager.h"
+#include "MsgSettingHandler.h"
+#include "MsgGconfWrapper.h"
+
+
+#define DEF_BUF_LEN    128
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgInitSimConfig(MSG_SIM_STATUS_T SimStatus)
+{
+       MSG_DEBUG("Start to initialize SIM Configuration");
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       if (SimStatus != MSG_SIM_STATUS_NOT_FOUND)
+       {
+               MSG_MAIN_TYPE_T mainType = MSG_SMS_TYPE;
+               MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType);
+
+               if (plg == NULL)
+               {
+                       MSG_DEBUG("No plugin for %d type", mainType);
+                       return MSG_ERR_INVALID_PLUGIN_HANDLE;
+               }
+
+               // Check SIM Status
+               MSG_DEBUG(" ** SIM is available - status : [%d] ** ", SimStatus);
+
+               err = plg->initConfigData(SimStatus);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgSetConfigData(const MSG_SETTING_S *pSetting)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_DEBUG("Setting Type : %d", pSetting->type);
+
+       switch (pSetting->type)
+       {
+               case MSG_GENERAL_OPT :
+                       err = MsgSetGeneralOpt(pSetting);
+               break;
+               case MSG_SMS_SENDOPT :
+                       err = MsgSetSMSSendOpt(pSetting);
+               break;
+               case MSG_SMSC_LIST :
+                       err = MsgSetSMSCList(pSetting, true);
+               break;
+               case MSG_MMS_SENDOPT :
+                       err = MsgSetMMSSendOpt(pSetting);
+               break;
+               case MSG_MMS_RECVOPT :
+                       err = MsgSetMMSRecvOpt(pSetting);
+               break;
+               case MSG_MMS_STYLEOPT :
+                       err = MsgSetMMSStyleOpt(pSetting);
+               break;
+               case MSG_PUSHMSG_OPT :
+                       err = MsgSetPushMsgOpt(pSetting);
+               break;
+               case MSG_CBMSG_OPT :
+                       err = MsgSetCBMsgOpt(pSetting, true);
+               break;
+               case MSG_VOICEMAIL_OPT :
+                       err = MsgSetVoiceMailOpt(pSetting);
+               break;
+               case MSG_MSGSIZE_OPT:
+                       err = MsgSetMsgSizeOpt(pSetting);
+               default :
+               break;
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgGetConfigData(MSG_SETTING_S *pSetting)
+{
+       switch (pSetting->type)
+       {
+               case MSG_GENERAL_OPT :
+                       MsgGetGeneralOpt(pSetting);
+               break;
+               case MSG_SMS_SENDOPT :
+                       MsgGetSMSSendOpt(pSetting);
+               break;
+               case MSG_SMSC_LIST :
+                       MsgGetSMSCList(pSetting);
+               break;
+               case MSG_MMS_SENDOPT :
+                       MsgGetMMSSendOpt(pSetting);
+               break;
+               case MSG_MMS_RECVOPT :
+                       MsgGetMMSRecvOpt(pSetting);
+               break;
+               case MSG_MMS_STYLEOPT :
+                       MsgGetMMSStyleOpt(pSetting);
+               break;
+               case MSG_PUSHMSG_OPT :
+                       MsgGetPushMsgOpt(pSetting);
+               break;
+               case MSG_CBMSG_OPT :
+                       MsgGetCBMsgOpt(pSetting);
+               break;
+               case MSG_VOICEMAIL_OPT :
+                       MsgGetVoiceMailOpt(pSetting);
+               break;
+               case MSG_MSGSIZE_OPT :
+                       MsgGetMsgSizeOpt(pSetting);
+               break;
+
+               default :
+               break;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgSetGeneralOpt(const MSG_SETTING_S *pSetting)
+{
+       MSG_GENERAL_OPT_S generalOpt;
+       bool bValue = false;
+
+       memcpy(&generalOpt, &(pSetting->option.generalOpt), sizeof(MSG_GENERAL_OPT_S));
+
+       MsgSettingGetBool(MSG_KEEP_COPY, &bValue);
+       if (bValue != generalOpt.bKeepCopy) {
+               if (MsgSettingSetBool(MSG_KEEP_COPY, generalOpt.bKeepCopy) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MSG_KEEP_COPY);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MSG_AUTO_ERASE, &bValue);
+       if (bValue != generalOpt.bAutoErase) {
+               if (MsgSettingSetBool(MSG_AUTO_ERASE, generalOpt.bAutoErase) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MSG_AUTO_ERASE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgSetSMSSendOpt(const MSG_SETTING_S *pSetting)
+{
+       MSG_SMS_SENDOPT_S sendOpt;
+       int iValue = 0;
+       bool bValue = false;
+
+       memcpy(&sendOpt, &(pSetting->option.smsSendOpt), sizeof(MSG_SMS_SENDOPT_S));
+
+       iValue = MsgSettingGetInt(SMS_SEND_DCS);
+       if (iValue != (int)sendOpt.dcs) {
+               if (MsgSettingSetInt(SMS_SEND_DCS, (int)sendOpt.dcs) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", SMS_SEND_DCS);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(SMS_SEND_NETWORK_MODE);
+       if (iValue != (int)sendOpt.netMode) {
+               if (MsgSettingSetInt(SMS_SEND_NETWORK_MODE, (int)sendOpt.netMode) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", SMS_SEND_NETWORK_MODE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(SMS_SEND_REPLY_PATH, &bValue);
+       if (bValue != sendOpt.bReplyPath) {
+               if (MsgSettingSetBool(SMS_SEND_REPLY_PATH, sendOpt.bReplyPath) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", SMS_SEND_REPLY_PATH);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &bValue);
+       if (bValue != sendOpt.bDeliveryReport) {
+               if (MsgSettingSetBool(SMS_SEND_DELIVERY_REPORT, sendOpt.bDeliveryReport) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", SMS_SEND_DELIVERY_REPORT);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(SMS_SEND_SAVE_STORAGE);
+       if (iValue != (int)sendOpt.saveStorage) {
+               if (MsgSettingSetInt(SMS_SEND_SAVE_STORAGE, (int)sendOpt.saveStorage) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", SMS_SEND_SAVE_STORAGE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgSetSMSCList(const MSG_SETTING_S *pSetting, bool bSetSim)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       for (int index = 0; index < pSetting->option.smscList.totalCnt; index++)
+       {
+               if(strlen(pSetting->option.smscList.smscData[index].smscAddr.address) > SMSC_ADDR_MAX)
+               {
+                       MSG_DEBUG("SMSC address is too long [%d]", strlen(pSetting->option.smscList.smscData[index].smscAddr.address));
+                       return MSG_ERR_SET_SIM_SET;
+               }
+       }
+
+       if (bSetSim == true)
+       {
+               err = MsgSetConfigInSim(pSetting);
+
+               if (err != MSG_SUCCESS)
+               {
+                       MSG_DEBUG("Error to set config data in sim [%d]", err);
+                       return MSG_ERR_SET_SIM_SET;
+               }
+       }
+
+       MSG_SMSC_LIST_S smscList;
+
+       memcpy(&smscList, &(pSetting->option.smscList), sizeof(MSG_SMSC_LIST_S));
+
+       char keyName[DEF_BUF_LEN] = {0, };
+
+       // No selected SMSC Info. in SIM.
+       if (bSetSim == true)
+       {
+               if (MsgSettingSetInt(SMSC_SELECTED, smscList.selected) != MSG_SUCCESS)
+               {
+                       MSG_DEBUG("Error to set config data [%s]", SMSC_SELECTED);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       if (MsgSettingSetInt(SMSC_TOTAL_COUNT, smscList.totalCnt) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", SMSC_TOTAL_COUNT);
+               return MSG_ERR_SET_SETTING;
+       }
+
+       for (int i = 0; i < smscList.totalCnt; i++)
+       {
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_PID, i);
+
+               if ((err = MsgSettingSetInt(keyName, (int)smscList.smscData[i].pid)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_VAL_PERIOD, i);
+
+               if ((err = MsgSettingSetInt(keyName, (int)smscList.smscData[i].valPeriod)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_NAME, i);
+
+               if ((err = MsgSettingSetString(keyName, smscList.smscData[i].name)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_TON, i);
+
+               if (smscList.smscData[i].smscAddr.address[0] == '+')
+                       smscList.smscData[i].smscAddr.ton = MSG_TON_INTERNATIONAL;
+               else
+                       smscList.smscData[i].smscAddr.ton = MSG_TON_NATIONAL;
+
+               if ((err = MsgSettingSetInt(keyName, (int)smscList.smscData[i].smscAddr.ton)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_NPI, i);
+
+               smscList.smscData[i].smscAddr.npi = MSG_NPI_ISDN; // app cannot set this value
+
+               if ((err = MsgSettingSetInt(keyName, (int)smscList.smscData[i].smscAddr.npi)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_ADDRESS, i);
+
+               if ((err = MsgSettingSetString(keyName, smscList.smscData[i].smscAddr.address)) != MSG_SUCCESS)
+                       break;
+       }
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", keyName);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgSetMMSSendOpt(const MSG_SETTING_S *pSetting)
+{
+       MSG_MMS_SENDOPT_S sendOpt;
+       int iValue = 0;
+       bool bValue = false;
+
+       memcpy(&sendOpt, &(pSetting->option.mmsSendOpt), sizeof(MSG_MMS_SENDOPT_S));
+
+       iValue = MsgSettingGetInt(MMS_SEND_MSG_CLASS);
+       if (iValue != (int)sendOpt.msgClass) {
+               if (MsgSettingSetInt(MMS_SEND_MSG_CLASS, (int)sendOpt.msgClass) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_MSG_CLASS);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_SEND_PRIORITY);
+       if (iValue != (int)sendOpt.priority) {
+               if (MsgSettingSetInt(MMS_SEND_PRIORITY, (int)sendOpt.priority) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_PRIORITY);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_SEND_EXPIRY_TIME);
+       if (iValue != (int)sendOpt.expiryTime) {
+               if (MsgSettingSetInt(MMS_SEND_EXPIRY_TIME, (int)sendOpt.expiryTime) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_EXPIRY_TIME);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_SEND_DELIVERY_TIME);
+       if (iValue != (int)sendOpt.deliveryTime) {
+               if (MsgSettingSetInt(MMS_SEND_DELIVERY_TIME, (int)sendOpt.deliveryTime) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_DELIVERY_TIME);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_SEND_CUSTOM_DELIVERY);
+       if (iValue != (int)sendOpt.customDeliveryTime) {
+               if (MsgSettingSetInt(MMS_SEND_CUSTOM_DELIVERY, sendOpt.customDeliveryTime) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_CUSTOM_DELIVERY);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MMS_SEND_SENDER_VISIBILITY, &bValue);
+       if (bValue != sendOpt.bSenderVisibility) {
+               if (MsgSettingSetBool(MMS_SEND_SENDER_VISIBILITY, sendOpt.bSenderVisibility) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_SENDER_VISIBILITY);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MMS_SEND_DELIVERY_REPORT, &bValue);
+       if (bValue != sendOpt.bDeliveryReport) {
+               if (MsgSettingSetBool(MMS_SEND_DELIVERY_REPORT, sendOpt.bDeliveryReport) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_DELIVERY_REPORT);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MMS_SEND_READ_REPLY, &bValue);
+       if (bValue != sendOpt.bReadReply) {
+               if (MsgSettingSetBool(MMS_SEND_READ_REPLY, sendOpt.bReadReply) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_READ_REPLY);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MMS_SEND_BODY_REPLYING, &bValue);
+       if (bValue != sendOpt.bBodyReplying) {
+               if (MsgSettingSetBool(MMS_SEND_BODY_REPLYING, sendOpt.bBodyReplying) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_BODY_REPLYING);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MMS_SEND_HIDE_RECIPIENTS, &bValue);
+       if (bValue != sendOpt.bHideRecipients) {
+               if (MsgSettingSetBool(MMS_SEND_HIDE_RECIPIENTS, sendOpt.bHideRecipients) != MSG_SUCCESS)
+               {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_HIDE_RECIPIENTS);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_SEND_REPLY_CHARGING);
+       if (iValue != sendOpt.replyCharging) {
+               if (MsgSettingSetInt(MMS_SEND_REPLY_CHARGING, sendOpt.replyCharging) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_REPLY_CHARGING);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_SEND_REPLY_CHARGING_DEADLINE);
+       if (iValue != (int)sendOpt.replyChargingDeadline) {
+               if (MsgSettingSetInt(MMS_SEND_REPLY_CHARGING_DEADLINE, sendOpt.replyChargingDeadline) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_REPLY_CHARGING_DEADLINE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_SEND_REPLY_CHARGING_SIZE);
+       if (iValue != (int)sendOpt.replyChargingSize) {
+               if (MsgSettingSetInt(MMS_SEND_REPLY_CHARGING_SIZE, sendOpt.replyChargingSize) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_REPLY_CHARGING_SIZE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_SEND_CREATION_MODE);
+       if (iValue != sendOpt.creationMode) {
+               if (MsgSettingSetInt(MMS_SEND_CREATION_MODE, sendOpt.creationMode) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_SEND_CREATION_MODE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgSetMMSRecvOpt(const MSG_SETTING_S *pSetting)
+{
+       MSG_MMS_RECVOPT_S recvOpt;
+       int iValue = 0;
+       bool bValue = false;
+
+       memcpy(&recvOpt, &(pSetting->option.mmsRecvOpt), sizeof(MSG_MMS_RECVOPT_S));
+
+       iValue = MsgSettingGetInt(MMS_RECV_HOME_NETWORK);
+       if (iValue != (int)recvOpt.homeNetwork) {
+               if (MsgSettingSetInt(MMS_RECV_HOME_NETWORK, (int)recvOpt.homeNetwork) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_RECV_HOME_NETWORK);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
+       if (iValue != (int)recvOpt.abroadNetwok) {
+               if (MsgSettingSetInt(MMS_RECV_ABROAD_NETWORK, (int)recvOpt.abroadNetwok) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_RECV_ABROAD_NETWORK);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MMS_RECV_READ_RECEIPT, &bValue);
+       if (bValue != recvOpt.readReceipt) {
+               if (MsgSettingSetBool(MMS_RECV_READ_RECEIPT, recvOpt.readReceipt) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_RECV_READ_RECEIPT);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MMS_RECV_DELIVERY_RECEIPT, &bValue);
+       if (bValue != recvOpt.bDeliveryReceipt) {
+               if (MsgSettingSetBool(MMS_RECV_DELIVERY_RECEIPT, recvOpt.bDeliveryReceipt) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_RECV_DELIVERY_RECEIPT);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MMS_RECV_REJECT_UNKNOWN, &bValue);
+       if (bValue != recvOpt.bRejectUnknown) {
+               if (MsgSettingSetBool(MMS_RECV_REJECT_UNKNOWN, recvOpt.bRejectUnknown) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_RECV_REJECT_UNKNOWN);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MMS_RECV_REJECT_ADVERTISE, &bValue);
+       if (bValue != recvOpt.bRejectAdvertisement) {
+               if (MsgSettingSetBool(MMS_RECV_REJECT_ADVERTISE, recvOpt.bRejectAdvertisement) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_RECV_REJECT_ADVERTISE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgSetMMSStyleOpt(const MSG_SETTING_S *pSetting)
+{
+       MSG_MMS_STYLEOPT_S styleOpt;
+       int iValue = 0;
+       bool bValue = false;
+
+       memcpy(&styleOpt, &(pSetting->option.mmsStyleOpt), sizeof(MSG_MMS_STYLEOPT_S));
+
+       iValue = MsgSettingGetInt(MMS_STYLE_FONT_SIZE);
+       if (iValue != (int)styleOpt.fontSize) {
+               if (MsgSettingSetInt(MMS_STYLE_FONT_SIZE, styleOpt.fontSize) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_SIZE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MMS_STYLE_FONT_STYLE_BOLD, &bValue);
+       if (bValue != styleOpt.bFontStyleBold) {
+               if (MsgSettingSetBool(MMS_STYLE_FONT_STYLE_BOLD, styleOpt.bFontStyleBold) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_STYLE_BOLD);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MMS_STYLE_FONT_STYLE_ITALIC, &bValue);
+       if (bValue != styleOpt.bFontStyleItalic) {
+               if (MsgSettingSetBool(MMS_STYLE_FONT_STYLE_ITALIC, styleOpt.bFontStyleItalic) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_STYLE_ITALIC);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(MMS_STYLE_FONT_STYLE_UNDERLINE, &bValue);
+       if (bValue != styleOpt.bFontStyleUnderline) {
+               if (MsgSettingSetBool(MMS_STYLE_FONT_STYLE_UNDERLINE, styleOpt.bFontStyleUnderline) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_STYLE_UNDERLINE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_RED);
+       if (iValue != (int)styleOpt.fontColorRed) {
+               if (MsgSettingSetInt(MMS_STYLE_FONT_COLOR_RED, styleOpt.fontColorRed) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_COLOR_RED);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_GREEN);
+       if (iValue != (int)styleOpt.fontColorGreen) {
+               if (MsgSettingSetInt(MMS_STYLE_FONT_COLOR_GREEN, styleOpt.fontColorGreen) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_COLOR_GREEN);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_BLUE);
+       if (iValue != (int)styleOpt.fontColorBlue) {
+               if (MsgSettingSetInt(MMS_STYLE_FONT_COLOR_BLUE, styleOpt.fontColorBlue) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_COLOR_BLUE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_HUE);
+       if (iValue != (int)styleOpt.fontColorHue) {
+               if (MsgSettingSetInt(MMS_STYLE_FONT_COLOR_HUE, styleOpt.fontColorHue) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_COLOR_HUE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_STYLE_BG_COLOR_RED);
+       if (iValue != (int)styleOpt.bgColorRed) {
+               if (MsgSettingSetInt(MMS_STYLE_BG_COLOR_RED, styleOpt.bgColorRed) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_BG_COLOR_RED);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_STYLE_BG_COLOR_GREEN);
+       if (iValue != (int)styleOpt.bgColorGreen) {
+               if (MsgSettingSetInt(MMS_STYLE_BG_COLOR_GREEN, styleOpt.bgColorGreen) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_BG_COLOR_GREEN);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_STYLE_BG_COLOR_BLUE);
+       if (iValue != (int)styleOpt.bgColorBlue) {
+               if (MsgSettingSetInt(MMS_STYLE_BG_COLOR_BLUE, styleOpt.bgColorBlue) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_BG_COLOR_BLUE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_STYLE_BG_COLOR_HUE);
+       if (iValue != (int)styleOpt.bgColorHue) {
+               if (MsgSettingSetInt(MMS_STYLE_BG_COLOR_HUE, styleOpt.bgColorHue) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_BG_COLOR_HUE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_STYLE_PAGE_DUR);
+       if (iValue != (int)styleOpt.pageDur) {
+               if (MsgSettingSetInt(MMS_STYLE_PAGE_DUR, styleOpt.pageDur) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_PAGE_DUR);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_STYLE_PAGE_CUSTOM_DUR);
+       if (iValue != (int)styleOpt.pageCustomDur) {
+               if (MsgSettingSetInt(MMS_STYLE_PAGE_CUSTOM_DUR, styleOpt.pageCustomDur) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_PAGE_CUSTOM_DUR);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(MMS_STYLE_PAGE_DUR_MANUAL);
+       if (iValue != (int)styleOpt.pageDurManual) {
+               if (MsgSettingSetInt(MMS_STYLE_PAGE_DUR_MANUAL, styleOpt.pageDurManual) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_PAGE_DUR_MANUAL);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T MsgSetPushMsgOpt(const MSG_SETTING_S *pSetting)
+{
+       MSG_PUSHMSG_OPT_S pushOpt;
+       int iValue = 0;
+       bool bValue = false;
+
+       memcpy(&pushOpt, &(pSetting->option.pushMsgOpt), sizeof(MSG_PUSHMSG_OPT_S));
+
+       MsgSettingGetBool(PUSH_RECV_OPTION, &bValue);
+       if (bValue != pushOpt.bReceive) {
+               if (MsgSettingSetBool(PUSH_RECV_OPTION, pushOpt.bReceive) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", PUSH_RECV_OPTION);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(PUSH_SERVICE_TYPE);
+       if (iValue != (int)pushOpt.serviceType) {
+               if (MsgSettingSetInt(PUSH_SERVICE_TYPE, (int)pushOpt.serviceType) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", PUSH_SERVICE_TYPE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgSetCBMsgOpt(const MSG_SETTING_S *pSetting, bool bSetSim)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_CBMSG_OPT_S cbOpt;
+       int iValue = 0;
+       bool bValue = false;
+
+       memcpy(&cbOpt, &(pSetting->option.cbMsgOpt), sizeof(MSG_CBMSG_OPT_S));
+
+       if (bSetSim == true)
+       {
+               cbOpt.maxSimCnt = MsgSettingGetInt(CB_MAX_SIM_COUNT);
+
+               if (cbOpt.channelData.channelCnt > cbOpt.maxSimCnt)
+               {
+                       MSG_DEBUG("Channel Count is over Max SIM Count [%d]", cbOpt.channelData.channelCnt);
+                       return MSG_ERR_SET_SIM_SET;
+               }
+
+               if (MsgSetConfigInSim(pSetting) != MSG_SUCCESS)
+               {
+                       MSG_DEBUG("Error to set config data in sim [%d]", err);
+                       return MSG_ERR_SET_SIM_SET;
+               }
+       }
+
+       MsgSettingGetBool(CB_RECEIVE, &bValue);
+       if (bValue != cbOpt.bReceive) {
+               if (MsgSettingSetBool(CB_RECEIVE, cbOpt.bReceive) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", CB_RECEIVE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       MsgSettingGetBool(CB_ALL_CHANNEL, &bValue);
+       if (bValue != cbOpt.bAllChannel) {
+               if (MsgSettingSetBool(CB_ALL_CHANNEL, cbOpt.bAllChannel) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", CB_ALL_CHANNEL);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(CB_MAX_SIM_COUNT);
+       if (iValue != cbOpt.maxSimCnt) {
+               if (MsgSettingSetInt(CB_MAX_SIM_COUNT, cbOpt.maxSimCnt) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", CB_MAX_SIM_COUNT);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       iValue = MsgSettingGetInt(CB_CHANNEL_COUNT);
+       if (iValue != cbOpt.channelData.channelCnt) {
+               if (MsgSettingSetInt(CB_CHANNEL_COUNT, cbOpt.channelData.channelCnt) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", CB_CHANNEL_COUNT);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       char keyName[DEF_BUF_LEN] = {0, };
+
+       for (int i = 0; i < cbOpt.channelData.channelCnt; i++)
+       {
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ACTIVATE, i);
+
+               if ((err = MsgSettingSetBool(keyName, cbOpt.channelData.channelInfo[i].bActivate)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ID, i);
+
+               if ((err = MsgSettingSetInt(keyName, cbOpt.channelData.channelInfo[i].id)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_NAME, i);
+
+               if ((err = MsgSettingSetString(keyName, cbOpt.channelData.channelInfo[i].name)) != MSG_SUCCESS)
+                       break;
+       }
+
+       if (bSetSim == true)
+       {
+               for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++)
+               {
+                       memset(keyName, 0x00, sizeof(keyName));
+                       snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_LANGUAGE, i);
+
+                       if (MsgSettingSetBool(keyName, cbOpt.bLanguage[i]) != MSG_SUCCESS)
+                       {
+                               MSG_DEBUG("Error to set config data [%s]", keyName);
+                               return MSG_ERR_SET_SETTING;
+                       }
+               }
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgSetVoiceMailOpt(const MSG_SETTING_S *pSetting)
+{
+       MSG_VOICEMAIL_OPT_S voiceMailOpt;
+       char *pValue = NULL;
+
+       memcpy(&voiceMailOpt, &(pSetting->option.voiceMailOpt), sizeof(MSG_VOICEMAIL_OPT_S));
+
+       pValue = MsgSettingGetString(VOICEMAIL_NUMBER);
+       if (pValue != NULL && strcmp(pValue, voiceMailOpt.mailNumber) == 0) {
+               /* Value is same with previous one. Therefore, we don't need to save it. */
+       } else {
+               if (MsgSettingSetString(VOICEMAIL_NUMBER, voiceMailOpt.mailNumber) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", VOICEMAIL_NUMBER);
+
+                       if (pValue != NULL) {
+                               free(pValue);
+                               pValue = NULL;
+                       }
+
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       if (pValue != NULL) {
+               free(pValue);
+               pValue = NULL;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgSetMsgSizeOpt(const MSG_SETTING_S *pSetting)
+{
+       MSG_MSGSIZE_OPT_S msgSizeOpt;
+       int iValue = 0;
+
+       memcpy(&msgSizeOpt, &(pSetting->option.msgSizeOpt), sizeof(MSG_MSGSIZE_OPT_S));
+
+       iValue = MsgSettingGetInt(MSGSIZE_OPTION);
+       if (iValue != msgSizeOpt.nMsgSize) {
+               if (MsgSettingSetInt(MSGSIZE_OPTION, msgSizeOpt.nMsgSize) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MSGSIZE_OPTION);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+void MsgGetGeneralOpt(MSG_SETTING_S *pSetting)
+{
+       memset(&(pSetting->option.generalOpt), 0x00, sizeof(MSG_GENERAL_OPT_S));
+
+       MsgSettingGetBool(MSG_KEEP_COPY, &pSetting->option.generalOpt.bKeepCopy);
+}
+
+
+void MsgGetSMSSendOpt(MSG_SETTING_S *pSetting)
+{
+       memset(&(pSetting->option.smsSendOpt), 0x00, sizeof(MSG_SMS_SENDOPT_S));
+
+       pSetting->option.smsSendOpt.dcs = (MSG_ENCODE_TYPE_T)MsgSettingGetInt(SMS_SEND_DCS);
+
+       pSetting->option.smsSendOpt.netMode = (MSG_SMS_NETWORK_MODE_T)MsgSettingGetInt(SMS_SEND_NETWORK_MODE);
+
+       MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSetting->option.smsSendOpt.bReplyPath);
+
+       MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSetting->option.smsSendOpt.bDeliveryReport);
+
+       pSetting->option.smsSendOpt.saveStorage = (MSG_SMS_SAVE_STORAGE_T)MsgSettingGetInt(SMS_SEND_SAVE_STORAGE);
+}
+
+
+void MsgGetSMSCList(MSG_SETTING_S *pSetting)
+{
+       char keyName[DEF_BUF_LEN] = {0, };
+       char *tmpValue = NULL;
+
+       memset(&(pSetting->option.smscList), 0x00, sizeof(MSG_SMSC_LIST_S));
+
+       pSetting->option.smscList.selected = MsgSettingGetInt(SMSC_SELECTED);
+
+       pSetting->option.smscList.totalCnt = MsgSettingGetInt(SMSC_TOTAL_COUNT);
+
+       for (int i = 0; i < pSetting->option.smscList.totalCnt; i++)
+       {
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_PID, i);
+
+               pSetting->option.smscList.smscData[i].pid = (MSG_SMS_PID_T)MsgSettingGetInt(keyName);
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_VAL_PERIOD, i);
+
+               pSetting->option.smscList.smscData[i].valPeriod = (MSG_VAL_PERIOD_T)MsgSettingGetInt(keyName);
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_NAME, i);
+
+               memset(pSetting->option.smscList.smscData[i].name, 0x00, SMSC_NAME_MAX+1);
+
+               tmpValue = MsgSettingGetString(keyName);
+               if (tmpValue != NULL) {
+                       strncpy(pSetting->option.smscList.smscData[i].name, tmpValue, SMSC_NAME_MAX);
+                       free(tmpValue);
+                       tmpValue = NULL;
+               }
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_TON, i);
+
+               pSetting->option.smscList.smscData[i].smscAddr.ton = (MSG_SMS_TON_T)MsgSettingGetInt(keyName);
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_NPI, i);
+
+               pSetting->option.smscList.smscData[i].smscAddr.npi = (MSG_SMS_NPI_T)MsgSettingGetInt(keyName);
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_ADDRESS, i);
+
+               memset(pSetting->option.smscList.smscData[i].smscAddr.address, 0x00, sizeof(pSetting->option.smscList.smscData[i].smscAddr.address));
+
+               tmpValue = MsgSettingGetString(keyName);
+               if (tmpValue != NULL) {
+                       strncpy(pSetting->option.smscList.smscData[i].smscAddr.address, tmpValue, SMSC_ADDR_MAX);
+                       free(tmpValue);
+                       tmpValue = NULL;
+               }
+       }
+}
+
+
+void MsgGetMMSSendOpt(MSG_SETTING_S *pSetting)
+{
+       memset(&(pSetting->option.mmsSendOpt), 0x00, sizeof(MSG_MMS_SENDOPT_S));
+
+       pSetting->option.mmsSendOpt.msgClass = (MSG_MMS_MSG_CLASS_TYPE_T)MsgSettingGetInt(MMS_SEND_MSG_CLASS);
+
+       pSetting->option.mmsSendOpt.priority = (MSG_PRIORITY_TYPE_T)MsgSettingGetInt(MMS_SEND_PRIORITY);
+
+       pSetting->option.mmsSendOpt.expiryTime = (MSG_MMS_EXPIRY_TIME_T)MsgSettingGetInt(MMS_SEND_EXPIRY_TIME);
+
+       pSetting->option.mmsSendOpt.deliveryTime = (MSG_MMS_DELIVERY_TIME_T)MsgSettingGetInt(MMS_SEND_DELIVERY_TIME);
+
+       pSetting->option.mmsSendOpt.customDeliveryTime = MsgSettingGetInt(MMS_SEND_CUSTOM_DELIVERY);
+
+       MsgSettingGetBool(MMS_SEND_SENDER_VISIBILITY, &pSetting->option.mmsSendOpt.bSenderVisibility);
+
+       MsgSettingGetBool(MMS_SEND_DELIVERY_REPORT, &pSetting->option.mmsSendOpt.bDeliveryReport);
+
+       MsgSettingGetBool(MMS_SEND_READ_REPLY, &pSetting->option.mmsSendOpt.bReadReply);
+
+       MsgSettingGetBool(MMS_SEND_BODY_REPLYING, &pSetting->option.mmsSendOpt.bBodyReplying);
+
+       MsgSettingGetBool(MMS_SEND_HIDE_RECIPIENTS, &pSetting->option.mmsSendOpt.bHideRecipients);
+
+       pSetting->option.mmsSendOpt.replyCharging = MsgSettingGetInt(MMS_SEND_REPLY_CHARGING);
+
+       pSetting->option.mmsSendOpt.replyChargingDeadline = MsgSettingGetInt(MMS_SEND_REPLY_CHARGING_DEADLINE);
+
+       pSetting->option.mmsSendOpt.replyChargingSize = MsgSettingGetInt(MMS_SEND_REPLY_CHARGING_SIZE);
+
+       pSetting->option.mmsSendOpt.creationMode = MsgSettingGetInt(MMS_SEND_CREATION_MODE);
+}
+
+
+void MsgGetMMSRecvOpt(MSG_SETTING_S *pSetting)
+{
+       memset(&(pSetting->option.mmsRecvOpt), 0x00, sizeof(MSG_MMS_RECVOPT_S));
+
+       pSetting->option.mmsRecvOpt.homeNetwork = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_HOME_NETWORK);
+
+       pSetting->option.mmsRecvOpt.abroadNetwok = (MSG_MMS_ABROAD_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
+
+       MsgSettingGetBool(MMS_RECV_READ_RECEIPT, &pSetting->option.mmsRecvOpt.readReceipt);
+
+       MsgSettingGetBool(MMS_RECV_DELIVERY_RECEIPT, &pSetting->option.mmsRecvOpt.bDeliveryReceipt);
+
+       MsgSettingGetBool(MMS_RECV_REJECT_UNKNOWN, &pSetting->option.mmsRecvOpt.bRejectUnknown);
+
+       MsgSettingGetBool(MMS_RECV_REJECT_ADVERTISE, &pSetting->option.mmsRecvOpt.bRejectAdvertisement);
+}
+
+
+void MsgGetMMSStyleOpt(MSG_SETTING_S *pSetting)
+{
+       memset(&(pSetting->option.mmsStyleOpt), 0x00, sizeof(MSG_MMS_STYLEOPT_S));
+
+       pSetting->option.mmsStyleOpt.fontSize = MsgSettingGetInt(MMS_STYLE_FONT_SIZE);
+
+       MsgSettingGetBool(MMS_STYLE_FONT_STYLE_BOLD, &pSetting->option.mmsStyleOpt.bFontStyleBold);
+
+       MsgSettingGetBool(MMS_STYLE_FONT_STYLE_ITALIC, &pSetting->option.mmsStyleOpt.bFontStyleItalic);
+
+       MsgSettingGetBool(MMS_STYLE_FONT_STYLE_UNDERLINE, &pSetting->option.mmsStyleOpt.bFontStyleUnderline);
+
+       pSetting->option.mmsStyleOpt.fontColorRed = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_RED);
+
+       pSetting->option.mmsStyleOpt.fontColorGreen = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_GREEN);
+
+       pSetting->option.mmsStyleOpt.fontColorBlue = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_BLUE);
+
+       pSetting->option.mmsStyleOpt.fontColorHue = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_HUE);
+
+       pSetting->option.mmsStyleOpt.bgColorRed = MsgSettingGetInt(MMS_STYLE_BG_COLOR_RED);
+
+       pSetting->option.mmsStyleOpt.bgColorGreen = MsgSettingGetInt(MMS_STYLE_BG_COLOR_GREEN);
+
+       pSetting->option.mmsStyleOpt.bgColorBlue = MsgSettingGetInt(MMS_STYLE_BG_COLOR_BLUE);
+
+       pSetting->option.mmsStyleOpt.bgColorHue = MsgSettingGetInt(MMS_STYLE_BG_COLOR_HUE);
+
+       pSetting->option.mmsStyleOpt.pageDur = MsgSettingGetInt(MMS_STYLE_PAGE_DUR);
+
+       pSetting->option.mmsStyleOpt.pageCustomDur = MsgSettingGetInt(MMS_STYLE_PAGE_CUSTOM_DUR);
+
+       pSetting->option.mmsStyleOpt.pageDurManual = MsgSettingGetInt(MMS_STYLE_PAGE_DUR_MANUAL);
+}
+
+
+void MsgGetPushMsgOpt(MSG_SETTING_S *pSetting)
+{
+       memset(&(pSetting->option.pushMsgOpt), 0x00, sizeof(MSG_PUSHMSG_OPT_S));
+
+       MsgSettingGetBool(PUSH_RECV_OPTION, &pSetting->option.pushMsgOpt.bReceive);
+
+       pSetting->option.pushMsgOpt.serviceType = (MSG_PUSH_SERVICE_TYPE_T)MsgSettingGetInt(PUSH_SERVICE_TYPE);
+}
+
+
+void MsgGetCBMsgOpt(MSG_SETTING_S *pSetting)
+{
+       char keyName[DEF_BUF_LEN] = {0, };
+       char *tmpValue = NULL;
+
+       memset(&(pSetting->option.cbMsgOpt), 0x00, sizeof(MSG_CBMSG_OPT_S));
+
+       MsgSettingGetBool(CB_RECEIVE, &pSetting->option.cbMsgOpt.bReceive);
+
+       MsgSettingGetBool(CB_ALL_CHANNEL, &pSetting->option.cbMsgOpt.bAllChannel);
+
+       pSetting->option.cbMsgOpt.maxSimCnt = MsgSettingGetInt(CB_MAX_SIM_COUNT);
+
+       pSetting->option.cbMsgOpt.channelData.channelCnt = MsgSettingGetInt(CB_CHANNEL_COUNT);
+
+       for (int i = 0; i < pSetting->option.cbMsgOpt.channelData.channelCnt; i++)
+       {
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ACTIVATE, i);
+
+               MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.channelData.channelInfo[i].bActivate);
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ID, i);
+
+               pSetting->option.cbMsgOpt.channelData.channelInfo[i].id = MsgSettingGetInt(keyName);
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_NAME, i);
+
+               tmpValue = MsgSettingGetString(keyName);
+               if (tmpValue != NULL) {
+                       strncpy(pSetting->option.cbMsgOpt.channelData.channelInfo[i].name, tmpValue, CB_CHANNEL_NAME_MAX);
+                       free(tmpValue);
+                       tmpValue = NULL;
+               }
+       }
+
+       for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++)
+       {
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_LANGUAGE, i);
+
+               MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]);
+       }
+}
+
+
+void MsgGetVoiceMailOpt(MSG_SETTING_S *pSetting)
+{
+       char *tmpValue = NULL;
+
+       memset(&(pSetting->option.voiceMailOpt), 0x00, sizeof(MSG_VOICEMAIL_OPT_S));
+
+       tmpValue = MsgSettingGetString(VOICEMAIL_NUMBER);
+       if (tmpValue != NULL) {
+               strncpy(pSetting->option.voiceMailOpt.mailNumber, tmpValue, MAX_PHONE_NUMBER_LEN);
+               free(tmpValue);
+               tmpValue = NULL;
+       }
+}
+
+
+void MsgGetMsgSizeOpt(MSG_SETTING_S *pSetting)
+{
+       memset(&(pSetting->option.msgSizeOpt), 0x00, sizeof(MSG_MSGSIZE_OPT_S));
+
+       pSetting->option.msgSizeOpt.nMsgSize = MsgSettingGetInt(MSGSIZE_OPTION);
+}
+
+
+MSG_ERROR_T MsgSetConfigInSim(const MSG_SETTING_S *pSetting)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE);
+
+       // Get Setting Data from SIM
+       if (plg != NULL)
+               err = plg->setConfigData(pSetting);
+       else
+               err = MSG_ERR_NULL_POINTER;
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error. Error code is %d.", err);
+               return err;
+       }
+
+       return err;
+}
diff --git a/framework/storage-handler/MsgStorageFolder.cpp b/framework/storage-handler/MsgStorageFolder.cpp
new file mode 100755 (executable)
index 0000000..f2e7114
--- /dev/null
@@ -0,0 +1,161 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgUtilStorage.h"
+#include "MsgSqliteWrapper.h"
+#include "MsgStorageHandler.h"
+
+
+/*==================================================================================================
+                                     VARIABLES
+==================================================================================================*/
+extern MsgDbHandler dbHandle;
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgStoAddFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       unsigned int rowId = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       err = dbHandle.getRowId(MSGFW_FOLDER_TABLE_NAME, &rowId);
+
+       if (err != MSG_SUCCESS)
+               return err;
+
+       // Add Folder
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, '%s', %d);",
+                               MSGFW_FOLDER_TABLE_NAME, rowId, pFolderInfo->folderName, pFolderInfo->folderType);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoUpdateFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       // Update Folder
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET FOLDER_NAME = '%s', FOLDER_TYPE = %d WHERE FOLDER_ID = %d;",
+                               MSGFW_FOLDER_TABLE_NAME, pFolderInfo->folderName, pFolderInfo->folderType, pFolderInfo->folderId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoDeleteFolder(const MSG_FOLDER_ID_T FolderId)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       dbHandle.beginTrans();
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE FOLDER_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, FolderId);
+
+       // Delete Message in the folder from msg table
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+       {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE FOLDER_ID = %d;",
+                                       MSGFW_FOLDER_TABLE_NAME, FolderId);
+
+       // Delete Message in the folder from msg table
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+       {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       // Clear Address table
+       if (MsgStoClearAddressTable(&dbHandle) != MSG_SUCCESS)
+       {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       dbHandle.endTrans(true);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetFolderList(MSG_FOLDER_LIST_S *pFolderList)
+{
+       if (pFolderList == NULL)
+       {
+               MSG_DEBUG("pFolderList is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       int rowCnt = 0;
+       int index = 3;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FOLDER_ID, FOLDER_TYPE, FOLDER_NAME FROM %s;",
+               MSGFW_FOLDER_TABLE_NAME);
+
+       if (dbHandle.getTable(sqlQuery, &rowCnt) != MSG_SUCCESS)
+       {
+               dbHandle.freeTable();
+               return MSG_ERR_DB_GETTABLE;
+       }
+
+       pFolderList->nCount = rowCnt;
+
+       MSG_DEBUG("pFolderList->nCount [%d]", pFolderList->nCount);
+
+       pFolderList->folderInfo = (MSG_FOLDER_INFO_S*)new char[sizeof(MSG_FOLDER_INFO_S)*rowCnt];
+
+       MSG_FOLDER_INFO_S* pTmp = pFolderList->folderInfo;
+
+       for (int i = 0; i < rowCnt; i++)
+       {
+               pTmp->folderId = dbHandle.getColumnToInt(index++);
+
+               pTmp->folderType = dbHandle.getColumnToInt(index++);
+
+               memset(pTmp->folderName, 0x00, sizeof(pTmp->folderName));
+               dbHandle.getColumnToString(index++, MAX_FOLDER_NAME_SIZE, pTmp->folderName);
+
+               pTmp++;
+       }
+
+       dbHandle.freeTable();
+
+       return MSG_SUCCESS;
+}
+
diff --git a/framework/storage-handler/MsgStorageManager.cpp b/framework/storage-handler/MsgStorageManager.cpp
new file mode 100755 (executable)
index 0000000..e6a8f23
--- /dev/null
@@ -0,0 +1,814 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgUtilStorage.h"
+#include "MsgGconfWrapper.h"
+#include "MsgSqliteWrapper.h"
+#include "MsgPluginManager.h"
+#include "MsgStorageHandler.h"
+
+
+/*==================================================================================================
+                                     VARIABLES
+==================================================================================================*/
+MsgDbHandler dbHandle;
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgStoConnectDB()
+{
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoDisconnectDB()
+{
+       if (dbHandle.disconnect() != MSG_SUCCESS)
+       {
+               MSG_DEBUG("DB Disconnect Fail");
+               return MSG_ERR_DB_DISCONNECT;
+       }
+
+       MSG_DEBUG("DB Disconnect Success");
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoInitDB(bool bSimChanged)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+#ifdef MSG_DB_CREATE
+       if (MsgCreateAddressTable() != MSG_SUCCESS)
+               return MSG_ERR_DB_STORAGE_INIT;
+       if (MsgCreateFolderTable() != MSG_SUCCESS)
+               return MSG_ERR_DB_STORAGE_INIT;
+       if (MsgCreateMsgTable() != MSG_SUCCESS)
+               return MSG_ERR_DB_STORAGE_INIT;
+       if (MsgCreateSimMessageTable() != MSG_SUCCESS)
+               return MSG_ERR_DB_STORAGE_INIT;
+       if (MsgCreateWAPMessageTable() != MSG_SUCCESS)
+               return MSG_ERR_DB_STORAGE_INIT;
+       if (MsgCreateCBMessageTable() != MSG_SUCCESS)
+               return MSG_ERR_DB_STORAGE_INIT;
+       if (MsgCreateSyncMLMessageTable() != MSG_SUCCESS)
+               return MSG_ERR_DB_STORAGE_INIT;
+       if (MsgCreateScheduledMessageTable() != MSG_SUCCESS)
+               return MSG_ERR_DB_STORAGE_INIT;
+       if (MsgCreateSmsSendOptTable() != MSG_SUCCESS)
+               return MSG_ERR_DB_STORAGE_INIT;
+       if (MsgCreateFilterTable() != MSG_SUCCESS)
+               return MSG_ERR_DB_STORAGE_INIT;
+       if (MsgCreateMmsMsgTable() != MSG_SUCCESS)
+               return MSG_ERR_DB_STORAGE_INIT;
+       if (MsgCreateMmsAttributeTable() != MSG_SUCCESS)
+               return MSG_ERR_DB_STORAGE_INIT;
+
+       // Add Default Folders
+       if (MsgAddDefaultFolders() != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Add Default Folders Fail");
+               return MSG_ERR_DB_STORAGE_INIT;
+       }
+
+       // Add Default Address
+       if (MsgAddDefaultAddress() != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Add Default Address Fail");
+               return MSG_ERR_DB_STORAGE_INIT;
+       }
+#endif
+
+       // Delete Msgs in Hidden Folder
+       MsgStoDeleteAllMessageInFolder(0, true, NULL);
+
+       // Reset network status
+       MsgStoResetNetworkStatus();
+
+       //clear abnormal mms message
+       MsgStoCleanAbnormalMmsData();
+
+       // Clear all old Sim data
+       MsgStoClearSimMessageInDB();
+
+       int smsCnt = 0, mmsCnt = 0;
+
+       smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE);
+       mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
+
+       // Set Indicator
+       MsgSettingSetIndicator(smsCnt, mmsCnt);
+
+       MSG_END();
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCreateAddressTable()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (!dbHandle.checkTableExist(MSGFW_ADDRESS_TABLE_NAME))
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "CREATE TABLE %s ( \
+                                                 ADDRESS_ID INTEGER PRIMARY KEY, \
+                                                 ADDRESS_TYPE INTEGER, \
+                                                 RECIPIENT_TYPE INTEGER, \
+                                                 ADDRESS_VAL TEXT, \
+                                                 CONTACT_ID INTEGER, \
+                                                 DISPLAY_NAME TEXT, \
+                                                 FIRST_NAME TEXT, \
+                                                 LAST_NAME TEXT, \
+                                                 IMAGE_PATH TEXT, \
+                                                 SYNC_TIME DATETIME, \
+                                                 UNREAD_CNT INTEGER DEFAULT 0, \
+                                                 SMS_CNT INTEGER DEFAULT 0, \
+                                                 MMS_CNT INTEGER DEFAULT 0, \
+                                                 MAIN_TYPE INTEGER NOT NULL, \
+                                                 SUB_TYPE INTEGER NOT NULL, \
+                                                 MSG_DIRECTION INTEGER NOT NULL, \
+                                                 MSG_TIME DATETIME, \
+                                                 MSG_TEXT TEXT);",
+                                               MSGFW_ADDRESS_TABLE_NAME);
+
+               err = dbHandle.execQuery(sqlQuery);
+
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("SUCCESS : create %s.", MSGFW_ADDRESS_TABLE_NAME);
+               else
+                       MSG_DEBUG("FAIL : create %s [%d].", MSGFW_ADDRESS_TABLE_NAME, err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCreateFolderTable()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (!dbHandle.checkTableExist(MSGFW_FOLDER_TABLE_NAME))
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "CREATE TABLE %s ( \
+                                                 FOLDER_ID INTEGER PRIMARY KEY, \
+                                                 FOLDER_NAME TEXT NOT NULL, \
+                                                 FOLDER_TYPE INTEGER DEFAULT 0);",
+                                                 MSGFW_FOLDER_TABLE_NAME);
+
+               err = dbHandle.execQuery(sqlQuery);
+
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("SUCCESS : create %s.", MSGFW_FOLDER_TABLE_NAME);
+               else
+                       MSG_DEBUG("FAIL : create %s [%d].", MSGFW_FOLDER_TABLE_NAME, err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCreateMsgTable()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (!dbHandle.checkTableExist(MSGFW_MESSAGE_TABLE_NAME))
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "CREATE TABLE %s ( \
+                                                 MSG_ID INTEGER PRIMARY KEY, \
+                                                 ADDRESS_ID INTEGER, \
+                                                 FOLDER_ID INTEGER, \
+                                                 REFERENCE_ID INTEGER, \
+                                                 STORAGE_ID INTEGER NOT NULL, \
+                                                 MAIN_TYPE INTEGER NOT NULL, \
+                                                 SUB_TYPE INTEGER NOT NULL, \
+                                                 DISPLAY_TIME DATETIME, \
+                                                 DATA_SIZE INTEGER DEFAULT 0, \
+                                                 NETWORK_STATUS INTEGER DEFAULT 0, \
+                                                 READ_STATUS INTEGER DEFAULT 0, \
+                                                 PROTECTED INTEGER DEFAULT 0, \
+                                                 PRIORITY INTEGER DEFAULT 0, \
+                                                 MSG_DIRECTION INTEGER NOT NULL, \
+                                                 SCHEDULED_TIME DATETIME, \
+                                                 BACKUP INTEGER DEFAULT 0, \
+                                                 SUBJECT TEXT, \
+                                                 MSG_DATA TEXT, \
+                                                 THUMB_PATH TEXT, \
+                                                 MSG_TEXT TEXT, \
+                                                 DELIVERY_REPORT_STATUS INTEGER DEFAULT 0, \
+                                                 DELIVERY_REPORT_TIME DATETIME, \
+                                                 READ_REPORT_STATUS INTEGER DEFAULT 0, \
+                                                 READ_REPORT_TIME DATETIME, \
+                                                 ATTACHMENT_COUNT INTEGER DEFAULT 0, \
+                                                 FOREIGN KEY(ADDRESS_ID) REFERENCES %s(ADDRESS_ID), \
+                                                 FOREIGN KEY(FOLDER_ID) REFERENCES %s(FOLDER_ID) \
+                                                 );",
+                                                 MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, MSGFW_FOLDER_TABLE_NAME);
+
+               err = dbHandle.execQuery(sqlQuery);
+
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("SUCCESS : create %s.", MSGFW_MESSAGE_TABLE_NAME);
+               else
+                       MSG_DEBUG("FAIL : create %s [%d].", MSGFW_MESSAGE_TABLE_NAME, err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCreateSimMessageTable()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (!dbHandle.checkTableExist(MSGFW_SIM_MSG_TABLE_NAME))
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "CREATE TABLE %s ( \
+                                                 MSG_ID INTEGER, \
+                                                 SIM_ID INTEGER NOT NULL, \
+                                                 FOREIGN KEY(MSG_ID) REFERENCES %s(MSG_ID));",
+                                                 MSGFW_SIM_MSG_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME);
+
+               err = dbHandle.execQuery(sqlQuery);
+
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("SUCCESS : create %s.", MSGFW_SIM_MSG_TABLE_NAME);
+               else
+                       MSG_DEBUG("FAIL : create %s [%d].", MSGFW_SIM_MSG_TABLE_NAME, err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCreateWAPMessageTable()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (!dbHandle.checkTableExist(MSGFW_PUSH_MSG_TABLE_NAME))
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "CREATE TABLE %s ( \
+                                                 MSG_ID INTEGER, \
+                                                 ACTION INTEGER, \
+                                                 CREATED INTEGER, \
+                                                 EXPIRES INTEGER, \
+                                                 ID TEXT, \
+                                                 HREF TEXT, \
+                                                 CONTENT TEXT, \
+                                                 FOREIGN KEY(MSG_ID) REFERENCES %s(MSG_ID));",
+                                                 MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME);
+
+               err = dbHandle.execQuery(sqlQuery);
+
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("SUCCESS : create %s.", MSGFW_PUSH_MSG_TABLE_NAME);
+               else
+                       MSG_DEBUG("FAIL : create %s [%d].", MSGFW_PUSH_MSG_TABLE_NAME, err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCreateCBMessageTable()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (!dbHandle.checkTableExist(MSGFW_CB_MSG_TABLE_NAME))
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "CREATE TABLE %s ( \
+                                                 MSG_ID INTEGER, \
+                                                 CB_MSG_ID INTEGER NOT NULL, \
+                                                 FOREIGN KEY(MSG_ID) REFERENCES %s(MSG_ID));",
+                                                 MSGFW_CB_MSG_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME);
+
+               err = dbHandle.execQuery(sqlQuery);
+
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("SUCCESS : create %s.", MSGFW_CB_MSG_TABLE_NAME);
+               else
+                       MSG_DEBUG("FAIL : create %s [%d].", MSGFW_CB_MSG_TABLE_NAME, err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCreateSyncMLMessageTable()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (!dbHandle.checkTableExist(MSGFW_SYNCML_MSG_TABLE_NAME))
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "CREATE TABLE %s ( \
+                                                 MSG_ID INTEGER, \
+                                                 EXT_ID INTEGER NOT NULL, \
+                                                 PINCODE INTEGER NOT NULL, \
+                                                 FOREIGN KEY(MSG_ID) REFERENCES %s(MSG_ID));",
+                                                 MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME);
+
+               err = dbHandle.execQuery(sqlQuery);
+
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("SUCCESS : create %s.", MSGFW_SYNCML_MSG_TABLE_NAME);
+               else
+                       MSG_DEBUG("FAIL : create %s [%d].", MSGFW_SYNCML_MSG_TABLE_NAME, err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCreateScheduledMessageTable()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (!dbHandle.checkTableExist(MSGFW_SCHEDULED_MSG_TABLE_NAME))
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "CREATE TABLE %s ( \
+                                                 MSG_ID INTEGER, \
+                                                 ALARM_ID INTEGER NOT NULL, \
+                                                 LISTENER_FD INTEGER NOT NULL, \
+                                                 FOREIGN KEY(MSG_ID) REFERENCES %s(MSG_ID));",
+                                                 MSGFW_SCHEDULED_MSG_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME);
+
+               err = dbHandle.execQuery(sqlQuery);
+
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("SUCCESS : create %s.", MSGFW_SCHEDULED_MSG_TABLE_NAME);
+               else
+                       MSG_DEBUG("FAIL : create %s [%d].", MSGFW_SCHEDULED_MSG_TABLE_NAME, err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCreateSmsSendOptTable()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (!dbHandle.checkTableExist(MSGFW_SMS_SENDOPT_TABLE_NAME))
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "CREATE TABLE %s ( \
+                                                 MSG_ID INTEGER, \
+                                                 DELREP_REQ INTEGER NOT NULL, \
+                                                 KEEP_COPY INTEGER NOT NULL, \
+                                                 REPLY_PATH INTEGER NOT NULL, \
+                                                 FOREIGN KEY(MSG_ID) REFERENCES %s(MSG_ID));",
+                                                 MSGFW_SMS_SENDOPT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME);
+
+               err = dbHandle.execQuery(sqlQuery);
+
+               if (err == MSG_SUCCESS)
+                               MSG_DEBUG("SUCCESS : create %s.", MSGFW_SMS_SENDOPT_TABLE_NAME);
+               else
+                               MSG_DEBUG("FAIL : create %s [%d].", MSGFW_SMS_SENDOPT_TABLE_NAME, err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCreateFilterTable()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (!dbHandle.checkTableExist(MSGFW_FILTER_TABLE_NAME))
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "CREATE TABLE %s ( \
+                                                 FILTER_ID INTEGER PRIMARY KEY, \
+                                                 FILTER_TYPE INTEGER NOT NULL, \
+                                                 FILTER_VALUE TEXT NOT NULL);",
+                                                 MSGFW_FILTER_TABLE_NAME);
+
+               err = dbHandle.execQuery(sqlQuery);
+
+               if (err == MSG_SUCCESS)
+                               MSG_DEBUG("SUCCESS : create %s.", MSGFW_FILTER_TABLE_NAME);
+               else
+                               MSG_DEBUG("FAIL : create %s [%d].", MSGFW_FILTER_TABLE_NAME, err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCreateMmsMsgTable()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (!dbHandle.checkTableExist(MMS_PLUGIN_MESSAGE_TABLE_NAME))
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "CREATE TABLE %s ( \
+                                                 MSG_ID INTEGER, \
+                                                 TRANSACTION_ID TEXT, \
+                                                 MESSAGE_ID TEXT, \
+                                                 FWD_MESSAGE_ID TEXT, \
+                                                 CONTENTS_LOCATION TEXT, \
+                                                 FILE_PATH TEXT, \
+                                                 FOREIGN KEY(MSG_ID) REFERENCES %s(MSG_ID));",
+                                                 MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME);
+
+               err = dbHandle.execQuery(sqlQuery);
+
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("SUCCESS : create %s.", MMS_PLUGIN_MESSAGE_TABLE_NAME);
+               else
+                       MSG_DEBUG("FAIL : create %s [%d].", MMS_PLUGIN_MESSAGE_TABLE_NAME, err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCreateMmsAttributeTable()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (!dbHandle.checkTableExist(MMS_PLUGIN_ATTRIBUTE_TABLE_NAME))
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "CREATE TABLE %s ( \
+                                                MSG_ID INTEGER, \
+                                                VERSION INTEGER NOT NULL, \
+                                                DATA_TYPE INTEGER DEFAULT -1, \
+                                                DATE DATETIME, \
+                                                HIDE_ADDRESS INTEGER DEFAULT 0, \
+                                                ASK_DELIVERY_REPORT INTEGER DEFAULT 0, \
+                                                REPORT_ALLOWED INTEGER DEFAULT 0, \
+                                                READ_REPORT_ALLOWED_TYPE INTEGER DEFAULT 0, \
+                                                ASK_READ_REPLY INTEGER DEFAULT 0, \
+                                                READ INTEGER DEFAULT 0, \
+                                                READ_REPORT_SEND_STATUS        INTEGER DEFAULT 0, \
+                                                READ_REPORT_SENT INTEGER DEFAULT 0, \
+                                                PRIORITY INTEGER DEFAULT 0, \
+                                                KEEP_COPY INTEGER DEFAULT 0, \
+                                                MSG_SIZE INTEGER NOT NULL, \
+                                                MSG_CLASS INTEGER DEFAULT -1, \
+                                                EXPIRY_TIME DATETIME, \
+                                                CUSTOM_DELIVERY_TIME INTEGER DEFAULT 0, \
+                                                DELIVERY_TIME DATETIME, \
+                                                MSG_STATUS INTEGER DEFAULT -1, \
+                                                FOREIGN KEY(MSG_ID) REFERENCES %s(MSG_ID));",
+                                                MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME);
+
+               err = dbHandle.execQuery(sqlQuery);
+
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("SUCCESS : create %s.", MMS_PLUGIN_ATTRIBUTE_TABLE_NAME);
+               else
+                       MSG_DEBUG("FAIL : create %s [%d].", MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgAddDefaultFolders()
+{
+       int nRowCnt = 0;
+       int nResult = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       // INBOX
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;",
+                                       MSGFW_FOLDER_TABLE_NAME, MSG_INBOX_ID);
+
+       if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS)
+       {
+               dbHandle.freeTable();
+               return MSG_ERR_DB_GETTABLE;
+       }
+
+       nResult = dbHandle.getColumnToInt(1);
+
+       dbHandle.freeTable();
+
+       if (nResult == 0)
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'INBOX', %d);",
+                                       MSGFW_FOLDER_TABLE_NAME, MSG_INBOX_ID, MSG_FOLDER_TYPE_INBOX);
+
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_EXEC;
+       }
+
+       // OUTBOX
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;",
+                                       MSGFW_FOLDER_TABLE_NAME, MSG_OUTBOX_ID);
+
+       if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS)
+       {
+               dbHandle.freeTable();
+               return MSG_ERR_DB_GETTABLE;
+       }
+
+       nResult = dbHandle.getColumnToInt(1);
+
+       dbHandle.freeTable();
+
+       if (nResult == 0)
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'OUTBOX', %d);",
+                                       MSGFW_FOLDER_TABLE_NAME, MSG_OUTBOX_ID, MSG_FOLDER_TYPE_OUTBOX);
+
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_EXEC;
+       }
+
+       // SENTBOX
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;",
+                                       MSGFW_FOLDER_TABLE_NAME, MSG_SENTBOX_ID);
+
+       if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS)
+       {
+               dbHandle.freeTable();
+               return MSG_ERR_DB_GETTABLE;
+       }
+
+       nResult = dbHandle.getColumnToInt(1);
+
+       dbHandle.freeTable();
+
+       if (nResult == 0)
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'SENTBOX', %d);",
+                                       MSGFW_FOLDER_TABLE_NAME, MSG_SENTBOX_ID, MSG_FOLDER_TYPE_OUTBOX);
+
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_EXEC;
+       }
+
+       // DRAFT
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;",
+                                       MSGFW_FOLDER_TABLE_NAME, MSG_DRAFT_ID);
+
+       if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS)
+       {
+               dbHandle.freeTable();
+               return MSG_ERR_DB_GETTABLE;
+       }
+
+       nResult = dbHandle.getColumnToInt(1);
+
+       dbHandle.freeTable();
+
+       if (nResult == 0)
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'DRAFT', %d);",
+                                       MSGFW_FOLDER_TABLE_NAME, MSG_DRAFT_ID, MSG_FOLDER_TYPE_DRAFT);
+
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_EXEC;
+       }
+
+       // CBMSGBOX
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;",
+                                       MSGFW_FOLDER_TABLE_NAME, MSG_CBMSGBOX_ID);
+
+       if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS)
+       {
+               dbHandle.freeTable();
+               return MSG_ERR_DB_GETTABLE;
+       }
+
+       nResult = dbHandle.getColumnToInt(1);
+
+       dbHandle.freeTable();
+
+       if (nResult == 0)
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'CBMSGBOX', %d);",
+                                       MSGFW_FOLDER_TABLE_NAME, MSG_CBMSGBOX_ID, MSG_FOLDER_TYPE_INBOX);
+
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_EXEC;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgAddDefaultAddress()
+{
+       MSG_BEGIN();
+
+       int nRowCnt = 0, nResult = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE ADDRESS_ID = 0;",
+                                       MSGFW_ADDRESS_TABLE_NAME);
+
+       if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS)
+       {
+               dbHandle.freeTable();
+               return MSG_ERR_DB_GETTABLE;
+       }
+
+       nResult = dbHandle.getColumnToInt(1);
+
+       dbHandle.freeTable();
+
+       if (nResult == 0)
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (0, 0, 0, '', 0, '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '');",
+                                       MSGFW_ADDRESS_TABLE_NAME);
+
+               MSG_DEBUG("%s", sqlQuery);
+
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_EXEC;
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoResetDatabase()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       const char* tableList[] = {MSGFW_FOLDER_TABLE_NAME, MSGFW_FILTER_TABLE_NAME,
+                                               MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME,
+                                               MMS_PLUGIN_MESSAGE_TABLE_NAME, MMS_PLUGIN_ATTRIBUTE_TABLE_NAME,
+                                               MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SCHEDULED_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME};
+
+       int listCnt = sizeof(tableList)/sizeof(char*);
+
+       dbHandle.beginTrans();
+
+       // Delete Database
+       for (int i = 0; i < listCnt; i++)
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s;", tableList[i]);
+
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+       }
+
+       // Delete Message Table
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE STORAGE_ID <> %d;",
+                       MSGFW_MESSAGE_TABLE_NAME, MSG_STORAGE_SIM);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+       {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       // Delete Address Table
+       err = MsgStoClearAddressTable(&dbHandle);
+
+       if (err != MSG_SUCCESS)
+       {
+               dbHandle.endTrans(false);
+               return err;
+       }
+
+       // Add Default Folders
+       if (MsgAddDefaultFolders() != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Add Default Folders Fail");
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_STORAGE_INIT;
+       }
+
+       // Add Default Address
+       if (MsgAddDefaultAddress() != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Add Default Address Fail");
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_STORAGE_INIT;
+       }
+
+       dbHandle.endTrans(true);
+
+       // Delete MMS Files
+       MsgRmRf((char*)MSG_DATA_PATH);
+       MsgRmRf((char*)MSG_SMIL_FILE_PATH);
+
+       // Reset SMS Count
+       if (MsgSettingSetIndicator(0, 0) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgSettingSetIndicator() FAILED");
+               return MSG_ERR_SET_SETTING;
+       }
+
+       // Reset MMS Count
+       if (MsgSettingSetIndicator(0, 0) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgSettingSetIndicator() FAILED");
+               return MSG_ERR_SET_SETTING;
+       }
+
+       return MSG_SUCCESS;
+}
diff --git a/framework/storage-handler/MsgStorageMessage.cpp b/framework/storage-handler/MsgStorageMessage.cpp
new file mode 100755 (executable)
index 0000000..629d207
--- /dev/null
@@ -0,0 +1,3313 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <tr1/unordered_set>
+#include <queue>
+#include <locale>
+#include <glib.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgContact.h"
+#include "MsgUtilFile.h"
+#include "MsgMutex.h"
+#include "MsgUtilStorage.h"
+#include "MsgSoundPlayer.h"
+#include "MsgGconfWrapper.h"
+#include "MsgSqliteWrapper.h"
+#include "MsgPluginManager.h"
+#include "MsgStorageHandler.h"
+#include "MsgNotificationWrapper.h"
+#include "MsgMmsMessage.h"
+
+using namespace std;
+
+
+/*==================================================================================================
+                                     VARIABLES
+==================================================================================================*/
+extern MsgDbHandler dbHandle;
+
+static unsigned int refId = 0;
+
+Mutex delNotiMx;
+CndVar delNoticv;
+bool delNotiRunning = false;
+
+Mutex delLogMx;
+CndVar delLogcv;
+bool delLogRunning = false;
+
+
+/*==================================================================================================
+                                     FUNCTION FOR THREAD
+==================================================================================================*/
+static gboolean startToDeleteNoti(void *pVoid)
+{
+       MSG_BEGIN();
+
+       MSG_MSGID_LIST_S *pMsgIdList = (MSG_MSGID_LIST_S *)pVoid;
+
+       MSG_DEBUG("pMsgIdList->nCount [%d]", pMsgIdList->nCount);
+
+       delNotiMx.lock();
+
+       while (delNotiRunning) {
+               delNoticv.wait(delNotiMx.pMutex());
+       }
+
+       delNotiRunning = true;
+
+       for (int i = 0; i < pMsgIdList->nCount; i++) {
+               MsgDeleteNotiByMsgId(pMsgIdList->msgIdList[i]);
+
+               /** sleep for moment */
+               if ((i%100 == 0) && (i != 0))
+                       usleep(70000);
+       }
+
+       delNotiRunning = false;
+
+       delNoticv.signal();
+       delNotiMx.unlock();
+
+       // memory free
+       if (pMsgIdList != NULL) {
+               //free peer info list
+               if (pMsgIdList->msgIdList != NULL)
+                       delete [] pMsgIdList->msgIdList;
+
+               delete [] pMsgIdList;
+       }
+
+       MSG_END();
+
+       return FALSE;
+}
+
+
+static gboolean updateUnreadMsgCount(void *pVoid)
+{
+       MSG_BEGIN();
+
+       int smsCnt = 0;
+       int mmsCnt = 0;
+
+       smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE);
+       mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
+
+       MsgSettingSetIndicator(smsCnt, mmsCnt);
+
+       MSG_END();
+
+       return FALSE;
+}
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, int addrIdx)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       unsigned int rowId = 0;
+       unsigned int addrId = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       dbHandle.beginTrans();
+
+       if (pMsg->nAddressCnt > 0) {
+               err = MsgStoAddAddress(&dbHandle, &(pMsg->addressList[addrIdx]), &addrId);
+
+               if (err != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return err;
+               }
+
+               pMsg->addressList[addrIdx].threadId = (MSG_THREAD_ID_T)addrId;
+       }
+
+       err = dbHandle.getRowId(MSGFW_MESSAGE_TABLE_NAME, &rowId);
+
+       if (err != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return err;
+       }
+
+       pMsg->msgId = (MSG_MESSAGE_ID_T)rowId;
+
+       if (addrIdx == 0)
+               refId = pMsg->msgId;
+
+       pMsg->referenceId = refId;
+
+       int fileSize = 0;
+
+       char *pFileData = NULL;
+       AutoPtr<char> buf(&pFileData);
+
+       // Get File Data
+       if (pMsg->bTextSms == false) {
+               if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_STORAGE_ERROR;
+               }
+               MSG_DEBUG("file size [%d]", fileSize);
+       }
+
+       // Add Message
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d, %d, %d, %ld, %d, %d, %d, %d, %d, %d, %ld, %d, ?, ?, ?, ?, %d, 0, %d, 0, 0);",
+                               MSGFW_MESSAGE_TABLE_NAME, rowId, addrId, pMsg->folderId, pMsg->referenceId, pMsg->storageId, pMsg->msgType.mainType, pMsg->msgType.subType,
+                               pMsg->displayTime, pMsg->dataSize, pMsg->networkStatus, pMsg->bRead, pMsg->bProtected, pMsg->priority, pMsg->direction,
+                               pMsg->scheduledTime, pMsg->bBackup, MSG_DELIVERY_REPORT_NONE, MSG_READ_REPORT_NONE);
+
+       MSG_DEBUG("QUERY : %s", sqlQuery);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       dbHandle.bindText(pMsg->subject, 1);
+
+       dbHandle.bindText(pMsg->msgData, 2);
+
+       dbHandle.bindText(pMsg->thumbPath, 3);
+
+       if (pMsg->bTextSms == false)
+               dbHandle.bindText(pFileData, 4);
+       else
+               dbHandle.bindText(pMsg->msgText, 4);
+
+       if (dbHandle.stepQuery() != MSG_ERR_DB_DONE) {
+               dbHandle.finalizeQuery();
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       dbHandle.finalizeQuery();
+
+       if (pMsg->msgType.subType != MSG_SENDREQ_MMS) {
+               err = MsgStoUpdateAddress(&dbHandle, addrId);
+
+               if (err != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return err;
+               }
+       }
+
+       dbHandle.endTrans(true);
+
+       /* In the case of MMS Message, load the MMS plugin to save MMS PDU */
+       if (pMsg->msgType.mainType == MSG_MMS_TYPE) {
+               MMS_MESSAGE_DATA_S mmsMsg;
+               memset(&mmsMsg, 0x00, sizeof(MMS_MESSAGE_DATA_S));
+
+               if (pMsg->dataSize == 0) {
+                       MSG_DEBUG("pMsg->dataSize == 0, So Making emtpy MMS body.");
+                       char * tempMmsBody = _MsgMmsSerializeMessageData(&mmsMsg, &(pMsg->dataSize));
+                       memcpy(&pMsg->msgText, tempMmsBody, pMsg->dataSize);
+                       free(tempMmsBody);
+               }
+
+               if (pMsg->msgType.subType != MSG_DELIVERYIND_MMS && pMsg->msgType.subType != MSG_READORGIND_MMS) {
+                       MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_MMS_TYPE);
+
+                       //pMsg->msgId = pMsg->refernceId;
+
+                       err = plg->addMessage(pMsg, pSendOptInfo, pFileData);
+
+                       if (err != MSG_SUCCESS)
+                               return MSG_ERR_STORAGE_ERROR;
+
+                       if (pMsg->msgType.subType == MSG_SENDREQ_MMS) {
+                               MSG_DEBUG("pMsg->msgText: %s, pMsg->thumbPath: %s ", pMsg->msgText, pMsg->thumbPath);
+
+                               err = MsgStoUpdateMMSMessage(pMsg);
+
+                               if (err != MSG_SUCCESS)
+                                       return MSG_ERR_STORAGE_ERROR;
+
+                       }
+               }
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, int addrIdx)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       unsigned int addrId = 0;
+
+       dbHandle.beginTrans();
+
+       if (pMsg->nAddressCnt > 0) {
+               err = MsgStoAddAddress(&dbHandle, &(pMsg->addressList[addrIdx]), &addrId);
+
+               if (err != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return err;
+               }
+       }
+
+       int fileSize = 0;
+
+       char *pFileData = NULL;
+       AutoPtr<char> buf(&pFileData);
+
+       // Get File Data
+       if (pMsg->bTextSms == false) {
+               if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_STORAGE_ERROR;
+               }
+       }
+
+       if (pSendOptInfo != NULL) {
+               // Get Global setting value if bSetting == false
+               if (pSendOptInfo->bSetting == false) {
+                       MsgSettingGetBool(MSG_KEEP_COPY, &pSendOptInfo->bKeepCopy);
+
+                       if (pMsg->msgType.mainType == MSG_SMS_TYPE) {
+                               MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSendOptInfo->bDeliverReq);
+                               MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSendOptInfo->option.smsSendOptInfo.bReplyPath);
+                       } else if (pMsg->msgType.mainType == MSG_MMS_TYPE) {
+                               MsgSettingGetBool(MMS_SEND_DELIVERY_REPORT, &pSendOptInfo->bDeliverReq);
+                               MsgSettingGetBool(MMS_SEND_READ_REPLY, &pSendOptInfo->option.mmsSendOptInfo.bReadReq);
+                               pSendOptInfo->option.mmsSendOptInfo.expiryTime.time = (unsigned int)MsgSettingGetInt(MMS_SEND_EXPIRY_TIME);
+
+                               MSG_MMS_DELIVERY_TIME_T deliveryTime = (MSG_MMS_DELIVERY_TIME_T)MsgSettingGetInt(MMS_SEND_DELIVERY_TIME);
+
+                               if (deliveryTime == MSG_DELIVERY_TIME_CUSTOM) {
+                                       pSendOptInfo->option.mmsSendOptInfo.bUseDeliveryCustomTime = true;
+                                       pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time = (unsigned int)MsgSettingGetInt(MMS_SEND_CUSTOM_DELIVERY);
+                               } else {
+                                       pSendOptInfo->option.mmsSendOptInfo.bUseDeliveryCustomTime = false;
+                                       pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time = (unsigned int)deliveryTime;
+                               }
+
+                               pSendOptInfo->option.mmsSendOptInfo.priority = (MSG_PRIORITY_TYPE_T)MsgSettingGetInt(MMS_SEND_PRIORITY);
+                       }
+               }
+       }
+
+       // Update Message
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET ADDRESS_ID = %d, FOLDER_ID = %d, STORAGE_ID = %d, MAIN_TYPE = %d, SUB_TYPE = %d, \
+                                                               DISPLAY_TIME = %lu, DATA_SIZE = %d, NETWORK_STATUS = %d, READ_STATUS = %d, \
+                                                               PROTECTED = %d, PRIORITY = %d, MSG_DIRECTION = %d, SCHEDULED_TIME = %lu, BACKUP = %d, SUBJECT = ?, MSG_DATA = ?, THUMB_PATH = ?, MSG_TEXT = ? \
+                                                               WHERE MSG_ID = %d;",
+                       MSGFW_MESSAGE_TABLE_NAME, addrId, pMsg->folderId, pMsg->storageId, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->displayTime, pMsg->dataSize,
+                       pMsg->networkStatus, pMsg->bRead, pMsg->bProtected, pMsg->priority, pMsg->direction, pMsg->scheduledTime, pMsg->bBackup, pMsg->msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       dbHandle.bindText(pMsg->subject, 1);
+
+       dbHandle.bindText(pMsg->msgData, 2);
+
+       dbHandle.bindText(pMsg->thumbPath, 3);
+
+       if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->bTextSms == false)
+               dbHandle.bindText(pFileData, 4);
+       else
+               dbHandle.bindText(pMsg->msgText, 4);
+
+       MSG_DEBUG("%s", sqlQuery);
+
+       if (dbHandle.stepQuery() != MSG_ERR_DB_DONE) {
+               dbHandle.finalizeQuery();
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       dbHandle.finalizeQuery();
+
+       if (pMsg->msgType.mainType == MSG_SMS_TYPE && pSendOptInfo != NULL) {
+               if (pSendOptInfo->bSetting == true) {
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET DELREP_REQ = %d, KEEP_COPY = %d, REPLY_PATH = %d \
+                                                                               WHERE MSG_ID = %d;",
+                                       MSGFW_SMS_SENDOPT_TABLE_NAME, pSendOptInfo->bDeliverReq, pSendOptInfo->bKeepCopy, pSendOptInfo->option.smsSendOptInfo.bReplyPath, pMsg->msgId);
+
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               dbHandle.endTrans(false);
+                               return MSG_ERR_DB_EXEC;
+                       }
+               }
+       } else if (pMsg->msgType.mainType == MSG_MMS_TYPE) {
+               MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_MMS_TYPE);
+
+               err = plg->updateMessage(pMsg, pSendOptInfo, pFileData);
+
+               if (err != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_STORAGE_ERROR;
+               }
+       }
+
+       err = MsgStoUpdateAddress(&dbHandle, addrId);
+
+       if (err != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       err = MsgStoClearAddressTable(&dbHandle);
+
+       if (err != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       dbHandle.endTrans(true);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoUpdateReadStatus(MSG_MESSAGE_ID_T MsgId, bool bRead)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       MSG_STORAGE_ID_T storageId;
+
+       if (MsgStoSetReadStatus(&dbHandle, MsgId, bRead) != MSG_SUCCESS) {
+               MSG_DEBUG("MsgStoUpdateAddress() Error");
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       // Get STORAGE_ID
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT STORAGE_ID \
+                                       FROM %s \
+                                    WHERE MSG_ID = %d;",
+                       MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               storageId = dbHandle.columnInt(0);
+       } else {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       MSG_DEBUG("StorageId:[%d]", storageId);
+
+       // Update Read Status for SIM Msg
+       if (storageId == MSG_STORAGE_SIM) {
+               MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE);
+
+               if (plg == NULL) {
+                       MSG_DEBUG("SMS Plug-in is NULL");
+                       return MSG_ERR_NULL_POINTER;
+               }
+
+               // Get SIM Msg ID
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_ID FROM %s WHERE MSG_ID = %d;",
+                                               MSGFW_SIM_MSG_TABLE_NAME, MsgId);
+
+               if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_PREPARE;
+
+               MSG_SIM_ID_T simId;
+
+               while (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+                       simId = dbHandle.columnInt(0);
+
+                       if (plg->setReadStatus(simId) != MSG_SUCCESS) {
+                               MSG_DEBUG("Fail to Set Read Status for SIM SMS");
+                               continue;
+                       }
+               }
+
+               dbHandle.finalizeQuery();
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoUpdateThreadReadStatus(MSG_THREAD_ID_T ThreadId)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int rowCnt = 0;
+       int index = 1;
+       MSG_MSGID_LIST_S *pUnreadMsgIdList = NULL;
+
+       pUnreadMsgIdList = (MSG_MSGID_LIST_S *)new char[sizeof(MSG_MSGID_LIST_S)];
+       memset(pUnreadMsgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       // Get MSG_ID List
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID \
+                                               FROM %s A \
+                                               WHERE ADDRESS_ID = %d AND READ_STATUS = 0;",
+                                       MSGFW_MESSAGE_TABLE_NAME, ThreadId);
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
+               dbHandle.freeTable();
+               return err;
+       }
+
+       pUnreadMsgIdList->nCount = rowCnt;
+
+       MSG_DEBUG("unreadMsgIdList.nCount [%d]", pUnreadMsgIdList->nCount);
+
+       pUnreadMsgIdList->msgIdList = (MSG_MESSAGE_ID_T *)new char[sizeof(MSG_MESSAGE_ID_T) * rowCnt];
+
+       for (int i = 0; i < rowCnt; i++)
+               pUnreadMsgIdList->msgIdList[i] = dbHandle.getColumnToInt(index++);
+
+       dbHandle.freeTable();
+
+
+       // Get sim MSG_ID
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID \
+                                       FROM %s A \
+                                    WHERE ADDRESS_ID = %d AND READ_STATUS = 0 AND STORAGE_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, ThreadId, MSG_STORAGE_SIM);
+
+       rowCnt = 0;
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
+               dbHandle.freeTable();
+               return err;
+       }
+
+       for (int i = 1; i <= rowCnt; i++) {
+               MsgStoUpdateReadStatus(dbHandle.getColumnToInt(i), true);
+       }
+
+       dbHandle.freeTable();
+
+       // set read status
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET READ_STATUS = %d \
+                                       WHERE ADDRESS_ID = %d AND READ_STATUS = 0;",
+                                       MSGFW_MESSAGE_TABLE_NAME, 1, ThreadId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+
+       if (MsgStoUpdateAddress(&dbHandle, ThreadId) != MSG_SUCCESS) {
+               MSG_DEBUG("MsgStoUpdateAddress() Error");
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       if (g_idle_add(updateUnreadMsgCount, NULL) == 0) {
+               MSG_DEBUG("updateUnreadMsgCount() Error");
+       }
+
+       if (pUnreadMsgIdList->nCount > 0) {
+               if (g_idle_add(startToDeleteNoti, (void *)pUnreadMsgIdList) == 0) {
+                       MSG_DEBUG("startToDeleteNoti not invoked: %s", strerror(errno));
+                       // memory free
+                       if (pUnreadMsgIdList != NULL) {
+                               //free peer info list
+                               if (pUnreadMsgIdList->msgIdList != NULL)
+                                       delete [] pUnreadMsgIdList->msgIdList;
+
+                               delete [] pUnreadMsgIdList;
+                       }
+                       err = MSG_ERR_UNKNOWN;
+               }
+       }
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoUpdateProtectedStatus(MSG_MESSAGE_ID_T MsgId, bool bProtected)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET PROTECTED = %d WHERE MSG_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, (int)bProtected, MsgId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoDeleteMessage(MSG_MESSAGE_ID_T MsgId, bool bCheckIndication)
+{
+       MSG_BEGIN();
+
+       MSG_DEBUG("Msg Id : %d", MsgId);
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       // Get SUB_TYPE, STORAGE_ID
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.MAIN_TYPE, A.SUB_TYPE, A.FOLDER_ID, A.STORAGE_ID, A.READ_STATUS, B.CONTACT_ID, B.ADDRESS_ID \
+                                       FROM %s A, %s B \
+                                    WHERE A.MSG_ID = %d AND A.ADDRESS_ID = B.ADDRESS_ID;",
+                       MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, MsgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       MSG_MESSAGE_TYPE_S msgType;
+       MSG_FOLDER_ID_T folderId;
+       MSG_STORAGE_ID_T storageId;
+       MSG_CONTACT_ID_T contactId;
+
+       bool bRead;
+       unsigned int addrId;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               msgType.mainType = dbHandle.columnInt(0);
+               msgType.subType = dbHandle.columnInt(1);
+               folderId = dbHandle.columnInt(2);
+               storageId = dbHandle.columnInt(3);
+               bRead = dbHandle.columnInt(4);
+               contactId = dbHandle.columnInt(5);
+               addrId = dbHandle.columnInt(6);
+
+               MSG_DEBUG("Main Type:[%d] SubType:[%d] FolderId:[%d] StorageId:[%d] ContactId:[%d] AddressId:[%d]", msgType.mainType, msgType.subType, folderId, storageId, contactId, addrId);
+       } else {
+               MSG_DEBUG("MsgStepQuery() Error [%s]", sqlQuery);
+
+               dbHandle.finalizeQuery();
+
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE);
+
+       if (plg == NULL) {
+               MSG_DEBUG("SMS Plug-in is NULL");
+
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       dbHandle.beginTrans();
+
+       // Check sim message
+       if (storageId == MSG_STORAGE_SIM) {
+               // get sim message id
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_ID FROM %s WHERE MSG_ID = %d;", MSGFW_SIM_MSG_TABLE_NAME, MsgId);
+
+               MSG_DEBUG("sqlQuery is [%s]", sqlQuery);
+
+               MSG_SIM_ID_T simMsgId;
+
+               if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_DB_PREPARE;
+               }
+
+               while (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+                       simMsgId = dbHandle.columnInt(0);
+
+                       MSG_DEBUG("SIM Msg Id : [%d]", simMsgId);
+
+                       err = plg->deleteSimMessage(simMsgId);
+
+                       if (err != MSG_SUCCESS) {
+                               dbHandle.finalizeQuery();
+                               dbHandle.endTrans(false);
+                               return err;
+                       }
+
+                       //Sim message delete in db table
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE SIM_ID = %d;", MSGFW_SIM_MSG_TABLE_NAME, simMsgId);
+
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               dbHandle.finalizeQuery();
+                               dbHandle.endTrans(false);
+                               return MSG_ERR_DB_EXEC;
+                       }
+               }
+
+               dbHandle.finalizeQuery();
+       }
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SCHEDULED_MSG_TABLE_NAME, MsgId);
+
+       // Delete Message from scheduled msg table
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       if (msgType.mainType == MSG_SMS_TYPE) {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SMS_SENDOPT_TABLE_NAME, MsgId);
+
+               // Delete SMS Send Option
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+
+               if (msgType.subType == MSG_CB_SMS || msgType.subType == MSG_JAVACB_SMS) {
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_CB_MSG_TABLE_NAME, MsgId);
+
+                       // Delete Push Message from push table
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               dbHandle.endTrans(false);
+                               return MSG_ERR_DB_EXEC;
+                       }
+               } else if (msgType.subType >= MSG_WAP_SI_SMS && msgType.subType <= MSG_WAP_CO_SMS) {
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_PUSH_MSG_TABLE_NAME, MsgId);
+
+                       // Delete Push Message from push table
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               dbHandle.endTrans(false);
+                               return MSG_ERR_DB_EXEC;
+                       }
+               } else if (msgType.subType == MSG_SYNCML_CP) {
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SYNCML_MSG_TABLE_NAME, MsgId);
+
+                       // Delete SyncML Message from syncML table
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               dbHandle.endTrans(false);
+                               return MSG_ERR_DB_EXEC;
+                       }
+               }
+       } else if (msgType.mainType == MSG_MMS_TYPE) {
+               //get multiple recipient message count
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE REFERENCE_ID IN \
+                                                                       (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                               MSGFW_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+               int rowCnt = 0;
+
+               err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+               if (err != MSG_SUCCESS) {
+                       dbHandle.freeTable();
+                       return err;
+               }
+
+               dbHandle.freeTable();
+               MSG_DEBUG("rowCnt = %d", rowCnt);
+
+               if (rowCnt == 1) {
+                       char filePath[MSG_FILEPATH_LEN_MAX] = {0,};
+                       char thumbnailpath[MSG_FILEPATH_LEN_MAX] = {0,};
+                       char dirPath[MSG_FILEPATH_LEN_MAX]= {0,};
+
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILE_PATH FROM %s WHERE REFERENCE_ID IN \
+                                                                       (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                                               MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+                       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
+                               dbHandle.endTrans(false);
+                               return MSG_ERR_DB_PREPARE;
+                       }
+
+                       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+                               strncpy(filePath, (char *)dbHandle.columnText(0), MSG_FILEPATH_LEN_MAX);
+
+                               snprintf(dirPath, MSG_FILEPATH_LEN_MAX, "%s.dir", filePath);
+
+                               if (remove(filePath) == -1)
+                                       MSG_DEBUG("Fail to delete file [%s]", filePath);
+                               else
+                                       MSG_DEBUG("Success to delete file [%s]", filePath);
+
+                               MsgRmRf(dirPath);
+                               rmdir(dirPath);
+
+                               // remove thumbnail file
+                               char *fileName = NULL;
+                               fileName = strrchr(filePath, '/');
+
+                               snprintf(thumbnailpath, MSG_FILEPATH_LEN_MAX, MSG_THUMBNAIL_PATH"%s.jpg", fileName+1);
+                               if(remove(thumbnailpath) == -1)
+                                       MSG_DEBUG("Fail to delete thumbnail [%s]", thumbnailpath);
+                               else
+                                       MSG_DEBUG("Success to delete thumbnail [%s]", thumbnailpath);
+                       } else {
+                               MSG_DEBUG("MsgStepQuery() Error [%s]", sqlQuery);
+                               dbHandle.finalizeQuery();
+                               dbHandle.endTrans(false);
+                               return MSG_ERR_DB_STEP;
+                       }
+
+                       dbHandle.finalizeQuery();
+
+                       const char *tableList[] = {MMS_PLUGIN_MESSAGE_TABLE_NAME, MMS_PLUGIN_ATTRIBUTE_TABLE_NAME};
+
+                       int listCnt = sizeof(tableList)/sizeof(char *);
+
+                       for (int i = 0; i < listCnt; i++) {
+                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                               snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE REFERENCE_ID IN \
+                                                                       (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                                                               tableList[i], MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+                               // Delete Data from MMS table
+                               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                                       dbHandle.endTrans(false);
+                                       return MSG_ERR_DB_EXEC;
+                               }
+                       }
+               } else {
+                       MSG_DEBUG("There is more multi-recipient mms. MMS DB table is not destroyed");
+               }
+       }
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+       // Delete Message from msg table
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       // Clear Address table
+       if (MsgStoClearAddressTable(&dbHandle) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       // Update Address Info.
+       if (MsgStoUpdateAddress(&dbHandle, addrId) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       dbHandle.endTrans(true);
+
+       if (msgType.mainType == MSG_SMS_TYPE && folderId == MSG_INBOX_ID) {
+               msgType.classType = MSG_CLASS_NONE;
+
+               // Set memory status in SIM
+               if (MsgStoCheckMsgCntFull(&dbHandle, &msgType, folderId) == MSG_SUCCESS) {
+                       MSG_DEBUG("Set Memory Status");
+
+                       plg->setMemoryStatus(MSG_SUCCESS);
+               }
+       }
+
+       if (bCheckIndication == true) {
+               MSG_DEBUG("bCheckIndication is true.");
+
+               int smsCnt = 0;
+               int mmsCnt = 0;
+
+               smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE);
+               mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
+
+               MsgSettingSetIndicator(smsCnt, mmsCnt);
+
+               MsgDeleteNotiByMsgId(MsgId);
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoDeleteAllMessageInFolder(MSG_FOLDER_ID_T FolderId, bool bOnlyDB, MSG_MSGID_LIST_S *pMsgIdList)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       queue<MSG_THREAD_ID_T> threadList;
+
+       const char *tableList[] = {MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME,
+                                               MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SCHEDULED_MSG_TABLE_NAME,
+                                               MSGFW_SMS_SENDOPT_TABLE_NAME, MMS_PLUGIN_MESSAGE_TABLE_NAME,
+                                               MSGFW_MESSAGE_TABLE_NAME};
+
+       int listCnt = sizeof(tableList)/sizeof(char *);
+       int rowCnt = 0;
+
+       // Get Address ID in Folder
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT(B.ADDRESS_ID) \
+                                       FROM %s A, %s B \
+                                    WHERE A.ADDRESS_ID = B.ADDRESS_ID \
+                                         AND A.FOLDER_ID = %d",
+                       MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, FolderId);
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
+               MSG_DEBUG("sql query is %s.", sqlQuery);
+
+               dbHandle.freeTable();
+               return err;
+       }
+
+       if (rowCnt <= 0) {
+               dbHandle.freeTable();
+
+               return MSG_SUCCESS;
+       }
+
+       for (int i = 1; i <= rowCnt; i++) {
+               MSG_DEBUG("thread ID : %d", dbHandle.getColumnToInt(i));
+               threadList.push((MSG_THREAD_ID_T)dbHandle.getColumnToInt(i));
+       }
+
+       dbHandle.freeTable();
+
+       /*** Get msg id list **/
+       MSG_MSGID_LIST_S *pToDeleteMsgIdList = NULL;
+       pToDeleteMsgIdList = (MSG_MSGID_LIST_S *)new char[sizeof(MSG_MSGID_LIST_S)];
+       memset(pToDeleteMsgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE FOLDER_ID = %d",
+                       MSGFW_MESSAGE_TABLE_NAME, FolderId);
+
+       rowCnt = 0;
+       int index = 1;
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
+               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+
+               dbHandle.freeTable();
+
+               goto FREE_MEMORY;
+       }
+
+       if (rowCnt <= 0) {
+               dbHandle.freeTable();
+               err = MSG_SUCCESS;
+
+               goto FREE_MEMORY;
+       }
+
+       pToDeleteMsgIdList->nCount = rowCnt;
+
+       MSG_DEBUG("pToDeleteMsgIdList->nCount [%d]", pToDeleteMsgIdList->nCount);
+
+       pToDeleteMsgIdList->msgIdList = (MSG_MESSAGE_ID_T *)new char[sizeof(MSG_MESSAGE_ID_T) * rowCnt];
+
+       for (int i = 0; i < rowCnt; i++)
+               pToDeleteMsgIdList->msgIdList[i] = dbHandle.getColumnToInt(index++);
+
+       dbHandle.freeTable();
+       /*** **/
+
+       /*** Delete Sim Message In Folder **/
+       if (FolderId >= MSG_INBOX_ID) {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s \
+                                            WHERE FOLDER_ID = %d AND STORAGE_ID = %d",
+                               MSGFW_MESSAGE_TABLE_NAME, FolderId, MSG_STORAGE_SIM);
+
+               MSG_DEBUG("sql query is %s.", sqlQuery);
+
+               rowCnt = 0;
+
+               err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+               if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
+                       dbHandle.freeTable();
+
+                       goto FREE_MEMORY;
+               }
+
+               for (int i = 1; i <= rowCnt; i++) {
+                       err = MsgStoDeleteMessage(dbHandle.getColumnToInt(i), false);
+
+                       if (err != MSG_SUCCESS) {
+                               MSG_DEBUG("MsgStoDeleteMessage() Error!!!");
+
+                               dbHandle.freeTable();
+
+                               goto FREE_MEMORY;
+                       }
+               }
+
+               dbHandle.freeTable();
+       }
+
+       dbHandle.beginTrans();
+
+       for (int i = 0; i < listCnt; i++) {
+               if (!strcmp(tableList[i], MMS_PLUGIN_MESSAGE_TABLE_NAME)) {
+                       //MMS_PLUGIN_MESSAGE_TABLE and MMS_PLUGIN_ATTRIBUTE_TABLE will be updated together
+                       int rowCnt = 0;
+                       int msgCnt = 0;
+                       int index = 2;
+
+                       //get mms msg id list
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, REFERENCE_ID FROM %s \
+                                                               WHERE FOLDER_ID = %d AND MAIN_TYPE = %d",
+                                                               MSGFW_MESSAGE_TABLE_NAME, FolderId, MSG_MMS_TYPE);
+
+                       MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+
+                       err = dbHandle.getTable(sqlQuery, &rowCnt);
+                       MSG_DEBUG("rowCnt %d", rowCnt);
+
+                       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
+                               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+
+                               dbHandle.freeTable();
+                               dbHandle.endTrans(false);
+
+                               goto FREE_MEMORY;
+                       }
+
+                       for (int i = 1; i <= rowCnt; i++) {
+                               int msgId = 0;
+                               int refId = 0;
+
+                               msgId = dbHandle.getColumnToInt(index++);
+                               refId = dbHandle.getColumnToInt(index++);
+
+                               //get multiple recipient message count
+                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE REFERENCE_ID = %d;",
+                                                               MSGFW_MESSAGE_TABLE_NAME, refId);
+
+                               if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
+                                       dbHandle.freeTable();
+                                       dbHandle.endTrans(false);
+                                       err = MSG_ERR_DB_PREPARE;
+
+                                       goto FREE_MEMORY;
+                               }
+
+                               msgCnt = 0;
+
+                               if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+                                       msgCnt = dbHandle.columnInt(0);
+                               } else {
+                                       dbHandle.finalizeQuery();
+                                       dbHandle.freeTable();
+                                       dbHandle.endTrans(false);
+                                       err = MSG_ERR_DB_STEP;
+
+                                       goto FREE_MEMORY;
+                               }
+
+                               dbHandle.finalizeQuery();
+
+                               //delete mms raw file and db(mms_table and mms_attr_table) data
+                               if (msgCnt == 1) {
+                                       char filePath[MSG_FILEPATH_LEN_MAX] = {0,};
+                                       char dirPath[MSG_FILEPATH_LEN_MAX] = {0,};
+                                       char thumbnailPath[MSG_FILEPATH_LEN_MAX] = {0,};
+
+                                       //get raw file_path
+                                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                                       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILE_PATH FROM %s WHERE REFERENCE_ID = %d;",
+                                                                               MMS_PLUGIN_MESSAGE_TABLE_NAME, refId);
+
+                                       MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+                                       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
+                                               dbHandle.freeTable();
+                                               dbHandle.endTrans(false);
+                                               err = MSG_ERR_DB_PREPARE;
+
+                                               goto FREE_MEMORY;
+                                       }
+
+                                       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+                                               strncpy(filePath, (char *)dbHandle.columnText(0), MSG_FILEPATH_LEN_MAX);
+                                       } else {
+                                               dbHandle.finalizeQuery();
+                                               dbHandle.freeTable();
+                                               dbHandle.endTrans(false);
+                                               err = MSG_ERR_DB_STEP;
+
+                                               goto FREE_MEMORY;
+                                       }
+
+                                       dbHandle.finalizeQuery();
+
+                                       MSG_DEBUG("filePath [%s]", filePath);
+
+                                       //delete raw file
+                                       snprintf(dirPath, sizeof(dirPath), "%s.dir", filePath);
+
+                                       if (remove(filePath) == -1)
+                                               MSG_DEBUG("Fail to delete file [%s]", filePath);
+                                       else
+                                               MSG_DEBUG("Success to delete file [%s]", filePath);
+
+                                       MsgRmRf(dirPath);
+                                       rmdir(dirPath);
+                                       // delete thumbanil
+
+                                       char *fileName = NULL;
+                                       fileName = strrchr(filePath, '/');
+
+                                       snprintf(thumbnailPath, sizeof(thumbnailPath), MSG_THUMBNAIL_PATH"%s.jpg", fileName+1);
+
+                                       if (remove(thumbnailPath) == -1)
+                                               MSG_DEBUG("Fail to delete thumbnail [%s]", thumbnailPath);
+                                       else
+                                               MSG_DEBUG("Success to delete thumbnail [%s]", thumbnailPath);
+
+                                       //delete MMS_PLUGIN_MESSAGE_TABLE_NAME table data
+                                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE REFERENCE_ID = %d;",
+                                                                               MMS_PLUGIN_MESSAGE_TABLE_NAME, refId);
+
+                                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                                               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+                                               dbHandle.freeTable();
+                                               dbHandle.endTrans(false);
+                                               err = MSG_ERR_DB_EXEC;
+
+                                               goto FREE_MEMORY;
+                                       }
+
+                                       //delete  MMS_PLUGIN_ATTRIBUTE_TABLE_NAME table data
+                                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE REFERENCE_ID = %d;",
+                                                                               MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, refId);
+
+                                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                                               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+                                               dbHandle.freeTable();
+                                               dbHandle.endTrans(false);
+                                               err = MSG_ERR_DB_EXEC;
+
+                                               goto FREE_MEMORY;
+                                       }
+                               } else {
+                                       MSG_DEBUG("There is remained multi-recipient mms for this msg = %d", msgId);
+                               }
+                       }
+
+                       dbHandle.freeTable();
+               } else {
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID IN \
+                                                               (SELECT MSG_ID FROM %s WHERE FOLDER_ID = %d);",
+                                                               tableList[i], MSGFW_MESSAGE_TABLE_NAME, FolderId);
+
+                       // Delete Message in specific folder from table
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+                               dbHandle.endTrans(false);
+                               err = MSG_ERR_DB_EXEC;
+
+                               goto FREE_MEMORY;
+                       }
+               }
+       }
+
+       // Clear Address table
+       if (MsgStoClearAddressTable(&dbHandle) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               err = MSG_ERR_DB_EXEC;
+
+               goto FREE_MEMORY;
+       }
+
+       // Update Address
+       while (!threadList.empty()) {
+               err = MsgStoUpdateAddress(&dbHandle, threadList.front());
+
+               threadList.pop();
+
+               if (err != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+
+                       goto FREE_MEMORY;
+               }
+       }
+
+       dbHandle.endTrans(true);
+
+       if (FolderId == MSG_INBOX_ID) {
+               int smsCnt = 0;
+               int mmsCnt = 0;
+
+               smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE);
+               mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
+
+               MsgSettingSetIndicator(smsCnt, mmsCnt);
+       }
+
+/*** Set pMsgIdList **/
+       if (pMsgIdList != NULL && pToDeleteMsgIdList->nCount > 0) {
+               pMsgIdList->nCount = pToDeleteMsgIdList->nCount;
+
+               pMsgIdList->msgIdList = (MSG_MESSAGE_ID_T *)new char[sizeof(MSG_MESSAGE_ID_T)*pToDeleteMsgIdList->nCount];
+               memcpy(pMsgIdList->msgIdList, pToDeleteMsgIdList->msgIdList, sizeof(MSG_MESSAGE_ID_T)*pToDeleteMsgIdList->nCount);
+       }
+/*** **/
+
+/*** Create thread  for noti delete. **/
+       if (!bOnlyDB) {
+               if (pToDeleteMsgIdList->nCount > 0) {
+
+                       if (g_idle_add(startToDeleteNoti, (void *)pToDeleteMsgIdList) == 0) {
+                               MSG_DEBUG("startToDeleteNoti not invoked: %s", strerror(errno));
+                               // memory free
+                               if (pToDeleteMsgIdList != NULL) {
+                                       //free peer info list
+                                       if (pToDeleteMsgIdList->msgIdList != NULL)
+                                               delete [] pToDeleteMsgIdList->msgIdList;
+
+                                       delete [] pToDeleteMsgIdList;
+                               }
+                               err = MSG_ERR_UNKNOWN;
+                       }
+               }
+       }
+/*** **/
+
+       return MSG_SUCCESS;
+
+FREE_MEMORY:
+       MSG_DEBUG("Error case Free Memory");
+
+       while (!threadList.empty()) {
+               threadList.front();
+               threadList.pop();
+       }
+
+       // memory free
+       if (pToDeleteMsgIdList != NULL) {
+               //free peer info list
+               if (pToDeleteMsgIdList->msgIdList != NULL)
+                       delete [] pToDeleteMsgIdList->msgIdList;
+
+               delete [] pToDeleteMsgIdList;
+       }
+
+       return err;
+
+}
+
+
+MSG_ERROR_T MsgStoMoveMessageToFolder(MSG_MESSAGE_ID_T MsgId, MSG_FOLDER_ID_T DestFolderId)
+{
+       MSG_MESSAGE_TYPE_S msgType;
+
+       MsgStoGetMsgType(MsgId, &msgType);
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       if (msgType.mainType == MSG_SMS_TYPE) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET FOLDER_ID = %d WHERE MSG_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, DestFolderId, MsgId);
+       } else {
+               snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET FOLDER_ID = %d WHERE REFERENCE_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, DestFolderId, MsgId);
+       }
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       unsigned int addrId = 0;
+       /* get address id */
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ADDRESS_ID FROM %s WHERE MSG_ID = %d;",
+                                                       MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               addrId = dbHandle.columnInt(0);
+       }
+       MSG_DEBUG("addrId : %d",  addrId);
+
+       dbHandle.finalizeQuery();
+
+       /* update address table */
+       MsgStoUpdateAddress(&dbHandle, addrId);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoMoveMessageToStorage(MSG_MESSAGE_ID_T MsgId, MSG_STORAGE_ID_T DestStorageId)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       MSG_DEBUG("MsgId : %d, DestStorageId : %d", MsgId, DestStorageId);
+
+       switch (DestStorageId) {
+       case MSG_STORAGE_SIM : // Move message to sim card
+               {
+                       MSG_MESSAGE_INFO_S msgInfo;
+                       SMS_SIM_ID_LIST_S simIdList;
+
+                       memset(&simIdList, 0x00, sizeof(SMS_SIM_ID_LIST_S));
+
+                       if ((err = MsgStoGetMessage(MsgId, &msgInfo, NULL)) != MSG_SUCCESS)
+                               return err;
+
+                       MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE);
+
+                       if ((err = plg->saveSimMessage(&msgInfo, &simIdList)) != MSG_SUCCESS)
+                               return err;
+
+                       dbHandle.beginTrans();
+
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET STORAGE_ID = %d WHERE MSG_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, DestStorageId, MsgId);
+
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               dbHandle.endTrans(false);
+                               return MSG_ERR_DB_EXEC;
+                       }
+
+                       for (unsigned int i = 0; i < simIdList.count; i++) {
+                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d);",
+                                                               MSGFW_SIM_MSG_TABLE_NAME, MsgId, simIdList.simId[i]);
+
+                               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                                       dbHandle.endTrans(false);
+                                       return MSG_ERR_DB_EXEC;
+                               }
+                       }
+
+                       dbHandle.endTrans(true);
+               }
+       break;
+
+       default: //Moving message to memory (when destination storage id is MSG_STORAGE_PHONE)
+               {
+                       bool bSimMsg = false;
+                       int rowCnt = 0;
+
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT STORAGE_ID FROM %s WHERE MSG_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+                       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+                       if (err != MSG_SUCCESS) {
+                               dbHandle.freeTable();
+                               return err;
+                       }
+
+                       if (dbHandle.getColumnToInt(1) == MSG_STORAGE_SIM) {
+                               MSG_DEBUG("It is SIM Message");
+                               bSimMsg = true;
+                       }
+
+                       dbHandle.freeTable();
+
+                       if (bSimMsg == true) {
+                               MSG_SIM_ID_T simMsgId;
+
+                               // get sim message id
+                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+                               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_ID FROM %s WHERE MSG_ID = %d;",
+                                       MSGFW_SIM_MSG_TABLE_NAME, MsgId);
+
+                               MSG_DEBUG("sqlQuery is %s.", sqlQuery);
+
+                               err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+                               if (err != MSG_SUCCESS) {
+                                       dbHandle.freeTable();
+                                       return err;
+                               }
+
+                               //Delete messages in sim card
+                               MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE);
+
+                               for (int i = 0; i < rowCnt; i++) {
+                                       simMsgId = dbHandle.getColumnToInt(i+1);
+
+                                       MSG_DEBUG("simMsgId is %d.", simMsgId);
+
+                                       if ((err = plg->deleteSimMessage(simMsgId)) != MSG_SUCCESS) {
+                                               dbHandle.freeTable();
+                                               return err;
+                                       }
+                               }
+
+                               dbHandle.freeTable();
+
+                               dbHandle.beginTrans();
+
+                               //Delete Messages in SIM Msg table
+                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                               snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;",
+                                                       MSGFW_SIM_MSG_TABLE_NAME, MsgId);
+                               MSG_DEBUG("sqlQuery is %s.", sqlQuery);
+
+                               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                                       dbHandle.endTrans(false);
+                                       return MSG_ERR_DB_EXEC;
+                               }
+
+                               //Move storage id
+                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                               snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET STORAGE_ID = %d WHERE MSG_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, DestStorageId, MsgId);
+
+                               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                                       dbHandle.endTrans(false);
+                                       return MSG_ERR_DB_EXEC;
+                               }
+
+                               dbHandle.endTrans(true);
+                       }
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoCountMessage(MSG_FOLDER_ID_T FolderId, MSG_COUNT_INFO_S *pCountInfo)
+{
+       if (pCountInfo == NULL) {
+               MSG_DEBUG("pCountInfo is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE FOLDER_ID = %d AND READ_STATUS = 1 \
+                                                                   UNION ALL SELECT COUNT(MSG_ID) FROM %s WHERE FOLDER_ID = %d AND READ_STATUS = 0 \
+                                                                   UNION ALL SELECT COUNT(MSG_ID) FROM %s WHERE FOLDER_ID = %d AND MAIN_TYPE = %d \
+                                                                   UNION ALL SELECT COUNT(MSG_ID) FROM %s WHERE FOLDER_ID = %d AND MAIN_TYPE = %d ;",
+                                                       MSGFW_MESSAGE_TABLE_NAME, FolderId,
+                                                       MSGFW_MESSAGE_TABLE_NAME, FolderId,
+                                                       MSGFW_MESSAGE_TABLE_NAME, FolderId, MSG_SMS_TYPE,
+                                                       MSGFW_MESSAGE_TABLE_NAME, FolderId, MSG_MMS_TYPE);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               pCountInfo->nReadCnt = dbHandle.columnInt(0);
+       } else {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               pCountInfo->nUnreadCnt = dbHandle.columnInt(0);
+       } else {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               pCountInfo->nSms = dbHandle.columnInt(0);
+       } else {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               pCountInfo->nMms = dbHandle.columnInt(0);
+       } else {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoCountMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCount)
+{
+       if (pMsgType == NULL) {
+               MSG_DEBUG("pMsgType is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       *pMsgCount = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       // SMS
+       if ((pMsgType->mainType == MSG_SMS_TYPE) &&
+               (pMsgType->subType == MSG_NORMAL_SMS || pMsgType->subType == MSG_STATUS_REPORT_SMS || pMsgType->subType == MSG_CONCAT_SIM_SMS)) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE MAIN_TYPE = %d AND SUB_TYPE IN (%d, %d, %d);",
+                               MSGFW_MESSAGE_TABLE_NAME, pMsgType->mainType, MSG_NORMAL_SMS, MSG_STATUS_REPORT_SMS, MSG_CONCAT_SIM_SMS);
+       } else if ((pMsgType->mainType == MSG_SMS_TYPE) &&
+                               (pMsgType->subType == MSG_WAP_SI_SMS || pMsgType->subType == MSG_WAP_SL_SMS)) {
+        // PUSH
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE MAIN_TYPE = %d AND SUB_TYPE IN (%d, %d);",
+                               MSGFW_MESSAGE_TABLE_NAME, pMsgType->mainType, MSG_WAP_SI_SMS, MSG_WAP_SL_SMS);
+       } else if ((pMsgType->mainType == MSG_MMS_TYPE) &&
+                               (pMsgType->subType == MSG_SENDREQ_MMS || pMsgType->subType == MSG_SENDCONF_MMS || pMsgType->subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgType->subType == MSG_RETRIEVE_MANUALCONF_MMS)) {
+        // MMS
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE MAIN_TYPE = %d AND SUB_TYPE IN (%d, %d, %d, %d);",
+                               MSGFW_MESSAGE_TABLE_NAME, pMsgType->mainType, MSG_SENDREQ_MMS, MSG_SENDCONF_MMS, MSG_RETRIEVE_AUTOCONF_MMS, MSG_RETRIEVE_MANUALCONF_MMS);
+       } else {
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               *pMsgCount = dbHandle.columnInt(0);
+       } else {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetMessage(MSG_MESSAGE_ID_T MsgId, MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       unsigned int addrId = 0;
+
+       char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
+
+       memset(firstName, 0x00, sizeof(firstName));
+       memset(lastName, 0x00, sizeof(lastName));
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.MSG_ID, A.ADDRESS_ID, A.FOLDER_ID, A.REFERENCE_ID, A.STORAGE_ID, A.MAIN_TYPE, A.SUB_TYPE, A.DISPLAY_TIME, A.DATA_SIZE, \
+                                                 A.NETWORK_STATUS, A.READ_STATUS, A.PROTECTED, A.BACKUP, A.PRIORITY, A.MSG_DIRECTION, A.SCHEDULED_TIME, A.SUBJECT, A.MSG_TEXT, \
+                                                 B.ADDRESS_TYPE, B.RECIPIENT_TYPE, B.CONTACT_ID, B.ADDRESS_VAL, B.DISPLAY_NAME, B.FIRST_NAME, B.LAST_NAME, A.THUMB_PATH \
+                                       FROM %s A, %s B WHERE A.MSG_ID = %d AND A.ADDRESS_ID = B.ADDRESS_ID;",
+                                       MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, MsgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               pMsg->msgId = dbHandle.columnInt(0);
+               addrId = dbHandle.columnInt(1);
+               pMsg->folderId = dbHandle.columnInt(2);
+               pMsg->referenceId = dbHandle.columnInt(3);
+               pMsg->storageId = dbHandle.columnInt(4);
+               pMsg->msgType.mainType = dbHandle.columnInt(5);
+               pMsg->msgType.subType = dbHandle.columnInt(6);
+               pMsg->displayTime = (time_t)dbHandle.columnInt(7);
+               pMsg->dataSize = dbHandle.columnInt(8);
+               pMsg->networkStatus = dbHandle.columnInt(9);
+               pMsg->bRead = dbHandle.columnInt(10);
+               pMsg->bProtected = dbHandle.columnInt(11);
+               pMsg->bBackup = dbHandle.columnInt(12);
+               pMsg->priority = dbHandle.columnInt(13);
+               pMsg->direction= dbHandle.columnInt(14);
+               pMsg->scheduledTime = (time_t)dbHandle.columnInt(15);
+
+               strncpy(pMsg->subject, (char *)dbHandle.columnText(16), MAX_SUBJECT_LEN);
+
+               /* Temp_File_Handling */
+               if (pMsg->msgType.mainType == MSG_SMS_TYPE || pMsg->msgType.subType == MSG_NOTIFICATIONIND_MMS) {
+                       if (pMsg->dataSize > MAX_MSG_TEXT_LEN) {
+                               char msgData[pMsg->dataSize+1];
+                               memset(msgData, 0x00, sizeof(msgData));
+
+                               strncpy(msgData, (char *)dbHandle.columnText(17), pMsg->dataSize);
+
+                               // Save Message Data into File
+                               char fileName[MAX_COMMON_INFO_SIZE+1];
+                               memset(fileName, 0x00, sizeof(fileName));
+
+                               if (MsgCreateFileName(fileName) == false) {
+                                       dbHandle.finalizeQuery();
+                                       return MSG_ERR_STORAGE_ERROR;
+                               }
+
+                               MSG_DEBUG("Save Message Data into file : size[%d] name[%s]\n", pMsg->dataSize, fileName);
+
+                               if (MsgWriteIpcFile(fileName, msgData, pMsg->dataSize) == false) {
+                                       dbHandle.finalizeQuery();
+                                       return MSG_ERR_STORAGE_ERROR;
+                               }
+
+                               strncpy(pMsg->msgData, fileName, MAX_MSG_DATA_LEN);
+
+                               pMsg->bTextSms = false;
+                       } else {
+                               memset(pMsg->msgText, 0x00, sizeof(pMsg->msgText));
+                               strncpy(pMsg->msgText, (char *)dbHandle.columnText(17), pMsg->dataSize);
+
+                               // For WAP PUSH SI Message
+                               if (pMsg->msgType.subType == MSG_WAP_SI_SMS) {
+                                       strncat(pMsg->msgText, "\n", MAX_MSG_TEXT_LEN-strlen(pMsg->msgText));
+                                       strncat(pMsg->msgText, pMsg->subject, MAX_MSG_TEXT_LEN-strlen(pMsg->msgText));
+                                       MSG_DEBUG("pMsg->msgText : [%s]", pMsg->msgText);
+                                       pMsg->dataSize = sizeof(pMsg->msgText);
+                               }
+
+                               pMsg->bTextSms = true;
+                       }
+               } else {
+                       if (dbHandle.columnText(17) != NULL)
+                               strncpy(pMsg->msgText, (char *)dbHandle.columnText(17), MAX_MSG_TEXT_LEN);
+               }
+
+               if (addrId > 0)
+                       pMsg->nAddressCnt = 1;
+               else
+                       pMsg->nAddressCnt = 0;
+
+               pMsg->addressList[0].threadId = addrId;
+               pMsg->addressList[0].addressType = dbHandle.columnInt(18);
+               pMsg->addressList[0].recipientType = dbHandle.columnInt(19);
+               pMsg->addressList[0].contactId = dbHandle.columnInt(20);
+
+               if (dbHandle.columnText(21) != NULL)
+                       strncpy(pMsg->addressList[0].addressVal, (char *)dbHandle.columnText(21), MAX_ADDRESS_VAL_LEN);
+
+               if (dbHandle.columnText(22) != NULL && ((char *)dbHandle.columnText(22))[0]!='\0') {
+                       MSG_DEBUG("displayName  : [%s]", dbHandle.columnText(22));
+                       strncpy(pMsg->addressList[0].displayName, (char *)dbHandle.columnText(22), MAX_DISPLAY_NAME_LEN);
+               } else {
+                       if (dbHandle.columnText(23) != NULL)
+                               strncpy(firstName, (char *)dbHandle.columnText(23), MAX_DISPLAY_NAME_LEN);
+
+                       if (dbHandle.columnText(24) != NULL)
+                               strncpy(lastName, (char *)dbHandle.columnText(24), MAX_DISPLAY_NAME_LEN);
+
+                       int order = MsgGetContactNameOrder();
+
+                       if (order == 0) {
+                               if (strlen(firstName) > 0) {
+                                       strncpy(pMsg->addressList[0].displayName, firstName, MAX_DISPLAY_NAME_LEN);
+                               }
+
+                               if (strlen(lastName) > 0) {
+                                       strncat(pMsg->addressList[0].displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(pMsg->addressList[0].displayName));
+                                       strncat(pMsg->addressList[0].displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(pMsg->addressList[0].displayName));
+                               }
+                       } else if (order == 1) {
+                               if (strlen(lastName) > 0) {
+                                       strncpy(pMsg->addressList[0].displayName, lastName, MAX_DISPLAY_NAME_LEN);
+                                       strncat(pMsg->addressList[0].displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(pMsg->addressList[0].displayName));
+                               }
+
+                               if (strlen(firstName) > 0) {
+                                       strncat(pMsg->addressList[0].displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(pMsg->addressList[0].displayName));
+                               }
+                       }
+               }
+
+               // thumbnail path
+               if (dbHandle.columnText(25)!=NULL && ((char *)dbHandle.columnText(25))[0] != '\0') {
+                       strncpy(pMsg->thumbPath, (char *)dbHandle.columnText(25), MSG_FILEPATH_LEN_MAX);
+                       MSG_DEBUG("pMsg->thumbPath : [%s]", pMsg->thumbPath);
+               }
+       } else {
+               dbHandle.finalizeQuery();
+               MSG_DEBUG("%s", sqlQuery);
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       // Get MMS body if it is MMS.
+       if ((pMsg->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS && (pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS)) ||
+               pMsg->msgType.subType == MSG_SENDREQ_MMS ||
+               pMsg->msgType.subType == MSG_SENDCONF_MMS) {
+               MSG_ERROR_T err = MSG_SUCCESS;
+               MMS_MESSAGE_DATA_S      mmsMsg;
+               char *pDestMsg = NULL;
+
+               // call mms plugin to get mms specific message data
+               MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(pMsg->msgType.mainType);
+               memset(&mmsMsg, 0, sizeof(MMS_MESSAGE_DATA_S));
+               err =  plg->getMmsMessage(pMsg, pSendOptInfo, &mmsMsg, &pDestMsg);
+
+               if (err != MSG_SUCCESS) {
+                       if (pDestMsg) {
+                               free(pDestMsg);
+                               pDestMsg = NULL;
+                       }
+                       return MSG_ERR_STORAGE_ERROR;
+               }
+
+               memset(pMsg->msgData, 0, MAX_MSG_DATA_LEN+1);
+
+               // Encode MMS specific data to MMS_MESSAGE_DATA_S
+               if (pMsg->dataSize > MAX_MSG_DATA_LEN) {
+                       // Save Message Data into File
+                       char tempFileName[MAX_COMMON_INFO_SIZE+1];
+                       memset(tempFileName, 0x00, sizeof(tempFileName));
+
+                       if (MsgCreateFileName(tempFileName) == false) {
+                               if(pDestMsg) {
+                                       free (pDestMsg);
+                                       pDestMsg = NULL;
+                               }
+                               return MSG_ERR_STORAGE_ERROR;
+                       }
+                       MSG_DEBUG("Save Message Data into file : size[%d] name[%s]\n", pMsg->dataSize, tempFileName);
+
+                       if (MsgWriteIpcFile(tempFileName, pDestMsg, pMsg->dataSize) == false) {
+                               if(pDestMsg) {
+                                       free (pDestMsg);
+                                       pDestMsg = NULL;
+                               }
+                               return MSG_ERR_STORAGE_ERROR;
+                       }
+                       strncpy(pMsg->msgData, tempFileName, MAX_MSG_DATA_LEN);
+                       //pMsg->dataSize = strlen(fileName);
+                       pMsg->bTextSms = false;
+               } else {
+                       strncpy(pMsg->msgData, pDestMsg, pMsg->dataSize);
+                       pMsg->bTextSms = true;
+               }
+
+               if (pDestMsg) {
+                       free(pDestMsg);
+                       pDestMsg = NULL;
+               }
+       }
+
+       // Get SMS Sending Options
+       if (pMsg->msgType.mainType == MSG_SMS_TYPE && pSendOptInfo != NULL) {
+               MsgStoGetSmsSendOpt(pMsg->msgId, pSendOptInfo);
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetFolderViewList(MSG_FOLDER_ID_T FolderId, const MSG_SORT_RULE_S *pSortRule, MSG_LIST_S *pMsgFolderViewList)
+{
+       if (pMsgFolderViewList == NULL) {
+               MSG_DEBUG("pMsgFolderViewList is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       int rowCnt = 0;
+       int index = 27; // numbers of index
+
+       unsigned int addrId = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+       char sqlSort[64];
+       char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
+       char displayName[MAX_DISPLAY_NAME_LEN+1];
+       // Get Name Order
+       int order = MsgGetContactNameOrder();
+
+       // Get Message In Folder
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       if (FolderId == MSG_ALLBOX_ID) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.MSG_ID, A.ADDRESS_ID, A.FOLDER_ID, A.REFERENCE_ID, A.STORAGE_ID, A.MAIN_TYPE, A.SUB_TYPE, \
+                                                       A.DISPLAY_TIME, A.DATA_SIZE, A.NETWORK_STATUS, A.READ_STATUS, A.PROTECTED, A.BACKUP, A.PRIORITY, \
+                                                       A.MSG_DIRECTION, A.SCHEDULED_TIME, A.SUBJECT, A.MSG_TEXT, B.ADDRESS_TYPE, B.RECIPIENT_TYPE, \
+                                                       B.CONTACT_ID, B.ADDRESS_VAL, B.DISPLAY_NAME, B.FIRST_NAME, B.LAST_NAME, A.ATTACHMENT_COUNT, A.THUMB_PATH \
+                                                               FROM %s A, %s B \
+                                                            WHERE A.ADDRESS_ID = B.ADDRESS_ID \
+                                                                 AND A.FOLDER_ID < %d ",
+                                               MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, MSG_CBMSGBOX_ID);
+       } else {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.MSG_ID, A.ADDRESS_ID, A.FOLDER_ID, A.REFERENCE_ID, A.STORAGE_ID, A.MAIN_TYPE, A.SUB_TYPE, \
+                                                       A.DISPLAY_TIME, A.DATA_SIZE, A.NETWORK_STATUS, A.READ_STATUS, A.PROTECTED, A.BACKUP, A.PRIORITY, \
+                                                       A.MSG_DIRECTION, A.SCHEDULED_TIME, A.SUBJECT, A.MSG_TEXT, B.ADDRESS_TYPE, B.RECIPIENT_TYPE, \
+                                                       B.CONTACT_ID, B.ADDRESS_VAL, B.DISPLAY_NAME, B.FIRST_NAME, B.LAST_NAME, A.ATTACHMENT_COUNT, A.THUMB_PATH \
+                                                               FROM %s A, %s B \
+                                                            WHERE A.ADDRESS_ID = B.ADDRESS_ID \
+                                                                 AND A.FOLDER_ID = %d ",
+                                               MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, FolderId);
+       }
+
+       memset(sqlSort, 0x00, sizeof(sqlSort));
+       MsgMakeSortRule(pSortRule, sqlSort);
+       strncat(sqlQuery, sqlSort, strlen(sqlSort));
+
+       MSG_ERROR_T  err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err == MSG_ERR_DB_NORECORD) {
+               pMsgFolderViewList->nCount = 0;
+               pMsgFolderViewList->msgInfo = NULL;
+
+               dbHandle.freeTable();
+
+               return MSG_SUCCESS;
+       } else if (err != MSG_SUCCESS) {
+               MSG_DEBUG("sqlQuery is - %s", sqlQuery);
+               dbHandle.freeTable();
+               return err;
+       }
+
+       pMsgFolderViewList->nCount = rowCnt;
+
+       MSG_DEBUG("pMsgCommInfoList->nCount [%d]", pMsgFolderViewList->nCount);
+
+       pMsgFolderViewList->msgInfo = (msg_message_t *)new char[sizeof(MSG_MESSAGE_S *) * rowCnt];
+
+       MSG_MESSAGE_S *pTmp = NULL;
+
+       for (int i = 0; i < rowCnt; i++) {
+               pMsgFolderViewList->msgInfo[i] = (msg_message_t)new char[sizeof(MSG_MESSAGE_S)];
+
+               pTmp = (MSG_MESSAGE_S *)pMsgFolderViewList->msgInfo[i];
+
+               memset(pTmp, 0x00, sizeof(pTmp));
+
+               pTmp->pData = NULL;
+               pTmp->pMmsData = NULL;
+
+               pTmp->msgId = dbHandle.getColumnToInt(index++);
+               addrId = dbHandle.getColumnToInt(index++);
+               pTmp->folderId = dbHandle.getColumnToInt(index++);
+               pTmp->referenceId = dbHandle.getColumnToInt(index++);
+               pTmp->storageId = dbHandle.getColumnToInt(index++);
+               pTmp->msgType.mainType = dbHandle.getColumnToInt(index++);
+               pTmp->msgType.subType = dbHandle.getColumnToInt(index++);
+               pTmp->displayTime = (time_t)dbHandle.getColumnToInt(index++);
+               pTmp->dataSize = dbHandle.getColumnToInt(index++);
+               pTmp->networkStatus = dbHandle.getColumnToInt(index++);
+               pTmp->bRead = dbHandle.getColumnToInt(index++);
+               pTmp->bProtected = dbHandle.getColumnToInt(index++);
+               pTmp->bBackup = dbHandle.getColumnToInt(index++);
+               pTmp->priority = dbHandle.getColumnToInt(index++);
+               pTmp->direction= dbHandle.getColumnToInt(index++);
+               pTmp->scheduledTime = (time_t)dbHandle.getColumnToInt(index++);
+
+               dbHandle.getColumnToString(index++, MAX_SUBJECT_LEN, pTmp->subject);
+
+               if (pTmp->msgType.mainType == MSG_MMS_TYPE &&
+                       (pTmp->networkStatus == MSG_NETWORK_RETRIEVING || pTmp->networkStatus == MSG_NETWORK_RETRIEVE_FAIL || pTmp->msgType.subType == MSG_NOTIFICATIONIND_MMS)) {
+                       pTmp->pData = NULL;
+                       index++;
+               } else {
+                       pTmp->pData = (void *)new char[pTmp->dataSize + 2];
+                       memset(pTmp->pData, 0x00, sizeof(pTmp->pData));
+
+                       dbHandle.getColumnToString(index++, pTmp->dataSize+1, (char *)pTmp->pData);
+               }
+
+               if (addrId > 0)
+                       pTmp->nAddressCnt = 1;
+               else
+                       pTmp->nAddressCnt = 0;
+
+               pTmp->addressList[0].threadId = addrId;
+               pTmp->addressList[0].addressType = dbHandle.getColumnToInt(index++);
+               pTmp->addressList[0].recipientType = dbHandle.getColumnToInt(index++);
+               pTmp->addressList[0].contactId = dbHandle.getColumnToInt(index++);
+
+               dbHandle.getColumnToString(index++, MAX_ADDRESS_VAL_LEN, pTmp->addressList[0].addressVal);
+
+               memset(displayName, 0x00, sizeof(displayName));
+               dbHandle.getColumnToString(index++, MAX_DISPLAY_NAME_LEN, displayName);
+
+               memset(firstName, 0x00, sizeof(firstName));
+               dbHandle.getColumnToString(index++, MAX_DISPLAY_NAME_LEN, firstName);
+
+               memset(lastName, 0x00, sizeof(lastName));
+               dbHandle.getColumnToString(index++, MAX_DISPLAY_NAME_LEN, lastName);
+
+
+               if (strlen(displayName) <= 0) {
+                       if (order == 0) {
+                               if (firstName[0] != '\0') {
+                                       strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
+                               }
+
+                               if (lastName[0] != '\0') {
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                                       strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       } else if (order == 1) {
+                               if (lastName[0] != '\0') {
+                                       strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+
+                               if (firstName[0] != '\0') {
+                                       strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       }
+               }
+
+               strncpy(pTmp->addressList[0].displayName, displayName, MAX_DISPLAY_NAME_LEN);
+
+               pTmp->attachCount = dbHandle.getColumnToInt(index++);
+
+               dbHandle.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pTmp->thumbPath);
+       }
+
+       dbHandle.freeTable();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoAddSyncMLMessage(MSG_MESSAGE_INFO_S *pMsgInfo, int ExtId, int PinCode)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       unsigned int rowId = 0;
+       unsigned int addrId = 0;
+
+       dbHandle.beginTrans();
+
+       if (pMsgInfo->nAddressCnt > 0) {
+               err = MsgStoAddAddress(&dbHandle, &(pMsgInfo->addressList[0]), &addrId);
+
+               if (err != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return err;
+               }
+       }
+
+       // Add Message Table
+       rowId = MsgStoAddMessageTable(&dbHandle, pMsgInfo, addrId);
+
+       if (rowId <= 0) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_ROW;
+       }
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d);",
+                                       MSGFW_SYNCML_MSG_TABLE_NAME, rowId, ExtId, PinCode);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       if (MsgStoUpdateAddress(&dbHandle, addrId) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       dbHandle.endTrans(true);
+
+       pMsgInfo->msgId = (MSG_MESSAGE_ID_T)rowId;
+       pMsgInfo->referenceId = (MSG_REFERENCE_ID_T)rowId;
+
+       MsgSoundPlayStart();
+
+       int smsCnt = 0;
+       int mmsCnt = 0;
+
+       smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE);
+       mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
+
+       MsgSettingHandleNewMsg(smsCnt, mmsCnt);
+
+       MsgInsertNoti(&dbHandle, pMsgInfo);
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetMsgType(MSG_MESSAGE_ID_T msgId, MSG_MESSAGE_TYPE_S *pMsgType)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MAIN_TYPE, SUB_TYPE FROM %s WHERE MSG_ID = %d;",
+                                                       MSGFW_MESSAGE_TABLE_NAME, msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               pMsgType->mainType = dbHandle.columnInt(0);
+               pMsgType->subType = dbHandle.columnInt(1);
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetQuickPanelData(MSG_QUICKPANEL_TYPE_T Type, MSG_MESSAGE_INFO_S *pMsg)
+{
+       MSG_ERROR_T     err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       if (Type == MSG_QUICKPANEL_SMS) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE FOLDER_ID = %d AND MAIN_TYPE = %d AND SUB_TYPE = %d AND READ_STATUS = 0 ORDER BY DISPLAY_TIME DESC;",
+                       MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID, MSG_SMS_TYPE, MSG_NORMAL_SMS);
+       } else if (Type == MSG_QUICKPANEL_MMS) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE FOLDER_ID = %d AND MAIN_TYPE = %d AND SUB_TYPE IN (%d, %d) AND READ_STATUS = 0 ORDER BY DISPLAY_TIME DESC;",
+                       MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID, MSG_MMS_TYPE, MSG_RETRIEVE_AUTOCONF_MMS, MSG_RETRIEVE_MANUALCONF_MMS);
+       } else if (Type == MSG_QUICKPANEL_DELIVER_REP) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE SUB_TYPE IN (%d, %d) AND READ_STATUS = 0 ORDER BY DISPLAY_TIME DESC;",
+                       MSGFW_MESSAGE_TABLE_NAME, MSG_STATUS_REPORT_SMS, MSG_DELIVERYIND_MMS);
+       } else if (Type == MSG_QUICKPANEL_READ_REP) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE MAIN_TYPE = %d AND SUB_TYPE = %d AND READ_STATUS = 0 ORDER BY DISPLAY_TIME DESC;",
+                       MSGFW_MESSAGE_TABLE_NAME, MSG_MMS_TYPE, MSG_READORGIND_MMS);
+       } else if (Type == MSG_QUICKPANEL_VOICEMAIL) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE FOLDER_ID = %d AND MAIN_TYPE = %d AND SUB_TYPE = %d AND READ_STATUS = 0 ORDER BY DISPLAY_TIME DESC;",
+                       MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID, MSG_SMS_TYPE, MSG_MWI_VOICE_SMS);
+       } else if (Type == MSG_QUICKPANEL_MMS_NOTI) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE FOLDER_ID = %d AND MAIN_TYPE = %d AND SUB_TYPE = %d AND READ_STATUS = 0 ORDER BY DISPLAY_TIME DESC;",
+                       MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID, MSG_MMS_TYPE, MSG_NOTIFICATIONIND_MMS);
+       }
+
+       // Get Message ID
+       MSG_MESSAGE_ID_T msgId;
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               msgId = dbHandle.columnInt(0);
+       } else {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       // Get Message Info
+       err = MsgStoGetMessage(msgId, pMsg, NULL);
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, MSG_THREAD_VIEW_LIST_S *pThreadViewList)
+{
+       pThreadViewList->nCount = 0;
+       pThreadViewList->msgThreadInfo = NULL;
+
+       int rowCnt = 0;
+       int index = 15; // numbers of index
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+       char sqlSort[64];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ADDRESS_ID, CONTACT_ID, ADDRESS_VAL, \
+                       DISPLAY_NAME, FIRST_NAME, LAST_NAME, IMAGE_PATH, \
+                       UNREAD_CNT, SMS_CNT, MMS_CNT, MAIN_TYPE, SUB_TYPE, \
+                       MSG_DIRECTION, MSG_TIME, MSG_TEXT \
+                       FROM %s \
+                       WHERE ADDRESS_ID <> 0 AND (SMS_CNT > 0 OR MMS_CNT > 0) ",
+                       MSGFW_ADDRESS_TABLE_NAME);
+
+       memset(sqlSort, 0x00, sizeof(sqlSort));
+       MsgMakeSortRule(pSortRule, sqlSort);
+       strncat(sqlQuery, sqlSort, sizeof(sqlQuery) - strlen(sqlQuery) - 1);
+
+       MSG_ERROR_T  err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err == MSG_ERR_DB_NORECORD) {
+               dbHandle.freeTable();
+
+               return MSG_SUCCESS;
+       } else if (err != MSG_SUCCESS) {
+               MSG_DEBUG("%s", sqlQuery);
+
+               dbHandle.freeTable();
+
+               return err;
+       }
+
+       char firstName[MAX_THREAD_NAME_LEN+1];
+       char lastName[MAX_THREAD_NAME_LEN+1];
+       char displayName[MAX_DISPLAY_NAME_LEN+1];
+
+       int order = MsgGetContactNameOrder();
+
+       pThreadViewList->nCount = rowCnt;
+
+       MSG_DEBUG("pThreadViewList->nCount [%d]", pThreadViewList->nCount);
+
+       pThreadViewList->msgThreadInfo = (msg_thread_view_t *)new char[sizeof(MSG_THREAD_VIEW_S *)*rowCnt];
+
+       MSG_THREAD_VIEW_S *pTmp = NULL;
+
+       for (int i = 0; i < rowCnt; i++) {
+               pThreadViewList->msgThreadInfo[i] = (msg_thread_view_t)new char[sizeof(MSG_THREAD_VIEW_S)];
+
+               pTmp = (MSG_THREAD_VIEW_S *)pThreadViewList->msgThreadInfo[i];
+
+               pTmp->threadId = dbHandle.getColumnToInt(index++);
+               pTmp->contactId = dbHandle.getColumnToInt(index++);
+
+               memset(pTmp->threadAddr, 0x00, sizeof(pTmp->threadAddr));
+               dbHandle.getColumnToString(index++, MAX_THREAD_ADDR_LEN, pTmp->threadAddr);
+
+               memset(displayName, 0x00, sizeof(displayName));
+               dbHandle.getColumnToString(index++, MAX_THREAD_NAME_LEN, displayName);
+
+               memset(firstName, 0x00, sizeof(firstName));
+               dbHandle.getColumnToString(index++, MAX_THREAD_NAME_LEN, firstName);
+
+               memset(lastName, 0x00, sizeof(lastName));
+               dbHandle.getColumnToString(index++, MAX_THREAD_NAME_LEN, lastName);
+
+               if (strlen(displayName) <= 0) {
+                       if (order == 0) {
+                               if (firstName[0] != '\0') {
+                                       strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
+                               }
+
+                               if (lastName[0] != '\0') {
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                                       strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       } else if (order == 1) {
+                               if (lastName[0] != '\0') {
+                                       strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+
+                               if (firstName[0] != '\0') {
+                                       strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       }
+               }
+
+               memset(pTmp->threadName, 0x00, sizeof(pTmp->threadName));
+               strncpy(pTmp->threadName, displayName, MAX_THREAD_NAME_LEN);
+
+               memset(pTmp->threadImagePath, 0x00, sizeof(pTmp->threadImagePath));
+               dbHandle.getColumnToString(index++, MAX_IMAGE_PATH_LEN, pTmp->threadImagePath);
+
+               pTmp->unreadCnt = dbHandle.getColumnToInt(index++);
+               pTmp->smsCnt = dbHandle.getColumnToInt(index++);
+               pTmp->mmsCnt = dbHandle.getColumnToInt(index++);
+
+               pTmp->threadType.mainType = dbHandle.getColumnToInt(index++);
+               pTmp->threadType.subType = dbHandle.getColumnToInt(index++);
+
+               pTmp->direction = dbHandle.getColumnToInt(index++);
+               pTmp->threadTime = (time_t)dbHandle.getColumnToInt(index++);
+
+               memset(pTmp->threadData, 0x00, sizeof(pTmp->threadData));
+               dbHandle.getColumnToString(index++, MAX_THREAD_DATA_LEN, pTmp->threadData);
+       }
+
+       dbHandle.freeTable();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetConversationViewList(MSG_THREAD_ID_T ThreadId, MSG_LIST_S *pConvViewList)
+{
+       MSG_BEGIN();
+
+       pConvViewList->nCount = 0;
+       pConvViewList->msgInfo = NULL;
+
+       int rowCnt = 0;
+       int index = 20; /** numbers of index */
+
+       unsigned int addrId = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, ADDRESS_ID, FOLDER_ID, REFERENCE_ID, STORAGE_ID, MAIN_TYPE, SUB_TYPE, \
+                                                       DISPLAY_TIME, DATA_SIZE, NETWORK_STATUS, READ_STATUS, PROTECTED, BACKUP, PRIORITY, \
+                                                       MSG_DIRECTION, SCHEDULED_TIME, SUBJECT, MSG_TEXT, ATTACHMENT_COUNT, THUMB_PATH \
+                                                       FROM %s \
+                                                       WHERE ADDRESS_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d \
+                                                       ORDER BY DISPLAY_TIME, MSG_ID ASC;",
+                                       MSGFW_MESSAGE_TABLE_NAME, ThreadId, MSG_ALLBOX_ID, MSG_CBMSGBOX_ID);
+
+       MSG_ERROR_T err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err == MSG_ERR_DB_NORECORD) {
+               dbHandle.freeTable();
+               return MSG_SUCCESS;
+       } else if (err != MSG_SUCCESS) {
+               MSG_DEBUG("%s", sqlQuery);
+               dbHandle.freeTable();
+               return err;
+       }
+
+       pConvViewList->nCount = rowCnt;
+
+       MSG_DEBUG("pConvViewList->nCount [%d]", pConvViewList->nCount);
+
+       pConvViewList->msgInfo = (msg_message_t *)new char[sizeof(MSG_MESSAGE_S *) * rowCnt];
+
+       MSG_MESSAGE_S *pTmp = NULL;
+
+       for (int i = 0; i < rowCnt; i++) {
+               pConvViewList->msgInfo[i] = (msg_message_t)new char[sizeof(MSG_MESSAGE_S)];
+
+               pTmp = (MSG_MESSAGE_S *)pConvViewList->msgInfo[i];
+
+               memset(pTmp, 0x00, sizeof(pTmp));
+
+               pTmp->pData = NULL;
+               pTmp->pMmsData = NULL;
+
+               pTmp->msgId = dbHandle.getColumnToInt(index++);
+               addrId = dbHandle.getColumnToInt(index++);
+               pTmp->folderId = dbHandle.getColumnToInt(index++);
+               pTmp->referenceId = dbHandle.getColumnToInt(index++);
+               pTmp->storageId = dbHandle.getColumnToInt(index++);
+               pTmp->msgType.mainType = dbHandle.getColumnToInt(index++);
+               pTmp->msgType.subType = dbHandle.getColumnToInt(index++);
+               pTmp->displayTime = (time_t)dbHandle.getColumnToInt(index++);
+               pTmp->dataSize = dbHandle.getColumnToInt(index++);
+               pTmp->networkStatus = dbHandle.getColumnToInt(index++);
+               pTmp->bRead = dbHandle.getColumnToInt(index++);
+               pTmp->bProtected = dbHandle.getColumnToInt(index++);
+               pTmp->bBackup = dbHandle.getColumnToInt(index++);
+               pTmp->priority = dbHandle.getColumnToInt(index++);
+               pTmp->direction = dbHandle.getColumnToInt(index++);
+               pTmp->scheduledTime = (time_t)dbHandle.getColumnToInt(index++);
+
+               dbHandle.getColumnToString(index++, MAX_SUBJECT_LEN, pTmp->subject);
+
+               if (pTmp->msgType.mainType == MSG_MMS_TYPE &&
+                       (pTmp->networkStatus == MSG_NETWORK_RETRIEVING || pTmp->networkStatus == MSG_NETWORK_RETRIEVE_FAIL || pTmp->msgType.subType == MSG_NOTIFICATIONIND_MMS)) {
+                       pTmp->pData = NULL;
+                       index++;
+               } else {
+                       pTmp->pData = (void *)new char[pTmp->dataSize+2];
+                       memset(pTmp->pData, 0x00, pTmp->dataSize+2);
+
+                       dbHandle.getColumnToString(index++, pTmp->dataSize+1, (char *)pTmp->pData);
+               }
+
+               pTmp->attachCount = dbHandle.getColumnToInt(index++);
+
+               dbHandle.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pTmp->thumbPath);
+
+       }
+
+       dbHandle.freeTable();
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoDeleteThreadMessageList(MSG_THREAD_ID_T ThreadId, MSG_MSGID_LIST_S *pMsgIdList)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+       /*** Get msg id list **/
+       MSG_MSGID_LIST_S *pToDeleteMsgIdList = NULL;
+
+       int rowCnt = 0;
+       int index = 1;
+       // Set Indicator
+       int smsCnt = 0;
+       int mmsCnt = 0;
+
+       const char *tableList[] = {MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME,
+                                       MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SCHEDULED_MSG_TABLE_NAME,
+                                       MSGFW_SMS_SENDOPT_TABLE_NAME, MMS_PLUGIN_MESSAGE_TABLE_NAME,
+                                       MSGFW_MESSAGE_TABLE_NAME};
+
+       int listCnt = sizeof(tableList)/sizeof(char *);
+
+       pToDeleteMsgIdList = (MSG_MSGID_LIST_S *)new char[sizeof(MSG_MSGID_LIST_S)];
+       memset(pToDeleteMsgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE ADDRESS_ID = %d",
+                       MSGFW_MESSAGE_TABLE_NAME, ThreadId);
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
+               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+
+               dbHandle.freeTable();
+
+               goto FREE_MEMORY;
+       }
+
+       if (rowCnt <= 0) {
+               dbHandle.freeTable();
+               err = MSG_SUCCESS;
+
+               goto FREE_MEMORY;
+       }
+
+       pToDeleteMsgIdList->nCount = rowCnt;
+
+       MSG_DEBUG("pToDeleteMsgIdList->nCount [%d]", pToDeleteMsgIdList->nCount);
+
+       pToDeleteMsgIdList->msgIdList = (MSG_MESSAGE_ID_T *)new char[sizeof(MSG_MESSAGE_ID_T) * rowCnt];
+
+       for (int i = 0; i < rowCnt; i++)
+               pToDeleteMsgIdList->msgIdList[i] = dbHandle.getColumnToInt(index++);
+
+       dbHandle.freeTable();
+       /*** **/
+
+       /*** Delete Sim Message **/
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID \
+                                       FROM %s \
+                                    WHERE ADDRESS_ID = %d \
+                                         AND STORAGE_ID = %d",
+                       MSGFW_MESSAGE_TABLE_NAME, ThreadId, MSG_STORAGE_SIM);
+
+       rowCnt = 0;
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
+               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+
+               dbHandle.freeTable();
+
+               goto FREE_MEMORY;
+       }
+
+       for (int i = 1; i <= rowCnt; i++) {
+               err = MsgStoDeleteMessage(dbHandle.getColumnToInt(i), false);
+
+               if (err != MSG_SUCCESS) {
+                       MSG_DEBUG("MsgStoDeleteMessage() Error!!!");
+
+                       dbHandle.freeTable();
+
+                       goto FREE_MEMORY;
+               }
+       }
+
+       dbHandle.freeTable();
+       /*** **/
+
+       dbHandle.beginTrans();
+
+       for (int i = 0; i < listCnt; i++) {
+               if (!strcmp(tableList[i], MMS_PLUGIN_MESSAGE_TABLE_NAME)) {
+                       //MMS_PLUGIN_MESSAGE_TABLE_NAME and MMS_PLUGIN_ATTRIBUTE_TABLE_NAME will be updated together
+                       int rowCnt = 0;
+                       int msgCnt = 0;
+                       int index = 2;
+
+                       //get mms msg id list
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, REFERENCE_ID FROM %s \
+                                                               WHERE ADDRESS_ID = %d AND MAIN_TYPE = %d",
+                                                               MSGFW_MESSAGE_TABLE_NAME, ThreadId, MSG_MMS_TYPE);
+
+                       err = dbHandle.getTable(sqlQuery, &rowCnt);
+                       MSG_DEBUG("rowCnt %d", rowCnt);
+
+                       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
+                               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+
+                               dbHandle.freeTable();
+                               dbHandle.endTrans(false);
+
+                               goto FREE_MEMORY;
+                       }
+
+                       for (int i = 1; i <= rowCnt; i++) {
+                               int msgId = 0;
+                               int refId = 0;
+
+                               msgId = dbHandle.getColumnToInt(index++);
+                               refId = dbHandle.getColumnToInt(index++);
+
+                               //get multiple recipient message count
+                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE REFERENCE_ID = %d;",
+                                                               MSGFW_MESSAGE_TABLE_NAME, refId);
+
+                               if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
+                                       dbHandle.freeTable();
+                                       dbHandle.endTrans(false);
+                                       err = MSG_ERR_DB_PREPARE;
+
+                                       goto FREE_MEMORY;
+                               }
+
+                               msgCnt = 0;
+
+                               if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+                                       msgCnt = dbHandle.columnInt(0);
+                               } else {
+                                       dbHandle.finalizeQuery();
+                                       dbHandle.freeTable();
+                                       dbHandle.endTrans(false);
+                                       err = MSG_ERR_DB_STEP;
+
+                                       goto FREE_MEMORY;
+                               }
+
+                               dbHandle.finalizeQuery();
+
+                               //delete mms raw file and db(mms_table and mms_attr_table) data
+                               if (msgCnt == 1) {
+                                       char filePath[MSG_FILEPATH_LEN_MAX] = {0,};
+                                       char dirPath[MSG_FILEPATH_LEN_MAX] = {0,};
+                                       char thumbnailPath[MSG_FILEPATH_LEN_MAX] = {0,};
+
+                                       //get raw file_path
+                                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                                       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILE_PATH FROM %s WHERE REFERENCE_ID = %d;",
+                                                                               MMS_PLUGIN_MESSAGE_TABLE_NAME, refId);
+
+                                       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
+                                               dbHandle.freeTable();
+                                               dbHandle.endTrans(false);
+                                               err = MSG_ERR_DB_PREPARE;
+
+                                               goto FREE_MEMORY;
+                                       }
+
+                                       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+                                               strncpy(filePath, (char *)dbHandle.columnText(0), MSG_FILEPATH_LEN_MAX);
+                                       } else {
+                                               dbHandle.finalizeQuery();
+                                               dbHandle.freeTable();
+                                               dbHandle.endTrans(false);
+                                               err = MSG_ERR_DB_STEP;
+
+                                               goto FREE_MEMORY;
+                                       }
+
+                                       dbHandle.finalizeQuery();
+
+                                       MSG_DEBUG("filePath [%s]", filePath);
+
+                                       //delete raw file
+                                       snprintf(dirPath, sizeof(dirPath), "%s.dir", filePath);
+
+                                       if (remove(filePath) == -1)
+                                               MSG_DEBUG("Fail to delete file [%s]", filePath);
+                                       else
+                                               MSG_DEBUG("Success to delete file [%s]", filePath);
+
+                                       MsgRmRf(dirPath);
+                                       // remove directory also
+                                       rmdir(dirPath);
+
+                                       // delete thumbnail
+                                       char *fileName = NULL;
+                                       fileName = strrchr(filePath, '/');
+
+                                       snprintf(thumbnailPath, sizeof(thumbnailPath), MSG_THUMBNAIL_PATH"%s.jpg", fileName+1);
+
+                                       if (remove(thumbnailPath) == -1)
+                                               MSG_DEBUG("Fail to delete thumbnail [%s]", thumbnailPath);
+                                       else
+                                               MSG_DEBUG("Success to delete thumbnail [%s]", thumbnailPath);
+
+                                       //delete MMS_PLUGIN_MESSAGE_TABLE_NAME table data
+                                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE REFERENCE_ID = %d;",
+                                                                               MMS_PLUGIN_MESSAGE_TABLE_NAME, refId);
+
+                                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                                               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+                                               dbHandle.freeTable();
+                                               dbHandle.endTrans(false);
+                                               err = MSG_ERR_DB_EXEC;
+
+                                               goto FREE_MEMORY;
+                                       }
+
+                                       //delete  MMS_PLUGIN_ATTRIBUTE_TABLE_NAME table data
+                                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE REFERENCE_ID = %d;",
+                                                                               MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, refId);
+
+                                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                                               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+                                               dbHandle.freeTable();
+                                               dbHandle.endTrans(false);
+                                               err = MSG_ERR_DB_EXEC;
+
+                                               goto FREE_MEMORY;
+                                       }
+                               } else {
+                                       MSG_DEBUG("There is remained multi-recipient mms for this msg = %d", msgId);
+                               }
+                       }
+
+                       dbHandle.freeTable();
+               } else {
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID IN \
+                                                                       (SELECT MSG_ID FROM %s WHERE ADDRESS_ID = %d);",
+                                                                       tableList[i], MSGFW_MESSAGE_TABLE_NAME, ThreadId);
+
+                       // Delete Message in specific folder from table
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+                               dbHandle.endTrans(false);
+                               err = MSG_ERR_DB_EXEC;
+
+                               goto FREE_MEMORY;
+                       }
+               }
+       }
+
+       // Delete Address table
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       if (ThreadId > 0) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s \
+                                            WHERE ADDRESS_ID = %d;",
+                                       MSGFW_ADDRESS_TABLE_NAME, ThreadId);
+
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                       MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+                       dbHandle.endTrans(false);
+                       err = MSG_ERR_DB_EXEC;
+
+                       goto FREE_MEMORY;
+               }
+       }
+
+       dbHandle.endTrans(true);
+
+       MSG_MESSAGE_TYPE_S msgType;
+
+       msgType.mainType = MSG_SMS_TYPE;
+       msgType.subType = MSG_NORMAL_SMS;
+       msgType.classType = MSG_CLASS_NONE;
+
+       // Set memory status in SIM
+       if (MsgStoCheckMsgCntFull(&dbHandle, &msgType, MSG_INBOX_ID) == MSG_SUCCESS) {
+               MSG_DEBUG("Set Memory Status");
+
+               MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE);
+
+               if (plg == NULL) {
+                       MSG_DEBUG("SMS Plug-in is NULL");
+                       err = MSG_ERR_NULL_POINTER;
+
+                       goto FREE_MEMORY;
+               }
+
+               plg->setMemoryStatus(MSG_SUCCESS);
+       }
+
+       // Set Indicator
+       smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE);
+       mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
+
+       MsgSettingSetIndicator(smsCnt, mmsCnt);
+
+/*** Set pMsgIdList **/
+       if (pMsgIdList != NULL && pToDeleteMsgIdList->nCount > 0) {
+               pMsgIdList->nCount = pToDeleteMsgIdList->nCount;
+
+               pMsgIdList->msgIdList = (MSG_MESSAGE_ID_T *)new char[sizeof(MSG_MESSAGE_ID_T)*pToDeleteMsgIdList->nCount];
+               memcpy(pMsgIdList->msgIdList, pToDeleteMsgIdList->msgIdList, sizeof(MSG_MESSAGE_ID_T)*pToDeleteMsgIdList->nCount);
+       }
+/*** **/
+
+       /*** Create thread  for noti delete. **/
+       if (pToDeleteMsgIdList->nCount > 0) {
+               if (g_idle_add(startToDeleteNoti, (void *)pToDeleteMsgIdList) == 0) {
+                       MSG_DEBUG("startToDeleteNoti not invoked: %s", strerror(errno));
+                       // memory free
+                       if (pToDeleteMsgIdList != NULL) {
+                               //free peer info list
+                               if (pToDeleteMsgIdList->msgIdList != NULL)
+                                       delete [] pToDeleteMsgIdList->msgIdList;
+
+                               delete [] pToDeleteMsgIdList;
+                       }
+                       err = MSG_ERR_UNKNOWN;
+               }
+       }
+       /*** **/
+
+       return MSG_SUCCESS;
+
+FREE_MEMORY:
+       MSG_DEBUG("Error case Free Memory");
+       // memory free
+       if (pToDeleteMsgIdList != NULL) {
+               //free peer info list
+               if (pToDeleteMsgIdList->msgIdList != NULL) {
+                       delete [] pToDeleteMsgIdList->msgIdList;
+                       pToDeleteMsgIdList->msgIdList = NULL;
+               }
+
+               delete [] pToDeleteMsgIdList;
+               pToDeleteMsgIdList = NULL;
+       }
+
+       return err;
+
+}
+
+
+MSG_ERROR_T MsgStoCountMsgByContact(const MSG_THREAD_LIST_INDEX_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pThreadCountInfo)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       if (pAddrInfo->contactId > 0) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) AS TOTAL, \
+                                               SUM(CASE WHEN READ_STATUS=0 AND FOLDER_ID=%d THEN 1 ELSE 0 END), \
+                                               SUM(CASE WHEN MAIN_TYPE=%d THEN 1 ELSE 0 END), \
+                                               SUM(CASE WHEN MAIN_TYPE=%d THEN 1 ELSE 0 END) \
+                                               FROM (SELECT * FROM %s A  JOIN %s B ON A.ADDRESS_ID = B.ADDRESS_ID WHERE B.CONTACT_ID = %d)",
+                                       MSG_INBOX_ID, MSG_SMS_TYPE, MSG_MMS_TYPE,
+                                       MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, pAddrInfo->contactId);
+       } else {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) AS TOTAL, \
+                                               SUM(CASE WHEN READ_STATUS=0 AND FOLDER_ID=%d THEN 1 ELSE 0 END), \
+                                               SUM(CASE WHEN MAIN_TYPE=%d THEN 1 ELSE 0 END), \
+                                               SUM(CASE WHEN MAIN_TYPE=%d THEN 1 ELSE 0 END) \
+                                               FROM (SELECT * FROM %s A  JOIN %s B ON A.ADDRESS_ID = B.ADDRESS_ID WHERE B.ADDRESS_VAL = '%s')",
+                                       MSG_INBOX_ID, MSG_SMS_TYPE, MSG_MMS_TYPE,
+                                       MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, pAddrInfo->msgAddrInfo.addressVal);
+       }
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               pThreadCountInfo->totalCount = dbHandle.columnInt(0);
+               pThreadCountInfo->unReadCount = dbHandle.columnInt(1);
+               pThreadCountInfo->smsMsgCount = dbHandle.columnInt(2);
+               pThreadCountInfo->mmsMsgCount = dbHandle.columnInt(3);
+       } else {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoSearchMessage(const char *pSearchString, MSG_THREAD_VIEW_LIST_S *pThreadViewList)
+{
+       if (!pSearchString)
+               return MSG_ERR_NULL_POINTER;
+
+       // Clear Out Parameter
+       pThreadViewList->nCount = 0;
+       pThreadViewList->msgThreadInfo = NULL;
+
+       tr1::unordered_set<MSG_THREAD_ID_T> IdList;
+       queue<MSG_THREAD_VIEW_S> searchList;
+
+       MSG_THREAD_VIEW_S threadView;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       char firstName[MAX_DISPLAY_NAME_LEN+1];
+       char lastName[MAX_DISPLAY_NAME_LEN+1];
+       char displayName[MAX_DISPLAY_NAME_LEN+1];
+
+       // Get Name Order
+       int order = MsgGetContactNameOrder();
+
+       // Replace string for '%' and '_' character
+       char *ext1_str = NULL;
+       char *ext2_str = NULL;
+
+       ext1_str = MsgStoReplaceString(pSearchString, "_", "\\_");
+       ext2_str = MsgStoReplaceString(ext1_str, "%", "\\%");
+
+       // Search - Address, Name
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.ADDRESS_ID, A.CONTACT_ID, A.ADDRESS_VAL, \
+                                               A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, A.IMAGE_PATH, \
+                                               A.UNREAD_CNT, A.SMS_CNT, A.MMS_CNT, \
+                                               A.MSG_DIRECTION, B.DISPLAY_TIME, B.MSG_TEXT \
+                                               FROM %s A, %s B \
+                                       WHERE A.ADDRESS_ID = B.ADDRESS_ID AND A.ADDRESS_ID <> 0 \
+                                               AND B.FOLDER_ID > 0 AND B.FOLDER_ID < %d \
+                                               AND ( B.MSG_TEXT LIKE '%%%s%%' ESCAPE '\\' \
+                                               OR B.SUBJECT LIKE '%%%s%%' ESCAPE '\\' \
+                                               OR A.ADDRESS_VAL LIKE '%%%s%%' ESCAPE '\\' \
+                                               OR A.DISPLAY_NAME LIKE '%%%s%%' ESCAPE '\\' \
+                                               OR A.FIRST_NAME LIKE '%%%s%%' ESCAPE '\\' \
+                                               OR A.LAST_NAME LIKE '%%%s%%' ESCAPE '\\') \
+                                       ORDER BY B.DISPLAY_TIME DESC;",
+                                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MSG_CBMSGBOX_ID,
+                                               ext2_str, ext2_str, ext2_str, ext2_str, ext2_str, ext2_str);
+
+
+       if (ext1_str) {
+               free(ext1_str);
+               ext1_str = NULL;
+       }
+
+       if (ext2_str) {
+               free(ext2_str);
+               ext2_str = NULL;
+       }
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       while (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               memset(&threadView, 0x00, sizeof(threadView));
+
+               threadView.threadId = dbHandle.columnInt(0);
+               threadView.contactId = dbHandle.columnInt(1);
+
+               memset(threadView.threadAddr, 0x00, sizeof(threadView.threadAddr));
+               strncpy(threadView.threadAddr, (char *)dbHandle.columnText(2), MAX_THREAD_ADDR_LEN);
+
+               memset(displayName, 0x00, sizeof(displayName));
+               strncpy(displayName, (char *)dbHandle.columnText(3), MAX_DISPLAY_NAME_LEN);
+
+               memset(firstName, 0x00, sizeof(firstName));
+               strncpy(firstName, (char *)dbHandle.columnText(4), MAX_DISPLAY_NAME_LEN);
+
+               memset(lastName, 0x00, sizeof(lastName));
+               strncpy(lastName, (char *)dbHandle.columnText(5), MAX_DISPLAY_NAME_LEN);
+
+               if (strlen(displayName) <= 0) {
+                       if (order == 0) {
+                               if (firstName[0] != '\0') {
+                                       strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
+                               }
+
+                               if (lastName[0] != '\0') {
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                                       strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       } else if (order == 1) {
+                               if (lastName[0] != '\0') {
+                                       strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+
+                               if (firstName[0] != '\0') {
+                                       strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       }
+               }
+
+               strncpy(threadView.threadName, displayName, MAX_THREAD_NAME_LEN);
+
+               strncpy(threadView.threadImagePath, (char *)dbHandle.columnText(6), MAX_IMAGE_PATH_LEN);
+
+               threadView.unreadCnt = dbHandle.columnInt(7);
+               threadView.smsCnt = dbHandle.columnInt(8);
+               threadView.mmsCnt = dbHandle.columnInt(9);
+
+               threadView.direction = dbHandle.columnInt(10);
+               threadView.threadTime = (time_t)dbHandle.columnInt(11);
+
+               strncpy(threadView.threadData, (char *)dbHandle.columnText(12), MAX_THREAD_DATA_LEN);
+
+               tr1::unordered_set<MSG_THREAD_ID_T>::iterator it;
+
+               it = IdList.find(threadView.threadId);
+
+               if (it == IdList.end()) {
+                       IdList.insert(threadView.threadId);
+                       searchList.push(threadView);
+               }
+
+       }
+
+       dbHandle.finalizeQuery();
+
+       // Add data to Out Parameter
+       pThreadViewList->nCount = searchList.size();
+       pThreadViewList->msgThreadInfo = (msg_thread_view_t *)new char[sizeof(MSG_THREAD_VIEW_S *) * searchList.size()];
+
+       MSG_THREAD_VIEW_S *pTmp = NULL;
+
+       int index = 0;
+
+       while (!searchList.empty()) {
+               pThreadViewList->msgThreadInfo[index] = (msg_thread_view_t)new char[sizeof(MSG_THREAD_VIEW_S)];
+
+               pTmp = (MSG_THREAD_VIEW_S *)pThreadViewList->msgThreadInfo[index];
+
+               memcpy(pTmp, &(searchList.front()), sizeof(MSG_THREAD_VIEW_S));
+
+               searchList.pop();
+
+               index++;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoSearchMessage(const MSG_SEARCH_CONDITION_S *pSearchCon, int offset, int limit, MSG_LIST_S *pMsgList)
+{
+       // Clear Out Parameter
+       pMsgList->nCount = 0;
+       pMsgList->msgInfo = NULL;
+
+       int rowCnt = 0;
+       int index = 27; // numbers of index
+
+       unsigned int addrId = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+       char sqlQuerySubset[(MAX_QUERY_LEN/5)+1];
+
+       char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
+       char displayName[MAX_DISPLAY_NAME_LEN+1];
+
+       char *ext1_str = NULL;
+       char *ext2_str = NULL;
+
+       // Get Name Order
+       int order = MsgGetContactNameOrder();
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.MSG_ID, A.ADDRESS_ID, A.FOLDER_ID, A.REFERENCE_ID, A.STORAGE_ID, A.MAIN_TYPE, A.SUB_TYPE, \
+                                                       A.DISPLAY_TIME, A.DATA_SIZE, A.NETWORK_STATUS, A.READ_STATUS, A.PROTECTED, A.BACKUP, A.PRIORITY, \
+                                                       A.MSG_DIRECTION, A.SCHEDULED_TIME, A.SUBJECT, A.MSG_TEXT, B.ADDRESS_TYPE, B.RECIPIENT_TYPE, \
+                                                       B.CONTACT_ID, B.ADDRESS_VAL, B.DISPLAY_NAME, B.FIRST_NAME, B.LAST_NAME, A.ATTACHMENT_COUNT, A.THUMB_PATH \
+                                                       FROM %s A, %s B \
+                                                       WHERE A.ADDRESS_ID = B.ADDRESS_ID AND B.ADDRESS_ID <> 0 ",
+                                                       MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME);
+
+       //// folder
+       memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset));
+
+       if (pSearchCon->folderId == MSG_ALLBOX_ID)
+               snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.FOLDER_ID > 0 AND A.FOLDER_ID < %d ", MSG_CBMSGBOX_ID);
+       else if (pSearchCon->folderId == MSG_IOSBOX_ID)
+               snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.FOLDER_ID > 0 AND A.FOLDER_ID < %d ", MSG_DRAFT_ID);
+       else
+               snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.FOLDER_ID = %d ", pSearchCon->folderId);
+
+       strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery));
+
+
+       //// msg type
+       memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset));
+
+       switch (pSearchCon->msgType) {
+               case MSG_TYPE_SMS:
+                       snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.MAIN_TYPE = %d AND A.SUB_TYPE = %d ", MSG_SMS_TYPE, MSG_NORMAL_SMS);
+                       break;
+
+               case MSG_TYPE_MMS:
+                       snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.MAIN_TYPE = %d ", MSG_MMS_TYPE);
+                       break;
+
+               case MSG_TYPE_MMS_JAVA:
+                       snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.MAIN_TYPE = %d AND A.SUB_TYPE = %d ", MSG_MMS_TYPE, MSG_SENDREQ_JAVA_MMS);
+                       break;
+
+               case MSG_TYPE_SMS_SYNCML:
+                       snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.MAIN_TYPE = %d AND A.SUB_TYPE = %d ", MSG_SMS_TYPE, MSG_SYNCML_CP);
+                       break;
+
+               case MSG_TYPE_SMS_REJECT:
+                       snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.MAIN_TYPE = %d AND A.SUB_TYPE = %d ", MSG_SMS_TYPE, MSG_REJECT_SMS);
+                       break;
+
+               default:
+                       MSG_DEBUG("msg type is not set.");
+       }
+
+       strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery));
+
+       /// string
+       if (pSearchCon->pSearchVal != NULL) {
+
+               // Replace string for '%' and '_' character
+               ext1_str = MsgStoReplaceString(pSearchCon->pSearchVal, "_", "\\_");
+               ext2_str = MsgStoReplaceString(ext1_str, "%", "\\%");
+
+               memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset));
+               snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND ( A.MSG_TEXT LIKE '%%%s%%' ESCAPE '\\' \
+                                                               OR A.SUBJECT LIKE '%%%s%%' ESCAPE '\\' \
+                                                               OR B.ADDRESS_VAL LIKE '%%%s%%' ESCAPE '\\' \
+                                                               OR B.DISPLAY_NAME LIKE '%%%s%%' ESCAPE '\\' \
+                                                               OR B.FIRST_NAME LIKE '%%%s%%' ESCAPE '\\' \
+                                                               OR B.LAST_NAME LIKE '%%%s%%' ESCAPE '\\') ",
+                                                               ext2_str, ext2_str, ext2_str, ext2_str, ext2_str, ext2_str);
+               strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery));
+
+               if (ext1_str) {
+                       free(ext1_str);
+                       ext1_str = NULL;
+               }
+
+               if (ext2_str) {
+                       free(ext2_str);
+                       ext2_str = NULL;
+               }
+       }
+
+       /// address
+       if (pSearchCon->pAddressVal != NULL) {
+
+               // Replace string for '%' and '_' character
+               ext1_str = MsgStoReplaceString(pSearchCon->pAddressVal, "_", "\\_");
+               ext2_str = MsgStoReplaceString(ext1_str, "%", "\\%");
+
+               memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset));
+               snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND B.ADDRESS_VAL LIKE '%%%s%%' ESCAPE '\\'", ext2_str);
+               strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery));
+
+               if (ext1_str) {
+                       free(ext1_str);
+                       ext1_str = NULL;
+               }
+
+               if (ext2_str) {
+                       free(ext2_str);
+                       ext2_str = NULL;
+               }
+       }
+
+       /// limit, offset
+       memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset));
+
+       if (offset >= 0 && limit > 0)
+               snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "ORDER BY A.DISPLAY_TIME DESC LIMIT %d OFFSET %d;", limit, offset);
+       else
+               snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "ORDER BY A.DISPLAY_TIME DESC;");
+
+       strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery));
+
+       MSG_ERROR_T err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err == MSG_ERR_DB_NORECORD) {
+               dbHandle.freeTable();
+
+               return MSG_SUCCESS;
+       } else if (err != MSG_SUCCESS) {
+               MSG_DEBUG("%s", sqlQuery);
+
+               dbHandle.freeTable();
+
+               return err;
+       }
+
+       pMsgList->nCount = rowCnt;
+
+       MSG_DEBUG("pMsgList->nCount [%d]", pMsgList->nCount);
+
+       pMsgList->msgInfo = (msg_message_t *)new char[sizeof(MSG_MESSAGE_S *) * rowCnt];
+
+       MSG_MESSAGE_S *pTmp = NULL;
+
+       for (int i = 0; i < rowCnt; i++) {
+               pMsgList->msgInfo[i] = (msg_message_t)new char[sizeof(MSG_MESSAGE_S)];
+
+               pTmp = (MSG_MESSAGE_S *)pMsgList->msgInfo[i];
+
+               memset(pTmp, 0x00, sizeof(pTmp));
+
+               pTmp->pData = NULL;
+               pTmp->pMmsData = NULL;
+
+               pTmp->msgId = dbHandle.getColumnToInt(index++);
+               addrId = dbHandle.getColumnToInt(index++);
+               pTmp->folderId = dbHandle.getColumnToInt(index++);
+               pTmp->referenceId = dbHandle.getColumnToInt(index++);
+               pTmp->storageId = dbHandle.getColumnToInt(index++);
+               pTmp->msgType.mainType = dbHandle.getColumnToInt(index++);
+               pTmp->msgType.subType = dbHandle.getColumnToInt(index++);
+               pTmp->displayTime = (time_t)dbHandle.getColumnToInt(index++);
+               pTmp->dataSize = dbHandle.getColumnToInt(index++);
+               pTmp->networkStatus = dbHandle.getColumnToInt(index++);
+               pTmp->bRead = dbHandle.getColumnToInt(index++);
+               pTmp->bProtected = dbHandle.getColumnToInt(index++);
+               pTmp->bBackup = dbHandle.getColumnToInt(index++);
+               pTmp->priority = dbHandle.getColumnToInt(index++);
+               pTmp->direction= dbHandle.getColumnToInt(index++);
+               pTmp->scheduledTime = (time_t)dbHandle.getColumnToInt(index++);
+
+               dbHandle.getColumnToString(index++, MAX_SUBJECT_LEN, pTmp->subject);
+
+               if (pTmp->msgType.mainType == MSG_MMS_TYPE &&
+                       (pTmp->networkStatus == MSG_NETWORK_RETRIEVING || pTmp->networkStatus == MSG_NETWORK_RETRIEVE_FAIL || pTmp->msgType.subType == MSG_NOTIFICATIONIND_MMS)) {
+                       pTmp->pData = NULL;
+                       index++;
+               } else {
+                       MSG_DEBUG("pTmp->dataSize [%d]", pTmp->dataSize);
+                       pTmp->pData = (void *)new char[pTmp->dataSize + 2];
+                       memset(pTmp->pData, 0x00, sizeof(pTmp->pData));
+
+                       dbHandle.getColumnToString(index++, pTmp->dataSize+1, (char *)pTmp->pData);
+               }
+
+               if (addrId > 0)
+                       pTmp->nAddressCnt = 1;
+               else
+                       pTmp->nAddressCnt = 0;
+
+               pTmp->addressList[0].threadId = addrId;
+               pTmp->addressList[0].addressType = dbHandle.getColumnToInt(index++);
+               pTmp->addressList[0].recipientType = dbHandle.getColumnToInt(index++);
+               pTmp->addressList[0].contactId = dbHandle.getColumnToInt(index++);
+
+               dbHandle.getColumnToString(index++, MAX_ADDRESS_VAL_LEN, pTmp->addressList[0].addressVal);
+
+               memset(displayName, 0x00, sizeof(displayName));
+               dbHandle.getColumnToString(index++, MAX_DISPLAY_NAME_LEN, displayName);
+
+               memset(firstName, 0x00, sizeof(firstName));
+               dbHandle.getColumnToString(index++, MAX_DISPLAY_NAME_LEN, firstName);
+
+               memset(lastName, 0x00, sizeof(lastName));
+               dbHandle.getColumnToString(index++, MAX_DISPLAY_NAME_LEN, lastName);
+
+               if (strlen(displayName) <= 0) {
+                       if (order == 0) {
+                               if (firstName[0] != '\0') {
+                                       strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
+                               }
+
+                               if (lastName[0] != '\0') {
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                                       strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       } else if (order == 1) {
+                               if (lastName[0] != '\0') {
+                                       strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+
+                               if (firstName[0] != '\0') {
+                                       strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       }
+               }
+
+               strncpy(pTmp->addressList[0].displayName, displayName, MAX_DISPLAY_NAME_LEN);
+
+               pTmp->attachCount = dbHandle.getColumnToInt(index++);
+
+               dbHandle.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pTmp->thumbPath);
+
+       }
+       dbHandle.freeTable();
+
+       return MSG_SUCCESS;
+}
+
+
+
+MSG_ERROR_T MsgStoGetMsgIdList(MSG_REFERENCE_ID_T RefId, MSG_MSGID_LIST_S *pMsgIdList)
+{
+       // Clear Out Parameter
+       pMsgIdList->nCount = 0;
+       pMsgIdList->msgIdList = NULL;
+
+       int rowCnt = 0;
+       int index = 1; // numbers of index
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       // Search - Address, Name
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery),
+               "SELECT MSG_ID \
+                                       FROM %s \
+                                    WHERE REFERENCE_ID = %d \
+                                     ORDER BY MSG_ID ASC;",
+                                     MSGFW_MESSAGE_TABLE_NAME, RefId);
+
+       MSG_ERROR_T err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS) {
+               MSG_DEBUG("%s", sqlQuery);
+
+               dbHandle.freeTable();
+
+               return err;
+       }
+
+       pMsgIdList->nCount = rowCnt;
+
+       MSG_DEBUG("pMsgIdList->nCount [%d]", pMsgIdList->nCount);
+
+       pMsgIdList->msgIdList = (MSG_MESSAGE_ID_T *)new char[sizeof(MSG_MESSAGE_ID_T *) * rowCnt];
+
+       for (int i = 0; i < rowCnt; i++) {
+               pMsgIdList->msgIdList[i] = (MSG_MESSAGE_ID_T)new char[sizeof(MSG_MESSAGE_ID_T)];
+
+               pMsgIdList->msgIdList[i] = dbHandle.getColumnToInt(index++);
+       }
+
+       dbHandle.freeTable();
+
+       return MSG_SUCCESS;
+}
+
+
+void MsgConvertNumber(const char *pSrcNum, char *pDestNum)
+{
+       int overLen = 0;
+       int i = 0;
+
+       overLen = strlen(pSrcNum) - MAX_PRECONFIG_NUM;
+
+       for (i = 0; i < MAX_PRECONFIG_NUM; i++)
+               pDestNum[i] = pSrcNum[i+overLen];
+
+       pDestNum[i] = '\0';
+}
+
+
+MSG_ERROR_T MsgStoGetRejectMsgList(const char *pNumber, MSG_REJECT_MSG_LIST_S *pRejectMsgList)
+{
+       // Clear Out Parameter
+       pRejectMsgList->nCount = 0;
+       pRejectMsgList->rejectMsgInfo = NULL;
+
+       int rowCnt = 0;
+       int index = 3; // numbers of index
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       // Search Reject Msg
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       if (pNumber != NULL) {
+               char phoneNumber[MAX_PRECONFIG_NUM+1];
+               memset(phoneNumber, 0x00, sizeof(phoneNumber));
+
+               if (strlen(pNumber) > MAX_PRECONFIG_NUM) {
+                       MsgConvertNumber(pNumber, phoneNumber);
+               } else {
+                       strncpy(phoneNumber, pNumber, MAX_PRECONFIG_NUM);
+               }
+
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                       "SELECT B.MSG_ID, B.MSG_TEXT, B.DISPLAY_TIME \
+                                               FROM %s A, %s B \
+                                            WHERE A.ADDRESS_ID = B.ADDRESS_ID \
+                                                 AND B.MAIN_TYPE = %d \
+                                                 AND B.SUB_TYPE = %d \
+                                                 AND A.ADDRESS_VAL LIKE '%%%s' \
+                                             ORDER BY B.DISPLAY_TIME DESC;",
+                                             MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
+                                             MSG_SMS_TYPE, MSG_REJECT_SMS, phoneNumber);
+       } else {
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                       "SELECT B.MSG_ID, B.MSG_TEXT, B.DISPLAY_TIME \
+                                               FROM %s A, %s B \
+                                            WHERE A.ADDRESS_ID = B.ADDRESS_ID \
+                                                 AND B.MAIN_TYPE = %d \
+                                                 AND B.SUB_TYPE = %d \
+                                             ORDER BY B.DISPLAY_TIME DESC;",
+                                             MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
+                                             MSG_SMS_TYPE, MSG_REJECT_SMS);
+       }
+
+       MSG_ERROR_T  err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS) {
+               MSG_DEBUG("%s", sqlQuery);
+
+               dbHandle.freeTable();
+
+               return err;
+       }
+
+       pRejectMsgList->nCount = rowCnt;
+
+       MSG_DEBUG("pRejectMsgList->nCount [%d]", pRejectMsgList->nCount);
+
+       pRejectMsgList->rejectMsgInfo = (MSG_REJECT_MSG_INFO_S *)new char[sizeof(MSG_REJECT_MSG_INFO_S)*rowCnt];
+
+       MSG_REJECT_MSG_INFO_S *pTmp = pRejectMsgList->rejectMsgInfo;
+
+       for (int i = 0; i < rowCnt; i++) {
+               pTmp->msgId = dbHandle.getColumnToInt(index++);
+
+               memset(pTmp->msgText, 0x00, sizeof(pTmp->msgText));
+               dbHandle.getColumnToString(index++, MAX_MSG_TEXT_LEN, pTmp->msgText);
+
+               pTmp->displayTime = (time_t)dbHandle.getColumnToInt(index++);
+
+               pTmp++;
+       }
+
+       dbHandle.freeTable();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetSyncMLExtId(MSG_MESSAGE_ID_T msgId, int *extId)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT EXT_ID FROM %s WHERE MSG_ID = %d;",
+                               MSGFW_SYNCML_MSG_TABLE_NAME, msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               *extId = dbHandle.columnInt(0);
+       } else {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetReportStatus(MSG_MESSAGE_ID_T msgId, MSG_REPORT_STATUS_INFO_S *pReportStatus)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DELIVERY_REPORT_STATUS, DELIVERY_REPORT_TIME, READ_REPORT_STATUS, READ_REPORT_TIME \
+                                                                       FROM %s WHERE MSG_ID = %d;",
+                                                       MSGFW_MESSAGE_TABLE_NAME, msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               pReportStatus->deliveryStatus = (MSG_DELIVERY_REPORT_STATUS_T)dbHandle.columnInt(0);
+               pReportStatus->deliveryStatusTime = (time_t)dbHandle.columnInt(1);
+               pReportStatus->readStatus = (MSG_READ_REPORT_STATUS_T)dbHandle.columnInt(2);
+               pReportStatus->readStatusTime = (time_t)dbHandle.columnInt(3);
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetThreadUnreadCnt(MSG_THREAD_ID_T ThreadId, int *cnt)
+{
+       MSG_BEGIN();
+
+       int msgCnt = 0;
+       *cnt = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       // Get MSG_ID
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s A \
+                                    WHERE ADDRESS_ID = %d AND READ_STATUS = 0;",
+                               MSGFW_MESSAGE_TABLE_NAME, ThreadId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               msgCnt = dbHandle.columnInt(0);
+       }
+
+       dbHandle.finalizeQuery();
+
+       *cnt = msgCnt;
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
diff --git a/framework/storage-handler/MsgStorageMms.cpp b/framework/storage-handler/MsgStorageMms.cpp
new file mode 100755 (executable)
index 0000000..8bb5eb2
--- /dev/null
@@ -0,0 +1,539 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgUtilFile.h"
+#include "MsgUtilStorage.h"
+#include "MsgSqliteWrapper.h"
+#include "MsgStorageHandler.h"
+#include "MsgContact.h"
+
+
+/*==================================================================================================
+                                     VARIABLES
+==================================================================================================*/
+extern MsgDbHandler dbHandle;
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgStoGetText(MSG_MESSAGE_ID_T MsgId, char *pSubject, char *pMsgText)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SUBJECT, MSG_TEXT FROM %s WHERE MSG_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+       if(dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if(dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+
+               char *subject = (char*)dbHandle.columnText(0);
+               char *text = (char*)dbHandle.columnText(1);
+
+               if(subject)
+                       strncpy(pSubject, subject, MAX_SUBJECT_LEN);
+               if(text)
+                       strncpy(pMsgText, text, MAX_MSG_TEXT_LEN);
+       } else {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+
+}
+
+
+
+MSG_ERROR_T MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+       int rowCnt = 0;
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       dbHandle.beginTrans();
+
+       if(pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS)
+       {
+               if( pMsg->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS )
+               {
+                       snprintf(sqlQuery, sizeof(sqlQuery),
+                               "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, DISPLAY_TIME = %lu, SUBJECT = ?, NETWORK_STATUS = %d, MSG_TEXT = ?, THUMB_PATH = '%s', DATA_SIZE = %d WHERE REFERENCE_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->displayTime, pMsg->networkStatus, pMsg->thumbPath,  pMsg->dataSize, pMsg->msgId);
+
+                       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+                               return MSG_ERR_DB_PREPARE;
+
+                       dbHandle.bindText(pMsg->subject, 1);
+                       dbHandle.bindText(pMsg->msgText, 2);
+               }
+               else if( pMsg->networkStatus == MSG_NETWORK_RETRIEVE_FAIL)
+               {
+                       snprintf(sqlQuery, sizeof(sqlQuery),
+                               "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, SUBJECT = ?, NETWORK_STATUS = %d, MSG_TEXT = ?, THUMB_PATH = '%s' WHERE REFERENCE_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->networkStatus, pMsg->thumbPath,  pMsg->msgId);
+
+                       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+                               return MSG_ERR_DB_PREPARE;
+
+                       dbHandle.bindText(pMsg->subject, 1);
+                       dbHandle.bindText(pMsg->msgText, 2);
+               }
+       }
+       else if (pMsg->msgType.subType == MSG_SENDREQ_MMS)
+       {
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                       "UPDATE %s SET MSG_DATA = '%s', MSG_TEXT = ?, THUMB_PATH = '%s' WHERE REFERENCE_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, pMsg->msgData, pMsg->thumbPath, pMsg->referenceId);
+
+               if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_PREPARE;
+
+               dbHandle.bindText(pMsg->msgText, 1);
+       }
+       else
+       {
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                       "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, FOLDER_ID = %d, NETWORK_STATUS = %d WHERE REFERENCE_ID = %d;",
+                                               MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->folderId, pMsg->networkStatus, pMsg->msgId);
+
+               if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_PREPARE;
+       }
+
+       if (dbHandle.stepQuery() != MSG_ERR_DB_DONE)
+       {
+               dbHandle.finalizeQuery();
+               dbHandle.endTrans(false);
+               MSG_DEBUG("Update MMS Message. Fail [%s]", sqlQuery);
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       unsigned int addrId = 0;
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       // Get SUB_TYPE, STORAGE_ID
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery),
+               "SELECT ADDRESS_ID \
+                                       FROM %s \
+                                    WHERE MSG_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+       {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_PREPARE;
+       }
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW)
+       {
+               addrId = dbHandle.columnInt(0);
+
+               MSG_DEBUG("AddressId:[%d]", addrId);
+       }
+       else
+       {
+               MSG_DEBUG("MsgStepQuery() Error [%s]", sqlQuery);
+               dbHandle.finalizeQuery();
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery),
+               "SELECT ADDRESS_ID \
+                                       FROM %s \
+                                    WHERE REFERENCE_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId);
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
+       {
+               MSG_DEBUG("Failed to Get Table");
+
+               dbHandle.freeTable();
+               dbHandle.endTrans(false);
+
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       for (int i = 1; i <= rowCnt; i++)
+       {
+               addrId = dbHandle.getColumnToInt(i);
+
+               if (MsgStoUpdateAddress(&dbHandle, addrId) != MSG_SUCCESS)
+               {
+                       MSG_DEBUG("MsgStoUpdateAddress() Error");
+                       dbHandle.freeTable();
+                       dbHandle.endTrans(false);
+
+                       return MSG_ERR_STORAGE_ERROR;
+               }
+       }
+
+       dbHandle.freeTable();
+
+       dbHandle.endTrans(true);
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetContentLocation(MSG_MESSAGE_INFO_S* pMsgInfo)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONTENTS_LOCATION FROM %s WHERE REFERENCE_ID IN \
+                                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                               MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, pMsgInfo->msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW)
+       {
+               if (dbHandle.columnText(0) != NULL)
+               {
+                       strncpy(pMsgInfo->msgData, (char*)dbHandle.columnText(0), MAX_MSG_DATA_LEN);
+                       pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
+               }
+               else
+               {
+                       dbHandle.finalizeQuery();
+                       return MSG_ERR_DB_NORECORD;
+               }
+       }
+       else
+       {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoSetReadReportSendStatus(MSG_MESSAGE_ID_T msgId, int readReportSendStatus)
+{
+       bool bReadReportSent = false;
+
+       if((MmsRecvReadReportSendStatus)readReportSendStatus == MMS_RECEIVE_READ_REPORT_SENT)
+               bReadReportSent = true;
+       else
+               bReadReportSent = false;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET READ_REPORT_SEND_STATUS = %d, READ_REPORT_SENT = %d WHERE REFERENCE_ID IN \
+                                       (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                       MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, (MmsRecvReadReportSendStatus)readReportSendStatus, (int)bReadReportSent,
+                                       MSGFW_MESSAGE_TABLE_NAME, msgId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetOrgAddressList(MSG_MESSAGE_INFO_S *pMsg)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       char sqlQuery[MAX_QUERY_LEN+1];
+       int referenceId = 0;
+       int rowCnt = 0;
+       int index = 3;
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW)
+               referenceId = dbHandle.columnInt(0);
+
+       dbHandle.finalizeQuery();
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ADDRESS_TYPE, RECIPIENT_TYPE, ADDRESS_VAL FROM %s WHERE ADDRESS_ID IN \
+                               (SELECT ADDRESS_ID FROM %s WHERE REFERENCE_ID = %d);",
+                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, referenceId);
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
+       {
+               dbHandle.freeTable();
+               return err;
+       }
+
+       for(int i = 0; i < rowCnt; i++)
+       {
+               pMsg->addressList[i].addressType = dbHandle.getColumnToInt(index++);
+               pMsg->addressList[i].recipientType = dbHandle.getColumnToInt(index++);
+               dbHandle.getColumnToString(index++, MAX_ADDRESS_VAL_LEN, pMsg->addressList[i].addressVal);
+       }
+
+       pMsg->nAddressCnt = rowCnt;
+
+       dbHandle.freeTable();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetSubject(MSG_MESSAGE_ID_T MsgId, char *pSubject)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SUBJECT FROM %s WHERE MSG_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW)
+       {
+               strncpy(pSubject, (char*)dbHandle.columnText(0), MAX_SUBJECT_LEN);
+       }
+       else
+       {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoUpdateNetworkStatus(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_NETWORK_STATUS_T Status)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET NETWORK_STATUS = %d WHERE REFERENCE_ID IN \
+                                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                               MSGFW_MESSAGE_TABLE_NAME, Status,
+                                               MSGFW_MESSAGE_TABLE_NAME, pMsgInfo->msgId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       MSG_END();
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgStoGetRecipientList(MSG_MESSAGE_ID_T msgId, MSG_RECIPIENTS_LIST_S *pRecipientList)
+{
+       if (pRecipientList == NULL)
+       {
+               MSG_DEBUG("pRecipientList is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       int rowCnt = 0, index = 7;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT B.ADDRESS_TYPE, B.RECIPIENT_TYPE, B.ADDRESS_VAL, B.CONTACT_ID, \
+                                       B.DISPLAY_NAME, B.FIRST_NAME, B.LAST_NAME \
+                                       FROM %s A, %s B \
+                                    WHERE A.MSG_ID = %d \
+                                         AND A.ADDRESS_ID = B.ADDRESS_ID;",
+                               MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, msgId);
+
+       if (dbHandle.getTable(sqlQuery, &rowCnt) != MSG_SUCCESS)
+       {
+               dbHandle.freeTable();
+               return MSG_ERR_DB_GETTABLE;
+       }
+
+       pRecipientList->recipientCnt= rowCnt;
+
+       MSG_DEBUG("pRecipientList->recipientCnt [%d]", pRecipientList->recipientCnt);
+
+       pRecipientList->recipientAddr= (MSG_ADDRESS_INFO_S*)new char[sizeof(MSG_ADDRESS_INFO_S)*rowCnt];
+
+       MSG_ADDRESS_INFO_S* pTmp = pRecipientList->recipientAddr;
+
+       char firstName[MAX_THREAD_NAME_LEN+1], lastName[MAX_THREAD_NAME_LEN+1];
+       char displayName[MAX_DISPLAY_NAME_LEN+1];
+
+       int order = MsgGetContactNameOrder();
+
+       for (int i = 0; i < rowCnt; i++)
+       {
+               pTmp->threadId = 0;
+
+               pTmp->addressType = dbHandle.getColumnToInt(index++);
+               pTmp->recipientType= dbHandle.getColumnToInt(index++);
+
+               memset(pTmp->addressVal, 0x00, sizeof(pTmp->addressVal));
+               dbHandle.getColumnToString(index++, MAX_ADDRESS_VAL_LEN, pTmp->addressVal);
+
+               pTmp->contactId= dbHandle.getColumnToInt(index++);
+
+               memset(displayName, 0x00, sizeof(displayName));
+               dbHandle.getColumnToString(index++, MAX_THREAD_NAME_LEN, displayName);
+
+               memset(firstName, 0x00, sizeof(firstName));
+               dbHandle.getColumnToString(index++, MAX_THREAD_NAME_LEN, firstName);
+
+               memset(lastName, 0x00, sizeof(lastName));
+               dbHandle.getColumnToString(index++, MAX_THREAD_NAME_LEN, lastName);
+
+               if (strlen(displayName) <= 0)
+               {
+                       if (order == 0)
+                       {
+                               if (firstName[0] != '\0')
+                               {
+                                       strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
+                               }
+
+                               if (lastName[0] != '\0')
+                               {
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                                       strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       }
+                       else if (order == 1)
+                       {
+                               if (lastName[0] != '\0')
+                               {
+                                       strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+
+                               if (firstName[0] != '\0')
+                               {
+                                       strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       }
+               }
+
+               memset(pTmp->displayName, 0x00, sizeof(pTmp->displayName));
+               strncpy(pTmp->displayName, displayName, MAX_DISPLAY_NAME_LEN);
+
+               pTmp++;
+       }
+
+       dbHandle.freeTable();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetReadStatus(MSG_MESSAGE_ID_T MsgId, bool *pReadStatus)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT READ_STATUS FROM %s WHERE MSG_ID = %d;",
+                                                       MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW)
+       {
+               *pReadStatus = (bool)dbHandle.columnInt(0);
+       }
+       else
+       {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetAddrInfo(MSG_MESSAGE_ID_T MsgId, MSG_ADDRESS_INFO_S *pAddrInfo)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       // Add Address
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.ADDRESS_ID, A.ADDRESS_TYPE, A.RECIPIENT_TYPE, A.CONTACT_ID, A.ADDRESS_VAL \
+                                       FROM %s A, %s B WHERE A.ADDRESS_ID = B.ADDRESS_ID AND B.MSG_ID = %d;",
+                                       MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               pAddrInfo->threadId = dbHandle.columnInt(0);
+               pAddrInfo->addressType = dbHandle.columnInt(1);
+               pAddrInfo->recipientType = dbHandle.columnInt(2);
+               pAddrInfo->contactId = dbHandle.columnInt(3);
+
+               strncpy(pAddrInfo->addressVal, (char*)dbHandle.columnText(4), MAX_ADDRESS_VAL_LEN);
+       } else {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
diff --git a/framework/storage-handler/MsgStorageSim.cpp b/framework/storage-handler/MsgStorageSim.cpp
new file mode 100755 (executable)
index 0000000..c3f114b
--- /dev/null
@@ -0,0 +1,168 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <queue>
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgContact.h"
+#include "MsgUtilStorage.h"
+#include "MsgGconfWrapper.h"
+#include "MsgSqliteWrapper.h"
+#include "MsgPluginManager.h"
+#include "MsgStorageHandler.h"
+
+using namespace std;
+
+
+/*==================================================================================================
+                                     VARIABLES
+==================================================================================================*/
+extern MsgDbHandler dbHandle;
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgInitSimMessage(MSG_SIM_STATUS_T SimStatus)
+{
+       MSG_DEBUG("Start SIM Message Initialization");
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       // Set SIM count of vconf to 0
+       if (MsgSettingSetInt(SIM_USED_COUNT, 0) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
+       }
+
+       if (MsgSettingSetInt(SIM_TOTAL_COUNT, 0) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", SIM_TOTAL_COUNT);
+       }
+
+       if (SimStatus != MSG_SIM_STATUS_NOT_FOUND)
+       {
+               MSG_MAIN_TYPE_T mainType = MSG_SMS_TYPE;
+               MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType);
+
+               if (plg == NULL)
+               {
+                       MSG_DEBUG("No plugin for %d type", mainType);
+                       return MSG_ERR_INVALID_PLUGIN_HANDLE;
+               }
+
+               // Check SIM Status
+               MSG_DEBUG(" ** SIM is available - status : [%d] ** ", SimStatus);
+
+               err = plg->initSimMessage();
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgStoClearSimMessageInDB()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       queue<MSG_THREAD_ID_T> threadList;
+
+       // Get Address ID of SIM Message
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT(B.ADDRESS_ID) \
+                                       FROM %s A, %s B \
+                                    WHERE A.ADDRESS_ID = B.ADDRESS_ID \
+                                         AND A.STORAGE_ID = %d",
+                       MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, MSG_STORAGE_SIM);
+
+       int rowCnt = 0;
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
+       {
+               MSG_DEBUG("sql query is %s.", sqlQuery);
+
+               dbHandle.freeTable();
+               return err;
+       }
+
+       if (rowCnt <= 0)
+       {
+               dbHandle.freeTable();
+               return MSG_SUCCESS;
+       }
+
+       for (int i = 1; i <= rowCnt; i++)
+       {
+               MSG_DEBUG("thread ID : %d", dbHandle.getColumnToInt(i));
+               threadList.push((MSG_THREAD_ID_T)dbHandle.getColumnToInt(i));
+       }
+
+       dbHandle.freeTable();
+
+       const char* tableList[] = {MSGFW_SMS_SENDOPT_TABLE_NAME, MSGFW_SIM_MSG_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME};
+
+       int listCnt = sizeof(tableList)/sizeof(char*);
+
+       dbHandle.beginTrans();
+
+       for (int i = 0; i < listCnt; i++)
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID IN \
+                                                                               (SELECT MSG_ID FROM %s WHERE STORAGE_ID = %d);",
+                                               tableList[i], MSGFW_MESSAGE_TABLE_NAME, MSG_STORAGE_SIM);
+
+               // Delete SIM Message in tables
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+       }
+
+       // Clear Address table
+       if (MsgStoClearAddressTable(&dbHandle) != MSG_SUCCESS)
+       {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       // Update Address
+       while (!threadList.empty())
+       {
+               err = MsgStoUpdateAddress(&dbHandle, threadList.front());
+
+               threadList.pop();
+
+               if (err != MSG_SUCCESS)
+               {
+                       dbHandle.endTrans(false);
+                       return err;
+               }
+       }
+
+       dbHandle.endTrans(true);
+
+       return MSG_SUCCESS;
+}
+
diff --git a/framework/storage-handler/MsgStorageUtil.cpp b/framework/storage-handler/MsgStorageUtil.cpp
new file mode 100755 (executable)
index 0000000..3899308
--- /dev/null
@@ -0,0 +1,384 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgUtilFile.h"
+#include "MsgContact.h"
+#include "MsgSoundPlayer.h"
+#include "MsgGconfWrapper.h"
+#include "MsgSqliteWrapper.h"
+#include "MsgPluginManager.h"
+#include "MsgUtilStorage.h"
+#include "MsgStorageHandler.h"
+
+
+/*==================================================================================================
+                                     VARIABLES
+==================================================================================================*/
+extern MsgDbHandler dbHandle;
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgMakeSortRule(const MSG_SORT_RULE_S *pSortRule, char *pSqlSort)
+{
+       char sql[128];
+       char order[6];
+
+       memset(sql, 0x00, sizeof(sql));
+       memset(order, 0x00, sizeof(order));
+
+       if (pSortRule->bAscending == true)
+               strncpy(order, "ASC", 5);
+       else
+               strncpy(order, "DESC", 5);
+
+       int nameOrder = MsgGetContactNameOrder();
+
+       switch (pSortRule->sortType)
+       {
+               case MSG_SORT_BY_DISPLAY_FROM :
+                       if (nameOrder == 0)
+                               snprintf(sql, sizeof(sql), "ORDER BY B.FIRST_NAME %s, B.LAST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order);
+                       else
+                               snprintf(sql, sizeof(sql), "ORDER BY B.LAST_NAME %s, B.FIRST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order);
+                       break;
+               case MSG_SORT_BY_DISPLAY_TO :
+                       if (nameOrder == 0)
+                               snprintf(sql, sizeof(sql), "ORDER BY B.FIRST_NAME %s, B.LAST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order);
+                       else
+                               snprintf(sql, sizeof(sql), "ORDER BY B.LAST_NAME %s, B.FIRST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order);
+                       break;
+               case MSG_SORT_BY_DISPLAY_TIME :
+                       snprintf(sql, sizeof(sql), "ORDER BY A.DISPLAY_TIME %s;", order);
+                       break;
+               case MSG_SORT_BY_MSG_TYPE :
+                       snprintf(sql, sizeof(sql), "ORDER BY A.MAIN_TYPE %s, A.DISPLAY_TIME DESC;", order);
+                       break;
+               case MSG_SORT_BY_READ_STATUS :
+                       snprintf(sql, sizeof(sql), "ORDER BY A.READ_STATUS %s, A.DISPLAY_TIME DESC;", order);
+                       break;
+               case MSG_SORT_BY_STORAGE_TYPE :
+                       snprintf(sql, sizeof(sql), "ORDER BY A.STORAGE_ID %s, A.DISPLAY_TIME DESC;", order);
+                       break;
+               case MSG_SORT_BY_THREAD_NAME :
+                       if (nameOrder == 0)
+                               snprintf(sql, sizeof(sql), "ORDER BY FIRST_NAME %s, LAST_NAME %s;", order, order);
+                       else
+                               snprintf(sql, sizeof(sql), "ORDER BY LAST_NAME %s, FIRST_NAME %s;", order, order);
+                       break;
+               case MSG_SORT_BY_THREAD_DATE :
+                       snprintf(sql, sizeof(sql), "ORDER BY MSG_TIME %s;", order);
+                       break;
+               case MSG_SORT_BY_THREAD_COUNT :
+                       snprintf(sql, sizeof(sql), "ORDER BY UNREAD_CNT %s;", order);
+                       break;
+               default :
+                       snprintf(sql, sizeof(sql), "ORDER BY A.DISPLAY_TIME %s;", order);
+                       break;
+       }
+
+       memcpy(pSqlSort, sql, strlen(sql));
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetSmsSendOpt(MSG_MESSAGE_ID_T MsgId, MSG_SENDINGOPT_INFO_S* pSendOpt)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DELREP_REQ, KEEP_COPY, REPLY_PATH FROM %s WHERE MSG_ID = %d;",
+                               MSGFW_SMS_SENDOPT_TABLE_NAME, MsgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW)
+       {
+               pSendOpt->bSetting = true;
+               pSendOpt->bDeliverReq = (bool)dbHandle.columnInt(0);
+               pSendOpt->bKeepCopy = (bool)dbHandle.columnInt(1);
+               pSendOpt->option.smsSendOptInfo.bReplyPath = (bool)dbHandle.columnInt(2);
+       }
+       else
+       {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetMmsSendOpt(MSG_MESSAGE_ID_T MsgId, MSG_SENDINGOPT_INFO_S* pSendOpt)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ASK_DELIVERY_REPORT, KEEP_COPY, ASK_READ_REPLY, EXPIRY_TIME, PRIORITY FROM %s WHERE MSG_ID = %d;",
+                               MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, MsgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW)
+       {
+               pSendOpt->bSetting = true;
+               pSendOpt->bDeliverReq = (bool)dbHandle.columnInt(0);
+               pSendOpt->bKeepCopy = (bool)dbHandle.columnInt(1);
+               pSendOpt->option.mmsSendOptInfo.bReadReq = (bool)dbHandle.columnInt(2);
+               pSendOpt->option.mmsSendOptInfo.expiryTime.time = (unsigned int)dbHandle.columnInt(3);
+               pSendOpt->option.mmsSendOptInfo.priority = (MSG_PRIORITY_TYPE_T)dbHandle.columnInt(4);
+       }
+       else
+       {
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoAddScheduledMessage(MSG_MESSAGE_ID_T MsgID, int AlarmId, int ListenerFd)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d);",
+                               MSGFW_SCHEDULED_MSG_TABLE_NAME, MsgID, AlarmId, ListenerFd);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+       {
+               return MSG_ERR_DB_EXEC;
+       }
+
+       if (dbHandle.stepQuery() != MSG_ERR_DB_DONE)
+       {
+               return MSG_ERR_DB_EXEC;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoDeleteScheduledMessage(MSG_MESSAGE_ID_T MsgId)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;",
+                               MSGFW_SCHEDULED_MSG_TABLE_NAME, MsgId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Delete Scheduled Msg Fail!!");
+               return MSG_ERR_DB_EXEC;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetScheduledMessage(int AlarmId, MSG_REQUEST_INFO_S *pReqInfo, int *pListenerFd)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T     err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, LISTENER_FD FROM %s WHERE ALARM_ID = %d;",
+                               MSGFW_SCHEDULED_MSG_TABLE_NAME, AlarmId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW)
+       {
+               pReqInfo->msgInfo.msgId = dbHandle.columnInt(0);
+               *pListenerFd = dbHandle.columnInt(1);
+       }
+
+       dbHandle.finalizeQuery();
+
+       err = MsgStoGetMessage(pReqInfo->msgInfo.msgId, &(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo));
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgStoGetMessage() Error!! [%d]", err);
+               return err;
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+bool MsgStoCheckSyncMLMsgInThread(MSG_THREAD_ID_T threadId)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       int rowCnt = 0;
+       bool isSyncMLMsg = false;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE SUB_TYPE = %d AND ADDRESS_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, MSG_SYNCML_CP, threadId);
+
+       MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (rowCnt > 0) isSyncMLMsg = true;
+
+       MSG_DEBUG("rowCnt [%d]", rowCnt);
+
+       dbHandle.freeTable();
+
+       return isSyncMLMsg;
+}
+
+
+MSG_ERROR_T MsgStoResetNetworkStatus()
+{
+       MSG_BEGIN();
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery),
+               "UPDATE %s SET NETWORK_STATUS = %d WHERE NETWORK_STATUS = %d; UPDATE %s SET NETWORK_STATUS = %d WHERE NETWORK_STATUS = %d;"
+               , MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SEND_FAIL, MSG_NETWORK_SENDING
+               , MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_RETRIEVE_FAIL, MSG_NETWORK_RETRIEVING);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoCleanAbnormalMmsData()
+{
+       MSG_BEGIN();
+
+       int rowCnt = 0, index = 2; // numbers of index
+
+       MSG_MESSAGE_ID_T msgId;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+       char    filePath[MSG_FILEPATH_LEN_MAX];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.MSG_ID, A.FILE_PATH FROM %s A, %s B WHERE A.MSG_ID = B.MSG_ID AND (B.SUB_TYPE = %d OR B.SUB_TYPE = %d OR B.SUB_TYPE = %d);",
+               MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MSG_SENDCONF_MMS, MSG_RETRIEVE_AUTOCONF_MMS, MSG_RETRIEVE_MANUALCONF_MMS);
+
+       MSG_ERROR_T  err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err == MSG_ERR_DB_NORECORD)
+       {
+               dbHandle.freeTable();
+
+               return MSG_SUCCESS;
+       }
+       else if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("%s", sqlQuery);
+
+               dbHandle.freeTable();
+
+               return err;
+       }
+
+
+       for (int i = 0; i < rowCnt; i++)
+       {
+               memset(filePath, 0x00, sizeof(filePath));
+
+               msgId = dbHandle.getColumnToInt(index++);
+
+               dbHandle.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, filePath);
+
+               if(strlen(filePath) > 1)
+               {
+                       MSG_DEBUG("strlen(filePath) [%d]", strlen(filePath));
+                       MSG_DEBUG("filePath [%s]", filePath);
+                       if(MsgGetFileSize(filePath) < 0)
+                       {
+                               // abnormal mms message
+                               MSG_DEBUG("abnormal mms message [%d]", msgId);
+
+                               // delete mms message
+                               MsgStoDeleteMessage(msgId, false);
+                       }
+               }
+
+       }
+       dbHandle.freeTable();
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T MsgStoCheckReadReportStatus(MSG_MESSAGE_ID_T msgId)
+{
+       MSG_BEGIN();
+
+       bool    bReadReportRequested;
+       bool    bReadReportIsSent;
+
+       bReadReportRequested = MsgStoCheckReadReportRequested(&dbHandle, msgId);
+       if(bReadReportRequested == false)
+               return MSG_ERR_READREPORT_NOT_REQUESTED;
+
+       bReadReportIsSent = MsgStoCheckReadReportIsSent(&dbHandle, msgId);
+       if(bReadReportIsSent == true)
+               return MSG_ERR_READREPORT_ALEADY_SENT;
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
diff --git a/framework/submit-handler/MsgSubmitHandler.cpp b/framework/submit-handler/MsgSubmitHandler.cpp
new file mode 100755 (executable)
index 0000000..2c45925
--- /dev/null
@@ -0,0 +1,449 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "MsgPluginManager.h"
+#include "MsgStorageHandler.h"
+#include "MsgSubmitHandler.h"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgSubmitReq(MSG_REQUEST_INFO_S *pReqInfo, bool bScheduled)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       static int reqId = 1;
+
+       pReqInfo->reqId = reqId;
+       reqId++;
+
+       MSG_DEBUG("==== Msg ID = [%d] ====", pReqInfo->msgInfo.msgId);
+       MSG_DEBUG("==== Folder ID = [%d] ====", pReqInfo->msgInfo.folderId);
+       MSG_DEBUG("==== Main Type = [%d] ====", pReqInfo->msgInfo.msgType.mainType);
+       MSG_DEBUG("==== Sub Type = [%d] ====", pReqInfo->msgInfo.msgType.subType);
+       MSG_DEBUG("==== Class Type = [%d] ====", pReqInfo->msgInfo.msgType.classType);
+       MSG_DEBUG("==== Message Data = [%s] ====", pReqInfo->msgInfo.msgData);
+       MSG_DEBUG("==== Message Text = [%s] ====", pReqInfo->msgInfo.msgText);
+
+       MSG_DEBUG("==== bSetting = [%d] ====", pReqInfo->sendOptInfo.bSetting);
+
+       if (pReqInfo->msgInfo.msgType.mainType == MSG_SMS_TYPE)
+       {
+               MSG_DEBUG("==== deliver = [%d] ====", pReqInfo->sendOptInfo.bDeliverReq);
+               MSG_DEBUG("==== keepcopy = [%d] ====", pReqInfo->sendOptInfo.bKeepCopy);
+               MSG_DEBUG("==== bReplyPath = [%d] ====", pReqInfo->sendOptInfo.option.smsSendOptInfo.bReplyPath);
+
+               err = MsgSubmitReqSMS(pReqInfo);
+       }
+       else if (pReqInfo->msgInfo.msgType.mainType == MSG_MMS_TYPE)
+       {
+               MSG_DEBUG("==== deliver = [%d] ====", pReqInfo->sendOptInfo.bDeliverReq);
+               MSG_DEBUG("==== keepcopy = [%d] ====", pReqInfo->sendOptInfo.bKeepCopy);
+               MSG_DEBUG("==== bReadReq = [%d] ====", pReqInfo->sendOptInfo.option.mmsSendOptInfo.bReadReq);
+               MSG_DEBUG("==== priority = [%d] ====", pReqInfo->sendOptInfo.option.mmsSendOptInfo.priority);
+               MSG_DEBUG("==== expiryTime = [%d] ====", pReqInfo->sendOptInfo.option.mmsSendOptInfo.expiryTime.time);
+
+               err = MsgSubmitReqMMS(pReqInfo, bScheduled);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgSubmitReqSMS(MSG_REQUEST_INFO_S *pReqInfo)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       // submit request based on msgType;
+       MSG_MAIN_TYPE_T mainType = pReqInfo->msgInfo.msgType.mainType;
+       MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType);
+
+       if (plg == NULL)
+       {
+               THROW(MsgException::PLUGIN_ERROR, "No plugin for %d type", mainType);
+       }
+
+       MSG_REQUEST_INFO_S tmpInfo = {};
+
+       bool bReqSentStatus = false;
+
+       for (int i = 0; i < pReqInfo->msgInfo.nAddressCnt; i++)
+       {
+               MsgCopyReqInfo(pReqInfo, i, &tmpInfo);
+
+               // If MSG ID > 0 -> MSG in DRAFT
+               // Move Folder to OUTBOX
+               if (pReqInfo->msgInfo.msgPort.valid == false)
+               {
+                       pReqInfo->msgInfo.folderId = MSG_OUTBOX_ID;
+
+                       if (pReqInfo->msgInfo.msgId > 0 && (pReqInfo->msgInfo.folderId == MSG_DRAFT_ID || pReqInfo->msgInfo.folderId == MSG_OUTBOX_ID))
+                       {
+                               err = MsgStoUpdateMessage(&(tmpInfo.msgInfo), &(tmpInfo.sendOptInfo));
+                       }
+
+                       if (err != MSG_SUCCESS)
+                       {
+                               MSG_DEBUG("MsgStoUpdateMessage() Fail");
+                               continue;
+                       }
+               }
+
+               if (i == (pReqInfo->msgInfo.nAddressCnt -1))
+               {
+                       // Request Sent Status Callback
+                       bReqSentStatus = true;
+               }
+
+               err = plg->submitReq(&tmpInfo, bReqSentStatus);
+
+               if (err != MSG_SUCCESS)
+               {
+                       break;
+               }
+
+               if (i == (pReqInfo->msgInfo.nAddressCnt -1))
+               {
+                       // Copy MSG ID
+                       pReqInfo->msgInfo.msgId = tmpInfo.msgInfo.msgId;
+               }
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo, bool bScheduled)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_RECIPIENTS_LIST_S pRecipientList;
+
+       MSG_MAIN_TYPE_T msgMainType = pReqInfo->msgInfo.msgType.mainType;
+       MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(msgMainType);
+
+       if(!plg)
+       {
+               MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+               MSG_DEBUG("No Plugin for %d type", msgMainType);
+
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+       }
+
+       //      If MSG ID > 0 -> MSG in DRAFT
+       // Move Folder to OUTBOX
+       /* reject_msg_support */
+       if(!bScheduled)
+       {
+               if(pReqInfo->msgInfo.msgType.subType == MSG_SENDREQ_JAVA_MMS)
+               {
+                       char fileName[MAX_COMMON_INFO_SIZE+1] = {0};
+
+                       // copy whole of MMS PDU filepath to msgData
+                       strncpy(fileName, pReqInfo->msgInfo.msgData, MAX_COMMON_INFO_SIZE);
+                       memset(pReqInfo->msgInfo.msgData, 0x00, MAX_MSG_DATA_LEN+1);
+                       snprintf(pReqInfo->msgInfo.msgData, MAX_MSG_DATA_LEN+1, MSG_IPC_DATA_PATH"%s", fileName);
+
+                       MSG_DEBUG("JAVA MMS PDU filepath:%s", pReqInfo->msgInfo.msgData);
+
+                       // submit request
+                       plg->submitReq(pReqInfo, false);
+
+                       if(err != MSG_SUCCESS)
+                       {
+                               MSG_DEBUG("Update Network Status : [%d]", err);
+                               MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo),MSG_NETWORK_SEND_FAIL);
+                       }
+
+                       return err;
+               }
+               else if((pReqInfo->msgInfo.msgType.subType == MSG_SENDREQ_MMS) || (pReqInfo->msgInfo.msgType.subType == MSG_FORWARD_MMS))
+               {
+                       // update address list in the ase of existing message
+                       if(pReqInfo->msgInfo.msgId > 0)
+                       {
+                               err = MsgStoGetOrgAddressList(&(pReqInfo->msgInfo));
+
+                               if(err != MSG_SUCCESS)
+                                       MSG_DEBUG("[WARNING]MsgStoGetOrgAddressList returned not a MSG_SUCCESS");
+                       }
+
+                       if(pReqInfo->msgInfo.msgId > 0 && (pReqInfo->msgInfo.folderId == MSG_DRAFT_ID || pReqInfo->msgInfo.folderId == MSG_OUTBOX_ID)) {
+                               MSG_ADDRESS_INFO_S addrInfo = {0,};
+                               int addrIdx = 0;
+
+                               err = MsgStoGetAddrInfo(pReqInfo->msgInfo.msgId, &addrInfo);
+
+                               if (err == MSG_SUCCESS) {
+                                       for (int i = 0; i < pReqInfo->msgInfo.nAddressCnt; i++) {
+                                               //if (pReqInfo->msgInfo.addressList[i].threadId == addrInfo.threadId) {
+                                               if (!strcmp(pReqInfo->msgInfo.addressList[i].addressVal, addrInfo.addressVal)) {
+                                                       addrIdx = i;
+                                                       MSG_DEBUG("addrIdx = %d, address = [%s]", addrIdx, pReqInfo->msgInfo.addressList[i].addressVal);
+                                                       break;
+                                               }
+                                       }
+                               } else {
+                                       MSG_DEBUG("[Error]MsgStoGetAddrInfo is failed");
+                               }
+
+                               pReqInfo->msgInfo.folderId = MSG_OUTBOX_ID;
+                               err = MsgStoUpdateMessage(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo), addrIdx);
+
+                               MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo), pReqInfo->msgInfo.networkStatus);
+                       } else {
+                               //new message case
+                               MSG_DEBUG("New Message");
+                               for(int i = 0; i < pReqInfo->msgInfo.nAddressCnt; i++) {
+                                       pReqInfo->msgInfo.folderId = MSG_OUTBOX_ID;
+                                       err = MsgStoAddMessage(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo), i);
+                                       //pReqInfo->msgInfo.msgId = 0;
+                               }
+
+                               if (pReqInfo->msgInfo.msgId != pReqInfo->msgInfo.referenceId) {
+                                       MSG_DEBUG("Add Multi-recipient Message");
+                                       //multi-recipient mms case
+                                       pReqInfo->msgInfo.msgId = pReqInfo->msgInfo.referenceId;
+                               }
+                       }
+               //      pReqInfo->msgInfo.msgId = pReqInfo->msgInfo.referenceId;
+               }
+               else if(pReqInfo->msgInfo.msgType.subType == MSG_READREPLY_MMS)
+               {
+                       err = MsgStoCheckReadReportStatus(pReqInfo->msgInfo.msgId);
+                       if(err != MSG_SUCCESS)
+                               return err;
+
+                       err = MsgStoGetRecipientList(pReqInfo->msgInfo.msgId, &pRecipientList);
+                       if(err != MSG_SUCCESS)
+                               return MSG_ERR_PLUGIN_STORAGE;
+
+                       pReqInfo->msgInfo.nAddressCnt = pRecipientList.recipientCnt;
+
+                       for(int i = 0; i < pRecipientList.recipientCnt; i++)
+                       {
+                               pReqInfo->msgInfo.addressList[i].addressType = pRecipientList.recipientAddr[i].addressType;
+                               pReqInfo->msgInfo.addressList[i].recipientType = MSG_RECIPIENTS_TYPE_TO;
+                               pReqInfo->msgInfo.addressList[i].contactId = pRecipientList.recipientAddr[i].contactId;
+                               strncpy(pReqInfo->msgInfo.addressList[i].addressVal, pRecipientList.recipientAddr[i].addressVal, MAX_ADDRESS_VAL_LEN);
+                       }
+
+                       char subject[MAX_SUBJECT_LEN+1];
+
+                       err = MsgStoGetSubject(pReqInfo->msgInfo.msgId, subject);
+                       if(err != MSG_SUCCESS)
+                               MSG_DEBUG("Getting subject returned not a MSG_SUCCESS");
+
+                       strncpy(pReqInfo->msgInfo.subject, subject, MAX_SUBJECT_LEN);
+
+                       err = plg->composeReadReport(&(pReqInfo->msgInfo));
+               }
+               else if(pReqInfo->msgInfo.msgType.subType == MSG_RETRIEVE_MMS)
+               {
+                       MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo), pReqInfo->msgInfo.networkStatus);
+               }
+       }
+
+       /* reject_msg_support */
+
+       if(err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Fail to Add/Update Message : MsgStoMoveMessageToFolder()/MsgStoAddMessage()");
+               return err;
+       }
+
+       switch(pReqInfo->msgInfo.msgType.subType)
+       {
+               case MSG_SENDREQ_MMS:
+               case MSG_FORWARD_MMS:
+                       MsgDeleteFile(pReqInfo->msgInfo.msgData);
+                       memset(pReqInfo->msgInfo.msgData, 0x00, MAX_MSG_DATA_LEN+1);
+                       snprintf(pReqInfo->msgInfo.msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pReqInfo->msgInfo.referenceId);
+                       break;
+
+               case MSG_READREPLY_MMS:
+               case MSG_READRECIND_MMS:
+                       memset(pReqInfo->msgInfo.msgData, 0x00, MAX_MSG_DATA_LEN+1);
+                       snprintf(pReqInfo->msgInfo.msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pReqInfo->msgInfo.msgId);
+                       break;
+               default:
+                       break;
+       }
+
+       // update content location from db
+       if(pReqInfo->msgInfo.msgType.subType == MSG_RETRIEVE_MMS)
+               err = MsgStoGetContentLocation(&(pReqInfo->msgInfo));
+       /* reject_msg_support */
+       else if(pReqInfo->msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS)
+               err = plg->updateRejectStatus(&(pReqInfo->msgInfo));
+       /* reject_msg_support */
+
+       // Check SIM is present or not
+       MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(MSG_SIM_CHANGED);
+
+       if(simStatus == MSG_SIM_STATUS_NOT_FOUND)
+       {
+               MSG_DEBUG("SIM is not present...");
+               MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+
+               return MSG_ERR_NO_SIM;
+       }
+
+       if(err == MSG_SUCCESS)
+               err = plg->submitReq(pReqInfo, false);
+
+       if(err == MSG_SUCCESS && ( pReqInfo->msgInfo.msgType.subType == MSG_READREPLY_MMS || pReqInfo->msgInfo.msgType.subType == MSG_READRECIND_MMS ))
+               MsgStoSetReadReportSendStatus(pReqInfo->msgInfo.msgId, MMS_RECEIVE_READ_REPORT_SENT);
+
+       if (err != MSG_SUCCESS)
+       {
+               if(pReqInfo->msgInfo.msgType.subType == MSG_RETRIEVE_MMS )
+                       MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo), MSG_NETWORK_RETRIEVE_FAIL);
+               else
+                       MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+       }
+
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgCancelReq(MSG_REQUEST_ID_T reqId)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgUpdateSentMsg(MSG_MESSAGE_ID_T MsgId, MSG_NETWORK_STATUS_T Status)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       bool bKeepCopy = true;
+
+       // Move Msg to SENTBOX
+       if (Status == MSG_NETWORK_SEND_SUCCESS)
+       {
+               MSG_DEBUG(" In Status == MSG_NETWORK_SEND_SUCCESS and  bKeepCopy is [%d]", bKeepCopy);
+               if (bKeepCopy == true)
+                       err = MsgStoMoveMessageToFolder(MsgId, MSG_SENTBOX_ID);
+               else
+                       err = MsgStoDeleteMessage(MsgId, false);
+       }
+
+       return err;
+}
+
+
+void MsgCopyReqInfo(MSG_REQUEST_INFO_S *pSrc, int addrIdx, MSG_REQUEST_INFO_S *pDest)
+{
+       MSG_BEGIN();
+
+       memset(pDest, 0x00, sizeof(pDest));
+
+       // Copy Request ID
+       pDest->reqId = pSrc->reqId;
+
+       // Copy Msg Info
+       pDest->msgInfo.msgId = pSrc->msgInfo.msgId;
+       pDest->msgInfo.folderId = pSrc->msgInfo.folderId;
+
+       pDest->msgInfo.referenceId = pSrc->msgInfo.referenceId;
+
+       pDest->msgInfo.msgType.mainType = pSrc->msgInfo.msgType.mainType;
+       pDest->msgInfo.msgType.subType = pSrc->msgInfo.msgType.subType;
+       pDest->msgInfo.msgType.classType = pSrc->msgInfo.msgType.classType;
+
+       pDest->msgInfo.storageId = pSrc->msgInfo.storageId;
+
+       pDest->msgInfo.nAddressCnt = 1;
+
+       pDest->msgInfo.addressList[0].threadId = pSrc->msgInfo.addressList[addrIdx].threadId;
+       pDest->msgInfo.addressList[0].addressType = pSrc->msgInfo.addressList[addrIdx].addressType;
+       pDest->msgInfo.addressList[0].recipientType = pSrc->msgInfo.addressList[addrIdx].recipientType;
+       pDest->msgInfo.addressList[0].contactId = pSrc->msgInfo.addressList[addrIdx].contactId;
+       strncpy(pDest->msgInfo.addressList[0].addressVal, pSrc->msgInfo.addressList[addrIdx].addressVal, MAX_ADDRESS_VAL_LEN);
+       strncpy(pDest->msgInfo.addressList[0].displayName, pSrc->msgInfo.addressList[addrIdx].displayName, MAX_DISPLAY_NAME_LEN);
+
+       strncpy(pDest->msgInfo.replyAddress, pSrc->msgInfo.replyAddress, MAX_PHONE_NUMBER_LEN);
+       strncpy(pDest->msgInfo.subject, pSrc->msgInfo.subject, MAX_SUBJECT_LEN);
+
+       pDest->msgInfo.scheduledTime = pSrc->msgInfo.scheduledTime;
+       pDest->msgInfo.displayTime = pSrc->msgInfo.displayTime;
+       pDest->msgInfo.networkStatus = pSrc->msgInfo.networkStatus;
+       pDest->msgInfo.encodeType = pSrc->msgInfo.encodeType;
+       pDest->msgInfo.bRead = pSrc->msgInfo.bRead;
+       pDest->msgInfo.bProtected = pSrc->msgInfo.bProtected;
+       pDest->msgInfo.priority = pSrc->msgInfo.priority;
+       pDest->msgInfo.direction = pSrc->msgInfo.direction;
+
+       pDest->msgInfo.msgPort.valid = pSrc->msgInfo.msgPort.valid;
+
+       if (pDest->msgInfo.msgPort.valid == true)
+       {
+               pDest->msgInfo.msgPort.dstPort = pSrc->msgInfo.msgPort.dstPort;
+               pDest->msgInfo.msgPort.srcPort = pSrc->msgInfo.msgPort.srcPort;
+       }
+
+       pDest->msgInfo.bTextSms = pSrc->msgInfo.bTextSms;
+       pDest->msgInfo.dataSize = pSrc->msgInfo.dataSize;
+
+       strncpy(pDest->msgInfo.msgData, pSrc->msgInfo.msgData, MAX_MSG_DATA_LEN);
+
+       if (pDest->msgInfo.bTextSms == true)
+       {
+               memcpy(pDest->msgInfo.msgText, pSrc->msgInfo.msgText, pDest->msgInfo.dataSize);
+               pDest->msgInfo.msgText[pDest->msgInfo.dataSize] = '\0';
+       }
+
+       // Set Sending Info
+       pDest->sendOptInfo.bSetting = pSrc->sendOptInfo.bSetting;
+
+       if (pDest->sendOptInfo.bSetting == true)
+       {
+               pDest->sendOptInfo.bDeliverReq = pSrc->sendOptInfo.bDeliverReq;
+               pDest->sendOptInfo.bKeepCopy = pSrc->sendOptInfo.bKeepCopy;
+
+               if (pDest->msgInfo.msgType.mainType == MSG_SMS_TYPE)
+               {
+                       pDest->sendOptInfo.option.smsSendOptInfo.bReplyPath = pSrc->sendOptInfo.option.smsSendOptInfo.bReplyPath;
+               }
+               else if (pDest->msgInfo.msgType.mainType == MSG_MMS_TYPE)
+               {
+                       pDest->sendOptInfo.option.mmsSendOptInfo.priority = pSrc->sendOptInfo.option.mmsSendOptInfo.priority;
+                       pDest->sendOptInfo.option.mmsSendOptInfo.bReadReq = pSrc->sendOptInfo.option.mmsSendOptInfo.bReadReq;
+
+                       pDest->sendOptInfo.option.mmsSendOptInfo.expiryTime.type = pSrc->sendOptInfo.option.mmsSendOptInfo.expiryTime.type;
+                       pDest->sendOptInfo.option.mmsSendOptInfo.expiryTime.time = pSrc->sendOptInfo.option.mmsSendOptInfo.expiryTime.time;
+
+                       pDest->sendOptInfo.option.mmsSendOptInfo.bUseDeliveryCustomTime = pSrc->sendOptInfo.option.mmsSendOptInfo.bUseDeliveryCustomTime;
+                       pDest->sendOptInfo.option.mmsSendOptInfo.deliveryTime.type = pSrc->sendOptInfo.option.mmsSendOptInfo.deliveryTime.type;
+                       pDest->sendOptInfo.option.mmsSendOptInfo.deliveryTime.time = pSrc->sendOptInfo.option.mmsSendOptInfo.deliveryTime.time;
+               }
+       }
+
+       MSG_END();
+}
+
diff --git a/framework/transaction-manager/MsgCmdHandlerSetting.cpp b/framework/transaction-manager/MsgCmdHandlerSetting.cpp
new file mode 100755 (executable)
index 0000000..bec9b09
--- /dev/null
@@ -0,0 +1,91 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgCmdHandler.h"
+#include "MsgSettingHandler.h"
+#include "MsgUtilFunction.h"
+#include "MsgCppTypes.h"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+int MsgSetConfigHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       // Get Setting Structure
+       MSG_SETTING_S* pSetting = (MSG_SETTING_S*)pCmd->cmdData;
+
+       // Set Config Data
+       err = MsgSetConfigData(pSetting);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgSetConfigData()");
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgSetConfigData()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SET_CONFIG, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgGetConfigHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Option Type
+       MSG_OPTION_TYPE_T* type = (MSG_OPTION_TYPE_T*)pCmd->cmdData;
+
+       // Get Config Data
+       MSG_SETTING_S setting;
+       setting.type = *type;
+
+       err = MsgGetConfigData(&setting);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgGetConfigData()");
+
+               // Encoding Config Data
+               dataSize = MsgEncodeSetting(&setting, &encodedData);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgGetConfigData()");
+       }
+
+       MSG_DEBUG("dataSize [%d]", dataSize);
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_CONFIG, err, (void**)ppEvent);
+
+       return eventSize;
+}
diff --git a/framework/transaction-manager/MsgCmdHandlerStorage.cpp b/framework/transaction-manager/MsgCmdHandlerStorage.cpp
new file mode 100755 (executable)
index 0000000..f136b8d
--- /dev/null
@@ -0,0 +1,1066 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdlib.h>
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgException.h"
+#include "MsgCppTypes.h"
+#include "MsgUtilFunction.h"
+#include "MsgStorageHandler.h"
+#include "MsgPluginManager.h"
+#include "MsgTransManager.h"
+#include "MsgCmdHandler.h"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+int MsgAddMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Message Info
+       MSG_MESSAGE_INFO_S* pMsgInfo = (MSG_MESSAGE_INFO_S*)pCmd->cmdData;
+
+       // Get Sending Option
+       MSG_SENDINGOPT_INFO_S* pSendOptInfo = (MSG_SENDINGOPT_INFO_S*)(pCmd->cmdData + sizeof(MSG_MESSAGE_INFO_S));
+
+       // Add Message with address
+       for (int i = 0; i < pMsgInfo->nAddressCnt; i++)
+       {
+               err = MsgStoAddMessage(pMsgInfo, pSendOptInfo, i);
+
+               if (err == MSG_SUCCESS)
+               {
+                       MSG_DEBUG("Command Handle Success : MsgStoAddMessage()");
+
+                       // Get First Msg Id
+                       if (i == 0)
+                       {
+                               // Encoding Message ID
+                               dataSize = MsgEncodeMsgId(&(pMsgInfo->msgId), &encodedData);
+                       }
+               }
+               else
+               {
+                       MSG_DEBUG("Command Handle Fail : MsgStoAddMessage()");
+               }
+       }
+
+       // Add Message without address
+       if (pMsgInfo->nAddressCnt == 0)
+       {
+               err = MsgStoAddMessage(pMsgInfo, pSendOptInfo);
+
+               if (err == MSG_SUCCESS)
+               {
+                       MSG_DEBUG("Command Handle Success : MsgStoAddMessage()");
+
+                       // Encoding Message ID
+                       dataSize = MsgEncodeMsgId(&(pMsgInfo->msgId), &encodedData);
+               }
+               else
+               {
+                       MSG_DEBUG("Command Handle Fail : MsgStoAddMessage()");
+               }
+       }
+
+       // Delete Temp File for Message Data
+       if (pMsgInfo->bTextSms == false)
+               MsgDeleteFile(pMsgInfo->msgData); //ipc
+
+       //storage change CB
+       MSG_MSGID_LIST_S msgIdList;
+       MSG_MESSAGE_ID_T msgIds[1];
+       memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+       msgIdList.nCount = 1;
+       msgIds[0] = pMsgInfo->msgId;
+       msgIdList.msgIdList = msgIds;
+
+       MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_ADD_MSG, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgAddSyncMLMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       int extId = 0, pinCode = 0;
+
+       MSG_MESSAGE_INFO_S msgInfo = {};
+
+       memcpy(&extId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
+       memcpy(&pinCode, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), sizeof(int));
+       memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+sizeof(int)), sizeof(MSG_MESSAGE_INFO_S));
+
+       // Add Message
+       err = MsgStoAddSyncMLMessage(&msgInfo, extId, pinCode);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoAddSyncMLMessage()");
+
+               // broadcast to listener threads, here
+               MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo);
+               //storage change CB
+               MSG_MSGID_LIST_S msgIdList;
+               MSG_MESSAGE_ID_T msgIds[1];
+               memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+               msgIdList.nCount = 1;
+               msgIds[0] = msgInfo.msgId;
+               msgIdList.msgIdList = msgIds;
+
+               MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoAddSyncMLMessage()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_ADD_SYNCML_MSG, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgUpdateMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       // Get Message Info
+       MSG_MESSAGE_INFO_S* pMsgInfo = (MSG_MESSAGE_INFO_S*)pCmd->cmdData;
+
+       // Get Sending Option
+       MSG_SENDINGOPT_INFO_S* pSendOptInfo = (MSG_SENDINGOPT_INFO_S*)(pCmd->cmdData + sizeof(MSG_MESSAGE_INFO_S));
+
+       // Update Message
+       err = MsgStoUpdateMessage(pMsgInfo, pSendOptInfo);
+
+       if (err == MSG_SUCCESS)
+               MSG_DEBUG("Command Handle Success : MsgStoUpdateMessage()");
+       else
+               MSG_DEBUG("Command Handle Fail : MsgStoUpdateMessage()");
+
+       // Delete Temp File for Message Data
+       if (pMsgInfo->bTextSms == false)
+               MsgDeleteFile(pMsgInfo->msgData); //ipc
+
+       //storage change CB
+       MSG_MSGID_LIST_S msgIdList;
+       MSG_MESSAGE_ID_T msgIds[1];
+       memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+       msgIdList.nCount = 1;
+       msgIds[0] = pMsgInfo->msgId;
+       msgIdList.msgIdList = msgIds;
+
+       MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_MSG, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgUpdateReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       MSG_MESSAGE_ID_T msgId;
+       bool readStatus;
+
+       memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_ID_T));
+       memcpy(&readStatus, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), sizeof(bool));
+
+       // Update Read Status
+       err = MsgStoUpdateReadStatus(msgId, readStatus);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoUpdateReadStatus()");
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoUpdateReadStatus()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_READ, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgUpdateThreadReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       MSG_THREAD_ID_T threadId;
+       int unReadCnt = 0;
+
+       memcpy(&threadId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_THREAD_ID_T));
+
+       MsgStoGetThreadUnreadCnt(threadId, &unReadCnt);
+
+       MSG_DEBUG("unReadCnt [%d]", unReadCnt);
+
+       if (unReadCnt > 0) {
+
+               err = MsgStoUpdateThreadReadStatus(threadId);
+
+               if (err == MSG_SUCCESS)
+                       MSG_DEBUG("Command Handle Success : MsgStoUpdateThreadReadStatus()");
+               else
+                       MSG_DEBUG("Command Handle Fail : MsgStoUpdateThreadReadStatus()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_THREAD_READ, err, (void**)ppEvent);
+
+       return eventSize;
+
+}
+
+
+int MsgUpdateProtectedStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       MSG_MESSAGE_ID_T msgId;
+       bool protectedStatus;
+
+       memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_ID_T));
+       memcpy(&protectedStatus, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), sizeof(bool));
+
+       // Update Protected Status
+       err = MsgStoUpdateProtectedStatus(msgId, protectedStatus);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoUpdateProtectedStatus()");
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoUpdateProtectedStatus()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_PROTECTED, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgDeleteMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       int extId = 0;
+
+       MSG_MESSAGE_ID_T* msgId = (MSG_MESSAGE_ID_T*)pCmd->cmdData;
+
+       MsgStoGetSyncMLExtId(*msgId, &extId);
+
+       // Delete Message
+       err = MsgStoDeleteMessage(*msgId, true);
+
+       if (err == MSG_SUCCESS) {
+               MSG_DEBUG("Command Handle Success : MsgStoDeleteMessage()");
+
+               if(extId > 0) {
+                       // broadcast to listener threads, here
+                       MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, -1, extId);
+               }
+
+               MSG_MSGID_LIST_S msgIdList;
+               MSG_MESSAGE_ID_T msgIds[1];
+               memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+               msgIdList.nCount = 1;
+               msgIds[0] = *msgId;
+               msgIdList.msgIdList = msgIds;
+
+               MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
+       } else {
+               MSG_DEBUG("Command Handle Fail : MsgStoDeleteMessage()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_MSG, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgDeleteAllMessageInFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       MSG_FOLDER_ID_T* folderId = (MSG_FOLDER_ID_T*)pCmd->cmdData;
+
+       bool bOnlyDB;
+       memcpy(&bOnlyDB, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_FOLDER_ID_T)), sizeof(bool));
+
+
+       MSG_MSGID_LIST_S msgIdList;
+       memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+       // Delete Message
+       err = MsgStoDeleteAllMessageInFolder(*folderId, bOnlyDB, &msgIdList);
+
+       if (err == MSG_SUCCESS) {
+               MSG_DEBUG("Command Handle Success : MsgStoDeleteAllMessageInFolder()");
+               MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
+               if(msgIdList.msgIdList != NULL)
+                       delete [] (char*)msgIdList.msgIdList;
+       } else {
+               MSG_DEBUG("Command Handle Fail : MsgStoDeleteAllMessageInFolder()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELALL_MSGINFOLDER, err, (void**)ppEvent);
+
+       return eventSize;
+
+}
+
+
+int MsgMoveMessageToFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       MSG_MESSAGE_ID_T msgId;
+       MSG_FOLDER_ID_T folderId;
+
+       memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_ID_T));
+       memcpy(&folderId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), sizeof(MSG_FOLDER_ID_T));
+
+       // Move Message
+       err = MsgStoMoveMessageToFolder(msgId, folderId);
+
+       if (err == MSG_SUCCESS) {
+               MSG_DEBUG("Command Handle Success : MsgStoMoveMessageToFolder()");
+
+               MSG_MSGID_LIST_S msgIdList;
+               MSG_MESSAGE_ID_T msgIds[1];
+               memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+               msgIdList.nCount = 1;
+               msgIds[0] = msgId;
+               msgIdList.msgIdList = msgIds;
+
+               MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
+       } else {
+               MSG_DEBUG("Command Handle Fail : MsgStoMoveMessageToFolder()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_MOVE_MSGTOFOLDER, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgMoveMessageToStorageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       MSG_MESSAGE_ID_T msgId;
+       MSG_STORAGE_ID_T storageId;
+
+       memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_ID_T));
+       memcpy(&storageId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), sizeof(MSG_STORAGE_ID_T));
+
+       // Move Message
+       err = MsgStoMoveMessageToStorage(msgId, storageId);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoMoveMessageToStorage()");
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoMoveMessageToStorage()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_MOVE_MSGTOSTORAGE, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgCountMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Folder ID
+       MSG_FOLDER_ID_T* folderId = (MSG_FOLDER_ID_T*)pCmd->cmdData;
+
+       // Get Message Count
+       MSG_COUNT_INFO_S countInfo;
+
+       err = MsgStoCountMessage(*folderId, &countInfo);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoCountMessage()");
+
+               // Encoding Messaging Count Data
+               dataSize = MsgEncodeCountInfo(&countInfo, &encodedData);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoCountMessage()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_COUNT_MSG, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgCountMsgByTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Folder ID
+       MSG_MESSAGE_TYPE_S* pMsgType = (MSG_MESSAGE_TYPE_S*)pCmd->cmdData;
+
+       int nMsgCnt = 0;
+
+       // Get Message Count
+       err = MsgStoCountMsgByType(pMsgType, &nMsgCnt);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoCountMsgByType()");
+
+               // Encoding Messaging Count Data
+               dataSize = MsgEncodeCountByMsgType(nMsgCnt, &encodedData);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoCountMsgByType()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_COUNT_BY_MSGTYPE, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgGetMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       // Get Message ID
+       MSG_MESSAGE_ID_T* msgId = (MSG_MESSAGE_ID_T*)pCmd->cmdData;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Message
+       MSG_MESSAGE_INFO_S msgInfo;
+       MSG_SENDINGOPT_INFO_S sendOptInfo;
+
+       memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+       memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S));
+
+       err = MsgStoGetMessage(*msgId, &msgInfo, &sendOptInfo);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoGetMessage()");
+
+               // Encoding Message Info  Data
+               dataSize = MsgEncodeMsgInfo(&msgInfo, &sendOptInfo, &encodedData);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoGetMessage()");
+       }
+
+//     MsgSoundPlayStop();
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_MSG, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgGetFolderViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       // Get Folder ID
+       MSG_FOLDER_ID_T folderId;
+       MSG_SORT_RULE_S sortRule;
+
+       memcpy(&folderId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_FOLDER_ID_T));
+       memcpy(&sortRule, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_FOLDER_ID_T)), sizeof(MSG_SORT_RULE_S));
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Message Common Info
+       MSG_LIST_S folderViewList;
+
+       err = MsgStoGetFolderViewList(folderId, &sortRule, &folderViewList);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoGetFolderViewList()");
+
+               // Encoding Folder View List Data
+               dataSize = MsgEncodeFolderViewList(&folderViewList, &encodedData);
+
+               MSG_DEBUG("dataSize [%d]", dataSize);
+
+               if (folderViewList.msgInfo != NULL)
+               {
+                       delete [] folderViewList.msgInfo;
+                       folderViewList.msgInfo = NULL;
+               }
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoGetFolderViewList()");
+               return err;
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_FOLDERVIEWLIST, MSG_SUCCESS, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgAddFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       // Get Folder Info
+       MSG_FOLDER_INFO_S* pFolderInfo = (MSG_FOLDER_INFO_S*)pCmd->cmdData;
+
+       // Add Folder
+       err = MsgStoAddFolder(pFolderInfo);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoAddFolder()");
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoAddFolder()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_ADD_FOLDER, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgUpdateFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       // Get Folder Info
+       MSG_FOLDER_INFO_S* pFolderInfo = (MSG_FOLDER_INFO_S*)pCmd->cmdData;
+
+       // Update Folder
+       err = MsgStoUpdateFolder(pFolderInfo);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoUpdateFolder()");
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoUpdateFolder()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_FOLDER, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgDeleteFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       // Get Folder Info
+       MSG_FOLDER_ID_T* pFolderInfo = (MSG_FOLDER_ID_T*)pCmd->cmdData;
+
+       // Delete Folder
+       err = MsgStoDeleteFolder(*pFolderInfo);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoDeleteFolder()");
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoDeleteFolder()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_FOLDER, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgGetFolderListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Storage List
+       MSG_FOLDER_LIST_S folderList;
+
+       err = MsgStoGetFolderList(&folderList);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoGetFolderList()");
+
+               // Encoding Folder List Data
+               dataSize = MsgEncodeFolderList(&folderList, &encodedData);
+
+               delete [] folderList.folderInfo;
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoGetFolderList()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_FOLDERLIST, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgInitSimBySatHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       // Sim Init - Later
+       //Run msg-init-app
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INIT_SIM_BY_SAT, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgGetMsgTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Message ID
+       MSG_MESSAGE_ID_T msgId;
+
+       memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_ID_T));
+
+       // Get Msg Type
+       MSG_MESSAGE_TYPE_S msgType;
+
+       err = MsgStoGetMsgType(msgId, &msgType);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoGetMsgType()");
+
+               // Encoding Storage List Data
+               dataSize = MsgEncodeMsgType(&msgType, &encodedData);
+
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoGetMsgType()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_MSG_TYPE, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_SORT_RULE_S sortRule = {0};
+
+       memcpy(&sortRule, pCmd->cmdData, sizeof(MSG_SORT_RULE_S));
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Thread View List
+       MSG_THREAD_VIEW_LIST_S msgThreadViewList;
+
+       err = MsgStoGetThreadViewList(&sortRule, &msgThreadViewList);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoGetThreadViewList()");
+
+               // Encoding Folder View List Data
+               dataSize = MsgEncodeThreadViewList(&msgThreadViewList, &encodedData);
+
+               MSG_DEBUG("dataSize [%d]", dataSize);
+
+               if (msgThreadViewList.msgThreadInfo != NULL)
+               {
+                       delete [] msgThreadViewList.msgThreadInfo;
+                       msgThreadViewList.msgThreadInfo = NULL;
+               }
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoGetThreadViewList()");
+               return err;
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_THREADVIEWLIST, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgGetConversationViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_THREAD_ID_T threadId;
+
+       memcpy(&threadId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_THREAD_ID_T));
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       MSG_LIST_S convViewList;
+
+       err = MsgStoGetConversationViewList(threadId, &convViewList);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoGetConversationViewList()");
+
+               // Encoding Folder View List Data
+               dataSize = MsgEncodeConversationViewList(&convViewList, &encodedData);
+
+               MSG_DEBUG("dataSize [%d]", dataSize);
+
+               if (convViewList.msgInfo != NULL)
+               {
+                       delete [] convViewList.msgInfo;
+                       convViewList.msgInfo = NULL;
+               }
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoGetConversationViewList()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_CONVERSATIONVIEWLIST, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgDeleteThreadMessageListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_THREAD_ID_T threadId;
+       bool isSyncMLMsg = false;
+
+       memcpy(&threadId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_THREAD_ID_T));
+
+       int eventSize = 0;
+
+       isSyncMLMsg = MsgStoCheckSyncMLMsgInThread(threadId);
+
+       MSG_MSGID_LIST_S msgIdList;
+       memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+       err = MsgStoDeleteThreadMessageList(threadId, &msgIdList);
+
+       if (err == MSG_SUCCESS) {
+               MSG_DEBUG("Command Handle Success : MsgStoDeleteThreadMessageList()");
+
+               if(isSyncMLMsg == true) {
+                       // broadcast to listener threads, here
+                       MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, -1, -1);
+               }
+
+               MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
+               if(msgIdList.msgIdList != NULL)
+                       delete [] (char*)msgIdList.msgIdList;
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoDeleteThreadMessageList()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_THREADMESSAGELIST, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgCountMsgByContactHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       // Get From address
+       MSG_THREAD_LIST_INDEX_S addrInfo;
+
+       memcpy(&addrInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_THREAD_LIST_INDEX_S));
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Message Common Info
+       MSG_THREAD_COUNT_INFO_S threadCountInfo = {0};
+
+       err = MsgStoCountMsgByContact(&addrInfo, &threadCountInfo);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoCountMsgByContact()");
+
+               // Encoding Folder View List Data
+               dataSize = MsgEncodeMsgGetContactCount(&threadCountInfo, &encodedData);
+
+               MSG_DEBUG("dataSize [%d]", dataSize);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoCountMsgByContact()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_CONTACT_COUNT, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgGetQuickPanelDataHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       // Get Message ID
+       MSG_QUICKPANEL_TYPE_T* type = (MSG_QUICKPANEL_TYPE_T*)pCmd->cmdData;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Message
+       MSG_MESSAGE_INFO_S msgInfo;
+
+       memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+       err = MsgStoGetQuickPanelData(*type, &msgInfo);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoGetQuickPanelData()");
+
+               // Encoding Message Info Data
+               dataSize = MsgEncodeMsgInfo(&msgInfo, &encodedData);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoGetQuickPanelData()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_QUICKPANEL_DATA, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgResetDatabaseHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       // Reset DB
+       err = MsgStoResetDatabase();
+
+       if (err == MSG_SUCCESS)
+               MSG_DEBUG("Command Handle Success : MsgStoResetDatabase()");
+       else
+               MSG_DEBUG("Command Handle Fail : MsgStoResetDatabase()");
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_RESET_DB, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgGetMemSizeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Memory size
+       unsigned int memsize = 0;
+
+       memsize = MsgDu(MSG_DATA_ROOT_PATH);
+
+       dataSize = MsgEncodeMemSize(&memsize, &encodedData);
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_MEMSIZE, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgGetReportStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       // Get Message ID
+       MSG_MESSAGE_ID_T* msgId = (MSG_MESSAGE_ID_T*)pCmd->cmdData;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       MSG_REPORT_STATUS_INFO_S reportStatus;
+
+       memset(&reportStatus, 0x00, sizeof(MSG_REPORT_STATUS_INFO_S));
+
+       err = MsgStoGetReportStatus(*msgId, &reportStatus);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgGetReportStatusHandler()");
+
+               // Encoding Report Status Data
+               dataSize = MsgEncodeReportStatus(&reportStatus, &encodedData);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgGetReportStatusHandler()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_REPORT_STATUS, err, (void**)ppEvent);
+
+       return eventSize;
+}
diff --git a/framework/transaction-manager/MsgCmdHandlerTransport.cpp b/framework/transaction-manager/MsgCmdHandlerTransport.cpp
new file mode 100755 (executable)
index 0000000..371821c
--- /dev/null
@@ -0,0 +1,648 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <time.h>
+
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MsgUtilFile.h"
+#include "MsgContact.h"
+#include "MsgSoundPlayer.h"
+#include "MsgGconfWrapper.h"
+#include "MsgNotificationWrapper.h"
+#include "MsgUtilFunction.h"
+#include "MsgSubmitHandler.h"
+#include "MsgDeliverHandler.h"
+#include "MsgStorageHandler.h"
+#include "MsgTransManager.h"
+#include "MsgPluginManager.h"
+#include "MsgCmdHandler.h"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       bool bNewMsg = true;
+
+       int eventSize = 0;
+
+       MSG_REQUEST_INFO_S reqInfo = {0,};
+       MSG_PROXY_INFO_S proxyInfo = {0,};
+
+       // Get Message Request
+       memcpy(&reqInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_REQUEST_INFO_S));
+
+       // Storing Request ID, Proxy Info for Sent Status CNF
+       memcpy(&proxyInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_REQUEST_INFO_S)), sizeof(MSG_PROXY_INFO_S));
+
+       if (reqInfo.msgInfo.msgId > 0)
+               bNewMsg = false;
+
+       // Submit Request
+       err = MsgSubmitReq(&reqInfo, false);
+
+       if (err == MSG_SUCCESS){
+               MSG_DEBUG("Command Handle Success : MsgSubmitReq()");
+       } else {
+               MSG_DEBUG("Command Handle Fail : MsgSubmitReq()");
+       }
+
+       int reqId = reqInfo.reqId;
+       proxyInfo.sentMsgId = reqInfo.msgInfo.msgId;
+
+       MSG_DEBUG("REQID: %d, MSGID: %d", reqId, proxyInfo.sentMsgId);
+
+       if (reqInfo.msgInfo.msgType.mainType == MSG_SMS_TYPE) {
+               MsgTransactionManager::instance()->insertSentMsg(reqId, &proxyInfo);
+       } else if (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE) {
+               // Retrieve MMS shall not be kept in sentMsg
+               if ((reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_MMS) ||
+                       (reqInfo.msgInfo.msgType.subType == MSG_FORWARD_MMS) ||
+                       (reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_JAVA_MMS))
+               MsgTransactionManager::instance()->insertSentMsg(reqId, &proxyInfo);
+       }
+
+       // keep transaction Id list for distinguish java MMS sent msg when sendconf received
+       if (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE &&
+               reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_JAVA_MMS) {
+               MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S trId={0};
+               memcpy(&trId.id, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_REQUEST_INFO_S)+sizeof(MSG_PROXY_INFO_S)), MMS_TR_ID_LEN);
+
+               char* pFileName;
+               pFileName = strstr(reqInfo.msgInfo.msgData, "MSG_");
+               strncpy(trId.pduFileName, pFileName, MAX_COMMON_INFO_SIZE);
+
+               MSG_DEBUG("java MMS msg trId:%s filepath:%s ",trId.id, reqInfo.msgInfo.msgData);
+
+               MsgTransactionManager* tm = MsgTransactionManager::instance();
+               tm->setJavaMMSList(&trId);
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(&reqId, sizeof(reqId), MSG_EVENT_SUBMIT_REQ, err, (void**)ppEvent);
+
+       /* reject_msg_support */
+       if(((reqInfo.msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS) &&
+                (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE)))
+               err = MsgStoDeleteMessage(reqInfo.msgInfo.msgId, true);
+       /* reject_msg_support */
+
+       /** send storage CB */
+       if (err == MSG_SUCCESS && bNewMsg && reqInfo.msgInfo.msgPort.valid == false) {
+
+               MSG_MSGID_LIST_S msgIdList;
+               MSG_MESSAGE_ID_T msgIds[1];
+               memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+               msgIdList.nCount = 1;
+               msgIds[0] = reqInfo.msgInfo.msgId;
+               msgIdList.msgIdList = msgIds;
+
+               MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
+       }
+       return eventSize;
+}
+
+
+int MsgCancelReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int eventSize = 0;
+
+       // Get Request ID
+       MSG_REQUEST_ID_T* reqId = (MSG_REQUEST_ID_T*)pCmd->cmdData;
+
+       // Cancel Request
+       err = MsgCancelReq(*reqId);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgSubCancelReq()");
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgSubCancelReq()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_CANCEL_REQ, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgRegSentStatusCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       // input check
+       if( !pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       // Get Message Request
+       int listenerFd = *((int*) pCmd->cmdData);
+       MSG_DEBUG("Registering sent status CB for %d", listenerFd);
+
+       // storing dst fd in list
+       MsgTransactionManager::instance()->setSentStatusCB(listenerFd);
+
+       // Make Event Data
+       int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_SENT_STATUS_CB, MSG_SUCCESS, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgRegIncomingMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       // input check
+       if( !pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       // Get Message Request
+       MSG_CMD_REG_INCOMING_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_MSG_CB_S*) pCmd->cmdData;
+       MSG_DEBUG("Registering incoming SMS CB for fd %d mType %d port %d", pCmdData->listenerFd, pCmdData->msgType, pCmdData->port);
+
+       // storing dst fd in list
+       MsgTransactionManager::instance()->setIncomingMsgCB(pCmdData);
+
+       // Make Event Data
+       int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgRegIncomingMMSConfMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       // input check
+       if( !pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       // Get Message Request
+       MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S*) pCmd->cmdData;
+       MSG_DEBUG("Registering incoming MMS Conf CB for fd:%d mType:%d appId:%s", pCmdData->listenerFd, pCmdData->msgType, pCmdData->appId);
+
+       // storing dst fd in list
+       MsgTransactionManager::instance()->setMMSConfMsgCB(pCmdData);
+
+       // Make Event Data
+       int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgRegIncomingSyncMLMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       // input check
+       if( !pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       // Get Message Request
+       MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S*) pCmd->cmdData;
+       MSG_DEBUG("Registering incoming Sync ML Msg CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
+
+       // storing dst fd in list
+       MsgTransactionManager::instance()->setSyncMLMsgCB(pCmdData);
+
+       // Make Event Data
+       int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgRegIncomingLBSMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       // input check
+       if( !pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       // Get Message Request
+       MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_LBS_MSG_CB_S*) pCmd->cmdData;
+       MSG_DEBUG("Registering incoming LBS Msg CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
+
+       // storing dst fd in list
+       MsgTransactionManager::instance()->setLBSMsgCB(pCmdData);
+
+       // Make Event Data
+       int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_LBS_MSG_CB, MSG_SUCCESS, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgRegSyncMLMsgOperationCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       // input check
+       if( !pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       // Get Message Request
+       MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCmdData = (MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S*) pCmd->cmdData;
+       MSG_DEBUG("Registering SyncML Msg ooperation CB for fd %d mType %d", pCmdData->listenerFd, pCmdData->msgType);
+
+       // storing dst fd in list
+       MsgTransactionManager::instance()->setSyncMLMsgOperationCB(pCmdData);
+
+       // Make Event Data
+       int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB, MSG_SUCCESS, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgRegStorageChangeCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       // input check
+       if( !pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       // Get Message Request
+       int listenerFd = *((int*) pCmd->cmdData);
+       MSG_DEBUG("Registering storage change CB for %d", listenerFd);
+
+       // storing dst fd in list
+       MsgTransactionManager::instance()->setStorageChangeCB(listenerFd);
+
+       // Make Event Data
+       int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_STORAGE_CHANGE_CB, MsgException::SUCCESS, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgSentStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       // input check
+       if (!pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       // Get Message Request
+       MSG_SENT_STATUS_S* pStatus = (MSG_SENT_STATUS_S*) pCmd->cmdData;
+
+       MSG_DEBUG("REQID %d, STATUS %d", pStatus->reqId, pStatus->status);
+
+       // storing dst fd in list
+       MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(pStatus->reqId);
+
+       // when no sent status cb is found (in case of mobile tracker)
+       if (!prxInfo)
+       {
+               return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
+       }
+
+       MSG_DEBUG("REQID %d, listenerFD %d, handleAddr %x, msgId %d", pStatus->reqId, prxInfo->listenerFd, prxInfo->handleAddr, prxInfo->sentMsgId);
+
+       // if APP send and quit(not exist at this time), don't send the data up.
+       if (prxInfo->handleAddr == 0)
+       {
+               // just making data which will be passed to plugin. it indicates "handling evt success"
+               MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId);
+
+               //in case of scheduled message sending, scheduled msg table should be updated.
+               MsgStoDeleteScheduledMessage(prxInfo->sentMsgId);
+
+               return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
+       }
+
+       unsigned int ret[3] = {0}; //3// reqid, status, object
+
+       ret[0] = pStatus->reqId;
+       ret[1] = pStatus->status;
+       ret[2] = prxInfo->handleAddr;
+
+       // Make Event Data for APP
+       int eventSize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
+
+       // Send to listener thread, here
+       MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventSize);
+
+       MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId);
+
+       return eventSize;
+}
+
+
+int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+       int eventSize = 0;
+       bool sendNoti = true;
+
+       // input check
+       if (!pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       // Get Incoming Message
+       MSG_MESSAGE_INFO_S msgInfo;
+       memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+       memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
+
+       // normal process
+       err = MsgHandleIncomingMsg(&msgInfo, &sendNoti);
+
+       // broadcast to listener threads, here
+       MSG_MSGID_LIST_S msgIdList;
+       MSG_MESSAGE_ID_T msgIds[1];
+       memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+       msgIdList.nCount = 1;
+       msgIds[0] = msgInfo.msgId;
+       msgIdList.msgIdList = msgIds;
+
+       if (sendNoti == true) {
+               MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo);
+               MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
+       }
+
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent);
+
+       MSG_END();
+
+       return eventSize;
+}
+
+int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_BEGIN();
+       MSG_ERROR_T err = MSG_SUCCESS;
+       int eventsize = 0;
+
+       MSG_MESSAGE_INFO_S msgInfo = {0};
+       MSG_REQUEST_ID_T reqID;
+
+       memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
+       memcpy(&reqID, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), sizeof(MSG_REQUEST_ID_T));
+
+       MSG_DEBUG(" pMsg = %s, pReqId = %d ", msgInfo.msgData, reqID);
+       MSG_DEBUG(" msgtype subtype is [%d]", msgInfo.msgType.subType);
+
+       // For Storage change callback
+       MSG_MSGID_LIST_S msgIdList;
+       MSG_MESSAGE_ID_T msgIds[1];
+       memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+       msgIdList.nCount = 1;
+       msgIds[0] = msgInfo.msgId;
+       msgIdList.msgIdList = msgIds;
+
+       err = MsgStoGetAddrInfo(msgInfo.msgId, &(msgInfo.addressList[0]));
+
+       if (err == MSG_SUCCESS) {
+               MSG_DEBUG("MmsStoGetAddrInfo() success.");
+               msgInfo.nAddressCnt = 1;
+       } else {
+               MSG_DEBUG("MmsStoGetAddrInfo() fail.");
+       }
+
+       if(msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) {
+
+               err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
+
+               if(err != MSG_SUCCESS)
+                       return err;
+
+               MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
+
+               if (pMmsRecvData->msgAppId.valid == true) {
+                       MSG_DEBUG("valid : %d, appId : %s", pMmsRecvData->msgAppId.valid, pMmsRecvData->msgAppId.appId);
+               } else {
+                       msgInfo.bTextSms = true;
+                       msgInfo.dataSize = 0 ;
+                       memset(msgInfo.msgData, 0x00, sizeof(MMS_RECV_DATA_S));
+               }
+
+               eventsize = MsgMakeEvent(&msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MMS_CONF, msgInfo.networkStatus, (void**)ppEvent);
+
+               // broadcast to listener threads, here
+               MsgTransactionManager::instance()->broadcastMMSConfCB(msgInfo.networkStatus, &msgInfo, pMmsRecvData);
+               MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
+       } else if (msgInfo.msgType.subType == MSG_SENDREQ_MMS || msgInfo.msgType.subType == MSG_SENDCONF_MMS) {
+               MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(reqID);
+
+               // when no sent status cb is found (in case of mobile tracker)
+               if (!prxInfo)
+                       return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
+
+               // No need to update javaMMS sent messages
+               javamms_list& listenerList = MsgTransactionManager::instance()->getJavaMMSList();
+               javamms_list::iterator it = listenerList.begin();
+
+               MSG_DEBUG("listenerList size:%d ",listenerList.size());
+
+               if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL && msgInfo.msgType.subType == MSG_SENDREQ_MMS) {
+                       for ( ; it != listenerList.end() ; it++) {
+                               if (strstr(it->pduFileName,"JAVA")) {
+                                       MSG_DEBUG("JAVA MMS fileName:%s", it->pduFileName);
+                                       MsgDeleteFile(it->pduFileName);         // ipc
+                                       listenerList.erase(it);
+                                       goto __BYPASS_UPDATE;
+                               }
+                       }
+               } else {
+                       //msgData has MMS_RECV_DATA_S
+                       MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData;
+
+                       for ( ; it != listenerList.end() ; it++) {
+                               if(!strcmp(it->id, pMmsRecvData->szTrID)) {
+                                       MSG_DEBUG("find sent JAVA MMS message trId:%s from listener list trId:%s",pMmsRecvData->szTrID, it->id);
+                                       MsgDeleteFile(it->pduFileName); // ipc
+                                       listenerList.erase(it);
+                                       goto __BYPASS_UPDATE;
+                               }
+                       }
+               }
+
+               err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID);
+
+               if(err != MSG_SUCCESS)
+                       return err;
+
+__BYPASS_UPDATE:
+               if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL) {
+                       MSG_DEBUG("message-dialog: send fail");
+                       MsgInsertTicker("Sending multimedia message failed.", SENDING_MULTIMEDIA_MESSAGE_FAILED);
+               } else {
+                       MSG_DEBUG("message-dialog: send success");
+                       MsgInsertTicker("Multimedia message sent.", MULTIMEDIA_MESSAGE_SENT);
+               }
+
+               if (prxInfo->handleAddr == 0) {
+                       // just making data which will be passed to plugin. it indicates "handling evt success"
+                       MsgTransactionManager::instance()->delProxyInfo(reqID);
+
+                       //in case of scheduled message sending, scheduled msg table should be updated.
+                       MsgStoDeleteScheduledMessage(prxInfo->sentMsgId);
+
+                       return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
+               }
+
+               unsigned int ret[3] = {0}; //3// reqid, status, object
+
+               ret[0] = reqID;
+               ret[1] = msgInfo.networkStatus;
+               ret[2] = prxInfo->handleAddr;
+
+               // Make Event Data for APP
+               eventsize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent);
+
+               // Send to listener thread, here
+               MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventsize);
+
+               MsgTransactionManager::instance()->delProxyInfo(reqID);
+
+               msgInfo.bTextSms = true;
+               MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
+       }
+
+       MSG_END();
+       return eventsize;
+}
+
+
+int MsgIncomingSyncMLMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       // input check
+       if (!pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       MSG_SYNCML_MESSAGE_DATA_S syncMLData;
+       memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
+
+       // Get Incoming Message
+       memcpy(&syncMLData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_SYNCML_MESSAGE_DATA_S));
+
+       int eventSize = 0;
+
+       // broadcast to listener threads, here
+       MsgTransactionManager::instance()->broadcastSyncMLMsgCB(MSG_SUCCESS, &syncMLData);
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgIncomingLBSMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       int eventSize = 0;
+
+       // input check
+       if (!pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       MSG_LBS_MESSAGE_DATA_S lbsData;
+       memset(&lbsData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
+
+       // Get Incoming Message
+       memcpy(&lbsData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_LBS_MESSAGE_DATA_S));
+
+       // broadcast to listener threads, here
+       MsgTransactionManager::instance()->broadcastLBSMsgCB(MSG_SUCCESS, &lbsData);
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, MSG_SUCCESS, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int eventSize = 0;
+
+       MSG_MESSAGE_ID_T msgId = 0;
+       int extId = 0;
+
+       // input check
+       if (!pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       // Get Data
+       memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_ID_T));
+       memcpy(&extId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), sizeof(int));
+
+       err = MsgStoGetSyncMLExtId(msgId, &extId);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoGetSyncMLExtId()");
+
+               // broadcast to listener threads, here
+               MsgTransactionManager::instance()->broadcastSyncMLMsgOperationCB(err, msgId, extId);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoGetSyncMLExtId()");
+       }
+
+       // Make Event Data to Client
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SYNCML_OPERATION, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       // input check
+       if (!pCmd || !ppEvent)
+               THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null");
+
+       MSG_STORAGE_CHANGE_TYPE_T storageChangeType;
+
+       MSG_MESSAGE_INFO_S msgInfo;
+       memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+       memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
+       memcpy(&storageChangeType, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), sizeof(MSG_STORAGE_CHANGE_TYPE_T));
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int eventSize = 0;
+
+       MSG_DEBUG("storageChangeType : [%d], msg Id : [%d]", storageChangeType, msgInfo.msgId);
+
+       // broadcast to listener threads, here
+       MSG_MSGID_LIST_S msgIdList;
+       MSG_MESSAGE_ID_T msgIds[1];
+       memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+       msgIdList.nCount = 1;
+       msgIds[0] = msgInfo.msgId;
+       msgIdList.msgIdList = msgIds;
+
+       MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, storageChangeType, &msgIdList);
+
+       // Make Event Data to Client
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_STORAGE_CHANGE_IND, MSG_SUCCESS, (void**)ppEvent);
+
+       return eventSize;
+}
diff --git a/framework/transaction-manager/MsgTransManager.cpp b/framework/transaction-manager/MsgTransManager.cpp
new file mode 100755 (executable)
index 0000000..5c615ec
--- /dev/null
@@ -0,0 +1,862 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+
+#include <security-server.h>
+
+#include "MsgDebug.h"
+#include "MsgMemory.h"
+#include "MsgException.h"
+#include "MsgCppTypes.h"
+#include "MsgContact.h"
+#include "MsgIpcSocket.h"
+#include "MsgGconfWrapper.h"
+#include "MsgUtilFunction.h"
+#include "MsgCmdHandler.h"
+#include "MsgSettingHandler.h"
+#include "MsgStorageHandler.h"
+#include "MsgPluginManager.h"
+#include "MsgTransManager.h"
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+void MsgContactChangedCallback()
+{
+       MSG_MSGID_LIST_S msgIdList;
+       memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+       MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_CONTACT, &msgIdList);
+}
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgTransactionManager - Member Functions
+==================================================================================================*/
+MsgTransactionManager* MsgTransactionManager::pInstance = NULL;
+MsgIpcServerSocket MsgTransactionManager::servSock;
+
+
+MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv()
+{
+       sentMsgMap.clear();
+
+       statusCBFdMap.clear();
+       newMsgCBList.clear();
+       newMMSConfMsgCBList.clear();
+       newSyncMLMsgCBList.clear();
+       newLBSMsgCBList.clear();
+       javaMMSList.clear();
+       operationSyncMLMsgCBList.clear();
+       storageChangeFdMap.clear();
+
+       handlerMap.clear();
+
+//     Fill in mMsgHandlers, as given in the below.
+       handlerMap[MSG_CMD_ADD_MSG]                             = &MsgAddMessageHandler;
+       handlerMap[MSG_CMD_ADD_SYNCML_MSG]              = &MsgAddSyncMLMessageHandler;
+       handlerMap[MSG_CMD_UPDATE_MSG]                  = &MsgUpdateMessageHandler;
+       handlerMap[MSG_CMD_UPDATE_READ]                         = &MsgUpdateReadStatusHandler;
+       handlerMap[MSG_CMD_UPDATE_PROTECTED]            = &MsgUpdateProtectedStatusHandler;
+       handlerMap[MSG_CMD_DELETE_MSG]                  = &MsgDeleteMessageHandler;
+       handlerMap[MSG_CMD_DELALL_MSGINFOLDER]  = &MsgDeleteAllMessageInFolderHandler;
+       handlerMap[MSG_CMD_MOVE_MSGTOFOLDER]    = &MsgMoveMessageToFolderHandler;
+       handlerMap[MSG_CMD_MOVE_MSGTOSTORAGE]   = &MsgMoveMessageToStorageHandler;
+       handlerMap[MSG_CMD_COUNT_MSG]                   = &MsgCountMessageHandler;
+       handlerMap[MSG_CMD_GET_MSG]                             = &MsgGetMessageHandler;
+       handlerMap[MSG_CMD_GET_FOLDERVIEWLIST]  = &MsgGetFolderViewListHandler;
+
+       handlerMap[MSG_CMD_ADD_FOLDER]                  = &MsgAddFolderHandler;
+       handlerMap[MSG_CMD_UPDATE_FOLDER]               = &MsgUpdateFolderHandler;
+       handlerMap[MSG_CMD_DELETE_FOLDER]               = &MsgDeleteFolderHandler;
+       handlerMap[MSG_CMD_GET_FOLDERLIST]              = &MsgGetFolderListHandler;
+
+       handlerMap[MSG_CMD_SET_CONFIG]                  = &MsgSetConfigHandler;
+       handlerMap[MSG_CMD_GET_CONFIG]                  = &MsgGetConfigHandler;
+       handlerMap[MSG_CMD_GET_MSG_TYPE]                        = &MsgGetMsgTypeHandler;
+
+       handlerMap[MSG_CMD_SUBMIT_REQ]                  = &MsgSubmitReqHandler;
+       handlerMap[MSG_CMD_CANCEL_REQ]                  = &MsgCancelReqHandler;
+
+       handlerMap[MSG_CMD_REG_SENT_STATUS_CB]  = &MsgRegSentStatusCallbackHandler;
+       handlerMap[MSG_CMD_REG_STORAGE_CHANGE_CB] = &MsgRegStorageChangeCallbackHandler;
+       handlerMap[MSG_CMD_REG_INCOMING_MSG_CB] = &MsgRegIncomingMsgCallbackHandler;
+       handlerMap[MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB]        = &MsgRegIncomingMMSConfMsgCallbackHandler;
+       handlerMap[MSG_CMD_REG_INCOMING_SYNCML_MSG_CB]  = &MsgRegIncomingSyncMLMsgCallbackHandler;
+       handlerMap[MSG_CMD_REG_INCOMING_LBS_MSG_CB]     = &MsgRegIncomingLBSMsgCallbackHandler;
+       handlerMap[MSG_CMD_REG_SYNCML_MSG_OPERATION_CB] = &MsgRegSyncMLMsgOperationCallbackHandler;
+
+       handlerMap[MSG_CMD_PLG_SENT_STATUS_CNF] = &MsgSentStatusHandler;
+       handlerMap[MSG_CMD_PLG_STORAGE_CHANGE_IND]      = &MsgStorageChangeHandler;
+       handlerMap[MSG_CMD_PLG_INCOMING_MSG_IND]        = &MsgIncomingMsgHandler;
+       handlerMap[MSG_CMD_PLG_INCOMING_MMS_CONF]       = &MsgIncomingMMSConfMsgHandler;
+
+        handlerMap[MSG_CMD_PLG_INCOMING_SYNCML_IND] = &MsgIncomingSyncMLMsgHandler;
+       handlerMap[MSG_CMD_PLG_INCOMING_LBS_IND] = &MsgIncomingLBSMsgHandler;
+       handlerMap[MSG_CMD_PLG_INIT_SIM_BY_SAT] = &MsgInitSimBySatHandler;
+
+       handlerMap[MSG_CMD_GET_THREADVIEWLIST]  = &MsgGetThreadViewListHandler;
+       handlerMap[MSG_CMD_GET_CONVERSATIONVIEWLIST]    = &MsgGetConversationViewListHandler;
+       handlerMap[MSG_CMD_DELETE_THREADMESSAGELIST]    = &MsgDeleteThreadMessageListHandler;
+
+       handlerMap[MSG_CMD_GET_CONTACT_COUNT]   = &MsgCountMsgByContactHandler;
+       handlerMap[MSG_CMD_GET_QUICKPANEL_DATA]         = &MsgGetQuickPanelDataHandler;
+       handlerMap[MSG_CMD_COUNT_BY_MSGTYPE]    = &MsgCountMsgByTypeHandler;
+       handlerMap[MSG_CMD_RESET_DB]    = &MsgResetDatabaseHandler;
+       handlerMap[MSG_CMD_GET_MEMSIZE]         = &MsgGetMemSizeHandler;
+
+       handlerMap[MSG_CMD_UPDATE_THREAD_READ] = &MsgUpdateThreadReadStatusHandler;
+
+       handlerMap[MSG_CMD_SYNCML_OPERATION] = &MsgSyncMLMsgOperationHandler;
+       handlerMap[MSG_CMD_GET_REPORT_STATUS]                   = &MsgGetReportStatusHandler;
+}
+
+
+MsgTransactionManager::~MsgTransactionManager()
+{
+
+}
+
+
+MsgTransactionManager* MsgTransactionManager::instance()
+{
+       if (!pInstance)
+               pInstance = new MsgTransactionManager();
+
+       return pInstance;
+}
+
+
+void MsgTransactionManager::run()
+{
+       servSock.open(MSG_SOCKET_PATH);
+
+       fd_set readfds = servSock.fdSet();
+       int nfds = 0;
+
+       MSG_DEBUG("Start Transaction Manager");
+
+       while(1)
+       {
+               readfds = servSock.fdSet();
+               nfds = servSock.maxFd();
+
+               MSG_DEBUG("Wait For Select() : nfds %d", nfds);
+
+               // set Status;
+               setTMStatus();
+
+               if( select(nfds, &readfds, NULL, NULL, NULL) == -1)
+               {
+                       THROW(MsgException::SELECT_ERROR, strerror(errno));
+               }
+
+               try
+               {
+                       for (int i=0 ; i < nfds; i++)
+                       {
+                               if (FD_ISSET(i, &readfds))
+                               {
+                                       if (i == servSock.fd()) // if it is socket connection request
+                                               servSock.accept();
+                                       else
+                                               handleRequest(i);
+                               }
+                       }
+               }
+               catch (MsgException& e)
+               {
+                       MSG_FATAL("%s", e.what());
+               }
+               catch (exception& e)
+               {
+                       MSG_FATAL("%s", e.what());
+               }
+
+               // Release Memory
+               MsgReleaseMemory();
+       }
+}
+
+
+void MsgTransactionManager::write(int fd, const char* buf, int len)
+{
+       servSock.write(fd, buf, len);
+}
+
+
+void MsgTransactionManager::insertSentMsg(int reqId, MSG_PROXY_INFO_S* pPrxInfo)
+{
+       if (pPrxInfo == NULL)
+               THROW(MsgException::SENT_STATUS_ERROR, "Input Parameter is NULL");
+
+       MSG_DEBUG("msg for submit: reqId %d listenerFd %d handleAddr %x", reqId, pPrxInfo->listenerFd, pPrxInfo->handleAddr);
+
+       fd_map::iterator it = statusCBFdMap.find(pPrxInfo->listenerFd);
+
+       if (it == statusCBFdMap.end()) { // if the status CB is not registered
+               MSG_DEBUG("No sent_status registered for fd %d", pPrxInfo->listenerFd);
+       } else {
+               sentMsgMap.insert(make_pair(reqId, *pPrxInfo));
+       }
+}
+
+
+MSG_PROXY_INFO_S* MsgTransactionManager::getProxyInfo(int reqId)
+{
+       sentmsg_map::iterator it = sentMsgMap.find(reqId);
+
+       if (it == sentMsgMap.end())
+       {
+               MSG_DEBUG("No sent status cb found (exception: mobile tracker)");
+               return NULL;
+       }
+
+       return &(it->second);
+}
+
+
+void MsgTransactionManager::delProxyInfo(int reqId)
+{
+       sentmsg_map::iterator it = sentMsgMap.find(reqId);
+
+       if (it == sentMsgMap.end())
+       {
+               THROW(MsgException::SENT_STATUS_ERROR, "channel info does not exist");
+       }
+
+       sentMsgMap.erase(it);
+}
+
+
+void MsgTransactionManager::handleRequest(int fd)
+{
+       MSG_BEGIN();
+
+       MSG_DEBUG("Event from fd %d", fd);
+
+       char* buf = NULL;
+       AutoPtr<char> wrap(&buf);
+       int len;
+       int ret = servSock.read(fd, &buf, &len);
+
+       if( ret == CLOSE_CONNECTION_BY_SIGNAL || ret == CLOSE_CONNECTION_BY_USER || ret < 0)
+       {
+               MSG_DEBUG("Read value [%d]", ret);
+               cleanup(fd);
+               return;
+       }
+
+       if (len == 0)
+               THROW(MsgException::INVALID_RESULT, "read buffer size = 0");
+
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       int eventSize = 0;
+
+       // decoding cmd from APP
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) buf;
+       MSG_DEBUG("Command Type [%d : %s]", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType));
+
+       if (pCmd->cmdType > MSG_CMD_NUM)
+               THROW(MsgException::OUT_OF_RANGE, "request CMD is not defined");
+
+       if (pCmd->cmdType < MSG_CMD_GET_REPORT_STATUS)
+       {
+               // check privilege
+               if (checkPrivilege(pCmd->cmdType, pCmd->cmdCookie) == false)
+               {
+#ifdef MSG_CHECK_PRIVILEGE
+                       eventSize = sizeof(MSG_EVENT_S);
+
+                       pEventData = new char[eventSize];
+
+                       MSG_EVENT_S* pMsgEvent = (MSG_EVENT_S*)pEventData;
+
+                       pMsgEvent->eventType = pCmd->cmdType;
+                       pMsgEvent->result = MSG_ERR_SECURITY_ERROR;
+
+                       MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
+                       servSock.write(fd, pEventData, eventSize);
+
+                       return;
+#endif
+               }
+       }
+
+       // determine the handler based on pCmd->cmdType
+       int (*pfHandler)(const MSG_CMD_S*, char**) = NULL;
+
+       pfHandler = handlerMap[pCmd->cmdType];
+
+       if (!pfHandler)
+               THROW(MsgException::INVALID_PARAM, "No handler for %d", pCmd->cmdType);
+
+       // run handler function
+       eventSize = pfHandler(pCmd, &pEventData);
+
+       if (eventSize == 0 || pEventData == NULL)
+               THROW(MsgException::INVALID_RESULT, "event size = 0 or event data = NULL");
+
+       MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
+
+       servSock.write(fd, pEventData, eventSize);
+
+       MSG_END();
+}
+
+
+// terminating the socket connection between ipc server and ipc client
+void MsgTransactionManager::cleanup(int fd)
+{
+       MSG_BEGIN();
+
+       servSock.close(fd);
+
+       MSG_DEBUG("fd %d disonnected", fd);
+
+       // remove sent msg info for fd
+       sentmsg_map::iterator sentmsg_it = sentMsgMap.begin();
+
+       for (; sentmsg_it != sentMsgMap.end(); sentmsg_it++)
+       {
+               if (sentmsg_it->second.listenerFd == fd)
+               {
+                       sentmsg_it->second.listenerFd = 0;
+                       sentmsg_it->second.handleAddr = 0;
+               }
+       }
+
+       // remove sent status callback for fd
+       statusCBFdMap.erase(fd);
+
+       // remove all newMsgCBs for fd
+       newmsg_list::iterator newmsg_it = newMsgCBList.begin();
+
+       while (newmsg_it != newMsgCBList.end())
+       {
+               if (newmsg_it->listenerFd == fd)
+               {
+                       newmsg_it = newMsgCBList.erase(newmsg_it);
+               }
+               else
+               {
+                       ++newmsg_it;
+               }
+       }
+
+       // remove all newMMSConfMsgCBs for fd
+       mmsconf_list::iterator mmsconf_it = newMMSConfMsgCBList.begin();
+
+       while (mmsconf_it != newMMSConfMsgCBList.end())
+       {
+               if (mmsconf_it->listenerFd == fd)
+               {
+                       mmsconf_it = newMMSConfMsgCBList.erase(mmsconf_it);
+               }
+               else
+               {
+                       ++mmsconf_it;
+               }
+       }
+
+       // remove all newSyncMLMsgCBs for fd
+       syncmlmsg_list::iterator syncmlmsg_it = newSyncMLMsgCBList.begin();
+
+       while (syncmlmsg_it != newSyncMLMsgCBList.end())
+       {
+               if (syncmlmsg_it->listenerFd == fd)
+               {
+                       syncmlmsg_it = newSyncMLMsgCBList.erase(syncmlmsg_it);
+               }
+               else
+               {
+                       ++syncmlmsg_it;
+               }
+       }
+
+       // remove all newLBSMsgCBs for fd
+       lbsmsg_list::iterator lbsmsg_it = newLBSMsgCBList.begin();
+
+       while (lbsmsg_it != newLBSMsgCBList.end())
+       {
+               if (lbsmsg_it->listenerFd == fd)
+               {
+                       lbsmsg_it = newLBSMsgCBList.erase(lbsmsg_it);
+               }
+               else
+               {
+                       ++lbsmsg_it;
+               }
+       }
+
+       // remove all operationSyncMLMsgCBs for fd
+       syncmlop_list::iterator syncmlop_it = operationSyncMLMsgCBList.begin();
+
+       while (syncmlop_it != operationSyncMLMsgCBList.end())
+       {
+               if (syncmlop_it->listenerFd == fd)
+               {
+                       syncmlop_it = operationSyncMLMsgCBList.erase(syncmlop_it);
+               }
+               else
+               {
+                       ++syncmlop_it;
+               }
+       }
+
+       // remove storage change callback for fd
+       storageChangeFdMap.erase(fd);
+
+       MSG_END();
+}
+
+
+bool MsgTransactionManager::checkPrivilege(MSG_CMD_TYPE_T CmdType, const char *pCookie)
+{
+       if (CmdType >= MSG_CMD_PLG_SENT_STATUS_CNF && CmdType <= MSG_CMD_PLG_INIT_SIM_BY_SAT)
+       {
+               MSG_DEBUG("Request from Plug-in");
+               return true;
+       }
+
+       // Get Cookie from APP
+       if (pCookie == NULL)
+       {
+               MSG_DEBUG("Cookie is NULL");
+               return false;
+       }
+
+       // Check Cookie
+       size_t cookieSize;
+       gid_t gid;
+
+       cookieSize = security_server_get_cookie_size();
+
+       MSG_DEBUG("cookie size : [%d]", cookieSize);
+
+       // Get GID
+       if (CmdType == MSG_CMD_REG_INCOMING_SYNCML_MSG_CB)
+       {
+               MSG_DEBUG("get GID for message_sync");
+               gid = security_server_get_gid("message_sync");
+       }
+       else if (CmdType == MSG_CMD_REG_INCOMING_LBS_MSG_CB)
+       {
+               MSG_DEBUG("get GID for message_lbs");
+               gid = security_server_get_gid("message_lbs");
+       }
+       else
+       {
+               MSG_DEBUG("get GID for message");
+               gid = security_server_get_gid("message");
+       }
+
+       MSG_DEBUG("gid [%d]", gid);
+
+       int retVal = 0;
+
+       retVal = security_server_check_privilege(pCookie, gid);
+
+       if (retVal < 0)
+       {
+               if (retVal == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
+               {
+                       MSG_DEBUG("access denied !! [%d]", retVal);
+               }
+               else
+               {
+                       MSG_DEBUG("fail to check privilege [%d]", retVal);
+               }
+
+               return false;
+       }
+
+       MSG_DEBUG("privilege check success !!");
+
+       return true;
+}
+
+
+void MsgTransactionManager::setSentStatusCB(int listenerFd)
+{
+       if (listenerFd <= 0)
+               THROW(MsgException::INVALID_PARAM,"InParam Error: listenerFd %d",listenerFd);
+
+       statusCBFdMap[listenerFd] = true;
+}
+
+
+void MsgTransactionManager::setIncomingMsgCB(MSG_CMD_REG_INCOMING_MSG_CB_S *pCbInfo)
+{
+       if (!pCbInfo)
+       {
+               MSG_FATAL("cbinfo NULL");
+               return;
+       }
+
+       newmsg_list::iterator it = newMsgCBList.begin();
+
+       for (; it != newMsgCBList.end(); it++)
+       {
+               if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType) && (it->port == pCbInfo->port))
+               {
+                       MSG_DEBUG("Duplicated messageCB info fd %d, mType %d, port %d", it->listenerFd, it->msgType, it->port);
+                       return;
+               }
+       }
+
+       newMsgCBList.push_back(*pCbInfo);
+}
+
+
+void MsgTransactionManager::setMMSConfMsgCB(MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCbInfo)
+{
+       if (!pCbInfo)
+       {
+               MSG_FATAL("cbinfo NULL");
+               return;
+       }
+
+       mmsconf_list::iterator it = newMMSConfMsgCBList.begin();
+
+       for (; it != newMMSConfMsgCBList.end(); it++)
+       {
+               if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType) && (!strncmp(it->appId, pCbInfo->appId, MAX_MMS_JAVA_APPID_LEN)))
+               {
+                       MSG_DEBUG("Duplicated MMSConfMessageCB info fd:%d, mType:%d, appId:%s", it->listenerFd, it->msgType, it->appId);
+                       return;
+               }
+       }
+
+       newMMSConfMsgCBList.push_back(*pCbInfo);
+}
+
+
+void MsgTransactionManager::setSyncMLMsgCB(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCbInfo)
+{
+       if (!pCbInfo)
+       {
+               MSG_FATAL("cbinfo NULL");
+               return;
+       }
+
+       syncmlmsg_list::iterator it = newSyncMLMsgCBList.begin();
+
+       for (; it != newSyncMLMsgCBList.end(); it++)
+       {
+               if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType))
+               {
+                       MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
+                       return;
+               }
+       }
+
+       newSyncMLMsgCBList.push_back(*pCbInfo);
+}
+
+
+void MsgTransactionManager::setLBSMsgCB(MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCbInfo)
+{
+       if (!pCbInfo)
+       {
+               MSG_FATAL("cbinfo NULL");
+               return;
+       }
+
+       lbsmsg_list::iterator it = newLBSMsgCBList.begin();
+
+       for (; it != newLBSMsgCBList.end(); it++)
+       {
+               if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType))
+               {
+                       MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
+                       return;
+               }
+       }
+
+       newLBSMsgCBList.push_back(*pCbInfo);
+}
+
+
+void MsgTransactionManager::setJavaMMSList(MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S *pTrId)
+{
+       if (!pTrId)
+       {
+               MSG_FATAL("trId NULL");
+               return;
+       }
+
+       javamms_list::iterator it;
+
+       for (it = javaMMSList.begin(); it != javaMMSList.end(); it++)
+       {
+               if (!strcmp(it->id, pTrId->id))
+               {
+                       MSG_DEBUG("Duplicated javaMMS transaction Id:%s", it->id);
+                       return;
+               }
+       }
+
+       javaMMSList.push_back(*pTrId);
+}
+
+
+void MsgTransactionManager::setSyncMLMsgOperationCB(MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCbInfo)
+{
+       if (!pCbInfo)
+       {
+               MSG_FATAL("cbinfo NULL");
+               return;
+       }
+
+       syncmlop_list::iterator it = operationSyncMLMsgCBList.begin();
+
+       for (; it != operationSyncMLMsgCBList.end(); it++)
+       {
+               if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType))
+               {
+                       MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType);
+                       return;
+               }
+       }
+
+       operationSyncMLMsgCBList.push_back(*pCbInfo);
+}
+
+
+void MsgTransactionManager::setStorageChangeCB(int listenerFd)
+{
+       if (listenerFd <= 0)
+               THROW(MsgException::INVALID_PARAM,"InParam Error: listenerFd %d", listenerFd);
+
+       storageChangeFdMap[listenerFd] = true;
+}
+
+
+javamms_list& MsgTransactionManager::getJavaMMSList()
+{
+       return javaMMSList;
+}
+
+
+void MsgTransactionManager::broadcastIncomingMsgCB(const MSG_ERROR_T err, const MSG_MESSAGE_INFO_S *msgInfo)
+{
+       MSG_BEGIN();
+
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       int eventSize = MsgMakeEvent(msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)(&pEventData));
+
+       MSG_DEBUG("valid %d dstport %d", msgInfo->msgPort.valid, msgInfo->msgPort.dstPort);
+
+       newmsg_list::iterator it = newMsgCBList.begin();
+
+       for (; it != newMsgCBList.end(); it++)
+       {
+               MSG_DEBUG("fd %d dstport %d",it->listenerFd, it->port);
+
+               if ((msgInfo->msgPort.valid == false) && (it->port == 0))
+               {
+                       MSG_DEBUG("Send incoming normal msg to listener %d", it->listenerFd);
+                       write(it->listenerFd, pEventData, eventSize);
+               }
+               else if ((msgInfo->msgPort.valid == true) && (it->port == msgInfo->msgPort.dstPort))
+               {
+                       MSG_DEBUG("Send incoming port msg to listener %d", it->listenerFd);
+                       write(it->listenerFd, pEventData, eventSize);
+               }
+       }
+
+       MSG_END();
+}
+
+
+void MsgTransactionManager::broadcastMMSConfCB(const MSG_ERROR_T err, const MSG_MESSAGE_INFO_S *msgInfo, const MMS_RECV_DATA_S *mmsRecvData)
+{
+       MSG_BEGIN();
+
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       int eventSize = MsgMakeEvent(msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)(&pEventData));
+
+       mmsconf_list::iterator it = newMMSConfMsgCBList.begin();
+
+       for (; it != newMMSConfMsgCBList.end(); it++)
+       {
+               MSG_DEBUG("fd:%d appId:%s",it->listenerFd, it->appId);
+
+               if (mmsRecvData->msgAppId.valid == true)
+               {
+                       if (!strcmp(it->appId, mmsRecvData->msgAppId.appId))
+                       {
+                               MSG_DEBUG("Send incoming java msg to listener %d", it->listenerFd);
+                               write(it->listenerFd, pEventData, eventSize);
+                       }
+               }
+               else
+               {
+                       if (strlen(it->appId) <= 0)
+                       {
+                               MSG_DEBUG("Send incoming normal msg to listener %d", it->listenerFd);
+                               write(it->listenerFd, pEventData, eventSize);
+                       }
+               }
+       }
+
+
+       MSG_END();
+}
+
+
+void MsgTransactionManager::broadcastSyncMLMsgCB(const MSG_ERROR_T err, const MSG_SYNCML_MESSAGE_DATA_S *syncMLData)
+{
+       MSG_BEGIN();
+
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       int eventSize = MsgMakeEvent(syncMLData, sizeof(MSG_SYNCML_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, err, (void**)(&pEventData));
+
+       syncmlmsg_list::iterator it = newSyncMLMsgCBList.begin();
+
+       for (; it != newSyncMLMsgCBList.end(); it++)
+       {
+               MSG_DEBUG("Send incoming SyncML information to listener %d", it->listenerFd);
+               write(it->listenerFd, pEventData, eventSize);
+       }
+
+       MSG_END();
+}
+
+
+void MsgTransactionManager::broadcastLBSMsgCB(const MSG_ERROR_T err, const MSG_LBS_MESSAGE_DATA_S *lbsData)
+{
+       MSG_BEGIN();
+
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       int eventSize = MsgMakeEvent(lbsData, sizeof(MSG_LBS_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, err, (void**)(&pEventData));
+
+       lbsmsg_list::iterator it = newLBSMsgCBList.begin();
+
+       for (; it != newLBSMsgCBList.end(); it++)
+       {
+               MSG_DEBUG("Send incoming LBS msg to listener %d", it->listenerFd);
+               write(it->listenerFd, pEventData, eventSize);
+       }
+
+       MSG_END();
+}
+
+
+void MsgTransactionManager::broadcastSyncMLMsgOperationCB(const MSG_ERROR_T err, const int msgId, const int extId)
+{
+       MSG_BEGIN();
+
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       // Encoding Storage Change Data
+       int dataSize = MsgEncodeSyncMLOperationData(msgId, extId, &encodedData);
+
+       int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_SYNCML_OPERATION, err, (void**)(&pEventData));
+
+       syncmlop_list::iterator it = operationSyncMLMsgCBList.begin();
+
+       for( ; it != operationSyncMLMsgCBList.end() ; it++ )
+       {
+               MSG_DEBUG("Send SyncML operation to listener %d", it->listenerFd);
+               write(it->listenerFd, pEventData, eventSize);
+       }
+
+       MSG_END();
+}
+
+
+void MsgTransactionManager::broadcastStorageChangeCB(const MSG_ERROR_T err, const MSG_STORAGE_CHANGE_TYPE_T storageChangeType, const MSG_MSGID_LIST_S *pMsgIdList)
+{
+       MSG_BEGIN();
+
+       if(pMsgIdList == NULL) {
+               MSG_DEBUG("pMsgIdList is NULL.");
+               return;
+       }
+
+       MSG_DEBUG("storageChangeType [%d]", storageChangeType);
+
+       int dataSize = 0;
+
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       // Encoding Storage Change Data
+       dataSize = MsgEncodeStorageChangeData(storageChangeType, pMsgIdList, &encodedData);
+
+       int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_STORAGE_CHANGE_IND, err, (void**)(&pEventData));
+
+       fd_map::iterator it = storageChangeFdMap.begin();
+
+       for (; it != storageChangeFdMap.end(); it++)
+       {
+               MSG_DEBUG("Send Storage Change Callback to listener %d", it->first);
+               write(it->first, pEventData, eventSize);
+       }
+
+       MSG_END();
+}
+
+
+void MsgTransactionManager::setTMStatus()
+{
+       MSG_BEGIN();
+       mx.lock();
+       cv.signal();
+       mx.unlock();
+       MSG_END();
+}
+
+
+void MsgTransactionManager::getTMStatus()
+{
+       MSG_BEGIN();
+       mx.lock();
+
+       int ret = 0;
+
+       ret = cv.timedwait(mx.pMutex(), 3);
+
+       mx.unlock();
+
+       if (ret == ETIMEDOUT)
+       {
+               MSG_DEBUG("MsgTransactionManager::getTMStatus TIME-OUT");
+       }
+       MSG_END();
+}
diff --git a/image/messaging_image001.png b/image/messaging_image001.png
new file mode 100755 (executable)
index 0000000..0c575c4
Binary files /dev/null and b/image/messaging_image001.png differ
diff --git a/include/common/MsgCmdTypes.h b/include/common/MsgCmdTypes.h
new file mode 100755 (executable)
index 0000000..b56839a
--- /dev/null
@@ -0,0 +1,221 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_CMD_TYPES_H
+#define MSG_CMD_TYPES_H
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgTypes.h"
+
+
+/*==================================================================================================
+                                         DEFINES
+==================================================================================================*/
+#define MAX_COOKIE_LEN 20
+
+
+/*==================================================================================================
+                                         TYPES
+==================================================================================================*/
+typedef unsigned int MSG_CMD_TYPE_T;
+
+typedef unsigned int MSG_EVENT_TYPE_T;
+
+
+/*==================================================================================================
+                                         STRUCTURES
+==================================================================================================*/
+typedef struct _MSG_CMD_S
+{
+       MSG_CMD_TYPE_T  cmdType;
+       char                            cmdCookie[MAX_COOKIE_LEN];
+       char                            cmdData[2];
+} MSG_CMD_S;
+
+
+typedef struct _MSG_EVENT_S
+{
+       MSG_EVENT_TYPE_T        eventType;
+       MSG_ERROR_T                     result;
+       char                                    data[2];
+} MSG_EVENT_S;
+
+
+/*==================================================================================================
+                                         ENUMS
+==================================================================================================*/
+
+enum _MSG_CMD_TYPE_E
+{
+       MSG_CMD_OPEN_HANDLE = 0,
+       MSG_CMD_CLOSE_HANDLE,
+       MSG_CMD_GET_STORAGELIST,
+       MSG_CMD_ADD_MSG,
+       MSG_CMD_ADD_SYNCML_MSG,
+
+// 05
+       MSG_CMD_UPDATE_MSG,
+       MSG_CMD_UPDATE_READ,
+       MSG_CMD_UPDATE_PROTECTED,
+       MSG_CMD_DELETE_MSG,
+       MSG_CMD_DELALL_MSGINFOLDER,
+
+// 10
+       MSG_CMD_MOVE_MSGTOFOLDER,
+       MSG_CMD_MOVE_MSGTOSTORAGE,
+       MSG_CMD_COUNT_MSG,
+       MSG_CMD_GET_MSG,
+       MSG_CMD_GET_FOLDERVIEWLIST,
+
+// 15
+       MSG_CMD_ADD_FOLDER,
+       MSG_CMD_UPDATE_FOLDER,
+       MSG_CMD_DELETE_FOLDER,
+       MSG_CMD_GET_FOLDERLIST,
+       MSG_CMD_SET_CONFIG,
+
+// 20
+       MSG_CMD_GET_CONFIG,
+       MSG_CMD_GET_MSG_TYPE,
+       MSG_CMD_SUBMIT_REQ,
+       MSG_CMD_CANCEL_REQ,
+       MSG_CMD_REG_SENT_STATUS_CB,
+
+// 25
+       MSG_CMD_REG_STORAGE_CHANGE_CB,
+       MSG_CMD_REG_INCOMING_MSG_CB,
+       MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB,
+       MSG_CMD_REG_INCOMING_SYNCML_MSG_CB,
+       MSG_CMD_REG_INCOMING_LBS_MSG_CB,
+
+// 30
+       MSG_CMD_PLG_SENT_STATUS_CNF,
+       MSG_CMD_PLG_STORAGE_CHANGE_IND,
+       MSG_CMD_PLG_INCOMING_MSG_IND,
+       MSG_CMD_PLG_INCOMING_MMS_CONF,
+       MSG_CMD_PLG_INCOMING_SYNCML_IND,
+
+// 35
+       MSG_CMD_PLG_INCOMING_LBS_IND,
+       MSG_CMD_PLG_INIT_SIM_BY_SAT,
+       MSG_CMD_GET_THREADVIEWLIST,
+       MSG_CMD_GET_CONVERSATIONVIEWLIST,
+       MSG_CMD_DELETE_THREADMESSAGELIST,
+
+// 40
+       MSG_CMD_GET_CONTACT_COUNT,
+       MSG_CMD_GET_QUICKPANEL_DATA,
+       MSG_CMD_COUNT_BY_MSGTYPE,
+       MSG_CMD_RESET_DB,
+       MSG_CMD_GET_MEMSIZE,
+
+// 45
+       MSG_CMD_BACKUP_MESSAGE,
+       MSG_CMD_RESTORE_MESSAGE,
+       MSG_CMD_UPDATE_THREAD_READ,
+       MSG_CMD_REG_SYNCML_MSG_OPERATION_CB,
+       MSG_CMD_SYNCML_OPERATION,
+
+// 50
+       MSG_CMD_GET_REPORT_STATUS,
+
+// end of MSG_CMD; new CMD should be defined before MSG_CMD_NUM
+       MSG_CMD_NUM
+};
+
+
+enum _MSG_EVENT_TYPE_E
+{
+       MSG_EVENT_OPEN_HANDLE = 0,
+       MSG_EVENT_CLOSE_HANDLE,
+       MSG_EVENT_GET_STORAGELIST,
+       MSG_EVENT_ADD_MSG,
+       MSG_EVENT_ADD_SYNCML_MSG,
+
+// 5
+       MSG_EVENT_UPDATE_MSG,
+       MSG_EVENT_UPDATE_READ,
+       MSG_EVENT_UPDATE_PROTECTED,
+       MSG_EVENT_DELETE_MSG,
+       MSG_EVENT_DELALL_MSGINFOLDER,
+
+// 10
+       MSG_EVENT_MOVE_MSGTOFOLDER,
+       MSG_EVENT_MOVE_MSGTOSTORAGE,
+       MSG_EVENT_COUNT_MSG,
+       MSG_EVENT_GET_MSG,
+       MSG_EVENT_GET_FOLDERVIEWLIST,
+
+// 15
+       MSG_EVENT_ADD_FOLDER,
+       MSG_EVENT_UPDATE_FOLDER,
+       MSG_EVENT_DELETE_FOLDER,
+       MSG_EVENT_GET_FOLDERLIST,
+       MSG_EVENT_SET_CONFIG,
+
+// 20
+       MSG_EVENT_GET_CONFIG,
+       MSG_EVENT_GET_MSG_TYPE,
+       MSG_EVENT_SUBMIT_REQ,
+       MSG_EVENT_CANCEL_REQ,
+       MSG_EVENT_REG_SENT_STATUS_CB,
+
+// 25
+       MSG_EVENT_REG_INCOMING_MSG_CB,
+       MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB,
+       MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB,
+       MSG_EVENT_REG_INCOMING_LBS_MSG_CB,
+       MSG_EVENT_REG_STORAGE_CHANGE_CB,
+
+// 30
+       MSG_EVENT_PLG_SENT_STATUS_CNF,
+       MSG_EVENT_PLG_STORAGE_CHANGE_IND,
+       MSG_EVENT_PLG_INCOMING_MSG_IND,
+       MSG_EVENT_PLG_INCOMING_MMS_CONF,
+       MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND,
+
+// 35
+       MSG_EVENT_PLG_INCOMING_LBS_MSG_IND,
+       MSG_EVENT_PLG_INIT_SIM_BY_SAT,
+       MSG_EVENT_GET_THREADVIEWLIST,
+       MSG_EVENT_GET_CONVERSATIONVIEWLIST,
+       MSG_EVENT_DELETE_THREADMESSAGELIST,
+
+// 40
+       MSG_EVENT_GET_CONTACT_COUNT,
+       MSG_EVENT_GET_QUICKPANEL_DATA,
+       MSG_EVENT_COUNT_BY_MSGTYPE,
+       MSG_EVENT_RESET_DB,
+       MSG_EVENT_GET_MEMSIZE,
+
+// 45
+       MSG_EVENT_BACKUP_MESSAGE, 
+       MSG_EVENT_RESTORE_MESSAGE, 
+       MSG_EVENT_UPDATE_THREAD_READ,
+       MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB,
+       MSG_EVENT_SYNCML_OPERATION,
+
+// 50
+       MSG_EVENT_GET_REPORT_STATUS,
+
+// end of MSG_EVENT; new EVENT should be defined before MSG_EVENT_NUM
+       MSG_EVENT_NUM
+};
+
+#endif // MSG_CMD_TYPES_H
+
diff --git a/include/common/MsgCppTypes.h b/include/common/MsgCppTypes.h
new file mode 100755 (executable)
index 0000000..ec4d34d
--- /dev/null
@@ -0,0 +1,51 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef __MSG_CPP_TYPES_H__
+#define __MSG_CPP_TYPES_H__
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <stdio.h>
+#include <vector>
+
+typedef std::vector<char> CharVector;
+
+template <class T>
+
+class AutoPtr
+{
+private:
+       T** ptr; // Caution: Memory allocation should be done by "new" not "malloc"
+
+
+public:
+       AutoPtr():ptr(NULL) {}
+
+       AutoPtr(T** target) { ptr = target; }
+
+       ~AutoPtr()
+       {
+               if (ptr)
+               {
+                       if ( *ptr )     delete[] *ptr;
+               }
+       }
+};
+
+#endif // #ifndef __MSG_CPP_TYPES_H__
+
diff --git a/include/common/MsgInternalTypes.h b/include/common/MsgInternalTypes.h
new file mode 100755 (executable)
index 0000000..dc17581
--- /dev/null
@@ -0,0 +1,512 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_INTERNAL_TYPES_H
+#define MSG_INTERNAL_TYPES_H
+
+/**
+ *     @file           MsgInternalTypes.h
+ *     @brief          Defines types of messaging framework
+ *     @version        1.0
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgMmsTypes.h"
+
+/*==================================================================================================
+                                    DEFINES
+==================================================================================================*/
+#define MSG_DATA_ROOT_PATH             "/opt/data/msg-service/"
+#define MSG_DATA_PATH                  MSG_DATA_ROOT_PATH"msgdata/"
+#define MSG_SMIL_FILE_PATH             MSG_DATA_ROOT_PATH"smildata/"
+#define MSG_IPC_DATA_PATH              MSG_DATA_ROOT_PATH"ipcdata/"
+#define MSG_THUMBNAIL_PATH             MSG_DATA_PATH"thumbnails/"
+#define MAX_FULL_PATH_SIZE             320     // max length for internal file path
+#define VALID_ADDRESS_LEN              8
+#define MAX_PRECONFIG_NUM              8
+#define MAX_THREAD_ADDR_LEN    40
+#define MAX_THREAD_NAME_LEN    195
+#define MAX_THREAD_DATA_LEN    128
+
+#define SMS_MINIMUM_SPACE              (3 * 1024)
+#define MMS_MINIMUM_SPACE              (600 * 1024)
+
+/*vconf keys*/
+#define MSG_SIM_CHANGED                "memory/msg/sim_changed"
+
+#define DEFAULT_SETTING_PATH                   "db/msg"
+
+#define DEFAULT_GENERAL_OPT_PATH               DEFAULT_SETTING_PATH"/general"
+#define DEFAULT_SMS_SEND_OPT_PATH      DEFAULT_SETTING_PATH"/sms_send"
+#define DEFAULT_SMSC_INFO_PATH                 DEFAULT_SETTING_PATH"/smsc"
+#define DEFAULT_MMS_SEND_OPT_PATH      DEFAULT_SETTING_PATH"/mms_send"
+#define DEFAULT_MMS_RECV_OPT_PATH      DEFAULT_SETTING_PATH"/mms_recv"
+#define DEFAULT_MMS_STYLE_OPT_PATH     DEFAULT_SETTING_PATH"/mms_style"
+#define DEFAULT_PUSH_MSG_OPT_PATH      DEFAULT_SETTING_PATH"/push_msg"
+#define DEFAULT_CB_MSG_OPT_PATH                DEFAULT_SETTING_PATH"/cb_msg"
+#define DEFAULT_VOICE_MAIL_OPT_PATH    DEFAULT_SETTING_PATH"/voice_mail"
+#define DEFAULT_MSGSIZE_OPT_PATH               DEFAULT_SETTING_PATH"/size_opt"
+#define DEFAULT_SIM_COUNT_PATH         DEFAULT_SETTING_PATH"/sim_count"
+
+#define MSG_KEEP_COPY                                  DEFAULT_GENERAL_OPT_PATH"/keep_copy"
+#define MSG_ALERT_TONE                                 VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT
+#define MSG_AUTO_ERASE                                 DEFAULT_GENERAL_OPT_PATH"/auto_erase"
+#define MSG_BLOCK_MESSAGE                              DEFAULT_GENERAL_OPT_PATH"/block_msg"
+#define CONTACT_SYNC_TIME              DEFAULT_GENERAL_OPT_PATH"/contact_sync_time"
+
+#define SMS_SEND_DCS                                   DEFAULT_SMS_SEND_OPT_PATH"/dcs"
+#define SMS_SEND_NETWORK_MODE          VCONFKEY_MESSAGE_NETWORK_MODE
+#define SMS_SEND_REPLY_PATH                    DEFAULT_SMS_SEND_OPT_PATH"/reply_path"
+#define SMS_SEND_DELIVERY_REPORT               DEFAULT_SMS_SEND_OPT_PATH"/delivery_report"
+#define SMS_SEND_SAVE_STORAGE                  DEFAULT_SMS_SEND_OPT_PATH"/save_storage"
+
+#define SMSC_TOTAL_COUNT                               DEFAULT_SMSC_INFO_PATH"/total_count"
+#define SMSC_SELECTED                                  DEFAULT_SMSC_INFO_PATH"/selected"
+#define SMSC_PID                                               DEFAULT_SMSC_INFO_PATH"/pid"
+#define SMSC_VAL_PERIOD                                DEFAULT_SMSC_INFO_PATH"/val_period"
+#define SMSC_NAME                                              DEFAULT_SMSC_INFO_PATH"/name"
+#define SMSC_TON                                               DEFAULT_SMSC_INFO_PATH"/ton"
+#define SMSC_NPI                                               DEFAULT_SMSC_INFO_PATH"/npi"
+#define SMSC_ADDRESS                                   DEFAULT_SMSC_INFO_PATH"/address"
+
+#define MMS_SEND_MSG_CLASS                                     DEFAULT_MMS_SEND_OPT_PATH"/msg_class"
+#define MMS_SEND_PRIORITY                                              DEFAULT_MMS_SEND_OPT_PATH"/priority"
+#define MMS_SEND_EXPIRY_TIME                                   DEFAULT_MMS_SEND_OPT_PATH"/expiry_time"
+#define MMS_SEND_CUSTOM_DELIVERY                               DEFAULT_MMS_SEND_OPT_PATH"/custom_delivery"
+#define MMS_SEND_DELIVERY_TIME                         DEFAULT_MMS_SEND_OPT_PATH"/delivery_time"
+#define MMS_SEND_SENDER_VISIBILITY                     DEFAULT_MMS_SEND_OPT_PATH"/sender_visibility"
+#define MMS_SEND_DELIVERY_REPORT                               DEFAULT_MMS_SEND_OPT_PATH"/delivery_report"
+#define MMS_SEND_READ_REPLY                                    DEFAULT_MMS_SEND_OPT_PATH"/read_reply"
+#define MMS_SEND_KEEP_COPY                                     DEFAULT_MMS_SEND_OPT_PATH"/keep_copy"
+#define MMS_SEND_BODY_REPLYING                         DEFAULT_MMS_SEND_OPT_PATH"/body_replying"
+#define MMS_SEND_HIDE_RECIPIENTS                               DEFAULT_MMS_SEND_OPT_PATH"/hide_recipients"
+#define MMS_SEND_REPORT_ALLOWED                                DEFAULT_MMS_SEND_OPT_PATH"/report_allowed"
+#define MMS_SEND_REPLY_CHARGING                                DEFAULT_MMS_SEND_OPT_PATH"/reply_charging"
+#define MMS_SEND_REPLY_CHARGING_DEADLINE       DEFAULT_MMS_SEND_OPT_PATH"/reply_charging_deadline"
+#define MMS_SEND_REPLY_CHARGING_SIZE                   DEFAULT_MMS_SEND_OPT_PATH"/reply_charging_size"
+#define MMS_SEND_CREATION_MODE                         DEFAULT_MMS_SEND_OPT_PATH"/creation_mode"
+
+#define MMS_RECV_HOME_NETWORK          DEFAULT_MMS_RECV_OPT_PATH"/home_network"
+#define MMS_RECV_ABROAD_NETWORK                DEFAULT_MMS_RECV_OPT_PATH"/abroad_network"
+#define MMS_RECV_READ_RECEIPT                  DEFAULT_MMS_RECV_OPT_PATH"/read_receipt"
+#define MMS_RECV_DELIVERY_RECEIPT              DEFAULT_MMS_RECV_OPT_PATH"/delivery_receipt"
+#define MMS_RECV_REJECT_UNKNOWN                DEFAULT_MMS_RECV_OPT_PATH"/reject_unknown"
+#define MMS_RECV_REJECT_ADVERTISE              DEFAULT_MMS_RECV_OPT_PATH"/reject_advertisement"
+
+#define MMS_STYLE_FONT_SIZE                            DEFAULT_MMS_STYLE_OPT_PATH"/font_size"
+#define MMS_STYLE_FONT_STYLE_BOLD              DEFAULT_MMS_STYLE_OPT_PATH"/font_style/bold"
+#define MMS_STYLE_FONT_STYLE_ITALIC            DEFAULT_MMS_STYLE_OPT_PATH"/font_style/italic"
+#define MMS_STYLE_FONT_STYLE_UNDERLINE DEFAULT_MMS_STYLE_OPT_PATH"/font_style/underline"
+#define MMS_STYLE_FONT_COLOR_RED                       DEFAULT_MMS_STYLE_OPT_PATH"/font_color/red"
+#define MMS_STYLE_FONT_COLOR_GREEN             DEFAULT_MMS_STYLE_OPT_PATH"/font_color/green"
+#define MMS_STYLE_FONT_COLOR_BLUE              DEFAULT_MMS_STYLE_OPT_PATH"/font_color/blue"
+#define MMS_STYLE_FONT_COLOR_HUE                       DEFAULT_MMS_STYLE_OPT_PATH"/font_color/hue"
+#define MMS_STYLE_BG_COLOR_RED                 DEFAULT_MMS_STYLE_OPT_PATH"/bg_color/red"
+#define MMS_STYLE_BG_COLOR_GREEN                       DEFAULT_MMS_STYLE_OPT_PATH"/bg_color/green"
+#define MMS_STYLE_BG_COLOR_BLUE                        DEFAULT_MMS_STYLE_OPT_PATH"/bg_color/blue"
+#define MMS_STYLE_BG_COLOR_HUE                 DEFAULT_MMS_STYLE_OPT_PATH"/bg_color/hue"
+#define MMS_STYLE_PAGE_DUR                             DEFAULT_MMS_STYLE_OPT_PATH"/page_dur"
+#define MMS_STYLE_PAGE_CUSTOM_DUR              DEFAULT_MMS_STYLE_OPT_PATH"/page_custom_dur"
+#define MMS_STYLE_PAGE_DUR_MANUAL              DEFAULT_MMS_STYLE_OPT_PATH"/page_dur_manual"
+
+#define PUSH_RECV_OPTION                               DEFAULT_PUSH_MSG_OPT_PATH"/recv_option"
+#define PUSH_SERVICE_TYPE                              DEFAULT_PUSH_MSG_OPT_PATH"/service_load"
+
+#define CB_RECEIVE                                             DEFAULT_CB_MSG_OPT_PATH"/receive"
+#define CB_ALL_CHANNEL                                 DEFAULT_CB_MSG_OPT_PATH"/all_channel"
+#define CB_MAX_SIM_COUNT                               DEFAULT_CB_MSG_OPT_PATH"/max_sim_count"
+#define CB_CHANNEL_COUNT                               DEFAULT_CB_MSG_OPT_PATH"/channel_count"
+#define CB_CHANNEL_ACTIVATE                    DEFAULT_CB_MSG_OPT_PATH"/channel_activate"
+#define CB_CHANNEL_ID                                  DEFAULT_CB_MSG_OPT_PATH"/channel_id"
+#define CB_CHANNEL_NAME                                DEFAULT_CB_MSG_OPT_PATH"/channel_name"
+#define CB_LANGUAGE                                    DEFAULT_CB_MSG_OPT_PATH"/language"
+
+#define VOICEMAIL_NUMBER                               DEFAULT_VOICE_MAIL_OPT_PATH"/voice_mail_number"
+
+#define MSGSIZE_OPTION                                 DEFAULT_MSGSIZE_OPT_PATH"/msg_size"
+
+#define SIM_USED_COUNT                                 DEFAULT_SIM_COUNT_PATH"/used_cnt"
+#define SIM_TOTAL_COUNT                                DEFAULT_SIM_COUNT_PATH"/total_cnt"
+
+
+/*==================================================================================================
+                                         TYPES
+==================================================================================================*/
+
+/**
+ *     @brief  Represents a message main type. \n
+ *     The values for this type SHOULD be in _MSG_MAIN_TYPE_E.
+ */
+typedef unsigned char MSG_MAIN_TYPE_T;
+
+
+/**
+ *     @brief  Represents a message sub type. \n
+ *     Each main type of a message can be divided into some sub types. \n
+ *     For instance of SMS, the message sub type can be one of the NORMAL, WAPPUSH, CB and so on. \n
+ *     The values for this type SHOULD be in _MSG_SUB_TYPE_E.
+ */
+typedef unsigned char MSG_SUB_TYPE_T;
+
+
+/**
+ *     @brief  Represents a message class. \n
+ *     The values for this type SHOULD be in _MSG_CLASS_TYPE_E.
+ */
+typedef unsigned char MSG_CLASS_TYPE_T;
+
+
+/**
+ *     @brief  Represents a message class. \n
+ *     The values for this type SHOULD be in _MSG_MMS_TRANSACTION_TYPE_E.
+ */
+typedef unsigned char MSG_MMS_TRANSACTION_TYPE_T;
+
+
+/*==================================================================================================
+                                         STRUCTURES
+==================================================================================================*/
+
+/**
+ *     @brief  Represents a message type.
+ */
+typedef struct
+{
+       MSG_MAIN_TYPE_T         mainType;       /**< Message main type. See enum _MSG_MAIN_TYPE_E */
+       MSG_SUB_TYPE_T          subType;        /**< Message sub type. See enum _MSG_SUB_TYPE_E */
+       MSG_CLASS_TYPE_T        classType;      /**< Message class type. See enum _MSG_CLASS_TYPE_E */
+} MSG_MESSAGE_TYPE_S;
+
+
+/**
+ *     @brief  Represents a message in the framework.
+ */
+typedef struct
+{
+       MSG_MESSAGE_ID_T                msgId;                  /**< Indicates the message ID of this message. */
+       MSG_FOLDER_ID_T                 folderId;                       /**< Indicates the folder ID. */
+       MSG_REFERENCE_ID_T              referenceId;            /**< Indicates group message of messages that is sent together. */
+       MSG_MESSAGE_TYPE_S              msgType;                /**< Indicates the message type such as SMS and MMS */
+       MSG_STORAGE_ID_T                storageId;              /**< Indicates where the message is saved. */
+       int                                             nAddressCnt;    /**< Indicates the count of addresses. */
+       MSG_ADDRESS_INFO_S              addressList[MAX_TO_ADDRESS_CNT];        /**< Indicates the address information list. */
+       char                                            replyAddress[MAX_PHONE_NUMBER_LEN+1];           /**< Indicates the reply address. */
+       char                                            subject[MAX_SUBJECT_LEN+1];                     /**< Indicates the message subject. */
+       time_t                                  displayTime;            /**< Indicates the display time related to the specific operation. */
+       MSG_NETWORK_STATUS_T    networkStatus;  /**< Indicates the network status of the message. */
+       MSG_ENCODE_TYPE_T               encodeType;             /**< Indicates the string encoding type. */
+       bool                                            bRead;                  /**< Indicates whether the message is read or not. */
+       bool                                            bProtected;             /**< Indicates whether the message is protected or not. */
+       bool                                            bBackup;                /**< Indicates whether the message was restored from PC. */
+       MSG_PRIORITY_TYPE_T             priority;                       /**< Indicates the priority of the message. */
+       MSG_DIRECTION_TYPE_T            direction;              /**< Indicates whether the message is MO or MT (affecting address). */
+       MSG_PORT_INFO_S                 msgPort;                /**< Indicates the port number information. */
+       bool                                            bTextSms;               /**< Indicates whether the message is just a text message or not. */
+       size_t                                  dataSize;               /**< Indicates the data size. The unit is byte. */
+       char                                            msgData[MAX_MSG_DATA_LEN+1];            /**< Indicates the message payload information as a body. */
+       char                                            msgText[MAX_MSG_TEXT_LEN+1];
+       char                                            thumbPath[MSG_FILEPATH_LEN_MAX];
+       time_t                                  scheduledTime;  /**< Indicates the time to send scheduled message. */
+} MSG_MESSAGE_INFO_S;
+
+
+typedef struct
+{
+       MSG_MESSAGE_ID_T                msgId;                  /**< Indicates the message ID of this message. */
+       MSG_FOLDER_ID_T                 folderId;               /**< Indicates the folder ID. see enum _MSG_FOLDER_TYPE_E */
+       MSG_REFERENCE_ID_T              referenceId;            /**< Indicates group message of messages that is sent together. */
+       MSG_MESSAGE_TYPE_S              msgType;                /**< Indicates the message type either of SMS or MMS */
+       MSG_STORAGE_ID_T                storageId;              /**< Indicates where the message is saved. see enum _MSG_FOLDER_TYPE_E*/
+       int                                             nAddressCnt;    /**< Indicates the count of addresses. */
+       MSG_ADDRESS_INFO_S              addressList[MAX_TO_ADDRESS_CNT];                /**< Indicates the address information list. */
+       char                                            replyAddress[MAX_PHONE_NUMBER_LEN+1];           /**< Indicates the reply address. */
+       char                                            subject[MAX_SUBJECT_LEN+1];                     /**< Indicates the message subject. */
+       time_t                                  displayTime;    /**< Indicates the display time related to the specific operation. */
+       time_t                                  scheduledTime;  /**< Indicates the time to send scheduled message. */
+       MSG_NETWORK_STATUS_T    networkStatus;  /**< Indicates the network status of the message. */
+       MSG_ENCODE_TYPE_T               encodeType;             /**< Indicates the string encoding type. */
+       bool                                            bRead;                  /**< Indicates whether the message is read or not. */
+       bool                                            bProtected;     /**< Indicates whether the message is protected or not. */
+       bool                                            bBackup;                /**< Indicates whether the message was restored from PC. */
+       MSG_PRIORITY_TYPE_T             priority;               /**< Indicates the priority of the message. */
+       MSG_DIRECTION_TYPE_T            direction;              /**< Indicates whether the message is MO or MT, affecting address. */
+       MSG_PORT_INFO_S                 msgPort;                /**< Indicates the port number information. */
+       int                                             attachCount;            /**< Indicates the count of attached files in mms. */
+       char                                            thumbPath[MSG_FILEPATH_LEN_MAX];
+       size_t                                  dataSize;               /**< Indicates the data size. The unit is byte. */
+       void                                            *pData;                 /**< Indicates the message payload information as a body. default character encoding is UTF-8*/
+       void                                            *pMmsData;                      /**< Indicates the message payload information as a body. default character encoding is UTF-8*/
+} MSG_MESSAGE_S;
+
+
+/**
+ *     @brief  Represents message information for thread view.
+ */
+typedef struct
+{
+       MSG_THREAD_ID_T                 threadId;                                                       /**< Indicates the thread ID of this peer. */
+       char                                            threadAddr[MAX_THREAD_ADDR_LEN+1];      /**< Indicates the address of this peer. > */
+       char                                            threadName[MAX_THREAD_NAME_LEN+1];      /**< Indicates the name of this peer. > */
+       char                                            threadImagePath[MAX_IMAGE_PATH_LEN+1];  /**< Indicates the image path of this peer */
+       MSG_MESSAGE_TYPE_S              threadType;                                                     /**< Indicates the latest msg type. */
+       char                                            threadData[MAX_THREAD_DATA_LEN+1];      /**< Indicates the latest msg data. */
+       time_t                                  threadTime;                                                     /**< Indicates the latest msg time. */
+       MSG_DIRECTION_TYPE_T            direction;                                                              /**< Indicates whether the message is MO or MT (affecting address). */
+
+       MSG_CONTACT_ID_T                contactId;                                                      /**< Indicates the unique contact ID. */
+
+       int                                             unreadCnt;      /**< Indicates the unread messages from the Peer. */
+       int                                             smsCnt;         /**< Indicates the SMS messages from the Peer. */
+       int                                             mmsCnt;         /**< Indicates the MMS messages from the Peer. */
+} MSG_THREAD_VIEW_S;
+
+
+/**
+ *     @brief  Represents message information for conversation view.
+ */
+typedef struct
+{
+       MSG_MESSAGE_ID_T                                msgId;                                                                  /**< Indicates the message ID of this message. */
+       MSG_MESSAGE_TYPE_S                              msgType;                                                                /**< Indicates the message type such as SMS, MMS, and Email. */
+       MSG_STORAGE_ID_T                                storageId;                                                              /**< Indicates where the message is saved. */
+       time_t                                                  displayTime;                                                            /**< Indicates the display time related to the specific operation. */   //MAX_DISPLAY_TIME_LEN
+       char                                                            subject[MAX_SUBJECT_LEN+1];                             /**< Indicates the message subject. */
+       MSG_NETWORK_STATUS_T                    networkStatus;                                                  /**< Indicates the network status of the message. */
+       bool                                                            bRead;                                                                  /**< Indicates whether the message is read or not. */
+       bool                                                            bProtected;                                                             /**< Indicates whether the message is protected or not. */
+       MSG_DIRECTION_TYPE_T                    direction;                                                              /**< Indicates whether the message is MO or MT, affecting address. */
+       char                                                            thumbNailPath[MSG_FILEPATH_LEN_MAX];    /**< Indicates the MMS media thumbnail path.*/
+       char                                                            msgText[MAX_MSG_TEXT_LEN+1];                    /**< Indicates the message payload information as a body. */
+       MSG_DELIVERY_REPORT_STATUS_T    deliveryStatus;                                                 /**< Indicates the message ID of this message. */
+       time_t                                                  deliveryStatusTime;                                             /**< Indicates the display time related to the specific operation. */   //MAX_DISPLAY_TIME_LEN
+       MSG_READ_REPORT_STATUS_T                readStatus;                                                             /**< Indicates the message ID of this message. */
+       time_t                                                  readStatusTime;                                                 /**< Indicates the display time related to the specific operation. */   //MAX_DISPLAY_TIME_LEN
+       int                                                             attachCount;                                                    /**< Indicates the count of attached files in mms. */
+} MSG_CONV_VIEW_S;
+
+
+/**
+ *     @brief  Represents sim message informatioin list.
+ */
+typedef struct
+{
+       int nIdxCnt;            /**< The count of sim index */
+       int nMsgCnt;            /**< The count of sim message */
+       MSG_MESSAGE_INFO_S              *simMsgInfo;            /**< The pointer to sim message informatioin */
+} MSG_SIM_MSG_INFO_LIST_S;
+
+
+/**
+ *     @brief  Represents a request in the framework. \n
+ *     Applications compose a request and send it to the framework via Message handle. \n
+ *     This request ID is used to manage the request by the framework.
+ */
+typedef struct
+{
+       MSG_REQUEST_ID_T                reqId;          /**< Indicates the request ID, which is unique.
+                                                                               When applications submit a request to the framework, this value will be set by the framework. */
+       MSG_MESSAGE_INFO_S              msgInfo;        /**< Indicates the message structure to be sent by applications. */
+       MSG_SENDINGOPT_INFO_S   sendOptInfo;
+} MSG_REQUEST_INFO_S;
+
+
+/**
+ *     @brief  Represents proxy information. \n
+ *     This stucture contains the information about the status cnf of a sent message.
+ */
+typedef struct
+{
+       int                                             listenerFd;             /**< Rx fd for status cnf */
+       unsigned int                    handleAddr;             /**< Handle address for status cnf */
+       MSG_MESSAGE_ID_T                sentMsgId;              /**< The ID of a sent message for updating message status */
+} MSG_PROXY_INFO_S;
+
+
+/**
+ *     @brief  Aux data structure for MSG_CMD_REG_INCOMING_MSG_CB. \n
+ *     This stucture contains the information about the receiver for msgType and port.
+ */
+typedef struct
+{
+       int                             listenerFd;
+       MSG_MAIN_TYPE_T         msgType;
+       unsigned short          port;
+} MSG_CMD_REG_INCOMING_MSG_CB_S;
+
+
+/**
+ *     @brief  Aux data structure for MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB. \n
+ *     This stucture contains the information about the receiver for msgType and port.
+ */
+typedef struct
+{
+       int                             listenerFd;
+       MSG_MAIN_TYPE_T         msgType;
+       char appId[MAX_MMS_JAVA_APPID_LEN+1];
+} MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S;
+
+
+/**
+ *     @brief  Aux data structure for MSG_CMD_REG_INCOMING_SYNCML_MSG_CB. \n
+ *     This stucture contains the information about the receiver for msgType and port.
+ */
+typedef struct
+{
+       int                             listenerFd;
+       MSG_MAIN_TYPE_T         msgType;
+} MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S;
+
+
+/**
+ *     @brief  Aux data structure for MSG_CMD_REG_INCOMING_LBS_MSG_CB_S. \n
+ *     This stucture contains the information about the receiver for msgType and port.
+ */
+typedef struct
+{
+       int                             listenerFd;
+       MSG_MAIN_TYPE_T         msgType;
+} MSG_CMD_REG_INCOMING_LBS_MSG_CB_S;
+
+
+/**
+ *     @brief  Aux data structure for MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S. \n
+ *     This stucture contains the information about the sent Java MMS messge transactionId.
+ */
+typedef struct
+{
+       bool                    posted;
+       char                    id[MMS_TR_ID_LEN+1];
+       char                            pduFileName[MAX_COMMON_INFO_SIZE+1];
+} MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S;
+
+
+/**
+ *     @brief  Aux data structure for MSG_CMD_REG_SYNCML_MSG_OPERATION_CB. \n
+ *     This stucture contains the information about the receiver for msgType and port.
+ */
+typedef struct
+{
+       int                             listenerFd;
+       MSG_MAIN_TYPE_T         msgType;
+} MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S;
+
+
+typedef struct
+{
+       int                                             alarm_id;
+       MSG_REQUEST_INFO_S              reqInfo;
+}MSG_SCHEDULED_MSG_S;
+
+
+/*==================================================================================================
+                                         ENUMS
+==================================================================================================*/
+
+/**
+ *     @brief  Represents the values of a message main type. \n
+ *     Three main types of a message are predefined : SMS, MMS, and Email. More main types of a message can be defined here. \n
+ *     This enum is used as the value of MSG_MAIN_TYPE_T.
+ */
+enum _MSG_MAIN_TYPE_E
+{
+       MSG_UNKNOWN_TYPE = 0,           /**< Unknown main type */
+       MSG_SMS_TYPE,                           /**< SMS */
+       MSG_MMS_TYPE,                           /**< MMS */
+};
+
+
+/**
+ *     @brief  Represents the values of a message sub type. \n
+ *     Three sub types of a message are predefined : NORMAL, WAPPUSH, and CB. More sub types of a message can be defined here. \n
+ *     This enum is used as the value of MSG_SUB_TYPE_T.
+ */
+enum _MSG_SUB_TYPE_E
+{
+       /* SMS Specific Message Type */
+       MSG_NORMAL_SMS = 0,                     /**< Text SMS message */
+       MSG_CB_SMS,                                     /**< Cell Broadcasting  message */
+       MSG_JAVACB_SMS,                         /**< JAVA Cell Broadcasting  message */
+       MSG_TYPE0_SMS,                                  /**< Short Message Type 0 */
+       MSG_REPLACE_TYPE1_SMS,          /**< Replace Short Message Type 1 */
+       MSG_REPLACE_TYPE2_SMS,          /**< Replace Short Message Type 2 */
+       MSG_REPLACE_TYPE3_SMS,          /**< Replace Short Message Type 3 */
+       MSG_REPLACE_TYPE4_SMS,          /**< Replace Short Message Type 4 */
+       MSG_REPLACE_TYPE5_SMS,          /**< Replace Short Message Type 5 */
+       MSG_REPLACE_TYPE6_SMS,          /**< Replace Short Message Type 6 */
+       MSG_REPLACE_TYPE7_SMS,          /**< Replace Short Message Type 7 */
+       MSG_WAP_SI_SMS,                         /**< WAP Push Message SI */
+       MSG_WAP_SL_SMS,                         /**< WAP Push Message SL */
+       MSG_WAP_CO_SMS,                         /**< WAP Push Message CO */
+       MSG_MWI_VOICE_SMS,                      /**< MWI Message Voice */
+       MSG_MWI_FAX_SMS,                                /**< MWI Message Fax */
+       MSG_MWI_EMAIL_SMS,                      /**< MWI Message Email */
+       MSG_MWI_OTHER_SMS,                      /**< MWI Message Other */
+       MSG_STATUS_REPORT_SMS,          /**< SMS-STATUS-REPORT */
+       MSG_SYNCML_CP,                          /**< SyncML Message CP */
+       MSG_LBS_SMS,                                    /**< LBS Message */
+       MSG_REJECT_SMS,                         /**< Reject Message */
+       MSG_CONCAT_SIM_SMS,                     /**< Concatenated Message in SIM */
+
+       /* MMS Specific Message Type */
+       MSG_SENDREQ_MMS = 24,                                   /**< MMS Send Request message */
+       MSG_SENDCONF_MMS,                               /**< MMS Send Confirm message */
+       MSG_NOTIFICATIONIND_MMS,                        /**< MMS Notification Indication message */
+       MSG_GET_MMS,                                            /**< MMS GET MMS message */
+       MSG_NOTIFYRESPIND_MMS,                  /**< MMS Notify Response Indication message */
+       MSG_RETRIEVE_MMS,                                       /**< MMS Retrive MMS message */
+       MSG_RETRIEVE_AUTOCONF_MMS,              /**< MMS Retrieve Confirm message by auto retrieving*/
+       MSG_RETRIEVE_MANUALCONF_MMS,    /**< MMS Retrieve Confirm message by manual retrieving*/
+       MSG_ACKNOWLEGEIND_MMS,                  /**< MMS Acknowledge Indication message */
+       MSG_DELIVERYIND_MMS,                            /**< MMS Delivery Indication message */
+       MSG_READRECIND_MMS,                             /**< MMS Read Receive Indication message */
+       MSG_READORGIND_MMS,                             /**< MMS Read Origin Indication message */
+       MSG_FORWARD_MMS,                                        /**< MMS Forward message */
+       MSG_FORWARDREQ_MMS,                             /**< MMS Forward Request message */
+       MSG_FORWARDCONF_MMS,                    /**< MMS Forward Confirm message */
+       MSG_READREPLY_MMS,                              /**< MMS Read Reply message */
+       MSG_SENDREQ_JAVA_MMS,                   /**< MMS Send Request message for JAVA MMS */
+};
+
+
+/**
+ *     @brief  Represents the values of a message class type. \n
+ *     This enum is used as the value of MSG_CLASS_TYPE_T.
+ */
+enum _MSG_CLASS_TYPE_E
+{
+       MSG_CLASS_0 = 0,                /**< Immediately presented on the recipient device display */
+       MSG_CLASS_1,                    /**< Stored in the mobile equipment or SIM (depending on memory availability) */
+       MSG_CLASS_2,                    /**< Stored in SIM */
+       MSG_CLASS_3,                    /**< Transferred to the terminal equipment (such as PDA or PC) which is connected to the mobile equipment */
+       MSG_CLASS_NONE,
+};
+
+
+/**
+ *     @brief  Represents the values of a message transaction type. \n
+ *     This enum is used as the value of MSG_MMS_TRANSACTION_TYPE_T.
+ */
+enum _MSG_MMS_TRANSACTION_TYPE_E
+{
+       MSG_MMS_SEND_COMPLETE = 0,
+       MSG_MMS_RETRIEVE_COMPLETE,
+       MSG_MMS_UNKNOWN,
+};
+
+#endif
+
diff --git a/include/common/MsgMmsTypes.h b/include/common/MsgMmsTypes.h
new file mode 100755 (executable)
index 0000000..2f61f47
--- /dev/null
@@ -0,0 +1,678 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_MMS_TYPES_H
+#define MSG_MMS_TYPES_H
+
+/**
+ *     @file           MsgMmsTypes.h
+ *     @brief          Defines MMS types of messaging framework
+ *     @version        1.0
+ */
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on MMS message Types
+ *     @section                Program
+ *     - Program : MMS message Types Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgTypes.h"
+
+
+#include <glib.h>
+
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_MMS_TYPES     Messaging MMS Types
+ *     @{
+ */
+
+/*==================================================================================================
+                                                                       DEFINES
+==================================================================================================*/
+
+/**
+ *     @brief  Defines the enabled MMS version
+ */
+#define        MMS_V1_2                                                                // MMS Version : MMS_V1_0 / MMS_V1_1 / MMS_V1_2
+
+/**
+ *     @brief  Defines the enabled DRM support
+ */
+#define        __SUPPORT_DRM__
+
+/**
+ *     @brief  Defines the enabled JAVA MMS Application Id
+ */
+#define FEATURE_JAVA_MMS
+
+/**
+ *     @brief  Defines the maximum file name length
+ */
+#define        MSG_FILENAME_LEN_MAX            255
+
+/**
+ *     @brief  Defines the maximum message id length
+ */
+#define        MSG_MSG_ID_LEN                  100
+
+/**
+ *     @brief  Defines the maximum in transition id length
+ */
+#define MAX_SMIL_TRANSIN_ID            100
+
+/**
+ *     @brief  Defines the maximum out transition id length
+ */
+#define MAX_SMIL_TRANSOUT_ID   100
+
+/**
+ *     @brief  Defines the maximum region id length
+ */
+#define        MAX_SMIL_REGION_ID              151
+
+/**
+ *     @brief  Defines the maximum transition id length
+ */
+#define MAX_SMIL_TRANSITION_ID         151
+
+/**
+ *     @brief  Defines the maximum meta id length
+ */
+#define MAX_SMIL_META_ID               151
+
+/**
+ *     @brief  Defines the maximum meta name length
+ */
+#define MAX_SMIL_META_NAME             100
+
+/**
+ *     @brief  Defines the maximum meta content length
+ */
+#define MAX_SMIL_META_CONTENT          255
+
+/**
+ *     @brief  Defines the maximum fit size
+ */
+#define        MAX_SMIL_FIT_SIZE               31
+
+/**
+ *     @brief  Defines the maximum pages in a MMS
+ */
+#define        MMS_PAGE_MAX                    20
+
+/**
+ *     @brief  Defines the maximum media in a MMS
+ */
+#define        MMS_MEDIA_MAX                   60
+
+/**
+ *     @brief  Defines the maximum alternate text length
+ */
+#define        MAX_SMIL_ALT_LEN                255
+
+
+//font size
+/**
+ *     @brief  Defines the small font size
+ */
+#define        MMS_SMIL_FONT_SIZE_SMALL                24
+
+/**
+ *     @brief  Defines the normal font size
+ */
+#define        MMS_SMIL_FONT_SIZE_NORMAL               30
+
+/**
+ *     @brief  Defines the large font size
+ */
+#define        MMS_SMIL_FONT_SIZE_LARGE                36
+
+//#ifdef MMS_SMIL_ANIMATE
+#define MAX_SMIL_ANIMATE_ATTRIBUTE_NAME 100
+#define MAX_SMIL_ANIMATE_ATTRIBUTE_TYPE 100
+#define MAX_SMIL_ANIMATE_TARGET_ELEMENT 100
+#define MAX_SMIL_ANIMATE_CALC_MODE 100
+//#endif
+
+//#ifdef FEATURE_JAVA_MMS
+#define MAX_MMS_JAVA_APPID_LEN 32
+//#endif
+
+#define CONV_THUMB_WIDTH       250
+#define CONV_THUMB_HEIGHT 170
+
+#define MMS_TR_ID_LEN          40
+#define MMS_MSG_ID_LEN         40
+#define MMS_LOCATION_LEN       100
+
+/*==================================================================================================
+                                         ENUMS
+==================================================================================================*/
+
+/**
+ *     @brief  Represents the values of a mime type.
+ */
+typedef enum   _MimeType
+{
+       // 0
+       MIME_ASTERISK                                                                                   = 0x0000, /**< Indicates the valid default mime type  */
+
+       // 1
+       MIME_APPLICATION_XML                                                                    = 0x1000, /**< Indicates the application xml type */
+       MIME_APPLICATION_WML_XML                                                        = 0x1001,       /**< Indicates the application wml xml type  */
+       MIME_APPLICATION_XHTML_XML                                                      = 0x1002,       /**< Indicates the application xhtml xml type  */
+       MIME_APPLICATION_JAVA_VM                                                                = 0x1003, /**< Indicates the application java vm type */
+       MIME_APPLICATION_SMIL                                                           = 0x1004, /**< Indicates the application smil  type */
+       MIME_APPLICATION_JAVA_ARCHIVE                                           = 0x1005, /**< Indicates the application java archive type */
+       MIME_APPLICATION_JAVA                                                           = 0x1006, /**< Indicates the application java  type */
+       MIME_APPLICATION_OCTET_STREAM                                           = 0x1007, /**< Indicates the application octect stream type */
+       MIME_APPLICATION_STUDIOM                                                        = 0x1008, /**< Indicates the application studiom type */
+       MIME_APPLICATION_FUNMEDIA                                                       = 0x1009, /**< Indicates the application fun media type */
+       MIME_APPLICATION_MSWORD                                                         = 0x100a,       /**< Indicates the application ms word type */
+       MIME_APPLICATION_PDF                                                                    = 0x100b, /**< Indicates the application pdf type */
+       MIME_APPLICATION_SDP                                                                    = 0x100c,  /**< Indicates the application sdp type */
+       MIME_APPLICATION_RAM                                                                    = 0x100d, /**< Indicates the application ram type */
+       MIME_APPLICATION_ASTERIC                                                                = 0x100e, /**< Indicates the application as main type and generic sub type */
+
+       // 16
+       MIME_APPLICATION_VND_WAP_XHTMLXML                                       = 0x1100, /**< Indicates the application wap xhtml xml type */
+       MIME_APPLICATION_VND_WAP_WMLC                                           = 0x1101,  /**< Indicates the application wap wmlc type */
+       MIME_APPLICATION_VND_WAP_WMLSCRIPTC                             = 0x1102,  /**< Indicates the application wap wmlscrpitc type */
+       MIME_APPLICATION_VND_WAP_WTA_EVENTC                             = 0x1103, /**< Indicates the application wap  wta event type */
+       MIME_APPLICATION_VND_WAP_UAPROF                                 = 0x1104, /**< Indicates the application wap uaprof type */
+       MIME_APPLICATION_VND_WAP_SIC                                            = 0x1105,  /**< Indicates the application wap sic type */
+       MIME_APPLICATION_VND_WAP_SLC                                            = 0x1106, /**< Indicates the application wap slc type */
+       MIME_APPLICATION_VND_WAP_COC                                            = 0x1107, /**< Indicates the application wap coc type */
+       MIME_APPLICATION_VND_WAP_SIA                                            = 0x1108, /**< Indicates the application wap sia type */
+       MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML             = 0x1109,  /**< Indicates the application wap connectivity wbxml type */
+       MIME_APPLICATION_VND_WAP_MULTIPART_FORM_DATA    = 0x110a, /**< Indicates the application wap multipart data type */
+       MIME_APPLICATION_VND_WAP_MULTIPART_BYTERANGES   = 0x110b, /**< Indicates the application wap multipart byte type */
+       MIME_APPLICATION_VND_WAP_MULTIPART_MIXED                        = 0x110c,  /**< Indicates the application wap multipart mixed type */
+       MIME_APPLICATION_VND_WAP_MULTIPART_RELATED              = 0x110d,  /**< Indicates the application wap multipart related type */
+       MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE  = 0x110e,  /**< Indicates the application wap  multipart alternative type */
+       MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC              = 0x110f, /**< Indicates the application wap mulitpart as main type and generic sub type */
+       MIME_APPLICATION_VND_WAP_WBXML                                  = 0x1110, /**< Indicates the application wap wbxml type */
+       MIME_APPLICATION_VND_OMA_DD_XML                                 = 0x1111, /**< Indicates the application oma dd xml type */
+       MIME_APPLICATION_VND_OMA_DRM_MESSAGE                            = 0x1112,  /**< Indicates the application oma drm message type */
+       MIME_APPLICATION_VND_OMA_DRM_CONTENT                            = 0x1113, /**< Indicates the application oma drm content type */
+       MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML                 = 0x1114, /**< Indicates the application oma drm rights xml type */
+       MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML               = 0x1115,  /**< Indicates the application oma drm rights wbxml type */
+       MIME_APPLICATION_VND_OMA_DRM_RO_XML                             = 0x1116, /**< Indicates the application oma drm ro xml type */
+       MIME_APPLICATION_VND_OMA_DRM_DCF                                        = 0x1117, /**< Indicates the application oma drm dcf type */
+       MIME_APPLICATION_VND_OMA_ROAPPDU_XML                            = 0x1118,  /**< Indicates the application oma roap pdu xml type */
+       MIME_APPLICATION_VND_OMA_ROAPTRIGGER_XML                        = 0x1119,       /**< Indicates the application oma roap trigger xml  type */
+       MIME_APPLICATION_VND_SMAF                                                       = 0x111a,  /**< Indicates the application smaf type */
+       MIME_APPLICATION_VND_RN_REALMEDIA                                       = 0x111b,  /**< Indicates the application rn real media type */
+       MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE              = 0x111c,  /**< Indicates the application j2me java archive type */
+       MIME_APPLICATION_VND_EXCEL                                                      = 0x111e,  /**< Indicates the application excel type */
+       MIME_APPLICATION_VND_POWERPOINT                                 = 0x111f,  /**< Indicates the application power point type */
+       MIME_APPLICATION_VND_MSWORD                                             = 0x1120,        /**< Indicates the application ms word type */
+
+       // 49
+       MIME_APPLICATION_X_HDMLC                                                        = 0x1200, /**< Indicates the application x hdmlc type */
+       MIME_APPLICATION_X_X968_USERCERT                                        = 0x1201, /**< Indicates the application x x968 user certified type */
+       MIME_APPLICATION_X_WWW_FORM_URLENCODED                  = 0x1202, /**< Indicates the application x www form url encoded type */
+       MIME_APPLICATION_X_SMAF                                                         = 0x1203, /**< Indicates the application x smaf type */
+       MIME_APPLICATION_X_FLASH                                                                = 0x1204, /**< Indicates the application x flash type */
+       MIME_APPLICATION_X_EXCEL                                                                = 0x1205, /**< Indicates the application x excel type */
+       MIME_APPLICATION_X_POWERPOINT                                           = 0x1206, /**< Indicates the application x power point type */
+
+       // 56
+       MIME_AUDIO_BASIC                                                                                = 0x2000, /**< Indicates the audio basic type  */
+       MIME_AUDIO_MPEG                                                                         = 0x2001, /**< Indicates the audio mpeg type  */
+       MIME_AUDIO_MP3                                                                          = 0x2002, /**< Indicates the audio mp3 type  */
+       MIME_AUDIO_MPG3                                                                         = 0x2003,  /**< Indicates the audio mpg3 type  */
+       MIME_AUDIO_MPEG3                                                                                = 0x2004, /**< Indicates the audio mpeg3 type  */
+       MIME_AUDIO_MPG                                                                          = 0x2005, /**< Indicates the audio mpg type  */
+       MIME_AUDIO_AAC                                                                          = 0x2006, /**< Indicates the audio aac type  */
+       MIME_AUDIO_G72                                                                          = 0x2007, /**< Indicates the audio g72 type  */
+       MIME_AUDIO_AMR                                                                          = 0x2008, /**< Indicates the audio amr type  */
+       MIME_AUDIO_AMR_WB                                                                       = 0x2009, /**< Indicates the audio amr wb type  */
+       MIME_AUDIO_MMF                                                                          = 0x200a, /**< Indicates the audio mmf type  */
+       MIME_AUDIO_SMAF                                                                         = 0x200b, /**< Indicates the audio smaf type  */
+       MIME_AUDIO_IMELODY                                                                      = 0x200c, /**< Indicates the audio imelody type  */
+       MIME_AUDIO_IMELODY2                                                                     = 0x200d, /**< Indicates the audio imelody2 type  */
+       MIME_AUDIO_MELODY                                                                       = 0x200e, /**< Indicates the audio melody type  */
+       MIME_AUDIO_MID                                                                          = 0x200f, /**< Indicates the audio mid type  */
+       MIME_AUDIO_MIDI                                                                         = 0x2010, /**< Indicates the audio midi type  */
+       MIME_AUDIO_SP_MIDI                                                                      = 0x2011, /**< Indicates the audio sp midi type  */
+       MIME_AUDIO_WAVE                                                                         = 0x2012, /**< Indicates the audio wave type  */
+       MIME_AUDIO_WAV                                                                          = 0x2013, /**< Indicates the audio wav type  */
+       MIME_AUDIO_3GPP                                                                         = 0x2014, /**< Indicates the audio 3gpp type  */
+       MIME_AUDIO_MP4                                                                          = 0x2015, /**< Indicates the audio mp4 type  */
+       MIME_AUDIO_MP4A_LATM                                                            = 0x2016, /**< Indicates the audio mp4 latm type  */
+       MIME_AUDIO_M4A                                                                          = 0x2017, /**< Indicates the audio m4a type  */
+       MIME_AUDIO_MPEG4                                                                                = 0x2018, /**< Indicates the audio mpeg4 type  */
+       MIME_AUDIO_WMA                                                                          = 0x2019, /**< Indicates the audio wma type  */
+       MIME_AUDIO_XMF                                                                          = 0x201a, /**< Indicates the audio xmf type  */
+       MIME_AUDIO_IMY                                                                          = 0x201b, /**< Indicates the audio imy type  */
+       MIME_AUDIO_MOBILE_XMF                                                           = 0x201c, /**< Indicates the audio mobile xmf type  */
+
+       //85
+       MIME_AUDIO_VND_RN_REALAUDIO                                             = 0x2100, /**< Indicates the audio rn real audio type  */
+
+       // 86
+       MIME_AUDIO_X_MPEG                                                                       = 0x2200, /**< Indicates the audio x mpeg type  */
+       MIME_AUDIO_X_MP3                                                                                = 0x2201, /**< Indicates the audio x mp3 type  */
+       MIME_AUDIO_X_MPEG3                                                                      = 0x2202,    /**< Indicates the audio x mpeg3 type  */
+       MIME_AUDIO_X_MPG                                                                                = 0x2203, /**< Indicates the audio x mpg type  */
+       MIME_AUDIO_X_AMR                                                                                = 0x2204, /**< Indicates the audio x amr type  */
+       MIME_AUDIO_X_MMF                                                                                = 0x2205, /**< Indicates the audio x mmf type  */
+       MIME_AUDIO_X_SMAF                                                                       = 0x2206, /**< Indicates the audio x smaf type  */
+       MIME_AUDIO_X_IMELODY                                                                    = 0x2207, /**< Indicates the audio x imelody type  */
+       MIME_AUDIO_X_MIDI                                                                               = 0x2208, /**< Indicates the audio x midi type  */
+       MIME_AUDIO_X_MPEGAUDIO                                                          = 0x2209, /**< Indicates the audio x mpeg  type  */
+       MIME_AUDIO_X_PN_REALAUDIO                                                       = 0x220a, /**< Indicates the audio x pn real audio type  */
+       MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO                             = 0x220b, /**< Indicates the audio x pn multirate real audio  type  */
+       MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO_LIVE                        = 0x220c, /**< Indicates the audio x pn multirate real audio live type  */
+       MIME_AUDIO_X_WAVE                                                                       = 0x220d, /**< Indicates the audio x wave  type  */
+       MIME_AUDIO_X_WAV                                                                                = 0x220e, /**< Indicates the audio x wav  type  */
+       MIME_AUDIO_X_MS_WMA                                                                     = 0x220f, /**< Indicates the audio ms wma type  */
+       MIME_AUDIO_X_MID                                                                                = 0x2210, /**< Indicates the audio mid type  */
+       MIME_AUDIO_X_MS_ASF                                                                     = 0x2211, /**< Indicates the audio ms asf  type  */
+       MIME_AUDIO_X_XMF                                                                                = 0x2212, /**< Indicates the audio x xmf  type  */
+
+       // 105
+       MIME_IMAGE_GIF                                                                          = 0x3000, /**< Indicates the image gif type  */
+       MIME_IMAGE_JPEG                                                                         = 0x3001, /**< Indicates the image jpeg type  */
+       MIME_IMAGE_JPG                                                                          = 0x3002, /**< Indicates the image jpg type  */
+       MIME_IMAGE_TIFF                                                                         = 0x3003, /**< Indicates the image tiff type  */
+       MIME_IMAGE_TIF                                                                          = 0x3004, /**< Indicates the image tif type  */
+       MIME_IMAGE_PNG                                                                          = 0x3005, /**< Indicates the image png type  */
+       MIME_IMAGE_WBMP                                                                         = 0x3006, /**< Indicates the image wbmp type  */
+       MIME_IMAGE_PJPEG                                                                                = 0x3007, /**< Indicates the image pjpeg type  */
+       MIME_IMAGE_BMP                                                                          = 0x3008, /**< Indicates the image bmp type  */
+       MIME_IMAGE_SVG                                                                          = 0x3009, /**< Indicates the image svg type  */
+       MIME_IMAGE_SVG1                                                                         = 0x300a, /**< Indicates the image svg1 type  */
+
+       // 116
+       MIME_IMAGE_VND_WAP_WBMP                                                 = 0x3100,  /**< Indicates the image vnd wap wbmp type  */
+
+       // 119
+       MIME_IMAGE_X_BMP                                                                                = 0x3200, /**< Indicates the image x bmp type  */
+
+       // 120
+       MIME_MESSAGE_RFC822                                                                     = 0x4000,  /**< Indicates the message rfc822 type  */
+
+       // 121
+       MIME_MULTIPART_MIXED                                                                    = 0x5000,  /**< Indicates the multipart mixed type  */
+       MIME_MULTIPART_RELATED                                                          = 0x5001, /**< Indicates the multipart related type  */
+       MIME_MULTIPART_ALTERNATIVE                                                      = 0x5002, /**< Indicates the multipart alternative type  */
+       MIME_MULTIPART_FORM_DATA                                                        = 0x5003, /**< Indicates the multipart form data type  */
+       MIME_MULTIPART_BYTERANGE                                                        = 0x5004, /**< Indicates the multipart byte range type  */
+       MIME_MULTIPART_REPORT                                                           = 0x5005, /**< Indicates the multipart report type  */
+       MIME_MULTIPART_VOICE_MESSAGE                                            = 0x5006, /**< Indicates the multipart voice message type  */
+
+       // 128
+       MIME_TEXT_TXT                                                                                   = 0x6000, /**< Indicates the text txt type  */
+       MIME_TEXT_HTML                                                                          = 0x6001, /**< Indicates the text html type  */
+       MIME_TEXT_PLAIN                                                                         = 0x6002,  /**< Indicates the text plain type  */
+       MIME_TEXT_CSS                                                                                   = 0x6003,  /**< Indicates the text css type  */
+       MIME_TEXT_XML                                                                                   = 0x6004,  /**< Indicates the text xml type  */
+       MIME_TEXT_IMELODY                                                                               = 0x6005,  /**< Indicates the text imelody type  */
+
+       // 134
+       MIME_TEXT_VND_WAP_WMLSCRIPT                                             = 0x6100, /**< Indicates the text wap wmlscript  type  */
+       MIME_TEXT_VND_WAP_WML                                                           = 0x6101, /**< Indicates the text wap wml  type  */
+       MIME_TEXT_VND_WAP_WTA_EVENT                                             = 0x6102, /**< Indicates the text wap wta event  type  */
+       MIME_TEXT_VND_WAP_CONNECTIVITY_XML                              = 0x6103, /**< Indicates the text wap connectivity xml  type  */
+       MIME_TEXT_VND_WAP_SI                                                                    = 0x6104,  /**< Indicates the text wap si  type  */
+       MIME_TEXT_VND_WAP_SL                                                            = 0x6105, /**< Indicates the text wap sl  type  */
+       MIME_TEXT_VND_WAP_CO                                                            = 0x6106, /**< Indicates the text wap co  type  */
+       MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR                           = 0x6107, /**< Indicates the text sun j2me type  */
+
+       // 142
+       MIME_TEXT_X_HDML                                                                                = 0x6200, /**< Indicates the x html  type  */
+       MIME_TEXT_X_VCALENDAR                                                           = 0x6201,  /**< Indicates the x calendar  type  */
+       MIME_TEXT_X_VCARD                                                                       = 0x6202, /**< Indicates the x vcard  type  */
+       MIME_TEXT_X_IMELODY                                                                     = 0x6203, /**< Indicates the x imelody  type  */
+       MIME_TEXT_X_IMELODY2                                                                    = 0x6204, /**< Indicates the x imelody2  type  */
+       MIME_TEXT_X_VNOTE                                                                       = 0x6205,  /**< Indicates the x vnote  type  */
+
+       // 148
+       MIME_VIDEO_MPEG4                                                                                = 0x7000, /**< Indicates the mpeg4  type  */
+       MIME_VIDEO_MP4                                                                          = 0x7001, /**< Indicates the mp4  type  */
+       MIME_VIDEO_H263                                                                         = 0x7002, /**< Indicates the h263  type  */
+       MIME_VIDEO_3GPP                                                                         = 0x7003, /**< Indicates the 3gpp  type  */
+       MIME_VIDEO_3GP                                                                          = 0x7004, /**< Indicates the 3gp  type  */
+       MIME_VIDEO_AVI                                                                          = 0x7005, /**< Indicates the avi  type  */
+       MIME_VIDEO_SDP                                                                          = 0x7006, /**< Indicates the sdp  type  */
+       MIME_VIDEO_MP4_ES                                                                       = 0x7007, /**< Indicates the mp4 es  type  */
+       MIME_VIDEO_MPEG                                                                         = 0x7008, /**< Indicates the mpeg  type  */
+
+       // 157
+       MIME_VIDEO_VND_RN_REALVIDEO                                                     = 0x7100, /**< Indicates the pn real video type  */
+       MIME_VIDEO_VND_RN_REALMEDIA                                                     = 0x7101, /**< Indicates the pn multi rate real media type  */
+
+       // 159
+       MIME_VIDEO_X_MP4                                                                                = 0x7200, /**< Indicates the video x mp4 type  */
+       MIME_VIDEO_X_PV_MP4                                                                     = 0x7201, /**< Indicates the video x pv mp4 type  */
+       MIME_VIDEO_X_PN_REALVIDEO                                                       = 0x7202, /**< Indicates the x pn real video type  */
+       MIME_VIDEO_X_PN_MULTIRATE_REALVIDEO                             = 0x7203, /**< Indicates the x pn multi rate real video type  */
+       MIME_VIDEO_X_MS_WMV                                                                     = 0x7204, /**< Indicates the x ms wmv type  */
+       MIME_VIDEO_X_MS_ASF                                                                     = 0x7205, /**< Indicates the x ms asf type  */
+       MIME_VIDEO_X_PV_PVX                                                                     = 0x7206, /**< Indicates the x pv pvx type  */
+
+       MIME_TYPE_VALUE_MAX                                                                     = 0x7207,               /**< Indicates the maximum mime type  */
+       MIME_UNKNOWN                                                                                    = 0xffff        /**< Indicates the unknown mime type  */
+
+} MimeType;
+
+/**
+ *     @brief  Represents the values of a DRM type.
+ */
+//#ifdef __SUPPORT_DRM__
+typedef enum
+{
+       MSG_DRM_TYPE_NONE       = 0, /**< Indicates the drm type none */
+       MSG_DRM_TYPE_FL         = 1, /**< Indicates the forward lock */         /* 2004-07-09: forwardLock type */
+       MSG_DRM_TYPE_CD         = 2, /**< Indicates the combined delivery */    /* 2004-07-09: combined delivery type */
+       MSG_DRM_TYPE_SD         = 3, /**< Indicates the separate delivery */    /* 2004-07-09: seperate delivery type */
+       MSG_DRM_TYPE_SSD        = 4     /**< Indicates the special separate delivery */ // 2005-02-28: add Special Sperate Delivery
+}MsgDrmType;
+//#endif
+
+/**
+ *     @brief  Represents the values of a SMIL region type.
+ */
+typedef enum _REGION_FIT_TYPE_T
+{
+       MMSUI_IMAGE_REGION_FIT_HIDDEN,   /**< Indicates the hidden fit type */
+       MMSUI_IMAGE_REGION_FIT_MEET,     /**< Indicates the meet fit type */
+}REGION_FIT_TYPE_T;
+
+
+/**
+ *     @brief  Represents the values of a SMIL media type.
+ */
+typedef enum
+{
+       MMS_SMIL_MEDIA_INVALID = 0, /**< Indicates the invalid media type */
+       MMS_SMIL_MEDIA_IMG,                     /**< Indicates the image media */
+       MMS_SMIL_MEDIA_AUDIO,           /**< Indicates the audio media */
+       MMS_SMIL_MEDIA_VIDEO,           /**< Indicates the video media */
+       MMS_SMIL_MEDIA_TEXT,            /**< Indicates the text media */
+       MMS_SMIL_MEDIA_ANIMATE,         /**< Indicates the animation media */
+       MMS_SMIL_MEDIA_IMG_OR_VIDEO     , /**< Indicates the image or video media */
+       MMS_SMIL_MEDIA_MAX = 0xffffffff,        /**< Indicates the maximum media type */
+}MmsSmilMediaType;
+
+/**
+ *     @brief  Represents the values of a SMIL transition type.
+ */
+typedef enum
+{
+       MMS_SMIL_TRANS_NONE = 0,                /**< Indicates the transition type none */                      /* default */
+       MMS_SMIL_TRANS_SLIDEWIPE = 1,   /**< Indicates the slide wipe transition */
+       MMS_SMIL_TRANS_BARWIPE = 2,             /**< Indicates the bar wipe transition */
+       MMS_SMIL_TRANS_BARNDOORWIPE = 3, /**< Indicates the bar and door wipe transition */
+       MMS_SMIL_TRANS_FADE = 4,                /**< Indicates the fade transition */
+       MMS_SMIL_TRANS_RANDOMBLOCK = 5, /**< Indicates the random block transition */
+       MMS_SMIL_TRANS_ZOOMIN = 6,              /**< Indicates the zoom in transition */
+       MMS_SMIL_TRANS_IRISWIPE = 7,    /**< Indicates the iris wipe transition */
+       MMS_SMIL_TRANS_BOXWIPE = 8,             /**< Indicates the box wipe transition */
+       MMS_SMIL_TRANS_FOURBOXWIPE = 9, /**< Indicates the four box wipe transition */
+       MMS_SMIL_TRANS_PUSHWIPE  =10,   /**< Indicates the push wipe transition */
+       MMS_SMIL_TRANS_ELLIPSEWIPE  = 11 /**< Indicates the ellipse wipe transition */
+}MmsSmilTransType;
+
+/**
+ *     @brief  Represents the values of a SMIL transition sub type.
+ */
+typedef enum
+{
+       MMS_SMIL_TRANS_SUB_NONE = 0,    /**< Indicates the transition sub type none */
+       MMS_SMIL_TRANS_SUB_FROM_LEFT = 1,       /**< Indicates the from left transition */      /* slideWipe's default */
+       MMS_SMIL_TRANS_SUB_FROM_TOP = 2,        /**< Indicates the from top transition */
+       MMS_SMIL_TRANS_SUB_FROM_BOTTOM = 3,     /**< Indicates the from bottom transition */
+       MMS_SMIL_TRANS_SUB_TOP_TO_BOTTOM = 4, /**< Indicates the from top to bottom transition */                       /* barWipe's default */
+       MMS_SMIL_TRANS_SUB_BOTTOM_TO_TOP = 5, /**< Indicates the from bottom to top transition */
+       MMS_SMIL_TRANS_SUB_HORIZONTAL = 6,      /**< Indicates the horizontal transition */             /* barDoorWipe's default */
+    MMS_SMIL_TRANS_SUB_FROM_RIGHT = 7, /**< Indicates the from right transition */
+    MMS_SMIL_TRANS_SUB_VERTICAL = 8 /**< Indicates the vertical transition */
+}MmsSmilTransSubType;
+
+/**
+ *     @brief  Represents the values of a text font type.
+ */
+typedef enum
+{
+       MMS_SMIL_FONT_TYPE_NONE = 0, /**< Indicates the font type none */
+       MMS_SMIL_FONT_TYPE_NORMAL = 1, /**< Indicates the font type normal */
+       MMS_SMIL_FONT_TYPE_ITALIC = 2, /**< Indicates the font type italic */
+       MMS_SMIL_FONT_TYPE_BOLD = 3, /**< Indicates the font type bold */
+       MMS_SMIL_FONT_TYPE_UNDERLINE = 4 /**< Indicates the font type underline */
+}MmsSmilFontType;
+
+/**
+ *     @brief  Represents the values of a MMS text direction.
+ */
+typedef enum   _MmsTextDir{
+       MMS_TEXT_DIRECTION_INVALID = -1, /**< Indicates the invalid direction */
+       MMS_TEXT_DIRECTION_RIGHT = 0,   /**< Indicates the right direction */
+       MMS_TEXT_DIRECTION_DOWN,                /**< Indicates the down direction */            // supported to GC
+} MmsTextDirection;
+
+/**
+ *     @brief  Represents the values of MMS Read Report Sent Status.
+ */
+typedef enum
+{
+       MMS_RECEIVE_READ_REPORT_NO_SEND,        // didn't send yet
+       MMS_RECEIVE_READ_REPORT_MUST_SEND,      // didn't send yet but will send
+       MMS_RECEIVE_READ_REPORT_SENT,           // sent
+       MMS_RECEIVE_READ_REPORT_NO_SENT,        // required but, didn't send by user's choice
+} MmsRecvReadReportSendStatus ;
+
+/**
+ *     @brief  Represents text information.
+ */
+typedef struct  {
+       char                    szTransInId[MAX_SMIL_TRANSIN_ID];  /**< Indicates the In SMIL transition id */
+       char                    szTransOutId[MAX_SMIL_TRANSOUT_ID]; /**< Indicates the Out SMIL transition id */
+       int                             nRepeat; /**< Indicates the text needs to be displayed repeatedly */
+       int                             nBegin;  /**< Indicates the begin time */
+       int                             nEnd;   /**< Indicates the end time */
+       int                             nDurTime; /**< Indicates the duration */
+       int                             nBgColor; /**< Indicates the background color of the text */
+       bool                    bBold;  /**< Indicates whether the text is bold */
+       bool                    bUnderLine; /**< Indicates whether the text is underlined */
+       bool                    bItalic;                /**< Indicates whether the text is Italic */
+       bool                    bReverse;       /**< Indicates whether the text is reversed */
+       MmsTextDirection        nDirection; /**< Indicates the text direction type. see enum MmsTextDirection */
+       //MmsSmilFontType       nFont;  /**< Indicates the text font type. see enum MmsSmilFontType */
+       int                             nSize;  /**< Indicates the font size */
+       int                             nColor; /**< Indicates the font color */
+}MmsSmilText;
+
+/**
+ *     @brief  Represents video information.
+ */
+typedef struct {
+       char                    szTransInId[MAX_SMIL_TRANSIN_ID]; /**< Indicates the In SMIL transition id */
+       char                    szTransOutId[MAX_SMIL_TRANSOUT_ID];  /**< Indicates the Out SMIL transition id */
+       int                             nRepeat; /**< Indicates the video needs to be displayed repeatedly */
+       int                             nBegin;  /**< Indicates the begin time */
+       int                             nEnd;   /**< Indicates the end time */
+       int                             nDurTime;  /**< Indicates the duration */
+       int                             nBgColor;  /**< Indicates the background color of the text */
+}MmsSmilAVI;
+
+/**
+ *     @brief  Represents media information.
+ */
+typedef struct
+{
+       MmsSmilMediaType        mediatype; /**< Indicates the SMIL media type. see enum MmsSmilMediaType */
+
+       char                    szSrc[MSG_FILEPATH_LEN_MAX];/**< Indicates the media source name */
+       char                    szFileName[MSG_FILENAME_LEN_MAX]; /**< Indicates the file name */
+       char                    szFilePath[MSG_FILEPATH_LEN_MAX]; /**< Indicates the file path */
+       char                    szContentID[MSG_MSG_ID_LEN+1]; /**< Indicates the content id */
+       char                    regionId[MAX_SMIL_REGION_ID]; /**< Indicates the region id */
+       char                    szAlt[MAX_SMIL_ALT_LEN]; /**< Indicates the alternative text to be displayed in failure case */
+       MsgDrmType              drmType; /**< Indicates the drm type. see enum MsgDrmType */
+       char                    szDrm2FullPath[MSG_FILEPATH_LEN_MAX];  /**< Indicates the fullpath of the DRM */
+       union{
+               MmsSmilText     sText;  /**< Indicates the text attributes */
+               MmsSmilAVI      sAVI; /**< Indicates the video attributes */
+       } sMedia;
+}MMS_MEDIA_S;
+
+/**
+ *     @brief  Represents attachment information.
+ */
+typedef struct
+{
+       MimeType        mediatype;      /**< Indicates the file mime type. see enum MimeType */
+       char            szFileName[MSG_FILENAME_LEN_MAX]; /**< Indicates the file name */
+       char            szFilePath[MSG_FILEPATH_LEN_MAX]; /**< Indicates the file path */
+       int             fileSize;        /**< Indicates the size of the file */
+       MsgDrmType      drmType; /**< Indicates the drm type. see enum MsgDrmType */
+       char            szDrm2FullPath[MSG_FILEPATH_LEN_MAX]; /**< Indicates the fullpath of the DRM */
+}MMS_ATTACH_S;
+
+/**
+ *     @brief  Represents SMIL page information.
+ */
+typedef struct
+{
+       int             mediaCnt;       /**< The count of the media */
+       GList   *medialist;     /**< The pointer to media list */
+       int             nDur;   /**< Indicates the duration of the page */
+       int             nBegin; /**< Indicates the begin time of the page */
+       int             nEnd;    /**< Indicates the end time of the page */
+       int             nMin;   /**< Indicates the min attribute of the page */
+       int             nMax;   /**< Indicates the max attribute of the page */
+       int             nRepeat;        /**< Indicates the page needs to be displayed repeatedly */
+
+}MMS_PAGE_S;
+
+/**
+ *     @brief  Represents length information.
+ */
+typedef struct
+{
+       bool    bUnitPercent; /**< Indicates the length is in percentage(%) or not */
+       int     value;  /**< Indicates the value for length */
+}MMS_LENGTH;
+
+/**
+ *     @brief  Represents SMIL region information.
+ */
+typedef struct
+{
+       char                            szID[MAX_SMIL_REGION_ID]; /**< Indicates the ID of region information */
+       MMS_LENGTH              nLeft; /**< Indicates the left co-ordinate of the region */
+       MMS_LENGTH              nTop; /**< Indicates the top co-ordinate of the region */
+       MMS_LENGTH              width; /**< Indicates the width of the region */
+       MMS_LENGTH              height; /**< Indicates the width of the region */ // '%' rate should be supported
+       int                             bgColor;        /**< Indicates the background color of the region */
+       REGION_FIT_TYPE_T       fit;    /**< Indicates the fit type. see enum REGION_FIT_TYPE_T */
+
+}MMS_SMIL_REGION;
+
+/**
+ *     @brief  Represents SMIL root layout information.
+ */
+typedef struct
+{
+       MMS_LENGTH      width;          /**< Indicates the width of the root layout */
+       MMS_LENGTH      height;         /**< Indicates the height of the root layout */ // '%' rate should be supported
+       int                     bgColor;                /**< Indicates the background color of the root layout */
+}MMS_SMIL_ROOTLAYOUT;
+
+
+/**
+ *     @brief  Represents SMIL transition information.
+ */
+typedef struct
+{
+       char                                    szID[MAX_SMIL_TRANSITION_ID];   /**< Indicates the ID of transition information */
+       MmsSmilTransType                nType;                                  /**< Indicates the transition type. see enum MmsSmilTransType */
+       MmsSmilTransSubType     nSubType;                               /**< Indicates the transition sub type. see enum MmsSmilTransSubType */
+       int                                     nDur;                                   /**< Indicates the transition duration */
+}MMS_SMIL_TRANSITION;
+
+
+/**
+ *     @brief  Represents SMIL meta information.
+ */
+typedef struct
+{
+       char            szID[MAX_SMIL_META_ID];                         /**< Indicates the ID of meta information */
+       char            szName[MAX_SMIL_META_NAME];             /**< Indicates the Name */
+       char            szContent[MAX_SMIL_META_CONTENT];       /**< Indicates the content */
+}MMS_SMIL_META;
+
+
+/**
+ *     @brief  Represents application id information for JAVA MMS msg.
+ */
+typedef struct
+{
+       bool                    valid;                                                                          /**< Indicates whether application id information is used or not. */
+       char                    appId[MAX_MMS_JAVA_APPID_LEN+1];                        /**< application id, it should not exceed 32 chars */
+       char                    replyToAppId[MAX_MMS_JAVA_APPID_LEN+1]; /**< reply to application id, application id, it should not exceeded 32 chars */
+}MMS_APPID_INFO_S;
+
+
+
+#define                MAX_FULL_PATH_SIZE_S    160     // max length for internal file path
+
+typedef struct
+{
+       char                                    szMsgID[MMS_MSG_ID_LEN+1];
+       char                                    retrievedFilePath[MAX_FULL_PATH_SIZE_S];
+       char                                    szTrID[MMS_TR_ID_LEN+1];
+       MMS_APPID_INFO_S        msgAppId;
+}MMS_RECV_DATA_S;
+
+
+/**
+ *     @brief  Represents MMS message data.
+ */
+typedef struct _MMS_MESSAGE_DATA_S
+{
+       char                                    szSmilFilePath[MSG_FILEPATH_LEN_MAX];   /**< Indicates the SMIL file path */
+       int                                             pageCnt;        /**< The count of the SMIL pages */
+       GList                                   *pagelist;      /**< The pointer to SMIL pages list */
+       int                                             regionCnt;      /**< The count of the SMIL regions */
+       GList                                   *regionlist;    /**< The pointer to SMIL regions list */
+       int                                             attachCnt;      /**< The count of the attachments */
+       GList                                   *attachlist;    /**< The pointer to attachment list */
+       int                                             transitionCnt;  /**< The count of the SMIL transitions information */
+       GList                                   *transitionlist;        /**< The pointer to SMIL transitions list */
+       int                                             metaCnt;        /**< The count of the SMIL meta information */
+       GList                                   *metalist;      /**< The pointer to SMIL meta list */
+       MMS_SMIL_ROOTLAYOUT             rootlayout;     /**< Indicates the root layout information */
+       MMS_APPID_INFO_S                msgAppId;
+}MMS_MESSAGE_DATA_S;
+
+/**
+ *     @}
+ */
+
+
+
+#endif
+
diff --git a/include/common/MsgPluginInterface.h b/include/common/MsgPluginInterface.h
new file mode 100755 (executable)
index 0000000..8f33e89
--- /dev/null
@@ -0,0 +1,1094 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+ /**
+ *     @file           MsgPluginInterface.h
+ *     @brief          Defines plug-ins API of messaging framework
+ *     @version        1.0
+ */
+
+#ifndef MSG_PLUGIN_INTERFACE_H
+#define MSG_PLUGIN_INTERFACE_H
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Messaging Plug-in API
+ *     @section                Program
+ *     - Program : Messaging Plug-in API Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgTransportTypes.h"
+#include "MsgStorageTypes.h"
+#include "MsgSettingTypes.h"
+#include "MsgInternalTypes.h"
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ *     @ingroup        MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_PLUGIN_API    Messaging Plug-in API
+ *     @{
+ */
+
+/*==================================================================================================
+                                         TYPE DEFINES
+==================================================================================================*/
+typedef struct _MSG_PLUGIN_HANDLER_S MSG_PLUGIN_HANDLER_S;
+
+typedef struct _MSG_PLUGIN_LISTENER_S MSG_PLUGIN_LISTENER_S;
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when the plug-in is loaded at Message Framework.
+ * ALL Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Create plug-in handle for Message Framework.
+ * Message Framework will able to reach plugin functions by handle.
+ *
+ * \par Typical use case:
+ * Create plug-in handle.
+ *
+ * \par Method of function operation:
+ * Set handle information by plug-in.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins..
+ *
+ * \param input - handle is Message handle.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_NULL_POINTER              Plug-in handle is invalid.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+MSG_ERROR_T MsgPlgCreateHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle);
+
+
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when the plug-in is finalized at Message Framework.
+ * ALL Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Destroy plug-in handle for Message Framework.
+ *
+ * \par Typical use case:
+ * Destroy plug-in handle.
+ *
+ * \par Method of function operation:
+ * Remove handle information by plug-in.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins..
+ *
+ * \param input - handle is Message handle.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_NULL_POINTER              Plug-in handle is invalid.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+MSG_ERROR_T MsgPlgDestroyHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle);
+
+
+
+
+// Control API
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when the plug-in is loaded at Message Framework.
+ * ALL Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Initializing plug-in.
+ * Precede jobs must done in this function.
+ *
+ * \par Typical use case:
+ * Initializing plug-in.
+ *
+ * \par Method of function operation:
+ * Make up pre-works for plug-in.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins..
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_PLUGIN_REGEVENT   Plug-in's error during operations.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgInitialize)();
+
+
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when the plug-in is loaded at Message Framework.
+ * ALL Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Create plug-in handle for Message Framework.
+ * Message Framework will able to reach plugin functions by handle.
+ *
+ * \par Typical use case:
+ * Create plug-in handle.
+ *
+ * \par Method of function operation:
+ * Set handle information by plug-in.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins..
+ *
+ * \param input - handle is Message handle.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_NULL_POINTER              Plug-in handle is invalid.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgFinalize)();
+
+
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when the plug-in is loaded at Message Framework.
+ * ALL Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Regist listeners to handle incomming messages..
+ * .
+ *
+ * \par Typical use case:
+ * Regist listeners.
+ *
+ * \par Method of function operation:
+ * Set listener informations in plug-in.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins..
+ *
+ * \param input - listener is callback listeners.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgRegisterListener)(MSG_PLUGIN_LISTENER_S *pListener);
+
+
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when Message Framework has to check sim card status.
+ * SMS Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Checking sim card status  for Message Framework.
+ *
+ * \par Typical use case:
+ * To check sim card status.
+ *
+ * \par Method of function operation:
+ * Check SIM card status and return result of sim card is changed or not.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins..
+ *
+ * \param output - bChanged is a boolean type value which shows sim card status.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgCheckSimStatus)(MSG_SIM_STATUS_T *pStatus);
+
+
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when Message Framework has to check device status.
+ * SMS Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Create plug-in handle for Message Framework.
+ * Message Framework will able to reach plugin functions by handle.
+ *
+ * \par Typical use case:
+ * Create plug-in handle.
+ *
+ * \par Method of function operation:
+ * Set handle information by plug-in.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins..
+ *
+ * \param input - handle is Message handle.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_NULL_POINTER              Plug-in handle is invalid.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgCheckDeviceStatus)();
+
+
+// Transport API
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when Message Framework has to submit a message to send.
+ * ALL Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Send message..
+ *
+ * \par Typical use case:
+ * To send messages.
+ *
+ * \par Method of function operation:
+ * Convert message data to raw message data.
+ * Send raw message data to selected network.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins.
+ *
+ * \param input - pReqInfo is message data to send.
+ * \param input - bReqCb shows callback is required.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_PLUGIN_TRANSPORT  Exception is occured in plug-in.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgSubmitRequest)(MSG_REQUEST_INFO_S *pReqInfo, bool bReqCb);
+
+
+// Storage API
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when Message Framework has to save a message to SIM card.
+ * SMS Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Save a message to SIM card.
+ *
+ * \par Typical use case:
+ * To save a message to SIM card..
+ *
+ * \par Method of function operation:
+ * Convert message data to raw message data.
+ * Save the raw message data to SIM card.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins.
+ *
+ * \param input - pMsgInfo is the information of message.
+ * \param output - pSimIdList is the list of messages saved in SIM card.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                               Success in operation.
+ * - MSG_ERR_PLUGIN_SIM_MSG_FULL       SIM card's capacity for SMS message is full.
+ * - MSG_ERR_PLUGIN_STORAGE            Exception is occured in plug-in.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgInitSimMessage)();
+
+
+// Storage API
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when Message Framework has to save a message to SIM card.
+ * SMS Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Save a message to SIM card.
+ *
+ * \par Typical use case:
+ * To save a message to SIM card..
+ *
+ * \par Method of function operation:
+ * Convert message data to raw message data.
+ * Save the raw message data to SIM card.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins.
+ *
+ * \param input - pMsgInfo is the information of message.
+ * \param output - pSimIdList is the list of messages saved in SIM card.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                               Success in operation.
+ * - MSG_ERR_PLUGIN_SIM_MSG_FULL       SIM card's capacity for SMS message is full.
+ * - MSG_ERR_PLUGIN_STORAGE            Exception is occured in plug-in.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgSaveSimMessage)(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList);
+
+
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when Message Framework has to delete a message in SIM card.
+ * SMS Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * delete a message in SIM card.
+ *
+ * \par Typical use case:
+ * To save a message to SIM card..
+ *
+ * \par Method of function operation:
+ * delete a message data in SIM card which is indexed by ID.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins.
+ *
+ * \param input - SimMsgId is the index of the message to delete.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                               Success in operation.
+ * - MSG_ERR_PLUGIN_STORAGE            Exception is occured in plug-in.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgDeleteSimMessage)(MSG_SIM_ID_T SimMsgId);
+
+
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when Message Framework has to set read status of  message in SIM card.
+ * SMS Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Set read status of SIM cad message.
+ *
+ * \par Typical use case:
+ * To set read status of SIM card message.
+ *
+ * \par Method of function operation:
+ * Save the given read status to SIM card message.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins.
+ *
+ * \param input - SimMsgId is the index of the message to set read status.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                               Success in operation.
+ * - MSG_ERR_PLUGIN_STORAGE            Exception is occured in plug-in.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgSetReadStatus)(MSG_SIM_ID_T SimMsgId);
+
+
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when Message Framework has to set read status of  message in SIM card.
+ * SMS Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Set read status of SIM cad message.
+ *
+ * \par Typical use case:
+ * To set read status of SIM card message.
+ *
+ * \par Method of function operation:
+ * Save the given read status to SIM card message.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins.
+ *
+ * \param input - SimMsgId is the index of the message to set read status.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                               Success in operation.
+ * - MSG_ERR_PLUGIN_STORAGE            Exception is occured in plug-in.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgSetMemoryStatus)(MSG_ERROR_T Error);
+
+
+// Setting API
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when Message Framework has to save configuration of network to SIM card.
+ * SMS Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Save configuration information to SIM card.
+ *
+ * \par Typical use case:
+ * To save configuration information to SIM card.
+ *
+ * \par Method of function operation:
+ * Convert information data to raw data.
+ * Save raw data to SIM card.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins.
+ *
+ * \param input - pSetting is information of configuration.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_PLUGIN_SETTING            Exception is occured in plug-in.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgInitConfigData)(MSG_SIM_STATUS_T SimStatus);
+
+
+// Setting API
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when Message Framework has to save configuration of network to SIM card.
+ * SMS Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Save configuration information to SIM card.
+ *
+ * \par Typical use case:
+ * To save configuration information to SIM card.
+ *
+ * \par Method of function operation:
+ * Convert information data to raw data.
+ * Save raw data to SIM card.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins.
+ *
+ * \param input - pSetting is information of configuration.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_PLUGIN_SETTING            Exception is occured in plug-in.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgSetConfigData)(const MSG_SETTING_S *pSetting);
+
+
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when Message Framework has to get configuration of network from SIM card.
+ * SMS Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Get configuration information from SIM card.
+ *
+ * \par Typical use case:
+ * To get configuration information from SIM card.
+ *
+ * \par Method of function operation:
+ * Convert raw data to information data.
+ * Get configuration data from SIM card.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins.
+ *
+ * \param input - pSetting is information of configuration.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_PLUGIN_SETTING            Exception is occured in plug-in.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgGetConfigData)(MSG_SETTING_S *pSetting);
+
+// MMS API
+/**
+
+* \par Description:
+* A Prototype of the function which will be called when Message Framework has to store MMS message.
+* MMS Plug-in SHOULD implement this function.
+*
+* \par Purpose:
+* Save MMS message to plug-in defined DB.
+*
+* \par Typical use case:
+* To save MMS message to plug-in defined DB.
+*
+* \par Method of function operation:
+* Convert MMS Message data to cetain format for plug-in.
+* Save the certain format MMS message information to DB.
+*
+* \par Sync (or) Async:
+* This is a Synchronous API.
+*
+* \par Important notes:
+*  This function MUST be implement by plug-ins.
+*
+* \param input - pMsgInfo is information of MMS message.
+* \param input - pSendOptInfo is information of sending option.
+* \param output - pFileData is the file path of saved MMS message.
+*
+* \return Return Type (int(MSG_ERROR_T)) \n
+* - MSG_SUCCESS                                          Success in operation.
+* - MSG_ERR_PLUGIN_TRANSPORT   Exception is occured in plug-in.
+*
+* \par Prospective clients:
+* Internal/Plug-ins.
+*
+* \par Related functions:
+* None
+*
+* \par Known issues/bugs:
+* None
+*
+*/
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgAddMessage)(MSG_MESSAGE_INFO_S *pMsgInfo,  MSG_SENDINGOPT_INFO_S* pSendOptInfo, char* pFileData);
+
+
+/**
+
+* \par Description:
+* A Prototype of the function which will be called when Message Framework has to process received MMS message indicator.
+* MMS Plug-in SHOULD implement this function.
+*
+* \par Purpose:
+* Process MMS message indicator.
+*
+* \par Typical use case:
+* To process MMS message indicator.
+*
+* \par Method of function operation:
+* Procces MMS Message indicator in options.
+*
+* \par Sync (or) Async:
+* This is a Synchronous API.
+*
+* \par Important notes:
+*  This function MUST be implement by plug-ins.
+*
+* \param input - pMsgInfo is information of MMS message.
+* \param input - pRequest is information of request options.
+* \param output - bRejects shows the reject status.
+*
+* \return Return Type (int(MSG_ERROR_T)) \n
+* - MSG_SUCCESS                                          Success in operation.
+* - MSG_ERR_PLUGIN_TRANSPORT   Exception is occured in plug-in.
+*
+* \par Prospective clients:
+* Internal/Plug-ins.
+*
+* \par Related functions:
+* None
+*
+* \par Known issues/bugs:
+* None
+*
+*/
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgProcessReceivedInd)(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S* pRequest, bool* bReject);
+
+
+/**
+
+* \par Description:
+* A Prototype of the function which will be called when Message Framework has to update MMS message.
+* MMS Plug-in SHOULD implement this function.
+*
+* \par Purpose:
+* Update MMS message to plug-in defined DB.
+*
+* \par Typical use case:
+* To update MMS message to plug-in defined DB.
+*
+* \par Method of function operation:
+* Convert MMS Message data to cetain format for plug-in.
+* Update the certain format MMS message information to DB.
+*
+* \par Sync (or) Async:
+* This is a Synchronous API.
+*
+* \par Important notes:
+*  This function MUST be implement by plug-ins.
+*
+* \param input - pMsgInfo is information of MMS message.
+* \param input - pSendOptInfo is information of sending option.
+* \param output - pFileData is the file path of saved MMS message.
+*
+* \return Return Type (int(MSG_ERROR_T)) \n
+* - MSG_SUCCESS                                          Success in operation.
+* - MSG_ERR_PLUGIN_TRANSPORT   Exception is occured in plug-in.
+*
+* \par Prospective clients:
+* Internal/Plug-ins.
+*
+* \par Related functions:
+* None
+*
+* \par Known issues/bugs:
+* None
+*
+*/
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgUpdateMessage)(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S* pSendOptInfo, char* pFileData);
+
+
+/**
+
+* \par Description:
+* A Prototype of the function which will be called when Message Framework has to get MMS message.
+* MMS Plug-in SHOULD implement this function.
+*
+* \par Purpose:
+* Get MMS message.
+*
+* \par Typical use case:
+* To get MMS message.
+*
+* \par Method of function operation:
+* Get MMS Message from certian plug-in defined DB.
+*
+* \par Sync (or) Async:
+* This is a Synchronous API.
+*
+* \par Important notes:
+*  This function MUST be implement by plug-ins.
+*
+* \param output - pMsg is information of MMS message.
+* \param output - pSendOptInfo is information of sending options.
+* \param output - pMmsMsg is information of MMS messages detail data.
+* \param output - pDestMsg is file path of MMS message.
+*
+* \return Return Type (int(MSG_ERROR_T)) \n
+* - MSG_SUCCESS                                          Success in operation.
+* - MSG_ERR_PLUGIN_TRANSPORT   Exception is occured in plug-in.
+*
+* \par Prospective clients:
+* Internal/Plug-ins.
+*
+* \par Related functions:
+* None
+*
+* \par Known issues/bugs:
+* None
+*
+*/
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgGetMmsMessage)(MSG_MESSAGE_INFO_S* pMsg,   MSG_SENDINGOPT_INFO_S* pSendOptInfo, MMS_MESSAGE_DATA_S* pMmsMsg, char** pDestMsg);
+
+
+/**
+
+* \par Description:
+* A Prototype of the function which will be called when Message Framework has to update reject status of MMS message.
+* MMS Plug-in SHOULD implement this function.
+*
+* \par Purpose:
+* Update reject status of MMS message.
+*
+* \par Typical use case:
+* To update reject status of MMS message.
+*
+* \par Method of function operation:
+* Update reject status of MMS Message from certian plug-in defined DB.
+*
+* \par Sync (or) Async:
+* This is a Synchronous API.
+*
+* \par Important notes:
+*  This function MUST be implement by plug-ins.
+*
+* \param input - pMsgInfo is information of MMS message.
+*
+* \return Return Type (int(MSG_ERROR_T)) \n
+* - MSG_SUCCESS                                          Success in operation.
+* - MSG_ERR_PLUGIN_TRANSPORT   Exception is occured in plug-in.
+*
+* \par Prospective clients:
+* Internal/Plug-ins.
+*
+* \par Related functions:
+* None
+*
+* \par Known issues/bugs:
+* None
+*
+*/
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgUpdateRejectStatus)(MSG_MESSAGE_INFO_S *pMsgInfo);
+
+
+/**
+
+* \par Description:
+* A Prototype of the function which will be called when Message Framework has to compose read report for MMS message.
+* MMS Plug-in SHOULD implement this function.
+*
+* \par Purpose:
+* Compose read report for MMS message.
+*
+* \par Typical use case:
+* To compose read report for MMS message.
+*
+* \par Method of function operation:
+* Compose read report for MMS message.
+* Send read report.
+*
+* \par Sync (or) Async:
+* This is a Synchronous API.
+*
+* \par Important notes:
+*  This function MUST be implement by plug-ins.
+*
+* \param input - pMsgInfo is information of MMS message.
+*
+* \return Return Type (int(MSG_ERROR_T)) \n
+* - MSG_SUCCESS                                          Success in operation.
+* - MSG_ERR_PLUGIN_TRANSPORT   Exception is occured in plug-in.
+*
+* \par Prospective clients:
+* Internal/Plug-ins.
+*
+* \par Related functions:
+* None
+*
+* \par Known issues/bugs:
+* None
+*
+*/
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgComposeReadReport)(MSG_MESSAGE_INFO_S *pMsgInfo);
+
+ /**
+
+ * \par Description:
+ * A Prototype of the function which will be called when Message Framework has to compose read report for MMS message.
+ * MMS Plug-in SHOULD implement this function.
+ *
+ * \par Purpose:
+ * Compose read report for MMS message.
+ *
+ * \par Typical use case:
+ * To compose read report for MMS message.
+ *
+ * \par Method of function operation:
+ * Compose read report for MMS message.
+ * Send read report.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be implement by plug-ins.
+ *
+ * \param input - pMsgInfo is information of MMS message.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_PLUGIN_TRANSPORT  Exception is occured in plug-in.
+ *
+ * \par Prospective clients:
+ * Internal/Plug-ins.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ */
+/*================================================================================================*/
+typedef MSG_ERROR_T (*MsgPlgRestoreMsg)(MSG_MESSAGE_INFO_S *pMsg, char* pRcvdBody, int rcvdBodyLen, char* filePath);
+
+
+// framework defined callbacks.
+typedef void (*MsgPlgOnSentStatus)(MSG_SENT_STATUS_S *pSentStatus);
+typedef void (*MsgPlgOnStorageChange)(MSG_STORAGE_CHANGE_TYPE_T storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo);
+typedef MSG_ERROR_T (*MsgPlgOnMsgIncoming)(MSG_MESSAGE_INFO_S *pMsgInfo);
+typedef MSG_ERROR_T (*MsgPlgOnInitSimBySat)(void);
+typedef MSG_ERROR_T (*MsgPlgOnSyncMLMsgIncoming)(MSG_SYNCML_MESSAGE_DATA_S *pSyncMLData);
+typedef MSG_ERROR_T (*MsgPlgOnLBSMsgIncoming)(MSG_LBS_MESSAGE_DATA_S *pLBSData);
+typedef MSG_ERROR_T (*MsgPlgOnMmsConfIncoming)(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_ID_T *pRequest);
+
+
+/*==================================================================================================
+                                         STRUCTURES
+==================================================================================================*/
+struct _MSG_PLUGIN_LISTENER_S
+{
+       MsgPlgOnSentStatus                      pfSentStatusCb;                 /** The function pointer of sent status callback. */
+       MsgPlgOnStorageChange           pfStorageChangeCb;              /** The function pointer of storage change callback. */
+       MsgPlgOnMsgIncoming                     pfMsgIncomingCb;                        /** The function pointer of receive message callback. */
+       MsgPlgOnInitSimBySat                    pfInitSimBySatCb;                       /** The function pointer of init SIM callback. */
+       MsgPlgOnSyncMLMsgIncoming       pfSyncMLMsgIncomingCb;  /** The function pointer of receive syncML message callback. */
+       MsgPlgOnLBSMsgIncoming          pfLBSMsgIncomingCb;             /** The function pointer of receive LBS message callback. */
+       MsgPlgOnMmsConfIncoming         pfMmsConfIncomingCb;    /** The function pointer of receive MMS conf */
+};
+
+
+struct _MSG_PLUGIN_HANDLER_S
+{
+       MsgPlgInitialize                                pfInitialize;                           /**< The function pointer of initialize. */
+       MsgPlgFinalize                                  pfFinalize;                             /**< The function pointer of finalize. */
+       MsgPlgRegisterListener                  pfRegisterListener;                     /**< The function pointer of register listener. */
+       MsgPlgCheckSimStatus                    pfCheckSimStatus;               /**< The function pointer of check SIM status. */
+       MsgPlgCheckDeviceStatus         pfCheckDeviceStatus;            /**< The function pointer of check device status. */
+       MsgPlgSubmitRequest                     pfSubmitRequest;                /**< The function pointer of submit request. */
+       MsgPlgInitSimMessage                    pfInitSimMessage;                       /**< The function pointer of initialize SIM msg. */
+       MsgPlgSaveSimMessage                    pfSaveSimMessage;               /**< The function pointer of save SIM msg. */
+       MsgPlgDeleteSimMessage          pfDeleteSimMessage;             /**< The function pointer of delete SIM msg. */
+       MsgPlgSetReadStatus                     pfSetReadStatus;                        /**< The function pointer of set read status. */
+       MsgPlgSetMemoryStatus           pfSetMemoryStatus;              /**< The function pointer of set memory status. */
+       MsgPlgInitConfigData                    pfInitConfigData;                       /**< The function pointer of initialize of setting. */
+       MsgPlgSetConfigData                     pfSetConfigData;                        /**< The function pointer of save setting. */
+       MsgPlgGetConfigData                     pfGetConfigData;                        /**< The function pointer of get setting. */
+       MsgPlgRestoreMsg                                pfRestoreMsg;
+       MsgPlgAddMessage                                pfAddMessage;                   /**< The function pointer of  add Message. */
+       MsgPlgProcessReceivedInd                pfProcessReceivedInd;   /**< The function pointer of  Process Notification Ind. */
+       MsgPlgUpdateMessage                     pfUpdateMessage;                /**< The function pointer of Update MMS Message */
+       MsgPlgGetMmsMessage                     pfGetMmsMessage;
+       MsgPlgUpdateRejectStatus                pfUpdateRejectStatus;
+       MsgPlgComposeReadReport                 pfComposeReadReport;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/common/MsgQueue.h b/include/common/MsgQueue.h
new file mode 100755 (executable)
index 0000000..c973056
--- /dev/null
@@ -0,0 +1,98 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef __MsgThdSafeQ_H__
+#define __MsgThdSafeQ_H__
+
+#include <queue>
+#include "MsgMutex.h"
+#include <list>
+
+template <typename T> class MsgThdSafeQ
+{
+public:
+       MsgThdSafeQ(){};
+       void pop_front ();
+       bool front(T* qItem);
+       void push_front(T const & input);
+       void push_back(T const & input);
+       int size();
+       bool empty();
+       void clear();
+private:
+       Mutex mx;
+       std::list <T> q;
+};
+
+/*
+       mx variable guarantees atomic operation in multi-threaded environment.
+       For example, when a thread is executing Pop(), other threads
+       trying to execute one of Pop, Push, Size, Empty are locked.
+*/
+
+template <typename T> void MsgThdSafeQ<T>::pop_front()
+{
+       MutexLocker lock(mx);
+       if( q.empty() ) return;
+
+       q.pop_front();
+}
+
+template <typename T> bool MsgThdSafeQ<T>::front(T* qItem)
+{
+       MutexLocker lock(mx);
+       if( qItem == NULL || q.empty() )
+               return false; // Fail
+
+       *qItem = q.front(); // copy
+
+       return true; // Success
+}
+
+
+template <typename T> void MsgThdSafeQ<T>::push_back(T const & qItem)
+{
+       MutexLocker lock(mx);
+       q.push_back(qItem);
+}
+
+template <typename T> void MsgThdSafeQ<T>::push_front(T const & qItem)
+{
+       MutexLocker lock(mx);
+       q.push_front(qItem);
+}
+
+
+template <typename T> int MsgThdSafeQ<T>::size()
+{
+       MutexLocker lock(mx);
+       return q.size();
+}
+
+template <typename T> bool MsgThdSafeQ<T>::empty()
+{
+       MutexLocker lock(mx);
+       return q.empty();
+}
+
+template <typename T> void MsgThdSafeQ<T>::clear()
+{
+       MutexLocker lock(mx);
+       q.clear();
+}
+
+#endif // __MsgThdSafeQ_H__
+
diff --git a/include/common/MsgSettingTypes.h b/include/common/MsgSettingTypes.h
new file mode 100755 (executable)
index 0000000..f1f273f
--- /dev/null
@@ -0,0 +1,671 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_SETTING_TYPES_H
+#define MSG_SETTING_TYPES_H
+
+/**
+ *     @file           MsgSettingTypes.h
+ *     @brief          Defines setting types of messaging framework
+ *     @version        1.0
+ */
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Messaging Setting Types
+ *     @section                Program
+ *     - Program : Messaging Setting Types Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgTypes.h"
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_SETTING_TYPES Messaging Setting Types
+ *     @{
+ */
+
+/*==================================================================================================
+                                         DEFINES
+==================================================================================================*/
+#define SMSC_NAME_MAX                  127             /* Max SMSC Name Length */
+#define SMSC_ADDR_MAX                  20              /* Max SMSC Adress Length  */
+#define SMSC_LIST_MAX                  5               /* Max List Count of SMSC */
+#define CB_CHANNEL_NAME_MAX    32              /* cb channel name max size */
+#define CB_CHANNEL_MAX                 30              /* cb channel max count */
+#define CB_LANG_TYPE_MAX               10
+
+/*==================================================================================================
+                                         TYPES
+==================================================================================================*/
+
+/**
+ *     @brief  Represents an option type. \n
+ *     The values for this type SHOULD be in _MSG_OPTION_TYPE_E.
+ */
+typedef unsigned int MSG_OPTION_TYPE_T;
+
+
+/**
+ *     @brief  Represents an SMS network mode. \n
+ *     The values for this type SHOULD be in _MSG_SMS_NETWORK_MODE_E.
+ */
+typedef unsigned char MSG_SMS_NETWORK_MODE_T;
+
+
+/**
+ *     @brief  Represents the period of playing alert tone. \n
+ *     The values for this type SHOULD be in _MSG_ALERT_TONE_E.
+ */
+typedef unsigned char MSG_ALERT_TONE_T;
+
+
+/**
+ *     @brief  Represents the default storage to save SMS. \n
+ *     The values for this type SHOULD be in _MSG_SMS_SAVE_STORAGE_E.
+ */
+typedef unsigned char MSG_SMS_SAVE_STORAGE_T;
+
+
+/**
+ *     @brief  Represents the type of number for SMS center address. \n
+ *     The values for this type SHOULD be in _MSG_SMS_TON_E.
+ */
+typedef unsigned char MSG_SMS_TON_T;
+
+
+/**
+ *     @brief  Represents the numbering plan ID for SMS center address. \n
+ *     The values for this type SHOULD be in _MSG_SMS_NPI_E.
+ */
+typedef unsigned char MSG_SMS_NPI_T;
+
+
+/**
+ *     @brief  Represents the protocol ID for SMS center address. \n
+ *     The values for this type SHOULD be in _MSG_SMS_PID_E.
+ */
+typedef unsigned char MSG_SMS_PID_T;
+
+
+/**
+ *     @brief  Represents the validity period of SMS. \n
+ *     The values for this type SHOULD be in _MSG_VAL_PERIOD_E.
+ */
+typedef unsigned char MSG_VAL_PERIOD_T;
+
+
+/**
+ *     @brief  Represents the class type of MMS. \n
+ *     The values for this type SHOULD be in _MSG_MMS_MSG_CLASS_TYPE_E.
+ */
+typedef unsigned char MSG_MMS_MSG_CLASS_TYPE_T;
+
+
+/**
+ *     @brief  Represents the expiry time of MMS. \n
+ *     The values for this type SHOULD be in _MSG_MMS_EXPIRY_TIME_E.
+ */
+typedef unsigned int MSG_MMS_EXPIRY_TIME_T;
+
+
+/**
+ *     @brief  Represents the delivery time of MMS. \n
+ *     The values for this type SHOULD be in _MSG_MMS_DELIVERY_TIME_E.
+ */
+typedef unsigned int MSG_MMS_DELIVERY_TIME_T;
+
+
+/**
+ *     @brief  Represents the reply charging type of MMS. \n
+ *     The values for this type SHOULD be in _MSG_MMS_REPLY_CHARGING_TYPE_E.
+ */
+typedef unsigned char MSG_MMS_REPLY_CHARGING_TYPE_T;
+
+
+/**
+ *     @brief  Represents the creation mode of MMS. \n
+ *     The values for this type SHOULD be in _MSG_MMS_CREATION_MODE_E.
+ */
+typedef unsigned char MSG_MMS_CREATION_MODE_T;
+
+/**
+ *     @brief  Represents the retrieve type for MMS home network. \n
+ *     The values for this type SHOULD be in _MSG_MMS_HOME_RETRIEVE_TYPE_E.
+ */
+typedef unsigned char MSG_MMS_HOME_RETRIEVE_TYPE_T;
+
+
+/**
+ *     @brief  Represents the retrieve type for MMS abroad network. \n
+ *     The values for this type SHOULD be in _MSG_MMS_ABROAD_RETRIEVE_TYPE_E.
+ */
+typedef unsigned char MSG_MMS_ABROAD_RETRIEVE_TYPE_T;
+
+
+/**
+ *     @brief  Represents the frequency of sending MMS read report. \n
+ *     The values for this type SHOULD be in _MSG_MMS_SEND_READ_REPORT_E.
+ */
+typedef unsigned char MSG_MMS_SEND_READ_REPORT_T;
+
+
+/**
+ *     @brief  Represents whether a push message is received or not. \n
+ *     The values for this type SHOULD be in _MSG_PUSH_RECEIVE_TYPE_E.
+ */
+typedef unsigned char MSG_PUSH_RECEIVE_TYPE_T;
+
+
+/**
+ *     @brief  Represents the service type for a push message. \n
+ *     The values for this type SHOULD be in _MSG_PUSH_SERVICE_TYPE_E.
+ */
+typedef unsigned char MSG_PUSH_SERVICE_TYPE_T;
+
+
+/**
+ *     @brief  Represents the language type for a cell broadcasting message. \n
+ *     The values for this type SHOULD be in _MSG_CB_LANGUAGE_TYPE_E.
+ */
+typedef unsigned char MSG_CB_LANGUAGE_TYPE_T;
+
+
+/**
+ *     @brief  Represents the SIM status from telephony. \n
+ *     The values for this type SHOULD be in \ref _MSG_SIM_STATUS_E.
+ */
+typedef unsigned char MSG_SIM_STATUS_T;
+
+
+/*==================================================================================================
+                                         STRUCTURES
+==================================================================================================*/
+
+/**
+ *     @brief  Represents SMSC address information.
+ */
+typedef struct
+{
+       MSG_SMS_TON_T                   ton;                                                            /**< Type of number */
+       MSG_SMS_NPI_T                   npi;                                                            /**< Numbering plan ID */
+       char                                            address[SMSC_ADDR_MAX+1];               /**< SMSC address */
+} MSG_SMSC_ADDRESS_S;
+
+
+/**
+ *     @brief  Represents SMSC data information.
+ */
+typedef struct
+{
+       MSG_SMS_PID_T                   pid;                                                    /**< Protocol idendifier */
+       MSG_VAL_PERIOD_T                valPeriod;                                      /**< Validity period value */
+       char                                            name[SMSC_NAME_MAX+1];          /**< SMSC name */
+       MSG_SMSC_ADDRESS_S              smscAddr;                                       /**< SMSC address structure */
+} MSG_SMSC_DATA_S;
+
+
+/**
+ *     @brief  Represents the information of a cell broadcasting channel.
+ */
+typedef struct
+{
+       bool                    bActivate;                                                      /**< Indicates whether the CB channel is activate or passive. */
+       unsigned int    id;                                                                     /**< Indicates the ID of a CB channel. */
+       char                    name[CB_CHANNEL_NAME_MAX+1];            /**< Indicates the name of a CB channel. */
+} MSG_CB_CHANNEL_INFO_S;
+
+
+/**
+ *     @brief  Represents cell broadcasting channel information.
+ */
+typedef struct
+{
+       int                                             channelCnt;                                     /**< The count of CB channels */
+       MSG_CB_CHANNEL_INFO_S   channelInfo[CB_CHANNEL_MAX];    /**< The structure of CB channel information */
+} MSG_CB_CHANNEL_S;
+
+
+/**
+ *     @brief  Represents an general option.
+ */
+typedef struct
+{
+       bool                                                    bKeepCopy;                      /**< Indicates whether the SMS message copy is kept or not. */
+       MSG_ALERT_TONE_T                        alertTone;                      /**< Indicates the period of playing alert tone. */
+       bool                                                    bAutoErase;                     /**< Indicates whether the auto-erase option is enabled or not. */
+}MSG_GENERAL_OPT_S;
+
+
+/**
+ *     @brief  Represents an SMS send option.
+ */
+typedef struct
+{
+       MSG_ENCODE_TYPE_T                       dcs;                                    /**< Indicates the string encoding type. */
+       MSG_SMS_NETWORK_MODE_T  netMode;                                /**< Indicates the network mode (CS/PS) to send SMS. */
+       bool                                                    bReplyPath;                     /**< Indicates whether the SMS reply path is set or not. */
+       bool                                                    bDeliveryReport;                /**< Indicates whether the SMS delivery report will be sent or not. */
+       MSG_SMS_SAVE_STORAGE_T          saveStorage;                    /**< Indicates the default storage to save SMS. */
+}MSG_SMS_SENDOPT_S;
+
+
+/**
+ *     @brief  Represents an SMSC list.
+ */
+typedef struct
+{
+       int                                             selected;                                                       /**< Selected SMSC index */
+       int                                             totalCnt;                                                       /**< The count of total SMSC addresses */
+       MSG_SMSC_DATA_S                 smscData[SMSC_LIST_MAX];                        /**< SMSC data information list*/
+}MSG_SMSC_LIST_S;
+
+
+/**
+ *     @brief  Represents an MMS send option.
+ */
+typedef struct
+{
+       MSG_MMS_MSG_CLASS_TYPE_T        msgClass;
+       MSG_PRIORITY_TYPE_T                     priority;                               /**< Indicates the priority of the message. */
+       MSG_MMS_EXPIRY_TIME_T           expiryTime;                     /**< Indicates the time when the message is to be removed from the MMSC. */
+       MSG_MMS_DELIVERY_TIME_T         deliveryTime;                   /**< Indicates the message transmission time which is set in the MMSC. */
+       unsigned int                                    customDeliveryTime;     /**< Indicates the message transmission time which is set in the MMSC. */
+       bool                                                    bSenderVisibility;              /**< Indicates whether the address is hidden or not. */
+       bool                                                    bDeliveryReport;                /**< Indicates whether the delivery report will be sent or not. */
+       bool                                                    bReadReply;                     /**< Indicates whether the read report will be sent or not. */
+       bool                                                    bKeepCopy;                      /**< Indicates whether the message copy is kept or not. */
+       bool                                                    bBodyReplying;          /**< Indicates whether the body is included when replying or not. */
+       bool                                                    bHideRecipients;                /**< Indicates whether the recipients are hidden or not. */
+
+       MSG_MMS_REPLY_CHARGING_TYPE_T   replyCharging;
+       unsigned int                                            replyChargingDeadline;
+       unsigned int /*long*/                           replyChargingSize;
+
+       MSG_MMS_CREATION_MODE_T creationMode;
+} MSG_MMS_SENDOPT_S;
+
+
+/**
+ *     @brief  Represents an MMS receive option.
+ */
+typedef struct
+{
+       MSG_MMS_HOME_RETRIEVE_TYPE_T            homeNetwork;    /**< Indicates the retrieve type for MMS home network. */
+       MSG_MMS_ABROAD_RETRIEVE_TYPE_T  abroadNetwok;   /**< Indicates the retrieve type for MMS abroad network. */
+       bool                            readReceipt;                                    /**< Indicates whether the read report will be sent or not. */
+       bool                            bDeliveryReceipt;                       /**< Indicates whether the delivery report will be sent or not. */
+       bool                            bRejectUnknown;                 /**< Indicates whether unknown addresses are rejected or not. */
+       bool                            bRejectAdvertisement;   /**< Indicates whether advertisement is rejected or not. */
+} MSG_MMS_RECVOPT_S;
+
+
+/**
+ *     @brief  Represents an MMS style option.
+ */
+typedef struct
+{
+       unsigned int    fontSize;
+       bool                    bFontStyleBold;
+       bool                    bFontStyleItalic;
+       bool                    bFontStyleUnderline;
+       unsigned int    fontColorRed;
+       unsigned int    fontColorGreen;
+       unsigned int    fontColorBlue;
+       unsigned int    fontColorHue;
+       unsigned int    bgColorRed;
+       unsigned int    bgColorGreen;
+       unsigned int    bgColorBlue;
+       unsigned int    bgColorHue;
+       unsigned int    pageDur;
+       unsigned int    pageCustomDur;
+       unsigned int    pageDurManual;
+} MSG_MMS_STYLEOPT_S;
+
+
+/**
+ *     @brief  Represents a push message option.
+ */
+typedef struct
+{
+       bool                                            bReceive;               /**< Indicates whether the push message is received or not. */
+       MSG_PUSH_SERVICE_TYPE_T serviceType;            /**< Indicates the service type of a push message. */
+} MSG_PUSHMSG_OPT_S;
+
+
+/**
+ *     @brief  Represents a cell broadcasting message option.
+ */
+typedef struct
+{
+       bool                                    bReceive;               /**< Indicates whether the CB message is received or not. */
+       bool                                    bAllChannel;            /**< Indicates whether All Channel's CB message is received or not. */
+       int                                     maxSimCnt;              /**< Indicates the number of channels which can be stored in SIM. */
+       MSG_CB_CHANNEL_S        channelData;            /**< Indicates the cell broadcasting channel information. */
+       bool                                    bLanguage[CB_LANG_TYPE_MAX];            /**< Indicates whether the language name of a cell broadcasting message is set or not. */
+} MSG_CBMSG_OPT_S;
+
+
+/**
+ *     @brief  Represents a voice mail number option.
+ */
+typedef struct
+{
+       char mailNumber[MAX_PHONE_NUMBER_LEN+1];
+} MSG_VOICEMAIL_OPT_S;
+
+
+/**
+ *     @brief  Represents a MMS size option.
+ */
+typedef struct
+{
+       int nMsgSize;
+} MSG_MSGSIZE_OPT_S;
+
+
+/**
+ *     @brief  Represents setting information.
+ */
+typedef struct
+{
+       MSG_OPTION_TYPE_T       type;           /**< The option type in a setting */
+
+       union
+       {
+               MSG_GENERAL_OPT_S               generalOpt;             /**< General option */
+               MSG_SMS_SENDOPT_S               smsSendOpt;             /**< SMS send option */
+               MSG_SMSC_LIST_S                 smscList;                       /**< SMSC list option */
+               MSG_MMS_SENDOPT_S               mmsSendOpt;             /**< MMS send option */
+               MSG_MMS_RECVOPT_S               mmsRecvOpt;             /**< MMS receive option */
+               MSG_MMS_STYLEOPT_S              mmsStyleOpt;            /**< MMS style option */
+               MSG_PUSHMSG_OPT_S               pushMsgOpt;             /**< Push message option */
+               MSG_CBMSG_OPT_S         cbMsgOpt;               /**< Cell broadcasting message option */
+               MSG_VOICEMAIL_OPT_S             voiceMailOpt;           /**< voice mail option */
+               MSG_MSGSIZE_OPT_S               msgSizeOpt;             /**< MMS size option */
+       } option;
+}MSG_SETTING_S;
+
+
+/*==================================================================================================
+                                         ENUMS
+==================================================================================================*/
+
+/**
+ *     @brief  Represents the values of an option type. \n
+ *     This enum is used as the value of MSG_OPTION_TYPE_T.
+ */
+enum _MSG_OPTION_TYPE_E
+{
+       MSG_GENERAL_OPT,                        /**< General option */
+       MSG_SMS_SENDOPT,                        /**< SMS send option */
+       MSG_SMSC_LIST,                          /**< SMSC list option */
+       MSG_MMS_SENDOPT,                        /**< MMS send option */
+       MSG_MMS_RECVOPT,                        /**< MMS receive option */
+       MSG_MMS_CLASSOPT,                       /**< MMS class option such as personal, advertisement, and informational */
+       MSG_MMS_STYLEOPT,                       /**< MMS style option */
+       MSG_PUSHMSG_OPT,                        /**< Push message option */
+       MSG_CBMSG_OPT,                  /**< Cell broadcasting message option */
+       MSG_VOICEMAIL_OPT,                      /**< Voice mail option */
+       MSG_MSGSIZE_OPT,                        /**< Message size option */
+};
+
+
+/**
+ *     @brief  Represents the values of an SMS network mode. \n
+ *     This enum is used as the value of MSG_SMS_NETWORK_MODE_T.
+ */
+enum _MSG_SMS_NETWORK_MODE_E
+{
+       MSG_SMS_NETWORK_PS_ONLY = 0x01,         /**< Packet switched */
+       MSG_SMS_NETWORK_CS_ONLY = 0x02,         /**< Circuit switched */
+       MSG_SMS_NETWORK_PS_FIRST = 0x03,                /**< Packet switching preferred */
+};
+
+
+/**
+ *     @brief  Represents the value of period of playing alert tone. \n
+ *     The values for this type SHOULD be in MSG_ALERT_TONE_T.
+ */
+enum _MSG_ALERT_TONE_E
+{
+       MSG_ALERT_TONE_ONCE,
+       MSG_ALERT_TONE_2MINS,
+       MSG_ALERT_TONE_5MINS,
+       MSG_ALERT_TONE_10MINS,
+};
+
+
+/**
+ *     @brief  Represents the value of a default storage to save SMS. \n
+ *     The values for this type SHOULD be in MSG_SMS_SAVE_STORAGE_T.
+ */
+enum _MSG_SMS_SAVE_STORAGE_E
+{
+       MSG_SMS_SAVE_STORAGE_SIM,
+       MSG_SMS_SAVE_STORAGE_PHONE,
+};
+
+
+/**
+ *     @brief  Represents the values of the type of number for SMS center address. \n
+ *     This enum is used as the value of MSG_SMS_TON_T.
+ */
+enum _MSG_SMS_TON_E
+{
+       MSG_TON_UNKNOWN = 0,                    /**< Unknown */
+       MSG_TON_INTERNATIONAL,          /**< International */
+       MSG_TON_NATIONAL,                               /**< National */
+       MSG_TON_NETWORK,                                /**< Network */
+       MSG_TON_SUBSCRIBER,                     /**< Subscriber */
+       MSG_TON_ALPHANUMERIC,           /**< Alpha numeric */
+       MSG_TON_ABBREVIATED,                    /**< Abbreviated */
+       MSG_TON_RESERVE,                                /**< Reserve */
+};
+
+
+/**
+ *     @brief  Represents the values of the numbering plan ID for SMS center address. \n
+ *     This enum is used as the value of MSG_SMS_NPI_T.
+ */
+enum _MSG_SMS_NPI_E
+{
+       MSG_NPI_UNKNOWN = 0,                    /**< Unknown */
+       MSG_NPI_ISDN = 1,                               /**< ISDN */
+       MSG_NPI_DATA = 3,                               /**< Data */
+       MSG_NPI_TELEX = 4,                              /**< Telex */
+       MSG_NPI_SMSC = 5,                               /**< SMSC */
+       MSG_NPI_NATIONAL = 8,                   /**< National */
+       MSG_NPI_PRIVATE = 9,                    /**< Private */
+       MSG_NPI_IDENTIFICATION_ERMES = 10,              /**< Identification ermes */
+       MSG_NPI_IDENTIFICATION_RESERVED = 0xF           /**< Identification reserved */
+};
+
+
+/**
+ *     @brief  Represents the values of the protocol ID for SMS center address. \n
+ *     This enum is used as the value of MSG_SMS_PID_T.
+ */
+enum  _MSG_SMS_PID_E
+{
+       MSG_PID_NONE,           /**< None */
+       MSG_PID_TEXT,           /**< Text */
+       MSG_PID_VOICE,          /**< Voice */
+       MSG_PID_FAX,            /**< Fax */
+       MSG_PID_X400,           /**< X400 */
+       MSG_PID_ERMES,          /**< Ermes */
+       MSG_PID_EMAIL,          /**< Email */
+       MSG_PID_MAX             /**< Default */
+};
+
+
+/**
+ *     @brief  Represents the values of the Validity Period for SMS center. \n
+ *     This enum is used as the value of MSG_VAL_PERIOD_T.
+ */
+enum  _MSG_VAL_PERIOD_E
+{
+       MSG_VAL_1DAY = 167,
+       MSG_VAL_2DAYS = 168,
+       MSG_VAL_1WEEK = 173,
+       MSG_VAL_2WEEKS = 180,
+       MSG_VAL_MAXIMUM = 255,
+};
+
+
+enum  _MSG_MMS_EXPIRY_TIME_E
+{
+       MSG_EXPIRY_TIME_MAXIMUM = 0,
+       MSG_EXPIRY_TIME_1DAY = 86400,
+       MSG_EXPIRY_TIME_2DAYS = 2*86400,
+       MSG_EXPIRY_TIME_1WEEK = 604800,
+       MSG_EXPIRY_TIME_2WEEKS = 2*604800,
+};
+
+
+enum  _MSG_MMS_DELIVERY_TIME_E
+{
+       MSG_DELIVERY_TIME_IMMEDIATLY = 0,
+       MSG_DELIVERY_TIME_1HOUR = 3600,
+       MSG_DELIVERY_TIME_1DAY = 86400,
+       MSG_DELIVERY_TIME_1WEEK = 604800,
+       MSG_DELIVERY_TIME_CUSTOM
+};
+
+
+enum _MSG_MMS_MSG_CLASS_TYPE_E
+{
+       MSG_CLASS_PERSONAL,                     /**<Personal message class*/
+       MSG_CLASS_ADVERTISEMENT,                /**<Advertisement message class*/
+       MSG_CLASS_INFORMATIONAL,                /**<Informational message class */
+       MSG_CLASS_AUTO,                         /**<Automatic */
+       MSG_CLASS_MAX                                   /**< */
+};
+
+
+enum _MSG_MMS_REPLY_CHARGING_TYPE_E
+{
+       MSG_REPLY_CHARGING_NONE,                                        /**<Reply-Charging none */
+       MSG_REPLY_CHARGING_REQUESTED,                           /**<Reply-Charging requested */
+       MSG_REPLY_CHARGING_REQUESTED_TEXT_ONLY, /**<Reply-Charging requested text-only */
+       MSG_REPLY_CHARGING_ACCEPTED,                            /**<Reply-Charging accepted */
+       MSG_REPLY_CHARGING_ACCEPTED_TEXT_ONLY,  /**<Reply-Charging accepted text-only */
+       MSG_REPLY_CHARGING_MAX
+};
+
+
+enum _MSG_MMS_CREATION_MODE_E
+{
+       MSG_CREATION_MODE_RESTRICTED,
+       MSG_CREATION_MODE_WARNING,
+       MSG_CREATION_MODE_FREE
+};
+
+
+/**
+ *     @brief  Represents the values of the retrieve type for MMS home network. \n
+ *     This enum is used as the value of MSG_MMS_HOME_RETRIEVE_TYPE_T.
+ */
+enum _MSG_MMS_HOME_RETRIEVE_TYPE_E
+{
+       MSG_HOME_AUTO_DOWNLOAD,         /**< Home auto download */
+       MSG_HOME_MANUAL,                                        /**< Home manual */
+       MSG_HOME_RESTRICTED,                            /**< Home restricted */
+       MSG_HOME_REJECT,                                        /**< Home reject */
+       MSG_HOME_MAX                                            /**< Default */
+};
+
+
+/**
+ *     @brief  Represents the values of the retrieve type for MMS abroad network. \n
+ *     This enum is used as the value of MSG_MMS_ABROAD_RETRIEVE_TYPE_T.
+ */
+enum _MSG_MMS_ABROAD_RETRIEVE_TYPE_E
+{
+       MSG_ABROAD_AUTO_DOWNLOAD,       /**< Abroad auto download */
+       MSG_ABROAD_MANUAL,                      /**< Abroad manual */
+       MSG_ABROAD_RESTRICTED,          /**< Abroad restricted */
+       MSG_ABROAD_REJECT,                      /**< Abroad reject */
+       MSG_ABROAD_MAX                          /**< Default */
+};
+
+
+/**
+ *     @brief  Represents the values of the frequency of sending MMS read report. \n
+ *     This enum is used as the value of MSG_MMS_SEND_READ_REPORT_T.
+ */
+enum _MSG_MMS_SEND_READ_REPORT_E
+{
+       MSG_SEND_READ_REPORT_ALWAYS,    /**< Read report always */
+       MSG_SEND_READ_REPORT_NEVER,             /**< Read report never */
+       MSG_SEND_READ_REPORT_REQUEST,   /**< Read report request */
+       MSG_SEND_READ_REPORT_MAX                /**< Default */
+};
+
+
+/**
+ *     @brief  Represents the values of the service type for a push message. \n
+ *     This enum is used as the value of MSG_PUSH_SERVICE_TYPE_T.
+ */
+enum _MSG_PUSH_SERVICE_TYPE_E
+{
+       MSG_PUSH_SERVICE_ALWAYS,        /**< Push message service always */
+       MSG_PUSH_SERVICE_PROMPT,                /**< Push message service prompt */
+       MSG_PUSH_SERVICE_NEVER,         /**< Push message service never */
+};
+
+
+/**
+ *     @brief  Represents the values of the language type for a cell broadcasting message. \n
+ *     This enum is used as the value of MSG_CB_LANGUAGE_TYPE_T.
+ */
+enum _MSG_CB_LANGUAGE_TYPE_E
+{
+       MSG_CBLANG_TYPE_ALL,                    /**< CB check all */
+       MSG_CBLANG_TYPE_ENG,                    /**< CB message English  */
+       MSG_CBLANG_TYPE_GER,                    /**< CB message Germany */
+       MSG_CBLANG_TYPE_FRE,                    /**< CB message France */
+       MSG_CBLANG_TYPE_ITA,                    /**< CB message Italy */
+       MSG_CBLANG_TYPE_NED,                    /**< CB message Netherland */
+       MSG_CBLANG_TYPE_SPA,                    /**< CB message Spain */
+       MSG_CBLANG_TYPE_POR,                    /**< CB message Portugal */
+       MSG_CBLANG_TYPE_SWE,                    /**< CB message Sweden */
+       MSG_CBLANG_TYPE_TUR,                    /**< CB message Turkey */
+       MSG_CBLANG_TYPE_MAX                     /**< Default */
+};
+
+
+/**
+ *     @brief  Represents the values of SIM status. \n
+ *     This enum is used as the value of MSG_SIM_STATUS_T.
+ */
+enum _MSG_SIM_STATUS_E
+{
+       MSG_SIM_STATUS_NORMAL = 0,
+       MSG_SIM_STATUS_CHANGED,
+       MSG_SIM_STATUS_NOT_FOUND,
+};
+
+
+/**
+ *     @}
+ */
+
+#endif // MSG_SETTING_TYPES_H
+
diff --git a/include/common/MsgStorageTypes.h b/include/common/MsgStorageTypes.h
new file mode 100755 (executable)
index 0000000..8228b9f
--- /dev/null
@@ -0,0 +1,367 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_STORAGE_TYPES_H
+#define MSG_STORAGE_TYPES_H
+
+
+/**
+ *     @file           MsgStorageTypes.h
+ *     @brief          Defines transport types of messaging framework
+ *     @version        1.0
+ */
+
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Messaging Storage Types
+ *     @section                Program
+ *     - Program : Messaging Storage Types Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <time.h>
+
+#include "MsgTypes.h"
+
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_STORAGE_TYPES Messaging Storage Types
+ *     @{
+ */
+
+/*==================================================================================================
+                                    DEFINES
+==================================================================================================*/
+#define MAX_FOLDER_NAME_SIZE           20
+#define MAX_SEGMENT_NUM                        12
+
+
+/*==================================================================================================
+                                         TYPES
+==================================================================================================*/
+
+/**
+ *     @brief  Represents a folder type. \n
+ *     The values for this type SHOULD be in _MSG_FOLDER_TYPE_E.
+ */
+typedef unsigned char MSG_FOLDER_TYPE_T;
+
+
+/**
+ *     @brief  Represents a sort type. \n
+ *     The values for this type SHOULD be in \ref _MSG_SORT_TYPE_E.
+ */
+typedef unsigned char MSG_SORT_TYPE_T;
+
+
+/**
+ *     @brief  Represents a Saved SIM message ID.
+ */
+typedef signed short MSG_SIM_ID_T;
+
+
+/**
+ *     @brief  Represents a message type for quick panel. \n
+ *     The values for this type SHOULD be in \ref _MSG_QUICKPANEL_TYPE_E.
+ */
+typedef unsigned char MSG_QUICKPANEL_TYPE_T;
+
+
+/**
+ *     @brief  Represents a storage change CB type. \n
+ *     The values for this type SHOULD be in \ref _MSG_STORAGE_CHANGE_TYPE_E.
+ */
+typedef unsigned char MSG_STORAGE_CHANGE_TYPE_T;
+
+
+/*==================================================================================================
+                                         STRUCTURES
+==================================================================================================*/
+/**
+ *     @brief  Represents the count of read/unread messages.
+ */
+typedef struct
+{
+       int     nReadCnt;               /**< The count of read messages */
+       int     nUnreadCnt;             /**< The count of unread messages */
+       int     nSms;                   /**< The count of sms type messages */
+       int     nMms;                   /**< The count of mms type messages */
+} MSG_COUNT_INFO_S;
+
+
+/**
+ *     @brief  Represents message thread view information list.
+ */
+typedef struct
+{
+       int                                     nCount;                         /**< The count of message thread informatioin */
+       msg_thread_view_t       *msgThreadInfo;         /**< The pointer to message thread informatioin */
+} MSG_THREAD_VIEW_LIST_S;
+
+
+/**
+ *     @brief  Represents message information list.
+ */
+typedef struct
+{
+       int                                     nCount;                         /**< The count of message informatioin */
+       msg_message_t           *msgInfo;               /**< The pointer to message informatioin */
+}MSG_LIST_S;
+
+
+/**
+ *     @brief  Represents message id list.
+ */
+typedef struct
+{
+       int                                     nCount;                         /**< The count of message id informatioin */
+       MSG_MESSAGE_ID_T        *msgIdList;                     /**< The pointer to message id informatioin */
+}MSG_MSGID_LIST_S;
+
+
+/**
+ *     @brief  Represents a reject message information.
+ */
+typedef struct
+{
+       MSG_MESSAGE_ID_T                msgId;                  /**< Indicates the unique message ID. */
+       char                                            msgText[MAX_MSG_TEXT_LEN+1];    /**< Indicates the message text. */
+       time_t                                  displayTime;
+} MSG_REJECT_MSG_INFO_S;
+
+
+/**
+ *     @brief  Represents reject message list.
+ */
+typedef struct
+{
+       int                                             nCount;                         /**< The count of reject message informatioin */
+       MSG_REJECT_MSG_INFO_S   *rejectMsgInfo;         /**< The pointer to reject message informatioin */
+}MSG_REJECT_MSG_LIST_S;
+
+
+/**
+ *     @brief  Represents folder information.
+ */
+typedef struct
+{
+       MSG_FOLDER_ID_T         folderId;                       /**< Indicates the unique folder ID. */
+       char                            folderName[MAX_FOLDER_NAME_SIZE+1];     /**< Indicates the name of the folder. */
+       MSG_FOLDER_TYPE_T       folderType;             /**< Indicates the folder type. */
+} MSG_FOLDER_INFO_S;
+
+
+/**
+ *     @brief  Represents a folder list.
+ */
+typedef struct
+{
+       int                                     nCount;                 /**< The count of folder information */
+       MSG_FOLDER_INFO_S       *folderInfo;            /**< The pointer to folder information */
+} MSG_FOLDER_LIST_S;
+
+
+/**
+ *     @brief  Represents contact information.
+ */
+typedef struct
+{
+       MSG_CONTACT_ID_T        contactId;                                                      /**< Indicates the unique contact ID. */
+       char                            displayName[MAX_DISPLAY_NAME_LEN+1];    /**< Indicates the display name of contact. */
+       char                            firstName[MAX_DISPLAY_NAME_LEN+1];              /**< Indicates the first name of contact. */
+       char                            lastName[MAX_DISPLAY_NAME_LEN+1];               /**< Indicates the last name of contact. */
+       char                            imagePath[MAX_IMAGE_PATH_LEN+1];                /**< Indicates the image path of contact. */
+} MSG_CONTACT_INFO_S;
+
+
+/**
+ *     @brief  Represents a sort rule. \n
+ *     The sort rule structure includes a sort type and a sort order. \n
+ *     Applications can use the sort rule when querying messages.
+ */
+typedef struct
+{
+       MSG_SORT_TYPE_T sortType;               /**< Indicates the sort type */
+       bool                                    bAscending;             /**< Indicates the sort order which is ascending or descending */
+}MSG_SORT_RULE_S;
+
+
+/**
+ *     @brief  Represents SIM ID List.
+ */
+typedef struct
+{
+       unsigned int            count;                                                                          /**< The total number of SIM Msg ID*/
+       MSG_SIM_ID_T    simId[MAX_SEGMENT_NUM];                                         /**< The SIM Msg ID List */
+} SMS_SIM_ID_LIST_S;
+
+
+/**
+ *     @brief  Represents recipien list information.
+ */
+typedef struct
+{
+       int                                             recipientCnt;
+       MSG_ADDRESS_INFO_S*     recipientAddr;
+} MSG_RECIPIENTS_LIST_S;
+
+
+/**
+ *     @brief  Represents search condition values.
+ */
+typedef struct
+{
+       MSG_FOLDER_ID_T         folderId;
+       MSG_MESSAGE_TYPE_T              msgType;
+       char                                            *pAddressVal;
+       char                                            *pSearchVal;
+       int                                             reserved;
+} MSG_SEARCH_CONDITION_S;
+
+
+/** @brief     Prototype of the function that will be called when the database of message framework is changed.
+ *     Applications SHOULD implement this callback function and register it into Message handle.
+ *     For how to register this callback function, please refer to msg_reg_storage_change_callback.
+ *     The callback function runs in the application process, not in the framework process.
+ *     @param[in]      handle is Message handle.
+ *     @param[in]      user_param is a pointer to user data.
+ *     @return void
+ */
+typedef void (*msg_storage_change_cb)(MSG_HANDLE_T handle, MSG_STORAGE_CHANGE_TYPE_T storageChangeType, MSG_MSGID_LIST_S *pMsgIdList, void *user_param);
+
+
+/*==================================================================================================
+                                         ENUMS
+==================================================================================================*/
+
+/**
+ *     @brief  Represents the values of a storage type. \n
+ *     This enum is used as the value of MSG_STORAGE_ID_T.
+ */
+enum _MSG_STORAGE_ID_E
+{
+       MSG_STORAGE_UNKNOWN = 0,                /**< Storage Id is unknown. */
+       MSG_STORAGE_PHONE,                      /**< Storage Id is Phone. */
+       MSG_STORAGE_SIM,                                /**< Storage Id is SIM card. */
+};
+
+
+/**
+ *     @brief  Represents the values of a storage type. \n
+ *     This enum is used as the value of MSG_FOLDER_ID_T.
+ */
+enum _MSG_FOLDER_ID_E
+{
+       MSG_IOSBOX_ID = -1,                     /**< Indicates INBOX, OUTBOX and SENTBOX group folder id. (Only for search option.) */
+       MSG_ALLBOX_ID = 0,                              /**< Indicates INBOX, OUTBOX, SENTBOX and DRAFTBOX group folder id. (Only for search option.) */
+       MSG_INBOX_ID = 1,
+       MSG_OUTBOX_ID = 2,
+       MSG_SENTBOX_ID = 3,
+       MSG_DRAFT_ID = 4,
+       MSG_CBMSGBOX_ID = 5,
+
+       // new folder should be placed here
+
+       MSG_MAX_FOLDER_ID
+};
+
+
+/**
+ *     @brief  Represents the values of a folder type. \n
+ *     This enum is used as the value of MSG_FOLDER_TYPE_T.
+ */
+enum _MSG_FOLDER_TYPE_E
+{
+       MSG_FOLDER_TYPE_INBOX = 1,              /**< Inbox folder */
+       MSG_FOLDER_TYPE_OUTBOX,         /**< Outbox folder */
+       MSG_FOLDER_TYPE_DRAFT,          /**< Draft folder */
+       MSG_FOLDER_TYPE_USER_DEF                /**< Folder which is created by a user */
+};
+
+
+/**
+ *     @brief  Represents the values of a sort type. \n
+ *     This enum is used as the value of MSG_SORT_TYPE_T.
+ */
+enum _MSG_SORT_TYPE_E
+{
+       MSG_SORT_BY_UNKNOWN = 0,                        /**< Unknown sort type */
+       MSG_SORT_BY_DISPLAY_FROM,               /**< Sort by display from */
+       MSG_SORT_BY_DISPLAY_TO,                 /**< Sort by display to */
+       MSG_SORT_BY_DISPLAY_TIME,                       /**< Sort by display time */
+       MSG_SORT_BY_MSG_TYPE,                           /**< Sort by msg type */
+       MSG_SORT_BY_READ_STATUS,                        /**< Sort by read status */
+       MSG_SORT_BY_STORAGE_TYPE,               /**< Sort by storage type */
+       MSG_SORT_BY_THREAD_NAME,                        /**< Sort by name for thread view*/
+       MSG_SORT_BY_THREAD_DATE,                        /**< Sort by date for thread view*/
+       MSG_SORT_BY_THREAD_COUNT,               /**< Sort by count for thread view*/
+};
+
+
+/**
+ *     @brief  Represents the values of a message type for quick panel. \n
+ *     This enum is used as the value of MSG_QUICKPANEL_TYPE_T.
+ */
+enum _MSG_QUICKPANEL_TYPE_E
+{
+       MSG_QUICKPANEL_SMS = 0,
+       MSG_QUICKPANEL_MMS,
+       MSG_QUICKPANEL_DELIVER_REP,
+       MSG_QUICKPANEL_READ_REP,
+       MSG_QUICKPANEL_VOICEMAIL,
+       MSG_QUICKPANEL_MMS_NOTI,
+};
+
+/**
+ *     @}
+ */
+enum _MSG_COUNT_LIMIT_MAILBOX_TYPE_E
+{
+       MSG_COUNT_LIMIT_INBOX_TYPE,
+       MSG_COUNT_LIMIT_OUTBOX_TYPE,
+       MSG_COUNT_LIMIT_SENTBOX_TYPE,
+       MSG_COUNT_LIMIT_DRAFTBOX_TYPE,
+       MSG_COUNT_LIMIT_CBMSGBOX_TYPE,
+       MSG_COUNT_LIMIT_MAILBOX_TYPE_MAX,
+};
+
+enum _MSG_COUNT_LIMIT_MSG_TYPE_E
+{
+       MSG_COUNT_LIMIT_SMS_TYPE,
+       MSG_COUNT_LIMIT_MMS_TYPE,
+       MSG_COUNT_LIMIT_CB_TYPE,
+       MSG_COUNT_LIMIT_WAPPUSH_TYPE,
+       MSG_COUNT_LIMIT_PROVISION_TYPE,
+       MSG_COUNT_LIMIT_MSG_TYPE_MAX,
+};
+
+enum _MSG_STORAGE_CHANGE_TYPE_E
+{
+       // msg data
+       MSG_STORAGE_CHANGE_INSERT = 1,
+       MSG_STORAGE_CHANGE_UPDATE,
+       MSG_STORAGE_CHANGE_DELETE,
+
+       // thread data
+       MSG_STORAGE_CHANGE_CONTACT,
+};
+
+#endif // MSG_STORAGE_TYPES_H
+
diff --git a/include/common/MsgThread.h b/include/common/MsgThread.h
new file mode 100755 (executable)
index 0000000..f107acf
--- /dev/null
@@ -0,0 +1,76 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef __MSG_THREAD_H__
+#define __MSG_THREAD_H__
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <pthread.h>
+#include "MsgDebug.h"
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class MsgThread
+{
+public:
+       MsgThread(): thd(0) {};
+
+       virtual void start()
+       {
+               MSG_DEBUG("MsgThread::Start() called");
+
+               if (pthread_create(&thd, NULL, &MsgThread::thdMain, this) < 0)
+               {
+                       MSG_DEBUG("pthread_create() error");
+                       return;
+               }
+
+               pthread_detach(thd);
+       }
+
+       virtual void stop()
+       {
+               MSG_DEBUG("MsgThread::stop() called");
+       }
+
+       void wait()
+       {
+               MSG_DEBUG("MsgThread::Wait() called");
+               void* pData;
+               pthread_join(thd, &pData);
+       }
+
+private:
+       static void* thdMain(void* pInst)
+       {
+               MSG_DEBUG("MsgThread::thdMain() called");
+               MsgThread* pt = static_cast<MsgThread*>(pInst);
+               pt->run();
+               return NULL;
+       }
+
+       virtual void run() = 0;
+
+       pthread_t thd;
+};
+
+
+#endif //__MSG_THREAD_H__
+
diff --git a/include/common/MsgTransportTypes.h b/include/common/MsgTransportTypes.h
new file mode 100755 (executable)
index 0000000..6a03840
--- /dev/null
@@ -0,0 +1,177 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_TRANSPORT_TYPES_H
+#define MSG_TRANSPORT_TYPES_H
+
+/**
+ *     @file           MsgTransportTypes.h
+ *     @brief          Defines transport types of messaging framework
+ *     @version        1.0
+ */
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Messaging Transport Types
+ *     @section                Program
+ *     - Program : Messaging Transport Types Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgTypes.h"
+#include "MsgStorageTypes.h"
+#include "MsgMmsTypes.h"
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_TRANSPORT_TYPES       Messaging Transport Types
+ *     @{
+ */
+
+
+/*==================================================================================================
+                                         STRUCTURES
+==================================================================================================*/
+
+/**
+ *     @brief  Represents the status of a sent message. \n
+ *     This stucture contains the information about the status of a sent message that application has submitted to the framework.
+ */
+typedef struct
+{
+       MSG_REQUEST_ID_T                reqId;          /**< Indicates the corresponding request Id. */
+       MSG_NETWORK_STATUS_T    status;         /**< Indicates the status of the corresponding request.
+                                                                       Refer to enum _MSG_NETWORK_STATUS_E*/
+} MSG_SENT_STATUS_S;
+
+
+/*==================================================================================================
+                                    DEFINES
+==================================================================================================*/
+
+/**    @brief  Prototype of the function that will be called when the status of the message which is already sent is changed.
+ *     Applications SHOULD implement this callback function and register it into Message handle.
+ *     For how to register this callback function, please refer to msg_reg_sent_status_callback.
+ *     If the application sends a message, this callback function will be called to report its sending status.
+ *     The application can get the request ID from sent_status to know which request is bound.
+ *     The callback function runs in the application process, not in the framework process.
+ *     The memory of sent_status is managed by MAPI, when the callback function is finished.
+ *     @param[in]      handle is Message handle.
+ *     @param[in]      sent_status is a pointer to an MSG_SENT_STATUS_S structure.
+ *     @param[in]      user_param is a pointer to user data.
+ *     @return void
+ */
+typedef void (*msg_sent_status_cb)(MSG_HANDLE_T handle, MSG_SENT_STATUS_S *sent_status, void *user_param);
+
+
+/**    @brief  Prototype of the function that will be called when the status of the message which is already sent is changed.
+ *     Applications SHOULD implement this callback function and register it into Message handle.
+ *     For how to register this callback function, please refer to msg_reg_sent_status_callback.
+ *     If the application sends a message, this callback function will be called to report its sending status.
+ *     The application can get the request ID from sent_status to know which request is bound.
+ *     The callback function runs in the application process, not in the framework process.
+ *     The memory of sent_status is managed by MAPI, when the callback function is finished.
+ *     @param[in]      sent_status is a pointer to an MSG_SENT_STATUS_S structure.
+ *     @param[in]      user_param is a pointer to user data.
+ *     @return void
+ */
+typedef void (*msg_simple_sent_status_cb)(MSG_SENT_STATUS_S *sent_status, void *user_param);
+
+
+/** @brief     Prototype of the function that will be called when a new message is received.
+ *     Applications SHOULD implement this callback function and register it into Message handle.
+ *     For how to register this callback function, please refer to msg_reg_sms_message_callback.
+ *     This callback function will be called when a new message is received and the message satisfies the filter list.
+ *     The callback function runs in the application process, not in the framework process.
+ *     The memory for msg is managed by MAPI, when the callback function is finished.
+ *     @param[in]      handle is Message handle.
+ *     @param[in]      msg is a pointer to an msg_message_t structure.
+ *     @param[in]      user_param is a pointer to user data.
+ *     @return void
+ */
+typedef void (*msg_sms_incoming_cb)(MSG_HANDLE_T handle, msg_message_t msg, void *user_param);
+
+
+/** @brief     Prototype of the function that will be called when a new MMS message is received.
+ *     Applications SHOULD implement this callback function and register it into Message handle.
+ *     For how to register this callback function, please refer to msg_reg_mms_conf_message_callback.
+ *     This callback function will be called when a new MMS message is received and the message satisfies the filter list.
+ *     The callback function runs in the application process, not in the framework process.
+ *     The memory for msg is managed by MAPI, when the callback function is finished.
+ *     @param[in]      handle is Message handle.
+ *     @param[in]      msg is a pointer to an msg_message_t structure.
+ *     @param[in]      user_param is a pointer to user data.
+ *     @return void
+ */
+typedef void (*msg_mms_conf_msg_incoming_cb)(MSG_HANDLE_T handle, msg_message_t msg, void *user_param);
+
+
+/** @brief     Prototype of the function that will be called when a new SyncML message is received.
+ *     Applications SHOULD implement this callback function and register it into Message handle.
+ *     For how to register this callback function, please refer to msg_reg_syncml_message_callback.
+ *     This callback function will be called when a new message is received and the message satisfies the filter list.
+ *     The callback function runs in the application process, not in the framework process.
+ *     @param[in]      handle is Message handle.
+ *     @param[in]      msg_type is MSG_SYNCML_MESSAGE_TYPE_T structure.
+ *     @param[in]      push_body is WAP Push body data.
+ *     @param[in]      push_body_len is the length of WAP Push body data.
+ *     @param[in]      user_param is a pointer to user data.
+ *     @return void
+ */
+typedef void (*msg_syncml_msg_incoming_cb)(MSG_HANDLE_T handle, MSG_SYNCML_MESSAGE_TYPE_T msg_type, const char *push_body, int push_body_len, const char* wsp_header, int wsp_header_len, void *user_param);
+
+
+/** @brief     Prototype of the function that will be called when a new LBS message is received.
+ *     Applications SHOULD implement this callback function and register it into Message handle.
+ *     For how to register this callback function, please refer to msg_reg_lbs_message_callback.
+ *     This callback function will be called when a new message is received and the message satisfies the filter list.
+ *     The callback function runs in the application process, not in the framework process.
+ *     @param[in]      hMsgHandle is Message handle.
+ *     @param[in]      push_header is push message header data.
+ *     @param[in]      push_body is push message body data.
+ *     @param[in]      push_body_len is push message body length.
+ *     @param[in]      user_param is a pointer to user data.
+ *     @return void
+ */
+typedef void (*msg_lbs_msg_incoming_cb)(MSG_HANDLE_T handle, const char *push_header, const char *push_body, int push_body_len, void *user_param);
+
+
+/** @brief     Prototype of the function that will be called when a new SyncML message is received.
+ *     Applications SHOULD implement this callback function and register it into Message handle.
+ *     For how to register this callback function, please refer to msg_reg_syncml_message_callback.
+ *     This callback function will be called when a new message is received and the message satisfies the filter list.
+ *     The callback function runs in the application process, not in the framework process.
+ *     @param[in]      handle is Message handle.
+ *     @param[in]      user_param is a pointer to user data.
+ *     @return void
+ */
+typedef void (*msg_syncml_msg_operation_cb)(MSG_HANDLE_T handle, int msgId, int extId, void *user_param);
+
+
+/*==================================================================================================
+                                         TYPES
+==================================================================================================*/
+
+
+
+/**
+ *     @}
+ */
+
+#endif // MSG_TRANSPORT_TYPES_H
+
diff --git a/include/common/MsgTypes.h b/include/common/MsgTypes.h
new file mode 100755 (executable)
index 0000000..43c2b79
--- /dev/null
@@ -0,0 +1,729 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_TYPES_H
+#define MSG_TYPES_H
+
+/**
+ *     @file           MsgTypes.h
+ *     @brief          Defines common types of messaging framework
+ *     @version        1.0
+ */
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Message Common Types
+ *     @section                Program
+ *     - Program : Message Common Types Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <stdbool.h>
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_COMMON_TYPES  Messaging Common Types
+ *     @{
+ */
+
+/*==================================================================================================
+                                    DEFINES
+==================================================================================================*/
+#define MAX_TO_ADDRESS_CNT             10
+#define MAX_PHONE_NUMBER_LEN   20
+#define MAX_ADDRESS_VAL_LEN    254
+#define MAX_SIGN_VAL_LEN               128
+#define MAX_SUBJECT_LEN                        120
+#define MAX_DISPLAY_NAME_LEN   195
+#define MAX_IMAGE_PATH_LEN             1024
+#define MAX_MSG_DATA_LEN               320
+#define MAX_MSG_TEXT_LEN               1530
+#define MAX_FILTER_VALUE_LEN   40
+#define MAX_COMMAND_LEN                1024
+
+#define MAX_WAPPUSH_ID_LEN                     40
+#define MAX_WAPPUSH_HREF_LEN           300
+#define MAX_WAPPUSH_CONTENTS_LEN       2048
+
+#define MAX_PUSH_CACHEOP_INVALID_OBJECT_MAX    5
+#define MAX_PUSH_CACHEOP_INVALID_SERVICE_MAX   5
+#define MAX_PUSH_CACHEOP_MAX_URL_LEN                   200
+
+#define MAX_COMMON_INFO_SIZE   20
+
+/**
+ *     @brief  Defines the maximum file path length
+ */
+#define        MSG_FILEPATH_LEN_MAX    1024
+
+#define DEPRECATED __attribute__((deprecated))
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+/*==================================================================================================
+                                         TYPES
+==================================================================================================*/
+
+/**
+ *     @brief  Defines Message handle.
+ */
+typedef struct MessagingHandle *MSG_HANDLE_T;
+
+typedef struct opq_message_s *msg_message_t;
+
+typedef struct opq_threadview_s *msg_thread_view_t;
+
+/**
+ *     @brief  Represents a messsage ID.
+ */
+typedef unsigned int MSG_MESSAGE_ID_T;
+
+
+/**
+ *     @brief  Represents a reference ID.
+ */
+typedef unsigned int MSG_REFERENCE_ID_T;
+
+
+/**
+ *     @brief  Represents a storage type.
+       See enum _MSG_STORAGE_ID_E
+ */
+typedef unsigned char MSG_STORAGE_ID_T;
+
+
+/**
+ *     @brief  Represents a folder ID.
+       See enum _MSG_FOLDER_ID_E
+ */
+typedef char MSG_FOLDER_ID_T;
+
+
+/**
+ *     @brief  Represents a request ID, which is unique for each request.
+ */
+typedef unsigned int MSG_REQUEST_ID_T;
+
+
+/**
+ *     @brief  Represents a message priority. \n
+ *     The values for this type SHOULD be in _MSG_PRIORITY_TYPE_E.
+ */
+typedef unsigned char MSG_PRIORITY_TYPE_T;
+
+
+/**
+ *     @brief  Represents the network status of a message. \n
+ *     The values for this type SHOULD be in _MSG_NETWORK_STATUS_E.
+ */
+typedef unsigned char MSG_NETWORK_STATUS_T;
+
+
+/**
+ *     @brief  Represents an address type. \n
+ *     The values for this type SHOULD be in _MSG_ADDRESS_TYPE_E.
+ */
+typedef unsigned char MSG_ADDRESS_TYPE_T;
+
+
+/**
+ *     @brief  Represents an recipient type. \n
+ *     The values for this type SHOULD be in _MSG_RECIPIENT_TYPE_E.
+ */
+typedef unsigned char MSG_RECIPIENT_TYPE_T;
+
+
+/**
+ *     @brief  Represents the type of a message direction. \n
+ *     The values for this type SHOULD be in _MSG_DIRECTION_TYPE_E.
+ */
+typedef unsigned char MSG_DIRECTION_TYPE_T;
+
+
+/**
+ *     @brief  Represents an encoding type. \n
+ *     The values for this type SHOULD be in _MSG_ENCODE_TYPE_E.
+ */
+typedef unsigned char MSG_ENCODE_TYPE_T;
+
+
+/**
+ *     @brief  Represents an error code. \n
+ *     The values for this type SHOULD be in _MSG_ERROR_E
+ */
+typedef int MSG_ERROR_T;
+
+
+/**
+\brief Represents WAP Push App Code.
+*/
+typedef unsigned char MSG_PUSH_ACTION_T;
+
+
+/**
+\brief Represents SyncML Message Type.
+*/
+typedef unsigned short MSG_SYNCML_MESSAGE_TYPE_T;
+
+
+/**
+ *     @brief  Represents a Contact ID.
+ */
+typedef unsigned int MSG_CONTACT_ID_T;
+
+
+/**
+  *  @brief    Represents a Delivery Report Status.
+ *     The values for this type SHOULD be in _MSG_DELIVERY_REPORT_STATUS_E
+  */
+typedef int MSG_DELIVERY_REPORT_STATUS_T;
+
+
+/**
+ *     @brief  Represents a Read Report Status.
+ *     The values for this type SHOULD be in _MSG_READ_REPORT_STATUS_E
+ */
+typedef int MSG_READ_REPORT_STATUS_T;
+
+
+/**
+ *     @brief  Represents a Message Type.
+ *     The values for this type SHOULD be in _MSG_MESSAGE_TYPE_E
+*/
+typedef unsigned short MSG_MESSAGE_TYPE_T;
+
+
+/**
+ *     @brief  Represents a thread ID. \n
+ */
+typedef unsigned int MSG_THREAD_ID_T;
+
+
+/*==================================================================================================
+                                         STRUCTURES
+==================================================================================================*/
+
+/**
+ *     @brief  Represents address information.
+ */
+typedef struct
+{
+       MSG_THREAD_ID_T         threadId;                                                               /**< the thread ID of address */
+       MSG_ADDRESS_TYPE_T              addressType;                                                    /**< The type of an address in case of an Email or a mobile phone */
+       MSG_RECIPIENT_TYPE_T    recipientType;                                                  /**< The type of recipient address in case of To, Cc, and Bcc */
+       MSG_CONTACT_ID_T                contactId;                                                      /**< The contact ID of address */
+       char                                            addressVal[MAX_ADDRESS_VAL_LEN+1];      /**< The actual value of an address */
+       char                                            displayName[MAX_DISPLAY_NAME_LEN+1];    /**< The display name of an address */
+} MSG_ADDRESS_INFO_S;
+
+
+/**
+ *     @brief  Represents port number information.
+ */
+typedef struct
+{
+       bool                            valid;          /**< Indicates whether port information is used or not. */
+       unsigned short          dstPort;                /**< Recipient port number, not greater than 16 bit */
+       unsigned short          srcPort;                /**< Sender port number, not greater than 16 bit */
+} MSG_PORT_INFO_S;
+
+
+/**
+ *     @brief  Represents MMS Sending Option Structure in application.
+ */
+typedef struct
+{
+       bool                                    bReadReq;
+       time_t                          expiryTime;
+       bool                                    bUseDeliveryCustomTime;
+       time_t                          deliveryTime;
+       MSG_PRIORITY_TYPE_T     priority;
+} MMS_SENDINGOPT_S;
+
+
+/**
+ *     @brief  Represents SMS Sending Option Structure in application.
+ */
+typedef struct
+{
+       bool bReplyPath;
+} SMS_SENDINGOPT_S;
+
+
+/**
+ *     @brief  Represents MSG Sending Option Structure in application.
+ */
+typedef struct
+{
+       bool bSetting;
+       bool bDeliverReq;
+       bool bKeepCopy;
+
+       union
+       {
+               MMS_SENDINGOPT_S        mmsSendOpt;
+               SMS_SENDINGOPT_S        smsSendOpt;
+       } option;
+} MSG_SENDINGOPT_S;
+
+
+typedef        enum
+{
+       MMS_TIMETYPE_NONE               = -1,   // fixme: backward compatibility
+       MMS_TIMETYPE_ERROR              = -1,   // error return in Get method
+       MMS_TIMETYPE_RELATIVE   = 0,    // default
+       MMS_TIMETYPE_ABSOLUTE   = 1
+}MmsTimeType;
+
+
+typedef struct
+{
+       MmsTimeType     type;
+       unsigned int    time;
+}MmsTimeStruct;
+
+
+/**
+ *     @brief  Represents MMS Sending Option Structure in framework.
+ */
+typedef struct
+{
+       bool                                    bReadReq;
+       bool                                    bUseDeliveryCustomTime;
+       MSG_PRIORITY_TYPE_T     priority;
+       MmsTimeStruct                   expiryTime;
+       MmsTimeStruct                   deliveryTime;
+} MMS_SENDINGOPT_INFO_S;
+
+
+/**
+ *     @brief  Represents SMS Sending Option Structure in framework.
+ */
+typedef struct
+{
+       bool    bReplyPath;
+} SMS_SENDINGOPT_INFO_S;
+
+
+/**
+ *     @brief  Represents MSG Sending Option Structure in framework.
+ */
+typedef struct
+{
+       bool bSetting;
+       bool bDeliverReq;
+       bool bKeepCopy;
+
+       union
+       {
+               MMS_SENDINGOPT_INFO_S   mmsSendOptInfo;
+               SMS_SENDINGOPT_INFO_S   smsSendOptInfo;
+       } option;
+} MSG_SENDINGOPT_INFO_S;
+
+
+/**
+ *     @brief  Represents a request in the application. \n
+ *     Applications compose a request and send it to the framework via Message handle. \n
+ *     This request ID is used to manage the request by the framework.
+ */
+typedef struct
+{
+       MSG_REQUEST_ID_T        reqId;  /**< Indicates the request ID, which is unique.
+                                                                       When applications submit a request to the framework, this value will be set by the framework. */
+       msg_message_t           msg;    /**< Indicates the message structure to be sent by applications. */
+       MSG_SENDINGOPT_S        sendOpt;
+} MSG_REQUEST_S;
+
+
+/**
+ *     @brief  Represents Address information list.
+ */
+typedef struct
+{
+       MSG_CONTACT_ID_T                contactId;                      /**< The contact id of message common informatioin */
+       MSG_ADDRESS_INFO_S              msgAddrInfo;            /**< The pointer to message common informatioin */
+} MSG_THREAD_LIST_INDEX_S;
+
+
+/**
+ *     @brief  Represents Peer Count Info.
+ */
+typedef struct
+{
+       int totalCount;                 /**< Indicates the total number of messages from the Peer. */
+       int unReadCount;                /**< Indicates the unread messages from the Peer. */
+       int smsMsgCount;                /**< Indicates the SMS messages from the Peer. */
+       int mmsMsgCount;                /**< Indicates the MMS messages from the Peer. */
+}MSG_THREAD_COUNT_INFO_S;
+
+
+/**
+ *     @brief  Represents the request information of Push Message (SI, SL).
+ */
+typedef struct
+{
+       MSG_PUSH_ACTION_T       action;
+       unsigned long                   received;
+       unsigned long                   created;
+       unsigned long                   expires;
+       char                                    id[MAX_WAPPUSH_ID_LEN];
+       char                                    href[MAX_WAPPUSH_HREF_LEN];
+       char                                    contents[MAX_WAPPUSH_CONTENTS_LEN];
+} MSG_PUSH_MESSAGE_S;
+
+
+/**
+ *     @brief  Represents the request information of Push Message (CO).
+ */
+typedef struct
+{
+       int             invalObjectCnt;
+       int             invalServiceCnt;
+       char            invalObjectUrl[MAX_PUSH_CACHEOP_INVALID_OBJECT_MAX][MAX_PUSH_CACHEOP_MAX_URL_LEN];
+       char            invalServiceUrl[MAX_PUSH_CACHEOP_INVALID_SERVICE_MAX][MAX_PUSH_CACHEOP_MAX_URL_LEN];
+} MSG_PUSH_CACHEOP_S;
+
+
+/**
+ *     @brief  Represents the SyncML Message Information.
+ */
+typedef struct
+{
+       int                                     extId;
+       int                                     pinCode;
+       msg_message_t           msg;
+}MSG_SYNCML_MESSAGE_S;
+
+
+/**
+ *     @brief  Represents the SyncML Message Data.
+ */
+ typedef struct
+{
+       MSG_SYNCML_MESSAGE_TYPE_T       syncmlType;
+       int                                                     pushBodyLen;
+       char                                                    pushBody[MAX_WAPPUSH_CONTENTS_LEN];
+       int                                                             wspHeaderLen;
+       char                                                    wspHeader[MAX_WAPPUSH_CONTENTS_LEN];
+}MSG_SYNCML_MESSAGE_DATA_S;
+
+
+/**
+ *     @brief  Represents the SyncML Message Data.
+ */
+ typedef struct
+{
+       char                                                    pushHeader[MAX_WAPPUSH_CONTENTS_LEN];
+       int                                                     pushBodyLen;
+       char                                                    pushBody[MAX_WAPPUSH_CONTENTS_LEN];
+}MSG_LBS_MESSAGE_DATA_S;
+
+
+
+/**
+ *     @brief  Represents the Report Status Data.
+ */
+ typedef struct
+{
+       MSG_DELIVERY_REPORT_STATUS_T    deliveryStatus;         /**< Indicates the message ID of this message. */
+       time_t                                                  deliveryStatusTime;     /**< Indicates the display time related to the specific operation. */   //MAX_DISPLAY_TIME_LEN
+       MSG_READ_REPORT_STATUS_T                readStatus;                     /**< Indicates the message ID of this message. */
+       time_t                                                  readStatusTime;         /**< Indicates the display time related to the specific operation. */   //MAX_DISPLAY_TIME_LEN
+}MSG_REPORT_STATUS_INFO_S;
+
+
+/*==================================================================================================
+                                         ENUMS
+==================================================================================================*/
+
+/**
+ *     @brief  Represents the type of Message. More members maybe added if needed \n
+ *     This enum is used as the value of MSG_MESSAGE_TYPE_T.
+ */
+ enum _MSG_MESSAGE_TYPE_E
+{
+       MSG_TYPE_INVALID = 0,                   /** < Invalid Type Message */
+
+       MSG_TYPE_SMS,                                   /** < Normal SMS Message */
+       MSG_TYPE_SMS_CB,                                /** < Cell Broadcasting SMS Message */
+       MSG_TYPE_SMS_JAVACB,                    /** < JAVA Cell Broadcasting SMS Message */
+       MSG_TYPE_SMS_WAPPUSH,           /** < WAP Push SMS Message */
+       MSG_TYPE_SMS_MWI,                               /** < MWI SMS Message */
+       MSG_TYPE_SMS_SYNCML,                    /** < SyncML CP SMS Message */
+       MSG_TYPE_SMS_REJECT,                    /** < Reject Message */
+
+       MSG_TYPE_MMS,                                   /** < Normal MMS Message */
+       MSG_TYPE_MMS_JAVA,                      /** < JAVA MMS Message */
+       MSG_TYPE_MMS_NOTI,                      /** < MMS Notification Message */
+};
+
+
+/**
+ *     @brief  Represents the values of an error code. \n
+ *     Success code is zero, but all error codes SHOULD be negative and smaller than MSG_ERROR_BEGIN. \n
+ *     This enum is used as the value of MSG_ERROR_T.
+ */
+enum _MSG_ERROR_E
+{
+       MSG_SUCCESS = 0,                                /**< Successful */
+
+       MSG_ERR_NULL_MSGHANDLE = -1,    /**< Message handle is NULL */
+       MSG_ERR_NULL_POINTER = -2,              /**< Pointer is NULL */
+       MSG_ERR_NULL_MESSAGE = -3,              /**< Message is NULL */
+       MSG_ERR_INVALID_STORAGE_ID = -4,        /**< Storage ID is invalid */
+       MSG_ERR_INVALID_MSG_TYPE = -5,          /**< Message type is invalid */
+
+       MSG_ERR_INVALID_STORAGE_REG= -6,        /**< Storage registry is invalid */
+       MSG_ERR_INVALID_MESSAGE_ID = -7,        /**< Message ID is invalid */
+       MSG_ERR_INVALID_MSGHANDLE = -8, /**< Message handle is invalid */
+       MSG_ERR_INVALID_PARAMETER = -9, /**< Parameter is invalid */
+       MSG_ERR_INVALID_MESSAGE = -10,                  /**< Message is invalid */
+
+       MSG_ERR_INVALID_PLUGIN_HANDLE = -11,    /**< Plugin handle is invalid */
+       MSG_ERR_MEMORY_ERROR = -12,                     /**< Memory is error */
+       MSG_ERR_COMMUNICATION_ERROR = -13,      /**< Communication between client and server is error */
+       MSG_ERR_SIM_STORAGE_FULL = -14,         /**< SIM Storage is full */
+       MSG_ERR_TRANSPORT_ERROR = -15,                  /**< Transport event error */
+
+       MSG_ERR_CALLBACK_ERROR = -16,                   /**< Callback event error */
+       MSG_ERR_STORAGE_ERROR = -17,                    /**< Storage event error */
+       MSG_ERR_FILTER_ERROR = -18,                             /**< Filter event error */
+       MSG_ERR_MMS_ERROR = -19,                                /**< MMS event error */
+       MSG_ERR_MMPLAYER_CREATE = -20,                  /**< Multimedia Error*/
+
+       MSG_ERR_MMPLAYER_SET_ATTRS = -21,               /**< Multimedia Error*/
+       MSG_ERR_MMPLAYER_REALIZE = -22,         /**< Multimedia Error*/
+       MSG_ERR_MMPLAYER_PLAY = -23,                    /**< Multimedia Error*/
+       MSG_ERR_MMPLAYER_STOP = -24,                    /**< Multimedia Error*/
+       MSG_ERR_MMPLAYER_DESTROY = -25,         /**< Multimedia Error*/
+
+       MSG_ERR_UNKNOWN = -26,                                  /**< Unknown errors */
+
+       /* Start Database Errors */
+       MSG_ERR_DB_CONNECT = -27,
+       MSG_ERR_DB_DISCONNECT = -28,
+       MSG_ERR_DB_EXEC = -29,
+       MSG_ERR_DB_GETTABLE = -30,
+
+       MSG_ERR_DB_PREPARE = -31,
+       MSG_ERR_DB_STEP = -32,
+       MSG_ERR_DB_NORECORD= -33,
+       MSG_ERR_DB_STORAGE_INIT = -34,
+       MSG_ERR_DB_MAKE_DIR = -35,
+
+       MSG_ERR_DB_ROW = -36,
+       MSG_ERR_DB_DONE = -37,
+       MSG_ERR_DB_GENERIC= -38,
+       MSG_ERR_DB_END = -39,
+       /* End Database Errors */
+
+       /* Start Setting Errors */
+       MSG_ERR_SET_SETTING = -40,
+       MSG_ERR_SET_SIM_SET = -41,
+       MSG_ERR_SET_READ_ERROR = -42,
+       MSG_ERR_SET_WRITE_ERROR = -43,
+       MSG_ERR_SET_DELETE_ERROR = -44,
+       /* End Setting Errors */
+
+       /* Start Plugin Errors */
+       MSG_ERR_PLUGIN_TAPIINIT = -45,
+       MSG_ERR_PLUGIN_REGEVENT = -46,
+       MSG_ERR_PLUGIN_TRANSPORT = -47,
+       MSG_ERR_PLUGIN_STORAGE = -48,
+       MSG_ERR_PLUGIN_SETTING = -49,
+
+       MSG_ERR_PLUGIN_WAPDECODE = -50,
+       MSG_ERR_PLUGIN_TAPI_FAILED = -51,
+       MSG_ERR_PLUGIN_SIM_MSG_FULL = -52,
+       /* End Plugin Errors */
+
+       MSG_ERR_MESSAGE_COUNT_FULL = -53,
+       MSG_ERR_READREPORT_NOT_REQUESTED = -54,
+       MSG_ERR_READREPORT_ALEADY_SENT = -55,
+
+       MSG_ERR_FILTER_DUPLICATED = -56,                                /**< Filter duplicate error */
+       MSG_ERR_SECURITY_ERROR = -57,
+       MSG_ERR_NO_SIM = -58,
+       MSG_ERR_SERVER_NOT_READY= -59,
+};
+
+
+/**
+ *     @brief  Represents the values of a message priority. \n
+ *     This enum is used as the value of MSG_PRIORITY_TYPE_T.
+ */
+enum _MSG_PRIORITY_TYPE_E
+{
+       MSG_MESSAGE_PRIORITY_LOW,               /**< Low priority */
+       MSG_MESSAGE_PRIORITY_NORMAL,    /**< Normal priority */
+       MSG_MESSAGE_PRIORITY_HIGH,              /**< High priority */
+};
+
+
+/**
+ *     @brief  Represents the values of a network status. \n
+ *     This enum is used as the value of MSG_NETWORK_STATUS_T.
+ */
+enum _MSG_NETWORK_STATUS_E
+{
+       MSG_NETWORK_NOT_SEND = 0,               /**< Message is not sending */
+       MSG_NETWORK_SENDING,                            /**< Message is sending */
+       MSG_NETWORK_SEND_SUCCESS,               /**< Message is sent successfully */
+       MSG_NETWORK_SEND_FAIL,                  /**< Message is failed to send */
+       MSG_NETWORK_DELIVER_SUCCESS,    /**< Message is delivered */
+       MSG_NETWORK_DELIVER_FAIL,               /**< Message is failed to deliver */
+       MSG_NETWORK_RECEIVED,                   /**< Message is received */
+       MSG_NETWORK_REQ_CANCELLED,              /**< Request is cancelled */
+       MSG_NETWORK_RETRIEVING,                         /**< Message is retrieving */
+       MSG_NETWORK_RETRIEVE_SUCCESS,           /**< Message is retrieved successfully */
+       MSG_NETWORK_RETRIEVE_FAIL,                      /**< Message is failed to retrieve */
+       MSG_NETWORK_SEND_TIMEOUT,                       /**< Message is failed to send by timeout */
+};
+
+
+/**
+ *     @brief  Represents the values of an address type. \n
+ *     This enum is used as the value of MSG_ADDRESS_TYPE_T.
+*/
+enum _MSG_ADDRESS_TYPE_E
+{
+       MSG_ADDRESS_TYPE_UNKNOWN = 0,   /**< The address type is unknown. */
+       MSG_ADDRESS_TYPE_PLMN,                  /**< The address type is for a phone number like +1012345678. */
+       MSG_ADDRESS_TYPE_EMAIL,                 /**< The address type is for an email address like abc@example.email. */
+};
+
+
+/**
+ *     @brief  Represents the values of a recipient type. \n
+ *     This enum is used as the value of MSG_RECIPIENT_TYPE_T.
+*/
+enum _MSG_RECIPIENT_TYPE_E
+{
+       MSG_RECIPIENTS_TYPE_UNKNOWN = 0,        /**< The recipient type is unknown. */
+       MSG_RECIPIENTS_TYPE_TO,                 /**< The recipient type is for "To". */
+       MSG_RECIPIENTS_TYPE_CC,                 /**< The recipient type is for "Cc". */
+       MSG_RECIPIENTS_TYPE_BCC,                        /**< The recipient type is for "Bcc". */
+};
+
+
+/**
+ *     @brief  Represents the values of a direction type. \n
+ *     This enum is used as the value of MSG_DIRECTION_TYPE_T.
+ */
+enum _MSG_DIRECTION_TYPE_E
+{
+       MSG_DIRECTION_TYPE_MO = 0,              /**< The direction type is for mobile originated */
+       MSG_DIRECTION_TYPE_MT,                  /**< The direction type is for mobile terminated */
+};
+
+
+/**
+ *     @brief  Represents the values of a string encoding type. \n
+ *     This enum is used as the value of MSG_ENCODE_TYPE_T.
+ */
+enum _MSG_ENCODE_TYPE_E
+{
+       MSG_ENCODE_GSM7BIT = 0, /**< The string encoding type is GSM7BIT */
+       MSG_ENCODE_8BIT,                /**< The string encoding type is 8 BIT */
+       MSG_ENCODE_UCS2,                /**< The string encoding type is UCS2 */
+       MSG_ENCODE_AUTO,                /**< The string encoding type is AUTO */
+};
+
+
+/**
+ *     @brief  Represents the action type of Push Message. \n
+ *     This enum is used as the value of MSG_PUSH_ACTION_T.
+ */
+enum _MSG_PUSH_ACTION_E
+{
+       // SI Action
+       MSG_PUSH_SI_ACTION_SIGNAL_NONE = 0x00,
+       MSG_PUSH_SI_ACTION_SIGNAL_LOW,
+       MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM,
+       MSG_PUSH_SI_ACTION_SIGNAL_HIGH,
+       MSG_PUSH_SI_ACTION_DELETE,
+
+       // SL Action
+       MSG_PUSH_SL_ACTION_EXECUTE_LOW,
+       MSG_PUSH_SL_ACTION_EXECUTE_HIGH,
+       MSG_PUSH_SL_ACTION_CACHE,
+};
+
+
+/**
+ *     @brief  Represents the type of SyncML Message. \n
+ *     This enum is used as the value of MSG_SYNCML_MESSAGE_TYPE_T.
+ */
+ enum _MSG_SYNCML_MESSAGE_TYPE_E
+ {
+       DM_WBXML,                                       /** < DM WBXML SyncML Message */
+       DM_XML,                                         /** < DM XML SyncML Message */
+       DM_NOTIFICATION,                        /** < DM Notification SyncML Message */
+
+       DS_NOTIFICATION,                        /** < DS Notification SyncML Message */
+       DS_WBXML,                                       /** < DS WBXML SyncML Message */
+
+       CP_XML,                                         /** < CP XML SyncML Message */
+       CP_WBXML,                                       /** < CP WBXML SyncML Message */
+
+       OTHERS,                                         /** < Unknown SyncML Message */
+ };
+
+
+/**
+ *     @brief  Represents the values of a Delivery Report Status. \n
+ *     This enum is used as the value of MSG_DELIVERY_REPORT_STATUS_T.
+*/
+ enum _MSG_DELIVERY_REPORT_STATUS_E
+ {
+        MSG_DELIVERY_REPORT_NONE                               =       -1,     /**< Indicates the status unavailable */
+        MSG_DELIVERY_REPORT_EXPIRED                    =       0,      /**< Indicates the expired status of message */
+        MSG_DELIVERY_REPORT_SUCCESS                            =       1,      /**< Indicates the success status of message */
+        MSG_DELIVERY_REPORT_REJECTED                   =       2,      /**< Indicates the rejected status of message */
+        MSG_DELIVERY_REPORT_DEFERRED                   =       3,      /**< Indicates the deferred status of message */
+        MSG_DELIVERY_REPORT_UNRECOGNISED               =       4,      /**< Indicates the unrecongnised status of message */
+        MSG_DELIVERY_REPORT_INDETERMINATE              =       5,      /**< Indicates the unrecongnised status of message */
+        MSG_DELIVERY_REPORT_FORWARDED                  =       6,      /**< Indicates the forwarded status of message */
+        MSG_DELIVERY_REPORT_UNREACHABLE                =       7,      /**< Indicates the unreachable status of message */
+        MSG_DELIVERY_REPORT_ERROR                              =       8,      /**< Indicates the error status of message */
+ };
+
+
+/**
+ *     @brief  Represents the values of a Read Report Status. \n
+ *     This enum is used as the value of MSG_READ_REPORT_STATUS_T.
+*/
+enum _MSG_READ_REPORT_STATUS_E
+ {
+        MSG_READ_REPORT_NONE                   =       -1,       /**< Indicates the status unavailable */
+        MSG_READ_REPORT_IS_READ                =       0,        /**< Indicates the message is read */
+        MSG_READ_REPORT_IS_DELETED     =       1         /**< Indicates the message is deleted */
+ };
+
+/**
+ *     @}
+ */
+
+#endif // MSG_TYPES_H
+
diff --git a/include/framework/MsgCmdHandler.h b/include/framework/MsgCmdHandler.h
new file mode 100755 (executable)
index 0000000..5fa7d7f
--- /dev/null
@@ -0,0 +1,95 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_CMD_HANDLER_H
+#define MSG_CMD_HANDLER_H
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgCmdTypes.h"
+#include "MsgInternalTypes.h"
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+int MsgAddMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgAddSyncMLMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgUpdateMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgUpdateReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgUpdateThreadReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgUpdateProtectedStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgDeleteMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgDeleteAllMessageInFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgMoveMessageToFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgMoveMessageToStorageHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgCountMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgCountMsgByTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgGetMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgGetFolderViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+
+int MsgAddFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgUpdateFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgDeleteFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgGetFolderListHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+
+int MsgInitSimBySatHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgGetMsgTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+
+int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgGetConversationViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgDeleteThreadMessageListHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+
+int MsgCountMsgByContactHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgGetQuickPanelDataHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgResetDatabaseHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgGetMemSizeHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgGetReportStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+
+int MsgSetConfigHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgGetConfigHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+
+int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgCancelReqHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+
+int MsgRegSentStatusCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgRegIncomingMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgRegIncomingMMSConfMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgRegIncomingSyncMLMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgRegIncomingLBSMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgRegSyncMLMsgOperationCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgRegStorageChangeCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+
+int MsgSentStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgIncomingSyncMLMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgIncomingLBSMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+
+MSG_ERROR_T MsgPrepareScheduledMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOpt, int ListenerFd);
+int MsgCreateScheduledAlarm(MSG_MESSAGE_INFO_S *pMsgInfo);
+int MsgScheduledAlarmCB(int AlarmId, void *pUserParam);
+int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgAddFilterHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgUpdateFilterHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgDeleteFilterHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgGetFilterListHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgSetFilterOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgGetFilterOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+
+#endif // MSG_CMD_HANDLER_H
diff --git a/include/framework/MsgDeliverHandler.h b/include/framework/MsgDeliverHandler.h
new file mode 100755 (executable)
index 0000000..69e9da3
--- /dev/null
@@ -0,0 +1,41 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_DELIVER_HANDLER_H
+#define MSG_DELIVER_HANDLER_H
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgPluginInterface.h"
+#include "MsgTypes.h"
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+MSG_ERROR_T MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_ID_T reqID);
+MSG_ERROR_T MsgHandleIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti);
+MSG_ERROR_T MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti);
+MSG_ERROR_T MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti);
+
+/*==================================================================================================
+                                       DEFINES
+==================================================================================================*/
+#define MSG_SVC_PKG_NAME_BROWSER       "org.tizen.browser"
+
+#endif // MSG_DELIVER_HANDLER_H
+
diff --git a/include/framework/MsgPluginConfig.h b/include/framework/MsgPluginConfig.h
new file mode 100755 (executable)
index 0000000..ef7db18
--- /dev/null
@@ -0,0 +1,94 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_PLUGIN_CONFIG_H
+#define MSG_PLUGIN_CONFIG_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <map>
+#include <list>
+#include <stdio.h>
+#include <string.h>
+#include "MsgDebug.h"
+#include "MsgTypes.h"
+#include "MsgCppTypes.h"
+
+class MsgPlgToken
+{
+       int tokenType; // not defined 0, title: 1, msgtype: 2, libpath: 3
+       char tokenVal[256]; // null-terminated char array
+
+public:
+       MsgPlgToken(char* pstr=NULL) : tokenType(TOK_UNDEFINED)
+       {
+               if(pstr)
+               {
+                       tokenize(pstr);
+               }
+               else
+               {
+                       bzero(tokenVal, 256);
+               }
+       }
+
+       MsgPlgToken& operator = (const MsgPlgToken& rhs)
+       {
+               if (this != &rhs)
+               {
+                       tokenType = rhs.tokenType;
+                       strncpy(tokenVal, rhs.tokenVal, 255);
+               }
+
+               return *this;
+       }
+
+       int getType() const { return tokenType; } // not defined 0, title: 1, msgtype: 2, libpath: 3
+       const char* getVal(void) const { return tokenVal; }
+       void getVal(CharVector& vec) const { vec.assign(tokenVal, tokenVal+strlen(tokenVal));}
+       int tokenize(char* pStr);
+
+       enum { TOK_UNDEFINED=0, TOK_PLG_TITLE, TOK_PLG_TYPE, TOK_PLG_PATH };
+
+       void reset() { tokenType = TOK_UNDEFINED; }
+       operator void*() const {
+               return (tokenType==TOK_UNDEFINED)? NULL:(void*) this;
+       }
+};
+
+typedef std::vector<MsgPlgToken> MsgPlgTokenVec;
+typedef std::map<CharVector, MsgPlgTokenVec> MsgConfigMap;
+
+class MsgPlgConfig
+{
+       MsgConfigMap configMap;
+       void insert(const MsgPlgToken& tokTitle, const MsgPlgToken& tokMsgType, const MsgPlgToken& tokLibPath);
+
+public:
+       MsgPlgConfig(FILE* fp);
+
+       /* access method for tokens */
+       const CharVector& title(unsigned int pos);// const; // iteration with ith position i=0, .. , itemCount-1
+       inline int titleCount() const { return configMap.size(); }
+
+       void token(const CharVector& key, unsigned int pos, MsgPlgToken& retTok);// const;
+       void token(int i, unsigned int pos, MsgPlgToken& retTok);// const;
+       int tokenCount(const CharVector& key) { return configMap[key].size(); } // const leads to error why?
+};
+
+#endif // MSG_PLUGIN_CONFIG_H
diff --git a/include/framework/MsgPluginManager.h b/include/framework/MsgPluginManager.h
new file mode 100755 (executable)
index 0000000..1c9f863
--- /dev/null
@@ -0,0 +1,114 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_PLUGIN_MANAGER_H
+#define MSG_PLUGIN_MANAGER_H
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <map>
+
+#include "MsgTypes.h"
+#include "MsgPluginInterface.h"
+#include "MsgPluginConfig.h"
+
+
+/*==================================================================================================
+                                    DEFINES
+==================================================================================================*/
+#define MSG_PLUGIN_CFG_PATH    "/usr/share/msg-service/"
+#define MSG_PLUGIN_CFG_NAME    "plugin.cfg"
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class MsgPlugin
+{
+public:
+       MsgPlugin(MSG_MAIN_TYPE_T plgType = MSG_UNKNOWN_TYPE, const char* libPath = NULL);
+       ~MsgPlugin();
+
+       MSG_ERROR_T initialize();
+       void finalize();
+
+       MSG_ERROR_T submitReq(MSG_REQUEST_INFO_S *pReqInfo, bool bReqCb);
+       MSG_ERROR_T registerListener(MSG_PLUGIN_LISTENER_S *pListener);
+       MSG_ERROR_T checkSimStatus(MSG_SIM_STATUS_T *pStatus);
+       MSG_ERROR_T checkDeviceStatus();
+
+       MSG_ERROR_T initSimMessage();
+       MSG_ERROR_T saveSimMessage(MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList);
+       MSG_ERROR_T deleteSimMessage(MSG_SIM_ID_T SimMsgId);
+       MSG_ERROR_T setReadStatus(MSG_SIM_ID_T SimMsgId);
+       MSG_ERROR_T setMemoryStatus(MSG_ERROR_T Error);
+
+       MSG_ERROR_T initConfigData(MSG_SIM_STATUS_T SimStatus);
+       MSG_ERROR_T setConfigData(const MSG_SETTING_S *pSetting);
+       MSG_ERROR_T getConfigData(MSG_SETTING_S *pSetting);
+
+       // MMS handlers
+       MSG_ERROR_T addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData);
+       MSG_ERROR_T updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData);
+       MSG_ERROR_T processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject);
+       MSG_ERROR_T getMmsMessage(MSG_MESSAGE_INFO_S *pMsg,  MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg);
+       MSG_ERROR_T updateRejectStatus(MSG_MESSAGE_INFO_S *pMsgInfo);
+       MSG_ERROR_T composeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo);
+
+       MSG_ERROR_T restoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char* pRecvBody, int rcvdBodyLen, char* filePath);
+
+       operator void*() const {
+               return (mSupportedMsg==MSG_UNKNOWN_TYPE)? NULL:(void*) this;
+       }
+
+private:
+       MSG_MAIN_TYPE_T                         mSupportedMsg;
+       MSG_PLUGIN_HANDLER_S    mPlgHandler;
+
+        void*                                  mLibHandler;    // plugin library pointer
+};
+
+
+/*==================================================================================================
+                                     GLOBAL VARIABLES
+==================================================================================================*/
+typedef std::map<MSG_MAIN_TYPE_T, MsgPlugin> MsgPluginMap;
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class MsgPluginManager
+{
+public:
+       static MsgPluginManager* instance();
+
+       void initialize();
+       void finalize();
+       MsgPlugin* getPlugin(MSG_MAIN_TYPE_T mainType);
+       void loadPlugins(const char* path);
+
+private:
+       MsgPluginManager();
+       ~MsgPluginManager();
+
+       static MsgPluginManager* pInstance;
+       MsgPluginMap plgMap;
+};
+
+#endif // MSG_PLUGIN_MANAGER_H
+
diff --git a/include/framework/MsgSettingHandler.h b/include/framework/MsgSettingHandler.h
new file mode 100755 (executable)
index 0000000..3387743
--- /dev/null
@@ -0,0 +1,61 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_SETTING_HANDLER_H
+#define MSG_SETTING_HANDLER_H
+
+
+/*==================================================================================================
+                                       INCLUDE FILES
+==================================================================================================*/
+#include "MsgSettingTypes.h"
+
+
+/*==================================================================================================
+                                       FUNCTION PROTOTYPES
+==================================================================================================*/
+MSG_ERROR_T MsgInitSimConfig(MSG_SIM_STATUS_T SimStatus);
+
+MSG_ERROR_T MsgSetConfigData(const MSG_SETTING_S *pSetting);
+MSG_ERROR_T MsgGetConfigData(MSG_SETTING_S *pSetting);
+
+MSG_ERROR_T MsgSetGeneralOpt(const MSG_SETTING_S *pSetting);
+MSG_ERROR_T MsgSetSMSSendOpt(const MSG_SETTING_S *pSetting);
+MSG_ERROR_T MsgSetSMSCList(const MSG_SETTING_S *pSetting, bool bSetSim);
+MSG_ERROR_T MsgSetMMSSendOpt(const MSG_SETTING_S *pSetting);
+MSG_ERROR_T MsgSetMMSRecvOpt(const MSG_SETTING_S *pSetting);
+MSG_ERROR_T MsgSetMMSStyleOpt(const MSG_SETTING_S *pSetting);
+MSG_ERROR_T MsgSetPushMsgOpt(const MSG_SETTING_S *pSetting);
+MSG_ERROR_T MsgSetCBMsgOpt(const MSG_SETTING_S *pSetting, bool bSetSim);
+MSG_ERROR_T MsgSetVoiceMailOpt(const MSG_SETTING_S *pSetting);
+MSG_ERROR_T MsgSetMsgSizeOpt(const MSG_SETTING_S *pSetting);
+
+void MsgGetGeneralOpt(MSG_SETTING_S *pSetting);
+void MsgGetSMSSendOpt(MSG_SETTING_S *pSetting);
+void MsgGetSMSCList(MSG_SETTING_S *pSetting);
+void MsgGetMMSSendOpt(MSG_SETTING_S *pSetting);
+void MsgGetMMSRecvOpt(MSG_SETTING_S *pSetting);
+void MsgGetMMSStyleOpt(MSG_SETTING_S *pSetting);
+void MsgGetPushMsgOpt(MSG_SETTING_S *pSetting);
+void MsgGetCBMsgOpt(MSG_SETTING_S *pSetting);
+void MsgGetVoiceMailOpt(MSG_SETTING_S *pSetting);
+void MsgGetMsgSizeOpt(MSG_SETTING_S *pSetting);
+
+MSG_ERROR_T MsgSetConfigInSim(const MSG_SETTING_S *pSetting);
+
+
+#endif
+
diff --git a/include/framework/MsgStorageHandler.h b/include/framework/MsgStorageHandler.h
new file mode 100755 (executable)
index 0000000..0313cc9
--- /dev/null
@@ -0,0 +1,126 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_STORAGE_HANDLER_H
+#define MSG_STORAGE_HANDLER_H
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgStorageTypes.h"
+#include "MsgSettingTypes.h"
+#include "MsgMmsTypes.h"
+#include "MsgTransportTypes.h"
+#include "MsgInternalTypes.h"
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+MSG_ERROR_T MsgStoConnectDB();
+MSG_ERROR_T MsgStoDisconnectDB();
+
+MSG_ERROR_T MsgStoInitDB(bool bSimChanged);
+
+MSG_ERROR_T MsgCreateAddressTable();
+MSG_ERROR_T MsgCreateFolderTable();
+MSG_ERROR_T MsgCreateMsgTable();
+MSG_ERROR_T MsgCreateSimMessageTable();
+MSG_ERROR_T MsgCreateWAPMessageTable();
+MSG_ERROR_T MsgCreateCBMessageTable();
+MSG_ERROR_T MsgCreateSyncMLMessageTable();
+MSG_ERROR_T MsgCreateScheduledMessageTable();
+MSG_ERROR_T MsgCreateSmsSendOptTable();
+MSG_ERROR_T MsgCreateFilterTable();
+MSG_ERROR_T MsgCreateMmsMsgTable();
+MSG_ERROR_T MsgCreateMmsAttributeTable();
+MSG_ERROR_T MsgAddDefaultFolders();
+MSG_ERROR_T MsgAddDefaultAddress();
+MSG_ERROR_T MsgStoResetDatabase();
+
+MSG_ERROR_T MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S* pSendOptInfo, int addrIdx = 0);
+MSG_ERROR_T MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S* pSendOptInfo, int addrIdx = 0);
+MSG_ERROR_T MsgStoUpdateReadStatus(MSG_MESSAGE_ID_T MsgId, bool bRead);
+MSG_ERROR_T MsgStoUpdateThreadReadStatus(MSG_THREAD_ID_T ThreadId);
+MSG_ERROR_T MsgStoUpdateProtectedStatus(MSG_MESSAGE_ID_T MsgId, bool bProtected);
+MSG_ERROR_T MsgStoDeleteMessage(MSG_MESSAGE_ID_T MsgId, bool bCheckIndication);
+MSG_ERROR_T MsgStoDeleteAllMessageInFolder(MSG_FOLDER_ID_T FolderId, bool bOnlyDB, MSG_MSGID_LIST_S *pMsgIdList);
+MSG_ERROR_T MsgStoMoveMessageToFolder(MSG_MESSAGE_ID_T MsgId, MSG_FOLDER_ID_T DestFolderId);
+MSG_ERROR_T MsgStoMoveMessageToStorage(const MSG_MESSAGE_ID_T MsgId, const MSG_STORAGE_ID_T DestStorageId);
+MSG_ERROR_T MsgStoCountMessage(MSG_FOLDER_ID_T FolderId, MSG_COUNT_INFO_S *pCountInfo);
+MSG_ERROR_T MsgStoCountMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCount);
+MSG_ERROR_T MsgStoGetMessage(MSG_MESSAGE_ID_T MsgId, MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S* pSendOptInfo);
+MSG_ERROR_T MsgStoGetFolderViewList(MSG_FOLDER_ID_T FolderId, const MSG_SORT_RULE_S *pSortRule, MSG_LIST_S *pMsgFolderViewList);
+MSG_ERROR_T MsgStoAddSyncMLMessage(MSG_MESSAGE_INFO_S *pMsgInfo, int ExtId, int PinCode);
+MSG_ERROR_T MsgStoGetMsgType(MSG_MESSAGE_ID_T msgId, MSG_MESSAGE_TYPE_S* pMsgType);
+MSG_ERROR_T MsgStoGetText(MSG_MESSAGE_ID_T MsgId, char *pSubject, char *pMsgText);
+MSG_ERROR_T MsgStoGetQuickPanelData(MSG_QUICKPANEL_TYPE_T Type, MSG_MESSAGE_INFO_S *pMsg);
+MSG_ERROR_T MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, MSG_THREAD_VIEW_LIST_S *pThreadViewList);
+MSG_ERROR_T MsgStoGetConversationViewList(MSG_THREAD_ID_T ThreadId, MSG_LIST_S *pConvViewList);
+MSG_ERROR_T MsgStoDeleteThreadMessageList(MSG_THREAD_ID_T ThreadId, MSG_MSGID_LIST_S *pMsgIdList);
+MSG_ERROR_T MsgStoCountMsgByContact(const MSG_THREAD_LIST_INDEX_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pThreadCountInfo);
+MSG_ERROR_T MsgStoSearchMessage(const char *pSearchString, MSG_THREAD_VIEW_LIST_S *pThreadViewList);
+MSG_ERROR_T MsgStoSearchMessage(const MSG_SEARCH_CONDITION_S *pSearchCon, int offset, int limit, MSG_LIST_S *pMsgList);
+MSG_ERROR_T MsgStoGetMsgIdList(MSG_REFERENCE_ID_T RefId, MSG_MSGID_LIST_S *pMsgIdList);
+MSG_ERROR_T MsgStoGetRejectMsgList(const char *pNumber, MSG_REJECT_MSG_LIST_S *pRejectMsgList);
+MSG_ERROR_T MsgStoGetReportStatus(MSG_MESSAGE_ID_T msgId, MSG_REPORT_STATUS_INFO_S* pReportStatus);
+MSG_ERROR_T MsgStoGetThreadUnreadCnt(MSG_THREAD_ID_T ThreadId, int *cnt);
+
+// Folder
+MSG_ERROR_T MsgStoAddFolder(const MSG_FOLDER_INFO_S *pFolderInfo);
+MSG_ERROR_T MsgStoUpdateFolder(const MSG_FOLDER_INFO_S *pFolderInfo);
+MSG_ERROR_T MsgStoDeleteFolder(MSG_FOLDER_ID_T FolderId);
+MSG_ERROR_T MsgStoGetFolderList(MSG_FOLDER_LIST_S *pFolderList);
+
+// Sim Operation related Functions
+MSG_ERROR_T MsgInitSimMessage(MSG_SIM_STATUS_T SimStatus);
+MSG_ERROR_T MsgStoClearSimMessageInDB();
+
+// Internal Function
+MSG_ERROR_T MsgMakeSortRule(const MSG_SORT_RULE_S *pSortRule, char *pSqlSort);
+MSG_ERROR_T MsgStoGetSmsSendOpt(MSG_MESSAGE_ID_T MsgId, MSG_SENDINGOPT_INFO_S* pSendOpt);
+MSG_ERROR_T MsgStoGetMmsSendOpt(MSG_MESSAGE_ID_T MsgId, MSG_SENDINGOPT_INFO_S* pSendOpt);
+
+// Scheduled Msg
+MSG_ERROR_T MsgStoAddScheduledMessage(MSG_MESSAGE_ID_T MsgID, int AlarmId, int ListenerFd);
+MSG_ERROR_T MsgStoGetScheduledMessage(int AlarmId, MSG_REQUEST_INFO_S *pReqInfo, int *pListenerFd);
+MSG_ERROR_T MsgStoDeleteScheduledMessage(MSG_MESSAGE_ID_T MsgId);
+
+// SyncML Msg
+MSG_ERROR_T MsgStoGetSyncMLExtId(MSG_MESSAGE_ID_T msgId, int *extId);
+bool MsgStoCheckSyncMLMsgInThread(MSG_THREAD_ID_T threadId);
+
+MSG_ERROR_T MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg);
+MSG_ERROR_T MsgStoGetContentLocation(MSG_MESSAGE_INFO_S* pMsgInfo);
+MSG_ERROR_T MsgStoSetReadReportSendStatus(MSG_MESSAGE_ID_T msgId, int readReportSendStatus);
+
+
+///////////////////////////////////////////////////////////////////////////////////
+MSG_ERROR_T MsgStoGetOrgAddressList(MSG_MESSAGE_INFO_S *pMsg);
+MSG_ERROR_T MsgStoUpdateNetworkStatus(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_NETWORK_STATUS_T Status);
+MSG_ERROR_T MsgStoGetSubject(MSG_MESSAGE_ID_T MsgId, char* pSubject);
+MSG_ERROR_T MsgStoGetRecipientList(MSG_MESSAGE_ID_T msgId, MSG_RECIPIENTS_LIST_S *pRecipientList);
+MSG_ERROR_T MsgStoGetReadStatus(MSG_MESSAGE_ID_T MsgId, bool *pReadStatus);
+MSG_ERROR_T MsgStoGetAddrInfo(MSG_MESSAGE_ID_T MsgId, MSG_ADDRESS_INFO_S *pAddrInfo);
+
+///////////////////////////////////////////////////////////////////////////////////
+
+MSG_ERROR_T MsgStoResetNetworkStatus();
+MSG_ERROR_T MsgStoCleanAbnormalMmsData();
+MSG_ERROR_T MsgStoCheckReadReportStatus(MSG_MESSAGE_ID_T msgId);
+
+#endif // MSG_STORAGE_HANDLER_H
+
diff --git a/include/framework/MsgSubmitHandler.h b/include/framework/MsgSubmitHandler.h
new file mode 100755 (executable)
index 0000000..02b353b
--- /dev/null
@@ -0,0 +1,40 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_SUBMIT_HANDLER_H
+#define MSG_SUBMIT_HANDLER_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgInternalTypes.h"
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+MSG_ERROR_T MsgSubmitReq(MSG_REQUEST_INFO_S* pReq, bool bScheduled);
+MSG_ERROR_T MsgSubmitReqSMS(MSG_REQUEST_INFO_S *pReqInfo);
+MSG_ERROR_T MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo, bool bScheduled);
+
+MSG_ERROR_T MsgCancelReq(MSG_REQUEST_ID_T reqId);
+MSG_ERROR_T MsgUpdateSentMsg(MSG_MESSAGE_ID_T MsgId, MSG_NETWORK_STATUS_T Status);
+
+void MsgCopyReqInfo(MSG_REQUEST_INFO_S *pSrc, int addrIdx, MSG_REQUEST_INFO_S *pDest);
+
+#endif // MSG_SUBMIT_HANDLER_H
+
diff --git a/include/framework/MsgTransManager.h b/include/framework/MsgTransManager.h
new file mode 100755 (executable)
index 0000000..62bc504
--- /dev/null
@@ -0,0 +1,123 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_TRANSACTION_MANAGER_H
+#define MSG_TRANSACTION_MANAGER_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <list>
+#include <map>
+
+#include "MsgMutex.h"
+#include "MsgIpcSocket.h"
+#include "MsgCmdTypes.h"
+#include "MsgInternalTypes.h"
+#include "MsgTransportTypes.h"
+
+
+
+/*==================================================================================================
+                                         DEFINITION
+==================================================================================================*/
+typedef std::map<MSG_CMD_TYPE_T, int (*)(const MSG_CMD_S*, char**)> handler_map;
+typedef std::map<int, MSG_PROXY_INFO_S> sentmsg_map;
+typedef std::map<int, bool> fd_map;
+typedef std::list<MSG_CMD_REG_INCOMING_MSG_CB_S> newmsg_list;
+typedef std::list<MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S>      mmsconf_list;
+typedef std::list<MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S> syncmlmsg_list;
+typedef std::list<MSG_CMD_REG_INCOMING_LBS_MSG_CB_S> lbsmsg_list;
+typedef std::list<MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S> javamms_list;
+typedef std::list<MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S> syncmlop_list;
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+void MsgContactChangedCallback();
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class MsgTransactionManager
+{
+public:
+       static MsgTransactionManager* instance();
+
+       void run();
+       void write(int fd, const char* buf, int len);
+
+       // methods for sent status event
+       void insertSentMsg(int reqId, MSG_PROXY_INFO_S* pChInfo);
+       MSG_PROXY_INFO_S* getProxyInfo(int reqId);
+       void delProxyInfo(int reqId);
+
+       void setSentStatusCB(int listenerFd);
+       void setIncomingMsgCB(MSG_CMD_REG_INCOMING_MSG_CB_S *pCbInfo);
+       void setMMSConfMsgCB(MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCbinfo);
+       void setSyncMLMsgCB(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCbinfo);
+       void setLBSMsgCB(MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCbinfo);
+       void setJavaMMSList(MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S *pTrId);
+       void setSyncMLMsgOperationCB(MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCbinfo);
+       void setStorageChangeCB(int listenerFd);
+
+       javamms_list& getJavaMMSList();
+
+       void broadcastIncomingMsgCB(const MSG_ERROR_T err, const MSG_MESSAGE_INFO_S *msgInfo);
+       void broadcastMMSConfCB(const MSG_ERROR_T err, const MSG_MESSAGE_INFO_S *msgInfo, const MMS_RECV_DATA_S *mmsRecvData);
+       void broadcastSyncMLMsgCB(const MSG_ERROR_T err, const MSG_SYNCML_MESSAGE_DATA_S *syncMLData);
+       void broadcastLBSMsgCB(const MSG_ERROR_T err, const MSG_LBS_MESSAGE_DATA_S *lbsData);
+       void broadcastSyncMLMsgOperationCB(const MSG_ERROR_T err, const int msgId, const int extId);
+       void broadcastStorageChangeCB(const MSG_ERROR_T err, const MSG_STORAGE_CHANGE_TYPE_T storageChangeType, const MSG_MSGID_LIST_S *pMsgIdList);
+
+       void setTMStatus();
+       void getTMStatus();
+
+private:
+       MsgTransactionManager();
+       ~MsgTransactionManager();
+
+       void handleRequest(int fd);
+       void cleanup(int fd);
+       bool checkPrivilege(MSG_CMD_TYPE_T CmdType, const char *pCookie);
+
+       static MsgTransactionManager* pInstance;
+
+       static MsgIpcServerSocket servSock;
+       bool running;
+
+       handler_map handlerMap;
+
+       sentmsg_map sentMsgMap;                 // req_id, listener_fd, msghandle_addr
+       fd_map statusCBFdMap;           // src_fd, true if registered
+
+       newmsg_list newMsgCBList;       // src_fd, msgType, port if registered
+       mmsconf_list newMMSConfMsgCBList;       // src_fd, msgType, port if registered
+       syncmlmsg_list newSyncMLMsgCBList;      // src_fd, msgType, port if registered
+       lbsmsg_list newLBSMsgCBList;    // src_fd, msgType, port if registered
+       javamms_list javaMMSList; // trId list to distinguish sent Java MMS msg when sendconf received
+       syncmlop_list operationSyncMLMsgCBList;         // src_fd, msgType, port if registered
+
+       fd_map storageChangeFdMap;      // src_fd, true if registered
+
+       Mutex mx;
+       CndVar cv;
+};
+
+#endif //MSG_TRANSACTION_MANAGER_H
+
diff --git a/include/mapi/MapiControl.h b/include/mapi/MapiControl.h
new file mode 100755 (executable)
index 0000000..6ebbad1
--- /dev/null
@@ -0,0 +1,193 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+/**
+ *     @file           MapiControl.h
+ *     @brief          Defines control API of messaging framework
+ *     @version        1.0
+ */
+
+#ifndef MAPI_CONTROL_H
+#define MAPI_CONTROL_H
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Messaging Control API
+ *     @section                Program
+ *     - Program : Messaging Control API Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include "MsgTypes.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_CONTROL_API   Messaging Control API
+ *     @{
+ */
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+
+ * \par Description:
+ * Opens a channel between an application and messaging framework.
+ *
+ * \par Purpose:
+ * For application to utilize the services of Messaging Framework, this API should be called to establish connection between the application and Messaging Framework.
+ *
+ * \par Typical use case:
+ * Any application which utilizes the services of Messaging Framework needs to call this API.
+ *
+ * \par Method of function operation:
+ * Check for Message Server ready status. If ready connect to the Messaging Server socket and pass the handle application.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - The handle parameter returned must be used by application for further API calls to Messaging Service \n
+ * - memory for the handle need not be allocated by the application \n
+ * - An error will be returned in case Messaging Service is not running.
+ *
+ * \param MSG_HANDLE_T    input - handle to be passed for all Messaging Services .
+ *
+ * \return Return Type (int) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ * - MSG_ERR_MEMORY_ERROR -    Memory error.
+ * - MSG_ERR_COMMUNICATION_ERROR       - Communication error between client and server \n
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_open_msg_handle() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_open_msg_handle(MSG_HANDLE_T *handle);
+
+
+/**
+
+ * \par Description:
+ * Closes the channel between application and messaging framework.
+ *
+ * \par Purpose:
+ * Once application utilizes services of Messaging Service, this API needs to be invoked the close the channel between application and Messaging Service.
+ *
+ * \par Typical use case:
+ * Any application which has completed using services of Messaging Framework needs to call this API.
+ *
+ * \par Method of function operation:
+ * Closes the connection to Messaging Service and deleted the reference to the handle object
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - The handle parameter returned must be used by application for further API calls to Messaging Service \n
+ * - memory for the handle need not be allocated by the application \n
+ * - An error will be returned in case Messaging Service is not running.
+ *
+ * \param MSG_HANDLE_T    input - handle to be passed for all Messaging Services .
+ *
+ * \return Return Type (int) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ * - MSG_ERR_COMMUNICATION_ERROR       - Communication error between client and server \n
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_close_msg_handle(&msgHandle);
+ *
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_close_msg_handle() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_close_msg_handle(MSG_HANDLE_T *handle);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MAPI_STORAGE_H
+
diff --git a/include/mapi/MapiMessage.h b/include/mapi/MapiMessage.h
new file mode 100755 (executable)
index 0000000..a4e5630
--- /dev/null
@@ -0,0 +1,4923 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+/**
+ *     @file           MapiMessage.h
+ *     @brief  Defines message data API of messaging framework
+ *     @version        1.0
+ */
+
+#ifndef MAPI_MESSAGE_H
+#define MAPI_MESSAGE_H
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on message data related API
+ *     @section                Program
+ *     - Program : message data related API Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include "MsgTypes.h"
+#include "MsgMmsTypes.h"
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ *     @ingroup        MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_DATA_API      Messaging Data API
+ *     @{
+ */
+
+/*==================================================================================================
+                                                                        FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+
+ * \par Description:
+ * Allocate the memory for new message, which is used for composing SMS or MMS.
+ *
+ * \par Purpose:
+ * This API is used to create Message object and should be called before any operation on the message object.
+ *
+ * \par Typical use case:
+ * Before performing common operations on Messages such as Send, Save, Load, etc., this API should be called to create the message object.
+ *
+ * \par Method of function operation:
+ * Creates the Message Object and initiaizes the members to default values.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - The type msg_message_t represents message object and hides the details of message object.
+ * - Memory for the Message abject need NOT be created by the called \n
+ * - You can set or get the value of message object using the below APIs.
+ * - You should release the memory using msg_release_message(), unless memory leaks.
+ *
+ * \param none.
+ *
+ * \return Return Type (msg_message_t) \n
+ * - msg_message_t - valid message object is returned upon success \n
+ * - NULL      - In case of error in allocation of message object \n
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_message_t               msg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg = msg_new_message();
+ *
+ * if (msg == NULL)
+ * {
+ *     sprintf(str, "msg_new_message() Fail");
+ *     print(str);
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+msg_message_t msg_new_message(void);
+
+
+/**
+
+ * \par Description:
+ * Free the memory of msg_message_t, which is created by msg_new_message().
+ *
+ * \par Purpose:
+ * This API is used to release memory created by message creation.
+ *
+ * \par Typical use case:
+ * After using message object for send/save scenario, release message need to be called.
+ *
+ * \par Method of function operation:
+ * Frees the memory allocated to message object and deletes the object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t    input - message object to be destroyed .
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t               msg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg = msg_new_message();
+ * ...
+ * err = msg_release_message(&msg);
+ *
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_release_message() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_release_message(msg_message_t *msg);
+
+
+
+/**
+
+ * \par Description:
+ * Set message id field to the passed msg_id.
+ *
+ * \par Purpose:
+ * This API is used to set the Message Id of the message object
+ *
+ * \par Typical use case:
+ * Explicitly set the msgId member of message object.
+ *
+ * \par Method of function operation:
+ * Set the msgId member of msg_message_t to the passed msgId.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object whose msgId is to be set.
+ * \param int    input - Message Id to be set to the message id.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t               msg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_add_message(msgHandle, msg, &sendOpt);
+ * ...
+ * err = msg_set_message_id(msg, 0);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_release_message() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_message_id(msg_message_t msg, int msg_id);
+
+
+/**
+
+ * \par Description:
+ * Get the message id in message object.
+ *
+ * \par Purpose:
+ * This API is used to get the Message Id of the message object
+ *
+ * \par Typical use case:
+ * Msg Id is needed to perform many operations on the message object.
+ *
+ * \par Method of function operation:
+ * Returns the Message Id of the message object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t    input - message object whose msgId is returned.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t               msg;
+ * int msgId;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_add_message(msgHandle, msg, &sendOpt);
+ * ...
+ * msgId = msg_get_message_id(msg);
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_message_id(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Check if the message object is an SMS Message
+ *
+ * \par Purpose:
+ * This API is used to to check if the message object is SMS type message
+ *
+ * \par Typical use case:
+ * To check if the message object type is SMS.
+ *
+ * \par Method of function operation:
+ * Compares the message object against SMS message type.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, nothing happens.
+ * - If msg is invalid, undefined behavior happens.
+ *
+ * \param msg_message_t    input - message object which is to be decided if its SMS.
+ *
+ * \return Return Type (bool) \n
+ * - true      - If message object is SMS  \n
+ * - false - If message object is not SMS.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t               msg;
+ * int msgId;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_add_message(msgHandle, msg, &sendOpt);
+ * ...
+ * if( msg_is_sms(msg) )
+ * {
+ *     sprintf(str, "Message object is SMS");
+ *     print(str);
+ * }
+ *...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+bool msg_is_sms(msg_message_t msg);
+
+
+
+/**
+
+ * \par Description:
+ * Check if the message object is an MMS Message
+ *
+ * \par Purpose:
+ * This API is used to to check if the message object is MMS type message
+ *
+ * \par Typical use case:
+ * To check if the message object type is MMS.
+ *
+ * \par Method of function operation:
+ * Compares the message object against MMS message type.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t    input - message object which is to be decided if its MMS.
+ *
+ * \return Return Type (bool) \n
+ * - true      - If message object is MMS  \n
+ * - false - If message object is not MMS.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t               msg;
+ * int msgId;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_add_message(msgHandle, msg, &sendOpt);
+ * ...
+ * if( msg_is_mms(msg) )
+ * {
+ *     sprintf(str, "Message object is MMS");
+ *     print(str);
+ * }
+ *...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+bool msg_is_mms(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Set storage id field to the passed storage_id.
+ *
+ * \par Purpose:
+ * This API is used to set the Storage Id of the message object
+ *
+ * \par Typical use case:
+ * Message objects can be saved in either phone memory or SIM card, this API helps in setting the same.
+ *
+ * \par Method of function operation:
+ * Set the storageId member of msg_message_t to the passed Storage Id.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object whose msgId is to be set.
+ * \param MSG_STORAGE_ID_T    input - Storage Id to be set to the message storage id.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t               msg;
+ * MSG_STORAGE_ID_T storageId = 0;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_add_message(msgHandle, msg, &sendOpt);
+ * ...
+ * err = msg_set_storage_id(msg, storageId);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_storage_id() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_storage_id(msg_message_t opq_msg, MSG_STORAGE_ID_T storage_id);
+
+
+/**
+
+ * \par Description:
+ * Gets storage id field of the message object.
+ *
+ * \par Purpose:
+ * This API is used to get Storage Id of the message object
+ *
+ * \par Typical use case:
+ *  * Message objects can be saved in either phone memory or SIM card, this API helps in getting the same.
+ *
+ * \par Method of function operation:
+ * Returnsthe storageId member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object whose msgId is to be set.
+ *
+ * \return Return Type (int (MSG_ERROR_T when negative, enum _MSG_STORAGE_ID_E when positive)) \n
+ * - storageId - Returns the storage Id defined by enum _MSG_STORAGE_ID_E. \n
+ * - MSG_ERR_NULL_POINTER                      msg is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t               msg;
+ * MSG_STORAGE_ID_T storageId = 0;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_add_message(msgHandle, msg, &sendOpt);
+ * ...
+ * storageId = msg_get_storage_id(msg);
+ *
+ * sprintf(str, "msg_set_storage_id() storageId [%d]", storageId);
+ * print(str);
+ *
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_storage_id(msg_message_t opq_msg);
+
+
+/**
+
+ * \par Description:
+ * Check if the message object is saved in SIM card
+ *
+ * \par Purpose:
+ * This API is used to to check if the message object is saved in SIM card
+ *
+ * \par Typical use case:
+ * Message can be stored in Phone memory or SIM card, to check this we can use this API.
+ *
+ * \par Method of function operation:
+ * Checks if storage Id is SIM and returns boolean.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (bool) \n
+ * - true      - If message object is stored in SIM  \n
+ * - false - If message object is not stored in SIM.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t               msg;
+ * int msgId;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_add_message(msgHandle, msg, &sendOpt);
+ * ...
+ * if( msg_is_in_sim(msg) )
+ * {
+ *     sprintf(str, "Message object stored in SIM");
+ *     print(str);
+ * }
+ *...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+bool msg_is_in_sim(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Set the message type field to msg_type.
+ *
+ * \par Purpose:
+ * This API is used to set the Message Type of the message object
+ *
+ * \par Typical use case:
+ * Message Objects can be SMS, MMS, etc message types, this API helps to set the message type.
+ *
+ * \par Method of function operation:
+ * Set the msgType member of msg_message_t to the passed msgType.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object whose msgId is to be set.
+ * \param MSG_MESSAGE_TYPE_T    input - Message type to be set.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_message_t               msg;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_add_message(msgHandle, msg, &sendOpt);
+ * ...
+ * err = msg_set_message_type(msg, MSG_TYPE_SMS);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_message_type() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_message_type(msg_message_t msg, MSG_MESSAGE_TYPE_T msg_type);
+
+
+/**
+
+ * \par Description:
+ * Gets Message type field of the message object.
+ *
+ * \par Purpose:
+ * This API is used to get Message Type of the message object
+ *
+ * \par Typical use case:
+ * Message Objects can be SMS, MMS, etc message types, this API helps to get the message type.
+ *
+ * \par Method of function operation:
+ * Returns the msgType member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object whose msgType  is to be set.
+ *
+ * \return Return Type (int) \n
+ * - msgType - Returns the Message type of the Message object passed \n
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_message_t               msg;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * int  msgType = 0;
+
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_add_message(msgHandle, msg, &sendOpt);
+ * ...
+ * msgType = msg_get_message_type(msg);
+ *
+ * sprintf(str, "msg_get_message_type() Type [%d]", msgType);
+ * print(str);
+ *
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_message_type(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Set the folder id field to folder_id.
+ *
+ * \par Purpose:
+ * This API is used to sets the Folder Id of the message object
+ *
+ * \par Typical use case:
+ * Message Objects can be associated with different folders such as Inbox, Outbox, Sent, etc. this API enables to set the folder id.
+ *
+ * \par Method of function operation:
+ * Set the folderId member of msg_message_t to the passed folder_id.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object whose msgId is to be set.
+ * \param MSG_FOLDER_ID_T    input - Folder Id to be set.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * MSG_FOLDER_ID_T folder_id = MSG_INBOX_ID;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_add_message(msgHandle, msg, &sendOpt);
+ * ...
+ * err = msg_set_folder_id(msg, folder_id);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_folder_id() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_folder_id(msg_message_t msg, MSG_FOLDER_ID_T folder_id);
+
+
+/**
+
+ * \par Description:
+ * Gets Folder Id field of the message object.
+ *
+ * \par Purpose:
+ * This API is used to get Folder Id of the message object
+ *
+ * \par Typical use case:
+ * Message Objects can be associated with different folders such as Inbox, Outbox, Sent, etc. this API enables to get the folder id.
+ *
+ * \par Method of function operation:
+ * Returns the folderId member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (int) \n
+ * - storageId - Returns the Folder Id of the Message object passed \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int  folderId = 0;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_add_message(msgHandle, msg, &sendOpt);
+ * ...
+ * folderId = msg_get_folder_id(msg);
+ *
+ * sprintf(str, "msg_get_folder_id() Folder Id [%d]", folderId);
+ * print(str);
+ *
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_folder_id(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Reset address field in message object.
+ *
+ * \par Purpose:
+ * This API is used for modifying the message object, such as forwarding a message.
+ *
+ * \par Typical use case:
+ * Message Object address field might be needed to reset. This API helps in the same.
+ *
+ * \par Method of function operation:
+ * Flushes the already set address list and reset to defaults.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (bool) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int msgId;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0};
+ * err = msg_get_message(msgHandle, (MSG_MESSAGE_ID_T)msgId, msg, &sendOpt);
+ * err = msg_reset_address(msg);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_release_message() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_reset_address(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Add recipient address in message object.
+ *
+ * \par Purpose:
+ * This API is used for adding address to the message object.
+ *
+ * \par Typical use case:
+ * Message Object recipient address field should be filled before message can be sent over the network.
+ *
+ * \par Method of function operation:
+ * The phone_num_list is added to the addressList member of the message object structure.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t        input - message object.
+ * \param phone_num_list       input - concatenated number string, which is separated by ",", such as "1112223333, 4445556666".
+ * \param to_type                      input - to_type is one of enum _MSG_RECIPIENT_TYPE_E.
+ *
+ * \return Return Type (bool) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int msgId;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0};
+ * err = msg_get_message(msgHandle, (MSG_MESSAGE_ID_T)msgId, msg, &sendOpt);
+ * err = msg_add_address(msg, "+1004", MSG_RECIPIENTS_TYPE_TO);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_release_message() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_add_address(msg_message_t msg, const char* phone_num_list, MSG_RECIPIENT_TYPE_T to_type);
+
+
+/**
+
+ * \par Description:
+ * Return count of recipient address in message object.
+ *
+ * \par Purpose:
+ * This API is used for getting the count of recipient addresses in the message object.
+ *
+ * \par Typical use case:
+ * To get the count of the recipient list in the message object.
+ *
+ * \par Method of function operation:
+ * Returns the address count member of the message object..
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t        input - message object.
+ *
+ * \return Return Type (int) \n
+ * - recipient count \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int nCount;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0};
+ * nCount = msg_get_address_count(msg);
+ * sprintf(str, "msg_add_address() nCount [%d]", nCount);
+ * print(str);
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_address_count(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Return ith thread id in message object.
+ *
+ * \par Purpose:
+ * This API is used for getting the ith thread id in message object.
+ *
+ * \par Typical use case:
+ * Get the requested thread id from the message object.
+ *
+ * \par Method of function operation:
+ * Returns the ith thread id from the message object address list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t        input - message object.
+ * \param int                          input - thread id.
+ *
+ * \return Return Type (int) \n
+ * - thread id \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int nCount;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_get_ith_thread_id(msg, 0);
+ * if(err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_get_ith_thread_id() Fail [%d]", err);
+ *     print(str);
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_ith_thread_id(msg_message_t msg, int ith);
+
+
+/**
+
+ * \par Description:
+ * Return ith recipient address in message object.
+ *
+ * \par Purpose:
+ * This API is used for getting the ith recipient address in message object.
+ *
+ * \par Typical use case:
+ * To get the requested recipient address index from the message object.
+ *
+ * \par Method of function operation:
+ * Returns the ith recipient address in address list from the message object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - You do not need to free the return value. It will be freed when you call msg_release_message().
+ * -   Also, the value is valid until msg_message_t is freed by calling msg_release_message().
+ *
+ * \param msg_message_t        input - message object.
+ * \param int                          input - recipient address index.
+ *
+ * \return Return Type (int) \n
+ * - thread id \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * const char* address;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * address = msg_get_ith_address(msg, 0);
+ * if(address != NULL && strlen(address) > 0)
+ * {
+ *     sprintf(str, "msg_get_ith_address() address [%s]", address);
+ *     print(str);
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+const char* msg_get_ith_address(msg_message_t msg, int ith);
+
+
+/**
+
+ * \par Description:
+ * Return ith recipient type in message object.
+ *
+ * \par Purpose:
+ * This API is used for getting the ith recipient type in message object.
+ *
+ * \par Typical use case:
+ * To get the requested recipient type from the message object.
+ *
+ * \par Method of function operation:
+ * Returns the ith recipient type in address list from the message object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t        input - message object.
+ * \param int                          input - recipient address index.
+ *
+ * \return Return Type (int) \n
+ * - thread id \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int r_type;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * r_type = msg_get_ith_recipient_type(msg, 0);
+ * sprintf(str, "msg_get_ith_recipient_type() r_type [%s]", r_type);
+ * print(str);
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_ith_recipient_type(msg_message_t msg, int ith);
+
+
+/**
+
+ * \par Description:
+ * Return ith recipient name which is associated with contact engine.
+ *
+ * \par Purpose:
+ * This API is used for getting the ith recipient name which is associated with contact engine.
+ *
+ * \par Typical use case:
+ * To get the requested recipient name from the message object which is associated with the contact engine.
+ *
+ * \par Method of function operation:
+ * Returns the ith recipient name of the address list from the message object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - You do not need to free the return value. It will be freed when you call msg_release_message().
+ * - Also, the value is valid until msg_message_t is freed by calling msg_release_message().
+ *
+ * \param msg_message_t        input - message object.
+ * \param int                          input - recipient address index.
+ *
+ * \return Return Type (int) \n
+ * - thread id \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * const char* name;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * name = msg_get_ith_name(msg, 0);
+ * if(name != NULL && strlen(name) > 0)
+ * {
+ *     sprintf(str, "msg_get_ith_recipient_type() name [%s]", name);
+ *     print(str);
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+const char* msg_get_ith_name(msg_message_t msg, int ith);
+
+
+/**
+
+ * \par Description:
+ * Return ith recipient contact id which is associated with contact engine.
+ *
+ * \par Purpose:
+ * This API is used for getting the ith recipient contact id which is associated with contact engine.
+ *
+ * \par Typical use case:
+ * To get the requested recipient contact id from the message object which is associated with the contact engine.
+ *
+ * \par Method of function operation:
+ * Returns the ith recipient contact id in address list from the message object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, nothing happens.
+ * - If msg is invalid, undefined behavior happens.
+ *
+ * \param msg_message_t        input - message object.
+ * \param int                          input - recipient address index.
+ *
+ * \return Return Type (int) \n
+ * - thread id \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int contact_id;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ * ...
+ * contact_id = msg_get_ith_contact_id(msg, 0);
+ * sprintf(str, "msg_get_ith_contact_id() contact_id [%d]", contact_id);
+ * print(str);
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_ith_contact_id(msg_message_t msg, int ith);
+
+
+/**
+
+ * \par Description:
+ * Add reply address in message object.
+ *
+ * \par Purpose:
+ * This API is used for adding reply address to the message object.
+ *
+ * \par Typical use case:
+ * Message Object reply address field should be filled before message can be sent over the network.
+ *
+ * \par Method of function operation:
+ * The phone_num is set to the replyAddress of the message object structure.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t        input - message object.
+ * \param phone_num            input - phone number such as "1112223333, 4445556666".
+ *
+ * \return Return Type (bool) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      - Input parameter is NULL.
+ * - MSG_ERR_INVALID_PARAMETER - Input parameter is too long.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int msgId;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0};
+ * err = msg_get_message(msgHandle, (MSG_MESSAGE_ID_T)msgId, msg, &sendOpt);
+ * err = msg_set_reply_address(msg, "+821030016057");
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_release_message() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_reply_address(msg_message_t opq_msg, const char* phone_num);
+
+
+/**
+
+ * \par Description:
+ * Set data field to mdata of size. SMS data is used for either of text or binary data.
+ *
+ * \par Purpose:
+ * This API is used to set the Message data field of the message object to the passed mdata parameter of size bytes.
+ *
+ * \par Typical use case:
+ * Message Object needs to be filled with the data member, in case of SMS data can be text or binary and in case of MMS data is the MIME encoded buffer.
+ *
+ * \par Method of function operation:
+ * Copies "size" bytes of mdata to the pData member of the message object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t        input - message object whose msgId is to be set.
+ * \param const char*                  input - data to be set.
+ * \param int                          input - size of mdata to be set to message object
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ * - MSG_ERR_INVALID_PARAMETER                 class_type is not one of enum _MSG_CLASS_TYPE_E.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * const char *msg_body = "Sample Message Body";
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ * ...
+ * msg = msg_new_message();
+ *
+ * ...
+ * ...
+ * err = msg_sms_set_message_body(msg, msg_body, strlen(msg_body));
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_sms_set_message_body() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_sms_set_message_body(msg_message_t msg, const char* mdata, int size);
+
+
+/**
+
+ * \par Description:
+ * Return data field in message object. SMS data is used for either of text or binary data.
+ *
+ * \par Purpose:
+ * This API is used for getting the data field of the message object.
+ *
+ * \par Typical use case:
+ * Message Object needs to be filled with the data member, in case of SMS data can be text or binary and in case of MMS data is the MIME encoded buffer.
+ *
+ * \par Method of function operation:
+ * Returns the storageId member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object whose msgId is to be set.
+ *
+ * \return Return Type (const char* (message body)) \n
+ * - char array        - Message body data \n
+ * - NULL              - Error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * const char *msg_body;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * msg_body = msg_sms_get_message_body(msg);
+ * if (msg_body != NULL && strlen(msg_body) > 0)
+ * {
+ *     sprintf(str, "msg_sms_set_message_body() msg_body [%s]", msg_body);
+ *     print(str);
+ * }
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+const char* msg_sms_get_message_body(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Return data field in message object. MMS data is used for text.
+ *
+ * \par Purpose:
+ * This API is used for getting the data field of the message object.
+ *
+ * \par Typical use case:
+ * Message Object needs to be filled with the data member, in case of SMS data can be text or binary and in case of MMS data is the MIME encoded buffer.
+ *
+ * \par Method of function operation:
+ * Returns the storageId member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object whose msgId is to be set.
+ *
+ * \return Return Type (const char* (message body)) \n
+ * - char array        - Message body data \n
+ * - NULL              - Error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * const char *msg_body;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * msg_body = msg_mms_get_text_contents(msg);
+ * if (msg_body != NULL && strlen(msg_body) > 0)
+ * {
+ *     sprintf(str, "msg_mms_get_text_contents() msg_body [%s]", msg_body);
+ *     print(str);
+ * }
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+const char* msg_mms_get_text_contents(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Gets the size of data field in message object.
+ *
+ * \par Purpose:
+ * This API is used for getting the size of data field in message object.
+ *
+ * \par Typical use case:
+ * Size of the Message data field can be useful in various scenarios such as restrict sending large MMS, display size to user, etc.
+ *
+ * \par Method of function operation:
+ * Returns the dataSize member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (int) \n
+ * - int - Size of the data in the Message Object
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int msg_body_size;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * msg_body_size = msg_get_message_body_size(msg);
+ * sprintf(str, "msg_sms_set_message_body() msg_body_size [%d]", msg_body_size);
+ * print(str);
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_message_body_size(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Sets subject field of the message object to subject. This API is used for MMS.
+ *
+ * \par Purpose:
+ * This API is used for setting the subject field of the message object
+ *
+ * \par Typical use case:
+ * MMS message object may contain subject field, this API enables to set the same.
+ *
+ * \par Method of function operation:
+ * Set the subject member of msg_message_t to the passed subject.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object whose msgId is to be set.
+ * \param const char*    input - Subject to be set.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * const char* subject = "Test Subject";
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_set_subject(msg, subject);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_subject() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_subject(msg_message_t msg, const char* subject);
+
+
+/**
+
+ * \par Description:
+ * Returns the subject field of the message object. This API is used for MMS.
+ *
+ * \par Purpose:
+ * This API is used for getting the subject field of the message object
+ *
+ * \par Typical use case:
+ * MMS message object may contain subject field, this API enables to get the same.
+ *
+ * \par Method of function operation:
+ * Returns the subject member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (const char*) \n
+ * - const char        - MMS message subject \n
+ * - NULL      -       Message object/Subject field is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * char* msg_subject;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * msg_subject = msg_get_subject(msg);
+ * if(msg_subject != NULL && strlen(msg_subject) > 0)
+ * {
+ *     sprintf(str, "msg_get_subject() msg_subject [%s]", msg_subject);
+ *     print(str);
+ * }
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+const char* msg_get_subject(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Set time field to msg_time of the message object. \n
+ * If you need to update time in message object, use this API with passing time() in time.h.
+ *
+ * \par Purpose:
+ * This API is used for setting the message time of the message object
+ *
+ * \par Typical use case:
+ * Message object should contain the time field before it is sent over the network.
+ *
+ * \par Method of function operation:
+ * Set the msg_time member of msg_message_t to the passed msg_time.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object whose msgId is to be set.
+ * \param const char*    input - Subject to be set.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * time_t curTime = time(NULL);
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+* msg = msg_new_message();
+* err = msg_set_time(msgInfo, curTime);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_time() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_time(msg_message_t msg, time_t msg_time);
+
+
+/**
+
+ * \par Description:
+ * Return the time field in message object.
+ *
+ * \par Purpose:
+ * This API is used for getting the time field of the message object
+ *
+ * \par Typical use case:
+ * Message object should contain the time field before it is sent over the network.
+ *
+ * \par Method of function operation:
+ * Returns the msg_time member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (time_t) \n
+ * - time_t - Message time value \n
+ * - NULL       - Message object is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * time_t msg_time;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * msg_time = msg_get_time(msg);
+ * sprintf(str, "msg_get_time() msg_time [%s]", ctime(msg_time));
+ * print(str);
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+time_t* msg_get_time(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Set network status to status. Network status represents the status result when you send/receive the message.
+ *
+ * \par Purpose:
+ * This API is used for setting the network status field of the message object
+ *
+ * \par Typical use case:
+ *  Network status represents the status result when you send/receive the message.
+ *
+ * \par Method of function operation:
+ * Set the networkStatus member of msg_message_t to the passed status.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object whose msgId is to be set.
+ * \param int    input - status is one of enum _MSG_NETWORK_STATUS_E.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err= msg_set_network_status(msg, MSG_NETWORK_SEND_SUCCESS);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_network_status() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_network_status(msg_message_t msg, MSG_NETWORK_STATUS_T status);
+
+
+/**
+
+ * \par Description:
+ * Returns the network status of message object. Network status represents the status result when you send/receive the message.
+ *
+ * \par Purpose:
+ * This API is used for getting the networkStatus field of the message object
+ *
+ * \par Typical use case:
+ *  Network status represents the status result when you send/receive the message.
+ *
+ * \par Method of function operation:
+ * Returns the networkStatus member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (int (MSG_ERROR_T when negative, enum _MSG_NETWORK_STATUS_E when positive)) \n
+ * - positive int                                              enum _MSG_NETWORK_STATUS_E.
+ * - MSG_ERR_NULL_POINTER                              msg is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int network_status;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * network_status = msg_get_network_status(msg);
+ *sprintf(str, "msg_get_network_status() network_status [%d]", network_status);
+ * print(str);
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_network_status(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Set message data encode type to encoding_type. The message data is encoded with one of GSM-7, ascii, ucs2, or auto.
+ *
+ * \par Purpose:
+ * This API is used for setting the encode type field of the message object
+ *
+ * \par Typical use case:
+ * The message data is encoded with one of GSM-7, ascii, ucs2, or auto.
+ *
+ * \par Method of function operation:
+ * Set the encodeType member of msg_message_t to the passed encoding_type.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ * \param MSG_ENCODE_TYPE_T    input - encode type to be set.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_set_encode_type(msgInfo, MSG_ENCODE_GSM7BIT);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_encode_type() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_encode_type(msg_message_t msg, MSG_ENCODE_TYPE_T encoding_type);
+
+
+/**
+
+ * \par Description:
+ * Return message data encode type. The message data is encoded with one of GSM-7, ascii, ucs2, or auto.
+ *
+ * \par Purpose:
+ * This API is used for getting the encode type field of the message object
+ *
+ * \par Typical use case:
+ *  The message data is encoded with one of GSM-7, ascii, ucs2, or auto.
+ *
+ * \par Method of function operation:
+ * Returns the encodeType member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (int) \n
+ * - positive int                                              enum MSG_ENCODE_TYPE_T.
+ * - MSG_ERR_NULL_POINTER                              msg is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int encode_type;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * encode_type = msg_get_encode_type(msg);
+ * sprintf(str, "msg_get_network_status() encode_type [%d]", encode_type);
+ * print(str);
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_encode_type(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Set message read status to read_flag.
+ *
+ * \par Purpose:
+ * This API is used to set read status to bRead field of the message object
+ *
+ * \par Typical use case:
+ * Read status can be set using this API.
+ *
+ * \par Method of function operation:
+ * Set the bRead member of msg_message_t to the passed read_flag.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ * \param bool    input - read status to be set.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_set_read_status(msg, true);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_read_status() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_read_status(msg_message_t msg, bool read_flag);
+
+
+/**
+
+ * \par Description:
+ * Return true if the message is read.
+ *
+ * \par Purpose:
+ * This API is used to check if the message object is read.
+ *
+ * \par Typical use case:
+ * Read status can be checked using this API.
+ *
+ * \par Method of function operation:
+ * Checks if message object is read and returns bool.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (bool) \n
+ * - true      - If message object is read \n
+ * - false - If message object is not read.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int msgId;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * if( msg_is_read(msgInfo) )
+ * {
+ *     sprintf(str, "Message object is read");
+ *     print(str);
+ * }
+ *...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+bool msg_is_read(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Set message protect status to protect_flag.
+ *
+ * \par Purpose:
+ * This API is used to set message protect status to protect_flag.
+ *
+ * \par Typical use case:
+ * Message protect status can be set using this API.
+ *
+ * \par Method of function operation:
+ * Set the bProtected member of msg_message_t to the passed protect_flag.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ * \param bool    input - protect status to be set.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_set_protect_status(msg, true);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_protect_status() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_protect_status(msg_message_t msg, bool protect_flag);
+
+
+/**
+
+ * \par Description:
+ * Return true if the message is protected.
+ *
+ * \par Purpose:
+ * This API is used to check if the message object is protected.
+ *
+ * \par Typical use case:
+ * Protected status can be checked using this API.
+ *
+ * \par Method of function operation:
+ * Checks if message object is protected and returns bool.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (bool) \n
+ * - true      - If message object is protected \n
+ * - false - If message object is not protected.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int msgId;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * if( msg_is_protected(msgInfo) )
+ * {
+ *     sprintf(str, "Message object is protected");
+ *     print(str);
+ * }
+ *...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+bool msg_is_protected(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Set message backup status to backup_flag.
+ *
+ * \par Purpose:
+ * This API is used to set message backup status to backup_flag.
+ *
+ * \par Typical use case:
+ * Message backup status can be set using this API.
+ *
+ * \par Method of function operation:
+ * Set the bBackup member of msg_message_t to the passed backup_flag.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ * \param bool    input - backup status to be set.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_set_backup_status(msg, true);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_backup_status() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_backup_status(msg_message_t opq_msg, bool backup_flag);
+
+
+/**
+
+ * \par Description:
+ * Return true if the message is a backup.
+ *
+ * \par Purpose:
+ * This API is used to check if the message object is a backup.
+ *
+ * \par Typical use case:
+ * Backup status can be checked using this API.
+ *
+ * \par Method of function operation:
+ * Checks if message object is a backup and returns bool.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (bool) \n
+ * - true      - If message object is a backup \n
+ * - false - If message object is not a backup.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int msgId;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * if( msg_is_backup(msgInfo) )
+ * {
+ *     sprintf(str, "Message object is a backup");
+ *     print(str);
+ * }
+ *...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+bool msg_is_backup(msg_message_t opq_msg);
+
+
+/**
+
+ * \par Description:
+ * Set message priority to priority.
+ *
+ * \par Purpose:
+ * This API is used to set message priority to priority.
+ *
+ * \par Typical use case:
+ * Message priority can be set using this API.
+ *
+ * \par Method of function operation:
+ * Set the priority member of msg_message_t to the passed priority.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ * \param bool    input - priority status to be set.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_set_priority_info(msgInfo, MSG_MESSAGE_PRIORITY_NORMAL);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_priority_info() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_priority_info(msg_message_t msg, MSG_PRIORITY_TYPE_T priority);
+
+
+/**
+
+ * \par Description:
+ * Return priority value in message object.
+ *
+ * \par Purpose:
+ * This API is used for getting the priority field of the message object
+ *
+ * \par Typical use case:
+ * Message priority can be got using this API.
+ *
+ * \par Method of function operation:
+ * Returns the priority member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type int (MSG_ERROR_T when negative, enum _MSG_PRIORITY_TYPE_E) \n
+ * - positive int                                              enum _MSG_PRIORITY_TYPE_E.
+ * - MSG_ERR_NULL_POINTER                              msg is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int priority;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * priority = msg_get_priority_info(msg);
+ * sprintf(str, "msg_get_priority_info() priority [%d]", priority);
+ * print(str);
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_priority_info(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Set message direction to direction.
+ *
+ * \par Purpose:
+ * This API is used to set message direction to direction.
+ *
+ * \par Typical use case:
+ * Message direction can be set using this API.
+ *
+ * \par Method of function operation:
+ * Set the direction member of msg_message_t to the passed direction.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ * \param int    input - defined in enum _MSG_DIRECTION_TYPE_E.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_set_direction_info(msgInfo, MSG_DIRECTION_TYPE_MT);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_direction_info() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_direction_info(msg_message_t msg, MSG_DIRECTION_TYPE_T direction);
+
+
+/**
+
+ * \par Description:
+ * Return direction information in message object.
+ *
+ * \par Purpose:
+ * This API is used for getting the direction information in message object.
+ *
+ * \par Typical use case:
+ * Message direction can be got using this API.
+ *
+ * \par Method of function operation:
+ * Returns the direction member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type int (MSG_ERROR_T when negative, enum _MSG_DIRECTION_TYPE_E when positive) \n
+ * - positive int                                              enum _MSG_DIRECTION_TYPE_E.
+ * - MSG_ERR_NULL_POINTER                              msg is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int direction;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * direction = msg_get_direction_info(msg);
+ * sprintf(str, "msg_get_direction_info() direction [%d]", direction);
+ * print(str);
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_direction_info(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Set message port to dst_prt and src_port.
+ *
+ * \par Purpose:
+ * This API is used to set message port to dst_prt and src_port.
+ *
+ * \par Typical use case:
+ * Message source and destinatin ports are used in case of Push message.
+ *
+ * \par Method of function operation:
+ * Set the msgPort member of msg_message_t to the passed source and destination port.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ * \param src_port is the port of origin.
+ * \param dst_port is the destination port for recipient.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_set_port(msg, 656, 656);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_port() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_port(msg_message_t msg, unsigned short dst_port, unsigned short src_port);
+
+
+/**
+
+ * \par Description:
+ * Return destination port number in message object.
+ *
+ * \par Purpose:
+ * This API is used for getting destination port number in message object.
+ *
+ * \par Typical use case:
+ * Recipient destinatin port be got using this API.
+ *
+ * \par Method of function operation:
+ * Returns the destination port  from msgPort member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (int (MSG_ERROR_T when negative, destination port number when positive)) \n
+ * - positive int                                              Destination port
+ * - MSG_ERR_NULL_POINTER                              msg is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int dest_port;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * dest_port = msg_get_dest_port(msg);
+ * sprintf(str, "msg_get_dest_port() dest_port [%d]", dest_port);
+ * print(str);
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_dest_port(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Return source port number in message object.
+ *
+ * \par Purpose:
+ * This API is used for getting source port number in message object.
+ *
+ * \par Typical use case:
+ * Recipient source port be got using this API.
+ *
+ * \par Method of function operation:
+ * Returns the source port  from msgPort member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type int (MSG_ERROR_T when negative, destination port number when positive) \n
+ * - positive int                                              source port.
+ * - MSG_ERR_NULL_POINTER                              msg is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int source_port;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * source_port = msg_get_src_port(msg);
+ * sprintf(str, "msg_get_src_port() source_port [%d]", source_port);
+ * print(str);
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_src_port(msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Set scheduled time to time_to_send, which is used for scheduled send.
+ *
+ * \par Purpose:
+ * This API is used to set scheduled time to time_to_send, which is used for scheduled send.
+ *
+ * \par Typical use case:
+ * Used to set Schedule Message feature on Message object
+ *
+ * \par Method of function operation:
+ * Set the scheduledTime member of msg_message_t to the passed time_to_send.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ * \param int    input - defined in enum _MSG_DIRECTION_TYPE_E.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * time_t scheduledTime;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * time(&scheduledTime);
+ *
+ * err = msg_set_scheduled_time(msgInfo, scheduledTime);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_set_scheduled_time() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * ...
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_scheduled_time(msg_message_t msg, time_t time_to_send);
+
+
+
+/**
+
+ * \par Description:
+ * Return pointer to scheduled time in message object, which can be used for ctime(time_t*) parameter
+ *
+ * \par Purpose:
+ * This API is used for getting the scheduled time in message object.
+ *
+ * \par Typical use case:
+ * Used to get Schedule Message feature on Message object
+ *
+ * \par Method of function operation:
+ * Returns the scheduledTime member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type time_t \n
+ * - time_t                                            Message scheduled time.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * time_t time_to_send;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * time_to_send = msg_get_scheduled_time(msg);
+ * sprintf(str, "msg_get_scheduled_time() time_to_send [%d]", time_to_send);
+ * print(str);
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+time_t* msg_get_scheduled_time(msg_message_t msg);
+
+
+
+/**
+
+ * \par Description:
+ * Get attachment count from MMS message.
+ *
+ * \par Purpose:
+ * This API is used for getting the attachment count in message object.
+ *
+ * \par Typical use case:
+ * Used to get attachment count feature on Message object
+ *
+ * \par Method of function operation:
+ * Returns the attachCount member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type int \n
+ * - int                                               Message attachment count.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * int attach_count;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * attach_count = msg_get_attachment_count(msg);
+ * sprintf(str, "msg_get_attachment_count() attach_count [%d]", attach_count);
+ * print(str);
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_attachment_count(msg_message_t opq_msg);
+
+
+/**
+
+ * \par Description:
+ * Returns the thumbnail path field of the message object. This API is used for MMS.
+ *
+ * \par Purpose:
+ * This API is used for getting the thumbnail path field of the message object
+ *
+ * \par Typical use case:
+ * MMS message object may contain thumbnail path field, this API enables to get the same.
+ *
+ * \par Method of function operation:
+ * Returns the thumbnail path member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object.
+ *
+ * \return Return Type (const char*) \n
+ * - const char        - MMS message thumbnail path \n
+ * - NULL      -       Message object/thumbnail path field is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * char* msg_thumbnail_path;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(hMsgHandle, 1, msg, &sendOpt);
+ * ...
+ * msg_thumbnail_path = msg_get_thumbnail_path(msg);
+ * if(msg_subject != NULL && strlen(msg_subject) > 0)
+ * {
+ *     sprintf(str, "msg_get_thumbnail_path() msg_thumbnail_path [%s]", msg_thumbnail_path);
+ *     print(str);
+ * }
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+const char* msg_get_thumbnail_path(msg_message_t opq_msg);
+
+
+
+/**
+
+ * \par Description:
+ * Set message data to MMS msg_data. This API is used for constructing MMS data.
+ *
+ * \par Purpose:
+ * This API is used to set the Message data field of the message object to the passed MMS message data.
+ *
+ * \par Typical use case:
+ * Compose the MMS_MESSAGE_DATA_S structure using msg_mms_* API and then this API can be called to set the MMS body.
+ *
+ * \par Method of function operation:
+ * Serialized "size" bytes of mdata to the pData member of the message object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is NULL, no action is done
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t        input - message object whose msgId is to be set.
+ * \param const char*                  input - data to be set.
+ * \param int                          input - size of mdata to be set to message object
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ * - MSG_ERR_INVALID_PARAMETER                 class_type is not one of enum _MSG_CLASS_TYPE_E.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * Refer to msg_mms_* APIs.
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ * ...
+ * mms_data = msg_mms_create_message();
+ * ...
+ * ...
+ * err = msg_mms_set_message_body(msgInfo, mms_data);
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_mms_set_message_body() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ * err = msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_mms_set_message_body(msg_message_t msg, const MMS_MESSAGE_DATA_S *msg_data);
+
+
+/**
+
+ * \par Description:
+ * Return pointer to MMS data in message object.
+ *
+ * \par Purpose:
+ * This API is used for getting pointer to MMS data in message object.
+ *
+ * \par Typical use case:
+ * Get the filled MMS data fromthe Message Object.
+ *
+ * \par Method of function operation:
+ * Returns the storageId member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg is invalid, behavior is undefined
+ *
+ * \param msg_message_t    input - message object whose msgId is to be set.
+ * \param MMS_MESSAGE_DATA_S - body is passed by pointer, which contains MMS message data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ * - MSG_ERR_INVALID_PARAMETER                 class_type is not one of enum _MSG_CLASS_TYPE_E.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t msg;
+ * MMS_MESSAGE_DATA_S  msgBody = {0};
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * msg_get_message(msgHandle, 1, msg, &sendOpt);
+ *
+ * ...
+ * err = msg_mms_get_message_body(msg, &msgBody);
+ * // access msgBody members using msg_mms_get_* APIs
+ *
+ * ..
+ * err = msg_release_message(&msg);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+int msg_mms_get_message_body(msg_message_t msg, MMS_MESSAGE_DATA_S *body );
+
+
+/**
+
+ * \par Description:
+ * Adds a SMIL page to MMS message data.
+ *
+ * \par Purpose:
+ * This API is used for adding a SMIL page to MMS message data.
+ *
+ * \par Typical use case:
+ * Add SMIL Page information to the MMS Message Object.
+ *
+ * \par Method of function operation:
+ * Returns the storageId member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * The memory for a SMIL page will be allocated and copied in this function. \n
+ * Applications need to call msg_mms_release_page_list to free the memory. \n
+ * However, if this function is failed, the memory for a SMIL page is NOT allocated in this function.
+ *
+ * \param MMS_MESSAGE_DATA_S   - msg_data is a pointer to MMS message data.
+ * \param int                                  - duration is time interval to play MMS SMIL page.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MMS_PAGE_S*       - Newly added MMS_PAGE_S object is returned \n
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_PAGE_S*         page[2];
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * page[0] = msg_mms_add_page(mms_data, 5440);
+ *
+ * ...
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+MMS_PAGE_S* msg_mms_add_page(MMS_MESSAGE_DATA_S *msg_data, const int duration);
+
+
+/**
+
+ * \par Description:
+ * Adds a SMIL region to MMS message data.
+ *
+ * \par Purpose:
+ * This API is used for adding a SMIL page to MMS message data.
+ *
+ * \par Typical use case:
+ * Add SMIL Page information to the MMS Message Object.
+ *
+ * \par Method of function operation:
+ * Allocates and assigns MMS_SMIL_REGION to region list member of MMS Message data object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * The memory for a SMIL page will be allocated and copied in this function. \n
+ * Applications need to call msg_mms_release_page_list to free the memory. \n
+ * However, if this function is failed, the memory for a SMIL page is NOT allocated in this function.
+ *
+ * \param MMS_MESSAGE_DATA_S   - msg_data is a pointer to MMS message data.
+ * \param const char*                  - szID is a pointer to SMIL region.
+ * \param const int                            - x coordinate of SMIL region.
+ * \param const int                            - y coordinate of SMIL region.
+ * \param const int                            - width of SMIL region.
+ * \param const int                            - height of SMIL region.
+ * \param int                                  - background color of SMIL region.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MMS_SMIL_REGION*  - Newly added MMS_SMIL_REGION object is returned \n
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_PAGE_S*         page[2];
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ * MMS_SMIL_REGION *mms_region;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ * ...
+ * msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+ * mms_region = msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+ * page[0] = msg_mms_add_page(mms_data, 5440);
+ *
+ * ..
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+MMS_SMIL_REGION* msg_mms_add_region(MMS_MESSAGE_DATA_S *msg_data, const char* szID, const int x, const int y, const int width, const int height, int bgcolor);
+
+
+/**
+
+ * \par Description:
+ * Adds a media to SMIL page.
+ *
+ * \par Purpose:
+ * This API is used for adding media to SMIL page of the MMS Message Data object.
+ *
+ * \par Typical use case:
+ * Add media to SMIL Page information of the MMS Message Object.
+ *
+ * \par Method of function operation:
+ * Allocates and assigns MMS_MEDIA_S to media list member of MMS Message data object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * The memory for a SMIL page will be allocated and copied in this function. \n
+ * Applications need to call msg_mms_release_page_list to free the memory. \n
+ * However, if this function is failed, the memory for a SMIL page is NOT allocated in this function.
+ *
+ * \param MMS_PAGE_S*                          - page is a pointer to SMIL page.
+ * \param const MmsSmilMediaType       - mediatype is a value to point the media category.
+ * \param const char*                          - regionid is a pointer of region, media to be displayed.
+ * \param char*                                        - filepath is a pointer of media file location.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MMS_MEDIA_S*      - Newly added MMS_MEDIA_S object is returned \n
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_PAGE_S*         page[2];
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ * MMS_SMIL_REGION *mms_region;
+ * MMS_MEDIA_S*        media[5];
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * page[0] = msg_mms_add_page(mms_data, 5440);
+ * media [0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/abc/xyz.jpg");
+ *
+ * ..
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+MMS_MEDIA_S* msg_mms_add_media(MMS_PAGE_S *page, const MmsSmilMediaType mediatype, const char* regionid, char* filepath);
+
+
+/**
+
+ * \par Description:
+ * Adds an attachment to MMS message data.
+ *
+ * \par Purpose:
+ * This API is used for adding an attachment to MMS message data.
+ *
+ * \par Typical use case:
+ * Adds attachment to SMIL Page information of the MMS Message Object.
+ *
+ * \par Method of function operation:
+ * Adds the filepath to attach list member of MMS Message data object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * The memory for a SMIL page will be allocated and copied in this function. \n
+ * Applications need to call msg_mms_release_page_list to free the memory. \n
+ * However, if this function is failed, the memory for a SMIL page is NOT allocated in this function.
+ *
+ * \param MMS_PAGE_S*                          - page is a pointer to SMIL page.
+ * \param const MmsSmilMediaType       - mediatype is a value to point the media category.
+ * \param const char*                          - regionid is a pointer of region, media to be displayed.
+ * \param char*                                        - filepath is a pointer of media file location.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MMS_MEDIA_S*      - Newly added MMS_MEDIA_S object is returned \n
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ * MMS_ATTACH_S*               attachment[1];
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * attachment[0] = msg_mms_add_attachment(mms_data, (char*)"/opt/abc/xyz.jpg");
+ *
+ * ..
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+MMS_ATTACH_S* msg_mms_add_attachment(MMS_MESSAGE_DATA_S *msg_data, char *filepath);
+
+
+/**
+
+ * \par Description:
+ * Adds a SMIL transition information  to MMS message data.
+ *
+ * \par Purpose:
+ * This API is used for adding a SMIL transition information  to MMS message data.
+ *
+ * \par Typical use case:
+ * Adds SMIL transition information of the MMS Message data.
+ *
+ * \par Method of function operation:
+ * Allocates and assigns MMS_SMIL_TRANSITION to transition list member of MMS Message data object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * The memory for a SMIL page will be allocated and copied in this function. \n
+ * Applications need to call msg_mms_release_page_list to free the memory. \n
+ * However, if this function is failed, the memory for a SMIL page is NOT allocated in this function.
+ *
+ * \param MMS_MESSAGE_DATA_S - msg_data is a pointer to MMS message data.
+ * \param MMS_SMIL_TRANSITION * - transition is a pointer to SMIL transition information.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * MSG_SUCCESS                 Success in operation.
+ * MSG_ERR_INVALID_PARAMETER   Parameter is invalid.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * MMS_SMIL_TRANSITION transition;
+ * err = msg_mms_add_transition(mms_data, &transition);
+ * ..
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+int msg_mms_add_transition(MMS_MESSAGE_DATA_S *msg_data, MMS_SMIL_TRANSITION *transition);
+
+
+/**
+
+ * \par Description:
+ * Adds SMIL meta information  to MMS message data.
+ *
+ * \par Purpose:
+ * This API is used for adding SMIL meta information  to MMS message data.
+ *
+ * \par Typical use case:
+ * Adds SMIL meta information of the MMS Message data.
+ *
+ * \par Method of function operation:
+ * Allocates and assigns MMS_SMIL_META to meta list member of MMS Message data object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * The memory for a SMIL page will be allocated and copied in this function. \n
+ * Applications need to call msg_mms_release_page_list to free the memory. \n
+ * However, if this function is failed, the memory for a SMIL page is NOT allocated in this function.
+ *
+ * \param MMS_MESSAGE_DATA_S - msg_data is a pointer to MMS message data.
+ * \param MMS_SMIL_META * - meta is a pointer to SMIL meta information.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * MSG_SUCCESS                 Success in operation.
+ * MSG_ERR_INVALID_PARAMETER   Parameter is invalid.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ * MMS_SMIL_META meta;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * MMS_MEDIA_S*        media = NULL;
+ * media = msg_mms_add_meta(mms_data, &meta);
+ * ...
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+int msg_mms_add_meta(MMS_MESSAGE_DATA_S *msg_data, MMS_SMIL_META *meta);
+
+
+/* MMS-1.3-con-601 */
+/**
+
+ * \par Description:
+ * Gets a SMIL page information of the current MMS message.
+ *
+ * \par Purpose:
+ * This API is used to get a SMIL page information
+ *
+ * \par Typical use case:
+ * Gets SMIL Page information of the MMS Message Object.
+ *
+ * \par Method of function operation:
+ * Returns the page_idx page from the pagelist member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * This function MUST be called only after SMIL page is added. \n
+ *
+ * \param MMS_MESSAGE_DATA_S - msg_data is a pointer to MMS message data.
+ * \param int page_idx - page_idx is the index of the SMIL page to be returned.
+ *
+ * \return Return Type (MMS_PAGE_S*) \n
+ * - MMS_PAGE_S*       - page_idx MMS_PAGE_S object is returned \n
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_PAGE_S*         page[2];
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * page[0] = msg_mms_get_page(mms_data, 0);
+ *
+ * ...
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+MMS_PAGE_S*    msg_mms_get_page(MMS_MESSAGE_DATA_S *msg_data, int page_idx);
+
+
+/**
+
+ * \par Description:
+ * Gets a SMIL region information of the current MMS message.
+ *
+ * \par Purpose:
+ * This API is used to gets a SMIL region information.
+ *
+ * \par Typical use case:
+ * Gets SMIL region information of the current MMS Message Object.
+ *
+ * \par Method of function operation:
+ * Returns the media_idx media from the current media list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * This function MUST be called only after SMIL region is added.
+ *
+ * \param MMS_MESSAGE_DATA_S - msg_data is a pointer to MMS message data.
+ * \param int input - region_idx is the index of the SMIL region to be returned.
+ *
+ * \return Return Type (MMS_SMIL_REGION*) \n
+ * - MMS_SMIL_REGION*  - pointer to MMS_SMIL_REGION structure.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_SMIL_REGION*    region[2];
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * region[0] = msg_mms_get_smil_region(mms_data, 0);
+ *
+ * ...
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+MMS_SMIL_REGION* msg_mms_get_smil_region(MMS_MESSAGE_DATA_S *msg_data, int region_idx);
+
+
+/**
+
+ * \par Description:
+ * Gets a media information in a SMIL page of the current MMS message.
+ *
+ * \par Purpose:
+ * This API is used to get a media information in a SMIL page
+ *
+ * \par Typical use case:
+ * Gets media information of the current MMS Message Object.
+ *
+ * \par Method of function operation:
+ * Returns the media_idx media from the current media list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * This function MUST be called only after media is added. \n
+ *
+ * \param int input - media_idx is the index of the media to be returned. \n
+ * \param MMS_PAGE_S* - page  is a pointer to SMIL page.
+ *
+ * \return Return Type (MMS_MEDIA_S*) \n
+ * - MMS_MEDIA_S*      - pointer to MMS_MEDIA_S structure.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_MEDIA_S*        media[2];
+ * MMS_PAGE_S *page[2];
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * media[0] = msg_mms_get_media(page, 0);
+ *
+ * ...
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+MMS_MEDIA_S* msg_mms_get_media(MMS_PAGE_S *page, int media_idx);
+
+/**
+
+ * \par Description:
+ * Gets a attachment information of the current MMS message.
+ *
+ * \par Purpose:
+ * This API is used to get a attachment information
+ *
+ * \par Typical use case:
+ * Gets attachment information of the MMS Message Object.
+ *
+ * \par Method of function operation:
+ * Returns the attach_idx attachment from the attachlist member of msg_message_t.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * This function MUST be called only after attachment is added. \n
+ *
+ * \param MMS_MESSAGE_DATA_S - msg_data is a pointer to MMS message data.
+ * \param int input - attach_idx is the index of the attachment to be returned.
+ *
+ * \return Return Type (MMS_ATTACH_S*) \n
+ * - MMS_ATTACH_S*     - pointer to MMS_ATTACH_S structure.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_ATTACH_S*       attachment[2];
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * attachment[0] = msg_mms_get_attachment(mms_data, 0);
+ *
+ * ...
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+MMS_ATTACH_S* msg_mms_get_attachment(MMS_MESSAGE_DATA_S *msg_data, int attach_idx);
+
+
+/**
+
+ * \par Description:
+ * Gets a SMIL transition information of the current MMS message.
+ *
+ * \par Purpose:
+ * This API is used to get a SMIL transition information.
+ *
+ * \par Typical use case:
+ * Gets SMIL transition information of the current MMS Message Object.
+ *
+ * \par Method of function operation:
+ * Returns the transition_idx transition from the current transition list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be called only after SMIL transition is added.
+ *
+ * \param MMS_MESSAGE_DATA_S - msg_data is a pointer to MMS message data.
+ * \param int input - transition_idx is the index of the SMIL transition to be returned.
+ *
+ * \return Return Type (MMS_SMIL_TRANSITION*) \n
+ * - MMS_SMIL_TRANSITION*      - pointer to MMS_SMIL_TRANSITION structure.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * MMS_SMIL_TRANSITION* pTrans = msg_mms_get_transition(mms_data, 0);
+ *
+ * ...
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+MMS_SMIL_TRANSITION* msg_mms_get_transition(MMS_MESSAGE_DATA_S *msg_data, int transition_idx);
+
+
+/**
+
+ * \par Description:
+ * Gets a SMIL meta information of the current MMS message.
+ *
+ * \par Purpose:
+ * This API is used to get a SMIL meta information.
+ *
+ * \par Typical use case:
+ * Gets SMIL meta information of the current MMS Message Object.
+ *
+ * \par Method of function operation:
+ * Returns the meta_idx meta from the current meta list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * This function MUST be called only after SMIL meta is added.
+ *
+ * \param MMS_MESSAGE_DATA_S - msg_data is a pointer to MMS message data.
+ * \param int input - meta_idx is the index of the SMIL meta to be returned.
+ *
+ * \return Return Type (MMS_SMIL_META*) \n
+ * - MMS_SMIL_META*    - pointer to MMS_SMIL_META structure.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * MMS_SMIL_META* pMeta = msg_mms_get_meta(mms_data, 0);
+ *
+ * ...
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+MMS_SMIL_META* msg_mms_get_meta(MMS_MESSAGE_DATA_S *msg_data, int meta_idx);
+
+
+/**
+
+ * \par Description:
+ * Release a SMIL page list of the current MMS message.
+ *
+ * \par Purpose:
+ * This API is used to release a SMIL page list
+ *
+ * \par Typical use case:
+ * Release SMIL page list of the MMS message object
+ *
+ * \par Method of function operation:
+ * Release SMIL page list of MMS_MESSAGE_DATA_S object
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * This function MUST be called only after SMIL page is added. \n
+ *
+ * \param MMS_MESSAGE_DATA_S   - msg_data is a pointer to MMS message data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * MSG_SUCCESS                 Success in operation.
+ * MSG_ERR_NULL_POINTER        Parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_PAGE_S*         page[2];
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ * ...
+ * page[0] = msg_mms_add_page(mms_data, 5440);
+ * ...
+ * page[0] = msg_mms_get_page(0);
+ *
+ * msg_mms_release_page_list(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+int msg_mms_release_page_list(MMS_MESSAGE_DATA_S *msg_data);
+
+
+/**
+
+ * \par Description:
+ * Release a SMIL region list of the current MMS message.
+ *
+ * \par Purpose:
+ * This API is used to release a SMIL region list
+ *
+ * \par Typical use case:
+ * Release SMIL region list of the MMS message object
+ *
+ * \par Method of function operation:
+ * Release SMIL region list of MMS_MESSAGE_DATA_S object
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * This function MUST be called only after SMIL region is added. \n
+ *
+ * \param MMS_MESSAGE_DATA_S   - msg_data is a pointer to MMS message data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * MSG_SUCCESS                 Success in operation.
+ * MSG_ERR_NULL_POINTER        Parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_PAGE_S*         page[2];
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ * MMS_SMIL_REGION *mms_region;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ * ...
+ * msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+ * mms_region = msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+ * page[0] = msg_mms_add_page(mms_data, 5440);
+ * ...
+ * msg_mms_release_region_list(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+int msg_mms_release_region_list(MMS_MESSAGE_DATA_S *msg_data);
+
+
+/**
+
+ * \par Description:
+ * Release an attachment list of the current MMS message.
+ *
+ * \par Purpose:
+ * This API is used to release an attachment list
+ *
+ * \par Typical use case:
+ * Release an attachment list of the MMS message object
+ *
+ * \par Method of function operation:
+ * Release an attachment list of MMS_MESSAGE_DATA_S object
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * This function MUST be called only after attachment is added. \n
+ *
+ * \param MMS_MESSAGE_DATA_S   - msg_data is a pointer to MMS message data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * MSG_SUCCESS                 Success in operation.
+ * MSG_ERR_NULL_POINTER        Parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ * MMS_ATTACH_S*               attachment[1];
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * attachment[0] = msg_mms_add_attachment(mms_data, (char*)"/opt/abc/xyz.jpg");
+ *
+ * ..
+ * msg_mms_release_attachment_list(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+int msg_mms_release_attachment_list(MMS_MESSAGE_DATA_S *msg_data);
+
+
+/**
+
+ * \par Description:
+ * Release a SMIL transition list of the current MMS message.
+ *
+ * \par Purpose:
+ * This API is used to release a SMIL transition list
+ *
+ * \par Typical use case:
+ * Release a SMIL transition list of the MMS message object
+ *
+ * \par Method of function operation:
+ * Release a SMIL transition list of MMS_MESSAGE_DATA_S object
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * This function MUST be called only after SMIL transition is added. \n
+ *
+ * \param MMS_MESSAGE_DATA_S   - msg_data is a pointer to MMS message data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * MSG_SUCCESS                 Success in operation.
+ * MSG_ERR_NULL_POINTER        Parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ * MMS_ATTACH_S*               attachment[1];
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * MMS_SMIL_TRANSITION transition;
+ * err = msg_mms_add_transition(mms_data, &transition);
+ * ..
+ * msg_mms_release_transition_list(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+int msg_mms_release_transition_list(MMS_MESSAGE_DATA_S *msg_data);
+
+
+/**
+
+ * \par Description:
+ * Release a SMIL meta list of the current MMS message.
+ *
+ * \par Purpose:
+ * This API is used to release a SMIL meta list
+ *
+ * \par Typical use case:
+ * Release a SMIL meta list of the MMS message object
+ *
+ * \par Method of function operation:
+ * Release a SMIL meta list of MMS_MESSAGE_DATA_S object
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * This function MUST be called only after SMIL meta is added. \n
+ *
+ * \param MMS_MESSAGE_DATA_S   - msg_data is a pointer to MMS message data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * MSG_SUCCESS                 Success in operation.
+ * MSG_ERR_NULL_POINTER        Parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ * MMS_SMIL_META meta;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * MMS_MEDIA_S*        media = NULL;
+ * media = msg_mms_add_meta(mms_data, &meta);
+ * ...
+ * msg_mms_release_meta_list(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+int msg_mms_release_meta_list(MMS_MESSAGE_DATA_S *msg_data);
+
+
+/**
+
+ * \par Description:
+ * Creates a MMS message data
+ *
+ * \par Purpose:
+ * This API creates a MMS message data
+ *
+ * \par Typical use case:
+ * MMS Message object should be created before adding Page, SMIL, attachment information.
+ *
+ * \par Method of function operation:
+ * Allocates and returns a pointer to MMS_MESSAGE_DATA_S.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * The created MMS_MESSAGE_DATA_S object should be explicitly destroyed using msg_mms_destroy_message()
+ *
+ * \param None input
+ *
+ * \return Return Type (MMS_MESSAGE_DATA_S*) \n
+ * - MMS_MESSAGE_DATA_S*       - pointer to newly created MMS_MESSAGE_DATA_S structure.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+MMS_MESSAGE_DATA_S* msg_mms_create_message(void);
+
+
+/**
+
+ * \par Description:
+ * Set the MMS root-layout
+ *
+ * \par Purpose:
+ * This API is used for adding a SMIL page to MMS message data.
+ *
+ * \par Typical use case:
+ * Add SMIL Page information to the MMS Message Object.
+ *
+ * \par Method of function operation:
+ * Sets the rootlayout member to the passed root layout.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * None
+ *
+ * \param MMS_MESSAGE_DATA_S*  - msg is a pointer to mms message data.
+ * \param const int                            - width of root-layout
+ * \param const int                            - height of root-layout
+ * \param int                                  - background color of root-layout
+ *
+ * \return Return Type (MMS_SMIL_ROOTLAYOUT*) \n
+ * - MMS_SMIL_ROOTLAYOUT*      - pointer to MMS_SMIL_ROOTLAYOUT object is returned \n
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * MMS_MESSAGE_DATA_S*  mms_data;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ * ...
+ * msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+ * ..
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+MMS_SMIL_ROOTLAYOUT* msg_mms_set_rootlayout(MMS_MESSAGE_DATA_S* msg, const int width, const int height, const int bgcolor);
+
+
+/**
+
+ * \par Description:
+ * Destroy the created MMS message data.
+ *
+ * \par Purpose:
+ * This API destroys the created MMS message data.
+ *
+ * \par Typical use case:
+ * To free memory allocated with create message API.
+ *
+ * \par Method of function operation:
+ * Frees the memory associated with MMS_MESSAGE_DATA_S object .
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *This function MUST be called only after MMS message is created by msg_mms_create_message.
+ *
+ * \param
+ * MMS_MESSAGE_DATA_S input - msg is a pointer to MMS message data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * MSG_SUCCESS                 Success in operation.
+ * MSG_ERR_NULL_POINTER        Parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * mms_data = msg_mms_create_message();
+ *
+ * ...
+ * msg_mms_destroy_message(mms_data);
+ * ...
+ * \endcode
+ */
+ /*================================================================================================*/
+int msg_mms_destroy_message(MMS_MESSAGE_DATA_S* msg);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/include/mapi/MapiSetting.h b/include/mapi/MapiSetting.h
new file mode 100755 (executable)
index 0000000..ae7ba78
--- /dev/null
@@ -0,0 +1,162 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MAPI_SETTING_H
+#define MAPI_SETTING_H
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Messaging Setting API
+ *     @section                Program
+ *     - Program : Messaging Setting API Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include "MsgSettingTypes.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_SETTING_API   Messaging Setting API
+ *     @{
+ */
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+
+ * \par Description:
+ * Sets a Messaging option such as SMS/MMS sending options, Push settings etc..
+ *
+ * \par Purpose:
+ * This API is used to set message options.
+ *
+ * \par Typical use case:
+ * Used in setting the messaging options such as SMS/MMS sending options, Push message settings etc.
+ *
+ * \par Method of function operation:
+ * Stores the MSG_SETTING_S settings to storage such as gconf, etc.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * None
+ *
+ * \param input - MSG_HANDLE_T  handle is Message handle.
+ * \param input - MSG_SETTING_S  setting is a pointer to setting information.
+ *
+ * \return Return Type int (MSG_ERROR_T) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_SET_WRITE_ERROR           Setting configuration is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_SETTING_S setting;
+ * MSG_ERROR_T err;
+ *
+ * ...
+ * err = msg_set_config(msgHandle, &setting);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_set_config(MSG_HANDLE_T handle, const MSG_SETTING_S *setting);
+
+
+/**
+
+ * \par Description:
+ * Retrieve a Messaging option such as SMS/MMS sending options, Push settings etc..
+ *
+ * \par Purpose:
+ * This API is used to getting message options.
+ *
+ * \par Typical use case:
+ * Used in setting the messaging options such as SMS/MMS sending options, Push message settings etc.
+ *
+ * \par Method of function operation:
+ * Stores the MSG_SETTING_S settings to storage such as gconf, etc.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * None
+ *
+ * \param input - MSG_HANDLE_T  handle is Message handle.
+ * \param input - MSG_SETTING_S  setting is a pointer to setting information.
+ *
+ * \return Return Type int (MSG_ERROR_T) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_SET_READ_ERROR            Getting configuration is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_SETTING_S setting;
+ * MSG_ERROR_T err;
+ *
+ * ...
+ * err = msg_get_config(msgHandle, &setting);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_config(MSG_HANDLE_T handle, MSG_SETTING_S *setting);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MAPI_SETTING_H
+
diff --git a/include/mapi/MapiStorage.h b/include/mapi/MapiStorage.h
new file mode 100755 (executable)
index 0000000..74f4d77
--- /dev/null
@@ -0,0 +1,3029 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+/**
+ *     @file           MapiStorage.h
+ *     @brief          Defines storage API of messaging framework
+ *     @version        1.0
+ */
+
+#ifndef MAPI_STORAGE_H
+#define MAPI_STORAGE_H
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Messaging Storage API
+ *     @section                Program
+ *     - Program : Messaging Storage API Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include "MsgStorageTypes.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_STORAGE_API   Messaging Storage API
+ *     @{
+ */
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+
+ * \par Description:
+ * Saves a message to the database.
+ *
+ * \par Purpose:
+ * This API is used to save Message object to the database.
+ *
+ * \par Typical use case:
+ * Save Message feature is used when the message is to be stored to persistent memory for later reference.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and inserts the message to message table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - Mandatory fields of a message structure MUST be valid, otherwise the function will be failed.
+ *
+ * \param input - MSG_HANDLE_T  handle is Message handle.
+ * \param input - msg_message_t  msg is a pointer to an msg_message_t structure.
+ * \param input - send_opt is a pointer to an MSG_SENDINGOPT_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      - Input parameter is NULL.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_message_t               msg;
+ * MSG_SENDINGOPT_S sendingOpt = {0};
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_add_message(handle, (msg_message_t) &msg, &sendingOpt);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_add_message(MSG_HANDLE_T handle, const msg_message_t msg, const MSG_SENDINGOPT_S *send_opt);
+
+
+/**
+
+ * \par Description:
+ * Adds a SyncML message to the database.
+ *
+ * \par Purpose:
+ * This API is used to save  a SyncML message to the database.
+ *
+ * \par Typical use case:
+ * Save Message feature is used when the message is to be stored to persistent memory for later reference.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and inserts the syncml message to message table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - Mandatory fields of a message structure MUST be valid, otherwise the function will be failed.
+ *
+ * \param input - MSG_HANDLE_T  handle is Message handle.
+ * \param input - MSG_SYNCML_MESSAGE_S  syncml_msg is a pointer to an MSG_SYNCML_MESSAGE_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_NULL_POINTER - pMsg is NULL.
+ * - MSG_ERR_INVALID_MSGHANDLE - Message handle is invalid.
+ * - MSG_ERR_MSGHANDLE_NOT_CONNECTED - Message handle is not connected.
+ * - MSG_ERR_STORAGE_FULL - Storage is FULL.
+ * - MSG_ERR_COMMUNICATION_ERROR - Communication between client and server is error.
+ * - MSG_ERR_MEMORY_ERROR - Memory is error.
+ * - MSG_ERR_MAX_NUMBER_REACHED - Max number is reached.
+ * - MSG_ERR_PLUGIN - Generic error code for plugin.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_SYNCML_MESSAGE_S syncMLMsg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * int err = msg_add_syncml_message(msgHandle, &syncMLMsg);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_add_syncml_message(MSG_HANDLE_T handle, const MSG_SYNCML_MESSAGE_S *syncml_msg);
+
+
+/**
+
+ * \par Description:
+ * Updates a message in the database.
+ *
+ * \par Purpose:
+ * This API is used to update a message in the database.
+ *
+ * \par Typical use case:
+ * Update message feature is used when a previously saved message is to be updated.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and set the message's new values to message table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - The function is to update message data for the message indentified by the given msgId as long as the given values are valid.
+ * - msg->msgId MUST NOT be updated because msg->msgId is a unique Id on platform.
+ * - If applications want to move a message between folders, applications SHOULD call msg_move_to_folder.
+ * - msg->storageId MUST NOT be updated.
+ * - The function will return MSG_ERR_INVALID_MESSAGE, if inputting a new msg->storageId.
+ * - If applications want to move the message between storages, applications SHOULD call msg_move_to_storage.
+ *
+ * \param input - handle is Message handle.
+ * \param input - msg is a pointer to an msg_message_t structure.
+ * \param input - send_opt is a pointer to an MSG_SENDINGOPT_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_SYNCML_MESSAGE_S syncMLMsg;
+ * MSG_SENDINGOPT_S sendingOpt = {0};
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_update_message(hMsgHandle, pMsg, &sendOpt);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_update_message(MSG_HANDLE_T handle, const msg_message_t msg, const MSG_SENDINGOPT_S *send_opt);
+
+
+/**
+
+ * \par Description:
+ * Updates a message's read status in the database.
+ *
+ * \par Purpose:
+ * This API is used to Updates a message's read status in the database.
+ *
+ * \par Typical use case:
+ * Update message's read status for a previously saved message.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and updates the message's read status to message table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ * \param input - msg_id is Message ID.
+ * \parem input - read is boolean for indicating whether a message is read or not.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_SYNCML_MESSAGE_S syncMLMsg;
+ * MSG_SENDINGOPT_S sendingOpt = {0};
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_update_message(hMsgHandle, pMsg, &sendOpt);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_update_read_status(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, bool read);
+
+
+/**
+
+ * \par Description:
+ * Updates a message's protected status in the database.
+ *
+ * \par Purpose:
+ * This API is used to Updates a message's protected status in the database.
+ *
+ * \par Typical use case:
+ * Update message's protected status for a previously saved message.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and updates the message's protected status to message table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ * \param input - msg_id is Message ID.
+ * \parem input - is_protected is boolean for indicating whether a message is protected or not.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_SYNCML_MESSAGE_S syncMLMsg;
+ * MSG_SENDINGOPT_S sendingOpt = {0};
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_update_protected_status(hMsgHandle, 0, true);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_update_protected_status(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, bool is_protected);
+
+
+/**
+
+ * \par Description:
+ * Deletes a message by Message ID from the database.
+ *
+ * \par Purpose:
+ * This API is used to delete a message by Message ID from the database.
+ *
+ * \par Typical use case:
+ * Deletes a previously saved message from the database.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and deletes a message by Message ID from the message table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ * \param input - msg_id is the ID of the Message to be deleted.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_SYNCML_MESSAGE_S syncMLMsg;
+ * MSG_SENDINGOPT_S sendingOpt = {0};
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_delete_message(msgHandle, 0);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_delete_message(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id);
+
+
+/**
+
+ * \par Description:
+ * Deletes all messages in the specified folder from the database.
+ *
+ * \par Purpose:
+ * This API is used to delete all messages in the specified folder from the database.
+ *
+ * \par Typical use case:
+ * Deletes all messages in the specified folder from the database.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and Deletes all messages in the specified folder from the message table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ * \param input - folder_id is the ID of the folder to be deleted.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_SYNCML_MESSAGE_S syncMLMsg;
+ * MSG_SENDINGOPT_S sendingOpt = {0};
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_delete_all_msgs_in_folder(msgHandle, MSG_DRAFT_ID);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_delete_all_msgs_in_folder(MSG_HANDLE_T handle, MSG_FOLDER_ID_T folder_id, bool bOnlyDB);
+
+
+
+/**
+
+ * \par Description:
+ * Moves a message to the specified folder in the database.
+ *
+ * \par Purpose:
+ * This API is used to move a message to the specified folder the database.
+ *
+ * \par Typical use case:
+ * Deletes all messages in the specified folder from the database.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and Deletes all messages in the specified folder from the message table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ * \param input - msg_id is the ID of the message to be moved.
+ * \param input - dest_folder_id is the ID of the destination folder.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_SYNCML_MESSAGE_S syncMLMsg;
+ * MSG_SENDINGOPT_S sendingOpt = {0};
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_move_msg_to_folder(hMsgHandle, 0, MSG_OUTBOX_ID);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_move_msg_to_folder(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, MSG_FOLDER_ID_T dest_folder_id);
+
+
+/**
+
+ * \par Description:
+ * Moves a message to the other storage.
+ *
+ * \par Purpose:
+ * This API is usd to move a message to the other storage.
+ *
+ * \par Typical use case:
+ * Moves a message to the other storage type.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and  moves a messages to specified storage type.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ * \param input - msg_id is the ID of the message to be moved.
+ * \param input - storage_id is the ID of the destination storage.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_SYNCML_MESSAGE_S syncMLMsg;
+ * MSG_SENDINGOPT_S sendingOpt = {0};
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_move_msg_to_storage( msgHandle, 0, MSG_STORAGE_PHONE);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_move_msg_to_storage(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, MSG_STORAGE_ID_T storage_id);
+
+
+/**
+
+ * \par Description:
+ * Gets the number of messages in the specified folder from the database.
+ *
+ * \par Purpose:
+ * This API is used to get the number of messages in the specified folder from the database.
+ *
+ * \par Typical use case:
+ * Gets the number of messages in the specified folder from the database.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and Gets the number of messages in the specified folder from the message table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ * \param input - folder_id is the ID of the folder to be counted.
+ * \param output - count_info is a pointer to an MSG_COUNT_INFO_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_COUNT_INFO_S countInfo;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_count_message(msgHandle, MSG_OUTBOX_ID, &countInfo)
+* if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_count_message(MSG_HANDLE_T handle, MSG_FOLDER_ID_T folder_id, MSG_COUNT_INFO_S *count_info);
+
+
+/**
+
+ * \par Description:
+ * Gets the number of messages of specific message type.
+ *
+ * \par Purpose:
+ * This API is used to get the number of messages of specific type.
+ *
+ * \par Typical use case:
+ * Gets the count of message of specific types such as SMS, MMS.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and queries the number of messages in the specified folder from the message table based on required message type.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ * \param input - msg_type is the message type to be counted.
+ * \param output - msg_count is a pointer to the number of message.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_COUNT_INFO_S countInfo;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_count_msg_by_type(msgHandle, MSG_TYPE_SMS, &countInfo);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_count_msg_by_type(MSG_HANDLE_T handle, MSG_MESSAGE_TYPE_T msg_type, int *msg_count);
+
+
+/**
+
+ * \par Description:
+ * Gets the number of messages of specific address.
+ *
+ * \par Purpose:
+ * This API is used to get the number of messages from a specific address.
+ *
+ * \par Typical use case:
+ * Get the count of messages from the specified address
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and queries the number of messages based on address from the message table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If addr_info is NULL, nothing happens.
+ *
+ * \param input - handle is Message handle.
+ * \param input - addr_info is a pointer to an MSG_ADDRESS_INFO_LIST_S structure.
+ * \param input - msg_thread_count_list is a pointer to an MSG_THREAD_COUNT_INFO_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_COUNT_INFO_S countInfo;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_count_msg_by_type(msgHandle, MSG_TYPE_SMS, &countInfo);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_count_msg_by_contact(MSG_HANDLE_T handle, const MSG_THREAD_LIST_INDEX_S *addr_info, MSG_THREAD_COUNT_INFO_S *msg_thread_count_list);
+
+
+/**
+
+ * \par Description:
+ * Gets the detail information of a message from the database.
+ *
+ * \par Purpose:
+ * This API is used to get the number of messages from a specific address.
+ *
+ * \par Typical use case:
+ * Get the count of messages from the specified address
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and queries the number of messages based on address from the message table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If addr_info is NULL, nothing happens.
+ * - Applications need to call msg_release_message to free the memory.
+ * - However, if this function is failed, the memory for the message is NOT allocated in this function.
+ *
+handle is Message handle.
+ * \param input - handle is Message handle.
+ * \param input - msg_id is the ID of the Message to be returned.
+ * \param output - msg is a pointer to an msg_message_t structure.
+ * \param input - send_opt is a pointer to an MSG_SENDINGOPT_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * - None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ *
+ * ...
+ * msg_message_t msg = msg_new_message();
+ * MSG_SENDINGOPT_S sendOpt = {0, };
+ * ...
+ * err = msg_get_message(msgHandle, 0, msg, &sendOpt);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_message(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, msg_message_t msg, MSG_SENDINGOPT_S *send_opt);
+
+
+/**
+
+ * \par Description:
+ * Returns the common information list of messages with selected folder id.
+ *
+ * \par Purpose:
+ * This API is used to get the common information list of messages with selected folder id from database.
+ *
+ * \par Typical use case:
+ * Get the common information from the specified folder from database.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and queries the common information based on selected folder id from the message and folder tables.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - The memory for a message will be allocated in this function.
+ * - Applications need to call msg_release_folder_view_list to free the memory.
+ * - However, if this function is failed, the memory for the message is NOT allocated in this function.
+ *
+ * \param input - handle is Message handle.
+ * \param input - folder_id is the ID of the folder to be returned.
+ * \param input - sort_rule indicates a sort type and sort order for querying messages.
+ * \param output - msg_folder_view_list is a pointer to an MSG_FOLDER_VIEW_LIST_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * - None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ *
+ * ...
+ * MSG_FOLDER_VIEW_LIST_S folderViewList;
+ * ...
+ * err = msg_get_folder_view_list(hMsgHandle, 0, NULL, &folderViewList);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_folder_view_list(MSG_HANDLE_T handle, MSG_FOLDER_ID_T folder_id, const MSG_SORT_RULE_S *sort_rule, MSG_LIST_S *msg_folder_view_list);
+
+
+/**
+
+ * \par Description:
+ * Returns the information of all peers to whom messages have been sent or recieved.
+ *
+ * \par Purpose:
+ * This API is used to get the information of all peers to whom messages have been sent or recieved.
+ *
+ * \par Typical use case:
+ * Get the common information from the specified folder from database.
+ *
+ * \par Method of function operation:
+ * Frees the memory occupied by MSG_FOLDER_VIEW_LIST_S object and its members.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - The memory for a list will be allocated in this function.
+ * - Applications need to call msg_release_thread_view_list to free the memory.
+ * - However, if this function is failed, the memory for a list is NOT allocated in this function.
+ *
+ * \param input - handle is Message handle.
+ * \param input - sort_rule indicates a sort type and sort order for querying messages.
+ * \param output - msg_thread_view_list is a pointer to an MSG_THREAD_VIEW_LIST_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ *
+ * ...
+ * MSG_THREAD_VIEW_LIST_S threadViewList;
+ * ...
+ * err = msg_get_thread_view_list(hMsgHandle, NULL, &threadViewList);
+ * ...
+ * msg_release_thread_view_list(&threadViewList);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_thread_view_list(MSG_HANDLE_T handle, const MSG_SORT_RULE_S *sort_rule, MSG_THREAD_VIEW_LIST_S *msg_thread_view_list);
+
+
+/**
+
+ * \par Description:
+ * Frees the memory of MSG_PEER_INFO_LIST_S allocated in msg_get_thread_view_list.
+ *
+ * \par Purpose:
+ * This API is used to get the information of all peers to whom messages have been sent or recieved.
+ *
+ * \par Typical use case:
+ * Get the common information from the specified folder from database.
+ *
+ * \par Method of function operation:
+ * Frees the memory occupied by MSG_FOLDER_VIEW_LIST_S object and its members.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - The memory for a list will be allocated in this function.
+ * - Applications need to call msg_release_thread_view_list to free the memory.
+ * - However, if this function is failed, the memory for a list is NOT allocated in this function.
+ *
+ * \param input - msg_thread_view_list is a pointer to an MSG_THREAD_VIEW_LIST_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ *
+ * ...
+ * MSG_THREAD_VIEW_LIST_S threadViewList;
+ * ...
+ * err = msg_get_thread_view_list(hMsgHandle, NULL, &threadViewList);
+ * ...
+ * msg_release_thread_view_list(&threadViewList);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+void msg_release_thread_view_list(MSG_THREAD_VIEW_LIST_S *msg_thread_view_list);
+
+
+/**
+
+ * \par Description:
+ * Returns the common information list of messages with selected thread_id.
+ *
+ * \par Purpose:
+ * This API is used to get the common information list of messages with selected thread_id.
+ *
+ * \par Typical use case:
+ * Gets the common information list of messages with the selected thread id from the database.
+ *
+ * \par Method of function operation:
+ * Connects to the database and queries the common infomation of  list messages with the provided thread id.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - The memory for a list will be allocated in this function.
+ * - Applications need to call msg_release_conversation_view_list to free the memory.
+ * - However, if this function is failed, the memory for a list is NOT allocated in this function.
+ *
+ * \param input - hMsgHandle is Message handle.
+ * \param input - thread_id is the ID of the thread to be returned.
+ * \param output - msg_conv_view_list is a pointer to an MSG_CONV_VIEW_LIST_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * - None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * ...
+ * MSG_CONV_VIEW_LIST_S convViewList;
+ * ...
+ * err = msg_get_conversation_view_list(hMsgHandle, ThreadId, &convViewList);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * msg_release_conversation_view_list(&convViewList);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_conversation_view_list(MSG_HANDLE_T handle, MSG_THREAD_ID_T thread_id, MSG_LIST_S *msg_conv_view_list);
+
+
+/**
+
+ * \par Description:
+ * Deletes all the Messages Sent/Received from the selected list.
+ *
+ * \par Purpose:
+ * This API is used to delete all the Messages Sent/Received from the selected list.
+ *
+ * \par Typical use case:
+ * Deletes all messages sent/received from the selected list.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and deletes all messages sent/received from a selected list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If addr_info is NULL, nothing happens.
+ *
+ * \param input - handle is Message handle.
+ * \param input - thread_id is the ID of the thread to be deleted.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_SYNCML_MESSAGE_S syncMLMsg;
+ * MSG_SENDINGOPT_S sendingOpt = {0};
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_delete_thread_message_list(hMsgHandle, 0);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_delete_thread_message_list(MSG_HANDLE_T handle, MSG_THREAD_ID_T thread_id);
+
+
+/**
+
+ * \par Description:
+ * Adds a new folder.
+ *
+ * \par Purpose:
+ * This API is used to add a new folder.
+ *
+ * \par Typical use case:
+ * Adds a new folder with the specified folder info
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and add a new folder to the folder table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None.
+ *
+ * \param - handle is Message handle.
+ * \param - folder_info is a pointer to an MSG_FOLDER_INFO_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ *  Make Folder
+ * MSG_FOLDER_INFO_S folderInfo;
+ * ...
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * folderInfo.folderId = 1;
+ * folderInfo.folderType = MSG_FOLDER_TYPE_USER_DEF;
+ * ...
+ *
+ * err = msg_add_folder(hMsgHandle, &folderInfo);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_add_folder(MSG_HANDLE_T handle, const MSG_FOLDER_INFO_S *folder_info);
+
+
+/**
+
+ * \par Description:
+ * Updates the folder info.
+ *
+ * \par Purpose:
+ * This API is used to add a new folder.
+ *
+ * \par Typical use case:
+ * Adds a new folder with the specified folder info
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and add a new folder to the folder table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None.
+ *
+ * \param - handle is Message handle.
+ * \param - folder_info is a pointer to an MSG_FOLDER_INFO_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ *  Make Folder
+ * MSG_FOLDER_INFO_S folderInfo;
+ * ...
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * folderInfo.folderId = 2;
+ * folderInfo.folderType = MSG_FOLDER_TYPE_USER_DEF;
+ * ...
+ * err = msg_update_folder(msgHandle, &folderInfo);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_update_folder(MSG_HANDLE_T handle, const MSG_FOLDER_INFO_S *folder_info);
+
+
+/**
+
+ * \par Description:
+ * Deletes an exisiting folder.
+ *
+ * \par Purpose:
+ * This API is used to delete an existing folder.
+ *
+ * \par Typical use case:
+ * Deletes an existing folder.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and deletes an existing folder to the folder table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None.
+ *
+ * \param input - handle is Message handle.
+ * \param input - folder_id is the ID of the folder to be deleted.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ * err = msg_delete_folder(hMsgHandle, MSG_INBOX_ID);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_delete_folder(MSG_HANDLE_T handle, MSG_FOLDER_ID_T folder_id);
+
+
+/**
+
+ * \par Description:
+ * Returns the information list of folders.
+ *
+ * \par Purpose:
+ * This API is used to get the information list of folders.
+ *
+ * \par Typical use case:
+ * Gets the folder list information.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and queries for the folder list information.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None.
+ *
+ * \param input - handle is Message handle.
+ * \param output - folder_list is a pointer to an MSG_FOLDER_LIST_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ *  MSG_FOLDER_LIST_S folderList;
+
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ * err = msg_get_folder_list(msgHandle, &folderList);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * msg_release_folder_list(&folderList);
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_folder_list(MSG_HANDLE_T handle, MSG_FOLDER_LIST_S *folder_list);
+
+
+
+/**
+
+ * \par Description:
+ * Releases the memory of a folder list.
+ *
+ * \par Purpose:
+ * This API is used to get the information list of folders.
+ *
+ * \par Typical use case:
+ * Gets the folder list information.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and queries for the folder list information.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If folder_list is NULL, nothing happens.
+ * - If folder_list is invalid, undefined behavior happens.
+ *
+ * \param input - folder_list is a pointer to an MSG_FOLDER_LIST_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ *  MSG_FOLDER_LIST_S folderList;
+
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ * err = msg_get_folder_list(msgHandle, &folderList);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * msg_release_folder_list(&folderList);
+ * \endcode
+ */
+/*================================================================================================*/
+void msg_release_folder_list(MSG_FOLDER_LIST_S *folder_list);
+
+
+/**
+
+ * \par Description:
+ * Creates the specified number of messages in database.
+ *
+ * \par Purpose:
+ * This API is used to generate specified number of messages in the database
+ *
+ * \par Typical use case:
+ * Generate large number of messages in the database.
+ *
+ * \par Method of function operation:
+ * Creates the specified number of messages in database for specified message type in the specified folder
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ * \param input - msg_type is one of enum _MSG_MESSAGE_TYPE_E.
+ * \param input - folder_id is the folder for the test messages.
+ * \param input - num_msg is the number of messages.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_MSGHANDLE Parameter is invalid.
+ * - MSG_ERR_INVALID_FOLDER_ID Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ *  MSG_FOLDER_LIST_S folderList;
+
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ * err = msg_generate_message(msgHandle, MSG_TYPE_SMS, MSG_INBOX_ID, 100);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_generate_message(MSG_HANDLE_T handle, MSG_MESSAGE_TYPE_T msg_type, MSG_FOLDER_ID_T folder_id, unsigned int num_msg);
+int msg_generate_sms(MSG_HANDLE_T handle, MSG_FOLDER_ID_T folder_id, unsigned int num_msg) DEPRECATED;
+
+
+/**
+
+ * \par Description:
+ * Returns the Message Data to be used by the Quick Panel.
+ *
+ * \par Purpose:
+ * This API is used to get the Message Datato be used by the Quick Panel.
+ *
+ * \par Typical use case:
+ * Quick panel needs the message information to show new message notification.
+ *
+ * \par Method of function operation:
+ * Connects to database and queries for information needed by the quick panel.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ * \param input - type is the type of message that Quick Panel need.
+ * \param output - msg is a pointer to an msg_message_t structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_MSGHANDLE Parameter is invalid.
+ * - MSG_ERR_INVALID_FOLDER_ID Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_message_t msgInfo;
+
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ * err = msg_get_quick_panel_data(msgHandle, MSG_QUICKPANEL_SMS, msgInfo);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_quick_panel_data(MSG_HANDLE_T handle, MSG_QUICKPANEL_TYPE_T type, msg_message_t msg);
+
+
+/**
+
+ * \par Description:
+ * Resets the Messaging database.
+ *
+ * \par Purpose:
+ * This API is used to reset the messaging database.
+ *
+ * \par Typical use case:
+ * Completely delete the messaging database.
+ *
+ * \par Method of function operation:
+ * Connects to database and deletes all the messaging tables.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR             Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ * err = msg_reset_database(msgHandle);
+ * if (err != MSG_SUCCESS)
+ *{
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_reset_database(MSG_HANDLE_T handle);
+
+
+/**
+
+ * \par Description:
+ * Returns the total size used for message contents.
+ *
+ * \par Purpose:
+ * This API is used to get the total size used for message contents.
+ *
+ * \par Typical use case:
+ * To get the total space used by message contents.
+ *
+ * \par Method of function operation:
+ * Uses linux system calls to query the space used by message contents.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ * \param output -     memsize is a pointer to the size.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR             Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * int memsize = 0;
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ * err = msg_get_mem_size(msgHandle, &memsize);
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_mem_size(MSG_HANDLE_T handle, unsigned int* memsize);
+
+
+/**
+
+ * \par Description:
+ * Return thread id in thread view object.
+ *
+ * \par Purpose:
+ * This API is used to get the thread id field in folder view object.
+ *
+ * \par Typical use case:
+ * Returns thread id value in thread view object.
+ *
+ * \par Method of function operation:
+ * Returns the threadId member of thread view object msg.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg_thread is NULL, nothing happens.
+ * - If msg_thread is invalid, undefined behavior happens.
+ *
+ * \param msg_thread_view_t input - msg_thread is a thread view object.
+ *
+ * \return Return Type int (MSG_ERROR_T when negative, msg_id when positive) \n
+ * - positive int                                              thread id.
+ * - MSG_ERR_NULL_POINTER                              msg_thread is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_thread_view_t   msgThreadInfo;
+ * MSG_ERROR_T err;
+ *
+ * ...
+ * err = msg_thread_view_get_thread_id(&msgThreadInfo);
+ * if(msg_size > 0)
+ * {
+ * ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_thread_view_get_thread_id(msg_thread_view_t msg_thread);
+
+
+/**
+
+ * \par Description:
+ * Return address value in thread view object.
+ *
+ * \par Purpose:
+ * This API is used to get the address value in thread view object.
+ *
+ * \par Typical use case:
+ * Returns address value in thread view object.
+ *
+ * \par Method of function operation:
+ * Returns the threadAddr member of thread view object msg.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg_thread is NULL, nothing happens.
+ * - If msg_thread is invalid, undefined behavior happens.
+ * - You do not need to free the return value. It will be freed when you call msg_release_thread_view_list().
+ * - Also, the value is valid until msg_thread_view_t is freed by calling msg_release_thread_view_list().
+ *
+ * \param msg_thread_view_t input - msg_thread is a thread view object.
+ *
+ * \return Return Type int const char* (address value) \n
+ * - const char*                                       address value.
+ * - NULL                                                      msg_thread is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_thread_view_t   msgThreadInfo;
+ * char* addr = NULL;
+ *
+ * ...
+ * addr = msg_thread_view_get_address(&msgThreadInfo);
+ * if(addr != 0 && strlen(addt) > 0)
+ * {
+ * ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+const char* msg_thread_view_get_address(msg_thread_view_t msg_thread);
+
+
+/**
+
+ * \par Description:
+ * Return display name value in thread view object.
+ *
+ * \par Purpose:
+ * This API is used to get the display name value in thread view object.
+ *
+ * \par Typical use case:
+ * Returns address value in thread view object.
+ *
+ * \par Method of function operation:
+ * Returns the threadName member of thread view object msg.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg_thread is NULL, nothing happens.
+ * - If msg_thread is invalid, undefined behavior happens.
+ * - You do not need to free the return value. It will be freed when you call msg_release_thread_view_list().
+ * - Also, the value is valid until msg_thread_view_t is freed by calling msg_release_thread_view_list().
+ *
+ * \param msg_thread_view_t input - msg_thread is a thread view object.
+ *
+ * \return Return Type int const char* (display name) \n
+ * - const char*                                       display name.
+ * - NULL                                                      msg_thread is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_thread_view_t   msgThreadInfo;
+ * char* disp_name = NULL;
+ *
+ * ...
+ * disp_name = msg_thread_view_get_name(&msgThreadInfo);
+ * if(disp_name != 0 && strlen(disp_name) > 0)
+ * {
+ * ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+const char* msg_thread_view_get_name(msg_thread_view_t msg_thread);
+
+
+/**
+
+ * \par Description:
+ * Return image path in thread view object.
+ *
+ * \par Purpose:
+ * This API is used to get the image path value in thread view object.
+ *
+ * \par Typical use case:
+ * Returns image path value in thread view object.
+ *
+ * \par Method of function operation:
+ * Returns the threadImagePath member of thread view object msg.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg_thread is NULL, nothing happens.
+ * - If msg_thread is invalid, undefined behavior happens.
+ * - You do not need to free the return value. It will be freed when you call msg_release_thread_view_list().
+ * - Also, the value is valid until msg_thread_view_t is freed by calling msg_release_thread_view_list().
+ *
+ * \param msg_thread_view_t input - msg_thread is a thread view object.
+ *
+ * \return Return Type int const char* (thread image path) \n
+ * - const char*                                       thread image path.
+ * - NULL                                                      msg_thread is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_thread_view_t   msgThreadInfo;
+ * char* img_path = NULL;
+ *
+ * ...
+ * img_path = msg_thread_view_get_name(&msgThreadInfo);
+ * if(img_path != 0 && strlen(img_path) > 0)
+ * {
+ * ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+const char* msg_thread_view_get_image_path(msg_thread_view_t msg_thread);
+
+
+/**
+
+ * \par Description:
+ * Return the message type field in thread view object.
+ *
+ * \par Purpose:
+ * This API is used to get the message type field value in thread view object.
+ *
+ * \par Typical use case:
+ * Returns the message type value in thread view object.
+ *
+ * \par Method of function operation:
+ * Returns the msgType member of thread view object msg.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg_thread is NULL, nothing happens.
+ * - If msg_thread is invalid, undefined behavior happens.
+ * - You do not need to free the return value. It will be freed when you call msg_release_thread_view_list().
+ * - Also, the value is valid until msg_thread_view_t is freed by calling msg_release_thread_view_list().
+ *
+ * \param msg_thread_view_t input - msg_thread is a thread view object.
+ *
+ * \return Return Type (int (MSG_ERROR_T when negative, msg_type when positive)) \n
+ * - positive int                                      enum _MSG_MESSAGE_TYPE_E.
+ * - EINVAL                                            msg_thread is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_thread_view_t   msgThreadInfo;
+ * MSG_MESSAGE_TYPE_T msg_type;
+ *
+ * ...
+ * msg_type = msg_thread_view_get_message_type(&msgThreadInfo);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_thread_view_get_message_type(msg_thread_view_t msg_thread);
+
+
+/**
+
+ * \par Description:
+ * Return data field in thread view object.
+ *
+ * \par Purpose:
+ * This API is used to get the data field value in thread view object.
+ *
+ * \par Typical use case:
+ * Returns data value in thread view object.
+ *
+ * \par Method of function operation:
+ * Returns the threadData member of thread view object msg.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg_thread is NULL, nothing happens.
+ * - If msg_thread is invalid, undefined behavior happens.
+ * - You do not need to free the return value. It will be freed when you call msg_release_thread_view_list().
+ * - Also, the value is valid until msg_thread_view_t is freed by calling msg_release_thread_view_list().
+ *
+ * \param msg_thread_view_t input - msg_thread is a thread view object.
+ *
+ * \return Return Type int const char* (message data) \n
+ * - const char*                                       message data.
+ * - NULL                                                      msg_thread is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_thread_view_t   msgThreadInfo;
+ * char* msg_data = NULL;
+ *
+ * ...
+ * msg_data = msg_thread_view_get_data(&msgThreadInfo);
+ * if(msg_data != 0 && strlen(msg_data) > 0)
+ * {
+ * ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+const char* msg_thread_view_get_data(msg_thread_view_t msg_thread);
+
+
+/**
+
+ * \par Description:
+ * Return time field in thread view object.
+ *
+ * \par Purpose:
+ * This API is used to get the time field value in thread view object.
+ *
+ * \par Typical use case:
+ * Returns time value in thread view object.
+ *
+ * \par Method of function operation:
+ * Returns the threadTime member of thread view object msg.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg_thread is NULL, nothing happens.
+ * - If msg_thread is invalid, undefined behavior happens.
+ * - You do not need to free the return value. It will be freed when you call msg_release_thread_view_list().
+ * - Also, the value is valid until msg_thread_view_t is freed by calling msg_release_thread_view_list().
+ *
+ * \param msg_thread_view_t input - msg_thread is a thread view object.
+ *
+ * \return Return Type (time_t) \n
+ * - time_t                                            message time.
+ * - NULL                                                      thread view object is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_thread_view_t   msgThreadInfo;
+ * time_t msg_time;
+ *
+ * ...
+ * msg_time = msg_thread_view_get_time(&msgThreadInfo);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+time_t* msg_thread_view_get_time(msg_thread_view_t msg_thread);
+
+
+/**
+
+ * \par Description:
+ * Return direction field in thread view object.
+ *
+ * \par Purpose:
+ * This API is used to get the direction field value in thread view object.
+ *
+ * \par Typical use case:
+ * Returns direction value in thread view object.
+ *
+ * \par Method of function operation:
+ * Returns the direction member of thread view object msg.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg_thread is NULL, nothing happens.
+ * - If msg_thread is invalid, undefined behavior happens.
+ *
+ * \param msg_thread_view_t input - msg_thread is a thread view object.
+ *
+ * \return Return Type (time_t) \n
+ * - positive int                                      enum _MSG_DIRECTION_TYPE_E.
+ * - MSG_ERR_NULL_POINTER                              msg_thread is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_thread_view_t   msgThreadInfo;
+ * int direction;
+ *
+ * ...
+ * direction = msg_thread_view_get_direction(&msgThreadInfo);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_thread_view_get_direction(msg_thread_view_t msg_thread);
+
+
+/**
+
+ * \par Description:
+ * Return contact id field in thread view object.
+ *
+ * \par Purpose:
+ * This API is used to get the contact id field value in thread view object.
+ *
+ * \par Typical use case:
+ * Returns contact id value in thread view object.
+ *
+ * \par Method of function operation:
+ * Returns the contactId member of thread view object msg.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg_thread is NULL, nothing happens.
+ * - If msg_thread is invalid, undefined behavior happens.
+ *
+ * \param msg_thread_view_t input - msg_thread is a thread view object.
+ *
+ * \return Return Type (int (MSG_ERROR_T when negative, contact id when positive)) \n
+ * - positive int                                      contact id
+ * - MSG_ERR_NULL_POINTER                      msg_thread is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_thread_view_t   msgThreadInfo;
+ * int contact_id;
+ *
+ * ...
+ * contact_id = msg_thread_view_get_contact_id(&msgThreadInfo);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_thread_view_get_contact_id(msg_thread_view_t msg_thread);
+
+
+/**
+
+ * \par Description:
+ * Return unread message count field in thread view object.
+ *
+ * \par Purpose:
+ * This API is used to get the unread message count field value in thread view object.
+ *
+ * \par Typical use case:
+ * Returns unread message count value in thread view object.
+ *
+ * \par Method of function operation:
+ * Returns the unreadCnt member of thread view object msg.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg_thread is NULL, nothing happens.
+ * - If msg_thread is invalid, undefined behavior happens.
+ *
+ * \param msg_thread_view_t input - msg_thread is a thread view object.
+ *
+ * \return Return Type nt (MSG_ERROR_T when negative, unread message count  when positive) \n
+ * - positive int                                      unread message count \n
+ * - MSG_ERR_NULL_POINTER                      msg_thread is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_thread_view_t   msgThreadInfo;
+ * int unread_count;
+ *
+ * ...
+ * unread_count= msg_thread_view_get_unread_cnt(&msgThreadInfo);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_thread_view_get_unread_cnt(msg_thread_view_t msg_thread);
+
+
+
+/**
+
+ * \par Description:
+ * Return sms message count field in thread view object.
+ *
+ * \par Purpose:
+ * This API is used to get the sms message count field value in thread view object.
+ *
+ * \par Typical use case:
+ * Returns sms message count value in thread view object.
+ *
+ * \par Method of function operation:
+ * Returns the smsCnt member of thread view object msg.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg_thread is NULL, nothing happens.
+ * - If msg_thread is invalid, undefined behavior happens.
+ *
+ * \param msg_thread_view_t input - msg_thread is a thread view object.
+ *
+ * \return Return Type int (MSG_ERROR_T when negative, sms message count when positive) \n
+ * - positive int                                      sms message count
+ * - MSG_ERR_NULL_POINTER                      msg_thread is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_thread_view_t   msgThreadInfo;
+ * int sms_count;
+ *
+ * ...
+ * sms_count= msg_thread_view_get_sms_cnt(&msgThreadInfo);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_thread_view_get_sms_cnt(msg_thread_view_t msg_thread);
+
+
+/**
+
+ * \par Description:
+ * Return mms message count field in thread view object.
+ *
+ * \par Purpose:
+ * This API is used to get the mms message count field value in thread view object.
+ *
+ * \par Typical use case:
+ * Returns mms message count value in thread view object.
+ *
+ * \par Method of function operation:
+ * Returns the mmsCnt member of thread view object msg.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If msg_thread is NULL, nothing happens.
+ * - If msg_thread is invalid, undefined behavior happens.
+ *
+ * \param msg_thread_view_t input - msg_thread is a thread view object.
+ *
+ * \return Return Type int (MSG_ERROR_T when negative, mms message count when positive) \n
+ * - positive int                                      sms message count
+ * - MSG_ERR_NULL_POINTER                      msg_thread is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * msg_thread_view_t   msgThreadInfo;
+ * int mms_count;
+ *
+ * ...
+ * mms_count= msg_thread_view_get_mms_cnt(&msgThreadInfo);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_thread_view_get_mms_cnt(msg_thread_view_t msg_thread);
+
+
+/**
+
+ * \par Description:
+ * Search messages or addresses which including a string that applcation want to find.
+ *
+ * \par Purpose:
+ * This API is used to search messages or addresses from storage.
+ *
+ * \par Typical use case:
+ * Search messages or addresses from storage.
+ *
+ * \par Method of function operation:
+ * search messages or addresses from storage.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * None
+ *
+ * \param input - MSG_HANDLE_T  handle is Message handle.
+ * \param input - search_string is the string to search.
+ * \param output - msg_thread_view_list is a pointer to an MSG_THREAD_VIEW_LIST_S structure.
+ *
+ * \return Return Type int (MSG_ERROR_T) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR             Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * ...
+ * char* search_string = "hello";
+ * MSG_THREAD_VIEW_LIST_S threadViewList;
+ * ...
+ * err = msg_search_message_for_thread_view(&msgHandle, search_string, &threadViewList);
+ *
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_search_message_for_thread_view(MSG_HANDLE_T handle, const char *search_string, MSG_THREAD_VIEW_LIST_S *msg_thread_view_list);
+
+
+/**
+
+ * \par Description:
+ * Search messages or addresses which including a string that applcation want to find.
+ *
+ * \par Purpose:
+ * This API is used to search messages or addresses from storage.
+ *
+ * \par Typical use case:
+ * Search messages or addresses from storage.
+ *
+ * \par Method of function operation:
+ * search messages or addresses from storage.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * None
+ *
+ * \param input - MSG_HANDLE_T  handle is Message handle.
+ * \param input - search_string is the string to search.
+ * \param input - offset is the offset of the search result.
+ * \param input - limit is the limit of the search result.
+ * \param output - msg_list is a pointer to an MSG_LIST_S structure.
+ *
+ * \return Return Type int (MSG_ERROR_T) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR             Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * ...
+ * MSG_LIST_S msg_list;
+ * int offset = 0;
+ * int limit = 10;
+ *
+ * MSG_SEARCH_CONDITION_S searchCon;
+ *
+ * searchCon.msgType = MSG_TYPE_SMS;
+ * searchCon.folderId = MSG_INBOX_ID;
+ * searchCon.pSearchVal = "keyString";
+ * searchCon.pAddressVal = "01000000000";
+ *
+ * ...
+ * err = msg_search_message(hMsgHandle, &searchCon, offset, limit, &msgList);
+ *
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_search_message(MSG_HANDLE_T handle, const MSG_SEARCH_CONDITION_S *msg_search_conditions, int offset, int limit, MSG_LIST_S *msg_list);
+
+
+/**
+
+ * \par Description:
+ * Free the memory of msg_message_t, which is created by msg_new_message().
+ *
+ * \par Purpose:
+ * This API is used to release memory created by message creation.
+ *
+ * \par Typical use case:
+ * After using message object for send/save scenario, release message need to be called.
+ *
+ * \par Method of function operation:
+ * Frees the memory allocated to message object and deletes the object.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param msg_message_t    input - message object to be destroyed .
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Successfully connected to Messaging Service \n
+ * - MSG_ERR_NULL_POINTER      -       Input parameter is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * msg_message_t               msg;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * msg = msg_new_message();
+ * ...
+ * err = msg_release_message(&msg);
+ *
+ * if (err != MSG_SUCCESS)
+ * {
+ *     sprintf(str, "msg_release_message() Fail [%d]", err);
+ *     print(str);
+ *
+ *     return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code.
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_release_message_list(MSG_LIST_S *msg_list);
+
+
+/**
+
+ * \par Description:
+ * Get message ID list that application wants to find by reference ID.
+ *
+ * \par Purpose:
+ * This API is used to get message ID list from storage.
+ *
+ * \par Typical use case:
+ * Get message ID list from storage.
+ *
+ * \par Method of function operation:
+ * Get message ID list from storage.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * None
+ *
+ * \param input - MSG_HANDLE_T  handle is Message handle.
+ * \param input - ref_id is the reference id of message group.
+ * \param output - msg_msgid_list is a pointer to an MSG_MSGID_LIST_S structure.
+ *
+ * \return Return Type int (MSG_ERROR_T) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR             Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * ...
+ * MSG_REFERENCE_ID_T refId = 0;
+ * MSG_MSGID_LIST_S msgIdList;
+ * ...
+ * err = msg_get_msgid_list(hMsgHandle, refId, &msgIdList);
+ *
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_msgid_list(MSG_HANDLE_T handle, MSG_REFERENCE_ID_T ref_id, MSG_MSGID_LIST_S *msg_msgid_list);
+
+
+/**
+
+ * \par Description:
+ * Frees the memory of MSG_MSGID_LIST_S allocated in msg_get_msgid_list.
+ *
+ * \par Purpose:
+ * This API is used to free the memory of MSG_MSGID_LIST_S allocated in msg_get_msgid_list.
+ *
+ * \par Typical use case:
+ * To free the memory of MSG_MSGID_LIST_S and its members which was allocated in msg_get_msgid_list.
+ *
+ * \par Method of function operation:
+ * To free the memory of MSG_MSGID_LIST_S and its members which was allocated in msg_get_msgid_list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If MSG_MSGID_LIST_S is NULL, nothing happens.
+ * - If MSG_MSGID_LIST_S is invalid, undefined behavior happens.
+ *
+ * \param input - MSG_MSGID_LIST_S structure.
+ *
+ * \return Return Type (void) \n
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * - None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * ...
+ * MSG_REFERENCE_ID_T refId = 0;
+ * MSG_MSGID_LIST_S msgIdList;
+ * ...
+ * err = msg_get_msgid_list(hMsgHandle, refId, &msgIdList);
+ *
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * msg_release_msgid_list(&msgIdList);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+void msg_release_msgid_list(MSG_MSGID_LIST_S *msg_msgid_list);
+
+
+/**
+
+ * \par Description:
+ * Get reject message list that application wants to find by phone number.
+ *
+ * \par Purpose:
+ * This API is used to get reject message list from storage.
+ *
+ * \par Typical use case:
+ * Get reject message list from storage.
+ *
+ * \par Method of function operation:
+ * Get reject message list from storage.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * None
+ *
+ * \param input - MSG_HANDLE_T  handle is Message handle.
+ * \param input - phone_num is the string of phone number to find.
+ * \param output - msg_reject_msg_list is a pointer to an MSG_REJECT_MSG_LIST_S structure.
+
+ * \return Return Type int (MSG_ERROR_T) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR             Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * ...
+ * char* phone_num = "01030016057";
+ * MSG_REJECT_MSG_LIST_S rejectMsgList;
+ * ...
+ * err = msg_get_reject_msg_list(hMsgHandle, phone_num, &rejectMsgList);
+ *
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_reject_msg_list(MSG_HANDLE_T handle, const char* phone_num, MSG_REJECT_MSG_LIST_S *msg_reject_msg_list);
+
+
+/**
+
+ * \par Description:
+ * Frees the memory of MSG_REJECT_MSG_LIST_S allocated in msg_get_reject_msg_list.
+ *
+ * \par Purpose:
+ * This API is used to free the memory of MSG_REJECT_MSG_LIST_S allocated in msg_get_reject_msg_list.
+ *
+ * \par Typical use case:
+ * To free the memory of MSG_REJECT_MSG_LIST_S and its members which was allocated in msg_get_reject_msg_list.
+ *
+ * \par Method of function operation:
+ * To free the memory of MSG_REJECT_MSG_LIST_S and its members which was allocated in msg_get_reject_msg_list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - If MSG_REJECT_MSG_LIST_S is NULL, nothing happens.
+ * - If MSG_REJECT_MSG_LIST_S is invalid, undefined behavior happens.
+ *
+ * \param input - MSG_REJECT_MSG_LIST_S structure.
+ *
+ * \return Return Type (void) \n
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * - None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_ERROR_T err = MSG_SUCCESS;
+ * ...
+ * char* phone_num = "01030016057";
+ * MSG_REJECT_MSG_LIST_S rejectMsgList;
+ * ...
+ * err = msg_get_reject_msg_list(hMsgHandle, phone_num, &rejectMsgList);
+ *
+ * if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * msg_release_reject_msg_list(&rejectMsgList);
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+void msg_release_reject_msg_list(MSG_REJECT_MSG_LIST_S *msg_reject_msg_list);
+
+
+/**
+
+ * \par Description:
+ * Registers a callback function about the change of storage status to Message handle.
+ *
+ * \par Purpose:
+ * This API is used to register a callback function about the change of storage status "msg_storage_change_cb" to Message handle.
+ *
+ * \par Typical use case:
+ * Register a callback function about the change of storage status.
+ *
+ * \par Method of function operation:
+ * Adds the msg_storage_change_cb API to a callback function list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be called after Message handle is opened.
+ *
+ * \param input - handle is Message handle.
+ * \param input - cb is a function to be called.
+ * \param input - user_param is a pointer to user data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                                       Success in operation.
+ * - MSG_ERR_MSGHANDLE_NOT_CONNECTED   Message handle is not connected.
+ * - MSG_ERR_MEMORY_ERROR                              Memory is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ *
+ * err = msg_reg_storage_change_callback(msgHandle, &storageCB, NULL);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ * return;
+ * }
+ *
+ * void storageCB(MSG_HANDLE_T handle, MSG_THREAD_ID_T threadId, MSG_MESSAGE_ID_T msgId, void *user_param)
+ * {
+ *     ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_reg_storage_change_callback(MSG_HANDLE_T handle, msg_storage_change_cb cb, void *user_param);
+
+
+/**
+
+ * \par Description:
+ * Gets the report status information of message.
+ *
+ * \par Purpose:
+ * This API is used to get the report status information of specified message.
+ *
+ * \par Typical use case:
+ * Gets the report status information of specified message from the database.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and Gets the report status information of specified message from the report table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input - handle is Message handle.
+ * \param input - msg_id is the ID of the message.
+ * \param output - report_status is a pointer to a MSG_REPORT_STATUS_INFO_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS       - Success in operation.
+ * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid.
+ * - MSG_ERR_STORAGE_ERROR - Storage is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * MSG_HANDLE_T msgHandle = NULL;
+ * MSG_REPORT_STATUS_INFO_S reportStatus;
+ *
+ * ...
+ *
+ * err = msg_open_msg_handle(&msgHandle);
+ *
+ * ...
+ *
+ * err = msg_get_report_status(msgHandle, msgID, &reportStatus)
+* if( err != MSG_SUCCESS )
+ * {
+ *     printf("err [%d]", err);
+ *     return err;
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_get_report_status(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, MSG_REPORT_STATUS_INFO_S *report_status);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MAPI_STORAGE_H
+
diff --git a/include/mapi/MapiTransport.h b/include/mapi/MapiTransport.h
new file mode 100755 (executable)
index 0000000..fefe251
--- /dev/null
@@ -0,0 +1,983 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+/**
+ *     @file           MapiTransport.h
+ *     @brief          Defines transport API of messaging framework
+ *     @version        1.0
+ */
+
+#ifndef MAPI_TRANSPORT_H
+#define MAPI_TRANSPORT_H
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Messaging Transport API
+ *     @section                Program
+ *     - Program : Messaging Transport API Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include "MsgTransportTypes.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_TRANSPORT_API Messaging Transport API
+ *     @{
+ */
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+
+ * \par Description:
+ * Submits a request to the Messaging Framework.
+ *
+ * \par Purpose:
+ * This API is used to submit a request to the Messaging Framework.
+ *
+ * \par Typical use case:
+ * Submit a request to Messaging Service such as Send Message, Forward etc.
+ *
+ * \par Method of function operation:
+ * Sets up the database connection and inserts the message to message table.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - The result information will be sent back by using the callback function, msg_sent_status_cb.
+ * - Applications MUST fill in the valid message type.
+ * -  reqId will be filled in the framework.
+ *
+ * \param input  - handle is Message handle.
+ * \param input  - req is a pointer to an MSG_REQUEST_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_MSGHANDLE Message handle is invalid.
+ * - MSG_ERR_NULL_POINTER                      Pointer is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ * MSG_REQUEST_S req;
+ *
+ * req.msg = msg;
+ * req.sendOpt = sendOpt;
+
+ * err = msg_submit_req(msgHandle, &req);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_submit_req(MSG_HANDLE_T handle, MSG_REQUEST_S *req);
+
+
+/**
+
+ * \par Description:
+ * Registers sent status callback function to Message handle.
+ *
+ * \par Purpose:
+ * This API is used to register sent status callback function "msg_sent_status_cb" to Message handle.
+ *
+ * \par Typical use case:
+ * Register for sent status callback.
+ *
+ * \par Method of function operation:
+ * Adds the msg_sent_status_cb API to sent status callback list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be called after Message handle is opened.
+ *
+ * \param input - handle is Message handle.
+ * \param input - cb is a function to be called.
+ * \param input - user_param is a pointer to user data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_MSGHANDLE Message handle is invalid.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ * MSG_REQUEST_S req;
+ *
+ * req.msg = msg;
+ * req.sendOpt = sendOpt;
+
+ * err = msg_reg_sent_status_callback(msgHandle, &sentStatusCB, (void*)"sent status callback");
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ * return;
+ * }
+
+ * void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam)
+ * {
+ *     ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_reg_sent_status_callback(MSG_HANDLE_T handle, msg_sent_status_cb cb, void *user_param);
+
+
+/**
+
+ * \par Description:
+ * Registers incoming SMS callback to Message handle.
+ *
+ * \par Purpose:
+ * This API is used to Registers incoming SMS callback function "msg_sms_incoming_cb" to Message handle.
+ *
+ * \par Typical use case:
+ * Register incoming SMS message callback.
+ *
+ * \par Method of function operation:
+ * Adds the msg_sms_incoming_cb API to incoming SMS callback list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be called after Message handle is opened.
+ *
+ * \param input - handle is Message handle.
+ * \param input - cb is a function to be called.
+ * \param input - port is used for listening. If port is not used, please assign 0 to it.
+ * \param input - user_param is a pointer to user data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_MSGHANDLE Message handle is invalid.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ * MSG_REQUEST_S req;
+ *
+ * req.msg = msg;
+ * req.sendOpt = sendOpt;
+
+ * err = msg_reg_sms_message_callback(msgHandle, &incomingSmsCB, 0, (void*)"sms message callback");
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ * return;
+ * }
+ *
+ * void incomingSmsCB(MSG_HANDLE_T Handle, msg_message_t msg, void *pUserParam)
+ * {
+ *     ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_reg_sms_message_callback(MSG_HANDLE_T handle, msg_sms_incoming_cb cb, unsigned short port, void *user_param);
+
+
+/**
+
+ * \par Description:
+ * Registers incoming MMS callback to Message handle.
+ *
+ * \par Purpose:
+ * This API is used to Registers incoming MMS callback function "msg_mms_conf_msg_incoming_cb" to Message handle.
+ *
+ * \par Typical use case:
+ * Register incoming SMS message callback.
+ *
+ * \par Method of function operation:
+ * Adds the msg_mms_conf_msg_incoming_cb API to incoming MMS callback list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be called after Message handle is opened.
+ *
+ * \param input - handle is Message handle.
+ * \param input - handle is Message handle.
+ * \param input - cb is a function to be called.
+ * \param input - app_id is used for listening. If appId is not used, please assign NULL to it.
+ * \param input - user_param is a pointer to user data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_MSGHANDLE Message handle is invalid.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ * MSG_REQUEST_S req;
+ *
+ * req.msg = msg;
+ * req.sendOpt = sendOpt;
+
+ * err = msg_reg_mms_conf_message_callback(msgHandle, &incomingMmsConfCB, NULL, NULL);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ * return;
+ * }
+ *
+ * void incomingMmsConfCB(MSG_HANDLE_T Handle, msg_message_t msg, void *pUserParam)
+ * {
+ *     ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_reg_mms_conf_message_callback(MSG_HANDLE_T handle, msg_mms_conf_msg_incoming_cb cb, const char *app_id, void *user_param);
+
+
+/**
+
+ * \par Description:
+ * Registers incoming SyncML Message callback to Message handle.
+ *
+ * \par Purpose:
+ * This API is used to Registers incoming SyncML Message callback function "msg_syncml_msg_incoming_cb" to Message handle.
+ *
+ * \par Typical use case:
+ * Register incoming SMS message callback.
+ *
+ * \par Method of function operation:
+ * Adds the msg_syncml_msg_incoming_cb API to incoming SyncML callback list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be called after Message handle is opened.
+ *
+ * \param input - handle is Message handle.
+ * \param input - cb is a function to be called.
+ * \param input - user_param is a pointer to user data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                                       Success in operation.
+ * - MSG_ERR_MSGHANDLE_NOT_CONNECTED   Message handle is not connected.
+ * - MSG_ERR_MEMORY_ERROR                              Memory is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ *
+ * err = err = msg_reg_syncml_message_callback(msgHandle, &syncMLCB, NULL);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ * return;
+ * }
+ *
+ * void syncMLCB(MSG_HANDLE_T hMsgHandle, MSG_SYNCML_MESSAGE_TYPE_T msgType, const char* pPushHeader, int PushHeaderLen, const char* pPushBody, int PushBodyLen, void *pUserParam)
+ * {
+ *     ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_reg_syncml_message_callback(MSG_HANDLE_T handle,  msg_syncml_msg_incoming_cb cb, void *user_param);
+
+
+/**
+
+ * \par Description:
+ * Registers incoming LBS Message callback to Message handle.
+ *
+ * \par Purpose:
+ * This API is used to Registers incoming LBS Message callback function "msg_lbs_msg_incoming_cb" to Message handle.
+ *
+ * \par Typical use case:
+ * Register incoming SMS message callback.
+ *
+ * \par Method of function operation:
+ * Adds the msg_lbs_msg_incoming_cb API to incoming LBS Message callback list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be called after Message handle is opened.
+ *
+ * \param input - handle is Message handle.
+ * \param input - cb is a function to be called.
+ * \param input - user_param is a pointer to user data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                                       Success in operation.
+ * - MSG_ERR_MSGHANDLE_NOT_CONNECTED   Message handle is not connected.
+ * - MSG_ERR_MEMORY_ERROR                              Memory is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ *
+ * err = msg_reg_lbs_message_callback(msgHandle, &lbsCB, NULL);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ * return;
+ * }
+ *
+ * void lbsCB(MSG_HANDLE_T hMsgHandle, const char* pPushHeader, const char* pPushBody, int pushBodyLen, void *pUserParam)
+ * {
+ *     ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_reg_lbs_message_callback(MSG_HANDLE_T handle, msg_lbs_msg_incoming_cb cb, void *user_param);
+
+
+/**
+
+ * \par Description:
+ * Registers incoming LBS Message callback to Message handle.
+ *
+ * \par Purpose:
+ * This API is used to Registers incoming LBS Message callback function "msg_lbs_msg_incoming_cb" to Message handle.
+ *
+ * \par Typical use case:
+ * Register incoming SMS message callback.
+ *
+ * \par Method of function operation:
+ * Adds the msg_lbs_msg_incoming_cb API to incoming LBS Message callback list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be called after Message handle is opened.
+ *
+ * \param input - handle is Message handle.
+ * \param input - cb is a function to be called.
+ * \param input - user_param is a pointer to user data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                                       Success in operation.
+ * - MSG_ERR_MSGHANDLE_NOT_CONNECTED   Message handle is not connected.
+ * - MSG_ERR_MEMORY_ERROR                              Memory is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ *
+ * err = msg_reg_lbs_message_callback(msgHandle, &lbsCB, NULL);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ * return;
+ * }
+ *
+ * void lbsCB(MSG_HANDLE_T hMsgHandle, const char* pPushHeader, const char* pPushBody, int pushBodyLen, void *pUserParam)
+ * {
+ *     ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_reg_syncml_message_operation_callback(MSG_HANDLE_T handle,  msg_syncml_msg_operation_cb cb, void *user_param);
+
+
+/**
+
+ * \par Description:
+ * Registers incoming LBS Message callback to Message handle.
+ *
+ * \par Purpose:
+ * This API is used to Registers incoming LBS Message callback function "msg_lbs_msg_incoming_cb" to Message handle.
+ *
+ * \par Typical use case:
+ * Register incoming SMS message callback.
+ *
+ * \par Method of function operation:
+ * Adds the msg_lbs_msg_incoming_cb API to incoming LBS Message callback list.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ *     This function MUST be called after Message handle is opened.
+ *
+ * \param input - handle is Message handle.
+ * \param input - cb is a function to be called.
+ * \param input - user_param is a pointer to user data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                                       Success in operation.
+ * - MSG_ERR_MSGHANDLE_NOT_CONNECTED   Message handle is not connected.
+ * - MSG_ERR_MEMORY_ERROR                              Memory is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ *
+ * err = msg_reg_lbs_message_callback(msgHandle, &lbsCB, NULL);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ * return;
+ * }
+ *
+ * void lbsCB(MSG_HANDLE_T hMsgHandle, const char* pPushHeader, const char* pPushBody, int pushBodyLen, void *pUserParam)
+ * {
+ *     ...
+ * }
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_syncml_message_operation(MSG_HANDLE_T handle,  MSG_MESSAGE_ID_T msgId);
+
+
+/**
+
+ * \par Description:
+ * Sends SMS. It is a synchronous API which has been blocked until sent status arrives.
+ *
+ * \par Purpose:
+ * This API is used to sends SMS.
+ *
+ * \par Typical use case:
+ * Sends a SMS Message
+ *
+ * \par Method of function operation:
+ * It is a synchronous API which has been blocked until sent status arrives.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input  - phone_num is the list of phone numbers. It is separated by ",".
+ * \param input  - sms_text is a SMS text.
+ * \param input  - cb is a function to be called.
+ * \param input  - user_param is for user data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                               Success in operation.
+ * - MSG_ERR_NULL_POINTER              Invalid parameter.
+ * - MSG_ERR_MEMORY_ERROR      Memory is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ *
+ * err = msg_sms_send("01000000000,01000000000", "1234567890", sentStatusCB, NULL);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_sms_send(const char *phone_num, const char *sms_text, msg_simple_sent_status_cb cb, void *user_param);
+
+
+/**
+
+ * \par Description:
+ * Submits request to send SMS message.
+ *
+ * \par Purpose:
+ * This API is used to submit request to send SMS message.
+ *
+ * \par Typical use case:
+ * Submits request to send SMS message.
+ *
+ * \par Method of function operation:
+ * Submits a request to send SMS.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input  - phone_num is the list of phone numbers. It is separated by ",".
+ * \param input  - sms_text is a SMS text.
+ * \param input  - cb is a function to be called.
+ * \param input  - user_param is for user data.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                               Success in operation.
+ * - MSG_ERR_NULL_POINTER              Invalid parameter.
+ * - MSG_ERR_MEMORY_ERROR      Memory is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ * MSG_REQUEST_S req;
+ *
+ * req.msg = msg;
+ * req.sendOpt = sendOpt;
+ *
+ * err = msg_sms_send_message(msgHandle, &req);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_sms_send_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req);
+
+
+/**
+
+ * \par Description:
+ * Submits request to send MMS message.
+ *
+ * \par Purpose:
+ * This API is used to submit request to send MMS message.
+ *
+ * \par Typical use case:
+ * Submits request to send MMS message.
+ *
+ * \par Method of function operation:
+ * Submits a request to send MMS.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input  - handle is Message handle.
+ * \param input  - req is a pointer to an MSG_REQUEST_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                               Success in operation.
+ * - MSG_ERR_NULL_POINTER              Invalid parameter.
+ * - MSG_ERR_MEMORY_ERROR      Memory is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ * MSG_REQUEST_S req;
+ *
+ * req.msg = msg;
+ * req.sendOpt = sendOpt;
+ *
+ * err = msg_mms_send_message(msgHandle, &req);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_mms_send_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req);
+
+
+/**
+
+ * \par Description:
+ * Submits request to send MMS read report request.
+ *
+ * \par Purpose:
+ * This API is used to submit request to send MMS read report request.
+ *
+ * \par Typical use case:
+ * Submits request to send MMS read report request.
+ *
+ * \par Method of function operation:
+ * Submits a request to send MMS read report request.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input  - handle is Message handle.
+ * \param input  - msg_id is a message id, which is a positive integer.
+ * \param input  - mms_read_status is status whether message was read or not.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                               Success in operation.
+ * - MSG_ERR_NULL_POINTER              Invalid parameter.
+ * - MSG_ERR_MEMORY_ERROR      Memory is error.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ *
+ * err = err = msg_mms_send_read_report(NULL, 0, MSG_READ_REPORT_IS_READ);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_mms_send_read_report(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msgId, MSG_READ_REPORT_STATUS_T mms_read_status);
+
+
+/**
+
+ * \par Description:
+ * Submits request to send forward MMS request.
+ *
+ * \par Purpose:
+ * This API is used to submit request to send forward MMS request.
+ *
+ * \par Typical use case:
+ * Submits request to send forward MMS request.
+ *
+ * \par Method of function operation:
+ * Submits a request to send forward MMS request.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input  - handle is Message handle.
+  * \param input  - req is a pointer to an MSG_REQUEST_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_MSGHANDLE         Message handle is invalid.
+ * - MSG_ERR_NULL_POINTER                              Pointer is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ *
+ * err = err = msg_mms_send_read_report(NULL, 0, MSG_READ_REPORT_IS_READ);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_mms_forward_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req);
+
+
+/**
+
+ * \par Description:
+ * Submits request to retrieve MMS request.
+ *
+ * \par Purpose:
+ * This API is used to submit request to retrieve MMS request.
+ *
+ * \par Typical use case:
+ * Submits request to retrieve MMS request.
+ *
+ * \par Method of function operation:
+ * Submits a request to send forward MMS request.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input  - handle is Message handle.
+  * \param input  - req is a pointer to an MSG_REQUEST_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_MSGHANDLE         Message handle is invalid.
+ * - MSG_ERR_NULL_POINTER                              Pointer is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ *
+ * err = msg_mms_retrieve_message(handle, &req);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_mms_retrieve_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req);
+
+
+/* reject_msg_support */
+/**
+
+ * \par Description:
+ * Submits request to reject MMS message.
+ *
+ * \par Purpose:
+ * This API is used to submit request to reject MMS message.
+ *
+ * \par Typical use case:
+ * Submits request to reject MMS message.
+ *
+ * \par Method of function operation:
+ * Submits a request to send forward reject MMS message.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important notes:
+ * - None
+ *
+ * \param input  - handle is Message handle.
+  * \param input  - req is a pointer to an MSG_REQUEST_S structure.
+ *
+ * \return Return Type (int(MSG_ERROR_T)) \n
+ * - MSG_SUCCESS                                       Success in operation.
+ * - MSG_ERR_INVALID_MSGHANDLE         Message handle is invalid.
+ * - MSG_ERR_NULL_POINTER                              Pointer is NULL.
+ *
+ * \par Prospective clients:
+ * External/Native Apps using Messaging Services.
+ *
+ * \par Related functions:
+ * None
+ *
+ * \par Known issues/bugs:
+ * None
+ *
+ * \par Sample code:
+ * \code
+ * ...
+ *
+ * int err = MSG_SUCCESS;
+ *
+ * err = msg_mms_reject_message(handle, &req);
+ * if (err != MSG_SUCCESS)
+ * {
+ * ...
+ * }
+ *
+ * ...
+ * \endcode
+ */
+/*================================================================================================*/
+int msg_mms_reject_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MAPI_TRANSPORT_H
+
diff --git a/include/msg_helper/MsgHelper.h b/include/msg_helper/MsgHelper.h
new file mode 100755 (executable)
index 0000000..af8ab57
--- /dev/null
@@ -0,0 +1,51 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_HELPER_H
+#define MSG_HELPER_H
+
+
+#include "MsgTypes.h"
+
+/*==================================================================================================
+                                       DEFINES
+==================================================================================================*/
+
+#define MSG_SOUND_START        "SOUND_START"
+#define MSG_SOUND_STOP         "SOUND_STOP"
+
+#define MAX_SOUND_FILE_LEN 1024
+
+#define DEFAULT_FILE           "/usr/share/media/Sherbet.wav"
+#define ALERT_ON_CALL_TONE     "/opt/etc/msg-service/alert_on_call.mp3"
+
+#define HAPTIC_TEST_ITERATION 1
+#define MSG_VIBRATION_INTERVAL 3000
+
+
+/*==================================================================================================
+                                       FUNCTION PROTOTYPES
+==================================================================================================*/
+
+// SoundPlayer
+MSG_ERROR_T MsgSoundPlayUninit();
+void MsgSoundPlayStart();
+void MsgSoundPlayStop();
+int MsgSoundPlayMelody(char *pMsgToneFilePath, bool bIncreasing);
+void MsgSoundPlayVibration();
+
+
+#endif // MSG_HELPER_H
diff --git a/include/proxy/MsgHandle.h b/include/proxy/MsgHandle.h
new file mode 100755 (executable)
index 0000000..052fd11
--- /dev/null
@@ -0,0 +1,123 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_HANDLE_H
+#define MSG_HANDLE_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgStorageTypes.h"
+#include "MsgTransportTypes.h"
+#include "MsgSettingTypes.h"
+#include "MsgCmdTypes.h"
+#include "MsgInternalTypes.h"
+#include "MsgIpcSocket.h"
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+
+class MsgHandle
+{
+       public:
+               MsgHandle();
+               virtual ~MsgHandle();
+
+               // Control
+               void openHandle();
+               void closeHandle(MsgHandle* pHandle);
+
+               // Transport
+               MSG_ERROR_T submitReq(MSG_REQUEST_S* pReq);
+               MSG_ERROR_T cancelReq(MSG_REQUEST_ID_T reqId);
+
+               MSG_ERROR_T regSentStatusCallback(msg_sent_status_cb onStatusChanged,  void *pUserParam);
+               MSG_ERROR_T regSmsMessageCallback(msg_sms_incoming_cb onMsgIncoming, unsigned short port, void *pUserParam);
+               MSG_ERROR_T regMmsConfMessageCallback(msg_mms_conf_msg_incoming_cb onMMSConfMsgIncoming, const char *pAppId, void *pUserParam);
+               MSG_ERROR_T regSyncMLMessageCallback(msg_syncml_msg_incoming_cb onSyncMLMsgIncoming, void *pUserParam);
+               MSG_ERROR_T regLBSMessageCallback(msg_lbs_msg_incoming_cb onLBSMsgIncoming, void *pUserParam);
+
+               MSG_ERROR_T regSyncMLMessageOperationCallback(msg_syncml_msg_operation_cb onSyncMLMsgOperation, void *pUserParam);
+
+               MSG_ERROR_T operateSyncMLMessage(MSG_MESSAGE_ID_T msgId);
+
+               // Storage
+               int addMessage(const MSG_MESSAGE_S *pMsg, const MSG_SENDINGOPT_S *pSendOpt);
+               MSG_ERROR_T addSyncMLMessage(const MSG_SYNCML_MESSAGE_S *pSyncMLMsg);
+               MSG_ERROR_T updateMessage(const MSG_MESSAGE_S *pMsg, const MSG_SENDINGOPT_S *pSendOpt);
+               MSG_ERROR_T updateReadStatus(MSG_MESSAGE_ID_T MsgId, bool bRead);
+               MSG_ERROR_T updateProtectedStatus(MSG_MESSAGE_ID_T MsgId, bool bProtected);
+               MSG_ERROR_T deleteMessage(MSG_MESSAGE_ID_T MsgId);
+               MSG_ERROR_T deleteAllMessagesInFolder(MSG_FOLDER_ID_T FolderId, bool bOnlyDB);
+               MSG_ERROR_T moveMessageToFolder(MSG_MESSAGE_ID_T MsgId, MSG_FOLDER_ID_T DestFolderId);
+               MSG_ERROR_T moveMessageToStorage(MSG_MESSAGE_ID_T MsgId, MSG_STORAGE_ID_T DestStorageId);
+               MSG_ERROR_T countMessage(MSG_FOLDER_ID_T FolderId, MSG_COUNT_INFO_S *pCountInfo);
+               MSG_ERROR_T countMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCount);
+               MSG_ERROR_T countMsgByContact(const MSG_THREAD_LIST_INDEX_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pMsgThreadCountList);
+               MSG_ERROR_T getMessage(MSG_MESSAGE_ID_T MsgId, MSG_MESSAGE_S *pMsg, MSG_SENDINGOPT_S *pSendOpt);
+               MSG_ERROR_T getFolderViewList(MSG_FOLDER_ID_T FolderId, const MSG_SORT_RULE_S *pSortRule, MSG_LIST_S *pMsgFolderViewList);
+               MSG_ERROR_T addFolder(const MSG_FOLDER_INFO_S *pFolderInfo);
+               MSG_ERROR_T updateFolder(const MSG_FOLDER_INFO_S *pFolderInfo);
+               MSG_ERROR_T deleteFolder(MSG_FOLDER_ID_T FolderId);
+               MSG_ERROR_T getFolderList(MSG_FOLDER_LIST_S *pFolderList);
+
+               MSG_ERROR_T getThreadViewList(const MSG_SORT_RULE_S *pSortRule, MSG_THREAD_VIEW_LIST_S *pThreadViewList);
+               MSG_ERROR_T getConversationViewList(MSG_THREAD_ID_T ThreadId, MSG_LIST_S *pConvViewList);
+               MSG_ERROR_T deleteThreadMessageList(MSG_THREAD_ID_T thread_id);
+               MSG_ERROR_T getQuickPanelData(MSG_QUICKPANEL_TYPE_T Type, MSG_MESSAGE_S *pMsg);
+               MSG_ERROR_T resetDatabase();
+               MSG_ERROR_T getMemSize(unsigned int* memsize);
+
+               // Setting
+               MSG_ERROR_T setConfig(const MSG_SETTING_S *pSetting);
+               MSG_ERROR_T getConfig(MSG_SETTING_S *pSetting);
+
+               // ETC
+               MSG_ERROR_T searchMessage(const char *pSearchString, MSG_THREAD_VIEW_LIST_S *pThreadViewList);
+               MSG_ERROR_T searchMessage(const MSG_SEARCH_CONDITION_S *pSearchCon, int offset, int limit, MSG_LIST_S *pMsgList);
+               MSG_ERROR_T getMsgIdList(MSG_REFERENCE_ID_T RefId, MSG_MSGID_LIST_S *pMsgIdList);
+               MSG_ERROR_T getRejectMsgList(const char *pNumber, MSG_REJECT_MSG_LIST_S *pRejectMsgList);
+               MSG_ERROR_T regStorageChangeCallback(msg_storage_change_cb onStorageChange, void *pUserParam);
+               MSG_ERROR_T getReportStatus(MSG_MESSAGE_ID_T msg_id, MSG_REPORT_STATUS_INFO_S *pReport_status);
+
+               void convertMsgStruct(const MSG_MESSAGE_INFO_S *pSource, MSG_MESSAGE_S *pDest);
+               void convertSendOptStruct(const MSG_SENDINGOPT_INFO_S* pSrc, MSG_SENDINGOPT_S* pDest, MSG_MESSAGE_TYPE_S msgType);
+
+       private:
+               void connectSocket();
+               void    disconnectSocket();
+               void write(const char *pCmd, int CmdSize, char **ppEvent);
+               void read(char **ppEvent);
+               void generateConnectionId(char *ConnectionId);
+               void convertMsgStruct(const MSG_MESSAGE_S *pSource, MSG_MESSAGE_INFO_S *pDest);
+               void convertSendOptStruct(const MSG_SENDINGOPT_S* pSrc, MSG_SENDINGOPT_INFO_S* pDest, MSG_MESSAGE_TYPE_S msgType);
+               int getSettingCmdSize(MSG_OPTION_TYPE_T optionType);
+
+               char            mConnectionId[20];
+               short   mCounter;
+
+               char                            mCookie[MAX_COOKIE_LEN];
+
+               MsgIpcClientSocket      mClientSock;
+};
+
+#endif // MSG_HANDLE_H
+
diff --git a/include/proxy/MsgProxyListener.h b/include/proxy/MsgProxyListener.h
new file mode 100755 (executable)
index 0000000..15a1ff5
--- /dev/null
@@ -0,0 +1,150 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef __MSG_PROXY_LISTENER_H__
+#define __MSG_PROXY_LISTENER_H__
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgIpcSocket.h"
+#include "MsgTypes.h"
+#include "MsgMutex.h"
+#include "MsgHandle.h"
+
+#include <map>
+#include <list>
+#include <glib.h>
+
+
+/*==================================================================================================
+                                         VARIABLES
+==================================================================================================*/
+typedef struct
+{
+       MsgHandle* hAddr;
+       msg_sent_status_cb pfSentStatusCB;
+       void* userParam;
+} MSG_SENT_STATUS_CB_ITEM_S;
+
+typedef struct
+{
+       MsgHandle* hAddr;
+       msg_sms_incoming_cb pfIncomingCB;
+       int port;
+       void* userParam;
+} MSG_INCOMING_CB_ITEM_S;
+
+typedef struct
+{
+       MsgHandle* hAddr;
+       msg_mms_conf_msg_incoming_cb pfMMSConfIncomingCB;
+       char appId[MAX_MMS_JAVA_APPID_LEN+1];
+       void* userParam;
+} MSG_MMS_CONF_INCOMING_CB_ITEM_S;
+
+typedef struct
+{
+       MsgHandle* hAddr;
+       msg_syncml_msg_incoming_cb pfSyncMLIncomingCB;
+       void* userParam;
+} MSG_SYNCML_INCOMING_CB_ITEM_S;
+
+typedef struct
+{
+       MsgHandle* hAddr;
+       msg_lbs_msg_incoming_cb pfLBSMsgIncoming;
+       void* userParam;
+} MSG_LBS_INCOMING_CB_ITEM_S;
+
+typedef struct
+{
+       MsgHandle* hAddr;
+       msg_syncml_msg_operation_cb pfSyncMLOperationCB;
+       void* userParam;
+} MSG_SYNCML_OPERATION_CB_ITEM_S;
+
+typedef struct
+{
+       MsgHandle* hAddr;
+       msg_storage_change_cb pfStorageChangeCB;
+       void* userParam;
+} MSG_STORAGE_CHANGE_CB_ITEM_S;
+
+
+typedef std::list<MSG_SENT_STATUS_CB_ITEM_S> MsgSentStatusCBList;
+typedef std::list<MSG_INCOMING_CB_ITEM_S> MsgNewMessageCBList;
+typedef std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S> MsgNewMMSConfMessageCBList;
+typedef std::list<MSG_SYNCML_INCOMING_CB_ITEM_S> MsgNewSyncMLMessageCBList;
+typedef std::list<MSG_LBS_INCOMING_CB_ITEM_S> MsgNewLBSMessageCBList;
+typedef std::list<MSG_SYNCML_OPERATION_CB_ITEM_S> MsgOperationSyncMLMessageCBList;
+typedef std::list<MSG_STORAGE_CHANGE_CB_ITEM_S> MsgStorageChangeCBList;
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class MsgProxyListener
+{
+public:
+       static MsgProxyListener* instance();
+
+       void start();
+       void stop();
+
+       bool regSentStatusEventCB(MsgHandle* pMsgHandle, msg_sent_status_cb pfSentStatus, void *pUserParam);
+       bool regMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_sms_incoming_cb pfNewMessage, int port, void *pUserParam);
+       bool regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_mms_conf_msg_incoming_cb pfNewMMSConfMessage, const char *pAppId, void *pUserParam);
+       bool regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_incoming_cb pfNewSyncMLMessage, void *pUserParam);
+       bool regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_lbs_msg_incoming_cb pfNewLBSMsgIncoming, void *pUserParam);
+       bool regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_operation_cb pfSyncMLMessageOperation, void *pUserParam);
+       bool regStorageChangeEventCB(MsgHandle* pMsgHandle, msg_storage_change_cb pfStorageChangeOperation, void *pUserParam);
+
+       void clearListOfClosedHandle(MsgHandle* pMsgHandle);
+
+       void handleEvent(const MSG_EVENT_S* ptr);
+
+       int getRemoteFd();
+       int readFromSocket(char** buf, int* len);
+
+private:
+       MsgProxyListener();
+       ~MsgProxyListener();
+
+       static MsgProxyListener* pInstance;
+
+       unsigned int running;
+
+       MsgIpcClientSocket cliSock;
+
+       Mutex mx;
+       CndVar cv;
+
+       MsgSentStatusCBList sentStatusCBList;
+       MsgNewMessageCBList newMessageCBList;
+       MsgNewMMSConfMessageCBList newMMSConfMessageCBList;
+       MsgNewSyncMLMessageCBList newSyncMLMessageCBList;
+       MsgNewLBSMessageCBList newLBSMessageCBList;
+       MsgOperationSyncMLMessageCBList operationSyncMLMessageCBList;
+       MsgStorageChangeCBList storageChangeCBList;
+
+       GIOChannel *channel;
+       guint eventSourceId;
+};
+
+#endif // __MSG_PROXY_LISTENER_H__
+
diff --git a/include/utils/MsgContact.h b/include/utils/MsgContact.h
new file mode 100755 (executable)
index 0000000..8a55347
--- /dev/null
@@ -0,0 +1,52 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_CONTACT_H
+#define MSG_CONTACT_H
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgStorageTypes.h"
+#include "MsgInternalTypes.h"
+
+
+typedef void (*MsgContactChangeCB)();
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+MSG_ERROR_T MsgOpenContactSvc();
+MSG_ERROR_T MsgCloseContactSvc();
+
+MSG_ERROR_T MsgInitContactSvc(MsgContactChangeCB cb);
+
+MSG_ERROR_T MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_INFO_S *pContactInfo);
+
+void MsgSyncContact();
+
+bool MsgInsertContact(MSG_CONTACT_INFO_S *pContactInfo, const char *pNumber);
+bool MsgUpdateContact(int index, int type);
+bool MsgDeleteContact(int index);
+
+int MsgGetContactNameOrder();
+
+int MsgContactSVCBeginTrans();
+int MsgContactSVCEndTrans(bool bSuccess);
+
+
+#endif //MSG_CONTACT_H
+
diff --git a/include/utils/MsgDebug.h b/include/utils/MsgDebug.h
new file mode 100755 (executable)
index 0000000..ee52510
--- /dev/null
@@ -0,0 +1,172 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef __MSG_DEBUG_H__
+#define __MSG_DEBUG_H__
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/time.h>
+#include <time.h>
+
+#include "MsgTypes.h"
+#include "MsgCmdTypes.h"
+
+extern "C"{
+       #include <dlog.h>
+};
+
+
+/*==================================================================================================
+                                    DEFINES
+==================================================================================================*/
+#define USER_TAG "MSG_FW"
+
+//#define DLOG_ENABLE
+//#define LOG_ENABLE
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+int get_tid();
+
+
+#if defined(DLOG_ENABLE)
+
+#define MSG_FATAL(fmt, ...) \
+       do \
+       {\
+               SLOG(LOG_ERROR, USER_TAG, "[%s: %s(): %d] ERROR << " fmt " >>\n\n", rindex(__FILE__, '/')+1,  __FUNCTION__, __LINE__, ##__VA_ARGS__);\
+       } while (0)
+
+#define MSG_DEBUG(fmt, ...)\
+       do\
+       {\
+               SLOG(LOG_DEBUG, USER_TAG, "[%s: %s(): %d] " fmt"\n\n", rindex(__FILE__, '/')+1,  __FUNCTION__, __LINE__, ##__VA_ARGS__);\
+       } while (0)
+
+#define MSG_BEGIN() \
+       do\
+    {\
+               SLOG(LOG_DEBUG, USER_TAG, "[%s: %s(): %d] BEGIN >>>> \n\n", rindex(__FILE__, '/')+1,  __FUNCTION__, __LINE__ );\
+    } while( 0 )
+
+#define MSG_END() \
+       do\
+    {\
+               SLOG(LOG_DEBUG, USER_TAG, "[%s: %s(): %d] END   <<<<  \n\n", rindex(__FILE__, '/')+1,  __FUNCTION__, __LINE__ );\
+    } \
+    while( 0 )
+
+#define MSG_PROFILE_BEGIN(pfid) \
+       unsigned int __prf_l1_##pfid = __LINE__;    \
+       struct timeval __prf_1_##pfid;              \
+       struct timeval __prf_2_##pfid;              \
+       do {                                        \
+               gettimeofday(&__prf_1_##pfid, 0);       \
+       } while (0)
+
+#define MSG_PROFILE_END(pfid) \
+       unsigned int __prf_l2_##pfid = __LINE__;\
+       do { \
+               gettimeofday(&__prf_2_##pfid, 0);\
+               long __ds = __prf_2_##pfid.tv_sec - __prf_1_##pfid.tv_sec;\
+               long __dm = __prf_2_##pfid.tv_usec - __prf_1_##pfid.tv_usec;\
+               if ( __dm < 0 ) { __ds--; __dm = 1000000 + __dm; } \
+               SLOG(LOG_DEBUG, USER_TAG, "**PROFILE** [MSGFW: %s: %s() %u ~ %u] " #pfid                            \
+               " -> Elapsed Time: %u.%06u seconds\n",                    \
+               rindex(__FILE__, '/')+1,                \
+               __FUNCTION__, \
+               __prf_l1_##pfid,                                         \
+               __prf_l2_##pfid,                                         \
+               (unsigned int)(__ds),                                    \
+               (unsigned int)(__dm));                                   \
+       } while (0)
+
+#elif defined(LOG_ENABLE)
+
+#define MSG_FATAL(fmt, ...) \
+       do \
+       {\
+               printf("\n[%d] [MSGFW: %s: %s(): %d] *FAILED* << " fmt" >>\n", get_tid(), rindex(__FILE__, '/')+1,  __FUNCTION__, __LINE__,  ##__VA_ARGS__);\
+       } while (0)
+
+#define MSG_DEBUG(fmt, ...) \
+       do\
+       {\
+               printf("\n[%d] [MSGFW: %s: %s(): %d] " fmt"\n", get_tid(), rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__);\
+       } while (0)
+
+#define MSG_BEGIN() \
+       do\
+    {\
+        printf("\n[%d] BEGIN >>>> %s() at [MSGFW: %s: %d]\n", get_tid(),__FUNCTION__, rindex(__FILE__, '/')+1,  __LINE__ );\
+    } while( 0 )
+
+#define MSG_END() \
+       do\
+    {\
+        printf("\n[%d] END   <<<< %s() at [MSGFW: %s: %d]\n", get_tid(), __FUNCTION__, rindex(__FILE__, '/')+1,  __LINE__); \
+    } \
+    while( 0 )
+
+#define MSG_PROFILE_BEGIN(pfid) \
+       unsigned int __prf_l1_##pfid = __LINE__;    \
+       struct timeval __prf_1_##pfid;              \
+       struct timeval __prf_2_##pfid;              \
+       do {                                        \
+               gettimeofday(&__prf_1_##pfid, 0);       \
+       } while (0)
+
+#define MSG_PROFILE_END(pfid) \
+       unsigned int __prf_l2_##pfid = __LINE__;\
+       do { \
+               gettimeofday(&__prf_2_##pfid, 0);\
+               long __ds = __prf_2_##pfid.tv_sec - __prf_1_##pfid.tv_sec;\
+               long __dm = __prf_2_##pfid.tv_usec - __prf_1_##pfid.tv_usec;\
+               if ( __dm < 0 ) { __ds--; __dm = 1000000 + __dm; } \
+               printf("**PROFILE** [MSGFW: %s: %s() %u ~ %u] " #pfid                            \
+               " -> Elapsed Time: %u.%06u seconds\n",                    \
+               rindex(__FILE__, '/')+1,                \
+               __FUNCTION__, \
+               __prf_l1_##pfid,                                         \
+               __prf_l2_##pfid,                                         \
+               (unsigned int)(__ds),                                    \
+               (unsigned int)(__dm));                                   \
+       } while (0)
+
+#else
+
+#define MSG_FATAL(fmt, ...)
+#define MSG_DEBUG(fmt, ...)
+#define MSG_BEGIN()
+#define MSG_END()
+
+#define MSG_PROFILE_BEGIN(pfid)
+#define MSG_PROFILE_END(pfid)
+
+#endif
+
+const char * MsgDbgCmdStr(MSG_CMD_TYPE_T cmdType);
+const char * MsgDbgEvtStr(MSG_EVENT_TYPE_T evtType);
+
+#endif //__MSG_DEBUG_H__
+
diff --git a/include/utils/MsgDrmWrapper.h b/include/utils/MsgDrmWrapper.h
new file mode 100755 (executable)
index 0000000..02c3ae4
--- /dev/null
@@ -0,0 +1,50 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef __MSG_DRM_WRAPPER_H_
+#define __MSG_DRM_WRAPPER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+       MSG_MODE_FILE,
+       MSG_MODE_STREAM
+} MSG_DRM_OPENMODE;
+
+typedef        enum {
+       MSG_DRM_NONE = 0,
+       MSG_DRM_FORWARD_LOCK,
+       MSG_DRM_COMBINED_DELIVERY,
+       MSG_DRM_SEPARATE_DELIVERY
+} MSG_DRM_TYPE;
+
+
+bool MsgDrmRegisterFile(MSG_DRM_OPENMODE eMode, char *pBuffer, int nSize);
+bool MsgDrmUnregisterFile(char *szFilename);
+bool MsgDrmIsDrmFile(const char *szFilePath);
+bool MsgDrmGetMimeTypeEx(const char *szFileName, char *szMimeType, int nMimeTypeLen);
+bool MsgDrmGetContentID(const char *szFileName, char *szContentID, int nContentIDLen);
+bool MsgDrmGetDrmType(const char *szFileName, MSG_DRM_TYPE *eDRMType);
+bool MsgDrmConvertDmtoDcfType(char *inputFile, char *outputFile);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/include/utils/MsgException.h b/include/utils/MsgException.h
new file mode 100755 (executable)
index 0000000..7f6c1f0
--- /dev/null
@@ -0,0 +1,85 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_EXCEPTION_H
+#define MSG_EXCEPTION_H
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <stdexcept>
+#include <string>
+
+using namespace std;
+
+
+/*==================================================================================================
+                                         DEFINES
+==================================================================================================*/
+#define THROW(errCode, debugFmt,...) \
+do {\
+       char __debugBuf[256];\
+       snprintf(__debugBuf, 256, debugFmt, ##__VA_ARGS__);\
+       MsgException e(errCode, __debugBuf);\
+       MSG_FATAL("%s [%d]", e.what(), e.errorCode());\
+    throw e; \
+} while(0)
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class MsgException : public runtime_error //public exception
+{
+public:
+       MsgException(int errCode, const string& msg = "")
+           : runtime_error( errorStrings[errCode] + " : " +  msg), eCode(errCode)
+       {}
+
+       enum
+       {
+               SUCCESS = 0,
+
+               INVALID_PARAM,
+               INVALID_RESULT,
+               SELECT_ERROR,
+               IPC_ERROR,
+               OUT_OF_RANGE = 5,
+
+               SMS_PLG_ERROR,
+               MMS_PLG_ERROR,
+               PLUGIN_ERROR,
+               SENT_STATUS_ERROR,
+               INCOMING_MSG_ERROR = 10,
+
+               FILE_ERROR,
+               SECURITY_ERROR,
+               SERVER_READY_ERROR = 13,
+
+               // dont erase NUM_ERRORS. place a new error code in ahead of NUM_ERRORS
+               NUM_ERRORS
+       };
+
+       int errorCode() { return eCode; }
+
+private:
+       static string errorStrings[NUM_ERRORS];
+       int eCode;
+};
+
+#endif //#ifndef __MSG_EXCEPTION_H__
+
+
diff --git a/include/utils/MsgGconfWrapper.h b/include/utils/MsgGconfWrapper.h
new file mode 100755 (executable)
index 0000000..eb7e6d6
--- /dev/null
@@ -0,0 +1,58 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_GCONF_WRAPPER_H
+#define MSG_GCONF_WRAPPER_H
+
+//#define USE_GCONF
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgInternalTypes.h"
+
+#ifdef USE_GCONF
+#include <gconf/gconf-client.h>
+#include <glib.h>
+#else
+#include <vconf.h>
+#endif
+
+/*==================================================================================================
+                                         STRUCTURES
+==================================================================================================*/
+#ifdef USE_GCONF
+typedef struct _MSG_GOBJECT_CLIENT_S
+{
+       GObject* object;
+}MSG_GOBJECT_CLIENT_S;
+#endif
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+MSG_ERROR_T    MsgSettingSetString(const char *pKey, const char *pSetValue);
+MSG_ERROR_T    MsgSettingSetInt(const char *pKey, int nSetValue);
+MSG_ERROR_T    MsgSettingSetBool(const char *pKey, bool bSetValue);
+
+char*                  MsgSettingGetString(const char *pKey);
+int                            MsgSettingGetInt(const char *pKey);
+int                            MsgSettingGetBool(const char *pKey, bool *pVal);
+
+MSG_ERROR_T    MsgSettingHandleNewMsg(int SmsCnt, int MmsCnt);
+MSG_ERROR_T    MsgSettingSetIndicator(int SmsCnt, int MmsCnt);
+
+#endif // MSG_GCONF_WRAPPER_H
diff --git a/include/utils/MsgIpcSocket.h b/include/utils/MsgIpcSocket.h
new file mode 100755 (executable)
index 0000000..ca15b42
--- /dev/null
@@ -0,0 +1,116 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef __IPCSocket_H__
+#define __IPCSocket_H__
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <sys/types.h>
+#include <map>
+
+#include "MsgTypes.h"
+#include "MsgCppTypes.h"
+
+
+/*==================================================================================================
+                                         DEFINES
+==================================================================================================*/
+#define MSG_MAX_IPC_SIZE 50000 // 50 * 1000 = sizeof(msg common info) * max message count
+#define MAX_NUM_IPC_CLIENT 10
+
+#define MSG_SOCKET_PATH "/tmp/.msgfw_socket"
+
+#define CUSTOM_SOCKET_ERROR            -1
+#define CUSTOM_SOCKET_BACKLOG  10
+
+
+/*==================================================================================================
+                                         ENUM
+==================================================================================================*/
+typedef enum
+{
+       CLOSE_CONNECTION_BY_SIGNAL = 0,
+       CLOSE_CONNECTION_BY_USER = -17,
+} IPC_CONTROL_E;
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class MsgIpcClientSocket
+{
+public:
+       MsgIpcClientSocket();
+//     ~MsgIpcClientSocket();
+
+       int     maxFd() { return (maxfd+1); }
+       fd_set  fdSet() { return fds; }
+       int     fd() { return sockfd; }
+
+       MSG_ERROR_T connect(const char *path);
+       MSG_ERROR_T close();
+       /* write msg to ipc server */
+       int     write(const char* buf, int len);
+       /* read msg from ipc server */
+       int     read(char** buf, int* len);
+       void    addfd(int fd);
+       int             getRemoteFd() {return remotefd; }
+private:
+       int readn(char *buf, int len );
+       int writen (const char *buf, int len);
+
+       int sockfd, remotefd, maxfd;
+       fd_set fds;
+};
+
+
+class MsgIpcServerSocket
+{
+public:
+       MsgIpcServerSocket();
+       ~MsgIpcServerSocket() { mapFds.clear(); }
+       int     maxFd() { return (maxfd+1); }
+       fd_set  fdSet() { return fds; }
+       int     fd() { return sockfd; }
+
+       MSG_ERROR_T open(const char *path);
+       MSG_ERROR_T accept();
+       void            close(int fd);
+
+       /* read msg from client of fd */
+       int     read(int fd, char** buf, int* len );
+       /* write msg to ipc client */
+       int     write(int fd, const char* buf, int len);
+       void    addfd(int fd);
+       void    setSockfd(int fd) { sockfd = fd; }
+
+private:
+       int readn(int fd, char *buf, int len );
+       int writen (int fd, const char *buf, int len);
+
+       /* server socket fd */
+       int sockfd;
+
+       /* information about IPC clients, it is used for select() */
+       fd_set                          fds;
+       int                             maxfd;
+       std::map<int, int>      mapFds;
+};
+
+#endif //__IPCSocket_H__
+
diff --git a/include/utils/MsgMemory.h b/include/utils/MsgMemory.h
new file mode 100755 (executable)
index 0000000..0c07f8c
--- /dev/null
@@ -0,0 +1,76 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef __MSG_MEMORY_H__
+#define __MSG_MEMORY_H__
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <stdio.h>
+#include <string.h>
+#include <sys/mman.h>
+
+
+/*==================================================================================================
+                                       DEFINES
+==================================================================================================*/
+#define GETSP() ({ unsigned int sp; asm volatile ("mov %0,sp " : "=r"(sp) ); sp;})
+#define BUF_SIZE                               256
+#define PAGE_SIZE                      (1 << 12)
+#define _ALIGN_UP(addr,size)    (((addr)+((size)-1))&(~((size)-1)))
+#define _ALIGN_DOWN(addr,size)  ((addr)&(~((size)-1)))
+#define PAGE_ALIGN(addr)        _ALIGN_DOWN(addr, PAGE_SIZE)
+
+
+/*==================================================================================================
+                                       FUNCTION PROTOTYPES
+==================================================================================================*/
+static inline void
+stack_trim(void)
+{
+       unsigned int sp;
+       char buf[BUF_SIZE];
+       FILE* file;
+       unsigned int stacktop;
+       int found = 0;
+
+       sp = GETSP();
+
+       snprintf(buf, BUF_SIZE, "/proc/%d/maps",getpid());
+       file = fopen(buf,"r");
+       while(fgets(buf, BUF_SIZE, file) != NULL) {
+               if(strstr(buf, "[stack]")){
+                       found = 1;
+                       break;
+               }
+       }
+       fclose(file);
+
+       if(found) {
+               sscanf(buf,"%x-",&stacktop);
+               if(madvise((void*)PAGE_ALIGN(stacktop), PAGE_ALIGN(sp)-stacktop, MADV_DONTNEED) < 0)
+                       perror("stack madvise fail");
+       }
+}
+
+
+void MsgReleaseMemory();
+
+
+#endif // __MSG_MEMORY_H__
+
diff --git a/include/utils/MsgMmsMessage.h b/include/utils/MsgMmsMessage.h
new file mode 100755 (executable)
index 0000000..9a323da
--- /dev/null
@@ -0,0 +1,60 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_MMS_MESSAGE_H
+#define MSG_MMS_MESSAGE_H
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgTypes.h"
+#include "MsgMmsTypes.h"
+
+int msg_verify_number(const char *raw, char *trimmed);
+int msg_verify_email(const char *raw);
+MSG_ERROR_T _MsgMmsAddPage(MMS_MESSAGE_DATA_S *pMsgData, MMS_PAGE_S *pPage);
+MSG_ERROR_T _MsgMmsAddMedia(MMS_PAGE_S *pPage, MMS_MEDIA_S *pMedia);
+MSG_ERROR_T _MsgMmsAddSmilDoc(char *pSmil, MMS_MESSAGE_DATA_S *pMsgData);
+MSG_ERROR_T _MsgMmsAddAttachment(MMS_MESSAGE_DATA_S *pMsgData, MMS_ATTACH_S *pMedia);
+MSG_ERROR_T _MsgMmsAddRegion(MMS_MESSAGE_DATA_S *pMsgData, MMS_SMIL_REGION * pRegion);
+MSG_ERROR_T _MsgMmsAddTransition(MMS_MESSAGE_DATA_S *pMsgData, MMS_SMIL_TRANSITION *pTransition);
+MSG_ERROR_T _MsgMmsAddMeta(MMS_MESSAGE_DATA_S *pMsgData, MMS_SMIL_META *pMeta);
+
+bool _MsgMmsFindMatchedMedia(MMS_MESSAGE_DATA_S *pMsgData, char *pszFilePath);
+
+MMS_PAGE_S *_MsgMmsGetPage(MMS_MESSAGE_DATA_S *pMsgData, int pageIdx);
+MMS_SMIL_REGION *_MsgMmsGetSmilRegion(MMS_MESSAGE_DATA_S *pMsgData, int regionIdx);
+MMS_MEDIA_S *_MsgMmsGetMedia(MMS_PAGE_S *pPage, int mediaIdx);
+MMS_ATTACH_S *_MsgMmsGetAttachment(MMS_MESSAGE_DATA_S *pMsgData, int attachIdx);
+MMS_SMIL_TRANSITION *_MsgMmsGetTransition(MMS_MESSAGE_DATA_S *pMsgData, int transitionIdx);
+MMS_SMIL_META *_MsgMmsGetMeta(MMS_MESSAGE_DATA_S *pMsgData, int metaIdx);
+int    _MsgMmsGetPageCount(MMS_MESSAGE_DATA_S *pMsgData);
+int _MsgMmsGetAttachCount(MMS_MESSAGE_DATA_S *pMsgData);
+int _MsgMmsGetTransitionCount(MMS_MESSAGE_DATA_S *pMsgData);
+int _MsgMmsGetMetaCount(MMS_MESSAGE_DATA_S *pMsgData);
+
+MSG_ERROR_T _MsgMmsReleasePageList(MMS_MESSAGE_DATA_S *pMsgData);
+MSG_ERROR_T _MsgMmsReleaseRegionList(MMS_MESSAGE_DATA_S *pMsgData);
+MSG_ERROR_T    _MsgMmsReleaseAttachList(MMS_MESSAGE_DATA_S *pMsgData);
+MSG_ERROR_T _MsgMmsReleaseMetaList(MMS_MESSAGE_DATA_S *pMsgData);
+MSG_ERROR_T _MsgMmsReleaseTransitionList(MMS_MESSAGE_DATA_S *pMsgData);
+
+char *_MsgMmsSerializeMessageData(const MMS_MESSAGE_DATA_S *pMsgData, unsigned int *pSize);
+bool _MsgMmsDeserializeMessageData(MMS_MESSAGE_DATA_S *pBody, char *pFileData);
+bool _MsgMmsSetRootLayout(MMS_MESSAGE_DATA_S *pMmsMsg, MMS_SMIL_ROOTLAYOUT *pRootlayout);
+
+
+#endif // MSG_MMS_MESSAGE_H
diff --git a/include/utils/MsgMutex.h b/include/utils/MsgMutex.h
new file mode 100755 (executable)
index 0000000..fd20d54
--- /dev/null
@@ -0,0 +1,86 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef __MSG_MUTEX_H__
+#define __MSG_MUTEX_H__
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <iostream>
+#include <pthread.h>
+#include <sys/time.h>
+#include <time.h>
+
+using namespace std;
+
+int GetMsgReady();
+void WaitMsgReady(int sec);
+
+class Mutex
+{
+public:
+       Mutex(){ pthread_mutex_init(&m, 0); }
+       void lock(){ pthread_mutex_lock(&m); }
+       void unlock(){ pthread_mutex_unlock(&m); }
+       pthread_mutex_t* pMutex() { return &m; }
+
+private:
+       pthread_mutex_t m;
+};
+
+class MutexLocker
+{
+public:
+       MutexLocker(Mutex& mx)
+       {
+               pm = &mx;
+               pm->lock();
+       }
+
+       ~MutexLocker()
+       {
+               pm->unlock();
+       }
+
+private:
+       Mutex *pm;
+};
+
+class CndVar
+{
+public:
+       CndVar(){ pthread_cond_init(&c, 0); }
+       void wait(pthread_mutex_t* m) { pthread_cond_wait(&c, m); }
+       int timedwait(pthread_mutex_t* m, int sec)
+       {
+               struct timeval now = {0};
+               struct timespec timeout = {0};
+               gettimeofday(&now, NULL);
+               timeout.tv_sec = now.tv_sec+sec;
+               timeout.tv_nsec = now.tv_usec;
+               int retcode = pthread_cond_timedwait(&c, m, &timeout);
+               return retcode;
+       }
+       void signal(){ pthread_cond_signal(&c); }
+       void broadcast(){ pthread_cond_broadcast(&c); }
+
+private:
+       pthread_cond_t c;
+};
+
+#endif //__MUTEX_H__
+
diff --git a/include/utils/MsgNotificationWrapper.h b/include/utils/MsgNotificationWrapper.h
new file mode 100755 (executable)
index 0000000..232cfc3
--- /dev/null
@@ -0,0 +1,60 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_QUICKPANEL_WRAPPER_H
+#define MSG_QUICKPANEL_WRAPPER_H
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgInternalTypes.h"
+#include "MsgSqliteWrapper.h"
+
+
+/*==================================================================================================
+                                         DEFINES
+==================================================================================================*/
+#define NORMAL_MSG_ICON_PATH   "/opt/apps/org.tizen.message/res/icons/default/small/org.tizen.message.png"
+#define VOICE_MSG_ICON_PATH    "/opt/apps/org.tizen.message/res/icons/default/small/org.tizen.message.voice.png"
+#define CB_MSG_ICON_PATH               "/opt/apps/org.tizen.message/res/icons/default/small/org.tizen.message.cb.png"
+#define NOTI_MSG_ICON_PATH             "/opt/apps/org.tizen.message/res/icons/default/small/org.tizen.message.noti.png"
+
+#define MSG_APP_PACKAGE_NAME "message"
+#define MSG_APP_LOCALEDIR              "/opt/apps/org.tizen.message/res/locale"
+
+#define SENDING_MULTIMEDIA_MESSAGE_FAILED "IDS_MSGF_POP_SENDING_MULTIMEDIA_MESSAGE_FAILED"
+#define MULTIMEDIA_MESSAGE_SENT                   "IDS_MSGF_POP_MULTIMEDIA_MESSAGE_SENT"
+#define RETRIEVING_MESSAGE_FAILED                 "IDS_MSGF_POP_RETRIEVING_MESSAGE_FAILED"
+#define MESSAGE_RETRIEVED                               "IDS_MSGF_BODY_MESSAGE_RETRIEVED"
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+
+MSG_ERROR_T MsgInsertNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg);
+
+MSG_ERROR_T MsgInsertSmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_ID_T MsgId, MSG_DELIVERY_REPORT_STATUS_T Status);
+
+MSG_ERROR_T MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg);
+
+MSG_ERROR_T MsgDeleteNotiByMsgId(MSG_MESSAGE_ID_T msgId);
+
+MSG_ERROR_T MsgDeleteNotiByThreadId(MSG_THREAD_ID_T ThreadId);
+
+MSG_ERROR_T MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg);
+
+#endif // MSG_QUICKPANEL_WRAPPER_H
diff --git a/include/utils/MsgSoundPlayer.h b/include/utils/MsgSoundPlayer.h
new file mode 100755 (executable)
index 0000000..1d81379
--- /dev/null
@@ -0,0 +1,32 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_SOUND_PLAYER_H
+#define MSG_SOUND_PLAYER_H
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+void MsgSoundPlayStart();
+void MsgSoundPlayStop();
+
+bool MsgSoundSetRepeatAlarm();
+bool MsgSoundCreateRepeatAlarm(int RepeatTime);
+int MsgSoundRepeatAlarmCB(int TimerId, void *pUserParam);
+int MsgSoundGetUnreadMsgCnt();
+
+#endif // MSG_SOUND_PLAYER_H
+
diff --git a/include/utils/MsgSqliteWrapper.h b/include/utils/MsgSqliteWrapper.h
new file mode 100755 (executable)
index 0000000..9cc59a5
--- /dev/null
@@ -0,0 +1,93 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_SQLITE_WRAPPER_H
+#define MSG_SQLITE_WRAPPER_H
+
+/*==================================================================================================
+                                    INCLUDE FILES
+==================================================================================================*/
+#include "MsgTypes.h"
+
+
+/*==================================================================================================
+                                    DEFINES
+==================================================================================================*/
+#define MSGFW_DB_NAME                  "/opt/dbspace/.msg_service.db"
+
+#define MSGFW_MESSAGE_TABLE_NAME               "MSG_MESSAGE_TABLE"
+#define MSGFW_FOLDER_TABLE_NAME                        "MSG_FOLDER_TABLE"
+#define MSGFW_ADDRESS_TABLE_NAME               "MSG_ADDRESS_TABLE"
+#define MSGFW_SIM_MSG_TABLE_NAME               "MSG_SIM_TABLE"
+#define MSGFW_FILTER_TABLE_NAME                        "MSG_FILTER_TABLE"
+#define MSGFW_PUSH_MSG_TABLE_NAME              "MSG_PUSH_TABLE"
+#define MSGFW_CB_MSG_TABLE_NAME                        "MSG_CBMSG_TABLE"
+#define MMS_PLUGIN_MESSAGE_TABLE_NAME          "MSG_MMS_MESSAGE_TABLE"
+#define MMS_PLUGIN_ATTRIBUTE_TABLE_NAME        "MSG_MMS_ATTR_TABLE"
+#define MSGFW_SYNCML_MSG_TABLE_NAME            "MSG_SYNCML_TABLE"
+#define MSGFW_SCHEDULED_MSG_TABLE_NAME         "MSG_SCHEDULED_TABLE"
+#define MSGFW_SMS_SENDOPT_TABLE_NAME           "MSG_SMS_SENDOPT_TABLE"
+#define MSGFW_REPORT_TABLE_NAME                        "MSG_REPORT_TABLE"
+
+#define MAX_QUERY_LEN                                  3072
+#define MAX_FOLDER_NAME_LEN                    20
+#define MAX_ACCOUNT_NAME_LEN                   51
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+void   MsgReleaseMemoryDB();
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class MsgDbHandler
+{
+public:
+       MsgDbHandler();
+       ~MsgDbHandler();
+
+       MSG_ERROR_T connect();
+       MSG_ERROR_T disconnect();
+
+       bool checkTableExist(const char *pTableName);
+       MSG_ERROR_T execQuery(const char *pQuery);
+       MSG_ERROR_T getTable(const char *pQuery, int *pRowCnt);
+       void freeTable();
+       MSG_ERROR_T bindText(const char *pBindStr, int index);
+       MSG_ERROR_T bindBlob(const void * pBindBlob, int size, int index);
+       MSG_ERROR_T prepareQuery(const char *pQuery);
+       MSG_ERROR_T stepQuery();
+       void finalizeQuery();
+       int columnInt(int ColumnIndex);
+       const unsigned char* columnText(int ColumnIndex);
+       const void* columnBlob(int ColumnIndex);
+       MSG_ERROR_T beginTrans();
+       MSG_ERROR_T endTrans(bool Success);
+       int getColumnToInt(int RowIndex);
+       char getColumnToChar(int RowIndex);
+       void getColumnToString(int RowIndex, int Length, char *pString);
+       MSG_ERROR_T getRowId(const char *pTableName, unsigned int *pRowId);
+
+private:
+
+
+};
+
+#endif // MSG_SQLITE_WRAPPER_H
+
diff --git a/include/utils/MsgUtilFile.h b/include/utils/MsgUtilFile.h
new file mode 100755 (executable)
index 0000000..6a5a4f2
--- /dev/null
@@ -0,0 +1,63 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_UTIL_FILE_H
+#define MSG_UTIL_FILE_H
+
+
+/*==================================================================================================
+                                       DEFINES
+==================================================================================================*/
+#define FM_READ_WRITE_BUFFER_MAX (1024*1024*3)
+
+#define TPDU_LOG_FILE "/opt/etc/msg-service/tpduLog.txt"
+
+
+/*==================================================================================================
+                                       FUNCTION PROTOTYPES
+==================================================================================================*/
+/**  file operation wrapper - for avoding runtime error */
+FILE* MsgOpenFile(const char* filepath, const char* opt);
+void MsgCloseFile(FILE* pFile);
+int MsgFseek(FILE* pFile, long int offset, int origin);
+size_t MsgWriteFile(const char* pData, size_t size, size_t count, FILE  *pFile);
+size_t MsgReadFile(void *pData, size_t size, size_t count, FILE *pFile);
+long int MsgFtell(FILE *pFile);
+int MsgFflush(FILE *pFile);
+int MsgFsync(FILE *pFile);
+
+bool MsgCreateFileName(char *pFileName);
+bool MsgOpenAndReadFile(const char *pFileName, char **ppData, int *pDataSize);
+bool MsgReadFileForDecode(FILE* pFile, char* pBuf, int length, int* nSize);
+bool   MsgWriteDataFromEncodeBuffer(FILE* pFile, char* pInBuffer, int *pPtr, int maxLen, int* pOffset );
+bool MsgWriteIpcFile(const char *pFileName, const char *pData, int DataSize);
+void MsgDeleteFile(const char *pFileName);
+bool MsgGetFileSize(const char *pFilePath, int* nSize);
+int MsgGetFileSize(const char *pFileName);
+FILE*  MsgOpenMMSFile(char *pFileName);
+bool MsgOpenCreateAndOverwriteFile(char *pFullPath, char *pBuff, int TotalLength);
+char* MsgOpenAndReadMmsFile(const char* szFilePath, int offset, int size, int* npSize );
+bool MsgWriteSmilFile(const char *pFilePath,char *pData, int DataSize);
+int    MsgReadSmilFile(const char *pFileName, char **ppData);
+void MsgDeleteSmilFile(const char *pFilePath);
+int MsgRmRf(char *pDirPath);
+unsigned int MsgDu(const char *pDirPath);
+bool MsgAppendFile(const char *pFilePath, const char *pData, int DataSize);
+void MsgMmsInitDir();
+
+
+#endif // MSG_UTIL_FILE_H
+
diff --git a/include/utils/MsgUtilFunction.h b/include/utils/MsgUtilFunction.h
new file mode 100755 (executable)
index 0000000..522a9d2
--- /dev/null
@@ -0,0 +1,101 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_UTIL_FUNCTION_H
+#define MSG_UTIL_FUNCTION_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgStorageTypes.h"
+#include "MsgSettingTypes.h"
+#include "MsgInternalTypes.h"
+#include "MsgCmdTypes.h"
+
+/*==================================================================================================
+                                       FUNCTION PROTOTYPES
+==================================================================================================*/
+
+// Encoders
+int MsgEncodeCountInfo(MSG_COUNT_INFO_S *pCountInfo, char **ppDest);
+
+int MsgEncodeCountByMsgType(int MsgCount, char **ppDest);
+
+int MsgEncodeRecipientList(MSG_RECIPIENTS_LIST_S *pRecipientList, char **ppDest);
+
+int MsgEncodeMsgId(MSG_MESSAGE_ID_T *pMsgId, char **ppDest);
+
+int MsgEncodeMsgInfo(MSG_MESSAGE_INFO_S *pMsgInfo, char **ppDest);
+
+int MsgEncodeMsgInfo(MSG_MESSAGE_INFO_S *pMsgInfo,  MSG_SENDINGOPT_INFO_S* pSendOptInfo, char **ppDest);
+
+int MsgEncodeFolderViewList(MSG_LIST_S *pFolderViewList, char **ppDest);
+
+int MsgEncodeFolderList(MSG_FOLDER_LIST_S *pFolderList, char **ppDest);
+
+int MsgEncodeSetting(MSG_SETTING_S *pSetting, char **ppDest);
+
+int MsgEncodeMsgType(MSG_MESSAGE_TYPE_S *pMsgType, char **ppDest);
+
+int MsgEncodeThreadViewList(MSG_THREAD_VIEW_LIST_S *pThreadViewList, char **ppDest);
+
+int MsgEncodeConversationViewList(MSG_LIST_S *pConvViewList, char **ppDest);
+
+int MsgEncodeMsgGetContactCount(MSG_THREAD_COUNT_INFO_S *threadCountInfo, char **ppDest);
+
+int MsgEncodeMemSize(unsigned int *memsize, char **ppDest);
+
+int MsgEncodeSyncMLOperationData(int msgId, int extId, char **ppDest);
+
+int MsgEncodeStorageChangeData(const MSG_STORAGE_CHANGE_TYPE_T storageChangeType, const MSG_MSGID_LIST_S *pMsgIdList, char **ppDest);
+
+int MsgEncodeReportStatus(MSG_REPORT_STATUS_INFO_S* pReportStatus, char **ppDest);
+
+
+// Decoders
+void MsgDecodeMsgId(char *pSrc, MSG_MESSAGE_ID_T *pMsgId);
+
+void MsgDecodeCountInfo(char *pSrc, MSG_COUNT_INFO_S *pCountInfo);
+
+void MsgDecodeMsgInfo(char *pSrc, MSG_MESSAGE_INFO_S *pMsgInfo,  MSG_SENDINGOPT_INFO_S* pSendOptInfo);
+
+void MsgDecodeFolderViewList(char *pSrc, MSG_LIST_S *pFolderViewList);
+
+void MsgDecodeRecipientList(char *pSrc, MSG_RECIPIENTS_LIST_S *pRecipientList);
+
+void MsgDecodeFolderList(char *pSrc, MSG_FOLDER_LIST_S *pFolderList);
+
+void MsgDecodeSetting(char *pSrc, MSG_SETTING_S *pSetting);
+
+void MsgDecodeMsgType(char *pSrc, MSG_MESSAGE_TYPE_S* pMsgType);
+
+void MsgDecodeThreadViewList(char *pSrc, MSG_THREAD_VIEW_LIST_S *pThreadViewList);
+
+void MsgDecodeConversationViewList(char *pSrc, MSG_LIST_S *pConvViewList);
+
+void   MsgDecodeContactCount(char *pSrc,  MSG_THREAD_COUNT_INFO_S *pMsgThreadCountList);
+
+void MsgDecodeMemSize(char *pSrc, unsigned int *memsize);
+
+void   MsgDecodeReportStatus(char *pSrc,  MSG_REPORT_STATUS_INFO_S *pReportStatus);
+
+
+// Event Encoder
+int MsgMakeEvent(const void *pData, int DataSize, MSG_EVENT_TYPE_T MsgEvent, MSG_ERROR_T MsgError, void **ppEvent);
+
+
+#endif // MSG_UTIL_FUNCTION_H
diff --git a/include/utils/MsgUtilStorage.h b/include/utils/MsgUtilStorage.h
new file mode 100755 (executable)
index 0000000..a345bc7
--- /dev/null
@@ -0,0 +1,55 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MSG_UTIL_STORAGE_H
+#define MSG_UTIL_STORAGE_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgInternalTypes.h"
+#include "MsgStorageTypes.h"
+#include "MsgSqliteWrapper.h"
+
+
+/*==================================================================================================
+                                       FUNCTION PROTOTYPES
+==================================================================================================*/
+// Common Function
+unsigned int MsgStoAddMessageTable(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsgInfo, unsigned int AddrId);
+MSG_ERROR_T MsgStoSetReadStatus(MsgDbHandler *pDbHandle, MSG_MESSAGE_ID_T MsgId, bool bRead);
+MSG_ERROR_T MsgStoGetOldestMessage(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsgInfo, MSG_MESSAGE_ID_T *pMsgId);
+MSG_ERROR_T MsgStoCheckMsgCntFull(MsgDbHandler *pDbHandle, const MSG_MESSAGE_TYPE_S* pMsgType, MSG_FOLDER_ID_T FolderId);
+MSG_ERROR_T MsgStoCountMsgByLimitCategory(MsgDbHandler *pDbHandle, const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCount, MSG_FOLDER_ID_T folderId );
+int MsgStoCheckMsgCntLimit(const MSG_MESSAGE_TYPE_S* pMsgType, MSG_FOLDER_ID_T FolderId);
+
+MSG_ERROR_T MsgStoAddAddress(MsgDbHandler *pDbHandle, const MSG_ADDRESS_INFO_S *pAddrInfo, unsigned int *pAddrId);
+MSG_ERROR_T MsgStoUpdateAddress(MsgDbHandler *pDbHandle, unsigned int AddrId);
+MSG_ERROR_T MsgStoClearAddressTable(MsgDbHandler *pDbHandle);
+bool MsgExistAddress(MsgDbHandler *pDbHandle, const char *pAddress, unsigned int *pAddrId);
+
+int MsgStoGetUnreadCnt(MsgDbHandler *pDbHandle, MSG_MAIN_TYPE_T MsgType);
+MSG_ERROR_T MsgStoAddContactInfo(MsgDbHandler *pDbHandle, MSG_CONTACT_INFO_S *pContactInfo, const char *pNumber);
+MSG_ERROR_T MsgStoClearContactInfo(MsgDbHandler *pDbHandle, int ContactId);
+MSG_ERROR_T MsgStoClearContactInfo(MsgDbHandler *pDbHandle, int ContactId, const char *pNumber);
+MSG_ERROR_T MsgStoGetMmsRawFilePath(MsgDbHandler *pDbHandle, MSG_MESSAGE_ID_T msgId, char *pFilePath);
+bool MsgStoCheckReadReportRequested(MsgDbHandler *pDbHandle, MSG_MESSAGE_ID_T MsgId);
+bool MsgStoCheckReadReportIsSent(MsgDbHandler *pDbHandle, MSG_MESSAGE_ID_T MsgId);
+char *MsgStoReplaceString(const char *org_str, const char *old_str, const char *new_str);
+
+#endif // MSG_UTIL_STORAGE_H
+
diff --git a/mapi/CMakeLists.txt b/mapi/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..842c32a
--- /dev/null
@@ -0,0 +1,54 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 
+PROJECT(msg-server CXX)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.1.0")
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "") 
+       SET(CMAKE_BUILD_TYPE "Debug") 
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") 
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall")
+
+##########################################################
+# Define MAPI   
+##########################################################
+
+SET(MAPI-SRCS 
+       ${CMAKE_SOURCE_DIR}/mapi/MapiControl.cpp
+       ${CMAKE_SOURCE_DIR}/mapi/MapiSetting.cpp
+       ${CMAKE_SOURCE_DIR}/mapi/MapiStorage.cpp
+       ${CMAKE_SOURCE_DIR}/mapi/MapiTransport.cpp
+       ${CMAKE_SOURCE_DIR}/mapi/MapiMessage.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include/common
+       ${CMAKE_SOURCE_DIR}/include/framework
+       ${CMAKE_SOURCE_DIR}/include/proxy
+       ${CMAKE_SOURCE_DIR}/include/utils
+       ${CMAKE_SOURCE_DIR}/include/mapi
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(mapi_pkgs REQUIRED glib-2.0 dlog)
+
+FOREACH(flag ${mapi_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${MAPI-LIB} SHARED ${MAPI-SRCS})
+TARGET_LINK_LIBRARIES(${MAPI-LIB} ${mapi_pkgs_LDFLAGS} ${UTILS-LIB} ${TRANS-PROXY-LIB})
+SET_TARGET_PROPERTIES(${MAPI-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${MAPI-LIB} PROPERTIES VERSION ${VERSION})
+
+INSTALL(TARGETS ${MAPI-LIB} DESTINATION lib COMPONENT RuntimeLibraries)
+
diff --git a/mapi/MapiControl.cpp b/mapi/MapiControl.cpp
new file mode 100755 (executable)
index 0000000..f71c405
--- /dev/null
@@ -0,0 +1,90 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <errno.h>
+
+#include "MsgHandle.h"
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MapiControl.h"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+EXPORT_API int msg_open_msg_handle(MSG_HANDLE_T *handle)
+{
+       MsgHandle* pHandle = new MsgHandle();
+
+       if (handle == NULL)
+       {
+               MSG_FATAL("Input Paramter is NULL");
+               return -EINVAL;
+       }
+
+       // Create MsgHandle
+       *handle = (MSG_HANDLE_T)pHandle;
+
+       if (*handle == NULL)
+               return -EINVAL;
+
+       try
+       {
+               // Connect to Socket
+               pHandle->openHandle();
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+
+               if (e.errorCode() == MsgException::SERVER_READY_ERROR)
+                       return MSG_ERR_SERVER_NOT_READY;
+               else
+                       return MSG_ERR_COMMUNICATION_ERROR;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_close_msg_handle(MSG_HANDLE_T *handle)
+{
+       if (handle == NULL || *handle == NULL)
+       {
+               MSG_FATAL("Input Paramter is NULL");
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)(*handle);
+
+       try
+       {
+               // Disconnect to Socket
+               pHandle->closeHandle(pHandle);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_COMMUNICATION_ERROR;
+       }
+
+       // Destroy MsgHandle
+       delete (MsgHandle*)(*handle);
+       (*handle) = NULL;
+
+       return MSG_SUCCESS;
+}
+
diff --git a/mapi/MapiMessage.cpp b/mapi/MapiMessage.cpp
new file mode 100755 (executable)
index 0000000..74b0777
--- /dev/null
@@ -0,0 +1,1471 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgTypes.h"
+#include "MsgMmsTypes.h"
+#include "MsgMmsMessage.h"
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgHandle.h"
+#include "MsgException.h"
+#include "MapiMessage.h"
+#include "MsgInternalTypes.h"
+#include "MsgDrmWrapper.h"
+
+
+static MSG_ERROR_T msg_mms_release_message(MMS_MESSAGE_DATA_S* msg_data);
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+EXPORT_API msg_message_t msg_new_message(void)
+{
+       MSG_MESSAGE_S *msg = new MSG_MESSAGE_S;
+
+       memset(msg, 0x00, sizeof(MSG_MESSAGE_S));
+
+       /* set default value to message*/
+       msg->msgId = 0;
+       msg->folderId = MSG_DRAFT_ID;
+       msg->referenceId = 0;
+       msg->msgType.mainType= MSG_SMS_TYPE;
+       msg->msgType.subType = MSG_NORMAL_SMS;
+       msg->msgType.classType = MSG_CLASS_NONE;
+       msg->storageId = MSG_STORAGE_PHONE;
+       msg->nAddressCnt = 0;
+       time_t curTime = time(NULL);
+       msg->displayTime = curTime;
+       msg->networkStatus = MSG_NETWORK_NOT_SEND;
+       msg->encodeType = MSG_ENCODE_AUTO;
+       msg->bRead = false;
+       msg->bProtected = false;
+       msg->bBackup = false;
+       msg->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+       msg->direction = MSG_DIRECTION_TYPE_MO;
+       msg->msgPort.valid = false;
+       msg->dataSize = 0;
+       msg->pData = NULL;
+       msg->pMmsData = NULL;
+       msg->scheduledTime = 0;
+
+       return (msg_message_t) msg;
+}
+
+
+EXPORT_API int msg_release_message(msg_message_t *opq_msg)
+{
+       if (opq_msg == NULL)
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S* msg = NULL;
+
+       msg = (MSG_MESSAGE_S*)(*opq_msg);
+
+       if (msg != NULL)
+       {
+               MSG_DEBUG("main type : %d, data size : %d", msg->msgType.mainType, msg->dataSize);
+
+               if (msg->pData)
+               {
+                       delete [] static_cast<char*>(msg->pData);
+                       msg->pData = NULL;
+               }
+
+               if (msg->pMmsData)
+               {
+                       delete [] static_cast<char*>(msg->pMmsData);
+                       msg->pMmsData = NULL;
+               }
+
+               delete (MSG_MESSAGE_S*)(*opq_msg);
+               *opq_msg = NULL;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_set_message_id(msg_message_t opq_msg, int msg_id)
+{
+       if ( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       msg->msgId = msg_id;
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_get_message_id(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       return msg->msgId;
+}
+
+
+EXPORT_API int msg_set_message_type(msg_message_t opq_msg, MSG_MESSAGE_TYPE_T msg_type)
+{
+       if (!opq_msg)
+       {
+               MSG_FATAL("msg or text is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*)opq_msg;
+
+       if (msg_type == MSG_TYPE_SMS)
+       {
+               msg->msgType.mainType = MSG_SMS_TYPE;
+               msg->msgType.subType = MSG_NORMAL_SMS;
+       }
+       else if (msg_type == MSG_TYPE_MMS)
+       {
+               msg->msgType.mainType = MSG_MMS_TYPE;
+               msg->msgType.subType = MSG_SENDREQ_MMS;
+       }
+       else if (msg_type == MSG_TYPE_MMS_JAVA)
+       {
+               msg->msgType.mainType = MSG_MMS_TYPE;
+               msg->msgType.subType = MSG_SENDREQ_JAVA_MMS;
+       }
+       else if (msg_type == MSG_TYPE_SMS_SYNCML)
+       {
+               msg->msgType.mainType = MSG_SMS_TYPE;
+               msg->msgType.subType = MSG_SYNCML_CP;
+       }
+       else if (msg_type == MSG_TYPE_SMS_REJECT)
+       {
+               msg->msgType.mainType = MSG_SMS_TYPE;
+               msg->msgType.subType = MSG_REJECT_SMS;
+       }
+       else
+       {
+               MSG_FATAL("invalid msg_type [%d]", msg_type);
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_get_message_type(msg_message_t opq_msg)
+{
+       if (!opq_msg)
+       {
+               MSG_FATAL("msg or msg_type is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*)opq_msg;
+
+       if (msg->msgType.mainType == MSG_SMS_TYPE)
+       {
+               if (msg->msgType.subType == MSG_CB_SMS)
+                       return MSG_TYPE_SMS_CB;
+               else    if (msg->msgType.subType == MSG_JAVACB_SMS)
+                       return MSG_TYPE_SMS_JAVACB;
+               else    if (msg->msgType.subType == MSG_WAP_SI_SMS || msg->msgType.subType == MSG_WAP_SL_SMS)
+                       return MSG_TYPE_SMS_WAPPUSH;
+               else    if (msg->msgType.subType == MSG_MWI_VOICE_SMS || msg->msgType.subType == MSG_MWI_FAX_SMS
+                               || msg->msgType.subType == MSG_MWI_EMAIL_SMS || msg->msgType.subType == MSG_MWI_OTHER_SMS)
+                       return MSG_TYPE_SMS_MWI;
+               else    if (msg->msgType.subType == MSG_SYNCML_CP)
+                       return MSG_TYPE_SMS_SYNCML;
+               else    if (msg->msgType.subType == MSG_REJECT_SMS)
+                       return MSG_TYPE_SMS_REJECT;
+               else
+                       return MSG_TYPE_SMS;
+       }
+       else if (msg->msgType.mainType == MSG_MMS_TYPE)
+       {
+               if (msg->msgType.subType == MSG_NOTIFICATIONIND_MMS)
+                       return MSG_TYPE_MMS_NOTI;
+               else if (msg->msgType.subType == MSG_SENDREQ_JAVA_MMS)
+                       return MSG_TYPE_MMS_JAVA;
+               else
+                       return MSG_TYPE_MMS;
+       }
+       else
+               return MSG_TYPE_INVALID;
+}
+
+
+EXPORT_API bool msg_is_sms(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg or msg_type is NULL");
+               return false;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       return (msg->msgType.mainType == MSG_SMS_TYPE);
+}
+
+
+EXPORT_API bool msg_is_mms(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg or msg_type is NULL");
+               return false;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       return (msg->msgType.mainType == MSG_MMS_TYPE);
+}
+
+
+EXPORT_API int msg_set_storage_id(msg_message_t opq_msg, MSG_STORAGE_ID_T storage_id)
+{
+       if( !opq_msg)
+       {
+               MSG_FATAL("msg or storage is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       if (storage_id != MSG_STORAGE_PHONE && storage_id != MSG_STORAGE_SIM)
+       {
+               MSG_FATAL("unsupported storage [%d]", storage_id);
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       msg->storageId = storage_id;
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_get_storage_id(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       return msg->storageId;
+}
+
+
+EXPORT_API bool msg_is_in_sim(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg or folder is NULL");
+               return false;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       return (msg->storageId == MSG_STORAGE_SIM);
+}
+
+
+EXPORT_API int msg_set_folder_id(msg_message_t opq_msg, MSG_FOLDER_ID_T folder_id)
+{
+       if( !opq_msg)
+       {
+               MSG_FATAL("msg or is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       if (folder_id < MSG_INBOX_ID || folder_id > MSG_MAX_FOLDER_ID)
+       {
+               MSG_FATAL("wrong folder ID [%d]", folder_id);
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       msg->folderId = folder_id;
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_get_folder_id(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       return msg->folderId;
+}
+
+
+EXPORT_API int msg_reset_address(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       msg->nAddressCnt = 0;
+
+       for (int i=0 ; i < MAX_TO_ADDRESS_CNT ; i++)
+       {
+               msg->addressList[i].threadId = 0;
+               msg->addressList[i].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
+               msg->addressList[i].recipientType = MSG_RECIPIENTS_TYPE_UNKNOWN;
+               msg->addressList[i].contactId = 0;
+               msg->addressList[i].addressVal[0] = '\0';
+               msg->addressList[i].displayName[0] = '\0';
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_add_address(msg_message_t opq_msg, const char* phone_num_list, MSG_RECIPIENT_TYPE_T to_type )
+{
+       if( !opq_msg || !phone_num_list)
+       {
+               MSG_FATAL("msg or text or type is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       if (to_type < MSG_RECIPIENTS_TYPE_TO || to_type > MSG_RECIPIENTS_TYPE_BCC)
+       {
+               MSG_FATAL("unsupported recipient type [%d]", to_type);
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+
+       if(msg->msgType.mainType == MSG_SMS_TYPE)
+       {
+               char trimmed_num[strlen(phone_num_list)+1];
+               bzero(trimmed_num, strlen(phone_num_list)+1);
+
+               MSG_ERROR_T retVal = msg_verify_number(phone_num_list, trimmed_num);
+
+               if ( retVal != MSG_SUCCESS )
+                       return retVal;
+
+               int i = msg->nAddressCnt;
+               for( char* cur_num = strtok(trimmed_num,", "); cur_num && (i < MAX_TO_ADDRESS_CNT);
+                                                                                                                       cur_num = strtok(NULL,", "), i++)
+               {
+                       if (strlen(cur_num) > MAX_ADDRESS_VAL_LEN)
+                       {
+                               MSG_DEBUG("Phone number is too long [%s], and sending is skipped", cur_num);
+                               continue;
+                       }
+
+                       /* fill the destination number in msgReq */
+                       msg->nAddressCnt++;
+                       msg->addressList[i].addressType = MSG_ADDRESS_TYPE_PLMN; // telephone number
+                       msg->addressList[i].recipientType = to_type; // recipient type
+                       snprintf(msg->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN, "%s", cur_num);
+                       MSG_DEBUG("SMS AddressVal = [%s]", msg->addressList[i].addressVal);
+               }
+
+       }
+       else
+       {
+               char phone_num_list_tmp[strlen(phone_num_list)+1];
+               bzero(phone_num_list_tmp, strlen(phone_num_list)+1);
+
+               strncpy(phone_num_list_tmp, phone_num_list, strlen(phone_num_list));
+
+               MSG_ERROR_T retVal = msg_verify_email(phone_num_list_tmp);
+
+               if ( retVal != MSG_SUCCESS )
+                       return retVal;
+
+               int i = msg->nAddressCnt;
+               for( char* cur_num = strtok(phone_num_list_tmp,", "); cur_num && (i < MAX_TO_ADDRESS_CNT);
+                                                                                                                       cur_num = strtok(NULL,", "), i++)
+               {
+                       if (strlen(cur_num) > MAX_ADDRESS_VAL_LEN)
+                       {
+                               MSG_DEBUG("Phone number is too long [%s], and sending is skipped", cur_num);
+                               continue;
+                       }
+
+                       char trimmed_num[strlen(cur_num)+1];
+                       bzero(trimmed_num, strlen(cur_num)+1);
+
+                       retVal = msg_verify_number(cur_num, trimmed_num);
+
+                       if(retVal == MSG_SUCCESS)
+                       {
+                               /* fill the destination number in msgReq */
+                               msg->nAddressCnt++;
+                               msg->addressList[i].addressType = MSG_ADDRESS_TYPE_PLMN; // telephone number
+                               msg->addressList[i].recipientType = to_type; // recipient type
+                               snprintf(msg->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN, "%s", trimmed_num);
+                               MSG_DEBUG("MMS Number AddressVal = [%s]", msg->addressList[i].addressVal);
+                       }
+                       else
+                       {
+                               /* fill the destination number in msgReq */
+                               msg->nAddressCnt++;
+                               msg->addressList[i].addressType = MSG_ADDRESS_TYPE_EMAIL; // telephone number
+                               msg->addressList[i].recipientType = to_type; // recipient type
+                               snprintf(msg->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN, "%s", cur_num);
+                               MSG_DEBUG("MMS Email AddressVal = [%s]", msg->addressList[i].addressVal);
+                       }
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_get_address_count(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg or count is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       return msg->nAddressCnt;
+}
+
+
+EXPORT_API int msg_get_ith_thread_id(msg_message_t opq_msg, int ith)
+{
+       if( !opq_msg)
+       {
+               MSG_FATAL("msg or text or type is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       if( ith < msg->nAddressCnt )
+       {
+               return msg->addressList[ith].threadId;
+       }
+       else
+       {
+               MSG_FATAL("Requested address count %d exceeds max %d in msg", ith, msg->nAddressCnt);
+               return MSG_ERR_UNKNOWN;
+       }
+}
+
+
+EXPORT_API const char* msg_get_ith_address(msg_message_t opq_msg, int ith)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg or addr is NULL");
+               return NULL;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       if( ith < msg->nAddressCnt )
+       {
+               return msg->addressList[ith].addressVal;
+       }
+       else
+       {
+               MSG_FATAL("Requested address count %d exceeds max %d in msg", ith, msg->nAddressCnt);
+               return NULL;
+       }
+}
+
+
+EXPORT_API int msg_get_ith_recipient_type(msg_message_t opq_msg, int ith)
+{
+       if( !opq_msg)
+       {
+               MSG_FATAL("msg or text or type is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       if( ith < msg->nAddressCnt )
+       {
+               return msg->addressList[ith].recipientType;
+       }
+       else
+       {
+               MSG_FATAL("Requested address count %d exceeds max %d in msg", ith, msg->nAddressCnt);
+               return MSG_ERR_UNKNOWN;
+       }
+}
+
+
+EXPORT_API const char* msg_get_ith_name(msg_message_t opq_msg, int ith)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg or addr is NULL");
+               return NULL;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       if( ith < msg->nAddressCnt )
+       {
+               return msg->addressList[ith].displayName;
+       }
+       else
+       {
+               MSG_FATAL("Requested address count %d exceeds max %d in msg", ith, msg->nAddressCnt);
+               return NULL;
+       }
+}
+
+
+EXPORT_API int msg_get_ith_contact_id(msg_message_t opq_msg, int ith)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg or addr is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       if( ith < msg->nAddressCnt )
+       {
+               return msg->addressList[ith].contactId;
+       }
+       else
+       {
+               MSG_FATAL("Requested address count %d exceeds max %d in msg", ith, msg->nAddressCnt);
+               return MSG_ERR_UNKNOWN;
+       }
+}
+
+
+EXPORT_API int msg_set_reply_address(msg_message_t opq_msg, const char* phone_num)
+{
+       if( !opq_msg || !phone_num)
+       {
+               MSG_FATAL("msg or text or type is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       if (strlen(phone_num) > MAX_PHONE_NUMBER_LEN)
+       {
+               MSG_DEBUG("Phone number is too long [%s]", phone_num);
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       char trimmed_num[strlen(phone_num)+1];
+       bzero(trimmed_num, strlen(phone_num)+1);
+
+       MSG_ERROR_T retVal = msg_verify_number(phone_num, trimmed_num);
+
+       if (retVal != MSG_SUCCESS)
+               return retVal;
+
+       snprintf(msg->replyAddress, MAX_PHONE_NUMBER_LEN, "%s", phone_num);
+
+       MSG_DEBUG("Reply Address Number : [%s]", msg->replyAddress);
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_sms_set_message_body(msg_message_t opq_msg, const char* mdata, int size)
+{
+       if (!opq_msg || !mdata) {
+               MSG_FATAL("msg or text is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       if (size <= 0) {
+               MSG_FATAL("msg size is invalid");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       if(msg->msgType.mainType == MSG_MMS_TYPE) {
+/** Temporary added codes for Binary MMS. */
+               if (msg->pMmsData)
+                       delete [] static_cast<char*>(msg->pMmsData);
+
+               msg->dataSize = size;
+
+               msg->pMmsData = (void*)new char[msg->dataSize+1];
+
+               memset(msg->pMmsData, 0x00, msg->dataSize+1);
+
+               memcpy((char *)msg->pMmsData, mdata, msg->dataSize);
+
+/** End. */
+       } else if (msg->msgType.mainType == MSG_SMS_TYPE) {
+               if (msg->pData)
+                       delete [] static_cast<char*>(msg->pData);
+
+               msg->dataSize = size;
+
+               msg->pData = (void*)new char[msg->dataSize+1];
+
+               memcpy((char *)msg->pData, mdata, msg->dataSize);
+
+               ((char*) msg->pData)[msg->dataSize] = '\0';
+
+       } else {
+               return MSG_ERR_INVALID_MSG_TYPE;
+       }
+
+       return MSG_SUCCESS;
+
+}
+
+
+EXPORT_API const char* msg_sms_get_message_body(msg_message_t opq_msg)
+{
+       if (!opq_msg) {
+               MSG_FATAL("msg is NULL");
+               return NULL;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+
+       if (msg->msgType.mainType == MSG_SMS_TYPE) {
+
+               return (char*) msg->pData;
+
+       } else if (msg->msgType.mainType == MSG_MMS_TYPE) {
+
+               return (char*) msg->pMmsData;
+
+       } else {
+               MSG_FATAL("msg type is invalid.");
+               return NULL;
+       }
+
+}
+
+
+EXPORT_API const char* msg_mms_get_text_contents(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return NULL;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       if(msg->msgType.mainType != MSG_MMS_TYPE)
+       {
+               MSG_FATAL("msg is not mms type.");
+               return NULL;
+       }
+
+       return (char*) msg->pData;
+}
+
+
+EXPORT_API int msg_get_message_body_size(msg_message_t opq_msg )
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       return msg->dataSize;
+}
+
+
+EXPORT_API int msg_set_subject(msg_message_t opq_msg, const char* subject )
+{
+       if( !opq_msg || !subject )
+       {
+               MSG_FATAL("msg or subject is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       snprintf(msg->subject, MAX_SUBJECT_LEN+1,"%s", subject);
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API const char* msg_get_subject(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return NULL;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       return msg->subject;
+}
+
+
+EXPORT_API int msg_set_time(msg_message_t opq_msg, time_t msg_time)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       msg->displayTime = msg_time;
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API time_t* msg_get_time(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return NULL;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       return &(msg->displayTime);
+}
+
+EXPORT_API int msg_set_network_status(msg_message_t opq_msg, MSG_NETWORK_STATUS_T status)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       msg->networkStatus = status;
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_get_network_status(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg or status is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       return msg->networkStatus;
+}
+
+
+EXPORT_API int msg_set_encode_type(msg_message_t opq_msg, MSG_ENCODE_TYPE_T encoding_type)
+{
+       if( !opq_msg)
+       {
+               MSG_FATAL("msg or encoding_type is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       if( encoding_type != MSG_ENCODE_GSM7BIT &&
+               encoding_type != MSG_ENCODE_8BIT &&
+               encoding_type != MSG_ENCODE_UCS2 &&
+               encoding_type != MSG_ENCODE_AUTO )
+       {
+               MSG_FATAL("Encoding_type has invalid value [%d]", encoding_type);
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       msg->encodeType = encoding_type;
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_get_encode_type(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       return msg->encodeType;
+}
+
+
+EXPORT_API int msg_set_read_status(msg_message_t opq_msg, bool read_flag)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       msg->bRead = read_flag;
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API bool msg_is_read(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return false;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       return msg->bRead;
+}
+
+
+EXPORT_API int msg_set_protect_status(msg_message_t opq_msg, bool protect_flag)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       msg->bProtected = protect_flag;
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API bool msg_is_protected(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg or protected is NULL");
+               return false;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       return msg->bProtected;
+}
+
+
+EXPORT_API int msg_set_backup_status(msg_message_t opq_msg, bool backup_flag)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       msg->bBackup = backup_flag;
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API bool msg_is_backup(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg or protected is NULL");
+               return false;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       return msg->bBackup;
+}
+
+
+EXPORT_API int msg_set_priority_info(msg_message_t opq_msg, MSG_PRIORITY_TYPE_T priority)
+{
+       if( !opq_msg)
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       msg->priority = priority;
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_get_priority_info(msg_message_t opq_msg)
+{
+       if( !opq_msg)
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       return msg->priority;
+}
+
+
+EXPORT_API int msg_set_direction_info(msg_message_t opq_msg, MSG_DIRECTION_TYPE_T direction)
+{
+       if( !opq_msg)
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       msg->direction= direction;
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_get_direction_info(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       return msg->direction;
+}
+
+
+EXPORT_API int msg_set_port(msg_message_t opq_msg, unsigned short dst_port, unsigned short src_port)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       if( !dst_port && !src_port )
+               return MSG_SUCCESS;
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       msg->msgPort.valid = true;
+       msg->msgPort.dstPort = dst_port;
+       msg->msgPort.srcPort = src_port;
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_get_dest_port(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg or dst_port or src_port is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       if( msg->msgPort.valid )
+               return msg->msgPort.dstPort;
+       else
+               return 0;
+}
+
+
+EXPORT_API int msg_get_src_port(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg or dst_port or src_port is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       if( msg->msgPort.valid )
+               return msg->msgPort.srcPort;
+       else
+               return 0;
+}
+
+
+EXPORT_API int msg_set_scheduled_time(msg_message_t opq_msg, time_t time_to_send)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       if( !time_to_send )
+               return MSG_SUCCESS;
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       msg->scheduledTime = time_to_send;
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API time_t* msg_get_scheduled_time(msg_message_t opq_msg)
+{
+       if( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return NULL;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+       return &(msg->scheduledTime);
+}
+
+
+EXPORT_API int msg_get_attachment_count(msg_message_t opq_msg)
+{
+       if ( !opq_msg )
+       {
+               MSG_FATAL("msg is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S* msg = (MSG_MESSAGE_S*) opq_msg;
+
+       return msg->attachCount;
+}
+
+EXPORT_API const char* msg_get_thumbnail_path(msg_message_t opq_msg)
+{
+       if (!opq_msg)
+       {
+               MSG_FATAL("msg is NULL");
+               return NULL;
+       }
+
+       MSG_MESSAGE_S* pMsg = (MSG_MESSAGE_S*)opq_msg;
+
+       return pMsg->thumbPath;
+}
+
+
+static MSG_ERROR_T msg_mms_release_message(MMS_MESSAGE_DATA_S* msg_data)
+{
+       _MsgMmsReleasePageList(msg_data);
+       _MsgMmsReleaseRegionList(msg_data);
+       _MsgMmsReleaseAttachList(msg_data);
+       _MsgMmsReleaseTransitionList(msg_data);
+       _MsgMmsReleaseMetaList(msg_data);
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_mms_set_message_body(msg_message_t opq_msg, const MMS_MESSAGE_DATA_S *msg_data)
+{
+       if (!opq_msg || !msg_data) {
+               MSG_FATAL("msg or msg_data is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S* msg = (MSG_MESSAGE_S*) opq_msg;
+
+       if (msg->msgType.mainType != MSG_MMS_TYPE) {
+               MSG_FATAL("msg is not mms type.");
+               return MSG_ERR_INVALID_MSG_TYPE;
+       }
+
+       if (msg->pMmsData) {
+               if (msg->dataSize > 0)
+                       delete[] ((char*) msg->pMmsData);
+       }
+
+       msg->dataSize = 0;
+
+       msg->pMmsData = _MsgMmsSerializeMessageData(msg_data, &(msg->dataSize));
+
+       MSG_DEBUG("msg->dataSize : [%d]", msg->dataSize);
+
+       if (msg->dataSize <= 0) {
+               MSG_FATAL("msg size is invalid");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_mms_get_message_body(msg_message_t opq_msg, MMS_MESSAGE_DATA_S *body )
+{
+       if (!opq_msg || !body) {
+               MSG_FATAL("msg or body is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_MESSAGE_S *msg = (MSG_MESSAGE_S*) opq_msg;
+
+       if (msg->msgType.mainType != MSG_MMS_TYPE) {
+               MSG_FATAL("msg is not mms type.");
+               return MSG_ERR_INVALID_MSG_TYPE;
+       }
+
+       if (msg->pMmsData == NULL) {
+               MSG_FATAL("msg->pMmsData is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       _MsgMmsDeserializeMessageData(body, (char*)msg->pMmsData);
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API MMS_PAGE_S* msg_mms_add_page(MMS_MESSAGE_DATA_S *msg_data, const int duration)
+{
+       if(msg_data == NULL)
+               return NULL;
+
+       MMS_PAGE_S* page = (MMS_PAGE_S*)calloc(sizeof(MMS_PAGE_S), 1);
+       page->nDur = duration;
+
+       _MsgMmsAddPage(msg_data, page);
+
+       return page;
+}
+
+
+EXPORT_API MMS_SMIL_REGION* msg_mms_add_region(MMS_MESSAGE_DATA_S *msg_data, const char* szID, const int x, const int y, const int width, const int height, const int bgcolor)
+{
+       if(msg_data == NULL || szID == NULL)
+               return NULL;
+
+       MMS_SMIL_REGION* region = (MMS_SMIL_REGION *)calloc( sizeof(MMS_SMIL_REGION), 1 );
+
+       strncpy(region->szID, szID, MAX_SMIL_REGION_ID-1);
+       region->bgColor = bgcolor;
+       region->nLeft.value = x;
+       region->nLeft.bUnitPercent = true;
+       region->nTop.value = y;
+       region->nTop.bUnitPercent = true;
+       region->width.value = width;
+       region->width.bUnitPercent = true;
+       region->height.value = height;
+       region->height.bUnitPercent = true;
+       region->fit = MMSUI_IMAGE_REGION_FIT_MEET;
+
+       _MsgMmsAddRegion(msg_data, region);
+
+       return region;
+}
+
+
+EXPORT_API MMS_MEDIA_S* msg_mms_add_media(MMS_PAGE_S *page, const MmsSmilMediaType mediatype, const char* regionid, char* filepath)
+{
+       if(page == NULL || filepath == NULL)
+               return NULL;
+
+       if (MsgDrmIsDrmFile(filepath)) {
+               MSG_DRM_TYPE drm_type = MSG_DRM_NONE;
+
+               if (MsgDrmGetDrmType(filepath, &drm_type)) {
+                       if (drm_type == MSG_DRM_FORWARD_LOCK || drm_type == MSG_DRM_COMBINED_DELIVERY) {
+                               MSG_FATAL("file is a FL content");
+                               return NULL;
+                       }
+               }
+       }
+
+       MMS_MEDIA_S* media = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
+       char *filename = NULL;
+
+       media->mediatype = mediatype;
+
+       if(regionid)
+               strncpy(media->regionId, regionid, MAX_SMIL_REGION_ID-1);
+
+       strncpy(media->szFilePath, filepath, MSG_FILEPATH_LEN_MAX-1);
+
+       filename = strrchr(filepath, '/');
+       strncpy(media->szFileName, filename + 1, MSG_FILENAME_LEN_MAX-1);
+       strncpy(media->szContentID, filename + 1, MSG_MSG_ID_LEN);
+
+       _MsgMmsAddMedia(page, media);
+
+       return media;
+}
+
+
+EXPORT_API MMS_ATTACH_S* msg_mms_add_attachment(MMS_MESSAGE_DATA_S *msg_data, char *filepath)
+{
+       if(msg_data == NULL || filepath == NULL)
+               return NULL;
+
+       if (MsgDrmIsDrmFile(filepath)) {
+               MSG_DRM_TYPE drm_type = MSG_DRM_NONE;
+
+               if (MsgDrmGetDrmType(filepath, &drm_type)) {
+                       if (drm_type == MSG_DRM_FORWARD_LOCK || drm_type == MSG_DRM_COMBINED_DELIVERY) {
+                               MSG_FATAL("file is a FL content");
+                               return NULL;
+                       }
+               }
+       }
+
+       MMS_ATTACH_S* attach = (MMS_ATTACH_S*)calloc(sizeof(MMS_ATTACH_S), 1);
+       char *filename = NULL;
+
+       attach->mediatype = MIME_UNKNOWN;
+       attach->fileSize = -1;
+       strncpy(attach->szFilePath, filepath, MSG_FILEPATH_LEN_MAX-1);
+       filename = strrchr(filepath, '/');
+       strncpy(attach->szFileName, filename + 1, MSG_FILENAME_LEN_MAX-1);
+
+       _MsgMmsAddAttachment(msg_data, attach);
+
+       return attach;
+}
+
+
+EXPORT_API int msg_mms_add_transition(MMS_MESSAGE_DATA_S *msg_data, MMS_SMIL_TRANSITION *transition)
+{
+       if(msg_data == NULL || transition == NULL)
+               return MSG_ERR_NULL_POINTER;
+
+       MMS_SMIL_TRANSITION *pTransition = (MMS_SMIL_TRANSITION *)calloc(sizeof(MMS_SMIL_TRANSITION), 1);
+
+       if (transition->szID[0] != '0')
+               strncpy(pTransition->szID, transition->szID, MAX_SMIL_TRANSITION_ID);
+
+       pTransition->nType = transition->nType;
+       pTransition->nSubType = transition->nSubType;
+       pTransition->nDur = transition->nDur;
+
+       _MsgMmsAddTransition(msg_data, pTransition);
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_mms_add_meta(MMS_MESSAGE_DATA_S *msg_data, MMS_SMIL_META *meta)
+{
+       if(msg_data == NULL || meta == NULL)
+               return MSG_ERR_NULL_POINTER;
+
+       MMS_SMIL_META *pMeta = (MMS_SMIL_META *)calloc(sizeof(MMS_SMIL_META), 1);
+
+       if (meta->szID[0] != '0')
+               strncpy(pMeta->szID, meta->szID, MAX_SMIL_TRANSITION_ID);
+
+       if (meta->szName[0] != '0')
+               strncpy(pMeta->szName, meta->szName, MAX_SMIL_META_NAME);
+
+       if (meta->szContent[0] != '0')
+               strncpy(pMeta->szContent, meta->szContent, MAX_SMIL_META_NAME);
+
+       _MsgMmsAddMeta(msg_data, pMeta);
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API MMS_PAGE_S *msg_mms_get_page(MMS_MESSAGE_DATA_S *msg_data, int page_idx)
+{
+       if (msg_data == NULL)
+               return NULL;
+
+       if (page_idx < 0)
+               return NULL;
+
+       return _MsgMmsGetPage(msg_data, page_idx);
+}
+
+
+EXPORT_API MMS_SMIL_REGION* msg_mms_get_smil_region(MMS_MESSAGE_DATA_S *msg_data, int region_idx)
+{
+       if (msg_data == NULL)
+               return NULL;
+
+       if (region_idx < 0)
+               return NULL;
+
+       return _MsgMmsGetSmilRegion(msg_data, region_idx);
+}
+
+
+EXPORT_API MMS_MEDIA_S* msg_mms_get_media(MMS_PAGE_S *page, int media_idx)
+{
+       if (page == NULL || media_idx < 0)
+               return NULL;
+
+       return _MsgMmsGetMedia(page, media_idx);
+}
+
+
+EXPORT_API MMS_ATTACH_S* msg_mms_get_attachment(MMS_MESSAGE_DATA_S *msg_data, int attach_idx)
+{
+       if (msg_data == NULL)
+               return NULL;
+
+       if ( attach_idx <0 )
+               return NULL;
+
+       return _MsgMmsGetAttachment(msg_data, attach_idx);
+}
+
+
+EXPORT_API MMS_SMIL_TRANSITION* msg_mms_get_transition(MMS_MESSAGE_DATA_S *msg_data, int transition_idx)
+{
+       if (msg_data == NULL)
+               return NULL;
+
+       if (transition_idx < 0)
+               return NULL;
+
+       return _MsgMmsGetTransition(msg_data, transition_idx);
+}
+
+
+EXPORT_API MMS_SMIL_META* msg_mms_get_meta(MMS_MESSAGE_DATA_S *msg_data, int meta_idx)
+{
+       if (msg_data == NULL)
+               return NULL;
+
+       if (meta_idx < 0)
+               return NULL;
+
+       return _MsgMmsGetMeta(msg_data, meta_idx);
+}
+
+
+EXPORT_API int msg_mms_release_page_list(MMS_MESSAGE_DATA_S *msg_data)
+{
+       if (msg_data == NULL)
+               return MSG_ERR_NULL_POINTER;
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = _MsgMmsReleasePageList(msg_data);
+
+       return err;
+}
+
+
+EXPORT_API int msg_mms_release_region_list(MMS_MESSAGE_DATA_S *msg_data)
+{
+       if (msg_data == NULL)
+               return MSG_ERR_NULL_POINTER;
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = _MsgMmsReleaseRegionList(msg_data);
+
+       return err;
+}
+
+
+EXPORT_API int msg_mms_release_attachment_list(MMS_MESSAGE_DATA_S *msg_data)
+{
+       if (msg_data == NULL)
+               return MSG_ERR_NULL_POINTER;
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = _MsgMmsReleaseAttachList(msg_data);
+
+       return err;
+}
+
+
+EXPORT_API int msg_mms_release_transition_list(MMS_MESSAGE_DATA_S *msg_data)
+{
+       if (msg_data == NULL)
+               return MSG_ERR_NULL_POINTER;
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = _MsgMmsReleaseTransitionList(msg_data);
+
+       return err;
+}
+
+
+EXPORT_API int msg_mms_release_meta_list(MMS_MESSAGE_DATA_S *msg_data)
+{
+       if (msg_data == NULL)
+               return MSG_ERR_NULL_POINTER;
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = _MsgMmsReleaseMetaList(msg_data);
+
+       return err;
+}
+
+
+EXPORT_API MMS_MESSAGE_DATA_S* msg_mms_create_message(void)
+{
+       MMS_MESSAGE_DATA_S *mmsmsg = (MMS_MESSAGE_DATA_S *)calloc(sizeof(MMS_MESSAGE_DATA_S), 1);
+
+       return mmsmsg;
+}
+
+
+EXPORT_API MMS_SMIL_ROOTLAYOUT* msg_mms_set_rootlayout(MMS_MESSAGE_DATA_S* msg, const int width, const int height, const int bgcolor)
+{
+       if (msg == NULL)
+               return NULL;
+
+       msg->rootlayout.width.value = width;
+       msg->rootlayout.width.bUnitPercent = true;
+       msg->rootlayout.height.value = height;
+       msg->rootlayout.height.bUnitPercent = true;
+       msg->rootlayout.bgColor = bgcolor;
+
+       return (MMS_SMIL_ROOTLAYOUT *)&(msg->rootlayout);
+}
+
+
+EXPORT_API int msg_mms_destroy_message(MMS_MESSAGE_DATA_S* msg)
+{
+       if (msg == NULL)
+               return MSG_ERR_NULL_POINTER;
+
+       msg_mms_release_message(msg);
+
+       free(msg);
+
+       msg = NULL;
+
+       return MSG_SUCCESS;
+}
+
diff --git a/mapi/MapiSetting.cpp b/mapi/MapiSetting.cpp
new file mode 100755 (executable)
index 0000000..385d797
--- /dev/null
@@ -0,0 +1,76 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <errno.h>
+
+#include "MsgHandle.h"
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MapiSetting.h"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+EXPORT_API int msg_set_config(MSG_HANDLE_T handle, const MSG_SETTING_S *setting)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || setting == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->setConfig(setting);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_SET_WRITE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_get_config(MSG_HANDLE_T handle, MSG_SETTING_S *setting)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || setting == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->getConfig(setting);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_SET_READ_ERROR;
+       }
+
+       return err;
+}
+
diff --git a/mapi/MapiStorage.cpp b/mapi/MapiStorage.cpp
new file mode 100755 (executable)
index 0000000..9aaba60
--- /dev/null
@@ -0,0 +1,1352 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <errno.h>
+
+#include "MsgHandle.h"
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MapiMessage.h"
+#include "MapiStorage.h"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+EXPORT_API int msg_add_message(MSG_HANDLE_T handle, const msg_message_t opq_msg, const MSG_SENDINGOPT_S *send_opt)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || opq_msg == NULL || send_opt == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+       MSG_MESSAGE_S* pMsg = (MSG_MESSAGE_S*) opq_msg;
+
+       try
+       {
+               err = pHandle->addMessage(pMsg, send_opt);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_add_syncml_message(MSG_HANDLE_T handle, const MSG_SYNCML_MESSAGE_S *syncml_msg)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || syncml_msg == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->addSyncMLMessage(syncml_msg);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_update_message(MSG_HANDLE_T handle, const msg_message_t opq_msg, const MSG_SENDINGOPT_S *send_opt)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || opq_msg == NULL || send_opt == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+       MSG_MESSAGE_S* pMsg = (MSG_MESSAGE_S*) opq_msg;
+
+       if (pMsg->nAddressCnt > 1)
+       {
+               MSG_DEBUG("Multiple Address cannot be updated [%d]", pMsg->nAddressCnt);
+               return -EINVAL;
+       }
+
+       try
+       {
+               err = pHandle->updateMessage(pMsg, send_opt);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_update_read_status(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, bool read)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->updateReadStatus(msg_id, read);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_update_protected_status(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, bool is_protected)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->updateProtectedStatus(msg_id, is_protected);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_delete_message(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->deleteMessage(msg_id);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_delete_all_msgs_in_folder(MSG_HANDLE_T handle, MSG_FOLDER_ID_T folder_id, bool bOnlyDB)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->deleteAllMessagesInFolder(folder_id, bOnlyDB);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_move_msg_to_folder(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, MSG_FOLDER_ID_T dest_folder_id)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->moveMessageToFolder(msg_id, dest_folder_id);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_move_msg_to_storage(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, MSG_STORAGE_ID_T storage_id)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       if (storage_id != MSG_STORAGE_PHONE && storage_id != MSG_STORAGE_SIM)
+       {
+               MSG_FATAL("unsupported storage [%d]", storage_id);
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->moveMessageToStorage(msg_id, storage_id);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_count_message(MSG_HANDLE_T handle, MSG_FOLDER_ID_T folder_id, MSG_COUNT_INFO_S *count_info)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->countMessage(folder_id, count_info);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_count_msg_by_type(MSG_HANDLE_T handle, MSG_MESSAGE_TYPE_T msg_type, int *msg_count)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       MSG_MESSAGE_TYPE_S msgType = {0};
+
+       if (msg_type == MSG_TYPE_SMS)
+       {
+               msgType.mainType = MSG_SMS_TYPE;
+               msgType.subType = MSG_NORMAL_SMS;
+       }
+       else if (msg_type == MSG_TYPE_SMS_WAPPUSH)
+       {
+               msgType.mainType = MSG_SMS_TYPE;
+               msgType.subType = MSG_WAP_SI_SMS;
+       }
+       else if (msg_type == MSG_TYPE_MMS)
+       {
+               msgType.mainType = MSG_MMS_TYPE;
+               msgType.subType = MSG_SENDREQ_MMS;
+       }
+
+       try
+       {
+               err = pHandle->countMsgByType(&msgType, msg_count);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_count_msg_by_contact(MSG_HANDLE_T handle, const MSG_THREAD_LIST_INDEX_S *addr_info, MSG_THREAD_COUNT_INFO_S *msg_thread_count_list)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || addr_info == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->countMsgByContact(addr_info, msg_thread_count_list);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_get_message(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, msg_message_t opq_msg, MSG_SENDINGOPT_S *send_opt)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || !opq_msg)
+       {
+               MSG_FATAL("handle or opq_msg is NULL");
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+       MSG_MESSAGE_S* pMsg = (MSG_MESSAGE_S*) opq_msg;
+
+       try
+       {
+               err = pHandle->getMessage(msg_id, pMsg, send_opt);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_get_folder_view_list(MSG_HANDLE_T handle, MSG_FOLDER_ID_T folder_id, const MSG_SORT_RULE_S *sort_rule, MSG_LIST_S *msg_folder_view_list)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               if (sort_rule == NULL)
+               {
+                       MSG_SORT_RULE_S sortRule = {0};
+
+                       sortRule.sortType = MSG_SORT_BY_READ_STATUS;
+                       sortRule.bAscending = true;
+
+                       err = pHandle->getFolderViewList(folder_id, &sortRule, msg_folder_view_list);
+               }
+               else
+               {
+               err = pHandle->getFolderViewList(folder_id, sort_rule, msg_folder_view_list);
+       }
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_get_thread_view_list(MSG_HANDLE_T handle, const MSG_SORT_RULE_S *sort_rule, MSG_THREAD_VIEW_LIST_S *msg_thread_view_list)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               if (sort_rule == NULL)
+               {
+                       MSG_SORT_RULE_S sortRule = {0};
+
+                       sortRule.sortType = MSG_SORT_BY_THREAD_DATE;
+                       sortRule.bAscending = false;
+
+                       err = pHandle->getThreadViewList(&sortRule, msg_thread_view_list);
+               }
+               else
+               {
+                       err = pHandle->getThreadViewList(sort_rule, msg_thread_view_list);
+               }
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API void msg_release_thread_view_list(MSG_THREAD_VIEW_LIST_S *msg_thread_view_list)
+{
+       if (msg_thread_view_list == NULL)
+       {
+               return;
+       }
+
+       // Memory Free
+       if(msg_thread_view_list->msgThreadInfo != NULL)
+       {
+               if(msg_thread_view_list->nCount > 0)
+               {
+                       for(int i=0; i<msg_thread_view_list->nCount; i++)
+                               delete [] (MSG_THREAD_VIEW_S*)msg_thread_view_list->msgThreadInfo[i];
+               }
+
+               //free peer info list
+               delete [] msg_thread_view_list->msgThreadInfo;
+               msg_thread_view_list->msgThreadInfo = NULL;
+       }
+
+       msg_thread_view_list->nCount = 0;
+}
+
+
+EXPORT_API int msg_get_conversation_view_list(MSG_HANDLE_T handle, MSG_THREAD_ID_T thread_id, MSG_LIST_S *msg_conv_view_list)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->getConversationViewList(thread_id, msg_conv_view_list);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_delete_thread_message_list(MSG_HANDLE_T handle, MSG_THREAD_ID_T thread_id)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->deleteThreadMessageList(thread_id);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_add_folder(MSG_HANDLE_T handle, const MSG_FOLDER_INFO_S *folder_info)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || folder_info == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->addFolder(folder_info);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_update_folder(MSG_HANDLE_T handle, const MSG_FOLDER_INFO_S *folder_info)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || folder_info == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->updateFolder(folder_info);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_delete_folder(MSG_HANDLE_T handle, MSG_FOLDER_ID_T folder_id)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->deleteFolder(folder_id);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_get_folder_list(MSG_HANDLE_T handle, MSG_FOLDER_LIST_S *folder_list)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->getFolderList(folder_list);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API void msg_release_folder_list(MSG_FOLDER_LIST_S *folder_list)
+{
+       if (folder_list == NULL)
+       {
+               return;
+       }
+
+       // Memory Free
+       if (folder_list->folderInfo != NULL)
+       {
+               free(folder_list->folderInfo);
+               folder_list->folderInfo = NULL;
+       }
+
+       folder_list->nCount = 0;
+}
+
+
+EXPORT_API int msg_generate_message(MSG_HANDLE_T handle, MSG_MESSAGE_TYPE_T msg_type, MSG_FOLDER_ID_T folder_id, unsigned int num_msg)
+{
+       if (handle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return -EINVAL;
+       }
+
+       if (folder_id >= MSG_MAX_FOLDER_ID)
+       {
+               MSG_DEBUG("folderId is invalid [%d]", folder_id);
+               return -EINVAL;
+       }
+
+       MSG_DEBUG("type : %d, folder : %d, num_msg : %d", msg_type, folder_id, num_msg);
+
+       int err = 0;
+       MSG_SENDINGOPT_S sendingOpt = {0};
+       sendingOpt.bSetting = false;
+
+       char strMsg[20] = {0};
+       char prefix[10] ="0103001";
+//     int postfix = 8111;
+       int postfix = 0;
+
+       srand(getpid());
+       // Make Message
+       MSG_MESSAGE_S msgInfo = {0, };  //structure is used to enhance performance
+
+       for (unsigned int i = 0; i < num_msg; i++)
+       {
+               bzero(&msgInfo, sizeof(MSG_MESSAGE_S));
+
+               msgInfo.msgId   = 0; // It should be set 0
+               msgInfo.folderId = folder_id;
+
+               if (msg_type == MSG_TYPE_MMS)
+               {
+                       msgInfo.msgType.mainType = MSG_MMS_TYPE;
+                       //msgInfo.msgType.subType = MSG_RETRIEVE_MMS;
+                       msgInfo.msgType.subType = MSG_SENDREQ_MMS;
+               }
+               else
+               {
+                       msgInfo.msgType.mainType = MSG_SMS_TYPE;
+                       msgInfo.msgType.subType = MSG_NORMAL_SMS;
+
+                       snprintf(strMsg, sizeof(strMsg), "test msg %d", i);
+                       msgInfo.dataSize = strlen(strMsg);
+                       msgInfo.pData = strMsg;
+               }
+
+               msgInfo.storageId = MSG_STORAGE_PHONE;
+
+               msgInfo.nAddressCnt = 1;
+
+               msgInfo.addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+
+               postfix = rand()%10000;
+               snprintf(msgInfo.addressList[0].addressVal, MAX_ADDRESS_VAL_LEN+1, "%s%04d", prefix, postfix);
+
+               msgInfo.addressList[0].recipientType = MSG_RECIPIENTS_TYPE_TO;
+
+               time(&(msgInfo.displayTime));
+
+               msgInfo.networkStatus = MSG_NETWORK_NOT_SEND;
+               msgInfo.bRead = false;
+               msgInfo.bProtected = false;
+               msgInfo.priority = MSG_MESSAGE_PRIORITY_NORMAL;
+
+               if (folder_id == MSG_OUTBOX_ID || folder_id == MSG_SENTBOX_ID)
+                       msgInfo.direction = MSG_DIRECTION_TYPE_MO;
+               else
+                       msgInfo.direction = MSG_DIRECTION_TYPE_MT;
+
+               if (msg_type == MSG_TYPE_MMS)
+               {
+                       snprintf(msgInfo.subject, MAX_SUBJECT_LEN+1, "subject %d", i);
+
+                       if(folder_id == MSG_INBOX_ID) msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS;
+
+                       MMS_MESSAGE_DATA_S* mms_data;
+                       MMS_PAGE_S* page[2];
+                       MMS_MEDIA_S* media[5];
+
+                       mms_data = msg_mms_create_message();
+
+                       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+                       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+                       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+                       //------------>  1st Slide Composing
+                       page[0] = msg_mms_add_page(mms_data, 5440);
+
+                       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+                       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+                       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+                       media[2]->sMedia.sText.nColor = 0x000000;
+                       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+                       media[2]->sMedia.sText.bBold = true;
+
+                       //------------>  2nd Slide Composing
+                       page[1] = msg_mms_add_page(mms_data, 4544);
+
+                       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+                       media[3]->sMedia.sText.nColor = 0x000000;
+                       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+                       media[3]->sMedia.sText.bItalic = true;
+                       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+                       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+
+                       msg_mms_set_message_body((msg_message_t)&msgInfo, mms_data);
+
+                       msg_mms_destroy_message(mms_data);
+               }
+
+               err = msg_add_message(handle, (msg_message_t)&msgInfo, &sendingOpt);
+
+               if (msg_type == MSG_TYPE_MMS && msgInfo.pMmsData) //free pMmsData directly. It is added to enhance performance
+                       delete [] static_cast<char*>(msgInfo.pMmsData);
+
+               if (err < 0)
+               {
+                       MSG_DEBUG("err [%d]", err);
+                       return err;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_generate_sms(MSG_HANDLE_T handle, MSG_FOLDER_ID_T folder_id, unsigned int num_msg)
+{
+       MSG_DEBUG("folder %d, num_msg %d", folder_id, num_msg);
+
+       if (handle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return -EINVAL;
+       }
+
+       if (folder_id >= MSG_MAX_FOLDER_ID)
+       {
+               MSG_DEBUG("folderId is invalid");
+               return -EINVAL;
+       }
+
+       int err = 0;
+
+       // Make Message
+       MSG_MESSAGE_S msgInfo = {0};
+       char strMsg[20] = {0};
+
+       char prefix[10] ="0103001";
+       int postfix = 0;
+
+       MSG_SENDINGOPT_S sendingOpt = {0};
+       sendingOpt.bSetting = false;
+
+       srand(getpid());
+
+       for (unsigned int i = 0; i < num_msg; i++)
+       {
+               bzero(&msgInfo, sizeof(msgInfo));
+               msgInfo.msgId   = 0; // It should be set 0
+               msgInfo.folderId = folder_id;
+
+               msgInfo.msgType.mainType = MSG_SMS_TYPE;
+               msgInfo.msgType.subType = 0;
+
+               msgInfo.storageId = MSG_STORAGE_PHONE;
+
+               snprintf(strMsg, sizeof(strMsg), "test %d", i);
+               msgInfo.dataSize = strlen(strMsg);
+               msgInfo.pData = strMsg;
+
+               msgInfo.addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+               postfix = rand()%10000;
+               snprintf(msgInfo.addressList[0].addressVal, MAX_ADDRESS_VAL_LEN+1, "%s%04d", prefix, postfix);
+               msgInfo.addressList[0].recipientType = MSG_RECIPIENTS_TYPE_TO;
+               msgInfo.nAddressCnt = 1;
+
+               time(&(msgInfo.displayTime));
+
+               msgInfo.networkStatus = MSG_NETWORK_NOT_SEND;
+               msgInfo.bRead = false;
+               msgInfo.bProtected = false;
+               msgInfo.priority = MSG_MESSAGE_PRIORITY_NORMAL;
+               msgInfo.direction = MSG_DIRECTION_TYPE_MO;
+
+               err = msg_add_message(handle, (msg_message_t) &msgInfo, &sendingOpt);
+
+               if (err < 0)
+               {
+                       MSG_DEBUG("err [%d]", err);
+                       return err;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_get_quick_panel_data(MSG_HANDLE_T handle, MSG_QUICKPANEL_TYPE_T type, msg_message_t opq_msg)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || !opq_msg )
+       {
+               MSG_FATAL("handle or opq_msg is NULL");
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+       MSG_MESSAGE_S* pMsg = (MSG_MESSAGE_S*) opq_msg;
+
+       try
+       {
+               err = pHandle->getQuickPanelData(type, pMsg);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_reset_database(MSG_HANDLE_T handle)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->resetDatabase();
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_get_mem_size(MSG_HANDLE_T handle, unsigned int* memsize)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->getMemSize(memsize);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+
+}
+
+
+EXPORT_API int msg_thread_view_get_thread_id(msg_thread_view_t msg_thread)
+{
+       if (msg_thread == NULL)
+       {
+               MSG_FATAL("msg_thread is NULL");
+               return -EINVAL;
+       }
+
+       MSG_THREAD_VIEW_S* pMsg = (MSG_THREAD_VIEW_S*)msg_thread;
+
+       return pMsg->threadId;
+}
+
+
+EXPORT_API const char* msg_thread_view_get_address(msg_thread_view_t msg_thread)
+{
+       if (msg_thread == NULL)
+       {
+               MSG_FATAL("msg_thread is NULL");
+               return NULL;
+       }
+
+       MSG_THREAD_VIEW_S* pMsg = (MSG_THREAD_VIEW_S*)msg_thread;
+
+       return pMsg->threadAddr;
+}
+
+
+EXPORT_API const char* msg_thread_view_get_name(msg_thread_view_t msg_thread)
+{
+       if (msg_thread == NULL)
+       {
+               MSG_FATAL("msg_thread is NULL");
+               return NULL;
+       }
+
+       MSG_THREAD_VIEW_S* pMsg = (MSG_THREAD_VIEW_S*)msg_thread;
+
+       return pMsg->threadName;
+}
+
+
+EXPORT_API const char* msg_thread_view_get_image_path(msg_thread_view_t msg_thread)
+{
+       if (msg_thread == NULL)
+       {
+               MSG_FATAL("msg_thread is NULL");
+               return NULL;
+       }
+
+       MSG_THREAD_VIEW_S* pMsg = (MSG_THREAD_VIEW_S*)msg_thread;
+
+       return pMsg->threadImagePath;
+}
+
+
+EXPORT_API int msg_thread_view_get_message_type(msg_thread_view_t msg_thread)
+{
+       if (msg_thread == NULL)
+       {
+               MSG_FATAL("msg_thread is NULL");
+               return -EINVAL;
+       }
+
+       MSG_THREAD_VIEW_S* pMsg = (MSG_THREAD_VIEW_S*)msg_thread;
+
+       if (pMsg->threadType.mainType == MSG_SMS_TYPE)
+       {
+               if (pMsg->threadType.subType == MSG_CB_SMS)
+                       return MSG_TYPE_SMS_CB;
+               else    if (pMsg->threadType.subType == MSG_JAVACB_SMS)
+                       return MSG_TYPE_SMS_JAVACB;
+               else    if (pMsg->threadType.subType == MSG_WAP_SI_SMS || pMsg->threadType.subType == MSG_WAP_SL_SMS)
+                       return MSG_TYPE_SMS_WAPPUSH;
+               else    if (pMsg->threadType.subType == MSG_MWI_VOICE_SMS || pMsg->threadType.subType == MSG_MWI_FAX_SMS
+                               || pMsg->threadType.subType == MSG_MWI_EMAIL_SMS || pMsg->threadType.subType == MSG_MWI_OTHER_SMS)
+                       return MSG_TYPE_SMS_MWI;
+               else    if (pMsg->threadType.subType == MSG_SYNCML_CP)
+                       return MSG_TYPE_SMS_SYNCML;
+               else    if (pMsg->threadType.subType == MSG_REJECT_SMS)
+                       return MSG_TYPE_SMS_REJECT;
+               else
+                       return MSG_TYPE_SMS;
+       }
+       else if (pMsg->threadType.mainType == MSG_MMS_TYPE)
+       {
+               if (pMsg->threadType.subType == MSG_NOTIFICATIONIND_MMS)
+                       return MSG_TYPE_MMS_NOTI;
+               else if (pMsg->threadType.subType == MSG_SENDREQ_JAVA_MMS)
+                       return MSG_TYPE_MMS_JAVA;
+               else
+                       return MSG_TYPE_MMS;
+       }
+       else
+               return MSG_TYPE_INVALID;
+}
+
+
+EXPORT_API const char* msg_thread_view_get_data(msg_thread_view_t msg_thread)
+{
+       if (msg_thread == NULL)
+       {
+               MSG_FATAL("msg_thread is NULL");
+               return NULL;
+       }
+
+       MSG_THREAD_VIEW_S* pMsg = (MSG_THREAD_VIEW_S*)msg_thread;
+
+       return pMsg->threadData;
+}
+
+
+EXPORT_API time_t* msg_thread_view_get_time(msg_thread_view_t msg_thread)
+{
+       if (msg_thread == NULL)
+       {
+               MSG_FATAL("msg_thread is NULL");
+               return NULL;
+       }
+
+       MSG_THREAD_VIEW_S* pMsg = (MSG_THREAD_VIEW_S*)msg_thread;
+
+       return &(pMsg->threadTime);
+}
+
+
+EXPORT_API int msg_thread_view_get_direction(msg_thread_view_t msg_thread)
+{
+       if (msg_thread == NULL)
+       {
+               MSG_FATAL("msg_thread is NULL");
+               return -EINVAL;
+       }
+
+       MSG_THREAD_VIEW_S* pMsg = (MSG_THREAD_VIEW_S*)msg_thread;
+
+       return pMsg->direction;
+}
+
+
+EXPORT_API int msg_thread_view_get_contact_id(msg_thread_view_t msg_thread)
+{
+       if (msg_thread == NULL)
+       {
+               MSG_FATAL("msg_thread is NULL");
+               return -EINVAL;
+       }
+
+       MSG_THREAD_VIEW_S* pMsg = (MSG_THREAD_VIEW_S*)msg_thread;
+
+       return pMsg->contactId;
+}
+
+
+EXPORT_API int msg_thread_view_get_unread_cnt(msg_thread_view_t msg_thread)
+{
+       if (msg_thread == NULL)
+       {
+               MSG_FATAL("msg_thread is NULL");
+               return -EINVAL;
+       }
+
+       MSG_THREAD_VIEW_S* pMsg = (MSG_THREAD_VIEW_S*)msg_thread;
+
+       return pMsg->unreadCnt;
+}
+
+
+EXPORT_API int msg_thread_view_get_sms_cnt(msg_thread_view_t msg_thread)
+{
+       if (msg_thread == NULL)
+       {
+               MSG_FATAL("msg_thread is NULL");
+               return -EINVAL;
+       }
+
+       MSG_THREAD_VIEW_S* pMsg = (MSG_THREAD_VIEW_S*)msg_thread;
+
+       return pMsg->smsCnt;
+}
+
+
+EXPORT_API int msg_thread_view_get_mms_cnt(msg_thread_view_t msg_thread)
+{
+       if (msg_thread == NULL)
+       {
+               MSG_FATAL("msg_thread is NULL");
+               return -EINVAL;
+       }
+
+       MSG_THREAD_VIEW_S* pMsg = (MSG_THREAD_VIEW_S*)msg_thread;
+
+       return pMsg->mmsCnt;
+}
+
+
+EXPORT_API int msg_search_message_for_thread_view(MSG_HANDLE_T handle, const char *search_string, MSG_THREAD_VIEW_LIST_S *msg_thread_view_list)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || search_string == NULL)
+       {
+               return -EINVAL;
+       }
+
+       if (strlen(search_string) <= 0 || strlen(search_string) > MAX_MSG_TEXT_LEN)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->searchMessage(search_string, msg_thread_view_list);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_search_message(MSG_HANDLE_T handle, const MSG_SEARCH_CONDITION_S *msg_search_conditions, int offset, int limit, MSG_LIST_S *msg_list)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || msg_search_conditions == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->searchMessage(msg_search_conditions, offset, limit, msg_list);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_release_message_list(MSG_LIST_S *msg_list)
+{
+       if (msg_list == NULL)
+       {
+               MSG_FATAL("msg_list is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+
+       // Memory Free
+       if (msg_list->msgInfo!= NULL)
+       {
+               if(msg_list->nCount > 0)
+               {
+                       for(int i=0; i<msg_list->nCount; i++)
+                               msg_release_message(&(msg_list->msgInfo[i]));
+               }
+
+               delete [] msg_list->msgInfo;
+               msg_list->msgInfo = NULL;
+       }
+
+       msg_list->nCount = 0;
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_get_msgid_list(MSG_HANDLE_T handle, MSG_REFERENCE_ID_T ref_id, MSG_MSGID_LIST_S *msg_msgid_list)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->getMsgIdList(ref_id, msg_msgid_list);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API void msg_release_msgid_list(MSG_MSGID_LIST_S *msg_msgid_list)
+{
+       if (msg_msgid_list == NULL)
+       {
+               return;
+       }
+
+       // Memory Free
+       if(msg_msgid_list->msgIdList != NULL)
+       {
+               //free peer info list
+               delete [] msg_msgid_list->msgIdList;
+               msg_msgid_list->msgIdList = NULL;
+       }
+
+       msg_msgid_list->nCount = 0;
+}
+
+
+EXPORT_API int msg_get_reject_msg_list(MSG_HANDLE_T handle, const char *phone_num, MSG_REJECT_MSG_LIST_S *msg_reject_msg_list)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->getRejectMsgList(phone_num, msg_reject_msg_list);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API void msg_release_reject_msg_list(MSG_REJECT_MSG_LIST_S *msg_reject_msg_list)
+{
+       if (msg_reject_msg_list == NULL)
+       {
+               return;
+       }
+
+       // Memory Free
+       if(msg_reject_msg_list->rejectMsgInfo != NULL)
+       {
+               //free peer info list
+               delete [] msg_reject_msg_list->rejectMsgInfo;
+               msg_reject_msg_list->rejectMsgInfo = NULL;
+       }
+
+       msg_reject_msg_list->nCount = 0;
+}
+
+
+EXPORT_API int msg_reg_storage_change_callback(MSG_HANDLE_T handle, msg_storage_change_cb cb, void *user_param)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || cb == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->regStorageChangeCallback(cb, user_param);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_CALLBACK_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_get_report_status(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, MSG_REPORT_STATUS_INFO_S *report_status)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || msg_id < 1)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->getReportStatus(msg_id, report_status);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
+
diff --git a/mapi/MapiTransport.cpp b/mapi/MapiTransport.cpp
new file mode 100755 (executable)
index 0000000..0cfbc38
--- /dev/null
@@ -0,0 +1,602 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <errno.h>
+
+#include "MsgHandle.h"
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MapiTransport.h"
+#include "MapiControl.h"
+#include "MapiStorage.h"
+#include "MapiMessage.h"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+EXPORT_API int msg_submit_req(MSG_HANDLE_T handle, MSG_REQUEST_S *req)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL ||req == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->submitReq(req);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_TRANSPORT_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_reg_sent_status_callback(MSG_HANDLE_T handle, msg_sent_status_cb cb, void *user_param)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || cb == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->regSentStatusCallback(cb, user_param);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_CALLBACK_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_reg_sms_message_callback(MSG_HANDLE_T handle, msg_sms_incoming_cb cb, unsigned short port, void *user_param)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || cb == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->regSmsMessageCallback(cb, port, user_param);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_CALLBACK_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_reg_mms_conf_message_callback(MSG_HANDLE_T handle, msg_mms_conf_msg_incoming_cb cb, const char *app_id, void *user_param)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || cb == NULL)
+       {
+               return -EINVAL;
+       }
+
+       if (app_id && strlen(app_id) > MAX_MMS_JAVA_APPID_LEN)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->regMmsConfMessageCallback(cb, app_id, user_param);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_CALLBACK_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_reg_syncml_message_callback(MSG_HANDLE_T handle,  msg_syncml_msg_incoming_cb cb, void *user_param)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || cb == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->regSyncMLMessageCallback(cb, user_param);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_CALLBACK_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_reg_lbs_message_callback(MSG_HANDLE_T handle, msg_lbs_msg_incoming_cb cb, void *user_param)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || cb == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->regLBSMessageCallback(cb, user_param);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_CALLBACK_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_reg_syncml_message_operation_callback(MSG_HANDLE_T handle,  msg_syncml_msg_operation_cb cb, void *user_param)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || cb == NULL)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->regSyncMLMessageOperationCallback(cb, user_param);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_CALLBACK_ERROR;
+       }
+
+       return err;
+}
+
+
+EXPORT_API int msg_syncml_message_operation(MSG_HANDLE_T handle,  MSG_MESSAGE_ID_T msgId)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || msgId < 1)
+       {
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->operateSyncMLMessage(msgId);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_TRANSPORT_ERROR;
+       }
+
+       return err;
+}
+
+
+static MSG_HANDLE_T msgHandle = NULL;
+static msg_simple_sent_status_cb sentStatusCallback = NULL;
+
+static void sent_status_cb_func(MSG_HANDLE_T handle, MSG_SENT_STATUS_S *sent_status, void *user_param)
+{
+       MSG_DEBUG("Sent Status [%d]", sent_status->status);
+
+       msg_simple_sent_status_cb pfunc = sentStatusCallback;
+
+       pfunc(sent_status, user_param);
+
+       MSG_DEBUG("After entering callback function.");
+
+       // Close control handle instance
+       //      msg_close_msg_handle(&msgHandle);
+
+       //      MSG_DEBUG("After msg_close_msg_handle.");
+
+}
+
+
+static int msg_send_single_sms(const char *phone_num, const char *sms_text, msg_simple_sent_status_cb cb, void *user_param)
+{
+       if (phone_num == NULL || sms_text == NULL || cb == NULL)
+       {
+               MSG_DEBUG("Invalid parameter [%s] [%s] [%s]", phone_num, sms_text, cb);
+               return -EINVAL;
+       }
+
+       if (strlen(phone_num) > MAX_PHONE_NUMBER_LEN)
+       {
+               MSG_DEBUG("Phone Number is too long [%s]", phone_num);
+               return -EINVAL;
+       }
+
+       MSG_REQUEST_S msgReq = {0};
+       MSG_ERROR_T retVal = MSG_SUCCESS;
+
+       // Open control handle instance
+       if ((retVal = msg_open_msg_handle(&msgHandle)) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgOpenMsgHandle is failed. Error Code = %d", retVal);
+               return retVal;
+       }
+
+       msgReq.msg = msg_new_message();
+       MSG_MESSAGE_S *reqmsg = (MSG_MESSAGE_S*) msgReq.msg;
+       /* when sending SMS */
+       reqmsg->msgType.mainType = MSG_SMS_TYPE;
+       reqmsg->msgType.subType = MSG_NORMAL_SMS;
+       reqmsg->msgId = 0;
+       reqmsg->folderId = MSG_OUTBOX_ID;
+
+       /* fill the destination number in msgReq */
+       reqmsg->nAddressCnt = 1;
+       reqmsg->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN; // telephone number
+       reqmsg->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_TO; // telephone number
+       memset(reqmsg->addressList, 0x00, MAX_ADDRESS_VAL_LEN);
+       strncpy(reqmsg->addressList[0].addressVal, phone_num, MAX_ADDRESS_VAL_LEN);
+       MSG_DEBUG("AddressVal = [%s]", reqmsg->addressList[0].addressVal);
+
+       reqmsg->msgPort.valid = false;
+
+       /* fill the msg text in msgReq */
+       reqmsg->dataSize = strlen(sms_text);
+       reqmsg->pData = (void*)malloc(reqmsg->dataSize+1);
+       strncpy((char *)reqmsg->pData, sms_text, reqmsg->dataSize);
+
+       sentStatusCallback = cb;
+
+       // register sent status callback
+       retVal = msg_reg_sent_status_callback(msgHandle, sent_status_cb_func, user_param);
+
+       if (retVal != MSG_SUCCESS)
+       {
+               MSG_DEBUG("msg_reg_sent_status_callback() is failed. Error Code = %d", retVal);
+               msg_close_msg_handle(&msgHandle);
+               return retVal;
+       }
+
+       // sending message request
+       retVal = msg_submit_req(msgHandle, &msgReq);
+
+       if (retVal != MSG_SUCCESS)
+       {
+               MSG_DEBUG("msg_submit_req() is failed. Error Code = %d", retVal);
+               msg_close_msg_handle(&msgHandle);
+               return retVal;
+       }
+
+       /* Releasing msg_message_t is mandotory. Unless, memory leaks */
+       msg_release_message(&(msgReq.msg));
+
+       return MSG_SUCCESS;
+}
+
+
+static int msg_verify_number(const char *raw, char *trimmed)
+{
+       if( !(raw && trimmed) )
+       {
+               MSG_DEBUG("Phone Number is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       MSG_DEBUG("Phone Number is NULL");
+       for( int i=0, j=0 ; raw[i] ; i++ )
+       {
+               if ( (raw[i] >= '0' && raw[i] <= '9') || (raw[i] == ',') || raw[i] == ' ' || raw[i] == '+' )
+                       trimmed[j++] = raw[i];
+               else if( raw[i] == '-')
+                       continue;
+               else
+               {
+                       MSG_DEBUG("Unacceptable character in telephone number: [%c]", raw[i]);
+                       return MSG_ERR_INVALID_PARAMETER;
+               }
+       }
+       MSG_DEBUG("Trimming [%s]->[%s]", raw, trimmed);
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_sms_send(const char *phone_num_list, const char *sms_text, msg_simple_sent_status_cb cb, void *user_param)
+{
+       if (phone_num_list == NULL || sms_text == NULL || cb == NULL)
+       {
+               MSG_DEBUG("Invalid parameter [%s] [%s] [%s]", phone_num_list, sms_text, cb);
+               return -EINVAL;
+       }
+
+       char trimmed_num[strlen(phone_num_list)+1];
+       bzero(trimmed_num, strlen(phone_num_list)+1);
+
+       MSG_ERROR_T retVal = msg_verify_number(phone_num_list, trimmed_num);
+
+       if ( retVal != MSG_SUCCESS )
+               return retVal;
+
+       for( char* cur_num = strtok(trimmed_num,", "); cur_num ; cur_num = strtok(NULL,", "))
+       {
+               if (strlen(cur_num) > MAX_PHONE_NUMBER_LEN)
+               {
+                       MSG_DEBUG("Phone number is too long [%s], and sending is skipped", cur_num);
+                       continue;
+               }
+
+               MSG_DEBUG("phone number: [%s]", cur_num);
+               MSG_DEBUG("text: [%s]", sms_text);
+               retVal = msg_send_single_sms(cur_num, sms_text, cb, user_param);
+
+               if (retVal != MSG_SUCCESS)
+                       return retVal;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+EXPORT_API int msg_sms_send_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || !req) {
+               MSG_FATAL("handle or req is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       req->reqId = 1; // arbitrary number
+
+       MSG_MESSAGE_S *reqmsg = (MSG_MESSAGE_S*) req->msg;
+
+       if (reqmsg->dataSize <= 0) {
+               MSG_FATAL("msg size is invalid : [%d]", reqmsg->dataSize);
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       if (reqmsg->msgType.mainType != MSG_SMS_TYPE) {
+               MSG_DEBUG("mainType is not SMS [%d]", reqmsg->msgType.mainType);
+               reqmsg->msgType.mainType = MSG_SMS_TYPE;
+       }
+
+       if (reqmsg->msgType.subType > MSG_CONCAT_SIM_SMS) {
+               MSG_DEBUG("subType is not SMS [%d]", reqmsg->msgType.subType);
+               reqmsg->msgType.subType = MSG_NORMAL_SMS;
+       }
+
+       reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
+       reqmsg->networkStatus = MSG_NETWORK_SENDING;
+
+       err = msg_submit_req(handle, req);
+
+       if (err == MSG_SUCCESS)
+               MSG_DEBUG("Sending Message is OK!");
+       else
+               MSG_DEBUG("Sending Message is failed! [%d]", err);
+
+       return err;
+}
+
+
+EXPORT_API int msg_mms_send_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || !req)
+       {
+               MSG_FATAL("handle or req is NULL");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       req->reqId = 1; // arbitrary number
+
+       MSG_MESSAGE_S *reqmsg = (MSG_MESSAGE_S*) req->msg;
+
+       if (reqmsg->dataSize <= 0)
+       {
+               MSG_FATAL("MMS data size is invalid");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       reqmsg->msgType.mainType = MSG_MMS_TYPE;
+       reqmsg->msgType.subType = MSG_SENDREQ_MMS;
+       reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
+       reqmsg->networkStatus = MSG_NETWORK_SENDING;
+
+       err = msg_submit_req(handle, req);
+
+       if (err == MSG_SUCCESS)
+               MSG_DEBUG("Sending Message is OK!");
+       else
+               MSG_DEBUG("Sending Message is failed! [%d]", err);
+
+       return err;
+}
+
+
+EXPORT_API int msg_mms_send_read_report(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msgId, MSG_READ_REPORT_STATUS_T mms_read_status)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_REQUEST_S req = {0};
+
+       if (handle == NULL)
+       {
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       req.reqId = 1; // arbitrary number
+
+       req.msg = msg_new_message();
+
+       MSG_MESSAGE_S *reqmsg = (MSG_MESSAGE_S*) req.msg;
+
+       reqmsg->msgPort.valid = false;
+       reqmsg->msgId = msgId;
+       reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
+       reqmsg->msgType.mainType = MSG_MMS_TYPE;
+       reqmsg->msgType.subType = MSG_READREPLY_MMS;
+
+       reqmsg->dataSize = sizeof(MSG_READ_REPORT_STATUS_T);
+       reqmsg->pMmsData = (char *)calloc(reqmsg->dataSize, 1);
+
+       memcpy((char *)reqmsg->pMmsData, &mms_read_status, sizeof(MSG_READ_REPORT_STATUS_T));
+
+       MSG_DEBUG("mms_read_status [%d]", mms_read_status);
+
+       err = msg_submit_req(handle, &req);
+
+       if (err == MSG_SUCCESS)
+               MSG_DEBUG("Sending Message is OK!");
+       else
+               MSG_DEBUG("Sending Message is failed!");
+
+       free(reqmsg->pMmsData);
+
+       return err;
+}
+
+
+EXPORT_API int msg_mms_forward_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       if (handle == NULL || !req )
+       {
+               MSG_FATAL("handle or req is NULL");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       MSG_MESSAGE_S *reqmsg = (MSG_MESSAGE_S*) req->msg;
+
+       req->reqId = 1;
+
+       reqmsg->msgType.mainType = MSG_MMS_TYPE;
+       reqmsg->msgType.subType = MSG_FORWARD_MMS;
+       reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
+       reqmsg->networkStatus = MSG_NETWORK_SENDING;
+
+       err = msg_submit_req(handle, req);
+
+       if (err == MSG_SUCCESS)
+               MSG_DEBUG("Sending Message is OK!");
+       else
+               MSG_DEBUG("Sending Message is failed!");
+
+       return err;
+}
+
+
+EXPORT_API int msg_mms_retrieve_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       if ( handle == NULL|| !req)
+       {
+               MSG_FATAL("handle or req is NULL");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       MSG_MESSAGE_S *reqmsg = (MSG_MESSAGE_S*) req->msg;
+
+       reqmsg->msgType.mainType = MSG_MMS_TYPE;
+       reqmsg->msgType.subType = MSG_RETRIEVE_MMS;
+       reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
+       reqmsg->networkStatus = MSG_NETWORK_RETRIEVING;
+
+       err = msg_submit_req(handle, req);
+
+       if (err == MSG_SUCCESS)
+               MSG_DEBUG("Sending Message is OK!");
+       else
+               MSG_DEBUG("Sending Message is failed!");
+
+       return err;
+}
+
+
+/* reject_msg_support */
+EXPORT_API int msg_mms_reject_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       if (handle == NULL || !req )
+       {
+               MSG_FATAL("handle or req is NULL");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       MSG_MESSAGE_S *reqmsg = (MSG_MESSAGE_S*) req->msg;
+
+       reqmsg->msgType.mainType = MSG_MMS_TYPE;
+       reqmsg->msgType.subType = MSG_NOTIFYRESPIND_MMS;
+       reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
+       reqmsg->networkStatus = MSG_NETWORK_SENDING;
+
+       err = msg_submit_req(handle, req);
+
+       if (err == MSG_SUCCESS)
+               MSG_DEBUG("Sending Message is OK!");
+       else
+               MSG_DEBUG("Sending Message is failed!");
+
+       return err;
+}
+/* reject_msg_support */
+
diff --git a/msg-server b/msg-server
new file mode 100755 (executable)
index 0000000..48318db
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+## A script for running msg-server in booting time.
+
+dlogutil -v threadtime -f /var/log/msgfw.log -r 1000 -n 10 MSG_FW &
+
+if [ ! -e /opt/etc/.hib_capturing ]; then
+/usr/bin/msg-server &
+fi
+
diff --git a/msg-service.pc.in b/msg-service.pc.in
new file mode 100755 (executable)
index 0000000..5d04123
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=/usr
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: MESSAGE-FRAMEWORK
+Version: @VERSION@
+Description: Messaging Framework
+Requires: glib-2.0
+Libs: -L${libdir} -lmsg_mapi
+Cflags: -I${includedir} -I${includedir}/msg-service
diff --git a/msg_helper/CMakeLists.txt b/msg_helper/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..a33a996
--- /dev/null
@@ -0,0 +1,46 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(msg-server CXX)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Debug")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall")
+
+##########################################################
+# Define Test App
+##########################################################
+
+SET(MSG-HELPER-SRCS
+       ${CMAKE_SOURCE_DIR}/msg_helper/MsgSoundPlayer.cpp
+       ${CMAKE_SOURCE_DIR}/msg_helper/main.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include/common
+       ${CMAKE_SOURCE_DIR}/include/framework
+       ${CMAKE_SOURCE_DIR}/include/msg_helper
+       ${CMAKE_SOURCE_DIR}/include/utils
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(msg_helper_pkgs REQUIRED glib-2.0 dlog vconf devman_haptic mm-player mm-fileinfo mm-player svi)
+
+FOREACH(flag ${msg_helper_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_EXECUTABLE(msg-helper ${MSG-HELPER-SRCS})
+TARGET_LINK_LIBRARIES(msg-helper ${msg_helper_pkgs_LDFLAGS} ${UTILS-LIB})
+
+INSTALL(TARGETS msg-helper DESTINATION bin)
+
diff --git a/msg_helper/MsgSoundPlayer.cpp b/msg_helper/MsgSoundPlayer.cpp
new file mode 100755 (executable)
index 0000000..b775368
--- /dev/null
@@ -0,0 +1,410 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <pthread.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgSettingTypes.h"
+#include "MsgGconfWrapper.h"
+#include "MsgHelper.h"
+
+#include <devman_haptic.h>
+#include <svi.h>
+
+#include <mm_error.h>
+#include <mm_player.h>
+#include <mm_session_private.h>
+
+
+extern void worker_done();
+
+/*==================================================================================================
+                                     VARIABLES
+==================================================================================================*/
+static MMHandleType hPlayerHandle = 0;
+static bool bPlaying = false;
+static bool bVibrating = false;
+static int dev_handle;
+
+pthread_mutex_t muMmPlay = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t cvMmPlay = PTHREAD_COND_INITIALIZER;
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+static gboolean MsgSoundMelodyTimeout(gpointer data)
+{
+       MSG_BEGIN();
+
+       MsgSoundPlayStop();
+       if(!bPlaying && !bVibrating)
+               worker_done();
+
+       MSG_END();
+
+       return FALSE;
+}
+
+
+static gboolean MsgSoundVibTimeout(gpointer data)
+{
+       MSG_BEGIN();
+
+       int ret = 0;
+
+       if (bVibrating == true) {
+               ret = device_haptic_stop_play(dev_handle);
+
+               if (ret != 0) {
+                       MSG_DEBUG("Fail to stop haptic : [%d]", ret);
+               }
+
+               ret = device_haptic_close(dev_handle);
+
+               if (ret != 0) {
+                       MSG_DEBUG("Fail to close haptic : [%d]", ret);
+               }
+
+               bVibrating = false;
+       }
+
+       if(!bPlaying && !bVibrating)
+               worker_done();
+
+       MSG_END();
+
+       return FALSE;
+}
+
+
+static int MsgSoundPlayCallback(int message, void *param, void *user_param)
+{
+       switch (message)
+       {
+               case MM_MESSAGE_ERROR:
+                       MSG_DEBUG("ERROR is happened.");
+                       MsgSoundPlayUninit();
+                       break;
+               case MM_MESSAGE_BEGIN_OF_STREAM:
+                       MSG_DEBUG("Play is started.");
+                       break;
+               case MM_MESSAGE_END_OF_STREAM:
+                       MSG_DEBUG("end of stream");
+                       MsgSoundPlayStop();
+                       if(!bPlaying && !bVibrating)
+                               worker_done();
+                       break;
+               default:
+                       MSG_DEBUG("message = %d", message);
+                       break;
+       }
+
+       return 1;
+}
+
+
+void* MsgPlayThread(void *data)
+{
+       MSG_BEGIN();
+
+       bool bSoundOn = false;
+       bool bVibrationOn = false;
+       int callStatus = 0;     /* 0 - off, 1 - sound, 2 - vibration */
+       int alertOnCall = 0;
+
+       char *msg_tone_file_path = NULL;
+       AutoPtr<char> buf(&msg_tone_file_path);
+
+       char *tmpFileFath = NULL;
+
+       tmpFileFath = MsgSettingGetString(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
+
+       if (tmpFileFath == NULL) {
+               msg_tone_file_path = new char[MAX_SOUND_FILE_LEN];
+               strncpy(msg_tone_file_path, DEFAULT_FILE, MAX_SOUND_FILE_LEN-1);
+       } else {
+               msg_tone_file_path = new char[MAX_SOUND_FILE_LEN];
+               strncpy(msg_tone_file_path, tmpFileFath, MAX_SOUND_FILE_LEN-1);
+               free(tmpFileFath);
+               tmpFileFath = NULL;
+       }
+
+       MSG_DEBUG("Sound File [%s]", msg_tone_file_path);
+
+       MsgSettingGetBool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &bSoundOn);
+       MsgSettingGetBool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &bVibrationOn);
+
+       int err = MM_ERROR_NONE;
+
+       err = mm_session_init(MM_SESSION_TYPE_NOTIFY);
+
+       if(err != MM_ERROR_NONE)
+               MSG_DEBUG("MM Session Init Failed");
+       else
+               MSG_DEBUG("MM Session Init Success : %d", err);
+
+       hPlayerHandle = 0;
+
+       err = mm_player_create(&hPlayerHandle);
+
+       if (err != MM_ERROR_NONE) {
+               MSG_DEBUG("creating the player handle failed");
+               return NULL;
+       }
+
+       /* Setting the call back function msg_callback */
+       mm_player_set_message_callback(hPlayerHandle, MsgSoundPlayCallback, (void *)hPlayerHandle);
+
+       callStatus = MsgSettingGetInt(VCONFKEY_CALL_STATE);
+       MSG_DEBUG("Call Status = %d", callStatus);
+
+       if (callStatus > VCONFKEY_CALL_OFF && callStatus < VCONFKEY_CALL_STATE_MAX) {
+               alertOnCall = MsgSettingGetInt(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT);
+               MSG_DEBUG("Alert On Call = %d", alertOnCall);
+
+               if (alertOnCall == 0) {
+                       MSG_DEBUG("Call is active & Alert on Call - Off");
+               } else if (alertOnCall == 1) {
+                       MSG_DEBUG("Call is active & Alert on Call - Sound");
+
+                       if (bSoundOn)
+                               MsgSoundPlayMelody(msg_tone_file_path, false);
+               } else if (alertOnCall == 2) {
+                       MSG_DEBUG("Call is active & Alert on Call - Vibration");
+
+                       if (bVibrationOn)
+                               MsgSoundPlayVibration();
+               }
+       } else{
+               MSG_DEBUG("Call is not active");
+
+               if (bVibrationOn) {
+                       MSG_DEBUG("Play vibration.");
+                       MsgSoundPlayVibration();
+               }
+
+               if (bSoundOn) {
+                       MSG_DEBUG("Play sound.");
+                       MsgSoundPlayMelody(msg_tone_file_path, false);
+               }
+       }
+
+       err = mm_session_finish();
+
+       if (err != MM_ERROR_NONE)
+               MSG_DEBUG("MM Session Finish Failed");
+       else
+               MSG_DEBUG("MM Session Finish Success : %d", err);
+
+       if(!bPlaying && !bVibrating)
+               worker_done();
+
+       MSG_END();
+
+       return NULL;
+}
+
+
+MSG_ERROR_T MsgSoundPlayUninit()
+{
+       MSG_BEGIN();
+
+       int err = MM_ERROR_NONE;
+
+       /* Uninitializing the player module */
+       err = mm_player_unrealize(hPlayerHandle);
+
+       /* Destroying the player handle */
+       err = mm_player_destroy(hPlayerHandle);
+
+       pthread_mutex_lock(&muMmPlay);
+
+       bPlaying = false;
+
+       pthread_mutex_unlock(&muMmPlay);
+
+       pthread_cond_signal(&cvMmPlay);
+
+       hPlayerHandle = 0;
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+void MsgSoundPlayStart()
+{
+       MSG_BEGIN();
+
+       pthread_mutex_lock(&muMmPlay);
+
+       if (bPlaying == true) {
+               MSG_DEBUG("Ringtone is Playing...");
+               pthread_mutex_unlock(&muMmPlay);
+               return;
+       }
+
+       pthread_mutex_unlock(&muMmPlay);
+
+       pthread_t tid;
+
+       if (pthread_create(&tid, NULL, &MsgPlayThread, (void*)NULL) == 0) {
+               MSG_DEBUG("Ring alert thread created = %d", tid);
+       } else {
+               MSG_DEBUG("Creating Thread was failed");
+               return;
+       }
+
+       MSG_END();
+}
+
+
+void MsgSoundPlayStop()
+{
+       MSG_BEGIN();
+
+       pthread_mutex_lock(&muMmPlay);
+
+       if (bPlaying == false) {
+               MSG_DEBUG("Ringtone is Not Playing...");
+               pthread_mutex_unlock(&muMmPlay);
+               return;
+       }
+
+       pthread_mutex_unlock(&muMmPlay);
+
+       /* Stop playing media contents */
+       MSG_DEBUG("Before mm_player_stop, %p", hPlayerHandle);
+
+       int err = mm_player_stop(hPlayerHandle);
+
+       MSG_DEBUG("After mm_player_stop");
+
+       if (err != MM_ERROR_NONE) {
+               MSG_DEBUG("stopping the player handle failed");
+       }
+
+       MsgSoundPlayUninit();
+
+       MSG_END();
+}
+
+
+int MsgSoundPlayMelody(char *pMsgToneFilePath, bool bIncreasing)
+{
+       int err = MM_ERROR_NONE;
+
+       /* Setting fade in,out */
+       err = mm_player_set_attribute(hPlayerHandle, NULL, "sound_priority", 2, NULL);
+
+       if (err != MM_ERROR_NONE) {
+               MSG_DEBUG("error setting the profile attr");
+               return err;
+       }
+
+       /* Setting the Volume */
+       err = mm_player_set_attribute(hPlayerHandle, NULL, "sound_volume_type", MM_SOUND_VOLUME_TYPE_NOTIFICATION,
+                                                                                                       "profile_uri", pMsgToneFilePath, strlen(pMsgToneFilePath), NULL);
+
+       if (err != MM_ERROR_NONE) {
+               MSG_DEBUG("error setting the profile attr");
+               return err;
+       }
+
+       err = mm_player_realize(hPlayerHandle);
+
+       if (err != MM_ERROR_NONE) {
+               MSG_DEBUG("mm_player_realize() error : [%d]", err);
+               return err;
+       }
+
+       /* Add Timer to stop playing after 5 sec. */
+       int g_contact_timer = -1;
+       g_contact_timer = g_timeout_add(5500, (GSourceFunc)MsgSoundMelodyTimeout, NULL);
+
+       err = mm_player_start(hPlayerHandle);
+
+       if (err != MM_ERROR_NONE) {
+               MSG_DEBUG("mm_player_start, FAIL [%x]", err);
+               bPlaying = false;
+
+               return err;
+       }
+
+       bPlaying = true;
+
+       pthread_mutex_lock(&muMmPlay);
+
+       while (bPlaying)
+       {
+               MSG_DEBUG("Ring Alert Playing");
+               pthread_cond_wait(&cvMmPlay, &muMmPlay);
+       }
+
+       pthread_mutex_unlock(&muMmPlay);
+
+       MSG_DEBUG("Ring Alert Idle");
+
+       return err;
+}
+
+
+void MsgSoundPlayVibration()
+{
+       MSG_BEGIN();
+
+       int ret = 0;
+       int vibLevel = 0;
+       char ivtFilePath[MAX_SOUND_FILE_LEN] = {0,};
+
+       vibLevel = MsgSettingGetInt(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT);
+
+       if (vibLevel > 0) {
+               bVibrating = true;
+
+               dev_handle = device_haptic_open(DEV_IDX_0, 0);
+
+               g_timeout_add(MSG_VIBRATION_INTERVAL , MsgSoundVibTimeout, NULL);
+
+               /* set timer to stop vibration, then play melody */
+               svi_get_path(SVI_TYPE_VIB, SVI_VIB_NOTIFICATION_MESSAGE, ivtFilePath, sizeof(ivtFilePath));
+               ret = device_haptic_play_file(dev_handle, ivtFilePath, HAPTIC_TEST_ITERATION, vibLevel);
+
+               if (ret != 0) {
+                       MSG_DEBUG("Fail to play haptic : [%d]", ret);
+               }
+       }
+
+       MSG_END();
+}
+
+
+int MsgSoundGetUnreadMsgCnt()
+{
+       int unreadCnt = 0;
+
+       /*  Get SMS Count */
+       unreadCnt = MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_SMS_STATE);
+
+       /*  Get MMS Count */
+       unreadCnt += MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_MMS_STATE);
+
+       MSG_DEBUG("unread count : [%d]", unreadCnt);
+
+       return unreadCnt;
+}
diff --git a/msg_helper/main.cpp b/msg_helper/main.cpp
new file mode 100755 (executable)
index 0000000..4ffd4a4
--- /dev/null
@@ -0,0 +1,89 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <glib.h>
+#include <sys/time.h>
+#include <stdlib.h>
+
+#include "MsgHelper.h"
+#include "MsgUtilFile.h"
+#include "MsgCppTypes.h"
+#include "MsgDebug.h"
+
+static GMainLoop *loop;
+
+static gboolean _worker_done(void* data)
+{
+       if (g_main_loop_is_running(loop))
+               g_main_loop_quit(loop);
+
+       return 0;
+}
+
+// may called by threads
+void worker_done()
+{
+       g_idle_add(_worker_done,NULL);
+}
+
+int main(int argc, char** argv)
+{
+
+       MSG_DEBUG("############### Start msg_helper ###############");
+
+       g_thread_init(NULL);
+
+       bool notEnd = false;
+
+       if(argc < 1)
+       {
+               MSG_DEBUG("No arguments to run msg_helper.");
+               return 0;
+       }
+
+       MSG_DEBUG("argv[0] [%s] ", argv[0]);
+
+       if(strcmp(argv[0],MSG_SOUND_START)==0)
+       {
+               MsgSoundPlayStart();
+               notEnd = true;
+       }
+       else if(strcmp(argv[0],MSG_SOUND_STOP)==0)
+       {
+               MsgSoundPlayStop();
+       }
+
+       if(notEnd)
+       {
+               loop = g_main_loop_new(NULL, FALSE);
+
+
+               if (loop != NULL)
+               {
+                       MSG_DEBUG("Waiting for working jobs to be finished!!!");
+
+                       // Run GMainLoop
+                       g_main_loop_run(loop);
+               }
+               else
+               {
+                       MSG_DEBUG("Fail to create g_main_loop!!!");
+               }
+       }
+
+       return 0;
+}
diff --git a/packaging/msg-service.spec b/packaging/msg-service.spec
new file mode 100755 (executable)
index 0000000..74016e3
--- /dev/null
@@ -0,0 +1,307 @@
+Name:           msg-service
+Version:        0.8.7
+Release:        5
+License:        Flora Software License
+Summary:        Messaging Framework Library 
+Group:          System/Libraries
+Source0:       %{name}-%{version}.tar.gz
+
+Requires(post): /usr/bin/sqlite3
+Requires(post): /usr/bin/vconftool
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires: cmake
+BuildRequires: pkgconfig(alarm-service)
+BuildRequires: pkgconfig(contacts-service)
+BuildRequires: pkgconfig(db-util)
+BuildRequires: pkgconfig(devman_haptic)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(drm-client)
+BuildRequires: pkgconfig(drm-trusted)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(libcurl)
+BuildRequires: pkgconfig(libxml-2.0)
+BuildRequires: pkgconfig(libwbxml2)
+BuildRequires: pkgconfig(media-thumbnail)
+BuildRequires: pkgconfig(mm-fileinfo)
+BuildRequires: pkgconfig(mm-player)
+BuildRequires: pkgconfig(mm-session)
+BuildRequires: pkgconfig(network)
+BuildRequires: pkgconfig(notification)
+BuildRequires: pkgconfig(pmapi)
+BuildRequires: pkgconfig(mmutil-imgp)
+BuildRequires: pkgconfig(mmutil-jpeg)
+BuildRequires: pkgconfig(security-server)
+BuildRequires: pkgconfig(sensor)
+BuildRequires: pkgconfig(svi)
+BuildRequires: pkgconfig(tapi)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(capi-appfw-application)
+
+%description 
+Description: Messaging Framework Library 
+
+
+%package devel
+License:        Flora Software License
+Summary:        Messaging Framework Library (development)
+Requires:       %{name} = %{version}-%{release}
+Group:          Development/Libraries
+
+%description devel
+Description: Messaging Framework Library (development)
+
+
+%package tools
+License:        Flora Software License
+Summary:        Messaging server application
+Requires:       %{name} = %{version}-%{release}
+Group:          TO_BU / FILL_IN
+Requires(post): /usr/bin/sqlite3
+Requires(post): /usr/bin/vconftool
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description tools
+Description:  Messaging server application
+
+
+%package -n sms-plugin
+License:        Flora Software License
+Summary:        SMS plugin library 
+Requires:       %{name} = %{version}-%{release}
+Group:          System/Libraries
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description -n sms-plugin
+Description: SMS plugin library  
+
+%package -n mms-plugin
+License:        Flora Software License
+Summary:        MMS plugin library 
+Requires:       %{name} = %{version}-%{release}
+Group:          System/Libraries
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description -n mms-plugin
+Description: MMS plugin library  
+
+%prep
+%setup -q
+
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+make %{?jobs:-j%jobs}
+
+%install
+
+rm -rf %{buildroot}
+%make_install
+
+mkdir -p  %{buildroot}%{_sysconfdir}/rc.d/rc3.d
+ln -s %{_sysconfdir}/rc.d/init.d/msg-server  %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S70msg-server
+mkdir -p  %{buildroot}%{_sysconfdir}/rc.d/rc5.d
+ln -s %{_sysconfdir}/rc.d/init.d/msg-server  %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S70msg-server
+
+
+
+mkdir -p %{buildroot}/opt/data/msg-service
+
+%post tools -p /sbin/ldconfig
+%post -n sms-plugin -p /sbin/ldconfig
+%post -n mms-plugin -p /sbin/ldconfig
+
+%post 
+/sbin/ldconfig
+
+if [ ! -f /opt/dbspace/.msg_service.db ]
+then
+        sqlite3 /opt/dbspace/.msg_service.db "PRAGMA journal_mode = PERSIST;
+
+        CREATE TABLE MSG_ADDRESS_TABLE(ADDRESS_ID INTEGER PRIMARY KEY, ADDRESS_TYPE INTEGER, RECIPIENT_TYPE INTEGER, ADDRESS_VAL TEXT, CONTACT_ID INTEGER, DISPLAY_NAME TEXT, FIRST_NAME TEXT, LAST_NAME TEXT, IMAGE_PATH TEXT, SYNC_TIME DATETIME, UNREAD_CNT INTEGER DEFAULT 0, SMS_CNT INTEGER DEFAULT 0, MMS_CNT INTEGER DEFAULT 0, MAIN_TYPE INTEGER NOT NULL, SUB_TYPE INTEGER NOT NULL, MSG_DIRECTION INTEGER NOT NULL, MSG_TIME DATETIME, MSG_TEXT TEXT);
+        CREATE TABLE MSG_FOLDER_TABLE(FOLDER_ID INTEGER PRIMARY KEY, FOLDER_NAME TEXT NOT NULL, FOLDER_TYPE INTEGER DEFAULT 0);
+        CREATE TABLE MSG_MESSAGE_TABLE(MSG_ID INTEGER PRIMARY KEY, ADDRESS_ID INTEGER, FOLDER_ID INTEGER, REFERENCE_ID INTEGER, STORAGE_ID INTEGER NOT NULL, MAIN_TYPE INTEGER NOT NULL, SUB_TYPE INTEGER NOT NULL, DISPLAY_TIME DATETIME, DATA_SIZE INTEGER DEFAULT 0, NETWORK_STATUS INTEGER DEFAULT 0, READ_STATUS INTEGER DEFAULT 0, PROTECTED INTEGER DEFAULT 0, PRIORITY INTEGER DEFAULT 0, MSG_DIRECTION INTEGER NOT NULL, SCHEDULED_TIME DATETIME, BACKUP INTEGER DEFAULT 0, SUBJECT TEXT, MSG_DATA TEXT, THUMB_PATH TEXT, MSG_TEXT TEXT, DELIVERY_REPORT_STATUS INTEGER DEFAULT 0, DELIVERY_REPORT_TIME DATETIME, READ_REPORT_STATUS INTEGER DEFAULT 0, READ_REPORT_TIME DATETIME, ATTACHMENT_COUNT INTEGER DEFAULT 0, FOREIGN KEY(ADDRESS_ID) REFERENCES MSG_ADDRESS_TABLE(ADDRESS_ID), FOREIGN KEY(FOLDER_ID) REFERENCES MSG_FOLDER_TABLE(FOLDER_ID));
+        CREATE TABLE MSG_SIM_TABLE(MSG_ID INTEGER, SIM_ID INTEGER NOT NULL, FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));
+        CREATE TABLE MSG_PUSH_TABLE(MSG_ID INTEGER, ACTION INTEGER, CREATED INTEGER, EXPIRES INTEGER, ID TEXT, HREF TEXT, CONTENT TEXT, FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));
+        CREATE TABLE MSG_CBMSG_TABLE(MSG_ID INTEGER, CB_MSG_ID INTEGER NOT NULL, FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));
+        CREATE TABLE MSG_SYNCML_TABLE(MSG_ID INTEGER, EXT_ID INTEGER NOT NULL, PINCODE INTEGER NOT NULL, FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));
+        CREATE TABLE MSG_SCHEDULED_TABLE(MSG_ID INTEGER, ALARM_ID INTEGER NOT NULL, LISTENER_FD INTEGER NOT NULL, FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));
+        CREATE TABLE MSG_SMS_SENDOPT_TABLE(MSG_ID INTEGER, DELREP_REQ INTEGER NOT NULL, KEEP_COPY INTEGER NOT NULL, REPLY_PATH INTEGER NOT NULL, FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));
+        CREATE TABLE MSG_FILTER_TABLE(FILTER_ID INTEGER PRIMARY KEY, FILTER_TYPE INTEGER NOT NULL, FILTER_VALUE TEXT NOT NULL);
+        CREATE TABLE MSG_MMS_MESSAGE_TABLE(REFERENCE_ID INTEGER, TRANSACTION_ID TEXT, MESSAGE_ID TEXT, FWD_MESSAGE_ID TEXT, CONTENTS_LOCATION TEXT, FILE_PATH TEXT, FOREIGN KEY(REFERENCE_ID) REFERENCES MSG_MESSAGE_TABLE(REFERENCE_ID));
+        CREATE TABLE MSG_MMS_ATTR_TABLE(REFERENCE_ID INTEGER, VERSION INTEGER NOT NULL, DATA_TYPE INTEGER DEFAULT -1, DATE DATETIME, HIDE_ADDRESS INTEGER DEFAULT 0, ASK_DELIVERY_REPORT INTEGER DEFAULT 0, REPORT_ALLOWED INTEGER DEFAULT 0, READ_REPORT_ALLOWED_TYPE INTEGER DEFAULT 0, ASK_READ_REPLY INTEGER DEFAULT 0, READ INTEGER DEFAULT 0, READ_REPORT_SEND_STATUS INTEGER DEFAULT 0, READ_REPORT_SENT INTEGER DEFAULT 0, PRIORITY INTEGER DEFAULT 0, KEEP_COPY INTEGER DEFAULT 0, MSG_SIZE INTEGER NOT NULL, MSG_CLASS INTEGER DEFAULT -1, EXPIRY_TIME DATETIME, CUSTOM_DELIVERY_TIME INTEGER DEFAULT 0, DELIVERY_TIME DATETIME, MSG_STATUS INTEGER DEFAULT -1, FOREIGN KEY(REFERENCE_ID) REFERENCES MSG_MESSAGE_TABLE(REFERENCE_ID));
+
+        CREATE INDEX MSG_ADDRESS_INDEX ON MSG_ADDRESS_TABLE(ADDRESS_ID);
+        CREATE INDEX MSG_FOLDER_INDEX ON MSG_FOLDER_TABLE(FOLDER_ID);
+        CREATE INDEX MSG_MESSAGE_INDEX ON MSG_MESSAGE_TABLE(MSG_ID, ADDRESS_ID, FOLDER_ID);
+
+        INSERT INTO MSG_FOLDER_TABLE VALUES (1, 'INBOX', 1);
+        INSERT INTO MSG_FOLDER_TABLE VALUES (2, 'OUTBOX', 2);
+        INSERT INTO MSG_FOLDER_TABLE VALUES (3, 'SENTBOX', 2);
+        INSERT INTO MSG_FOLDER_TABLE VALUES (4, 'DRAFT', 3);
+        INSERT INTO MSG_FOLDER_TABLE VALUES (5, 'CBMSGBOX', 1);
+        INSERT INTO MSG_FOLDER_TABLE VALUES (6, 'SPAMBOX', 4);
+        INSERT INTO MSG_FOLDER_TABLE VALUES (7, 'SMS TEMPLATE', 5);
+        INSERT INTO MSG_FOLDER_TABLE VALUES (8, 'MMS TEMPLATE', 5);
+
+        INSERT INTO MSG_ADDRESS_TABLE VALUES (0, 0, 0, '', 0, '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '');"
+fi
+
+chown :6011 /opt/dbspace/.msg_service.db
+chown :6011 /opt/dbspace/.msg_service.db-journal
+
+
+chmod 660 /opt/dbspace/.msg_service.db
+chmod 660 /opt/dbspace/.msg_service.db-journal
+
+
+########## Setting Config Value ##########
+# General Options
+vconftool set -t bool db/msg/general/keep_copy 1
+vconftool set -t int db/msg/general/alert_tone 0
+vconftool set -t bool db/msg/general/auto_erase 0
+vconftool set -t bool db/msg/general/block_msg 0
+
+# SMS Send Options
+vconftool set -t int db/msg/sms_send/dcs 3
+vconftool set -t int db/msg/network_mode 2
+vconftool set -t bool db/msg/sms_send/reply_path 0
+vconftool set -t bool db/msg/sms_send/delivery_report 0
+vconftool set -t int db/msg/sms_send/save_storage 1
+
+# MMS Send Options
+vconftool set -t int db/msg/mms_send/msg_class 0
+vconftool set -t int db/msg/mms_send/priority 1
+vconftool set -t int db/msg/mms_send/expiry_time 0
+vconftool set -t int db/msg/mms_send/custom_delivery 0
+vconftool set -t bool db/msg/mms_send/sender_visibility 0
+vconftool set -t bool db/msg/mms_send/delivery_report 1
+vconftool set -t bool db/msg/mms_send/read_reply 1
+vconftool set -t bool db/msg/mms_send/keep_copy 0
+vconftool set -t bool db/msg/mms_send/body_replying 0
+vconftool set -t bool db/msg/mms_send/hide_recipients 0
+vconftool set -t bool db/msg/mms_send/report_allowed 1
+vconftool set -t int db/msg/mms_send/reply_charging 0
+vconftool set -t int db/msg/mms_send/reply_charging_deadline 0
+vconftool set -t int db/msg/mms_send/reply_charging_size 0
+vconftool set -t int db/msg/mms_send/delivery_time 0
+vconftool set -t int db/msg/mms_send/creation_mode 2
+
+# MMS Receive Options
+vconftool set -t int db/msg/mms_recv/home_network 0
+vconftool set -t int db/msg/mms_recv/abroad_network 0
+vconftool set -t bool db/msg/mms_recv/read_receipt 1
+vconftool set -t bool db/msg/mms_recv/delivery_receipt 1
+vconftool set -t bool db/msg/mms_recv/reject_unknown 0
+vconftool set -t bool db/msg/mms_recv/reject_advertisement 0
+
+# MMS Receive Options
+vconftool set -t int db/msg/mms_style/font_size 30
+vconftool set -t bool db/msg/mms_style/font_style/bold 0
+vconftool set -t bool db/msg/mms_style/font_style/italic 0
+vconftool set -t bool db/msg/mms_style/font_style/underline 0
+vconftool set -t int db/msg/mms_style/font_color/red 0
+vconftool set -t int db/msg/mms_style/font_color/green 0
+vconftool set -t int db/msg/mms_style/font_color/blue 0
+vconftool set -t int db/msg/mms_style/font_color/hue 255
+vconftool set -t int db/msg/mms_style/bg_color/red 255
+vconftool set -t int db/msg/mms_style/bg_color/green 255
+vconftool set -t int db/msg/mms_style/bg_color/blue 255
+vconftool set -t int db/msg/mms_style/bg_color/hue 255
+vconftool set -t int db/msg/mms_style/page_dur 2
+vconftool set -t int db/msg/mms_style/page_custom_dur 0
+vconftool set -t int db/msg/mms_style/page_dur_manual 0
+
+# Push Msg Options
+vconftool set -t bool db/msg/push_msg/recv_option 1
+vconftool set -t int db/msg/push_msg/service_load 1
+
+# CB Msg Options
+vconftool set -t bool db/msg/cb_msg/receive 0
+vconftool set -t bool db/msg/cb_msg/all_channel 0
+vconftool set -t int db/msg/cb_msg/max_sim_count 0
+vconftool set -t int db/msg/cb_msg/channel_count 0
+vconftool set -t bool db/msg/cb_msg/language/0 0
+vconftool set -t bool db/msg/cb_msg/language/1 0
+vconftool set -t bool db/msg/cb_msg/language/2 0
+vconftool set -t bool db/msg/cb_msg/language/3 0
+vconftool set -t bool db/msg/cb_msg/language/4 0
+vconftool set -t bool db/msg/cb_msg/language/5 0
+vconftool set -t bool db/msg/cb_msg/language/6 0
+vconftool set -t bool db/msg/cb_msg/language/7 0
+vconftool set -t bool db/msg/cb_msg/language/8 0
+vconftool set -t bool db/msg/cb_msg/language/9 0
+
+# SOS Msg Options
+vconftool set -t bool db/msg/sos_msg/send_option 0
+vconftool set -t int db/msg/sos_msg/recipient_count 0
+vconftool set -t int db/msg/sos_msg/repeat_count 0
+vconftool set -t string db/msg/sos_msg/msg_text ""
+vconftool set -t int db/msg/sos_msg/alert_type 0
+
+# Voice Mail Options
+vconftool set -t string db/msg/voice_mail/voice_mail_number "12345678"
+
+# MMS Size Options
+vconftool set -t int db/msg/size_opt/msg_size 300
+
+vconftool set -t int db/badge/org.tizen.message 0
+
+# Msg Count
+vconftool set -t int db/msg/recv_sms 0 -u 0
+vconftool set -t int db/msg/recv_mms 0 -u 0
+
+%postun -p /sbin/ldconfig
+
+%postun tools -p /sbin/ldconfig
+
+%postun -n sms-plugin -p /sbin/ldconfig
+
+%postun -n mms-plugin -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%dir /opt/data/msg-service
+%{_libdir}/libmsg_plugin_manager.so
+%{_libdir}/libmsg_mapi.so.*
+%{_libdir}/libmsg_framework_handler.so
+%{_libdir}/libmsg_transaction_manager.so
+%{_libdir}/libmsg_utils.so
+%{_libdir}/libmsg_transaction_proxy.so
+%{_sysconfdir}/rc.d/init.d/msg-server
+%{_sysconfdir}/rc.d/rc3.d/S70msg-server
+%{_sysconfdir}/rc.d/rc5.d/S70msg-server
+
+%files devel
+%defattr(-,root,root,-)
+%{_libdir}/libmsg_mapi.so
+%{_libdir}/pkgconfig/msg-service.pc
+%{_includedir}/msg-service/*
+
+
+%files tools
+%defattr(-,root,root,-)
+%{_bindir}/msg-helper
+%{_bindir}/msg-test-app
+%{_bindir}/msg-server
+%{_datadir}/media/Sherbet.wav
+%attr(0644,root,root)/usr/share/msg-service/plugin.cfg
+%attr(0644,root,root)/opt/etc/msg-service/Temp0_2.txt
+%attr(0644,root,root)/opt/etc/msg-service/Temp1_0.txt
+%attr(0644,root,root)/opt/etc/msg-service/audio.amr
+%attr(0644,root,root)/opt/etc/msg-service/P091120_104633.jpg
+%attr(0644,root,root)/opt/etc/msg-service/A.smi
+%attr(0644,root,root)/opt/etc/msg-service/V091120_104905.3gp
+%attr(0644,root,root)/opt/etc/msg-service/alert_on_call.mp3
+
+%files -n sms-plugin
+%defattr(-,root,root,-)
+%{_libdir}/libmsg_sms_plugin.so
+
+%files -n mms-plugin
+%defattr(-,root,root,-)
+%{_libdir}/libmsg_mms_plugin.so
+%{_libdir}/libmsg_mms_language_pack.so
diff --git a/plugin/mms_plugin/CMakeLists.txt b/plugin/mms_plugin/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..d121f6c
--- /dev/null
@@ -0,0 +1,100 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(mms-plugin CXX)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+##########################################################
+# Define MMS Language Pack
+##########################################################
+
+SET(MMS-LANGUAGE-PACK-SRCS
+       LanguagePack/MmsPluginWmLngLatinUni.cpp
+       LanguagePack/MmsPluginWmLngString.cpp
+       LanguagePack/MmsPluginWmLngUTF8Uni.cpp
+       LanguagePack/MmsPluginWmLngUniUTF8.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include/common
+       ${CMAKE_SOURCE_DIR}/include/utils
+       ${CMAKE_CURRENT_SOURCE_DIR}/include
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(mms_language_pkgs REQUIRED glib-2.0 dlog)
+
+FOREACH(flag ${mms_language_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${MMS-LANGUAGE-PACK-LIB} SHARED ${MMS-LANGUAGE-PACK-SRCS})
+TARGET_LINK_LIBRARIES(${MMS-LANGUAGE-PACK-LIB} ${mms_language_pkgs_LDFLAGS} ${UTILS-LIB})
+
+INSTALL(TARGETS ${MMS-LANGUAGE-PACK-LIB} LIBRARY DESTINATION lib)
+
+##########################################################
+# Define MMS Plugin
+##########################################################
+
+SET(MMS-PLUGIN-SRCS
+       MmsPluginTransport.cpp
+       MmsPluginMain.cpp
+       MmsPluginEventHandler.cpp
+       MmsPluginStorage.cpp
+       MmsPluginMessage.cpp
+       MmsPluginMIME.cpp
+       MmsPluginDecode.cpp
+       MmsPluginAvCodec.cpp
+       MmsPluginDebug.cpp
+       MmsPluginConnManWrapper.cpp
+       MmsPluginUserAgent.cpp
+       MmsPluginHttp.cpp
+       MmsPluginEncode.cpp
+       MmsPluginCodec.cpp
+       MmsPluginInternal.cpp
+       MmsPluginContentCodec.cpp
+       MmsPluginSmil.cpp
+       MmsPluginSMILValidate.cpp
+       MmsPluginDrm.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include/common
+       ${CMAKE_SOURCE_DIR}/include/framework
+       ${CMAKE_SOURCE_DIR}/include/msg_helper
+       ${CMAKE_SOURCE_DIR}/include/utils
+       ${CMAKE_CURRENT_SOURCE_DIR}/include
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(mms_plugin_pkgs REQUIRED glib-2.0 network libxml-2.0 drm-client libcurl mm-fileinfo mmutil-jpeg vconf dlog media-thumbnail)
+
+FOREACH(flag ${mms_plugin_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+#ADD_DEFINITIONS("-DWno-write-strings")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${MMS-PLUGIN-LIB} SHARED ${MMS-PLUGIN-SRCS})
+TARGET_LINK_LIBRARIES(${MMS-PLUGIN-LIB} ${mms_plugin_pkgs_LDFLAGS} ${MMS-LANGUAGE-PACK-LIB} ${UTILS-LIB})
+
+INSTALL(TARGETS ${MMS-PLUGIN-LIB} LIBRARY DESTINATION lib)
+
diff --git a/plugin/mms_plugin/LanguagePack/MmsPluginWmLngLatinUni.cpp b/plugin/mms_plugin/LanguagePack/MmsPluginWmLngLatinUni.cpp
new file mode 100755 (executable)
index 0000000..936c096
--- /dev/null
@@ -0,0 +1,1131 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MmsPluginWmLngPack.h"
+#include "MmsPluginMessage.h"
+#include <stdlib.h>
+
+
+#define                MAX_ASCII                       256
+#define                MAX_ASCII_NUM           255
+
+static void     __WmLngReverseKeyCode(UCHAR *pOutStr, MCHAR *pInputStr, UINT len);
+static UINT     __WmLngLatin12UnicodeN(MCHAR *pOutStr, UCHAR *pInputStr, UINT len);
+static int      __WmLngConvertLatin12Unicode (MCHAR *des, UCHAR *str, UINT len);
+
+#define tabLatin2UniMax 93
+#define tabLatin3UniMax 87
+#define tabLatin4UniMax 96
+#define tabLatin8UniMax 60
+#define tabLatin15UniMax 96
+#define tabLatin5UniMax 96
+#define tabWin1251UniMax 128
+#define tabKoi8rUniMax 128
+#define tabKoi8uUniMax 128
+
+#define        SIM_SMSP_ALPHA_ID_MAX_LEN 30
+#define        SMS_MCHAR_TO_SIM_ALPHA_MASK 0x80
+#define        SMS_SIM_ALPHA_TO_MCHAR_MASK 0x7F
+
+
+/* latin2 table */
+typedef struct {
+       UCHAR latin2;
+       MCHAR unicode;
+}Latin2UniTable;
+
+const Latin2UniTable tabLatin2Uni[] = {
+       {0xA0,0x0020},{0xA1,0x0104},{0xA3,0x0141},{0xA4,0x00A4},{0xA5,0x013D},
+       {0xA6,0x015A},{0xA7,0x00A7},{0xA8,0x00A8},{0xA9,0x0160},{0xAA,0x015E},
+       {0xAB,0x0164},{0xAC,0x0179},{0xAD,0x00AD},{0xAE,0x017D},{0xAF,0x017B},
+       {0xB0,0x00B0},{0xB1,0x0105},{0xB2,0x00B8},{0xB3,0x0142},{0xB4,0x00B4},
+       {0xB5,0x012D},{0xB7,0x015B},{0xB8,0x00B8},{0xB9,0x0161},{0xBA,0x015F},
+       {0xBB,0x0165},{0xBC,0x017A},{0xBE,0x017E},{0xBF,0x017C},{0xC0,0x0154},
+       {0xC1,0x00C1},{0xC2,0x00C2},{0xC3,0x0102},{0xC4,0x00C4},{0xC5,0x0139},
+       {0xC6,0x0106},{0xC7,0x00C7},{0xC8,0x010C},{0xC9,0x00C9},{0xCA,0x0118},
+       {0xCB,0x00CB},{0xCC,0x0114},{0xCD,0x00CD},{0xCE,0x00CE},{0xCF,0x010E},
+       {0xD0,0x00D0},{0xD1,0x0143},{0xD2,0x0147},{0xD3,0x00D3},{0xD4,0x00D4},
+       {0xD5,0x0150},{0xD6,0x00D6},{0xD7,0x00D7},{0xD8,0x0158},{0xD9,0x016E},
+       {0xDA,0x00DA},{0xDB,0x0170},{0xDC,0x00DC},{0xDD,0x00DD},{0xDE,0x0162},
+       {0xDF,0x00DF},{0xE0,0x0155},{0xE1,0x00E1},{0xE2,0x00E2},{0xE3,0x0103},
+       {0xE4,0x00E4},{0xE5,0x013A},{0xE6,0x0107},{0xE7,0x00E7},{0xE8,0x010D},
+       {0xE9,0x00E9},{0xEA,0x0119},{0xEB,0x00EB},{0xEC,0x011B},{0xED,0x00ED},
+       {0xEE,0x00EE},{0xEF,0x010F},{0xF0,0x0111},{0xF1,0x0144},{0xF2,0x0148},
+       {0xF3,0x00F3},{0xF4,0x00F4},{0xF5,0x0151},{0xF6,0x00F6},{0xF7,0x00F7},
+       {0xF8,0x0159},{0xF9,0x016F},{0xFA,0x00FA},{0xFB,0x0171},{0xFC,0x00FC},
+       {0xFD,0x00FD},{0xFE,0x0163},{0xFF,0x00B7},
+};
+
+/* latin3 table */
+typedef struct {
+       UCHAR latin3;
+       MCHAR unicode;
+}Latin3UniTable;
+
+const Latin3UniTable tabLatin3Uni[] = {
+       {0xA0,0x0020},{0xA1,0x0126},{0xA2,0x02D8},{0xA3,0x00A3},{0xA4,0x00A4},
+       {0xA6,0x0124},{0xA7,0x00A7},{0xA8,0x00A8},{0xA9,0x0130},{0xAA,0x015E},
+       {0xAB,0x011E},{0xAC,0x0134},{0xAD,0x00AD},{0xAF,0x017B},{0xB0,0x00B0},
+       {0xB1,0x0127},{0xB2,0x00B2},{0xB3,0x00B3},{0xB4,0x00B4},{0xB5,0x00B5},
+       {0xB6,0x0125},{0xB7,0x00B7},{0xB8,0x00B8},{0xB9,0x0131},{0xBA,0x015F},
+       {0xBB,0x011F},{0xBC,0x0135},{0xBD,0x00BD},{0xBF,0x017C},{0xC0,0x00C0},
+       {0xC1,0x00C1},{0xC2,0x00C2},{0xC4,0x00C4},{0xC5,0x010A},{0xC6,0x0108},
+       {0xC7,0x00C7},{0xC8,0x00C8},{0xC9,0x00C9},{0xCA,0x00CA},{0xCB,0x00CB},
+       {0xCC,0x00CC},{0xCD,0x00CD},{0xCE,0x00CE},{0xCF,0x00CF},{0xD1,0x00D1},
+       {0xD2,0x00D2},{0xD3,0x00D3},{0xD4,0x00D4},{0xD6,0x00D6},{0xD7,0x00D7},
+       {0xD8,0x011C},{0xD9,0x00D9},{0xDA,0x00DA},{0xDB,0x00DB},{0xDC,0x00DC},
+       {0xDE,0x015C},{0xDF,0x00DF},{0xE0,0x00E0},{0xE1,0x00E1},{0xE2,0x00E2},
+       {0xE4,0x00E4},{0xE5,0x010B},{0xE6,0x0109},{0xE7,0x00E7},{0xE8,0x00E8},
+       {0xE9,0x00E9},{0xEA,0x00EA},{0xEB,0x00EB},{0xEC,0x00EC},{0xED,0x00ED},
+       {0xEE,0x00EE},{0xEF,0x00EF},{0xF1,0x00F1},{0xF2,0x00F2},{0xF3,0x00F3},
+       {0xF4,0x00F4},{0xF5,0x0121},{0xF6,0x00F6},{0xF7,0x00F7},{0xF8,0x011D},
+       {0xF9,0x00F9},{0xFA,0x00FA},{0xFB,0x00FB},{0xFC,0x00FC},{0xFD,0x016D},
+       {0xFE,0x015D},{0xFF,0x02D9},
+};
+/* latin4 table */
+typedef struct {
+       UCHAR latin4;
+       MCHAR unicode;
+}Latin4UniTable;
+
+const Latin4UniTable tabLatin4Uni[] = {
+       {0xA0,0x0020},{0xA1,0x0104},{0xA2,0x0138},{0xA3,0x0156},{0xA4,0x00A4},
+       {0xA5,0x0128},{0xA6,0x013B},{0xA7,0x00A7},{0xA8,0x00A8},{0xA9,0x0160},
+       {0xAA,0x0112},{0xAB,0x0122},{0xAC,0x0166},{0xAD,0x00AD},{0xAE,0x017D},
+       {0xAF,0x00AF},{0xB0,0x00B0},{0xB1,0x0105},{0xB2,0x02DB},{0xB3,0x0157},
+       {0xB4,0x00B4},{0xB5,0x0129},{0xB6,0x013C},{0xB7,0x02C7},{0xB8,0x00B8},
+       {0xB9,0x0161},{0xBA,0x0113},{0xBB,0x0123},{0xBC,0x0167},{0xBD,0x014A},
+       {0xBE,0x017E},{0xBF,0x014B},{0xC0,0x0100},{0xC1,0x00C1},{0xC2,0x00C2},
+       {0xC3,0x00C3},{0xC4,0x00C4},{0xC5,0x00C5},{0xC6,0x00C6},{0xC7,0x012E},
+       {0xC8,0x010C},{0xC9,0x00C9},{0xCA,0x0118},{0xCB,0x00CB},{0xCC,0x0116},
+       {0xCD,0x00CD},{0xCE,0x00CE},{0xCF,0x012A},{0xD0,0x0110},{0xD1,0x0145},
+       {0xD2,0x014C},{0xD3,0x0136},{0xD4,0x00D4},{0xD5,0x00D5},{0xD6,0x00D6},
+       {0xD7,0x00D7},{0xD8,0x00D8},{0xD9,0x0172},{0xDA,0x00DA},{0xDB,0x00DB},
+       {0xDC,0x00DC},{0xDD,0x0168},{0xDE,0x016A},{0xDF,0x00DF},{0xE0,0x0101},
+       {0xE1,0x00E1},{0xE2,0x00E2},{0xE3,0x00E3},{0xE4,0x00E4},{0xE5,0x00E5},
+       {0xE6,0x00E6},{0xE7,0x012F},{0xE8,0x010D},{0xE9,0x00E9},{0xEA,0x0119},
+       {0xEB,0x00EB},{0xEC,0x0117},{0xED,0x00ED},{0xEE,0x00EE},{0xEF,0x012B},
+       {0xF0,0x0111},{0xF1,0x0146},{0xF2,0x014D},{0xF3,0x0137},{0xF4,0x00F4},
+       {0xF5,0x00F5},{0xF6,0x00F6},{0xF7,0x00F7},{0xF8,0x00F8},{0xF9,0x0173},
+       {0xFA,0x00FA},{0xFB,0x00FB},{0xFC,0x00FC},{0xFD,0x0169},{0xFE,0x016B},
+       {0xFF,0x02D9},
+
+};
+/* latin8 table */
+typedef struct {
+       UCHAR latin8;
+       MCHAR unicode;
+}Latin8UniTable;
+
+const Latin8UniTable tabLatin8Uni[] = {
+       {0xA0,0x0020},{0xA2,0x00A2},{0xA3,0x00A3},{0xA4,0x00A4},{0xA5,0x00A5},
+       {0xA6,0x00A6},{0xA7,0x00A7},{0xA8,0x00A8},{0xA9,0x00A9},{0xAA,0x00D7},
+       {0xAB,0x00AB},{0xAC,0x00AC},{0xAD,0x00AD},{0xAE,0x00AE},{0xAF,0x203E},
+       {0xB0,0x00B0},{0xB1,0x00B1},{0xB2,0x00B2},{0xB3,0x00B3},{0xB4,0x00B4},
+       {0xB5,0x00B5},{0xB6,0x00B6},{0xB7,0x00B7},{0xB8,0x00B8},{0xB9,0x00B9},
+       {0xBA,0x00F7},{0xBB,0x00BB},{0xBC,0x00BC},{0xBD,0x00BD},{0xBE,0x00BE},
+       {0xDF,0x2017},{0xE0,0x05D0},{0xE1,0x05D1},{0xE2,0x05D2},{0xE3,0x05D3},
+       {0xE4,0x05D4},{0xE5,0x05D5},{0xE6,0x05D6},{0xE7,0x05D7},{0xE8,0x05D8},
+       {0xE9,0x05D9},{0xEA,0x05DA},{0xEB,0x05DB},{0xEC,0x05DC},{0xED,0x05DD},
+       {0xEE,0x05DE},{0xEF,0x05DF},{0xF0,0x05E0},{0xF1,0x05E1},{0xF2,0x05E2},
+       {0xF3,0x05E3},{0xF4,0x05E4},{0xF5,0x05E5},{0xF6,0x05E6},{0xF7,0x05E7},
+       {0xF8,0x05E8},{0xF9,0x05E9},{0xFA,0x05EA},{0xFD,0x200E},{0xFE,0x200F},
+};
+
+/* latin15 table */
+typedef struct {
+       UCHAR latin15;
+       MCHAR unicode;
+}Latin15UniTable;
+
+const Latin15UniTable tabLatin15Uni[] = {
+       {0xA0,0x0020},{0xA1,0x00A1},{0xA2,0x00A2},{0xA3,0x00A3},{0xA4,0x20AC},
+       {0xA5,0x00A5},{0xA6,0x0160},{0xA7,0x00A7},{0xA8,0x0161},{0xA9,0x00A9},
+       {0xAA,0x00AA},{0xAB,0x00AB},{0xAC,0x00AC},{0xAD,0x00AD},{0xAE,0x00AE},
+       {0xAF,0x00AF},{0xB0,0x00B0},{0xB1,0x00B1},{0xB2,0x00B2},{0xB3,0x00B3},
+       {0xB4,0x017D},{0xB5,0x00B5},{0xB6,0x00B6},{0xB7,0x00B7},{0xB8,0x017E},
+       {0xB9,0x00B9},{0xBA,0x00BA},{0xBB,0x00BB},{0xBC,0x0152},{0xBD,0x0153},
+       {0xBE,0x0178},{0xBF,0x00BF},{0xC0,0x00C0},{0xC1,0x00C1},{0xC2,0x00C2},
+       {0xC3,0x00C3},{0xC4,0x00C4},{0xC5,0x00C5},{0xC6,0x00C6},{0xC7,0x00C7},
+       {0xC8,0x00C8},{0xC9,0x00C9},{0xCA,0x00CA},{0xCB,0x00CB},{0xCC,0x00CC},
+       {0xCD,0x00CD},{0xCE,0x00CE},{0xCF,0x00CF},{0xD0,0x00D0},{0xD1,0x00D1},
+       {0xD2,0x00D2},{0xD3,0x00D3},{0xD4,0x00D4},{0xD5,0x00D5},{0xD6,0x00D6},
+       {0xD7,0x00D7},{0xD8,0x00D8},{0xD9,0x00D9},{0xDA,0x00DA},{0xDB,0x00DB},
+       {0xDC,0x00DC},{0xDD,0x00DD},{0xDE,0x00DE},{0xDF,0x00DF},{0xE0,0x00E0},
+       {0xE1,0x00E1},{0xE2,0x00E2},{0xE3,0x00E3},{0xE4,0x00E4},{0xE5,0x00E5},
+       {0xE6,0x00E6},{0xE7,0x00E7},{0xE8,0x00E8},{0xE9,0x00E9},{0xEA,0x00EA},
+       {0xEB,0x00EB},{0xEC,0x00EC},{0xED,0x00ED},{0xEE,0x00EE},{0xEF,0x00EF},
+       {0xF0,0x00F0},{0xF1,0x00F1},{0xF2,0x00F2},{0xF3,0x00F3},{0xF4,0x00F4},
+       {0xF5,0x00F5},{0xF6,0x00F6},{0xF7,0x00F7},{0xF8,0x00F8},{0xF9,0x00F9},
+       {0xFA,0x00FA},{0xFB,0x00FB},{0xFC,0x00FC},{0xFD,0x00FD},{0xFE,0x00FE},
+       {0xFF,0x00FF},
+};
+
+
+/* Win1251 table */
+typedef struct {
+       UCHAR win1251;
+       MCHAR unicode;
+}Win1251UniTable;
+const Win1251UniTable tabWin1251Uni[] = {
+       {0x80,0x0402},{0x81,0x0403},{0x82,0x201A},{0x83,0x0453},{0x84,0x201E},
+       {0x85,0x2026},{0x86,0x2020},{0x87,0x2021},{0x88,0x20AC},{0x89,0x2030},
+       {0x8A,0x0409},{0x8B,0x2039},{0x8C,0x040A},{0x8D,0x040C},{0x8E,0x040B},
+       {0x8F,0x040F},{0x90,0x0452},{0x91,0x2018},{0x92,0x2019},{0x93,0x201C},
+       {0x94,0x201D},{0x95,0x2022},{0x96,0x2013},{0x97,0x2014},{0x98,0x0000},
+       {0x99,0x2122},{0x9A,0x0459},{0x9B,0x203A},{0x9C,0x045A},{0x9D,0x045C},
+       {0x9E,0x045B},{0x9F,0x045F},{0xA0,0x00a0},{0xA1,0x040e},{0xA2,0x045e},
+       {0xA3,0x0408},{0xA4,0x00a4},{0xA5,0x0490},{0xA6,0x00a6},{0xA7,0x00a7},
+       {0xA8,0x0401},{0xA9,0x00a9},{0xAA,0x0404},{0xAB,0x00ab},{0xAC,0x00ac},
+       {0xAD,0x00ad},{0xAE,0x00ae},{0xAF,0x0407},{0xB0,0x00b0},{0xB1,0x00b1},
+       {0xB2,0x0406},{0xB3,0x0456},{0xB4,0x0491},{0xB5,0x00b5},{0xB6,0x00b6},
+       {0xB7,0x00b7},{0xB8,0x0451},{0xB9,0x2116},{0xBA,0x0454},{0xBB,0x00bb},
+       {0xBC,0x0458},{0xBD,0x0405},{0xBE,0x0455},{0xBF,0x0457},{0xC0,0x0410},
+       {0xC1,0x0411},{0xC2,0x0412},{0xC3,0x0413},{0xC4,0x0414},{0xC5,0x0415},
+       {0xC6,0x0416},{0xC7,0x0417},{0xC8,0x0418},{0xC9,0x0419},{0xCA,0x041a},
+       {0xCB,0x041b},{0xCC,0x041c},{0xCD,0x041d},{0xCE,0x041e},{0xCF,0x041f},
+       {0xD0,0x0420},{0xD1,0x0421},{0xD2,0x0422},{0xD3,0x0423},{0xD4,0x0424},
+       {0xD5,0x0425},{0xD6,0x0426},{0xD7,0x0427},{0xD8,0x0428},{0xD9,0x0429},
+       {0xDA,0x042a},{0xDB,0x042b},{0xDC,0x042c},{0xDD,0x042d},{0xDE,0x042e},
+       {0xDF,0x042f},{0xE0,0x0430},{0xE1,0x0431},{0xE2,0x0432},{0xE3,0x0433},
+       {0xE4,0x0434},{0xE5,0x0435},{0xE6,0x0436},{0xE7,0x0437},{0xE8,0x0438},
+       {0xE9,0x0439},{0xEA,0x043a},{0xEB,0x043b},{0xEC,0x043c},{0xED,0x043d},
+       {0xEE,0x043e},{0xEF,0x043f},{0xF0,0x0440},{0xF1,0x0441},{0xF2,0x0442},
+       {0xF3,0x0443},{0xF4,0x0444},{0xF5,0x0445},{0xF6,0x0446},{0xF7,0x0447},
+       {0xF8,0x0448},{0xF9,0x0449},{0xFA,0x044a},{0xFB,0x044b},{0xFC,0x044c},
+       {0xFD,0x044d},{0xFE,0x044e},{0xFF,0x044f}
+};
+
+
+/* Koi8-r table */
+typedef struct {
+       UCHAR koi8r;
+       MCHAR unicode;
+}Koi8rUniTable;
+const Koi8rUniTable tabKoi8rUni[] = {
+       {0x80,0x2500},{0x81,0x2502},{0x82,0x250C},{0x83,0x2510},{0x84,0x2514},
+       {0x85,0x2518},{0x86,0x251C},{0x87,0x2524},{0x88,0x252C},{0x89,0x2534},
+       {0x8A,0x253C},{0x8B,0x2580},{0x8C,0x2584},{0x8D,0x2588},{0x8E,0x258C},
+       {0x8F,0x2590},{0x90,0x2591},{0x91,0x2592},{0x92,0x2593},{0x93,0x2320},
+       {0x94,0x25A0},{0x95,0x2219},{0x96,0x221A},{0x97,0x2248},{0x98,0x2264},
+       {0x99,0x2265},{0x9A,0x00A0},{0x9B,0x2321},{0x9C,0x00B0},{0x9D,0x00B2},
+       {0x9E,0x00B7},{0x9F,0x00F7},{0xA0,0x2550},{0xA1,0x2551},{0xA2,0x2552},
+       {0xA3,0x0451},{0xA4,0x2553},{0xA5,0x2554},{0xA6,0x2555},{0xA7,0x2556},
+       {0xA8,0x2557},{0xA9,0x2558},{0xAA,0x2559},{0xAB,0x255A},{0xAC,0x255B},
+       {0xAD,0x255C},{0xAE,0x255D},{0xAF,0x255E},{0xB0,0x255F},{0xB1,0x2560},
+       {0xB2,0x2561},{0xB3,0x0401},{0xB4,0x2562},{0xB5,0x2563},{0xB6,0x2564},
+       {0xB7,0x2565},{0xB8,0x2566},{0xB9,0x2567},{0xBA,0x2568},{0xBB,0x2569},
+       {0xBC,0x256A},{0xBD,0x256B},{0xBE,0x256C},{0xBF,0x00A9},{0xC0,0x044E},
+       {0xC1,0x0430},{0xC2,0x0431},{0xC3,0x0446},{0xC4,0x0434},{0xC5,0x0435},
+       {0xC6,0x0444},{0xC7,0x0433},{0xC8,0x0445},{0xC9,0x0438},{0xCA,0x0439},
+       {0xCB,0x043A},{0xCC,0x043B},{0xCD,0x043C},{0xCE,0x043D},{0xCF,0x043E},
+       {0xD0,0x043F},{0xD1,0x044F},{0xD2,0x0440},{0xD3,0x0441},{0xD4,0x0442},
+       {0xD5,0x0443},{0xD6,0x0436},{0xD7,0x0432},{0xD8,0x044C},{0xD9,0x044B},
+       {0xDA,0x0437},{0xDB,0x0448},{0xDC,0x044D},{0xDD,0x0449},{0xDE,0x0447},
+       {0xDF,0x044A},{0xE0,0x042E},{0xE1,0x0410},{0xE2,0x0411},{0xE3,0x0426},
+       {0xE4,0x0414},{0xE5,0x0415},{0xE6,0x0424},{0xE7,0x0413},{0xE8,0x0425},
+       {0xE9,0x0418},{0xEA,0x0419},{0xEB,0x041A},{0xEC,0x041B},{0xED,0x041C},
+       {0xEE,0x041D},{0xEF,0x041E},{0xF0,0x041F},{0xF1,0x042F},{0xF2,0x0420},
+       {0xF3,0x0421},{0xF4,0x0422},{0xF5,0x0423},{0xF6,0x0416},{0xF7,0x0412},
+       {0xF8,0x042C},{0xF9,0x042B},{0xFA,0x0417},{0xFB,0x0428},{0xFC,0x042D},
+       {0xFD,0x0429},{0xFE,0x0427},{0xFF,0x042A}
+};
+
+
+
+/* Koi8-u table */
+typedef struct {
+       UCHAR koi8u;
+       MCHAR unicode;
+}Koi8uUniTable;
+
+const Koi8uUniTable tabKoi8uUni[] = {
+       {0x80,0x2500},{0x81,0x2502},{0x82,0x250C},{0x83,0x2510},{0x84,0x2514},
+       {0x85,0x2518},{0x86,0x251C},{0x87,0x2524},{0x88,0x252C},{0x89,0x2534},
+       {0x8A,0x253C},{0x8B,0x2580},{0x8C,0x2584},{0x8D,0x2588},{0x8E,0x258C},
+       {0x8F,0x2590},{0x90,0x2591},{0x91,0x2592},{0x92,0x2593},{0x93,0x2320},
+       {0x94,0x25A0},{0x95,0x2219},{0x96,0x221A},{0x97,0x2248},{0x98,0x2264},
+       {0x99,0x2265},{0x9A,0x00A0},{0x9B,0x2321},{0x9C,0x00B0},{0x9D,0x00B2},
+       {0x9E,0x00B7},{0x9F,0x00F7},{0xA0,0x2550},{0xA1,0x2551},{0xA2,0x2552},
+       {0xA3,0x0451},{0xA4,0x0454},{0xA5,0x2554},{0xA6,0x0456},{0xA7,0x0457},
+       {0xA8,0x2557},{0xA9,0x2558},{0xAA,0x2559},{0xAB,0x255A},{0xAC,0x255B},
+       {0xAD,0x0491},{0xAE,0x255D},{0xAF,0x255E},{0xB0,0x255F},{0xB1,0x2560},
+       {0xB2,0x2561},{0xB3,0x0401},{0xB4,0x0404},{0xB5,0x2563},{0xB6,0x0406},
+       {0xB7,0x0407},{0xB8,0x2566},{0xB9,0x2567},{0xBA,0x2568},{0xBB,0x2569},
+       {0xBC,0x256A},{0xBD,0x0490},{0xBE,0x256C},{0xBF,0x00A9},{0xC0,0x044E},
+       {0xC1,0x0430},{0xC2,0x0431},{0xC3,0x0446},{0xC4,0x0434},{0xC5,0x0435},
+       {0xC6,0x0444},{0xC7,0x0433},{0xC8,0x0445},{0xC9,0x0438},{0xCA,0x0439},
+       {0xCB,0x043A},{0xCC,0x043B},{0xCD,0x043C},{0xCE,0x043D},{0xCF,0x043E},
+       {0xD0,0x043F},{0xD1,0x044F},{0xD2,0x0440},{0xD3,0x0441},{0xD4,0x0442},
+       {0xD5,0x0443},{0xD6,0x0436},{0xD7,0x0432},{0xD8,0x044C},{0xD9,0x044B},
+       {0xDA,0x0437},{0xDB,0x0448},{0xDC,0x044D},{0xDD,0x0449},{0xDE,0x0447},
+       {0xDF,0x044A},{0xE0,0x042E},{0xE1,0x0410},{0xE2,0x0411},{0xE3,0x0426},
+       {0xE4,0x0414},{0xE5,0x0415},{0xE6,0x0424},{0xE7,0x0413},{0xE8,0x0425},
+       {0xE9,0x0418},{0xEA,0x0419},{0xEB,0x041A},{0xEC,0x041B},{0xED,0x041C},
+       {0xEE,0x041D},{0xEF,0x041E},{0xF0,0x041F},{0xF1,0x042F},{0xF2,0x0420},
+       {0xF3,0x0421},{0xF4,0x0422},{0xF5,0x0423},{0xF6,0x0416},{0xF7,0x0412},
+       {0xF8,0x042C},{0xF9,0x042B},{0xFA,0x0417},{0xFB,0x0428},{0xFC,0x042D},
+       {0xFD,0x0429},{0xFE,0x0427},{0xFF,0x042A}
+};
+
+
+/* Latin5 table */
+typedef struct {
+       UCHAR Latin5;
+       MCHAR unicode;
+}Latin5UniTable;
+
+const Latin5UniTable tabLatin5Uni[] = {
+       {0xA0,0x00A0},{0xA1,0x0401},{0xA2,0x0402},{0xA3,0x0403},{0xA4,0x0404},
+       {0xA5,0x0405},{0xA6,0x0406},{0xA7,0x0407},{0xA8,0x0408},{0xA9,0x0409},
+       {0xAA,0x040A},{0xAB,0x040B},{0xAC,0x040C},{0xAD,0x00AD},{0xAE,0x040E},
+       {0xAF,0x040F},{0xB0,0x0410},{0xB1,0x0411},{0xB2,0x0412},{0xB3,0x0413},
+       {0xB4,0x0414},{0xB5,0x0415},{0xB6,0x0416},{0xB7,0x0417},{0xB8,0x0418},
+       {0xB9,0x0419},{0xBA,0x041A},{0xBB,0x041B},{0xBC,0x041C},{0xBD,0x041D},
+       {0xBE,0x041E},{0xBF,0x041F},{0xC0,0x0420},{0xC1,0x0421},{0xC2,0x0422},
+       {0xC3,0x0423},{0xC4,0x0424},{0xC5,0x0425},{0xC6,0x0426},{0xC7,0x0427},
+       {0xC8,0x0428},{0xC9,0x0429},{0xCA,0x042A},{0xCB,0x042B},{0xCC,0x042C},
+       {0xCD,0x042D},{0xCE,0x042E},{0xCF,0x042F},{0xD0,0x0430},{0xD1,0x0431},
+       {0xD2,0x0432},{0xD3,0x0433},{0xD4,0x0434},{0xD5,0x0435},{0xD6,0x0436},
+       {0xD7,0x0437},{0xD8,0x0438},{0xD9,0x0439},{0xDA,0x043A},{0xDB,0x043B},
+       {0xDC,0x043C},{0xDD,0x043D},{0xDE,0x043E},{0xDF,0x043F},{0xE0,0x0440},
+       {0xE1,0x0441},{0xE2,0x0442},{0xE3,0x0443},{0xE4,0x0444},{0xE5,0x0445},
+       {0xE6,0x0446},{0xE7,0x0447},{0xE8,0x0448},{0xE9,0x0449},{0xEA,0x044A},
+       {0xEB,0x044B},{0xEC,0x044C},{0xED,0x044D},{0xEE,0x044E},{0xEF,0x044F},
+       {0xF0,0x2116},{0xF1,0x0451},{0xF2,0x0452},{0xF3,0x0453},{0xF4,0x0454},
+       {0xF5,0x0455},{0xF6,0x0456},{0xF7,0x0457},{0xF8,0x0458},{0xF9,0x0459},
+       {0xFA,0x045A},{0xFB,0x045B},{0xFC,0x045C},{0xFD,0x00A7},{0xFE,0x045E},
+       {0xFF,0x045F},
+
+};
+
+#define __LOCALCODE_TO_UTF8
+
+#ifdef __LOCALCODE_TO_UTF8
+
+bool __WmConvertCodeBufferSizeCheck (char *ftnName, int outBufSize, int requiredBufSize)
+{
+       if (outBufSize < requiredBufSize) {
+
+               if (outBufSize == sizeof(void*)) {  // if it is not array
+                       MSG_DEBUG("__WmConvertCodeBufferSizeCheck: Out buffer size seems to be small (%s)\n",ftnName);
+               } else {
+                       MSG_DEBUG("__WmConvertCodeBufferSizeCheck: Buffer size is too small %s: OutBuffer(%d), RequiredBufSize(%d)\n",ftnName,outBufSize,requiredBufSize);
+               }
+               return false;
+       }
+       return true;
+}
+
+
+
+MCHAR __WmLngSwapShort(MCHAR aShort)
+{
+       return ((aShort << 8) + (aShort >> 8));
+}
+
+/**
+ * converting byte ordering between Network and device
+ *
+ * @param      mszOutput       [out] converted[destination] MCHAR buffer
+ * @param      mszInput                [in]    source MCHAR buffer
+ * @param      length          [in]    source MCHAR's string length (not byte count)
+ *
+ * @return     This function returns a true on success, or false on failure.
+ */
+MCHAR* __WmLngSwapPCode(MCHAR *mszOutput, MCHAR *mszInput, int length)
+{
+       int     i;
+
+       for (i = 0; i < length; i++) {
+               if (mszInput[i] == (MCHAR)NULL)
+                       break;
+
+               mszOutput[i] = __WmLngSwapShort(mszInput[i]);
+       }
+
+       mszOutput[i] = NULL;
+
+       return mszOutput;
+}
+
+
+/**
+ * This function convert character Processcode(Unicode) to Localcode(UTF8)
+ *
+ * @param      pszOutText      :       Output Buffer Pointer to LocalCode(UTF8)
+ * @param      mszInText       :       Input Buffer Pointer to ProcessCode(UniCode)
+ * @return     This function returns true on success, or false on failure.
+ * @see                WmConvert2LCodeN
+ */
+bool WmConvert2LCode(char *pszOutText, int outBufSize, MCHAR *mszInText)
+{
+       int charCount;
+       charCount = WmStrlen(mszInText);
+       if (charCount == 0)
+               pszOutText[0] = '\0';
+
+       if ((WmConvertPCode2UTF((UCHAR*)pszOutText, outBufSize, mszInText, charCount) == true)) {
+               return true;
+       } else {
+               MSG_DEBUG("WmConvert2LCode: Converting Unicode(%x) to utf8 code failed\n",mszInText);
+               return false;
+       }
+}
+
+/**
+ * This function convert character Localcode(UTF8) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      szInText                :       Input Buffer Pointer to LocalCode(UTF8)
+ * @return     This function returns true on success, or false on failure.
+ * @see                WmConvert2PCodeN
+ */
+bool WmConvert2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
+{
+       int byteCount;
+
+       byteCount = strlen((char*) szInText);
+
+       if (byteCount == 0)
+               pmszOutText[0] = NULL;
+
+       if((WmConvertUTF2PCode(pmszOutText, outBufSize,(UCHAR*)szInText, byteCount) == true)) {
+               return true;
+       } else {
+               MSG_DEBUG("WmConvert2PCode: Converting UTF8code(%x) to Unicode failed\n",szInText);
+               return false;
+       }
+}
+
+/**
+ * This function convert N'th byte Localcode(UTF8) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to  ProcessCode(UniCode)
+ * @param      szInText                :       Input Buffer Pointer to LocalCode(KSC5601)
+ * @param      byteCount               :       byte number for converting character
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ * @see                WmConvert2PCode
+ */
+bool WmConvert2PCodeN(MCHAR *pmszOutText, int outBufSize, char *szInText, int byteCount)
+{
+       if ((WmConvertUTF2PCode (pmszOutText, outBufSize, (UCHAR*)szInText, byteCount) == true)) {
+               return true;
+       } else {
+               MSG_DEBUG("WmConvert2PCodeN: Converting UTF8code(%x) to Unicode failed\n",szInText);
+               return false;
+       }
+}
+
+/**
+ * This function convert N'th character Processcode(Unicode) to Localcode(UTF8)
+ *
+ * @param      pszOutText              :       Output Buffer Pointer to LocalCode(UTF8)
+ * @param      mszInText               :       Input Buffer Pointer to ProcessCode(UniCode)
+ * @param      charCount               :       number for convert n'th chararcter
+ * @return     This function returns true on success, or false on failure.
+ *
+ * @see                WmConvert2LCode
+ */
+bool WmConvert2LCodeN(char *pszOutText, int outBufSize, MCHAR *mszInText, int charCount)
+{
+       if ( (WmConvertPCode2UTF((UCHAR*)pszOutText, outBufSize, mszInText, charCount) == true)) {
+               return true;
+       } else {
+               MSG_DEBUG("WmConvert2LCodeN: Converting Unicode(%x) to utf8 code failed\n",mszInText);
+               return false;
+       }
+}
+
+/**
+ * This function return output LocalCode Buffer Size
+ *
+ * @param      mszText :       Input ProcessCode String Pointer
+ * @return     This function returns BufferSize for LocalCode
+ *
+ * @see                WmGetPcodeSize
+ */
+int WmGetLCodeSize(MCHAR *mszText)
+{
+       int nBuffSize = 0;
+
+       if (mszText[0] == '\0')
+               return 0;
+
+       while (*mszText != '\0') {
+
+               if (0x0001 <= *mszText && *mszText <= 0x007F) {
+                       nBuffSize++;
+                       mszText++;
+               } else if ((*mszText == 0x0000) || (0x0080 <= *mszText && *mszText <= 0x07FF)) {
+                       nBuffSize += 2;
+                       mszText++;
+               } else {
+                       nBuffSize += 3;
+                       mszText++;
+               }
+       }
+       return nBuffSize;
+}
+
+
+/**
+ * This function return output LocalCode Buffer Size
+ *
+ * @param      mszText :       Input ProcessCode String Pointer
+ * @return     This function returns BufferSize for LocalCode
+ *
+ * @see                WmGetPcodeSize
+ */
+int WmGetLCodeSizeN(MCHAR *mszText, int charCount)
+{
+       int nBuffSize = 0;
+       int i = 0;
+
+       if (mszText[0] == '\0')
+               return 0;
+
+       while ((*mszText != '\0') && (i < charCount)) {
+
+               if (0x0001 <= *mszText && *mszText <= 0x007F) {
+                       nBuffSize++;
+                       mszText++;
+               } else if ((*mszText == 0x0000) || (0x0080 <= *mszText && *mszText <= 0x07FF)) {
+                       nBuffSize += 2;
+                       mszText++;
+               } else {
+                       nBuffSize += 3;
+                       mszText++;
+               }
+               i++;
+       }
+       return nBuffSize;
+}
+#endif
+
+
+/**
+ * This function convert character Localcode(Latin2) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      szInText        :       Input Buffer Pointer to Latin2 code
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ * @see                WmConvert2PCodeN
+ */
+bool WmConvertLatin2Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
+{
+       int i = 0;
+       int j = 0;
+       int strLen = 0;
+       bool bInLatin2Table = false;
+
+       strLen = strlen((char *)szInText);
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
+               MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       for (i = 0; i < strLen; i++) {
+               bInLatin2Table = false;
+               for (j = 0; j < tabLatin2UniMax; j++) {
+                       if ((UCHAR)szInText[i] == tabLatin2Uni[j].latin2) {
+                               pmszOutText[i] = tabLatin2Uni[j].unicode;
+                               bInLatin2Table = true;
+                       }
+               }
+               if (bInLatin2Table == false)
+                       pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
+       }
+       /* Latin2 -> UNICODE */
+       pmszOutText[strLen] = NULL;
+
+       return true;
+}
+
+
+/**
+ * This function convert character Localcode(Latin3) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      szInText        :       Input Buffer Pointer to Latin2 code
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ * @see                WmConvert2PCodeN
+ */
+bool WmConvertLatin3Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
+{
+       int i = 0;
+       int j = 0;
+       int strLen = 0;
+       bool bInLatin3Table = false;
+
+       strLen = strlen((char *)szInText);
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
+               MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       for (i = 0; i < strLen; i++) {
+               bInLatin3Table = false;
+               for (j = 0; j < tabLatin3UniMax; j++) {
+                       if ((UCHAR)szInText[i] == tabLatin3Uni[j].latin3) {
+                               pmszOutText[i] = tabLatin3Uni[j].unicode;
+                               bInLatin3Table = true;
+                       }
+               }
+               if (bInLatin3Table == false)
+                       pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
+       }
+       /* Latin3 -> UNICODE */
+       pmszOutText[strLen] = NULL;
+
+       return true;
+}
+
+/**
+ * This function convert character Localcode(Latin4) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      szInText        :       Input Buffer Pointer to Latin2 code
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ * @see                WmConvert2PCodeN
+ */
+bool WmConvertLatin4Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
+{
+       int i = 0;
+       int j = 0;
+       int strLen = 0;
+       bool bInLatin4Table = false;
+
+       strLen = strlen((char *)szInText);
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
+               MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       for (i = 0; i < strLen; i++) {
+               bInLatin4Table = false;
+               for (j = 0; j < tabLatin4UniMax; j++) {
+                       if ((UCHAR)szInText[i] == tabLatin4Uni[j].latin4) {
+                               pmszOutText[i] = tabLatin4Uni[j].unicode;
+                               bInLatin4Table = true;
+                       }
+               }
+               if (bInLatin4Table == false)
+                       pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
+       }
+       /* Latin4 -> UNICODE */
+       pmszOutText[strLen] = NULL;
+
+       return true;
+}
+
+/**
+ * This function convert character Localcode(Latin8) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      szInText        :       Input Buffer Pointer to Latin2 code
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ * @see                WmConvert2PCodeN
+ */
+bool WmConvertLatin8Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
+{
+       int i = 0;
+       int j = 0;
+       int strLen = 0;
+       bool bInLatin8Table = false;
+
+       strLen = strlen((char *)szInText);
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
+               MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       for (i = 0; i < strLen; i++) {
+               bInLatin8Table = false;
+               for (j = 0; j < tabLatin8UniMax; j++) {
+                       if ((UCHAR)szInText[i] == tabLatin8Uni[j].latin8) {
+                               pmszOutText[i] = tabLatin8Uni[j].unicode;
+                               bInLatin8Table = true;
+                       }
+               }
+               if (bInLatin8Table == false)
+                       pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
+       }
+       /* Latin8 -> UNICODE */
+       pmszOutText[strLen] = NULL;
+
+       return true;
+}
+
+
+/**
+ * This function convert character Localcode(Win1251) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      szInText        :       Input Buffer Pointer to Win1251 code
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ * @see                WmConvert2PCodeN
+ */
+bool WmConvertWin1251Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
+{
+       int i = 0;
+       int j = 0;
+       int strLen = 0;
+       bool bInWin1251Table = false;
+
+       strLen = strlen((char *)szInText);
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
+               MSG_DEBUG("WmConvertWin1251Code2PCode: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       for (i = 0; i < strLen; i++) {
+               bInWin1251Table = false;
+               for (j = 0; j < tabWin1251UniMax; j++) {
+                       if ((UCHAR)szInText[i] == tabWin1251Uni[j].win1251) {
+                               pmszOutText[i] = tabWin1251Uni[j].unicode;
+                               bInWin1251Table = true;
+                       }
+               }
+               if (bInWin1251Table == false)
+                       pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
+       }
+       /* Win1251 -> UNICODE */
+       pmszOutText[strLen] = NULL;
+
+       return true;
+}
+
+
+/**
+ * This function convert character Localcode(Koi8-r) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      szInText        :       Input Buffer Pointer to Koi8-r code
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ * @see                WmConvert2PCodeN
+ */
+bool WmConvertKoi8rCode2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
+{
+       int i = 0;
+       int j = 0;
+       int strLen = 0;
+       bool bInKoi8rTable = false;
+
+       strLen = strlen((char *)szInText);
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
+               MSG_DEBUG("WmConvertKoi8rCode2PCode: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       for (i = 0; i < strLen; i++) {
+               bInKoi8rTable = false;
+               for (j = 0; j < tabKoi8rUniMax; j++) {
+                       if ((UCHAR)szInText[i] == tabKoi8rUni[j].koi8r) {
+                               pmszOutText[i] = tabKoi8rUni[j].unicode;
+                               bInKoi8rTable = true;
+                       }
+               }
+               if (bInKoi8rTable == false)
+                       pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
+       }
+       /* bInKoi8-rTable -> UNICODE */
+       pmszOutText[strLen] = NULL;
+
+       return true;
+}
+
+
+/**
+ * This function convert character Localcode(Koi8-u) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      szInText        :       Input Buffer Pointer to Koi8-u code
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ * @see                WmConvert2PCodeN
+ */
+bool WmConvertKoi8uCode2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
+{
+       int i = 0;
+       int j = 0;
+       int strLen = 0;
+       bool bInKoi8uTable = false;
+
+       strLen = strlen((char *)szInText);
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
+               MSG_DEBUG("WmConvertKoi8uCode2PCode: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       for (i = 0; i < strLen; i++) {
+               bInKoi8uTable = false;
+               for (j = 0; j < tabKoi8uUniMax; j++) {
+                       if ((UCHAR)szInText[i] == tabKoi8uUni[j].koi8u) {
+                               pmszOutText[i] = tabKoi8uUni[j].unicode;
+                               bInKoi8uTable = true;
+                       }
+               }
+               if (bInKoi8uTable == false)
+                       pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
+       }
+       /* bInKoi8uTable -> UNICODE */
+       pmszOutText[strLen] = NULL;
+
+       return true;
+}
+
+
+/**
+ * This function convert character Localcode(Latin15) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      szInText        :       Input Buffer Pointer to Latin2 code
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ * @see                WmConvert2PCodeN
+ */
+bool WmConvertLatin15Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
+{
+       int i = 0;
+       int j = 0;
+       int strLen = 0;
+       bool bInLatin15Table = false;
+
+       strLen = strlen((char *)szInText);
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
+               MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       for (i = 0; i < strLen; i++) {
+               bInLatin15Table = false;
+               for (j = 0; j < tabLatin15UniMax; j++) {
+                       if ((UCHAR)szInText[i] == tabLatin15Uni[j].latin15) {
+                               pmszOutText[i] = tabLatin15Uni[j].unicode;
+                               bInLatin15Table = true;
+                       }
+               }
+               if (bInLatin15Table == false)
+                       pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
+       }
+       /* Latin15 -> UNICODE */
+       pmszOutText[strLen] = NULL;
+
+       return true;
+}
+
+
+
+
+/**
+ * This function convert character Localcode(Latin5) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      szInText        :       Input Buffer Pointer to Latin5 code
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ * @see                WmConvert2PCodeN
+ */
+bool WmConvertLatin5Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
+{
+       int i = 0;
+       int j = 0;
+       int strLen = 0;
+       bool bInLatin5Table = false;
+
+       strLen = strlen((char *)szInText);
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
+               MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       for (i = 0; i < strLen; i++) {
+               bInLatin5Table = false;
+               for (j = 0; j < tabLatin5UniMax; j++) {
+                       if ((UCHAR)szInText[i] == tabLatin5Uni[j].Latin5) {
+                               pmszOutText[i] = tabLatin5Uni[j].unicode;
+                               bInLatin5Table = true;
+                       }
+               }
+               if (bInLatin5Table == false)
+                       pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
+       }
+       /* Latin5 -> UNICODE */
+       pmszOutText[strLen] = NULL;
+
+       return true;
+}
+
+
+int WmGetLatin32UTFCodeSize(unsigned char *szSrc, int nChar)
+{
+       int bufferSize = 0;
+       int latin3Size = -1;
+       MCHAR *pmszText;
+
+       bufferSize = nChar*3+1;
+       pmszText = (MCHAR *)malloc(bufferSize);
+       if (!pmszText) {
+               MSG_DEBUG("WmGetLatin32UTFCodeSize: memory allocation is failed!\n");
+               return -1;
+       }
+       WmConvertLatin3Code2PCode(pmszText, bufferSize, (char*)szSrc);
+       latin3Size = WmGetLCodeSize(pmszText);
+       free(pmszText);
+       return latin3Size;
+}
+
+
+int WmGetLatin42UTFCodeSize(unsigned char *szSrc, int nChar)
+{
+       int bufferSize = 0;
+       int latin4Size = -1;
+       MCHAR *pmszText;
+
+       bufferSize = nChar*3+1;
+       pmszText = (MCHAR *)malloc(bufferSize);
+       if (!pmszText) {
+               MSG_DEBUG("WmGetLatin42UTFCodeSize: memory allocation is failed!\n");
+               return -1;
+       }
+       WmConvertLatin4Code2PCode(pmszText, bufferSize, (char*)szSrc);
+       latin4Size = WmGetLCodeSize(pmszText);
+       free(pmszText);
+       return latin4Size;
+}
+
+
+int WmGetLatin82UTFCodeSize(unsigned char *szSrc, int nChar)
+{
+       int bufferSize = 0;
+       int latin8Size = -1;
+       MCHAR *pmszText;
+
+       bufferSize = nChar*3+1;
+       pmszText = (MCHAR *)malloc(bufferSize);
+       if (!pmszText) {
+               MSG_DEBUG("WmGetLatin82UTFCodeSize: memory allocation is failed!\n");
+               return -1;
+       }
+       WmConvertLatin8Code2PCode(pmszText, bufferSize, (char*)szSrc);
+       latin8Size = WmGetLCodeSize(pmszText);
+       free(pmszText);
+       return latin8Size;
+}
+
+int WmGetLatin152UTFCodeSize(unsigned char *szSrc, int nChar)
+{
+       int bufferSize = 0;
+       int latin15Size = -1;
+       MCHAR *pmszText;
+
+       bufferSize = nChar*3+1;
+       pmszText = (MCHAR *)malloc(bufferSize);
+       if (!pmszText) {
+               MSG_DEBUG("WmGetLatin152UTFCodeSize: memory allocation is failed!\n");
+               return -1;
+       }
+       WmConvertLatin15Code2PCode(pmszText, bufferSize, (char*)szSrc);
+       latin15Size = WmGetLCodeSize(pmszText);
+       free(pmszText);
+       return latin15Size;
+}
+
+int WmGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar)
+{
+       int bufferSize = 0;
+       int latin5Size = -1;
+       MCHAR *pmszText;
+
+       bufferSize = nChar*3+1;
+       pmszText = (MCHAR *)malloc(bufferSize);
+       if (!pmszText) {
+               MSG_DEBUG("WmGetLatin52UTFCodeSize: memory allocation is failed!\n");
+               return -1;
+       }
+       WmConvertLatin5Code2PCode(pmszText, bufferSize, (char*)szSrc);
+       latin5Size = WmGetLCodeSize(pmszText);
+       free(pmszText);
+       return latin5Size;
+}
+
+
+/**
+ * This function convert character Localcode(Latin1) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      szInText        :       Input Buffer Pointer to LocalCode(KSC5601)
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ * @see                WmConvert2PCodeN
+ */
+bool WmConvertLatinCode2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
+{
+       UINT strLen;
+
+       strLen = strlen((char *)szInText);
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
+               MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       /* Latin1 -> UNICODE */
+       __WmLngConvertLatin12Unicode(pmszOutText,(UCHAR*)szInText,strLen);
+       pmszOutText[strLen] = NULL;
+
+       return true;
+}
+
+/**
+ * This function convert N'th character Localcode(Latin1) to Processcode(Unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to  ProcessCode(UniCode)
+ * @param      szInText        :       Input Buffer Pointer to LocalCode(KSC5601)
+ * @param      charCount               :       number for convert n'th chararcter
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ * @see                WmConvert2PCode
+ */
+bool WmConvertLatinCode2PCodeN(MCHAR *pmszOutText, int outBufSize, char *szInText, int charCount)
+{
+       int strLen;
+
+       if (charCount == 0) {
+               MSG_DEBUG("WmConvert2PCodeN: charCount is0\n");
+               pmszOutText[charCount] = NULL;
+       }
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, charCount) == false) {
+               MSG_DEBUG("WmConvertLatinCode2PCodeN: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       /* Latin1 -> UNICODE */
+       __WmLngLatin12UnicodeN (pmszOutText, (UCHAR*)szInText, charCount);
+
+       strLen = strlen((char *)szInText);
+       if(strLen < charCount) {
+               pmszOutText[strLen] = NULL;
+       } else {
+               pmszOutText[charCount] = NULL;
+       }
+
+       return true;
+}
+
+/*
+ * This function convert character Processcode(Unicode) to Localcode(Latin1)
+ *
+ * @param      pOutStr         :       Output Buffer Pointer to LocalCode(Latin1)
+ * @param      pInputStr       :       Input Buffer Pointer to ProcessCode(UniCode)
+ * @param      len                     :       number for convert n'th chararcter
+ * @return     void
+ *
+ * @see
+ */
+static void __WmLngReverseKeyCode(UCHAR *pOutStr, MCHAR *pInputStr, UINT len)
+{
+       UCHAR *rear=NULL;
+       MCHAR *p;
+       UCHAR temp;
+
+       rear = pOutStr;
+
+       for (p = pInputStr; len > 0 && p; len--) {
+               if (*pInputStr < MAX_ASCII_NUM) {                  // ASCII String
+                       if (*p == 0)
+                               *rear = '\0';
+                       temp = (UCHAR)(*p);
+                       *rear = temp;
+                       rear++;
+                       p++;
+                       if(len == 1)
+                               *rear = '\0';
+               } else {
+                       *rear = 0x3F;
+                       rear++;
+                       p++;
+                       if(len == 1)
+                               *rear = '\0';
+               }
+               pInputStr = p;
+       }
+}
+
+
+/*
+ * This function convert character Localcode(Latin1) to Processcode(Unicode)
+ *
+ * @param      des[in]         :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      str[in]         :       Input Buffer Pointer to LocalCode(Latin1)
+ * @param      len[in]         :       number for convert n'th chararcter
+ * @return     This function returns number for convert n'th chararcter on success
+ *
+ * @see
+ */
+static int __WmLngConvertLatin12Unicode (MCHAR *des, UCHAR *str, UINT len)
+{
+       MCHAR *org;
+       org = des;
+       while (len>0) {
+               *des++ = *str++;
+               len--;
+       }
+
+       return (des - org) ;
+}
+
+/*
+ * This function convert N'th character Localcode(Latin1) to Processcode(Unicode)
+ *
+ * @param      pOutStr         :       Output Buffer Pointer to  ProcessCode(UniCode)
+ * @param      pInputStr       :       Input Buffer Pointer to LocalCode(Latin1)
+ * @param      len                     :       number for convert n'th chararcter
+ * @return     This function returns true on success, or false on failure.
+ *
+ * @see
+ */
+static UINT __WmLngLatin12UnicodeN(MCHAR *pOutStr, UCHAR *pInputStr, UINT len)
+{
+       UINT n;
+
+       n = strlen((char*)pInputStr);
+
+       if(len > n)
+               len = n;
+
+       return __WmLngConvertLatin12Unicode (pOutStr, pInputStr, len);
+}
+
diff --git a/plugin/mms_plugin/LanguagePack/MmsPluginWmLngString.cpp b/plugin/mms_plugin/LanguagePack/MmsPluginWmLngString.cpp
new file mode 100755 (executable)
index 0000000..1fcb907
--- /dev/null
@@ -0,0 +1,38 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MmsPluginWmLngPack.h"
+
+
+/**
+ * return length of a string (character count of a string)
+ * @param      mszInText [in]  input string pointer
+ * @return     lenght of string
+ *
+ */
+int WmStrlen(const MCHAR *mszInText)
+{
+       register int n;
+
+       n=0;
+
+       while(*(mszInText+n) != '\0')
+               n++;
+
+       return n;
+}
+
diff --git a/plugin/mms_plugin/LanguagePack/MmsPluginWmLngUTF8Uni.cpp b/plugin/mms_plugin/LanguagePack/MmsPluginWmLngUTF8Uni.cpp
new file mode 100755 (executable)
index 0000000..cade759
--- /dev/null
@@ -0,0 +1,201 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MmsPluginWmLngPack.h"
+
+
+/* Local function */
+int __WmLngUTF2Unicode (unsigned short *des,unsigned char *src, int nChar);
+
+
+int __WmLngStrlenByByte(UCHAR *szInText, int byteCount)
+{
+       int nCount = 0;
+       while (byteCount > 0 && (*szInText != '\0')) {
+               if (*szInText < 0x80) {
+                       szInText++;
+                       byteCount--;
+               } else if  (((0xC0 <= *szInText) && (*szInText < 0xE0)) && (*(szInText+1) >= 0x80)) {
+                       szInText += 2;
+                       byteCount -= 2;
+               } else if  ((*szInText >= 0xE0) && (*(szInText+1) >= 0x80) && (*(szInText+2) >= 0x80)) {
+                       szInText += 3;
+                       byteCount -= 3;
+               } else {
+                       szInText++;
+                       byteCount--;
+                       MSG_DEBUG("__WmLngStrlenByByte: utf8 incorrect range!\n");
+               }
+               nCount++;
+       }
+       return (nCount+1)*sizeof(MCHAR);
+}
+
+/**
+ * This function convert character n'th byte UTF8 character to ProcessCode(unicode)
+ *
+ * @param      pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      szInText                :       Input  Buffer Pointer to UTF8
+ * @param      byteCount               :       byte number for converting the character
+ * @return                                     :       This function returns true on success, or false
+ *                                                             on failure.
+ *
+ * @see                WmConvertPCode2UTF
+ */
+bool WmConvertUTF2PCode (MCHAR *pmszOutText, int outBufSize, UCHAR *szInText, int byteCount)
+{
+       int length;
+       if (byteCount == 0) {
+               pmszOutText[0] = NULL;
+               return true;
+       }
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, __WmLngStrlenByByte((UCHAR*)szInText, byteCount)) == false) {
+               MSG_DEBUG("WmConvertUTF2PCode: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       length = __WmLngUTF2Unicode (pmszOutText, szInText, byteCount);
+       if (length == -1) {
+               MSG_DEBUG("WmConvertUTF2PCode: __WmLngUTF2Unicode returns false!\n");
+               return false;
+       } else {
+               return true;
+       }
+}
+
+
+/*
+ * change 1byte-encoded-UTF8 character to Unicode
+ * @param      byte1   :       1byte character code
+ * @return                     :       result of bit operation
+ *
+ *
+ * @see
+ */
+unsigned short __WmLngConvert1ByteChar (unsigned char byte1)
+{
+       unsigned short result;
+
+       result = 0;
+       result = (byte1 & 0x7F);
+
+       return result;
+}
+
+/*
+ * change 2byte-encoded-UTF8 character to Unicode
+ * @param      byte1   :       1'st byte character code
+ * @param      byte2   :       2'st byte character code
+ * @return                     :       result of bit operation
+ *
+ * @see
+ */
+unsigned short __WmLngConvert2ByteChar (unsigned char byte1, unsigned char byte2)
+{
+       unsigned short result;
+       unsigned char hi;
+       unsigned char lo;
+
+       result = 0;
+
+       hi = byte1 & 0x1F;
+       lo = byte2 & 0x3F;
+
+       result = (hi << 6) | lo;
+
+       return result;
+}
+
+/*
+ * change 3byte-encoded-UTF8 character to Unicode
+ * @param      byte1   :       1'st character code
+ * @param      byte2   :       2'st character code
+ * @param      byte3   :       3'st character code
+ * @return                     :       result of bit operation
+ *
+ * @see
+ */
+unsigned short __WmLngConvert3ByteChar (unsigned char byte1, unsigned char byte2, unsigned char byte3)
+{
+       unsigned short result;
+       unsigned char hi;
+       unsigned char mid;
+       unsigned char lo;
+
+       result = 0;
+
+       hi = byte1 & 0x0F;
+       mid = byte2 & 0x3F;
+       lo = byte3 & 0x3F;
+
+       result = (hi << 12) | (mid << 6) | lo;
+
+       return result;
+}
+
+/*
+ * This function convert character UTF8 to ProcessCode(unicode)
+ *
+ * @param      des             :       Output Buffer Pointer to ProcessCode(UniCode)
+ * @param      src             :       Input  Buffer Pointer to UTF8
+ * @param      nChar   :       number for convert n'th chararcter
+ * @return                     :       This function returns number for convert n'th chararcter on success, or -1
+ *                                             on failure.
+ *
+ * @see
+ */
+
+int __WmLngUTF2Unicode (unsigned short *des,unsigned char *src, int nChar)
+{
+       unsigned short *org;
+
+       org = des;
+
+       while (nChar > 0 && (*src != '\0')) {
+               if (*src < 0x80) {
+                       *des = __WmLngConvert1ByteChar (*src);
+
+                       des++;
+                       src++;
+                       nChar--;
+               } else if  (((0xC0 <= *src) && (*src < 0xE0)) && (*(src+1) >= 0x80)) {
+                       *des = __WmLngConvert2ByteChar (*src, *(src+1));
+
+                       des++;
+                       src += 2;
+                       nChar -= 2;
+               } else if  ((*src >= 0xE0) && (*(src+1) >= 0x80) && (*(src+2) >= 0x80)) {
+                       *des = __WmLngConvert3ByteChar (*src, *(src+1), *(src+2));
+
+                       des++;
+
+                       src += 3;
+                       nChar -= 3;
+               } else {
+                       *des = __WmLngConvert1ByteChar (*src);
+                       des++;
+                       src++;
+                       nChar--;
+                       MSG_DEBUG("__WmLngUTF2Unicode: utf8 incorrect range!\n");
+               }
+       }
+       *des = 0;
+       return (des - org);
+}
+
+
diff --git a/plugin/mms_plugin/LanguagePack/MmsPluginWmLngUniUTF8.cpp b/plugin/mms_plugin/LanguagePack/MmsPluginWmLngUniUTF8.cpp
new file mode 100755 (executable)
index 0000000..b209434
--- /dev/null
@@ -0,0 +1,142 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MmsPluginWmLngPack.h"
+
+
+/* Local function */
+int __WmLngUnicode2UTF (unsigned char *des, unsigned short *src, int nChar);
+
+
+int __WmLngGetLCodeSizeN(MCHAR *mszText, int charCount)
+{
+       int nBuffSize = 0;
+
+       if (mszText[0] == '\0')
+               return 0;
+
+       while (charCount > 0 && *mszText != '\0') {
+
+               if (0x0001 <= *mszText && *mszText <= 0x007F) {
+                       nBuffSize++;
+                       mszText++;
+                       charCount--;
+               } else if((*mszText == 0x0000) || (0x0080 <= *mszText && *mszText <= 0x07FF)) {
+                       nBuffSize += 2;
+                       mszText++;
+                       charCount--;
+               } else {
+                       nBuffSize += 3;
+                       mszText++;
+                       charCount--;
+               }
+       }
+       return nBuffSize+1;     /* include NULL  */
+}
+
+/**
+ * This function convert character ProcessCode(unicode) to UTF8
+ *
+ * @param      pszOutText      :       Output Buffer Pointer to UTF8
+ * @param      mszInText       :       Input  Buffer Pointer to ProcessCode(UniCode)
+ * @param      charCount       :       number for convert n'th chararcter
+ * @return     This function returns true on success, or false
+ *                     on failure.
+ *
+ * @see                WmConvertPCode2UTF
+ */
+bool WmConvertPCode2UTF(UCHAR *pszOutText, int outBufSize, MCHAR *mszInText, int charCount)
+{
+       int length;
+
+       if (charCount == 0) {
+               pszOutText[0] = '\0';
+               return true;
+       }
+
+       if (__WmConvertCodeBufferSizeCheck((char*)pszOutText, outBufSize, __WmLngGetLCodeSizeN(mszInText, charCount)) == false) {
+               MSG_DEBUG("WmConvertPCode2UTF: Out buffer size seems to be small!\n");
+               return false;
+       }
+
+       length = __WmLngUnicode2UTF(pszOutText, mszInText, charCount);
+       if(length == -1) {
+               MSG_DEBUG("WmConvertPCode2UTF: __WmLngUnicode2UTF returns false!\n");
+               return false;
+       } else {
+               return true;
+       }
+}
+
+/*
+ * This function convert character ProcessCode(unicode) to UTF8
+ *
+ * @param      des             :       Output Buffer Pointer to UTF8
+ * @param      src             :       Input  Buffer Pointer to ProcessCode(UniCode)
+ * @param      nChar   :       number for convert n'th chararcter
+ * @return     This function returns number for convert n'th chararcter on success, or -1
+ *                     on failure.
+ *
+ * @see                WmConvertPCode2UTF
+ */
+int __WmLngUnicode2UTF (unsigned char *des, unsigned short *src, int nChar)
+{
+       unsigned char *org;
+       unsigned char t1;
+       unsigned char t2;
+       unsigned char t3;
+
+       org = des;
+
+       while (nChar > 0 && *src != '\0') {
+               if (0x0001 <= *src && *src <= 0x007F) {
+                       *des = (unsigned char) (*src & 0x007F);
+
+                       des++;
+                       src++;
+                       nChar--;
+               } else if  ((*src == 0x0000) || (0x0080 <= *src && *src <= 0x07FF)) {
+                       t2 = (unsigned char) (*src & 0x003F);                           //      right most 6 bit
+                       t1 = (unsigned char) ((*src & 0x07C0) >> 6);                    //      right most 5 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       src += 1;
+                       nChar -= 1;
+               } else {
+                       t3 = (unsigned char) (*src & 0x003F);                                   //      right most 6 bit
+                       t2 = (unsigned char) ((*src & 0x0FC0) >> 6);                    //      right most 6 bit
+                       t1 = (unsigned char) ((*src & 0xF000) >> 12);                   //      right most 4 bit
+
+                       *des = 0xE0 | (t1 & 0x0F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+                       *(des+2) = 0x80 | (t3 & 0x3F);
+
+                       des += 3;
+                       src += 1;
+                       nChar -= 1;
+               }
+       }
+
+       *des = 0;
+       return (des - org);
+}
+
+
+
diff --git a/plugin/mms_plugin/MmsPluginAvCodec.cpp b/plugin/mms_plugin/MmsPluginAvCodec.cpp
new file mode 100755 (executable)
index 0000000..e8f1e20
--- /dev/null
@@ -0,0 +1,211 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MmsPluginAvCodec.h"
+#include <string.h>
+
+AvCodecType    AvGetFileCodecType(const char *szFileName)
+{
+       char szFileExt[FILEEXT_MAX] = {0, };
+       int iPos = 0;
+       int iStrLen = 0;
+       bool bMIME = false;
+
+       iStrLen = strlen(szFileName);
+
+       iPos = iStrLen;
+
+       while (iPos > 0) {
+               iPos--;
+
+               if (szFileName[iPos] == '.')
+                       break;
+               if (szFileName[iPos] == '/') {
+                       bMIME = true;
+                       break;
+               }
+       }
+
+       if (iPos == 0) {
+               return AV_CODEC_NONE;
+       }
+
+       if (FILEEXT_MAX > (iStrLen - iPos - 1)) {
+               strncpy(szFileExt, szFileName + iPos + 1, (iStrLen - iPos - 1));
+               szFileExt[iStrLen - iPos - 1] = '\0';
+       } else
+               return AV_CODEC_NONE;
+
+       if (strcasecmp(szFileExt, "mp3") == 0 || strcasecmp(szFileExt, "MP3") == 0)
+               return AV_DEC_AUDIO_MP3;
+
+       if (strcasecmp(szFileExt, "pvx") == 0 || strcasecmp(szFileExt, "PVX") == 0)
+               return AV_DEC_VIDEO_PVX;
+       else if (strcasecmp(szFileExt, "wav") == 0 || strcasecmp(szFileExt, "WAV") == 0) {
+#ifdef AV_DEBUG_MODE
+               if (!bMIME) {
+                       if (__AvValidWAVE(szFileName) == true)
+                               return AV_DEC_AUDIO_WAVE;
+                       else
+                               return AV_CODEC_NONE;
+               } else
+#endif
+                       return AV_DEC_AUDIO_WAVE;
+       } else if (strcasecmp(szFileExt, "aac") == 0 || strcasecmp(szFileExt, "AAC") == 0)
+               return AV_DEC_AUDIO_AAC;
+#ifdef AV_DEBUG_MODE
+       else if (strcasecmp(szFileExt, "wma") == 0 || strcasecmp(szFileExt, "WMA") == 0)
+               return AvWMFFGetFileType(szFileName);
+       else if (strcasecmp(szFileExt, "wmv") == 0 || strcasecmp(szFileExt, "WMV") == 0)
+               return AvWMFFGetFileType(szFileName);
+       else if (strcasecmp(szFileExt, "asf") == 0 || strcasecmp(szFileExt, "ASF") == 0)
+               return AvWMFFGetFileType(szFileName);
+#endif
+       else if (strcasecmp(szFileExt, "amr") == 0 || strcasecmp(szFileExt, "AMR") == 0 ||
+                       strcasecmp(szFileExt, "x-amr") == 0 || strcasecmp(szFileExt, "X-AMR") == 0) {
+#ifdef AV_DEBUG_MODE
+               if (!bMIME) {
+                       if (__AvValidAMR(szFileName) == true)
+                               return AV_DEC_AUDIO_AMR;
+                       else
+                               return AV_CODEC_NONE;
+               } else
+#endif
+                       return AV_DEC_AUDIO_AMR;
+       } else if (strcasecmp(szFileExt, "g7231") == 0 || strcasecmp(szFileExt, "G7231") == 0)
+               return AV_DEC_AUDIO_G723_1;
+       else if ((strcasecmp(szFileExt, "mid") == 0 || strcasecmp(szFileExt, "MID") == 0) ||
+                       (strcasecmp(szFileExt, "midi") == 0 || strcasecmp(szFileExt, "MIDI") == 0)) {
+#ifdef AV_DEBUG_MODE
+               if (!bMIME) {
+                       if (__AvValidMIDI(szFileName) == true)
+                               return AV_DEC_AUDIO_MIDI;
+                       else
+                               return AV_CODEC_NONE;
+               } else
+#endif
+                       return AV_DEC_AUDIO_MIDI;
+       } else if (strcasecmp(szFileExt, "mmf") == 0 || strcasecmp(szFileExt, "MMF") == 0 || strcasecmp(szFileExt, "x-mmf") == 0) {
+#ifdef AV_DEBUG_MODE
+               if (!bMIME) {
+                       if (__AvValidMMF(szFileName) == true)
+                               return AV_DEC_AUDIO_MMF;
+                       else
+                               return AV_CODEC_NONE;
+               } else
+#endif
+                       return AV_DEC_AUDIO_MMF;
+       } else if (strcasecmp(szFileExt, "pmd") == 0 || strcasecmp(szFileExt, "PMD") == 0) {
+                       return AV_DEC_AUDIO_MIDI;
+       } else if (strcasecmp(szFileExt, "xmf") == 0 || strcasecmp(szFileExt, "XMF") == 0 ||
+                               strcasecmp(szFileExt,  "mxmf") == 0 || strcasecmp(szFileExt,  "MXMF") == 0) {
+               return AV_DEC_AUDIO_XMF;
+       } else if (strcasecmp(szFileExt, "smp") == 0 || strcasecmp(szFileExt, "SMP") == 0) {
+#ifdef AV_DEBUG_MODE
+               if (!bMIME) {
+                       if (__AvValidSMP(szFileName) == true)
+                               return AV_DEC_AUDIO_ADPCM;
+                       else
+                               return AV_CODEC_NONE;
+               } else
+#endif
+                       return AV_DEC_AUDIO_ADPCM;
+       } else if (strcasecmp(szFileExt, "spm") == 0 || strcasecmp(szFileExt, "SPM") == 0) {
+#ifdef AV_DEBUG_MODE
+               if (!bMIME) {
+                       if (__AvValidMIDI(szFileName) == true)
+                               return AV_DEC_AUDIO_SPM;
+                       else
+                               return AV_CODEC_NONE;
+               } else
+#endif
+                       return AV_DEC_AUDIO_SPM;
+       } else if (strcasecmp(szFileExt, "spf") == 0 || strcasecmp(szFileExt, "SPF") == 0) {
+#ifdef AV_DEBUG_MODE
+               if (!bMIME) {
+                       if (__AvValidMMF(szFileName) == true)
+                               return AV_DEC_AUDIO_MMF_PHRASE_L1;
+                       else
+                               return AV_CODEC_NONE;
+               } else
+#endif
+                       return AV_DEC_AUDIO_MMF_PHRASE_L1;
+       } else if (strcasecmp(szFileExt, "imy") == 0 || strcasecmp(szFileExt, "IMY") == 0 ||
+               strcasecmp(szFileExt, "iMelody") == 0 || strcasecmp(szFileExt, "x-iMelody") == 0 ||
+               strcasecmp(szFileExt, "Melody") == 0) {
+#ifdef AV_DEBUG_MODE
+               if (!bMIME) {
+                       if (__AvValidIMELODY(szFileName) == true)
+                               return AV_DEC_AUDIO_IMELODY;
+                       else
+                               return AV_CODEC_NONE;
+               } else
+#endif
+                       return AV_DEC_AUDIO_IMELODY;
+       } else if (strcasecmp(szFileExt, "dtmf") == 0)
+               return AV_DEC_AUDIO_DTMF_TONE;
+       else if (strcasecmp(szFileExt, "h263") == 0 || strcasecmp(szFileExt, "H263") == 0)
+               return AV_DEC_VIDEO_H263;
+       else if (strcasecmp(szFileExt, "mp4") == 0 || strcasecmp(szFileExt, "MP4") == 0 ||
+                       strcasecmp(szFileExt, "mpeg4") == 0 || strcasecmp(szFileExt, "MPEG4") == 0 ||
+                       strcasecmp(szFileExt, "m4a") == 0 || strcasecmp(szFileExt, "M4A") == 0) {
+#ifdef AV_DEBUG_MODE
+               if (!bMIME) {
+                       AvCodecType avCodecType = AV_CODEC_NONE;
+                       FmFileAttribute fileAttrib;
+                       size_t strLen;
+                       UINT32  dateTime = 0;
+
+                       if (!DrmGetFileAttributes(szFileName, &fileAttrib)) {
+                               return AV_CODEC_NONE;
+                       } else {
+                               dateTime =  TmDateTimeToSeconds(&fileAttrib.dt);
+                               strLen = strlen(szFileName);
+                               if ((strnicmp(lastAccessFileInfo.szFileName, szFileName, strLen) == 0) &&
+                                       (lastAccessFileInfo.fileSize == fileAttrib.fileSize) &&
+                                       (lastAccessFileInfo.dateTime == dateTime)) {
+                                       return lastAccessFileInfo.codecType;
+                               } else {
+                                       avCodecType = AvMP4FFGetFileType(szFileName);
+
+                                       if (strcasecmp(szFileExt, "3ga") == 0 || strcasecmp(szFileExt, "3GA") == 0 ||
+                                               strcasecmp(szFileExt, "m4a") == 0 || strcasecmp(szFileExt, "M4A") == 0) {
+                                               if (avCodecType | AV_DEC_AUDIO_MPEG4)
+                                                       avCodecType = AV_DEC_AUDIO_MPEG4;
+                                       }
+
+                                       if (avCodecType != AV_CODEC_NONE) {
+                                               strncpy(lastAccessFileInfo.szFileName, szFileName, strLen);
+                                               lastAccessFileInfo.szFileName[strLen] = '\0';
+                                               lastAccessFileInfo.fileSize = fileAttrib.fileSize;
+                                               lastAccessFileInfo.dateTime = dateTime;
+                                               lastAccessFileInfo.codecType = avCodecType;
+                                       }
+                                       return avCodecType;
+                               }
+                       }
+               }
+#endif
+               return AV_DEC_VIDEO_MPEG4;
+       } else if (strcasecmp(szFileExt, "3gp") == 0 || strcasecmp(szFileExt, "3GP") == 0 ||
+               strcasecmp(szFileExt, "3ga") == 0 || strcasecmp(szFileExt, "3GA") == 0 ||
+               strcasecmp(szFileExt, "3gpp") == 0 || strcasecmp(szFileExt, "3GPP") == 0) {
+               return AV_CODEC_NONE;
+       } else if (strcasecmp(szFileExt, "sdp") == 0 || strcasecmp(szFileExt, "SDP") == 0)
+               return AV_DEC_VIDEO_MPEG4;
+       else
+               return AV_CODEC_NONE;
+}
diff --git a/plugin/mms_plugin/MmsPluginCodec.cpp b/plugin/mms_plugin/MmsPluginCodec.cpp
new file mode 100755 (executable)
index 0000000..bbfaf5a
--- /dev/null
@@ -0,0 +1,625 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MmsPluginCodec.h"
+#include "MsgMmsTypes.h"
+#include "MmsPluginMessage.h"
+#include "MmsPluginMIME.h"
+#include "MsgDebug.h"
+
+/* Reference : MMS-209-Encapsulation & WAP-203-WSP-20000504.pdf Table 39 */
+const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] =
+{
+       /* MMS Specific (MsgMmsMsg.h / MsgMmsUA.h) -----------------------*/
+
+       /* MmsCodeFieldCode */
+       {
+               {"Bcc", 0x01},                                                          //0
+               {"Cc", 0x02},
+               {"X-Mms-Content-Location", 0x03},
+               {"Content-Type", 0x04},
+               {"Date", 0x05},
+               {"X-Mms-Delivery-Report", 0x06},
+               {"X-Mms-Delivery-Time", 0x07},
+               {"X-Mms-Expiry", 0x08},
+               {"From", 0x09},
+               {"X-Mms-Message-Class", 0x0A},
+               {"Message-ID", 0x0B},                                           // 10
+               {"X-Mms-Message-Type", 0x0C},
+               {"X-Mms-MMS-Version", 0x0D},
+               {"X-Mms-Message-Size", 0x0E},
+               {"X-Mms-Priority", 0x0F},
+               {"X-Mms-Read-Reply", 0x10},
+               {"X-Mms-Report-Allowed", 0x11},
+               {"X-Mms-Response-Status", 0x12},
+               {"X-Mms-Retrieve-Status", 0x19},                        /* Add by MMSENC v1.1 */
+               {"X-Mms-Response-Text", 0x13},
+               {"X-Mms-Retrieve-Text", 0x1A},                          // 20   /* Add by MMSENC v1.1 */
+               {"X-Mms-Sender-Visibility", 0x14},
+               {"X-Mms-Status", 0x15},
+               {"Subject", 0x16},
+               {"To", 0x17},
+               {"X-Mms-Transaction-ID", 0x18},
+
+               /* Add by MMSENC v1.1 */
+               {"X-Mms-Read-Status", 0x1B},
+               {"X-Mms-Reply-Charging", 0x1C},
+               {"X-Mms-Reply-Charging-Deadline", 0x1D},        // 30
+               {"X-Mms-Reply-Charging-ID", 0x1E},
+               {"X-Mms-Reply-Charging-Size", 0x1F},
+               {"X-Mms-Previously-Sent-By", 0x20},
+               {"X-Mms-Previously-Sent-Date", 0x21},
+       },
+
+       /* MmsCodeParameterCode ( By WSP Table 38. Wellknown parameter Assignments ) */
+       {
+               {"Charset", 0x01},              // v1.1 base
+               {"Name", 0x05},                 // v1.1 base. 0x17 at v1.4
+               {"FileName", 0x06},             // v1.1 base. ox18 at v1.4
+               {"Type", 0x09},                 // v1.2 base
+               {"Start", 0x0A},                // v1.2 base. 0x19 at v1.4
+               {"Start-Info", 0x0B},   // v1.2 base. 0x1A at v1.4
+               {"boundary", 0xFF},             //laconic_javaParamFix
+               {"report-type", 0xFF},        // only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
+#ifdef FEATURE_JAVA_MMS
+               {"Application-ID", 0xFF},
+               {"Reply-To-Application-ID", 0xFF},
+#endif
+       },
+
+       /* MmsCodeMsgBodyHeaderCode ( By WSP Table 39. Header Field Name Assignments ) */
+       {
+               {"Content-Transfer-Encoding", 0xFFFF},  // only text encoding, no binary number
+               {"Content-Disposition", 0x2E},                  // v1.1 base. 0x45 at v1.4
+               {"Content-ID", 0x40},                                   // v1.3 base
+               {"Content-Location", 0x0E},                             // v1.3 base
+               {"X-Oma-Drm-Separate-Delivery", 0xFF }, // DRM RO WAITING
+       },
+
+       /* MmsCodeMsgType */
+       {
+               {"m-send-req", 0x00},
+               {"m-send-conf", 0x01},
+               {"m-notification-ind", 0x02},
+               {"m-notifyresp-ind", 0x03},
+               {"m-retrieve-conf", 0x04},
+               {"m-acknowledge-ind", 0x05},
+               {"m-delivery-ind", 0x06},
+
+               /* Add by MMSENC v1.1 */
+               {"m-read-rec-ind", 0x07},
+               {"m-read-orig-ind", 0x08},
+               {"m-forward-req", 0x09},
+               {"m-forward-conf", 0x0A}
+       },
+
+       /* MmsCodeDeliveryReport */
+       {
+               { "Yes", 0x00 }, { "No", 0x01 }
+       },
+
+       /* MmsCodeTimeType */
+       {
+               { "relative", 0x01 }, { "absolute", 0x00 }
+       },
+
+       /* MmsCodeMsgClass */
+       {
+               {"Personal", 0x00},
+               {"Advertisement", 0x01},
+               {"Informational", 0x02},
+               {"Auto", 0x03}
+       },
+
+       /* MmsCodePriority */
+       {
+               { "Low", 0x00 }, { "Normal", 0x01 }, { "High", 0x02 }
+       },
+
+       /* MmsCodeResponseStatus */
+       {
+               {"Ok", 0x00},
+               {"Error-unspecified", 0x01},
+               {"Error-service-denied", 0x02},
+               {"Error-message-format-corrupt", 0x03},
+               {"Error-sending-address-unresolved", 0x04},
+               {"Error-message-not-found", 0x05},
+               {"Error-network-problem", 0x06},
+               {"Error-content-not-accepted", 0x07},
+               {"Error-unsupported-message", 0x08},
+
+               {"Error-transient-failure", 0x40},
+               {"Error-transient-sending-address-unresolved", 0x41},
+               {"Error-transient-message-not-found", 0x42},
+               {"Error-transient-network-problem", 0x43},
+
+               {"Error-transient-failure", 0x44}, //reserved for future
+               {"Error-transient-failure", 0x45},
+               {"Error-transient-failure", 0x46},
+               {"Error-transient-failure", 0x47},
+               {"Error-transient-failure", 0x48},
+               {"Error-transient-failure", 0x49},
+               {"Error-transient-failure", 0x4A},
+               {"Error-transient-failure", 0x4B},
+               {"Error-transient-failure", 0x4C},
+               {"Error-transient-failure", 0x4D},
+               {"Error-transient-failure", 0x4E},
+               {"Error-transient-failure", 0x4F},
+               {"Error-transient-failure", 0x50},
+               {"Error-transient-failure", 0x51},
+               {"Error-transient-failure", 0x52},
+               {"Error-transient-failure", 0x53},
+               {"Error-transient-failure", 0x54},
+               {"Error-transient-failure", 0x55},
+               {"Error-transient-failure", 0x56},
+               {"Error-transient-failure", 0x57},
+               {"Error-transient-failure", 0x58},
+               {"Error-transient-failure", 0x59},
+               {"Error-transient-failure", 0x5A},
+               {"Error-transient-failure", 0x5B},
+               {"Error-transient-failure", 0x5C},
+               {"Error-transient-failure", 0x5D},
+               {"Error-transient-failure", 0x5E},
+               {"Error-transient-failure", 0x5F},
+
+               {"Error-permanent-failure", 0x60},
+               {"Error-permanent-service-denied", 0x61},
+               {"Error-permanent-message-format-corrupt", 0x62},
+               {"Error-permanent-sending-address-unresolved", 0x63},
+               {"Error-permanent-message-not-found", 0x64},
+               {"Error-permanent-content-not-accepted", 0x65},
+               {"Error-permanent-reply-charging-limitations-not-met", 0x66},
+               {"Error-permanent-reply-charging-request-not-accepted", 0x67},
+               {"Error-permanent-reply-charging-forwarding-denied", 0x68},
+               {"Error-permanent-reply-charging-not-supported", 0x69},
+
+               {"Error-permanent-failure", 0x6A}, //reserved for future
+               {"Error-permanent-failure", 0x6B},
+               {"Error-permanent-failure", 0x6C},
+               {"Error-permanent-failure", 0x6D},
+               {"Error-permanent-failure", 0x6E},
+               {"Error-permanent-failure", 0x6F},
+               {"Error-permanent-failure", 0x70},
+               {"Error-permanent-failure", 0x71},
+               {"Error-permanent-failure", 0x72},
+               {"Error-permanent-failure", 0x73},
+               {"Error-permanent-failure", 0x74},
+               {"Error-permanent-failure", 0x75},
+               {"Error-permanent-failure", 0x76},
+               {"Error-permanent-failure", 0x77},
+               {"Error-permanent-failure", 0x78},
+               {"Error-permanent-failure", 0x79},
+               {"Error-permanent-failure", 0x7A},
+               {"Error-permanent-failure", 0x7B},
+               {"Error-permanent-failure", 0x7C},
+               {"Error-permanent-failure", 0x7D},
+               {"Error-permanent-failure", 0x7E},
+               {"Error-permanent-failure", 0x7F}
+
+
+       },
+
+       /* MmsCodeRetrieveStatus */
+       {
+               {"Ok", 0x00},
+               {"Error-transient-failure", 0x40},
+               {"Error-transient-message-not-found", 0x41},
+               {"Error-transient-network-problem", 0x42},
+
+               {"Error-transient-failure", 0x43}, //reserved for future
+               {"Error-transient-failure", 0x44},
+               {"Error-transient-failure", 0x45},
+               {"Error-transient-failure", 0x46},
+               {"Error-transient-failure", 0x47},
+               {"Error-transient-failure", 0x48},
+               {"Error-transient-failure", 0x49},
+               {"Error-transient-failure", 0x4A},
+               {"Error-transient-failure", 0x4B},
+               {"Error-transient-failure", 0x4C},
+               {"Error-transient-failure", 0x4D},
+               {"Error-transient-failure", 0x4E},
+               {"Error-transient-failure", 0x4F},
+               {"Error-transient-failure", 0x50},
+               {"Error-transient-failure", 0x51},
+               {"Error-transient-failure", 0x52},
+               {"Error-transient-failure", 0x53},
+               {"Error-transient-failure", 0x54},
+               {"Error-transient-failure", 0x55},
+               {"Error-transient-failure", 0x56},
+               {"Error-transient-failure", 0x57},
+               {"Error-transient-failure", 0x58},
+               {"Error-transient-failure", 0x59},
+               {"Error-transient-failure", 0x5A},
+               {"Error-transient-failure", 0x5B},
+               {"Error-transient-failure", 0x5C},
+               {"Error-transient-failure", 0x5D},
+               {"Error-transient-failure", 0x5E},
+               {"Error-transient-failure", 0x5F},
+
+               {"Error-permanent-failure", 0x60},
+               {"Error-permanent-service-denied", 0x61},
+               {"Error-permanent-message-not-found", 0x62},
+               {"Error-permanent-content-unsupported", 0x63},
+
+               {"Error-permanent-failure", 0x64}, //reserved for future
+               {"Error-permanent-failure", 0x65},
+               {"Error-permanent-failure", 0x66},
+               {"Error-permanent-failure", 0x67},
+               {"Error-permanent-failure", 0x68},
+               {"Error-permanent-failure", 0x69},
+               {"Error-permanent-failure", 0x6A},
+               {"Error-permanent-failure", 0x6B},
+               {"Error-permanent-failure", 0x6C},
+               {"Error-permanent-failure", 0x6D},
+               {"Error-permanent-failure", 0x6E},
+               {"Error-permanent-failure", 0x6F},
+               {"Error-permanent-failure", 0x70},
+               {"Error-permanent-failure", 0x71},
+               {"Error-permanent-failure", 0x72},
+               {"Error-permanent-failure", 0x73},
+               {"Error-permanent-failure", 0x74},
+               {"Error-permanent-failure", 0x75},
+               {"Error-permanent-failure", 0x76},
+               {"Error-permanent-failure", 0x77},
+               {"Error-permanent-failure", 0x78},
+               {"Error-permanent-failure", 0x79},
+               {"Error-permanent-failure", 0x7A},
+               {"Error-permanent-failure", 0x7B},
+               {"Error-permanent-failure", 0x7C},
+               {"Error-permanent-failure", 0x7D},
+               {"Error-permanent-failure", 0x7E},
+               {"Error-permanent-failure", 0x7F}
+
+       },
+
+       /* MmsCodeReadReply */
+       {
+               { "Yes", 0x00 }, { "No", 0x01 }
+       },
+
+       /* MmsCodeReportAllowed */
+       {
+               { "Yes", 0x00 }, { "No", 0x01 }
+       },
+
+       /* MmsCodeSenderVisibility */
+       {
+               { "Show", 0x01 }, { "Hide", 0x00 }
+       },
+
+       /* MmsCodeMsgStatus */
+       {
+               {"Expired", 0x00},
+               {"Retrieved", 0x01},
+               {"Rejected", 0x02},
+               {"Deferred", 0x03},
+               {"Unrecognised", 0x04},
+
+               /* Add by MMSENC v1.1 */
+               {"Indeterminate ", 0x05},
+               {"Forwarded", 0x06},
+
+               /* Add by MMSENC v1.2 */
+               {"Unreachable", 0x07 }
+
+       },
+
+       /* MmsCodeReadStatus */
+       {
+               {"Read", 0x00}, {"Deleted", 0x01}
+       },
+
+       /* MmsCodeAddressType */
+       {
+               {"present", 0x00}, {"insert", 0x01}
+       },
+
+
+       /* MSG Specific (MsgMIMEExtern.h) -----------------------*/
+
+       /* MmsCodeCharSet */
+       {
+               {"us-ascii", 0x03},
+               {"UTF-16", 0x03F7},
+               {"ISO-10646-UCS-2", 0x03E8},
+               {"UTF-8", 0x6A},
+
+               {"ISO-2022-KR", 0x25},
+               {"KS_C_5601-1987", 0x24},
+               {"EUC-KR", 0x26},
+               {"ISO-2022-JP", 0x27},
+               {"ISO-2022-JP-2", 0x28},
+
+               {"ISO_8859-1", 0x04},
+               {"ISO_8859-2", 0x05},
+               {"ISO-8859-3", 0x06},
+               {"ISO-8859-4", 0x07},
+               {"ISO-8859-5", 0x08},
+               {"ISO-8859-6", 0x09},
+               {"ISO-8859-6-E", 0x51},
+               {"ISO-8859-6-I", 0x52},
+               {"ISO-8859-7", 0x0a},
+               {"ISO-8859-8", 0x0b},
+               {"ISO-8859-8-I", 0x85},
+               {"ISO-8859-9", 0x0c},
+               {"ISO-8859-10", 0x0d},
+               {"ISO-8859-15", 0x6F},
+
+               {"Shift_JIS", 0x11},
+               {"EUC-JP", 0x13},
+               {"GB2312", 0x07E9},
+               {"BIG5", 0x0d},
+               {"WIN1251", 0xFF},
+               {"WINDOW-1251", 0xFF},
+               {"WINDOWS-1251", 0xFF},
+               {"KOI8-R", 0x0824},
+               {"KOI8-U", 0x0828},
+       },
+
+       /* MmsCodeReplyCharging, */
+       {
+               { "Requested", 0x00 },
+               { "Requested text only", 0x01 },
+               { "Accepted", 0x02 },
+               { "Accepted text only", 0x03 }
+       },
+
+
+       /* MSG Specific (MsgMIMEExtern.h) -----------------------*/
+
+       /* Content-Type (http://www.wapforum.org/wina/wsp-content-type.htm) */
+       /* this group(Content-Type) will be replaced by utyMime */
+       {
+               // {"Text/txt", 0x01},
+               {"Text/html", 0x02},
+               {"Text/plain", 0x03},
+               {"Text/vnd.wap.wml", 0x08},
+               {"Text/x-vCalendar", 0x06},
+               {"Text/x-vCard", 0x07},
+
+               {"Application/vnd.wap.multipart.*", 0x22},
+               {"Application/vnd.wap.multipart.mixed", 0x23},
+               {"Application/vnd.wap.multipart.related", 0x33},
+               {"Application/vnd.wap.multipart.alternative", 0x26},
+
+               {"application/vnd.oma.drm.message", 0x48},                      // 10
+               {"application/vnd.oma.drm.content", 0x49},
+               {"application/vnd.oma.drm.rights+xml", 0x4A},
+               {"application/vnd.oma.drm.rights+wbxml", 0x4B},
+
+               {"application/smil", 0xFFFF},
+               {"Multipart/mixed", 0x0c},
+               {"Multipart/related", 0x0B},
+               {"Multipart/alternative", 0x0F},
+
+               {"multipart/report", 0xffff},
+               {"Message/rfc822", 0xffff},
+
+       //   T E X T
+               {"Image/gif", 0x1D},                    // 20
+               {"Image/jpeg", 0x1E},
+               {"Image/jpg", 0xFFFF},
+               {"image/tiff", 0x1f},
+               {"Image/png", 0x20},
+
+
+               {"Image/vnd.wap.wbmp", 0x21},
+
+               {"Image/wbmp", 0xFFFF},
+               {"Image/pjpeg", 0xFFFF},
+
+               {"Image/bmp", 0xFFFF},
+
+       // A U D I O
+               {"Audio/basic", 0xFFFF},
+               {"Audio/mpeg", 0xFFFF},                 // 30
+               {"Audio/x-mpeg", 0xFFFF},
+               {"Audio/mp3", 0xFFFF},
+               {"audio/x-mp3", 0xFFFF},
+               {"audio/mpeg3", 0xFFFF},
+               {"audio/x-mpeg3", 0xFFFF},
+               {"audio/mpg", 0xFFFF},
+               {"audio/x-mpg", 0xFFFF},
+               {"audio/x-mpegaudio", 0xFFFF},
+               {"Audio/aac", 0xFFFF},                  // 39
+               {"Audio/g72", 0xFFFF},
+               {"Audio/amr", 0xFFFF},
+               {"audio/x-amr", 0xFFFF},
+               {"audio/x-mmf", 0xFFFF},
+               {"application/vnd.smaf",  0xffff},
+               {"application/x-smaf", 0xFFFF},
+               {"audio/mmf", 0xFFFF},
+
+               {"text/x-iMelody", 0xffff},
+               {"audio/x-iMelody", 0xffff},
+               {"audio/iMelody", 0xffff},              // 49
+               {"audio/mid",0xffff},
+               {"audio/midi", 0xffff},
+               {"audio/x-midi", 0xffff},
+               {"audio/sp-midi", 0xffff},
+               {"audio/wave", 0xffff},
+               {"audio/3gpp", 0xffff},
+               {"audio/vnd.rn-realaudio", 0xffff},
+               {"audio/x-pn-realaudio", 0xffff},
+               {"audio/mp4",  0xffff},
+
+       // V I D E O
+               {"video/mpeg4", 0xFFFF},
+               {"video/mp4", 0xffff},
+               {"video/x-mp4", 0xFFFF},
+               {"video/x-vp-mp4", 0xffff},
+               {"Video/h263", 0xFFFF},
+
+               {"video/3gpp", 0xffff},
+               {"video/3gp", 0xffff},
+               {"Video/avi", 0xFFFF},
+
+               {"video/sdp", 0xffff},                  // 70
+               {"application/vnd.rn-realmedia", 0xffff},
+               {"video/vnd.rn-realvideo", 0xffff},
+
+               {"application/octet-stream", 0xFFFF }
+       },
+
+       /* MmsCodeMsgDisposition : Wsp Header (By Wsp 8.4.2.53) */
+       {
+               {"form-data", 0x00},
+               {"attachment", 0x01},
+               {"inline", 0x02}
+       },
+
+       /* Content-transfer-encoding : HTTP Header(Binary Value is not assigned) */
+       {
+               {"7bit", 0x00},
+               {"8bit", 0x00},
+               {"binary", 0x00},
+               {"base64", 0x00},
+               {"quoted-printable", 0x00}
+       }
+};
+
+/* global variables */
+static char    gszMmsVersion[5] = {0, };
+
+char *_MmsGetTextValue(MmsCode i, int j)
+{
+       if (i == MmsCodeContentType) {
+               //apply UtyMime
+               return MimeGetMimeStringFromMimeInt(j);
+       }
+
+       return (char *)gMmsField[i][j].szText;
+}
+
+char *_MmsGetTextValuebyField(int field, int value)
+{
+       char *szValue = NULL;
+
+       switch (field) {
+       case MMS_CODE_MSGTYPE:
+               szValue = _MmsGetTextValue(MmsCodeMsgType, value);
+               break;
+
+       case MMS_CODE_MSGCLASS:
+               szValue = _MmsGetTextValue(MmsCodeMsgClass, value);
+               break;
+
+       case MMS_CODE_PRIORITY:
+               szValue = _MmsGetTextValue(MmsCodePriority, value);
+               break;
+
+       case MMS_CODE_SENDERVISIBILLITY:
+               szValue = _MmsGetTextValue(MmsCodeSenderVisibility, value);
+               break;
+
+       case MMS_CODE_DELIVERYREPORT:
+               szValue = _MmsGetTextValue(MmsCodeDeliveryReport, value);
+               break;
+
+       case MMS_CODE_READREPLY:
+               szValue = _MmsGetTextValue(MmsCodeReadReply, value);
+               break;
+
+       case MMS_CODE_MSGSTATUS:
+               szValue = _MmsGetTextValue(MmsCodeMsgStatus, value);
+               break;
+
+       case MMS_CODE_REPORTALLOWED:
+               szValue = _MmsGetTextValue(MmsCodeReportAllowed, value);
+               break;
+
+       case MMS_CODE_RESPONSESTATUS:
+               szValue = _MmsGetTextValue(MmsCodeResponseStatus, value);
+               break;
+
+       /* Add by MMSENC v1.1 */
+       case MMS_CODE_READSTATUS:
+               szValue = _MmsGetTextValue(MmsCodeReadStatus, value);
+               break;
+
+       default:
+               szValue = NULL;
+               break;
+       }
+
+       return szValue;
+}
+
+UINT16 _MmsGetBinaryValue(MmsCode i, int j)
+{
+       if (i == MmsCodeContentType) {
+               return MimeGetBinaryValueFromMimeInt((MimeType)j);
+       }
+
+       return gMmsField[i][j].binary;
+}
+
+// getting mime type (int) by binary type
+int _MmsGetBinaryType(MmsCode i, UINT16 value)
+{
+       MSG_BEGIN();
+
+       if (i == MmsCodeContentType) {
+               //apply UtyMime
+               return MimeGetMimeIntFromBi(value);
+       }
+
+       for (int j = 0; j < MMS_MAX_FIELD_VALUE_COUNT; j++) {
+               if (gMmsField[i][j].binary == value) {
+                       return j;
+               }
+       }
+
+       MSG_END();
+
+       return MIME_UNKNOWN;
+}
+
+int _MmsGetTextType(MmsCode i, char *pValue)
+{
+       int j = 0;
+
+       if (i == MmsCodeContentType) {
+               /*apply UtyMime */
+               return MimeGetMimeIntFromMimeString( pValue );
+       }
+
+       for (j = 0; j < MMS_MAX_FIELD_VALUE_COUNT; j++) {
+               if (gMmsField[i][j].szText != NULL) {
+                       if (strcasecmp( gMmsField[i][j].szText, pValue ) == 0) {
+                               return j;
+                       }
+               }
+       }
+
+       return -1;
+}
+
+UINT8 _MmsGetVersion(MmsMsg *pMsg)
+{
+       if (pMsg == NULL) {
+               return MMS_VERSION;
+       }
+
+       return pMsg->mmsAttrib.version;
+}
+
+bool _MmsSetVersion(int majorVer, int minorVer)
+{
+       snprintf(gszMmsVersion, sizeof(gszMmsVersion), "%d.%d", majorVer, minorVer);
+       return true;
+}
+
diff --git a/plugin/mms_plugin/MmsPluginConnManWrapper.cpp b/plugin/mms_plugin/MmsPluginConnManWrapper.cpp
new file mode 100755 (executable)
index 0000000..02ed598
--- /dev/null
@@ -0,0 +1,447 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MmsPluginConnManWrapper.h"
+
+void network_print_profile(net_profile_info_t *ProfInfo)
+{
+       int di = 0;
+
+       unsigned char *ipaddr;
+       unsigned char *netmaskaddr;
+       unsigned char *gwaddr;
+       net_dev_info_t *net_info;
+
+       if (ProfInfo->profile_type == NET_DEVICE_CELLULAR) {
+               ipaddr = (unsigned char *)&ProfInfo->ProfileInfo.Pdp.net_info.IpAddr.Data.Ipv4.s_addr;
+               netmaskaddr = (unsigned char *)&ProfInfo->ProfileInfo.Pdp.net_info.SubnetMask.Data.Ipv4.s_addr;
+               gwaddr = (unsigned char *)&ProfInfo->ProfileInfo.Pdp.net_info.GatewayAddr.Data.Ipv4.s_addr;
+               net_info = &(ProfInfo->ProfileInfo.Pdp.net_info);
+       } else {
+               MSG_DEBUG("Error!!! Invalid profile type\n");
+               return;
+       }
+
+       MSG_DEBUG("**************************************************************************************************");
+
+       MSG_DEBUG("Profile Name = [%s]\n", ProfInfo->ProfileName);
+
+       if (ProfInfo->ProfileState == NET_STATE_TYPE_IDLE)
+               MSG_DEBUG("Profile State = [idle]\n");
+       else if (ProfInfo->ProfileState == NET_STATE_TYPE_FAILURE)
+               MSG_DEBUG("Profile State = [failure]\n");
+       else if (ProfInfo->ProfileState == NET_STATE_TYPE_ASSOCIATION)
+               MSG_DEBUG("Profile State = [association]\n");
+       else if (ProfInfo->ProfileState == NET_STATE_TYPE_CONFIGURATION)
+               MSG_DEBUG("Profile State = [configuration]\n");
+       else if (ProfInfo->ProfileState == NET_STATE_TYPE_READY)
+               MSG_DEBUG("Profile State = [ready]\n");
+       else if (ProfInfo->ProfileState == NET_STATE_TYPE_ONLINE)
+               MSG_DEBUG("Profile State = [online]\n");
+       else if (ProfInfo->ProfileState == NET_STATE_TYPE_DISCONNECT)
+               MSG_DEBUG("Profile State = [disconnect]\n");
+       else
+               MSG_DEBUG("Profile State = [unknown]\n");
+
+               MSG_DEBUG("Profile Type = [pdp]\n");
+
+       if (ProfInfo->ProfileInfo.Pdp.ProtocolType == NET_PDP_TYPE_GPRS)
+               MSG_DEBUG("Profile Protocol Type = [GPRS]\n");
+       else if (ProfInfo->ProfileInfo.Pdp.ProtocolType == NET_PDP_TYPE_EDGE)
+               MSG_DEBUG("Profile Protocol Type = [EDGE]\n");
+       else if (ProfInfo->ProfileInfo.Pdp.ProtocolType == NET_PDP_TYPE_UMTS)
+               MSG_DEBUG("Profile Protocol Type = [UMTS]\n");
+       else
+               MSG_DEBUG("Profile Protocol Type = [NONE]\n");
+
+       MSG_DEBUG("Profile APN = [%s]\n", ProfInfo->ProfileInfo.Pdp.Apn);
+
+       if (ProfInfo->ProfileInfo.Pdp.AuthInfo.AuthType == NET_PDP_AUTH_PAP)
+               MSG_DEBUG("Profile Auth Type = [PAP]\n");
+       else if (ProfInfo->ProfileInfo.Pdp.AuthInfo.AuthType == NET_PDP_AUTH_CHAP)
+               MSG_DEBUG("Profile Auth Type = [CHAP]\n");
+       else
+               MSG_DEBUG("Profile Auth Type = [NONE]\n");
+
+       MSG_DEBUG("Profile Auth UserName = [%s]\n", ProfInfo->ProfileInfo.Pdp.AuthInfo.UserName);
+       MSG_DEBUG("Profile Auth Password = [%s]\n", ProfInfo->ProfileInfo.Pdp.AuthInfo.Password);
+       MSG_DEBUG("Profile Home URL = [%s]\n", ProfInfo->ProfileInfo.Pdp.HomeURL);
+       MSG_DEBUG("Profile MCC = [%s]\n", ProfInfo->ProfileInfo.Pdp.Mcc);
+       MSG_DEBUG("Profile MNC = [%s]\n", ProfInfo->ProfileInfo.Pdp.Mnc);
+       MSG_DEBUG("Profile Roaming = [%d]\n", (int)ProfInfo->ProfileInfo.Pdp.Roaming);
+       MSG_DEBUG("Profile Setup Required = [%d]\n", (int)ProfInfo->ProfileInfo.Pdp.SetupRequired);
+       MSG_DEBUG("Profile Favourite = [%d]\n", (int)ProfInfo->Favourite);
+       MSG_DEBUG("Profile Device Name = [%s]\n", net_info->DevName);
+       MSG_DEBUG("Profile DNS Count = [%d]\n", net_info->DnsCount);
+       for (di = 0; di < net_info->DnsCount; di++) {
+               unsigned char *dns = (unsigned char *)&net_info->DnsAddr[di].Data.Ipv4.s_addr;
+               MSG_DEBUG("Profile DNS Address %d = [%d.%d.%d.%d]\n", di+1, dns[0], dns[1], dns[2], dns[3]);
+       }
+
+       if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_DYNAMIC)
+               MSG_DEBUG("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_DYNAMIC]\n");
+       else if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC)
+               MSG_DEBUG("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_STATIC]\n");
+       else if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_FIXED)
+               MSG_DEBUG("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_FIXED]\n");
+       else if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_OFF)
+               MSG_DEBUG("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_OFF]\n");
+       else
+               MSG_DEBUG("Profile IPv4 Method = [UNKNOWN]\n");
+
+       MSG_DEBUG("Profile IP Address = [%d.%d.%d.%d]\n", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
+       MSG_DEBUG("Profile Netmask = [%d.%d.%d.%d]\n", netmaskaddr[0], netmaskaddr[1], netmaskaddr[2], netmaskaddr[3]);
+       MSG_DEBUG("Profile Gateway = [%d.%d.%d.%d]\n", gwaddr[0], gwaddr[1], gwaddr[2], gwaddr[3]);
+
+       if (net_info->ProxyMethod == NET_PROXY_TYPE_DIRECT)
+               MSG_DEBUG("Proxy Method = [direct]\n");
+       else if (net_info->ProxyMethod == NET_PROXY_TYPE_AUTO)
+               MSG_DEBUG("Proxy Method = [auto]\n");
+       else if (net_info->ProxyMethod == NET_PROXY_TYPE_MANUAL)
+               MSG_DEBUG("Proxy Method = [manual]\n");
+       else
+               MSG_DEBUG("Proxy Method = [unknown]\n");
+
+       MSG_DEBUG("Profile Proxy = [%s]\n", net_info->ProxyAddr);
+
+       MSG_DEBUG("**************************************************************************************************");
+}
+
+
+
+void network_evt_cb (net_event_info_t *event_cb, void *user_data)
+{
+       MSG_BEGIN();
+
+       MmsPluginCmAgent::instance()->processCBdatas(event_cb, user_data);
+
+       MSG_END();
+}
+
+
+MmsPluginCmAgent *MmsPluginCmAgent::pInstance = NULL;
+
+MmsPluginCmAgent *MmsPluginCmAgent::instance()
+{
+       if (!pInstance)
+               pInstance = new MmsPluginCmAgent();
+
+       return pInstance;
+}
+
+MmsPluginCmAgent::MmsPluginCmAgent()
+{
+       MSG_BEGIN();
+
+       isCmOpened = false;
+       bzero(&mmsProfile, sizeof (net_profile_info_t));
+
+       MSG_END();
+}
+
+MmsPluginCmAgent::~MmsPluginCmAgent()
+{
+
+}
+
+bool MmsPluginCmAgent::registration()
+{
+       MSG_BEGIN();
+
+       bool registResult = true;
+
+       if (net_register_client((net_event_cb_t) network_evt_cb, NULL) != NET_ERR_NONE) {
+               MSG_DEBUG("Error!! net_register_client() failed.\n");
+               registResult = false;
+       }
+
+       MSG_END();
+
+       return registResult;
+}
+
+bool MmsPluginCmAgent::open()
+{
+       MSG_BEGIN();
+
+       if (!isCmOpened) {
+               if (!registration())
+                       return false;
+
+               int netOpenResult = NET_ERR_NONE;
+               net_service_type_t service_type = NET_SERVICE_MMS;
+
+               netOpenResult = net_open_connection_with_preference(service_type);
+               if (netOpenResult != NET_ERR_NONE) {
+                       MSG_DEBUG("Error!! net_open_connection_with_profile() failed. [%d]", netOpenResult);
+                       deregistration();
+                       return false;
+               }
+
+               MSG_DEBUG("WAITING UNTIL Network Connection Open.");
+
+               lock();
+
+               int time_ret = 0;
+               time_ret = cv.timedwait(mx.pMutex(), 50);
+
+               unlock();
+
+               if (time_ret == ETIMEDOUT) {
+                       MSG_DEBUG("Network Connection Open Time Out.");
+                       deregistration();
+                       return false;
+               } else {
+                       if(!isCmOpened) {
+                               MSG_DEBUG("Network connection open failed");
+                               deregistration();
+                               return false;
+                       }
+               }
+       } else {
+               MSG_DEBUG("Network is already opened.");
+               return false;
+       }
+
+       MSG_END();
+
+       return isCmOpened;
+}
+
+
+void MmsPluginCmAgent::close()
+{
+       MSG_BEGIN();
+
+       if (isCmOpened) {
+               int netOpenResult = NET_ERR_NONE;
+
+               netOpenResult = net_close_connection(mmsProfile.ProfileName);
+               if (netOpenResult != NET_ERR_NONE) {
+                       MSG_DEBUG("Error!! net_close_connection() failed.\n");
+                       deregistration();
+                       return;
+               }
+
+               MSG_DEBUG("WAITING UNTIL Network Connection Close.");
+
+               lock();
+
+               int time_ret = 0;
+               time_ret = cv.timedwait(mx.pMutex(), 50);
+
+               unlock();
+
+               if (time_ret == ETIMEDOUT) {
+                       MSG_DEBUG("Network Connection Close Timed Out.");
+               }
+
+               deregistration();
+       } else {
+               MSG_DEBUG ("Network Connection is not opened.");
+               return;
+       }
+}
+
+
+void MmsPluginCmAgent::deregistration()
+{
+       MSG_BEGIN();
+
+       int netOpenResult = NET_ERR_NONE;
+
+       netOpenResult = net_deregister_client();
+       if (netOpenResult != NET_ERR_NONE)
+               MSG_DEBUG("Error!! net_deregister_client() failed. [%d]", netOpenResult);
+       else
+               MSG_DEBUG ("net_deregister_client() Success.");
+
+       MSG_END();
+}
+
+
+void MmsPluginCmAgent::processCBdatas(net_event_info_t *event_cb, void *user_data)
+{
+       MSG_BEGIN();
+
+       net_dev_info_t *dev_info = NULL;
+       net_profile_info_t *prof_info = NULL;
+
+       switch (event_cb->Event) {
+       case NET_EVENT_NET_CONFIGURE_RSP:
+               MSG_DEBUG("Received Network Configuration response: %d \n", event_cb->Error);
+               dev_info = (net_dev_info_t *)event_cb->Data;
+
+               /*Successful PDP Activation*/
+               if (event_cb->Error == NET_ERR_NONE) {
+                       char *ip = (char *)&dev_info->IpAddr.Data.Ipv4;
+                       char *netmask = (char *)&dev_info->SubnetMask.Data.Ipv4;
+                       char *gateway = (char *)&dev_info->GatewayAddr.Data.Ipv4;
+                       char *dns1 = (char *)&dev_info->DnsAddr[0].Data.Ipv4.s_addr;
+                       char *dns2 = (char *)&dev_info->DnsAddr[1].Data.Ipv4.s_addr;
+
+                       MSG_DEBUG("= IP address [%d.%d.%d.%d]\n",
+                                       (int)ip[0], ip[1], ip[2], ip[3]);
+                       MSG_DEBUG("= Netmask [%d.%d.%d.%d]\n",
+                                       (int)netmask[0], netmask[1], netmask[2], netmask[3]);
+                       MSG_DEBUG("= Gateway [%d.%d.%d.%d]\n",
+                                       (int)gateway[0], gateway[1], gateway[2], gateway[3]);
+                       MSG_DEBUG("= DNS address [%d.%d.%d.%d]\n",
+                                       (int)dns1[0], dns1[1], dns1[2], dns1[3]);
+                       MSG_DEBUG("= DNS2 address [%d.%d.%d.%d]\n",
+                                       (int)dns2[0], dns2[1], dns2[2], dns2[3]);
+                       MSG_DEBUG("= Device name [%s]\n", dev_info->DevName);
+                       MSG_DEBUG("= Profile name [%s]\n", dev_info->ProfileName);
+               } else {
+                       MSG_DEBUG("Error!!! Network Configuration Failed %d \n", event_cb->Error);
+               }
+               break;
+
+               /*Response from Datacom for PDP Activation Request*/
+       case NET_EVENT_OPEN_IND:
+               MSG_DEBUG("Got Open Indication\n");
+               MSG_DEBUG("Received ACTIVATION response: %d \n", event_cb->Error);
+               break;
+       case NET_EVENT_OPEN_RSP:
+               MSG_DEBUG("Got Open RSP\n");
+               MSG_DEBUG("Received ACTIVATION response: %d \n", event_cb->Error);
+               prof_info = (net_profile_info_t *)event_cb->Data;
+
+               /*Successful PDP Activation*/
+               if (event_cb->Error == NET_ERR_NONE || event_cb->Error == NET_ERR_ACTIVE_CONNECTION_EXISTS) {
+                       network_print_profile(prof_info);
+
+                       lock();
+
+                       memcpy(&mmsProfile, prof_info, sizeof(net_profile_info_t));
+                       isCmOpened = true;
+                       signal();
+
+                       unlock();
+               } else {
+                       MSG_DEBUG("Activation Failed %d \n", event_cb->Error); // open failed
+                       lock();
+                       isCmOpened = false;
+                       signal();
+                       unlock();
+               }
+               break;
+
+       case NET_EVENT_CLOSE_RSP:
+               MSG_DEBUG("Got Close RSP\n");
+
+               lock();
+
+               bzero(&mmsProfile, sizeof(net_profile_info_t));
+               isCmOpened = false;
+               signal();
+
+               unlock();
+               break;
+
+       case NET_EVENT_CLOSE_IND:
+               MSG_DEBUG("Got Close IND\n");
+               break;
+       case NET_EVENT_PROFILE_MODIFY_IND:
+               MSG_DEBUG("Received Profile modified Indication\n");
+               MSG_DEBUG("No. of profile [%d]\n", event_cb->Datalength);
+               break;
+       case NET_EVENT_NET_STATE_IND:
+               MSG_DEBUG("Received NET_EVENT_NET_STATE_IND\n");
+               break;
+       default :
+               MSG_DEBUG("Error! Unknown Event\n\n");
+               break;
+       }
+
+       MSG_END();
+}
+
+
+bool MmsPluginCmAgent::getDeviceName(char *deviceName)
+{
+       if (!isCmOpened)
+               return false;
+
+       int deviceNameLength = strlen(mmsProfile.ProfileInfo.Pdp.net_info.DevName);
+
+       if (deviceNameLength > 0) {
+               strncpy(deviceName, mmsProfile.ProfileInfo.Pdp.net_info.DevName, deviceNameLength);
+               deviceName[deviceNameLength] = '\0';
+               return true;
+       }
+
+       return false;
+}
+
+
+bool MmsPluginCmAgent::getHomeURL(char *homeURL)
+{
+       if (!isCmOpened)
+               return false;
+
+       int homeURLLength = strlen(mmsProfile.ProfileInfo.Pdp.HomeURL);
+
+       if (homeURLLength > 0) {
+               strncpy(homeURL, mmsProfile.ProfileInfo.Pdp.HomeURL, homeURLLength);
+               homeURL[homeURLLength] = '\0';
+               return true;
+       }
+
+       return false;
+}
+
+
+bool MmsPluginCmAgent::getProxyAddr(char *proxyAddr)
+{
+       if (!isCmOpened)
+               return false;
+
+       int proxyAddrLength = strlen(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr);
+
+       if (proxyAddrLength > 0) {
+               if (strchr(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr, ':') == NULL)
+                       return false;
+
+               proxyAddrLength = proxyAddrLength - strlen(strchr(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr, ':'));
+               strncpy(proxyAddr, mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr, proxyAddrLength);
+               proxyAddr[proxyAddrLength] = '\0';
+
+               return true;
+       }
+
+       return false;
+}
+
+
+int MmsPluginCmAgent::getProxyPort()
+{
+       if (!isCmOpened)
+               return -1;
+
+       int proxyAddrLength = strlen(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr);
+
+       if (proxyAddrLength > 0) {
+               char *pPort = strchr(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr, ':') + 1;
+               if (pPort)
+                       return atoi(pPort);
+               else
+                       return -1;
+       }
+
+       return -1;
+}
+
diff --git a/plugin/mms_plugin/MmsPluginContentCodec.cpp b/plugin/mms_plugin/MmsPluginContentCodec.cpp
new file mode 100755 (executable)
index 0000000..b747d90
--- /dev/null
@@ -0,0 +1,1068 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdlib.h>
+#include <ctype.h>
+#include "MsgDebug.h"
+#include "MmsPluginCodec.h"
+#include "MmsPluginCodec.h"
+#include "MmsPluginMIME.h"
+#include "MmsPluginMessage.h"
+#include "MmsPluginWmLngPack.h"
+
+const int MSG_MAX_CH_PER_LINE = 75;
+
+/* ==================================================================
+ *     Decode/Encode inline base64 string
+ *
+ * base64 : 3*8bit -> 4*6bit & convert the value into A~Z, a~z, 0~9, +, or /
+ * pad(=) is needed when the end of the string is < 24bit.
+ *
+ *     Value Encoding  Value Encoding  Value Encoding  Value Encoding
+ *         0 A            17 R            34 i            51 z
+ *         1 B            18 S            35 j            52 '0'
+ *         2 C            19 T            36 k            53 1
+ *         3 D            20 U            37 l            54 2
+ *         4 E            21 V            38 m            55 3
+ *         5 F            22 W            39 n            56 4
+ *         6 G            23 X            40 o            57 5
+ *         7 H            24 Y            41 p            58 6
+ *         8 I            25 Z            42 q            59 7
+ *         9 J            26 a            43 r            60 8
+ *        10 K            27 b            44 s            61 9
+ *        11 L            28 c            45 t            62 +
+ *        12 M            29 d            46 u            63 /
+ *        13 N            30 e            47 v
+ *        14 O            31 f            48 w         (pad) =
+ *        15 P            32 g            49 x
+ *        16 Q            33 h            50 y
+ *
+ * (1) the final quantum = 24 bits : no "=" padding,
+ * (2) the final quantum = 8 bits : two "=" + two characters
+ * (3) the final quantum = 16 bits : one "=" + three characters
+ * ================================================================== */
+
+bool _MsgEncodeBase64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret)
+{
+       unsigned char *d = NULL;
+       unsigned char *s = (unsigned char *)pSrc;
+
+       char *v = (char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+       unsigned long i = ((srcLen + 2) / 3) * 4;
+
+       i += 2 * ((i / 60) + 1);
+       *len = i;
+
+       if (ret == NULL) {
+               MSG_DEBUG("_MsgEncodeBase64: ret Memory Alloc Fail \n");
+               return false;
+       }
+       memset(ret, 0, i);
+
+       d = ret;
+
+       /* Convert 3*8bit into 4*6bit */
+       for (i = 0; srcLen > 0; s += 3) {
+               *d++ = v[s[0] >> 2];                                                                                                                    // byte 1: high 6 bits of character-1
+               *d++ = v[((s[0] << 4) + (--srcLen ? (s[1] >> 4) : 0)) & 0x3f];                                  // byte 2: low 2 bits of character-1 and high 4 bits of character-2
+               *d++ = srcLen ? v[((s[1] << 2) + (--srcLen ? (s[2] >> 6) : 0)) & 0x3f] : '=';   // byte 3: low 4 bits of charcter-2 and high 2 bits of character-3
+               *d++ = srcLen ? v[s[2] & 0x3f] : '=';                                                                                   // byte 4: low 6 bits of character-3
+
+               if (srcLen)
+                       srcLen--;
+
+               /* Insert CRLF at every 60 characters */
+               if ((++i) == 15) {
+                       i = 0;
+                       *d++ = '\015';
+                       *d++ = '\012';
+               }
+       }
+
+       if (i == 15) {
+               *d++ = '\015';
+               *d++ = '\012';
+       }
+       *d = '\0';
+
+       if (((unsigned long)(d - ret)) != *len) {
+               *len = d - ret;
+               MSG_DEBUG("base64 encoding length = %d \n", *len);
+       }
+
+       return true;
+}
+
+
+void *_MsgDecodeBase64(unsigned char *pSrc, unsigned long srcLen, unsigned long *len)
+{
+       char c;
+       void *ret = NULL;
+       char *d = NULL;
+       short e = 0;
+
+       ret = malloc((size_t)(*len = 4 + ((srcLen * 3) / 4)));
+       d = (char *)ret;
+
+       if (ret == NULL) {
+               MSG_DEBUG("_MsgDecodeBase64: ret malloc Fail \n");
+               return NULL;
+       }
+
+       memset(ret, 0, (size_t)*len);
+       *len = 0;
+
+       while (srcLen-- > 0) {
+               c = *pSrc++;
+
+               /* Convert base64 character into original value */
+
+               if (isupper(c))
+                       c -= 'A';
+               else if (islower(c))
+                       c -= 'a' - 26;
+               else if (isdigit(c))
+                       c -= '0' - 52;
+               else if (c == '+')
+                       c = 62;
+               else if (c == '/')
+                       c = 63;
+               else if (c == '=') {
+                       switch (e++) {
+                       case 2:
+                               if (*pSrc != '=') {
+                                       *len = d - (char *)ret;
+                                       return ret;
+                               }
+                               break;
+                       case 3:
+                               e = 0;
+                               break;
+                       default:
+                               *len = d - (char *)ret;
+                               return ret;
+                       }
+                       continue;
+               } else
+                       continue;                                       // Actually, never get here
+
+               /* Pad 4*6bit character into 3*8bit character */
+
+               switch (e++) {
+               case 0:
+                       *d = c << 2;                    // byte 1: high 6 bits
+                       break;
+
+               case 1:
+                       *d++ |= c >> 4;                 // byte 1: low 2 bits
+                       *d = c << 4;                    // byte 2: high 4 bits
+                       break;
+
+               case 2:
+                       *d++ |= c >> 2;                 // byte 2: low 4 bits
+                       *d = c << 6;                    // byte 3: high 2 bits
+                       break;
+
+               case 3:
+                       *d++ |= c;                              // byte 3: low 6 bits
+                       e = 0;                                  // Calculate next unit.
+                       break;
+
+               default:
+                       MSG_DEBUG("_MsgDecodeBase64: Unknown paremeter\n");
+                       break;
+               }
+       }
+
+       *len = d - (char *)ret;                 // Calculate the size of decoded string.
+
+       return ret;
+}
+
+
+
+/* ==========================================
+ *     Decode/Encode inline base64 string
+ *
+ * quoted-printable := ([*(ptext / SPACE / TAB) ptext] ["="] CRLF)
+ *       ; Maximum line length of 76 characters excluding CRLF
+ *
+ * ptext := octet /<any ASCII character except "=", SPACE, or TAB>
+ *       ; characters not listed as "mail-safe" in Appendix B
+ *       ; are also not recommended.
+ *
+ * octet := "=" 2(DIGIT / "A" / "B" / "C" / "D" / "E" / "F")
+ *       ; octet must be used for characters > 127, =, SPACE, or TAB.
+ *
+ * ==========================================*/
+
+bool _MsgEncodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret)
+{
+       unsigned long lp = 0;
+       unsigned char *d = ret;
+       char *hex = (char *)"0123456789ABCDEF";
+       unsigned char c;
+
+       if (ret == NULL) {
+               MSG_DEBUG("_MsgEncodeQuotePrintable: ret malloc Fail \n");
+               return false;
+       }
+
+       d = ret;
+
+       /*
+        * The type of srcLen is unsigned long
+        * The value of srcLen is decreased by 1 -> We can't check by "srcLen > 0".
+        */
+       while (srcLen-- > 0) {
+               /* Just copy CRLF */
+               if (((c = *pSrc++) == '\015') && (*pSrc == '\012') && srcLen) {
+                       *d++ = '\015';
+                       *d++ = *pSrc++;
+                       srcLen--;
+                       lp = 0;
+               } else {
+                       if (iscntrl(c) || (c == 0x7f) || (c & 0x80) || (c == '=') || ((c == ' ') && (*pSrc == '\015'))) {
+                               if ((lp += 3) > (unsigned long)MSG_MAX_CH_PER_LINE) {
+                                       *d++ = '=';
+                                       *d++ = '\015';
+                                       *d++ = '\012';
+                                       lp = 3;
+                               }
+
+                               *d++ = '=';                             /* quote character */
+                               *d++ = hex[c >> 4];             /* high order 4 bits */
+                               *d++ = hex[c & 0xf];    /* low order 4 bits */
+                       } else {
+                               /* Just copy ASCII character */
+                               if ((++lp) > (unsigned long)MSG_MAX_CH_PER_LINE) {
+                                       *d++ = '=';
+                                       *d++ = '\015';
+                                       *d++ = '\012';
+                                       lp = 1;
+                               }
+                               *d++ = c;
+                       }
+               }
+       }
+
+       *d = '\0';
+       *len = d - ret;
+
+       return true;
+}
+
+
+unsigned char *_MsgDecodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len)
+{
+       unsigned char *ret = NULL;
+       unsigned char *d = NULL;
+       unsigned char *s = NULL;                                        /* last non-blank */
+       unsigned char c;
+       unsigned char e;
+
+       d = s = ret = (unsigned char *)malloc((size_t)srcLen + 1);
+       if (ret == NULL) {
+               MSG_DEBUG("_MsgDecodeQuotePrintable: ret malloc Fail \n");
+               return NULL;
+       }
+
+       *len = 0;
+       pSrc[srcLen] = '\0';
+
+       while ((c = *pSrc++)!= '\0') {
+               switch (c) {
+               case '=':                                                       /* octet characters (> 127, =, SPACE, or TAB) */
+                       switch (c = *pSrc++) {
+                       case '\0':                                      /* end of string -> postpone to while */
+                               break;
+
+                       case '\015':                            /* CRLF */
+                               if (*pSrc == '\012')
+                                       pSrc++;
+                               break;
+
+                       default:                                        /* two hexes */
+                               if (!isxdigit(c)) {
+                                       *d = '\0';
+                                       *len = d - ret;
+                                       return ret;
+                               }
+
+                               if (isdigit(c))
+                                       e = c - '0';
+                               else
+                                       e = c - (isupper(c) ? 'A' - 10 : 'a' - 10);
+
+                               c = *pSrc++;
+                               if (!isxdigit(c)) {
+                                       *d = '\0';
+                                       *len = d - ret;
+                                       return ret;
+                               }
+
+                               if (isdigit(c))
+                                       c -= '0';
+                               else
+                                       c -= (isupper(c) ? 'A' - 10 : 'a' - 10);
+
+                               *d++ = c + (e << 4);
+                               s = d;
+                               break;
+                       }
+                       break;
+
+               case ' ':                                                       /* skip the blank */
+                       *d++ = c;
+                       break;
+
+               case '\015':                                            /* Line Feedback : to last non-blank character */
+                       d = s;
+                       break;
+
+               default:
+                       *d++ = c;                                               /* ASCII character */
+                       s = d;
+                       break;
+               }
+       }
+
+       *d = '\0';
+       *len = d - ret;
+
+       return ret;
+}
+
+
+/* ========================================
+ * Decode/Encode inline base64 string
+ * Inline base64 has no "\r\n" in it,
+ * and has charset and encoding sign in it
+ * ======================================== */
+bool _MsgEncode2Base64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret)
+{
+       unsigned char *d = NULL;
+       unsigned char *s = (unsigned char *)pSrc;
+       char *v = (char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+       unsigned long i = ((srcLen + 2) / 3) * 4;
+
+       i += 2 * ((i / 60) + 1);
+       *len = i;
+
+       if (ret == NULL) {
+               MSG_DEBUG("_MsgEncode2Base64: ret Memory Alloc Fail \n");
+               return false;
+       }
+       memset(ret, 0, i);
+
+       d = ret;
+
+       /* Convert 3*8bit into 4*6bit */
+       for (i = 0; srcLen > 0; s += 3) {
+               *d++ = v[s[0] >> 2];                                                                                                                    // byte 1: high 6 bits of character-1
+               *d++ = v[((s[0] << 4) + (--srcLen ? (s[1] >> 4) : 0)) & 0x3f];                                  // byte 2: low 2 bits of character-1 and high 4 bits of character-2
+               *d++ = srcLen ? v[((s[1] << 2) + (--srcLen ? (s[2] >> 6) : 0)) & 0x3f] : '=';   // byte 3: low 4 bits of charcter-2 and high 2 bits of character-3
+               *d++ = srcLen ? v[s[2] & 0x3f] : '=';                                                                                   // byte 4: low 6 bits of character-3
+
+               if (srcLen)
+                       srcLen--;
+       }
+
+       *d = '\0';
+
+       if (((unsigned long)(d - ret)) != *len) {
+               *len = d - ret;
+               MSG_DEBUG("base64 encoding length = %d \n", *len);
+       }
+
+       return true;
+}
+
+
+char *_MsgDecodeText(char *pOri)
+{
+       MSG_BEGIN();
+
+       int size = 0;
+       int cnt = 0;
+       char *pSrc = NULL;
+       char *pTemp = NULL;
+       char *pRe = NULL;
+       char *pStrEnd = NULL;
+       char *pDecStart = NULL;
+       char *pDecEnd = NULL;
+       char *pDecQ = NULL;
+       char *pDecQ2 = NULL;
+       bool bEncoding = false;
+       int     nCharset = MSG_CHARSET_UTF8;
+       int     nChar = 0;
+       int     nByte = 0;
+       int     nTemp = 0;
+       char *pReturnStr = NULL;
+       char *pConvertedStr = NULL;
+       MCHAR *mszTempStr = NULL;
+
+       MCHAR *pmszOutTextStr = NULL;
+
+       char szTempBuf[MSG_LOCAL_TEMP_BUF_SIZE] = {0};
+
+       // copy original string
+       if (strlen(pOri) >= MSG_LOCAL_TEMP_BUF_SIZE) {
+               pSrc = MsgStrCopy( pOri );
+       } else {
+               memset(szTempBuf, 0, MSG_LOCAL_TEMP_BUF_SIZE);
+               strcpy(szTempBuf, pOri);
+
+               pSrc = szTempBuf;
+       }
+
+       // it can be one or more encoding methods in a line
+       while (1) {
+               cnt++;
+
+               bEncoding = false;
+
+               /*
+                 (ex) "=?euc-kr?B?Y2NqMjEyMw==?="
+
+                 pDecStart: charset                    (=?euc-kr?B?Y2NqMjEyMw==?=)
+                 pDecQ : Encoding type         (B?Y2NqMjEyMw==?=)
+                 pDecQ2        : Encoded text          (Y2NqMjEyMw==?=)
+                 pDecEnd       : Encoded of text       (?=)
+                */
+               if (pSrc == NULL)
+                       goto __CATCH;
+
+               if (((pDecStart = strstr(pSrc, MSG_STR_DEC_START)) != NULL)     //"=?"
+                    && ((pDecQ = strchr(pDecStart + 2, MSG_CH_QUESTION)) != NULL)      // '?'
+                    && ((pDecQ2 = strchr(pDecQ + 1, MSG_CH_QUESTION))!= NULL)          // '?'
+                    && ((pDecEnd = strstr(pDecQ2 + 1, MSG_STR_DEC_END))!= NULL)) {     //"=?"
+                       bEncoding = true;
+
+                       /* fixme: charset problem
+                        * pDecStart ~ pDecQ : charSet & MSG_CHARSET_USC2 ~ MSG_CHARSET_UTF8 & LATIN
+                        */
+
+                       *pDecQ = '\0';
+                       nCharset = _MsgGetCode(MSG_CHARSET, pDecStart + 2);
+                       *pDecQ = MSG_CH_QUESTION;
+               }
+
+               // End of encoding
+               if (!bEncoding)
+                       goto __RETURN;
+
+               // find end of string
+               pStrEnd = pSrc + strlen(pSrc);
+
+               // Decoding
+               if ((*(pDecQ2 - 1) == MSG_CH_BASE64_UPPER) ||
+                       (*(pDecQ2 - 1) == MSG_CH_BASE64_LOWER) ||
+                       (*(pDecQ + 1) == MSG_CH_BASE64_UPPER) ||
+                       (*(pDecQ + 1) == MSG_CH_BASE64_LOWER)) {
+                       pTemp = (char *)_MsgDecodeBase64((UCHAR *)(pDecQ2 + 1), (ULONG)(pDecEnd - pDecQ2 - 1), (ULONG *)&size);
+
+                       if (pTemp != NULL) {
+                               pTemp[size] = MSG_CH_NULL;
+
+                               if(pRe) {
+                                       free(pRe);
+                                       pRe = NULL;
+                               }
+
+                               pRe = (char *)malloc((pDecStart-pSrc) + size + (pStrEnd - (pDecEnd + 2)) + 1);
+                               if (pRe == NULL) {
+                                       MSG_DEBUG("_MsgDecodeText: pRemalloc fail \n");
+                                       free(pTemp);
+                                       pTemp = NULL;
+
+                                       goto __RETURN;
+                               }
+
+                               memcpy(pRe, pSrc, pDecStart - pSrc);
+                               memcpy(&pRe[pDecStart-pSrc], pTemp, size);
+                               memcpy(&pRe[(pDecStart - pSrc) + size], pDecEnd + 2, pStrEnd - (pDecEnd + 2));
+                               pRe[(pDecStart - pSrc) + size + (pStrEnd - (pDecEnd + 2))] = MSG_CH_NULL;
+
+                               free(pTemp);
+                               pTemp = NULL;
+
+                               if (pSrc != NULL && pSrc != szTempBuf) {
+                                       free(pSrc);
+                                       pSrc = NULL;
+                               }
+                       }
+               } else if ((*(pDecQ2-1) == MSG_CH_QPRINT_UPPER) ||
+                               (*(pDecQ2-1) == MSG_CH_QPRINT_LOWER) ||
+                               (*(pDecQ+1) == MSG_CH_QPRINT_UPPER) ||
+                               (*(pDecQ+1) == MSG_CH_QPRINT_LOWER)) {
+
+                       pTemp = (char *)_MsgDecodeQuotePrintable((UCHAR *)( pDecQ2 + 1 ), (ULONG)(pDecEnd - pDecQ2 - 1), (ULONG *)&size);
+
+                       if (pTemp != NULL) {
+                               int i;
+                               pTemp[size] = MSG_CH_NULL;
+
+                               for (i = 0; i < size; i++) {
+                                       if (pTemp[i] == MSG_CH_UNDERLINE) {
+                                               pTemp[i] = MSG_CH_SP;                         // change '_' to ' '
+                                       }
+                               }
+
+                               if(pRe) {
+                                       free(pRe);
+                                       pRe = NULL;
+                               }
+
+                               pRe = (char *)malloc((pDecStart - pSrc) + size + (pStrEnd - (pDecEnd + 2)) + 1);
+                               if (pRe == NULL) {
+                                       MSG_DEBUG("_MsgDecodeText: pRemalloc fail \n");
+                                       free(pTemp);
+                                       pTemp = NULL;
+
+                                       goto __RETURN;
+                               }
+
+                               memcpy(pRe, pSrc, pDecStart - pSrc);
+                               memcpy(&pRe[pDecStart - pSrc], pTemp, size);
+                               memcpy(&pRe[(pDecStart - pSrc) + size], pDecEnd + 2, pStrEnd - (pDecEnd + 2));
+                               pRe[(pDecStart - pSrc) + size + (pStrEnd - (pDecEnd + 2))] = MSG_CH_NULL;
+
+                               if (pTemp) {
+                                       free(pTemp);
+                                       pTemp = NULL;
+                               }
+
+                               if (pSrc != NULL && pSrc != szTempBuf) {
+                                       free(pSrc);
+                                       pSrc = NULL;
+                               }
+                       }
+               } else {
+                       goto __RETURN;
+               }
+       }
+
+__RETURN:
+
+       pTemp = pSrc;
+       nTemp = strlen(pSrc);
+
+       switch (nCharset) {
+       case MSG_CHARSET_UTF16:
+       case MSG_CHARSET_USC2:
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_USC2 \n");
+
+               if (pTemp) {
+                       // mmf file name display patch
+                       if (((UINT8)pTemp[0] == 0xFF && (UINT8)pTemp[1] == 0xFE) || ((UINT8)pTemp[0] == 0xFE && (UINT8)pTemp[1] == 0xFF)) {
+
+                               nChar = (nTemp / 2 - 1);
+
+                               // Re check char-set
+                               if (MsgIsUTF8String((unsigned char *)pTemp + 2, nTemp - 2)) {
+                                       strncpy(pTemp, pTemp + 2, strlen(pTemp + 2));
+                                       nTemp = nTemp - 2;
+                                       MSG_DEBUG("_MsgDecodeText: real char-set = MSG_CHARSET_UTF8.\n");
+                                       break;
+                               }
+
+                               mszTempStr = (unsigned short *)malloc(nChar * sizeof(unsigned short));
+                               if (mszTempStr == NULL) {
+                                       MSG_DEBUG("_MsgDecodeText: 1. Memory Full !!! \n");
+                                       goto __CATCH;
+                               }
+
+                               memcpy(mszTempStr, ((unsigned short *)pTemp + 1), nChar * sizeof(unsigned short));
+
+                               nByte = MsgGetUnicode2UTFCodeSize(((unsigned short *)pTemp + 1), nChar);
+
+                               pConvertedStr = (char *)malloc(nByte + 1);
+                               if (pConvertedStr) {
+                                       MsgUnicode2UTF ((unsigned char *)pConvertedStr, nByte + 1, mszTempStr, nChar);
+                               }
+                       } else {
+                               nChar = (nTemp / 2);
+
+                               if (nChar == 0) {
+                                       nChar = 2;
+                               }
+
+                               // Re check char-set
+                               if (MsgIsUTF8String((unsigned char *)pTemp, nTemp)) {
+                                       MSG_DEBUG("_MsgDecodeText: real char-set = MSG_CHARSET_UTF8.\n");
+                                       break;
+                               }
+
+                               mszTempStr = (unsigned short *)malloc(nChar * sizeof(unsigned short));
+                               if (mszTempStr == NULL) {
+                                       MSG_DEBUG("_MsgDecodeText: 2. Memory Full !!! \n");
+                                       goto __CATCH;
+                               }
+
+                               memcpy(mszTempStr, ((unsigned short *)pTemp), nChar * sizeof(unsigned short));
+
+                               nByte = MsgGetUnicode2UTFCodeSize(((unsigned short *)pTemp), nChar);
+
+                               pConvertedStr = (char *)malloc(nByte + 1);
+                               if (pConvertedStr) {
+                                       MsgUnicode2UTF ((unsigned char *)pConvertedStr, nByte + 1, mszTempStr, nChar);
+                               }
+                       }
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_CHARSET_US_ASCII:
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_US_ASCII \n");
+               break;
+
+       case MSG_CHARSET_UTF8:
+
+               /* UTF8 is  default charset of Messenger */
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_UTF8 \n");
+
+               break;
+
+       case MSG_CHARSET_ISO_8859_1:
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_1 \n");
+
+               nByte = nTemp * 3;
+
+               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
+               if (pmszOutTextStr == NULL) {
+                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
+                       goto __CATCH;
+               }
+
+               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
+               if (pConvertedStr) {
+                       WmConvertLatinCode2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
+                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
+               }
+
+               if (pmszOutTextStr) {
+                       free(pmszOutTextStr);
+                       pmszOutTextStr = NULL;
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_CHARSET_ISO_8859_2:
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_2 \n");
+
+               nByte = nTemp * 3;
+
+               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
+               if (pmszOutTextStr == NULL) {
+                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
+                       goto __CATCH;
+               }
+
+               pConvertedStr =  (char *)malloc(sizeof(char *) * (nByte + 1));
+               if (pConvertedStr) {
+                       WmConvertLatin2Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
+                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
+               }
+
+               if (pmszOutTextStr) {
+                       free(pmszOutTextStr);
+                       pmszOutTextStr = NULL;
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_CHARSET_ISO_8859_3:
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_3 \n");
+
+               nByte = WmGetLatin32UTFCodeSize((unsigned char *)pTemp, nTemp);
+
+               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
+               if (pmszOutTextStr == NULL) {
+                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
+                       goto __CATCH;
+               }
+
+               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
+               if (pConvertedStr) {
+                       WmConvertLatin3Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
+                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
+               }
+
+               if (pmszOutTextStr) {
+                       free(pmszOutTextStr);
+                       pmszOutTextStr = NULL;
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_CHARSET_ISO_8859_4:
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_4 \n");
+
+               nByte = WmGetLatin42UTFCodeSize((unsigned char *)pTemp, nTemp);
+
+               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
+               if (pmszOutTextStr == NULL) {
+                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
+                       goto __CATCH;
+               }
+
+               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
+               if (pConvertedStr) {
+                       WmConvertLatin4Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
+                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
+               }
+
+               if (pmszOutTextStr) {
+                       free(pmszOutTextStr);
+                       pmszOutTextStr = NULL;
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_CHARSET_ISO_8859_5:
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_5 \n");
+
+               nByte = WmGetLatin52UTFCodeSize((unsigned char *)pTemp, nTemp);
+
+               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
+               if (pmszOutTextStr == NULL) {
+                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
+                       goto __CATCH;
+               }
+
+               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
+               if (pConvertedStr) {
+                       WmConvertLatin5Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
+                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
+               }
+
+               if (pmszOutTextStr) {
+                       free(pmszOutTextStr);
+                       pmszOutTextStr = NULL;
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_CHARSET_ISO_8859_7:
+
+               /* Greek */
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_9 \n");
+
+               nByte = MsgGetLatin72UTFCodeSize((unsigned char *)pTemp, nTemp);
+               pConvertedStr = (char *)malloc( nByte + 1);
+               if (pConvertedStr) {
+                       MsgLatin7code2UTF((unsigned char *)pConvertedStr, nByte + 1 , (unsigned char *)pTemp, nTemp);
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_CHARSET_ISO_8859_8:
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_8 \n");
+
+               nByte = WmGetLatin82UTFCodeSize((unsigned char *)pTemp, nTemp);
+
+               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
+               if (pmszOutTextStr == NULL) {
+                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
+                       goto __CATCH;
+               }
+
+               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
+               if (pConvertedStr) {
+                       WmConvertLatin8Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
+                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
+               }
+
+               if (pmszOutTextStr) {
+                       free(pmszOutTextStr);
+                       pmszOutTextStr = NULL;
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_CHARSET_ISO_8859_9:
+               /* Turkish */
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_9 \n");
+
+               nByte = MsgGetLatin52UTFCodeSize((unsigned char *)pTemp, nTemp);
+               pConvertedStr = (char *)malloc(nByte + 1);
+               if (pConvertedStr) {
+                       MsgLatin5code2UTF((unsigned char *)pConvertedStr, nByte + 1 , (unsigned char *)pTemp, nTemp);
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_CHARSET_ISO_8859_15:
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_15 \n");
+
+               nByte = WmGetLatin152UTFCodeSize((unsigned char *)pTemp, nTemp);
+
+               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
+               if (pmszOutTextStr == NULL) {
+                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
+                       goto __CATCH;
+               }
+
+               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
+               if (pConvertedStr) {
+                       WmConvertLatin15Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
+                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
+               }
+
+               if (pmszOutTextStr) {
+                       free(pmszOutTextStr);
+                       pmszOutTextStr = NULL;
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_CHARSET_WIN1251:
+       case MSG_CHARSET_WINDOW_1251:
+       case MSG_CHARSET_WINDOWS_1251:
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_WINDOWS_1251 \n");
+
+               nByte = nTemp * 3;
+
+               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
+               if (pmszOutTextStr == NULL) {
+                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
+                       goto __CATCH;
+               }
+
+               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
+               if (pConvertedStr) {
+                       WmConvertWin1251Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
+                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
+               }
+
+               if (pmszOutTextStr) {
+                       free(pmszOutTextStr);
+                       pmszOutTextStr = NULL;
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_CHARSET_KOI8_R:
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_KOI8_R \n");
+
+               nByte = nTemp * 3;
+
+               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
+               if (pmszOutTextStr == NULL) {
+                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
+                       goto __CATCH;
+               }
+
+               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
+               if (pConvertedStr) {
+                       WmConvertKoi8rCode2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
+                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
+               }
+
+               if (pmszOutTextStr) {
+                       free(pmszOutTextStr);
+                       pmszOutTextStr = NULL;
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_CHARSET_KOI8_U:
+
+               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_KOI8_U \n");
+
+               nByte = nTemp * 3;
+
+               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
+               if (pmszOutTextStr == NULL) {
+                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
+                       goto __CATCH;
+               }
+
+               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
+               if (pConvertedStr) {
+                       WmConvertKoi8uCode2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
+                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
+               }
+
+               if (pmszOutTextStr) {
+                       free(pmszOutTextStr);
+                       pmszOutTextStr = NULL;
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+
+       default:
+
+               MSG_DEBUG("_MsgDecodeText: Other charsets \n");
+
+               nByte = MsgGetLatin2UTFCodeSize((unsigned char *)pTemp, nTemp);
+               pConvertedStr = (char *)malloc(nByte + 1);
+               if (pConvertedStr) {
+                       MsgLatin2UTF((unsigned char *)pConvertedStr, nByte + 1, (unsigned char *)pTemp, nTemp);
+               }
+
+               pTemp = pConvertedStr;
+               nTemp = nByte;
+
+               break;
+       }
+
+       pReturnStr = (char *)malloc(nTemp + 1);
+       if (pReturnStr == NULL) {
+               goto __CATCH;
+       }
+       memset(pReturnStr, 0, nTemp + 1);
+
+       if (pTemp)
+               memcpy(pReturnStr, pTemp, nTemp);
+
+       if (pConvertedStr) {
+               free(pConvertedStr);
+               pConvertedStr = NULL;
+       }
+
+       if (mszTempStr) {
+               free(mszTempStr);
+               mszTempStr = NULL;
+       }
+
+       if(pRe) {
+               free(pRe);
+               pRe = NULL;
+       }
+
+       if (pSrc != NULL && pSrc != szTempBuf) {
+               free(pSrc);
+               pSrc = NULL;
+       }
+
+       return pReturnStr;
+
+__CATCH:
+
+       if (pConvertedStr) {
+               free(pConvertedStr);
+               pConvertedStr = NULL;
+       }
+
+       if (mszTempStr) {
+               free(mszTempStr);
+               mszTempStr = NULL;
+       }
+
+       if(pRe) {
+               free(pRe);
+               pRe = NULL;
+       }
+
+       if (pSrc != NULL && pSrc != szTempBuf) {
+               free(pSrc);
+               pSrc = NULL;
+       }
+
+       return NULL;
+}
+
+
+char *MsgEncodeText(char *pOri)
+{
+       ULONG nLen = 0;
+       char *szBuff = NULL;
+       int length  = 0;
+
+       length = (strlen(pOri) * 4) / 3 + 2 + 12 + 1 + 30;
+       szBuff = (char *)malloc(length + 1);
+
+       if (szBuff == NULL) {
+               // error handling
+               MSG_DEBUG("_MsgEncodeText: szBuff alloc is failed \n");
+               goto __CATCH;
+       }
+
+       memset(szBuff, 0 , length + 1);
+
+       snprintf(szBuff, length+1, "%s%s%c%c%c", MSG_STR_DEC_START, "utf-8", MSG_CH_QUESTION, MSG_CH_BASE64_LOWER, MSG_CH_QUESTION);
+
+       if (_MsgEncode2Base64((unsigned char *)pOri, strlen(pOri), &nLen, (unsigned char *)szBuff + 10) == false) {
+               MSG_DEBUG("_MsgEncodeText: MsgEncodeBase64() is failed \n");
+               goto __CATCH;
+       }
+
+       strcat(szBuff, MSG_STR_DEC_END);
+
+       return szBuff;
+
+__CATCH:
+       if (szBuff) {
+               free(szBuff);
+       }
+
+       return false;
+}
+
diff --git a/plugin/mms_plugin/MmsPluginDebug.cpp b/plugin/mms_plugin/MmsPluginDebug.cpp
new file mode 100755 (executable)
index 0000000..395bb35
--- /dev/null
@@ -0,0 +1,1365 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include "MmsPluginMIME.h"
+#include "MmsPluginMessage.h"
+
+static char gszDebugStringBuf[50];
+
+static char *MmsDebugPrintUnknownValue(int value)
+{
+       printf(gszDebugStringBuf, "unknown value(%d)", value);
+       return gszDebugStringBuf;
+}
+
+
+const char *MmsDebugGetMimeType(MimeType mimeType)
+{
+       switch (mimeType) {
+       case MIME_APPLICATION_XML:
+               return "MIME_APPLICATION_XML";
+       case MIME_APPLICATION_WML_XML:
+               return "MIME_APPLICATION_WML_XML";
+       case MIME_APPLICATION_XHTML_XML:
+               return "MIME_APPLICATION_XHTML_XML";
+       case MIME_APPLICATION_JAVA_VM:
+               return "MIME_APPLICATION_JAVA_VM";
+       case MIME_APPLICATION_SMIL:
+               return "MIME_APPLICATION_SMIL";
+       case MIME_APPLICATION_JAVA_ARCHIVE:
+               return "MIME_APPLICATION_JAVA_ARCHIVE";
+       case MIME_APPLICATION_JAVA:
+               return "MIME_APPLICATION_JAVA";
+       case MIME_APPLICATION_OCTET_STREAM:
+               return "MIME_APPLICATION_OCTET_STREAM";
+       case MIME_APPLICATION_STUDIOM:
+               return "MIME_APPLICATION_STUDIOM";
+       case MIME_APPLICATION_FUNMEDIA:
+               return "MIME_APPLICATION_FUNMEDIA";
+       case MIME_APPLICATION_MSWORD:
+               return "MIME_APPLICATION_MSWORD";
+       case MIME_APPLICATION_PDF:
+               return "MIME_APPLICATION_PDF";
+       case MIME_APPLICATION_ASTERIC:
+               return "MIME_APPLICATION_ASTERIC";
+       case MIME_APPLICATION_VND_WAP_XHTMLXML:
+               return "MIME_APPLICATION_VND_WAP_XHTMLXML";
+       case MIME_APPLICATION_VND_WAP_WMLC:
+               return "MIME_APPLICATION_VND_WAP_WMLC";
+       case MIME_APPLICATION_VND_WAP_WMLSCRIPTC:
+               return "MIME_APPLICATION_VND_WAP_WMLSCRIPTC";
+       case MIME_APPLICATION_VND_WAP_WTA_EVENTC:
+               return "MIME_APPLICATION_VND_WAP_WTA_EVENTC";
+       case MIME_APPLICATION_VND_WAP_UAPROF:
+               return "MIME_APPLICATION_VND_WAP_UAPROF";
+       case MIME_APPLICATION_VND_WAP_SIC:
+               return "MIME_APPLICATION_VND_WAP_SIC";
+       case MIME_APPLICATION_VND_WAP_SLC:
+               return "MIME_APPLICATION_VND_WAP_SLC";
+       case MIME_APPLICATION_VND_WAP_COC:
+               return "MIME_APPLICATION_VND_WAP_COC";
+       case MIME_APPLICATION_VND_WAP_SIA:
+               return "MIME_APPLICATION_VND_WAP_SIA";
+       case MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML:
+               return "MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML";
+       case MIME_APPLICATION_VND_WAP_MULTIPART_FORM_DATA:
+               return "MIME_APPLICATION_VND_WAP_MULTIPART_FORM_DATA";
+       case MIME_APPLICATION_VND_WAP_MULTIPART_BYTERANGES:
+               return "MIME_APPLICATION_VND_WAP_MULTIPART_BYTERANGES";
+       case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED:
+               return "MIME_APPLICATION_VND_WAP_MULTIPART_MIXED";
+       case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED:
+               return "MIME_APPLICATION_VND_WAP_MULTIPART_RELATED";
+       case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE:
+               return "MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE";
+       case MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC:
+               return "MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC";
+       case MIME_APPLICATION_VND_OMA_DD_XML:
+               return "MIME_APPLICATION_VND_OMA_DD_XML";
+       case MIME_APPLICATION_VND_OMA_DRM_MESSAGE:
+               return "MIME_APPLICATION_VND_OMA_DRM_MESSAGE";
+       case MIME_APPLICATION_VND_OMA_DRM_CONTENT:
+               return "MIME_APPLICATION_VND_OMA_DRM_CONTENT";
+       case MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML:
+               return "MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML";
+       case MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML:
+               return "MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML";
+       case MIME_APPLICATION_VND_SMAF:
+               return "MIME_APPLICATION_VND_SMAF";
+       case MIME_APPLICATION_VND_RN_REALMEDIA:
+               return "MIME_APPLICATION_VND_RN_REALMEDIA";
+       case MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE:
+               return "MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE";
+       case MIME_APPLICATION_VND_EXCEL:
+               return "MIME_APPLICATION_VND_EXCEL";
+       case MIME_APPLICATION_X_HDMLC:
+               return "MIME_APPLICATION_X_HDMLC";
+       case MIME_APPLICATION_X_X968_USERCERT:
+               return "MIME_APPLICATION_X_X968_USERCERT";
+       case MIME_APPLICATION_X_WWW_FORM_URLENCODED:
+               return "MIME_APPLICATION_X_WWW_FORM_URLENCODED";
+       case MIME_APPLICATION_X_SMAF:
+               return "MIME_APPLICATION_X_SMAF";
+       case MIME_APPLICATION_X_FLASH:
+               return "MIME_APPLICATION_X_FLASH";
+       case MIME_APPLICATION_X_EXCEL:
+               return "MIME_APPLICATION_X_EXCEL";
+       case MIME_APPLICATION_X_POWERPOINT:
+               return "MIME_APPLICATION_X_POWERPOINT";
+
+       case MIME_AUDIO_BASIC:
+               return "MIME_AUDIO_BASIC";
+       case MIME_AUDIO_MPEG:
+               return "MIME_AUDIO_MPEG";
+       case MIME_AUDIO_MP3:
+               return "MIME_AUDIO_MP3";
+       case MIME_AUDIO_MPG3:
+               return "MIME_AUDIO_MPG3";
+       case MIME_AUDIO_MPEG3:
+               return "MIME_AUDIO_MPEG3";
+       case MIME_AUDIO_MPG:
+               return "MIME_AUDIO_MPG";
+       case MIME_AUDIO_AAC:
+               return "MIME_AUDIO_AAC";
+       case MIME_AUDIO_G72:
+               return "MIME_AUDIO_G72";
+       case MIME_AUDIO_AMR:
+               return "MIME_AUDIO_AMR";
+       case MIME_AUDIO_AMR_WB:
+               return "MIME_AUDIO_AMR_WB";
+       case MIME_AUDIO_MMF:
+               return "MIME_AUDIO_MMF";
+       case MIME_AUDIO_SMAF:
+               return "MIME_AUDIO_SMAF";
+       case MIME_AUDIO_IMELODY:
+               return "MIME_AUDIO_IMELODY";
+       case MIME_AUDIO_MELODY:
+               return "MIME_AUDIO_MELODY";
+       case MIME_AUDIO_MID:
+               return "MIME_AUDIO_MID";
+       case MIME_AUDIO_MIDI:
+               return "MIME_AUDIO_MIDI";
+       case MIME_AUDIO_X_MID:
+               return "MIME_AUDIO_X_MID";
+       case MIME_AUDIO_SP_MIDI:
+               return "MIME_AUDIO_SP_MIDI";
+       case MIME_AUDIO_WAVE:
+               return "MIME_AUDIO_WAVE";
+       case MIME_AUDIO_3GPP:
+               return "MIME_AUDIO_3GPP";
+       case MIME_AUDIO_MP4:
+               return "MIME_AUDIO_MP4";
+       case MIME_AUDIO_MP4A_LATM:
+               return "MIME_AUDIO_MP4A_LATM";
+       case MIME_AUDIO_VND_RN_REALAUDIO:
+               return "MIME_AUDIO_VND_RN_REALAUDIO";
+       case MIME_AUDIO_X_MPEG:
+               return "MIME_AUDIO_X_MPEG";
+       case MIME_AUDIO_X_MP3:
+               return "MIME_AUDIO_X_MP3";
+       case MIME_AUDIO_X_MPEG3:
+               return "MIME_AUDIO_X_MPEG3";
+       case MIME_AUDIO_X_MPG:
+               return "MIME_AUDIO_X_MPG";
+       case MIME_AUDIO_X_AMR:
+               return "MIME_AUDIO_X_AMR";
+       case MIME_AUDIO_X_MMF:
+               return "MIME_AUDIO_X_MMF";
+       case MIME_AUDIO_X_SMAF:
+               return "MIME_AUDIO_X_SMAF";
+       case MIME_AUDIO_X_IMELODY:
+               return "MIME_AUDIO_X_IMELODY";
+       case MIME_AUDIO_X_MIDI:
+               return "MIME_AUDIO_X_MIDI";
+       case MIME_AUDIO_X_MPEGAUDIO:
+               return "MIME_AUDIO_X_MPEGAUDIO";
+       case MIME_AUDIO_X_PN_REALAUDIO:
+               return "MIME_AUDIO_X_PN_REALAUDIO";
+       case MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO:
+               return "MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO";
+       case MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO_LIVE:
+               return "MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO_LIVE";
+       case MIME_AUDIO_X_WAV:
+               return "MIME_AUDIO_X_WAV";
+
+       case MIME_IMAGE_GIF:
+               return "MIME_IMAGE_GIF";
+       case MIME_IMAGE_JPEG:
+               return "MIME_IMAGE_JPEG";
+       case MIME_IMAGE_JPG:
+               return "MIME_IMAGE_JPG";
+       case MIME_IMAGE_TIFF:
+               return "MIME_IMAGE_TIFF";
+       case MIME_IMAGE_TIF:
+               return "MIME_IMAGE_TIF";
+       case MIME_IMAGE_PNG:
+               return "MIME_IMAGE_PNG";
+       case MIME_IMAGE_WBMP:
+               return "MIME_IMAGE_WBMP";
+       case MIME_IMAGE_PJPEG:
+               return "MIME_IMAGE_PJPEG";
+       case MIME_IMAGE_BMP:
+               return "MIME_IMAGE_BMP";
+       case MIME_IMAGE_SVG:
+               return "MIME_IMAGE_SVG";
+       case MIME_IMAGE_SVG1:
+               return "MIME_IMAGE_SVG1";
+       case MIME_IMAGE_VND_WAP_WBMP:
+               return "MIME_IMAGE_VND_WAP_WBMP";
+
+       case MIME_IMAGE_X_BMP:
+               return "MIME_IMAGE_X_BMP";
+
+       case MIME_MESSAGE_RFC822:
+               return "MIME_MESSAGE_RFC822";
+
+       case MIME_MULTIPART_MIXED:
+               return "MIME_MULTIPART_MIXED";
+       case MIME_MULTIPART_RELATED:
+               return "MIME_MULTIPART_RELATED";
+       case MIME_MULTIPART_ALTERNATIVE:
+               return "MIME_MULTIPART_ALTERNATIVE";
+       case MIME_MULTIPART_FORM_DATA:
+               return "MIME_MULTIPART_FORM_DATA";
+       case MIME_MULTIPART_BYTERANGE:
+               return "MIME_MULTIPART_BYTERANGE";
+       case MIME_MULTIPART_REPORT:
+               return "MIME_MULTIPART_REPORT";
+
+       case MIME_TEXT_TXT:
+               return "MIME_TEXT_TXT";
+       case MIME_TEXT_HTML:
+               return "MIME_TEXT_HTML";
+       case MIME_TEXT_PLAIN:
+               return "MIME_TEXT_PLAIN";
+       case MIME_TEXT_CSS:
+               return "MIME_TEXT_CSS";
+       case MIME_TEXT_XML:
+               return "MIME_TEXT_XML";
+       case MIME_TEXT_IMELODY:
+               return "MIME_TEXT_IMELODY";
+       case MIME_TEXT_VND_WAP_WMLSCRIPT:
+               return "MIME_TEXT_VND_WAP_WMLSCRIPT";
+       case MIME_TEXT_VND_WAP_WML:
+               return "MIME_TEXT_VND_WAP_WML";
+       case MIME_TEXT_VND_WAP_WTA_EVENT:
+               return "MIME_TEXT_VND_WAP_WTA_EVENT";
+       case MIME_TEXT_VND_WAP_CONNECTIVITY_XML:
+               return "MIME_TEXT_VND_WAP_CONNECTIVITY_XML";
+       case MIME_TEXT_VND_WAP_SI:
+               return "MIME_TEXT_VND_WAP_SI";
+       case MIME_TEXT_VND_WAP_SL:
+               return "MIME_TEXT_VND_WAP_SL";
+       case MIME_TEXT_VND_WAP_CO:
+               return "MIME_TEXT_VND_WAP_CO";
+       case MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR:
+               return "MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR";
+       case MIME_TEXT_X_HDML:
+               return "MIME_TEXT_X_HDML";
+       case MIME_TEXT_X_VCALENDAR:
+               return "MIME_TEXT_X_VCALENDAR";
+       case MIME_TEXT_X_VCARD:
+               return "MIME_TEXT_X_VCARD";
+       case MIME_TEXT_X_IMELODY:
+               return "MIME_TEXT_X_IMELODY";
+
+       case MIME_VIDEO_MPEG4:
+               return "MIME_VIDEO_MPEG4";
+       case MIME_VIDEO_MP4:
+               return "MIME_VIDEO_MP4";
+       case MIME_VIDEO_H263:
+               return "MIME_VIDEO_H263";
+       case MIME_VIDEO_3GPP:
+               return "MIME_VIDEO_3GPP";
+       case MIME_VIDEO_3GP:
+               return "MIME_VIDEO_3GP";
+       case MIME_VIDEO_AVI:
+               return "MIME_VIDEO_AVI";
+       case MIME_VIDEO_SDP:
+               return "MIME_VIDEO_SDP";
+       case MIME_VIDEO_VND_RN_REALVIDEO:
+               return "MIME_VIDEO_VND_RN_REALVIDEO";
+       case MIME_VIDEO_X_MP4:
+               return "MIME_VIDEO_X_MP4";
+       case MIME_VIDEO_X_PV_MP4:
+               return "MIME_VIDEO_X_PV_MP4";
+       case MIME_VIDEO_X_PN_REALVIDEO:
+               return "MIME_VIDEO_X_PN_REALVIDEO";
+       case MIME_VIDEO_X_PN_MULTIRATE_REALVIDEO:
+               return "MIME_VIDEO_X_PN_MULTIRATE_REALVIDEO";
+       default:
+               return MmsDebugPrintUnknownValue(mimeType);
+       }
+}
+
+
+/* MsgMmsMsg.h */
+const char *MmsDebugGetMmsReport(MmsReport report)
+{
+       switch (report) {
+       case MMS_REPORT_ERROR:
+               return "MMS_REPORT_ERROR";
+       case MMS_REPORT_YES:
+               return "MMS_REPORT_YES";
+       case MMS_REPORT_NO:
+               return "MMS_REPORT_NO";
+       }
+
+       return MmsDebugPrintUnknownValue(report);
+}
+
+
+const char *MmsDebugGetMmsReportAllowed(MmsReportAllowed reportAllowed)
+{
+       switch (reportAllowed) {
+       case MMS_REPORTALLOWED_ERROR:
+               return "MMS_REPORTALLOWED_ERROR";
+       case MMS_REPORTALLOWED_YES:
+               return "MMS_REPORTALLOWED_YES";
+       case MMS_REPORTALLOWED_NO:
+               return "MMS_REPORTALLOWED_NO";
+       }
+
+       return MmsDebugPrintUnknownValue(reportAllowed);
+}
+
+
+const char *MmsDebugGetMmsReadStatus(MSG_READ_REPORT_STATUS_T readStatus)
+{
+       _MSG_READ_REPORT_STATUS_E readReport = (_MSG_READ_REPORT_STATUS_E)readStatus;
+
+       switch (readReport) {
+       case MSG_READ_REPORT_NONE:
+               return "MMS_READSTATUS_NONE";
+       case MSG_READ_REPORT_IS_READ:
+               return "MMS_IS_READ";
+       case MSG_READ_REPORT_IS_DELETED:
+               return "MMS_IS_DELETED";
+       }
+
+       return MmsDebugPrintUnknownValue(readStatus);
+}
+
+const char *MmsDebugGetMsgType(MmsMsgType msgType)
+{
+       switch (msgType) {
+       case MMS_MSGTYPE_ERROR:
+               return "error";
+       case MMS_MSGTYPE_SEND_REQ:
+               return "send.req";
+       case MMS_MSGTYPE_SEND_CONF:
+               return "send.conf";
+       case MMS_MSGTYPE_NOTIFICATION_IND:
+               return "notification.ind";
+       case MMS_MSGTYPE_NOTIFYRESP_IND:
+               return "notifyResp.ind";
+       case MMS_MSGTYPE_RETRIEVE_CONF:
+               return "retrieve conf";
+       case MMS_MSGTYPE_ACKNOWLEDGE_IND:
+               return "acknowledge ind";
+       case MMS_MSGTYPE_DELIVERY_IND:
+               return "delivery ind";
+       case MMS_MSGTYPE_READREC_IND:
+               return "read rec ind";
+       case MMS_MSGTYPE_READORG_IND:
+               return "read org ind";
+       case MMS_MSGTYPE_FORWARD_REQ:
+               return "forward req";
+       case MMS_MSGTYPE_FORWARD_CONF:
+               return "forward conf";
+       case MMS_MSGTYPE_READ_REPLY:
+               return "read reply";
+       default:
+               return MmsDebugPrintUnknownValue(msgType);
+       }
+}
+
+const char *MmsDebugGetResponseStatus(MmsResponseStatus responseStatus)
+{
+       switch (responseStatus) {
+       case MMS_RESPSTATUS_ERROR:
+               return "error";
+       case MMS_RESPSTATUS_OK:
+               return "ok";
+       case MMS_RESPSTAUTS_ERROR_UNSPECIFIED:
+               return "unspecified";
+       case MMS_RESPSTAUTS_ERROR_SERVICEDENIED:
+               return "service denied";
+       case MMS_RESPSTAUTS_ERROR_MESSAGEFORMATCORRUPT:
+               return "message format corrupt";
+       case MMS_RESPSTAUTS_ERROR_SENDINGADDRESSUNRESOLVED:
+               return "sending address unresolved";
+       case MMS_RESPSTAUTS_ERROR_MESSAGENOTFOUND:
+               return "message not found";
+       case MMS_RESPSTAUTS_ERROR_NETWORKPROBLEM:
+               return "network problem";
+       case MMS_RESPSTAUTS_ERROR_CONTENTNOTACCEPTED:
+               return "content not accepted";
+       case MMS_RESPSTAUTS_ERROR_UNSUPPORTEDMESSAGE:
+               return "unsupported message";
+       case MMS_RESPSTAUTS_ERROR_TRANSIENT_FAILURE:
+               return "transient failure";
+       case MMS_RESPSTAUTS_ERROR_TRANSIENT_SENDING_ADDRESS_UNRESOLVED:
+               return "transient sending address unresolved";
+       case MMS_RESPSTAUTS_ERROR_TRANSIENT_MESSAGE_NOT_FOUND:
+               return "transient message not found";
+       case MMS_RESPSTAUTS_ERROR_TRANSIENT_NETWORK_PROBLEM:
+               return "transient network problem";
+       case MMS_RESPSTAUTS_ERROR_PERMANENT_FAILURE:
+               return "permanent failure";
+       case MMS_RESPSTAUTS_ERROR_PERMANENT_SERVICE_DENIED:
+               return "permanent service denied";
+       case MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_FORMAT_CORRUPT:
+               return "permanent message format corrupt";
+       case MMS_RESPSTAUTS_ERROR_PERMANENT_SENDING_ADDRESS_UNRESOLVED:
+               return "permanent sending address unresolved";
+       case MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_NOT_FOUND:
+               return "permanent message not found";
+       case MMS_RESPSTAUTS_ERROR_PERMANENT_CONTENT_NOT_ACCEPTED:
+               return "permanent content not accepted";
+       case MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_LIMITATIONS_NOT_MET:
+               return "permanent reply charging limitations not met";
+       case MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_REQUEST_NOT_ACCEPTED:
+               return "permanent reply charging request not accepted";
+       case MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_FORWARDING_DENIED:
+               return "permanent reply charging forwarding denied";
+       case MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_NOT_SUPPORTED:
+               return "permanent reply charging not supported";
+       }
+
+       return MmsDebugPrintUnknownValue(responseStatus);
+}
+
+
+const char *MmsDebugGetRetrieveStatus(MmsRetrieveStatus retrieveStatus)
+{
+       switch (retrieveStatus) {
+       case MMS_RETRSTATUS_ERROR:
+               return "error";
+       case MMS_RETRSTATUS_OK:
+               return "ok";
+       case MMS_RETRSTATUS_TRANSIENT_FAILURE:
+               return "transient failure";
+       case MMS_RETRSTATUS_TRANSIENT_MESSAGE_NOT_FOUND:
+               return "transient message not found";
+       case MMS_RETRSTATUS_TRANSIENT_NETWORK_PROBLEM:
+               return "transient network problem";
+       case MMS_RETRSTATUS_PERMANENT_FAILURE:
+               return "permanent failure";
+       case MMS_RETRSTATUS_PERMANENT_SERVICE_DENIED:
+               return "permanent service denied";
+       case MMS_RETRSTATUS_PERMANENT_MESSAGE_NOT_FOUND:
+               return "permanent message not found";
+       case MMS_RETRSTATUS_PERMANENT_CONTENT_UNSUPPORT:
+               return "permanent content unsupport";
+       }
+
+       return MmsDebugPrintUnknownValue(retrieveStatus);
+}
+
+
+const char *MmsDebugGetMsgStatus(MSG_DELIVERY_REPORT_STATUS_T msgStatus)
+{
+       switch (msgStatus) {
+       case MSG_DELIVERY_REPORT_ERROR:
+               return "error";
+       case MSG_DELIVERY_REPORT_EXPIRED:
+               return "expired";
+       case MSG_DELIVERY_REPORT_SUCCESS:
+               return "retrieved";
+       case MSG_DELIVERY_REPORT_REJECTED:
+               return "rejected";
+       case MSG_DELIVERY_REPORT_DEFERRED:
+               return "deferred";
+       case MSG_DELIVERY_REPORT_UNRECOGNISED:
+               return "unrecognised";
+       case MSG_DELIVERY_REPORT_INDETERMINATE:
+               return "indeterminate";
+       case MSG_DELIVERY_REPORT_FORWARDED:
+               return "forwarded";
+       case MSG_DELIVERY_REPORT_UNREACHABLE:
+               return "unreachable";
+       }
+
+       return MmsDebugPrintUnknownValue(msgStatus);
+}
+
+
+const char *MmsDebugGetMsgClass(MmsMsgClass msgClass)
+{
+       switch (msgClass) {
+       case MMS_MSGCLASS_ERROR:
+               return "error";
+       case MMS_MSGCLASS_PERSONAL:
+               return "personal";
+       case MMS_MSGCLASS_ADVERTISEMENT:
+               return "advertisement";
+       case MMS_MSGCLASS_INFORMATIONAL:
+               return "information";
+       case MMS_MSGCLASS_AUTO:
+               return "auto";
+       }
+
+       return MmsDebugPrintUnknownValue(msgClass);
+}
+
+
+const char *MmsDebugGetDataType(MmsDataType dataType)
+{
+       switch (dataType) {
+       case MMS_DATATYPE_NONE:
+               return "MMS_DATATYPE_NONE";
+       case MMS_DATATYPE_READ:
+               return "MMS_DATATYPE_READ";
+       case MMS_DATATYPE_SENT:
+               return "MMS_DATATYPE_SENT";
+       case MMS_DATATYPE_NOTIFY:
+               return "MMS_DATATYPE_NOTIFY";
+       case MMS_DATATYPE_UNSENT:
+               return "MMS_DATATYPE_UNSENT";
+       case MMS_DATATYPE_DRAFT:
+               return "MMS_DATATYPE_DRAFT";
+       case MMS_DATATYPE_SENDING:
+               return "MMS_DATATYPE_SENDING";
+       case MMS_DATATYPE_DRM_RO_WAITING:
+               return "MMS_DATATYPE_DRM_RO_WAITING";
+       case MMS_DATATYPE_RETRIEVING:
+               return "MMS_DATATYPE_RETRIEVING";
+       case MMS_DATATYPE_UNRETV:
+               return "MMS_DATATYPE_UNRETV";
+       default:
+               return MmsDebugPrintUnknownValue(dataType);
+       }
+}
+
+#ifdef MMS_PLUGIN_DEBUG_ENABLE
+bool
+MmsDebugPrintMsgAttributes(char *pszFunc, MmsAttrib *pAttrib, bool bAll)
+{
+       SysRequireEx(pAttrib != NULL, false);
+
+       if (pszFunc)
+               SysDebug((MID_MMS|DBG_MMS_COMMON,"%s ========= \n", pszFunc));
+
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "szSubject = %s \n", pAttrib->szSubject));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "contentType=%s \n", MmsDebugGetMimeType(pAttrib->contentType)));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "dataType=%s \n", MmsDebugGetDataType(pAttrib->dataType)));
+
+       if (pAttrib->specialMsgType != MMS_SPECIAL_MSG_TYPE_NONE)
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "spcialMsgType = %lu \n", pAttrib->specialMsgType));
+
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "date=%lu, msgSize=%lu, bRead=%lu\n", pAttrib->date, pAttrib->msgSize, pAttrib->bRead));
+
+       if (!bAll)
+               return true;
+
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "msgClass=%s, priority=%lu \n", MmsDebugGetMsgClass(pAttrib->msgClass), pAttrib->priority ));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "deliveryTime.type = %lu, time = %lu\n", pAttrib->deliveryTime.type, pAttrib->deliveryTime.time));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "expiryTime.type = %lu, time = %lu\n", pAttrib->expiryTime.type, pAttrib->expiryTime.time));
+
+       if (pAttrib->szTo && pAttrib->szTo[0] != 0)
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "szTo = %s \n", pAttrib->szTo));
+       if (pAttrib->szCc && pAttrib->szCc[0] != 0)
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "szCc = %s \n", pAttrib->szCc));
+       if (pAttrib->szBcc && pAttrib->szBcc[0] != 0)
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "szBcc = %s \n", pAttrib->szBcc));
+
+#if defined(_MMS_SUPPORT_RECEIVING_OPTION_PROMPT)
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "readReportAllowedType = %lu \n", pAttrib->readReportAllowedType));
+#endif
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "bAskDeliveryReport=%lu, bReportAllowed=%lu, bAskReadReply=%lu, bLeaveCopy=%lu \n",
+                       pAttrib->bAskDeliveryReport, pAttrib->bReportAllowed, pAttrib->bAskReadReply, pAttrib->bLeaveCopy));
+
+       if (pAttrib->bHideAddress)
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "bHideAddress=true\n"));
+
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "msgStatus = %s \n", MmsDebugGetMsgStatus(pAttrib->msgStatus)));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "responseStatus = %s \n", MmsDebugGetResponseStatus(pAttrib->responseStatus)));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "retrieveStatus = %s \n", MmsDebugGetRetrieveStatus(pAttrib->retrieveStatus)));
+
+       if (pAttrib->szResponseText && pAttrib->szResponseText[0] != 0)
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "szResponseText = %s \n", pAttrib->szResponseText));
+
+       if (pAttrib->szRetrieveText && pAttrib->szRetrieveText[0] != 0)
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "szRetrieveText = %s \n", pAttrib->szRetrieveText));
+
+       return true;
+}
+
+char *MmsDebugGetMsgDrmType(MsgDrmType drmType)
+{
+       switch (drmType) {
+       case MSG_DRM_TYPE_NONE:
+               return "MSG_DRM_TYPE_NONE";
+       case MSG_DRM_TYPE_FL:
+               return "MSG_DRM_TYPE_FL";
+       case MSG_DRM_TYPE_CD:
+               return "MSG_DRM_TYPE_CD";
+       case MSG_DRM_TYPE_SD:
+               return "MSG_DRM_TYPE_SD";
+       case MSG_DRM_TYPE_SSD:
+               return "MSG_DRM_TYPE_SSD";
+       }
+
+       return MmsDebugPrintUnknownValue(drmType);
+}
+
+char *MmsDebugGetDrmDeliveryMode(DrmDeliveryMode deliveryMode)
+{
+       switch (deliveryMode) {
+       case DRM_DELIVERYMODE_FORWARD_LOCK:
+               return "DRM_DELIVERYMODE_FORWARD_LOCK";
+       case DRM_DELIVERYMODE_COMBINED_DELIVERY:
+               return "DRM_DELIVERYMODE_COMBINED_DELIVERY";
+       case DRM_DELIVERYMODE_SEPARATE_DELIVERY:
+               return "DRM_DELIVERYMODE_SEPARATE_DELIVERY";
+       case DRM_DELIVERYMODE_SPECIAL_SEPARATE:
+               return "DRM_DELIVERYMODE_SPECIAL_SEPARATE";
+       }
+
+       return MmsDebugPrintUnknownValue(deliveryMode);
+}
+
+char *MmsDebugGetDrmRightState(DrmRightState rightState)
+{
+       switch (rightState) {
+       case DRMRIGHT_STATE_NORIGHTS:
+               return "DRMRIGHT_STATE_NORIGHTS";
+       case DRMRIGHT_STATE_INVALID_RIGHTS:
+               return "DRMRIGHT_STATE_INVALID_RIGHTS";
+       case DRMRIGHT_STATE_VALID_RIGHTS:
+               return "DRMRIGHT_STATE_VALID_RIGHTS";
+       case DRMRIGHT_STATE_EXPIRED_RIGHTS:
+               return "DRMRIGHT_STATE_EXPIRED_RIGHTS";
+       }
+
+       return MmsDebugPrintUnknownValue(rightState);
+}
+
+
+bool MmsDebugPrintDrmRight(DrmRight *pDrmRight)
+{
+       if (!pDrmRight)
+               return true;
+
+       if (pDrmRight->rightStatus == DRMRIGHT_STATE_NORIGHTS) {
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "rightStatus = %s \n", MmsDebugGetDrmRightState(pDrmRight->rightStatus)));
+               return true;
+       }
+
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "iDeliveryType = %s \n", MmsDebugGetDrmDeliveryMode(pDrmRight->iDeliveryType)));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "bestConstraint = %s \n", MmsDebugGetDrmConsumeMode(pDrmRight->bestConstraint)));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "bFirstIntervalRender = %d \n", pDrmRight->bFirstIntervalRender));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "rightStatus = %s \n", MmsDebugGetDrmRightState(pDrmRight->rightStatus)));
+
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "bValidIssuer = %d \n", pDrmRight->bValidIssuer));
+
+       return true;
+}
+
+char *MmsDebugPrintMsgDRMStatus(MsgDRMStatus status)
+{
+       switch (status) {
+       case MSG_DRM_STATUS_INVALID:
+               return "MSG_DRM_STATUS_INVALID";
+       case MSG_DRM_STATUS_VALID:
+               return "MSG_DRM_STATUS_VALID";
+       case MSG_DRM_STATUS_EXPIRED:
+               return "MSG_DRM_STATUS_EXPIRED";
+       }
+
+       return MmsDebugPrintUnknownValue(status);
+}
+
+
+bool MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index)
+{
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "------------------------------\n"));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "%dth multipart info\n", index));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "header size=%d\n", pMultipart->type.size));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "body size=%d\n", pMultipart->type.contentSize));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "content type=%s\n", MmsDebugGetMimeType(pMultipart->type.type)));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "content ID=%s\n", pMultipart->type.szContentID));
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "content location=%s\n", pMultipart->type.szContentLocation));
+
+       if (pMultipart->type.type == MIME_TEXT_PLAIN) {
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "text info\n"));
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "charset=%d\n", pMultipart->type.param.charset));
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "text file name=%s\n", pMultipart->type.param.szName));
+       }
+
+       if (pMultipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) {
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "drm info\n"));
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "drm type=%s\n", MmsDebugGetMsgDrmType(pMultipart->type.drmInfo.drmType)));
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "drm content type=%s\n", MmsDebugGetMimeType(pMultipart->type.drmInfo.contentType)));
+               SysDebug((MID_MMS|DBG_MMS_COMMON, "drm content URI=%s\n", pMultipart->type.drmInfo.szContentURI));
+       }
+       SysDebug((MID_MMS|DBG_MMS_COMMON, "------------------------------\n"));
+       return true;
+}
+
+
+bool MmsDebugPrintCurrentEventHandler(char *pszFunc, MmsDebugEvType evType)
+{
+       HEventHandler hMmsEH;
+       HEventHandler hSmsEH;
+       HEventHandler hEmailEH;
+       HEventHandler hCommonEH;
+       HEventHandler hCurrentEH;
+
+       hMmsEH          = WmGetEventHandlerByName(EHN_MMS);
+       hSmsEH          = WmGetEventHandlerByName(EHN_SMS);
+       hEmailEH        = WmGetEventHandlerByName(EHN_EMAIL);
+       hCommonEH       = WmGetEventHandlerByName(EHN_MESSENGER);
+       hCurrentEH      = WmGetCurrentEventHandler();
+
+       switch (evType) {
+       case MMS_DEBUG_EV_MMS:
+               SysRequireExf(hCurrentEH == hMmsEH, false, ("%s, hMmsEH=%d, hSmsEH=%d, hEmailEH=%d, hCommonEH=%d, hCurrentEH=%d\n",     \
+                                                       pszFunc, hMmsEH, hSmsEH, hEmailEH, hCommonEH, hCurrentEH));
+               break;
+
+       case MMS_DEBUG_EV_SMS:
+               SysRequireExf(hCurrentEH == hSmsEH, false, ("%s, hMmsEH=%d, hSmsEH=%d, hEmailEH=%d, hCommonEH=%d, hCurrentEH=%d\n",     \
+                                                       pszFunc, hMmsEH, hSmsEH, hEmailEH, hCommonEH, hCurrentEH));
+               break;
+
+       case MMS_DEBUG_EV_COMMON:
+               SysRequireExf(hCurrentEH == hCommonEH, false, ("%s, hMmsEH=%d, hSmsEH=%d, hEmailEH=%d, hCommonEH=%d, hCurrentEH=%d\n",  \
+                                                       pszFunc, hMmsEH, hSmsEH, hEmailEH, hCommonEH, hCurrentEH));
+               break;
+
+       case MMS_DEBUG_EV_EMAIL:
+               SysRequireExf(hCurrentEH == hEmailEH, false, ("%s, hMmsEH=%d, hSmsEH=%d, hEmailEH=%d, hCommonEH=%d, hCurrentEH=%d\n",   \
+                                                       pszFunc, hMmsEH, hSmsEH, hEmailEH, hCommonEH, hCurrentEH));
+               break;
+
+       case MMS_DEBUG_EV_NONE:
+       default:
+               SysDebug((MID_MMS,"%s, hMmsEH=%d, hSmsEH=%d, hEmailEH=%d, hCommonEH=%d, hCurrentEH=%d\n",       \
+                                                       pszFunc, hMmsEH, hSmsEH, hEmailEH, hCommonEH, hCurrentEH));
+               break;
+       }
+       return true;
+}
+
+
+char *DebugPrintGetRmResultInd(MmsRmResultInd indType)
+{
+       switch (indType) {
+       case RM_RESULTIND_NONE:
+               return "RM_RESULTIND_NONE";
+
+       case RM_RESULTIND_MANUAL_SEND:
+               return "RM_RESULTIND_MANUAL_SEND";
+
+       case RM_RESULTIND_AUTO_SEND:
+               return "RM_RESULTIND_AUTO_SEND";
+
+       case RM_RESULTIND_MANUAL_GET:
+               return "RM_RESULTIND_MANUAL_GET";
+
+       case RM_RESULTIND_AUTO_GET:
+               return "RM_RESULTIND_AUTO_GET";
+
+       case RM_RESULTIND_MANUAL_FORWARD:
+               return "RM_RESULTIND_MANUAL_FORWARD";
+       }
+
+       return MmsDebugPrintUnknownValue(indType);
+}
+
+
+char *DebugPrintHttpStatusCode(int status)
+{
+       switch (status) {
+       case HTTP_STATUS_100:
+               return "HTTP_STATUS_100";
+       case HTTP_STATUS_101:
+               return "HTTP_STATUS_101";
+
+       case HTTP_STATUS_200:
+               return "HTTP_STATUS_200";
+       case HTTP_STATUS_201:
+               return "HTTP_STATUS_201";
+       case HTTP_STATUS_202:
+               return "HTTP_STATUS_202";
+       case HTTP_STATUS_203:
+               return "HTTP_STATUS_203";
+       case HTTP_STATUS_204:
+               return "HTTP_STATUS_204";
+       case HTTP_STATUS_205:
+               return "HTTP_STATUS_205";
+       case HTTP_STATUS_206:
+               return "HTTP_STATUS_206";
+
+       case HTTP_STATUS_300:
+               return "HTTP_STATUS_300";
+       case HTTP_STATUS_301:
+               return "HTTP_STATUS_301";
+       case HTTP_STATUS_302:
+               return "HTTP_STATUS_302";
+       case HTTP_STATUS_303:
+               return "HTTP_STATUS_303";
+       case HTTP_STATUS_304:
+               return "HTTP_STATUS_304";
+       case HTTP_STATUS_305:
+               return "HTTP_STATUS_305";
+
+       case HTTP_STATUS_400:
+               return "HTTP_STATUS_400";
+       case HTTP_STATUS_401:
+               return "HTTP_STATUS_401";
+       case HTTP_STATUS_402:
+               return "HTTP_STATUS_402";
+       case HTTP_STATUS_403:
+               return "HTTP_STATUS_403";
+       case HTTP_STATUS_404:
+               return "HTTP_STATUS_404";
+       case HTTP_STATUS_405:
+               return "HTTP_STATUS_405";
+       case HTTP_STATUS_406:
+               return "HTTP_STATUS_406";
+       case HTTP_STATUS_407:
+               return "HTTP_STATUS_407";
+       case HTTP_STATUS_408:
+               return "HTTP_STATUS_408";
+       case HTTP_STATUS_409:
+               return "HTTP_STATUS_409";
+       case HTTP_STATUS_410:
+               return "HTTP_STATUS_410";
+       case HTTP_STATUS_411:
+               return "HTTP_STATUS_411";
+       case HTTP_STATUS_412:
+               return "HTTP_STATUS_412";
+       case HTTP_STATUS_413:
+               return "HTTP_STATUS_413";
+       case HTTP_STATUS_414:
+               return "HTTP_STATUS_414";
+       case HTTP_STATUS_415:
+               return "HTTP_STATUS_415";
+
+       case HTTP_STATUS_500:
+               return "HTTP_STATUS_500";
+       case HTTP_STATUS_501:
+               return "HTTP_STATUS_501";
+       case HTTP_STATUS_502:
+               return "HTTP_STATUS_502";
+       case HTTP_STATUS_503:
+               return "HTTP_STATUS_503";
+       case HTTP_STATUS_504:
+               return "HTTP_STATUS_504";
+       case HTTP_STATUS_505:
+               return "HTTP_STATUS_505";
+
+       case REASON_WTP_UNKNOWN:
+               return "REASON_WTP_UNKNOWN";
+       case REASON_WTP_PROTO_ERR:
+               return "REASON_WTP_PROTO_ERR";
+       case REASON_WTP_INVALID_TID:
+               return "REASON_WTP_INVALID_TID";
+       case REASON_WTP_NOT_IMPLEMENTED_CL2:
+               return "REASON_WTP_NOT_IMPLEMENTED_CL2";
+       case REASON_WTP_NOT_IMPLEMENTED_SAR:
+               return "REASON_WTP_NOT_IMPLEMENTED_SAR";
+       case REASON_WTP_NOT_IMPLEMENTEDU_ACK:
+               return "REASON_WTP_NOT_IMPLEMENTEDU_ACK";
+       case REASON_WTP_VERSIONONE:
+               return "REASON_WTP_VERSIONONE";
+       case REASON_WTP_CAPTEMP_EXCEED:
+               return "REASON_WTP_CAPTEMP_EXCEED";
+       case REASON_WTP_NO_RESPONSE:
+               return "REASON_WTP_NO_RESPONSE";
+       case REASON_WTP_MESSAGE_TOO_LARGE:
+               return "REASON_WTP_MESSAGE_TOO_LARGE";
+
+       case REASON_PROTOERR:
+               return "REASON_PROTOERR";       //  = 0xE0
+       case REASON_DISCONNECT:
+               return "REASON_DISCONNECT";
+       case REASON_SUSPEND:
+               return "REASON_SUSPEND";
+       case REASON_RESUME:
+               return "REASON_RESUME";
+       case REASON_CONGESTION:
+               return "REASON_CONGESTION";
+       case REASON_CONNECTERR:
+               return "REASON_CONNECTERR";
+       case REASON_MRUEXCEEDED:
+               return "REASON_MRUEXCEEDED";
+       case REASON_MOREXCEEDED:
+               return "REASON_MOREXCEEDED";
+       case REASON_PEERREQ:
+               return "REASON_PEERREQ";
+       case REASON_NETERR:
+               return "REASON_NETERR";
+       case REASON_USERREQ:
+               return "REASON_USERREQ";
+       /* added for ver 1.2 */
+       case REASON_USERRFS:
+               return "REASON_USERRFS";
+       case REASON_PND:
+               return "REASON_PND";
+       case REASON_USERDCR:
+               return "REASON_USERDCR";
+       case REASON_USERDCU:
+               return "REASON_USERDCU";
+       }
+
+       return MmsDebugPrintUnknownValue(status);
+}
+
+
+char *DebugPrintRmMethodType(MmsRmMethodType method)
+{
+       switch (method) {
+       case RM_METHOD_NONE:
+               return "RM_METHOD_NONE";
+       case RM_METHOD_GET:
+               return "RM_METHOD_GET";
+       case RM_METHOD_POST:
+               return "RM_METHOD_POST";
+       }
+
+       return MmsDebugPrintUnknownValue(method);
+}
+
+
+char *DebugPrintGetMmsRmNetState(MmsRmNetState state)
+{
+       switch (state) {
+       case RM_PROTO_IDLE:
+               return "RM_PROTO_IDLE";
+       case RM_PROTO_STARTING:
+               return "RM_PROTO_STARTING";
+       case RM_PROTO_STARTED:
+               return "RM_PROTO_STARTED";
+       case RM_PROTO_STOPPING:
+               return "RM_PROTO_STOPPING";
+
+       case RM_PROTO_WAITING:
+               return "RM_PROTO_WAITING";
+       case RM_PROTO_DISCONNECTING_OTHER_APP:
+               return "RM_PROTO_DISCONNECTING_OTHER_APP";
+       case RM_PROTO_DISCONNECTED_BY_OTHER_APP:
+               return "RM_PROTO_DISCONNECTED_BY_OTHER_APP";
+
+       case RM_PROTO_FAILED:
+               return "RM_PROTO_FAILED";
+       }
+
+       return MmsDebugPrintUnknownValue(state);
+}
+
+
+char *DebugPrintGetMmsRmEntityState(MmsRmExEntityState stateEx)
+{
+       switch (stateEx) {
+       case RM_ENTITY_IDLE:
+               return "RM_ENTITY_IDLE";
+       case RM_ENTITY_PROTO_STARTING:
+               return "RM_ENTITY_PROTO_STARTING";
+
+       case RM_ENTITY_CNXN_ESTABLISHING:
+               return "RM_ENTITY_CNXN_ESTABLISHING";
+       case RM_ENTITY_CNXN_ESTABLISHED:
+               return "RM_ENTITY_CNXN_ESTABLISHED";
+
+       case RM_ENTITY_SENDING_REQUEST:
+               return "RM_ENTITY_SENDING_REQUEST";
+       case RM_ENTITY_SENDING_REQ_N_NO_RESPONSE:
+               return "RM_ENTITY_SENDING_REQ_N_NO_RESPONSE";
+
+       case RM_ENTITY_SENDING_REQ_COMPLETED:
+               return "RM_ENTITY_SENDING_REQ_COMPLETED";
+
+       case RM_ENTITY_SENDING_REQ_FAILED:
+               return "RM_ENTITY_SENDING_REQ_FAILED";
+       case RM_ENTITY_SENDING_REQ_CANCELLED_BY_USER_CONFIRMED:
+               return "RM_ENTITY_SENDING_REQ_CANCELLED_BY_USER_CONFIRMED";
+       }
+
+       return MmsDebugPrintUnknownValue(stateEx);
+}
+
+
+char *MmsDebugPrintMmsRmResult(MmsRmResult result)
+{
+       switch (result) {
+       case MMS_RM_RESULT_SUCCESSED:
+               return "MMS_RM_RESULT_SUCCESSED";
+       case MMS_RM_RESULT_FAIL:
+               return "MMS_RM_RESULT_FAIL";
+       case MMS_RM_RESULT_FAIL_N_RETRY:
+               return "MMS_RM_RESULT_FAIL_N_RETRY";
+
+       case MMS_RM_RESULT_PROTO_STARTING_FAILED:
+               return "MMS_RM_RESULT_PROTO_STARTING_FAILED";
+
+       case MMS_RM_RESULT_DISCONNECT_MMS:
+               return "MMS_RM_RESULT_DISCONNECT_MMS";
+       case MMS_RM_RESULT_CLOSING_OTHER_APP_FAILED:
+               return "MMS_RM_RESULT_CLOSING_OTHER_APP_FAILED";
+
+       case MMS_RM_RESULT_SENDING_REQ_FAILED:
+               return "MMS_RM_RESULT_SENDING_REQ_FAILED";
+       case MMS_RM_RESULT_CANCELED_BY_USER:
+               return "MMS_RM_RESULT_CANCELED_BY_USER";
+       case MMS_RM_RESULT_CANCELED_FROM_RETRY_POPUP:
+               return "MMS_RM_RESULT_CANCELED_FROM_RETRY_POPUP";
+
+       case MMS_RM_RESULT_PROTO_FAILED:
+               return "MMS_RM_RESULT_PROTO_FAILED";
+       case MMS_RM_RESULT_DISCONNECTED_BY_OTHER:
+               return "MMS_RM_RESULT_DISCONNECTED_BY_OTHER";
+
+       case MMS_RM_RESULT_MEMORY_FULL:
+               return "MMS_RM_RESULT_MEMORY_FULL";
+       }
+
+       return MmsDebugPrintUnknownValue(result);
+}
+
+void MmsDebugPrintReqEntityInfo(MmsRmRequest *pEntity)
+{
+       SysDebug((MID_MMS,"     - proto state=%s\n", DebugPrintGetMmsRmNetState(_MmsRmNetGetState())));
+
+       if (_MmsRmNetGetProtoType() == MMS_RM_WAP_CONNORIENTED || _MmsRmNetGetProtoType() == MMS_RM_WTLS) {
+               SysDebug((MID_MMS,"     - wap cnxn state=%s\n", DebugPrintWspState(MmsRmWspGetCnxnState())));
+       }
+
+       if (!pEntity) {
+               SysDebug((MID_EXCEPTION, "MmsDebugPrintReqEntityInfo : pEntity is NULL. \n"));
+               return;
+       }
+
+       SysDebug((MID_MMS,"     - entity state=%s\n", DebugPrintGetMmsRmEntityState(pEntity->stateEx)));
+
+       if (pEntity->cb.result.bSend) {
+               if (pEntity->pduType == MMS_RM_READ_REPORT_V10) {
+                       SysDebug((MID_MMS,"     - sending read report v10\n"));
+               } else if (pEntity->pduType == MMS_RM_READ_REPORT_V11) {
+                       SysDebug((MID_MMS,"     - sending read report v11\n"));
+               } else {
+                       SysDebug((MID_MMS,"     - sending msg\n"));
+               }
+       } else {        // then receiving..
+               if (pEntity->cb.result.bAutoRetrieving) {
+                       SysDebug((MID_MMS,"     - retrieving(auto)\n"));
+               } else {
+                       SysDebug((MID_MMS,"     - retrieving(manual)\n"));
+               }
+       }
+
+       SysDebug((MID_MMS,"     - msgID=%d, trID=0x%x, pduType=%s\n", pEntity->msgID, pEntity->trId, MmsDebugPrintRmPduType(pEntity->pduType)));
+
+       if (pEntity->protoActvCount > 1) {
+               SysDebug((MID_MMS,"     - protoActvCount=%d\n", pEntity->protoActvCount));
+       }
+
+       if (pEntity->reqCount > 1) {
+               SysDebug((MID_MMS,"     - reqCount=%d\n", pEntity->reqCount));
+       }
+
+       if (pEntity->fullRetryCount > 1) {
+               SysDebug((MID_MMS,"     - fullRetryCount=%d\n", pEntity->fullRetryCount));
+       }
+}
+
+char *MmsDebugPrintHttpErrorCode(int errCode)
+{
+       switch (errCode) {
+       case HTTPERR_INVALID_PARAM:
+               return "HTTPERR_INVALID_PARAM";
+       case HTTPERR_UNKNOWN:
+               return "HTTPERR_UNKNOWN";
+       case HTTPERR_INVALID_PROXY:
+               return "HTTPERR_INVALID_PROXY";
+       case HTTPERR_OUT_OF_MEMORY:
+               return "HTTPERR_OUT_OF_MEMORY";
+       case HTTPERR_NO_RESPONSE:
+               return "HTTPERR_NO_RESPONSE";
+       case HTTPERR_INIT:
+               return "HTTPERR_INIT";
+       case HTTPERR_NETDOWN:
+               return "HTTPERR_NETDOWN";
+       case HTTPERR_TIMEOUT:
+               return "HTTPERR_TIMEOUT";
+       case HTTPERR_HOST_UNREACH:
+               return "HTTPERR_HOST_UNREACH";
+       case HTTPERR_CONN_RESET:
+               return "HTTPERR_CONN_RESET";
+       case HTTPERR_INTERNAL:
+               return "HTTPERR_INTERNAL";
+       case HTTPERR_CHUNKEDTR:
+               return "HTTPERR_CHUNKEDTR";
+       case HTTPERR_USER:
+               return "HTTPERR_USER";
+       case HTTPERR_TOO_BIG:
+               return "HTTPERR_TOO_BIG";
+       case HTTPERR_NOT_SUPPORTED_SVC:
+               return "HTTPERR_NOT_SUPPORTED_SVC";
+       case HTTPERR_NO_CONTENT:
+               return "HTTPERR_NO_CONTENT";
+       case HTTPERR_WRITEFAIL:
+               return "HTTPERR_WRITEFAIL";
+       case HTTPERR_AUTHFAIL:
+               return "HTTPERR_AUTHFAIL";
+
+       case HTTPERR_DNSFAIL:
+               return "HTTPERR_DNSFAIL";
+       case HTTPERR_UAGENT_NOT_ALLOWED:
+               return "HTTPERR_UAGENT_NOT_ALLOWED";
+
+       }
+       return MmsDebugPrintUnknownValue(errCode);
+}
+
+char *MmsDebugPrintProtoErrorCode(int errCode)
+{
+       switch (errCode) {
+       case PROTO_ERROR_NONE:
+               return "PROTO_ERROR_NONE";
+       /* Wireless stack errors */
+       case PROTO_ERROR_NO_SERVICE:
+               return "PROTO_ERROR_NO_SERVICE";
+       case PROTO_ERROR_INVALID_PARAM:
+               return "PROTO_ERROR_INVALID_PARAM";
+       case PROTO_ERROR_INVALID_APN:
+               return "PROTO_ERROR_INVALID_APN";
+       case PROTO_ERROR_INVALID_OP_MODE:
+               return "PROTO_ERROR_INVALID_OP_MODE";
+       case PROTO_ERROR_INVALID_PROTO_TYPE:
+               return "PROTO_ERROR_INVALID_PROTO_TYPE";
+       case PROTO_ERROR_INVALID_SERVICE_DOMAIN:
+               return "PROTO_ERROR_INVALID_SERVICE_DOMAIN";
+       case PROTO_ERROR_INVALID_PDP_DATA:
+               return "PROTO_ERROR_INVALID_PDP_DATA";
+       case PROTO_ERROR_INVALID_QOS:
+               return "PROTO_ERROR_INVALID_QOS";
+       case PROTO_ERROR_SESSION_DEACTIVATED:
+               return "PROTO_ERROR_SESSION_DEACTIVATED";
+       case PROTO_ERROR_AUTHENTICATION_FAILED:
+               return "PROTO_ERROR_AUTHENTICATION_FAILED";
+       case PROTO_ERROR_MOBILE_FAILURE:
+               return "PROTO_ERROR_MOBILE_FAILURE";
+       case PROTO_ERROR_NETWORK_FAILURE:
+               return "PROTO_ERROR_NETWORK_FAILURE";
+       case PROTO_ERROR_TIMEOUT:
+               return "PROTO_ERROR_TIMEOUT";
+       case PROTO_ERROR_NO_RESOURCE:
+               return "PROTO_ERROR_NO_RESOURCE";
+       case PROTO_ERROR_INVALID_CONTEXT_ID:
+               return "PROTO_ERROR_INVALID_CONTEXT_ID";
+       case PROTO_ERROR_MODEM_IN_USE:
+               return "PROTO_ERROR_MODEM_IN_USE";
+       case PROTO_ERROR_INVALID_SIM_STATE:
+               return "PROTO_ERROR_INVALID_SIM_STATE:";
+       case PROTO_ERROR_SERVICE_NOT_SUBSCRIBED:
+               return "PROTO_ERROR_SERVICE_NOT_SUBSCRIBED";
+       case PROTO_ERROR_SERVICE_NOT_IMPLEMENTED:
+               return "PROTO_ERROR_SERVICE_NOT_IMPLEMENTED";
+       case PROTO_ERROR_FDN_NOT_ALLOWED:
+               return "PROTO_ERROR_FDN_NOT_ALLOWED";
+       case PROTO_ERROR_CALL_INCOME:
+               return "PROTO_ERROR_CALL_INCOME";
+       case PROTO_ERROR_NOT_SUPPORT_3GCSD:
+               return "PROTO_ERROR_NOT_SUPPORT_3GCSD";
+       case PROTO_ERROR_UNKNOWN:
+               return "PROTO_ERROR_UNKNOWN";
+       case PROTO_ERROR_SI_OFFLINE:
+               return "PROTO_ERROR_SI_OFFLINE";
+       /* TCP/IP/PPP stack errors */
+       case PROTO_ERROR_TCPIP_UP:
+               return "PROTO_ERROR_TCPIP_UP";
+       case PROTO_ERROR_TCPIP_DOWN:
+               return "PROTO_ERROR_TCPIP_DOWN";
+       case PROTO_ERROR_PPP_UP:
+               return "PROTO_ERROR_PPP_UP";
+       case PROTO_ERROR_PPP_DOWN:
+               return "PROTO_ERROR_PPP_DOWN";
+       case PROTO_ERROR_WDP_INIT:
+               return "PROTO_ERROR_WDP_INIT";
+       /* ProtoMgr API call errors */
+       case PROTO_ERROR_ACTIVE_CONNECTIONS:
+               return "PROTO_ERROR_ACTIVE_CONNECTIONS";
+       case PROTO_ERROR_MAX_CONNECTIONS:
+               return "PROTO_ERROR_MAX_CONNECTIONS";
+       case PROTO_ERROR_INVALID_HANDLE:
+               return "PROTO_ERROR_INVALID_HANDLE";
+       case PROTO_ERROR_INVALID_CONTEXT:
+               return "PROTO_ERROR_INVALID_CONTEXT";
+       case PROTO_ERROR_INVALID_CALLBACK:
+               return "PROTO_ERROR_INVALID_CALLBACK";
+       case PROTO_ERROR_INVALID_EHN:
+               return "PROTO_ERROR_INVALID_EHN";
+       case PROTO_ERROR_INVALID_EVENTCLASS:
+               return "PROTO_ERROR_INVALID_EVENTCLASS";
+       case PROTO_ERROR_INVALID_REFTYPE:
+               return "PROTO_ERROR_INVALID_REFTYPE";
+       case PROTO_ERROR_INVALID_TIMEOUT:
+               return "PROTO_ERROR_INVALID_TIMEOUT";
+       case PROTO_ERROR_MAX_CLIENT:
+               return "PROTO_ERROR_MAX_CLIENT";
+       case PROTO_ERROR_MAX_ACCOUNT:
+               return "PROTO_ERROR_MAX_ACCOUNT";
+       case PROTO_ERROR_ACCESS_DENIED:
+               return "PROTO_ERROR_ACCESS_DENIED";
+       case PROTO_ERROR_REGISTRY_LOAD:
+               return "PROTO_ERROR_REGISTRY_LOAD";
+
+       case PROTO_ERROR_PCBROWSING_ON:
+               return "PROTO_ERROR_PCBROWSING_ON";
+       case PROTO_ERROR_REACTIVATION_REQ:
+               return "PROTO_ERROR_REACTIVATION_REQ";
+       case PROTO_ERROR_NO_PDP_ACTIVATED:
+               return "PROTO_ERROR_NO_PDP_ACTIVATED";
+
+       case PROTO_ERROR_MAX:
+               return "PROTO_ERROR_MAX";
+
+       }
+
+       return MmsDebugPrintUnknownValue(errCode);
+}
+
+
+char *DebugPrintWspResult(WspResult wspResult)
+{
+       switch (wspResult) {
+       case WSP_RESULT_NO_ERROR:
+               return "WSP_RESULT_NO_ERROR";
+       case WSP_RESULT_NO_SESSION:
+               return "WSP_RESULT_NO_SESSION";
+       case WSP_RESULT_NOT_SUITABLE:
+               return "WSP_RESULT_NOT_SUITABLE";
+
+       case WSP_RESULT_NOT_RESPONDING:
+               return "WSP_RESULT_NOT_RESPONDING";
+       case WSP_RESULT_MOP_EXCEED:
+               return "WSP_RESULT_MOP_EXCEED";
+       case WSP_RESULT_MOM_EXCEED:
+               return "WSP_RESULT_MOM_EXCEED";
+
+       case WSP_RESULT_UNABLE:
+               return "WSP_RESULT_UNABLE";
+       case WSP_RESULT_UNKNOWN:
+               return "WSP_RESULT_UNKNOWN";
+       case WSP_RESULT_WRONG_PARAM:
+               return "WSP_RESULT_WRONG_PARAM";
+
+       case WSP_RESULT_NO_MEMORY:
+               return "WSP_RESULT_NO_MEMORY";
+       case WSP_RESULT_NO_HANDLE:
+               return "WSP_RESULT_NO_HANDLE";
+
+       case WSP_RESULT_CAPABILITY_UNABLE:
+               return "WSP_RESULT_CAPABILITY_UNABLE";
+       case WSP_RESULT_UAGENT_NOT_ALLOWED:
+               return "WSP_RESULT_UAGENT_NOT_ALLOWED";
+       }
+
+       return MmsDebugPrintUnknownValue(wspResult);
+}
+
+
+char *DebugPrintWspState(MmsRmWapState wspState)
+{
+       switch (wspState) {     //gMmsRmWapState
+       case RM_WAP_IDLE:
+               return "RM_WAP_IDLE";
+       case RM_WAP_CONNECTING:
+               return "RM_WAP_CONNECTING";
+       case RM_WAP_CONNECTED:
+               return "RM_WAP_CONNECTED";
+       case RM_WAP_DISCONNECTING:
+               return "RM_WAP_DISCONNECTING";
+       case RM_WAP_SECURE_REDIRECT:
+               return "RM_WAP_SECURE_REDIRECT";
+       case RM_WAP_FAILED:
+               return "RM_WAP_FAILED";
+       case RM_WAP_WTLS_HANDSHAKING:
+               return "RM_WAP_WTLS_HANDSHAKING";
+       case RM_WAP_WTLS_HANDSHAKE_COMPLETED:
+               return "RM_WAP_WTLS_HANDSHAKE_COMPLETED";
+       }
+
+       return MmsDebugPrintUnknownValue(wspState);
+}
+
+
+char *MmsDebugPrintRmPduType(MmsRmPduType pduType)
+{
+       switch (pduType) {
+       case MMS_RM_PDU_TYPE:
+               return "MMS_RM_PDU_TYPE";
+
+       case MMS_RM_SEND_REQ:
+               return "MMS_RM_SEND_REQ";
+       case MMS_RM_GET_REQ_AUTO:
+               return "MMS_RM_GET_REQ_AUTO";
+       case MMS_RM_GET_REQ_MANUAL:
+               return "MMS_RM_GET_REQ_MANUAL";
+       case MMS_RM_NOTIFY_RESP_IND:
+               return "MMS_RM_NOTIFY_RESP_IND";
+       case MMS_RM_ACK_IND:
+               return "MMS_RM_ACK_IND";
+
+       case MMS_RM_NOTI_IND:
+               return "MMS_RM_NOTI_IND";
+       case MMS_RM_RETRIEVE_CONF:
+               return "MMS_RM_RETRIEVE_CONF";
+
+       case MMS_RM_READ_REPORT_V10:
+               return "MMS_RM_READ_REPORT_V10";
+       case MMS_RM_READ_REPORT_V11:
+               return "MMS_RM_READ_REPORT_V11";
+       }
+
+       return MmsDebugPrintUnknownValue(pduType);
+}
+
+
+char *MmsDebugPrintMailboxType(MsgMailboxType mailboxType)
+{
+       switch (mailboxType) {
+       case MSG_MAILBOX_WRITE:
+               return "MSG_MAILBOX_WRITE";
+       case MSG_MAILBOX_INBOX:
+               return "MSG_MAILBOX_INBOX";
+       case MSG_MAILBOX_DRAFT:
+               return "MSG_MAILBOX_DRAFT";
+       case MSG_MAILBOX_SENT:
+               return "MSG_MAILBOX_SENT";
+       case MSG_MAILBOX_MAILBOX:
+               return "MSG_MAILBOX_MAILBOX";
+       case MSG_MAILBOX_OUTBOX:
+               return "MSG_MAILBOX_OUTBOX";
+       case MSG_MAILBOX_TEMPLATE:
+               return "MSG_MAILBOX_TEMPLATE";
+       case MSG_MAILBOX_MYFOLDER:
+               return "MSG_MAILBOX_MYFOLDER";
+       case MSG_MAILBOX_MYFOLDER_LIST:
+               return "MSG_MAILBOX_MYFOLDER_LIST";
+       case MSG_MAILBOX_PRESET:
+               return "MSG_MAILBOX_PRESET";
+       }
+
+       return MmsDebugPrintUnknownValue(mailboxType);
+}
+#endif
+
diff --git a/plugin/mms_plugin/MmsPluginDecode.cpp b/plugin/mms_plugin/MmsPluginDecode.cpp
new file mode 100755 (executable)
index 0000000..55e95d2
--- /dev/null
@@ -0,0 +1,8577 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include<stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MmsPluginMessage.h"
+#include "MmsPluginStorage.h"
+#include "MsgUtilFile.h"
+#include "MmsPluginCodec.h"
+#include "MmsPluginDebug.h"
+#include "MsgSettingTypes.h"
+#include "MsgSettingHandler.h"
+#include "MmsPluginInternal.h"
+#include "MmsPluginAvCodec.h"
+#include "MmsPluginStorage.h"
+#include "MmsPluginSmil.h"
+#ifdef __SUPPORT_DRM__
+#include "MmsPluginDrm.h"
+#include "MsgDrmWrapper.h"
+#endif
+
+
+static bool _MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength);          /* bufLen < gMmsDecodeMaxLen */
+static bool _MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength);      /* no bufLen limit */
+static bool _MmsBinaryDecodeGetOneByte(FILE *pFile, UINT8 *pOneByte, int totalLength);
+
+static int __MmsBinaryDecodeUintvar(FILE *pFile, UINT32 *pUintVar, int totalLength);
+static int __MmsDecodeValueLength(FILE *pFile, UINT32 *pValueLength, int totalLength);
+static int __MmsDecodeValueLength2(FILE *pFile, UINT32 *pValueLength, int totalLength);
+static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen, int totalLength);
+static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen, int totalLength);
+static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen, int totalLength);
+static bool __MmsBinaryDecodeCharset(FILE *pFile, UINT32 *nCharSet, int *pCharSetLen, int totalLength);
+static char *__MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength);
+static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int totalLength);
+static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int totalLength);
+static bool __MmsDecodeLongInteger(FILE *pFile, UINT32 *pLongInteger, int totalLength);
+static int __MmsDecodeGetFilename(FILE *pFile, char *szBuff, int bufLen, int totalLength);
+static MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength);
+
+#ifdef __SUPPORT_DRM__
+bool __MmsParseDCFInfo(FILE *pFile, MsgDRMInfo *pDrmInfo, int totalLength);
+bool __MmsParseDCFHdr(FILE *pFile, MsgDRMInfo *pDrmInfo, UINT32 headerLen, int totalLength);
+bool MmsBinaryDecodeDRMMessage(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int fullBodyLength, int totalLength);
+bool MmsBinaryDecodeDRMContent(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int bodyLength, int totalLength);
+#endif
+
+static bool MmsBinaryDecodeMovePointer(FILE *pFile, int offset, int totalLength);
+bool MmsBinaryIsTextEncodedPart(FILE *pFile, int totalLength);
+static bool    __MmsBinaryDecodeCheckAndDecreaseLength(int *pLength, int valueLength);
+
+bool __MmsTextDecodeMsgHeader(FILE *pFile);
+bool MmsTextDecodeMsgBody(FILE *pFile);
+
+char gszMmsLoadBuf1[MSG_MMS_DECODE_BUFFER_MAX + 1] = {0, };
+char gszMmsLoadBuf2[MSG_MMS_DECODE_BUFFER_MAX + 1] = {0, };
+
+static char *gpCurMmsDecodeBuff = NULL;
+static int gCurMmsDecodeBuffPos = 0;   /* next decoding position in gpCurMmsDecodeBuff  */
+static int gMmsDecodeMaxLen = 0;
+static int gMmsDecodeCurOffset = 0;    /* current offset in file (last read) */
+static int gMmsDecodeBufLen = 0;               /* number of last read characters */
+
+static char *gpMmsDecodeBuf1 = NULL;
+static char *gpMmsDecodeBuf2 = NULL;
+
+MmsHeader      mmsHeader =
+{
+       false,                                                                  //bActive
+       NULL,                                                                   //pszOwner
+       -1,                                                                             //msgID
+
+       (MmsMsgType)MMS_MSGTYPE_ERROR,                  //MmsMsgType                    iType;
+       "",                                                                             //char[]                                szTrID;
+       //"",                                                                           //short int                             version;
+       0,                                                                              //short int                             version;
+       0,                                                                              //UINT32                                date;
+
+       NULL,                                                                   //MsgHeaderAddress*             pFrom;
+       NULL,                                                                   //MsgHeaderAddress*             pTo;
+       NULL,                                                                   //MsgHeaderAddress*             pCc;
+       NULL,                                                                   //MsgHeaderAddress*             pBcc;
+       "",                                                                             //char[]                                szSubject;
+       (MmsResponseStatus)MMS_RESPSTATUS_OK,   //MmsResponseStatus             iResponseStatus;
+       (MmsRetrieveStatus)MMS_RETRSTATUS_OK,   //MmsRetrieveStatus             iRetrieveStatus;
+       "",                                                                             //char[]                                szResponseText;
+       "",                                                                             //char[]                                szRetrieveText;
+
+
+       /* has default value in specification */
+
+       (MmsMsgClass)MMS_MSGCLASS_PERSONAL,             //MmsMsgClass                   msgClass;
+       {MMS_TIMETYPE_RELATIVE, 0},                             //MmsTimeStruct                 expiryTime;
+       {MMS_TIMETYPE_RELATIVE, 0},                             //MmsTimeStruct                 deliveryTime;
+       (MmsPriority)MMS_PRIORITY_NORMAL,               //MmsPriority                   priority;               // Refer [OMA-MMS-ENC-v1_2-20030915-C]
+       (MmsSenderVisible)MMS_SENDER_SHOW,              //MmsSenderVisible              senderVisible;
+       (MmsReport)MMS_REPORT_NO,                               //MmsReport                             deliveryReport;
+       (MmsReport)MMS_REPORT_NO,                               //MmsReport                             readReply;
+       (MmsReportAllowed)MMS_REPORTALLOWED_NO,//MmsReportAllowed               iReportAllowed;
+       "",                                                                             //char[]                                szContentLocation;
+
+
+       /* there is no right default value */
+
+       (MSG_DELIVERY_REPORT_STATUS_T)MSG_DELIVERY_REPORT_NONE,         //MmsMsgStatus                  iMsgStatus;
+       (MSG_READ_REPORT_STATUS_T)MSG_READ_REPORT_NONE,         //MmsReadStatus                 readStatus;
+
+       /* MMS v1.1 ReplyCharge */
+       {
+               (MmsReplyChargeType)MMS_REPLY_NONE,     //MmsReplyChargeType    chargeType;
+               {MMS_TIMETYPE_RELATIVE, 0},                     //MmsTimeStruct                 deadLine;
+               0,                                                                      //int                                   chargeSize;
+               "" ,                                                            //char                                  szChargeID;
+       },
+
+       "",                                                                             //char[]                                szMsgID;
+       0,                                                                              //UINT32                                msgSize;
+};
+
+#ifdef __SUPPORT_DRM__
+
+#define        MMS_DRM2_CONVERT_BUFFER_MAX     4*1024
+const UINT32 MMS_UINTVAR_LENGTH_1 =  0x0000007f;               //7bit
+const UINT32 MMS_UINTVAR_LENGTH_2 =  0x00003fff;               //14bit
+const UINT32 MMS_UINTVAR_LENGTH_3 =  0x001fffff;               //21bit
+
+#endif
+
+
+bool _MmsDecodeInitialize(void)
+{
+       MmsInitMsgType(&mmsHeader.msgType);
+       MmsInitMsgBody(&mmsHeader.msgBody);
+
+       return true;
+}
+
+bool __MmsSetMmsHeaderOwner(int msgID, char* pszNewOwner)
+{
+       if (pszNewOwner) {
+               // set new owner
+               MSG_DEBUG("__MmsSetMmsHeaderOwner: set (%s, msgID=%d)\n", pszNewOwner, msgID);
+
+               if ((mmsHeader.pszOwner = (char*)malloc(strlen(pszNewOwner) + 1)) == NULL)
+                       return false;
+
+               memset (mmsHeader.pszOwner, 0, strlen(pszNewOwner) + 1) ;
+
+               strcpy(mmsHeader.pszOwner, pszNewOwner);
+               mmsHeader.bActive = true;
+               mmsHeader.msgID = msgID;
+       } else {
+               // delete current owner
+               if (mmsHeader.pszOwner) {
+                       MSG_DEBUG("__MmsSetMmsHeaderOwner: free (%s %d)\n", mmsHeader.pszOwner, msgID);
+                       free(mmsHeader.pszOwner);
+                       mmsHeader.pszOwner = NULL;
+               }
+               mmsHeader.bActive = false;
+               mmsHeader.msgID = -1;
+       }
+
+       return true;
+}
+
+
+void _MmsInitHeader()
+{
+       mmsHeader.type = MMS_MSGTYPE_ERROR;
+
+       memset(mmsHeader.szTrID, 0, MMS_TR_ID_LEN + 1);
+       mmsHeader.version = MMS_VERSION;
+       mmsHeader.date = 0;
+
+       MsgFreeHeaderAddress(mmsHeader.pFrom);
+       MsgFreeHeaderAddress(mmsHeader.pTo);
+       MsgFreeHeaderAddress(mmsHeader.pCc);
+       MsgFreeHeaderAddress(mmsHeader.pBcc);
+
+       mmsHeader.pFrom = NULL;
+       mmsHeader.pTo = NULL;
+       mmsHeader.pCc = NULL;
+       mmsHeader.pBcc = NULL;
+
+       memset(mmsHeader.szSubject, 0, MSG_LOCALE_SUBJ_LEN + 1);
+
+       mmsHeader.responseStatus = (MmsResponseStatus)MMS_RESPSTATUS_OK;
+       mmsHeader.retrieveStatus = (MmsRetrieveStatus)MMS_RETRSTATUS_OK;
+       memset(mmsHeader.szResponseText, 0, MMS_LOCALE_RESP_TEXT_LEN + 1);
+       memset(mmsHeader.szRetrieveText, 0, MMS_LOCALE_RESP_TEXT_LEN + 1);
+
+
+       mmsHeader.msgClass = (MmsMsgClass)MMS_MSGCLASS_PERSONAL;
+       mmsHeader.expiryTime.type = MMS_TIMETYPE_RELATIVE;
+       mmsHeader.expiryTime.time = 0;
+       mmsHeader.deliveryTime.type     = MMS_TIMETYPE_RELATIVE;
+       mmsHeader.deliveryTime.time     = 0;
+       mmsHeader.priority = (MmsPriority)MMS_PRIORITY_NORMAL;  // Refer [OMA-MMS-ENC-v1_2-20030915-C]
+       mmsHeader.hideAddress =(MmsSenderVisible)MMS_SENDER_SHOW;
+       mmsHeader.deliveryReport = (MmsReport)MMS_REPORT_NO;
+       mmsHeader.readReply = (MmsReport)MMS_REPORT_NO;
+       mmsHeader.reportAllowed = (MmsReportAllowed)MMS_REPORTALLOWED_YES;
+       memset(mmsHeader.szContentLocation, 0, MMS_LOCATION_LEN + 1);
+
+
+       mmsHeader.msgStatus = (MSG_DELIVERY_REPORT_STATUS_T)MSG_DELIVERY_REPORT_NONE;
+       mmsHeader.readStatus = (MSG_READ_REPORT_STATUS_T)MSG_READ_REPORT_NONE;
+
+       mmsHeader.replyCharge.chargeType = (MmsReplyChargeType)MMS_REPLY_NONE;
+       mmsHeader.replyCharge.chargeSize = 0;
+       mmsHeader.replyCharge.deadLine.type = MMS_TIMETYPE_RELATIVE;
+       mmsHeader.replyCharge.deadLine.time = 0;
+       memset(mmsHeader.replyCharge.szChargeID, 0, MMS_MSG_ID_LEN + 1);
+
+
+       memset(mmsHeader.szMsgID, 0, MMS_MSG_ID_LEN + 1);
+       mmsHeader.msgSize = 0;
+#ifdef __SUPPORT_DRM__
+       mmsHeader.drmType = MSG_DRM_TYPE_NONE;
+#endif
+
+       _MmsDecodeInitialize();
+}
+
+
+
+void _MmsCleanDecodeBuff(void)
+{
+       memset(gpMmsDecodeBuf1, 0, gMmsDecodeMaxLen + 1);
+       memset(gpMmsDecodeBuf2, 0, gMmsDecodeMaxLen + 1);
+       gpCurMmsDecodeBuff = NULL;
+       gCurMmsDecodeBuffPos = 0;
+       gMmsDecodeBufLen = 0;
+}
+
+
+void _MmsRegisterDecodeBuffer(char *pInBuff1, char *pInBuff2, int maxLen)
+{
+       gpMmsDecodeBuf1 = pInBuff1;
+       gpMmsDecodeBuf2 = pInBuff2;
+       gpCurMmsDecodeBuff = NULL;
+       gCurMmsDecodeBuffPos = 0;
+       gMmsDecodeMaxLen = maxLen;
+       gMmsDecodeCurOffset = 0;
+       gMmsDecodeBufLen = 0;
+}
+
+void _MmsUnregisterDecodeBuffer(void)
+{
+       gpMmsDecodeBuf1 = NULL;
+       gpMmsDecodeBuf2 = NULL;
+       gpCurMmsDecodeBuff = NULL;
+       gCurMmsDecodeBuffPos = 0;
+       gMmsDecodeMaxLen = 0;
+       gMmsDecodeCurOffset = 0;
+       gMmsDecodeBufLen = 0;
+}
+
+
+int _MmsGetDecodeOffset(void)
+{
+       return (gMmsDecodeCurOffset - gMmsDecodeBufLen + gCurMmsDecodeBuffPos);
+}
+
+
+static bool __MmsBinaryDecodeCheckAndDecreaseLength(int *pLength, int valueLength)
+{
+       if (*pLength <= valueLength) {
+               gCurMmsDecodeBuffPos -= valueLength;
+               gCurMmsDecodeBuffPos += *pLength;
+               return false;
+       }
+
+       *pLength -= valueLength;
+
+       return true;
+}
+
+
+/* ==========================================================
+
+          B  I  N  A  R  Y         D  E  C  O  D  I  N  G
+
+   ==========================================================*/
+
+/*
+ * Binary Encoded Message Format
+ *
+ *             < Single Part Body Message >
+ * -----------------------------------
+ * |           Header Fields                    |
+ * -----------------------------------
+ * | Content Type:start=xxx;type=xxx | ->(ex) Text/Plain, Text/Html, ....
+ * -----------------------------------
+ * |           Single Part Body                 |
+ * -----------------------------------
+ *
+ *             < Multi Part Body Message >
+ * -----------------------------------
+ * |           Header Fields                    |
+ * -----------------------------------
+ * | Content Type:start=xxx;type=xxx | -> (ex) Application/vnd.wap.multipart.mixed(related), multipart/mixed(related)
+ * -----------------------------------
+ * |   # of Entries (body parts)        |
+ * -----------------------------------                         < Each Entry >
+ * |                   Entry 1                          |      ->      -----------------------------
+ * -----------------------------------         |               header Length           |
+ * |                   Entry 2                          |              -----------------------------
+ * -----------------------------------         |               Data Length                     |
+ * |                   ......                           |              -----------------------------  -
+ * -----------------------------------         |               Content-Type            |  |
+ * |                   Entry n                          |              -----------------------------  | Header Length
+ * -----------------------------------         |                       Header                  |  |
+ *                                                                                     -----------------------------  -
+ *                                                                                     |                       Data                    |  | Data Length
+ *                                                                                     -----------------------------  -
+ */
+bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
+{
+       UINT16 fieldCode = 0xffff;
+       UINT16 fieldValue = 0xffff;
+       UINT8 oneByte = 0xff;
+
+       MsgHeaderAddress *pAddr = NULL;
+       MsgHeaderAddress *pLastTo = NULL;
+       MsgHeaderAddress *pLastCc = NULL;
+       MsgHeaderAddress *pLastBcc = NULL;
+
+       UINT32 valueLength = 0;
+       UINT32 tmpInteger = 0;
+       int     tmpIntLen = 0;
+
+       int offset = 0;
+
+       char szGarbageBuff[MSG_STDSTR_LONG]     = {0, };
+       char *pLimitData = NULL;
+       int nRead = 0;
+
+       MSG_DEBUG("MmsBinaryDecodeMsgHeader: pFile=%d, total len=%d\n", pFile, totalLength);
+
+       _MmsCleanDecodeBuff();
+
+       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos,
+                                                                  &gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2,
+                                                                  gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+               MSG_DEBUG("MmsBinaryDecodeMsgHeader: fail to load to buffer \n");
+               goto __CATCH;
+       }
+
+       while (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength)) {
+               fieldCode = oneByte & 0x7f;
+
+               switch (_MmsGetBinaryType(MmsCodeFieldCode, fieldCode)) {
+               case MMS_CODE_RESPONSESTATUS:
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: responseStatus GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       fieldValue = _MmsGetBinaryType(MmsCodeResponseStatus, (UINT16)(oneByte & 0x7F));
+
+                       if (fieldValue == 0xFFFF) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: responseStatus error\n");
+                               goto __CATCH;
+                       }
+
+                       if (fieldValue >= 0x0044 && fieldValue <= 0x005F) {
+                               fieldValue = 0x0040;
+                       } else if (fieldValue >= 0x006A && fieldValue <= 0x007F) {
+                               fieldValue = 0x0060;
+                       }
+
+                       mmsHeader.responseStatus = (MmsResponseStatus)fieldValue;
+
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: response status = %s\n", MmsDebugGetResponseStatus(mmsHeader.responseStatus));
+
+                       break;
+
+               case MMS_CODE_RETRIEVESTATUS:
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: retrieveStatus GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       fieldValue = _MmsGetBinaryType(MmsCodeRetrieveStatus, (UINT16)(oneByte & 0x7F));
+
+                       if (fieldValue == 0xFFFF) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: retrieveStatus error\n");
+                               goto __CATCH;
+                       }
+
+                       if (fieldValue >= 0x0043 && fieldValue <= 0x005F) {
+                               fieldValue = 0x0040; // 192; Error-transient-failure
+                       } else if (fieldValue >= 0x0064 && fieldValue <= 0x007F) {
+                               fieldValue = 0x0060; //224; Error-permanent-failure
+                       }
+
+                       mmsHeader.retrieveStatus = (MmsRetrieveStatus)fieldValue;
+
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: retrieve status = %s\n",
+                                                                                                                       MmsDebugGetRetrieveStatus(mmsHeader.retrieveStatus));
+
+                       break;
+
+               case MMS_CODE_RESPONSETEXT:
+
+                       if (__MmsBinaryDecodeEncodedString(pFile, mmsHeader.szResponseText, MMS_LOCALE_RESP_TEXT_LEN + 1, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_RESPONSETEXT \n");
+                               goto __CATCH;
+                       }
+
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: response text = %s\n", mmsHeader.szResponseText);
+                       break;
+
+               case MMS_CODE_RETRIEVETEXT:
+
+                       if (__MmsBinaryDecodeEncodedString(pFile, mmsHeader.szRetrieveText, MMS_LOCALE_RESP_TEXT_LEN + 1, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_RETRIEVETEXT \n");
+                               goto __CATCH;
+                       }
+
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: retrieve text = %s\n", mmsHeader.szResponseText);
+                       break;
+
+               case MMS_CODE_MSGID:
+
+                       if (__MmsBinaryDecodeText(pFile, mmsHeader.szMsgID, MMS_MSG_ID_LEN + 1, totalLength) < 0) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_MSGID is invalid\n");
+                               goto __CATCH;
+                       }
+
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg id = %s\n", mmsHeader.szMsgID);
+
+                       if (MsgStrlen (mmsHeader.szMsgID) > 2)
+                               MsgMIMERemoveQuote (mmsHeader.szMsgID);
+
+                       break;
+
+               case MMS_CODE_SUBJECT:
+
+                       if (__MmsBinaryDecodeEncodedString(pFile, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN + 1, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_SUBJECT \n");
+                               goto __CATCH;
+                       }
+
+                       pLimitData = (char *)malloc(MSG_LOCALE_SUBJ_LEN + 1);
+
+                       if (pLimitData == NULL) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : pLimitData malloc fail \n");
+                               goto __CATCH;
+                       }
+
+                       nRead = MsgCutUTFString((unsigned char*)pLimitData, MSG_LOCALE_SUBJ_LEN + 1, (unsigned char*)mmsHeader.szSubject, MSG_SUBJ_LEN);
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader : Subject edit.. \n");
+
+                       if (nRead > MSG_LOCALE_SUBJ_LEN) {
+                               memset(mmsHeader.szSubject, 0 , sizeof(mmsHeader.szSubject));
+                               strncpy(mmsHeader.szSubject, pLimitData, MSG_SUBJ_LEN);
+                       } else {
+                               memset(mmsHeader.szSubject, 0 , sizeof(mmsHeader.szSubject));
+                               strncpy(mmsHeader.szSubject, pLimitData, MSG_LOCALE_SUBJ_LEN);
+                       }
+
+                       if (pLimitData) {
+                               free(pLimitData);
+                               pLimitData = NULL;
+                       }
+
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: subject = %s\n", mmsHeader.szSubject);
+                       break;
+
+               case MMS_CODE_FROM:
+
+                       /* Value-length (Address-present-token Encoded-string-value | Insert-address-token) */
+
+                       if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_FROM is invalid\n");
+                               goto __CATCH;
+                       }
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: MMS_CODE_FROM GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       // DRM_TEMPLATE - start
+
+                       valueLength--;
+
+                       if (oneByte == (_MmsGetBinaryValue(MmsCodeAddressType, MMS_ADDRESS_PRESENT_TOKEN)|0x80)) {
+                               if (valueLength > 0) {
+                                       mmsHeader.pFrom = __MmsDecodeEncodedAddress(pFile, totalLength);
+                                       if (mmsHeader.pFrom == NULL) {
+                                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_FROM __MmsDecodeEncodedAddress fail\n");
+                                               goto __CATCH;
+                                       }
+                               } else {
+                                       mmsHeader.pFrom = (MsgHeaderAddress *)malloc(sizeof(MsgHeaderAddress));
+                                       if (mmsHeader.pFrom == NULL)
+                                               goto __CATCH;
+
+                                       mmsHeader.pFrom->szAddr = (char *)malloc(1);
+                                       if (mmsHeader.pFrom->szAddr == NULL) {
+                                               free(mmsHeader.pFrom);
+                                               mmsHeader.pFrom = NULL;
+                                               goto __CATCH;
+                                       }
+
+                                       mmsHeader.pFrom->szAddr[0] = '\0';
+                                       mmsHeader.pFrom->pNext = NULL;
+                               }
+
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: from = %s\n", mmsHeader.pFrom->szAddr);
+                               // DRM_TEMPLATE - end
+                       } else if (oneByte == (_MmsGetBinaryValue(MmsCodeAddressType, MMS_INSERT_ADDRESS_TOKEN)|0x80)) {
+                               /* Present Token only */
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_FROM insert token\n");
+                       } else {
+                               /* from data broken */
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: from addr broken\n");
+                               gCurMmsDecodeBuffPos--;
+                               goto __CATCH;
+                       }
+                       break;
+
+               case MMS_CODE_TO:
+
+                       pAddr = __MmsDecodeEncodedAddress(pFile, totalLength);
+                       if (pAddr == NULL) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_TO __MmsDecodeEncodedAddress fail\n");
+                               goto __CATCH;
+                       }
+
+                       if (mmsHeader.pTo == NULL) {
+                               /* the first TO */
+                               pLastTo = mmsHeader.pTo = pAddr;
+                       } else {
+                               if (pLastTo)
+                                       pLastTo->pNext = pAddr;
+                               pLastTo = pAddr;
+                       }
+
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: to = %s\n", mmsHeader.pTo->szAddr);
+                       break;
+
+               case MMS_CODE_BCC:
+
+                       pAddr = __MmsDecodeEncodedAddress(pFile, totalLength);
+                       if (pAddr == NULL) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_BCC __MmsDecodeEncodedAddress fail\n");
+                               goto __CATCH;
+                       }
+
+                       if (mmsHeader.pBcc == NULL) {
+                               /* the first Bcc */
+                               pLastBcc = mmsHeader.pBcc = pAddr;
+                       } else {
+                               if (pLastBcc)
+                                       pLastBcc->pNext = pAddr;
+                               pLastBcc = pAddr;
+                       }
+
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: bcc = %s\n", mmsHeader.pBcc->szAddr);
+                       break;
+
+               case MMS_CODE_CC:
+
+                       pAddr = __MmsDecodeEncodedAddress(pFile, totalLength);
+                       if (pAddr == NULL) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_CC __MmsDecodeEncodedAddress fail\n");
+                               goto __CATCH;
+                       }
+
+                       if (mmsHeader.pCc == NULL) {
+                               /* the first Cc */
+                               pLastCc = mmsHeader.pCc = pAddr;
+                       } else {
+                               if (pLastCc)
+                                       pLastCc->pNext = pAddr;
+                               pLastCc = pAddr;
+                       }
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: cc = %s\n", mmsHeader.pCc->szAddr);
+                       break;
+
+               case MMS_CODE_CONTENTLOCATION:
+
+                       if (__MmsBinaryDecodeText(pFile, mmsHeader.szContentLocation, MMS_LOCATION_LEN + 1, totalLength) < 0) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_CONTENTLOCATION is invalid\n");
+                               goto __CATCH;
+                       }
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: content location = %s\n", mmsHeader.szContentLocation);
+                       break;
+
+               case MMS_CODE_DATE:
+
+                       if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.date, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_DATE is invalid\n");
+                               goto __CATCH;
+                       }
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: date = %d\n", mmsHeader.date);
+                       break;
+
+               case MMS_CODE_DELIVERYREPORT:
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: deliveryReport GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       fieldValue = _MmsGetBinaryType(MmsCodeDeliveryReport, (UINT16)(oneByte & 0x7F));
+
+                       if (fieldValue == 0xFFFF) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: deliveryReport error\n");
+                               goto __CATCH;
+                       }
+
+                       mmsHeader.deliveryReport = (MmsReport)fieldValue;
+
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: delivery report=%s\n", MmsDebugGetMmsReport(mmsHeader.deliveryReport));
+                       break;
+
+               case MMS_CODE_DELIVERYTIME:
+
+                       /* value_length (absolute-token Long-integer | Relative-token Long-integer) */
+
+                       if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_DELIVERYTIME \n");
+                               goto __CATCH;
+                       }
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: delivery time GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       //DRM_TEMPLATE - start
+                       valueLength--;
+
+                       if (oneByte == (_MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE)|0x80)) {
+                               mmsHeader.deliveryTime.type = MMS_TIMETYPE_ABSOLUTE;
+
+                               if (valueLength > 0) {
+                                       if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.deliveryTime.time, totalLength) == false) {
+                                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_DELIVERYTIME\n");
+                                               goto __CATCH;
+                                       }
+                               }
+                       // DRM_TEMPLATE - end
+                       } else {
+                               mmsHeader.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
+
+                               if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&mmsHeader.deliveryTime.time, &tmpIntLen, totalLength) == false) {
+                                       MSG_DEBUG("MmsBinaryDecodeMsgHeader : __MmsBinaryDecodeInteger fail...\n");
+                                       goto __CATCH;
+                               }
+                       }
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: delivery type=%d, time=%d\n", mmsHeader.deliveryTime.type, mmsHeader.deliveryTime.time);
+                       break;
+
+               case MMS_CODE_EXPIRYTIME:
+
+                       /* value_length(absolute-token Long-integer | Relative-token Long-integer) */
+
+                       if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_EXPIRYTIME \n");
+                               goto __CATCH;
+                       }
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: expiry time GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       // DRM_TEMPLATE - start
+                       valueLength--;
+
+                       if (oneByte == (_MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE)|0x80)) {
+                               mmsHeader.expiryTime.type = MMS_TIMETYPE_ABSOLUTE;
+
+                               if (valueLength > 0) {
+                                       if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.expiryTime.time, totalLength) == false) {
+                                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_EXPIRYTIME is invalid\n");
+                                               goto __CATCH;
+                                       }
+                               }
+                       // DRM_TEMPLATE - end
+                       } else {
+                               mmsHeader.expiryTime.type = MMS_TIMETYPE_RELATIVE;
+
+                               if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&mmsHeader.expiryTime.time, &tmpIntLen, totalLength) == false) {
+                                       MSG_DEBUG("MmsBinaryDecodeMsgHeader : __MmsBinaryDecodeInteger fail...\n");
+                                       goto __CATCH;
+                               }
+                       }
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: expiry = %d\n", mmsHeader.expiryTime.time);
+                       break;
+
+               case MMS_CODE_MSGCLASS:
+
+                       /* Class-value = Class-identifier | Token Text */
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgClass GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       if (oneByte > 0x7f) {
+                               /* Class-identifier */
+                               mmsHeader.msgClass = (MmsMsgClass)_MmsGetBinaryType(MmsCodeMsgClass, (UINT16)(oneByte & 0x7F));
+                       } else {
+                               if (__MmsBinaryDecodeText(pFile, szGarbageBuff, MSG_STDSTR_LONG, totalLength) < 0) {
+                                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: 1. __MmsBinaryDecodeText fail. (class)\n");
+                                       goto __CATCH;
+                               }
+                       }
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg class=%s\n", MmsDebugGetMsgClass(mmsHeader.msgClass));
+                       break;
+
+               case MMS_CODE_MSGSIZE:
+
+                       if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.msgSize, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_MSGSIZE is invalid\n");
+                               goto __CATCH;
+                       }
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg size = %d\n", mmsHeader.msgSize);
+                       break;
+
+               case MMS_CODE_MSGSTATUS:
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       mmsHeader.msgStatus =  (MSG_DELIVERY_REPORT_STATUS_T)_MmsGetBinaryType(MmsCodeMsgStatus, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg status=%s \n", MmsDebugGetMsgStatus(mmsHeader.msgStatus)) ;
+                       break;
+
+               case MMS_CODE_MSGTYPE:
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       mmsHeader.type = (MmsMsgType)_MmsGetBinaryType(MmsCodeMsgType, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg type=%s\n", MmsDebugGetMsgType(mmsHeader.type));
+                       break;
+
+               case MMS_CODE_PRIORITY:
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+                       mmsHeader.priority = (MmsPriority)_MmsGetBinaryType(MmsCodePriority, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: priority=%d\n", mmsHeader.priority);
+                       break;
+
+               case MMS_CODE_READREPLY:
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+                       mmsHeader.readReply = (MmsReport)_MmsGetBinaryType(MmsCodeReadReply, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: read reply=%s \n", MmsDebugGetMmsReport(mmsHeader.readReply));
+                       break;
+
+               case MMS_CODE_REPORTALLOWED:
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+                       mmsHeader.reportAllowed =  (MmsReportAllowed)_MmsGetBinaryType(MmsCodeReportAllowed, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: mmsHeader.reportAllowed=%d\n", MmsDebugGetMmsReportAllowed(mmsHeader.reportAllowed));
+                       break;
+
+               case MMS_CODE_SENDERVISIBILLITY:
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+                       mmsHeader.hideAddress= (MmsSenderVisible)!(_MmsGetBinaryType(MmsCodeSenderVisibility, (UINT16)(oneByte &0x7F)));
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: sender visible=%d \n", mmsHeader.hideAddress);
+                       break;
+
+               case MMS_CODE_TRID:
+
+                       if (__MmsBinaryDecodeText(pFile, mmsHeader.szTrID, MMS_TR_ID_LEN + 1, totalLength) < 0) {
+                               MSG_DEBUG("Transaction ID Too Long \n");
+                               goto __CATCH;
+                       }
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: trID = %s\n", mmsHeader.szTrID);
+                       break;
+
+               case MMS_CODE_VERSION:
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+                       mmsHeader.version = oneByte;
+
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: ver = 0x%x\n", mmsHeader.version);
+                       break;
+
+               case MMS_CODE_CONTENTTYPE:
+
+                       /*
+                        * Content-type is the last header field of SendRequest and RetrieveConf.
+                        * It's required to decrease pointer by one and return,
+                        * to parse this field in MmsBinaryDecodeContentType().
+                        */
+                       goto __RETURN;
+
+
+               /* ----------- Add by MMSENC v1.1 ----------- */
+
+               case MMS_CODE_READSTATUS:
+
+                       /* Read-status-value = Read | Deleted without being read */
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       mmsHeader.readStatus =  (MSG_READ_REPORT_STATUS_T)_MmsGetBinaryType(MmsCodeReadStatus, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: read status=%s\n", MmsDebugGetMmsReadStatus(mmsHeader.readStatus));
+                       break;
+
+               case MMS_CODE_REPLYCHARGING:
+
+                       /* Reply-charging-value = Requested | Requested text only | Accepted | Accepted text only */
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       mmsHeader.replyCharge.chargeType =  (MmsReplyChargeType)_MmsGetBinaryType(MmsCodeReplyCharging, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: mmsHeader.reply charge=%d\n", mmsHeader.replyCharge.chargeType);
+                       break;
+
+               case MMS_CODE_REPLYCHARGINGDEADLINE:
+
+                       /* Reply-charging-deadline-value = Value-length (Absolute-token Date-value | Relative-token Delta-seconds-value) */
+
+                       if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_REPLYCHARGINGDEADLINE \n");
+                               goto __CATCH;
+                       }
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       if (oneByte == (_MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE) | 0x80)) {
+                               mmsHeader.replyCharge.deadLine.type = MMS_TIMETYPE_ABSOLUTE;
+                       } else {
+                               mmsHeader.replyCharge.deadLine.type = MMS_TIMETYPE_RELATIVE;
+                       }
+
+                       // DRM_TEMPLATE - start
+                       valueLength--;
+
+                       if (valueLength > 0) {
+                               if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.replyCharge.deadLine.time, totalLength) == false) {
+                                       MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_REPLYCHARGINGDEADLINE is invalid\n");
+                                       goto __CATCH;
+                               }
+                       }
+                       // DRM_TEMPLATE - end
+                       break;
+
+               case MMS_CODE_REPLYCHARGINGID:
+
+                       /* Reply-charging-ID-value = Text-string */
+
+                       if (__MmsBinaryDecodeText(pFile, mmsHeader.replyCharge.szChargeID, MMS_MSG_ID_LEN + 1, totalLength) < 0) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: 1. __MmsBinaryDecodeText fail. (szReplyChargingID)\n");
+                               goto __CATCH;
+                       }
+                       break;
+
+               case MMS_CODE_REPLYCHARGINGSIZE:
+
+                       /* Reply-charging-size-value = Long-integer */
+
+                       if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.replyCharge.chargeSize, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_REPLYCHARGINGSIZE is invalid\n");
+                               goto __CATCH;
+                       }
+                       break;
+
+               case MMS_CODE_PREVIOUSLYSENTBY:
+
+                       /*
+                        * Previously-sent-by-value = Value-length Forwarded-count-value Encoded-string-value
+                        * Forwarded-count-value = Integer-value
+                        * MMS_CODE_PREVIOUSLYSENTBY shall be a pair with MMS_CODE_PREVIOUSLYSENTDATE
+                        */
+
+                       /*
+                        * fixme: There is no proper field to store this information.
+                        * Just increase pointer now.
+                        */
+
+                       if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : 1. invalid MMS_CODE_PREVIOUSLYSENTBY \n");
+                               goto __CATCH;
+                       }
+
+                       if (__MmsBinaryDecodeInteger(pFile, &tmpInteger, &tmpIntLen, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : 2. invalid MMS_CODE_PREVIOUSLYSENTBY \n");
+                               goto __CATCH;
+                       }
+
+                       if (__MmsBinaryDecodeEncodedString(pFile, szGarbageBuff, MSG_STDSTR_LONG, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_RETRIEVETEXT \n");
+                               goto __CATCH;
+                       }
+                       break;
+
+               case MMS_CODE_PREVIOUSLYSENTDATE:
+
+                       /*
+                        * Previously-sent-date-value = Value-length Forwarded-count-value Date-value
+                        * Forwarded-count-value = Integer-value
+                        * MMS_CODE_PREVIOUSLYSENTDATE shall be a pair with MMS_CODE_PREVIOUSLYSENTBY
+                        */
+
+                       /*
+                        * fixme: There is no proper field to store this information.
+                        * Just increase pointer now.
+                        */
+
+                       if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : 1. invalid MMS_CODE_PREVIOUSLYSENTDATE \n");
+                               goto __CATCH;
+                       }
+
+                       if (__MmsBinaryDecodeInteger(pFile, &tmpInteger, &tmpIntLen, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : 2. invalid MS_CODE_PREVIOUSLYSENTDATE \n");
+                               goto __CATCH;
+                       }
+
+                       if (__MmsDecodeLongInteger(pFile, (UINT32*)&tmpInteger, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : 3. invalid MMS_CODE_PREVIOUSLYSENTDATE \n");
+                               goto __CATCH;
+                       }
+                       break;
+
+
+               default:
+
+                       /*
+                        * Application-header             = Token-text Application-specific-value
+                        * Token-text                             = Token End-of-string
+                        * Application-specific-value = Text -string
+                        *
+                        * OR unknown header field - Just ignore these fields.
+                        *
+                        * Read one byte and check the value >= 0x80
+                        * (check these value can be field code)
+                        */
+                       {
+                               int             remainLength = 0;
+
+                               oneByte = 0x00;
+
+                               offset = _MmsGetDecodeOffset();
+                               if (offset >= totalLength)
+                                       goto __RETURN;
+
+                               remainLength = totalLength - offset;
+
+                               while ((oneByte < 0x80) && (remainLength > 0)) {
+                                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&remainLength, 1) == false) {
+                                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: __MmsBinaryDecodeCheckAndDecreaseLength fail\n");
+                                               goto __CATCH;
+                                       }
+                                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: responseStatus GetOneByte fail\n");
+                                               goto __CATCH;
+                                       }
+                               }
+
+                               gCurMmsDecodeBuffPos--;
+                       }
+
+                       break;
+               }       /* switch */
+
+               offset = _MmsGetDecodeOffset();
+               if (offset >= totalLength)
+                       goto __RETURN;
+
+       }       /* while */
+
+
+__RETURN:
+
+       MSG_DEBUG("MmsBinaryDecodeMsgHeader: success\n");
+       return true;
+
+
+__CATCH:
+       MSG_DEBUG("MmsBinaryDecodeMsgHeader: failed\n");
+
+       return false;
+}
+
+#ifdef FEATURE_JAVA_MMS
+// for JAVA MMS AppId - check later whether it can be handled by MmsBinaryDecodeMsgHeader
+bool MmsBinaryDecodeContentType(FILE *pFile, char *szFilePath, int totalLength)
+{
+       int length      = 0;
+
+       MSG_DEBUG("MmsBinaryDecodeContentType:\n");
+
+       if (szFilePath != NULL)
+               strncpy(mmsHeader.msgType.szOrgFilePath, szFilePath, strlen(szFilePath));
+       mmsHeader.msgType.offset = _MmsGetDecodeOffset() - 1;           // + Content-Type code value
+
+       // read data(2K) from msg file(/User/Msg/Inbox/5) to gpCurMmsDecodeBuff for decoding
+       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos,
+                                                                       &gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2,
+                                                                       gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+               MSG_DEBUG("MmsBinaryDecodeContentType: fail to load to buffer \n");
+               goto __CATCH;
+       }
+
+       // msg's type [ex] related, mixed, single part (jpg, amr and etc)
+       length = MmsBinaryDecodeContentType(pFile, &mmsHeader.msgType, totalLength);
+       if (length == -1) {
+               MSG_DEBUG("MmsBinaryDecodeContentType: MMS_CODE_CONTENTTYPE is fail\n");
+               goto __CATCH;
+       }
+       MSG_DEBUG("Content-Type: Application-ID:%s Reply-To-Application-ID:%s",mmsHeader.msgType.param.szApplicationID, mmsHeader.msgType.param.szReplyToApplicationID);
+
+       return true;
+
+__CATCH:
+
+       /* fixme: Delete multipart using MmsDeleteMsg() */
+
+       return false;
+}
+#endif
+
+bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength)
+{
+       int length = 0;
+       int offset = 0;
+
+       MsgMultipart *pMultipart = NULL;
+
+       MSG_DEBUG("MmsBinaryDecodeMsgBody:\n");
+
+       if (szFilePath != NULL)
+               strncpy(mmsHeader.msgType.szOrgFilePath, szFilePath , strlen(szFilePath));
+
+       mmsHeader.msgType.offset = _MmsGetDecodeOffset() - 1;           // + Content-Type code value
+
+       // read data(2K) from msg file(/User/Msg/Inbox/5) to gpCurMmsDecodeBuff for decoding
+       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos,
+                                                                       &gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2,
+                                                                       gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+               MSG_DEBUG("MmsBinaryDecodeMsgBody: fail to load to buffer \n");
+               goto __CATCH;
+       }
+
+       // msg's type [ex] related, mixed, single part (jpg, amr and etc)
+       length = MmsBinaryDecodeContentType(pFile, &mmsHeader.msgType, totalLength);
+       if (length == -1) {
+               MSG_DEBUG("MmsBinaryDecodeMsgBody: MMS_CODE_CONTENTTYPE is fail\n");
+               goto __CATCH;
+       }
+
+       mmsHeader.msgType.size   = length + 1;                                          // + Content-Type code value
+       mmsHeader.msgBody.offset = _MmsGetDecodeOffset();
+
+       switch (mmsHeader.msgType.type) {
+       case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED:
+       case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED:
+       case MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC:
+       case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE:
+       case MIME_MULTIPART_REPORT:
+       case MIME_MULTIPART_MIXED:
+       case MIME_MULTIPART_RELATED:
+       case MIME_MULTIPART_ALTERNATIVE:
+       case MIME_APPLICATION_VND_OMA_DRM_MESSAGE:
+       case MIME_APPLICATION_VND_OMA_DRM_CONTENT:
+
+               MSG_DEBUG("__MmsBinaryMsgBodyDecode: Decode multipart\n");
+
+               offset = _MmsGetDecodeOffset();
+               if (offset >= totalLength)
+                       goto __RETURN;
+
+               if (MmsBinaryDecodeMultipart(pFile, szFilePath, &mmsHeader.msgType, &mmsHeader.msgBody, totalLength) == false) {
+                       MSG_DEBUG("__MmsBinaryMsgBodyDecode: MmsBinaryDecodeMultipart is fail.\n");
+                       goto __CATCH;
+               }
+               break;
+
+       default:
+
+               /* Single part message ---------------------------------------------- */
+
+               strcpy(mmsHeader.msgBody.szOrgFilePath, szFilePath);
+
+               offset = _MmsGetDecodeOffset();
+               if (offset >= totalLength)
+                       goto __RETURN;
+
+               if (MmsBinaryDecodePartBody(pFile, totalLength - mmsHeader.msgBody.offset, totalLength) == false) {
+                       MSG_DEBUG("__MmsBinaryMsgBodyDecode: MmsBinaryDecodePartBody is fail.(Single Part)\n");
+                       goto __CATCH;
+               }
+
+               mmsHeader.msgBody.size = totalLength - mmsHeader.msgBody.offset;
+               mmsHeader.msgType.contentSize = totalLength - mmsHeader.msgBody.offset;
+
+               break;
+       }
+
+#ifdef __SUPPORT_DRM__
+       mmsHeader.drmType = MsgGetDRMType(&mmsHeader.msgType, &mmsHeader.msgBody);
+#endif
+
+__RETURN:
+
+       return true;
+
+__CATCH:
+
+       /* fixme: Delete multipart using MmsDeleteMsg() */
+
+       if (pMultipart) {
+               if (pMultipart->pBody) {
+                       if (pMultipart->pBody->body.pText) {
+                               free(pMultipart->pBody->body.pText);
+                               pMultipart->pBody->body.pText = NULL;
+                       }
+
+                       free(pMultipart->pBody);
+                       pMultipart->pBody = NULL;
+               }
+
+               free(pMultipart);
+               pMultipart = NULL;
+       }
+
+       return false;
+}
+
+#if MMS_ENABLE_EXTEND_CFM
+// DRM (Extended)CFM
+//     Get Extended CFM value.
+static bool __MmsConvertString2Bool(char *pszValue)
+{
+       if (!strcasecmp(pszValue, "no"))
+               return true;
+
+       return false;
+}
+#endif
+
+bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, int totalLength)
+{
+       UINT8 oneByte = 0;
+       int charSetLen = 0;
+       char *szTypeString = NULL;
+       char *szTypeValue = NULL;
+       UINT8 paramCode = 0xff;
+       UINT32 integer = 0;
+       int intLen = 0;
+       int length = 0;
+       int textLength = 0;
+
+       /*
+        * Parameter = Typed-parameter | Untyped-parameter
+        * WAP-230-WSP-20010118-p, Proposed Version 18 January 2001 (pp.107)
+        */
+
+       MSG_DEBUG("MmsBinaryDecodeParameter: \n");
+
+       while (valueLength > 0) {
+               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                       MSG_DEBUG("MmsBinaryDecodeContentType: paramCode _MmsBinaryDecodeGetOneByte fail\n");
+                       goto __CATCH;
+               }
+
+               paramCode = oneByte;
+               valueLength--;
+
+               switch (paramCode) {
+               case 0x81: // charset
+
+                       if (__MmsBinaryDecodeCharset(pFile, (UINT32*)&(pMsgType->param.charset), &charSetLen, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeContentType : __MmsBinaryDecodeCharset fail.\n");
+                               goto __CATCH;
+                       }
+
+                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, charSetLen) == false)
+                               goto __RETURN;
+
+                       break;
+
+               case 0x85: //name = Text-string
+               case 0x97: //name = Text-value  = No-value | Token-text | Quoted-string
+                       memset(pMsgType->param.szName, 0, sizeof(pMsgType->param.szName));
+                       length = __MmsDecodeGetFilename(pFile,  pMsgType->param.szName,
+                                                                                        MSG_FILENAME_LEN_MAX -5,               // MSG_LOCALE_FILENAME_LEN_MAX + 1, :  change @ 110(Ui code have to change for this instead of DM)
+                                                                                        totalLength);
+                       if (length < 0) {
+                               MSG_DEBUG("MmsBinaryDecodeContentType : __MmsDecodeGetFilename fail. (name parameter)\n");
+                               goto __CATCH;
+                       }
+
+                       if (MsgCheckFileNameHasInvalidChar(pMsgType->param.szName)) {
+                               _MsgReplaceInvalidFileNameChar(pMsgType->param.szName, '_');
+                       }
+
+                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, length) == false)
+                               goto __RETURN;
+
+                       break;
+
+               case 0x86: //filename = Text-string
+               case 0x98: //filename = Text-value  = No-value | Token-text | Quoted-string
+                       memset(pMsgType->param.szFileName, 0, sizeof(pMsgType->param.szFileName));
+                       length = __MmsDecodeGetFilename(pFile, pMsgType->param.szFileName, MSG_FILENAME_LEN_MAX -5, totalLength);
+                       if (length < 0) {
+                               MSG_DEBUG("MmsBinaryDecodeContentType : __MmsDecodeGetFilename fail. (filename parameter)\n");
+                               goto __CATCH;
+                       }
+
+                       if (MsgCheckFileNameHasInvalidChar(pMsgType->param.szFileName)) {
+                               _MsgReplaceInvalidFileNameChar(pMsgType->param.szFileName, '_');
+                       }
+
+                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, length) == false)
+                               goto __RETURN;
+
+                       break;
+
+               case 0x89: //type = Constrained-encoding = Extension-Media | Short-integer
+
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MmsBinaryDecodeContentType: type _MmsBinaryDecodeGetOneByte fail\n");
+                               goto __CATCH;
+                       }
+
+                       if (oneByte > 0x7f) {
+                               pMsgType->param.type = _MmsGetBinaryType(MmsCodeContentType,
+                                                                                                                 (UINT16)(oneByte & 0x7f));
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, 1) == false)
+                                       goto __RETURN;
+                       } else {
+                               gCurMmsDecodeBuffPos--;
+
+                               textLength = 0;
+                               szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+                               pMsgType->param.type = _MmsGetTextType(MmsCodeContentType, szTypeString);
+
+                               if (szTypeString) {
+                                       free(szTypeString);
+                                       szTypeString = NULL;
+                               }
+
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, textLength) == false)
+                                       goto __RETURN;
+                       }
+
+                       break;
+
+               case 0x8A: //start encoding version 1.2
+               case 0x99: //start encoding version 1.4
+
+                       textLength       = 0;
+                       szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+                       if (szTypeString) {
+                               memset(pMsgType->param.szStart, 0, MMS_CONTENT_ID_LEN + 1);
+                               strncpy(pMsgType->param.szStart, szTypeString, MMS_CONTENT_ID_LEN);
+                               free(szTypeString);
+                               szTypeString = NULL;
+
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, textLength) == false)
+                                       goto __RETURN;
+                       }
+
+                       break;
+
+               case 0x8B: //startInfo encoding version 1.2
+               case 0x9A: //startInfo encoding version 1.4
+
+                       textLength       = 0;
+                       szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+
+                       if (szTypeString) {
+                               memset(pMsgType->param.szStartInfo, 0, MMS_CONTENT_ID_LEN + 1);
+                               strncpy(pMsgType->param.szStartInfo, szTypeString, MMS_CONTENT_ID_LEN);
+
+                               free(szTypeString);
+                               szTypeString = NULL;
+
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, textLength) == false)
+                                       goto __RETURN;
+                       }
+
+                       break;
+
+               default:
+
+                       if (paramCode > 0x7F) {
+                               MSG_DEBUG("MmsBinaryDecodeContentType: Unsupported parameter\n");
+
+                               // In case of the last byte of Parameter field, it should be returned without decreasing the gCurMmsDecodeBuffPos value.
+                               valueLength++;
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, 1) == false)
+                                       goto __RETURN;
+                       } else {
+                               /*
+                                * Untyped Parameter = Token-text Untyped-value
+                                * Token-text            = Token End-of-string
+                                * Untyped-value         = Integer-value | Text-value
+                                * Text-value            = No-value | Token-text | Quoted-string
+                                *
+                                * Just increase pointer!!!
+                                */
+
+
+                               /* Token-text */
+
+                               gCurMmsDecodeBuffPos--;
+                               valueLength++;
+
+                               textLength        = 0;
+                               szTypeString  = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, textLength) == false)
+                                       goto __RETURN;
+
+
+                               /* Text-value */
+
+                               if (__MmsBinaryDecodeInteger(pFile, &integer, &intLen, totalLength) == true) {
+                                       MSG_DEBUG("MmsBinaryDecodeContentType: Unsupported parameter(%d)\n", integer);
+                                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, intLen) == false)
+                                               goto __RETURN;
+                               } else {
+                                       textLength        = 0;
+                                       szTypeValue  = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+
+                                       if (szTypeValue) {
+                                               /* checkMe:  forwardLock needs boudary string */
+                                               if (strcasecmp(szTypeString, "boundary") == 0) {
+                                                       memset(pMsgType->param.szBoundary, 0, MSG_BOUNDARY_LEN + 1);
+                                                       strncpy(pMsgType->param.szBoundary, szTypeValue, MSG_BOUNDARY_LEN);
+#ifdef FEATURE_JAVA_MMS
+                                               } else if (strcasecmp(szTypeString, "Application-ID") == 0) {
+                                                       pMsgType->param.szApplicationID = (char*) malloc(textLength + 1);
+                                                       memset(pMsgType->param.szApplicationID,  0,  textLength + 1);
+                                                       strncpy(pMsgType->param.szApplicationID, szTypeValue, textLength);
+                                                       MSG_DEBUG("Application-ID:%s",pMsgType->param.szApplicationID);
+                                               } else if (strcasecmp(szTypeString,"Reply-To-Application-ID") == 0) {
+                                                       pMsgType->param.szReplyToApplicationID= (char*) malloc(textLength + 1);
+                                                       memset(pMsgType->param.szReplyToApplicationID, 0, textLength + 1);
+                                                       strncpy(pMsgType->param.szReplyToApplicationID, szTypeValue, textLength);
+                                                       MSG_DEBUG("ReplyToApplication-ID:%s",pMsgType->param.szReplyToApplicationID);
+#endif
+                                               }
+                                               free(szTypeValue);
+                                               szTypeValue = NULL;
+
+                                               MSG_DEBUG("MmsBinaryDecodeContentType: Unsupported parameter(%s)\n", szTypeValue);
+                                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, textLength) == false)
+                                                       goto __RETURN;
+                                       }
+                               }
+
+                               if (szTypeString) {
+                                       MSG_DEBUG("MmsBinaryDecodeContentType: Unsupported parameter(%s)\n", szTypeString);
+                                       free(szTypeString);
+                                       szTypeString = NULL;
+                               }
+                       }
+
+                       break;
+               }
+       }       /*end of while loop*/
+
+
+__RETURN:
+
+       if (szTypeString) {
+               free(szTypeString);
+               szTypeString = NULL;
+       }
+
+       return true;
+
+__CATCH:
+
+       if (szTypeString) {
+               free(szTypeString);
+               szTypeString = NULL;
+       }
+       return false;
+}
+
+
+
+/**
+ * Decode Encoded Content type
+ *
+ * @param      pEncodedData    [in] ContentType encoded data
+ * @param      pMsgType                [out] Decoded MsgType
+ * @return     Decoded address list
+ */
+int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength)
+{
+       UINT8 oneByte = 0;
+       char *szTypeString = NULL;
+       int valueLength = 0;
+       int length = 0;
+       int textLength = 0;
+
+
+       /*
+        * Content-type-value             : [WAPWSP 8.4.2.24]
+        * Preassigned content-types  : [WAPWSP Appendix A, Table 40]
+        * The use of start-parameter : [RFC2387] and SHOULD be encoded according to [WAPWSP].
+        *
+        * Content-type-value   = Constrained-media | Content-general-form
+        * Content-general-form = Value-length Media-type
+        * Media-type                   = (Well-known-media | Extension-Media) *(Parameter)
+        */
+
+       MSG_DEBUG("MmsBinaryDecodeContentType: decoding content type..\n");
+
+
+       length = __MmsDecodeValueLength(pFile, (UINT32*)&valueLength, totalLength);
+       if (length <= 0) {
+               /*
+                * Constrained-media or Single part message
+                * Constrained-media = Constrained-encoding = Extension-Media | Short-integer
+                * Extension-media   = *TEXT End-of-string
+                * Short-integer     = OCTET(1xxx xxxx)
+                */
+
+               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                       MSG_DEBUG("MmsBinaryDecodeContentType: Constrained-media _MmsBinaryDecodeGetOneByte fail\n");
+                       goto __CATCH;
+               }
+
+               if (oneByte > 0x7F) {
+                       /* Short-integer */
+                       pMsgType->type = _MmsGetBinaryType(MmsCodeContentType, (UINT16)(oneByte & 0x7F));
+                       length = 1;
+               } else {
+                       char *pszTemp = NULL;
+
+                       /* Extension-Media */
+                       gCurMmsDecodeBuffPos--;
+
+                       textLength = 0;
+                       szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+
+                       if (szTypeString && (strchr(szTypeString, ';')) != NULL) {
+                               pszTemp = _MsgGetStringUntilDelimiter(szTypeString, ';');
+                               if (pszTemp) {
+                                       free(szTypeString);
+                                       szTypeString = pszTemp;
+                               }
+                       }
+
+                       pMsgType->type = _MmsGetTextType(MmsCodeContentType, szTypeString);
+
+                       length = textLength;
+
+                       if (szTypeString) {
+                               free(szTypeString);
+                               szTypeString = NULL;
+                       }
+               }
+       } else {
+               /*
+                * Content-general-form = Value-length Media-type
+                * Media-type                   = (Well-known-media | Extension-Media)*(Parameter)
+                */
+
+               length += valueLength;
+
+               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                       MSG_DEBUG("MmsBinaryDecodeContentType: Well-known-media _MmsBinaryDecodeGetOneByte fail\n");
+                       goto __CATCH;
+               }
+
+               if (oneByte > 0x7F) {
+                       /* Well-known-media */
+                       pMsgType->type = _MmsGetBinaryType(MmsCodeContentType, (UINT16)(oneByte & 0x7F));
+                       valueLength--;
+               } else {
+                       /* Extension-Media */
+                       gCurMmsDecodeBuffPos--;
+
+                       textLength = 0;
+                       szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+                       pMsgType->type = _MmsGetTextType(MmsCodeContentType, szTypeString);
+                       valueLength -= textLength;
+
+                       if (szTypeString) {
+                               free(szTypeString);
+                               szTypeString = NULL;
+                       }
+               }
+
+               MSG_DEBUG("MmsBinaryDecodeContentType: content type=%s\n", MmsDebugGetMimeType((MimeType)pMsgType->type));
+
+
+               if (MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) {
+                       MSG_DEBUG("MmsBinaryDecodeContentType: Content-Type parameter fail\n");
+                       goto __CATCH;
+               }
+       }
+
+       return length;
+
+__CATCH:
+       return -1;
+}
+
+
+bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, int totalLength)
+{
+       UINT8 fieldCode = 0xff;
+       int length = 0;
+       UINT32 valueLength = 0;
+       char *pCode = NULL;
+       char *pValue = NULL;
+       char *pParam = NULL;
+       char ch = '\0';
+       UINT8 oneByte = 0;
+       int     textLength = 0;
+       int tmpInt = 0;
+       int tmpIntLen = 0;
+       char *pLatinBuff = NULL;
+       char *szSrc = NULL;
+       char *szTemp = NULL;
+
+
+       if (pFile == NULL || pMsgType == NULL)
+               return false;
+
+       /*
+        * Message-header                         = Well-known-header | Application-header
+        * Well-known-header              = Well-known-field-name Wap-value
+        * Application-header             = Token-text Application-specific-value
+        * Well-known-field-name          = Short-integer
+        * Application-specific-value = Text-string
+        */
+
+       while (headerLen > 0) {
+               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                       MSG_DEBUG("MmsBinaryDecodePartHeader: field code GetOneByte fail\n");
+                       goto __CATCH;
+               }
+
+               if (0x80 <= oneByte && oneByte <= 0xC7) {
+                       /* Well-known-header = Well-known-field-name Wap-value (0x00 ~ 0x47) */
+
+                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, 1) == false)
+                               goto __RETURN;
+
+                       fieldCode = oneByte & 0x7f;
+
+                       switch (fieldCode) {
+                       case 0x0E:      //Content-Location
+                       case 0x04:      //Content-Location
+
+                               pLatinBuff = (char *)malloc(MMS_CONTENT_ID_LEN + 1);
+                               if (pLatinBuff == NULL)
+                                       goto __CATCH;
+
+                               length = __MmsBinaryDecodeText(pFile, pLatinBuff, MMS_CONTENT_ID_LEN + 1, totalLength);
+                               if (length == -1) {
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeQuotedString fail.\n");
+                                       goto __CATCH;
+                               }
+
+                               szSrc = MsgChangeHexString(pLatinBuff);
+
+                               if (szSrc) {
+                                       strcpy(pLatinBuff, szSrc);
+                                       free(szSrc);
+                                       szSrc = NULL;
+                               }
+
+                               textLength = strlen(pLatinBuff);
+
+                               if (MsgLatin2UTF ((unsigned char*)pMsgType->szContentLocation, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, textLength) < 0) {
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader: MsgLatin2UTF fail \n");
+                                       goto __CATCH;
+                               }
+
+                               free(pLatinBuff);
+                               pLatinBuff = NULL;
+
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false)
+                                       goto __RETURN;
+
+                               break;
+
+                       case 0x40:      // Content-ID
+
+                               pLatinBuff = (char *)malloc(MMS_CONTENT_ID_LEN + 1);
+                               if (pLatinBuff == NULL)
+                                       goto __CATCH;
+
+                               length = __MmsBinaryDecodeQuotedString(pFile, pLatinBuff, MMS_CONTENT_ID_LEN + 1, totalLength);
+
+                               if (length == -1) {
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader : Content-ID __MmsBinaryDecodeQuotedString fail.\n");
+                                       goto __CATCH;
+                               }
+
+                               szSrc = MsgChangeHexString(pLatinBuff);
+
+                               if (szSrc) {
+                                       strcpy(pLatinBuff, szSrc);
+                                       free(szSrc);
+                                       szSrc = NULL;
+                               }
+
+                               textLength = strlen(pLatinBuff);
+                               if (MsgLatin2UTF ((unsigned char*)pMsgType->szContentID, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, textLength) < 0) {
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader: MsgLatin2UTF fail \n");
+                                       goto __CATCH;
+                               }
+                               free(pLatinBuff);
+                               pLatinBuff = NULL;
+
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false)
+                                       goto __RETURN;
+
+                               break;
+
+                       case 0x2E:      // Content-Disposition
+                       case 0x45:      // Content-Disposition
+
+                               /*
+                                * Content-disposition-value = Value-length Disposition *(Parameter)
+                                * Disposition = Form-data | Attachment | Inline | Token-text
+                                *                               Form-data = <Octet 128> : 0x80
+                                *                               Attachment = <Octet 129> : 0x81
+                                *                               Inline = <Octet 130> : 0x82
+                                */
+
+                               length = __MmsDecodeValueLength2(pFile, &valueLength, totalLength);
+
+                               if (length > 0) {
+                                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false)
+                                               goto __RETURN;
+
+                               }
+
+                               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader: Disposition value GetOneByte fail\n");
+                                       goto __CATCH;
+                               }
+
+                               if (length > 0)
+                                       valueLength--;
+
+                               if (oneByte >= 0x80) {
+                                       pMsgType->disposition = _MmsGetBinaryType(MmsCodeMsgDisposition, (UINT16)(oneByte & 0x7F));
+
+                                       if (pMsgType->disposition == INVALID_HOBJ) {
+                                               MSG_DEBUG("MmsBinaryDecodePartHeader : Content-Disposition _MmsGetBinaryType fail.\n");
+                                               pMsgType->disposition = MSG_DISPOSITION_ATTACHMENT;             // default
+                                       }
+
+                                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, 1) == false)
+                                               goto __RETURN;
+
+                                       if (MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) {
+                                               MSG_DEBUG("MmsBinaryDecodePartHeader: Disposition parameter fail\n");
+                                               goto __CATCH;
+                                       }
+
+                                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, valueLength) == false)
+                                               goto __RETURN;
+                               } else {
+
+                                       gCurMmsDecodeBuffPos--;
+                                       valueLength++;
+
+                                       pLatinBuff = (char *)malloc(MSG_FILENAME_LEN_MAX);
+                                       memset(pLatinBuff, 0, MSG_FILENAME_LEN_MAX);
+
+                                       textLength = __MmsBinaryDecodeText(pFile, pLatinBuff, MSG_FILENAME_LEN_MAX-1, totalLength);
+
+
+                                       if (textLength < 0) {
+                                               MSG_DEBUG("MmsBinaryDecodePartHeader : Content-Disposition decodingfail. \n");
+                                               goto __CATCH;
+                                       }
+                                       free(pLatinBuff);
+                                       pLatinBuff = NULL;
+
+                                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, textLength) == false)
+                                               goto __RETURN;
+
+                                       valueLength -= textLength;
+
+                                       if (MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false)
+                                       {
+                                               MSG_DEBUG("MmsBinaryDecodePartHeader: Disposition parameter fail\n");
+                                               goto __CATCH;
+                                       }
+
+                                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, valueLength) == false)
+                                               goto __RETURN;
+
+                               }
+
+                               break;
+
+                       case 0x0B:      //Content-Encoding
+
+                               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader: Disposition value GetOneByte fail\n");
+                                       goto __CATCH;
+                               }
+
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, 1) == false)
+                                       goto __RETURN;
+
+                               break;
+
+                       case 0x0C:      //Content-Language
+
+                               if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&tmpInt, &tmpIntLen, totalLength) == true) {
+                                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, tmpIntLen) == false)
+                                               goto __RETURN;
+                               } else {
+                                       char* cTemp = NULL;
+
+                                       cTemp = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+
+                                       if (cTemp == NULL) {
+                                               MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeText2 fail...\n");
+                                               goto __CATCH;
+                                       }
+
+                                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, textLength) == false) {
+                                               if (cTemp) {
+                                                       free(cTemp);
+                                               }
+                                               goto __RETURN;
+                                       }
+
+                                       if (cTemp)
+                                               free(cTemp);
+                               }
+
+                               break;
+
+                       case 0x0D:      //Content-Length
+
+                               if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&tmpInt, &tmpIntLen, totalLength) == false) {
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeInteger fail...\n");
+                                       goto __CATCH;
+                               }
+
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, tmpIntLen) == false)
+                                       goto __RETURN;
+
+                               break;
+
+                       case 0x30:      //X-Wap-Content-URI skip this value
+
+                               MSG_DEBUG("MmsBinaryDecodePartHeader : X-Wap-Content-URI header.\n");
+                               pLatinBuff = (char *)malloc(MMS_TEXT_LEN);
+                               if (pLatinBuff == NULL)
+                                       goto __CATCH;
+
+                               length = __MmsBinaryDecodeText(pFile, pLatinBuff, MMS_TEXT_LEN, totalLength);
+
+                               if (length == -1) {
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeQuotedString fail.\n");
+                                       goto __CATCH;
+                               }
+
+                               MSG_DEBUG("MmsBinaryDecodePartHeader : X-Wap-Content-URI header decoded. Value length %d\n", length);
+                               free(pLatinBuff);
+                               pLatinBuff = NULL;
+
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false)
+                                       goto __RETURN;
+
+                               MSG_DEBUG("MmsBinaryDecodePartHeader : X-Wap-Content-URI header skipped.\n");
+
+                               break;
+
+                       case 0x01:      // Accept-charset
+                               //if (NvGetInt(NV_SI_ADM_GCF_STATE) == 1)
+                               {
+                                       /*      WAP-230-WSP-200010705-a.pdf
+                                               8.4.2.8 Accept charset field
+                                               The following rules are used to encode accept character set values.
+                                               Accept-charset-value = Constrained-charset | Accept-charset-general-form
+                                               Accept-charset-general-form = Value-length (Well-known-charset | Token-text) [Q-value]
+                                               Constrained-charset = Any-charset | Constrained-encoding
+                                               Well-known-charset = Any-charset | Integer-value
+                                               ; Both are encoded using values from Character Set Assignments table in Assigned Numbers
+                                               Any-charset = <Octet 128>
+                                               ; Equivalent to the special RFC2616 charset value Â¡Â°*¡±
+                                       */
+
+                                       int     charset = 0;
+                                       int charSetLen = 0;
+
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader : Accept-charset. \n");
+
+                                       length = __MmsDecodeValueLength(pFile, &valueLength, totalLength);
+                                       if (length > 0) {
+                                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false)
+                                                       goto __RETURN;
+
+                                       }
+
+                                       if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&charset, &charSetLen, totalLength) == false) {
+                                               // We only support the well-known-charset format
+                                               MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeInteger fail...\n");
+                                               goto __CATCH;
+                                       }
+
+                                       if (charset > 0)
+                                               _MmsGetBinaryType(MmsCodeCharSet, (UINT16)charset);
+
+                                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, charSetLen) == false)
+                                               goto __RETURN;
+
+                                       break;
+                               }
+
+                       default:
+
+                               /* Other Content-xxx headers : Have valueLength */
+
+                               MSG_DEBUG("MmsBinaryDecodePartHeader : unknown Value = 0x%x\n", oneByte);
+
+                               length = __MmsDecodeValueLength(pFile, &valueLength, totalLength);
+                               if (length <= 0) {
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader : 1. invalid MMS_CODE_PREVIOUSLYSENTDATE \n");
+                                       goto __CATCH;
+                               }
+
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false)
+                                       goto __RETURN;
+
+                               szTemp = (char *)malloc(valueLength);
+                               if (szTemp == NULL)
+                                       goto __CATCH;
+
+                               if (_MmsBinaryDecodeGetBytes(pFile, szTemp, valueLength, totalLength) < 0) {
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader : default _MmsBinaryDecodeGetBytes() fail\n");
+                                       if (szTemp) {
+                                               free(szTemp);
+                                               szTemp = NULL;
+                                       }
+                                       goto __CATCH;
+                               }
+
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, valueLength) == false)
+                                       goto __RETURN;
+
+                               break;
+                       }
+               } else {
+                       /*
+                        * Application-header  = Token-text Application-specific-value
+                        * Application-specific-value = Text-string
+                        */
+
+                       MSG_DEBUG(" MmsBinaryDecodePartHeader: Application-header = Token-text Application-specific-value \n");
+
+                       gCurMmsDecodeBuffPos--;
+
+                       /* Token-text */
+
+                       textLength = 0;
+                       pCode = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+                       if (pCode == NULL) {
+                               MSG_DEBUG("MmsBinaryDecodePartHeader: pCode is null\n");
+                               goto __CATCH;
+                       }
+
+                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, textLength) == false)
+                               goto __RETURN;
+
+                       MSG_DEBUG(" MmsBinaryDecodePartHeader: Token-text (%s) \n", pCode);
+
+
+                       /* Application-specific-value */
+
+                       textLength = 0;
+                       pValue = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+                       if (pValue == NULL) {
+                               MSG_DEBUG("MmsBinaryDecodePartHeader: pValue is null\n");
+                               goto __CATCH;
+                       }
+
+                       MSG_DEBUG(" MmsBinaryDecodePartHeader: Application-specific-value (%s) \n", pValue);
+
+
+                       pParam = strchr(pValue, MSG_CH_ADDR_DELIMETER);
+                       if (pParam) {
+                               ch = *pParam;
+                               *pParam = '\0';
+                       }
+
+                       switch (_MmsGetTextType(MmsCodeMsgBodyHeaderCode, pCode)) {
+                       case MMS_BODYHDR_TRANSFERENCODING:              // Content-Transfer-Encoding
+                               pMsgType->encoding = _MmsGetTextType(MmsCodeContentTransferEncoding, pValue);
+                               break;
+
+                       case MMS_BODYHDR_CONTENTID:                             // Content-ID
+
+                               pLatinBuff = (char *)malloc(MMS_CONTENT_ID_LEN + 1);
+                               if (pLatinBuff == NULL)
+                               {
+                                       goto __CATCH;
+                               }
+
+                               MsgMIMERemoveQuote (pValue);
+                               strncpy(pLatinBuff, pValue, MMS_MSG_ID_LEN);
+
+                               length = strlen(pLatinBuff);
+                               if (MsgLatin2UTF ((unsigned char*)pMsgType->szContentID, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, length) < 0)
+                               {
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader: MsgLatin2UTF fail \n");
+                                       goto __CATCH;
+                               }
+
+                               free(pLatinBuff);
+                               pLatinBuff = NULL;
+                               break;
+
+                       case MMS_BODYHDR_CONTENTLOCATION:               // Content-Location
+
+                               pLatinBuff = (char *)malloc(MMS_CONTENT_ID_LEN + 1);
+                               if (pLatinBuff == NULL)
+                                       goto __CATCH;
+
+                               strncpy(pLatinBuff, pValue, MMS_MSG_ID_LEN);
+
+                               length = strlen(pLatinBuff);
+                               if (MsgLatin2UTF ((unsigned char*)pMsgType->szContentLocation, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, length) < 0) {
+                                       MSG_DEBUG("MmsBinaryDecodePartHeader: MsgLatin2UTF fail \n");
+                                       goto __CATCH;
+                               }
+
+                               free(pLatinBuff);
+                               pLatinBuff = NULL;
+                               break;
+
+                       case MMS_BODYHDR_DISPOSITION:                   // Content-Disposition
+                               pMsgType->disposition = _MmsGetTextType(MmsCodeMsgDisposition, pValue);
+                               break;
+
+                       case MMS_BODYHDR_X_OMA_DRM_SEPARATE_DELIVERY:   // DRM RO WAITING
+                                       break;
+
+                       default:
+                               MSG_DEBUG("Unknown Field : %s, Value: %s\n", pCode, pValue);
+                               break;
+                       }
+
+                       if (pParam) {
+                               _MsgParseParameter(pMsgType, pParam + 1);
+                               *pParam = ch;
+                       }
+                       if (pCode) {
+                               free(pCode);
+                               pCode = NULL;
+                       }
+                       if (pValue) {
+                               free(pValue);
+                               pValue = NULL;
+                       }
+
+                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, textLength) == false)
+                               goto __RETURN;
+
+               }
+       }       //while
+
+__RETURN:
+
+       if (pLatinBuff) {
+               free(pLatinBuff);
+               pLatinBuff = NULL;
+       }
+
+       if (szTemp) {
+               free(szTemp);
+               szTemp = NULL;
+       }
+
+       if (pCode) {
+               free(pCode);
+               pCode = NULL;
+       }
+
+       return true;
+
+__CATCH:
+
+       if (pLatinBuff) {
+               free(pLatinBuff);
+               pLatinBuff = NULL;
+       }
+       if (pCode) {
+               free(pCode);
+               pCode = NULL;
+       }
+       if (pValue) {
+               free(pValue);
+               pValue = NULL;
+       }
+
+       if (szTemp) {
+               free(szTemp);
+               szTemp = NULL;
+       }
+
+       return false;
+}
+
+
+bool MmsBinaryDecodeEntries(FILE *pFile, UINT32 *npEntries, int totalLength)
+{
+       int length = 0;
+
+       length = __MmsBinaryDecodeUintvar(pFile, npEntries, totalLength);
+       if (length <= 0) {
+               goto __CATCH;
+       }
+
+       MSG_DEBUG("MmsBinaryDecodeEntries: Number of Entries = %d\n", *npEntries);
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+
+bool MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalLength)
+{
+       int offset = 0;
+
+       /*
+        * Currently, offset and size is
+        * the only information used with msgBody.
+        * If you need, add here more information
+        */
+
+       MSG_DEBUG("MmsBinaryDecodePartBody: \n");
+
+       offset = _MmsGetDecodeOffset();
+       offset += bodyLength;
+
+       if (MsgFseek(pFile, offset, SEEK_SET) < 0) {
+               MSG_DEBUG("MmsBinaryDecodePartBody: fail to seek file pointer \n");
+               goto __CATCH;
+       }
+
+       _MmsCleanDecodeBuff();
+
+       gMmsDecodeCurOffset = offset;
+
+       if (offset >= totalLength)
+               goto __RETURN;
+
+       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+                                                                  gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+               MSG_DEBUG("_MmsBinaryDecodeGetOneByte: fail to load to buffer \n");
+               goto __CATCH;
+       }
+
+       return true;
+
+__RETURN:
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+static bool MmsBinaryDecodeMovePointer(FILE *pFile, int offset, int totalLength)
+{
+       if (offset > totalLength)
+               goto __RETURN;
+
+       if (MsgFseek(pFile, offset, SEEK_SET) < 0) {
+               MSG_DEBUG("MmsBinaryDecodeMovePointer: fail to seek file pointer \n");
+               goto __CATCH;
+       }
+
+       _MmsCleanDecodeBuff();
+
+       gMmsDecodeCurOffset = offset;
+
+       if (offset == totalLength)
+               goto __RETURN;
+
+       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+                                                                       gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+               MSG_DEBUG("MmsBinaryDecodeMovePointer: fail to load to buffer \n");
+               goto __CATCH;
+       }
+
+__RETURN:
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+bool MmsBinaryIsTextEncodedPart(FILE *pFile, int totalLength)
+{
+       UINT8 oneByte   = 0;
+       int byteCount = 0;
+
+       byteCount++;                            //check 0x0D
+
+       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
+               goto __CATCH;
+
+       if (oneByte != 0x0D) {
+               //it can be started "--" without 0x0D 0x0A
+               if (oneByte != 0x2D) {
+                       goto __CATCH;
+               } else {
+                       byteCount++;            // check 0x2D ('-')
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
+                               goto __CATCH;
+
+                       if (oneByte != 0x2D) {
+                               goto __CATCH;
+                       } else {
+                               goto __RETURN;
+                       }
+               }
+       } else {
+               byteCount++;                    //check 0x0A
+               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
+                       goto __CATCH;
+
+               if (oneByte != 0x0A) {
+                       goto __CATCH;
+               } else {
+                       byteCount++;            // check 0x2D ('-')
+                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
+                               goto __CATCH;
+
+                       if (oneByte != 0x2D) {
+                               goto __CATCH;
+                       } else {
+                               byteCount++;    // check 0x2D ('-')
+                               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
+                                       goto __CATCH;
+
+                               if (oneByte != 0x2D) {
+                                       goto __CATCH;
+                               } else {
+                                       goto __RETURN;
+                               }
+                       }
+               }
+       }
+
+__RETURN:
+       gCurMmsDecodeBuffPos -= byteCount;
+       return true;
+
+__CATCH:
+       gCurMmsDecodeBuffPos -= byteCount;
+       return false;
+}
+
+
+bool MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength)
+{
+       UINT32 nEntries = 0;
+       MsgMultipart *pMultipart = NULL;
+       MsgMultipart *pLastMultipart = NULL;
+       MsgMultipart *pPreMultipart     = NULL;
+       int offset = 0;
+       int     index = 0;
+
+       MsgPresentationFactor factor = MSG_PRESENTATION_NONE;
+       MsgPresentaionInfo presentationInfo;
+
+       MSG_DEBUG("MmsBinaryDecodeMultipart: total length=%d\n", totalLength);
+
+       presentationInfo.factor = MSG_PRESENTATION_NONE;
+       presentationInfo.pCurPresentation = NULL;
+       presentationInfo.pPrevPart = NULL;
+
+       if (MmsBinaryDecodeEntries(pFile, &nEntries, totalLength) == false) {
+               MSG_DEBUG("MmsBinaryDecodeMultipart: MmsBinaryDecodeEntries is fail.\n");
+               goto __CATCH;
+       }
+
+       while (nEntries) {
+               MSG_DEBUG("MmsBinaryDecodeMultipart: decoding %dth multipart\n", index);
+
+               offset = _MmsGetDecodeOffset();
+               if (offset >= totalLength)
+                       goto __RETURN;
+
+               if ((pMultipart = MsgAllocMultipart()) == NULL) {
+                       MSG_DEBUG("MmsBinaryDecodeMultipart: MsgAllocMultipart Fail \n");
+                       goto __CATCH;
+               }
+
+               if (MmsBinaryDecodeEachPart(pFile, szFilePath, &(pMultipart->type), pMultipart->pBody, totalLength) == false) {
+                       MSG_DEBUG("MmsBinaryDecodeMultipart: MmsBinaryDecodeEachPart is fail.(nEntries = %d)\n", nEntries);
+                       goto __CATCH;
+               }
+
+               if (pMsgType->param.type == MIME_APPLICATION_SMIL) {
+                       factor = MsgIsPresentationEx(&(pMultipart->type), pMsgType->param.szStart, (MimeType)pMsgType->param.type);
+               } else {
+                       factor = MSG_PRESENTATION_NONE;
+               }
+               // priority 1 : content type match, 2: content location, 3: type
+               if (presentationInfo.factor < factor) {
+                       // Presentation part
+                       presentationInfo.factor = factor;
+                       presentationInfo.pPrevPart = pPreMultipart;
+                       presentationInfo.pCurPresentation = pMultipart;
+               }
+
+               if (pMsgBody->body.pMultipart == NULL) {
+                       /* first multipart */
+                       pMsgBody->body.pMultipart = pMultipart;
+                       pLastMultipart                    = pMultipart;
+                       pPreMultipart                     = NULL;
+               } else if (pLastMultipart != NULL) {
+                       pPreMultipart = pLastMultipart;
+
+                       pLastMultipart->pNext   = pMultipart;
+                       pLastMultipart                  = pMultipart;
+               }
+
+               pMsgType->contentSize += pMultipart->pBody->size;
+
+               nEntries--;
+               pPreMultipart = pMultipart;
+               MmsDebugPrintMulitpartEntry(pMultipart, index++);
+
+       }
+
+       pMsgBody->size = totalLength - pMsgBody->offset;
+
+#ifdef __SUPPORT_DRM__
+       if (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_REQUIRED)
+#endif
+               MsgConfirmPresentationPart(pMsgType, pMsgBody, &presentationInfo);
+
+       if (MsgResolveNestedMultipart(pMsgType, pMsgBody) == false) {
+               MSG_DEBUG("MmsBinaryDecodeMultipart : MsgResolveNestedMultipart failed \n");
+               goto __CATCH;
+       }
+
+__RETURN:
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength)
+{
+       int     length = 0;
+       bool bSuccess = false;
+       UINT32 headerLength = 0;
+       UINT32 bodyLength = 0;
+       int offset = 0;
+
+       MSG_DEBUG("MmsBinaryDecodeEachPart: total length=%d\n", totalLength);
+
+       /* header length */
+
+       if (__MmsBinaryDecodeUintvar(pFile, &headerLength, totalLength) <= 0) {
+               MSG_DEBUG("MmsBinaryDecodeEachPart: Get header length fail \n");
+               goto __CATCH;
+       }
+
+       offset = _MmsGetDecodeOffset();
+       if (offset >= totalLength)
+               goto __RETURN;
+
+
+       /* body length */
+
+       if (__MmsBinaryDecodeUintvar(pFile, &bodyLength, totalLength) <= 0) {
+               MSG_DEBUG("MmsBinaryDecodeEachPart: Get body length fail\n");
+               goto __CATCH;
+       }
+
+
+       offset = _MmsGetDecodeOffset();
+       if (offset >= totalLength)
+               goto __RETURN;
+
+
+       /* Content Type */
+       if (szFilePath != NULL)
+               strncpy(pMsgType->szOrgFilePath, szFilePath, strlen(szFilePath));
+
+       pMsgType->offset = _MmsGetDecodeOffset();
+       pMsgType->size = headerLength;
+       pMsgType->contentSize = bodyLength;
+
+       if (pMsgType->offset > totalLength)
+               goto __RETURN;
+
+       length = MmsBinaryDecodeContentType(pFile, pMsgType, totalLength);
+       if (length <= 0) {
+               MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentType Fail \n");
+               goto __CATCH;
+       }
+
+       offset = _MmsGetDecodeOffset();
+       if (offset >= totalLength)
+               goto __RETURN;
+
+
+       /* Part Header */
+
+       if (MmsBinaryDecodePartHeader(pFile, pMsgType, headerLength - length, totalLength) == false) {
+               MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentHeader Fail \n");
+               goto __CATCH;
+       }
+
+       offset = _MmsGetDecodeOffset();
+       if (offset >= totalLength)
+               goto __RETURN;
+
+       /* Part Body */
+
+       if (szFilePath != NULL)
+               strncpy(pMsgBody->szOrgFilePath, szFilePath, strlen(szFilePath));
+
+       pMsgBody->offset = _MmsGetDecodeOffset();
+       pMsgBody->size   = bodyLength;
+
+       if (pMsgBody->offset > totalLength)
+               goto __RETURN;
+
+       switch (pMsgType->type) {
+       case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED:
+       case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED:
+       case MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC:
+       case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE:
+       case MIME_MULTIPART_REPORT:
+       case MIME_MULTIPART_MIXED:
+       case MIME_MULTIPART_RELATED:
+       case MIME_MULTIPART_ALTERNATIVE:
+
+               MSG_DEBUG("MmsBinaryDecodeEachPart: Decode multipart\n");
+
+               if (MmsBinaryDecodeMultipart(pFile, szFilePath, pMsgType, pMsgBody, totalLength) == false) {
+                       MSG_DEBUG("MmsBinaryDecodeEachPart: MmsBinaryDecodeMultipart is fail.\n");
+                       goto __CATCH;
+               }
+
+               offset = _MmsGetDecodeOffset();
+               if (offset >= totalLength)
+                       goto __RETURN;
+
+               break;
+
+
+#ifdef __SUPPORT_DRM__
+
+       case MIME_APPLICATION_VND_OMA_DRM_MESSAGE: /* Contains forwardLock OR combined-delivery media part */
+               MSG_DEBUG("MmsBinaryDecodeEachPart: MIME_APPLICATION_VND_OMA_DRM_MESSAGE Part \n");
+
+               if (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_NOT_FIXED && MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_REQUIRED) {
+
+                       if (MmsBinaryDecodeDRMContent(pFile, szFilePath, pMsgType, pMsgBody, bodyLength, totalLength) == false)
+                               goto __CATCH;
+               } else {
+                       MmsDrm2SetConvertState(MMS_DRM2_CONVERT_REQUIRED);
+
+                       bSuccess = MmsBinaryDecodePartBody(pFile, bodyLength, totalLength);
+                       if (bSuccess == false) {
+                               MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentBody Fail \n");
+                               goto __CATCH;
+                       }
+               }
+               offset = _MmsGetDecodeOffset();
+               if (offset >= totalLength)
+                       goto __RETURN;
+
+               break;
+
+       case MIME_APPLICATION_VND_OMA_DRM_CONTENT: /* Contains seperate-delivery media part (DCF) */
+
+               MSG_DEBUG("MmsBinaryDecodeEachPart: MIME_APPLICATION_VND_OMA_DRM_CONTENT Part \n");
+
+               if (MmsBinaryDecodeDRMContent(pFile, szFilePath, pMsgType, pMsgBody, bodyLength, totalLength) == false)
+                       goto __CATCH;
+
+               offset = _MmsGetDecodeOffset();
+               if (offset >= totalLength)
+                       goto __RETURN;
+
+               break;
+#endif
+
+       default:
+               MSG_DEBUG("MmsBinaryDecodeEachPart: Other normal Part \n");
+
+               bSuccess = MmsBinaryDecodePartBody(pFile, bodyLength, totalLength);
+               if (bSuccess == false) {
+                       MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentBody Fail \n");
+                       goto __CATCH;
+               }
+
+               offset = _MmsGetDecodeOffset();
+               if (offset >= totalLength)
+                       goto __RETURN;
+
+               break;
+       }
+
+       return true;
+
+__RETURN:
+
+       return true;
+
+__CATCH:
+
+       return false;
+}
+
+#ifdef __SUPPORT_DRM__
+bool __MmsParseDCFInfo(FILE *pFile, MsgDRMInfo *pDrmInfo, int totalLength)
+{
+       UINT8 version = 0;
+       UINT8 contentTypeLen = 0;
+       UINT8 contentURILen = 0;
+       char *szContentType     = NULL;
+       char *szContentURI = NULL;
+
+       if (_MmsBinaryDecodeGetOneByte(pFile, &version, totalLength) == false) {
+               MSG_DEBUG("__MmsParseDCFInfo: [version] GetOneByte fail\n");
+               goto __CATCH;
+       }
+
+       if (_MmsBinaryDecodeGetOneByte(pFile, &contentTypeLen, totalLength) == false) {
+               MSG_DEBUG("__MmsParseDCFInfo: [contentTypeLen] GetOneByte fail\n");
+               goto __CATCH;
+       }
+
+       if (_MmsBinaryDecodeGetOneByte(pFile, &contentURILen, totalLength) == false) {
+               MSG_DEBUG("__MmsParseDCFInfo: [contentURILen] GetOneByte fail\n");
+               goto __CATCH;
+       }
+
+       //Get media content-type (mime-type)
+       szContentType = (char *)malloc(contentTypeLen + 1);
+       if (szContentType == NULL)
+               goto __CATCH;
+
+       memset(szContentType, 0, contentTypeLen + 1);
+
+       if (_MmsBinaryDecodeGetBytes(pFile, szContentType, contentTypeLen + 1, totalLength) < 0) {
+               MSG_DEBUG("__MmsParseDCFInfo : contentType is invalid\n");
+               goto __CATCH;
+       }
+       gCurMmsDecodeBuffPos--;
+       pDrmInfo->contentType = (MsgContentType)_MsgGetCode(MSG_TYPE, szContentType);
+
+
+       //Get content-ID - 1.remover "cid:",   2.resolve "%hexa",   3.and copy the string
+       szContentURI = (char *)malloc(contentURILen + 1);
+       if (szContentURI == NULL)
+               goto __CATCH;
+
+       memset(szContentURI, 0, contentURILen + 1);
+
+       if (_MmsBinaryDecodeGetBytes(pFile, szContentURI, contentURILen + 1, totalLength) < 0) {
+               MSG_DEBUG("__MmsParseDCFInfo : contentType is invalid\n");
+               goto __CATCH;
+       }
+       gCurMmsDecodeBuffPos--;
+       pDrmInfo->szContentURI = MsgResolveContentURI(szContentURI);
+
+
+       if (szContentType) {
+               free(szContentType);
+               szContentType = NULL;
+       }
+
+       if (szContentURI) {
+               free(szContentURI);
+               szContentURI = NULL;
+       }
+       return true;
+
+
+__CATCH:
+
+       if (szContentType) {
+               free(szContentType);
+               szContentType = NULL;
+       }
+
+       if (szContentURI) {
+               free(szContentURI);
+               szContentURI = NULL;
+       }
+       return false;
+
+}
+
+
+bool __MmsParseDCFHdr(FILE *pFile, MsgDRMInfo *pDrmInfo, UINT32 headerLen, int totalLength)
+{
+       char *szDCFHdr = NULL;
+       MsgType partType;
+       ULONG nRead = 0;
+       int offset = 0;
+
+       /* add to parse DCF header such as,
+        *  Right-Issuer, Content-Name, and Content-Description.
+        */
+
+       szDCFHdr = (char *)malloc(headerLen + 1);
+       if (szDCFHdr == NULL) {
+               MSG_DEBUG("__MmsParseDCFHdr: szDCFHdr alloc fail\n");
+               goto __CATCH;
+       }
+       memset(szDCFHdr, 0, headerLen + 1);
+
+       offset = _MmsGetDecodeOffset();
+       if (offset >= totalLength)
+               goto __RETURN;
+
+       if (MsgFseek(pFile, offset, SEEK_SET) < 0)
+               goto __CATCH;
+
+       if ((nRead = MsgReadFile(szDCFHdr, sizeof(char), headerLen, pFile)) == 0){
+               goto __CATCH;
+       }
+       szDCFHdr[nRead] = '\0';
+
+       _MsgInitMsgType(&partType);
+       _MsgParsePartHeader(&partType, szDCFHdr, headerLen);
+
+       pDrmInfo->szContentName = partType.drmInfo.szContentName;
+       pDrmInfo->szContentVendor = partType.drmInfo.szContentVendor;
+       pDrmInfo->szContentDescription = partType.drmInfo.szContentDescription;
+       pDrmInfo->szRightIssuer = partType.drmInfo.szRightIssuer;
+
+       if (MmsBinaryDecodeMovePointer(pFile, offset + headerLen, totalLength) == false)
+               goto __CATCH;
+
+__RETURN:
+
+       if (szDCFHdr) {
+               free(szDCFHdr);
+               szDCFHdr = NULL;
+       }
+
+       return true;
+
+__CATCH:
+
+       if (szDCFHdr) {
+               free(szDCFHdr);
+               szDCFHdr = NULL;
+       }
+
+       return false;
+}
+
+
+bool MmsBinaryDecodeDRMContent(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int bodyLength, int totalLength)
+{
+       int offset = 0;
+       char szTempFilePath[MSG_FILEPATH_LEN_MAX] = MSG_DATA_PATH"drm.dcf";
+       char *pRawData = NULL;
+       bool isFileCreated = false;
+
+       MSG_DEBUG("bodyLength: %d\n", bodyLength);
+
+       offset = _MmsGetDecodeOffset();
+
+       if (offset >= totalLength)
+               goto __RETURN;
+
+       if (szFilePath != NULL)
+               strncpy(pMsgBody->szOrgFilePath, szFilePath, strlen(szFilePath));
+       if (szFilePath != NULL)
+               strncpy(pMsgType->szOrgFilePath, szFilePath, strlen(szFilePath));
+
+       pRawData = (char *)malloc(bodyLength);
+       if (pRawData == NULL) {
+               MSG_DEBUG("pRawData alloc FAIL \n");
+               goto __CATCH;
+       }
+
+       if (MsgFseek(pFile, offset, SEEK_SET) < 0) {
+               MSG_DEBUG("MsgFseek() returns -1 \n");
+               goto __CATCH;
+       }
+       if (MsgReadFile(pRawData, sizeof(char), bodyLength, pFile) != (size_t)bodyLength) {
+               MSG_DEBUG("FmReadFile() returns false \n");
+               goto __CATCH;
+       }
+       if (MsgOpenCreateAndOverwriteFile(szTempFilePath, pRawData, bodyLength) == false) {
+               MSG_DEBUG("MsgOpenCreateAndOverwriteFile() returns false \n");
+               goto __CATCH;
+       }
+
+       isFileCreated = true;
+       MSG_DEBUG("MmsDrm2GetConvertState() [%d]", MmsDrm2GetConvertState());
+
+       if (pMsgType->type == MIME_APPLICATION_VND_OMA_DRM_MESSAGE && (MmsDrm2GetConvertState()!=MMS_DRM2_CONVERT_FINISH)) {
+               MmsDrm2SetConvertState(MMS_DRM2_CONVERT_REQUIRED);
+       } else {
+               if (MsgDRM2GetDRMInfo(szTempFilePath, pMsgType) == false) {
+                       MSG_DEBUG("MsgDRM2GetDRMInfo() returns false \n");
+                       goto __CATCH;
+               }
+       }
+
+       remove(szTempFilePath);
+       isFileCreated = false;
+
+       if (MmsBinaryDecodeMovePointer(pFile, offset + bodyLength, totalLength) == false)
+               goto __CATCH;
+
+__RETURN:
+
+       if (pRawData) {
+               free(pRawData);
+               pRawData = NULL;
+       }
+
+       return true;
+
+__CATCH:
+       if (isFileCreated)
+               remove(szTempFilePath);
+
+       if (pRawData) {
+               free(pRawData);
+               pRawData = NULL;
+       }
+
+       return false;
+}
+
+
+bool MmsBinaryDecodeDRMMessage(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int fullBodyLength, int totalLength)
+{
+       int offset = 0;
+       char szTempFilePath[MSG_FILEPATH_LEN_MAX] = "/User/Msg/Mms/Temp/drm.dm";
+       char *pRawData = NULL;
+       bool isFileCreated = false;
+
+       offset = _MmsGetDecodeOffset();
+       if (offset >= totalLength)
+               goto __RETURN;
+
+       if (szFilePath != NULL)
+               strncpy(pMsgBody->szOrgFilePath, szFilePath, strlen(szFilePath));
+       if (szFilePath != NULL)
+               strncpy(pMsgType->szOrgFilePath, szFilePath, strlen(szFilePath));
+
+       pRawData = (char *)malloc(fullBodyLength);
+       if (pRawData == NULL) {
+               MSG_DEBUG("pRawData alloc FAIL \n");
+               goto __CATCH;
+       }
+
+       if (MsgFseek(pFile, offset,  SEEK_SET) < 0) {
+               MSG_DEBUG("MsgFseek() returns -1 \n");
+               goto __CATCH;
+       }
+
+       if (MsgReadFile(pRawData, sizeof(char), fullBodyLength, pFile)!= (size_t)fullBodyLength) {
+               MSG_DEBUG("FmReadFile() returns false \n");
+               goto __CATCH;
+       }
+
+       if (MsgOpenCreateAndOverwriteFile(szTempFilePath, pRawData, fullBodyLength) == false) {
+               MSG_DEBUG("MsgOpenCreateAndOverwriteFile() returns false \n");
+               goto __CATCH;
+       }
+       isFileCreated = true;
+
+       if (strstr(szTempFilePath, ".dm")) {
+               char szConvertedFilePath[MSG_FILEPATH_LEN_MAX] = {0,};
+
+               if (MsgDrmConvertDmtoDcfType(szTempFilePath, szConvertedFilePath)) {
+                       remove(szTempFilePath);
+                       memset(szTempFilePath, 0, MSG_FILEPATH_LEN_MAX);
+                       strncpy(szTempFilePath, szConvertedFilePath, MSG_FILEPATH_LEN_MAX-1);
+               }
+       }
+
+       if (MsgDRM2GetDRMInfo(szTempFilePath, pMsgType) == false) {
+               MSG_DEBUG("MsgDRM2GetDRMInfo() returns false \n");
+               goto __CATCH;
+       }
+
+       remove(szTempFilePath);
+       isFileCreated = false;
+
+       if (MmsBinaryDecodeMovePointer(pFile, offset + fullBodyLength, totalLength) == false)
+               goto __CATCH;
+
+__RETURN:
+
+       if (pRawData) {
+               free(pRawData);
+               pRawData = NULL;
+       }
+       return true;
+
+__CATCH:
+       if (isFileCreated)
+               remove(szTempFilePath);
+
+       if (pRawData) {
+               free(pRawData);
+               pRawData = NULL;
+       }
+       return false;
+}
+
+static int __MmsDrm2BinaryEncodeUintvarLen(UINT32 integer)
+{
+       UINT32 length   = 0;
+
+       /* Find encoded unitvar length */
+       if (integer  <= MMS_UINTVAR_LENGTH_1) {
+               length = 1;
+       } else {
+               if (integer <= MMS_UINTVAR_LENGTH_2) {
+                       length = 2;
+               } else {
+                       if (integer <= MMS_UINTVAR_LENGTH_3) {
+                               length = 3;
+                       } else {
+                               length = 4;
+                       }
+               }
+       }
+
+       return length;
+}
+
+
+static bool __MmsDrm2BinaryEncodeUintvar(UINT32 integer, int length, char *pszOutput)
+{
+       const char ZERO = 0x00;
+       int i = 2;
+       char szReverse[MSG_STDSTR_LONG] = {0, };
+
+       union {
+               UINT32 integer;
+               char bytes[4];
+       } source;
+       source.integer = integer;
+       memset(szReverse, 0, MSG_STDSTR_LONG);
+
+       /* Seperate integer to 4 1 byte integer */
+       szReverse[3] = source.bytes[3] & 0x0f;
+       szReverse[0] = source.bytes[0];
+       szReverse[0] = szReverse[0] & 0x7f;
+
+       while (length >= i) {// initially, i = 2
+               /* Move integer bit to proper position */
+               source.integer = source.integer << 1;
+               source.integer = source.integer >> 8;
+               source.bytes[3] = ZERO;
+
+               /* Retrive 1 encode uintvar */
+               szReverse[i-1] = source.bytes[0];
+               szReverse[i-1] = szReverse[i-1] | 0x80;
+               i++;
+       }
+
+       for (i=0; i < length; i++)
+               pszOutput[i] = szReverse[length - i - 1];
+
+       return true;
+}
+
+
+static int __MmsDrm2GetEntriesValueLength(FILE *pFile, int orgOffset)
+{
+       char szEntries[5] = {0, };
+       UINT8 oneByte   = 0;
+       int j = 0;                      //j is the length of nEntries value
+
+       if (MsgReadFile(szEntries, sizeof(char), 4, pFile) != (size_t)4) {
+               MSG_DEBUG("__MmsDrm2GetEntriesValueLength: FmReadFile() returns false \n");
+               return false;
+       }
+
+       while (true) {
+               oneByte = szEntries[j++];
+
+               if (oneByte <= 0x7f)
+                       break;
+       }
+
+       //move file pointer to point nEntries
+       if (MsgFseek(pFile, orgOffset, SEEK_SET) < 0) {
+               MSG_DEBUG("__MmsDrm2GetEntriesValueLength: fail to seek file pointer\n");
+               return false;
+       }
+
+       return j;
+}
+
+
+static bool __MmsDrm2WriteDataToConvertedFile(FILE *pSrcFile, FILE *pDestinationFile, char *pszMmsLoadTempBuf, int length, int bufLen)
+{
+       int loadLen = 0, totalLoadLen = 0, nRead = 0;
+
+       for (int i=0; i<(length/bufLen)+1; i++) {
+               loadLen = (length-totalLoadLen < bufLen) ? length-totalLoadLen : bufLen;
+
+               memset(pszMmsLoadTempBuf, 0, MMS_DRM2_CONVERT_BUFFER_MAX + 1);
+
+               if (MsgReadFile(pszMmsLoadTempBuf, sizeof(char), loadLen, pSrcFile) != (size_t)loadLen) {
+                       MSG_DEBUG("__MmsDrm2WriteDataToConvertedFile: FmReadFile() returns false \n");
+                       return false;
+               }
+
+               if (MsgWriteFile(pszMmsLoadTempBuf, sizeof(char), loadLen, pDestinationFile) != (size_t)loadLen) {
+                       MSG_DEBUG("__MmsDrm2WriteDataToConvertedFile: File Writing is failed.\n");
+                       return false;
+               }
+
+               totalLoadLen += nRead;
+       }
+
+       return true;
+}
+
+
+/*************************************************************************
+ * description : make new message file converting CD & FL part of original message file to SD type
+ * argument : void
+ * return value
+    - bool :  result of converting
+**************************************************************************/
+bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
+{
+       FILE *pFile = NULL;
+       FILE *hConvertedFile = NULL;
+       FILE *hTempFile = NULL;
+       FILE *hFile = NULL;
+       MsgMultipart *pMultipart = NULL;
+       char szTempFilePath[MSG_FILEPATH_LEN_MAX] = MSG_DATA_PATH"Drm_Convert";
+       char szTempFile[MSG_FILEPATH_LEN_MAX] = MSG_DATA_PATH"temp.dm";
+       char *pszMmsLoadTempBuf = NULL;
+       char *pszOrgData = NULL;
+       int length = 0;
+       int bufLen = MMS_DRM2_CONVERT_BUFFER_MAX;
+       int curOffset = 0;
+
+       MSG_DEBUG("start convert~~~~~~\n");
+
+       pFile = MsgOpenFile(szOriginFilePath, "rb");
+       if (pFile == NULL) {
+               MSG_DEBUG("Open decode temporary file fail\n");
+               goto __CATCH;
+       }
+
+       hConvertedFile = MsgOpenFile(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, "wb+");
+       if (hConvertedFile == NULL) {
+               MSG_DEBUG("Open decode temporary file fail\n");
+               goto __CATCH;
+       }
+
+       pszMmsLoadTempBuf = (char*)malloc(MMS_DRM2_CONVERT_BUFFER_MAX + 1);
+       if (pszMmsLoadTempBuf == NULL) {
+               MSG_DEBUG("malloc for pszMmsLoadTempBuf failed\n");
+               goto __CATCH;
+       }
+       memset(pszMmsLoadTempBuf, 0, MMS_DRM2_CONVERT_BUFFER_MAX + 1);
+
+       // MMS Header  copy
+       length = mmsHeader.msgBody.offset;
+       if (__MmsDrm2WriteDataToConvertedFile(pFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) {
+               MSG_DEBUG("Write header data fail\n");
+               goto __CATCH;
+       }
+
+       curOffset += length;    //change offset
+
+       // MMS Body copy
+       if (MsgIsMultipart(mmsHeader.msgType.type) == true)
+       {
+               // nEntries copy
+               length = __MmsDrm2GetEntriesValueLength(pFile, curOffset);      // getting nEntries value's length
+
+               if (__MmsDrm2WriteDataToConvertedFile(pFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) {
+                       MSG_DEBUG("Write nEntries fail\n");
+                       goto __CATCH;
+               }
+
+               curOffset += length;    //change offset
+
+               // each Multipart entry copy
+               pMultipart = mmsHeader.msgBody.body.pMultipart;
+
+               while (pMultipart) {
+                       if (pMultipart->type.type == MIME_APPLICATION_VND_OMA_DRM_MESSAGE) {
+                               int orgDataLen = pMultipart->pBody->size;
+                               int nSize = 0;
+
+                               MSG_DEBUG("Write MIME_APPLICATION_VND_OMA_DRM_MESSAGE multipart data(orgDataLen = %d).\n", orgDataLen);
+
+                               pszOrgData = (char *)malloc(orgDataLen + 1);
+                               if (pszOrgData == NULL) {
+                                       MSG_DEBUG("pszOrgData is NULL \n");
+                                       goto __CATCH;
+                               }
+                               memset(pszOrgData, 0, orgDataLen + 1);
+
+                               // move file pointer to data
+                               if (MsgFseek(pFile, pMultipart->pBody->offset, SEEK_SET) < 0) {
+                                       MSG_DEBUG("fail to seek file pointer 1\n");
+                                       goto __CATCH;
+                               }
+
+                               if (MsgReadFile(pszOrgData, sizeof(char), orgDataLen, pFile) != (size_t)orgDataLen) {
+                                       MSG_DEBUG("FmReadFile() returns false for orgData\n");
+                                       goto __CATCH;
+                               }
+
+                               if((hFile = MsgOpenFile(szTempFile, "wb+")) == NULL) {
+                                       MSG_DEBUG("file open failed [%s]", szTempFile);
+                                       goto __CATCH;
+                               }
+
+                               if (MsgWriteFile(pszOrgData, sizeof(char), orgDataLen, hFile) != (size_t)orgDataLen) {
+                                       MSG_DEBUG("File write error");
+                                       goto __CATCH;
+                               }
+
+                               MsgFflush(hFile);
+                               MsgCloseFile(hFile);
+
+                               hFile = NULL;
+
+                               // --> invoking drm agent api, converting data part start
+                               MSG_DEBUG("start data part convert by callling drm agent api\n");
+
+                               int ret = 0;
+                               ret = MsgDrmConvertDmtoDcfType(szTempFile, szTempFilePath);
+                               MSG_DEBUG("MsgDrmConvertDmtoDcfType returned %s", ret ? "true": "false");
+
+                               if (MsgGetFileSize(szTempFilePath, &nSize) == false) {
+                                       MSG_DEBUG("MsgGetFileSize error");
+                                       goto __CATCH;
+                               }
+                               MSG_DEBUG("MmsDrm2ConvertMsgBody: end data part convert(converted data len = %d)\n", nSize);
+                               // <-- invoking drm agent api, converting data part end
+
+                               // move file pointer to the head of multipart
+                               if (MsgFseek(pFile, curOffset, SEEK_SET) < 0) {
+                                       MSG_DEBUG("fail to seek file pointer 2\n");
+                                       goto __CATCH;
+                               }
+
+                               // read headerLen, dataLen
+                               length = pMultipart->type.offset - curOffset;
+                               memset(pszMmsLoadTempBuf, 0, MMS_DRM2_CONVERT_BUFFER_MAX + 1);
+                               if (MsgReadFile(pszMmsLoadTempBuf, sizeof(char), length, pFile) != (size_t)length) {
+                                       MSG_DEBUG("FmReadFile() returns false for headerLen, dataLen\n");
+                                       goto __CATCH;
+                               }
+
+                               curOffset += length;
+
+                               // change dataLen based on converted data
+                               {
+                                       UINT8   oneByte = 0;
+                                       int             j = 0;
+                                       int             encodeLen = 0;
+                                       char    szOutput[MSG_STDSTR_LONG] = {0, };
+
+                                       while (true) {
+                                               oneByte = pszMmsLoadTempBuf[j++];
+
+                                               if (oneByte <= 0x7f)
+                                                       break;
+                                       }
+
+                                       encodeLen = __MmsDrm2BinaryEncodeUintvarLen((UINT32)nSize);
+                                       __MmsDrm2BinaryEncodeUintvar((UINT32)nSize, encodeLen, szOutput);
+
+                                       strncpy(&(pszMmsLoadTempBuf[j]), szOutput, encodeLen);
+                                       pszMmsLoadTempBuf[j+encodeLen] = '\0';
+
+                                       if (MsgWriteFile(pszMmsLoadTempBuf, sizeof(char), length, hConvertedFile) != (size_t)length) {
+                                               MSG_DEBUG("Drm2WriteConvertData: FmWriteFile() returns false for dateLen\n");
+                                               goto __CATCH;
+                                       }
+                               }
+
+
+                               length = pMultipart->pBody->offset - pMultipart->type.offset;
+
+                               if (__MmsDrm2WriteDataToConvertedFile(pFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) {
+                                       MSG_DEBUG("Drm2WriteConvertData: Write content type, headers fail\n");
+                                       goto __CATCH;
+                               }
+
+                               curOffset += length;
+
+                               // write converted data
+                               hTempFile = MsgOpenFile(szTempFilePath, "rb");
+                               if (hTempFile == NULL) {
+                                       MSG_DEBUG("Open decode temporary file fail\n");
+                                       goto __CATCH;
+                               }
+
+                               length = nSize;
+
+                               if (__MmsDrm2WriteDataToConvertedFile(hTempFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) {
+                                       MSG_DEBUG("Write converted data fail\n");
+                                       goto __CATCH;
+                               }
+
+                               if (hTempFile != NULL) {
+                                       MsgCloseFile(hTempFile);
+                                       hTempFile = NULL;
+                               }
+
+                               curOffset += pMultipart->pBody->size;
+
+                               // move file pointer to the head of multipart
+                               if (MsgFseek(pFile, curOffset, SEEK_SET) < 0) {
+                                       MSG_DEBUG("fail to seek file pointer \n");
+                                       goto __CATCH;
+                               }
+                       } else {        // it doesn't need to convert if it is not CD or FL
+                               MSG_DEBUG("Write normal multipart data\n");
+
+                               length = pMultipart->pBody->offset + pMultipart->pBody->size - curOffset;
+
+                               if (__MmsDrm2WriteDataToConvertedFile(pFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) {
+                                       MSG_DEBUG("Write multipart data fail \n");
+                                       goto __CATCH;
+                               }
+
+                               curOffset += length;
+                       }
+
+                       pMultipart = pMultipart->pNext;
+               }
+       }
+
+       MSG_DEBUG("end convert~~~~~~\n");
+
+       if (pFile != NULL) {
+               MsgCloseFile(pFile);
+               pFile = NULL;
+       }
+
+       if (hConvertedFile != NULL) {
+               MsgCloseFile(hConvertedFile);
+               hConvertedFile = NULL;
+       }
+
+       if (hTempFile != NULL) {
+               MsgCloseFile(hTempFile);
+               hTempFile = NULL;
+       }
+
+       if (pszMmsLoadTempBuf) {
+               free(pszMmsLoadTempBuf);
+               pszMmsLoadTempBuf = NULL;
+       }
+
+       if (pszOrgData) {
+               free(pszOrgData);
+               pszOrgData = NULL;
+       }
+
+       if (hFile != NULL) {
+               MsgCloseFile(hFile);
+               hFile = NULL;
+       }
+
+       remove(szTempFile);
+       remove(szTempFilePath);
+
+       return true;
+
+__CATCH:
+
+       if (pFile != NULL) {
+               MsgCloseFile(pFile);
+               pFile = NULL;
+       }
+
+       if (hConvertedFile != NULL) {
+               MsgCloseFile(hConvertedFile);
+               hConvertedFile = NULL;
+       }
+
+       if (hTempFile != NULL) {
+               MsgCloseFile(hTempFile);
+               hTempFile = NULL;
+       }
+
+       if (pszMmsLoadTempBuf) {
+               free(pszMmsLoadTempBuf);
+               pszMmsLoadTempBuf = NULL;
+       }
+
+       if (pszOrgData) {
+               free(pszOrgData);
+               pszOrgData = NULL;
+       }
+
+       if (hFile != NULL)
+       {
+               MsgCloseFile(hFile);
+               hFile = NULL;
+       }
+
+       remove(szTempFile);
+       remove(szTempFilePath);
+       remove(MMS_DECODE_DRM_CONVERTED_TEMP_FILE);     //remove convertin result if it goes to __CATCH
+
+       return false;
+}
+
+
+/*************************************************************************
+ * description : Function for decoding a converted file
+ * argument : void
+ * return value
+    - bool :  result of converting
+**************************************************************************/
+bool MmsDrm2DecodeConvertedMsg(int msgID, char *pszFullPath)
+{
+       FILE *hConvertedFile = NULL;
+       int     nSize = 0;
+
+       MSG_DEBUG("MmsDrm2DecodeConvertedMsg: start re-decoding~~~~~~\n");
+
+       // free
+       _MsgFreeDRMInfo(&mmsHeader.msgType.drmInfo);
+       _MsgFreeBody(&mmsHeader.msgBody, mmsHeader.msgType.type);
+
+       _MmsInitHeader();
+       _MmsUnregisterDecodeBuffer();
+
+       // start decoding
+       _MmsRegisterDecodeBuffer(gszMmsLoadBuf1, gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX);
+
+       // open converted file
+       if ((hConvertedFile = MsgOpenFile(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, "rb")) == NULL) {
+               MSG_DEBUG("MmsDrm2ReDecodeMsg: opening temporary file failed\n");
+               goto __CATCH;
+       }
+
+       if (MsgGetFileSize(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, &nSize) == false) {
+               MSG_DEBUG("MsgGetFileSize: failed\n");
+               goto __CATCH;
+       }
+
+       if (!MmsBinaryDecodeMsgHeader(hConvertedFile, nSize)) {
+               MSG_DEBUG("MmsDrm2ReDecodeMsg: decoding header(binary mode) failed\n");
+               goto __CATCH;
+       }
+
+       if (!MmsBinaryDecodeMsgBody(hConvertedFile, pszFullPath, nSize)) {
+               MSG_DEBUG("MmsDrm2ReDecodeMsg: decoding body failed\n");
+               goto __CATCH;
+       }
+
+       if (hConvertedFile != NULL) {
+               MsgCloseFile(hConvertedFile);
+               hConvertedFile = NULL;
+       }
+
+       return true;
+
+__CATCH:
+
+       if (hConvertedFile != NULL) {
+               MsgCloseFile(hConvertedFile);
+               remove(MMS_DECODE_DRM_CONVERTED_TEMP_FILE);
+               hConvertedFile = NULL;
+       }
+
+       return false;
+}
+
+
+bool MmsDrm2ReadMsgConvertedBody(MSG_MESSAGE_INFO_S *pMsg, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath)
+{
+       MmsMsg *pMmsMsg;
+       MmsPluginStorage::instance()->getMmsMessage(&pMmsMsg);
+       _MmsUnregisterDecodeBuffer();
+#ifdef __SUPPORT_DRM__
+       _MsgFreeDRMInfo(&pMmsMsg->msgType.drmInfo);
+#endif
+       _MsgFreeBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type);
+
+       if (_MmsReadMsgBody(pMsg->msgId, bSavePartsAsTempFiles, bRetrieved, retrievedPath) == false) {
+               MSG_DEBUG("MmsDrm2ReadMsgConvertedBody: _MmsReadMsgBody with converted file is failed\n");
+               return false;
+       }
+
+       return true;
+}
+
+#endif
+
+/* --------------------------------------------------------------------
+ *
+ *     B  I  N  A  R  Y       D  E  C  D  E      U  T  I  L  I  T  Y
+ *
+ * --------------------------------------------------------------------*/
+
+bool _MmsBinaryDecodeGetOneByte(FILE *pFile, UINT8 *pOneByte, int totalLength)
+{
+       int length = gMmsDecodeMaxLen - gCurMmsDecodeBuffPos;
+
+       if (pFile == NULL || pOneByte == NULL)
+       {
+               MSG_DEBUG("_MmsBinaryDecodeGetOneByte: invalid file or buffer\n");
+               goto __CATCH;
+       }
+
+       if (length < 1) {
+               if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+                                                                          gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+                       MSG_DEBUG("_MmsBinaryDecodeGetOneByte: fail to load to buffer \n");
+                       goto __CATCH;
+               }
+       }
+
+       *pOneByte = gpCurMmsDecodeBuff[gCurMmsDecodeBuffPos++];
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+/*
+ * @remark: bufLen < gMmsDecodeMaxLen
+ */
+bool _MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength)
+{
+       int length = gMmsDecodeMaxLen - gCurMmsDecodeBuffPos;
+       int i = 0;
+
+
+       if (pFile == NULL || szBuff == NULL || bufLen == 0 || bufLen > gMmsDecodeMaxLen)
+               goto __CATCH;
+
+       memset(szBuff, 0, bufLen);
+
+       if (length < bufLen) {
+               if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+                                                                          gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+                       MSG_DEBUG("_MmsBinaryDecodeGetBytes: fail to load to buffer \n");
+                       goto __CATCH;
+               }
+       }
+
+       for (i = 0; i < bufLen - 1; i++)
+               szBuff[i] = gpCurMmsDecodeBuff[gCurMmsDecodeBuffPos++];
+
+
+       gCurMmsDecodeBuffPos++; //NULL
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+
+bool _MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength)
+{
+       int iPos = 0;
+
+       if (pFile == NULL || szBuff == NULL || bufLen == 0)
+               goto __CATCH;
+
+       memset(szBuff, 0, bufLen);
+
+       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+                                                                  gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+               MSG_DEBUG("_MmsBinaryDecodeGetLongBytes: fail to load to buffer \n");
+               goto __CATCH;
+       }
+
+       while ((bufLen - iPos) >= gMmsDecodeMaxLen) {
+               if (_MmsBinaryDecodeGetBytes(pFile, szBuff + iPos, gMmsDecodeMaxLen, totalLength) == false) {
+                       MSG_DEBUG("_MmsBinaryDecodeGetLongBytes: 1. _MmsBinaryDecodeGetBytes fail \n");
+                       goto __CATCH;
+               }
+
+               iPos += gMmsDecodeMaxLen;
+       }
+
+       if ((bufLen - iPos) > 0) {
+               if (_MmsBinaryDecodeGetBytes(pFile, szBuff + iPos, (bufLen - iPos), totalLength) == false) {
+                       MSG_DEBUG("_MmsBinaryDecodeGetLongBytes: 2. _MmsBinaryDecodeGetBytes fail \n");
+                       goto __CATCH;
+               }
+
+               iPos += (bufLen - iPos);
+       }
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+/**
+ * Decode uintvar to 32bit unsigned integer
+ *
+ * @param      pEncodedData    [in] encoded data
+ * @param      pUintVar                [out] Decode uintvar (32bit unsigned integer)
+ * @return     The length of uintvar (-1, if cannot be converted to a uintvar)
+ *
+ * 0 XXXXXXX -> 0-bit: continue bit & 1~7bit: integer value
+ * - -------
+ */
+static const UINT32 uintvarDecodeTable[] = { 0x00000001, 0x00000080, 0x00004000, 0x00100000, 0x08000000 };
+
+static int __MmsBinaryDecodeUintvar(FILE *pFile, UINT32 *pUintVar, int totalLength)
+{
+       UINT8 count = 0;
+       UINT8 oneByte = 0;
+       UINT32 decodedUintvar = 0;
+       UINT8 iBuff[5] = {0};
+       int length = MSG_MMS_DECODE_BUFFER_MAX - gCurMmsDecodeBuffPos;
+
+
+       if (pFile == NULL || pUintVar == NULL)
+               return -1;
+
+       if (length < 5) {
+               if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+                                                                          gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+                       MSG_DEBUG("__MmsBinaryDecodeUintvar: fail to load to buffer \n");
+                       goto __CATCH;
+               }
+       }
+
+       while (true) {
+               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
+                       goto __CATCH;
+
+               if (oneByte > 0x7f)     {
+                       iBuff[count++] = oneByte;
+               } else {
+                       iBuff[count++] = oneByte;
+                       break;
+               }
+
+               if (count > 5) {
+                       MSG_DEBUG("__MmsBinaryDecodeUintvar : legnth is too long\n");
+                       goto __CATCH;
+               }
+       }
+
+       for (int i = 0; i < count; i++)
+               decodedUintvar += (uintvarDecodeTable[i] * (iBuff[count-(i+1)]&0x7f));
+
+       *pUintVar = decodedUintvar;
+
+       return count;
+
+__CATCH:
+       gCurMmsDecodeBuffPos -= count;
+       return -1;
+}
+
+
+/**
+ * Decode uintvar to 32bit unsigned integer by uintvar length
+ *
+ * @param      pEncodedData [in] uintvar encoded data
+ * @param      length           [in] length of integer value
+ * @return     unsigned integer value
+ */
+static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int totalLength)
+{
+       UINT32 i = 0;
+       UINT8 oneByte = 0;
+       char *pData = NULL;
+       union {
+               UINT32  integer;
+               UINT8   seg[4];
+       } returner;
+
+       returner.integer = 0;
+
+       if (length > 4)
+               length = 4;
+
+       if (length == 1)
+       {
+               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                       MSG_DEBUG("__MmsHeaderDecodeIntegerByLength: _MmsBinaryDecodeGetOneByte fail\n");
+                       return oneByte;
+               }
+
+               if (oneByte > 0x7f) {
+                       return (oneByte & 0x7f);
+               } else {
+                       return oneByte;
+               }
+       }
+
+       if (length == 0)
+               return 0;
+
+       pData = (char *)malloc(length + 1);
+       if (pData == NULL) {
+               MSG_DEBUG("__MmsHeaderDecodeIntegerByLength: pData alloc fail\n");
+               goto __CATCH;
+       }
+       memset(pData, 0, length + 1);
+
+       if (_MmsBinaryDecodeGetBytes(pFile, pData, length + 1, totalLength) == false) {
+               MSG_DEBUG("__MmsHeaderDecodeIntegerByLength: _MmsBinaryDecodeGetOneByte fail\n");
+               goto __CATCH;
+       }
+
+       gCurMmsDecodeBuffPos--; // - NULL
+
+       for (i= 0; i < length; i++)
+               returner.seg[length - (i+1)] = pData[i];
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       return returner.integer;
+
+__CATCH:
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       return returner.integer;
+}
+
+
+/**
+ * Decode uintvar to 32bit unsigned integer by uintvar length
+ *
+ * @param      pEncodedData    [in]  uintvar encoded data
+ * @param      pInteger                [out] Decode integer value (long/short)
+ * @return     unsigned integer value (-1, if cannot be converted to unsigned integer value)
+ */
+static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen, int totalLength)
+{
+       UINT8 oneByte   = 0;
+       char *pData     = NULL;
+       union {
+               UINT32  integer;
+               UINT8   seg[4];
+       } returner;
+
+
+       if (pInteger == NULL)
+               return false;
+
+       returner.integer = 0;
+       *pIntLen                 = 0;
+
+       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+               MSG_DEBUG("__MmsBinaryDecodeInteger: GetOneByte fail\n");
+               return false;
+       }
+
+       if (oneByte < 0x1F)                             /* long integer : WAP-230-WSP-20010118-p, Proposed Version 18 January 2001 (pp.86) */
+       {
+               pData = (char *)malloc(oneByte + 1);
+               if (pData == NULL) {
+                       MSG_DEBUG("__MmsBinaryDecodeInteger: pData memalloc fail\n");
+                       goto __CATCH;
+               }
+               memset(pData, 0, oneByte + 1);
+
+               // Even NULL is copied in the _MmsBinaryDecodeGetBytes
+               if (_MmsBinaryDecodeGetBytes(pFile, pData, oneByte + 1, totalLength) == false) {
+                       MSG_DEBUG("__MmsBinaryDecodeInteger: GetBytes fail\n");
+                       goto __CATCH;
+               }
+
+               gCurMmsDecodeBuffPos--; // - NULL
+
+               int             length  = 0;
+               if (oneByte > 4) {
+                       length = 4;
+               } else {
+                       length = oneByte;
+               }
+
+               int             i = 0;
+               for (i = 0; i < length; i++)
+                       returner.seg[length - (i+1)] = pData[i];
+
+               *pInteger = returner.integer;
+               *pIntLen  = oneByte + 1;
+       } else if (oneByte >= 0x80)     {
+               /* short integer : WAP-230-WSP-20010118-p, Proposed Version 18 January 2001 (pp.86) */
+               *pInteger = oneByte & 0x7f;
+               *pIntLen  = 1;
+       } else {
+               goto __CATCH;
+       }
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       return true;
+
+__CATCH:
+
+       gCurMmsDecodeBuffPos--;
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       return false;
+}
+
+
+/**
+ * Decode uintvar to 32bit unsigned integer by uintvar length
+ *
+ * @return     1  : Success
+ *                     0  : This is not Value Length type data
+ *                     -1 : Requires System error report
+ */
+static int __MmsDecodeValueLength(FILE *pFile, UINT32 *pValueLength, int totalLength)
+{
+       int length = 0;
+       UINT32 uintvar = 0;
+       UINT8 oneByte = 0;
+
+
+       /*
+        * value-length = short-length | (Length-quote Length)
+        *                              = 0~30             | 31 + Uintvar-length
+        */
+
+       if (pFile == NULL || pValueLength == NULL)
+               goto __CATCH;
+
+       *pValueLength = 0;
+
+       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+               gCurMmsDecodeBuffPos--;
+               goto __CATCH;
+       }
+
+       if (0x00 < oneByte && oneByte < 0x1F) {
+               /* short-length */
+
+               *pValueLength = oneByte;
+               length = 1;
+       } else if (oneByte == 0x1F) {
+               /* Length-quote = 0x1F */
+
+               length = __MmsBinaryDecodeUintvar(pFile, &uintvar, totalLength);
+               if (length == -1) {
+                       MSG_DEBUG("__MmsDecodeValueLength: __MmsBinaryDecodeUintvar fail..\n");
+                       goto __CATCH;
+               }
+               length ++;                                      // + length-quote
+               *pValueLength = uintvar;
+       } else {
+               MSG_DEBUG("__MmsDecodeValueLength: not a value length type data\n");
+               gCurMmsDecodeBuffPos--;
+               return 0;
+       }
+
+       return length;
+
+__CATCH:
+       MSG_DEBUG("__MmsDecodeValueLength: getting data fail\n");
+       return -1;
+}
+
+
+
+/**
+ * Decode uintvar to 32bit unsigned integer by uintvar length
+ *
+ * @return     1  : Success
+ *                     0  : This is not Value Length type data
+ *                     -1 : Requires System error report
+ * @ defference : if there is not length-quote, consider it as short length.
+ */
+static int __MmsDecodeValueLength2(FILE *pFile, UINT32 *pValueLength, int totalLength)
+{
+       int length      = 0;
+       UINT32 uintvar = 0;
+       UINT8 oneByte = 0;
+
+
+       /*
+        * value-length = short-length | (Length-quote Length)
+        *                              = 0~30             | 31 + Uintvar-length
+        */
+
+       if (pFile == NULL || pValueLength == NULL)
+               goto __CATCH;
+
+       *pValueLength = 0;
+
+       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+               gCurMmsDecodeBuffPos--;
+               goto __CATCH;
+       }
+
+       if (0x00 < oneByte && oneByte < 0x1F) {
+               /* short-length */
+
+               *pValueLength = oneByte;
+               length = 1;
+       } else if (oneByte == 0x1F) {
+               /* Length-quote = 0x1F */
+
+               length = __MmsBinaryDecodeUintvar(pFile, &uintvar, totalLength);
+               if (length == -1) {
+                       MSG_DEBUG("__MmsDecodeValueLength2: __MmsBinaryDecodeUintvar fail..\n");
+                       goto __CATCH;
+               }
+               length ++;                                      // + length-quote
+               *pValueLength = uintvar;
+       } else {
+               MSG_DEBUG("__MmsDecodeValueLength2: there is not length-quote, consider it as short length.\n");
+               *pValueLength = oneByte;
+               length = 1;
+       }
+
+       return length;
+
+__CATCH:
+       MSG_DEBUG("__MmsDecodeValueLength2: getting data fail\n");
+       return -1;
+}
+
+
+
+/**
+ * Decode QuotedString
+ *
+ * @param      pEncodedData    [in] QuotedString encoded data
+ * @param      szBuff                  [out] Decoded quoted string
+ * @param      bufLen                  [out] Buffer length
+ * @return     length of quoted string
+ */
+static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen, int totalLength)
+{
+       int iPos = 0;
+       int length = 0;
+       int readBytes = 0;
+       char *pData = NULL;
+       int returnLength = 0;
+
+       /*
+        * Quoted-string = <Octet 34> *TEXT End-of-string
+        * The TEXT encodes an RFC2616 Quoted-string with the enclosing quotation-marks <"> removed
+        */
+
+       if (pFile == NULL || szBuff == NULL || bufLen <= 0)
+               return -1;
+
+       memset(szBuff, 0, bufLen);
+
+       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+                                                                        gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+               MSG_DEBUG("__MmsBinaryDecodeQuotedString: 1. fail to load to buffer \n");
+               goto __CATCH;
+       }
+
+       length = strlen(gpCurMmsDecodeBuff) + 1;        // + NULL
+
+       if (length == 0)
+               goto __RETURN;
+
+       while (length > gMmsDecodeBufLen) {
+               if (gMmsDecodeBufLen <= 0) {
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: gMmsDecodeBufLen <= 0 \n");
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+                                                                               gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2],
+                                                                               gpCurMmsDecodeBuff[3], gpCurMmsDecodeBuff[4]);
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+                                                                               gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7],
+                                                                               gpCurMmsDecodeBuff[8], gpCurMmsDecodeBuff[9]);
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+                                                                               gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12],
+                                                                               gpCurMmsDecodeBuff[13], gpCurMmsDecodeBuff[14]);
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+                                                                               gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17],
+                                                                               gpCurMmsDecodeBuff[18], gpCurMmsDecodeBuff[19]);
+                       goto __CATCH;
+               }
+
+               pData = (char *)malloc(gMmsDecodeBufLen + 1);
+               if (pData == NULL)
+                       goto __CATCH;
+
+               memset(pData, 0, gMmsDecodeBufLen + 1);
+
+               if (_MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false)
+                       goto __CATCH;
+
+               returnLength += gMmsDecodeBufLen;
+
+               if ((bufLen - iPos) > 0) {
+                       readBytes = (gMmsDecodeBufLen < (bufLen - iPos)) ? gMmsDecodeBufLen : (bufLen - iPos);
+                       if (iPos == 0 && (pData[0] == MARK)) {
+                               /* MARK: check first time only */
+
+                               strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1);
+                               iPos += (readBytes - 1);
+                       } else {
+                               strncpy(szBuff + iPos, (char*)pData, readBytes);
+                               iPos += readBytes;
+                       }
+               }
+
+               if (pData) {
+                       free(pData);
+                       pData = NULL;
+               }
+
+               if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+                                                                               gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+                       MSG_DEBUG("__MmsBinaryDecodeText: 2. fail to load to buffer \n");
+                       goto __CATCH;
+               }
+               length = strlen(gpCurMmsDecodeBuff) + 1;        // + NULL
+       }       /* while */
+
+       if (length > 0) {
+               pData = (char *)malloc(length);
+               if (pData == NULL)
+                       goto __CATCH;
+
+               if (_MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false)
+                       goto __CATCH;
+
+               returnLength += length;
+
+               if ((bufLen - iPos) > 0) {
+                       /* read until NULL from raw data, and copy only string */
+                       readBytes = (length < (bufLen - iPos)) ? length : (bufLen - iPos);
+                       if (iPos == 0 && (pData[0] == MARK)) {
+                               /* MARK: check first time only */
+                               strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1);
+                               iPos += (readBytes - 1);
+                       } else {
+                               strncpy(szBuff + iPos, (char*)pData, readBytes - 1);    // + NULL
+                               iPos += readBytes;
+                       }
+               }
+
+               if (pData) {
+                       free(pData);
+                       pData = NULL;
+               }
+       }
+
+       szBuff[bufLen - 1] = '\0';
+
+       return returnLength;
+
+__RETURN:
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       return length;
+
+__CATCH:
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       return -1;
+}
+
+
+/**
+ * Decode Text
+ *
+ * @param      pEncodedData    [in] QuotedString encoded data
+ * @param      szBuff                  [out] Decoded quoted string
+ * @param      bufLen                  [out] Buffer length
+ * @return     length of decode text string
+ */
+static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int totalLength)
+{
+       int length = 0;
+       int readBytes = 0;
+       int iPos = 0;
+       int returnLength = 0;
+       char *pData = NULL;
+       bool bQuote = false;
+       int offset = 0;
+
+       /*
+        * Text-String = [QUOTE]*TEXT end_of_string
+        *                               [QUOTE]*(128~255)\0
+        *                               *(32~126)\0
+        */
+
+       if (pFile == NULL || szBuff == NULL || bufLen <= 0)
+               return -1;
+
+       offset = _MmsGetDecodeOffset();
+       if (offset >= totalLength)
+               goto __RETURN;
+
+       memset(szBuff, 0, bufLen);
+
+       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+                                                                       gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+               MSG_DEBUG("__MmsBinaryDecodeText: 1. fail to load to buffer \n");
+               goto __CATCH;
+       }
+
+       length = strlen(gpCurMmsDecodeBuff) + 1;        // + NULL
+
+       if (length == 0)
+               goto __RETURN;
+
+       while (length > gMmsDecodeBufLen) {
+               if (gMmsDecodeBufLen <= 0) {
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: gMmsDecodeBufLen <= 0 \n");
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2],
+                                                                               gpCurMmsDecodeBuff[3], gpCurMmsDecodeBuff[4]);
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7],
+                                                                               gpCurMmsDecodeBuff[8], gpCurMmsDecodeBuff[9]);
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12],
+                                                                               gpCurMmsDecodeBuff[13], gpCurMmsDecodeBuff[14]);
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17],
+                                                                               gpCurMmsDecodeBuff[18], gpCurMmsDecodeBuff[19]);
+                       goto __CATCH;
+               }
+
+               pData = (char *)malloc(gMmsDecodeBufLen + 1);
+               if (pData == NULL)
+                       goto __CATCH;
+
+               memset(pData, 0, gMmsDecodeBufLen + 1);
+
+               if (_MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false)
+                       goto __CATCH;
+
+               if ((bufLen - iPos) > 0) {
+                       readBytes = (gMmsDecodeBufLen < (bufLen - iPos)) ? gMmsDecodeBufLen : (bufLen - iPos);
+                       if (iPos == 0 && (pData[0] == QUOTE) && (bQuote == false)) {
+                               /* QUOTE: check first time only */
+
+                               strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1);
+                               iPos += (readBytes - 1);
+                               bQuote = true;
+                       } else {
+                               strncpy(szBuff + iPos, (char*)pData, readBytes);
+                               iPos += readBytes;
+                       }
+               }
+
+               if (pData) {
+                       free(pData);
+                       pData = NULL;
+               }
+
+               returnLength += gMmsDecodeBufLen;
+
+               if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+                                                                          gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+                       MSG_DEBUG("__MmsBinaryDecodeText: 2. fail to load to buffer \n");
+                       goto __CATCH;
+               }
+               length = strlen(gpCurMmsDecodeBuff) + 1;        // + NULL
+       }       /* while */
+
+       if (length > 0) {
+               pData = (char *)malloc(length);
+               if (pData == NULL)
+                       goto __CATCH;
+
+               memset(pData, 0, length);
+
+               if (_MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false)
+                       goto __CATCH;
+
+               if ((bufLen - iPos) > 0) {
+                       readBytes = (length < (bufLen - iPos)) ? length : (bufLen - iPos);
+                       if (iPos == 0 && (pData[0] == QUOTE) && (bQuote == false)) {
+                               /* QUOTE: check first time only */
+
+                               strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1);
+                               iPos += (readBytes - 1);
+                               bQuote = true;
+                       } else {
+                               strncpy(szBuff + iPos, (char*)pData, readBytes - 1);    // + NULL
+                               iPos += readBytes;
+                       }
+               }
+
+               if (pData) {
+                       free(pData);
+                       pData = NULL;
+               }
+
+               returnLength += length;         // + NULL
+       }
+
+       szBuff[bufLen - 1] = '\0';
+
+       return returnLength;
+
+__RETURN:
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       szBuff[0] = '\0';
+       length = 0;
+
+       MmsBinaryDecodeMovePointer(pFile, offset, totalLength);
+
+       return length;
+
+__CATCH:
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       return -1;
+}
+
+
+static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
+{
+       int length = 0;
+       int curLen = 0;
+       char *pData = NULL;
+       char *szBuff = NULL;
+       char *szTempPtr = NULL;
+       bool bQuote = false;
+       int offset = 0;
+
+       /*
+        * Text-String = [QUOTE]*TEXT end_of_string
+        *                               [QUOTE]*(128~255)\0
+        *                               *(32~126)\0
+        */
+
+       if (pFile == NULL || pLength == NULL)
+               goto __CATCH;
+
+       *pLength = 0;
+       offset = _MmsGetDecodeOffset();
+       if (offset >= totalLength)
+               goto __RETURN;
+
+       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+                                                                  gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
+               MSG_DEBUG("__MmsBinaryDecodeTextLen: 1. fail to load to buffer \n");
+               goto __CATCH;
+       }
+
+       length = strlen(gpCurMmsDecodeBuff) + 1;
+
+       if (length == 0)
+               goto __CATCH;
+
+       while (length > gMmsDecodeBufLen) {
+               if (gMmsDecodeBufLen <= 0) {
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: gMmsDecodeBufLen <= 0 \n");
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+                                                                               gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2],
+                                                                               gpCurMmsDecodeBuff[3], gpCurMmsDecodeBuff[4]);
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+                                                                               gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7],
+                                                                               gpCurMmsDecodeBuff[8], gpCurMmsDecodeBuff[9]);
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+                                                                               gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12],
+                                                                               gpCurMmsDecodeBuff[13], gpCurMmsDecodeBuff[14]);
+                       MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+                                                                               gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17],
+                                                                               gpCurMmsDecodeBuff[18], gpCurMmsDecodeBuff[19]);
+                       goto __CATCH;
+               }
+
+               pData = (char *)malloc(gMmsDecodeBufLen + 1);
+               if (pData == NULL)
+                       goto __CATCH;
+
+               memset(pData, 0, gMmsDecodeBufLen + 1);
+
+               if (_MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false)
+                       goto __CATCH;
+
+               if (szBuff == NULL)     {
+                       szBuff = (char *)malloc(gMmsDecodeBufLen + 1);
+               } else {
+                       szTempPtr = (char *)realloc(szBuff, curLen + gMmsDecodeBufLen + 1);
+
+                       //NULL pointer check for realloc
+                       if (szTempPtr == NULL) {
+                               goto __CATCH;
+                       } else {
+                               szBuff = szTempPtr;
+                       }
+               }
+               if (szBuff == NULL)
+                       goto __CATCH;
+
+               memset(szBuff + curLen, 0, gMmsDecodeBufLen + 1);
+
+               if (curLen == 0 && (pData[0] == QUOTE) && (bQuote == false)) {
+                       /* QUOTE: check first time only */
+
+                       strncpy(szBuff + curLen, (char*)pData + 1, gMmsDecodeBufLen - 1);
+                       curLen += (gMmsDecodeBufLen - 1);
+                       bQuote = true;
+               } else {
+                       strncpy(szBuff + curLen, (char*)pData, gMmsDecodeBufLen);
+                       curLen += gMmsDecodeBufLen;
+               }
+
+               if (pData) {
+                       free(pData);
+                       pData = NULL;
+               }
+
+               *pLength += gMmsDecodeBufLen;
+
+               if (MsgLoadDataToDecodeBuffer(pFile,
+                                                          &gpCurMmsDecodeBuff,
+                                                          &gCurMmsDecodeBuffPos,
+                                                          &gMmsDecodeCurOffset,
+                                                          gpMmsDecodeBuf1,
+                                                          gpMmsDecodeBuf2,
+                                                          gMmsDecodeMaxLen,
+                                                          &gMmsDecodeBufLen,
+                                                          totalLength) == false)
+               {
+                       MSG_DEBUG("__MmsBinaryDecodeText: 2. fail to load to buffer \n");
+                       goto __CATCH;
+               }
+               length = strlen(gpCurMmsDecodeBuff) + 1;
+       }       /* while */
+
+       if (length > 0) {
+               pData = (char *)malloc(length);
+               if (pData == NULL) {
+                       goto __CATCH;
+               }
+
+               if (_MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false) {
+                       goto __CATCH;
+               }
+
+               if (szBuff == NULL) {
+                       szBuff = (char *)malloc(length);
+               } else {
+                       szTempPtr = (char *)realloc(szBuff, curLen + length);
+
+                       //NULL pointer check for realloc
+                       if (szTempPtr == NULL)
+                               goto __CATCH;
+                       else
+                               szBuff = szTempPtr;
+               }
+
+               if (szBuff == NULL) {
+                       goto __CATCH;
+               }
+
+               memset(szBuff + curLen, 0, length);
+
+               if (curLen == 0 && (pData[0] == QUOTE)  && (bQuote == false)) {
+                       /* QUOTE: check first time only */
+
+                       strncpy(szBuff + curLen, (char*)pData + 1, length - 2);
+                       curLen += (length - 1);
+                       bQuote = true;
+               } else {
+                       strncpy(szBuff + curLen, (char*)pData, length - 1);
+                       curLen += length;
+               }
+
+               if (pData) {
+                       free(pData);
+                       pData = NULL;
+               }
+
+               *pLength += length;             // + NULL
+       }
+
+       return szBuff;
+
+__RETURN:
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       *pLength = 1;
+
+       MmsBinaryDecodeMovePointer(pFile, offset, totalLength);
+
+       return szBuff;
+
+__CATCH:
+
+       if (szBuff) {
+               free(szBuff);
+               szBuff = NULL;
+       }
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       return NULL;
+}
+
+
+/**
+ * Decode Charset
+ *
+ * @param      pEncodedData    [in] QuotedString encoded data
+ * @param      nCharSet                [out] Decoded character set
+ * @return     length of charset value
+ */
+static bool __MmsBinaryDecodeCharset(FILE *pFile, UINT32 *nCharSet, int *pCharSetLen, int totalLength)
+{
+       UINT32 integer = 0;
+
+       /*
+        * Charset v1.1 0x01 Well-known-charset
+        *                                       Well-known-charset = Any-charset | Integer-value
+        *                                              ; Both are encoded using values from
+        *                                                Character Set Assignments table in Assigned Numbers
+        *                                       Any-charset = <Octet 128>
+        *                                              ; Equivalent to the special RFC2616 charset value Â¡Â°*¡±
+        */
+
+       if (pFile == NULL || nCharSet == NULL || pCharSetLen == NULL)
+               return false;
+
+       if (__MmsBinaryDecodeInteger(pFile, &integer, pCharSetLen, totalLength) == false) {
+               MSG_DEBUG("__MmsBinaryDecodeCharset : __MmsBinaryDecodeInteger fail...\n");
+               goto __CATCH;
+       }
+
+       if (integer == 0) {
+               /* AnyCharSet : return MSG_CHARSET_UTF8 */
+               *nCharSet = MSG_CHARSET_UTF8;
+               return true;
+       }
+
+       *nCharSet = _MmsGetBinaryType(MmsCodeCharSet, (UINT16)integer);
+
+       if (*nCharSet == MIME_UNKNOWN) {
+               MSG_DEBUG("__MmsBinaryDecodeCharset : _MmsGetBinaryType fail..\n");
+               *nCharSet = MSG_CHARSET_UNKNOWN;
+       }
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+
+/**
+ * Decode EncodedString
+ *
+ * @param      pEncodedData    [in] QuotedString encoded data
+ * @param      szBuff                  [out] Decoded string buffer
+ * @param      bufLen                  [in]  Decoded buffer length
+ * @return     length of decoded string length
+ */
+static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen, int totalLength)
+{
+       UINT32 valueLength = 0;
+       UINT32 charSet = 0;
+       int charSetLen = 0;
+       int nChar = 0;
+       int nRead2 = 0;
+       int nByte = 0;
+       int nTemp = 0;
+       char *pData = NULL;
+       char *pTempData = NULL;
+       unsigned short *mszTempStr = NULL;
+       char *pConvertedStr = NULL;
+       char *pNewData = NULL;
+
+
+       MSG_DEBUG("__MmsBinaryDecodeEncodedString: decode string..\n");
+
+       if (pFile == NULL || szBuff == NULL || bufLen <= 0) {
+               MSG_DEBUG("__MmsBinaryDecodeEncodedString: invalid file or buffer\n");
+               goto __CATCH;
+       }
+
+       /*
+        * Encoded_string_value = Text-string | Value-length Char-set Text-String
+        *                                                Text-string    = [Quote]*TEXT End-of-string
+        *                                                Value-length   = 0 ~ 31
+        */
+
+       memset(szBuff, 0, bufLen);
+
+       switch (__MmsDecodeValueLength(pFile, &valueLength, totalLength)) {
+       case -1:
+               goto __CATCH;
+
+       case 0:
+
+               /* Text-string = [Quote]*TEXT End-of-string */
+
+               if (__MmsBinaryDecodeText(pFile, szBuff, bufLen, totalLength) < 0) {
+                       MSG_DEBUG("__MmsBinaryDecodeEncodedString : 1. __MmsBinaryDecodeText fail.\n");
+                       goto __CATCH;
+               }
+               break;
+
+       default:
+
+               /* Value-length Charset Text_string */
+
+               if (__MmsBinaryDecodeCharset(pFile, &charSet, &charSetLen, totalLength) == false) {
+                       MSG_DEBUG("__MmsBinaryDecodeEncodedString : __MmsBinaryDecodeCharset error\n");
+                       goto __CATCH;                   /* (valueLength + valueLengthLen) */
+               }
+
+               nTemp = __MmsBinaryDecodeText(pFile, szBuff, bufLen, totalLength);
+               if (nTemp < 0) {
+                       /* There can be some error in data - no NULL -> try again with value length */
+
+                       pData = (char *)malloc(valueLength - charSetLen);
+                       if (pData == NULL) {
+                               MSG_DEBUG("__MmsBinaryDecodeEncodedString : pData alloc fail.\n");
+                               goto __CATCH;
+                       }
+
+                       if (_MmsBinaryDecodeGetLongBytes(pFile, pData, valueLength - charSetLen, totalLength) == false) {
+                               MSG_DEBUG("__MmsBinaryDecodeEncodedString : _MmsBinaryDecodeGetLongBytes fail.\n");
+                               goto __CATCH;
+                       }
+
+                       strncpy(szBuff, pData, bufLen - 1);
+               }
+
+
+               /* fixme: charset transformation */
+               switch (charSet) {
+               case MSG_CHARSET_UTF16:
+               case MSG_CHARSET_USC2:
+
+                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_USC2 \n");
+
+                       nTemp = strlen(szBuff);
+                       pTempData = (char *)malloc(nTemp + 1);
+                       if (pTempData == NULL) {
+                               MSG_DEBUG("__MmsBinaryDecodeEncodedString: Memory Full \n");
+                               goto __CATCH;
+                       }
+
+                       memset(pTempData, 0, nTemp + 1);
+                       memcpy(pTempData, szBuff, nTemp + 1);
+
+                       if (((UINT8)pTempData[0]) == 0xFF && ((UINT8)pTempData[1]) == 0xFE) {
+                               if ((nChar = (nTemp / 2 - 1)) <= 0)     {
+                                       MSG_DEBUG("__MmsBinaryDecodeEncodedString(%d) : nChar is invalid value (%d), charset(%d)\n", __LINE__, nChar, charSet);
+                                       goto __CATCH ;
+                               }
+
+                               mszTempStr = (unsigned short*) malloc(nChar * sizeof(unsigned short));
+                               if (mszTempStr == NULL) {
+                                       MSG_DEBUG("MmsGetMediaPartData : 1. Memory Full !!! \n");
+                                       goto __CATCH;
+                               }
+
+                               memcpy(mszTempStr, ((unsigned short*)pTempData + 1), nChar * sizeof(unsigned short));
+
+                               nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTempData + 1), nChar);
+
+                               pConvertedStr = (char *)malloc(nByte + 1);
+                               if (pConvertedStr)
+                                       MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar);
+                       } else {
+                               if ((nChar = (nTemp / 2)) <= 0) {
+                                       MSG_DEBUG("__MmsBinaryDecodeEncodedString(%d) : nChar is invalid value (%d), charset(%d)\n", __LINE__, nChar, charSet);
+                                       goto __CATCH ;
+                               }
+
+                               mszTempStr = (unsigned short*) malloc(nChar * sizeof(unsigned short));
+                               if (mszTempStr == NULL) {
+                                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: 2. Memory Full !!! \n");
+                                       goto __CATCH;
+                               }
+
+                               memcpy(mszTempStr, ((unsigned short*)pTempData), nChar * sizeof(unsigned short));
+
+                               nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTempData), nChar);
+
+                               pConvertedStr = (char *)malloc(nByte + 1);
+                               if (pConvertedStr != NULL)
+                                       MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar);
+                       }
+
+                       if (pConvertedStr != NULL) {
+                               pNewData = pConvertedStr;
+                               nRead2 = nByte;
+
+                               strncpy(szBuff, pNewData, bufLen - 1);
+                       }
+
+                       break;
+
+               case MSG_CHARSET_US_ASCII:
+
+                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_US_ASCII \n");
+
+               case MSG_CHARSET_UTF8:
+
+                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_UTF8 or Others \n");
+
+                       pNewData = pTempData;
+                       nRead2 = nTemp;
+
+                       break;
+
+               case MSG_CHARSET_ISO_8859_7: /* Greek */
+
+                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_ISO_8859_7 \n");
+
+                       nTemp = strlen(szBuff);
+                       pTempData = (char *)malloc(nTemp + 1);
+                       if (pTempData == NULL)
+                       {
+                               MSG_DEBUG("__MmsBinaryDecodeEncodedString: Memory Full \n");
+                               goto __CATCH;
+                       }
+
+                       memset(pTempData, 0 , nTemp + 1);
+                       memcpy(pTempData, szBuff, nTemp + 1);
+
+                       nByte = MsgGetLatin72UTFCodeSize((unsigned char*)pTempData, nTemp);
+                       pConvertedStr = (char *)malloc(nByte + 1);
+
+                       if (pConvertedStr != NULL) {
+                               MsgLatin7code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTempData, nTemp);
+
+                               pNewData = pConvertedStr;
+                               nRead2 = nByte;
+
+                               strncpy(szBuff, pNewData, bufLen - 1);
+                       }
+
+                       break;
+
+               case MSG_CHARSET_ISO_8859_9: /* Turkish */
+
+                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_ISO_8859_9 \n");
+
+                       nTemp = strlen(szBuff);
+                       pTempData = (char *)malloc(nTemp + 1);
+                       if (pTempData == NULL) {
+                               MSG_DEBUG("__MmsBinaryDecodeEncodedString: Memory Full \n");
+                               goto __CATCH;
+                       }
+
+                       memset(pTempData, 0 , nTemp + 1);
+                       memcpy(pTempData, szBuff, nTemp + 1);
+
+                       nByte = MsgGetLatin52UTFCodeSize((unsigned char*)pTempData, nTemp);
+                       pConvertedStr = (char *)malloc(nByte + 1);
+
+                       if (pConvertedStr != NULL) {
+                               MsgLatin5code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTempData, nTemp);
+
+                               pNewData = pConvertedStr;
+                               nRead2 = nByte;
+
+                               strncpy(szBuff, pNewData, bufLen - 1);
+                       }
+
+                       break;
+
+               default:
+
+                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: Other charsets \n");
+
+                       nTemp = strlen(szBuff);
+                       pTempData = (char *)malloc(nTemp + 1);
+                       if (pTempData == NULL) {
+                               MSG_DEBUG("__MmsBinaryDecodeEncodedString: Memory Full \n");
+                               goto __CATCH;
+                       }
+
+                       memset(pTempData, 0, nTemp + 1);
+                       memcpy(pTempData, szBuff, nTemp + 1);
+
+                       nByte = MsgGetLatin2UTFCodeSize((unsigned char*)pTempData, nTemp);
+                       pConvertedStr = (char *)malloc(nByte + 1);
+
+                       if (pConvertedStr != NULL) {
+                               MsgLatin2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTempData, nTemp);
+
+                               pNewData = pConvertedStr;
+                               nRead2 = nByte;
+
+                               strncpy(szBuff, pNewData, bufLen - 1);
+                       }
+
+                       break;
+
+               } //switch (charset)
+
+       } //switch (__MmsDecodeValueLength....)
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       if (pTempData) {
+               free(pTempData);
+               pTempData = NULL;
+       }
+
+       if (mszTempStr) {
+               free(mszTempStr);
+               mszTempStr = NULL;
+       }
+
+       if (pConvertedStr) {
+               free(pConvertedStr);
+               pConvertedStr = NULL;
+       }
+
+
+       return true;
+
+__CATCH:
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       if (pTempData) {
+               free(pTempData);
+               pTempData = NULL;
+       }
+
+       if (mszTempStr) {
+               free(mszTempStr);
+               mszTempStr = NULL;
+       }
+
+       if (pConvertedStr) {
+               free(pConvertedStr);
+               pConvertedStr = NULL;
+       }
+
+       return false;
+}
+
+
+
+/**
+ * Decode Encoded Addresses
+ *
+ * @param      pEncodedData    [in] QuotedString encoded data
+ * @param      pAddrLength             [out] Decoded address length
+ * @return     Decoded address list
+ */
+MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength)
+{
+       UINT32 valueLength      = 0;
+       UINT32 charSet          = 0;
+       int charSetLen  = 0;
+       int textLength  = 0;
+       char *pAddrStr  = NULL;
+       MsgHeaderAddress *pAddr = NULL;
+
+       MSG_DEBUG("__MmsDecodeEncodedAddress: decoding address..\n");
+
+       if (pFile == NULL) {
+               MSG_DEBUG("__MmsDecodeEncodedAddress: invalid file or buffer\n");
+               goto __CATCH;
+       }
+
+       /*
+        * Encoded_string_value = Text-string | Value-length Char-set Text-String
+        *                                                Text-string    = [Quote]*TEXT End-of-string
+        *                                                Value-length   = 0 ~ 31
+        */
+
+       switch (__MmsDecodeValueLength(pFile, &valueLength, totalLength)) {
+       case -1:
+               goto __CATCH;
+
+       case 0:
+
+               /* Text-string = [Quote]*TEXT End-of-string */
+
+               textLength = 0;
+               pAddrStr   = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+               if (pAddrStr == NULL) {
+                       MSG_DEBUG("__MmsDecodeEncodedAddress : 1. __MmsBinaryDecodeText2 fail.\n");
+                       goto __CATCH;
+               }
+               break;
+
+       default:
+
+               /* Value-length Charset Text_string */
+
+               if (__MmsBinaryDecodeCharset(pFile, &charSet, &charSetLen, totalLength) == false) {
+                       MSG_DEBUG("__MmsDecodeEncodedAddress : __MmsBinaryDecodeCharset error\n");
+                       goto __CATCH;
+               }
+
+               textLength = 0;
+               pAddrStr   = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+               if (pAddrStr == NULL) {
+                       /* There can be some error in data - no NULL -> try again with value length */
+
+                       pAddrStr = (char *)malloc(valueLength - charSetLen);
+                       if (pAddrStr == NULL) {
+                               MSG_DEBUG("__MmsDecodeEncodedAddress : pData alloc fail.\n");
+                               goto __CATCH;
+                       }
+
+                       if (_MmsBinaryDecodeGetLongBytes(pFile, pAddrStr, valueLength - charSetLen, totalLength) == false) {
+                               MSG_DEBUG("__MmsDecodeEncodedAddress : _MmsBinaryDecodeGetLongBytes fail.\n");
+                               goto __CATCH;
+                       }
+               }
+
+               /* fixme: charset transformation */
+
+               break;
+       }
+
+       pAddr = (MsgHeaderAddress *)malloc(sizeof(MsgHeaderAddress));
+       if (pAddr == NULL)
+               goto __CATCH;
+
+       memset(pAddr, 0, sizeof(MsgHeaderAddress));
+       pAddr->szAddr = pAddrStr;
+
+       return pAddr;
+
+__CATCH:
+
+       if (pAddrStr) {
+               free(pAddrStr);
+               pAddrStr = NULL;
+       }
+
+       return NULL;
+}
+
+
+/**
+ * Decode Encoded Pointer String
+ *
+ * @param      pEncodedData    [in] Long integer encoded data
+ * @param      pLongInteger    [out] Decoded long integer
+ * @return     Decoded address list
+ */
+static bool __MmsDecodeLongInteger(FILE *pFile, UINT32 *pLongInteger, int totalLength)
+{
+       UINT8 oneByte = 0;
+
+       /*
+        * Long-integer = Short-length Multi-octet-integer
+        *                                Short-length = 0~30
+        *                                Multi-octet-integer
+        */
+
+       if (pFile == NULL || pLongInteger == NULL)
+               return false;
+
+       *pLongInteger = 0;
+
+       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
+               goto __CATCH;
+
+       if (oneByte > 31)
+               goto __CATCH;
+
+       *pLongInteger = __MmsHeaderDecodeIntegerByLength(pFile, oneByte, totalLength);
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+/*
+ * @param      pEncodedData    [in] filename encoded data
+ * @param      szBuff                  [out] filename output buffer
+ * @param      fullLength              [in] full filename length
+ * @param      bufLen                  [in] buffer length
+ * CAUTION: bufLen - 1
+ */
+static int __MmsDecodeGetFilename(FILE *pFile, char *szBuff, int bufLen, int totalLength)
+{
+       char *pUTF8Buff = NULL;
+       char *pLatinBuff = NULL;
+       char *pExt = NULL;
+       char *szSrc = NULL;
+       char *szSrc2 = NULL;
+       int length = 0;
+       int textLength = 0;
+
+       char *pTmpBuff = NULL;
+
+       memset (szBuff, 0, bufLen);
+
+       textLength = 0;
+       pLatinBuff  = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
+
+       //remove ""
+       if (pLatinBuff) {
+               szSrc = MsgRemoveQuoteFromFilename(pLatinBuff);
+               if (szSrc) {
+                       strcpy(pLatinBuff, szSrc);
+                       free(szSrc);
+                       szSrc = NULL;
+               }
+
+               szSrc2 = MsgChangeHexString(pLatinBuff);
+               if (szSrc2) {
+                       strcpy(pLatinBuff, szSrc2);
+                       free(szSrc2);
+                       szSrc2 = NULL;
+               }
+
+               if (MsgIsUTF8String((unsigned char*)pLatinBuff, strlen(pLatinBuff)) == false) {
+                       length = strlen(pLatinBuff);
+
+                       int             utf8BufSize = 0;
+                       utf8BufSize = MsgGetLatin2UTFCodeSize((unsigned char*)pLatinBuff, length);
+                       pUTF8Buff = (char *)malloc(utf8BufSize + 1);
+                       if (pUTF8Buff == NULL) {
+                               MSG_DEBUG("__MmsDecodeGetFilename: pUTF8Buff alloc fail \n");
+                               goto __CATCH;
+                       }
+
+                       if (MsgLatin2UTF ((unsigned char*)pUTF8Buff, utf8BufSize + 1, (unsigned char*)pLatinBuff, length) < 0) {
+                               MSG_DEBUG("__MmsDecodeGetFilename: MsgLatin2UTF fail \n");
+                               goto __CATCH;
+                       }
+                       free(pLatinBuff);
+                       pLatinBuff = NULL;
+               } else {
+                       pTmpBuff = _MsgDecodeText(pLatinBuff);
+                       pUTF8Buff = pTmpBuff;
+                       free (pLatinBuff);
+                       pLatinBuff = NULL;
+               }
+       }
+
+       if (pUTF8Buff) {
+               /*
+                * keeping extension
+                * it should be kept extention even if the file name is shorten
+                */
+
+               length = strlen(pUTF8Buff);
+               if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) {
+                       int nameLength  = 0;
+                       nameLength = (length < bufLen) ? (length - strlen(pExt)) : (bufLen - strlen(pExt));
+                       strncpy(szBuff, pUTF8Buff, nameLength);
+                       strcat (szBuff, pExt);
+               } else {
+                       strncpy(szBuff, pUTF8Buff, bufLen - 1);
+               }
+               free(pUTF8Buff);
+               pUTF8Buff = NULL;
+
+               return textLength;
+       }
+
+__CATCH:
+
+       if (pLatinBuff) {
+               free(pLatinBuff);
+               pLatinBuff = NULL;
+       }
+
+       if (pUTF8Buff) {
+               free(pUTF8Buff);
+               pUTF8Buff = NULL;
+       }
+
+       return -1;
+}
+
+
+/* ==========================================================
+
+          T  E  X  T         D  E  C  O  D  I  N  G
+
+   ==========================================================*/
+
+
+bool MmsTextDecodeMsgBody(FILE *pFile)
+{
+       MSG_DEBUG("MmsTextDecodeMsgBody: \n");
+       return false;
+}
+
+bool __MmsTextDecodeMsgHeader(FILE *pFile)
+{
+       return true;
+}
+
+
+/* ==========================================================
+
+          M  M  S        D  E  C  O  D  I  N  G
+
+   ==========================================================*/
+
+//  to get message body this function should be modified from message raw file.
+bool _MmsReadMsgBody(MSG_MESSAGE_ID_T msgID, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath)
+{
+       FILE *pFile     = NULL;
+       MmsMsg *pMsg = NULL;
+       MsgMultipart *pMultipart = NULL;
+       int nSize = 0;
+       char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, };
+       char szTempMediaDir[MSG_FILEPATH_LEN_MAX] = {0, };
+       int attachmax = MSG_ATTACH_MAX;
+
+       MSG_DEBUG("_MmsReadMsgBody: start read msg(msgID=%d)\n", msgID);
+
+       MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+       memset(pMsg, 0, sizeof(MmsMsg));
+
+       _MmsInitHeader();
+
+       if (bRetrieved && (retrievedPath != NULL)) {
+               strncpy(szFullPath, retrievedPath, (strlen(retrievedPath) > MSG_FILEPATH_LEN_MAX ? MSG_FILEPATH_LEN_MAX:strlen(retrievedPath)));
+       } else {
+               MmsPluginStorage::instance()->getMmsRawFilePath(msgID, szFullPath);
+       }
+
+       pMsg->msgID = msgID;
+
+       /*      read from MMS raw file  */
+       if (szFullPath != NULL)
+               strncpy(pMsg->szFileName, szFullPath + strlen(MSG_DATA_PATH), strlen(szFullPath + strlen(MSG_DATA_PATH)));
+
+       MSG_DEBUG("szFullPath = (%s)", szFullPath);
+
+       if (MsgGetFileSize(szFullPath, &nSize) == false) {
+               MSG_DEBUG("MsgGetFileSize: failed");
+               goto __CATCH;
+       }
+
+       pFile = MsgOpenFile(szFullPath, "rb");
+
+       if (pFile == NULL) {
+               MSG_DEBUG("_MmsReadMsgBody: invalid mailbox\n");
+               goto __CATCH;
+       }
+
+       _MmsRegisterDecodeBuffer(gszMmsLoadBuf1, gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX);
+
+       if (MmsBinaryDecodeMsgHeader(pFile, nSize) == false) {
+               MSG_DEBUG("_MmsReadMsgBody: MmsBinaryDecodeMsgHeader fail...\n");
+               goto __CATCH;
+       }
+
+#ifdef __SUPPORT_DRM__
+       if (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_FINISH)
+               MmsDrm2SetConvertState(MMS_DRM2_CONVERT_NONE);  //initialize convertState
+#endif
+
+       if (MmsBinaryDecodeMsgBody(pFile, szFullPath, nSize) == false) {
+               MSG_DEBUG("_MmsReadMsgBody: MmsBinaryDecodeMsgBody fail\n");
+               goto __CATCH;
+       }
+
+#ifdef __SUPPORT_DRM__
+       if (MmsDrm2GetConvertState() == MMS_DRM2_CONVERT_REQUIRED) {
+               MSG_DEBUG("_MmsReadMsgBody: MmsDrm2GetConvertState returns MMS_DRM2_CONVERT_REQUIRED.\n");
+               goto RETURN;
+       }
+#endif
+
+       /* Set mmsHeader.msgType & msgBody to pMsg ----------- */
+
+       pMsg->mmsAttrib.contentType = (MsgContentType)mmsHeader.msgType.type;
+
+       memcpy(&(pMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType));
+       memcpy(&(pMsg->msgBody), &(mmsHeader.msgBody), sizeof(MsgBody));
+
+       if (pMsg->msgBody.pPresentationBody) {
+               if(MsgFseek(pFile, pMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0)
+                       goto __CATCH;
+
+               pMsg->msgBody.pPresentationBody->body.pText = (char *)malloc(pMsg->msgBody.pPresentationBody->size + 1);
+               if (pMsg->msgBody.pPresentationBody->body.pText == NULL)
+                       goto __CATCH;
+
+               memset(pMsg->msgBody.pPresentationBody->body.pText, 0, pMsg->msgBody.pPresentationBody->size + 1);
+
+               ULONG nRead = 0;
+               nRead = MsgReadFile(pMsg->msgBody.pPresentationBody->body.pText, sizeof(char), pMsg->msgBody.pPresentationBody->size, pFile);
+               if (nRead == 0)
+                       goto __CATCH;
+
+       }
+
+       MsgCloseFile(pFile);
+       pFile = NULL;
+
+       /* nPartCount */
+       pMsg->nPartCount = 0;
+
+       if (MsgIsMultipart(mmsHeader.msgType.type) == true) {
+               pMultipart = pMsg->msgBody.body.pMultipart;
+               while (pMultipart) {
+                       pMsg->nPartCount++;
+
+                       if (pMultipart->type.type == MIME_TEXT_PLAIN)
+                               attachmax++;
+
+                       if ((mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED)||(mmsHeader.msgType.type == MIME_MULTIPART_MIXED)) {
+                               if ((pMsg->nPartCount >= attachmax)&&(pMultipart->pNext != NULL)) {
+                                       _MsgFreeBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type);
+
+                                       free(pMultipart->pNext->pBody);
+                                       pMultipart->pNext->pBody= NULL;
+
+                                       free(pMultipart->pNext);
+
+                                       pMultipart->pNext = NULL;
+                                       break;
+                               }
+                       }
+                       pMultipart = pMultipart->pNext;
+               }
+       } else {
+               if (pMsg->msgBody.size > 0)
+                       pMsg->nPartCount++;
+       }
+
+       /*      make temporary  */
+       snprintf(szTempMediaDir, MSG_FILEPATH_LEN_MAX, MSG_DATA_PATH"%s.dir", pMsg->szFileName);
+
+       ///////////////////////////////////////////////
+       // call before processing urgent event.
+       //_MmsInitHeader();
+       //_MmsUnregisterDecodeBuffer();
+       ///////////////////////////////////////////////
+
+       if (MsgIsMultipart(pMsg->msgType.type) == true) {
+               int partIndex = 0;
+               pMultipart = pMsg->msgBody.body.pMultipart;
+
+               if (bSavePartsAsTempFiles) {
+                       if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
+                               if (errno == EEXIST) {
+                                       MSG_DEBUG("The %s already exists", szTempMediaDir);
+                               } else {
+                                       MSG_DEBUG("Fail to Create Dir [%s]", szTempMediaDir);
+                                       goto __CATCH;
+                               }
+                       }
+               }
+
+               while (pMultipart) {
+
+                       if (_MmsMultipartSaveAsTempFile(&pMultipart->type, pMultipart->pBody,
+                                                                                       (char*)MSG_DATA_PATH, pMsg->szFileName, partIndex, bSavePartsAsTempFiles) == false)
+                               goto __CATCH;
+
+                       pMultipart = pMultipart->pNext;
+                       partIndex ++;
+               }
+
+       } else { //single part
+               if (pMsg->nPartCount > 0) {
+
+                       if (bSavePartsAsTempFiles) {
+                               if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
+                                       if (errno == EEXIST) {
+                                               MSG_DEBUG("The %s already exists", szTempMediaDir);
+                                       } else {
+                                               MSG_DEBUG("Fail to Create Dir [%s]", szTempMediaDir);
+                                               goto __CATCH;
+                                       }
+                               }
+                       }
+
+                       if (_MmsMultipartSaveAsTempFile( &pMsg->msgType, &pMsg->msgBody,
+                                                                                       (char*)MSG_DATA_PATH, pMsg->szFileName, 0, bSavePartsAsTempFiles) == false)
+                               goto __CATCH;
+               }
+       }
+       MSG_DEBUG("****   _MmsReadMsgBody:  E  N  D   (Success)  ***\n");
+       return true;
+
+#ifdef __SUPPORT_DRM__
+
+RETURN:
+
+       if (pFile != NULL) {
+               MsgCloseFile(pFile);
+               pFile = NULL;
+       }
+
+       return false;
+
+#endif
+
+__CATCH:
+
+       _MmsInitHeader();
+       _MmsUnregisterDecodeBuffer();
+
+       if (pFile != NULL) {
+               MsgCloseFile(pFile);
+               pFile = NULL;
+       }
+
+#ifdef __SUPPORT_DRM__
+       _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
+#endif
+
+       _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
+       MSG_DEBUG("_MmsReadMsgBody:    E  N  D    (fail)    ******************** \n");
+
+       return false;
+}
+
+
+bool MsgFreeHeaderAddress(MsgHeaderAddress *pAddr)
+{
+       MsgHeaderAddress *pTempAddr = NULL;
+
+       while (pAddr != NULL) {
+               pTempAddr = pAddr;
+               pAddr = pAddr->pNext;
+
+               if (pTempAddr->szAddr) {
+                       free(pTempAddr->szAddr);
+                       pTempAddr->szAddr = NULL;
+               }
+
+               free(pTempAddr);
+               pTempAddr = NULL;
+       }
+
+       return true;
+}
+
+bool MsgCheckFileNameHasInvalidChar(char *szName)
+{
+       int     strLen = 0;
+       int i = 0;
+
+       strLen = strlen(szName);
+
+       for (i=0; i<strLen; i++) {
+               if (__MsgIsInvalidFileNameChar(szName[i]))
+                       return true;
+       }
+
+       return false;
+}
+
+bool _MsgReplaceInvalidFileNameChar(char *szInText, char replaceChar)
+{
+       int nCount = 0;
+       int totalLength = 0;
+
+       totalLength = strlen(szInText);
+
+       while ((*(szInText+nCount) != '\0') && (nCount < totalLength)) {
+               if (0x0001 <= *(szInText+nCount) && *(szInText+nCount) <= 0x007F) {
+                       if (__MsgIsInvalidFileNameChar(szInText[nCount]))
+                               *(szInText+nCount) = replaceChar;
+
+                       nCount += 1;
+               } else {
+                       nCount += 2;
+               }
+       }
+
+       return true;
+}
+
+char *_MsgGetStringUntilDelimiter(char *pszString, char delimiter)
+{
+       char *pszBuffer = NULL;
+       char *pszStrDelimiter = NULL;
+       int     bufLength = 0;
+
+       if (!pszString) {
+               MSG_DEBUG("_MsgGetStringUntilDelimiter: pszString == NULL \n");
+               return NULL;
+       }
+
+       if ((pszStrDelimiter = strchr(pszString, delimiter)) == NULL) {
+               MSG_DEBUG("_MsgGetStringUntilDelimiter: There is no %c in %s. \n", delimiter, pszString);
+               return NULL;
+       }
+
+       bufLength = pszStrDelimiter - pszString;
+
+       if ((pszBuffer = (char*)malloc (bufLength + 1)) == NULL) {
+               MSG_DEBUG("malloc is failed");
+               return NULL;
+       }
+       memset(pszBuffer, 0, bufLength + 1) ;
+
+       strncat(pszBuffer, pszString, bufLength);
+
+       return pszBuffer;
+}
+
+char *MsgChangeHexString(char *pOrg)
+{
+       char *pNew = NULL;
+       char szBuf[10] = {0,};
+       char OneChar;
+       int cLen = 0;
+       int cIndex =0;
+       int index = 0;
+
+       if (pOrg == NULL)
+               return false;
+
+       cLen = strlen(pOrg);
+
+       pNew = (char *)malloc(cLen + 1);
+       if (pNew == NULL)
+               return NULL;
+
+       memset(pNew, 0, cLen + 1);
+
+       for (cIndex = 0; cIndex< cLen ; cIndex++) {
+               if (pOrg[cIndex] == '%') {
+                       if (pOrg[cIndex+1] != 0 && pOrg[cIndex+2] != 0)         {
+                               snprintf(szBuf, sizeof(szBuf), "%c%c", pOrg[cIndex+1], pOrg[cIndex+2]); // read two chars after '%'
+
+                               if (MsgIsHexChar(szBuf) == true) { // check the two character is between  0 ~ F
+                                       OneChar = _MsgConvertHexValue(szBuf);
+
+                                       pNew[index] = OneChar;
+                                       index++;
+                                       cIndex+= 2;
+                                       continue;
+                               }
+                       }
+               }
+               pNew[index++] = pOrg[cIndex];
+       }
+       return pNew;
+}
+
+bool _MsgParseParameter(MsgType *pType, char *pSrc)
+{
+       char *pName = NULL;
+       char *pValue = NULL;
+       char *pDec = NULL;
+       char *pTest = NULL;
+       char *pNextParam = NULL;
+       char *pExt = NULL;
+       int nameLen = 0;
+       int count;
+       char *pTempNextParam = NULL;
+       char *pCh = NULL;
+       char *szSrc = NULL;
+       char *pUTF8Buff = NULL;
+
+       while (pSrc != NULL) {
+               pSrc = _MsgSkipWS(pSrc);
+               if (pSrc == NULL) {
+                       /* End of parse parameter */
+                       return true;
+               }
+
+               pNextParam = NULL;
+               pTempNextParam = strchr(pSrc, MSG_CH_SEMICOLON);
+               pCh = pSrc;
+
+               if (*pCh == MSG_CH_QUOT) {
+                       count = 1;
+               } else {
+                       count = 0;
+               }
+
+               pCh++;
+               for (; pCh<=pTempNextParam ; pCh++) {
+                       if (*pCh == MSG_CH_QUOT)
+                               if (*(pCh - 1) != '\\')
+                                       count++;
+               }
+
+               if (count%2 == 0)
+                       pNextParam = pTempNextParam;
+
+               if (pNextParam)
+                       *pNextParam++ = MSG_CH_NULL;
+
+               if ((pName = strchr(pSrc, MSG_CH_EQUAL)) != NULL) {
+                       *pName++ = MSG_CH_NULL;
+
+                       if ((pValue = strchr(pName, MSG_CH_QUOT))!= NULL) {
+                               *pValue++ = MSG_CH_NULL;
+
+                               if ((pTest = strchr(pValue, MSG_CH_QUOT)) != NULL)
+                                       *pTest = MSG_CH_NULL;
+
+                               pDec = _MsgDecodeText(pValue);          // Api is to long, consider Add to another file (MsgMIMECodec.c)
+                       } else {
+                               pDec = _MsgDecodeText(pName);
+                       }
+
+                       switch (_MsgGetCode(MSG_PARAM, pSrc)) {
+                       case MSG_PARAM_BOUNDARY:
+
+                               /* RFC 822: boundary := 0*69<bchars> bcharsnospace */
+
+                               memset (pType->param.szBoundary, 0, MSG_BOUNDARY_LEN + 1);
+                               strncpy(pType->param.szBoundary, pDec, MSG_BOUNDARY_LEN);
+                               MSG_DEBUG("_MsgParseParameter: szBoundary = %s \n", pType->param.szBoundary);
+                               break;
+
+                       case MSG_PARAM_CHARSET:
+                               pType->param.charset = _MsgGetCode(MSG_CHARSET, pDec);
+
+                               if (pType->param.charset == INVALID_HOBJ)
+                                       pType->param.charset = MSG_CHARSET_UNKNOWN;
+
+                               MSG_DEBUG("_MsgParseParameter: type = %d    [charset] = %d \n", pType->type, pType->param.charset);
+                               break;
+
+                       case MSG_PARAM_NAME:
+
+                               memset (pType->param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1);
+
+                               pUTF8Buff = MsgConvertLatin2UTF8FileName(pDec);
+
+                               if (pUTF8Buff) {
+                                       if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) {
+                                               if ((MSG_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) {
+                                                       nameLen = (MSG_FILENAME_LEN_MAX-1) - strlen(pExt);
+                                               } else {
+                                                       nameLen = strlen(pUTF8Buff) - strlen(pExt);
+                                               }
+
+                                               strncpy(pType->param.szName, pUTF8Buff, nameLen);
+                                               strcat (pType->param.szName, pExt);
+                                       } else {
+                                               strncpy(pType->param.szName, pUTF8Buff, (MSG_FILENAME_LEN_MAX-1));
+                                       }
+                                       free(pUTF8Buff);
+                                       pUTF8Buff = NULL;
+
+                                       if (_MsgChangeSpace(pType->param.szName, &szSrc) == true) {
+                                               if (szSrc)
+                                                       strncpy(pType->param.szName, szSrc , strlen(szSrc));
+                                       }
+
+                                       if (szSrc) {
+                                               free(szSrc);
+                                               szSrc = NULL;
+                                       }
+
+                                       // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif"
+                                       _MsgRemoveFilePath(pType->param.szName);
+                               } else {
+                                       MSG_DEBUG("_MsgParseParameter: MsgConvertLatin2UTF8FileName(%s) return NULL\n", pDec);
+                               }
+
+                               MSG_DEBUG("_MsgParseParameter: szName = %s \n", pType->param.szName);
+                               break;
+
+                       case MSG_PARAM_FILENAME:
+
+                               memset (pType->param.szFileName, 0, MSG_FILENAME_LEN_MAX+1);
+
+                               pUTF8Buff = MsgConvertLatin2UTF8FileName(pDec);
+
+                               if (pUTF8Buff) {
+                                       if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) {
+                                               if ((MSG_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) {
+                                                       nameLen = (MSG_FILENAME_LEN_MAX-1) - strlen(pExt);
+                                               } else {
+                                                       nameLen = strlen(pUTF8Buff) - strlen(pExt);
+                                               }
+
+                                               strncpy(pType->param.szFileName, pUTF8Buff, nameLen);
+                                               strcat (pType->param.szFileName, pExt);
+                                       } else {
+                                               strncpy(pType->param.szFileName, pUTF8Buff, (MSG_FILENAME_LEN_MAX-1));
+                                       }
+                                       free(pUTF8Buff);
+                                       pUTF8Buff = NULL;
+
+                                       if (_MsgChangeSpace(pType->param.szFileName, &szSrc) == true)
+                                               strcpy(pType->param.szFileName, szSrc);
+
+                                       if (szSrc) {
+                                               free(szSrc);
+                                               szSrc = NULL;
+                                       }
+
+                                       // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif"
+                                       _MsgRemoveFilePath(pType->param.szFileName);
+                               } else {
+                                       MSG_DEBUG("_MsgParseParameter: MsgConvertLatin2UTF8FileName(%s) return NULL\n", pDec);
+                               }
+
+                               MSG_DEBUG("_MsgParseParameter: szFileName = %s \n", pType->param.szFileName);
+
+                               break;
+
+                       case MSG_PARAM_TYPE:
+
+                               /* type/subtype of root. Only if content-type is multipart/related */
+
+                               pType->param.type = _MsgGetCode(MSG_TYPE, pDec);
+                               MSG_DEBUG("_MsgParseParameter: type = %d \n", pType->param.type);
+
+                               break;
+
+                       case MSG_PARAM_START:
+
+                               /* Content-id. Only if content-type is multipart/related */
+
+                               memset (pType->param.szStart, 0, MSG_MSG_ID_LEN + 1);
+                               strncpy(pType->param.szStart, pDec, MSG_MSG_ID_LEN);
+
+                               MSG_DEBUG("_MsgParseParameter: szStart = %s \n", pType->param.szStart);
+
+                               break;
+
+                       case MSG_PARAM_START_INFO :
+
+                               /* Only if content-type is multipart/related */
+
+                               memset (pType->param.szStartInfo, 0, MSG_MSG_ID_LEN + 1);
+                               strncpy(pType->param.szStartInfo, pDec, MSG_MSG_ID_LEN);
+
+                               MSG_DEBUG("_MsgParseParameter: szStartInfo = %s \n", pType->param.szStartInfo);
+
+                               break;
+
+                       case MSG_PARAM_REPORT_TYPE :
+
+                               //  only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
+
+                               if (pDec != NULL && strcasecmp(pDec, "delivery-status") == 0) {
+                                       pType->param.reportType = MSG_PARAM_REPORT_TYPE_DELIVERY_STATUS;
+                               } else {
+                                       pType->param.reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN;
+                               }
+
+                               MSG_DEBUG("_MsgParseParameter: reportType = %s \n", pDec);
+                               break;
+
+                       default:
+
+                               MSG_DEBUG("_MsgParseParameter: Unknown paremeter (%s)\n", pDec);
+                               break;
+                       }
+
+                       if (pDec) {
+                               free(pDec);
+                               pDec = NULL;
+                       }
+               }
+               pSrc = pNextParam;
+       }
+       return true;
+}
+
+char *_MsgSkipWS(char *s)
+{
+       while (true) {
+               if ((*s == MSG_CH_CR) || (*s == MSG_CH_LF) || (*s == MSG_CH_SP) || (*s == MSG_CH_TAB)) {
+                       ++s;
+               } else if ((*s != '(') || (__MsgSkipComment(s,(long)NULL)==NULL)) {
+                       return s;
+               }
+       }
+}
+
+char *__MsgSkipComment (char *s,long trim)
+{
+
+       char *ret;
+       char *s1 = s;
+       char *t = NULL;
+
+       // ignore empty space
+       for (ret = ++s1; *ret == ' '; ret++)
+               ;
+
+       // handle '(', ')', '\',  '\0'
+       do {
+               switch (*s1) {
+               case '(':
+                       if (!__MsgSkipComment (s1,(long)NULL))
+                               return NULL;
+                       t = --s1;
+                       break;
+               case ')':
+                       s = ++s1;
+                       if (trim) {
+                               if (t) {
+                                       t[1] = '\0';
+                               } else {
+                                       *ret = '\0';
+                               }
+                       }
+                       return ret;
+               case '\\':
+                       if (*++s1)
+                               break;
+               case '\0':
+                       *s = '\0';
+                       return NULL;
+               case ' ':
+                       break;
+               default:
+                       t = s1;
+                       break;
+               }
+       }while (s1++);
+
+       return NULL;
+}
+
+char *MsgConvertLatin2UTF8FileName(char *pSrc)
+{
+       char *pUTF8Buff  = NULL;
+       char *pData = NULL;
+
+
+       //convert utf8 string
+       if (MsgIsUTF8String((unsigned char*)pSrc, strlen(pSrc)) == false) {
+               int length  = 0;
+               int utf8BufSize = 0;
+
+               length = strlen(pSrc);
+               utf8BufSize = MsgGetLatin2UTFCodeSize((unsigned char*)pSrc, length);
+               pUTF8Buff = (char *)malloc(utf8BufSize + 1);
+
+               if (pUTF8Buff == NULL) {
+                       MSG_DEBUG("MsgConvertLatin2UTF8FileName: pUTF8Buff alloc fail \n");
+                       goto __CATCH;
+               }
+
+               if (MsgLatin2UTF ((unsigned char*)pUTF8Buff, utf8BufSize + 1, (unsigned char*)pSrc, length) < 0) {
+                       MSG_DEBUG("MsgConvertLatin2UTF8FileName: MsgLatin2UTF fail \n");
+                       goto __CATCH;
+               }
+       } else {
+               int length = strlen(pSrc);
+               pUTF8Buff = (char *)calloc(1, length+1);
+
+               if (pUTF8Buff == NULL) {
+                       MSG_DEBUG("MsgConvertLatin2UTF8FileName: pUTF8Buff alloc fail \n");
+                       goto __CATCH;
+               }
+
+               memcpy(pUTF8Buff, pSrc, length);
+       }
+
+       //convert hex string
+       if (MsgIsPercentSign(pUTF8Buff) == true) {
+               pData = MsgChangeHexString(pUTF8Buff);
+               if (pData) {
+                       strcpy(pUTF8Buff, pData);
+                       free(pData);
+                       pData = NULL;
+               }
+       }
+
+       return pUTF8Buff;
+
+__CATCH:
+
+       if (pUTF8Buff) {
+               free(pUTF8Buff);
+               pUTF8Buff = NULL;
+       }
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+       return NULL;
+}
+
+bool _MsgChangeSpace(char *pOrg, char **ppNew)
+{
+       char *pNew = NULL;
+       int cLen = 0;
+       int cIndex =0;
+       int index = 0;
+
+       if (pOrg == NULL)
+               return false;
+
+       cLen = strlen(pOrg);
+
+       pNew = (char *)malloc(cLen + 1);
+       if (pNew == NULL)
+               return false;
+
+       memset(pNew, 0, cLen + 1);
+
+       for (cIndex=0; cIndex<cLen;cIndex++) {
+               if (pOrg[cIndex] == '%' && pOrg[cIndex+1] == '2' && pOrg[cIndex+2] == '0') {
+                       pNew[index] = ' ';
+                       index++;
+                       cIndex+= 2;
+                       continue;
+               }
+               pNew[index++] = pOrg[cIndex];
+       }
+
+       *ppNew = pNew;
+
+       return true;
+}
+
+void _MsgRemoveFilePath(char *pSrc)
+{
+       // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif"
+       char *pPath = NULL;
+       char *pTemp = NULL;
+       char szFileName[MSG_FILENAME_LEN_MAX] = {0};
+
+       if (pSrc == NULL)
+               return;
+
+       pTemp = pSrc;
+       while ((pTemp = strchr(pTemp, '/')) != NULL) {
+               // Find the last  '/'
+               pPath = pTemp;
+               pTemp++;
+       }
+
+       if (pPath) {
+               MSG_DEBUG("_MsgRemoveFilePath: filename(%s)\n", pSrc);
+
+               // case : images/vf7.gif -> vf7.gif
+               if (pPath != NULL && *(pPath+1) != '\0') {
+                       strncpy(szFileName, pPath+1, strlen(pPath+1));
+                       strncpy(pSrc, szFileName , strlen(szFileName));
+               }
+       }
+       // Remove additional file information
+       // ex) Content-type: application/octet-stream; name="060728gibson_210.jpg?size=s"
+       // if "?size=" exist, insert NULL char.
+       {
+               pTemp = strcasestr(pSrc, "?size=");
+               if (pTemp != NULL)
+                       *pTemp = '\0';
+       }
+}
+
+bool MsgIsUTF8String(unsigned char *szSrc, int nChar)
+{
+       MSG_DEBUG("MsgIsUTF8String: --------------- \n");
+
+       if (szSrc == NULL) {
+               MSG_DEBUG("MsgIsUTF8String: szSrc is NULL !!!! --------------- \n");
+               return true;
+       }
+
+       while (nChar > 0 && (*szSrc != '\0')) {
+               if (*szSrc < 0x80) {
+                       szSrc++;
+                       nChar--;
+               } else if ((0xC0 <= *szSrc) && (*szSrc < 0xE0)) {
+                       if (*(szSrc + 1) >= 0x80) {
+                               szSrc += 2;
+                               nChar -= 2;
+                       } else {
+                               MSG_DEBUG("MsgIsUTF8String: 1. NOT utf8 range!\n");
+                               goto __CATCH;
+                       }
+               } else if (*szSrc >= 0xE0) {
+                       if (*(szSrc + 1) >= 0x80) {
+                               if (*(szSrc + 2) >= 0x80) {
+                                       szSrc += 3;
+                                       nChar -= 3;
+                               } else {
+                                       MSG_DEBUG("MsgIsUTF8String: 2. NOT utf8 range!\n");
+                                       goto __CATCH;
+                               }
+                       } else {
+                               MSG_DEBUG("MsgIsUTF8String: 3. NOT utf8 range!\n");
+                               goto __CATCH;
+                       }
+               } else {
+                       MSG_DEBUG("MsgIsUTF8String: 4. NOT utf8 range!\n");
+                       goto __CATCH;
+               }
+       }
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+bool MsgIsPercentSign(char *pSrc)
+{
+       char *pCh = NULL;
+       bool bRet = false;
+
+       pCh = strchr(pSrc , '%');
+
+       if (pCh != NULL) {
+               bRet = true;
+       } else {
+               bRet = false;
+       }
+
+       return bRet;
+}
+
+MsgMultipart *MsgAllocMultipart(void)
+{
+       MsgMultipart *pMultipart = NULL;
+
+       MSG_DEBUG("MsgAllocMultipart: --------- \n");
+
+       pMultipart = (MsgMultipart*)malloc(sizeof(MsgMultipart));
+       if (pMultipart == NULL) {
+               MSG_DEBUG("MsgAllocMultipart: pMultipart malloc Fail \n");
+               goto __CATCH;
+       }
+
+       pMultipart->pBody = (MsgBody*)malloc(sizeof(MsgBody));
+       if (pMultipart->pBody == NULL) {
+               MSG_DEBUG("MsgAllocMultipart: pMultipart->pBody malloc Fail \n");
+               goto __CATCH;
+       }
+
+       _MsgInitMsgType(&pMultipart->type);
+       _MsgInitMsgBody(pMultipart->pBody);
+
+       pMultipart->pNext = NULL;
+
+       return pMultipart;
+
+__CATCH:
+
+       if (pMultipart) {
+               if (pMultipart->pBody) {
+                       free(pMultipart->pBody);
+                       pMultipart->pBody = NULL;
+               }
+
+               free(pMultipart);
+               pMultipart = NULL;
+       }
+
+       return NULL;
+}
+
+bool _MsgInitMsgType(MsgType *pMsgType)
+{
+       pMsgType->offset = 0;
+       pMsgType->size = 0;
+       pMsgType->contentSize = 0;
+       pMsgType->disposition = 0;
+       pMsgType->encoding = 0;
+       pMsgType->type = MIME_UNKNOWN;
+#ifdef FEATURE_JAVA_MMS_MIME
+       pMsgType->szMimeString[0] ='\0';
+#endif
+       pMsgType->section = 0;
+
+       pMsgType->szOrgFilePath[0] = '\0';
+       pMsgType->szContentID[0] = '\0';
+       pMsgType->szContentLocation[0] = '\0';
+
+       pMsgType->szContentRepPos[0] = '\0';
+       pMsgType->szContentRepSize[0] = '\0';
+       pMsgType->szContentRepIndex[0] = '\0';
+
+       __MsgInitMsgContentParam(&pMsgType->param);
+#ifdef __SUPPORT_DRM__
+       __MsgInitMsgDRMInfo(&pMsgType->drmInfo);
+#endif
+
+       return true;
+}
+
+
+bool __MsgInitMsgContentParam(MsgContentParam *pMsgContentParam)
+{
+       pMsgContentParam->charset = MSG_CHARSET_UNKNOWN;
+       pMsgContentParam->type = MIME_UNKNOWN;
+       pMsgContentParam->szBoundary[0] = '\0';
+       pMsgContentParam->szFileName[0] = '\0';
+       pMsgContentParam->szName[0] = '\0';
+#ifdef FEATURE_JAVA_MMS
+       pMsgContentParam->szApplicationID = NULL;
+       pMsgContentParam->szReplyToApplicationID = NULL;
+#endif
+       pMsgContentParam->szStart[0] = '\0';
+       pMsgContentParam->szStartInfo[0] = '\0';
+       pMsgContentParam->pPresentation = NULL;
+
+       pMsgContentParam->reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; //  add only used as parameter of Content-Type: multipart/report; report-type
+
+       return true;
+}
+
+
+bool _MsgInitMsgBody(MsgBody *pMsgBody)
+{
+       pMsgBody->offset = 0;
+       pMsgBody->size = 0;
+       pMsgBody->body.pText = NULL;
+       pMsgBody->szOrgFilePath[0] = '\0';
+
+       _MsgInitMsgType(&pMsgBody->presentationType);
+       pMsgBody->pPresentationBody = NULL;
+
+       memset(pMsgBody->szOrgFilePath, 0, MSG_FILEPATH_LEN_MAX);
+
+       return true;
+}
+
+
+MsgPresentationFactor MsgIsPresentationEx(MsgType *multipartType, char* szStart, MsgContentType typeParam)
+{
+       char szTmpStart[MSG_MSG_ID_LEN + 3] = { 0, };
+       char szTmpContentID[MSG_MSG_ID_LEN + 3] = { 0, };
+       char szTmpContentLO[MSG_MSG_ID_LEN + 3] = { 0, };
+       int strLen = 0;
+
+       // remove '<' and '>' in Start Param : contentID ex] <0_1.jpg> or <1233445>
+       if (szStart && szStart[0]) {
+               int startLen = 0;
+               startLen = strlen(szStart);
+               if (szStart[0] == '<' && szStart[startLen - 1] == '>') {
+                       strncpy(szTmpStart, &szStart[1], startLen - 2);
+               } else {
+                       strncpy(szTmpStart, szStart, startLen);
+               }
+       }
+
+       // remove '<' and '>' in ContentID : contentID ex] <0_1.jpg> or <1233445>
+       if (multipartType->szContentID[0])      {
+               strLen = strlen(multipartType->szContentID);
+               if (multipartType->szContentID[0] == '<' && multipartType->szContentID[strLen - 1] == '>') {
+                       strncpy(szTmpContentID, &(multipartType->szContentID[1]), strLen - 2);
+               } else {
+                       strncpy(szTmpContentID, multipartType->szContentID, strLen);
+               }
+       }
+
+       // remove '<' and '>' in ContentLocation : contentID ex] <0_1.jpg> or <1233445>
+       if (multipartType->szContentLocation[0]) {
+               strLen = strlen(multipartType->szContentLocation);
+               if (multipartType->szContentLocation[0] == '<' && multipartType->szContentLocation[strLen - 1] == '>') {
+                       strncpy(szTmpContentLO, &multipartType->szContentLocation[1], strLen - 2);
+               } else {
+                       strncpy(szTmpContentLO, multipartType->szContentLocation, strLen);
+               }
+       }
+
+       if ((szTmpContentID[0] == '\0') && (szTmpContentLO[0] == '\0') && (multipartType->type == MIME_UNKNOWN))
+               return  MSG_PRESENTATION_NONE;
+
+       // exception handling
+       if (szTmpStart[0] != '\0') {
+               // presentation part : 1.compare with contentID 2.compare with content Location 3. compare with type
+               if (strcmp(szTmpStart, szTmpContentID) == 0) {
+                       return MSG_PRESENTATION_ID;
+               } else if (strcmp(szTmpStart, szTmpContentLO) == 0) {
+                       return   MSG_PRESENTATION_LOCATION;
+               } else if (multipartType->type == typeParam) {
+                       return   MSG_PRESENTATION_TYPE_BASE;
+               } else {
+                       return   MSG_PRESENTATION_NONE;
+               }
+       } else {
+               if (multipartType->type == typeParam && typeParam != MIME_UNKNOWN) {
+                       return   MSG_PRESENTATION_TYPE_BASE;
+               } else {
+                       return   MSG_PRESENTATION_NONE;
+               }
+       }
+}
+
+void MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresentaionInfo *pPresentationInfo)
+{
+       MSG_BEGIN();
+       MsgMultipart *pNextPart = NULL;
+       MsgMultipart *pRemovePart = NULL;
+
+       if (MsgIsMultipartRelated(pMsgType->type)) {
+               // assign the multipart to presentation part
+               // remove the multipart(pCurPresentation) which is presentation part from the linked list.
+               // if there is no presentation part -> assign first multipart to presentation part by force.
+               if (pPresentationInfo->pCurPresentation == NULL) {
+                       pPresentationInfo->pCurPresentation     = pMsgBody->body.pMultipart;
+                       pPresentationInfo->pPrevPart            = NULL;
+                       pPresentationInfo->factor                       = MSG_PRESENTATION_NONE;
+               }
+
+               if (pPresentationInfo->pCurPresentation != NULL && MsgIsPresentablePart(pPresentationInfo->pCurPresentation->type.type)) {
+                       /* Presentable Part is some MARK-UP page, such as SMIL, HTML, WML, XHTML.
+                        * In this case, COPY the Presentation part and leave other multiparts.
+                        */
+                       memcpy(&pMsgBody->presentationType, &pPresentationInfo->pCurPresentation->type, sizeof(MsgType));
+                       pMsgBody->pPresentationBody = pPresentationInfo->pCurPresentation->pBody;
+
+                       // remove pCurPresentation from multipart linked list
+                       if ((pPresentationInfo->factor == MSG_PRESENTATION_NONE)||(pPresentationInfo->pPrevPart == NULL)) {
+                               // first part
+                               pMsgBody->body.pMultipart = pPresentationInfo->pCurPresentation->pNext;
+                               pMsgType->contentSize -= pPresentationInfo->pCurPresentation->pBody->size;
+                               pMsgBody->size -= pPresentationInfo->pCurPresentation->pBody->size;
+                               if (pPresentationInfo->pCurPresentation) {
+#ifdef __SUPPORT_DRM__
+                                       _MsgFreeDRMInfo(&pPresentationInfo->pCurPresentation->type.drmInfo);
+#endif
+                                       free(pPresentationInfo->pCurPresentation);
+                                       pPresentationInfo->pCurPresentation = NULL;
+                               }
+                       } else {
+                               // not a first part
+                               pPresentationInfo->pPrevPart->pNext = pPresentationInfo->pCurPresentation->pNext;
+                               pMsgType->contentSize -= pPresentationInfo->pCurPresentation->pBody->size;
+                               pMsgBody->size -= pPresentationInfo->pCurPresentation->pBody->size;
+                               if (pPresentationInfo->pCurPresentation) {
+                                       free(pPresentationInfo->pCurPresentation);
+                                       pPresentationInfo->pCurPresentation = NULL;
+                               }
+                       }
+               } else if (pPresentationInfo->pCurPresentation != NULL && MsgIsText(pPresentationInfo->pCurPresentation->type.type)) {
+                       /* NON-Presentable Part is some PLAIN part such as, text/plain, multipart/alternative.
+                        * In this case, leave the Presentation part as a multipart and remove other multiparts.
+                        */
+
+                       // Backup the multipart link information
+                       pNextPart = pMsgBody->body.pMultipart;
+
+                       // Copy presentation part as a main part
+                       memcpy(pMsgType, &pPresentationInfo->pCurPresentation->type, sizeof(MsgType));
+                       memcpy(pMsgBody, pPresentationInfo->pCurPresentation->pBody, sizeof(MsgBody));
+
+                       // Remove multipart linked list
+                       while (pNextPart) {
+                               pRemovePart = pNextPart;
+                               pNextPart = pNextPart->pNext;
+
+                               if (pRemovePart->pBody) {
+                                       _MsgFreeBody(pRemovePart->pBody, pRemovePart->type.type);
+                                       free(pRemovePart->pBody);
+                                       pRemovePart->pBody = NULL;
+                               }
+
+                               free(pRemovePart);
+                               pRemovePart = NULL;
+                       }
+               } else {
+#ifdef __SUPPORT_DRM__
+                       _MsgFreeDRMInfo(&pMsgBody->presentationType.drmInfo);
+#endif
+                       _MsgInitMsgType(&pMsgBody->presentationType);
+                       pMsgBody->pPresentationBody = NULL;
+               }
+       }
+       MSG_END();
+}
+
+bool MsgIsMultipartRelated(int type)
+{
+       if (type == MIME_MULTIPART_RELATED || type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
+               return true;
+       } else {
+               return false;
+       }
+}
+
+bool MsgIsPresentablePart(int type)
+{
+       if (type == MIME_TEXT_HTML || type == MIME_TEXT_VND_WAP_WML || type == MIME_APPLICATION_SMIL) {
+               return true;
+       } else {
+               return false;
+       }
+}
+
+#ifdef __SUPPORT_DRM__
+void _MsgFreeDRMInfo(MsgDRMInfo *pDrmInfo)
+{
+       MSG_DEBUG("_MsgFreeDRMInfo: S T A R T  !!! \n");
+
+       if (pDrmInfo == NULL) {
+               MSG_DEBUG("pDrmInfo is NULL");
+               return;
+       }
+
+       if (pDrmInfo->szContentDescription) {
+               free(pDrmInfo->szContentDescription);
+               pDrmInfo->szContentDescription = NULL;
+       }
+
+       if (pDrmInfo->szContentVendor) {
+               free(pDrmInfo->szContentVendor);
+               pDrmInfo->szContentVendor = NULL;
+       }
+
+       if (pDrmInfo->szContentName) {
+               free(pDrmInfo->szContentName);
+               pDrmInfo->szContentName = NULL;
+       }
+
+       if (pDrmInfo->szContentURI) {
+               free(pDrmInfo->szContentURI);
+               pDrmInfo->szContentURI = NULL;
+       }
+
+       if (pDrmInfo->szRightIssuer) {
+               free(pDrmInfo->szRightIssuer);
+               pDrmInfo->szRightIssuer = NULL;
+       }
+
+       if (pDrmInfo->szDrm2FullPath) {
+               free(pDrmInfo->szDrm2FullPath);
+               pDrmInfo->szDrm2FullPath = NULL;
+       }
+
+#if MMS_ENABLE_EXTEND_CFM
+       // DRM (Extended)CFM
+       if (pDrmInfo->pszContentType) {
+               free(pDrmInfo->pszContentType);
+               pDrmInfo->pszContentType = NULL;
+       }
+#endif
+
+       pDrmInfo->contentType = MIME_UNKNOWN;
+       pDrmInfo->drmType = MSG_DRM_TYPE_NONE;
+}
+
+bool MsgCopyDrmInfo(MsgType *pPartType)
+{
+       char *pExt = NULL;
+       char *pTmpBuf = NULL;
+
+       //convert application/vnd.oma.drm.content to media type
+       pPartType->type = pPartType->drmInfo.contentType;
+
+       // fix wrong file name presentation on save media screen.
+       if (pPartType->szContentID[0] == '\0' && pPartType->drmInfo.szContentURI)
+               strncpy(pPartType->szContentID, pPartType->drmInfo.szContentURI, MSG_MSG_ID_LEN);
+
+       /* set title name (content name) */
+       if (pPartType->param.szName[0] == '\0') {
+               /*      szName is vitual name, real filename is *.dcf or *.dm   */
+               if (pPartType->drmInfo.szContentName && pPartType->drmInfo.szContentName[0] != '\0') {
+                       /* In case of szContentName retrieved from DRM agent is exist. */
+                       pTmpBuf = pPartType->drmInfo.szContentName;
+               } else if (pPartType->szContentLocation[0] != '\0')     {
+                       /* In case of szContentLocation parsed from MMS header */
+                       pTmpBuf = strrchr(pPartType->szContentLocation, '/');
+                       if (pTmpBuf == NULL)
+                               pTmpBuf = pPartType->szContentLocation;
+               } else {
+                       /* use another name */
+                       /* possible NULL pointer assignment*/
+                       pTmpBuf = strdup("untitled");
+               }
+
+               if ((pExt = strrchr(pTmpBuf, '.')) != NULL) {
+                       int extLen = 0;
+                       int fileNameLen = 0;
+                       int tmpLen = 0;
+
+                       extLen = strlen(pExt);
+                       tmpLen = strlen(pTmpBuf);
+                       fileNameLen = (tmpLen - extLen < MSG_LOCALE_FILENAME_LEN_MAX - extLen)?(tmpLen - extLen):(MSG_LOCALE_FILENAME_LEN_MAX - extLen);
+                       strncpy(pPartType->param.szName, pTmpBuf, fileNameLen);
+                       strcpy (pPartType->param.szName + fileNameLen, pExt);
+               } else {
+                       strncpy(pPartType->param.szName, pTmpBuf, MSG_LOCALE_FILENAME_LEN_MAX);
+                       MsgMakeFileName(pPartType->type, pPartType->param.szName, MSG_DRM_TYPE_NONE, 0);
+               }
+       }
+
+       return true;
+}
+
+#endif
+
+bool MsgIsText(int type)
+{
+       if (type == MIME_TEXT_PLAIN || type == MIME_TEXT_HTML || type == MIME_TEXT_VND_WAP_WML ||
+               type == MIME_TEXT_X_VNOTE || type == MIME_APPLICATION_SMIL || type == MIME_TEXT_X_IMELODY) {
+               return true;
+       } else {
+               return false;
+       }
+}
+
+bool MsgFreeAttrib(MmsAttrib *pAttrib)
+{
+       MSG_BEGIN();
+
+       if (pAttrib == NULL) {
+               MSG_DEBUG("pAttrib is NULL");
+               return false;
+       }
+
+       if (pAttrib->szTo) {
+               free(pAttrib->szTo);
+               pAttrib->szTo = NULL;
+       }
+
+       if (pAttrib->szCc) {
+               free(pAttrib->szCc);
+               pAttrib->szCc = NULL;
+       }
+
+       if (pAttrib->szBcc) {
+               free(pAttrib->szBcc);
+               pAttrib->szBcc = NULL;
+       }
+
+       //check if pMultiStatus should be freed or not, because pMultiStatus is not allocated
+       if (pAttrib->pMultiStatus) {
+               MmsMsgMultiStatus *pMultiStatus = pAttrib->pMultiStatus;
+               MmsMsgMultiStatus *pCurStatus = NULL;
+
+               while (pMultiStatus != NULL ) {
+                       pCurStatus = pMultiStatus;
+                       pMultiStatus = pMultiStatus->pNext;
+
+                       if (pCurStatus) {
+                               free(pCurStatus);
+                               pCurStatus = NULL;
+                       }
+               }
+
+               pAttrib->pMultiStatus = NULL;
+       }
+
+
+       MSG_END();
+
+       return true;
+}
+
+bool _MsgFreeBody(MsgBody *pBody, int type)
+{
+       MSG_DEBUG("_MsgFreeBody: S T A R T  !!! \n") ;
+
+       if (pBody == NULL) {
+               MSG_DEBUG("_MsgFreeBody: pBody == NULL \n" );
+               MSG_DEBUG("_MsgFreeBody: E  N  D   (End)!!! \n") ;
+
+               return false;
+       }
+
+       switch (type) {
+       case MIME_MULTIPART_REPORT:
+       case MIME_APPLICATION_VND_OMA_DRM_MESSAGE:
+       case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED:
+       case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED:
+       case MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC:
+       case MIME_MULTIPART_MIXED:
+       case MIME_MULTIPART_RELATED:
+       case MIME_MULTIPART_ALTERNATIVE:
+       case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE:
+               {
+                       MsgMultipart *pMulti = pBody->body.pMultipart;
+                       MsgMultipart *pCurrPart = NULL;
+                       MsgBody *pPresentation = pBody->pPresentationBody;
+                       while (pMulti != NULL) {
+                               pCurrPart = pMulti;
+
+                               pMulti = pMulti->pNext;
+
+                               if (pCurrPart) {
+#ifdef __SUPPORT_DRM__
+                                       _MsgFreeDRMInfo(&pCurrPart->type.drmInfo);
+#endif
+
+                                       if (pCurrPart->pBody) {
+                                               if (pCurrPart->pBody->body.pBinary) {
+                                                       free(pCurrPart->pBody->body.pBinary);
+                                                       pCurrPart->pBody->body.pBinary = NULL;
+                                               }
+                                               free(pCurrPart->pBody);
+                                               pCurrPart->pBody = NULL;
+                                       }
+                                       free(pCurrPart);
+                                       pCurrPart = NULL;
+                               }
+                       }
+
+                       pBody->body.pMultipart = NULL;
+
+                       if (pPresentation) {
+                               if (pPresentation->body.pText) {
+                                       free(pPresentation->body.pText);
+                                       pPresentation->body.pText = NULL;
+                               }
+                               free(pPresentation);
+                               pBody->pPresentationBody = NULL;
+                       }
+
+                       _MsgInitMsgType(&pBody->presentationType);
+
+                       break;
+               }
+
+       default:
+               /* Any single part */
+
+               if (pBody->body.pBinary) {
+                       free(pBody->body.pBinary);
+                       pBody->body.pBinary = NULL;
+               }
+
+               break;
+       }
+
+       MSG_DEBUG("_MsgFreeBody: E  N  D  (Successfully) !!! \n") ;
+
+       return true;
+
+}
+
+bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
+{
+       MSG_BEGIN();
+       MsgMultipart *pTmpMultipart = NULL;
+       MsgMultipart *pSelectedPart = NULL;
+       MsgMultipart *pPrevPart = NULL;
+       MsgMultipart *pFirstPart = NULL;
+       MsgMultipart *pLastPart = NULL;
+       MsgMultipart *pRemoveList = NULL;
+       MsgMultipart *pNextRemovePart = NULL;
+
+       switch (pPartType->type) {
+       case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE:
+       case MIME_MULTIPART_ALTERNATIVE:
+
+               /* fixme:
+                * Policy: multipart/alternative
+                * multipart/alternative message has only several parts of media.
+                * You should choose one of them and make the alternative part
+                * to the selected media part.
+                */
+
+               MSG_DEBUG("MsgResolveNestedMultipart : MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE\n");
+
+               pSelectedPart = pPartBody->body.pMultipart;
+
+               // NULL Pointer check!!
+               if (pSelectedPart == NULL) {
+                       MSG_DEBUG("MsgResolveNestedMultipart : multipart(ALTERNATIVE) does not exist\n");
+                       break;
+               }
+
+               pTmpMultipart = pPartBody->body.pMultipart->pNext;
+
+               while (pTmpMultipart) {
+                       if (pSelectedPart->type.type <= pTmpMultipart->type.type)
+                               pSelectedPart = pTmpMultipart;
+
+                       pTmpMultipart = pTmpMultipart->pNext;
+               }
+
+               pTmpMultipart = pPartBody->body.pMultipart;
+               pPrevPart = NULL;
+
+               while (pTmpMultipart) {
+                       if (pSelectedPart == pTmpMultipart)
+                               break;
+
+                       pPrevPart = pTmpMultipart;
+                       pTmpMultipart = pTmpMultipart->pNext;
+               }
+
+               if (pPrevPart == NULL) {
+                       /* selected part is the first part */
+                       pRemoveList = pSelectedPart->pNext;
+               } else {
+                       pPrevPart->pNext = pSelectedPart->pNext;
+                       pRemoveList = pPartBody->body.pMultipart;
+                       pPartBody->body.pMultipart = pSelectedPart;
+               }
+
+               pSelectedPart->pNext = NULL;
+
+               if (pRemoveList) {
+#ifdef __SUPPORT_DRM__
+                       _MsgFreeDRMInfo(&pRemoveList->type.drmInfo);
+#endif
+                       _MsgFreeBody(pRemoveList->pBody, pRemoveList->type.type);
+
+                       free(pRemoveList->pBody);
+                       free(pRemoveList);
+               }
+
+               if (MsgCopyNestedMsgType(pPartType, &(pSelectedPart->type)) == false) {
+                       MSG_DEBUG("MsgResolveNestedMultipart : MsgPriorityCopyMsgType failed \n");
+                       goto __CATCH;
+               }
+
+               if (pSelectedPart->pBody != NULL)
+                       memcpy(pPartBody, pSelectedPart->pBody, sizeof(MsgBody));
+
+               if (pSelectedPart != NULL) {
+#ifdef __SUPPORT_DRM__
+                       _MsgFreeDRMInfo(&pSelectedPart->type.drmInfo);
+#endif
+
+                       if (pSelectedPart->pBody != NULL) {
+                               free(pSelectedPart->pBody);
+                               pSelectedPart->pBody = NULL;
+                       }
+                       free(pSelectedPart);
+                       pSelectedPart = NULL;
+               }
+
+               break;
+
+       case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED:
+       case MIME_MULTIPART_RELATED:
+
+               MSG_DEBUG("MsgResolveNestedMultipart : MIME_APPLICATION_VND_WAP_MULTIPART_RELATED\n");
+
+               pSelectedPart = pPartBody->body.pMultipart;
+
+               while (pSelectedPart) {
+                       if (MsgIsMultipartMixed(pSelectedPart->type.type)) {
+
+                               if (pSelectedPart->pBody == NULL) {
+                                       MSG_DEBUG("MsgResolveNestedMultipart :pSelectedPart->pBody(1) is NULL\n");
+                                       break;
+                               }
+
+                               pFirstPart = pSelectedPart->pBody->body.pMultipart;
+
+                               if (pFirstPart == NULL) {
+                                       MSG_DEBUG("MsgResolveNestedMultipart : multipart(RELATED) does not exist\n");
+                                       break;
+                               }
+
+                               if (pFirstPart->pNext) {
+                                       pLastPart = pFirstPart->pNext;
+                                       while (pLastPart->pNext)
+                                               pLastPart = pLastPart->pNext;
+                               } else {
+                                       pLastPart = pFirstPart;
+                               }
+
+                               if (pPrevPart == NULL) {
+                                       /* the first part */
+                                       pTmpMultipart = pPartBody->body.pMultipart->pNext;
+                                       pPartBody->body.pMultipart = pFirstPart;
+                                       pLastPart->pNext = pTmpMultipart;
+                               } else {
+                                       pTmpMultipart = pSelectedPart->pNext;
+                                       pPrevPart->pNext = pFirstPart;
+                                       pLastPart->pNext = pTmpMultipart;
+                               }
+
+                               if (pSelectedPart) {
+#ifdef __SUPPORT_DRM__
+                                       _MsgFreeDRMInfo(&pSelectedPart->type.drmInfo);
+#endif
+                                       free(pSelectedPart->pBody);
+                                       free(pSelectedPart);
+                               }
+                               pSelectedPart = pTmpMultipart;
+                       } else if (MsgIsMultipartRelated(pSelectedPart->type.type) && pPrevPart != NULL) {
+                               pPrevPart->pNext = pTmpMultipart = pSelectedPart->pNext;
+                               _MsgFreeBody(pSelectedPart->pBody, pSelectedPart->type.type);
+
+                               free(pSelectedPart->pBody);
+                               free(pSelectedPart);
+                               pSelectedPart = pTmpMultipart;
+                       } else {
+                               pPrevPart = pSelectedPart;
+                               pSelectedPart = pSelectedPart->pNext;
+                       }
+               }
+
+               break;
+
+
+       case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED:
+       case MIME_MULTIPART_MIXED:
+
+               MSG_DEBUG("MsgResolveNestedMultipart : MIME_APPLICATION_VND_WAP_MULTIPART_MIXED\n");
+
+               pPrevPart = NULL;
+               pSelectedPart = pPartBody->body.pMultipart;
+
+               while (pSelectedPart) {
+                       if (MsgIsMultipart(pSelectedPart->type.type)) {
+                               if (pSelectedPart->pBody == NULL) {
+                                       MSG_DEBUG("MsgResolveNestedMultipart :pSelectedPart->pBody(2) is NULL\n");
+                                       break;
+                               }
+
+                               pFirstPart = pSelectedPart->pBody->body.pMultipart;
+
+                               // NULL Pointer check!!
+                               if (pFirstPart == NULL) {
+                                       MSG_DEBUG("MsgResolveNestedMultipart : multipart does not exist\n");
+                                       break;
+                               }
+
+                               if (pFirstPart->pNext) {
+                                       pLastPart = pFirstPart->pNext;
+                                       while (pLastPart->pNext)
+                                               pLastPart = pLastPart->pNext;
+                               } else {
+                                       pLastPart = pFirstPart;
+                               }
+
+                               if (pPrevPart == NULL) {
+                                       /* the first part */
+                                       pTmpMultipart = pPartBody->body.pMultipart->pNext;
+                                       pPartBody->body.pMultipart = pFirstPart;
+                                       pLastPart->pNext = pTmpMultipart;
+                               } else {
+                                       pTmpMultipart = pSelectedPart->pNext;
+                                       pPrevPart->pNext = pFirstPart;
+                                       pLastPart->pNext = pTmpMultipart;
+                               }
+
+                               if (pSelectedPart->pBody->pPresentationBody)
+                                       pPartBody->pPresentationBody = pSelectedPart->pBody->pPresentationBody;
+
+                               memcpy(&pPartBody->presentationType,
+                                                 &pSelectedPart->pBody->presentationType, sizeof(MsgType));
+
+                               pPartType->type = pSelectedPart->type.type;
+
+#ifdef __SUPPORT_DRM__
+                               _MsgFreeDRMInfo(&pSelectedPart->type.drmInfo);
+#endif
+                               free(pSelectedPart->pBody);
+                               free(pSelectedPart);
+
+                               pSelectedPart = pTmpMultipart;
+                       } else {
+                               pPrevPart = pSelectedPart;
+                               pSelectedPart = pSelectedPart->pNext;
+                       }
+               }
+
+               break;
+
+       case MIME_MULTIPART_REPORT:
+
+               MSG_DEBUG("MsgResolveNestedMultipart : MIME_MULTIPART_REPORT \n");
+
+               pTmpMultipart = pPartBody->body.pMultipart;
+               pPrevPart = NULL;
+
+               if (pTmpMultipart == NULL) {
+                       MSG_DEBUG("MsgResolveNestedMultipart : pTmpMultipart == NULL \n");
+                       return false;
+               }
+
+               while (pTmpMultipart) {
+                       if (pTmpMultipart->type.type == MIME_TEXT_PLAIN) {
+                               pSelectedPart = pTmpMultipart;
+                               break;
+                       }
+
+                       pPrevPart = pTmpMultipart;
+                       pTmpMultipart = pTmpMultipart->pNext;
+               }
+
+               if (pSelectedPart == NULL) {
+                       MSG_DEBUG("MsgResolveNestedMultipart : MIME_MULTIPART_REPORT [no selected part]\n");
+                       MSG_DEBUG("MsgResolveNestedMultipart : MIME_MULTIPART_REPORT [no selected part]\n");
+
+                       pRemoveList = pPartBody->body.pMultipart->pNext;
+                       pSelectedPart = pPartBody->body.pMultipart;
+                       pSelectedPart->pNext = NULL;
+               } else {
+                       if (pPrevPart == NULL) {
+                               // first part is selected
+                               pRemoveList = pPartBody->body.pMultipart->pNext;
+                       } else {
+                               pRemoveList = pPartBody->body.pMultipart->pNext;
+                               pPrevPart->pNext = pSelectedPart->pNext;
+                       }
+
+                       pSelectedPart->pNext = NULL;
+                       pPartBody->body.pMultipart = pSelectedPart;
+               }
+
+               pTmpMultipart = pRemoveList;
+
+               while (pTmpMultipart) {
+#ifdef __SUPPORT_DRM__
+                       _MsgFreeDRMInfo(&pTmpMultipart->type.drmInfo);
+#endif
+                       _MsgFreeBody(pTmpMultipart->pBody, pTmpMultipart->type.type);
+                       pNextRemovePart = pTmpMultipart->pNext;
+
+                       free(pTmpMultipart->pBody);
+                       free(pTmpMultipart);
+                       pTmpMultipart = pNextRemovePart;
+               }
+
+               if (MsgCopyNestedMsgType(pPartType, &(pSelectedPart->type)) == false) {
+                       MSG_DEBUG("MsgResolveNestedMultipart : MsgPriorityCopyMsgType failed \n");
+                       goto __CATCH;
+               }
+
+               if (pSelectedPart->pBody != NULL)
+                       memcpy(pPartBody, pSelectedPart->pBody, sizeof(MsgBody));
+
+               if (pSelectedPart != NULL) {
+#ifdef __SUPPORT_DRM__
+                       _MsgFreeDRMInfo(&pSelectedPart->type.drmInfo);
+#endif
+                       if (pSelectedPart->pBody != NULL) {
+                               free(pSelectedPart->pBody);
+                               pSelectedPart->pBody = NULL;
+                       }
+                       free(pSelectedPart);
+                       pSelectedPart = NULL;
+               }
+
+               break;
+
+       default:
+               break;
+       }
+       MSG_END();
+
+       return true;
+
+__CATCH:
+       return false;
+
+}
+
+char *MsgResolveContentURI(char *szSrc)
+{
+       char *szTemp = NULL;
+       char *szReturn = NULL;
+       int length = 0;
+
+       if (szSrc == NULL) {
+               goto __CATCH;
+       }
+
+       if (szSrc[0] == '\0')
+               goto __CATCH;
+
+
+       if (!strncasecmp(szSrc, "cid:", 4)) {
+               length = strlen(szSrc) - 3;
+               szSrc += 4;
+       } else {
+               length = strlen(szSrc) + 1;
+       }
+
+       szTemp = (char *)malloc(length);
+       if (szTemp == NULL) {
+               MSG_DEBUG("MsgResolveContentURI: memory full\n");
+               goto __CATCH;
+       }
+
+       memset(szTemp, 0, length);
+       strcpy(szTemp, szSrc);
+
+       szReturn = MsgChangeHexString(szTemp);
+
+       if (szTemp) {
+               free(szTemp);
+               szTemp = NULL;
+       }
+
+       return szReturn;
+
+__CATCH:
+       if (szTemp) {
+               free(szTemp);
+               szTemp = NULL;
+       }
+
+       return NULL;
+}
+
+bool _MsgParsePartHeader(MsgType *pType, const char *pRawData, int nRawData)
+{
+       char ch = '\0';
+       int cRaw = nRawData;
+       char *pFieldLine = NULL;
+       char *pFieldValue = NULL;
+       char *szFieldValue = NULL;
+       char *szSrc = NULL;
+       int nLen = 0;
+       char fieldLine[MSG_LINE_LEN] = {0, }; //temporary line buffer
+       int length = 0;
+
+       char szTempBuf[MSG_LOCAL_TEMP_BUF_SIZE];
+
+       while ((cRaw > 0) && *pRawData != MSG_CH_LF) {
+               memset(fieldLine, 0, MSG_LINE_LEN);
+               pFieldLine = fieldLine;
+
+               ch = MSG_CH_SP; //remember previous character.
+
+               while (ch) {
+                       switch (ch = *pRawData++) {
+                       case MSG_CH_CR: //'\r'
+                               if (*pRawData == MSG_CH_LF)
+                                       break;
+
+                       case MSG_CH_LF: //'\n'
+                               if (*pRawData != MSG_CH_SP && *pRawData != MSG_CH_TAB) {
+                                       ch = MSG_CH_NULL;
+                                       *pFieldLine = ch;
+                                       pFieldLine++;
+                               }
+                               break;
+
+                       case MSG_CH_TAB: //'\t'
+                               *pFieldLine = MSG_CH_SP;
+                               pFieldLine++;
+                               break;
+
+                       default:
+                               *pFieldLine = ch;
+                               pFieldLine++;
+                               break;
+                       }
+
+                       if (--cRaw <= 0) {  //If is the last character of header
+                               *pFieldLine = MSG_CH_NULL;
+                               pFieldLine++;
+                       }
+               }
+
+
+               if ((pFieldValue =  strchr(fieldLine, MSG_CH_COLON)) != NULL) {
+                       char*   pTemp = pFieldValue;
+                       char*   pValue = NULL;
+
+                       *pFieldValue++ = MSG_CH_NULL; //remove ':'
+
+                       while (*pFieldValue == MSG_CH_SP) //remove space ' '
+                               pFieldValue++;
+
+                       while ((fieldLine < pTemp--) && (*pTemp == MSG_CH_SP))
+                               *pTemp = MSG_CH_NULL;
+
+                       nLen = strlen(pFieldValue);
+
+                       if (nLen >= MSG_LOCAL_TEMP_BUF_SIZE) {
+                               szFieldValue = (char *)malloc(nLen + 1);
+                               memset(szFieldValue, 0 , nLen + 1);
+                               memcpy(szFieldValue, pFieldValue, nLen + 1);
+                       } else {
+                               memset(szTempBuf, 0, MSG_LOCAL_TEMP_BUF_SIZE);
+                               strcpy(szTempBuf, pFieldValue);
+                               szFieldValue = szTempBuf;
+                       }
+
+                       if (MsgStrcpyWithoutCRLF(szFieldValue, &szSrc) == true) {
+                               if (szSrc != NULL)
+                                       strncpy(szFieldValue, szSrc, strlen(szSrc));
+                       }
+                       if (szSrc) {
+                               free(szSrc);
+                               szSrc = NULL;
+                       }
+
+                       switch (_MsgGetCode(MSG_FIELD, fieldLine)) {
+                       case MSG_FIELD_CONTENT_ID:
+                               if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) != NULL)
+                                       *pTemp++ = MSG_CH_NULL;
+
+                               pValue = _MsgDecodeText(szFieldValue);
+                               memset (pType->szContentID, 0, MSG_MSG_ID_LEN + 1);
+
+                               if (pValue) {
+                                       // support CD & SD
+                                       length = MsgStrlen(pValue);
+                                       if (pValue[0] == '<' && pValue[length-1] == '>') {
+                                               strncpy(pType->szContentID, pValue + 1, length - 2);
+                                       } else {
+                                               strncpy(pType->szContentID, pValue, MSG_MSG_ID_LEN);
+                                       }
+
+                                       MSG_DEBUG("_MsgParsePartHeader: Content-ID = %s     %s\n", pFieldValue, pType->szContentID);
+
+                                       if (pTemp != NULL)
+                                               _MsgParseParameter(pType, pTemp);
+
+                                       free(pValue);
+                                       pValue = NULL;
+                               }
+
+                               break;
+
+                       case MSG_FIELD_CONTENT_LOCATION:
+                               if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) != NULL)
+                                       *pTemp++ = MSG_CH_NULL;
+
+                               pValue = _MsgDecodeText(szFieldValue);
+                               memset (pType->szContentLocation, 0, MSG_MSG_ID_LEN + 1);
+
+                               if (pValue) {
+                                       strncpy(pType->szContentLocation, pValue, MSG_MSG_ID_LEN);
+
+                                       MSG_DEBUG("_MsgParsePartHeader: Content-Location = %s     %s\n", pFieldValue, pType->szContentLocation);
+
+                                       if (pTemp != NULL)
+                                               _MsgParseParameter(pType, pTemp);
+
+                                       free(pValue);
+                                       pValue = NULL;
+                               }
+
+                               break;
+
+                       case MSG_FIELD_CONTENT_TYPE:
+                               if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) == NULL) {
+                                       if ((pTemp = strchr(szFieldValue, MSG_CH_SP)) != NULL)
+                                               *pTemp++ = MSG_CH_NULL;
+                               } else {
+                                       *pTemp++ = MSG_CH_NULL;
+                               }
+
+                               pType->type = _MsgGetCode(MSG_TYPE, szFieldValue);
+
+                               MSG_DEBUG("_MsgParsePartHeader: Content-Type = %s     %d\n", pFieldValue, pType->type);
+
+                               if (pType->type == INVALID_HOBJ)
+                                       pType->type = MIME_UNKNOWN;
+
+                               if (pTemp != NULL)
+                                       _MsgParseParameter(pType, pTemp);
+
+                               break;
+
+                       case MSG_FIELD_CONTENT_TRANSFER_ENCODING:
+                               if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) == NULL) {
+                                       if ((pTemp = strchr(szFieldValue, MSG_CH_SP)) != NULL)
+                                               *pTemp++ = MSG_CH_NULL;
+                               } else {
+                                       *pTemp++ = MSG_CH_NULL;
+                               }
+
+                               pType->encoding = _MsgGetCode(MSG_ENCODING, szFieldValue);
+
+                               MSG_DEBUG("_MsgParsePartHeader: Content-Encoding = %s     %d\n", pFieldValue, pType->encoding);
+
+                               if (pTemp != NULL)
+                                       _MsgParseParameter(pType, pTemp);
+
+                               break;
+
+                       case MSG_FIELD_CONTENT_DISPOSITION:
+                               if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) == NULL) {
+                                       if ((pTemp = strchr(szFieldValue, MSG_CH_SP)) != NULL)
+                                               *pTemp++ = MSG_CH_NULL;
+                               } else {
+                                       *pTemp++ = MSG_CH_NULL;
+                               }
+
+                               pType->disposition = _MsgGetCode(MSG_DISPOSITION, szFieldValue);
+
+                               MSG_DEBUG("_MsgParsePartHeader: Content-Disposition = %s     %d\n", pFieldValue, pType->disposition);
+
+                               if (pTemp != NULL)
+                                       _MsgParseParameter(pType, pTemp);
+
+                               break;
+
+#ifdef __SUPPORT_DRM__
+
+                       case MSG_FIELD_CONTENT_NAME:
+                               /* add to parse DCF header such as,
+                                * Right-Issuer, Content-Name, and Content-Description.
+                                */
+                               MsgMIMERemoveQuote(szFieldValue);
+                               pType->drmInfo.szContentName = MsgStrCopy(szFieldValue);
+                               break;
+
+                       case MSG_FIELD_CONTENT_DESCRIPTION:
+                               MsgMIMERemoveQuote(szFieldValue);
+                               pType->drmInfo.szContentDescription = MsgStrCopy(szFieldValue);
+                               break;
+
+                       case MSG_FIELD_CONTENT_VENDOR:
+                               MsgMIMERemoveQuote(szFieldValue);
+                               pType->drmInfo.szContentVendor = MsgStrCopy(szFieldValue);
+                               break;
+
+                       case MSG_FIELD_RIGHT_ISSUER:
+                               MsgMIMERemoveQuote(szFieldValue);
+                               pType->drmInfo.szRightIssuer = MsgStrCopy(szFieldValue);
+                               break;
+
+
+                       case MSG_FIELD_DRM_CONVERTED:
+                               MsgMIMERemoveQuote(szFieldValue);
+                               pType->nDrmConvertedStatus = atoi(szFieldValue);
+                               break;
+
+#endif
+                       case MSG_FILED_CONTENT_REPLACE_POS:
+                               MsgMIMERemoveQuote(szFieldValue);
+                               strncpy(pType->szContentRepPos, szFieldValue, sizeof(pType->szContentRepPos));
+                               break;
+
+                       case MSG_FILED_CONTENT_REPLACE_SIZE:
+                               MsgMIMERemoveQuote(szFieldValue);
+                               strncpy(pType->szContentRepSize, szFieldValue, sizeof(pType->szContentRepSize));
+                               break;
+
+                       case MSG_FILED_CONTENT_REPLACE_INDEX:
+                               MsgMIMERemoveQuote(szFieldValue);
+                               strncpy(pType->szContentRepIndex, szFieldValue, sizeof(pType->szContentRepIndex));
+                               break;
+
+                       default:
+                               MSG_DEBUG("_MsgParsePartHeader: Unhandled field \n");
+                               break;
+                       }
+               }
+
+               if (szFieldValue != NULL && szFieldValue != szTempBuf) {
+                       free(szFieldValue);
+                       szFieldValue = NULL;
+               }
+
+       }
+
+       return true;
+}
+
+char *MsgRemoveQuoteFromFilename(char *pSrc)
+{
+       int cLen = 0;   // length of pBuff
+       char *pBuff = NULL;
+
+       if (pSrc == NULL) {
+               MSG_DEBUG("MsgRemoveQuoteFromFilename: pSrc is Null\n");
+               return NULL;
+       }
+
+       cLen = strlen(pSrc);
+
+       pBuff = (char *)malloc(cLen + 1);
+
+       if (pBuff == NULL) {
+               MSG_DEBUG("MsgRemoveQuoteFromFilename: pBuff mem alloc fail!\n");
+               return NULL;
+       }
+       memset(pBuff, 0 , sizeof(char)*(cLen + 1));
+
+       // remove front quote
+       if (pSrc[0] == MSG_CH_QUOT) {
+               cLen--;
+               strncpy(pBuff, &pSrc[1], cLen);
+               pBuff[cLen] = '\0';
+       }
+
+       if (pSrc[0] == MSG_CH_LF) {
+               cLen--;
+               strncpy(pBuff, &pSrc[1], cLen);
+       } else {
+               strcpy(pBuff, pSrc);
+       }
+
+       // remove last qoute
+       if (pBuff[cLen-1] == MSG_CH_QUOT) {
+               pBuff[cLen-1] = '\0';
+       }
+
+       return pBuff;
+}
+
+bool MsgIsMultipart(int type)
+{
+       if (type == MIME_MULTIPART_RELATED || type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED ||
+               type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED || type == MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC ||
+               type == MIME_MULTIPART_MIXED || type == MIME_MULTIPART_REPORT) {
+               return true;
+       } else {
+               return false;
+       }
+}
+
+
+bool MsgIsHexChar(char *pSrc)
+{
+       int cIndex = 0;
+       int cLen = 0;
+       bool bRet = false;
+
+       cLen = strlen(pSrc);
+
+       for (cIndex = 0; cIndex < cLen ; cIndex++) {
+               if ((pSrc[cIndex] >= '0' && pSrc[cIndex] <= '9') || (pSrc[cIndex] >= 'A'&& pSrc[cIndex] <= 'F') ||
+                       (pSrc[cIndex] >= 'a' && pSrc[cIndex] <= 'f')) {
+                       bRet = true;
+               } else {
+                       return false;
+               }
+       }
+
+       return bRet;
+}
+
+char _MsgConvertHexValue(char *pSrc)
+{
+       int ch = 0;
+       int cIndex = 0;
+       int cLen = 0;
+       char ResultChar;
+       unsigned char uCh[2] = {0,};
+
+       cLen = strlen(pSrc);
+
+       for (cIndex = 0; cIndex < cLen ; cIndex += 2) {
+               uCh[0] = __MsgConvertCharToInt(pSrc[cIndex]);
+               uCh[1] = __MsgConvertCharToInt(pSrc[cIndex+1]);
+               ch = (int)uCh[0]<<4|uCh[1];
+       }
+
+       ResultChar = (char)ch;
+
+       return ResultChar;
+}
+
+int __MsgConvertCharToInt(char ch)
+{
+       if (ch>='0' && ch<='9') {
+               return ch - '0';
+       } else if (ch>='a'&& ch <='f') {
+               return ch -'a'+10;
+       } else if (ch>='A'&& ch <='F') {
+               return ch -'A'+10;
+       } else {
+               return 0;
+       }
+}
+
+bool MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2)
+{
+       if (pMsgType1->section == INVALID_HOBJ)
+               pMsgType1->section = pMsgType2->section;
+
+#ifdef __SUPPORT_DRM__
+       int             length = 0;
+
+       if (pMsgType1->drmInfo.drmType == MSG_DRM_TYPE_NONE)
+               pMsgType1->drmInfo.drmType = pMsgType2->drmInfo.drmType;
+
+
+       if (pMsgType1->szContentID[0] == '\0') {
+               strcpy(pMsgType1->szContentID, pMsgType2->szContentID);
+
+               if (pMsgType2->szContentID[0]) {
+                       length = MsgStrlen(pMsgType2->szContentID);
+                       if (pMsgType2->szContentID[0] == '<' && pMsgType2->szContentID[length - 1] == '>') {
+                               pMsgType1->drmInfo.szContentURI = MsgStrNCopy(pMsgType2->szContentID + 1, length - 2);
+                       } else {
+                               pMsgType1->drmInfo.szContentURI = MsgStrCopy(pMsgType2->szContentID);
+                       }
+               }
+       } else {
+               length = MsgStrlen(pMsgType1->szContentID);
+               if (pMsgType1->szContentID[0] == '<' && pMsgType1->szContentID[length - 1] == '>') {
+                       pMsgType1->drmInfo.szContentURI = MsgStrNCopy(pMsgType1->szContentID + 1, length - 2);
+               } else {
+                       pMsgType1->drmInfo.szContentURI = MsgStrCopy(pMsgType1->szContentID);
+               }
+       }
+#endif
+
+       if (pMsgType1->szContentLocation[0] == '\0')
+               strcpy(pMsgType1->szContentLocation, pMsgType2->szContentLocation);
+
+       /* Copy informations - we shoud open the pMsgType2's orgFile
+        * concerning its offset and size.
+        */
+       if (pMsgType2->szOrgFilePath[0] != '\0')
+               strcpy(pMsgType1->szOrgFilePath, pMsgType2->szOrgFilePath);
+
+       if (pMsgType2->disposition != INVALID_HOBJ)
+               pMsgType1->disposition = pMsgType2->disposition;
+
+       if ((pMsgType1->type != MIME_APPLICATION_VND_OMA_DRM_MESSAGE && pMsgType1->type != MIME_APPLICATION_VND_OMA_DRM_CONTENT) &&
+                pMsgType2->encoding != INVALID_HOBJ)
+               pMsgType1->encoding = pMsgType2->encoding;
+
+       pMsgType1->contentSize = pMsgType2->contentSize;
+       pMsgType1->offset = pMsgType2->offset;
+       pMsgType1->size = pMsgType2->size;
+       pMsgType1->type = pMsgType2->type;
+
+       MsgCopyNestedMsgParam(&(pMsgType1->param), &(pMsgType2->param));
+
+       if (pMsgType1->param.szName[0]) {
+#ifdef __SUPPORT_DRM__
+               pMsgType1->drmInfo.szContentName = MsgStrCopy(pMsgType2->param.szName);
+#endif
+       }
+
+       return true;
+}
+
+
+bool MsgCopyNestedMsgParam(MsgContentParam *pParam1, MsgContentParam *pParam2)
+{
+       if (pParam1->charset == MSG_CHARSET_UNKNOWN)
+               pParam1->charset = pParam2->charset;
+
+       if (pParam1->type == MIME_UNKNOWN)
+               pParam1->type = pParam2->type;
+
+       /* Don't copy pParam2->pPresentation */
+
+       /* For alternative: copy the boundary string */
+       if (pParam2->szBoundary[0] !='\0')
+               strcpy(pParam1->szBoundary, pParam2->szBoundary);
+
+       if (pParam1->szFileName[0] =='\0')
+               strcpy(pParam1->szFileName, pParam2->szFileName);
+
+       if (pParam1->szName[0] =='\0')
+               strcpy(pParam1->szName, pParam2->szName);
+
+       if (pParam1->szStart[0] =='\0')
+               strcpy(pParam1->szStart, pParam2->szStart);
+
+       if (pParam1->szStartInfo[0] =='\0')
+               strcpy(pParam1->szStartInfo, pParam2->szStartInfo);
+
+       return true;
+}
+
+bool MsgIsMultipartMixed(int type)
+{
+       if (type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED || type == MIME_MULTIPART_MIXED) {
+               return true;
+       } else {
+               return false;
+       }
+}
+
+bool MsgStrcpyWithoutCRLF(char *pOrg, char **ppNew)
+{
+       int nLen = 0;
+       int     i = 0;
+       int index = 0;
+       char*   pDest = NULL;
+
+
+       nLen = strlen(pOrg);
+
+       pDest = (char *)malloc(nLen + 1);
+
+       if (pDest == NULL) {
+               MSG_DEBUG("MsgStrcpyWithoutCRLF: malloc is failed\n");
+               return false;
+       }
+
+       memset(pDest, 0 , (nLen + 1));
+
+       for (i = 0; i < nLen ; i++) {
+               if (i < nLen - 2) {
+                       if ((pOrg[i] == MSG_CH_CR && pOrg[i+1] == MSG_CH_LF && pOrg[i+2] == MSG_CH_TAB) ||
+                               (pOrg[i] == MSG_CH_CR && pOrg[i+1] == MSG_CH_LF && pOrg[i+2] == MSG_CH_SP)) {
+                               i+=2;
+                               continue;
+                       }
+               }
+               pDest[index++] = pOrg[i];
+       }
+       *ppNew = pDest;
+
+       return true;
+}
+
+bool MmsGetMsgAttrib(MmsMsgID msgID, MmsAttrib* pAttrib)
+{
+       MmsMsg *pMsg = NULL;
+
+       memset(pAttrib, 0, sizeof(MmsAttrib));
+       MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+       memcpy(pAttrib, &(pMsg->mmsAttrib), sizeof(MmsAttrib));
+
+       MSG_DEBUG("MmsGetMsgAttrib: msgID = %lu ---------------------\n", msgID);
+
+       if ('\0' != pMsg->szTrID[0])
+               MSG_DEBUG("szTrID = %s \n", pMsg->szTrID);
+
+       MSG_END();
+       return true;
+}
+
+bool __MsgIsInvalidFileNameChar(char ch)
+{
+       if ((ch == 0x5C /* \ */) ||
+               (ch == 0x2F /* / */) ||
+               (ch == 0x3A /* : */) ||
+               (ch == 0x2A /* * */) ||
+               (ch == 0x3F /* ? */) ||
+               (ch == 0x22 /* " */) ||
+               (ch == 0x3C /* < */) ||
+               (ch == 0x3E /* > */) ||
+               (ch == 0x7C /* | */))
+               return true;
+
+       return false;
+}
+
+bool _MmsDataUpdateLastStatus(MmsMsg *pMsg)
+{
+       MmsMsgMultiStatus*      pStatus = NULL;
+
+       pStatus = pMsg->mmsAttrib.pMultiStatus;
+
+       while (pStatus != NULL) {
+               pStatus->bDeliveyrReportIsLast = false;
+               pStatus->bReadReplyIsLast = false;
+               pStatus = pStatus->pNext;
+       }
+
+       return true;
+}
+
+
+bool MmsAddrUtilCompareAddr(char *pszAddr1, char *pszAddr2)
+{
+       int len1;
+       int len2;
+       char *p;
+
+       MmsAddrUtilRemovePlmnString(pszAddr1);
+       MmsAddrUtilRemovePlmnString(pszAddr2);
+
+       MSG_DEBUG("##### pszAddr1 = %s #####", pszAddr1);
+       MSG_DEBUG("##### pszAddr2 = %s #####", pszAddr2);
+       if (!strcmp(pszAddr1, pszAddr2))
+               return true;
+
+       len1 = strlen(pszAddr1);
+       len2 = strlen(pszAddr2);
+
+       if (len1 > len2) {
+               p = strstr(pszAddr1, pszAddr2);
+       } else {
+               p = strstr(pszAddr2, pszAddr1);
+       }
+
+       if (p)
+               return true;
+
+       return false;
+}
+
+int MsgGetLatin2UTFCodeSize(unsigned char *szSrc, int nChar)
+{
+       int nCount = 0;
+
+       MSG_DEBUG("MsgGetLatin2UTFCodeSize: --------------- \n");
+
+       if ((szSrc == NULL) || (nChar <= 0)) {
+               MSG_DEBUG("MsgGetLatin2UTFCodeSize: szSrc is NULL !!!! --------------- \n");
+               return 0;
+       }
+
+       while ((nChar > 0) && (*szSrc != '\0')) {
+               if (0x01 <= *szSrc && *szSrc <= 0x7F) {
+                       nCount += 1;
+                       szSrc++;
+                       nChar--;
+               } else {
+                       nCount += 2;
+                       szSrc++;
+                       nChar--;
+               }
+       }
+
+       return nCount;
+}
+
+int MsgLatin5code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar)
+{
+       unsigned char *org;
+       unsigned char t1;
+       unsigned char t2;
+       unsigned short temp = 0;
+
+       org = des;
+       outBufSize--;   //Null Character
+
+       while ((nChar > 0) && (*szSrc != '\0')) {
+
+               if (*szSrc >= 0x01 && *szSrc <= 0x7F) { //basic common
+                       temp = (unsigned short)(*szSrc);
+
+                       outBufSize --;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       *des = (unsigned char) ((*szSrc) & 0x007F);
+
+                       des++;
+                       szSrc++;
+                       nChar--;
+               } else if ((*szSrc == 0x00) || (*szSrc >= 0x80 && *szSrc <= 0x9F) ||
+                                       (*szSrc >= 0xA0 && *szSrc <= 0xCF) || (*szSrc >= 0xD1 && *szSrc <= 0xDC) ||
+                                       (*szSrc >= 0xDF && *szSrc <= 0xEF) || (*szSrc >= 0xF1 && *szSrc <= 0xFC) ||
+                                       (*szSrc == 0xFF)) {//uni 0x00A0 ~ 0x00CF
+
+                       temp = (unsigned short)(*szSrc);
+
+                       outBufSize -= 2;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t2 = (unsigned char) (temp & 0x003F);                           //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0x07C0) >> 6);            //      right most 5 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       szSrc += 1;
+                       nChar -= 1;
+               } else if (*szSrc == 0xD0) {//empty section OR vendor specific codes.
+
+                       temp = 0x011E;
+
+                       outBufSize -= 2;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t2 = (unsigned char) (temp & 0x003F);                           //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0x07C0) >> 6);            //      right most 5 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       szSrc += 1;
+                       nChar -= 1;
+               } else if (*szSrc == 0xDD) {
+                       temp = 0x0130;
+
+                       outBufSize -= 2;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t2 = (unsigned char) (temp & 0x003F);                           //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0x07C0) >> 6);            //      right most 5 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       szSrc += 1;
+                       nChar -= 1;
+               } else if (*szSrc == 0xDE) {
+                       temp = 0x015E;
+
+                       outBufSize -= 2;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t2 = (unsigned char) (temp & 0x003F);                           //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0x07C0) >> 6);            //      right most 5 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       szSrc += 1;
+                       nChar -= 1;
+               } else if (*szSrc == 0xF0) {
+                       temp = 0x011F;
+                               outBufSize -= 2;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t2 = (unsigned char) (temp & 0x003F);                           //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0x07C0) >> 6);            //      right most 5 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       szSrc += 1;
+                       nChar -= 1;
+               } else if (*szSrc == 0xFD) {
+                       temp = 0x0131;
+
+                       outBufSize -= 2;
+
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t2 = (unsigned char) (temp & 0x003F);                           //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0x07C0) >> 6);            //      right most 5 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       szSrc += 1;
+                       nChar -= 1;
+               } else if (*szSrc == 0xFE) {
+                       temp = 0x015F;
+
+                       outBufSize -= 2;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t2 = (unsigned char) (temp & 0x003F);                           //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0x07C0) >> 6);            //      right most 5 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       szSrc += 1;
+                       nChar -= 1;
+               } else {
+                       return -1;
+               }
+       }
+__RETURN:
+       *des = 0;
+       return(des-org);
+}
+
+int MsgGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar)
+{
+       int nCount = 0;
+
+       MSG_DEBUG("MsgGetLatin52UTFCodeSize: --------------- \n");
+
+       if ((szSrc == NULL) || (nChar <= 0))
+               return 0;
+
+       while ((nChar > 0) && (*szSrc != '\0')) {
+               if (*szSrc >= 0x01 && *szSrc <= 0x7F) {
+                       nCount += 1;
+                       szSrc++;
+                       nChar--;
+               } else if (*szSrc == 0x00 || (*szSrc >= 0x80 && *szSrc <= 0x9F) ||
+                                       (*szSrc >= 0xA0 && *szSrc <= 0xCF) || (*szSrc >= 0xD1 && *szSrc <= 0xDC) |
+                                       (*szSrc >= 0xDF && *szSrc <= 0xEF) || (*szSrc >= 0xF1 && *szSrc <= 0xFC) ||
+                                       *szSrc == 0xD0 || *szSrc == 0xDD || *szSrc == 0xDE || *szSrc == 0xF0 ||
+                                       *szSrc == 0xFD || *szSrc == 0xFE        || *szSrc == 0xFF) { //uni 0x00A0 ~ 0x00CF
+                       nCount += 2;
+                       szSrc++;
+                       nChar--;
+               } else {
+                       return -1;
+               }
+       }
+       return nCount;
+}
+
+int MsgLatin2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar)
+{
+       unsigned char*  org;
+       unsigned char   t1, t2;
+
+       MSG_DEBUG("MsgLatin2UTF: --------------- \n");
+
+       org = des;
+       outBufSize--;                   // NULL character
+
+       while ((nChar > 0) && (*szSrc != '\0')) {
+               if (0x01 <= *szSrc && *szSrc <= 0x7F) {
+                       /* check outbuffer's room for this UTF8 character */
+
+                       outBufSize --;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       *des = (unsigned char) (*szSrc & 0x007F);
+
+                       des++;
+                       szSrc++;
+                       nChar--;
+               } else {
+                       /* check outbuffer's room for this UTF8 character */
+
+                       outBufSize -= 2;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t2 = (unsigned char) (*szSrc & 0x003F);                         //      right most 6 bit
+                       t1 = (unsigned char) ((*szSrc & 0xC0) >> 6);            //      right most 2 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des + 1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       szSrc += 1;
+                       nChar -= 1;
+               }
+       }
+
+__RETURN:
+
+       *des = 0;
+       return (des - org);
+}
+
+
+int MsgLatin7code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar)
+{
+       unsigned char *org;
+       unsigned char t1;
+       unsigned char t2;
+       unsigned char t3;
+       unsigned short temp = 0;
+
+       MSG_DEBUG("MsgUnicode2UTF: --------------- \n");
+
+       org = des;
+       outBufSize--;   //Null Character
+
+       while ((nChar > 0) && (*szSrc != '\0')) {
+               if (*szSrc >= 0x01 && *szSrc <= 0x7F) {
+                       temp = (unsigned short)(*szSrc);
+
+                       outBufSize --;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       *des = (unsigned char) (temp & 0x007F);
+
+                       des++;
+                       szSrc++;
+                       nChar--;
+
+               } else if ((*szSrc == 0x00) || (*szSrc >= 0x80 && *szSrc <= 0x9F) ||
+                                       (*szSrc >= 0xA3 && *szSrc <= 0xAD) || (*szSrc == 0xBB)) { // consider 0xA4, 0xA5
+
+                       temp = (unsigned short)(*szSrc);
+
+                       outBufSize -= 2;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t2 = (unsigned char) (temp & 0x003F);                           //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0xC0) >> 6);              //      right most 2 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des + 1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       szSrc += 1;
+                       nChar -= 1;
+               } else if (*szSrc == 0xA0) {
+                       temp = 0x0020;
+                       //*des = temp to utf-8
+                       outBufSize--;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       *des = (unsigned char) (temp & 0x007F);
+
+                       des++;
+                       szSrc++;
+                       nChar--;
+
+               } else if (*szSrc == 0xA1) {
+                       temp = 0x2018;
+
+                       outBufSize -= 3;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t3 = (unsigned char) (temp & 0x003F);                                   //      right most 6 bit
+                       t2 = (unsigned char) ((temp & 0x0FC0) >> 6);                    //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0xF000) >> 12);                   //      right most 4 bit
+
+                       *des = 0xE0 | (t1 & 0x0F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+                       *(des+2) = 0x80 | (t3 & 0x3F);
+
+                       des += 3;
+                       szSrc += 1;
+                       nChar -= 1;
+
+               } else if (*szSrc == 0xA2) {
+                       temp = 0x2019;
+
+                       outBufSize -= 3;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t3 = (unsigned char) (temp & 0x003F);                                   //      right most 6 bit
+                       t2 = (unsigned char) ((temp & 0x0FC0) >> 6);                    //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0xF000) >> 12);                   //      right most 4 bit
+
+                       *des = 0xE0 | (t1 & 0x0F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+                       *(des+2) = 0x80 | (t3 & 0x3F);
+
+                       des += 3;
+                       szSrc += 1;
+                       nChar -= 1;
+
+               } else if (*szSrc == 0xAF) {
+                       temp = 0x2015;
+
+                       outBufSize -= 3;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t3 = (unsigned char) (temp & 0x003F);                                   //      right most 6 bit
+                       t2 = (unsigned char) ((temp & 0x0FC0) >> 6);                    //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0xF000) >> 12);                   //      right most 4 bit
+
+                       *des = 0xE0 | (t1 & 0x0F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+                       *(des+2) = 0x80 | (t3 & 0x3F);
+
+                       des += 3;
+                       szSrc += 1;
+                       nChar -= 1;
+
+               } else if (0xB0 <= *szSrc && *szSrc <= 0xB4) { //0x00B0 ~ 0x00B4
+
+                       temp = (unsigned short)(*szSrc);
+
+                       outBufSize -= 2;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t2 = (unsigned char) (temp & 0x003F);                           //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0x07C0) >> 6);            //      right most 5 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       szSrc += 1;
+                       nChar -= 1;
+
+               } else if ((0xB5 <= *szSrc &&  *szSrc <= 0xBA) ||
+                               (0xBC <= *szSrc && *szSrc <= 0xD1) ||
+                               (0xD3 <= *szSrc && *szSrc <= 0xFE)) {
+                       temp= (unsigned short)(*szSrc + 0x02D0);
+
+                       outBufSize -= 2;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t2 = (unsigned char) (temp & 0x003F);                           //      right most 6 bit
+                       t1 = (unsigned char) ((temp & 0x07C0) >> 6);            //      right most 5 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       szSrc += 1;
+                       nChar -= 1;
+
+               } else {
+                       return -1;
+               }
+
+       }
+
+__RETURN:
+       *des = 0;
+       return(des - org);
+}
+
+int MsgGetLatin72UTFCodeSize(unsigned char *szSrc, int nChar)
+{
+       int nCount = 0;
+
+       MSG_DEBUG("MsgGetLatin72UTFCodeSize: --------------- \n");
+
+       if ((szSrc == NULL) || (nChar <= 0))
+               return 0;
+
+       while ((nChar > 0) && (*szSrc != '\0')) {
+
+               if ((*szSrc >= 0x01 && *szSrc <= 0x7F) || (*szSrc == 0xA0)) {
+                       nCount += 1;
+                       szSrc++;
+                       nChar--;
+               } else if (*szSrc == 0x00 || (0x80 <= *szSrc && *szSrc <= 0x9F) || (0xA3 <= *szSrc && *szSrc <= 0xAD) ||
+                                       (0xB0 <= *szSrc && *szSrc <= 0xB4) || (0xB5 <= *szSrc && *szSrc <= 0xFE)) {
+                       nCount += 2;
+                       szSrc++;
+                       nChar--;
+               } else if (*szSrc == 0xA1 ||*szSrc == 0xA2 || *szSrc == 0xAF) {
+                       nCount += 3;
+                       szSrc += 1;
+                       nChar -= 1;
+
+               } else {
+                       return -1;
+               }
+       }
+       return nCount;
+}
+
+int MsgUnicode2UTF(unsigned char *des, int outBufSize, unsigned short *szSrc, int nChar)
+{
+       unsigned char *org;
+       unsigned char t1;
+       unsigned char t2;
+       unsigned char t3;
+
+       MSG_DEBUG("MsgUnicode2UTF: --------------- \n");
+
+       org = des;
+       outBufSize--;                   // NULL character
+
+       while ((nChar > 0) && (*szSrc != '\0')) {
+               if (0x0001 <= *szSrc && *szSrc <= 0x007F) {
+                       /* check outbuffer's room for this UTF8 character */
+
+                       outBufSize --;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       *des = (unsigned char) (*szSrc & 0x007F);
+
+                       des++;
+                       szSrc++;
+                       nChar--;
+               } else if  ((*szSrc == 0x0000) || (0x0080 <= *szSrc && *szSrc <= 0x07FF)) {
+                       /* check outbuffer's room for this UTF8 character */
+
+                       outBufSize -= 2;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t2 = (unsigned char) (*szSrc & 0x003F);                         //      right most 6 bit
+                       t1 = (unsigned char) ((*szSrc & 0x07C0) >> 6);          //      right most 5 bit
+
+                       *des = 0xC0 | (t1 & 0x1F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+
+                       des += 2;
+                       szSrc += 1;
+                       nChar -= 1;
+               } else {
+                       /* check outbuffer's room for this UTF8 character */
+
+                       outBufSize -= 3;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       t3 = (unsigned char) (*szSrc & 0x003F);                                 //      right most 6 bit
+                       t2 = (unsigned char) ((*szSrc & 0x0FC0) >> 6);                  //      right most 6 bit
+                       t1 = (unsigned char) ((*szSrc & 0xF000) >> 12);                 //      right most 4 bit
+
+                       *des = 0xE0 | (t1 & 0x0F);
+                       *(des+1) = 0x80 | (t2 & 0x3F);
+                       *(des+2) = 0x80 | (t3 & 0x3F);
+
+                       des += 3;
+                       szSrc += 1;
+                       nChar -= 1;
+               }
+       }
+
+__RETURN:
+
+       *des = 0;
+       return (des - org);
+}
+
+int MsgGetUnicode2UTFCodeSize(unsigned short *szSrc, int nChar)
+{
+       int nCount = 0;
+
+       MSG_DEBUG("MsgGetUnicode2UTFCodeSize: --------------- \n");
+
+       if ((szSrc == NULL) || (nChar <= 0)) {
+               MSG_DEBUG("MsgGetUnicode2UTFCodeSize: szSrc is NULL !!!! --------------- \n");
+               return 0;
+       }
+
+       while ((nChar > 0) && (*szSrc != '\0')) {
+               if (0x0001 <= *szSrc && *szSrc <= 0x007F) {
+                       nCount += 1;
+                       szSrc++;
+                       nChar--;
+               } else if  ((*szSrc == 0x0000) || (0x0080 <= *szSrc && *szSrc <= 0x07FF)) {
+                       nCount += 2;
+                       szSrc++;
+                       nChar--;
+               } else {
+                       nCount += 3;
+                       szSrc++;
+                       nChar--;
+               }
+       }
+
+       return nCount;
+}
+
+bool MmsAddrUtilCheckEmailAddress(char *pszAddr)
+{
+       if (!pszAddr || pszAddr[0] == 0)
+               return false;
+
+       if (!strchr (pszAddr, MSG_MMS_CH_EMAIL_AT))
+               return false;
+
+       return true;
+}
+
+bool MmsAddrUtilRemovePlmnString(char *pszAddr)
+{
+       char *pszAddrCopy = NULL;
+       char *pszStrStart = NULL;
+       char *pszStrTemp = NULL;
+       int strLen = 0;
+
+       if ((!pszAddr) || (pszAddr[0] == 0)) {
+               MSG_DEBUG("MmsAddrUtilRemovePlmnString: pszAddr is null or zero\n");
+               return false;
+       }
+
+       strLen = strlen(pszAddr);
+
+       pszAddrCopy = (char*)malloc(strLen + 1);
+       if (!pszAddrCopy) {
+               MSG_DEBUG("MmsAddrUtilRemovePlmnString: pszAddrCopy is NULL, mem alloc failed\n");
+               return false;
+       }
+
+       strcpy(pszAddrCopy, pszAddr);
+
+
+       pszAddr[0] = 0;
+       pszStrStart = pszAddrCopy;
+
+       while (true) {
+               char*   pszStrEnd = NULL;
+               int             addressLen = 0;
+
+               if (MmsAddrUtilCheckEmailAddress(pszAddrCopy))
+                       pszStrEnd = strstr(pszStrStart, "/TYPE=PLMN");
+               else
+                       pszStrEnd = strstr(pszStrStart, "/");
+
+               if (!pszStrEnd) {
+                       // "/TYPE=PLMN" not found
+
+                       int remainedLen = strlen(pszStrStart);
+
+                       if (remainedLen <= 0)
+                               break;
+
+                       strcat(pszAddr, pszStrStart);
+
+                       break;
+               }
+
+               // Get one address length
+               addressLen = pszStrEnd - pszStrStart;
+
+               strncat(pszAddr, pszStrStart, addressLen);
+
+               // Find next address
+               pszStrStart = pszStrEnd;
+
+               pszStrTemp = strstr(pszStrStart, MSG_MMS_STR_ADDR_DELIMETER);
+
+               if (pszStrTemp) {
+                       addressLen = pszStrTemp - pszStrEnd;
+                       pszStrStart += addressLen;
+               } else {
+                       pszStrStart += strlen(pszStrEnd);
+               }
+
+               if (pszStrStart[0] == 0)        // end of string
+                       break;
+
+
+               strcat(pszAddr, MSG_MMS_STR_ADDR_DELIMETER);    // add ';'
+               pszStrStart++;  // remove ';'
+       }
+
+       if (pszAddr[0] == 0)
+               strcpy(pszAddr, pszAddrCopy);
+
+       free(pszAddrCopy);
+
+       return true;
+}
+
+int MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar)
+{
+       unsigned char *org;
+
+       MSG_DEBUG("MsgCutUTFString: --------------- \n");
+
+       org = des;
+       outBufSize--;                   // NULL character
+
+       while ((nChar > 0) && (*szSrc != '\0')) {
+               if (*szSrc < 0x80) {
+                       outBufSize --;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       *des = *szSrc;
+                       des++;
+                       szSrc++;
+               } else if  (((0xC0 <= *szSrc) && (*szSrc < 0xE0)) && (*(szSrc+1) >= 0x80)) {
+                       outBufSize -= 2;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       *des = *szSrc;
+                       *(des + 1) = *(szSrc + 1);
+
+                       des += 2;
+                       szSrc += 2;
+               } else if  ((*szSrc >= 0xE0) && (*(szSrc+1) >= 0x80) && (*(szSrc+2) >= 0x80)) {
+                       outBufSize -= 3;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       *des = *szSrc;
+                       *(des + 1) = *(szSrc + 1);
+                       *(des + 2) = *(szSrc + 2);
+
+                       des += 3;
+                       szSrc += 3;
+               } else {
+                       outBufSize --;
+                       if (outBufSize < 0)
+                               goto __RETURN;
+
+                       *des = *szSrc;
+                       des++;
+                       szSrc++;
+                       MSG_DEBUG("MsgCutUTFString: utf8 incorrect range!\n");
+               }
+
+               nChar--;
+       }
+
+__RETURN:
+
+       *des = 0;
+       return (des - org);
+}
+
+void MsgMIMERemoveQuote(char *szSrc)
+{
+       int             length = 0;
+
+       length = MsgStrlen(szSrc);
+       if (szSrc[0] == MSG_CH_QUOT && szSrc[length-1] == MSG_CH_QUOT) {
+               int index = 0;
+
+               for (index = 0; index < length-2; index++)
+                       szSrc[index] = szSrc[index+1];
+               szSrc[index] = '\0';
+       }
+}
+
+bool MsgLoadDataToDecodeBuffer(FILE *pFile, char **ppBuf, int *pPtr, int *pOffset, char *pInBuf1, char *pInBuf2, int maxLen, int *pBufLen, int endOfFile)
+{
+       MSG_BEGIN();
+       int nRead = 0;
+       int length= 0;
+
+       MSG_DEBUG("MsgLoadDataToDecodeBuffer: \n");
+
+       if (pFile == NULL) {
+               MSG_DEBUG("Error");
+
+               *pBufLen = 0;
+               return false;
+       }
+
+       if (pPtr == NULL || pInBuf1 == NULL || pInBuf2 == NULL) {
+               MSG_DEBUG("Error");
+
+               *pBufLen = 0;
+               return false;
+       }
+
+       if (*pBufLen == 0) {
+               length = maxLen - (*pPtr);
+       } else {
+               length = (*pBufLen) - (*pPtr);
+       }
+
+       if (length < 0)
+               length = 0;
+
+       if ((*ppBuf) == NULL) {
+               memset(pInBuf1, 0, maxLen);
+               (*ppBuf) = pInBuf1;
+       } else if ((*ppBuf) == pInBuf1) {
+               memset(pInBuf2, 0, maxLen);
+               if (length)
+                       memcpy(pInBuf2, pInBuf1 + (*pPtr), length);
+               (*ppBuf) = pInBuf2;
+       } else {
+               memset(pInBuf1, 0, maxLen);
+               if (length)
+                       memcpy(pInBuf1, pInBuf2 + (*pPtr), length);
+               (*ppBuf) = pInBuf1;
+       }
+
+       (*pPtr) = 0;
+
+       if (*pOffset == endOfFile) {
+               *pBufLen = length;
+               return true;
+       }
+
+       if (maxLen == length) {
+               /* (*pPtr) was 0 */
+               if (MsgReadFileForDecode(pFile, (*ppBuf), maxLen, &nRead) == false)
+                       return false;
+
+               *pBufLen = nRead;
+       } else {
+               if (MsgReadFileForDecode(pFile, (*ppBuf) + length, maxLen - length, &nRead) == false)
+                       return false;
+
+               *pBufLen = length + nRead;
+       }
+
+       if ((*pOffset = MsgFtell(pFile)) == -1L) {
+               MSG_DEBUG("MsgFtell Error");
+               return false;
+       }
+
+       MSG_END();
+
+       return true;
+}
+
+
+bool MsgGetTypeByFileName(int *type, char *szFileName)
+{
+       char *pExt   = NULL;
+       AvCodecType AvType = AV_CODEC_NONE;
+
+       pExt = strrchr(szFileName, '.');
+       if (pExt == NULL || pExt[0] == '\0')
+               goto __CATCH;
+
+       pExt++;
+
+       if (strcasecmp(pExt, "mp4") == 0 ||strcasecmp(pExt, "mpeg4") == 0 ||strcasecmp(pExt, "3gp") == 0 ||strcasecmp(pExt, "3gpp") == 0) {
+
+               if (szFileName[0] != '/')
+                       goto __CATCH;
+
+               AvType = AvGetFileCodecType(szFileName);
+               MSG_DEBUG("MsgGetTypeByFileName:AvType(0x%x)\n", AvType);
+
+               switch (AvType) {
+               case AV_DEC_AUDIO_MPEG4:
+                       *type = MIME_AUDIO_MP4;
+                       break;
+
+               case AV_DEC_VIDEO_MPEG4:
+                       *type = MIME_VIDEO_MP4;
+                       break;
+
+               default:
+                       *type = MIME_VIDEO_3GPP;
+                       break;
+               }
+               return true;
+       }
+
+       if (strcasecmp(pExt, "amr") == 0) {
+               *type = MIME_AUDIO_AMR;
+               return true;
+       } else if ((strcasecmp(pExt, "mid") == 0) || (strcasecmp(pExt, "midi") == 0)) {
+               *type = MIME_AUDIO_MIDI;
+               return true;
+       } else if (strcasecmp(pExt, "imy") == 0) {
+               *type = MIME_TEXT_X_IMELODY;
+               return true;
+       }
+
+       *type = MimeGetMimeFromExtInt((const char*)pExt);
+       MSG_DEBUG("MsgGetTypeByFileName: szFileName = %s     type = %d \n", szFileName, type);
+       return true;
+
+
+__CATCH:
+
+       *type = MIME_UNKNOWN;
+       MSG_DEBUG("MsgGetTypeByFileName: szFileName = %s     type = %d \n", szFileName, type);
+
+       return false;
+
+}
+
+
+/*
+ *     This function write media data from raw data to file.
+ *     @param  pMsg
+ *     @param  pPartBody
+ *     @param  pszMailboxPath  : path of mailbox
+ *     @param  pszMsgFilename  : name of msg file
+ *     @param  index                   : used for file naming
+ *     @param  bSave                   : if true, file will be save otherwise just filename will be stored.
+ */
+bool _MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *pszMailboxPath, char *pszMsgFilename, int index, bool bSave)
+{
+       FILE *pFile = NULL;
+       char *pExt = NULL;
+       char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, };        // file name of temp file
+       char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; // full absolute path of temp file.
+
+       MSG_DEBUG("****   _MmsSaveMediaData:  [Multi part]  START  ***\n");
+
+       if (!pPartType) {
+               MSG_DEBUG("pPartType is NULL\n");
+               return true; // why true value is retured ??? ; false;
+       }
+
+       if (pPartType->param.szName[0] == '\0' && pPartType->param.szFileName[0] == '\0')
+               strcpy(pPartType->param.szName, pPartType->param.szFileName);
+
+       if (pPartType->param.szName) {
+               strcpy(szFileName, pPartType->param.szName);
+       } else {
+               snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%lu", (unsigned long)index);
+       }
+
+
+#ifndef __SUPPORT_DRM__
+       MsgMakeFileName(pPartType->type, szFileName, 0);        //FL & CD -> extension(.dm) SD -> extension(.dcf)
+#else
+       MsgMakeFileName(pPartType->type, szFileName, pPartType->drmInfo.drmType, 0);    //FL & CD -> extension(.dm) SD -> extension(.dcf)
+       if (MsgDRMIsForwardLockType(pPartType->drmInfo.drmType))
+               MsgChangeDrm2FileName(szFileName);
+#endif
+
+
+       snprintf(szFullPath, MSG_FILEPATH_LEN_MAX, "%s%s.dir/%s", pszMailboxPath, pszMsgFilename, szFileName);  // get absolute path of each temp file of each part
+       snprintf(pPartType->param.szFileName, MSG_FILENAME_LEN_MAX+1, "%s.dir/%s", pszMsgFilename, szFileName);         // store relative path of each temp file of each part including sub folder.
+
+       if (pPartType->type == MIME_APPLICATION_OCTET_STREAM)
+               MsgGetTypeByFileName(&pPartType->type, szFullPath);
+
+       // save file
+       if (bSave) {
+               if ((pFile = MsgOpenFile(szFullPath, "wb+")) == NULL) {
+                       MSG_DEBUG("MsgOpenFile failed");
+                       goto __CATCH;
+               }
+
+               if (MmsGetMediaPartData(pPartType, pPartBody, pFile) == false) {
+                       MSG_DEBUG("MmsGetMediaPartData fail [index:%d]\n", index);
+                       goto __CATCH;
+               }
+
+               MsgCloseFile(pFile);
+               pFile = NULL;
+               if (pPartType->drmInfo.drmType != MSG_DRM_TYPE_NONE) {
+                       MsgDrmRegisterFile(MSG_MODE_FILE, szFullPath, strlen(szFullPath));
+
+                       /* change szDrm2FullPath as current content path*/
+                       if (pPartType->drmInfo.szDrm2FullPath) {
+                               free(pPartType->drmInfo.szDrm2FullPath);
+                               pPartType->drmInfo.szDrm2FullPath = MsgStrCopy(szFullPath);
+                       }
+               }
+
+       }
+       MSG_DEBUG("****   MmsGetMediaPartData:  [Multi part]  E  N  D  (Successfully)  ***\n");
+
+       return true;
+
+__CATCH:
+
+       if (pFile != NULL) {
+               MsgCloseFile(pFile);
+               pFile = NULL;
+       }
+
+       return false;
+}
+
+
+
+bool MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE* pFile)
+{
+       int nRead = 0;
+       int nRead2 = 0;
+       char *pData = NULL;
+       char *pNewData = NULL;
+       char *pTempData = NULL;
+       int msgEncodingValue = 0;
+       int msgTypeValue = 0;
+       int msgCharsetValue     = 0;
+       int cidLen = 0;
+       char *szCid = NULL;
+       int offset = 0;
+       int size = 0;
+
+       msgEncodingValue = pPartType->encoding;
+       msgTypeValue = pPartType->type;
+       msgCharsetValue = pPartType->param.charset;
+
+       cidLen = MsgStrlen(szCid);
+
+       offset = pPartBody->offset;
+       size = pPartBody->size;
+
+       if (pPartBody->szOrgFilePath[0]) {
+               pTempData = MsgOpenAndReadMmsFile(pPartBody->szOrgFilePath, offset, size, &nRead);
+
+               if (pTempData == NULL) {
+                       MSG_DEBUG("MmsGetMediaPartData : pTempData read fail\n");
+                       goto __CATCH;
+               }
+
+               pData = pTempData;
+       } else if (pPartBody->body.pText) {
+               pData = pPartBody->body.pText;
+               nRead = pPartBody->size;
+       }
+
+       if (pData == NULL) {
+               MSG_DEBUG("MmsGetMediaPartData : there is no data \n");
+               goto __RETURN;
+       }
+
+       pNewData = MmsGetBinaryUTF8Data(pData, nRead, msgEncodingValue, msgTypeValue, msgCharsetValue, &nRead2);
+       pPartType->encoding = MSG_ENCODING_BINARY;
+
+       if (MsgIsText(msgTypeValue))
+               pPartType->param.charset = MSG_CHARSET_UTF8;
+
+       if (MsgWriteFile(pNewData, sizeof(char), nRead2,  pFile) != (size_t)nRead2) {
+               MSG_DEBUG("MmsGetMediaPartData: file writing fail \n");
+
+               goto __CATCH;
+       }
+
+__RETURN:
+
+       if (pNewData) {
+               free(pNewData);
+               pNewData = NULL;
+       }
+
+       if (pTempData) {
+               free(pTempData);
+               pTempData = NULL;
+       }
+
+       return true;
+
+__CATCH:
+
+       if (pNewData) {
+               free(pNewData);
+               pNewData = NULL;
+       }
+
+       if (pTempData) {
+               free(pTempData);
+               pTempData = NULL;
+       }
+
+       return false;
+}
+
+char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msgTypeValue, int msgCharsetValue, int *npRead)
+{
+       int nChar = 0;
+       int nByte = 0;
+       int nTemp = 0;
+       char *pTemp = NULL;
+       unsigned short *mszTempStr = NULL;
+       char *pConvertedStr     = NULL;
+       char *pConvertedData = NULL;
+       char *pNewData = NULL;
+       char *pReturnData = NULL;
+
+
+       switch (msgEncodingValue) {
+       case MSG_ENCODING_BASE64:
+
+               pConvertedData = (char*)_MsgDecodeBase64((UCHAR*)pData, (ULONG)nRead, (ULONG*)&nByte);
+               MSG_DEBUG("MmsGetBinaryUTF8Data : MSG_ENCODING_BASE64     bodyLength = %d \n", nByte);
+
+               pTemp = pConvertedData;
+               nTemp = nByte;
+
+               break;
+
+       case MSG_ENCODING_QUOTE_PRINTABLE:
+
+               pConvertedData = (char*)_MsgDecodeQuotePrintable((UCHAR*)pData, (ULONG)nRead, (ULONG*)&nByte);
+               MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_ENCODING_QUOTE_PRINTABLE     bodyLength = %d \n", nByte);
+
+               pTemp = pConvertedData;
+               nTemp = nByte;
+
+               break;
+
+       default:
+
+               MSG_DEBUG("MmsGetBinaryUTF8Data: 8bit    OR    Binary   bodyLength = %d \n", nRead);
+
+               pTemp = pData;
+               nTemp = nRead;
+
+               break;
+       }
+
+       if (MsgIsText(msgTypeValue)) {
+               /* charset converting */
+
+               switch (msgCharsetValue) {
+               case MSG_CHARSET_UTF16:
+               case MSG_CHARSET_USC2:
+
+                       MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_USC2 \n");
+
+                       if (((UINT8)pTemp[0]) == 0xFF && ((UINT8)pTemp[1]) == 0xFE) {
+                               nChar = (nTemp / 2 - 1);
+
+                               mszTempStr = (unsigned short*) malloc(nChar * sizeof(unsigned short));
+                               if (mszTempStr == NULL) {
+                                       MSG_DEBUG("MmsGetBinaryUTF8Data : 1. Memory Full !!! \n");
+                                       goto __CATCH;
+                               }
+
+                               memcpy(mszTempStr, ((unsigned short*)pTemp + 1), nChar * sizeof(unsigned short));
+
+                               nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTemp + 1), nChar);
+
+                               pConvertedStr = (char *)malloc(nByte + 1);
+                               if (pConvertedStr != NULL)
+                                       MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar);
+                       } else {
+                               nChar = (nTemp / 2);
+
+                               mszTempStr = (unsigned short*) malloc(nChar * sizeof(unsigned short));
+                               if (mszTempStr == NULL) {
+                                       MSG_DEBUG("MmsGetBinaryUTF8Data: 2. Memory Full !!! \n");
+                                       goto __CATCH;
+                               }
+
+                               memcpy(mszTempStr, ((unsigned short*)pTemp), nChar * sizeof(unsigned short));
+
+                               nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTemp), nChar);
+
+                               pConvertedStr = (char *)malloc(nByte + 1);
+                               if (pConvertedStr)
+                                       MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar);
+                       }
+
+                       if (pConvertedStr != NULL)
+                               pNewData = pConvertedStr;
+
+                       *npRead = nByte + 1;
+
+                       break;
+
+               case MSG_CHARSET_US_ASCII:
+
+                       MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_US_ASCII \n");
+
+                       /* fall through */
+
+               case MSG_CHARSET_UTF8:
+
+                       MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_UTF8 or Others \n");
+
+                       // skip BOM (Byte Order Mark) bytes .. (Please refer to the http://www.unicode.org/faq/utf_bom.html#BOM)
+                       if (nTemp >= 3) {
+                               if (((UINT8)pTemp[0]) == 0xEF && ((UINT8)pTemp[1]) == 0xBB && ((UINT8)pTemp[2]) == 0xBF) {
+                                       pTemp += 3;
+                                       nTemp -= 3;
+                               }
+                       }
+                       pNewData = pTemp;
+                       *npRead = nTemp;
+
+                       break;
+
+               case MSG_CHARSET_ISO_8859_7:
+
+                       /* Greek */
+
+                       MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_ISO_8859_7 \n");
+
+                       nByte = MsgGetLatin72UTFCodeSize((unsigned char*)pTemp, nTemp);
+                       pConvertedStr = (char *)malloc(nByte + 1);
+                       if (pConvertedStr)
+                               MsgLatin7code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTemp, nTemp);
+
+                       pNewData = pConvertedStr;
+                       *npRead = nByte + 1;
+
+                       break;
+
+               case MSG_CHARSET_ISO_8859_9:
+
+                       /* Turkish */
+                       MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_ISO_8859_9 \n");
+
+                       nByte = MsgGetLatin52UTFCodeSize((unsigned char*)pTemp, nTemp);
+                       pConvertedStr = (char *)malloc(nByte + 1);
+                       if (pConvertedStr)
+                                       MsgLatin5code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTemp, nTemp);
+
+                       pNewData = pConvertedStr;
+                       *npRead = nByte + 1;
+
+                       break;
+
+               default:
+
+                       MSG_DEBUG("MmsGetBinaryUTF8Data: Other charsets \n");
+
+                       nByte = MsgGetLatin2UTFCodeSize((unsigned char*)pTemp, nTemp);
+                       pConvertedStr = (char *)malloc(nByte + 1);
+                       if (pConvertedStr)
+                               MsgLatin2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTemp, nTemp);
+
+                       pNewData = pConvertedStr;
+                       *npRead = nByte + 1;
+
+                       break;
+               }
+       } else {
+               pNewData = pTemp;
+               *npRead = nTemp;
+       }
+
+       pReturnData = (char *)malloc(*npRead);
+       if (pReturnData == NULL) {
+               MSG_DEBUG("MmsGetBinaryUTF8Data : pReturnData alloc fail. \n");
+
+               goto __CATCH;
+       }
+
+       if (pNewData != NULL) {
+               memset(pReturnData, 0, *npRead);
+               memcpy(pReturnData, pNewData, *npRead);
+       }
+
+       if (pConvertedData) {
+               free(pConvertedData);
+               pConvertedData = NULL;
+       }
+
+       if (pConvertedStr) {
+               free(pConvertedStr);
+               pConvertedStr = NULL;
+       }
+
+       if (mszTempStr) {
+               free(mszTempStr);
+               mszTempStr = NULL;
+       }
+
+       return pReturnData;
+
+__CATCH:
+
+       if (pConvertedData) {
+               free(pConvertedData);
+               pConvertedData = NULL;
+       }
+
+       if (pConvertedStr) {
+               free(pConvertedStr);
+               pConvertedStr = NULL;
+       }
+
+       if (mszTempStr) {
+               free(mszTempStr);
+               mszTempStr = NULL;
+       }
+
+       return NULL;
+}
+
+#ifndef __SUPPORT_DRM__
+bool MsgMakeFileName(int iMsgType, char *szFileName, int nUntitleIndex)
+{
+       char szText[MSG_FILENAME_LEN_MAX+1]={0,};
+       char szTemp[MSG_FILENAME_LEN_MAX+1]={0,};
+       char szTempFileName[MSG_FILENAME_LEN_MAX+1]={0,};
+       char *pExt = NULL;
+
+
+       MSG_DEBUG("MsgMakeFileName: iMsgType = %d     szFileName = %s \n", iMsgType, szFileName);
+
+       if (szFileName == NULL)
+               return false;
+
+       if (szFileName && (szFileName[0] != '\0')) {
+               MsgGetFileNameWithoutExtension (szTempFileName, szFileName);
+
+               pExt = strrchr(szTempFileName, '.');
+               if (pExt == NULL) {
+                       memset  (szText, 0, MSG_FILENAME_LEN_MAX+1);
+                       strncpy(szText, szTempFileName, MSG_FILEPATH_LEN_MAX - 1);
+                       strcat(szText, ".");                    // add '.'
+               } else {
+                       memset  (szText, 0, MSG_FILENAME_LEN_MAX+1);
+                       strncpy(szText, szTempFileName, pExt+1 - szFileName);   // add '.'
+               }
+       } else {
+               if (nUntitleIndex >= 1) {
+                       snprintf(szText, MSG_FILENAME_LEN_MAX+1, "%s_%d.", "Untitled", nUntitleIndex);
+               } else {
+                       snprintf(szText, MSG_FILENAME_LEN_MAX+1, "%s.", "Untitled");
+               }
+       }
+
+       if (iMsgType == MIME_APPLICATION_OCTET_STREAM) {
+               MSG_DEBUG("MsgMakeFileName: unsupported MsgType\n");
+               goto __CATCH;
+       } else {
+               int             nLen = 0;
+               strncpy(szTemp, szText, MSG_FILENAME_LEN_MAX - 5);
+               if (iMsgType == MIME_UNKNOWN || (pExt = MimeGetExtFromMimeInt((MimeType)iMsgType)) == NULL) {
+                       MSG_DEBUG("MsgMakeFileName: Failed to get extension of that mime data file. \n");
+                       goto __CATCH;
+               }
+               nLen = MSG_FILENAME_LEN_MAX - strlen(szTemp);
+               strncat(szTemp, pExt, nLen);
+       }
+
+
+       strcpy(szFileName, szTemp);
+
+       MSG_DEBUG("MsgMakeFileName: made szFileName = %s \n", szFileName);
+
+       return true;
+
+__CATCH:
+       {
+               char *p = NULL;
+               p = strrchr(szText, '.');
+               if (p != NULL)
+                       *p = 0;
+               snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%s", szText);
+
+               return false;
+       }
+}
+#else
+bool MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex)
+{
+       char szText[MSG_FILENAME_LEN_MAX+1]={0,};
+       char szTemp[MSG_FILENAME_LEN_MAX+1]={0,};
+       char szTempFileName[MSG_FILENAME_LEN_MAX+1]={0,};
+       char *pExt = NULL;
+
+       MSG_DEBUG("MsgMakeFileName: iMsgType = 0x%x, drmType = %d, szFileName = %s \n", iMsgType, drmType, szFileName);
+
+       if (szFileName == NULL)
+               return false;
+
+       if (szFileName && (szFileName[0] != '\0')) {
+               MsgGetFileNameWithoutExtension (szTempFileName, szFileName);
+
+               if (drmType != MSG_DRM_TYPE_NONE) {
+                       pExt = strrchr(szTempFileName, '.');
+                       if (pExt == NULL) {
+                               memset(szText, 0, MSG_FILENAME_LEN_MAX+1);
+                               strncpy(szText, szTempFileName, MSG_FILENAME_LEN_MAX - 1);
+                               strcat(szText, ".");                    // add '.'
+                       } else {
+                               memset(szText, 0, MSG_FILENAME_LEN_MAX+1);
+                               strncpy(szText, szTempFileName, pExt+1 - szFileName);
+                       }
+               } else {
+                       if (strrchr(szTempFileName, '.'))
+                               return true;
+
+                       memset(szText, 0, MSG_FILENAME_LEN_MAX+1);
+                       strncpy(szText, szTempFileName, MSG_FILENAME_LEN_MAX - 1);
+               //temporary commented to save file as original name.
+                       pExt = strrchr(szFileName, '.');
+               }
+       } else {
+               if (nUntitleIndex >= 1) {
+                       snprintf(szText, MSG_FILENAME_LEN_MAX+1, "%s_%d.", "untitled", nUntitleIndex);
+               } else {
+                       snprintf(szText, MSG_FILENAME_LEN_MAX+1, "%s.", "untitled");
+               }
+       }
+
+       if (drmType == MSG_DRM_TYPE_SD) {
+               strncpy(szTemp, szText, MSG_FILENAME_LEN_MAX - 5);
+               strcat(szTemp, "dcf");
+       } else if (MsgDRMIsForwardLockType(drmType)) {
+               strncpy(szTemp, szText, MSG_FILENAME_LEN_MAX - 4);
+               strcat(szTemp, "dm");
+       } else {
+               if (iMsgType == MIME_APPLICATION_OCTET_STREAM) {
+                       MSG_DEBUG("MsgMakeFileName: unsupported MsgType\n");
+                       goto __CATCH;
+               } else {
+                       int             nLen = 0;
+                       strncpy(szTemp, szText, MSG_FILENAME_LEN_MAX - 5);
+                       //temporary commented to save file as original name.
+                       if (pExt == NULL) {
+
+                               if (iMsgType == MIME_UNKNOWN || (pExt = MimeGetExtFromMimeInt((MimeType)iMsgType)) == NULL) {
+                                       MSG_DEBUG("MsgMakeFileName: Failed to get extension of that mime data file. \n");
+                                       goto __CATCH;
+                               }
+                       }
+
+                       nLen = MSG_FILENAME_LEN_MAX - strlen(szTemp);
+                       strncat(szTemp, pExt, nLen);
+               }
+       }
+
+       strcpy(szFileName, szTemp);
+
+       MSG_DEBUG("MsgMakeFileName: made szFileName = %s \n", szFileName);
+
+       return true;
+
+__CATCH:
+       {
+               char *p = NULL;
+               p = strrchr(szText, '.');
+               if (p != NULL)
+                       *p = 0;
+               snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%s", szText);
+
+               return false;
+       }
+}
+#endif
+
+bool MsgGetFileNameWithoutExtension (char *szOutputName, char *szName)
+{
+       char *pszExt = NULL;
+
+       if (szOutputName == NULL) {
+               MSG_DEBUG("szOutputName is NULL");
+               return false;
+       }
+
+       strncpy(szOutputName, szName, strlen(szName));
+
+       if ((pszExt = strrchr(szOutputName, '.'))) {
+               if (pszExt[0] == '.')
+                       pszExt[0] = '\0';
+       }
+
+       return true;
+}
+
+int MmsGetMediaPartCount(MSG_MESSAGE_ID_T msgId)
+{
+       MmsMsg *pMsg;
+
+       MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+
+       if (msgId != pMsg->msgID) {
+               MSG_DEBUG("Invalid Message Id");
+               return -1;
+       }
+
+       return pMsg->nPartCount;
+}
+
+bool MmsGetMediaPartHeader(int index, MsgType *pHeader)
+{
+       MmsMsg *pMsg = NULL;
+       MsgMultipart *pPart = NULL;
+
+       if (pHeader == NULL) {
+               MSG_DEBUG("MmsGetMediaPartHeader: Invalid pHeader input. It's null \n");
+               return false;
+       }
+
+       MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+
+       _MsgInitMsgType(pHeader);
+
+
+       /* Requires header of non-presentation */
+       if (MsgIsMultipart(pMsg->msgType.type)) {
+               MSG_DEBUG("MmsGetMediaPartHeader: Multipart header [index = %d] \n", index);
+
+               pPart = pMsg->msgBody.body.pMultipart;
+
+               while (pPart && index--)
+                       pPart = pPart->pNext;
+
+               if (pPart == NULL) {
+                       MSG_DEBUG("MmsGetMediaPartHeader: There is no such msg part.\n");
+                       return false;
+               }
+
+               memcpy(pHeader, &pPart->type, sizeof(MsgType));
+       } else {
+               MSG_DEBUG("MmsGetMediaPartHeader: Requires singlepart header \n");
+               memcpy(pHeader, &pMsg->msgType, sizeof(MsgType));
+       }
+
+       return true;
+}
+
+bool MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index)
+{
+       MSG_DEBUG("------------------------------\n");
+       MSG_DEBUG("%dth multipart info\n", index);
+       MSG_DEBUG("header size=%d\n", pMultipart->type.size);
+       MSG_DEBUG("body size=%d\n", pMultipart->type.contentSize);
+       MSG_DEBUG("content type=%s\n", MmsDebugGetMimeType((MimeType)pMultipart->type.type));
+       MSG_DEBUG("content ID=%s\n", pMultipart->type.szContentID);
+       MSG_DEBUG("content location=%s\n", pMultipart->type.szContentLocation);
+
+       if (pMultipart->type.type == MIME_TEXT_PLAIN) {
+               MSG_DEBUG("text info\n");
+               MSG_DEBUG("charset=%d\n", pMultipart->type.param.charset);
+               MSG_DEBUG("text file name=%s\n", pMultipart->type.param.szName);
+       }
+#ifdef __SUPPORT_DRM__
+       if (pMultipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) {
+               MSG_DEBUG("drm info\n");
+               MSG_DEBUG("drm type=%d      (0: NONE 1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery)\n", pMultipart->type.drmInfo.drmType);
+               MSG_DEBUG("drm content type=%s\n", MmsDebugGetMimeType((MimeType)pMultipart->type.drmInfo.contentType));
+               MSG_DEBUG("drm content URI=%s\n", pMultipart->type.drmInfo.szContentURI);
+               MSG_DEBUG("drm2FullPath=%s\n", pMultipart->type.drmInfo.szDrm2FullPath);
+       }
+#endif
+       MSG_DEBUG("------------------------------\n");
+       return true;
+}
+
diff --git a/plugin/mms_plugin/MmsPluginDrm.cpp b/plugin/mms_plugin/MmsPluginDrm.cpp
new file mode 100755 (executable)
index 0000000..0f13934
--- /dev/null
@@ -0,0 +1,173 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <string.h>
+#include <drm_client_types.h>
+#include <drm_client.h>
+#include "MmsPluginDrm.h"
+#include "MmsPluginCodec.h"
+#include "MsgMmsTypes.h"
+#include "MsgDrmWrapper.h"
+#include "MsgDebug.h"
+
+
+#ifdef __SUPPORT_DRM__
+
+MmsDrm2ConvertState    mmsDrm2ConvertState;
+
+MsgDrmType MsgGetDRMType(MsgType *pMsgType, MsgBody *pMsgBody)
+{
+       MsgDrmType drmType = MSG_DRM_TYPE_NONE;
+       MsgMultipart *pMultipart = NULL;
+
+       if (MsgIsMultipart(pMsgType->type)) {
+               pMultipart = pMsgBody->body.pMultipart;
+               while (pMultipart) {
+                       if (drmType < pMultipart->type.drmInfo.drmType)
+                               drmType = pMultipart->type.drmInfo.drmType;
+
+                       pMultipart = pMultipart->pNext;
+               }
+       } else {
+               drmType = pMsgType->drmInfo.drmType;
+       }
+
+       return drmType;
+}
+
+void MmsDrm2SetConvertState(MmsDrm2ConvertState newConvertState)
+{
+       mmsDrm2ConvertState = newConvertState;
+       MSG_DEBUG("MmsDrm2SetConvertState: mmsDrm2ConvertState = %d\n", mmsDrm2ConvertState);
+}
+
+MmsDrm2ConvertState MmsDrm2GetConvertState(void)
+{
+       return mmsDrm2ConvertState;
+}
+
+bool MsgDRM2GetDRMInfo(char *szFilePath, MsgType *pMsgType)
+{
+       if (szFilePath == NULL || pMsgType == NULL) {
+               MSG_DEBUG("Param is NULL szFilePath = %d, pMsgType = %d", szFilePath, pMsgType);
+               return false;
+       }
+
+       char szMimeType[DRM_MAX_LEN_MIME + 1];
+       char szContentID[DRM_MAX_LEN_CID + 1];
+       MSG_DRM_TYPE drmType = MSG_DRM_NONE;
+
+       MsgDrmGetDrmType(szFilePath, &drmType);
+       MsgDrmGetMimeTypeEx(szFilePath, szMimeType, sizeof(szMimeType));
+       MsgDrmGetContentID(szFilePath, szContentID, sizeof(szContentID));
+       MSG_DEBUG("drmType: %d", drmType);
+
+       switch (drmType) {
+       case MSG_DRM_FORWARD_LOCK:
+               pMsgType->drmInfo.drmType = MSG_DRM_TYPE_FL;
+               pMsgType->drmInfo.contentType = (MsgContentType)_MsgGetCode(MSG_TYPE, szMimeType);
+               if (MsgCopyDrmInfo(pMsgType) == false) {
+                       MSG_DEBUG("MsgDRM2GetDRMInfo : MsgCopyDrmInfo failed");
+                       return false;
+               }
+               break;
+
+       case MSG_DRM_COMBINED_DELIVERY:
+               pMsgType->drmInfo.drmType = MSG_DRM_TYPE_CD;
+               pMsgType->drmInfo.szContentURI = MsgResolveContentURI(szContentID);
+               break;
+
+       case MSG_DRM_SEPARATE_DELIVERY:
+               pMsgType->drmInfo.drmType = MSG_DRM_TYPE_SD;
+
+               pMsgType->drmInfo.contentType = (MsgContentType)_MsgGetCode(MSG_TYPE, szMimeType);
+
+               drm_content_info_s dcfHdrInfo;
+               bzero(&dcfHdrInfo, sizeof(drm_content_info_s));
+               drm_get_content_info(szFilePath, &dcfHdrInfo);
+
+               drm_file_info_s fileInfo;
+               bzero(&fileInfo, sizeof(drm_file_info_s));
+               drm_get_file_info(szFilePath,&fileInfo);
+
+               if (fileInfo.oma_info.version == DRM_OMA_DRMV1_RIGHTS) {
+                       pMsgType->drmInfo.szContentName = MsgRemoveQuoteFromFilename(dcfHdrInfo.title);
+                       pMsgType->drmInfo.szContentDescription = MsgStrCopy(dcfHdrInfo.description);
+               }
+               break;
+
+       default:
+               pMsgType->drmInfo.drmType = MSG_DRM_TYPE_NONE;
+               break;
+       }
+
+       pMsgType->drmInfo.szDrm2FullPath = MsgStrCopy(szFilePath);
+       MSG_DEBUG("pMsgType->drmInfo.szDrm2FullPath: %s", pMsgType->drmInfo.szDrm2FullPath);
+
+       return true;
+}
+
+bool MsgDRMIsForwardLockType(MsgDrmType        drmType)
+{
+       switch (drmType) {
+       case MSG_DRM_TYPE_FL:
+       case MSG_DRM_TYPE_CD:
+               return true;
+
+       case MSG_DRM_TYPE_NONE:         //SD & plain can be forwarded
+       case MSG_DRM_TYPE_SD:
+       default:
+               return false;
+       }
+}
+
+bool MsgChangeDrm2FileName(char *szFileName)
+{
+       char szTempFileName[MSG_FILENAME_LEN_MAX] = {0,};
+
+       if (szFileName == NULL || szFileName[0] == '\0')
+               return false;
+
+       MsgGetFileNameWithoutExtension(szTempFileName, szFileName);
+
+       if (strrchr(szTempFileName, '.'))
+               return true;
+
+       strcat(szTempFileName, ".dcf");
+       strcpy(szFileName, szTempFileName);
+
+       MSG_DEBUG("MsgChangeDrm2FileName: made szFileName = %s \n", szFileName);
+
+       return true;
+}
+
+bool MsgIsDCFFile(char *szFilePath)
+{
+       int length = 0;
+
+       MSG_DEBUG("MsgIsDCFFile: szFilePath = %s \n", szFilePath);
+
+       length = MsgStrlen(szFilePath);
+       if (szFilePath[length - 4] == '.' &&
+               (szFilePath[length - 3] == 'd' || szFilePath[length - 3] == 'D') &&
+               (szFilePath[length - 2] == 'c' || szFilePath[length - 2] == 'C') &&
+               (szFilePath[length - 1] == 'f' || szFilePath[length - 1] == 'F'))
+               return true;
+
+       return false;
+}
+
+#endif
diff --git a/plugin/mms_plugin/MmsPluginEncode.cpp b/plugin/mms_plugin/MmsPluginEncode.cpp
new file mode 100755 (executable)
index 0000000..2bf0a46
--- /dev/null
@@ -0,0 +1,3308 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <time.h>
+#include <stdlib.h>
+
+#include "MmsPluginMessage.h"
+#include "MmsPluginCodec.h"
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MmsPluginMIME.h"
+
+gint _g_time_rev_set = 0;
+gint _g_time_rev = 0;
+
+/**  Sending message related variables  ------------------------ */
+
+static char gszMmsEncodeBuf[MSG_MMS_ENCODE_BUFFER_MAX] = {0, };
+static int gCurMmsEncodeBuffPos = 0;   /* number of characters on gpMmsEncodeBuf */
+static int     gMmsEncodeMaxLen = 0;
+static int     gMmsEncodeCurOffset = 0;        /* offset in file */
+static char *gpMmsEncodeBuf = NULL;
+
+
+/* Acknowledge.ind & NotifyResp.ind related variables ------------------------ */
+
+static char gszMmsEncodeBuf2[MSG_MMS_ENCODE_BUFFER_MAX] = {0, };
+static int     gCurMmsEncodeBuffPos2 = 0;      /* number of characters on gpMmsEncodeBuf */
+static int     gMmsEncodeMaxLen2 = 0;
+static int     gMmsEncodeCurOffset2 = 0;       /* offset in file */
+static char *gpMmsEncodeBuf2 = NULL;
+
+
+bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg);
+bool _MmsBinaryEncodeAckIndHdr(FILE *pFile, char *pTrID, bool bReportAllowed);
+bool _MmsBinaryEncodeNotiRespIndHdr(FILE* pFile, char *pTrID, MSG_DELIVERY_REPORT_STATUS_T iStatus, bool bReportAllowed);
+bool _MmsBinaryEncodeForwardReqHdr(FILE *pFile, char *szContentLocation, char *szForwardTo, char *szForwardCc, char *szForwardBcc);
+bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, MSG_READ_REPORT_STATUS_T mmsReadStatus);
+bool _MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, MSG_READ_REPORT_STATUS_T mmsReadStatus);
+
+static         bool __MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg, bool bIncludeSendReqHeader);
+static int MmsBinaryEncodeUintvarLen(UINT32 integer);
+static bool MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length);
+static int MmsBinaryEncodeValueLengthLen(UINT32 integer);
+static bool MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length);
+static int     MmsBinaryEncodeIntegerLen(UINT32 integer);
+static bool MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length);
+static int     MmsBinaryEncodeLongIntegerLen(UINT32 integer);
+static bool MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length);
+static int     MmsBinaryEncodeTextStringLen(UINT8 *source);
+static bool MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length);
+static int     MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc);
+static bool MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length);
+static int     MmsBinaryEncodeEncodedStringLen(UINT8 *source);
+static bool MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length);
+bool MmsBinaryEncodeSendReqHdrwithinBufRegi(FILE *pFile, MmsMsg *pMsg);
+bool MmsBinaryEncodeSendReqHdrContTypeFildCode(FILE *pFile, int msgID);
+
+static bool __MmsBinaryEncodeFieldCodeAndValue(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue);
+
+static bool __MmsBinaryEncodeMmsVersion(FILE *pFile);
+static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen);
+static bool __MmsBinaryEncodeMsgID(FILE *pFile, const char *szMsgID);  /** 2005-05-24, added for read-reply PDU 1.2 */
+static bool __MmsBinaryEncodeFrom(FILE *pFile);
+static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeStruct time);
+static bool __MmsBinaryEncodeDate(FILE *pFile);
+static bool __MmsBinaryEncodeOneAddress(FILE *pFile, MmsFieldCode addrType, char *szAddrStr);
+static bool __MmsBinaryEncodeAddress(FILE *pFile, MmsFieldCode addrType, char *szAddr);
+
+
+/* Functions for Acknowledge.ind & NotifyResp.ind  ------------------------ */
+
+static bool MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length);
+static bool __MmsBinaryEncodeMmsVersion2(FILE *pFile);
+static bool __MmsBinaryEncodeFieldCodeAndValue2(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue);
+extern int MsgProcessUrgentEvent(int iMode);
+
+
+/** -----------------------------------------------------------------
+ *                                     M   M   S       E   N   C   O   D   E
+ * * -----------------------------------------------------------------*/
+
+
+static void __MmsCleanEncodeBuff(void)
+{
+       memset(gpMmsEncodeBuf, 0, MSG_MMS_ENCODE_BUFFER_MAX);
+       gCurMmsEncodeBuffPos = 0;
+}
+
+
+void _MmsRegisterEncodeBuffer(char *pInBuff, int maxLen)
+{
+       gpMmsEncodeBuf = pInBuff;
+       gCurMmsEncodeBuffPos = 0;
+       gMmsEncodeMaxLen = maxLen;
+       gMmsEncodeCurOffset = 0;
+}
+
+void _MmsUnregisterEncodeBuffer(void)
+{
+       gpMmsEncodeBuf = NULL;
+       gCurMmsEncodeBuffPos = 0;
+       gMmsEncodeMaxLen = 0;
+       gMmsEncodeCurOffset = 0;
+}
+
+int _MmsGetEncodeOffset(void)
+{
+       return (gMmsEncodeCurOffset + gCurMmsEncodeBuffPos);
+}
+
+
+bool _MmsEncodeMsg(void)
+{
+       MSG_DEBUG("_MmsEncodeMsg: Start Binary Encoding now ============= \n");
+       return true;
+}
+
+
+bool _MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg)
+{
+       return __MmsEncodeSendReq(pFile, pMsg, true);
+}
+
+
+bool _MmsEncodeTemplate(FILE *pFile, MmsMsg *pMsg)
+{
+       return __MmsEncodeSendReq(pFile, pMsg, false);
+}
+
+
+static bool __MmsEncodeSendReq(FILE* pFile, MmsMsg* pMsg, bool bIncludeSendReqHeader)
+{
+       _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
+
+       if (bIncludeSendReqHeader) {
+               if (_MmsBinaryEncodeSendReqHdr(pFile, pMsg) == false) {
+                       _MmsUnregisterEncodeBuffer();
+                       return false;
+               }
+       }
+
+       if (MmsBinaryEncodeMsgBody(pFile, &pMsg->msgType, &pMsg->msgBody, pMsg->nPartCount, !bIncludeSendReqHeader) == false) {
+               _MmsUnregisterEncodeBuffer();
+               return false;
+       }
+
+       _MmsUnregisterEncodeBuffer();
+
+       return true;
+}
+
+
+/* Functions for Acknowledge.ind & NotifyResp.ind ------------------------ */
+
+static void __MmsCleanEncodeBuff2(void)
+{
+       memset(gpMmsEncodeBuf2, 0, MSG_MMS_ENCODE_BUFFER_MAX);
+       gCurMmsEncodeBuffPos2 = 0;
+}
+
+
+void _MmsRegisterEncodeBuffer2(char *pInBuff, int maxLen)
+{
+       gpMmsEncodeBuf2 = pInBuff;
+       gCurMmsEncodeBuffPos2 = 0;
+       gMmsEncodeMaxLen2 = maxLen;
+       gMmsEncodeCurOffset2 = 0;
+}
+
+void _MmsUnregisterEncodeBuffer2(void)
+{
+       gpMmsEncodeBuf2 = NULL;
+       gCurMmsEncodeBuffPos2 = 0;
+       gMmsEncodeMaxLen2 = 0;
+       gMmsEncodeCurOffset2 = 0;
+}
+
+
+/**
+ * @param      source [in] originam string
+ * @param      length [in] gotten from MmsBinaryEncodeTextStringLen()
+ * @param      dest [in] buffer to store quted string
+ * @return     changed string length
+*/
+static bool MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length)
+{
+       MSG_DEBUG("MmsBinaryEncodeTextString2: \n");
+
+       /**
+        * make text string
+        * Text-string = [Quote] *TEXT End-of-string
+        * If the 1st char in the TEXT is in the range of 128-255, a Quote char must precede it.
+        * Otherwise the Quote char must be omitted.
+        * The Quote is not part of the contents.
+        * Quote = <Octet 127>
+        */
+
+       if (pFile == NULL || source == NULL) {
+               MSG_DEBUG("MmsBinaryEncodeTextString2: source == NULL \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < length) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2,
+                                                                                       gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeTextString2: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       if (source[0] > 0x7F) {
+               gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = QUOTE;
+               length--;
+       }
+
+       strncpy(gpMmsEncodeBuf2 + gCurMmsEncodeBuffPos2, (char*)source, (length - 1));  /** except NULL */
+       gCurMmsEncodeBuffPos2 += (length - 1);  /** except NULL */
+       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = (UINT8)NULL;
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+static bool __MmsBinaryEncodeFieldCodeAndValue2(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue)
+{
+       if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < 2) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2,
+                                                                                       gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) {
+                       MSG_DEBUG("__MmsBinaryEncodeFieldCodeAndValue: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       if (fieldCode == 0xff) {
+               MSG_DEBUG("__MmsBinaryEncodeFieldCodeAndValue: invalid fieldCode \n");
+               goto __CATCH;
+       }
+
+       if (fieldValue == 0xff) {
+               MSG_DEBUG("__MmsBinaryEncodeFieldCodeAndValue: invalid fieldValue \n");
+               return true;
+       }
+
+       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = fieldCode;
+       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = fieldValue;
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+static bool __MmsBinaryEncodeMmsVersion2(FILE *pFile)
+{
+       UINT8 majorVer = MMS_MAJOR_VERSION;
+       UINT8 minorVer = MMS_MINOR_VERSION;
+
+       MSG_DEBUG("__MmsBinaryEncodeMmsVersion2: \n");
+
+       if (pFile == NULL) {
+               MSG_DEBUG("__MmsBinaryEncodeMmsVersion2: invalid input file \n");
+               goto __CATCH;
+       }
+
+       if (majorVer < 1) {
+               MSG_DEBUG("__MmsBinaryEncodeMmsVersion2: invalid major version (%d)\n", majorVer);
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < 2) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2,
+                                                                                       gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) {
+                       MSG_DEBUG("__MmsBinaryEncodeMmsVersion2: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_VERSION) | 0x80;
+       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2] = (majorVer << 4) | (minorVer & 0x0f) | MSB;
+
+       if (gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2] < 0x80) {
+               gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] |= 0x80;
+       } else {
+               gCurMmsEncodeBuffPos2++;
+       }
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+bool _MmsBinaryEncodeAckIndHdr(FILE *pFile, char *szTrID, bool bReportAllowed)
+{
+       int length = 0;
+       UINT8 fieldCode = 0xff;
+       UINT8 fieldValue = 0xff;
+
+       MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: szTrID = %s\n", szTrID);
+       MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: bReportAllowed = %d\n", bReportAllowed);
+
+       __MmsCleanEncodeBuff2();
+
+       /* msgType */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
+       fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_ACKNOWLEDGE_IND) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: msgType error\n");
+               goto __CATCH;
+       }
+
+       /* trID (other type of message) */
+       length = MmsBinaryEncodeTextStringLen((UINT8*)szTrID);
+       if (length == -1) {
+               MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: MmsBinaryEncodeTextStringLen fail \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < (length + 1)) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2,
+                                                                                       gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80;
+
+       if (MmsBinaryEncodeTextString2(pFile, (UINT8*)szTrID, length) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: MmsBinaryEncodeTextString fail\n");
+               goto __CATCH;
+       }
+
+
+       if (__MmsBinaryEncodeMmsVersion2(pFile) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: __MmsBinaryEncodeMmsVersion error\n");
+               goto __CATCH;
+       }
+
+
+       /* Report Allowed */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPORTALLOWED) | 0x80;
+
+       if (bReportAllowed) {
+               fieldValue = _MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_YES) | 0x80;
+       } else {
+               fieldValue = _MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_NO) | 0x80;
+       }
+
+       if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: Report Allowed error\n");
+               goto __CATCH;
+       }
+
+       /* flush remained data on encoding file */
+       if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2,
+                                                                               gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: remained data MsgWriteDataFromEncodeBuffer fail \n");
+               goto __CATCH;
+       }
+
+       return true;
+
+__CATCH:
+
+       return false;
+}
+
+
+
+bool _MmsBinaryEncodeNotiRespIndHdr(FILE *pFile, char *szTrID, MSG_DELIVERY_REPORT_STATUS_T iStatus, bool bReportAllowed)
+{
+       int length = 0;
+       UINT8 fieldCode = 0xff;
+       UINT8 fieldValue = 0xff;
+
+       MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: szTrID = %s\n", szTrID);
+       MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: iStatus = %d\n", iStatus);
+       MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: bReportAllowed = %d\n", bReportAllowed);
+
+       __MmsCleanEncodeBuff2();
+
+       /* msgType */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
+       fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_NOTIFYRESP_IND) | 0x80;
+
+       if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: msgType error\n");
+               goto __CATCH;
+       }
+
+
+       /* trID (other type of message) */
+       length = MmsBinaryEncodeTextStringLen((UINT8*)szTrID);
+       if (length == -1) {
+               MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MmsBinaryEncodeTextStringLen fail \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < (length + 1)) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2,
+                                                                                       gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80;
+       if (MmsBinaryEncodeTextString2(pFile, (UINT8*)szTrID, length) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MmsBinaryEncodeTextString fail\n");
+               goto __CATCH;
+       }
+
+
+       if (__MmsBinaryEncodeMmsVersion2(pFile) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: __MmsBinaryEncodeMmsVersion error\n");
+               goto __CATCH;
+       }
+
+
+       /* MsgStatus */
+       MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MsgStatus = %d\n", iStatus);
+
+       if (iStatus != MSG_DELIVERY_REPORT_NONE) {
+               fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGSTATUS) | 0x80;
+               fieldValue = _MmsGetBinaryValue(MmsCodeMsgStatus, iStatus) | 0x80;
+               if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MsgStatus error\n");
+                       goto __CATCH;
+               }
+       }
+
+
+       /* Report Allowed */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPORTALLOWED) | 0x80;
+
+       if (bReportAllowed) {
+               fieldValue = _MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_YES) | 0x80;
+       } else {
+               fieldValue = _MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_NO) | 0x80;
+       }
+
+       if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: Report Allowed error\n");
+               goto __CATCH;
+       }
+
+       /* flush remained data on encoding file */
+       if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2,
+                                                                               gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: remained data MsgWriteDataFromEncodeBuffer fail \n");
+               goto __CATCH;
+       }
+
+       return true;
+
+__CATCH:
+
+       return false;
+}
+
+
+bool _MmsEncodeAckInd(FILE *pFile, char *pTrID, bool bReportAllowed)
+{
+       _MmsRegisterEncodeBuffer2(gszMmsEncodeBuf2, MSG_MMS_ENCODE_BUFFER_MAX);
+
+       MSG_DEBUG("_MmsEncodeAckInd: Start Binary Encoding now ============= \n");
+
+       if (_MmsBinaryEncodeAckIndHdr(pFile, pTrID, bReportAllowed) == false) {
+               MSG_DEBUG("_MmsEncodeAckInd: SendReq Binary encoding fail \n");
+               goto __CATCH;
+       }
+
+       _MmsUnregisterEncodeBuffer2();
+
+       return true;
+
+__CATCH:
+
+       MSG_DEBUG("## _MmsEncodeAckInd: failed");
+       _MmsUnregisterEncodeBuffer2();
+
+       return false;
+}
+
+
+
+bool _MmsEncodeNotiRespInd(FILE *pFile, char *pTrID, MSG_DELIVERY_REPORT_STATUS_T iStatus, bool bReportAllowed)
+{
+       _MmsRegisterEncodeBuffer2(gszMmsEncodeBuf2, MSG_MMS_ENCODE_BUFFER_MAX);
+
+       MSG_DEBUG("_MmsEncodeNotiRespInd: Start Binary Encoding now ============= \n");
+
+       if (_MmsBinaryEncodeNotiRespIndHdr(pFile, pTrID, iStatus, bReportAllowed) == false) {
+               MSG_DEBUG("_MmsEncodeNotiRespInd: SendReq Binary encoding fail \n");
+               goto __CATCH;
+       }
+
+       _MmsUnregisterEncodeBuffer2();
+
+       return true;
+
+__CATCH:
+
+       return false;
+}
+
+
+/* Functions for Acknowledge.ind & NotifyResp.ind  (END) ------------------------ */
+bool _MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, MSG_READ_REPORT_STATUS_T mmsReadStatus)
+{
+       char *pText = NULL;
+       MsgMultipart *pPart = NULL;
+       MsgType msgType;
+       MsgBody msgBody;
+
+       char *pszReportMsg = NULL;
+       int     maxLen = 0;
+
+       struct  tm      *dateTime = NULL;
+       time_t  RawTime = 0;
+       time_t  dateSec = 0;
+
+       _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
+
+       MSG_DEBUG("_MmsEncodeMsg: Start Binary Encoding now V1.0============= \n");
+
+       if (_MmsBinaryEncodeReadReport10Hdr(pFile, pMsg, mmsReadStatus) == false) {
+               MSG_DEBUG("_MmsEncodeReadReport10: SendReq Binary encoding fail \n");
+               goto __CATCH;
+       }
+
+       memset(&msgType, 0, sizeof(MsgType));
+       memset(&msgBody, 0, sizeof(MsgBody));
+
+       pText = (char *)malloc(MSG_STDSTR_LONG);
+       if (pText == NULL) {
+               MSG_DEBUG("__MmsSendReadReportV10: text body malloc fail \n");
+               goto __CATCH;
+       }
+
+       memset(pText, 0, MSG_STDSTR_LONG);
+
+       time(&RawTime);
+       dateTime = localtime(&RawTime);
+       dateSec = mktime(dateTime);
+
+       // get report message
+       if (mmsReadStatus == MSG_READ_REPORT_IS_DELETED) {
+               pszReportMsg = (char*)"Your message has been deleted " ;
+       } else {
+               pszReportMsg = (char*)"Your message has been read " ;
+       }
+
+       // make report body ..
+       maxLen = strlen (pszReportMsg) +16 /* date string */ + 8 /* enter chars */ ;
+
+       if (maxLen > MSG_STDSTR_LONG) {
+               snprintf (pText, MSG_STDSTR_LONG, "%s\n", pszReportMsg);
+       } else {
+               snprintf(pText, MSG_STDSTR_LONG, "%s\r\n\r\n%.4d/%.2d/%.2d %.2d:%.2d\r\n",
+                                               pszReportMsg, dateTime->tm_year+1900, dateTime->tm_mon+1, dateTime->tm_mday, dateTime->tm_hour, dateTime->tm_min);
+       }
+
+       // make header
+       msgType.type = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED;
+       msgType.contentSize = strlen(pText);
+       msgType.param.charset = MSG_CHARSET_UNKNOWN;
+
+       // make body
+       if ((pPart = MmsAllocMultipart()) == NULL) {
+               MSG_DEBUG("__MmsSendReadReportV10: MsgAllocMultipart Fail \n");
+               goto __CATCH;
+       }
+
+
+       pPart->type.type = MIME_TEXT_PLAIN;
+       pPart->type.contentSize = strlen(pText);
+       pPart->type.param.charset = MSG_CHARSET_UTF8;
+
+       if (pPart->pBody == NULL) {
+               MSG_DEBUG("__MmsSendReadReportV10: pPart->pBody is NULL \n");
+               goto __CATCH;
+       }
+
+       pPart->pBody->size = strlen(pText);
+       pPart->pBody->body.pText = pText;
+
+       msgBody.body.pMultipart = pPart;
+
+       if (MmsBinaryEncodeMsgBody(pFile, &msgType, &msgBody, 1, false) == false) {
+               MSG_DEBUG("__MmsSendReadReportV10: MmsBinaryEncodeMsgBody fail \n");
+               goto __CATCH;
+       }
+
+       MSG_DEBUG("__MmsSendReadReportV10:  Send To RM ReadReport Msg \n");
+
+       if (pText) {
+               free(pText);
+               pText = NULL;
+       }
+
+       if (pPart) {
+               if (pPart->pBody) {
+                       free(pPart->pBody);
+                       pPart->pBody = NULL;
+               }
+               free(pPart);
+               pPart = NULL;
+       }
+
+       _MmsUnregisterEncodeBuffer();
+
+       return true;
+
+__CATCH:
+
+       if (pText) {
+               free(pText);
+               pText = NULL;
+       }
+
+       if (pPart) {
+               if (pPart->pBody) {
+                       free(pPart->pBody);
+                       pPart->pBody = NULL;
+               }
+               free(pPart);
+               pPart = NULL;
+       }
+
+       _MmsUnregisterEncodeBuffer();
+
+       return false;
+}
+
+
+bool _MmsEncodeReadReport11(FILE *pFile, MmsMsg *pMsg, MSG_READ_REPORT_STATUS_T mmsReadStatus)
+{
+       _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
+
+       MSG_DEBUG("_MmsEncodeMsg: Start Binary Encoding now V1.1============= \n");
+
+       if (_MmsBinaryEncodeReadReport11Hdr(pFile, pMsg, mmsReadStatus) == false) {
+               MSG_DEBUG("_MmsEncodeMsg: SendReq Binary encoding fail \n");
+               goto __CATCH;
+       }
+
+       _MmsUnregisterEncodeBuffer();
+
+       return true;
+
+__CATCH:
+       _MmsUnregisterEncodeBuffer();
+
+       return false;
+}
+
+
+
+/* ==========================================================
+
+                                       B  I  N  A  R  Y         E  N  C  O  D  I  N  G
+
+   ==========================================================*/
+
+/*
+ * Binary Encoded Message Format
+ *
+ *             < Single Part Body Message >
+ * -----------------------------------
+ * |           Header Fields                    |
+ * -----------------------------------
+ * | Content Type:start=xxx;type=xxx | ->(ex) Text/Plain, Text/Html, ....
+ * -----------------------------------
+ * |           Single Part Body                 |
+ * -----------------------------------
+ *
+ *             < Multi Part Body Message >
+ * -----------------------------------
+ * |           Header Fields                    |
+ * -----------------------------------
+ * | Content Type:start=xxx;type=xxx | -> (ex) Application/vnd.wap.multipart.mixed(related), multipart/mixed(related)
+ * -----------------------------------
+ * |   # of Entries (body parts)        |
+ * -----------------------------------                         < Each Entry >
+ * |                   Entry 1                          |      ->      -----------------------------
+ * -----------------------------------         |               header Length           |
+ * |                   Entry 2                          |              -----------------------------
+ * -----------------------------------         |               Data Length                     |
+ * |                   ......                           |              -----------------------------  -
+ * -----------------------------------         |               Content-Type            |  |
+ * |                   Entry n                          |              -----------------------------  | Header Length
+ * -----------------------------------         |                       Header                  |  |
+ *                                                                                     -----------------------------  -
+ *                                                                                     |                       Data                    |  | Data Length
+ *                                                                                     -----------------------------  -
+ */
+
+bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
+{
+       UINT8 fieldCode = 0xff;
+       UINT8 fieldValue        = 0xff;
+       int length              = 0;
+
+       __MmsCleanEncodeBuff();
+
+       /* msgType */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
+       fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_SEND_REQ) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: msgType error\n");
+               goto __CATCH;
+       }
+
+       /* trID (other type of message) */
+       if (__MmsBinaryEncodeTrID(pFile, pMsg->szTrID, MMS_TR_ID_LEN + 1) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: trID error\n");
+               goto __CATCH;
+       }
+
+       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr:                pMsg->szTrID = %s\n", pMsg->szTrID);
+
+       if (__MmsBinaryEncodeMmsVersion(pFile) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: __MmsBinaryEncodeMmsVersion error\n");
+               goto __CATCH;
+       }
+
+       /* From : Insert Token mode */
+       if (__MmsBinaryEncodeFrom(pFile) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: __MmsBinaryEncodeFrom fail\n");
+               goto __CATCH;
+       }
+
+
+       /* To = Encoded-string-value */
+       if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_TO, pMsg->mmsAttrib.szTo) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: To __MmsBinaryEncodeAddress fail\n");
+               goto __CATCH;
+       }
+
+
+       /* Cc = Encoded-string-value */
+       if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_CC, pMsg->mmsAttrib.szCc) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: Cc __MmsBinaryEncodeAddress fail\n");
+               goto __CATCH;
+       }
+
+
+       /* Bcc = Encoded-string-value */
+
+       if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_BCC, pMsg->mmsAttrib.szBcc) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: Bcc __MmsBinaryEncodeAddress fail\n");
+               goto __CATCH;
+       }
+
+
+       MSG_DEBUG("_MmsBinaryEnocdeSendReqHdr() pMsg->mmsAttrib.szSubject =%s\n",pMsg->mmsAttrib.szSubject);
+
+       /* Subject = Encoded-string-value */
+       if (pMsg->mmsAttrib.szSubject[0]) {
+               length = MmsBinaryEncodeEncodedStringLen((UINT8*)pMsg->mmsAttrib.szSubject);
+               if (length == -1) {
+                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: subject MmsBinaryEncodeEncodedStringLen fail \n");
+                       goto __CATCH;
+               }
+
+               if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length + 1) {
+                       if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                               gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: subject MsgWriteDataFromEncodeBuffer fail \n");
+                               goto __CATCH;
+                       }
+               }
+
+               fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SUBJECT) | 0x80;
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode;
+               if (MmsBinaryEncodeEncodedString(pFile, (UINT8*)pMsg->mmsAttrib.szSubject, length) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: subject MmsBinaryEncodeEncodedString fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       /* MMS-1.3-con-739 */
+       /* Msg class */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGCLASS) | 0x80;
+       fieldValue = _MmsGetBinaryValue(MmsCodeMsgClass,  (int)pMsg->mmsAttrib.msgClass) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: msgClass error\n");
+               goto __CATCH;
+       }
+       /* MMS-1.3-con-739 */
+       /* MMS-1.3-con-733 */
+       /* Date = Long-integer */
+       if (!__MmsBinaryEncodeDate(pFile)) {
+                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: __MmsBinaryEncodeDate error\n");
+                       goto __CATCH;
+       }
+       /* MMS-1.3-con-733 */
+
+       /* Expiry Time  : Value-length Absolute-token Date-value */
+       if (pMsg->mmsAttrib.bUseExpiryCustomTime == true) {
+               if (__MmsBinaryEncodeTime(pFile, MMS_CODE_EXPIRYTIME, pMsg->mmsAttrib.expiryCustomTime) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: expiryTime __MmsBinaryEncodeTime fail\n");
+                       goto __CATCH;
+               }
+       } else if (pMsg->mmsAttrib.expiryTime.type != MMS_TIMETYPE_NONE) {      // for avoiding the creation of the expiry field in case the user selects the maximum
+               if (__MmsBinaryEncodeTime(pFile, MMS_CODE_EXPIRYTIME, pMsg->mmsAttrib.expiryTime) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: expiryTime __MmsBinaryEncodeTime fail\n");
+                       goto __CATCH;
+               }
+       }
+
+       /* Use Custom time for Delivery Time */
+       if (pMsg->mmsAttrib.bUseDeliveryCustomTime == true) {
+               if (__MmsBinaryEncodeTime(pFile, MMS_CODE_DELIVERYTIME, pMsg->mmsAttrib.deliveryCustomTime) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: deliveryTime __MmsBinaryEncodeTime fail\n");
+                       goto __CATCH;
+               }
+       } else {
+               if (__MmsBinaryEncodeTime(pFile, MMS_CODE_DELIVERYTIME, pMsg->mmsAttrib.deliveryTime) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: deliveryTime __MmsBinaryEncodeTime fail\n");
+                       goto __CATCH;
+               }
+       }
+
+       /* Priority */
+       if (pMsg->mmsAttrib.priority!= MMS_PRIORITY_ERROR && pMsg->mmsAttrib.priority!= MMS_PRIORITY_NORMAL) {
+               /* MMS_PRIORITY_NORMAL is default : don't send optional field */
+
+               fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_PRIORITY)|0x80;
+               fieldValue = _MmsGetBinaryValue(MmsCodePriority, pMsg->mmsAttrib.priority)|0x80;
+
+               if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: priority error\n");
+                       goto __CATCH;
+               }
+       }
+
+       /* Sender Visible (hide | show) */
+       if (pMsg->mmsAttrib.bHideAddress == true) {
+               fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SENDERVISIBILLITY) | MSB;
+               fieldValue = _MmsGetBinaryValue(MmsCodeSenderVisibility, MMS_SENDER_HIDE) | 0x80;
+
+               if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: sender visibility error\n");
+                       goto __CATCH;
+               }
+       }
+
+       /* Delivery Report (yes | no) */
+       fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DELIVERYREPORT)|0x80;
+
+       if (pMsg->mmsAttrib.bAskDeliveryReport) {
+               fieldValue = _MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_YES) | 0x80;
+       } else {
+               fieldValue = _MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_NO) | 0x80;
+       }
+
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: sender visibility error\n");
+               goto __CATCH;
+       }
+
+       /* Read Reply (Yes | no) */
+       fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READREPLY)|0x80;
+       if (pMsg->mmsAttrib.bAskReadReply) {
+               fieldValue = _MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_YES)|0x80;
+       } else {
+               fieldValue = _MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_NO)|0x80;
+       }
+
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: read reply error\n");
+               goto __CATCH;
+       }
+
+       if ((pMsg->mmsAttrib.replyCharge.chargeType == MMS_REPLY_REQUESTED) ||
+               (pMsg->mmsAttrib.replyCharge.chargeType == MMS_REPLY_REQUESTED_TEXT_ONLY)) {
+
+               // reply charging
+               fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGING)|0x80;
+               fieldValue = _MmsGetBinaryValue(MmsCodeReadReply, pMsg->mmsAttrib.replyCharge.chargeType)|0x80;
+
+               if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: replyCharging error\n");
+                       goto __CATCH;
+               }
+
+               /** fixme: Reply-charging-deadline */
+               if (pMsg->mmsAttrib.replyCharge.deadLine.time > 0) {
+                       if (__MmsBinaryEncodeTime(pFile, MMS_CODE_REPLYCHARGINGDEADLINE, pMsg->mmsAttrib.replyCharge.deadLine) == false) {
+                               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: replyCharging __MmsBinaryEncodeTime fail\n");
+                               goto __CATCH;
+                       }
+               }
+
+               /** fixme: Reply-charging-size */
+               if (pMsg->mmsAttrib.replyCharge.chargeSize > 0) {
+                       length = MmsBinaryEncodeIntegerLen(pMsg->mmsAttrib.replyCharge.chargeSize);
+
+                       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) {
+                               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                               gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: MsgWriteDataFromEncodeBuffer fail \n");
+                                       goto __CATCH;
+                               }
+                       }
+
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGINGSIZE) | 0x80;
+
+                       if (MmsBinaryEncodeInteger(pFile, pMsg->mmsAttrib.replyCharge.chargeSize, length) == false)     {
+                               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: replyChargingSize MmsBinaryEncodeInteger error\n");
+                               goto __CATCH;
+                       }
+               }
+
+               /** fixme: Reply-charging-ID  ----> used only when reply message  */
+               if (pMsg->mmsAttrib.replyCharge.szChargeID[0]) {
+                       length = MmsBinaryEncodeTextStringLen((UINT8*)pMsg->mmsAttrib.replyCharge.szChargeID);
+                       if (length == -1) {
+                               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: szReplyChargingID MmsBinaryEncodeTextStringLen fail\n");
+                               goto __CATCH;
+                       }
+
+                       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) {
+                               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                               gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: MsgWriteDataFromEncodeBuffer fail \n");
+                                       goto __CATCH;
+                               }
+                       }
+
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGINGID) | 0x80;
+
+                       if (MmsBinaryEncodeTextString(pFile, (UINT8*)pMsg->mmsAttrib.replyCharge.szChargeID, length) == false) {
+                               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: szContentLocation MmsBinaryEncodeTextString fail\n");
+                               goto __CATCH;
+                       }
+               }
+       }
+
+       /* flush remained data on encoding file */
+       if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: remained data MsgWriteDataFromEncodeBuffer fail \n");
+               goto __CATCH;
+       }
+
+       return true;
+
+__CATCH:
+
+       MSG_DEBUG("## _MmsBinaryEncodeSendReqHdr: failed");
+       return false;
+}
+
+bool MmsBinaryEncodeSendReqHdrwithinBufRegi(FILE *pFile, MmsMsg *pMsg)
+{
+       bool ret = false;
+
+       _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
+       ret = _MmsBinaryEncodeSendReqHdr(pFile, pMsg);
+       _MmsUnregisterEncodeBuffer();
+
+       return ret;
+}
+
+bool _MmsBinaryEncodeContentTypeFieldCode(FILE *pFile, int msgID)
+{
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < 2) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("__MmsBinaryEncodeMmsVersion: MsgWriteDataFromEncodeBuffer fail \n");
+                       return false;
+               }
+       }
+
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_CONTENTTYPE) | 0x80;
+
+       if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: remained data MsgWriteDataFromEncodeBuffer fail \n");
+               return false;
+       }
+
+       return true;
+}
+
+bool MmsBinaryEncodeSendReqHdrContTypeFildCode(FILE *pFile, int msgID)
+{
+       bool ret = false;
+
+       _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
+
+       ret = _MmsBinaryEncodeContentTypeFieldCode(pFile, msgID);
+
+       _MmsUnregisterEncodeBuffer();
+
+
+       return ret;
+}
+
+
+bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, MSG_READ_REPORT_STATUS_T mmsReadStatus)
+{
+       int length      = 0;
+       char *szTo      = NULL;
+       UINT8 fieldCode = 0xff;
+       UINT8 fieldValue = 0xff;
+       char szSubject[MSG_LOCALE_SUBJ_LEN + 8] = {0, };
+
+       if (pMsg == NULL) {
+               MSG_DEBUG("pMsg is NULL");
+               goto __CATCH;
+       }
+
+       MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: mmsReadStatus = %d\n", mmsReadStatus);
+
+       __MmsCleanEncodeBuff();
+
+       /* msgType */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
+       fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_SEND_REQ) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: msgType error\n");
+               goto __CATCH;
+       }
+
+       /* trID (other type of message) */
+       if (__MmsBinaryEncodeTrID(pFile, NULL, 0) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: __MmsBinaryEncodeTrID error\n");
+               goto __CATCH;
+       }
+
+       if (__MmsBinaryEncodeMmsVersion(pFile) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: __MmsBinaryEncodeMmsVersion error\n");
+               goto __CATCH;
+       }
+
+       /* Date = Long-integer */
+       if (!__MmsBinaryEncodeDate(pFile)) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: date __MmsBinaryEncodeDate error\n");
+               goto __CATCH;
+       }
+
+       /* From : Insert Token mode */
+       if (__MmsBinaryEncodeFrom(pFile) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: __MmsBinaryEncodeFrom fail\n");
+               goto __CATCH;
+       }
+
+       MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: To = %s\n", pMsg->mmsAttrib.szFrom);
+
+       /* To = Encoded-string */
+       if (pMsg && (strchr(pMsg->mmsAttrib.szFrom, '/') == NULL)) {
+               length = strlen(pMsg->mmsAttrib.szFrom);
+               szTo = (char *)malloc(length + 11);
+               if (szTo == NULL) {
+                       MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: szTo alloc fail\n");
+                       goto __CATCH;
+               }
+
+               snprintf(szTo, length + 11, "%s/TYPE=PLMN", pMsg->mmsAttrib.szFrom);
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: To = %s\n", szTo);
+
+               if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_TO, szTo) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: To __MmsBinaryEncodeAddress fail\n");
+                       goto __CATCH;
+               }
+
+               if (szTo) {
+                       free(szTo);
+                       szTo = NULL;
+               }
+       } else {
+               if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_TO, pMsg->mmsAttrib.szFrom) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: To __MmsBinaryEncodeAddress fail\n");
+                       goto __CATCH;
+               }
+       }
+
+       /* Subject = Encoded-string-value */
+       if (pMsg && pMsg->mmsAttrib.szSubject[0]) {
+               if (mmsReadStatus == MSG_READ_REPORT_IS_READ) {
+                       snprintf(szSubject, MSG_LOCALE_SUBJ_LEN + 8, "%s%s", MMS_READ_REPORT_STRING_READ, pMsg->mmsAttrib.szSubject);
+               } else {
+                       snprintf(szSubject, MSG_LOCALE_SUBJ_LEN + 8, "%s%s", MMS_READ_REPORT_STRING_DELETED, pMsg->mmsAttrib.szSubject);
+               }
+       } else {
+               if (mmsReadStatus == MSG_READ_REPORT_IS_READ) {
+                       snprintf(szSubject, MSG_LOCALE_SUBJ_LEN + 8, "%s", MMS_READ_REPORT_STRING_READ);
+
+               } else {
+                       snprintf(szSubject, MSG_LOCALE_SUBJ_LEN + 8, "%s", MMS_READ_REPORT_STRING_DELETED );
+               }
+       }
+
+       length = MmsBinaryEncodeEncodedStringLen((UINT8*)szSubject);
+       if (length == -1) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: subject MmsBinaryEncodeEncodedStringLen fail \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length + 1) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: subject MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SUBJECT) | 0x80;
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode;
+       if (MmsBinaryEncodeEncodedString(pFile, (UINT8*)szSubject, length) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: subject MmsBinaryEncodeEncodedString fail \n");
+               goto __CATCH;
+       }
+
+       /* Msg class */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGCLASS) | 0x80;
+       fieldValue = _MmsGetBinaryValue(MmsCodeMsgClass, MMS_MSGCLASS_AUTO) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: msgClass error\n");
+               goto __CATCH;
+       }
+
+
+       /* Delivery Report (yes | no) */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DELIVERYREPORT) | 0x80;
+       fieldValue = _MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_NO) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: Delivery Report error\n");
+               goto __CATCH;
+       }
+
+
+       /* Read Reply (Yes | no) */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READREPLY) | 0x80;
+       fieldValue = _MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_NO) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: Read Reply error\n");
+               goto __CATCH;
+       }
+
+
+       /* Sender Visible (hide | show) */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SENDERVISIBILLITY) | 0x80;
+       fieldValue = _MmsGetBinaryValue(MmsCodeSenderVisibility, MMS_SENDER_SHOW) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: Sender Visible error\n");
+               goto __CATCH;
+       }
+
+       /* fixme: msgContentType */
+       /* fixme: msgHeader */
+       /* fixme: msgBody */
+
+       /* flush remained data on encoding file */
+       if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                               gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: remained data MsgWriteDataFromEncodeBuffer fail \n");
+               goto __CATCH;
+       }
+
+       return true;
+
+__CATCH:
+       if (szTo) {
+               free(szTo);
+               szTo = NULL;
+       }
+
+       return false;
+}
+
+
+
+bool _MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, MSG_READ_REPORT_STATUS_T mmsReadStatus)
+{
+       UINT8 fieldCode = 0xff;
+       UINT8 fieldValue = 0xff;
+       char *szTo = NULL;
+
+       __MmsCleanEncodeBuff();
+
+       /* msgType */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
+       fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_READREC_IND) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: msgType error\n");
+               goto __CATCH;
+       }
+
+       /* MMS version */
+       if (__MmsBinaryEncodeMmsVersion(pFile) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: __MmsBinaryEncodeMmsVersion error\n");
+               goto __CATCH;
+       }
+
+       if (__MmsBinaryEncodeMsgID(pFile, pMsg->szMsgID) == false)
+               goto __CATCH;
+
+       /* To = Encoded-string */
+       if (strchr(pMsg->mmsAttrib.szFrom, '/') == NULL) {
+               int length = 0;
+               length = strlen(pMsg->mmsAttrib.szFrom);
+               szTo = (char *)malloc(length + 11);
+
+               if (szTo == NULL) {
+                       MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: szTo alloc fail\n");
+                       goto __CATCH;
+               }
+
+               snprintf(szTo, length + 11,"%s/TYPE=PLMN", pMsg->mmsAttrib.szFrom);
+               MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: To = %s\n", szTo);
+
+               if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_TO, szTo) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: To __MmsBinaryEncodeAddress fail\n");
+                       goto __CATCH;
+               }
+
+               if (szTo) {
+                       free(szTo);
+                       szTo = NULL;
+               }
+       } else {
+               if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_TO, pMsg->mmsAttrib.szFrom) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: To __MmsBinaryEncodeAddress fail\n");
+                       goto __CATCH;
+               }
+       }
+
+       /* From : Insert Token mode */
+       if (__MmsBinaryEncodeFrom(pFile) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: __MmsBinaryEncodeFrom fail\n");
+               goto __CATCH;
+       }
+
+       /* Date = Long-integer */
+       if (!__MmsBinaryEncodeDate(pFile)) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: __MmsBinaryEncodeDate error\n");
+               goto __CATCH;
+       }
+
+       /* Read Status (Yes | no) */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READSTATUS) | 0x80;
+       fieldValue = _MmsGetBinaryValue(MmsCodeReadStatus, mmsReadStatus) | 0x80;
+
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: Read Status error\n");
+               goto __CATCH;
+       };
+
+       if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                               gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+               MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: remained data MsgWriteDataFromEncodeBuffer fail \n");
+               goto __CATCH;
+       }
+
+       return true;
+
+__CATCH:
+       if (szTo) {
+               free(szTo);
+               szTo = NULL;
+       }
+
+       return false;
+}
+
+bool MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPartCount, bool bTemplate)
+{
+       int length = 0;
+       MsgMultipart *pMultipart = NULL;
+
+       MSG_DEBUG("MmsBinaryEncodeMsgBody: nPartCount = %d\n", nPartCount);
+
+       if (pFile == NULL || pType == NULL) {
+               MSG_DEBUG("MmsBinaryEncodeMsgBody: invalid file handle\n");
+               goto __CATCH;
+       }
+
+       if (MmsIsMultipart(pType->type)) {
+
+               int     nEntries   = 0;
+               /* ---------------------------
+                *       Multipart message
+                * ---------------------------*/
+
+               pType->offset = _MmsGetEncodeOffset();
+
+               /* Content type */
+               length = MmsBinaryEncodeContentTypeLen(pType);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgBody: MmsBinaryEncodeContentTypeLen fail \n");
+                       goto __CATCH;
+               }
+               if (bTemplate == false)
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_CONTENTTYPE) | 0x80;
+
+               if (MmsBinaryEncodeContentType(pFile, pType, length) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgBody: MmsBinaryEncodeContentType fail \n");
+                       goto __CATCH;
+               }
+
+               pBody->offset = _MmsGetEncodeOffset();
+
+               /* nEntries */
+               if (pBody->pPresentationBody) {
+                       nEntries = nPartCount + 1;
+               } else {
+                       nEntries = nPartCount;
+               }
+
+               if (nEntries >= 0) {
+                       length = MmsBinaryEncodeUintvarLen(nEntries);
+                       if (length == -1) {
+                               MSG_DEBUG("MmsBinaryEncodeMsgBody: nEntries MmsBinaryEncodeUintvarLen fail \n");
+                               goto __CATCH;
+                       }
+                       if (MmsBinaryEncodeUintvar(pFile, nEntries, length) == false) {
+                               MSG_DEBUG("MmsBinaryEncodeMsgBody: nEntries MmsBinaryEncodeUintvar fail \n");
+                               goto __CATCH;
+                       }
+
+                       pType->size = _MmsGetEncodeOffset() - pType->offset;
+               }
+
+               if (nEntries > 0) {
+                       if (nEntries && pBody->pPresentationBody) {
+                               if (MmsBinaryEncodeMsgPart(pFile, pType->type, &pBody->presentationType, pBody->pPresentationBody) == false) {
+                                       MSG_DEBUG("MmsBinaryEncodeMsgBody: __MmsBinaryEncodeMsgPart fail \n");
+                                       goto __CATCH;
+                               }
+
+                               nEntries--;
+                       }
+
+                       pMultipart = pBody->body.pMultipart;
+                       while (nEntries && pMultipart) {
+                               if (MmsBinaryEncodeMsgPart(pFile, pType->type, &pMultipart->type, pMultipart->pBody) == false) {
+                                       MSG_DEBUG("MmsBinaryEncodeMsgBody: __MmsBinaryEncodeMsgPart fail \n");
+                                       goto __CATCH;
+                               }
+                               pMultipart = pMultipart->pNext;
+                               nEntries--;
+                       }
+               } else {
+                       if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                               gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                               MSG_DEBUG("MmsBinaryEncodeMsgBody: Empty message body MsgWriteDataFromEncodeBuffer fail \n");
+                               goto __CATCH;
+                       }
+               }
+
+               pBody->size = _MmsGetEncodeOffset() - pBody->offset;
+       } else {
+               /* ---------------------------
+                *       Singlepart message
+                * ---------------------------*/
+               pType->offset = _MmsGetEncodeOffset();
+
+               if (MmsBinaryEncodeContentHeader(pFile, (MimeType)pType->type, pType, false) == false)
+                       goto __CATCH;
+
+               length = MmsBinaryEncodeContentTypeLen(pType);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgBody: Singlepart MmsBinaryEncodeContentTypeLen fail \n");
+                       goto __CATCH;
+               }
+
+               if (MmsBinaryEncodeContentType(pFile, pType, length) == false)
+                       goto __CATCH;
+
+               pType->size = _MmsGetEncodeOffset() - pType->offset;
+
+               if (MmsBinaryEncodeContentBody(pFile, pBody) == false)
+                       goto __CATCH;
+       }
+
+       return true;
+
+__CATCH:
+       MSG_DEBUG("## MmsBinaryEncodeMsgBody: failed\n");
+
+       return false;
+}
+
+
+int MmsBinaryEncodeContentTypeLen(MsgType *pType)
+{
+       int length = 0;
+       int     totalLength = 0;
+       UINT16 fieldValue = 0xffff;
+       char *szTextType = NULL;
+       int     contentType = MIME_UNKNOWN;
+
+       MSG_DEBUG("MSmsBinaryEncodeContentTypeLen:  type\n");
+
+       /*
+        * Content-type-value = Constrained-media | Content-general-form
+        * Constrained-media  = Constrained-encoding
+        *                                              Constrained-encoding = Extension-Media | Short-integer
+        *                                              Extension-media = *TEXT End-of-string
+        * Content-general-form = Value-length Media-type
+        *                                              Media-type = (Well-known-media | Extension-Media) *(Parameter)
+        */
+
+       /* Content-type-value = Content-general-form ------------------------------- */
+       /* Content-Type */
+
+       contentType = pType->type;
+
+       fieldValue = _MmsGetBinaryValue(MmsCodeContentType, contentType);
+       if (fieldValue == UNDEFINED_BINARY || fieldValue == 0x0049)     {
+               /* Extension-media type */
+               szTextType = _MmsGetTextValue(MmsCodeContentType, contentType);
+               if (szTextType != NULL) {
+                       length  = MmsBinaryEncodeTextStringLen((UINT8*)szTextType);
+                       if (length == -1) {
+                               MSG_DEBUG("MSmsBinaryEncodeContentTypeLen: szTextType MmsBinaryEncodeTextStringLen fail \n");
+                               goto __CATCH;
+                       }
+                       totalLength += length;
+               } else {
+                       totalLength++;
+               }
+       } else {
+               totalLength++;
+       }
+
+       /* Parameters -------------------------------------------------------------- */
+
+       MSG_DEBUG("MSmsBinaryEncodeContentTypeLen:  parameters    \n\n");
+
+       /* Well-known-charset = Any-charset | Integer-value ----------------------- */
+
+       if (pType->param.charset != MSG_CHARSET_UNKNOWN) {
+               fieldValue = _MmsGetBinaryValue(MmsCodeCharSet, pType->param.charset);
+               length     = MmsBinaryEncodeIntegerLen(fieldValue);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeContentTypeLen: charSet MmsBinaryEncodeIntegerLen fail \n");
+                       goto __CATCH;
+               }
+               totalLength += (length + 1);
+       } else {
+               if (MmsIsText(contentType)) {   // Any-charset
+                       if (!MmsIsVitemContent (contentType, pType->param.szName))
+                               totalLength += 2;
+               }
+       }
+
+
+       /* Name = Text-string ------------------------------------------------------ */
+
+       if (pType->param.szName[0]) {
+               char* pszName = NULL;
+
+               if (_MsgIsASCII (pType->param.szName)) {
+                       MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szName is consisted of ascii char-set chars. \n");
+
+                       pszName = (char *)malloc(strlen(pType->param.szName) +1);
+                       memset(pszName, 0, (strlen(pType->param.szName)+1));
+                       strcpy(pszName, pType->param.szName);
+               } else {
+                       MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szName is not consisted of ascii char-set chars. \n");
+                       MSG_DEBUG("MmsBinaryEncodeContentTypeLen: pType->param.szName : %s\n", pType->param.szName);
+
+                       /* if msg-server can't support non ascii, then convert non-ascii to '_' by using _MsgReplaceNonAscii*/
+                       int filelen = strlen(pType->param.szName);
+
+                       pszName = (char *)malloc(filelen + 1);
+                       memset(pszName, 0, (filelen + 1));
+                       strncpy(pszName, pType->param.szName, filelen);
+
+                       MSG_DEBUG("MmsBinaryEncodeContentTypeLen: pszName : %s\n", pszName);
+               }
+
+               //change empty space to '_' in the file name
+               if (_MsgIsSpace(pszName)) {
+                       char *pszTempName = NULL;
+
+                       MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szName has space(' '). \n");
+
+                       _MsgReplaceSpecialChar(pszName, &pszTempName, ' ');
+
+                       if (pszTempName) {
+                               free(pszName);
+                               pszName = pszTempName;
+                       }
+                       MSG_DEBUG("MmsBinaryEncodeContentTypeLen: pszName : %s\n", pszName);
+               }
+
+               length = MmsBinaryEncodeTextStringLen((UINT8*)pszName);
+               free(pszName);
+
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szName MmsBinaryEncodeIntegerLen fail \n");
+                       goto __CATCH;
+               }
+
+               totalLength += (length + 1);
+       }
+
+#ifdef FEATURE_JAVA_MMS
+       if (pType->param.szApplicationID) {
+               length = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szApplicationID);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szApplicationID MmsBinaryEncodeTextStrinLen fail \n");
+                       goto __CATCH;
+               }
+
+               totalLength += (length);
+               if (_MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID) == UNDEFINED_BINARY) {
+                       totalLength += strlen(_MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID)) + 1; /* NULL */
+               } else {
+                       totalLength++;
+               }
+       }
+
+       if (pType->param.szReplyToApplicationID) {
+               length = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szReplyToApplicationID);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szApplicationID MmsBinaryEncodeTextStrinLen fail \n");
+                       goto __CATCH;
+               }
+
+               totalLength += (length);
+               if (_MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID) == UNDEFINED_BINARY) {
+                       totalLength += strlen(_MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID)) + 1; /* NULL */
+               } else {
+                       totalLength++;
+               }
+       }
+#endif
+
+       /* type, start, & startInfo : multipart/related only parameters -------------- */
+       if (contentType == MIME_MULTIPART_RELATED || contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
+               /* type ------------------------------------- */
+               fieldValue = _MmsGetBinaryValue(MmsCodeContentType, pType->param.type);
+               if (fieldValue == UNDEFINED_BINARY || fieldValue == 0x0049) {
+                       /* Extension-media type */
+                       szTextType = _MmsGetTextValue(MmsCodeContentType, pType->param.type);
+                       if (szTextType != NULL) {
+                               length  = MmsBinaryEncodeTextStringLen((UINT8*)szTextType);
+                               if (length == -1) {
+                                       MSG_DEBUG("MmsBinaryEncodeContentTypeLen: type param MmsBinaryEncodeTextStringLen fail \n");
+                                       goto __CATCH;
+                               }
+                               totalLength += (length + 1);
+                       } else {
+                               totalLength += 2;
+                       }
+               } else {
+                       totalLength += 2;
+               }
+
+               /* start = Text-string ----------------------- */
+               if (pType->param.szStart[0]) {
+                       /* start = Text-string */
+                       length  = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStart);
+                       if (length == -1) {
+                               MSG_DEBUG("MmsBinaryEncodeContentType: szStart MmsBinaryEncodeTextStringLen fail \n");
+                               goto __CATCH;
+                       }
+
+                       totalLength += (length + 1);
+               }
+
+
+               /* startInfo = Text-string -------------------- */
+               if (pType->param.szStartInfo[0]) {
+                       /* StartInfo (with multipart/related) = Text-string */
+                       length  = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStartInfo);
+                       if (length == -1) {
+                               MSG_DEBUG("MmsBinaryEncodeContentType: szStartInfo MmsBinaryEncodeTextStringLen fail \n");
+                               goto __CATCH;
+                       }
+
+                       totalLength += (length + 1);
+               }
+       }
+
+       return totalLength;
+
+__CATCH:
+
+       MSG_DEBUG("## MmsBinaryEncodeContentTypeLen: failed");
+       return -1;
+}
+
+
+
+bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
+{
+       int length = 0;
+       UINT16 fieldValue = 0xffff;
+       char *szTextType = NULL;
+       int contentType = MIME_UNKNOWN;
+
+#ifdef FEATURE_JAVA_MMS
+       char *szParameter = NULL;
+#endif
+
+       MSG_DEBUG("************************************************************************************\n");
+       MSG_DEBUG("MmsBinaryEncodeContentType:  C O N T E N T     T Y P E    \n\n");
+
+       /*
+        * Content-type-value = Constrained-media | Content-general-form
+        * Constrained-media  = Constrained-encoding
+        *                                              Constrained-encoding = Extension-Media | Short-integer
+        *                                              Extension-media = *TEXT End-of-string
+        * Content-general-form = Value-length Media-type
+        *                                              Media-type = (Well-known-media | Extension-Media) *(Parameter)
+        */
+
+       if (pFile == NULL) {
+               MSG_DEBUG("MmsBinaryEncodeContentType: invalid file handle\n");
+               goto __CATCH;
+       }
+
+
+       /* Content-Type = Content-general-form ------------------------------- */
+
+       length = MmsBinaryEncodeValueLengthLen(typeLength);
+       if (length == -1) {
+               MSG_DEBUG("MSmsBinaryEncodeContentType : MmsBinaryEncodeValueLengthLen fail.\n");
+               goto __CATCH;
+       }
+
+       if (MmsBinaryEncodeValueLength(pFile, typeLength, length) == false) {
+               MSG_DEBUG("MSmsBinaryEncodeContentType : MmsBinaryEncodeValueLength fail.\n");
+               goto __CATCH;
+       }
+
+       contentType = pType->type;
+
+       fieldValue = _MmsGetBinaryValue(MmsCodeContentType, (int)contentType);
+       if (fieldValue == UNDEFINED_BINARY || fieldValue == 0x0049) {
+               /* Extension-media type */
+               szTextType = _MmsGetTextValue(MmsCodeContentType, (int)contentType);
+               if (szTextType == NULL)
+                       fieldValue = 0x00;
+       }
+
+       if (szTextType == NULL) {
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)fieldValue | 0x80;
+       } else {
+               length  = MmsBinaryEncodeTextStringLen((UINT8*)szTextType);
+               if (length == -1) {
+                       MSG_DEBUG("MSmsBinaryEncodeContentType: szTextType MmsBinaryEncodeTextStringLen fail \n");
+                       goto __CATCH;
+               }
+
+               if (MmsBinaryEncodeTextString(pFile, (UINT8*)szTextType, length) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeContentType: szTextType MmsBinaryEncodeTextString fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       /* Parameters -------------------------------------------------------------- */
+
+       MSG_DEBUG("MmsBinaryEncodeContentType:  P A R M E T E R S    \n\n");
+
+       /* Name = Text-string ------------------------------------------------------ */
+
+       if (pType->param.szName[0]) {
+               char* pszName = NULL;
+
+               if (_MsgIsASCII (pType->param.szName)) {
+
+                       MSG_DEBUG("MmsBinaryEncodeContentType: szName is consisted of ascii char-set chars. \n");
+
+                       pszName = (char *)malloc(strlen(pType->param.szName) +1);
+                       memset(pszName, 0, (strlen(pType->param.szName)+1));
+                       strcpy(pszName, pType->param.szName);
+               } else {
+                       MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szName is not consisted of ascii char-set chars. \n");
+
+                       /* if msg-server can't support non ascii, then convert non-ascii to '_' by using _MsgReplaceNonAscii*/
+                       int filelen = strlen(pType->param.szName);
+
+                       pszName = (char *)malloc(filelen + 1);
+                       memset(pszName, 0, (filelen + 1));
+                       strncpy(pszName, pType->param.szName, filelen);
+
+                       MSG_DEBUG("MmsBinaryEncodeContentType: pszName : %s\n", pszName);
+               }
+
+               //change empty space to '_' in the file name
+               if (_MsgIsSpace(pszName)) {
+                       char*   pszTempName = NULL;
+
+                       MSG_DEBUG("MmsBinaryEncodeContentType: szName has space(' '). \n");
+
+                       _MsgReplaceSpecialChar(pszName, &pszTempName, ' ');
+
+                       if (pszTempName) {
+                               free(pszName);
+                               pszName = pszTempName;
+                       }
+                       MSG_DEBUG("MmsBinaryEncodeContentType: pszName : %s\n", pszName);
+               }
+
+               length = MmsBinaryEncodeTextStringLen((UINT8*)pszName);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeContentType: szName MmsBinaryEncodeIntegerLen fail \n");
+                       free(pszName);
+                       goto __CATCH;
+               }
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_NAME) | 0x80;
+
+               if (MmsBinaryEncodeTextString(pFile, (UINT8*)pszName, length) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeContentType: szName MmsBinaryEncodeTextString fail\n");
+                       free(pszName);
+                       goto __CATCH;
+               }
+               free(pszName);
+       }
+#ifdef FEATURE_JAVA_MMS
+       MSG_DEBUG(" MmsBinaryEncodeContentType: Application-ID \n");
+
+       /* Application-ID: Text-string */
+       if (pType->param.szApplicationID) {
+               length = MmsBinaryEncodeTextStringLen((UINT8*) pType->param.szApplicationID);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeContentType: szApplicationID MmsBinaryEncodeIntegerLen Fail \n");
+                       goto __CATCH;
+               }
+
+               fieldValue = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID);
+
+               if (fieldValue == UNDEFINED_BINARY)
+                       szParameter = _MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID);
+
+               if (szParameter == NULL) {
+                       MSG_DEBUG("MmsBinaryEncodeContentType: szParameter is NULL \n");
+                       goto __CATCH;
+               }
+
+               strncpy(gpMmsEncodeBuf + gCurMmsEncodeBuffPos, (char*)szParameter, strlen(szParameter));
+               gCurMmsEncodeBuffPos += strlen(szParameter);
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] =(UINT8)NULL;
+
+               if (MmsBinaryEncodeTextString(pFile, (UINT8*) pType->param.szApplicationID, length) == false) {
+                       MSG_DEBUG(" MmsBinaryEncodeContentType: szApplicationID MmsBinaryEncodeTextString fail\n");
+                       goto __CATCH;
+               }
+
+       }
+
+       /* ReplyToApplicationID: Text-string */
+       if (pType->param.szReplyToApplicationID) {
+               length = MmsBinaryEncodeTextStringLen((UINT8*) pType->param.szReplyToApplicationID);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeContentType: szReplyToApplicationID MmsBinaryEncodeIntegerLen Fail \n");
+                       goto __CATCH;
+               }
+
+               fieldValue = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID);
+
+               if (fieldValue == UNDEFINED_BINARY)
+                       szParameter = _MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID);
+
+               if (szParameter == NULL) {
+                       MSG_DEBUG("MmsBinaryEncodeContentType: szParameter is NULL \n");
+                       goto __CATCH;
+               }
+
+               strncpy(gpMmsEncodeBuf + gCurMmsEncodeBuffPos, (char*)szParameter, strlen(szParameter));
+               gCurMmsEncodeBuffPos += strlen(szParameter);
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] =(UINT8)NULL;
+
+               if (MmsBinaryEncodeTextString(pFile, (UINT8*) pType->param.szReplyToApplicationID, length) == false) {
+                       MSG_DEBUG(" MmsBinaryEncodeContentType: szApplicationID MmsBinaryEncodeTextString fail\n");
+                       goto __CATCH;
+               }
+       }
+#endif
+
+       /* Well-known-charset = Any-charset | Integer-value ----------------------- */
+
+       if (pType->param.charset != MSG_CHARSET_UNKNOWN) {
+               fieldValue = _MmsGetBinaryValue(MmsCodeCharSet, pType->param.charset);
+               length = MmsBinaryEncodeIntegerLen(fieldValue);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeContentType: charSet MmsBinaryEncodeIntegerLen fail \n");
+                       goto __CATCH;
+               }
+
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_CHARSET) | 0x80;
+               if (MmsBinaryEncodeInteger(pFile, fieldValue, length) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeContentType: charSet MmsBinaryEncodeInteger fail\n");
+                       goto __CATCH;
+               }
+       } else {
+               /* Any-charset */
+               if (MmsIsText(contentType)) {
+                       if (!MmsIsVitemContent (contentType, pType->param.szName)) {
+                               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_CHARSET) | 0x80;
+                               fieldValue = 0x0000;    //laconic_warning, just to remove warning message
+                               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)fieldValue | 0x80;
+                       }
+               }
+       }
+
+       /* type, start, & startInfo : multipart/related only parameters -------------- */
+       if (contentType == MIME_MULTIPART_RELATED || contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
+               /* type ------------------------------------- */
+               fieldValue = _MmsGetBinaryValue(MmsCodeContentType, pType->param.type);
+               if (fieldValue == UNDEFINED_BINARY || fieldValue == 0x0049) {
+                       /* Extension-media type */
+                       szTextType = _MmsGetTextValue(MmsCodeContentType, pType->param.type);
+                       if (szTextType == NULL)
+                               fieldValue = 0x00;
+               }
+
+               if (szTextType == NULL) {
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)fieldValue | 0x80;
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_TYPE) | 0x80;
+               } else {
+                       length  = MmsBinaryEncodeTextStringLen((UINT8*)szTextType);
+                       if (length == -1) {
+                               MSG_DEBUG("MmsBinaryEncodeContentType: type param MmsBinaryEncodeTextStringLen fail \n");
+                               goto __CATCH;
+                       }
+
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_TYPE) | 0x80;
+                       if (MmsBinaryEncodeTextString(pFile, (UINT8*)szTextType, length) == false) {
+                               MSG_DEBUG("MmsBinaryEncodeContentType: type param MmsBinaryEncodeTextString fail \n");
+                               goto __CATCH;
+                       }
+               }
+
+               /* start = Text-string ----------------------- */
+               if (pType->param.szStart && pType->param.szStart[0]) {
+                       /* start = Text-string */
+                       length  = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStart);
+                       if (length == -1) {
+                               MSG_DEBUG("MmsBinaryEncodeContentType: szStart MmsBinaryEncodeTextStringLen fail \n");
+                               goto __CATCH;
+                       }
+
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode,
+                                                                                                                                                MSG_PARAM_START) | 0x80;
+                       if (MmsBinaryEncodeTextString(pFile, (UINT8*)pType->param.szStart, length) == false) {
+                               MSG_DEBUG("MmsBinaryEncodeContentType: szStart MmsBinaryEncodeTextString fail \n");
+                               goto __CATCH;
+                       }
+               }
+
+               /* startInfo = Text-string -------------------- */
+               if (pType->param.szStartInfo[0]) {
+                       /* StartInfo (with multipart/related) = Text-string */
+                       length  = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStartInfo);
+                       if (length == -1) {
+                               MSG_DEBUG("MmsBinaryEncodeContentType: szStartInfo MmsBinaryEncodeTextStringLen fail \n");
+                               goto __CATCH;
+                       }
+
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_START_INFO) | 0x80;
+                       if (MmsBinaryEncodeTextString(pFile, (UINT8*)pType->param.szStartInfo, length) == false) {
+                               MSG_DEBUG("MmsBinaryEncodeContentType: szStartInfo MmsBinaryEncodeTextString fail \n");
+                               goto __CATCH;
+                       }
+               }
+       }
+
+       return true;
+
+__CATCH:
+       MSG_DEBUG("## MmsBinaryEncodeContentType: failed");
+       return false;
+}
+
+
+
+bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBody *pBody)
+{
+       FILE *pFile2 = NULL;
+       char *pData = NULL;
+       int     length = 0;
+
+
+       if (pType->offset && pType->size) {
+               /* header length & body length --------------------------- */
+
+               length = MmsBinaryEncodeUintvarLen(pType->size);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. headerLeng MmsBinaryEncodeUintvarLen fail \n");
+                       goto __CATCH;
+               }
+
+               if (MmsBinaryEncodeUintvar(pFile, pType->size, length) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. eaderLeng fail \n");
+                       goto __CATCH;
+               }
+
+               length = MmsBinaryEncodeUintvarLen(pBody->size);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. bodyLeng MmsBinaryEncodeUintvarLen fail \n");
+                       goto __CATCH;
+               }
+
+               if (MmsBinaryEncodeUintvar(pFile, pBody->size, length) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. bodyLeng fail \n");
+                       goto __CATCH;
+               }
+
+               pFile2 = MsgOpenFile(pType->szOrgFilePath, "rb");
+               if (pFile != NULL) {
+                       pData = (char *)malloc(pType->size);
+                       if (pData == NULL)
+                               goto __CATCH;
+
+                       if (MsgFseek(pFile2, pType->offset, SEEK_SET) < 0) {
+                               MSG_DEBUG("MmsBinaryEncodeMsgPart: MsgFseek fail \n");
+                               goto __CATCH;
+                       }
+
+                       ULONG nRead = 0;
+
+                       if ((nRead = MsgReadFile(pData, sizeof(char), pType->size, pFile2)) == 0) {
+                               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                                       MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. header MsgWriteDataFromEncodeBuffer fail \n");
+                                       goto __CATCH;
+                               }
+                               pType->offset = _MmsGetEncodeOffset();
+                               if(MsgWriteFile(pData, sizeof(char), nRead, pFile) != (size_t)nRead) {
+                                       MSG_DEBUG("MsgWriteFile failed");
+                                       goto __CATCH;
+                               }
+                               gMmsEncodeCurOffset = MsgFtell(pFile);
+                               if(gMmsEncodeCurOffset < 0) {
+                                       MSG_DEBUG("MsgFtell returns negative value [%ld]", gMmsEncodeCurOffset);
+                                       goto __CATCH;
+                               }
+                       }
+
+                       MsgCloseFile(pFile2);
+                       pFile2 = NULL;
+               }
+       } else {
+               int headerLeng     = 0;
+               int contentTypeLen = 0;
+               int contentHdrLen  = 0;
+
+               /* header length & body length --------------------------- */
+               contentTypeLen = MmsBinaryEncodeContentTypeLen(pType);
+               length = MmsBinaryEncodeValueLengthLen(contentTypeLen);
+               contentHdrLen  = MmsBinaryEncodeContentHeaderLen((MimeType)contentType, pType, true);
+
+               if (contentTypeLen == -1 || length == -1 || contentHdrLen == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgPart: headerLeng calculation fail \n");
+                       goto __CATCH;
+               }
+
+               headerLeng = contentTypeLen + contentHdrLen + length;
+               length = MmsBinaryEncodeUintvarLen(headerLeng);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgPart: headerLeng MmsBinaryEncodeUintvarLen fail \n");
+                       goto __CATCH;
+               }
+
+               if (MmsBinaryEncodeUintvar(pFile, headerLeng, length) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgPart: headerLeng fail \n");
+                       goto __CATCH;
+               }
+
+               length = MmsBinaryEncodeUintvarLen(pBody->size);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgPart: bodyLeng MmsBinaryEncodeUintvarLen fail \n");
+                       goto __CATCH;
+               }
+
+               if (MmsBinaryEncodeUintvar(pFile, pBody->size, length) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgPart: bodyLeng fail \n");
+                       goto __CATCH;
+               }
+
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgPart: 2. header MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+
+               /* content-type & header --------------------------- */
+               pType->offset = _MmsGetEncodeOffset();
+
+               if (MmsBinaryEncodeContentType(pFile, pType, contentTypeLen) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeMsgPart: MmsBinaryEncodeContentType fail \n");
+                       goto __CATCH;
+               }
+
+               if (MmsBinaryEncodeContentHeader(pFile, (MsgContentType)contentType, pType, true) == false)     {
+                       MSG_DEBUG("MmsBinaryEncodeMsgPart: MmsBinaryEncodeContentHeader fail \n");
+                       goto __CATCH;
+               }
+
+               pType->size = _MmsGetEncodeOffset() - pType->offset;
+       }
+
+       if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+               MSG_DEBUG("MmsBinaryEncodeMsgPart: contentBody MsgWriteDataFromEncodeBuffer fail \n");
+               goto __CATCH;
+       }
+
+       /* content-body --------------------------- */
+       if (MmsBinaryEncodeContentBody(pFile, pBody) == false) {
+               MSG_DEBUG("MmsBinaryEncodeMsgPart: MmsBinaryEncodeContentBody fail \n");
+               goto __CATCH;
+       }
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       return true;
+
+__CATCH:
+
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       MSG_DEBUG("## MmsBinaryEncodeMsgPart: failed\n");
+       if (pFile2) {
+               MsgCloseFile(pFile2);
+               pFile2 = NULL;
+       }
+
+       return false;
+}
+
+
+int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType, bool bMultipart)
+{
+       int     length = 0;
+       int     totalLength = 0;
+       char *szTextValue = NULL;
+
+
+       MSG_DEBUG("MmsBinaryEncodeContentHeaderLen: S T A R T \n\n");
+
+       /* content-id ------------------------------------------------- */
+       if (pType->szContentID[0]) {
+               if (bMultipart) { //Binary Encoding
+                       totalLength++;
+               } else {
+                       /* content-id = Quoted-string */
+                       length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-ID");
+                       if (length == -1) {
+                               MSG_DEBUG("MmsBinaryEncodeContentHeaderLen: Content-ID MmsBinaryEncodeTextStringLen fail.\n");
+                               goto __CATCH;
+                       }
+
+                       totalLength += length;
+               }
+
+               length = MmsBinaryEncodeQuotedStringLen((UINT8*)pType->szContentID);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentID MmsBinaryEncodeQuotedStringLen fail.\n");
+                       goto __CATCH;
+               }
+               totalLength += length;
+       }
+
+
+       if (pType->szContentLocation[0]) {
+               if (bMultipart) { //Binary Encoding
+                       totalLength++;
+               } else {
+                       /* content-location = Quoted-string */
+                       length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-Location");
+                       if (length == -1) {
+                               MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Location MmsBinaryEncodeTextStringLen fail.\n");
+                               goto __CATCH;
+                       }
+
+                       totalLength += length;
+               }
+
+               length = MmsBinaryEncodeTextStringLen((UINT8*)pType->szContentLocation);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentLocation MmsBinaryEncodeTextStringLen fail.\n");
+                       goto __CATCH;
+               }
+
+               totalLength += length;
+       }
+
+
+       /* MIME_APPLICATION_VND_WAP_MULTIPART_RELATEDrequires always "inline" */
+
+       if (contentType != MIME_APPLICATION_VND_WAP_MULTIPART_RELATED &&
+               contentType != MIME_MULTIPART_RELATED &&
+               pType->disposition != INVALID_VALUE) {
+
+               /*
+                * Content-disposition-value = Value-length Disposition *(Parameter)
+                * Disposition = Form-data | Attachment | Inline | Token-text
+                * Form-data = <Octet 128> : 0x80
+                * Attachment = <Octet 129> : 0x81
+                * Inline = <Octet 130> : 0x82
+                */
+
+               if (bMultipart) { //Binary Encoding
+                       totalLength += 3;
+               } else {
+                       /* content-disposition = Quoted-string */
+                       szTextValue = _MmsGetTextValue(MmsCodeMsgDisposition, pType->disposition);
+
+                       if (szTextValue) {
+                               length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-Disposition");
+                               if (length == -1) {
+                                       MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextStringLen fail.\n");
+                                       goto __CATCH;
+                               }
+
+                               totalLength += length;
+
+                               length = MmsBinaryEncodeTextStringLen((UINT8*)szTextValue);
+                               if (length == -1) {
+                                       MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextStringLen fail.\n");
+                                       goto __CATCH;
+                               }
+                               totalLength += length;
+                       }
+               }
+       }
+
+       return totalLength;
+
+__CATCH:
+       MSG_DEBUG("## MmsBinaryEncodeContentHeadeLen: failed");
+
+       return -1;
+}
+
+
+
+bool MmsBinaryEncodeContentHeader(FILE *pFile, MsgContentType contentType, MsgType *pType, bool bMultipart)
+{
+       int     length = 0;
+       char *szTextValue = NULL;
+
+       MSG_DEBUG("MmsBinaryEncodeContentHeader: S T A R T \n\n");
+
+       /* content-id ------------------------------------------------- */
+       if (pType->szContentID[0]) {
+               if (bMultipart) { //Binary Encoding
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_CONTENTID) | 0x80;
+               } else {
+                       /* content-id = Quoted-string */
+                       length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-ID");
+                       if (length == -1) {
+                               MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-ID MmsBinaryEncodeTextStringLen fail.\n");
+                               goto __CATCH;
+                       }
+
+                       if (MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-ID", length) == false) {
+                               MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-ID MmsBinaryEncodeTextString fail.\n");
+                               goto __CATCH;
+                       }
+               }
+
+               length = MmsBinaryEncodeQuotedStringLen((UINT8*)pType->szContentID);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentID MmsBinaryEncodeQuotedStringLen fail.\n");
+                       goto __CATCH;
+               }
+
+               if (MmsBinaryEncodeQuotedString(pFile, (UINT8*)pType->szContentID, length) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentID MmsBinaryEncodeQuotedString fail.\n");
+                       goto __CATCH;
+               }
+       }
+
+       if (pType->szContentLocation[0]) {
+               if (bMultipart) { //Binary Encoding
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_CONTENTLOCATION) | 0x80;
+               } else {
+                       /* content-location = Quoted-string */
+                       length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-Location");
+                       if (length == -1) {
+                               MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Location MmsBinaryEncodeTextStringLen fail.\n");
+                               goto __CATCH;
+                       }
+
+                       if (MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-Location", length) == false) {
+                               MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Location MmsBinaryEncodeTextString fail.\n");
+                               goto __CATCH;
+                       }
+               }
+
+               length = MmsBinaryEncodeTextStringLen((UINT8*)pType->szContentLocation);
+               if (length == -1) {
+                       MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentLocation MmsBinaryEncodeTextStringLen fail.\n");
+                       goto __CATCH;
+               }
+
+               if (MmsBinaryEncodeTextString(pFile, (UINT8*)pType->szContentLocation, length) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentLocation MmsBinaryEncodeTextString fail.\n");
+                       goto __CATCH;
+               }
+       }
+
+       /* MIME_APPLICATION_VND_WAP_MULTIPART_RELATEDrequires always "inline" */
+
+       if (contentType != MIME_APPLICATION_VND_WAP_MULTIPART_RELATED &&
+               contentType != MIME_MULTIPART_RELATED &&
+               pType->disposition != INVALID_VALUE) {
+
+               /*
+                * Content-disposition-value = Value-length Disposition *(Parameter)
+                * Disposition = Form-data | Attachment | Inline | Token-text
+                * Form-data = <Octet 128> : 0x80
+                * Attachment = <Octet 129> : 0x81
+                * Inline = <Octet 130> : 0x82
+                */
+
+               if (bMultipart) {//Binary Encoding
+
+                       UINT8 fieldValue  = 0xff;
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_DISPOSITION) | 0x80;
+
+                       fieldValue = _MmsGetBinaryValue(MmsCodeMsgDisposition, pType->disposition) | 0x80;
+
+                       if (fieldValue == 0xff)
+                               fieldValue = 0x81;
+
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = 0x01;
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldValue;
+               } else {
+                       /* content-disposition = Disposition (no support parameter) */
+
+                       szTextValue = _MmsGetTextValue(MmsCodeMsgDisposition, pType->disposition);
+
+                       if (szTextValue) {
+                               length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-Disposition");
+                               if (length == -1) {
+                                       MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextStringLen fail.\n");
+                                       goto __CATCH;
+                               }
+
+                               if (MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-Disposition", length) == false) {
+                                       MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextString fail.\n");
+                                       goto __CATCH;
+                               }
+
+                               length = MmsBinaryEncodeTextStringLen((UINT8*)szTextValue);
+                               if (length == -1) {
+                                       MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextStringLen fail.\n");
+                                       goto __CATCH;
+                               }
+
+                               if (MmsBinaryEncodeTextString(pFile, (UINT8*)szTextValue, length) == false) {
+                                       MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextString fail.\n");
+                                       goto __CATCH;
+                               }
+                       }
+               }
+       }
+
+       return true;
+
+__CATCH:
+       MSG_DEBUG("## MmsBinaryEncodeContentHeader: failed");
+       return false;
+}
+
+
+
+bool MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody)
+{
+       int nRead = 0;
+       char *pData = NULL;
+
+
+       if (pFile == NULL)
+               goto __CATCH;
+
+       if (pBody == NULL)
+               return true;
+
+       if (pBody->szOrgFilePath[0]) {
+               pData = MsgOpenAndReadMmsFile(pBody->szOrgFilePath, pBody->offset, pBody->size, &nRead);
+               if (pData == NULL)
+                       goto __CATCH;
+
+               pBody->offset = _MmsGetEncodeOffset();
+               if(MsgWriteFile(pData, sizeof(char), nRead, pFile) != nRead) {
+                       MSG_DEBUG("MsgWriteFile failed");
+                       goto __CATCH;
+               }
+               gMmsEncodeCurOffset = MsgFtell(pFile);
+
+               if (gMmsEncodeCurOffset < 0) {
+                       MSG_DEBUG("MsgFtell returns negative value [%ld]", gMmsEncodeCurOffset);
+                       goto __CATCH;
+               }
+
+               if (pData) {
+                       free(pData);
+                       pData = NULL;
+               }
+       } else if (pBody->body.pText && pBody->size) {
+               pBody->offset = _MmsGetEncodeOffset();
+               if (MsgWriteFile(pBody->body.pText, sizeof(char),pBody->size, pFile) != pBody->size) {
+                       MSG_DEBUG("MsgWriteFile failed");
+                       goto __CATCH;
+               }
+               gMmsEncodeCurOffset = MsgFtell(pFile);
+
+               if(gMmsEncodeCurOffset < 0) {
+                       MSG_DEBUG("MsgFtell returns negative value [%ld]", gMmsEncodeCurOffset);
+                       goto __CATCH;
+               }
+       }
+
+       return true;
+
+__CATCH:
+       MSG_DEBUG("## MmsBinaryEncodeContentBody: failed\n");
+       if (pData) {
+               free(pData);
+               pData = NULL;
+       }
+
+       return false;
+}
+
+
+
+/* =========================================================================
+
+   B  I  N  A  R  Y       E  N  C  O  D  I  N  G      U  T  I  L  I  T  Y
+
+   =========================================================================*/
+
+static int MmsBinaryEncodeIntegerLen(UINT32 integer)
+{
+       if (integer < 0x80) {
+               /* short-integer */
+               return 1;
+       } else {
+
+               int     length = 0;
+               /*
+                * Long-integer = Short-length Multi-octet-integer
+                * The Short-length indicates the length of the Multi-octet-integer
+                */
+
+               while (integer) {
+                       length++;
+                       integer = (integer >> 8);
+               }
+
+               length++;       // + Short-length
+
+               return length;
+       }
+}
+
+
+/*
+ * This makes value-length by specified integer value
+ *
+ * @param      length [in] gotten from MmsBinaryEncodeIntegerLen()
+ */
+static bool MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length)
+{
+       union {
+               UINT32 integer;
+               UINT8 seg[4];
+       } changer;
+
+
+       if (pFile == NULL) {
+               MSG_DEBUG("MmsBinaryEncodeInteger: source == NULL \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeInteger: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       if (integer < 0x80) {
+               /* short-integer */
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)integer | 0x80;
+       } else {
+               /*
+                * Long-integer = Short-length Multi-octet-integer
+                * The Short-length indicates the length of the Multi-octet-integer
+                */
+               changer.integer = integer;
+               length--;                                       // - "Short-length"
+
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)length;
+
+               int i;
+               for(i = 0; i < length; i++)
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos + i] = changer.seg[length - (i + 1)];
+
+               gCurMmsEncodeBuffPos += length;
+       }
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+static int MmsBinaryEncodeLongIntegerLen(UINT32 integer)
+{
+       int length = 0;
+
+       /*
+        * Long-integer = Short-length Multi-octet-integer
+        * The Short-length indicates the length of the Multi-octet-integer
+        */
+
+       if (integer == 0)
+               return 2;
+
+       while (integer) {
+               length++;
+               integer = (integer >> 8);
+       }
+
+       length++;       // + Short-length
+
+       return length;
+}
+
+
+/*
+ * This makes value-length by specified integer value
+ *
+ * @param      length [in] gotten from MmsBinaryEncodeIntegerLen()
+ */
+static bool MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length)
+{
+       int i  = 0;
+       union {
+               UINT32 integer;
+               UINT8 seg[4];
+       }changer;
+
+
+       /*
+        * Long-integer = Short-length Multi-octet-integer
+        * The Short-length indicates the length of the Multi-octet-integer
+        */
+
+       if (pFile == NULL) {
+               MSG_DEBUG("MmsBinaryEncodeLongInteger: source == NULL \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeLongInteger: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       changer.integer = integer;
+       length--;                                       // - "Short-length"
+
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)length;
+
+       for(i = 0; i < length; i++)
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos + i] = changer.seg[length - (i + 1)];
+
+       gCurMmsEncodeBuffPos += length;
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+
+static int MmsBinaryEncodeTextStringLen(UINT8 *source)
+{
+       int      length = 0;
+
+       MSG_DEBUG("MmsBinaryEncodeTextStringLen: \n");
+
+       if (source == NULL) {
+               MSG_DEBUG("MmsBinaryEncodeTextStringLen: source == NULL \n");
+               return -1;
+       }
+
+       length = (int)strlen((char*)source);
+       if (source[0] > 0x7F) {
+               length += 2;                    // + NULL
+       } else {
+               length++;                               // + NULL
+       }
+
+       return length;
+}
+
+
+/*
+ * @param      source [in] originam string
+ * @param      length [in] gotten from MmsBinaryEncodeTextStringLen()
+ * @param      dest [in] buffer to store quted string
+ * @return     changed string length
+*/
+static bool MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length)
+{
+
+       MSG_DEBUG("MmsBinaryEncodeTextString: \n");
+
+       /*
+        * make text string
+        * Text-string = [Quote] *TEXT End-of-string
+        * If the 1st char in the TEXT is in the range of 128-255, a Quote char must precede it.
+        * Otherwise the Quote char must be omitted.
+        * The Quote is not part of the contents.
+        * Quote = <Octet 127>
+        */
+
+       if (pFile == NULL || source == NULL) {
+               MSG_DEBUG("MmsBinaryEncodeTextString: source == NULL \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeTextString: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       if (source[0] > 0x7F) {
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = QUOTE;
+               length--;
+       }
+
+       strncpy(gpMmsEncodeBuf + gCurMmsEncodeBuffPos, (char*)source, (length - 1));    // except NULL
+       gCurMmsEncodeBuffPos += (length - 1);                   // except NULL
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)NULL;
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+
+/*
+ * Encode 28bit unsigned integer(Maximum) to uintvar
+ *
+ * @param      interger [in] integer to be encoded
+ * @return     encoded UINTVAR stream
+*/
+const UINT32 UINTVAR_LENGTH_1 =  0x0000007f;           //7bit
+const UINT32 UINTVAR_LENGTH_2 =  0x00003fff;           //14bit
+const UINT32 UINTVAR_LENGTH_3 =  0x001fffff;           //21bit
+
+
+static int MmsBinaryEncodeUintvarLen(UINT32 integer)
+{
+       UINT32          length  = 0;
+
+       /* Find encoded unitvar length */
+       if (integer  <= UINTVAR_LENGTH_1) {
+               length = 1;
+       } else {
+               if (integer <= UINTVAR_LENGTH_2) {
+                       length = 2;
+               } else {
+                       if (integer <= UINTVAR_LENGTH_3) {
+                               length = 3;
+                       } else {
+                               length = 4;
+                       }
+               }
+       }
+
+       return length;
+}
+
+
+static bool MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length)
+{
+       const char ZERO = 0x00;
+       int i = 2;
+       char szReverse[MSG_STDSTR_LONG] = {0, };
+
+       union {
+               UINT32  integer;
+               char    bytes[4];
+       } source;
+
+       if (pFile == NULL) {
+               MSG_DEBUG("MmsBinaryEncodeUintvar: pFile == INVALID_HBOJ \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeUintvar: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       source.integer = integer;
+       memset(szReverse, 0, MSG_STDSTR_LONG);
+
+       /* Seperate integer to 4 1 byte integer */
+       szReverse[3] = source.bytes[3] & 0x0f;
+       szReverse[0] = source.bytes[0];
+       szReverse[0] = szReverse[0] & 0x7f;
+
+       while (length >= i) { // initially, i = 2
+               /* Move integer bit to proper position */
+               source.integer = source.integer << 1;
+               source.integer = source.integer >> 8;
+               source.bytes[3] = ZERO;
+
+               /* Retrive 1 encode uintvar */
+               szReverse[i-1] = source.bytes[0];
+               szReverse[i-1] = szReverse[i-1] | 0x80;
+               i++;
+       }
+
+       for(i=0; i < length; i++)
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = szReverse[length - i - 1];
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+
+static int MmsBinaryEncodeValueLengthLen(UINT32 integer)
+{
+       int length = 0;
+
+       if (integer < 0x1f) {
+               length = 1;
+       } else {
+               length = MmsBinaryEncodeUintvarLen(integer) + 1;                //LENGTH_QUOTE
+       }
+
+       return length;
+}
+
+
+/*
+ * This makes value-length by specified integer value
+ *
+ * @param      length [in] from MmsBinaryEncodeValueLengthLen()
+ * @return     encoded value-length
+ */
+static bool MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length)
+{
+       /*
+        * Value-length = Short-length | (Length-quote Length)
+        * ; Value length is used to indicate the length of the value to follow
+        * Short-length = <Any octet 0-30>
+        * Length-quote = <Octet 31>
+        * Length = Uintvar-integer
+        */
+
+       if (pFile == NULL) {
+               MSG_DEBUG("MmsBinaryEncodeValueLength: pFile == INVALID_HBOJ \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeValueLength: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       if (integer < 0x1F) {
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)integer;
+       } else {
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)LENGTH_QUOTE;
+               if (MmsBinaryEncodeUintvar(pFile, integer, length - 1) == false) {      // LENGTH_QUOTE
+                       MSG_DEBUG("MmsBinaryEncodeValueLength: MmsBinaryEncodeUintvar fail\n");
+                       goto __CATCH;
+               }
+       }
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+static int MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc)
+{
+       if (pSrc == NULL) {
+               MSG_DEBUG("MmsBinaryEncodeQuotedStringLen: invalid file\n");
+               goto __CATCH;
+       }
+
+       return (strlen((char*)pSrc) + 2);       // QUOTE + NULL
+
+__CATCH:
+       return -1;
+}
+
+
+/*
+ * make quoted string
+ * Quoted-string = <Octet 34> *TEXT End-of-string
+ *
+ * @param      source [in] original string
+ * @param      length [in] length (in bytes) of data
+ * @param      dest [out] buffer to store quted string
+ * @return     changed string length
+*/
+static bool MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length)
+{
+       if (source == NULL || pFile == NULL) {
+               MSG_DEBUG("MmsBinaryEncodeQuotedString: invalid file\n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeQuotedString: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = '\"';
+       strncpy(gpMmsEncodeBuf + gCurMmsEncodeBuffPos, (char*)source, length - 2);              // except '\"' & NULL
+       gCurMmsEncodeBuffPos += (length - 2);
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)NULL;
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+
+static int MmsBinaryEncodeEncodedStringLen(UINT8 *source)
+{
+       UINT32 charset = 0x6A;          // default = utf-8
+       int charLeng            = 0;
+       int textLeng            = 0;
+       int valueLengthLen      = 0;
+
+
+       MSG_DEBUG("MmsBinaryEncodeEncodedStringLen: \n");
+
+       /* value-length charSet text-string */
+       /* Estimate charset value length and text string length */
+       charLeng = MmsBinaryEncodeIntegerLen(charset);
+       if (charLeng == -1) {
+               MSG_DEBUG("MmsBinaryEncodeEncodedStringLen : charLeng MmsBinaryEncodeTextStringLen fail.\n");
+               goto __CATCH;;
+       }
+
+       textLeng = MmsBinaryEncodeTextStringLen((UINT8*)source);
+       if (textLeng == -1)     {
+               MSG_DEBUG("MmsBinaryEncodeEncodedStringLen : textLeng MmsBinaryEncodeTextStringLen fail.\n");
+               goto __CATCH;;
+       }
+
+       valueLengthLen = MmsBinaryEncodeValueLengthLen(charLeng + textLeng);
+       if (valueLengthLen == -1) {
+               MSG_DEBUG("MmsBinaryEncodeEncodedStringLen : valLengthLen MmsBinaryEncodeTextStringLen fail.\n");
+               goto __CATCH;
+       }
+
+       return (charLeng + textLeng + valueLengthLen);
+
+__CATCH:
+       return -1;
+}
+
+
+/*
+ * This makes value-length by specified integer value
+ *
+ * @param      length [in] from MmsBinaryEncodeEncodedStringLen()
+ * @return     encoded encoded-string
+ */
+static bool MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length)
+{
+       UINT32 charset = 0x6A;          // default = utf-8
+       int charLeng = 0;
+       int textLeng = 0;
+       int valLengthLen = 0;
+
+
+       MSG_DEBUG("MmsBinaryEncodeEncodedString: \n");
+
+       /* value-length charSet text-string */
+
+       if (pFile == NULL || source == NULL) {
+               MSG_DEBUG("MmsBinaryEncodeEncodedString: invalid input parameter\n");
+               goto __CATCH;
+       }
+
+       /* Estimate charset value length and text string length */
+       charLeng = MmsBinaryEncodeIntegerLen(charset);
+       if (charLeng == -1) {
+               MSG_DEBUG("MmsBinaryEncodeEncodedString : charLeng MmsBinaryEncodeTextStringLen fail.\n");
+               goto __CATCH;;
+       }
+
+       textLeng = MmsBinaryEncodeTextStringLen((UINT8*)source);
+       if (textLeng == -1) {
+               MSG_DEBUG("MmsBinaryEncodeEncodedString : textLeng MmsBinaryEncodeTextStringLen fail.\n");
+               goto __CATCH;;
+       }
+
+       valLengthLen = MmsBinaryEncodeValueLengthLen(charLeng + textLeng);
+       if (valLengthLen == -1) {
+               MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeValueLengthLen fail.\n");
+               goto __CATCH;
+       }
+
+       if (length != (charLeng + textLeng + valLengthLen))
+       {
+               MSG_DEBUG("MmsBinaryEncodeEncodedString: invalid length\n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("MmsBinaryEncodeEncodedString: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       /* Value length of charset value and text string */
+       if (MmsBinaryEncodeValueLength(pFile, charLeng + textLeng, valLengthLen) == false) {
+               MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeValueLength fail.\n");
+               goto __CATCH;
+       }
+
+       /* fixme: Write charset on buffer -> integer value not long-integer */
+       if (MmsBinaryEncodeInteger(pFile, charset, charLeng) == false) {
+               MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeInteger fail.\n");
+               goto __CATCH;
+       }
+
+
+       /* Write text string on buffer */
+       if (MmsBinaryEncodeTextString(pFile, (UINT8*)source, textLeng) == false) {
+               MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeTextString fail.\n");
+               goto __CATCH;
+       }
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+static bool __MmsBinaryEncodeFieldCodeAndValue(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue)
+{
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < 2) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                               gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("__MmsBinaryEncodeFieldCodeAndValue: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       if (fieldCode == 0xff) {
+               MSG_DEBUG("__MmsBinaryEncodeFieldCodeAndValue: invalid fieldCode \n");
+               goto __CATCH;
+       }
+
+       if (fieldValue == 0xff) {
+               MSG_DEBUG("__MmsBinaryEncodeFieldCodeAndValue: invalid fieldValue \n");
+               return true;
+       }
+
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode;
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldValue;
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+
+static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen)
+{
+       int     length    = 0;
+       UINT8 fieldCode = 0xff;
+       char szBuff[MMS_TR_ID_LEN + 1] = {0, };
+       struct  tm      *dateTime = NULL;
+       time_t  RawTime = 0;
+       time_t  dateSec = 0;
+
+       time(&RawTime);
+       dateTime = localtime(&RawTime);
+       dateSec = mktime(dateTime);
+
+
+       fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80;
+       if (fieldCode == 0xff) {
+               MSG_DEBUG("__MmsBinaryEncodeTrID: invalid fieldCode \n");
+               goto __CATCH;
+       }
+
+       snprintf(szBuff, MMS_TR_ID_LEN + 1, "%lu.%lu", dateSec, (unsigned long)random());
+       MSG_DEBUG("__MmsBinaryEncodeTrID: 2. szBuff = %s\n", szBuff);
+
+       length = MmsBinaryEncodeTextStringLen((UINT8*)szBuff);
+       if (length == -1) {
+               MSG_DEBUG("__MmsBinaryEncodeTrID: MmsBinaryEncodeTextStringLen fail \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("__MmsBinaryEncodeTrID: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode;
+       if (MmsBinaryEncodeTextString(pFile, (UINT8*)szBuff, length) == false) {
+               MSG_DEBUG("__MmsBinaryEncodeTrID: MmsBinaryEncodeTextString fail\n");
+               goto __CATCH;
+       }
+
+       if (szTrID) {
+               memset(szTrID, 0, bufLen);
+               strncpy(szTrID, szBuff, bufLen - 1);
+       }
+
+       return true;
+
+__CATCH:
+
+       return false;
+}
+
+static bool __MmsBinaryEncodeMsgID(FILE *pFile, const char *szMsgID)
+{
+       int     length = 0;
+       UINT8 fieldCode = 0xff;
+
+       fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGID) | 0x80;
+       if (fieldCode == 0xff) {
+               MSG_DEBUG("__MmsBinaryEncodeTrID: invalid fieldCode \n");
+               goto __CATCH;
+       }
+
+       MSG_DEBUG("__MmsBinaryEncodeMsgID: 2. szBuff = %s\n", szMsgID);
+
+       length = MmsBinaryEncodeTextStringLen((UINT8*)szMsgID);
+       if (length == -1) {
+               MSG_DEBUG("__MmsBinaryEncodeMsgID: MmsBinaryEncodeTextStringLen fail \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                               gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("__MmsBinaryEncodeTrID: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode;
+       if (MmsBinaryEncodeTextString(pFile, (UINT8*)szMsgID, length) == false) {
+               MSG_DEBUG("__MmsBinaryEncodeTrID: MmsBinaryEncodeTextString fail\n");
+               goto __CATCH;
+       }
+
+       return true;
+
+__CATCH:
+
+       return false;
+}
+
+
+
+static bool __MmsBinaryEncodeMmsVersion(FILE *pFile)
+{
+       UINT8 majorVer = MMS_MAJOR_VERSION;
+       UINT8 minorVer = MMS_MINOR_VERSION;
+
+       MSG_DEBUG("__MmsBinaryEncodeMmsVersion: \n");
+
+       if (pFile == NULL) {
+               MSG_DEBUG("__MmsBinaryEncodeMmsVersion: invalid input file \n");
+               goto __CATCH;
+       }
+
+       if (majorVer < 1) {
+               MSG_DEBUG("__MmsBinaryEncodeMmsVersion: invalid major version (%d)\n", majorVer);
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < 2) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                               gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("__MmsBinaryEncodeMmsVersion: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_VERSION) | 0x80;
+
+       MSG_DEBUG("__MmsBinaryEncodeMmsVersion: major version (%d)\n", majorVer);
+       MSG_DEBUG("__MmsBinaryEncodeMmsVersion: minor version (%d)\n", minorVer);
+
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos] = (majorVer << 4) | (minorVer & 0x0f) | MSB;
+
+       if (gpMmsEncodeBuf[gCurMmsEncodeBuffPos] < 0x80) {
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] |= 0x80;
+       } else {
+               gCurMmsEncodeBuffPos++;
+       }
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+
+static bool __MmsBinaryEncodeDate(FILE *pFile)
+{
+       struct  tm      *dateTime = NULL;
+       time_t  dateSec = 0;
+
+       dateSec = time(NULL);
+       dateTime = localtime(&dateSec);
+
+       MSG_DEBUG("%d - %d - %d, %d : %d (SYSTEM)", dateTime->tm_year + 1900, dateTime->tm_mon + 1, dateTime->tm_mday
+               , dateTime->tm_hour, dateTime->tm_min);
+
+       if (dateSec > 0) {
+               int     length  = 0;
+               length = MmsBinaryEncodeLongIntegerLen(dateSec);
+
+               if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) { // + fieldCode
+                       if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                               gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                               MSG_DEBUG("__MmsBinaryEncodeDate: MsgWriteDataFromEncodeBuffer fail \n");
+                               goto __CATCH;
+                       }
+               }
+
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DATE) | 0x80;
+
+               if (MmsBinaryEncodeLongInteger(pFile, dateSec, length) == false) {
+                       MSG_DEBUG("__MmsBinaryEncodeDate: date MmsBinaryEncodeLongInteger error\n");
+                       goto __CATCH;
+               }
+       } else {
+               MSG_DEBUG("__MmsBinaryEncodeDate: date has a negative value (%d) \n", dateSec);
+               goto __CATCH;
+       }
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+
+static bool __MmsBinaryEncodeFrom(FILE *pFile)
+{
+       if (pFile == NULL) {
+               MSG_DEBUG("__MmsBinaryEncodeFrom: invalid input file \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < 3) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("__MmsBinaryEncodeFrom: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_FROM) | 0x80;
+       /* length of MMS_INSERT_ADDRESS_TOKEN value */
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = 0x01;
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeAddressType, MMS_INSERT_ADDRESS_TOKEN) | 0x80;
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+static bool __MmsBinaryEncodeOneAddress(FILE *pFile, MmsFieldCode addrType, char *szAddrStr)
+{
+       int length = 0;
+
+       if (pFile == NULL) {
+               MSG_DEBUG("__MmsBinaryEncodeOneAddress: invalid input file \n");
+               goto __CATCH;
+       }
+
+       /* EncodedString */
+       length = MmsBinaryEncodeEncodedStringLen((UINT8*)szAddrStr);
+
+       if (length == -1) {
+               MSG_DEBUG("__MmsBinaryEncodeOneAddress: MmsBinaryEncodeEncodedStringLen fail \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length + 1) {
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("__MmsBinaryEncodeOneAddress: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, addrType) | 0x80;
+
+
+       if (MmsBinaryEncodeEncodedString(pFile, (UINT8*)szAddrStr, length) == false) {
+               MSG_DEBUG("__MmsBinaryEncodeOneAddress: MmsBinaryEncodeEncodedString fail \n");
+               goto __CATCH;
+       }
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+static bool __MmsBinaryEncodeAddress(FILE *pFile, MmsFieldCode addrType, char *szAddr)
+{
+       char *pSingleAddr = NULL;
+
+
+       if (pFile == NULL) {
+               MSG_DEBUG("__MmsBinaryEncodeAddress: invalid input file \n");
+               goto __CATCH;
+       }
+
+       while (szAddr && szAddr[0]) {
+               szAddr = _MsgSkipWS3(szAddr);
+               if (szAddr == NULL)
+                       break;
+
+               pSingleAddr = strchr(szAddr, MSG_CH_SEMICOLON);
+               if (pSingleAddr) {
+
+                       *pSingleAddr = MSG_CH_NULL;
+                       if (__MmsBinaryEncodeOneAddress(pFile, addrType, szAddr) == false) {
+                               MSG_DEBUG("__MmsBinaryEncodeAddress: __MmsBinaryEncodeAddress fail\n");
+                               goto __CATCH;
+                       }
+                       *pSingleAddr = MSG_CH_SEMICOLON;
+
+                       szAddr           = pSingleAddr + 1;
+                       pSingleAddr  = NULL;
+               } else {
+                       if (__MmsBinaryEncodeOneAddress(pFile, addrType, szAddr) == false) {
+                               MSG_DEBUG("__MmsBinaryEncodeAddress: __MmsBinaryEncodeAddress fail\n");
+                               goto __CATCH;
+                       }
+
+                       szAddr = NULL;
+               }
+       }
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
+
+
+static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeStruct time)
+{
+       int             timeLen  = 0;
+       int             length   = 0;
+
+       if (pFile == NULL) {
+               MSG_DEBUG("__MmsBinaryEncodeTime: invalid input file \n");
+               goto __CATCH;
+       }
+
+       if (time.time == 0 ||
+               (fieldCode != MMS_CODE_EXPIRYTIME && fieldCode != MMS_CODE_DELIVERYTIME && fieldCode != MMS_CODE_REPLYCHARGINGDEADLINE) ||
+               (time.type != MMS_TIMETYPE_ABSOLUTE && time.type != MMS_TIMETYPE_RELATIVE)) {
+               MSG_DEBUG("__MmsBinaryEncodeTime: time.type = %d \n", time.type);
+               return true;
+       }
+
+       /*
+        * use temporary buffer to estimate value length
+        * and copy it to pData buffer later.
+        */
+
+       if (time.type == MMS_TIMETYPE_RELATIVE) {
+               timeLen = MmsBinaryEncodeIntegerLen(time.time);
+       } else {
+               timeLen = MmsBinaryEncodeLongIntegerLen(time.time);
+       }
+
+       if (timeLen <= 0) {
+               MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeLongIntegerLen fail \n");
+               goto __CATCH;
+       }
+
+       length = MmsBinaryEncodeValueLengthLen(timeLen + 1);    //time length + time type token
+       if (length == -1) {
+               MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeValueLengthLen fail \n");
+               goto __CATCH;
+       }
+
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + timeLen + 2)) {       // + fieldCode + timeType
+
+               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
+                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
+                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: MsgWriteDataFromEncodeBuffer fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       /* fieldCode */
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, fieldCode) | 0x80;
+
+       /* value length */
+       if (MmsBinaryEncodeValueLength(pFile, timeLen + 1, length) == false) {
+               MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeValueLength fail \n");
+               goto __CATCH;
+       }
+
+       /* time type & value */
+       if (time.type == MMS_TIMETYPE_RELATIVE) {
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_RELATIVE) | 0x80;
+               if (MmsBinaryEncodeInteger(pFile, time.time, timeLen) == false) {
+                       MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeLongInteger fail \n");
+                       goto __CATCH;
+               }
+       } else {
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE) | 0x80;
+               if (MmsBinaryEncodeLongInteger(pFile, time.time, timeLen) == false) {
+                       MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeLongInteger fail \n");
+                       goto __CATCH;
+               }
+       }
+
+       return true;
+
+__CATCH:
+       return false;
+}
+
diff --git a/plugin/mms_plugin/MmsPluginEventHandler.cpp b/plugin/mms_plugin/MmsPluginEventHandler.cpp
new file mode 100755 (executable)
index 0000000..881a9aa
--- /dev/null
@@ -0,0 +1,165 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include<stdio.h>
+#include<stdlib.h>
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgMmsTypes.h"
+#include "MsgSoundPlayer.h"
+#include "MsgStorageHandler.h"
+#include "MmsPluginTransport.h"
+#include "MmsPluginEventHandler.h"
+#include "MmsPluginCodec.h"
+#include "MmsPluginInternal.h"
+#include "MmsPluginSmil.h"
+#include "MsgMmsMessage.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginEventHandler - Member Functions
+==================================================================================================*/
+MmsPluginEventHandler *MmsPluginEventHandler::pInstance = NULL;
+
+
+MmsPluginEventHandler::MmsPluginEventHandler()
+{
+       memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S));
+}
+
+
+MmsPluginEventHandler::~MmsPluginEventHandler()
+{
+
+}
+
+
+MmsPluginEventHandler *MmsPluginEventHandler::instance()
+{
+       if (!pInstance)
+               pInstance = new MmsPluginEventHandler();
+
+       return pInstance;
+}
+
+
+void MmsPluginEventHandler::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
+{
+       listener = *pListener;
+}
+
+
+void MmsPluginEventHandler::handleMmsReceivedData(mmsTranQEntity *pRequest, char *pRetrievedFilePath)
+{
+       MSG_MESSAGE_INFO_S msgInfo = {0,};
+
+       switch (pRequest->eMmsPduType) {
+       // received data is send-conf
+       case eMMS_SEND_CONF:
+               MmsPluginInternal::instance()->processSendConf(&msgInfo, pRequest);
+
+               // callback to MSG FW
+               listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
+
+               //MsgDeleteFile(pRetrievedFilePath + strlen(MSG_DATA_PATH)); // not ipc
+               remove(pRetrievedFilePath); // not ipc
+               break;
+
+       // received data is retrieve-conf
+       case eMMS_RETRIEVE_AUTO_CONF:
+       case eMMS_RETRIEVE_MANUAL_CONF:
+               MmsPluginInternal::instance()->processRetrieveConf(&msgInfo, pRequest, pRetrievedFilePath);
+
+               // callback to MSG FW
+               listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
+               break;
+
+       case eMMS_FORWARD_CONF:
+               MmsPluginInternal::instance()->processForwardConf(&msgInfo, pRequest);
+               break;
+
+       default:
+               break;
+       }
+}
+
+
+void MmsPluginEventHandler::handleMmsError(mmsTranQEntity *pRequest)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_MESSAGE_INFO_S msgInfo = {};
+       MMS_RECV_DATA_S recvData = {{0}, };
+
+       MSG_DEBUG("pRequest->msgId [%d]", pRequest->msgId);
+
+       switch (pRequest->eMmsPduType) {
+       case eMMS_SEND_REQ:
+       case eMMS_SEND_CONF:
+               msgInfo.msgId = pRequest->msgId;
+               //Set only changed members
+               msgInfo.msgType.mainType = MSG_MMS_TYPE;
+
+               if (pRequest->eMmsPduType == eMMS_SEND_REQ)
+                       msgInfo.msgType.subType = MSG_SENDREQ_MMS;
+               else
+                       msgInfo.msgType.subType = MSG_SENDCONF_MMS;
+
+               msgInfo.networkStatus = MSG_NETWORK_SEND_FAIL;
+
+               msgInfo.folderId = MSG_OUTBOX_ID;
+
+               listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
+               break;
+
+       case eMMS_RETRIEVE_AUTO:
+       case eMMS_RETRIEVE_AUTO_CONF:
+               msgInfo.msgId = pRequest->msgId;
+               //Set only changed members
+               msgInfo.msgType.mainType = MSG_MMS_TYPE;
+               msgInfo.msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS;
+
+               msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
+               msgInfo.folderId = MSG_INBOX_ID;
+
+               err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
+
+               break;
+
+       case eMMS_RETRIEVE_MANUAL:
+       case eMMS_RETRIEVE_MANUAL_CONF:
+               msgInfo.msgId = pRequest->msgId;
+               //Set only changed members
+               msgInfo.msgType.mainType = MSG_MMS_TYPE;
+               msgInfo.msgType.subType = MSG_RETRIEVE_MANUALCONF_MMS;
+
+               msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
+               msgInfo.folderId = MSG_INBOX_ID;
+
+               err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
+
+               break;
+
+       default:
+               break;
+       }
+
+       MSG_END();
+}
+
diff --git a/plugin/mms_plugin/MmsPluginHttp.cpp b/plugin/mms_plugin/MmsPluginHttp.cpp
new file mode 100755 (executable)
index 0000000..5762a63
--- /dev/null
@@ -0,0 +1,631 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MmsPluginHttp.h"
+#include "MmsPluginUserAgent.h"
+#include "stdlib.h"
+#include <time.h>
+#include "MmsPluginConnManWrapper.h"
+
+
+
+void httpGetHostFromUrl(char *pUrl, char *pHost)
+{
+       int hostLen = 0;
+       int tailLen = 0;
+       char *tail = NULL;
+
+       if (strstr(pUrl, "HTTP://") == NULL) {
+               tail = strstr(pUrl, "/");
+               if (NULL == tail)
+                       tailLen = 0;
+               else
+                       tailLen = strlen(tail);
+
+               hostLen = strlen(pUrl) - tailLen;
+               memcpy(pHost, pUrl, hostLen);
+               pHost[hostLen] = '\0';
+       } else {
+               tail = strstr(&pUrl[7], "/");
+               if (NULL == tail)
+                       tailLen = 0;
+               else
+                       tailLen = strlen(tail);
+
+               hostLen = strlen(pUrl) - tailLen - 7;
+               memcpy(pHost, &pUrl[7], hostLen);
+               pHost[hostLen] = '\0';
+       }
+}
+
+void  HttpHeaderInfo(curl_slist **responseHeaders, char *szUrl, int ulContentLen)
+{
+       char szBuffer[1025] = {0, };
+       char pcheader[HTTP_REQUEST_LEN] = {0, };
+
+       bool nResult = MsgMmsGetCustomHTTPHeader(MMS_HH_CONTENT_TYPE, szBuffer);
+       if (nResult) {
+               strcat(pcheader,"Content-Type: ");
+               strcat(pcheader, szBuffer);
+               MSG_DEBUG("%s", pcheader);
+               *responseHeaders = curl_slist_append(*responseHeaders, pcheader);
+       }
+
+       memset(szBuffer, 0, 1025);
+       memset(pcheader, 0, HTTP_REQUEST_LEN);
+       snprintf(szBuffer, 1024, "%d", ulContentLen);
+       if (nResult) {
+               strcat(pcheader, "Content-Length: ");
+               strcat(pcheader, szBuffer);
+               MSG_DEBUG("%s", pcheader);
+               *responseHeaders = curl_slist_append(*responseHeaders, pcheader);
+       }
+
+       memset(szBuffer, 0, 1025);
+       memset(pcheader, 0, HTTP_REQUEST_LEN);
+       nResult = MsgMmsGetCustomHTTPHeader(MMS_HH_HOST, szBuffer);
+       if (nResult) {
+               strcat(pcheader, "HOST: ");
+               strcat(pcheader, szBuffer);
+               MSG_DEBUG("%s", pcheader);
+               *responseHeaders = curl_slist_append(*responseHeaders, pcheader);
+       }
+
+       memset(szBuffer, 0, 1025);
+       memset(pcheader, 0, HTTP_REQUEST_LEN);
+       nResult = MsgMmsGetCustomHTTPHeader(MMS_HH_ACCEPT, szBuffer);
+       if (nResult) {
+               strcat(pcheader, "Accept: ");
+               strcat(pcheader, szBuffer);
+               MSG_DEBUG("%s", pcheader);
+               *responseHeaders = curl_slist_append(*responseHeaders, pcheader);
+       }
+
+       memset(szBuffer, 0, 1025);
+       memset(pcheader, 0, HTTP_REQUEST_LEN);
+       nResult = MsgMmsGetCustomHTTPHeader(MMS_HH_ACCEPT_CHARSET, szBuffer);
+       if (nResult) {
+               strcat(pcheader, "Accept-Charset: ");
+               strcat(pcheader, szBuffer);
+               MSG_DEBUG("%s", pcheader);
+               *responseHeaders = curl_slist_append(*responseHeaders, pcheader);
+       }
+
+       memset(szBuffer, 0, 1025);
+       memset(pcheader, 0, HTTP_REQUEST_LEN);
+       nResult = MsgMmsGetCustomHTTPHeader(MMS_HH_ACCEPT_LANGUAGE, szBuffer);
+       if (nResult) {
+               strcat(pcheader, "Accept-Language: ");
+               strcat(pcheader, szBuffer);
+               MSG_DEBUG("%s", pcheader);
+               *responseHeaders = curl_slist_append(*responseHeaders, pcheader);
+       }
+
+       memset(szBuffer, 0, 1025);
+       memset(pcheader, 0, HTTP_REQUEST_LEN);
+       nResult = MsgMmsGetCustomHTTPHeader(MMS_HH_ACCEPT_ENCODING, szBuffer);
+       if (nResult) {
+               strcat(pcheader, "Accept-Encoding: ");
+               strcat(pcheader, szBuffer);
+               MSG_DEBUG("%s", pcheader);
+               *responseHeaders = curl_slist_append(*responseHeaders, pcheader);
+       }
+
+       memset(szBuffer, 0, 1025);
+       memset(pcheader, 0, HTTP_REQUEST_LEN);
+       nResult = MsgMmsGetCustomHTTPHeader(MMS_HH_USER_AGENT, szBuffer);
+       if (nResult) {
+               strcat(pcheader, "User-Agent: ");
+               strcat(pcheader, szBuffer);
+               MSG_DEBUG("%s", pcheader);
+               *responseHeaders = curl_slist_append(*responseHeaders, pcheader);
+       }
+
+       memset(szBuffer, 0, 1025);
+       memset(pcheader, 0, HTTP_REQUEST_LEN);
+       nResult = MsgMmsGetCustomHTTPHeader(MMS_HH_WAP_PROFILE, szBuffer);
+       if (nResult) {
+               strcat(pcheader, "X-wap-profile: ");
+               strcat(pcheader, szBuffer);
+               MSG_DEBUG("%s", pcheader);
+               *responseHeaders = curl_slist_append(*responseHeaders, pcheader);
+       }
+}
+
+bool MsgMmsGetCustomHTTPHeader(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *szHeaderBuffer)
+{
+       bool result;
+
+       result = false;
+       if (szHeaderBuffer != NULL) {
+               switch (httpHeaderItem) {
+               case MMS_HH_CONTENT_TYPE:
+                       snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_CONTENT_TYPE);
+                       result = true;
+                       break;
+
+               case MMS_HH_HOST:
+                       MsgMmsGetHost(szHeaderBuffer, 1024);
+                       if (strlen(szHeaderBuffer) > 0)
+                               result = true;
+                       else
+                               result = false;
+                       break;
+
+               case MMS_HH_ACCEPT:
+                       snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_ACCEPT);
+                       result = true;
+                       break;
+
+               case MMS_HH_ACCEPT_CHARSET:
+                       snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_CHARSET);
+                       result = true;
+                       break;
+
+               case MMS_HH_ACCEPT_LANGUAGE:
+                       snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_LANGUAGE);
+                       result = true;
+                       break;
+
+               case MMS_HH_ACCEPT_ENCODING:
+                       snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_ENCODING);
+                       result = true;
+                       break;
+
+               case MMS_HH_USER_AGENT:
+                       {
+                               char szUserAgent[1024 + 1] = {0,};
+
+                               memset(szUserAgent, 0x00, (sizeof(char) * (1024 + 1) ));
+                               snprintf(szUserAgent, 1024, "%s", MSG_MMS_HH_USER_AGENT);
+
+                               snprintf((char *)szHeaderBuffer, 1024, "%s", szUserAgent);
+                               result = true;
+                       }
+                       break;
+
+               case MMS_HH_WAP_PROFILE:
+                       {
+                               char szUAProfile[1024 + 1] = {0,};
+
+                               memset(szUAProfile, 0x00, (sizeof(char)*(1024+1) ));
+                               snprintf(szUAProfile, 1024, "%s", MSG_MMS_WAP_PROFILE);
+
+                               snprintf((char *)szHeaderBuffer, 1024, "%s", szUAProfile);
+                               result = true;
+                       }
+                       break;
+
+               default:
+                       MSG_DEBUG("invalid param");
+                       break;
+               }
+       }
+
+       return result;
+}
+
+void MsgMmsGetHost(char *szHost, int nBufferLen)
+{
+       MmsPluginHttpAgent *pHttpAgent = MmsPluginHttpAgent::instance();
+       MMS_PLUGIN_HTTP_DATA_S *httpConfigData = pHttpAgent->getHttpConfigData();
+
+       const char *prefixString = "http://";
+       const char *delim = ":/\\=@";
+
+       int prefixLength = strlen(prefixString);
+
+       char *startPtr = &httpConfigData->mmscConfig.mmscUrl[0];
+       char *movePtr = NULL;
+
+       MSG_DEBUG("startPtr(%s)", startPtr);
+
+       if (strncasecmp(startPtr, prefixString, prefixLength) == 0) {
+               MSG_DEBUG("(%s) exist", prefixString);
+               startPtr += prefixLength;
+               movePtr = startPtr;
+               movePtr = strpbrk(movePtr, delim);
+               MSG_DEBUG("strpbrk --> movePtr(%s)", movePtr);
+               if (movePtr == NULL) {
+                       strncpy(szHost, startPtr, nBufferLen);
+                       MSG_DEBUG("szHost(%s)", szHost);
+               } else {
+                       int nCopyLen = movePtr - startPtr;
+                       strncpy(szHost, startPtr, nCopyLen);
+                       MSG_DEBUG("szHost(%s)", szHost);
+               }
+       } else {
+               MSG_DEBUG("(%s) not exist", prefixString);
+               movePtr = startPtr;
+               movePtr = strpbrk(movePtr, delim);
+               MSG_DEBUG("strpbrk --> movePtr(%s)", movePtr);
+               if (movePtr == NULL) {
+                       strncpy(szHost, startPtr, nBufferLen);
+                       MSG_DEBUG("szHost(%s)", szHost);
+               } else {
+                       int nCopyLen = movePtr - startPtr;
+                       strncpy(szHost, startPtr, nCopyLen);
+                       MSG_DEBUG("szHost(%s)", szHost);
+               }
+       }
+}
+
+
+MMS_NET_ERROR_T MmsHttpReadData(void *ptr, size_t size, size_t nmemb, void *userdata)
+{
+       MMS_NET_ERROR_T httpRet = eMMS_UNKNOWN;
+
+       MmsPluginHttpAgent *pHttpAgent = MmsPluginHttpAgent::instance();
+       MMS_PLUGIN_HTTP_CONTEXT_S *pMmsPlgCd = pHttpAgent->getMmsPldCd();
+       long length_received = size * nmemb;
+
+       if (length_received) {
+               //Save the received buffer in a safe place.
+               if (pMmsPlgCd->final_content_buf == NULL) {
+                       MSG_DEBUG("Body Lenghth Read = %d", length_received);
+                       pMmsPlgCd->final_content_buf = (unsigned char *)malloc((length_received + 1) * sizeof(unsigned char));
+                       memset(pMmsPlgCd->final_content_buf,0x0,((length_received + 1) * sizeof(unsigned char)));
+                       MSG_DEBUG(" Global g_final_content_buf=%0x", pMmsPlgCd->final_content_buf);
+               } else {
+                       //realloc pHttpEvent->bodyLen extra and memset
+                       pMmsPlgCd->final_content_buf = (unsigned char *)realloc(pMmsPlgCd->final_content_buf,
+                                       (pMmsPlgCd->bufOffset + length_received + 1) * sizeof(unsigned char));
+                       MSG_DEBUG("Body Lenghth Read = %d Content Length = %d", length_received, pMmsPlgCd->bufOffset);
+                       memset((pMmsPlgCd->final_content_buf +pMmsPlgCd->bufOffset), 0x0,
+                                       ((length_received + 1) * sizeof(unsigned char)));
+                       MSG_DEBUG(" Global g_final_content_buf=%0x", pMmsPlgCd->final_content_buf);
+               }
+
+               //copy body
+               if (pMmsPlgCd->final_content_buf != NULL) {
+                       memcpy( pMmsPlgCd->final_content_buf + pMmsPlgCd->bufOffset, ptr, length_received);
+                       MSG_DEBUG("Current g_bufOffset =%d", pMmsPlgCd->bufOffset);
+                       /*  Content  Received */
+                       MSG_DEBUG("Total Content received PTR =%0X, Content Size =%d", pMmsPlgCd->final_content_buf,
+                                               pMmsPlgCd->bufOffset);
+                       pMmsPlgCd->bufOffset = pMmsPlgCd->bufOffset + length_received;
+                       httpRet = eMMS_UNKNOWN;
+               }
+       } else {
+               MSG_DEBUG("End of Data transfer");
+               MSG_DEBUG("MmsHttpReadData Buffer Size = %d", pMmsPlgCd->bufOffset);
+               MSG_DEBUG("MmsHttpReadData Buffer = %s", pMmsPlgCd->final_content_buf);
+
+               if (pMmsPlgCd->bufOffset == 0) {
+                       /*  This is applicable when - M-ReadRec.inf,M-Ack.ind, M-NotifyResp.ind posted  */
+                       MSG_DEBUG(" Content Size is Zero");
+
+                       if (pMmsPlgCd->final_content_buf != NULL) {
+                       free(pMmsPlgCd->final_content_buf );
+                               pMmsPlgCd->final_content_buf = NULL;
+                       }
+
+                       httpRet = eMMS_HTTP_EVENT_SENT_ACK_COMPLETED;
+               } else if (pMmsPlgCd->final_content_buf != NULL && pMmsPlgCd->bufOffset != 0) {
+                       // Process Http Data
+                       MSG_DEBUG(" Send Received Data to UA");
+                       httpRet = eMMS_HTTP_RECV_DATA; // eMMS_HTTP_RECV_DATA;
+               } else {
+                       httpRet = eMMS_UNKNOWN; // check later
+               }
+
+               return httpRet;
+       }
+
+       return httpRet;
+}
+
+
+size_t  MmsHttpPostTransactionCB(void *ptr, size_t size, size_t nmemb, void *userdata)
+{
+       MSG_DEBUG(" ======  HTTP_EVENT_SENT ========");
+       long length_received = size * nmemb;
+       MmsHttpReadData(ptr, size, nmemb, userdata);
+
+       return length_received;
+}
+
+size_t  MmsHttpGetTransactionCB(void *ptr, size_t size, size_t nmemb, void *userdata)
+{
+       MSG_DEBUG(" ======  HTTP_EVENT_RECEIVED ========");
+       long length_received = size * nmemb;
+       MmsHttpReadData(ptr, size, nmemb, userdata);
+
+       return length_received;
+}
+
+int httpCmdInitSession(MMS_PLUGIN_HTTP_DATA_S *httpConfig)
+{
+       MSG_DEBUG("HttpCmd Init Session");
+
+       char proxyAddr[MAX_IPV4_LENGTH + 1] = {0};
+
+       snprintf(proxyAddr, MAX_IPV4_LENGTH + 1, "%s:%d", httpConfig->mmscConfig.httpProxyIpAddr, httpConfig->mmscConfig.proxyPortNo);
+       MSG_DEBUG("profileId [%d], proxyAddr [%s]", httpConfig->currentProfileId, proxyAddr);
+
+       CURL *curl_session = curl_easy_init();
+       if (NULL == curl_session) {
+               MSG_DEBUG("curl_easy_init() failed");
+               return eMMS_HTTP_SESSION_OPEN_FAILED;
+       }
+
+       int curl_status = curl_easy_setopt(curl_session, CURLOPT_PROXY, proxyAddr);
+       if (curl_status != CURLM_OK) {
+               MSG_DEBUG("curl_easy_setopt(): CURLOPT_PROXY failed");
+               curl_easy_cleanup(curl_session);
+               return eMMS_HTTP_SESSION_OPEN_FAILED;
+       }
+
+       httpConfig->session = curl_session;
+
+       return eMMS_HTTP_SESSION_INIT;
+}
+
+
+int httpCmdPostTransaction(MMS_PLUGIN_HTTP_DATA_S *httpConfig)
+{
+       int trId;
+
+       MSG_DEBUG("HttpCmd Post Transaction");
+       MSG_DEBUG(" === HTTP Agent Thread : Signal ==> eMMS_HTTP_SIGNAL_POST_TRANSACTION");
+
+       char deviceName[1024] = {0,};
+
+       MmsPluginCmAgent::instance()->getDeviceName(deviceName);
+
+       MSG_DEBUG("deviceName: [%s]", deviceName);
+       int curl_status = curl_easy_setopt(httpConfig->session, CURLOPT_INTERFACE, deviceName);
+
+       if (curl_status != CURLM_OK) {
+               MSG_DEBUG("curl_easy_setopt(): CURLOPT_INTERFACE failed");
+
+               return eMMS_EXCEPTIONAL_ERROR;
+       }
+
+       MSG_PROFILE_BEGIN(libcurl);
+
+       CURLcode rc = curl_easy_perform(httpConfig->session);
+
+       MSG_PROFILE_END(libcurl);
+
+       MmsPluginHttpAgent*     httpAgent = MmsPluginHttpAgent::instance();
+       MMS_PLUGIN_HTTP_DATA_S *httpConfigData = httpAgent->getHttpConfigData();
+       if (httpConfigData->sessionHeader) {
+               curl_slist_free_all((curl_slist *)httpConfigData->sessionHeader);
+               httpConfigData->sessionHeader = NULL;
+       }
+
+       if (CURLE_OK != rc) {
+               MSG_DEBUG("curl_easy_perform return error rc[%d]", rc);
+
+               return eMMS_HTTP_ERROR_NETWORK;
+       }
+
+       MSG_DEBUG("## End Transaction ##");
+       MSG_DEBUG("############ trID = %d ###########", trId);
+
+       srandom((unsigned int) time(NULL));
+       trId = random() % 1000000000 + 1;
+
+       httpConfig->transactionId = trId;
+
+       return eMMS_HTTP_SENT_SUCCESS;
+}
+
+int httpCmdGetTransaction(MMS_PLUGIN_HTTP_DATA_S *httpConfig)
+{
+       int trId;
+
+       MSG_DEBUG("HttpCmd Get Transaction");
+       MSG_DEBUG(" === HTTP Agent Thread : Signal ==> eMMS_HTTP_SIGNAL_GET_TRANSACTION");
+
+       char deviceName[1024] = {0,};
+       MmsPluginCmAgent::instance()->getDeviceName(deviceName);
+       MSG_DEBUG("deviceName: [%s]", deviceName);
+
+       int curl_status = curl_easy_setopt(httpConfig->session, CURLOPT_INTERFACE, deviceName);
+       if (curl_status != CURLM_OK) {
+               MSG_DEBUG("curl_easy_setopt(): CURLOPT_INTERFACE failed");
+
+               return eMMS_EXCEPTIONAL_ERROR;
+       }
+
+       CURLcode rc = curl_easy_perform(httpConfig->session);
+
+       MmsPluginHttpAgent*     httpAgent = MmsPluginHttpAgent::instance();
+       MMS_PLUGIN_HTTP_DATA_S *httpConfigData = httpAgent->getHttpConfigData();
+       if (httpConfigData->sessionHeader) {
+               curl_slist_free_all((curl_slist *)httpConfigData->sessionHeader);
+               httpConfigData->sessionHeader = NULL;
+       }
+
+       if (CURLE_OK != rc) {
+               MSG_DEBUG("curl_easy_perform return error = %d", rc);
+
+               return eMMS_HTTP_ERROR_NETWORK;
+       }
+
+       MSG_DEBUG("## End Transaction ##");
+       MSG_DEBUG("############ trID = %d ###########", trId);
+       srandom((unsigned int) time(NULL));
+       trId = random() % 1000000000 + 1;
+       httpConfig->transactionId = trId;
+
+       return eMMS_HTTP_SENT_SUCCESS;
+}
+
+MmsPluginHttpAgent *MmsPluginHttpAgent::pInstance = NULL;
+MmsPluginHttpAgent *MmsPluginHttpAgent::instance()
+{
+       if (!pInstance)
+               pInstance = new MmsPluginHttpAgent();
+
+       return pInstance;
+}
+
+
+MmsPluginHttpAgent::MmsPluginHttpAgent()
+{
+       MSG_DEBUG("MmsPluginHttpAgent()");
+
+       bzero(&httpConfigData, sizeof(httpConfigData));
+       bzero(&mmsPlgCd, sizeof(mmsPlgCd));
+
+       httpCmdHandler.clear();
+
+       waiting = false;
+
+       httpCmdHandler[eHTTP_CMD_INIT_SESSION] = &httpCmdInitSession;
+       httpCmdHandler[eHTTP_CMD_POST_TRANSACTION] = &httpCmdPostTransaction;
+       httpCmdHandler[eHTTP_CMD_GET_TRANSACTION] = &httpCmdGetTransaction;
+}
+
+MmsPluginHttpAgent::~MmsPluginHttpAgent()
+{
+
+}
+
+void MmsPluginHttpAgent::SetMMSProfile()
+{
+       MSG_BEGIN();
+
+       MMSC_CONFIG_DATA_S *mmscConfig = &(httpConfigData.mmscConfig);
+
+       MmsPluginCmAgent::instance()->getHomeURL(mmscConfig->mmscUrl);
+       if (strlen(mmscConfig->mmscUrl) < 1) {
+               strcpy(mmscConfig->mmscUrl, DEFAULT_MMSC_URL);
+       }
+
+       MmsPluginCmAgent::instance()->getProxyAddr(mmscConfig->httpProxyIpAddr);
+       mmscConfig->proxyPortNo = MmsPluginCmAgent::instance()->getProxyPort();
+
+       MSG_END();
+}
+
+int MmsPluginHttpAgent::cmdRequest(MMS_HTTP_CMD_TYPE_T cmdType)
+{
+       MSG_DEBUG("cmdRequest:%x", cmdType);
+
+       int ret = 0;
+
+       ret = httpCmdHandler[cmdType](&httpConfigData);
+
+       return ret;
+}
+
+MMS_PLUGIN_HTTP_CONTEXT_S* MmsPluginHttpAgent::getMmsPldCd()
+{
+       return &mmsPlgCd;
+}
+
+MMS_PLUGIN_HTTP_DATA_S *MmsPluginHttpAgent::getHttpConfigData()
+{
+       return &httpConfigData;
+}
+
+void MmsPluginHttpAgent::setHttpWaitingFlag(bool val)
+{
+       waiting = val;
+}
+
+bool MmsPluginHttpAgent::getHttpWaitingFlag()
+{
+       return waiting;
+}
+
+
+int MmsPluginHttpAgent::setSession(mmsTranQEntity *qEntity)
+{
+       MSG_DEBUG("%s %d", qEntity->pPostData, qEntity->postDataLen);
+
+       if (qEntity->eHttpCmdType == eHTTP_CMD_POST_TRANSACTION) {
+               MSG_DEBUG("HttpCmd Post Transaction");
+               MSG_DEBUG(" === HTTP Agent Thread : Signal ==> eMMS_HTTP_SIGNAL_POST_TRANSACTION");
+
+               curl_slist *responseHeaders = NULL;
+
+               HttpHeaderInfo(&responseHeaders, NULL, qEntity->postDataLen);
+               responseHeaders = curl_slist_append(responseHeaders, "Pragma: ");
+               responseHeaders = curl_slist_append(responseHeaders, "Proxy-Connection: ");
+               responseHeaders = curl_slist_append(responseHeaders, "Expect: ");
+               MSG_DEBUG(" === MMSCURI = %s === ", httpConfigData.mmscConfig.mmscUrl);
+
+               httpConfigData.sessionHeader = (void *)responseHeaders;
+
+               MSG_DEBUG("## Start Transaction : Post ##");
+               curl_easy_setopt(httpConfigData.session, CURLOPT_VERBOSE, true);
+               curl_easy_setopt(httpConfigData.session, CURLOPT_POST, true);
+               curl_easy_setopt(httpConfigData.session, CURLOPT_URL, httpConfigData.mmscConfig.mmscUrl);
+               curl_easy_setopt(httpConfigData.session, CURLOPT_NOPROGRESS, true);
+               curl_easy_setopt(httpConfigData.session, CURLOPT_HTTPHEADER, responseHeaders);
+               curl_easy_setopt(httpConfigData.session, CURLOPT_POSTFIELDS, qEntity->pPostData);
+               curl_easy_setopt(httpConfigData.session, CURLOPT_POSTFIELDSIZE, qEntity->postDataLen);
+               curl_easy_setopt(httpConfigData.session, CURLOPT_WRITEFUNCTION, MmsHttpPostTransactionCB);
+
+               curl_easy_setopt(httpConfigData.session, CURLOPT_TCP_NODELAY, 1);
+       } else if (qEntity->eHttpCmdType == eHTTP_CMD_GET_TRANSACTION) {
+               MSG_DEBUG("MmsHttpInitTransactionGet  %d pGetData (%s)", qEntity->getDataLen, qEntity->pGetData);
+               MSG_DEBUG("MmsHttpInitTransactionGet  mmscURL (%s) ", httpConfigData.mmscConfig.mmscUrl);
+
+               char szUrl[MAX_MMSC_URL_LEN] = {0, };
+
+               memcpy(szUrl, qEntity->pGetData, qEntity->getDataLen);
+
+               MSG_DEBUG("MmsHttpInitTransactionGet  szURL (%s)", szUrl);
+
+               curl_slist *responseHeaders = NULL;
+
+               HttpHeaderInfo(&responseHeaders, szUrl, 0);
+               responseHeaders = curl_slist_append(responseHeaders, "Pragma: ");
+               responseHeaders = curl_slist_append(responseHeaders, "Proxy-Connection: ");
+
+               httpConfigData.sessionHeader = (void *)responseHeaders;
+
+               MSG_DEBUG("## Start Transaction : Get ##");
+               curl_easy_setopt(httpConfigData.session, CURLOPT_VERBOSE, true);
+               curl_easy_setopt(httpConfigData.session, CURLOPT_URL, szUrl);
+               curl_easy_setopt(httpConfigData.session, CURLOPT_NOPROGRESS, true);
+               curl_easy_setopt(httpConfigData.session, CURLOPT_HTTPHEADER, responseHeaders);
+               curl_easy_setopt(httpConfigData.session, CURLOPT_WRITEFUNCTION, MmsHttpGetTransactionCB);
+       } else {
+               MSG_DEBUG("Unknown eHttpCmdType [%d]", qEntity->eHttpCmdType);
+               return -1;
+       }
+
+       return 0;
+}
+
+
+void MmsPluginHttpAgent::clearSession()
+{
+       MSG_BEGIN();
+
+       if (httpConfigData.sessionHeader) {
+               curl_slist_free_all((curl_slist *)httpConfigData.sessionHeader);
+               httpConfigData.sessionHeader = NULL;
+       }
+
+       if (httpConfigData.session == NULL) {
+               MSG_DEBUG("[Error]httpConfigData.session is NULL");
+               return;
+       }
+
+       curl_easy_cleanup(httpConfigData.session);
+
+       httpConfigData.session = NULL;
+
+       MSG_END();
+}
diff --git a/plugin/mms_plugin/MmsPluginInternal.cpp b/plugin/mms_plugin/MmsPluginInternal.cpp
new file mode 100755 (executable)
index 0000000..15ffcbe
--- /dev/null
@@ -0,0 +1,898 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgException.h"
+#include "MsgMmsMessage.h"
+#include "MsgTransportTypes.h"
+#include "MsgGconfWrapper.h"
+#include "MsgSoundPlayer.h"
+#include "MsgStorageHandler.h"
+#include "MmsPluginTypes.h"
+#include "MmsPluginCodec.h"
+#include "MmsPluginSetup.h"
+#include "MmsPluginInternal.h"
+#include "MmsPluginStorage.h"
+#include "MmsPluginHttp.h"
+#include "MmsPluginCodec.h"
+
+#include "MsgNotificationWrapper.h"
+#include "MmsPluginSmil.h"
+
+MmsSetup gMmsSetup;
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MmsPluginInternal - Member Functions
+==================================================================================================*/
+MmsPluginInternal *MmsPluginInternal::pInstance = NULL;
+
+
+MmsPluginInternal::MmsPluginInternal()
+{
+
+}
+
+MmsPluginInternal::~MmsPluginInternal()
+{
+
+}
+
+MmsPluginInternal *MmsPluginInternal::instance()
+{
+       if (!pInstance)
+               pInstance = new MmsPluginInternal();
+
+       return pInstance;
+}
+
+void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject)
+{
+       MSG_DEBUG("processReceivedInd \r\n");
+
+       FILE *pFile = NULL;
+       char fileName[MSG_FILENAME_LEN_MAX] = {0,};
+
+       if (pMsgInfo->bTextSms == true) {
+               char fullPath[MAX_FULL_PATH_SIZE+1] = {0,};
+
+               if(MsgCreateFileName(fileName) == false)
+                       THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+
+               MSG_DEBUG(" File name = %s", fileName);
+
+               if(MsgWriteIpcFile(fileName, pMsgInfo->msgText, pMsgInfo->dataSize) == false)
+                       THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+
+               snprintf(fullPath, MAX_FULL_PATH_SIZE+1, MSG_IPC_DATA_PATH"%s", fileName);
+
+               memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData));
+               memcpy(pMsgInfo->msgData, fullPath, strlen(fullPath));
+               pMsgInfo->bTextSms = false;
+       }
+
+       MSG_DEBUG("MMS File Path = %s", pMsgInfo->msgData);
+
+       _MmsInitHeader();
+       _MmsRegisterDecodeBuffer(gszMmsLoadBuf1,  gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX);
+
+       if ((pFile = MsgOpenFile(pMsgInfo->msgData, "rb+")) == NULL) {
+               MSG_DEBUG("File Open Error: %s", pMsgInfo->msgData);
+       } else {
+               //Decode Header
+               if (!MmsBinaryDecodeMsgHeader(pFile, pMsgInfo->dataSize))
+                       MSG_DEBUG("Decoding Header Failed \r\n");
+
+               MsgDeleteFile(pMsgInfo->msgData + strlen(MSG_IPC_DATA_PATH));
+
+               switch (mmsHeader.type) {
+               case MMS_MSGTYPE_NOTIFICATION_IND:
+                       MSG_DEBUG("MmsProcessNewMsgInd: process noti.ind\n");
+                       // For Set Value pMsgInfo
+                       if (processNotiInd(pMsgInfo, pRequest) == false)
+                               *bReject = true;
+                       else
+                               *bReject = false;
+                       break;
+
+               case MMS_MSGTYPE_DELIVERY_IND:
+                       MSG_DEBUG("MmsProcessNewMsgInd: process delivery.ind\n");
+                       // For Set Value pMsgInfo
+                       processDeliveryInd(pMsgInfo);
+                       break;
+
+               case MMS_MSGTYPE_READORG_IND:
+                       MSG_DEBUG("MmsProcessNewMsgInd: process readorig.ind\n");
+                       processReadOrgInd(pMsgInfo);
+                       break;
+               default:
+                       break;
+               }
+
+               MsgCloseFile(pFile);
+       }
+       //Check Msg Type & Process(Save ...)
+}
+
+bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest)
+{
+       MSG_DEBUG("MmsProcessNotiInd");
+       MSG_ERROR_T     err = MSG_SUCCESS;
+
+       MSG_MMS_HOME_RETRIEVE_TYPE_T retrieveType;
+       bool bReportAllowed;
+
+       MmsAttrib attrib;
+
+       MmsInitMsgAttrib(&attrib);
+
+       pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
+       pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS;
+       pMsgInfo->priority = mmsHeader.priority;
+       strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
+
+       MSG_DEBUG("pMsgInfo->subject [%s]", pMsgInfo->subject);
+
+       if (strlen(pMsgInfo->subject) < 1)
+               snprintf(pMsgInfo->subject, MAX_SUBJECT_LEN, "MMS Notification Message.");
+
+       attrib.expiryTime = mmsHeader.expiryTime;
+
+       MmsPluginStorage *pStorage = MmsPluginStorage::instance();
+       err = pStorage->updateMmsAttrib(pMsgInfo->msgId, &attrib, pMsgInfo->msgType.subType);
+
+       if (mmsHeader.pFrom) {
+               MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr);
+               // From
+               strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN);
+       }
+
+       int roamState = 0;
+
+       roamState = MsgSettingGetInt(VCONFKEY_TELEPHONY_SVC_ROAM);
+       MsgSettingGetBool(MMS_SEND_REPORT_ALLOWED, &bReportAllowed);
+
+       if (checkRejectNotiInd(roamState, bReportAllowed, pMsgInfo->msgData)) {
+               MSG_DEBUG("MMS Message Rejected......");
+
+               pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
+               pMsgInfo->bTextSms = true;
+               memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+
+               pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
+
+               return false;
+       }
+
+       if (roamState == VCONFKEY_TELEPHONY_SVC_ROAM_OFF) {
+               retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_HOME_NETWORK);
+               MSG_DEBUG("$$$$$$$$$$ MMS_RECV_HOME_NETWORK = %d $$$$$$$$$$$$$", retrieveType);
+       } else {
+               retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
+               MSG_DEBUG("$$$$$$$$$$ MMS_RECV_ABROAD_NETWORK = %d $$$$$$$$$$$$$", retrieveType);
+
+               if (retrieveType == MSG_ABROAD_RESTRICTED) {
+                       MSG_DEBUG("MMS Receiving Setting Restricted was selected.");
+                       // m-notify-resp-ind encoding process
+                       memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
+
+                       encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pMsgInfo->msgData);
+
+                       pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
+                       pMsgInfo->bTextSms = true;
+                       memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+
+                       pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
+
+                       return true;
+               }
+       }
+
+       // should send http 'GET'
+       if (retrieveType == MSG_HOME_AUTO_DOWNLOAD || retrieveType == MSG_ABROAD_AUTO_DOWNLOAD) {
+               MSG_DEBUG("=========== START AUTO RETRIEVE MODE ============");
+               memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
+
+               memcpy(pMsgInfo->msgData, mmsHeader.szContentLocation, strlen(mmsHeader.szContentLocation)) ;
+
+               pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
+
+               pMsgInfo->bTextSms = true;
+
+               memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+
+               pRequest->msgInfo.msgType.subType = MSG_GET_MMS;
+
+               MSG_DEBUG("MSG SUBTYPE = %d msg data %s bTextsms %d", pRequest->msgInfo.msgType.subType, pRequest->msgInfo.msgData, pRequest->msgInfo.bTextSms);
+       } else {
+       // should send m-notify-resp-ind
+               MSG_DEBUG("=========== START MANUAL RETRIEVE MODE ===========");
+               // m-notify-resp-ind encoding process
+               memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
+
+               if (retrieveType == MSG_HOME_MANUAL || retrieveType == MSG_ABROAD_MANUAL) {
+                       encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pMsgInfo->msgData);
+               }
+
+               pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
+               pMsgInfo->bTextSms = true;
+               memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+
+               pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
+       }
+
+       return true;
+}
+
+
+void MmsPluginInternal::processDeliveryInd(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_BEGIN();
+
+       MmsMsg *pMsg = NULL;
+       bool bFound = false;
+       MmsMsgMultiStatus *pStatus = NULL;
+       MmsMsgMultiStatus *pLastStatus = NULL;
+
+       pMsg = (MmsMsg *)malloc(sizeof(MmsMsg));
+
+       if (pMsg == NULL) {
+               MSG_DEBUG("fail to allocation memory.");
+               return;
+       }
+
+       MmsInitMsgAttrib(&pMsg->mmsAttrib);
+
+       pMsgInfo->msgType.mainType      = MSG_MMS_TYPE;
+       pMsgInfo->msgType.subType       = MSG_DELIVERYIND_MMS;
+       pMsgInfo->bTextSms = true;
+
+       MSG_DEBUG("#### mmsHeader.szMsgID = %s : when received delivery ind####", mmsHeader.szMsgID);
+
+       int tmpId = (MSG_MESSAGE_ID_T)MmsSearchMsgId(mmsHeader.pTo->szAddr, mmsHeader.szMsgID);
+
+
+       MSG_DEBUG("tmpId [%d]", tmpId);
+       MSG_DEBUG("mmsHeader.pTo->szAddr [%s]", mmsHeader.pTo->szAddr);
+
+       if (tmpId > 0) {
+               pMsgInfo->msgId = (MSG_MESSAGE_ID_T)tmpId;
+
+               pMsg->mmsAttrib.pMultiStatus = MmsGetMultiStatus(pMsgInfo->msgId);
+
+               pStatus = pMsg->mmsAttrib.pMultiStatus;
+
+               MSG_DEBUG("### pStatus->szTo = %s ###", pStatus->szTo);
+
+               while (pStatus && !bFound) {
+                       MSG_DEBUG("### MmsAddrUtilCompareAddr ###");
+                       MSG_DEBUG("### mmsHeader.pTo->szAddr = %s ###", mmsHeader.pTo->szAddr);
+                       if (MmsAddrUtilCompareAddr( pStatus->szTo, mmsHeader.pTo->szAddr)) {
+                               bFound = true;
+                               break;
+                       }
+
+                       pStatus = pStatus->pNext;
+               }
+
+               if (bFound == false) {
+                       MSG_DEBUG("### bFound == false ###");
+                       /* Queue the delivery report  --------------------------- */
+
+                       pStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus));
+                       memset(pStatus, 0, sizeof(MmsMsgMultiStatus));
+
+                       pStatus->readStatus = MMS_READSTATUS_NONE;
+                       memset(pStatus->szTo, 0, MSG_ADDR_LEN + 1);
+                       strncpy(pStatus->szTo, mmsHeader.pTo->szAddr, MSG_ADDR_LEN);
+
+                       if (pMsg->mmsAttrib.pMultiStatus == NULL) {
+                               /* first delivery report */
+                               pMsg->mmsAttrib.pMultiStatus = pStatus;
+                       } else {
+                               pLastStatus = pMsg->mmsAttrib.pMultiStatus;
+
+                               while (pLastStatus->pNext) {
+                                       pLastStatus = pLastStatus->pNext;
+                               }
+
+                               pLastStatus->pNext = pStatus;
+                               pLastStatus = pStatus;
+                       }
+               }
+
+               pStatus->handledTime = mmsHeader.date;
+               pStatus->msgStatus = mmsHeader.msgStatus;
+
+               memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
+               pMsgInfo->dataSize = 0;
+               strncpy(pMsgInfo->msgData, getMmsDeliveryStatus(pStatus->msgStatus), MAX_MSG_DATA_LEN);
+               pMsgInfo->dataSize  = strlen(pMsgInfo->msgData);
+               pMsgInfo->bTextSms = true;
+               MSG_DEBUG("Delivery Status = %s", pMsgInfo->msgData);
+
+               strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN);
+
+               pStatus->bDeliveryReportIsRead = false;
+
+               _MmsDataUpdateLastStatus(pMsg);
+
+               pStatus->bDeliveyrReportIsLast= true;
+
+               MmsUpdateDeliveryReport(pMsgInfo->msgId, pStatus);
+
+               MmsPluginStorage::instance()->addMmsNoti(pMsgInfo);
+       } else {
+               MSG_DEBUG("Can't not find Message!");
+               memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
+               pMsgInfo->dataSize = 0;
+               strncpy(pMsgInfo->msgData, getMmsDeliveryStatus(mmsHeader.msgStatus), MAX_MSG_DATA_LEN);
+
+               MSG_DEBUG("Delivery Status = %s", pMsgInfo->msgData);
+
+               pMsgInfo->dataSize  = strlen(pMsgInfo->msgData);
+
+               MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr);
+
+               strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN);
+       }
+
+       MsgFreeAttrib(&pMsg->mmsAttrib);
+
+       free(pMsg);
+
+       MSG_END();
+}
+
+void MmsPluginInternal::processReadOrgInd(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_BEGIN();
+
+       MmsMsg *pMsg = NULL;
+       bool bFound = false;
+       MmsMsgMultiStatus *pStatus = NULL;
+       MmsMsgMultiStatus *pLastStatus = NULL;
+
+       pMsg = (MmsMsg *)malloc(sizeof(MmsMsg));
+
+       if (pMsg == NULL) {
+               MSG_DEBUG("fail to allocation memory.");
+               return;
+       }
+
+       MmsInitMsgAttrib(&pMsg->mmsAttrib);
+
+       pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
+       pMsgInfo->msgType.subType = MSG_READORGIND_MMS;
+       pMsgInfo->bTextSms = true;
+
+       MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr);
+       MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr);
+
+       if (mmsHeader.readStatus != MSG_READ_REPORT_IS_DELETED || (strcmp(mmsHeader.pFrom->szAddr, mmsHeader.pTo->szAddr))) {
+               MSG_DEBUG("#### mmsHeader.szMsgID = %s : when received read orig ind####", mmsHeader.szMsgID);
+
+               int tmpId = MmsSearchMsgId(mmsHeader.pFrom->szAddr, mmsHeader.szMsgID);
+
+               if (tmpId > 0) {
+                       pMsgInfo->msgId = (MSG_MESSAGE_ID_T)tmpId;
+
+                       pMsg->mmsAttrib.pMultiStatus = MmsGetMultiStatus(pMsgInfo->msgId);
+
+                       pStatus = pMsg->mmsAttrib.pMultiStatus;
+
+                       MSG_DEBUG("### pStatus->szTo = %s ###", pStatus->szTo);
+
+                       while (pStatus && !bFound) {
+                               MSG_DEBUG("### MmsAddrUtilCompareAddr ###");
+                               MSG_DEBUG("### mmsHeader.pFrom->szAddr = %s ###", mmsHeader.pFrom->szAddr);
+                               if (MmsAddrUtilCompareAddr(pStatus->szTo, mmsHeader.pFrom->szAddr)) {
+                                       bFound = true;
+                                       break;
+                               }
+
+                               pStatus = pStatus->pNext;
+                       }
+
+                       if (bFound == false) {
+                               MSG_DEBUG("### bFound == false ###");
+                               /* Queue the delivery report  --------------------------- */
+
+                               pStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus));
+                               memset(pStatus, 0, sizeof(MmsMsgMultiStatus));
+
+                               pStatus->msgStatus = MMS_MSGSTATUS_NONE;
+
+                               memset(pStatus->szTo, 0, MSG_ADDR_LEN + 1);
+                               strncpy(pStatus->szTo, mmsHeader.pFrom->szAddr, MSG_ADDR_LEN);
+
+                               if (pMsg->mmsAttrib.pMultiStatus == NULL) {
+                                       /* first readOrg report */
+                                       pMsg->mmsAttrib.pMultiStatus = pStatus;
+                               } else {
+                                       pLastStatus = pMsg->mmsAttrib.pMultiStatus;
+
+                                       while (pLastStatus->pNext) {
+                                               pLastStatus = pLastStatus->pNext;
+                                       }
+
+                                       pLastStatus->pNext = pStatus;
+                                       pLastStatus = pStatus;
+                               }
+                       }
+
+                       pStatus->readTime = mmsHeader.date;
+                       pStatus->readStatus = mmsHeader.readStatus;
+
+                       memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
+                       pMsgInfo->dataSize = 0;
+                       strncpy(pMsgInfo->msgData, getMmsReadStatus(pStatus->readStatus), MAX_MSG_DATA_LEN);
+                       pMsgInfo->dataSize  = strlen(pMsgInfo->msgData);
+                       pMsgInfo->bTextSms = true;
+                       MSG_DEBUG("read Status = %s", pMsgInfo->msgData);
+
+                       strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN);
+
+                       pStatus->bReadReplyIsRead = false;
+
+                       _MmsDataUpdateLastStatus(pMsg);
+
+                       pStatus->bReadReplyIsLast= true;
+
+                       MmsUpdateReadReport(pMsgInfo->msgId, pStatus);
+
+                       MmsPluginStorage::instance()->addMmsNoti(pMsgInfo);
+               } else {
+                       MSG_DEBUG("Can't not find Message!");
+                       memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
+                       pMsgInfo->dataSize = 0;
+                       strncpy(pMsgInfo->msgData, getMmsReadStatus(mmsHeader.readStatus), MAX_MSG_DATA_LEN);
+                       pMsgInfo->dataSize  = strlen(pMsgInfo->msgData);
+                       MSG_DEBUG("read Status = %s", pMsgInfo->msgData);
+
+                       MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr);
+
+                       strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN);
+               }
+       }
+
+       MsgFreeAttrib(&pMsg->mmsAttrib);
+
+       free(pMsg);
+
+       MSG_END();
+}
+
+void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MMS_RECV_DATA_S recvData = {{0}, };
+
+       pMsgInfo->msgId = pRequest->msgId;
+
+       //Set only changed members
+       pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
+       pMsgInfo->msgType.subType = MSG_SENDCONF_MMS;
+
+       pMsgInfo->folderId = MSG_OUTBOX_ID;
+
+       strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
+
+       if (mmsHeader.responseStatus == MMS_RESPSTATUS_OK) {
+               pMsgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS;
+       } else {
+               pMsgInfo->networkStatus = MSG_NETWORK_SEND_FAIL;
+
+               char responseText[MMS_LOCALE_RESP_TEXT_LEN];
+
+               memset(responseText, 0x00, MMS_LOCALE_RESP_TEXT_LEN);
+               snprintf(responseText, MMS_LOCALE_RESP_TEXT_LEN, " %s [%d]", mmsHeader.szResponseText, mmsHeader.responseStatus);
+
+               memset(pMsgInfo->msgText, 0x00, MAX_MSG_TEXT_LEN + 1);
+               strncpy(pMsgInfo->msgText, responseText, MMS_LOCALE_RESP_TEXT_LEN);
+       }
+
+       // set message-id from mmsc
+       strncpy(recvData.szMsgID, mmsHeader.szMsgID, MMS_MSG_ID_LEN);
+       strncpy(recvData.szTrID, mmsHeader.szTrID, MMS_TR_ID_LEN);
+
+       memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
+       memcpy(pMsgInfo->msgData, &recvData, sizeof(MMS_RECV_DATA_S));
+
+       time_t curTime;
+       curTime = time(NULL);
+
+       pMsgInfo->displayTime = curTime;
+
+       MmsMsg *pMsg = NULL;
+       MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+       _MmsInitHeader();
+#ifdef __SUPPORT_DRM__
+       _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
+#endif
+       _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
+
+
+       MSG_END();
+}
+
+
+void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest, char *pRetrievedFilePath)
+{
+       MSG_BEGIN();
+
+       int partCnt = 0;
+       int attachCount = 0;
+       MsgType partHeader;
+       bool bMultipartRelated = false;
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MMS_RECV_DATA_S recvData = {{0}, };
+
+       MmsAttrib attrib;
+
+       MmsInitMsgAttrib(&attrib);
+
+       attrib.priority = mmsHeader.priority;
+       attrib.bAskDeliveryReport = getMmsReport(mmsHeader.deliveryReport);
+       attrib.bAskReadReply = getMmsReport(mmsHeader.readReply);
+
+       //Set only changed members
+       pMsgInfo->msgId = pRequest->msgId;
+       MSG_DEBUG("@@@@@ msgId = %d @@@@@", pMsgInfo->msgId);
+       pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
+
+       if (pRequest->eMmsPduType == eMMS_RETRIEVE_AUTO_CONF)
+               pMsgInfo->msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS;
+       else
+               pMsgInfo->msgType.subType = MSG_RETRIEVE_MANUALCONF_MMS;
+
+       strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
+
+       strncpy(pRequest->transactionId, mmsHeader.szTrID, MMS_TR_ID_LEN);
+
+       time_t curTime;
+       curTime = time(NULL);
+
+       pMsgInfo->displayTime = curTime;
+
+       if (mmsHeader.retrieveStatus == MMS_RETRSTATUS_OK) {
+               pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS;
+               pMsgInfo->folderId = MSG_INBOX_ID;
+       } else {
+               pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
+               pMsgInfo->folderId = MSG_INBOX_ID;
+               // If failed MMS Retrieve, then saved as MMS Noti Ind Message.
+               pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS;
+       }
+
+       pMsgInfo->dataSize = pRequest->getDataLen;
+
+       // set message-id & MMS TPDU file path
+       strcpy(recvData.szMsgID, mmsHeader.szMsgID);
+       if (pRetrievedFilePath)
+               strncpy(recvData.retrievedFilePath, pRetrievedFilePath, sizeof(recvData.retrievedFilePath));
+
+#ifdef FEATURE_JAVA_MMS
+       if (mmsHeader.msgType.param.szApplicationID || mmsHeader.msgType.param.szReplyToApplicationID) {
+               recvData.msgAppId.valid = true;
+               if (mmsHeader.msgType.param.szApplicationID)
+                       strncpy(recvData.msgAppId.appId, mmsHeader.msgType.param.szApplicationID, sizeof(recvData.msgAppId.appId));
+               if (mmsHeader.msgType.param.szReplyToApplicationID)
+                       strncpy(recvData.msgAppId.replyToAppId, mmsHeader.msgType.param.szReplyToApplicationID, sizeof(recvData.msgAppId.replyToAppId));
+
+               char fullPath[MAX_FULL_PATH_SIZE+1] = {0, };
+
+               char *filename = NULL;
+               filename = strrchr(pRetrievedFilePath, '/');
+
+               snprintf(fullPath, MAX_FULL_PATH_SIZE+1, "%s%s", MSG_IPC_DATA_PATH, filename + 1);
+
+               rename(pRetrievedFilePath, fullPath);
+
+               if (chmod(fullPath, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) != 0) {
+                       MSG_DEBUG("File Write Error: %s", strerror(errno));
+               }
+
+               if (chown(fullPath, 0, 6502 ) != 0) {
+                       MSG_DEBUG("File Write Error: %s", strerror(errno));
+               }
+       }
+#endif
+       memcpy(pMsgInfo->msgData, &recvData, sizeof(MMS_RECV_DATA_S));
+
+       MSG_DEBUG("@@@@@ MsgData = %s @@@@@", pMsgInfo->msgData);
+       MSG_DEBUG("@@@@@ retrievedFilePath = %s @@@@@", recvData.retrievedFilePath);
+       MSG_DEBUG("@@@@@ szMsgID = %s @@@@@", recvData.szMsgID);
+       //update delivery report, read reply
+
+       MmsPluginStorage *pStorage = MmsPluginStorage::instance();
+
+       MMS_MESSAGE_DATA_S msgData;
+       memset(&msgData, 0, sizeof(MMS_MESSAGE_DATA_S));
+
+       // Conversation is supported only Multipart Related message, Presentation info should be provided
+       if (mmsHeader.msgType.type == MIME_MULTIPART_RELATED || mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
+               char *pSmilDoc = NULL;
+               MmsMsg *pMsg = NULL;
+               char szFileName[MSG_FILENAME_LEN_MAX] = {0, };
+
+               msgData.regionCnt = 0;
+               msgData.pageCnt = 0;
+               msgData.attachCnt = 0;
+               msgData.transitionCnt = 0;
+               msgData.metaCnt = 0;
+               memset(msgData.szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX);
+
+               pSmilDoc = MmsSmilGetPresentationData(pMsgInfo->msgId);
+               MmsSmilParseSmilDoc(&msgData, pSmilDoc);
+
+               MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+               strcpy(szFileName, pMsg->szFileName);
+
+               err = pStorage->getMsgText(&msgData, pMsgInfo->msgText);
+               err = pStorage->makeThumbnail(&msgData, pMsgInfo->thumbPath, szFileName);
+
+               bMultipartRelated = true;
+       } else {
+               MSG_DEBUG("Multipart mixed message doesn't support mms conversation");
+       }
+
+       err = pStorage->updateMmsAttrib(pMsgInfo->msgId, &attrib, pMsgInfo->msgType.subType);
+
+       partCnt = MmsGetMediaPartCount(pMsgInfo->msgId);
+       MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt );
+
+       if (partCnt < 0) {
+               MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt );
+       } else {
+               for (int i = 0; i < partCnt; ++i) {
+                       if (!MmsGetMediaPartHeader(i, &partHeader)) {
+                               MSG_DEBUG("MmsUiGetMediaAttachInfo: MmsGetMediaPartHeader failed\n" );
+                               break;
+                       }
+
+                       if (partHeader.contentSize > 0) {
+                               char szBuf[MSG_FILEPATH_LEN_MAX];
+
+                               strcpy((char *)szBuf, partHeader.param.szFileName);
+                               sprintf(partHeader.param.szFileName, MSG_DATA_PATH"%s", szBuf);
+                               if (!bMultipartRelated || MmsCheckAdditionalMedia(&msgData, &partHeader))
+                                       attachCount++;
+                       }
+               }
+       }
+       MSG_DEBUG("attachCount [%d]", attachCount);
+       err = pStorage->updateMmsAttachCount(pMsgInfo->msgId, attachCount);
+
+       if (bMultipartRelated) {
+               _MsgMmsReleasePageList(&msgData);
+               _MsgMmsReleaseRegionList(&msgData);
+               _MsgMmsReleaseAttachList(&msgData);
+               _MsgMmsReleaseTransitionList(&msgData);
+               _MsgMmsReleaseMetaList(&msgData);
+       }
+
+       MmsMsg *pMsg = NULL;
+       pStorage->getMmsMessage(&pMsg);
+       _MmsInitHeader();
+#ifdef __SUPPORT_DRM__
+       _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
+#endif
+       _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
+
+       MSG_END();
+}
+
+void MmsPluginInternal::processForwardConf(MSG_MESSAGE_INFO_S *msgInfo, mmsTranQEntity *pRequest)
+{
+
+}
+
+/* This function Send NotifyRespInd Msg
+ *
+ * @param      pTrID [in] Specifies Transaction ID
+ * @param      iStatus [in] Specifies Msg Status
+ * @param      iReportAllowed [in] Specifies whether to send deliveryReport to sender or not
+ * @return     This function returns true on success, or false on failure.
+ */
+bool MmsPluginInternal::encodeNotifyRespInd(char *szTrID, MSG_DELIVERY_REPORT_STATUS_T iStatus, bool bReportAllowed, char *pSendFilePath)
+{
+       MSG_BEGIN();
+
+       FILE *pFile = NULL;
+       char pTempFileName[MSG_FILENAME_LEN_MAX+1] = {0};
+       char pTempFilePath[MAX_FULL_PATH_SIZE] = {0};
+
+       if (MsgCreateFileName(pTempFileName) == false)
+               return false;
+
+       snprintf(pTempFilePath, MAX_FULL_PATH_SIZE, MSG_DATA_PATH"%s.noti.ind", pTempFileName);
+
+       pFile = MsgOpenMMSFile(pTempFilePath);
+
+       if (!pFile) {
+               MSG_DEBUG("[ERROR] MsgOpenMMSFile fail");
+               return false;
+       }
+
+       if (_MmsEncodeNotiRespInd(pFile, szTrID, iStatus, bReportAllowed) == false) {
+               MSG_DEBUG("MmsEncodeNotifyRespInd: _MmsEncodeNotiRespInd fail");
+               MsgCloseFile(pFile);
+               return false;
+       }
+
+       MsgCloseFile(pFile);
+
+       if (pSendFilePath) {
+               snprintf(pSendFilePath, MAX_MSG_DATA_LEN+1, "%s.mms", pTempFilePath);
+       } else {
+               MSG_DEBUG("[ERROR] pSendFilePath is NULL");
+               return false;
+       }
+
+       MSG_END();
+
+       return true;
+}
+
+/* This function Send AcknowledgeInd Msg
+ *
+ * @param      pTrID [in] Specifies Transaction ID
+ * @param      iReportAllowed [in] Specifies whether to send deliveryReport to sender or not
+ * @return     This function returns true on success, or false on failure.
+ */
+bool MmsPluginInternal::encodeAckInd(char *szTrID, bool bReportAllowed, char *pSendFilePath)
+{
+       MSG_BEGIN();
+       FILE *pFile = NULL;
+       char pTempFileName[MSG_FILENAME_LEN_MAX+1] = {0};
+       char pTempFilePath[MAX_FULL_PATH_SIZE] = {0};
+
+       if (MsgCreateFileName(pTempFileName) == false)
+               return false;
+
+       snprintf(pTempFilePath, MAX_FULL_PATH_SIZE, MSG_DATA_PATH"%s.ack.ind", pTempFileName);
+
+       pFile = MsgOpenMMSFile(pTempFilePath);
+       if (!pFile) {
+               MSG_DEBUG("[ERROR] MsgOpenMMSFile fail \n" );
+               return false;
+       }
+
+       if (_MmsEncodeAckInd(pFile, szTrID, bReportAllowed) == false) {
+               MSG_DEBUG("MmsEncodeAckInd: _MmsEncodeAckInd fail \n" );
+               MsgCloseFile(pFile);
+               return false;
+       }
+
+       MsgCloseFile(pFile);
+
+       if (pSendFilePath) {
+               snprintf(pSendFilePath, MAX_MSG_DATA_LEN+1, "%s.mms", pTempFilePath);
+       } else {
+               MSG_DEBUG("[ERROR] pSendFilePath is NULL");
+               return false;
+       }
+
+       MSG_END();
+
+       return true;
+}
+
+bool MmsPluginInternal::checkRejectNotiInd(int roamState, bool bReportAllowed, char *pSendFilePath)
+{
+       MSG_BEGIN();
+       MSG_MMS_HOME_RETRIEVE_TYPE_T retrieveType;
+       bool bRejectAnonymous;
+       bool bRejectAdvertisement;
+
+       MsgSettingGetBool(MMS_RECV_REJECT_UNKNOWN, &bRejectAnonymous);
+       MsgSettingGetBool(MMS_RECV_REJECT_ADVERTISE, &bRejectAdvertisement);
+
+       // Anonymous Reject
+       if (bRejectAnonymous &&
+               (mmsHeader.pFrom == NULL || mmsHeader.pFrom->szAddr[0] == '\0')) {
+               MSG_DEBUG("Anonymous Reject... ");
+               encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
+
+               return true;
+       }
+
+       // Advertisement Reject
+       if (bRejectAdvertisement && mmsHeader.msgClass == MMS_MSGCLASS_ADVERTISEMENT) {
+               MSG_DEBUG("Advertisement Reject... ");
+               encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
+
+               return true;
+       }
+
+       // Message Reject - Roaming Case
+       if (roamState == VCONFKEY_TELEPHONY_SVC_ROAM_ON) {
+               retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
+               if (retrieveType == MSG_ABROAD_REJECT) {
+                       MSG_DEBUG("Abroad_Network : Notification Reject... ");
+                       encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
+
+                       return true;
+               }
+       } else {
+               retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_HOME_NETWORK);
+               if (retrieveType == MSG_HOME_REJECT) {
+                       MSG_DEBUG("Home_Network : Notification Reject... ");
+                       encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
+
+                       return true;
+               }
+       }
+
+       // Not Rejected
+       MSG_END();
+       return false;
+
+}
+
+bool MmsPluginInternal::getMmsReport(MmsReport mmsReport)
+{
+       bool result = false;
+
+       if (mmsReport == MMS_REPORT_YES)
+               result = true;
+       else if (mmsReport == MMS_REPORT_NO)
+               result = false;
+
+       return result;
+}
+
+const char *MmsPluginInternal::getMmsDeliveryStatus(MSG_DELIVERY_REPORT_STATUS_T deliveryStatus)
+{
+       MSG_DEBUG("msgStatus= %d", deliveryStatus);
+
+       switch (deliveryStatus) {
+       case MSG_DELIVERY_REPORT_EXPIRED:
+               return "expired.";
+       case MSG_DELIVERY_REPORT_REJECTED:
+               return "rejected.";
+       case MSG_DELIVERY_REPORT_UNREACHABLE:
+               return "unreachable.";
+       case MSG_DELIVERY_REPORT_UNRECOGNISED:
+               return "unrecognised.";
+       case MSG_DELIVERY_REPORT_SUCCESS:
+               return "delivered.";
+       default:
+               return "delivery failed.";
+       }
+}
+
+const char *MmsPluginInternal::getMmsReadStatus(MSG_READ_REPORT_STATUS_T readStatus)
+{
+       switch (readStatus) {
+       case MSG_READ_REPORT_IS_READ:
+               return "message is read.";
+       case MSG_READ_REPORT_IS_DELETED:
+               return "message is deleted.";
+       default:
+               return "read status is none.";
+       }
+}
+
diff --git a/plugin/mms_plugin/MmsPluginMIME.cpp b/plugin/mms_plugin/MmsPluginMIME.cpp
new file mode 100755 (executable)
index 0000000..6874224
--- /dev/null
@@ -0,0 +1,1315 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <string>
+#include <stdlib.h>
+#include "MmsPluginMIME.h"
+#include "MsgDebug.h"
+
+#include "MmsPluginSmil.h"
+#ifndef        NULL
+#define        NULL    0
+#endif
+
+
+/* Header field */
+static const char *szMsgField[MSG_FIELD_NUM] =
+{
+       "Return-Path",
+       "Message-ID",
+       "From" ,
+       "To" ,
+       "Cc" ,
+       "Subject",
+       "Date",
+       "Mime-Version",
+       "Content-Type",
+       "Content-Transfer-Encoding",
+       "Content-Disposition", //If start param is given in multipart/related, this field will be ignored
+       "Content-ID", //for start part of multipart/related body
+       "Content-Location",
+       "Content-Name",
+       "Content-Description",
+       "Content-Vendor",
+       "Rights-Issuer",
+       "Return-Receipt-To",                    /* Delivery confirm */
+       "Disposition-Notification-To",  /* Read confirm */
+       "Content-Rep-Pos",
+       "Content-Rep-Size",
+       "Content-Rep-Index"
+};
+
+/*  MIME header field parameter */
+static const char *szMsgParam[MSG_PARAM_NUM] =
+{
+       "charset",
+       "name",
+       "filename",
+       "type",         //Only if content-type is multipart/related,
+       "start",        //Only if content-type is multipart/related
+       "start-info",   //Only if content-type is multipart/related
+       "boundary",
+       "report-type", // only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
+#ifdef FEATURE_JAVA_MMS
+       "Application-ID",                               //laconic_javaParamFix
+       "Reply-To-Application-ID",              //laconic_javaParamFix
+#endif
+};
+
+/* Content-Transfer-Encoding header value */
+static const char *szMsgEncoding[MSG_ENCODING_NUM] =
+{
+       "7bit",
+       "8bit",
+       "binary",
+       "base64",
+       "quoted-printable"
+};
+
+/* Content-Disposition header value */
+static const char *szMsgDisposition[MSG_DISPOSITION_NUM] =
+{
+       "form-data",
+       "attachment",
+       "inline"
+};
+
+static const char *szMsgAddrType[MSG_ADDR_TYPE_NUM] =
+{
+       "/TYPE=PLMN",
+       "",
+       "/TYPE=IPV4",
+       "/TYPE=IPV6",
+       ""
+};
+
+/* character-set value */
+static const char *szMsgCharset [MSG_CHARSET_NUM] =
+{
+       "us-ascii",
+       "utf-16",
+       "usc-2",
+       "utf-8",
+       /* MIME character-set value */
+
+       "iso-2022-kr",
+       "ks_c_5601-1987",
+       "euc_kr",
+       "iso-2022-jp",
+       "iso-2022-jp-2",
+       "iso-8859-1",
+       "iso-8859-2",
+       "iso-8859-3",
+       "iso-8859-4",
+       "iso-8859-5",
+       "iso-8859-6",
+       "iso-8859-6-e",
+       "iso-8859-6-i",
+       "iso-8859-7",
+       "iso-8859-8",
+       "iso-8859-8-i",
+       "iso-8859-9",
+       "iso-8859-10",
+       "iso-8859-15",
+       "Shift_jis",
+       "euc-jp",
+       "gb2312",
+       "big5",
+       "win1251",
+       "window-1251",
+       "windows-1251",
+       "koi8-r",
+       "koi8-u"
+};
+
+
+/**************************************************     MIME definition     ***************************************************/
+static const MimeTable mimeTable[] = {
+       // 0
+       {"*/*",                                                                                                 "",                                     false,          MIME_ASTERISK,                                                                  MIME_ASTERISK,                                                  MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                              UNDEFINED_BINARY        },
+
+    // 1
+       {"application/xml",                                                                     "",                                     false,          MIME_APPLICATION_XML,                                                   MIME_APPLICATION_XML,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x27    },
+       {"application/wml+xml",                                                         "",                                     false,          MIME_APPLICATION_WML_XML,                                               MIME_APPLICATION_WML_XML,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x3c    },
+       {"application/xhtml+xml",                                                               "xhtml",                        false,          MIME_APPLICATION_XHTML_XML,                                             MIME_APPLICATION_XHTML_XML,                             MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x3b    },
+       {"application/java-vm",                                                         "",                                     false,          MIME_APPLICATION_JAVA_VM,                                               MIME_APPLICATION_JAVA_VM,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x11    },
+       {"application/smil",                                                                    "smil",                         true,           MIME_APPLICATION_SMIL,                                                  MIME_APPLICATION_SMIL,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
+       {"application/java-archive",                                                    "jar",                          true,           MIME_APPLICATION_JAVA_ARCHIVE,                                  MIME_APPLICATION_JAVA_ARCHIVE,                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      UNDEFINED_BINARY        },
+       {"application/java",                                                                    "jar",                          true,           MIME_APPLICATION_JAVA,                                                  MIME_APPLICATION_JAVA,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      UNDEFINED_BINARY        },
+       {"application/octet-stream",                                                    "",                                     false,          MIME_APPLICATION_OCTET_STREAM,                                  MIME_APPLICATION_OCTET_STREAM,                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      UNDEFINED_BINARY        },
+       {"application/studiom",                                                         "smp",                          true,           MIME_APPLICATION_STUDIOM,                                               MIME_APPLICATION_STUDIOM,                               MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"application/funMedia",                                                                "smp",                          true,           MIME_APPLICATION_FUNMEDIA,                                              MIME_APPLICATION_FUNMEDIA,                              MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"application/msword",                                                                  "doc",                          true,           MIME_APPLICATION_MSWORD,                                                MIME_APPLICATION_MSWORD,                                MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
+       {"application/pdf",                                                                     "pdf",                          true,           MIME_APPLICATION_PDF,                                                   MIME_APPLICATION_PDF,                                   MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
+       {"application/sdp",                                                                     "sdp",                          true,           MIME_APPLICATION_SDP,                                                   MIME_APPLICATION_SDP,                                   MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,    UNDEFINED_BINARY        },
+       {"application/ram",                                                                     "ram",                          true,           MIME_APPLICATION_RAM,                                                   MIME_APPLICATION_RAM,                                   MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"application/*",                                                                               "",                                     false,          MIME_APPLICATION_ASTERIC,                                               MIME_APPLICATION_ASTERIC,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x10    },
+
+       //16
+       {"application/vnd.wap.xhtml+xml",                                               "",                                     false,          MIME_APPLICATION_VND_WAP_XHTMLXML,                              MIME_APPLICATION_VND_WAP_XHTMLXML,              MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x45    },
+       {"application/vnd.wap.wmlc",                                                    "",                                     false,          MIME_APPLICATION_VND_WAP_WMLC,                                  MIME_APPLICATION_VND_WAP_WMLC,                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x14    },
+       {"application/vnd.wap.wmlscriptc",                                              "",                                     false,          MIME_APPLICATION_VND_WAP_WMLSCRIPTC,                    MIME_APPLICATION_VND_WAP_WMLSCRIPTC,    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x15    },
+       {"application/vnd.wap.wta-eventc",                                              "",                                     false,          MIME_APPLICATION_VND_WAP_WTA_EVENTC,                    MIME_APPLICATION_VND_WAP_WTA_EVENTC,    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x16    },
+       {"application/vnd.wap.uaprof",                                                  "",                                     false,          MIME_APPLICATION_VND_WAP_UAPROF,                                MIME_APPLICATION_VND_WAP_UAPROF,                MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x17    },
+       {"application/vnd.wap.sic",                                                     "",                                     false,          MIME_APPLICATION_VND_WAP_SIC,                                   MIME_APPLICATION_VND_WAP_SIC,                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x2e    },
+       {"application/vnd.wap.slc",                                                     "",                                     false,          MIME_APPLICATION_VND_WAP_SLC,                                   MIME_APPLICATION_VND_WAP_SLC,                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x30    },
+       {"application/vnd.wap.coc",                                                     "",                                     false,          MIME_APPLICATION_VND_WAP_COC,                                   MIME_APPLICATION_VND_WAP_COC,                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x32    },
+       {"application/vnd.wap.sia",                                                     "",                                     false,          MIME_APPLICATION_VND_WAP_SIA,                                   MIME_APPLICATION_VND_WAP_SIA,                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x34    },
+       {"application/vnd.wap,connectivity-wbxml",                              "",                                     false,          MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML,    MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML,            MIME_APPLICATION_NONE,          MIME_MAINTYPE_TEXT,                     UNDEFINED_BINARY        },
+       {"application/vnd.wap.multipart.form-data",                     "",                                     false,          MIME_APPLICATION_VND_WAP_MULTIPART_FORM_DATA,   MIME_MULTIPART_FORM_DATA,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x24    },
+       {"application/vnd.wap.multipart.byteranges",                    "",                                     false,          MIME_APPLICATION_VND_WAP_MULTIPART_BYTERANGES,  MIME_MULTIPART_BYTERANGE,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x25    },
+       {"application/vnd.wap.multipart.mixed",                         "",                                     false,          MIME_APPLICATION_VND_WAP_MULTIPART_MIXED,               MIME_MULTIPART_MIXED,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x23    },
+       {"application/vnd.wap.multipart.related",                               "",                                     false,          MIME_APPLICATION_VND_WAP_MULTIPART_RELATED,             MIME_MULTIPART_RELATED,                                 MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x33    },
+       {"application/vnd.wap.multipart.alternative",                   "",                                     false,          MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE, MIME_MULTIPART_ALTERNATIVE,                                     MIME_APPLICATION_NONE,                          MIME_MAINTYPE_APPLICATION,      0x26    },
+       {"application/vnd.wap.multipart.*",                                     "",                                     false,          MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC,             MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC,             MIME_APPLICATION_NONE,                  MIME_MAINTYPE_APPLICATION,      0x22    },
+       {"application/vnd.wap.wbxml",                                                   "",                                     false,          MIME_APPLICATION_VND_WAP_WBXML,                                 MIME_APPLICATION_VND_WAP_WBXML,                 MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x29    },
+       {"application/vnd.oma.dd+xml",                                                  "dd",                           true,           MIME_APPLICATION_VND_OMA_DD_XML,                                MIME_APPLICATION_VND_OMA_DD_XML,                MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      0x47    },
+       {"application/vnd.oma.drm.message",                                     "dm",                           true,           MIME_APPLICATION_VND_OMA_DRM_MESSAGE,                   MIME_APPLICATION_VND_OMA_DRM_MESSAGE,           MIME_APPLICATION_NONE,                          MIME_MAINTYPE_ETC,                      0x48    },
+       {"application/vnd.oma.drm.content",                                     "dcf",                          true,           MIME_APPLICATION_VND_OMA_DRM_CONTENT,                   MIME_APPLICATION_VND_OMA_DRM_CONTENT,           MIME_APPLICATION_NONE,                          MIME_MAINTYPE_ETC,                      0x49    },
+       {"application/vnd.oma.drm.rights+xml",                                  "ro",                           true,           MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML,                MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML,                MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                      0x4a    },
+       {"application/vnd.oma.drm.rights+wbxml",                                "ro",                           true,           MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML,              MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML,              MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                      0x4b    },
+       {"application/vnd.oma.drm.ro+xml",                              "oro",                          true,           MIME_APPLICATION_VND_OMA_DRM_RO_XML,            MIME_APPLICATION_VND_OMA_DRM_RO_XML,            MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                      0x4b    },
+       {"application/vnd.oma.drm.dcf",                         "odf",                          true,           MIME_APPLICATION_VND_OMA_DRM_DCF,               MIME_APPLICATION_VND_OMA_DRM_DCF,               MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                      0x4b    },
+       {"application/vnd.oma.drm.roap-pdu+xml",                                "xml",                          true,           MIME_APPLICATION_VND_OMA_ROAPPDU_XML,           MIME_APPLICATION_VND_OMA_ROAPPDU_XML,           MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                      0x4b    },
+       {"application/vnd.oma.drm.roap-trigger+xml",                            "xml",                          true,           MIME_APPLICATION_VND_OMA_ROAPTRIGGER_XML,               MIME_APPLICATION_VND_OMA_ROAPTRIGGER_XML,               MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                      0x4b    },
+       {"application/vnd.smaf",                                                                "mmf",                          true,           MIME_APPLICATION_VND_SMAF,                                              MIME_APPLICATION_X_SMAF,                                MIME_APPLICATION_SOUNDPLAYER,                   MIME_MAINTYPE_AUDIO,            UNDEFINED_BINARY        },
+       {"application/vnd.rn-realmedia",                                                "rm",                           true,           MIME_APPLICATION_VND_RN_REALMEDIA,                              MIME_APPLICATION_VND_RN_REALMEDIA,              MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
+       {"application/vnd.sun.j2me.java-archive",                               "jar",                          true,           MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE,             MIME_APPLICATION_JAVA_ARCHIVE,                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      UNDEFINED_BINARY        },
+       {"application/vnd.ms-excel",                                                    "xls",                          true,           MIME_APPLICATION_VND_EXCEL,                                             MIME_APPLICATION_X_EXCEL,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
+       {"application/vnd.ms-powerpoint",                                               "ppt",                          true,           MIME_APPLICATION_VND_POWERPOINT,                                MIME_APPLICATION_VND_POWERPOINT,                MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
+       {"applcation/vnd.ms-word",                                                              "doc",                          true,           MIME_APPLICATION_VND_MSWORD,                                    MIME_APPLICATION_MSWORD,                                MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
+
+       //49
+       {"application/x-hdmlc",                                                         "",                                     false,          MIME_APPLICATION_X_HDMLC,                                               MIME_APPLICATION_X_HDMLC,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x13    },
+       {"application/x-x968-user-cert",                                                "",                                     false,          MIME_APPLICATION_X_X968_USERCERT,                               MIME_APPLICATION_X_X968_USERCERT,               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x2c    },
+       {"application/x-www-form-urlencoded",                                   "",                                     false,          MIME_APPLICATION_X_WWW_FORM_URLENCODED,                 MIME_APPLICATION_X_WWW_FORM_URLENCODED,         MIME_APPLICATION_NONE,                          MIME_MAINTYPE_APPLICATION,      0x12    },
+       {"application/x-smaf",                                                                  "mmf",                          true,           MIME_APPLICATION_X_SMAF,                                                MIME_APPLICATION_X_SMAF,                                MIME_APPLICATION_SOUNDPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"application/x-shockwave-flash",                                               "swf",                          true,           MIME_APPLICATION_X_FLASH,                                               MIME_APPLICATION_X_FLASH,                               MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            UNDEFINED_BINARY        },
+       {"application/x-msexcel",                                                               "xls",                          true,           MIME_APPLICATION_X_EXCEL,                                               MIME_APPLICATION_X_EXCEL,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
+       {"application/x-mspowerpoint",                                                  "ppt",                          true,           MIME_APPLICATION_X_POWERPOINT,                                  MIME_APPLICATION_X_POWERPOINT,                  MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
+
+
+       //56
+       {"audio/basic",                                                                         "snd"/*,au"*/,          false,          MIME_AUDIO_BASIC,                                                               MIME_AUDIO_BASIC,                                               MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/mpeg",                                                                                  "mp3",                          true,           MIME_AUDIO_MPEG,                                                                MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/mp3",                                                                                   "mp3",                          true,           MIME_AUDIO_MP3,                                                                 MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/mpg3",                                                                                  "mp3",                          true,           MIME_AUDIO_MPG3,                                                                MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/mpeg3",                                                                         "mp3",                          true,           MIME_AUDIO_MPEG3,                                                               MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/mpg",                                                                                   "mp3",                          true,           MIME_AUDIO_MPG,                                                                 MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/aac",                                                                                   "aac",                          true,           MIME_AUDIO_AAC,                                                                 MIME_AUDIO_AAC,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/g72",                                                                                   "aac",                          true,           MIME_AUDIO_G72,                                                                 MIME_AUDIO_AAC,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/amr",                                                                                   "amr",                          true,           MIME_AUDIO_AMR,                                                                 MIME_AUDIO_AMR,                                                 MIME_APPLICATION_VOICEMEMO,                             MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/amr-wb",                                                                                "amr",                          true,           MIME_AUDIO_AMR_WB,                                                              MIME_AUDIO_AMR_WB,                                              MIME_APPLICATION_VOICEMEMO,                             MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/mmf",                                                                                   "mmf",                          true,           MIME_AUDIO_MMF,                                                                 MIME_AUDIO_MMF,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/smaf",                                                                                  "mmf",                          true,           MIME_AUDIO_SMAF,                                                                MIME_AUDIO_SMAF,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/iMelody",                                                                               "imy",                          true,           MIME_AUDIO_IMELODY,                                                             MIME_AUDIO_IMELODY,                                             MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/imelody",                                                                               "imy",                          true,           MIME_AUDIO_IMELODY2,                                                            MIME_AUDIO_IMELODY,                                             MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/melody",                                                                                "imy",                          true,           MIME_AUDIO_MELODY,                                                              MIME_AUDIO_IMELODY,                                             MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/mid",                                                                                   "mid",                          true,           MIME_AUDIO_MID,                                                                 MIME_AUDIO_MID,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/midi",                                                                                  "mid"/*,midi"*/,        true,           MIME_AUDIO_MIDI,                                                                MIME_AUDIO_MID,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/sp-midi",                                                                               "spm"/*,midi"*/,        true,           MIME_AUDIO_SP_MIDI,                                                             MIME_AUDIO_SP_MIDI,                                             MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/wave",                                                                                  "wav",                          true,           MIME_AUDIO_WAVE,                                                                MIME_AUDIO_WAVE,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/wav",                                                                                   "wav",                          true,           MIME_AUDIO_WAV,                                                         MIME_AUDIO_WAVE,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/3gpp",                                                                                  "3gp",                          true,           MIME_AUDIO_3GPP,                                                                MIME_AUDIO_3GPP,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/mp4",                                                                                   "mp4",                          true,           MIME_AUDIO_MP4,                                                                 MIME_AUDIO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/MP4A-LATM",                                                                     "mp4",                          true,           MIME_AUDIO_MP4A_LATM,                                                   MIME_AUDIO_MP4A_LATM,                                   MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/m4a",                                                                                   "m4a",                          true,           MIME_AUDIO_M4A,                                                                 MIME_AUDIO_M4A,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/mpeg4",                                                                         "mp4",                          true,           MIME_AUDIO_MPEG4,                                                               MIME_AUDIO_MPEG4,                                               MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/wma",                                                                                   "wma",                          true,           MIME_AUDIO_WMA,                                                                 MIME_AUDIO_WMA,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/xmf",                                                                                   "xmf",                          true,           MIME_AUDIO_XMF,                                                                 MIME_AUDIO_XMF,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/imy",                                                                                   "imy",                          true,           MIME_AUDIO_IMY,                                                                 MIME_AUDIO_IMY,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/mobile-xmf",                                                                    "mxmf",                         true,           MIME_AUDIO_MOBILE_XMF,                                                  MIME_AUDIO_XMF,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+
+       // 85
+       {"audio/vnd.rn-realaudio",                                                              "rm"/*,ram,ra"*/,       true,           MIME_AUDIO_VND_RN_REALAUDIO,                                    MIME_AUDIO_VND_RN_REALAUDIO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+
+       //86
+       {"audio/x-mpeg",                                                                                "mp3",                          true,           MIME_AUDIO_X_MPEG,                                                              MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-mp3",                                                                         "mp3",                          true,           MIME_AUDIO_X_MP3,                                                               MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-mpeg3",                                                                               "mp3",                          true,           MIME_AUDIO_X_MPEG3,                                                             MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-mpg",                                                                         "mp3",                          true,           MIME_AUDIO_X_MPG,                                                               MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-amr",                                                                         "amr",                          true,           MIME_AUDIO_X_AMR,                                                               MIME_AUDIO_AMR,                                                 MIME_APPLICATION_VOICEMEMO,                             MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-mmf",                                                                         "mmf",                          true,           MIME_AUDIO_X_MMF,                                                               MIME_AUDIO_MMF,                                                 MIME_APPLICATION_VOICEMEMO,                             MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-smaf",                                                                                "mmf",                          true,           MIME_AUDIO_X_SMAF,                                                              MIME_AUDIO_SMAF,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-iMelody",                                                                     "imy",                          true,           MIME_AUDIO_X_IMELODY,                                                   MIME_AUDIO_IMELODY,                                             MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-midi",                                                                                "mid"/*,midi"*/,        true,           MIME_AUDIO_X_MIDI,                                                              MIME_AUDIO_MID,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-mpegaudio",                                                                   "mp3",                          true,           MIME_AUDIO_X_MPEGAUDIO,                                                 MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-pn-realaudio",                                                                "ra"/*,ram,ra"*/,       true,           MIME_AUDIO_X_PN_REALAUDIO,                                              MIME_AUDIO_VND_RN_REALAUDIO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-pn-multirate-realaudio",                                              "rm"/*,ram,ra"*/,       true,           MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO,                    MIME_AUDIO_VND_RN_REALAUDIO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-pn-multirate-realaudio-live",                         "rm"/*,ram,ra"*/,       true,           MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO_LIVE,               MIME_AUDIO_VND_RN_REALAUDIO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-wave",                                                                                "wav",                          true,           MIME_AUDIO_X_WAVE,                                                              MIME_AUDIO_WAVE,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-wav",                                                                         "wav",                          true,           MIME_AUDIO_X_WAV,                                                               MIME_AUDIO_WAVE,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-ms-wma",                                                                              "wma",                          true,           MIME_AUDIO_X_MS_WMA,                                                    MIME_AUDIO_WAVE,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-mid",                                                                         "mid",                          true,           MIME_AUDIO_X_MID,                                                               MIME_AUDIO_MID,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-ms-asf",                                                                              "asf",                          true,           MIME_AUDIO_X_MS_ASF,                                                    MIME_AUDIO_X_MS_ASF,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/x-xmf",                                                                         "xmf",                          true,           MIME_AUDIO_X_XMF,                                                               MIME_AUDIO_XMF,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+
+       //105
+       {"image/gif",                                                                                   "gif",                          false,          MIME_IMAGE_GIF,                                                                 MIME_IMAGE_GIF,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    0x1d    },
+       {"image/jpeg",                                                                                  "jpg"/*,jpeg,jpe,jpz"*/,        false,  MIME_IMAGE_JPEG,                                                        MIME_IMAGE_JPG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            0x1e    },
+       {"image/jpg",                                                                                   "jpg",                          false,          MIME_IMAGE_JPG,                                                                 MIME_IMAGE_JPG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
+       {"image/tiff",                                                                                  "tif"/*,tiff"*/,        false,          MIME_IMAGE_TIFF,                                                                MIME_IMAGE_TIF,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    0x1f    },
+       {"image/tif",                                                                                   "tif",                          false,          MIME_IMAGE_TIF,                                                                 MIME_IMAGE_TIF,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
+       {"image/png",                                                                                   "png"/*,pnz"*/,         false,          MIME_IMAGE_PNG,                                                                 MIME_IMAGE_PNG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    0x20    },
+       {"image/wbmp",                                                                                  "wbmp",                         false,          MIME_IMAGE_WBMP,                                                                MIME_IMAGE_WBMP,                                                MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
+       {"image/pjpeg",                                                                         "jpg",                          false,          MIME_IMAGE_PJPEG,                                                               MIME_IMAGE_JPG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
+       {"image/bmp",                                                                                   "bmp",                          false,          MIME_IMAGE_BMP,                                                                 MIME_IMAGE_BMP,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
+       {"image/svg+xml",                                                                               "svg",                          false,          MIME_IMAGE_SVG,                                                                 MIME_IMAGE_SVG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
+       {"image/svg-xml",                                                                               "svg",                          false,          MIME_IMAGE_SVG1,                                                                MIME_IMAGE_SVG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
+
+       //116
+       {"image/vnd.wap.wbmp",                                                                  "wbmp",                         false,          MIME_IMAGE_VND_WAP_WBMP,                                                MIME_IMAGE_WBMP,                                                MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            0x21    },
+
+       {"image/x-bmp",                                                                         "bmp",                          false,          MIME_IMAGE_X_BMP,                                                               MIME_IMAGE_BMP,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            UNDEFINED_BINARY        },
+
+       {"message/rfc822",                                                                              "elm",                          false,          MIME_MESSAGE_RFC822,                                                    MIME_MESSAGE_RFC822,                                    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_MESSAGE,          UNDEFINED_BINARY        },
+
+       {"multipart/mixed",                                                                     "",                                     false,          MIME_MULTIPART_MIXED,                                                   MIME_MULTIPART_MIXED,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x0c    },
+       {"multipart/related",                                                                   "",                                     false,          MIME_MULTIPART_RELATED,                                                 MIME_MULTIPART_RELATED,                                 MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
+       {"multipart/alternative",                                                               "",                                     false,          MIME_MULTIPART_ALTERNATIVE,                                             MIME_MULTIPART_ALTERNATIVE,                             MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x0f    },
+       {"multipart/form-data",                                                         "",                                     false,          MIME_MULTIPART_FORM_DATA,                                               MIME_MULTIPART_FORM_DATA,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x0d    },
+       {"multipart/byterange",                                                         "",                                     false,          MIME_MULTIPART_BYTERANGE,                                               MIME_MULTIPART_BYTERANGE,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x0e    },
+       {"multipart/report",                                                                    "",                                     false,          MIME_MULTIPART_REPORT,                                                  MIME_MULTIPART_REPORT,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
+       {"multipart/voice-message",                                                     "",                                     false,          MIME_MULTIPART_VOICE_MESSAGE,                                   MIME_MULTIPART_VOICE_MESSAGE,                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
+
+       //128
+       {"text/txt",                                                                                    "txt",                          false,          MIME_TEXT_TXT,                                                                  MIME_TEXT_TXT,                                                  MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_TEXT,                     UNDEFINED_BINARY        },
+       {"text/html",                                                                                   "html"/*,htm"*/,        false,          MIME_TEXT_HTML,                                                                 MIME_TEXT_HTML,                                                 MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x02    },
+       {"text/plain",                                                                                  "txt"/*,vbm,url"*/,                             false,          MIME_TEXT_PLAIN,                                                                MIME_TEXT_PLAIN,                                                MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_TEXT,                     0x03    },
+       {"text/css",                                                                                    "",                                     false,          MIME_TEXT_CSS,                                                                  MIME_TEXT_CSS,                                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x3d    },
+       {"text/xml",                                                                                    "",                                     false,          MIME_TEXT_XML,                                                                  MIME_TEXT_XML,                                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x28    },
+       {"text/iMelody",                                                                                "imy",                          true,           MIME_TEXT_IMELODY,                                                              MIME_TEXT_IMELODY,                                              MIME_APPLICATION_SOUNDPLAYER,                   MIME_MAINTYPE_AUDIO,            UNDEFINED_BINARY        },
+
+       //134
+       {"text/vnd.wap.wmlscript",                                                              "",                                     false,          MIME_TEXT_VND_WAP_WMLSCRIPT,                                    MIME_TEXT_VND_WAP_WMLSCRIPT,                    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x09    },
+       {"text/vnd.wap.wml",                                                                    "wml",                          false,          MIME_TEXT_VND_WAP_WML,                                                  MIME_TEXT_VND_WAP_WML,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x08    },
+       {"text/vnd.wap.wta-event",                                                              "",                                     false,          MIME_TEXT_VND_WAP_WTA_EVENT,                                    MIME_TEXT_VND_WAP_WTA_EVENT,                    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x0a    },
+       {"text/vnd.wap.connectivity-xml",                                               "",                                     false,          MIME_TEXT_VND_WAP_CONNECTIVITY_XML,                             MIME_TEXT_VND_WAP_CONNECTIVITY_XML,             MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x35    },
+       {"text/vnd.wap.si",                                                                     "",                                     false,          MIME_TEXT_VND_WAP_SI,                                                   MIME_TEXT_VND_WAP_SI,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x2d    },
+       {"text/vnd.wap.sl",                                                                     "",                                     false,          MIME_TEXT_VND_WAP_SL,                                                   MIME_TEXT_VND_WAP_SL,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x2f    },
+       {"text/vnd.wap.co",                                                                     "",                                     false,          MIME_TEXT_VND_WAP_CO,                                                   MIME_TEXT_VND_WAP_CO,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x31    },
+       {"text/vnd.sun.j2me.app-descriptor",                                    "jad",                          true,           MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR,                  MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR,  MIME_APPLICATION_NONE,                                          MIME_MAINTYPE_ETC,                      UNDEFINED_BINARY        },
+
+
+       //142
+       {"text/x-hdml",                                                                         "",                                     false,          MIME_TEXT_X_HDML,                                                               MIME_TEXT_X_HDML,                                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x04    },
+       {"text/x-vCalendar",                                                                    "vcs",                          true,           MIME_TEXT_X_VCALENDAR,                                                  MIME_TEXT_X_VCALENDAR,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x06    },
+       {"text/x-vCard",                                                                                "vcf",                          true,           MIME_TEXT_X_VCARD,                                                              MIME_TEXT_X_VCARD,                                              MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x07    },
+       {"text/x-iMelody",                                                                              "imy",                          true,           MIME_TEXT_X_IMELODY,                                                    MIME_TEXT_X_IMELODY,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,            UNDEFINED_BINARY        },
+       {"text/x-imelody",                                                                              "imy",                          true,           MIME_TEXT_X_IMELODY2,                                                   MIME_TEXT_X_IMELODY,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,            UNDEFINED_BINARY        },
+       {"text/x-vnote",                                                                                "vnt",                          true,           MIME_TEXT_X_VNOTE,                                                              MIME_TEXT_X_VNOTE,                                              MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     UNDEFINED_BINARY        },
+
+       //148
+       {"video/mpeg4",                                                                         "mp4",                          true,           MIME_VIDEO_MPEG4,                                                               MIME_VIDEO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
+       {"video/mp4",                                                                                   "mp4",                          true,           MIME_VIDEO_MP4,                                                                 MIME_VIDEO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
+       {"video/h263",                                                                                  "3gp"/*,3gpp,mp4"*/,true,               MIME_VIDEO_H263,                                                                MIME_VIDEO_H263,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
+       {"video/3gpp",                                                                                  "3gp"/*,3gpp"*/,        true,           MIME_VIDEO_3GPP,                                                                MIME_VIDEO_3GPP,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
+       {"video/3gp",                                                                                   "3gp"/*,3gpp"*/,        true,           MIME_VIDEO_3GP,                                                                 MIME_VIDEO_3GP,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
+       {"video/avi",                                                                                   "avi",                          false,          MIME_VIDEO_AVI,                                                                 MIME_VIDEO_AVI,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
+       {"video/sdp",                                                                                   "sdp",                          true,           MIME_VIDEO_SDP,                                                                 MIME_APPLICATION_SDP,                                                   MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
+       {"video/mp4v-es",                                                                                       "3gp",                          true,           MIME_VIDEO_MP4_ES,                                                                      MIME_VIDEO_3GP,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
+       {"video/mpeg",                                                                                  "3gp",                          true,           MIME_VIDEO_MPEG,                                                                        MIME_VIDEO_3GP,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
+
+       // 157
+       {"video/vnd.rn-realvideo",                                                              "rm",                           true,           MIME_VIDEO_VND_RN_REALVIDEO,                                    MIME_VIDEO_VND_RN_REALVIDEO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
+       {"video/vnd.rn-realmedia",                                                              "rm",                           true,           MIME_VIDEO_VND_RN_REALMEDIA,                                    MIME_VIDEO_VND_RN_REALMEDIA,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
+
+       //159
+       {"video/x-mp4",                                                                         "mp4",                          true,           MIME_VIDEO_X_MP4,                                                               MIME_VIDEO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
+       {"video/x-pv-mp4",                                                                              "mp4",                          true,           MIME_VIDEO_X_PV_MP4,                                                    MIME_VIDEO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
+       {"video/x-pn-realvideo",                                                                "rv",                           true,           MIME_VIDEO_X_PN_REALVIDEO,                                              MIME_VIDEO_VND_RN_REALVIDEO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
+       {"video/x-pn-multirate-realvideo",                                              "rm",                           true,           MIME_VIDEO_X_PN_MULTIRATE_REALVIDEO,                    MIME_VIDEO_VND_RN_REALVIDEO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
+       {"video/x-ms-wmv",                                                                              "wmv",                          true,           MIME_VIDEO_X_MS_WMV,                                                    MIME_VIDEO_X_MS_WMV,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
+       {"video/x-ms-asf",                                                                              "asf",                          true,           MIME_VIDEO_X_MS_ASF,                                                    MIME_VIDEO_X_MS_ASF,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
+       {"video/x-pv-pvx",                                                                              "pvx",                          true,           MIME_VIDEO_X_PV_PVX,                                                    MIME_VIDEO_X_PV_PVX,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        }
+
+};
+
+/**********             MIME table information     ***********/
+static const int mimeTableIndex[] = {
+       1,                      16,                     49,
+       56,                     85,                     86,
+       105,            116,            119,
+       120,            120,            120,
+       121,            121,            121,
+       128,            134,            142,
+       148,            157,            159
+};
+
+
+/*****************             Extension definition      *****************/
+static const ExtTable extTable[] = {
+
+       {"txt",                 MIME_TEXT_PLAIN},
+       {"html",                        MIME_TEXT_HTML},
+       {"htm",                 MIME_TEXT_HTML},
+       {"xhtml",                       MIME_APPLICATION_XHTML_XML},
+       {"wml",                 MIME_TEXT_VND_WAP_WML},
+       {"vcs",                 MIME_TEXT_X_VCALENDAR},
+       {"vcf",                 MIME_TEXT_X_VCARD},
+       {"vnt",                 MIME_TEXT_X_VNOTE},
+       {"smil",                        MIME_APPLICATION_SMIL},
+       {"eml",                 MIME_MESSAGE_RFC822},
+       {"gif",                 MIME_IMAGE_GIF},
+       {"jpeg",                        MIME_IMAGE_JPEG},
+       {"jpg",                 MIME_IMAGE_JPEG},
+       {"jpe",                 MIME_IMAGE_JPEG},
+       {"jpz",                 MIME_IMAGE_JPEG},
+       {"tiff",                        MIME_IMAGE_TIFF},
+       {"tif",                 MIME_IMAGE_TIFF},
+       {"png",                 MIME_IMAGE_PNG},
+       {"pnz",                 MIME_IMAGE_PNG},
+       {"wbmp",                        MIME_IMAGE_VND_WAP_WBMP},
+       {"bmp",                 MIME_IMAGE_BMP},
+       {"au",                          MIME_AUDIO_BASIC},
+       {"snd",                 MIME_AUDIO_BASIC},
+       {"mp3",                 MIME_AUDIO_MP3},
+       {"aac",                 MIME_AUDIO_AAC},
+       {"mp4",                 MIME_AUDIO_MP4},
+       {"m4a",                 MIME_AUDIO_M4A},
+       {"amr",                 MIME_AUDIO_X_AMR},
+       {"mmf",                 MIME_APPLICATION_VND_SMAF},
+       {"imy",                 MIME_AUDIO_X_IMELODY},
+       {"mid",                 MIME_AUDIO_MID},
+       {"midi",                        MIME_AUDIO_MID},
+       {"spm",                 MIME_AUDIO_SP_MIDI},
+       {"wav",                 MIME_AUDIO_WAVE},
+       {"3gp",                 MIME_AUDIO_3GPP},
+       {"3gpp",                        MIME_VIDEO_3GPP},
+       {"rm",                          MIME_VIDEO_VND_RN_REALVIDEO},
+       {"ra",                          MIME_AUDIO_VND_RN_REALAUDIO},
+       {"ram",                 MIME_AUDIO_VND_RN_REALAUDIO},
+       {"wma",                 MIME_AUDIO_X_MS_WMA},
+       {"smp",                 MIME_APPLICATION_STUDIOM},
+       {"avi",                 MIME_VIDEO_AVI},
+       {"sdp",                 MIME_APPLICATION_SDP},
+       {"vbm",                 MIME_TEXT_PLAIN},
+       {"url",                 MIME_TEXT_PLAIN},
+       {"jad",                 MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR},
+       {"jar",                 MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE},
+       {"dd",                          MIME_APPLICATION_VND_OMA_DD_XML},
+       {"dm",                          MIME_APPLICATION_VND_OMA_DRM_MESSAGE},
+       {"dcf",                 MIME_APPLICATION_VND_OMA_DRM_CONTENT},
+       {"rv",                          MIME_VIDEO_X_PN_REALVIDEO},
+       {"ro",                          MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML},
+       {"xls",                 MIME_APPLICATION_X_EXCEL},
+       {"pdf",                 MIME_APPLICATION_PDF},
+       {"ppt",                 MIME_APPLICATION_X_POWERPOINT},
+       {"swf",                 MIME_APPLICATION_X_FLASH},
+       {"svg",                 MIME_IMAGE_SVG},
+       {"doc",                 MIME_APPLICATION_MSWORD},
+       {"wmv",                 MIME_VIDEO_X_MS_WMV},
+       {"asf",                 MIME_VIDEO_X_MS_ASF},
+       {"3ga",                 MIME_AUDIO_M4A},
+       {"xmf",                 MIME_AUDIO_XMF},
+       {"mxmf",                        MIME_AUDIO_MOBILE_XMF},
+       {"pvx",                 MIME_VIDEO_X_PV_PVX},
+       {"oro",                 MIME_APPLICATION_VND_OMA_DRM_RO_XML},
+       {"odf",                 MIME_APPLICATION_VND_OMA_DRM_DCF}
+};
+
+
+static int mimeTableEnum[] =
+{
+       MIME_ASTERISK   ,
+
+       MIME_APPLICATION_XML    ,
+       MIME_APPLICATION_WML_XML        ,
+       MIME_APPLICATION_XHTML_XML      ,
+       MIME_APPLICATION_JAVA_VM        ,
+       MIME_APPLICATION_SMIL   ,
+       MIME_APPLICATION_JAVA_ARCHIVE   ,
+       MIME_APPLICATION_JAVA   ,
+       MIME_APPLICATION_OCTET_STREAM   ,
+       MIME_APPLICATION_STUDIOM        ,
+       MIME_APPLICATION_FUNMEDIA       ,
+       MIME_APPLICATION_MSWORD         ,
+       MIME_APPLICATION_PDF            ,
+       MIME_APPLICATION_SDP            ,
+       MIME_APPLICATION_RAM            ,
+       MIME_APPLICATION_ASTERIC        ,
+
+
+       MIME_APPLICATION_VND_WAP_XHTMLXML       ,
+       MIME_APPLICATION_VND_WAP_WMLC   ,
+       MIME_APPLICATION_VND_WAP_WMLSCRIPTC     ,
+       MIME_APPLICATION_VND_WAP_WTA_EVENTC     ,
+       MIME_APPLICATION_VND_WAP_UAPROF ,
+       MIME_APPLICATION_VND_WAP_SIC    ,
+       MIME_APPLICATION_VND_WAP_SLC    ,
+       MIME_APPLICATION_VND_WAP_COC    ,
+       MIME_APPLICATION_VND_WAP_SIA    ,
+       MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML     ,
+       MIME_APPLICATION_VND_WAP_MULTIPART_FORM_DATA    ,
+       MIME_APPLICATION_VND_WAP_MULTIPART_BYTERANGES   ,
+       MIME_APPLICATION_VND_WAP_MULTIPART_MIXED        ,
+       MIME_APPLICATION_VND_WAP_MULTIPART_RELATED      ,
+       MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE  ,
+       MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC      ,
+       MIME_APPLICATION_VND_WAP_WBXML  ,
+       MIME_APPLICATION_VND_OMA_DD_XML ,
+       MIME_APPLICATION_VND_OMA_DRM_MESSAGE    ,
+       MIME_APPLICATION_VND_OMA_DRM_CONTENT    ,
+       MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML ,
+       MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML       ,
+       MIME_APPLICATION_VND_OMA_DRM_RO_XML     ,
+       MIME_APPLICATION_VND_OMA_DRM_DCF        ,
+       MIME_APPLICATION_VND_OMA_ROAPPDU_XML    ,
+       MIME_APPLICATION_VND_OMA_ROAPTRIGGER_XML,
+       MIME_APPLICATION_VND_SMAF       ,
+       MIME_APPLICATION_VND_RN_REALMEDIA       ,
+       MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE      ,
+       MIME_APPLICATION_VND_EXCEL      ,
+       MIME_APPLICATION_VND_POWERPOINT,
+       MIME_APPLICATION_VND_MSWORD,
+
+
+       MIME_APPLICATION_X_HDMLC        ,
+       MIME_APPLICATION_X_X968_USERCERT        ,
+       MIME_APPLICATION_X_WWW_FORM_URLENCODED  ,
+       MIME_APPLICATION_X_SMAF ,
+       MIME_APPLICATION_X_FLASH        ,
+       MIME_APPLICATION_X_EXCEL        ,
+       MIME_APPLICATION_X_POWERPOINT   ,
+
+
+       MIME_AUDIO_BASIC,
+       MIME_AUDIO_MPEG ,
+       MIME_AUDIO_MP3  ,
+       MIME_AUDIO_MPG3 ,
+       MIME_AUDIO_MPEG3        ,
+       MIME_AUDIO_MPG  ,
+       MIME_AUDIO_AAC  ,
+       MIME_AUDIO_G72  ,
+       MIME_AUDIO_AMR  ,
+       MIME_AUDIO_AMR_WB       ,
+       MIME_AUDIO_MMF  ,
+       MIME_AUDIO_SMAF ,
+       MIME_AUDIO_IMELODY      ,
+       MIME_AUDIO_IMELODY2 ,
+       MIME_AUDIO_MELODY       ,
+       MIME_AUDIO_MID  ,
+       MIME_AUDIO_MIDI ,
+       MIME_AUDIO_SP_MIDI      ,
+       MIME_AUDIO_WAVE ,
+       MIME_AUDIO_WAV ,
+       MIME_AUDIO_3GPP ,
+       MIME_AUDIO_MP4  ,
+       MIME_AUDIO_MP4A_LATM    ,
+       MIME_AUDIO_M4A  ,
+       MIME_AUDIO_MPEG4,
+       MIME_AUDIO_WMA,
+       MIME_AUDIO_XMF,
+       MIME_AUDIO_IMY,
+       MIME_AUDIO_MOBILE_XMF,
+
+
+       MIME_AUDIO_VND_RN_REALAUDIO     ,
+
+
+       MIME_AUDIO_X_MPEG       ,
+       MIME_AUDIO_X_MP3        ,
+       MIME_AUDIO_X_MPEG3      ,
+       MIME_AUDIO_X_MPG        ,
+       MIME_AUDIO_X_AMR        ,
+       MIME_AUDIO_X_MMF        ,
+       MIME_AUDIO_X_SMAF       ,
+       MIME_AUDIO_X_IMELODY    ,
+       MIME_AUDIO_X_MIDI       ,
+       MIME_AUDIO_X_MPEGAUDIO  ,
+       MIME_AUDIO_X_PN_REALAUDIO       ,
+       MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO     ,
+       MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO_LIVE        ,
+       MIME_AUDIO_X_WAVE       ,
+       MIME_AUDIO_X_WAV        ,
+       MIME_AUDIO_X_MS_WMA     ,
+       MIME_AUDIO_X_MID ,
+       MIME_AUDIO_X_MS_ASF ,
+       MIME_AUDIO_X_XMF,
+
+
+       MIME_IMAGE_GIF  ,
+       MIME_IMAGE_JPEG ,
+       MIME_IMAGE_JPG  ,
+       MIME_IMAGE_TIFF ,
+       MIME_IMAGE_TIF  ,
+       MIME_IMAGE_PNG  ,
+       MIME_IMAGE_WBMP ,
+       MIME_IMAGE_PJPEG        ,
+       MIME_IMAGE_BMP  ,
+       MIME_IMAGE_SVG  ,
+       MIME_IMAGE_SVG1 ,
+       MIME_IMAGE_VND_WAP_WBMP ,
+       MIME_IMAGE_X_BMP        ,
+
+
+       MIME_MESSAGE_RFC822     ,
+
+
+       MIME_MULTIPART_MIXED    ,
+       MIME_MULTIPART_RELATED  ,
+       MIME_MULTIPART_ALTERNATIVE      ,
+       MIME_MULTIPART_FORM_DATA        ,
+       MIME_MULTIPART_BYTERANGE        ,
+       MIME_MULTIPART_REPORT   ,
+       MIME_MULTIPART_VOICE_MESSAGE    ,
+
+
+       MIME_TEXT_TXT   ,
+       MIME_TEXT_HTML  ,
+       MIME_TEXT_PLAIN ,
+       MIME_TEXT_CSS   ,
+       MIME_TEXT_XML   ,
+       MIME_TEXT_IMELODY       ,
+       MIME_TEXT_VND_WAP_WMLSCRIPT     ,
+       MIME_TEXT_VND_WAP_WML   ,
+       MIME_TEXT_VND_WAP_WTA_EVENT     ,
+       MIME_TEXT_VND_WAP_CONNECTIVITY_XML      ,
+       MIME_TEXT_VND_WAP_SI    ,
+       MIME_TEXT_VND_WAP_SL    ,
+       MIME_TEXT_VND_WAP_CO    ,
+       MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR   ,
+       MIME_TEXT_X_HDML        ,
+       MIME_TEXT_X_VCALENDAR   ,
+       MIME_TEXT_X_VCARD       ,
+       MIME_TEXT_X_IMELODY     ,
+       MIME_TEXT_X_IMELODY2 ,
+       MIME_TEXT_X_VNOTE ,
+
+
+       MIME_VIDEO_MPEG4        ,
+       MIME_VIDEO_MP4  ,
+       MIME_VIDEO_H263 ,
+       MIME_VIDEO_3GPP ,
+       MIME_VIDEO_3GP  ,
+       MIME_VIDEO_AVI  ,
+       MIME_VIDEO_SDP  ,
+       MIME_VIDEO_MP4_ES,
+       MIME_VIDEO_MPEG ,
+       MIME_VIDEO_VND_RN_REALVIDEO     ,
+       MIME_VIDEO_VND_RN_REALMEDIA     ,
+       MIME_VIDEO_X_MP4        ,
+       MIME_VIDEO_X_PV_MP4     ,
+       MIME_VIDEO_X_PN_REALVIDEO       ,
+       MIME_VIDEO_X_PN_MULTIRATE_REALVIDEO     ,
+       MIME_VIDEO_X_MS_WMV ,
+       MIME_VIDEO_X_MS_ASF,
+       MIME_VIDEO_X_PV_PVX ,
+
+       MIME_UNKNOWN    // MIME_MAX
+};
+
+
+#define MIME_MAX_NUM   166
+#define EXT_MAX        67
+#define MIME_SUB_TYPE_VND      1
+#define MIME_SUB_TYPE_X                2
+
+int __MimeGetTableIndexInt(MimeType mime);
+int __MimeGetTableIndexString(const char *szMime);
+MimeMainType __MimeGetMainTypeName(const char *szType);
+
+
+/*
+ * This function checks whether a mime is downloadable or not.
+ *
+ * @param      mime [in] Enumeration number for a MIME type.
+ * @return     This function returns true if downloadable, or false.
+ */
+bool MimeIsDownloadableInt(MimeType mime)
+{
+       int index;
+
+       index = __MimeGetTableIndexInt(mime);
+       if (index == MIME_UNKNOWN)
+               return false;
+
+       return mimeTable[index].bDownloadable;
+}
+
+/*
+ * This function checks whether a mime is downloadable or not.
+ *
+ * @param      mime [in] MIME string.
+ * @return     This function returns true if downloadable, or false.
+ */
+bool MimeIsDownloadableString(const char *szMime)
+{
+       int index;
+
+       index = __MimeGetTableIndexString(szMime);
+       if (index == MIME_UNKNOWN)
+               return false;
+
+       return mimeTable[index].bDownloadable;
+}
+
+/*
+ * This function checks main type of a MIME.
+ *
+ * @param      mime [in] Enumeration number for a MIME type.
+ * @return     This function returns main type of a MIME.
+ */
+MimeMainType MimeGetMainTypeInt(MimeType mime)
+{
+       int index;
+
+       index = __MimeGetTableIndexInt(mime);
+       if (index == MIME_UNKNOWN)
+               return MIME_MAINTYPE_ETC;
+
+       return mimeTable[index].mainType;
+}
+
+/*
+ * This function checks main type of a MIME.
+ *
+ * @param      mime [in] MIME string.
+ * @return     This function returns main type of a MIME.
+ */
+MimeMainType MimeGetMainTypeString(const char *szMime)
+{
+       int index;
+
+       index = __MimeGetTableIndexString(szMime);
+       if (index == MIME_UNKNOWN)
+               return MIME_MAINTYPE_ETC;
+
+       return mimeTable[index].mainType;
+}
+
+/*
+ * This function returns a extension name for a specified MIME.
+ *
+ * @param      mime [in] Enumeration number for a MIME type.
+ * @return     This function returns Extension string.
+ */
+char *MimeGetExtFromMimeInt(MimeType mime)
+{
+       int index;
+
+       index = __MimeGetTableIndexInt(mime);
+       if (index == MIME_UNKNOWN)
+               return NULL;
+
+       return (char *)mimeTable[index].szExt;
+}
+
+/*
+ * This function returns a extension name for a specified MIME.
+ *
+ * @param      mime [in] MIME string.
+ * @return     This function returns Extension string.
+ */
+char *MimeGetExtFromMimeString(const char *szMime)
+{
+       int index;
+
+       index = __MimeGetTableIndexString(szMime);
+       if (index == MIME_UNKNOWN)
+               return NULL;
+
+       return (char *)mimeTable[index].szExt;
+}
+
+
+/*
+ * This function returns a MIME type for a specified Extension.
+ *
+ * @param      mime [in] Extension string.
+ * @return     This function returns MIME string.
+ */
+char *MimeGetMimeFromExtString(const char *szExt)
+{
+       int i;
+
+       for (i = 0; i < EXT_MAX; i++) {
+               if (!strcasecmp( extTable[i].szExt, szExt)) {
+                       int index;
+
+                       index = __MimeGetTableIndexInt(extTable[i].mimeType);
+                       if (index == MIME_UNKNOWN)
+                               return NULL;
+
+                       return (char *)mimeTable[index].szMIME;
+               }
+       }
+
+       return NULL;
+}
+
+/*
+ * This function returns a MIME type for a specified Extension.
+ *
+ * @param      mime [in] Extension string.
+ * @return     This function returns MIME string.
+ */
+MimeType MimeGetMimeFromExtInt(const char *szExt)
+{
+       int i;
+
+       for (i = 0; i < EXT_MAX; i++) {
+               if (!strcasecmp( extTable[i].szExt, szExt))
+                       return extTable[i].mimeType;
+       }
+
+       return MIME_UNKNOWN;
+}
+
+/*
+ * This function returns index number in MIME definition table with MIME enumeration.
+ * Internal function.
+ */
+int __MimeGetTableIndexInt(MimeType mime)
+{
+       int type;
+       int subtype;
+       int index;
+       int tableIndex;
+
+       if (mime == MIME_UNKNOWN)
+               return MIME_UNKNOWN;
+
+       type = (mime & 0xf000) >> 12;
+       subtype = (mime & 0x0f00) >> 8;
+       index = (mime & 0x003f);
+
+       //If 'type' is zero, mimeTableIndex's array value have a minus value
+       //If 'type' is zero, mime type is '*/*'
+       if (type == 0)
+               tableIndex = 0;
+       else
+               tableIndex = mimeTableIndex[(type - 1) * 3 + subtype] + index;
+
+       return tableIndex;
+}
+
+
+#define MIME_MAX_LEN   43
+/*
+ * This function returns index number in MIME definition table with MIME string.
+ * Internal function.
+ */
+int __MimeGetTableIndexString(const char *szMime)
+{
+       int type;
+       int subtype;
+       char szType[50];
+       char szSubType[50];
+       char *szTmpStart = NULL;
+       char c;
+       int i = 0;
+       int j = 0;
+       int start;
+       int end;
+       char *szMIMEType = NULL;
+       int len;
+
+       if (szMime == NULL) {
+               MSG_DEBUG("szMime is NULL");
+               return MIME_UNKNOWN;
+       }
+
+       szMIMEType = (char * )malloc(strlen(szMime) + 1);
+
+       if (szMIMEType == NULL) {
+               MSG_DEBUG("szMime is NULL");
+                return MIME_UNKNOWN;
+       }
+
+       memset(szMIMEType, 0, strlen(szMime) + 1);
+
+       if (!strcmp(szMime, "*/*")) {
+               free(szMIMEType);
+               return 0;
+       }
+       strcpy(szMIMEType, szMime);
+       type = 0;
+       subtype = 0;
+
+       szTmpStart = szMIMEType;
+       len = strlen(szTmpStart);
+
+       while (true) {
+               if (i >= len) {
+                       free(szMIMEType);
+                       return MIME_UNKNOWN;
+               }
+
+               c = szTmpStart[i++];
+
+               if (c == '/') {
+                       szType[j] = '\0';
+                       type = __MimeGetMainTypeName(szType);
+                       szTmpStart = &szTmpStart[i];
+                       break;
+               } else
+                       szType[j++] = c;
+       }
+
+       i = 0;
+       j = 0;
+       len = strlen(szTmpStart);
+
+       while (true) {
+               c = szTmpStart[i++];
+               if (i > len) {
+                       szSubType[j] = '\0';
+                       break;
+               }
+
+               if (c == '.') {
+                       szSubType[j] = '\0';
+                       if (!strcasecmp(szSubType, "vnd"))
+                               subtype = MIME_SUB_TYPE_VND;
+                       break;
+               } else if (c == '-') {
+                       szSubType[j] = '\0';
+                       if (!strcasecmp(szSubType, "x"))
+                               subtype = MIME_SUB_TYPE_X;
+                       break;
+               } else
+                       szSubType[j++] = c;
+       }
+
+
+       start = mimeTableIndex[type * 3 + subtype];
+
+       if (type == MIME_MAINTYPE_VIDEO && subtype == MIME_SUB_TYPE_X)
+               end = MIME_MAX_NUM;
+       else
+               end = mimeTableIndex[type * 3 + subtype + 1];
+
+       if (start == end && type < MIME_MAINTYPE_VIDEO) {
+               end = mimeTableIndex[(type + 1) * 3 + subtype + 1];
+       }
+
+
+       for (i = start; i < end; i++) {
+               if (i >= MIME_MAX_NUM)
+                       break;
+
+               if (!strcasecmp(mimeTable[i].szMIME, szMime)) {
+                       free(szMIMEType);
+                       return i;
+               }
+       }
+
+       free(szMIMEType);
+       return MIME_UNKNOWN;
+}
+
+/*
+ * This function returns main type of MIME : Internal function.
+ */
+MimeMainType __MimeGetMainTypeName(const char *szType)
+{
+       if (szType == NULL )
+               return MIME_MAINTYPE_APPLICATION;
+
+       if (!strcasecmp(szType, "application"))
+               return MIME_MAINTYPE_APPLICATION;
+       else if (!strcasecmp(szType, "audio"))
+               return MIME_MAINTYPE_AUDIO;
+       else if (!strcasecmp(szType, "image"))
+               return MIME_MAINTYPE_IMAGE;
+       else if (!strcasecmp(szType, "message"))
+               return MIME_MAINTYPE_MESSAGE;
+       else if (!strcasecmp(szType, "multipart"))
+               return MIME_MAINTYPE_MULTIPART;
+       else if (!strcasecmp(szType, "text"))
+               return MIME_MAINTYPE_TEXT;
+       else if (!strcasecmp(szType, "video"))
+               return MIME_MAINTYPE_VIDEO;
+
+       return MIME_MAINTYPE_APPLICATION;
+}
+
+
+
+// MimeString -> MimeInt
+MimeType MimeGetMimeIntFromMimeString(char *szMimeStr)
+{
+       int index = __MimeGetTableIndexString(szMimeStr);
+       if (index == MIME_UNKNOWN) {
+               return MIME_UNKNOWN;
+       } else {
+               return (MimeType)mimeTableEnum[index];
+       }
+}
+
+// MimeInt -> MimeString
+char *MimeGetMimeStringFromMimeInt(int mimeType)
+{
+       int idx = __MimeGetTableIndexInt((MimeType)mimeType);
+
+       if (idx == MIME_UNKNOWN)
+               return NULL;
+
+       return (char *)mimeTable[idx].szMIME;
+}
+
+
+// BinaryCode -> MimeInt
+MimeType MimeGetMimeIntFromBi(int binCode)
+{
+       int index;
+
+       if (binCode < 0x00 || binCode > 0x4b)
+               return MIME_UNKNOWN;
+
+       for (index = 0; index < MIME_MAX_NUM; index++) {
+               if (binCode == mimeTable[index].binary)
+                       return (MimeType)mimeTableEnum[index];
+       }
+
+       return MIME_UNKNOWN;
+}
+
+// BinaryCode -> MimeInt
+char *MimeGetMimeStringFromBi(int binCode)
+{
+       int index;
+
+       if (binCode < 0x00 || binCode > 0x4b)
+               return NULL;
+
+       for (index = 0; index < MIME_MAX_NUM; index++) {
+               if (binCode == mimeTable[index].binary)
+                       return (char *)mimeTable[index].szMIME;
+       }
+
+       return NULL;
+}
+
+// Mimeint -> Binary Value
+int MimeGetBinaryValueFromMimeInt(MimeType mime)
+{
+       int index;
+
+       index = __MimeGetTableIndexInt(mime);
+       if (index == MIME_UNKNOWN)
+               return UNDEFINED_BINARY;
+
+       return mimeTable[index].binary;
+}
+
+// MimeString -> Binary value
+int MimeGetBinaryValueFromMimeString(const char *szMime)
+{
+       int index;
+
+       index = __MimeGetTableIndexString(szMime);
+       if (index == MIME_UNKNOWN)
+               return UNDEFINED_BINARY;
+
+       return mimeTable[index].binary;
+}
+
+
+/*
+ * This function checks main type of a MIME.
+ *
+ * @param      mime [in] Enumeration number for a MIME type.
+ * @return     This function returns application type of a MIME.
+ */
+MimeAppType MimeGetAppTypeFromInt(MimeType mime)
+{
+       int index;
+
+       index = __MimeGetTableIndexInt(mime);
+       if (index == MIME_UNKNOWN)
+               return MIME_APPLICATION_NONE;
+
+       return mimeTable[index].appType;
+}
+
+/*
+ * This function checks main type of a MIME.
+ *
+ * @param      mime [in] MIME string.
+ * @return     This function returns application type of a MIME.
+ */
+MimeAppType MimeGetAppTypeFromString(const char *szMime)
+{
+       int index;
+
+       index = __MimeGetTableIndexString(szMime);
+       if (index == MIME_UNKNOWN)
+               return MIME_APPLICATION_NONE;
+
+       return mimeTable[index].appType;
+}
+
+
+/*
+ * This function returns a application type for a specified Extension.
+ *
+ * @param      mime [in] Extension string.
+ * @return     This function returns application type.
+ */
+MimeAppType MimeGetAppTypeFromExtString(const char *szExt)
+{
+       int i;
+
+       for (i = 0; i < EXT_MAX; i++) {
+               if (!strcasecmp( extTable[i].szExt, szExt)) {
+                       int index;
+
+                       index = __MimeGetTableIndexInt(extTable[i].mimeType);
+                       if (index == MIME_UNKNOWN)
+                               return MIME_APPLICATION_NONE;
+                       return mimeTable[index].appType;
+               }
+       }
+
+       return MIME_APPLICATION_NONE;
+}
+
+/*
+ * This function gets the representative mime type from MimeType
+ *
+ * @param      mime [in] Enumeration number for a MIME type.
+ * @return     representative mime type Enumeration number
+ */
+
+MimeType MimeGetContentTypeFromInt(MimeType mime)
+{
+       int index;
+
+       for (index = 0; index < MIME_MAX_NUM; index++) {
+               if (mime == mimeTable[index].mime)
+                       return mimeTable[index].contentType;
+       }
+
+       return MIME_UNKNOWN;
+}
+
+/*
+ * This function gets the representative mime type from mime string
+ *
+ * @param      szMime - string name of MimeType
+ * @return     representative mime type Enumeration number
+ */
+
+MimeType MimeGetContentTypeFromString(const char *szMime)
+{
+       int index;
+
+       for (index = 0; index < MIME_MAX_NUM; index++) {
+               if (!strcasecmp(szMime, mimeTable[index].szMIME))
+                       return mimeTable[index].contentType;
+       }
+
+       return MIME_UNKNOWN;
+}
+
+/*
+ * This function gets the index from mime string
+ *
+ * @param      szMime - string name of MimeType
+ * @return     Enumeration number for a MIME type.
+ */
+
+MimeType MimeGetMimeTypeFromString(const char *szMime)
+{
+       int index;
+
+       for (index = 0; index < MIME_MAX_NUM; index++) {
+               if (!strcasecmp(szMime, mimeTable[index].szMIME))
+                       return mimeTable[index].mime;
+       }
+
+       return MIME_UNKNOWN;
+}
+
+
+int MsgGetCode(MsgHeaderField tableId, char *pStr)
+{
+       int cCode = 0;
+       int nNum = MSG_FIELD_UNKNOWN;
+       char **pTable = NULL;
+
+       switch (tableId) {
+       case MSG_FIELD:
+               nNum = MSG_FIELD_NUM;
+               pTable = (char **)szMsgField;
+               break;
+
+       case MSG_PARAM:
+               nNum = MSG_PARAM_NUM;
+               pTable = (char **)szMsgParam;
+               break;
+
+       case MSG_TYPE:
+               return MimeGetMimeIntFromMimeString(pStr);
+
+       case MSG_CHARSET:
+               nNum = MSG_CHARSET_NUM;
+               pTable = (char **)szMsgCharset;
+               break;
+
+       case MSG_ENCODING:
+               nNum = MSG_ENCODING_NUM;
+               pTable = (char **)szMsgEncoding;
+               break;
+
+       case MSG_DISPOSITION:
+               nNum = MSG_DISPOSITION_NUM;
+               pTable = (char **)szMsgDisposition;
+               break;
+
+       case MSG_ADDR_TYPE:
+               nNum = MSG_ADDR_TYPE_NUM;
+               pTable = (char **)szMsgAddrType;
+               break;
+
+       default:
+               break;
+       }
+
+       for (cCode = 0; cCode < nNum; cCode++) {
+               if (!strcasecmp(pStr, pTable[cCode])) {
+                       return cCode;
+               }
+       }
+
+       return -1;
+}
+
+
+char *MsgGetString(MsgHeaderField tableId, int code)
+{
+       int nNum = MSG_FIELD_UNKNOWN;
+       char **pTable = NULL;
+
+       switch (tableId) {
+       case MSG_FIELD:
+               nNum = MSG_FIELD_NUM;
+               pTable = (char **)szMsgField;
+               break;
+
+       case MSG_PARAM:
+               nNum = MSG_PARAM_NUM;
+               pTable = (char **)szMsgParam;
+               break;
+
+       case MSG_TYPE:
+               if (code != MIME_UNKNOWN && code != -1)
+                       return MimeGetMimeStringFromMimeInt(code);
+               else
+                       return (char *)MSG_UNKNOWN_TYPE_STRING;
+
+       case MSG_CHARSET:
+               nNum = MSG_CHARSET_NUM;
+               pTable = (char **)szMsgCharset;
+               break;
+
+       case MSG_ENCODING:
+               nNum = MSG_ENCODING_NUM;
+               pTable = (char **)szMsgEncoding;
+               break;
+
+       case MSG_DISPOSITION:
+               nNum = MSG_DISPOSITION_NUM;
+               pTable = (char **)szMsgDisposition;
+               break;
+
+       case MSG_ADDR_TYPE:
+               nNum = MSG_ADDR_TYPE_NUM;
+               pTable = (char **)szMsgAddrType;
+               break;
+
+       default:
+               break;
+       }
+
+       if (code < 0 || code >= nNum || !pTable)
+               return (char *)MSG_UNKNOWN_TYPE_STRING;
+
+       return pTable[code];
+}
+
+char *_MsgSkipWS3(char *s)
+{
+       while (true) {
+               if ((*s == MSG_CH_CR) ||
+                       (*s == MSG_CH_LF) ||
+                       (*s == MSG_CH_SP) ||
+                       (*s == MSG_CH_TAB))
+                       ++s;
+               else
+                       return s;
+       }
+}
+
+
+int _MsgGetCode(MsgHeaderField tableId, char *pStr)
+{
+       int cCode = 0;
+       int nNum = MSG_FIELD_UNKNOWN;
+       char **pTable = NULL;
+
+       switch (tableId) {
+       case MSG_FIELD:
+               nNum = MSG_FIELD_NUM;
+               pTable = (char **)szMsgField;
+               break;
+
+       case MSG_PARAM:
+               nNum = MSG_PARAM_NUM;
+               pTable = (char **)szMsgParam;
+               break;
+
+       case MSG_TYPE:
+               return MimeGetMimeIntFromMimeString(pStr);
+
+       case MSG_CHARSET:
+               nNum = MSG_CHARSET_NUM;
+               pTable = (char **)szMsgCharset;
+               break;
+
+       case MSG_ENCODING:
+               nNum = MSG_ENCODING_NUM;
+               pTable = (char **)szMsgEncoding;
+               break;
+
+       case MSG_DISPOSITION:
+               nNum = MSG_DISPOSITION_NUM;
+               pTable = (char **)szMsgDisposition;
+               break;
+
+       case MSG_ADDR_TYPE:
+               nNum = MSG_ADDR_TYPE_NUM;
+               pTable = (char **)szMsgAddrType;
+               break;
+
+       default:
+               MSG_DEBUG("_MsgGetCode: Invalid tableId [%d] \n", tableId);
+               break;
+       }
+
+       for (cCode = 0; cCode < nNum; cCode++) {
+               if (pTable[cCode] != NULL) {
+                       if (!strcasecmp( pStr, pTable[cCode])) {
+                               return cCode;
+                       }
+               }
+       }
+
+       return INVALID_HOBJ;
+}
+
diff --git a/plugin/mms_plugin/MmsPluginMain.cpp b/plugin/mms_plugin/MmsPluginMain.cpp
new file mode 100755 (executable)
index 0000000..6b10ab5
--- /dev/null
@@ -0,0 +1,328 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <glib.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <time.h>
+
+#include "MmsPluginTypes.h"
+#include "MmsPluginMain.h"
+#include "MmsPluginTransport.h"
+#include "MsgDebug.h"
+#include "MsgException.h"
+
+#include "MmsPluginMain.h"
+#include "MmsPluginMessage.h"
+#include "MmsPluginStorage.h"
+#include "MmsPluginInternal.h"
+#include "MmsPluginEventHandler.h"
+#include "MsgGconfWrapper.h"
+#include "MmsPluginCodec.h"
+#include "MsgUtilFile.h"
+#include "MmsPluginUserAgent.h"
+
+
+/*==================================================================================================
+                                                       FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgPlgCreateHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
+{
+       if (pPluginHandle == NULL) {
+               MSG_DEBUG("MMS plugin: create handler error ");
+               return MSG_ERR_NULL_POINTER;
+       } else {
+               pPluginHandle->pfInitialize = MmsInitialize;
+               pPluginHandle->pfFinalize = MmsFinalize;
+               pPluginHandle->pfRegisterListener = MmsRegisterListener;
+               pPluginHandle->pfSubmitRequest = MmsSubmitRequest;
+               pPluginHandle->pfAddMessage = MmsAddMessage;
+               pPluginHandle->pfProcessReceivedInd = MmsProcessReceivedInd;
+               pPluginHandle->pfUpdateMessage = MmsUpdateMessage;
+               pPluginHandle->pfGetMmsMessage = MmsGetMmsMessage;
+               pPluginHandle->pfUpdateRejectStatus = MmsUpdateRejectStatus;
+               pPluginHandle->pfComposeReadReport = MmsComposeReadReport;
+               pPluginHandle->pfRestoreMsg = MmsRestoreMsg;
+
+               MSG_DEBUG("MMS plugin: create handler OK");
+               MSG_DEBUG ("MMS plugin %p", pPluginHandle);
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsPlgDestroyHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
+{
+       MSG_BEGIN();
+
+       if (pPluginHandle != NULL) {
+               free(pPluginHandle);
+               pPluginHandle = NULL;
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsInitialize()
+{
+       MSG_BEGIN();
+
+       // remove temp files
+       MsgMmsInitDir();
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsFinalize()
+{
+       MSG_BEGIN();
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsRegisterListener(MSG_PLUGIN_LISTENER_S *pListener)
+{
+       MSG_BEGIN();
+
+       MmsPluginEventHandler::instance()->registerListener(pListener);
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo, bool bReqCb)
+{
+       MSG_BEGIN();
+
+       try {
+               MmsPluginTransport::instance()->submitRequest(pReqInfo);
+       } catch (MsgException& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_TRANSPORT;
+       } catch (exception& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_TRANSPORT;
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsAddMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
+{
+       MSG_BEGIN();
+
+       try {
+               MmsPluginStorage::instance()->addMessage(pMsgInfo, pSendOptInfo, pFileData);
+       } catch (MsgException& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_TRANSPORT;
+       } catch (exception& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_TRANSPORT;
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsProcessReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject)
+{
+       MSG_BEGIN();
+
+       MSG_DEBUG("MMS Plugin ProcessReceivedInd");
+
+       try {
+               MmsPluginInternal::instance()->processReceivedInd(pMsgInfo, pRequest, bReject);
+       } catch (MsgException& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_TRANSPORT;
+       } catch (exception& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_TRANSPORT;
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsUpdateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo,  char *pFileData)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       try {
+               if (pMsgInfo->networkStatus == MSG_NETWORK_NOT_SEND) {
+                       err = MmsPluginStorage::instance()->updateMessage(pMsgInfo, pSendOptInfo, pFileData);
+               } else {
+                       //[Update Message ID & File path only in case of retrieve. Else update Message ID]
+                       if (pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) {
+                               err = MmsPluginStorage::instance()->updateConfMessage(pMsgInfo);
+                       } else {
+                               err = MmsPluginStorage::instance()->updateMsgServerID(pMsgInfo, pSendOptInfo);
+                       }
+               }
+       } catch (MsgException& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       } catch (exception& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       }
+
+       MSG_END();
+
+       return err;
+}
+
+
+MSG_ERROR_T MmsGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T     err = MSG_SUCCESS;
+
+       try {
+               err = MmsPluginStorage::instance()->plgGetMmsMessage(pMsg, pSendOptInfo, pMmsMsg, pDestMsg);
+       } catch (MsgException& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       } catch (exception& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       }
+
+       MSG_END();
+
+       return err;
+}
+
+
+MSG_ERROR_T MmsUpdateRejectStatus(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       try {
+               char szTrID[MMS_TR_ID_LEN + 1] = {0x00};
+               bool bReportAllowed;
+
+               err = MmsPluginStorage::instance()->getTrID(pMsgInfo,szTrID,sizeof(szTrID));
+               if (err != MSG_SUCCESS)
+                       MSG_DEBUG("MmsPlgUpdRejectStatus : Get MMS Transacation id Failed");
+
+               memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
+               MsgSettingGetBool(MMS_SEND_REPORT_ALLOWED, &bReportAllowed);
+               if (MmsPluginInternal::instance()->encodeNotifyRespInd(szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pMsgInfo->msgData)) {
+                       MSG_DEBUG("MmsPlgUpdRejectStatus : Encode Notify Response Success");
+                       pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
+                       pMsgInfo->bTextSms = true;
+               } else
+                       MSG_DEBUG("MmsPlgSetRejectStatus : Encode Notify Response Failed");
+       } catch (MsgException& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       } catch (exception& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       }
+
+       if (err != MSG_SUCCESS)
+               MSG_DEBUG("MmsPlgSetRejectStatus : Update MMS Message Failed");
+
+       MSG_END();
+
+       return err;
+}
+
+
+MSG_ERROR_T MmsComposeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_BEGIN();
+
+       try {
+               MmsPluginStorage::instance()->composeReadReport(pMsgInfo);
+       } catch (MsgException& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       } catch (exception& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsRestoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char *pRcvBody, int rcvdBodyLen, char *filePath)
+{
+       MSG_BEGIN();
+
+       if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) {
+               FILE *pFile;
+               _MmsInitHeader();
+               _MmsRegisterDecodeBuffer(gszMmsLoadBuf1,  gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX);
+
+               if ((pFile = MsgOpenFile(pMsgInfo->msgData, "rb+")) == NULL) {
+                       MSG_DEBUG("File Open Error: %s", pMsgInfo->msgData);
+               } else {
+                       //Decode Header
+                       if (!MmsBinaryDecodeMsgHeader(pFile, rcvdBodyLen))
+                               MSG_DEBUG("Decoding Header Failed \r\n");
+
+                       MsgCloseFile(pFile);
+               }
+       } else {
+               MSG_DEBUG(":::%d :%s ",rcvdBodyLen, pRcvBody);
+
+               if (filePath) {
+                       snprintf(filePath, MAX_FULL_PATH_SIZE, MSG_DATA_PATH"BODY_%lu.DATA", random() % 1000000000 + 1);
+               } else {
+                       return MSG_ERR_NULL_POINTER;
+               }
+
+               // create temp file
+               if (!MsgOpenCreateAndOverwriteFile(filePath, (char*)pRcvBody,rcvdBodyLen))
+                       return MSG_ERR_PLUGIN_STORAGE;
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
diff --git a/plugin/mms_plugin/MmsPluginMessage.cpp b/plugin/mms_plugin/MmsPluginMessage.cpp
new file mode 100755 (executable)
index 0000000..4089ef6
--- /dev/null
@@ -0,0 +1,1465 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <ctype.h>
+
+#include "MsgTypes.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgStorageTypes.h"
+#include "MsgSettingTypes.h"
+#include "MmsPluginMessage.h"
+#include "MmsPluginMIME.h"
+#include "MmsPluginAvCodec.h"
+#include "MsgUtilFile.h"
+#include "MsgDebug.h"
+#include "MmsPluginCodec.h"
+#include "MmsPluginStorage.h"
+#include "MsgMmsMessage.h"
+#include "MsgGconfWrapper.h"
+
+#include "MmsPluginSMILValidate.h"
+
+
+bool MmsInitMsgAttrib(MmsAttrib *pAttrib)
+{
+       MSG_DEBUG("MmsInitMsgAttrib");
+
+       pAttrib->bAskDeliveryReport = false;
+
+       pAttrib->bAskReadReply = false;
+       pAttrib->bRead = false;
+       pAttrib->bReportAllowed = false;
+       pAttrib->readReportAllowedType = MMS_RECEIVE_READ_REPORT_ALLOWED;
+       pAttrib->readReportSendStatus = MMS_RECEIVE_READ_REPORT_NO_SEND;
+       pAttrib->bReadReportSent = false;
+
+       pAttrib->bHideAddress = false;
+       pAttrib->date = 0;
+       pAttrib->bUseDeliveryCustomTime = false;
+       pAttrib->deliveryTime.type = MMS_TIMETYPE_RELATIVE;
+       pAttrib->deliveryTime.time = 0;
+       pAttrib->bUseExpiryCustomTime = false;
+       pAttrib->expiryTime.type = MMS_TIMETYPE_RELATIVE;
+       pAttrib->expiryTime.time = 0;
+       memset(&pAttrib->expiryTime, 0, sizeof(MmsTimeStruct));
+       pAttrib->msgClass = MMS_MSGCLASS_PERSONAL;
+       pAttrib->msgStatus = MSG_DELIVERY_REPORT_NONE;
+       pAttrib->priority = MMS_PRIORITY_NORMAL;
+       pAttrib->responseStatus = MMS_RESPSTATUS_ERROR;
+       pAttrib->retrieveStatus = MMS_RETRSTATUS_ERROR;
+       pAttrib->contentType = MIME_UNKNOWN;
+       pAttrib->msgSize = 0;
+       pAttrib->bLeaveCopy = true;
+
+       pAttrib->specialMsgType = MMS_SPECIAL_MSG_TYPE_NONE;
+#ifdef __SUPPORT_DRM__
+       pAttrib->drmType = MSG_DRM_TYPE_NONE;
+       pAttrib->roWaitingTimerMax = 0;
+       pAttrib->pszDrmData = NULL;
+#endif
+       pAttrib->version = MMS_VERSION;
+
+       memset(pAttrib->szFrom, 0, MSG_LOCALE_ADDR_LEN + 10);
+       memset(pAttrib->szResponseText, 0, MMS_LOCALE_RESP_TEXT_LEN + 1);
+       memset(pAttrib->szRetrieveText, 0, MMS_LOCALE_RESP_TEXT_LEN + 1);
+       memset(pAttrib->szSubject, 0, MSG_LOCALE_SUBJ_LEN + 1);
+       pAttrib->szTo = NULL;
+       pAttrib->szCc = NULL;
+       pAttrib->szBcc = NULL;
+
+       pAttrib->pMultiStatus = NULL;
+
+       pAttrib->replyCharge.chargeType = MMS_REPLY_NONE;
+       memset(&pAttrib->replyCharge.deadLine , 0, sizeof(MmsTimeStruct));
+       pAttrib->replyCharge.chargeSize = 0;
+       memset(pAttrib->replyCharge.szChargeID, 0, MMS_MSG_ID_LEN);
+
+       return true;
+}
+
+bool MmsInitMsgType(MsgType *pMsgType)
+{
+       MSG_DEBUG("MmsInitMsgType");
+       pMsgType->offset = 0;
+       pMsgType->size = 0;
+       pMsgType->contentSize = 0;
+       pMsgType->disposition = -1;
+       pMsgType->encoding = -1;
+       pMsgType->type = MIME_UNKNOWN;
+       pMsgType->section = -1;
+
+       pMsgType->szOrgFilePath[0] = '\0';
+       pMsgType->szContentID[0] = '\0';
+       pMsgType->szContentLocation[0] = '\0';
+
+       pMsgType->szContentRepPos[0] = '\0';
+       pMsgType->szContentRepSize[0] = '\0';
+       pMsgType->szContentRepIndex[0] = '\0';
+
+       MmsInitMsgContentParam(&pMsgType->param);
+#ifdef __SUPPORT_DRM__
+       __MsgInitMsgDRMInfo(&pMsgType->drmInfo);
+#endif
+
+       return true;
+}
+
+bool MmsInitMsgBody(MsgBody *pMsgBody)
+{
+       MSG_DEBUG("MmsInitMsgBody");
+       pMsgBody->offset = 0;
+       pMsgBody->size = 0;
+       pMsgBody->body.pText = NULL;
+
+       MmsInitMsgType(&pMsgBody->presentationType);
+       pMsgBody->pPresentationBody = NULL;
+
+       memset(pMsgBody->szOrgFilePath, 0, MSG_FILEPATH_LEN_MAX);
+
+       return true;
+}
+
+bool MmsInitMsgContentParam(MsgContentParam *pMsgContentParam)
+{
+       MSG_DEBUG("MmsInitMsgContentParam");
+       pMsgContentParam->charset = MSG_CHARSET_UNKNOWN;
+       pMsgContentParam->type = MIME_UNKNOWN;
+       pMsgContentParam->szBoundary[0] = '\0';
+       pMsgContentParam->szFileName[0] = '\0';
+       pMsgContentParam->szName[0] = '\0';
+       pMsgContentParam->szStart[0] = '\0';
+       pMsgContentParam->szStartInfo[0] = '\0';
+       pMsgContentParam->pPresentation = NULL;
+       pMsgContentParam->reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; // only used as parameter of Content-Type: multipart/report; report-type
+#ifdef FEATURE_JAVA_MMS
+       pMsgContentParam->szApplicationID = NULL;
+       pMsgContentParam->szReplyToApplicationID = NULL;
+#endif
+       return true;
+}
+
+bool MmsSetMsgAddressList(MmsAttrib *pAttrib, const MSG_MESSAGE_INFO_S * pMsgInfo)
+{
+       MSG_DEBUG("MmsSetMsgAddressList");
+       pAttrib->szTo = MmsComposeAddress(pMsgInfo, MSG_RECIPIENTS_TYPE_TO);
+       MSG_DEBUG("To address: %s", pAttrib->szTo);
+       pAttrib->szCc = MmsComposeAddress(pMsgInfo, MSG_RECIPIENTS_TYPE_CC);
+       MSG_DEBUG("Cc address: %s", pAttrib->szCc);
+       pAttrib->szBcc = MmsComposeAddress(pMsgInfo, MSG_RECIPIENTS_TYPE_BCC);
+       MSG_DEBUG("Bcc address: %s", pAttrib->szBcc);
+
+       return true;
+}
+
+void MmsSetMsgMultiStatus(MmsAttrib *pAttrib, const MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       int     nAddressCnt = 0;
+
+       nAddressCnt = pMsgInfo->nAddressCnt;
+
+       for (int i = 0; i < nAddressCnt; ++i) {
+               pAttrib->pMultiStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus));
+
+               memset(pAttrib->pMultiStatus->szTo, 0, MAX_ADDRESS_VAL_LEN + 1);
+               strncpy(pAttrib->pMultiStatus->szTo, pMsgInfo->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN);
+
+               MSG_DEBUG("### pMultistatus->szTo = %s ####", pAttrib->pMultiStatus->szTo);
+               pAttrib->pMultiStatus->bDeliveryReportIsRead = false;
+               pAttrib->pMultiStatus->bDeliveyrReportIsLast = false;
+               pAttrib->pMultiStatus->msgStatus = MMS_MSGSTATUS_NONE;
+               pAttrib->pMultiStatus->handledTime = 0;
+               pAttrib->pMultiStatus->bReadReplyIsRead = false;
+               pAttrib->pMultiStatus->bReadReplyIsLast = false;
+               pAttrib->pMultiStatus->readStatus = MMS_READSTATUS_NONE;
+               pAttrib->pMultiStatus->readTime = 0;
+
+               pAttrib->pMultiStatus = pAttrib->pMultiStatus->pNext;
+       }
+}
+
+char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType)
+{
+       MSG_DEBUG("MmsComposeAddress");
+       int     addrLen = 0;
+       int     nAddressCnt = 0;
+       int nRecpCnt = 0;
+       char pString[MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3] = {0, };
+       char *szCompose;
+
+       nAddressCnt = pMsgInfo->nAddressCnt;
+
+       // Calculate allocated buffer size
+       for (int i = 0; i < nAddressCnt; ++i) {
+               MSG_DEBUG("recipientType: %d, address value: %s", pMsgInfo->addressList[i].recipientType, pMsgInfo->addressList[i].addressVal);
+               if (pMsgInfo->addressList[i].recipientType == recipientType) {
+                       if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_PLMN) {
+                               addrLen += strlen(MsgGetString(MSG_ADDR_TYPE, MSG_ADDR_TYPE_PHONE));
+                               addrLen += strlen(pMsgInfo->addressList[i].addressVal);
+                       } else if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_EMAIL) {
+                               addrLen += strlen(pMsgInfo->addressList[i].addressVal);
+                       } else
+                               ; // Need to consider IPV4, IPV6, and Alias formatted address
+
+                       nRecpCnt++;
+               }
+       }
+
+       if (nRecpCnt > 1)
+               addrLen = addrLen + nRecpCnt - 1;
+       szCompose = (char *)calloc(addrLen + 1, 1);
+
+       // Address String copy
+       for (int i = 0; i < nAddressCnt; ++i) {
+               if (pMsgInfo->addressList[i].recipientType == recipientType) {
+                       if (strlen(szCompose) > 0)
+                               strcat(szCompose, MSG_STR_ADDR_DELIMETER);
+
+                       memset(pString, 0x00, (MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3) * sizeof(char));
+                       if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_PLMN) {
+                               snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s%s", pMsgInfo->addressList[i].addressVal, MsgGetString(MSG_ADDR_TYPE, MSG_ADDR_TYPE_PHONE));
+                               MSG_DEBUG("%s", pString);
+                       } else if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_EMAIL) {
+                               snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s", pMsgInfo->addressList[i].addressVal);
+                       } else
+                               ; // Need to consider IPV4, IPV6, and Alias formatted address
+
+                       strcat(szCompose, pString);
+               }
+       }
+
+       return szCompose;
+}
+
+
+bool MmsGetMsgBodyfromMsgInfo(const MSG_MESSAGE_INFO_S *pMsgInfo, MMS_MESSAGE_DATA_S *pMsgBody, char *pFileData)
+{
+       MSG_DEBUG("MmsGetMsgBodyfromMsgInfo");
+       memset(pMsgBody, 0, sizeof(MMS_MESSAGE_DATA_S));
+
+       if (pMsgInfo->bTextSms == false) {       //if  the message body was stored in file.
+               _MsgMmsDeserializeMessageData(pMsgBody, pFileData);
+       }
+
+       return true;
+}
+
+int MmsGetSmilRawData(MMS_MESSAGE_DATA_S *pMsgBody, char **pRawdata)
+{
+       MSG_BEGIN();
+
+       if (MsgReadSmilFile(pMsgBody->szSmilFilePath, pRawdata) < 0)
+               return false;
+
+       MsgDeleteSmilFile(pMsgBody->szSmilFilePath);
+
+       MSG_END();
+
+       return true;
+}
+
+
+bool MmsInsertPresentation(MmsMsg *pMsg, MsgContentType mimeType, char *pData, int size)
+{
+       MSG_DEBUG("MmsInsertPresentation");
+
+       if (pMsg == NULL) {
+               MSG_DEBUG("pMsg is NULL");
+               return false;
+       }
+
+       if (pMsg->msgBody.pPresentationBody != NULL)
+               goto __CATCH;
+
+       memset(&pMsg->msgBody.presentationType, 0, sizeof(MsgType));
+       pMsg->msgBody.pPresentationBody = (MsgBody *)malloc(sizeof(MsgBody));
+       if (pMsg->msgBody.pPresentationBody == NULL)
+               goto __CATCH;
+
+       MmsInitMsgBody(pMsg->msgBody.pPresentationBody);
+
+       pMsg->msgBody.pPresentationBody->body.pText = (char *)malloc(size + 1);
+       if (pMsg->msgBody.pPresentationBody->body.pText == NULL)
+               goto __CATCH;
+
+       pMsg->msgBody.pPresentationBody->size = size;
+       pMsg->msgBody.presentationType.type = mimeType;
+       pMsg->msgBody.presentationType.param.charset = MSG_CHARSET_UTF8;
+       snprintf(pMsg->msgBody.presentationType.szContentID, MSG_MSG_ID_LEN + 1, "<_S_>");
+
+       snprintf(pMsg->msgType.param.szStart, MSG_MSG_ID_LEN + 1, pMsg->msgBody.presentationType.szContentID);
+       pMsg->msgType.param.type = mimeType;
+
+       memset(pMsg->msgBody.pPresentationBody->body.pText, 0, size + 1);
+       strncpy(pMsg->msgBody.pPresentationBody->body.pText, pData, size);
+
+       return true;
+
+__CATCH:
+
+       if (pMsg->msgBody.pPresentationBody != NULL) {
+               if (pMsg->msgBody.pPresentationBody->body.pText != NULL) {
+                       free(pMsg->msgBody.pPresentationBody->body.pText);
+                       pMsg->msgBody.pPresentationBody->body.pText = NULL;
+               }
+
+               free(pMsg->msgBody.pPresentationBody);
+               pMsg->msgBody.pPresentationBody = NULL;
+       }
+
+       return false;
+}
+
+
+bool MmsInsertPartFromFile(MmsMsg *pMsg, char *szTitleName, char *szOrgFilePath, char *szContentID)
+{
+       MSG_DEBUG("MmsInsertPartFromFile");
+
+       MsgMultipart *pMultipart = NULL;
+       MsgMultipart *pLastPart = NULL;
+       int nFileSize;
+       MsgContentType mimeType = MIME_UNKNOWN;
+       char *pExt = NULL;
+
+       pExt = strrchr(szOrgFilePath, '.');
+
+       if (pExt == NULL || pExt[0] == '\0' || strrchr(pExt, '/'))
+               mimeType = MIME_UNKNOWN;
+       else {
+               if (strcasecmp(pExt, ".dcf") == 0)
+                       mimeType = MIME_APPLICATION_VND_OMA_DRM_CONTENT;
+               else {
+                       if (MmsGetTypeByFileName((int *)&mimeType, szOrgFilePath) == false)
+                               goto __CATCH;
+               }
+       }
+
+       if (mimeType == MIME_UNKNOWN)
+               mimeType = MIME_APPLICATION_OCTET_STREAM;
+
+       if (MmsIsMultipart(pMsg->msgType.type) == true) {
+               /* Insert as a multipart */
+               if (MsgGetFileSize(szOrgFilePath, &nFileSize) == false) {
+                       MSG_DEBUG("MsgGetFileSize: failed");
+                       goto __CATCH;
+               }
+
+               pMultipart = MmsMakeMultipart(mimeType, szTitleName, szOrgFilePath, NULL, 0, nFileSize, szContentID);
+               if (pMultipart == NULL)
+                       goto __CATCH;
+
+               if (pMsg->mmsAttrib.contentType == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED ||
+                       pMsg->mmsAttrib.contentType == MIME_MULTIPART_MIXED)
+                       pMultipart->type.disposition = MSG_DISPOSITION_ATTACHMENT;
+
+               if (pMsg->msgBody.body.pMultipart == NULL) {
+                       pMsg->msgBody.body.pMultipart = pMultipart;
+               } else {
+                       pLastPart = pMsg->msgBody.body.pMultipart;
+                       while (pLastPart->pNext) {
+                               pLastPart = pLastPart->pNext;
+                       }
+
+                       pLastPart->pNext = pMultipart;
+               }
+
+               pMsg->msgBody.size += pMultipart->pBody->size;
+               pMsg->msgType.contentSize += pMultipart->pBody->size;
+       } else {
+               /* Single part - Insert as a message body */
+               if (pMsg->mmsAttrib.contentType != mimeType || pMsg->msgType.type != mimeType)
+                       goto __CATCH;
+
+               strncpy(pMsg->msgType.param.szName, szTitleName, MSG_LOCALE_FILENAME_LEN_MAX);
+
+               if (MmsIsText(pMsg->msgType.type) == true) {
+                       pMsg->msgType.param.charset = MSG_CHARSET_UTF8;
+                       if (pMultipart)
+                               pMultipart->type.encoding       = MSG_ENCODING_8BIT;
+               } else {
+                       if (pMultipart)
+                               pMultipart->type.encoding       = MSG_ENCODING_BINARY;
+               }
+
+               strncpy(pMsg->msgBody.szOrgFilePath, szOrgFilePath, MSG_FILEPATH_LEN_MAX - 1);
+               if (MsgGetFileSize(szOrgFilePath, &nFileSize) == false) {
+                       MSG_DEBUG("MsgGetFileSize: failed");
+                       goto __CATCH;
+               }
+
+               pMsg->msgBody.offset = 0;
+               pMsg->msgBody.size = nFileSize;
+               pMsg->msgType.contentSize = nFileSize;
+       }
+
+       pMsg->nPartCount++;
+
+       return true;
+
+__CATCH:
+       return false;
+
+}
+
+bool MmsIsMultipart(int type)
+{
+       MSG_DEBUG("MmsIsMultipart");
+       if (type == MIME_MULTIPART_RELATED ||
+               type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED ||
+               type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED ||
+               type == MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC ||
+               type == MIME_MULTIPART_MIXED ||
+               type == MIME_MULTIPART_REPORT) {
+               return true;
+       } else {
+               return false;
+       }
+}
+
+bool MmsIsText(int type)
+{
+       if (type == MIME_TEXT_PLAIN ||
+               type == MIME_TEXT_HTML ||
+               type == MIME_TEXT_VND_WAP_WML ||
+               type == MIME_TEXT_X_VCARD ||
+               type == MIME_TEXT_X_VCALENDAR ||
+               type == MIME_TEXT_X_VNOTE ||
+               type == MIME_APPLICATION_SMIL ||
+               type == MIME_TEXT_X_IMELODY) {
+               MSG_DEBUG("MmsIsText true.");
+               return true;
+       } else {
+               MSG_DEBUG("MmsIsText false.");
+               return false;
+       }
+}
+
+bool MmsIsVitemContent (int type, char *pszName)
+{
+       switch (type) {
+
+/*
+*      To make Encoding information right.
+*              case MIME_TEXT_X_VCARD :
+*              case MIME_TEXT_X_VCALENDAR :
+*              case MIME_TEXT_X_VNOTE :        // vnt
+*              {
+*                      MSG_DEBUG("MmsIsVitemContent true.");
+*                      return true;
+*              }
+*
+*/
+       case MIME_TEXT_X_VCARD:
+       case MIME_TEXT_X_VCALENDAR:
+       case MIME_TEXT_X_VNOTE: // vnt
+       case MIME_TEXT_PLAIN:           // vbm - It SHOULD be distinguished from a normal text file.
+               {
+                       char *pszExt = NULL;
+
+                       if (!pszName)
+                               break;
+
+                       // search file extension.
+                       if ((pszExt = strrchr(pszName, '.')) == NULL)
+                               break;
+
+                       if (!strcasecmp(pszExt, ".vbm")) {
+                               MSG_DEBUG("MmsIsVitemContent true.");
+                               return true;
+                       }
+               }
+               break;
+
+       default:
+               break;
+       }
+
+       MSG_DEBUG("MmsIsVitemContent false.");
+       return false;
+}
+
+bool _MsgIsASCII(char *pszText)
+{
+       int length = strlen(pszText);
+
+       for (int i = 0; i < length; ++i) {
+               if (!isascii(pszText[i])) {
+                       MSG_DEBUG("_MsgIsASCII false.");
+                       return false;
+               }
+       }
+
+       MSG_DEBUG("_MsgIsASCII true.");
+       return true;
+}
+
+
+bool _MsgReplaceNonAscii(char *szInText, char **szOutText, char replaceChar)
+{
+       MSG_DEBUG("_MsgReplaceNonAscii");
+       int nCount = 0;
+       int index = 0;
+       int cLen = 0;
+       char *pNew = NULL;
+
+       cLen = strlen(szInText);
+
+       pNew = (char *)malloc(cLen + 1);
+
+       if (pNew == NULL)
+               return false;
+
+       memset(pNew, 0, cLen + 1);
+
+       while (*(szInText+nCount) != '\0') {
+               if (0x0001 <= *(szInText+nCount) && *(szInText+nCount) <= 0x007F) {
+                       MSG_DEBUG("_MsgReplaceNonAscii: non ascii characters (1bytes). \n");
+                       pNew[index] = szInText[nCount];
+                       nCount += 1;
+                       index += 1;
+               } else {
+                       MSG_DEBUG("_MsgReplaceNonAscii: UTF-8 characters (2bytes). \n");
+                       pNew[index] = replaceChar;
+                       nCount += 1;
+                       index +=1;
+               }
+       }
+
+       *szOutText = pNew;
+       return true;
+}
+
+bool _MsgIsSpace(char *pszText)
+{
+       MSG_DEBUG("_MsgIsSpace");
+       if (!pszText) {
+               MSG_DEBUG("_MsgIsSpace: pszText == NULL!\n");
+               return false;
+       }
+
+       if (strchr(pszText, ' ') != NULL)
+               return true;
+       else
+               return false;
+}
+
+bool _MsgReplaceSpecialChar(char *szInText, char **szOutText, char specialChar)
+{
+       MSG_DEBUG("_MsgReplaceSpecialChar");
+       char *pszOutText = NULL;
+       char szBuf[10] = {0, };
+       char temp[5] = {0, };
+       int cLen = 0;
+       int i = 0;
+
+       if (!szInText) {
+               MSG_DEBUG("_MsgReplaceSpecialChar: szInText == NULL! \n");
+               return false;
+       }
+
+       if (!szOutText)
+               return false;
+
+       cLen = strlen(szInText);
+
+       if (specialChar == ' ') {
+               if ((pszOutText = (char *)malloc(cLen + 1)) == NULL) {
+                       MSG_DEBUG("_MsgReplaceSpecialChar : %d line. MemAlloc failed.\n", __LINE__);
+                       return false;
+               }
+               memset(pszOutText, 0, cLen + 1);
+
+               *szOutText = pszOutText;
+       }
+
+       for (i = 0; i<cLen; i++) {
+               switch (specialChar) {
+               // changed space to '_'
+               case ' ':
+                       pszOutText[i] = (szInText[i] == specialChar) ? '_' : szInText[i];
+                       break;
+
+               default:
+                       if (szInText[i] != specialChar) {
+                               temp[0] = szInText[i];
+                               *szOutText = MsgStrAppend(*szOutText, temp);
+                               continue;
+                       } else {
+                               _MsgConvertCharToHex(specialChar, szBuf);
+                               *szOutText = MsgStrAppend(*szOutText, (char *)"%");
+                               *szOutText = MsgStrAppend(*szOutText, szBuf);
+                       }
+                       break;
+               }
+       }
+
+       MSG_DEBUG("_MsgReplaceSpecialChar : output text : [%s]\n", pszOutText);
+
+       return true;
+}
+
+char *MsgStrAppend(char *szInputStr1, char *szInputStr2)
+{
+       MSG_DEBUG("MsgStrAppend");
+       char *szOutputStr = NULL;
+
+       if (szInputStr1 == NULL) {
+               szOutputStr = MsgStrCopy(szInputStr2);
+       } else {
+               int length1 = 0;
+               int length2 = 0;
+               length1 = MsgStrlen(szInputStr1);
+               length2 = MsgStrlen(szInputStr2);
+
+               szOutputStr = (char *)malloc(length1 + length2 + 1);
+
+               if (szOutputStr == NULL)
+                       goto __CATCH;
+
+               memset(szOutputStr, 0, length1 + length2 + 1);
+
+               strncpy(szOutputStr, szInputStr1, length1);
+
+               if (length2 > 0)
+                       strcat(szOutputStr, szInputStr2);
+
+               free(szInputStr1);
+               szInputStr1 = NULL;
+       }
+
+       return szOutputStr;
+
+__CATCH:
+       return NULL;
+}
+
+char *MsgStrCopy(const char *string)
+{
+       char *pDst = NULL;
+
+       if (string) {
+               pDst = (char *)malloc(1 + strlen(string));
+               if (pDst == NULL) {
+                       MSG_DEBUG("MsgStrCopy: pDst MemAlloc Fail \n");
+                       return NULL;
+               }
+
+               memset(pDst, 0, strlen(string) + 1);
+
+               strcpy(pDst,string);
+
+               return pDst;
+       }
+
+       return NULL;
+}
+
+char *MsgStrNCopy(const char *string, int length)
+{
+       char *pDst = NULL;
+
+       if (string) {
+               pDst = (char *)malloc(1 + length);
+               if (pDst == NULL) {
+                       MSG_DEBUG("MsgStrNCopy: pDst MemAlloc Fail \n");
+                       return NULL;
+               }
+
+               memset(pDst, 0, length + 1);
+               strncpy(pDst,string, length);
+
+               return pDst;
+       }
+
+       return NULL;
+}
+
+int MsgStrlen(char * pStr)
+{
+       if (pStr == NULL)
+               return 0;
+
+       return strlen(pStr);
+}
+
+bool _MsgConvertCharToHex(char pSrc, char *pDest)
+{
+       static unsigned char saucHex[] = "0123456789ABCDEF";
+
+       pDest[0] = saucHex[pSrc >> 4];
+       pDest[1] = saucHex[pSrc & 0xF];
+       pDest[2] = 0;
+
+       return true;
+}
+
+MsgMultipart *MmsAllocMultipart(void)
+{
+       MsgMultipart *pMultipart = NULL;
+
+       pMultipart = (MsgMultipart *)malloc(sizeof(MsgMultipart));
+
+       if (pMultipart == NULL)
+               goto __CATCH;
+
+       pMultipart->pBody = (MsgBody *)malloc(sizeof(MsgBody));
+
+       if (pMultipart == NULL)
+               goto __CATCH;
+
+       MmsInitMsgType(&pMultipart->type);
+       MmsInitMsgBody(pMultipart->pBody);
+
+       pMultipart->pNext = NULL;
+
+       return pMultipart;
+
+__CATCH:
+
+       if (pMultipart) {
+               if (pMultipart->pBody) {
+                       free(pMultipart->pBody);
+                       pMultipart->pBody = NULL;
+               }
+
+               free(pMultipart);
+               pMultipart = NULL;
+       }
+
+       return NULL;
+}
+
+
+
+MsgMultipart *MmsMakeMultipart(MsgContentType mimeType, char *szTitleName, char *szOrgFilePath, void *pData, int offset, int size, char *szContentID)
+{
+       MsgMultipart *pMultipart = NULL;
+
+       if ((pMultipart = MmsAllocMultipart()) == NULL)
+               goto __CATCH;
+
+       pMultipart->type.type = mimeType;
+
+       if (szTitleName && szTitleName[0]) {
+               memset(pMultipart->type.param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1);
+               strncpy(pMultipart->type.param.szName, szTitleName, MSG_LOCALE_FILENAME_LEN_MAX);
+       }
+
+       if (szContentID && szContentID[0]) {
+               memset(pMultipart->type.szContentID, 0, MSG_MSG_ID_LEN + 1);
+               snprintf(pMultipart->type.szContentID, MSG_MSG_ID_LEN + 1, "<%s>", szContentID);
+
+               memset(pMultipart->type.szContentLocation, 0, MSG_MSG_ID_LEN + 1);
+               snprintf(pMultipart->type.szContentLocation, MSG_MSG_ID_LEN + 1, "%s", szContentID);
+       }
+
+       if (MmsIsText(mimeType) == true) {
+               if (!MmsIsVitemContent (mimeType, pMultipart->type.param.szName)) {
+                       pMultipart->type.param.charset = MSG_CHARSET_UTF8;
+               }
+               pMultipart->type.encoding = MSG_ENCODING_8BIT;
+       } else {
+               pMultipart->type.encoding = MSG_ENCODING_BINARY;
+       }
+
+       if (szOrgFilePath == NULL) {
+               if (pData != NULL) {
+                       if (MmsIsText(mimeType) == true) {
+                               pMultipart->pBody->body.pText = (char *)malloc(size + 1);
+                               if (pMultipart->pBody->body.pText == NULL)
+                                       goto __CATCH;
+
+                               memset(pMultipart->pBody->body.pText, 0, size + 1);
+                       } else {
+                               pMultipart->pBody->body.pBinary = malloc(size);
+                               if (pMultipart->pBody->body.pBinary == NULL)
+                                       goto __CATCH;
+
+                               memset(pMultipart->pBody->body.pBinary, 0, size);
+                       }
+
+                       memcpy(pMultipart->pBody->body.pBinary, pData, size);
+                       pMultipart->pBody->size = size;
+               }
+       } else {
+               if (szOrgFilePath)
+                       strncpy(pMultipart->pBody->szOrgFilePath, szOrgFilePath, MSG_FILEPATH_LEN_MAX - 1);
+
+               pMultipart->pBody->offset = offset;
+               pMultipart->pBody->size = size;
+       }
+
+       return pMultipart;
+
+__CATCH:
+
+       if (pMultipart) {
+               if (pMultipart->pBody) {
+                       if (pMultipart->pBody->body.pText) {
+                               free(pMultipart->pBody->body.pText);
+                               pMultipart->pBody->body.pText = NULL;
+                       }
+                       free(pMultipart->pBody);
+                       pMultipart->pBody = NULL;
+               }
+               free(pMultipart);
+               pMultipart = NULL;
+       }
+
+       return NULL;
+}
+
+
+bool MmsGetTypeByFileName(int *type, char *szFileName)
+{
+       char *pExt   = NULL;
+       AvCodecType AvType = AV_CODEC_NONE;
+
+       /* AVMS unknown or text/image file format identify type from file extention  */
+
+       pExt = strrchr(szFileName, '.');
+       if (pExt == NULL || pExt[0] == '\0')
+               goto __CATCH;
+
+       pExt++;
+
+       if (strcasecmp(pExt, "mp4") == 0 || strcasecmp(pExt, "mpeg4") == 0 ||
+               strcasecmp(pExt, "3gp") == 0 || strcasecmp(pExt, "3gpp") == 0) {
+               /* Audio / Video format. If file exists already, AvGetFileCodecType() can identify the format  */
+               if (szFileName[0] != '/')
+                       goto __CATCH;
+
+               AvType = AvGetFileCodecType(szFileName);
+
+               switch (AvType) {
+               case AV_DEC_AUDIO_MPEG4:
+                       *type = MIME_AUDIO_MP4;//*type = MIME_AUDIO_3GPP;
+                       break;
+
+               case AV_DEC_VIDEO_MPEG4:
+                       *type = MIME_VIDEO_MP4;
+                       break;
+
+               default:
+                       *type = MIME_VIDEO_3GPP;
+                       break;
+               }
+               return true;
+       }
+
+       if (strcasecmp(pExt, "amr") == 0) {
+               *type = MIME_AUDIO_AMR;
+               return true;
+       } else if ((strcasecmp(pExt, "mid") == 0) || (strcasecmp(pExt, "midi") == 0)) {
+               *type = MIME_AUDIO_MIDI;
+               return true;
+       } else if (strcasecmp(pExt, "imy") == 0) {
+               *type = MIME_TEXT_X_IMELODY;
+               return true;
+       }
+
+       *type = MimeGetMimeFromExtInt((const char *)pExt);
+
+       return true;
+
+__CATCH:
+
+       *type = MIME_UNKNOWN;
+       return false;
+
+}
+
+bool MmsComposeMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMsgData, char *pFileData)
+{
+       MSG_BEGIN();
+
+       char *pRawData = NULL;
+       AutoPtr<char> buf(&pRawData);
+
+       struct tm *timeInfo = NULL;
+       time_t RawTime = 0;
+       time_t nTimeInSecs = 0;
+
+       MSG_ERROR_T     err = MSG_SUCCESS;
+
+       // Initialize mmsMsg structure
+       MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
+       MmsInitMsgType(&pMmsMsg->msgType);
+       MmsInitMsgBody(&pMmsMsg->msgBody);
+
+       // setting mmsMsg structure
+       pMmsMsg->mailbox = pMsgInfo->folderId;
+       pMmsMsg->msgID = pMsgInfo->msgId;
+
+       memset(pMmsMsg->szTrID, 0, MMS_TR_ID_LEN + 1);
+       memset(pMmsMsg->szContentLocation, 0, MMS_LOCATION_LEN + 1);
+       memset(pMmsMsg->szMsgID, 0, MMS_MSG_ID_LEN + 1);
+       memset(pMmsMsg->szForwardMsgID, 0, MMS_MSG_ID_LEN + 1);
+
+       pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_DRAFT;
+
+       MSG_DEBUG("## delivery = %d ##", pSendOptInfo->bDeliverReq);
+       MSG_DEBUG("## read = %d ##", pSendOptInfo->option.mmsSendOptInfo.bReadReq);
+       MSG_DEBUG("## priority = %d ##", pSendOptInfo->option.mmsSendOptInfo.priority);
+       MSG_DEBUG("## expiryTime = %d ##", pSendOptInfo->option.mmsSendOptInfo.expiryTime.time);
+
+       if (pSendOptInfo->bSetting == false) {
+               unsigned int expiryTime;
+               MSG_MMS_DELIVERY_TIME_T deliveryTime;
+
+               pMmsMsg->mmsAttrib.priority = (MmsPriority)MsgSettingGetInt(MMS_SEND_PRIORITY);
+
+               MsgSettingGetBool(MMS_SEND_DELIVERY_REPORT, &pMmsMsg->mmsAttrib.bAskDeliveryReport);
+               MsgSettingGetBool(MMS_SEND_READ_REPLY, &pMmsMsg->mmsAttrib.bAskReadReply);
+               MsgSettingGetBool(MSG_KEEP_COPY, &pMmsMsg->mmsAttrib.bLeaveCopy);
+
+               expiryTime = (unsigned int)MsgSettingGetInt(MMS_SEND_EXPIRY_TIME);
+
+               if (expiryTime == 0)
+                       pMmsMsg->mmsAttrib.expiryTime.type = MMS_TIMETYPE_NONE;
+               else {
+                       pMmsMsg->mmsAttrib.expiryTime.type = MMS_TIMETYPE_RELATIVE;
+                       pMmsMsg->mmsAttrib.expiryTime.time = expiryTime;
+               }
+
+               deliveryTime = (MSG_MMS_DELIVERY_TIME_T)MsgSettingGetInt(MMS_SEND_DELIVERY_TIME);
+
+               if (deliveryTime == MSG_DELIVERY_TIME_CUSTOM) {
+                       pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = true;
+
+                       pMmsMsg->mmsAttrib.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
+                       pMmsMsg->mmsAttrib.deliveryTime.time = (unsigned int)MsgSettingGetInt(MMS_SEND_CUSTOM_DELIVERY);
+               } else {
+                       pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = false;
+
+                       pMmsMsg->mmsAttrib.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
+                       pMmsMsg->mmsAttrib.deliveryTime.time = (unsigned int)deliveryTime;
+               }
+       } else {
+               pMmsMsg->mmsAttrib.priority = (MmsPriority)pSendOptInfo->option.mmsSendOptInfo.priority;
+               pMmsMsg->mmsAttrib.bAskDeliveryReport = pSendOptInfo->bDeliverReq;
+               pMmsMsg->mmsAttrib.bAskReadReply = pSendOptInfo->option.mmsSendOptInfo.bReadReq;
+               pMmsMsg->mmsAttrib.expiryTime.type = pSendOptInfo->option.mmsSendOptInfo.expiryTime.type;
+               pMmsMsg->mmsAttrib.bLeaveCopy = pSendOptInfo->bKeepCopy;
+
+               if (pMmsMsg->mmsAttrib.expiryTime.type != MMS_TIMETYPE_NONE)
+                       pMmsMsg->mmsAttrib.expiryTime.time = pSendOptInfo->option.mmsSendOptInfo.expiryTime.time;
+
+               pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = pSendOptInfo->option.mmsSendOptInfo.bUseDeliveryCustomTime;
+               pMmsMsg->mmsAttrib.deliveryTime.type = pSendOptInfo->option.mmsSendOptInfo.deliveryTime.type;
+               pMmsMsg->mmsAttrib.deliveryTime.time = pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time;
+       }
+
+       MSG_DEBUG("pSendOptInfo->bSetting = %d", pSendOptInfo->bSetting);
+       MSG_DEBUG("pMmsMsg->mmsAttrib.bLeaveCopy = %d", pMmsMsg->mmsAttrib.bLeaveCopy);
+       MSG_DEBUG("pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = %d", pMmsMsg->mmsAttrib.bUseDeliveryCustomTime);
+       MSG_DEBUG("pMmsMsg->mmsAttrib.deliveryTime.type = %d", pMmsMsg->mmsAttrib.deliveryTime.type);
+       MSG_DEBUG("pMmsMsg->mmsAttrib.deliveryTime.time = %d", pMmsMsg->mmsAttrib.deliveryTime.time);
+
+       /* MMS-1.3-con-739 */
+       pMmsMsg->mmsAttrib.msgClass = (MmsMsgClass)MsgSettingGetInt(MMS_SEND_MSG_CLASS);
+       /* MMS-1.3-con-739 */
+#ifdef MMS_13_CON_742_ENABLED
+       /* MMS-1.3-con-742 */
+       pMmsMsg->mmsAttrib.deliveryTime.time = (unsigned int)MsgSettingGetInt(MMS_SEND_DELIVERY_TIME);
+       /* MMS-1.3-con-742 */
+#endif
+
+       MSG_DEBUG("@@@ pMmsMsg->mmsAttrib.bAskDeliveryReport = %d @@@", pMmsMsg->mmsAttrib.bAskDeliveryReport);
+       MSG_DEBUG("@@@ pMmsMsg->mmsAttrib.bAskReadReply = %d @@@", pMmsMsg->mmsAttrib.bAskReadReply);
+       MSG_DEBUG("@@@ pMmsMsg->mmsAttrib.priority = %d @@@", pMmsMsg->mmsAttrib.priority);
+
+       // setting date
+       time(&RawTime);
+       timeInfo = localtime(&RawTime);
+       nTimeInSecs = mktime(timeInfo);
+       pMmsMsg->mmsAttrib.date = nTimeInSecs;  // todo: need to subtract timeline value to make GMT+0 time
+
+       //setting subject
+       strcpy(pMmsMsg->mmsAttrib.szSubject, pMsgInfo->subject);
+
+       //setting adddress
+       MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo);
+       MmsGetMsgBodyfromMsgInfo(pMsgInfo, pMsgData, pFileData);
+
+       int pageCnt = _MsgMmsGetPageCount(pMsgData);
+
+       if (pageCnt == 0) {     // Multipart mixed
+               pMmsMsg->mmsAttrib.contentType = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED;
+               pMmsMsg->msgType.type = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED;
+       } else {        // Multipart related
+
+               int RawDataSize = 0;
+
+               time_t RawTime = 0;
+               time(&RawTime);
+               snprintf(pMsgData->szSmilFilePath, MSG_FILEPATH_LEN_MAX, "%lu", RawTime);
+
+               MsgMMSCreateSMIL(pMsgData);
+
+               RawDataSize = MmsGetSmilRawData(pMsgData, &pRawData);
+               if (RawDataSize < 0) {
+                       MSG_DEBUG("Smil file size is less than 0");
+                       return false;
+               }
+               MSG_DEBUG("%s", pRawData);
+               if (pRawData)
+                       MmsInsertPresentation(pMmsMsg, MIME_APPLICATION_SMIL, pRawData, strlen(pRawData));
+
+               pMmsMsg->mmsAttrib.contentType = MIME_APPLICATION_VND_WAP_MULTIPART_RELATED;
+               pMmsMsg->msgType.type = MIME_APPLICATION_VND_WAP_MULTIPART_RELATED;
+
+               for (int i = 0; i < pageCnt; ++i) {
+                       MMS_PAGE_S *pPage = _MsgMmsGetPage(pMsgData, i);
+                       int mediaCnt = pPage->mediaCnt;
+                       MSG_DEBUG("PAGE %d's media Cnt: %d", i+1, mediaCnt);
+
+                       for (int j = 0; j < mediaCnt; ++j) {
+                               MMS_MEDIA_S *pMedia = _MsgMmsGetMedia(pPage, j);
+
+                               switch (pMedia->mediatype) {
+                               case MMS_SMIL_MEDIA_IMG:
+                               case MMS_SMIL_MEDIA_VIDEO:
+                               case MMS_SMIL_MEDIA_AUDIO:
+                               case MMS_SMIL_MEDIA_TEXT:
+                                       if (pMedia->szFilePath[0] != 0) {
+                                               if (!MmsInsertPartFromFile(pMmsMsg, pMedia->szFileName, pMedia->szFilePath, pMedia->szContentID))
+                                                       return false;
+                                       }
+                                       break;
+
+                               default:
+                                       break;
+                               }
+                       }
+               }
+
+               char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, };;
+               snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%d.mms", pMsgInfo->msgId);
+
+               MmsPluginStorage *pStorage = MmsPluginStorage::instance();
+               err = pStorage->getMsgText(pMsgData, pMsgInfo->msgText);
+               err = pStorage->makeThumbnail(pMsgData, pMsgInfo->thumbPath, szFileName);
+       }
+
+#ifdef FEATURE_JAVA_MMS
+       MSG_DEBUG("msgAppId: valid:%d appId:%s replyToAppId:%s", pMsgData->msgAppId.valid, pMsgData->msgAppId.appId, pMsgData->msgAppId.replyToAppId);
+       if (pMsgData->msgAppId.valid) { // check if msgAppId.valid is true, both appId and replytoappId must have a meaning data
+               if (pMsgData->msgAppId.appId[0] != 0) {
+                       pMmsMsg->msgType.param.szApplicationID = (char *)malloc(strlen(pMsgData->msgAppId.appId) + 1);
+                       if (pMmsMsg->msgType.param.szApplicationID == NULL) {
+                               MSG_DEBUG("Error: out of Memory");
+                               return false;
+                       }
+                       memset(pMmsMsg->msgType.param.szApplicationID, 0, strlen(pMsgData->msgAppId.appId) + 1);
+
+                       strcpy(pMmsMsg->msgType.param.szApplicationID, pMsgData->msgAppId.appId);
+               }
+
+               if (pMsgData->msgAppId.replyToAppId[0] != 0) {
+                       pMmsMsg->msgType.param.szReplyToApplicationID = (char *)malloc(strlen(pMsgData->msgAppId.replyToAppId) + 1);
+                       if (pMmsMsg->msgType.param.szReplyToApplicationID == NULL) {
+                               MSG_DEBUG("Error: out of Memory");
+                               return false;
+                       }
+                       memset(pMmsMsg->msgType.param.szReplyToApplicationID, 0, strlen(pMsgData->msgAppId.replyToAppId) + 1);
+
+                       strcpy(pMmsMsg->msgType.param.szReplyToApplicationID, pMsgData->msgAppId.replyToAppId);
+               }
+       }
+#endif
+
+       //Processing Attachment List
+       for (int i = 0; i < _MsgMmsGetAttachCount(pMsgData); ++i) {
+               MMS_ATTACH_S *pMedia = _MsgMmsGetAttachment(pMsgData, i);
+               if (pMedia->szFilePath[0] != 0) {
+                       if (!MmsInsertPartFromFile(pMmsMsg, pMedia->szFileName, pMedia->szFilePath, NULL))
+                               return false;
+               }
+       }
+
+       return true;
+}
+
+void MmsComposeNotiMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_ID_T msgID)
+{
+       MSG_BEGIN();
+
+       struct tm *timeInfo = NULL;
+       time_t RawTime = 0;
+       time_t nTimeInSecs = 0;
+
+       MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
+       MmsInitMsgType(&pMmsMsg->msgType);
+       MmsInitMsgBody(&pMmsMsg->msgBody);
+
+       pMmsMsg->msgID = msgID;
+
+       pMmsMsg->mmsAttrib.version = mmsHeader.version;
+
+       // setting date
+       time(&RawTime);
+       timeInfo = localtime(&RawTime);
+       nTimeInSecs = mktime(timeInfo);
+       pMmsMsg->mmsAttrib.date = nTimeInSecs;
+
+       pMmsMsg->mmsAttrib.bReportAllowed = mmsHeader.reportAllowed;
+       pMmsMsg->mmsAttrib.bAskDeliveryReport = mmsHeader.deliveryReport;
+
+       MSG_DEBUG("######## Version = %d ########", pMmsMsg->mmsAttrib.version);
+
+       strncpy(pMmsMsg->szTrID, mmsHeader.szTrID, MMS_TR_ID_LEN);
+       strncpy(pMmsMsg->szMsgID, mmsHeader.szMsgID, MMS_MSG_ID_LEN);
+       pMmsMsg->szForwardMsgID[0] = '\0';
+
+       if (mmsHeader.pFrom) {
+               MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr );
+               strncpy(pMmsMsg->mmsAttrib.szFrom, mmsHeader.pFrom->szAddr, MSG_LOCALE_ADDR_LEN + 9);
+       }
+
+       strncpy(pMmsMsg->mmsAttrib.szSubject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
+       strncpy(pMmsMsg->szContentLocation, mmsHeader.szContentLocation, MMS_LOCATION_LEN);
+
+       pMmsMsg->mmsAttrib.msgClass = mmsHeader.msgClass;
+       pMmsMsg->mmsAttrib.msgSize = mmsHeader.msgSize;
+       pMmsMsg->mmsAttrib.expiryTime.type = mmsHeader.expiryTime.type;
+       pMmsMsg->mmsAttrib.expiryTime.time = mmsHeader.expiryTime.time;
+       pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_NOTIFY;
+       pMmsMsg->mmsAttrib.bRead = false;
+       pMmsMsg->mailbox = MSG_INBOX_ID;
+
+       pMmsMsg->mmsAttrib.replyCharge.chargeType = mmsHeader.replyCharge.chargeType;
+       pMmsMsg->mmsAttrib.replyCharge.deadLine.type = mmsHeader.replyCharge.deadLine.type;
+       pMmsMsg->mmsAttrib.replyCharge.deadLine.time = mmsHeader.replyCharge.deadLine.time;
+       pMmsMsg->mmsAttrib.replyCharge.chargeSize = mmsHeader.replyCharge.chargeSize;
+
+       strncpy(pMmsMsg->mmsAttrib.replyCharge.szChargeID, mmsHeader.replyCharge.szChargeID, MMS_MSG_ID_LEN);
+
+       MSG_END();
+}
+
+bool MmsGetMmsMessageBody(MmsMsg *pMmsMsg, char *retrievedFilePath)
+{
+       FILE *pFile     = NULL;
+       MsgMultipart *pMultipart = NULL;
+       int attachmax = MSG_ATTACH_MAX;
+       int nSize = 0;
+
+       /*      read from MMS raw file  */
+       if (retrievedFilePath)
+               strncpy(pMmsMsg->szFileName, retrievedFilePath + strlen(MSG_DATA_PATH), strlen(retrievedFilePath + strlen(MSG_DATA_PATH)));
+       else
+               goto __CATCH;
+
+       pFile = MsgOpenFile(retrievedFilePath, "rb");
+
+       if (pFile == NULL) {
+               MSG_DEBUG( "_MmsReadMsgBody: invalid mailbox\n");
+               goto __CATCH;
+       }
+
+       if (MsgGetFileSize(retrievedFilePath, &nSize) == false) {
+               MSG_DEBUG("MsgGetFileSize: failed");
+               goto __CATCH;
+       }
+
+       _MmsRegisterDecodeBuffer(gszMmsLoadBuf1,
+                                                         gszMmsLoadBuf2,
+                                                         MSG_MMS_DECODE_BUFFER_MAX);
+
+       if (MmsBinaryDecodeMsgHeader(pFile, nSize) == false) {
+               MSG_DEBUG( "_MmsReadMsgBody: MmsBinaryDecodeMsgHeader fail...\n");
+               goto __CATCH;
+       }
+
+       if (MmsBinaryDecodeMsgBody(pFile, retrievedFilePath, nSize) == false) {
+               MSG_DEBUG( "_MmsReadMsgBody: MmsBinaryDecodeMsgBody fail\n");
+               goto __CATCH;
+       }
+
+       /* Set mmsHeader.msgType & msgBody to pMsg ----------- */
+
+       pMmsMsg->mmsAttrib.contentType = (MsgContentType)mmsHeader.msgType.type;
+
+       memcpy(&(pMmsMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType));
+       memcpy(&(pMmsMsg->msgBody), &(mmsHeader.msgBody), sizeof(MsgBody));
+
+       MSG_DEBUG("#############################");
+       MSG_DEBUG("## pMmsMsg->msgType.type = %d ##", pMmsMsg->msgType.type);
+       MSG_DEBUG("## pMmsMsg->msgType.szContentID = %s ##", pMmsMsg->msgType.szContentID);
+       MSG_DEBUG("## pMmsMsg->msgType.szContentLocation = %s ##", pMmsMsg->msgType.szContentLocation);
+       MSG_DEBUG("#############################");
+
+       if (pMmsMsg->msgBody.pPresentationBody) {
+               if(MsgFseek(pFile, pMmsMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0)
+                       goto __CATCH;
+
+               pMmsMsg->msgBody.pPresentationBody->body.pText = (char *)malloc(pMmsMsg->msgBody.pPresentationBody->size + 1);
+               if (pMmsMsg->msgBody.pPresentationBody->body.pText == NULL)
+                       goto __CATCH;
+
+               memset(pMmsMsg->msgBody.pPresentationBody->body.pText, 0, pMmsMsg->msgBody.pPresentationBody->size + 1);
+               ULONG nRead = 0;
+               nRead = MsgReadFile(pMmsMsg->msgBody.pPresentationBody->body.pText, sizeof(char), pMmsMsg->msgBody.pPresentationBody->size, pFile);
+
+               if (nRead == 0)
+                       goto __CATCH;
+       }
+
+       MsgCloseFile(pFile);
+       pFile = NULL;
+
+       /* nPartCount */
+       pMmsMsg->nPartCount = 0;
+
+       if (MsgIsMultipart(mmsHeader.msgType.type) == true) {
+               pMultipart = pMmsMsg->msgBody.body.pMultipart;
+               while (pMultipart) {
+                       pMmsMsg->nPartCount++;
+
+                       if (pMultipart->type.type == MIME_TEXT_PLAIN)
+                               attachmax++;
+
+                       if ((mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED) ||
+                               (mmsHeader.msgType.type == MIME_MULTIPART_MIXED)) {
+                               if ((pMmsMsg->nPartCount >= attachmax ) && (pMultipart->pNext != NULL)) {
+                                       _MsgFreeBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type);
+
+                                       free(pMultipart->pNext->pBody);
+                                       pMultipart->pNext->pBody = NULL;
+
+                                       free(pMultipart->pNext);
+
+                                       pMultipart->pNext = NULL;
+                                       break;
+                               }
+                       }
+                       pMultipart = pMultipart->pNext;
+               }
+       } else {
+               if (pMmsMsg->msgBody.size > 0)
+                       pMmsMsg->nPartCount++;
+       }
+
+       //call before processing urgent event.
+       _MmsInitHeader();
+       _MmsUnregisterDecodeBuffer();
+
+       return true;
+
+__CATCH:
+
+       _MmsInitHeader();
+       _MmsUnregisterDecodeBuffer();
+
+       if (pFile != NULL) {
+               MsgCloseFile(pFile);
+               pFile = NULL;
+       }
+
+       _MsgFreeBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type);
+       MSG_DEBUG("_MmsReadMsgBody:    E  N  D    ( fail )    ******************** \n");
+
+       return false;
+}
+
+#ifdef MMS_DELIEVERY_IND_ENABLED
+MmsMsgMultiStatus *MmsComposeDeliveryIndMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_ID_T msgId)
+{
+       MmsMsgMultiStatus *pStatus = NULL;
+       MmsMsgMultiStatus *pLastStatus = NULL;
+       bool bFound = false;
+
+       MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
+       MmsInitMsgType(&pMmsMsg->msgType);
+       MmsInitMsgBody(&pMmsMsg->msgBody);
+
+       pMmsMsg->mmsAttrib.version = mmsHeader.version;
+
+       pMmsMsg->mmsAttrib.pMultiStatus = MmsGetMultiStatus(msgId);
+
+       pStatus = pMmsMsg->mmsAttrib.pMultiStatus;
+
+       MSG_DEBUG("### pStatus->szTo = %s ###", pStatus->szTo);
+
+       while (pStatus && !bFound) {
+               MSG_DEBUG("### MmsAddrUtilCompareAddr ###");
+               MSG_DEBUG("### mmsHeader.pTo->szAddr = %s ###", mmsHeader.pTo->szAddr);
+               if (MmsAddrUtilCompareAddr(pStatus->szTo, mmsHeader.pTo->szAddr)) {
+                       bFound = true;
+                       break;
+               }
+
+               pStatus = pStatus->pNext;
+       }
+
+       if (bFound == false) {
+               MSG_DEBUG("### bFound == false ###");
+               /* Queue the delivery report  --------------------------- */
+
+               pStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus));
+               memset(pStatus, 0, sizeof(MmsMsgMultiStatus));
+
+               pStatus->readStatus = MMS_READSTATUS_NONE;
+
+               memset(pStatus->szTo, 0, MSG_ADDR_LEN + 1);
+               strncpy(pStatus->szTo, mmsHeader.pTo->szAddr, MSG_ADDR_LEN);
+
+               if (pMmsMsg->mmsAttrib.pMultiStatus == NULL) {
+                       /* first delivery report */
+                       pMmsMsg->mmsAttrib.pMultiStatus = pStatus;
+               } else {
+                       pLastStatus = pMmsMsg->mmsAttrib.pMultiStatus;
+                       while (pLastStatus->pNext) {
+                               pLastStatus = pLastStatus->pNext;
+                       }
+
+                       pLastStatus->pNext = pStatus;
+                       pLastStatus = pStatus;
+               }
+       }
+
+       pStatus->handledTime = mmsHeader.date;
+       pStatus->msgStatus = mmsHeader.msgStatus;
+       pStatus->bDeliveryReportIsRead = false;
+
+       _MmsDataUpdateLastStatus(pMmsMsg);
+
+       pStatus->bDeliveyrReportIsLast = true;
+
+       return pStatus;
+}
+#endif
+
+void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, MSG_MESSAGE_ID_T selectedMsgId)
+{
+       struct tm *timeInfo = NULL;
+       time_t RawTime = 0;
+       time_t nTimeInSecs = 0;
+
+       MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
+       MmsInitMsgType(&pMmsMsg->msgType);
+       MmsInitMsgBody(&pMmsMsg->msgBody);
+
+       // setting mmsMsg structure
+       pMmsMsg->mailbox = pMsgInfo->folderId;
+       pMmsMsg->msgID = pMsgInfo->msgId;
+
+       memset(pMmsMsg->szTrID, 0, MMS_TR_ID_LEN + 1);
+       memset(pMmsMsg->szContentLocation, 0, MMS_LOCATION_LEN + 1);
+       memset(pMmsMsg->szForwardMsgID, 0, MMS_MSG_ID_LEN + 1);
+
+       pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_DRAFT;
+
+       // setting date
+       time(&RawTime);
+       timeInfo = localtime(&RawTime);
+       nTimeInSecs = mktime(timeInfo);
+       pMmsMsg->mmsAttrib.date = nTimeInSecs;
+
+       // setting szMsgId
+       MmsPluginStorage::instance()->getMmsMessageId(selectedMsgId, pMmsMsg);
+
+       //setting subject
+       strcpy(pMmsMsg->mmsAttrib.szSubject, pMsgInfo->subject);
+
+       //setting adddress
+       MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo);
+
+       if (pMmsMsg->mmsAttrib.szTo)
+               strncpy(pMmsMsg->mmsAttrib.szFrom, pMmsMsg->mmsAttrib.szTo, strlen(pMmsMsg->mmsAttrib.szTo));
+}
+
+int MmsSearchMsgId(char *toNumber, char *szMsgID)
+{
+       MSG_BEGIN();
+
+       int msgId;
+
+       msgId = MmsPluginStorage::instance()->searchMsgId(toNumber, szMsgID);
+
+       if (msgId < 0)
+               return 0;
+
+       MSG_END();
+
+       return msgId;
+}
+
+void MmsUpdateDeliveryReport(MSG_MESSAGE_ID_T msgId, MmsMsgMultiStatus *pStatus)
+{
+       MSG_BEGIN();
+
+       MmsPluginStorage::instance()->updateDeliveryReport(msgId, pStatus);
+
+       MSG_END();
+}
+
+void MmsUpdateReadReport(MSG_MESSAGE_ID_T msgId, MmsMsgMultiStatus *pStatus)
+{
+       MSG_BEGIN();
+
+       MmsPluginStorage::instance()->updateReadReport(msgId, pStatus);
+
+       MSG_END();
+}
+
+MmsMsgMultiStatus *MmsGetMultiStatus(MSG_MESSAGE_ID_T msgId)
+{
+       MmsMsgMultiStatus *pMultiStatus;
+
+       pMultiStatus = MmsPluginStorage::instance()->getMultiStatus(msgId);
+
+       MSG_DEBUG("### szTo = %s ###", pMultiStatus->szTo);
+
+       MSG_END();
+
+       return pMultiStatus;
+}
+
+bool MmsCheckAdditionalMedia(MMS_MESSAGE_DATA_S *pMsgData, MsgType *partHeader)
+{
+       if (_MsgMmsFindMatchedMedia(pMsgData, partHeader->param.szFileName))
+               return false;
+       else
+               return true;
+}
+
+#ifdef __SUPPORT_DRM__
+bool __MsgInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo)
+{
+       pMsgDrmInfo->contentType = MIME_UNKNOWN;
+       pMsgDrmInfo->drmType = MSG_DRM_TYPE_NONE;
+
+       pMsgDrmInfo->szContentName = NULL;
+       pMsgDrmInfo->szContentURI = NULL;
+       pMsgDrmInfo->szContentDescription = NULL;
+       pMsgDrmInfo->szContentVendor = NULL;
+       pMsgDrmInfo->szRightIssuer = NULL;
+       pMsgDrmInfo->szDrm2FullPath = NULL;
+       pMsgDrmInfo->roWaitingTimerMax = 0;
+       pMsgDrmInfo->bFwdLock = false;
+       pMsgDrmInfo->bNoScreen = false;
+       pMsgDrmInfo->bNoRingTone = false;
+       pMsgDrmInfo->pszContentType = NULL;
+
+       return true;
+}
+#endif
diff --git a/plugin/mms_plugin/MmsPluginSMILValidate.cpp b/plugin/mms_plugin/MmsPluginSMILValidate.cpp
new file mode 100755 (executable)
index 0000000..d592da0
--- /dev/null
@@ -0,0 +1,492 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MmsPluginSMILValidate.h"
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MmsPluginSmil.h"
+#include "MsgMmsMessage.h"
+
+#define MSG_RETURN_VAL_IF_FAIL(Expr, Val)                                      \
+               if (!(Expr)) {                                                                          \
+                       MSG_DEBUG("%s:[%s] Failed - %d\n", __FUNCTION__, __LINE__, Val); \
+                       return Val;                                                                             \
+               };
+
+MSG_SMIL_ERR_E MsgMMSCreateSMIL(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       MSG_BEGIN();
+
+       MSG_SMIL_ERR_E eRet = MSG_SMIL_ERR_UNKNOWN;
+       bool bRegAdded = false;
+
+       MSG_RETURN_VAL_IF_FAIL((pMsgData!= NULL), MSG_SMIL_ERR_INVALID_PARAM);
+       MSG_RETURN_VAL_IF_FAIL((strlen(pMsgData->szSmilFilePath)> 0), MSG_SMIL_ERR_INVALID_SMIL_FILE_PATH);
+
+       eRet = _MsgMMSValidateSMILRootLayout(pMsgData);
+       if (eRet != MSG_SMIL_SUCCESS) {
+               MSG_DEBUG("MsgMMSCreateSMIL: Root Layout Information Invalid eRet =%d\n", eRet);
+               return eRet;
+       }
+
+       eRet = _MsgMMSValidateSMILRegion(pMsgData, &bRegAdded);
+       if (eRet != MSG_SMIL_SUCCESS) {
+               MSG_DEBUG("MsgMMSCreateSMIL: Region Information Invalid eRet =%d\n", eRet);
+               return eRet;
+       }
+
+       eRet = _MsgMMSValidateSMILPage(pMsgData, bRegAdded);
+       if (eRet != MSG_SMIL_SUCCESS) {
+               MSG_DEBUG("MsgMMSCreateSMIL: Page Information Invalid eRet =%d\n", eRet);
+               return eRet;
+       }
+
+       if (MMSGenerateSmilBuffer(pMsgData)) {
+               MSG_DEBUG("MsgMMSCreateSMIL: Generate SMIL Buffer is success eRet =%d\n", eRet);
+               eRet = MSG_SMIL_SUCCESS;
+       } else {
+               MSG_DEBUG("MsgMMSCreateSMIL: Generate SMIL Buffer failed eRet =%d\n", eRet);
+               eRet = MSG_SMIL_ERR_UNKNOWN;
+       }
+
+       MSG_END();
+       return eRet;
+}
+
+MSG_SMIL_ERR_E _MsgMMSValidateSMILRootLayout(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       MSG_BEGIN();
+
+       MSG_SMIL_ERR_E eRet = MSG_SMIL_ERR_INVALID_ROOTLAYOUT;
+
+       MSG_RETURN_VAL_IF_FAIL((pMsgData!= NULL), MSG_SMIL_ERR_INVALID_PARAM);
+
+       if ((pMsgData->rootlayout.width.value >  0) &&
+               (pMsgData->rootlayout.height.value> 0)) {
+               if (pMsgData->rootlayout.width.bUnitPercent == pMsgData->rootlayout.height.bUnitPercent) {
+                       MSG_DEBUG("_MsgMMSValidateSMILRootLayout: Root Layout Information Valid \n");
+                       eRet = MSG_SMIL_SUCCESS;
+               }
+       } else  {
+               MSG_DEBUG("_MsgMMSValidateSMILRootLayout: Root Layout Information not Present \n");
+               eRet = _MsgMMSAddDefaultSMILRootLayout(pMsgData);
+       }
+
+       MSG_END();
+       return eRet;
+}
+
+MSG_SMIL_ERR_E _MsgMMSAddDefaultSMILRootLayout(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       MSG_BEGIN();
+
+       char *pContent = (char *)MSG_SMIL_ROOT_LAYOUT_BG_COLOR;
+
+       MSG_RETURN_VAL_IF_FAIL((pMsgData!= NULL), MSG_SMIL_ERR_INVALID_PARAM);
+
+       pMsgData->rootlayout.width.value = MSG_SMIL_ROOT_LAYOUT_WIDTH;
+       pMsgData->rootlayout.width.bUnitPercent = MSG_SMIL_ROOT_LAYOUT_IN_PERCENT;
+
+       pMsgData->rootlayout.height.value = MSG_SMIL_ROOT_LAYOUT_HEIGHT;
+       pMsgData->rootlayout.height.bUnitPercent = MSG_SMIL_ROOT_LAYOUT_IN_PERCENT;
+
+       pMsgData->rootlayout.bgColor = MmsSmilAtoIHexa((char *)&pContent[1]);
+
+       MSG_END();
+       return MSG_SMIL_SUCCESS;
+}
+
+MSG_SMIL_ERR_E _MsgMMSValidateSMILRegion(MMS_MESSAGE_DATA_S *pMsgData, bool *pbRegAdded)
+{
+       MSG_BEGIN();
+
+       MSG_SMIL_ERR_E eRet = MSG_SMIL_ERR_INVALID_REGION_INFO;
+
+       MSG_RETURN_VAL_IF_FAIL((pMsgData!= NULL), MSG_SMIL_ERR_INVALID_PARAM);
+       MSG_RETURN_VAL_IF_FAIL((pbRegAdded!= NULL), MSG_SMIL_ERR_INVALID_PARAM);
+
+       if (pMsgData->regionCnt == 0) {
+               bool bTextReg = MSG_SMIL_TEXT_ON_TOP;
+               bool bfullReg = false;
+               bool btwoReg = false;
+
+               MSG_DEBUG("_MsgMMSValidateSMILRegion: Region Information not Present \n");
+
+               for (int PgIdx = 0; PgIdx < pMsgData->pageCnt; ++PgIdx) {
+                       MMS_PAGE_S *pPage = _MsgMmsGetPage(pMsgData, PgIdx);
+                       int nMediaCnt = 0;
+
+                       MSG_RETURN_VAL_IF_FAIL((NULL != pPage), MSG_SMIL_ERR_INVALID_PAGE_INFO);
+
+                       for (int MediaIdx = 0; MediaIdx < pPage->mediaCnt; ++MediaIdx) {
+                               MMS_MEDIA_S *pMedia = _MsgMmsGetMedia(pPage, MediaIdx);
+
+                               MSG_RETURN_VAL_IF_FAIL((NULL != pMedia), MSG_SMIL_ERR_INVALID_PAGE_INFO);
+
+                               if (pMedia->mediatype != MMS_SMIL_MEDIA_AUDIO)
+                                       nMediaCnt++;
+                       }
+
+                       if (nMediaCnt == 1)
+                               bfullReg = true;
+                       else if (nMediaCnt == 2)
+                               btwoReg = true;
+                       else if (nMediaCnt > 2) {
+                               MSG_DEBUG("_MsgMMSValidateSMILRegion: Invalid Region Information\n");
+                               eRet = MSG_SMIL_ERR_INVALID_PAGE_INFO;
+                               return eRet;
+                       }
+               }
+
+               if (bfullReg) {
+                       eRet = _MsgMMSAddDefaultFullSMILRegion(pMsgData);
+                       if (eRet != MSG_SMIL_SUCCESS) {
+                               MSG_DEBUG("_MsgMMSValidateSMILRegion: Invalid Region Information\n");
+                               return eRet;
+                       }
+               }
+               if (btwoReg) {
+                       eRet = _MsgMMSAddDefaultFirstSMILRegion(pMsgData, bTextReg);
+                       if (eRet != MSG_SMIL_SUCCESS) {
+                               MSG_DEBUG("_MsgMMSValidateSMILRegion: Invalid Region Information\n");
+                               return eRet;
+                       }
+
+                       eRet = _MsgMMSAddDefaultSecondSMILRegion(pMsgData,!bTextReg);
+                       if (eRet != MSG_SMIL_SUCCESS) {
+                               MSG_DEBUG("_MsgMMSValidateSMILRegion: Invalid Region Information\n");
+                               return eRet;
+                       }
+               }
+               *pbRegAdded  = true;
+               eRet = MSG_SMIL_SUCCESS;
+       } else {
+               MSG_DEBUG("_MsgMMSValidateSMILRegion: Region Information Present \n");
+
+               for (int Idx = 0; Idx< pMsgData->regionCnt; ++Idx) {
+                       MMS_SMIL_REGION *pRegion = _MsgMmsGetSmilRegion(pMsgData, Idx);
+
+                       if ((pRegion->width.value == 0) ||
+                                       (pRegion->height.value == 0)) {
+                               MSG_DEBUG("_MsgMMSValidateSMILRegion: Invalid Region information\n");
+
+                               return eRet;
+                       }
+
+                       if (pMsgData->rootlayout.width.bUnitPercent == true) {
+                               if ((pRegion->width.value > 100) ||
+                                       (pRegion->height.value > 100) ||
+                                       (pRegion->nLeft.value > 100) ||
+                                       (pRegion->nTop.value > 100)) {
+                                       MSG_DEBUG("_MsgMMSValidateSMILRegion: Region and root layout information does not map\n");
+
+                                       return eRet;
+                               }
+                       } else {
+                               if (((pRegion->width.bUnitPercent == true) && (pRegion->width.value > 100)) ||
+                                       ((pRegion->height.bUnitPercent == true) && (pRegion->height.value > 100)) ||
+                                       ((pRegion->nLeft.bUnitPercent == true) && (pRegion->nLeft.value > 100)) ||
+                                       ((pRegion->nTop.bUnitPercent == true) && (pRegion->nTop.value > 100))) {
+                                       MSG_DEBUG("_MsgMMSValidateSMILRegion: Invalid Region information\n");
+
+                                       return eRet;
+                               }
+                       }
+               }
+
+               eRet = MSG_SMIL_SUCCESS;
+       }
+
+       MSG_END();
+       return eRet;
+}
+
+MSG_SMIL_ERR_E _MsgMMSAddDefaultFirstSMILRegion(MMS_MESSAGE_DATA_S *pMsgData, bool bTextReg)
+{
+       MSG_BEGIN();
+
+       MSG_SMIL_ERR_E eRet = MSG_SMIL_ERR_INVALID_REGION_INFO;
+       MMS_SMIL_REGION *pRegion = NULL;
+       char *pszfit = (char *)MSG_SMIL_REG_FIT_TYPE;
+       char *pContent = (char *)MSG_SMIL_REG_BG_COLOR;
+
+       MSG_RETURN_VAL_IF_FAIL((pMsgData!= NULL), MSG_SMIL_ERR_INVALID_PARAM);
+       pRegion = (MMS_SMIL_REGION *)calloc(sizeof(MMS_SMIL_REGION), 1);
+
+       if (pRegion == NULL) {
+               MSG_DEBUG("_MsgMMSValidateSMILRegion: Memory Allocation failed\n");
+               return eRet;
+       }
+
+       if (!strcmp(pszfit, "meet"))
+               pRegion->fit = MMSUI_IMAGE_REGION_FIT_MEET;
+       else
+               pRegion->fit = MMSUI_IMAGE_REGION_FIT_HIDDEN;
+       pRegion->bgColor = MmsSmilAtoIHexa((char *)&pContent[1]);
+
+       pRegion->nLeft.value = MSG_SMIL_FIRST_REG_LEFT;
+       pRegion->nLeft.bUnitPercent = true;
+       pRegion->nTop.value = MSG_SMIL_FIRST_REG_TOP;
+       pRegion->nTop.bUnitPercent = true;
+       pRegion->width.value = MSG_SMIL_FIRST_REG_WIDTH;
+       pRegion->width.bUnitPercent = true;
+       pRegion->height.value = MSG_SMIL_FIRST_REG_HEIGHT;
+       pRegion->height.bUnitPercent = true;
+
+       if (bTextReg)
+               snprintf(pRegion->szID, MAX_SMIL_REGION_ID, "%s", MSG_SMIL_DEFAULT_TXT_REG);
+       else
+               snprintf(pRegion->szID, MAX_SMIL_REGION_ID, "%s", MSG_SMIL_DEFAULT_IMG_REG);
+
+       if (_MsgMmsAddRegion(pMsgData,pRegion) != MSG_SUCCESS) {
+               MSG_DEBUG("_MsgMMSValidateSMILRegion: Add Region failed\n");
+               free(pRegion);
+
+               return eRet;
+       }
+
+       eRet = MSG_SMIL_SUCCESS;
+
+       MSG_END();
+       return eRet;
+}
+
+MSG_SMIL_ERR_E _MsgMMSAddDefaultSecondSMILRegion(MMS_MESSAGE_DATA_S *pMsgData, bool bTextReg)
+{
+       MSG_BEGIN();
+
+       MSG_SMIL_ERR_E eRet = MSG_SMIL_ERR_INVALID_REGION_INFO;
+       MMS_SMIL_REGION *pRegion = NULL;
+       char *pszfit = (char *)MSG_SMIL_REG_FIT_TYPE;
+       char *pContent = (char *)MSG_SMIL_REG_BG_COLOR;
+
+       MSG_RETURN_VAL_IF_FAIL((pMsgData!= NULL), MSG_SMIL_ERR_INVALID_PARAM);
+       pRegion = (MMS_SMIL_REGION *)calloc(sizeof(MMS_SMIL_REGION), 1);
+
+       if (pRegion == NULL) {
+               MSG_DEBUG("_MsgMMSValidateSMILRegion: Memory Allocation failed\n");
+               return eRet;
+       }
+
+       if (!strcmp(pszfit, "meet"))
+               pRegion->fit = MMSUI_IMAGE_REGION_FIT_MEET;
+       else
+               pRegion->fit = MMSUI_IMAGE_REGION_FIT_HIDDEN;
+       pRegion->bgColor = MmsSmilAtoIHexa((char *)&pContent[1]);
+
+       pRegion->nLeft.value = MSG_SMIL_SECOND_REG_LEFT;
+       pRegion->nLeft.bUnitPercent = true;
+       pRegion->nTop.value = MSG_SMIL_SECOND_REG_TOP;
+       pRegion->nTop.bUnitPercent = true;
+       pRegion->width.value = MSG_SMIL_SECOND_REG_WIDTH;
+       pRegion->width.bUnitPercent = true;
+       pRegion->height.value = MSG_SMIL_SECOND_REG_HEIGHT;
+       pRegion->height.bUnitPercent = true;
+
+       if (bTextReg)
+               snprintf(pRegion->szID, MAX_SMIL_REGION_ID, "%s", MSG_SMIL_DEFAULT_TXT_REG);
+       else
+               snprintf(pRegion->szID, MAX_SMIL_REGION_ID, "%s", MSG_SMIL_DEFAULT_IMG_REG);
+
+       if (_MsgMmsAddRegion(pMsgData,pRegion) != MSG_SUCCESS) {
+               MSG_DEBUG("_MsgMMSValidateSMILRegion: Add Region failed\n");
+               free(pRegion);
+
+               return eRet;
+       }
+
+       eRet = MSG_SMIL_SUCCESS;
+
+       MSG_END();
+       return eRet;
+}
+
+MSG_SMIL_ERR_E _MsgMMSAddDefaultFullSMILRegion(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       MSG_BEGIN();
+
+       MSG_SMIL_ERR_E eRet = MSG_SMIL_ERR_INVALID_REGION_INFO;
+       MMS_SMIL_REGION *pRegion = NULL;
+       char *pszfit = (char *)MSG_SMIL_REG_FIT_TYPE;
+       char *pContent = (char *)MSG_SMIL_REG_BG_COLOR;
+
+       MSG_RETURN_VAL_IF_FAIL((pMsgData!= NULL), MSG_SMIL_ERR_INVALID_PARAM);
+       pRegion = (MMS_SMIL_REGION *)calloc(sizeof(MMS_SMIL_REGION), 1);
+
+       if (pRegion == NULL) {
+               MSG_DEBUG("_MsgMMSValidateSMILRegion: Memory Allocation failed\n");
+               return eRet;
+       }
+
+       if (!strcmp(pszfit, "meet"))
+               pRegion->fit = MMSUI_IMAGE_REGION_FIT_MEET;
+       else
+               pRegion->fit = MMSUI_IMAGE_REGION_FIT_HIDDEN;
+       pRegion->bgColor = MmsSmilAtoIHexa((char *)&pContent[1]);
+
+       pRegion->nLeft.value = MSG_SMIL_FULL_REG_LEFT;
+       pRegion->nLeft.bUnitPercent = true;
+       pRegion->nTop.value = MSG_SMIL_FULL_REG_TOP;
+       pRegion->nTop.bUnitPercent = true;
+       pRegion->width.value = MSG_SMIL_FULL_REG_WIDTH;
+       pRegion->width.bUnitPercent = true;
+       pRegion->height.value = MSG_SMIL_FULL_REG_HEIGHT;
+       pRegion->height.bUnitPercent = true;
+
+       snprintf(pRegion->szID, MAX_SMIL_REGION_ID, "%s", MSG_SMIL_DEFAULT_FULL_REG);
+
+       if (_MsgMmsAddRegion(pMsgData,pRegion) != MSG_SUCCESS) {
+               MSG_DEBUG("_MsgMMSValidateSMILRegion: Add Region failed\n");
+               free(pRegion);
+
+               return eRet;
+       }
+
+       eRet = MSG_SMIL_SUCCESS;
+
+       MSG_END();
+       return eRet;
+}
+
+MSG_SMIL_ERR_E  _MsgMMSValidateSMILPage(MMS_MESSAGE_DATA_S *pMsgData, bool bRegAdded)
+{
+       MSG_BEGIN();
+
+       MSG_SMIL_ERR_E eRet = MSG_SMIL_ERR_INVALID_PAGE_INFO;
+
+       MSG_RETURN_VAL_IF_FAIL((pMsgData!= NULL), MSG_SMIL_ERR_INVALID_PARAM);
+       MSG_RETURN_VAL_IF_FAIL((pMsgData->pageCnt > 0), eRet);
+
+       for (int PgIdx = 0; PgIdx < pMsgData->pageCnt; ++PgIdx) {
+               MMS_PAGE_S *pPage = _MsgMmsGetPage(pMsgData, PgIdx);
+               int PageRegionCnt = 0;
+               int PageRegionIdx = 0;
+               bool bVidExists = false;
+               bool bImgExists = false;
+               bool bTxtExists = false;
+               bool bAudExists = false;
+               bool bImgOrVidExists = false;
+               bool bResetRegion = false;
+
+               MSG_RETURN_VAL_IF_FAIL((NULL != pPage), MSG_SMIL_ERR_INVALID_PAGE_INFO);
+               MSG_RETURN_VAL_IF_FAIL((pPage->nDur >= 0), MSG_SMIL_ERR_INVALID_PAGE_DUR);
+
+               for (int MediaIdx = 0; MediaIdx < pPage->mediaCnt; ++MediaIdx) {
+                       MMS_MEDIA_S *pMedia = _MsgMmsGetMedia(pPage, MediaIdx);
+
+                       MSG_RETURN_VAL_IF_FAIL((NULL != pMedia), MSG_SMIL_ERR_INVALID_PAGE_INFO);
+
+                       bResetRegion = false;
+                       if ((pMedia->mediatype != MMS_SMIL_MEDIA_AUDIO)) {
+                               if (bRegAdded) {
+                                       bResetRegion = true;
+                               } else if ((strlen(pMedia->regionId) == 0)) {
+                                       MSG_DEBUG("_MsgMMSValidateSMILRegion: Invalid Region Information\n");
+                                       return MSG_SMIL_ERR_INVALID_REGION_INFO;
+                               }
+                               PageRegionCnt++;
+                       }
+               }
+
+               for (int MediaIdx = 0; MediaIdx < pPage->mediaCnt; ++MediaIdx) {
+                       MMS_MEDIA_S *pMedia = _MsgMmsGetMedia(pPage, MediaIdx);
+
+                       MSG_RETURN_VAL_IF_FAIL((NULL != pMedia), MSG_SMIL_ERR_INVALID_PAGE_INFO);
+                       MSG_RETURN_VAL_IF_FAIL((strlen(pMedia->szFilePath) > 0), MSG_SMIL_ERR_INVALID_PAGE_INFO);
+
+                       switch (pMedia->mediatype) {
+                       case MMS_SMIL_MEDIA_IMG:
+                               {
+                                       if ((bImgExists == true) || (bVidExists == true) ||
+                                               (bImgOrVidExists== true)) {
+                                               eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
+                                       } else
+                                               bImgExists = true;
+                               }
+                               break;
+                       case MMS_SMIL_MEDIA_AUDIO:
+                               {
+                                       if ((bAudExists == true) || (bVidExists == true) ||
+                                               (bImgOrVidExists== true)) {
+                                               eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
+                                       } else
+                                               bAudExists = true;
+                               }
+                               break;
+                       case MMS_SMIL_MEDIA_VIDEO:
+                               {
+                                       if ((bImgExists == true) || (bVidExists == true) ||
+                                               (bImgOrVidExists== true)) {
+                                               eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
+                                       } else
+                                               bVidExists = true;
+                               }
+                               break;
+                       case MMS_SMIL_MEDIA_TEXT:
+                               {
+                                       if (bTxtExists == true) {
+                                               eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
+                                       } else
+                                               bTxtExists = true;
+                               }
+                               break;
+                       case MMS_SMIL_MEDIA_IMG_OR_VIDEO:
+                               {
+                                       if ((bImgExists == true) || (bVidExists == true) ||
+                                               (bImgOrVidExists== true)) {
+                                               eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
+                                       } else
+                                               bImgOrVidExists = true;
+                               }
+                               break;
+                       default:
+                               {
+                                       MSG_DEBUG("_MsgMMSValidateSMILRegion: Invalid Media Information\n");
+                                       return eRet;
+                               }
+                               break;
+                       }
+
+                       if (eRet == MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS) {
+                               MSG_DEBUG("_MsgMMSValidateSMILRegion: Similar Media Exists\n");
+                               return eRet;
+                       }
+
+                       if (bResetRegion) {
+                               if (PageRegionCnt > 1) {
+                                       if (pMedia->mediatype == MMS_SMIL_MEDIA_AUDIO) {
+                                               memset(pMedia->regionId,0x00, MAX_SMIL_REGION_ID);
+                                               continue;
+                                       }
+
+                                       if (pMedia->mediatype == MMS_SMIL_MEDIA_TEXT)
+                                               snprintf(pMedia->regionId, MAX_SMIL_REGION_ID, "%s", MSG_SMIL_DEFAULT_TXT_REG);
+                                       else
+                                               snprintf(pMedia->regionId, MAX_SMIL_REGION_ID, "%s", MSG_SMIL_DEFAULT_IMG_REG);
+                               } else
+                                       snprintf(pMedia->regionId, MAX_SMIL_REGION_ID, "%s", MSG_SMIL_DEFAULT_FULL_REG);
+                       }
+                       PageRegionIdx++;
+               }
+       }
+
+       eRet = MSG_SMIL_SUCCESS;
+
+       MSG_END();
+
+       return eRet;
+}
+
diff --git a/plugin/mms_plugin/MmsPluginSmil.cpp b/plugin/mms_plugin/MmsPluginSmil.cpp
new file mode 100755 (executable)
index 0000000..9d22b91
--- /dev/null
@@ -0,0 +1,2160 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include<stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <ctype.h>
+#include "MmsPluginSmil.h"
+#include "MmsPluginMessage.h"
+#include "MmsPluginStorage.h"
+#include "MsgDebug.h"
+#include "MmsPluginCodec.h"
+#include "MsgMmsMessage.h"
+
+#include "MsgTypes.h"
+#include "MmsPluginSetup.h"
+#include "MsgUtilFile.h"
+
+/* static variables */
+static char gszEmptyRawDoc[] = "<smil><head><layout></layout></head><body></body></smil>";
+static MmsSmilDoc *__gpaMmsSmilDoc[MMS_SMIL_MAX_DOC]={NULL, };
+static char gszColor[MMS_SMIL_COLOR_SIZE] = {0, };
+
+
+char *MmsSmilGetPresentationData(MSG_MESSAGE_ID_T msgId)
+{
+       MmsMsg *pMsg;
+
+       MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+
+       if (pMsg == NULL) {
+               MSG_DEBUG("pMsg is NULL");
+               goto _LCATCH;
+       }
+
+       if (msgId != pMsg->msgID) {
+               MSG_DEBUG("Invalid Message Id");
+               return NULL;
+       }
+
+       if (!pMsg->msgBody.pPresentationBody)
+               goto _LCATCH;
+
+       if (!pMsg->msgBody.pPresentationBody->body.pText)
+               goto _LCATCH;
+       else
+               return pMsg->msgBody.pPresentationBody->body.pText;
+
+_LCATCH:
+       return NULL;
+}
+
+bool MmsSmilParseSmilDoc(MMS_MESSAGE_DATA_S *pMmsMsg, char *pSmilDoc)
+{
+       xmlDocPtr doc;
+       xmlNodePtr cur;
+       MSG_DEBUG("%s", pSmilDoc);
+       doc = xmlParseMemory(pSmilDoc, strlen(pSmilDoc));
+
+       if (doc == NULL) {
+               MSG_DEBUG("Document not parsed successfully. \n");
+               return false;
+       }
+
+       cur = xmlDocGetRootElement(doc);
+
+       if (cur == NULL) {
+               MSG_DEBUG("empty document\n");
+               xmlFreeDoc(doc);
+               return false;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *) "smil")) {
+               MSG_DEBUG("document of the wrong type, root node != smil");
+               xmlFreeDoc(doc);
+               return false;
+       }
+
+       MmsSmilGetElement(pMmsMsg, cur);
+
+       xmlFreeDoc(doc);
+
+       return true;
+}
+
+void MmsSmilGetElement(MMS_MESSAGE_DATA_S *pMmsMsg, xmlNode *a_node)
+{
+       MSG_BEGIN();
+
+       int elementType;
+       int attrType;
+       MMS_SMIL_ROOTLAYOUT rootlayout = {};
+       static bool cmd[ELEMENT_MAX] = {false, };
+       static MMS_SMIL_REGION *pRegion;
+       static MMS_PAGE_S *pPage;
+       static MMS_MEDIA_S *pMedia;
+       static MMS_SMIL_TRANSITION *pTransition;
+       static MMS_SMIL_META *pMeta;
+
+       xmlNode *cur_node = NULL;
+
+       for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
+               MSG_DEBUG("******* node, name: %s ***\n", cur_node->name);
+
+               if (cur_node->type == XML_ELEMENT_NODE) {
+                       // Get Smil Element =====================================================
+                       MSG_DEBUG("*** node type: Element, name: %s ***\n", cur_node->name);
+
+                       switch (elementType = MmsSmilGetElementID((char *)cur_node->name)) {
+                       case ELEMENT_ROOTLAYOUT:
+                               memset(cmd, 0, ELEMENT_MAX);
+                               cmd[ELEMENT_ROOTLAYOUT] = true;
+                               break;
+
+                       case ELEMENT_REGION:
+                               pRegion = (MMS_SMIL_REGION *)calloc(sizeof(MMS_SMIL_REGION), 1);
+                               memset(cmd, 0, ELEMENT_MAX);
+                               cmd[ELEMENT_REGION] = true;
+                               break;
+
+                       case ELEMENT_TRANSITION:
+                               pTransition = (MMS_SMIL_TRANSITION *)calloc(sizeof(MMS_SMIL_TRANSITION), 1);
+                               memset(cmd, 0, ELEMENT_MAX);
+                               cmd[ELEMENT_TRANSITION] = true;
+                               break;
+
+                       case ELEMENT_META:
+                               pMeta = (MMS_SMIL_META *)calloc(sizeof(MMS_SMIL_META), 1);
+                               memset(cmd, 0, ELEMENT_MAX);
+                               cmd[ELEMENT_META] = true;
+                               break;
+
+                       case ELEMENT_PAR:
+                               pPage = (MMS_PAGE_S *)calloc(sizeof(MMS_PAGE_S), 1);
+                               memset(cmd, 0, ELEMENT_MAX);
+                               cmd[ELEMENT_PAR] = true;
+                               break;
+
+                       case ELEMENT_PARAM: // Need to check the original element type
+                               break;
+
+                       case ELEMENT_TEXT:
+                               pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
+                               pMedia->mediatype = MMS_SMIL_MEDIA_TEXT;
+                               memset(cmd, 0, ELEMENT_MAX);
+                               cmd[ELEMENT_TEXT] = true;
+                               break;
+
+                       case ELEMENT_IMG:
+                               pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
+                               pMedia->mediatype = MMS_SMIL_MEDIA_IMG;
+                               memset(cmd, 0, ELEMENT_MAX);
+                               cmd[ELEMENT_IMG] = true;
+                               break;
+
+                       case ELEMENT_AUDIO:
+                               pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
+                               pMedia->mediatype = MMS_SMIL_MEDIA_AUDIO;
+                               memset(cmd, 0, ELEMENT_MAX);
+                               cmd[ELEMENT_AUDIO] = true;
+                               break;
+
+                       case ELEMENT_VIDEO:
+                               pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
+                               pMedia->mediatype = MMS_SMIL_MEDIA_VIDEO;
+                               memset(cmd, 0, ELEMENT_MAX);
+                               cmd[ELEMENT_VIDEO] = true;
+                               break;
+
+                       case ELEMENT_REF:
+                               pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
+                               pMedia->mediatype = MMS_SMIL_MEDIA_IMG_OR_VIDEO;
+                               memset(cmd, 0, ELEMENT_MAX);
+                               cmd[ELEMENT_REF] = true;
+                               break;
+
+                       case ELEMENT_ANIMATE:
+                               pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
+                               pMedia->mediatype = MMS_SMIL_MEDIA_ANIMATE;
+                               memset(cmd, 0, ELEMENT_MAX);
+                               cmd[ELEMENT_ANIMATE] = true;
+                               break;
+
+                       default:
+                               memset(cmd, 0, ELEMENT_MAX);
+                               break;
+                       }
+
+                       //Get Smil Attribute =====================================================
+                       xmlAttr *pAttr = cur_node->properties;
+                       SMIL_ATTRIBUTE_T paramType = ATTRIBUTE_UNKNOWN;
+
+                       for ( ; pAttr; pAttr = pAttr->next) {
+                               MSG_DEBUG("AttributeType: (%s, %s) ", pAttr->name, pAttr->children->content);
+                               switch (attrType = MmsSmilGetAttrID((char *)pAttr->name)) {
+                               case ATTRIBUTE_ID:
+                                       {
+                                               if (cmd[ELEMENT_REGION]) {
+                                                       strncpy(pRegion->szID, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1);
+                                               } else if (cmd[ELEMENT_TRANSITION]) {
+                                                       strncpy(pTransition->szID, (char *)pAttr->children->content, MAX_SMIL_TRANSITION_ID - 1);
+                                               } else if (cmd[ELEMENT_META]) {
+                                                       strncpy(pMeta->szID, (char *)pAttr->children->content, MAX_SMIL_META_ID - 1);
+                                               }
+                                       }
+                                       break;
+
+                               case ATTRIBUTE_TOP:
+                                       {
+                                               int bUnitPercent;
+                                               int value;
+
+                                               if (strchr((char *)pAttr->children->content, '%'))
+                                                       bUnitPercent = true;
+                                               else
+                                                       bUnitPercent = false;
+
+                                               value = atoi((char *)pAttr->children->content);
+
+                                               if (cmd[ELEMENT_REGION]) {
+                                                       pRegion->nTop.bUnitPercent = bUnitPercent;
+                                                       pRegion->nTop.value = value;
+                                               }
+                                       }
+                                       break;
+
+                               case ATTRIBUTE_LEFT:
+                                       {
+                                               int bUnitPercent;
+                                               int value;
+
+                                               if (strchr((char *)pAttr->children->content, '%'))
+                                                       bUnitPercent = true;
+                                               else
+                                                       bUnitPercent = false;
+
+                                               value = atoi((char *)pAttr->children->content);
+
+                                               if (cmd[ELEMENT_REGION]) {
+                                                       pRegion->nLeft.bUnitPercent = bUnitPercent;
+                                                       pRegion->nLeft.value = value;
+                                               }
+                                       }
+                                       break;
+
+
+                               case ATTRIBUTE_WIDTH:
+                                       {
+                                               int bUnitPercent;
+                                               int value;
+
+                                               if (strchr((char *)pAttr->children->content, '%'))
+                                                       bUnitPercent = true;
+                                               else
+                                                       bUnitPercent = false;
+
+                                               value = atoi((char *)pAttr->children->content);
+
+                                               if (cmd[ELEMENT_ROOTLAYOUT]) {
+                                                       rootlayout.width.bUnitPercent = bUnitPercent;
+                                                       rootlayout.width.value = value;
+                                               } else if (cmd[ELEMENT_REGION]) {
+                                                       pRegion->width.bUnitPercent = bUnitPercent;
+                                                       pRegion->width.value = value;
+                                               }
+                                       }
+                                       break;
+
+                               case ATTRIBUTE_HEIGHT:
+                                       {
+                                               int bUnitPercent;
+                                               int value;
+
+                                               if (strchr((char *)pAttr->children->content, '%'))
+                                                       bUnitPercent = true;
+                                               else
+                                                       bUnitPercent = false;
+
+                                               value = atoi((char *)pAttr->children->content);
+
+                                               if (cmd[ELEMENT_ROOTLAYOUT]) {
+                                                       rootlayout.height.bUnitPercent = bUnitPercent;
+                                                       rootlayout.height.value = value;
+                                               } else if (cmd[ELEMENT_REGION]) {
+                                                       pRegion->height.bUnitPercent = bUnitPercent;
+                                                       pRegion->height.value = value;
+                                               }
+                                       }
+                                       break;
+
+                               case ATTRIBUTE_FIT:
+                                       if (cmd[ELEMENT_REGION]) {
+                                               if (!strcmp((char *)pAttr->children->content, "meet")) {
+                                                       pRegion->fit = MMSUI_IMAGE_REGION_FIT_MEET;
+                                               } else {
+                                                       pRegion->fit = MMSUI_IMAGE_REGION_FIT_HIDDEN;
+                                               }
+                                       }
+                                       break;
+
+                               case ATTRIBUTE_BGCOLOR:
+                                       if (cmd[ELEMENT_ROOTLAYOUT])
+                                               rootlayout.bgColor = MmsSmilGetColorValue(pAttr->children->content);
+                                       else if (cmd[ELEMENT_REGION])
+                                               pRegion->bgColor = MmsSmilGetColorValue(pAttr->children->content);
+                                       else if (cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
+                                       else
+                                               pMedia->sMedia.sAVI.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
+
+                                       break;
+
+                               case ATTRIBUTE_DUR:
+                                       if (cmd[ELEMENT_PAR])
+                                               pPage->nDur =  MmsSmilGetTime((char *)pAttr->children->content);
+                                       else if (cmd[ELEMENT_TRANSITION])
+                                               pTransition->nDur =  MmsSmilGetTime((char *)pAttr->children->content);
+                                       else if (cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.nDurTime =  MmsSmilGetTime((char *)pAttr->children->content);
+                                       else
+                                               pMedia->sMedia.sAVI.nDurTime =  MmsSmilGetTime((char *)pAttr->children->content);
+
+#ifdef MMS_SMIL_ANIMATE
+                                       if (cmd[ELEMENT_ANIMATE])
+                                               pMedia->sMedia.sAVI.nDur = MmsSmilGetTime((char *)pAttr->children->content);
+#endif
+                                       break;
+
+                               case ATTRIBUTE_SRC:
+                                       {
+                                               char *szSrc;
+                                               char szTmpSrc[MSG_FILEPATH_LEN_MAX] = {0,};
+                                               char szOutBuf[MSG_FILEPATH_LEN_MAX] = {0, };
+                                               int cLen;
+                                               MsgMultipart *pPart = NULL;
+                                               MmsMsg *pMsg;
+
+                                               szSrc = MsgChangeHexString((char *)pAttr->children->content);
+
+                                               memcpy(pMedia->szSrc, szSrc, strlen(szSrc) + 1);
+                                               free(szSrc);
+
+                                               cLen = strlen(pMedia->szSrc);
+                                               if (!strncasecmp(pMedia->szSrc, "cid:", 4)) {
+                                                       strncpy(szTmpSrc, pMedia->szSrc + 4, cLen - 4);
+                                                       szTmpSrc[cLen - 4] = '\0';
+                                               } else {
+                                                       strncpy(szTmpSrc, pMedia->szSrc, cLen);
+                                                       szTmpSrc[cLen] = '\0';
+                                               }
+
+                                               MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+                                               pPart = pMsg->msgBody.body.pMultipart;
+#ifndef __SUPPORT_DRM__
+                                               MmsSmilGetMediaSrcForNormalMsg(szOutBuf, szTmpSrc, pPart);
+#else
+                                               MmsSmilGetMediaSrcForNormalMsg(szOutBuf, szTmpSrc, pPart, pMedia);
+#endif
+
+                                               strcpy(pMedia->szSrc, szOutBuf);
+                                               MmsSmilGetMediaFilePath(pMedia, szTmpSrc, pMsg->msgID);
+                                       }
+                                       break;
+
+                               case ATTRIBUTE_COLOR:
+                                       if (cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_SIZE:
+                                       if (cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.nSize = atoi((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_BOLD:
+                                       if (cmd[ELEMENT_TEXT]) {
+                                               pMedia->sMedia.sText.bBold = MmsSmilGetFontAttrib((char *)pAttr->children->content);
+                                       }
+                                       break;
+
+                               case ATTRIBUTE_UNDERLINE:
+                                       if (cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.bUnderLine = MmsSmilGetFontAttrib((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_ITALIC:
+                                       if (cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.bItalic = MmsSmilGetFontAttrib((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_REVERSE:
+                                       if (cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.bReverse = MmsSmilGetFontAttrib((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_DIRECTION:
+                                       if (cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.nDirection = MmsSmilGetFontDirection((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_REGION:
+                                       strncpy(pMedia->regionId, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1);
+                                       break;
+
+                               case ATTRIBUTE_TRANSIN:
+                                       if (cmd[ELEMENT_TEXT])
+                                               strncpy(pMedia->sMedia.sText.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1);
+                                       else
+                                               strncpy(pMedia->sMedia.sAVI.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1);
+                                       break;
+
+                               case ATTRIBUTE_TRANSOUT:
+                                       if (cmd[ELEMENT_TEXT])
+                                               strncpy(pMedia->sMedia.sText.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1);
+                                       else
+                                               strncpy(pMedia->sMedia.sAVI.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1);
+                                       break;
+
+                               case ATTRIBUTE_BEGIN:
+                                       if (cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.nBegin = MmsSmilGetTime((char *)pAttr->children->content);
+                                       else
+                                               pMedia->sMedia.sAVI.nBegin = MmsSmilGetTime((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_END:
+                                       if (cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.nEnd = MmsSmilGetTime((char *)pAttr->children->content);
+                                       else
+                                               pMedia->sMedia.sAVI.nEnd = MmsSmilGetTime((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_REPEAT_COUNT:
+                                       if (cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.nRepeat = atoi((char *)pAttr->children->content);
+                                       else
+                                               pMedia->sMedia.sAVI.nRepeat = atoi((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_NAME:
+                                       if (!strcmp((char *)pAttr->children->content, "foreground-color") || !strcmp((char *)pAttr->children->content, "foregroundcolor"))
+                                               paramType = ATTRIBUTE_FGCOLOR;
+                                       else if (!strcmp((char *)pAttr->children->content, "background-color") || !strcmp((char *)pAttr->children->content, "backgroundcolor"))
+                                               paramType = ATTRIBUTE_BGCOLOR;
+                                       else if (!strcmp((char *)pAttr->children->content, "textsize"))
+                                               paramType = ATTRIBUTE_SIZE;
+                                       else if (!strcmp((char *)pAttr->children->content, "textattribute"))
+                                               paramType = ATTRIBUTE_TEXTFORMAT;
+
+                                       if (cmd[ELEMENT_META])
+                                               strncpy(pMeta->szName, (char *)pAttr->children->content, MAX_SMIL_META_NAME - 1);
+                                       break;
+
+                               case ATTRIBUTE_VALUE:
+                                       if (paramType == ATTRIBUTE_SIZE && cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.nSize = MmsSmilGetFontSizeValue((char *)pAttr->children->content);
+                                       else if (paramType == ATTRIBUTE_FGCOLOR && cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.nColor =  MmsSmilGetColorValue(pAttr->children->content);
+                                       else if (paramType == ATTRIBUTE_BGCOLOR && cmd[ELEMENT_TEXT])
+                                               pMedia->sMedia.sText.nBgColor =  MmsSmilGetColorValue(pAttr->children->content);
+                                       else if (paramType == ATTRIBUTE_TEXTFORMAT && cmd[ELEMENT_TEXT]) {
+                                               MmsSmilFontType fontType;
+
+                                               fontType = MmsSmilGetFontTypeValue((char *)pAttr->children->content);
+
+                                               if (fontType == MMS_SMIL_FONT_TYPE_BOLD)
+                                                       pMedia->sMedia.sText.bBold = true;
+                                               else
+                                                       pMedia->sMedia.sText.bBold = false;
+
+                                               if (fontType == MMS_SMIL_FONT_TYPE_ITALIC)
+                                                       pMedia->sMedia.sText.bItalic = true;
+                                               else
+                                                       pMedia->sMedia.sText.bItalic = false;
+
+                                               if (fontType == MMS_SMIL_FONT_TYPE_UNDERLINE)
+                                                       pMedia->sMedia.sText.bUnderLine = true;
+                                               else
+                                                       pMedia->sMedia.sText.bUnderLine = false;
+                                       }
+                                       break;
+
+                               case ATTRIBUTE_ALT:
+                                       strncpy(pMedia->szAlt, (char *)pAttr->children->content, MAX_SMIL_ALT_LEN - 1);
+                                       break;
+
+                               case ATTRIBUTE_TYPE:
+                                       pTransition->nType = (MmsSmilTransType)atoi((char *)pAttr->children->content);
+
+                                       switch (pTransition->nType) {
+                                       case MMS_SMIL_TRANS_SLIDEWIPE:
+                                               pTransition->nSubType = MMS_SMIL_TRANS_SUB_FROM_LEFT;
+                                               break;
+                                       case MMS_SMIL_TRANS_BARWIPE:
+                                               pTransition->nSubType = MMS_SMIL_TRANS_SUB_TOP_TO_BOTTOM;
+                                               break;
+                                       case MMS_SMIL_TRANS_BARNDOORWIPE:
+                                               pTransition->nSubType = MMS_SMIL_TRANS_SUB_HORIZONTAL;
+                                               break;
+                                       default:
+                                               pTransition->nSubType = MMS_SMIL_TRANS_SUB_NONE;
+                                               break;
+                                       }
+
+                                       break;
+
+                               case ATTRIBUTE_SUBTYPE:
+                                       pTransition->nSubType = (MmsSmilTransSubType)atoi((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_CONTENT:
+                                       strncpy(pMeta->szContent, (char *)pAttr->children->content, MAX_SMIL_META_CONTENT - 1);
+                                       break;
+#ifdef MMS_SMIL_ANIMATE
+                               case ATTRIBUTE_ATTRIBUTE_NAME:
+                                       strcpy(pMedia->sMedia.sAVI.nAttributeName, (char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_ATTRIBUTE_TYPE:
+                                       strcpy(pMedia->sMedia.sAVI.nAttributeType, (char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_TARGET_ELEMENT:
+                                       strcpy(pMedia->sMedia.sAVI.nTargetElement, (char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_FROM:
+                                       pMedia->sMedia.sAVI.nFrom = atoi((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_TO:
+                                       pMedia->sMedia.sAVI.nTo = atoi((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_BY:
+                                       pMedia->sMedia.sAVI.nBy = atoi((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_VALUES:
+                                       pMedia->sMedia.sAVI.nValues = atoi((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_CALCMODE:
+                                       strcpy(pMedia->sMedia.sAVI.nCalcMode, (char *)pAttr->children->content);
+                                       break;
+#endif
+                               default:
+                                       MSG_DEBUG("Undefined Attribute was found!!!!!");
+                               }
+                       }
+
+                       if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_REGION]) {
+                               // Insert a region to region list
+                               _MsgMmsAddRegion(pMmsMsg, pRegion);
+                       } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_PAR]) {
+                               //Insert a page to page list
+                               _MsgMmsAddPage(pMmsMsg, pPage);
+                       } else if (paramType == ATTRIBUTE_UNKNOWN && (cmd[ELEMENT_TEXT] ||cmd[ELEMENT_IMG] ||cmd[ELEMENT_AUDIO] ||cmd[ELEMENT_VIDEO] ||cmd[ELEMENT_ANIMATE])) {
+                               //Insert a media to media list
+                               _MsgMmsAddMedia(pPage, pMedia);
+                       } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_ROOTLAYOUT]) {
+                               _MsgMmsSetRootLayout(pMmsMsg, &rootlayout);
+                       } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_TRANSITION]) {
+                               //Insert a transition to transition list
+                               _MsgMmsAddTransition(pMmsMsg, pTransition);
+                       } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_META]) {
+                               //Insert a meta to meta list
+                               _MsgMmsAddMeta(pMmsMsg, pMeta);
+                       }
+
+                       paramType = ATTRIBUTE_UNKNOWN;
+               }
+
+               MmsSmilGetElement(pMmsMsg, cur_node->children);
+       }
+
+       MSG_END();
+}
+
+
+int MmsSmilGetColorValue(xmlChar *content)
+{
+       int color;
+
+       if (content[0] == '#')  // RGB value
+               color = MmsSmilAtoIHexa((char *)&content[1]);
+       else if (content[0] == '0' && (content[1] == 'x' || content[1] == 'X'))
+               color = MmsSmilAtoIHexa((char *)&content[2]);
+       else {
+               MSG_DEBUG("Invalid Color Value");
+               color = -1;
+       }
+
+       return color;
+}
+
+int MmsSmilAtoIHexa(char *pInput)
+{
+       int res = 0;
+       int len = 0;
+       int temp = 1;
+       int i  = 0;
+       int j = 0;
+       char *pOutput = NULL;
+
+       MSG_DEBUG("__MmsSmilAtoIHexa() enter..\n");
+
+       len = strlen(pInput);
+       pOutput = (char *)malloc(len + 1);
+
+       if (pOutput == NULL) {
+               MSG_DEBUG("__MmsSmilAtoIHexa: Memory full \n");
+               goto __CATCH;
+       }
+
+       memset(pOutput, 0, len + 1);
+
+       for (i = len - 1; i >= 0; i--) {
+               for (j = 0; j < (len - 1 - i); j++) {
+                       temp *= 16;
+               }
+
+               switch (pInput[i]) {
+               case '0':
+                       pOutput[i] = 0;
+                       break;
+
+               case '1':
+                       pOutput[i] = 1;
+                       break;
+
+               case '2':
+                       pOutput[i] = 2;
+                       break;
+
+               case '3':
+                       pOutput[i] = 3;
+                       break;
+
+               case '4':
+                       pOutput[i] = 4;
+                       break;
+
+               case '5':
+                       pOutput[i] = 5;
+                       break;
+
+               case '6':
+                       pOutput[i] = 6;
+                       break;
+
+               case '7':
+                       pOutput[i] = 7;
+                       break;
+
+               case '8':
+                       pOutput[i] = 8;
+                       break;
+
+               case '9':
+                       pOutput[i] = 9;
+                       break;
+
+               case 'a':
+               case 'A':
+                       pOutput[i] = 10;
+                       break;
+
+               case 'b':
+               case 'B':
+                       pOutput[i] = 11;
+                       break;
+
+               case 'c':
+               case 'C':
+                       pOutput[i] = 12;
+                       break;
+
+               case 'd':
+               case 'D':
+                       pOutput[i] = 13;
+                       break;
+
+               case 'e':
+               case 'E':
+                       pOutput[i] = 14;
+                       break;
+
+               case 'f':
+               case 'F':
+                       pOutput[i] = 15;
+                       break;
+               }
+
+               res += (pOutput[i] * temp);
+               temp = 1;
+       }
+
+__CATCH:
+
+       if (pOutput) {
+               free(pOutput);
+               pOutput = NULL;
+       }
+
+       return res;
+}
+
+int MmsSmilGetTime(char *pValue)
+{
+       char *pTemp = NULL;
+       bool bMSec = false;
+       int retVal = 0;
+       int i = 0;
+       int len = 0;
+
+       if (pValue == NULL || pValue[0] == '\0')
+               return 0;
+
+       len = strlen(pValue);
+
+       /* Default time unit -> millisecond */
+       if (strstr(pValue, "msec"))
+               bMSec = true;
+
+       if (strstr(pValue, "ms"))
+               bMSec = true;
+
+       pTemp = (char *)malloc(strlen(pValue) + 1);
+
+       if (NULL == pTemp) {
+               MSG_DEBUG("__MmsSmilGetTime : malloc for <time> attribute is failed \n");
+               return 0;
+       }
+
+       while (isdigit(pValue[i])) {
+               pTemp[i] = pValue[i];
+               i++;
+       }
+       pTemp[i] = '\0';
+
+       /* Detect 's' and 'ms' here */
+       retVal = atoi(pTemp);
+
+       if (bMSec == false)
+               retVal *= 1000;
+
+       if (pTemp) {
+               free(pTemp);
+               pTemp = NULL;
+       }
+
+       return retVal;
+}
+#ifndef __SUPPORT_DRM__
+int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart)
+#else
+int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart, MMS_MEDIA_S *pMedia)
+#endif
+{
+       char szContentID[MSG_MSG_ID_LEN + 1] = {0, };
+       char szContentLI[MSG_MSG_ID_LEN + 1] = {0, };
+       int cLen  = 0;
+       int nPart = 0;
+
+       MSG_DEBUG("szInBuf: %s", szInBuf);
+       while (pPart && pPart->pBody) {
+               if (pPart->type.szContentID[0]) {
+                       cLen = strlen(pPart->type.szContentID);
+
+                       if (pPart->type.szContentID[0] == '<' && pPart->type.szContentID[cLen - 1] == '>') {
+                               strncpy(szContentID, &pPart->type.szContentID[1], cLen - 2);
+                               szContentID[cLen - 2] = '\0';
+                       } else if (pPart->type.szContentID[0] == MSG_CH_QUOT && pPart->type.szContentID[cLen-1] == MSG_CH_QUOT) {
+                               strncpy(szContentID, &pPart->type.szContentID[1], cLen - 2);
+                               szContentID[cLen - 2] = '\0';
+                       } else {
+                               strncpy(szContentID, pPart->type.szContentID, cLen);
+                               szContentID[cLen] = '\0';
+                       }
+               } else {
+                       szContentID[0] = '\0';
+               }
+
+               MSG_DEBUG("szContentID: %s", szContentID);
+
+               if (pPart->type.szContentLocation[0]) {
+                       cLen = strlen(pPart->type.szContentLocation);
+
+                       if (pPart->type.szContentLocation[0] == MSG_CH_QUOT &&
+                               pPart->type.szContentLocation[cLen-1] == MSG_CH_QUOT) {
+                               strncpy(szContentLI, &pPart->type.szContentLocation[1], cLen-2);
+                               szContentLI[cLen-2] = '\0';
+                       } else {
+                               strncpy(szContentLI, pPart->type.szContentLocation, cLen);
+                               szContentLI[cLen] = '\0';
+                       }
+               } else {
+                       szContentLI[0] = '\0';
+               }
+
+               MSG_DEBUG("szContentLocation: %s", szContentLI);
+
+               if (strcasecmp(szContentID, szInBuf) == 0) {
+                       strcpy(szOutbuf, pPart->type.param.szFileName);
+                       MSG_DEBUG("match with szContentID.");
+                       goto RETURN;
+               } else {
+                       char *szInFileName = strrchr(szInBuf, '/');
+
+                       if (szInFileName == NULL) {
+                               szInFileName = szInBuf;
+                       } else
+                               szInFileName++;
+
+                       if (strcasecmp(szContentLI, szInFileName) == 0) {
+                               strcpy(szOutbuf, pPart->type.param.szFileName);
+                               MSG_DEBUG("match with szContentLI.");
+                               goto RETURN;
+                       } else if (strcasecmp(pPart->type.param.szName, szInBuf) == 0) {
+                               strcpy(szOutbuf, pPart->type.param.szFileName);
+                               MSG_DEBUG("match with pPart->type.param.szName.");
+                               goto RETURN;
+                       } else if (strlen(szContentID) > 4) {
+                               if (strcasecmp(strtok(szContentID, "."), strtok(szInBuf, ".")) == 0) {
+                                       strcpy(szOutbuf, pPart->type.param.szFileName);
+                                       MSG_DEBUG("only name is match with szContentID.");
+                                       goto RETURN;
+                               }
+                       } else if (strlen(szContentLI) > 4) {
+                               if (strcasecmp(strtok(szContentLI, "."), strtok(szInBuf, ".")) == 0) {
+                                       strcpy(szOutbuf, pPart->type.param.szFileName);
+                                       MSG_DEBUG("only name is match with szContentLI.");
+                                       goto RETURN;
+                               }
+                       }
+               }
+
+               nPart++;
+               pPart = pPart->pNext;
+       }
+
+       return -1;
+
+RETURN:
+#ifdef __SUPPORT_DRM__
+       pMedia->drmType = pPart->type.drmInfo.drmType;
+
+       if (pPart->type.drmInfo.szDrm2FullPath != NULL) {
+               MSG_DEBUG("szDrm2FullPath: %s", pPart->type.drmInfo.szDrm2FullPath);
+               strncpy(pMedia->szDrm2FullPath, pPart->type.drmInfo.szDrm2FullPath, MSG_FILEPATH_LEN_MAX - 1);
+       }
+#endif
+       return nPart;
+
+}
+
+int    MmsSmilGetElementID(char *pString)
+{
+       if (!strcmp(pString, "smil"))
+               return ELEMENT_SMIL;
+       else if (!strcmp(pString, "head"))
+               return ELEMENT_HEAD;
+       else if (!strcmp(pString, "layout"))
+               return ELEMENT_LAYOUT;
+       else if (!strcmp(pString, "root-layout"))
+               return ELEMENT_ROOTLAYOUT;
+       else if (!strcmp(pString, "region"))
+               return ELEMENT_REGION;
+       else if (!strcmp(pString, "body"))
+               return ELEMENT_BODY;
+       else if (!strcmp(pString, "par"))
+               return ELEMENT_PAR;
+       else if (!strcmp(pString, "param"))
+               return ELEMENT_PARAM;
+       else if (!strcmp(pString, "text"))
+               return ELEMENT_TEXT;
+       else if (!strcmp(pString, "img"))
+               return ELEMENT_IMG;
+       else if (!strcmp(pString, "audio"))
+               return ELEMENT_AUDIO;
+       else if (!strcmp(pString, "video"))
+               return ELEMENT_VIDEO;
+       else if (!strcmp(pString, "ref"))
+               return ELEMENT_REF;
+       else if (!strcmp(pString, "animate"))
+               return ELEMENT_ANIMATE;
+       else if (!strcmp(pString, "root-layout"))
+               return ELEMENT_HEAD;
+       else if (!strcmp(pString, "transition"))
+               return ELEMENT_TRANSITION;
+       else if (!strcmp(pString, "meta"))
+               return ELEMENT_META;
+       else
+               return -1;
+}
+
+int    MmsSmilGetAttrID(char *pString)
+{
+       if (!strcmp(pString, "id"))
+               return ATTRIBUTE_ID;
+       else if (!strcmp(pString, "top"))
+               return ATTRIBUTE_TOP;
+       else if (!strcmp(pString, "left"))
+               return ATTRIBUTE_LEFT;
+       else if (!strcmp(pString, "width"))
+               return ATTRIBUTE_WIDTH;
+       else if (!strcmp(pString, "height"))
+               return ATTRIBUTE_HEIGHT;
+       else if (!strcmp(pString, "fit"))
+               return ATTRIBUTE_FIT;
+       else if (!strcmp(pString, "backgroundColor"))
+               return ATTRIBUTE_BGCOLOR;
+       else if (!strcmp(pString, "dur"))
+               return ATTRIBUTE_DUR;
+       else if (!strcmp(pString, "src"))
+               return ATTRIBUTE_SRC;
+       else if (!strcmp(pString, "color"))
+               return ATTRIBUTE_COLOR;
+       else if (!strcmp(pString, "bold"))
+               return ATTRIBUTE_BOLD;
+       else if (!strcmp(pString, "underline"))
+               return ATTRIBUTE_UNDERLINE;
+       else if (!strcmp(pString, "italic"))
+               return ATTRIBUTE_ITALIC;
+       else if (!strcmp(pString, "reverse"))
+               return ATTRIBUTE_REVERSE;
+       else if (!strcmp(pString, "direction"))
+               return ATTRIBUTE_DIRECTION;
+       else if (!strcmp(pString, "size"))
+               return ATTRIBUTE_SIZE;
+       else if (!strcmp(pString, "font"))
+               return ATTRIBUTE_FONT;
+       else if (!strcmp(pString, "region"))
+               return ATTRIBUTE_REGION;
+       else if (!strcmp(pString, "name"))
+               return ATTRIBUTE_NAME;
+       else if (!strcmp(pString, "value"))
+               return ATTRIBUTE_VALUE;
+       else if (!strcmp(pString, "alt"))
+               return ATTRIBUTE_ALT;
+       else if (!strcmp(pString, "type"))
+               return ATTRIBUTE_TYPE;
+       else if (!strcmp(pString, "subtype"))
+               return ATTRIBUTE_SUBTYPE;
+       else if (!strcmp(pString, "content"))
+               return ATTRIBUTE_CONTENT;
+       else if (!strcmp(pString, "transIn"))
+               return ATTRIBUTE_TRANSIN;
+       else if (!strcmp(pString, "transOut"))
+               return ATTRIBUTE_TRANSOUT;
+       else if (!strcmp(pString, "begin"))
+               return ATTRIBUTE_BEGIN;
+       else if (!strcmp(pString, "end"))
+               return ATTRIBUTE_END;
+       else if (!strcmp(pString, "repeatCount"))
+               return ATTRIBUTE_REPEAT_COUNT;
+#ifdef MMS_SMIL_ANIMATE
+       else if (!strcmp(pString, "attributeName"))
+               return ATTRIBUTE_ATTRIBUTE_NAME;
+       else if (!strcmp(pString, "attributeType"))
+               return ATTRIBUTE_ATTRIBUTE_TYPE;
+       else if (!strcmp(pString, "targetElement"))
+               return ATTRIBUTE_TARGET_ELEMENT;
+       else if (!strcmp(pString, "from"))
+               return ATTRIBUTE_FROM;
+       else if (!strcmp(pString, "to"))
+               return ATTRIBUTE_TO;
+       else if (!strcmp(pString, "by"))
+               return ATTRIBUTE_BY;
+       else if (!strcmp(pString, "values"))
+               return ATTRIBUTE_VALUES;
+       else if (!strcmp(pString, "calcMode"))
+               return ATTRIBUTE_CALCMODE;
+#endif
+       else
+               return -1;
+}
+
+bool MmsSmilGetFontAttrib(char *pString)
+{
+       if (!strcmp(pString, "true"))
+               return true;
+       else
+               return false;
+}
+
+MmsTextDirection MmsSmilGetFontDirection(char *pString)
+{
+       MmsTextDirection direction = MMS_TEXT_DIRECTION_INVALID;
+
+       if (!strcmp(pString, "right"))
+               direction = MMS_TEXT_DIRECTION_RIGHT;
+       else if (!strcmp(pString, "down"))
+               direction = MMS_TEXT_DIRECTION_DOWN;
+
+       return direction;
+}
+
+int MmsSmilGetFontSizeValue(char *pString)
+{
+       MSG_DEBUG(" #### content = %s #### ", pString);
+       if (!strcmp(pString, "small"))
+               return MMS_SMIL_FONT_SIZE_SMALL;
+       else if (!strcmp(pString, "normal"))
+               return MMS_SMIL_FONT_SIZE_NORMAL;
+       else if (!strcmp(pString, "large"))
+               return MMS_SMIL_FONT_SIZE_LARGE;
+       else
+               return atoi(pString);
+}
+
+MmsSmilFontType MmsSmilGetFontTypeValue(char *pString)
+{
+       MSG_DEBUG(" #### content = %s #### ", pString);
+
+       if (!strcmp(pString, "normal"))
+               return MMS_SMIL_FONT_TYPE_NORMAL;
+       else if (!strcmp(pString, "italic"))
+               return MMS_SMIL_FONT_TYPE_ITALIC;
+       else if (!strcmp(pString, "bold"))
+               return MMS_SMIL_FONT_TYPE_BOLD;
+       else if (!strcmp(pString, "underline"))
+               return MMS_SMIL_FONT_TYPE_UNDERLINE;
+       else
+               return MMS_SMIL_FONT_TYPE_NORMAL;
+}
+
+bool MmsSmilGetMediaFilePath(MMS_MEDIA_S *pMedia, char *pszTemp, int msgID)
+{
+       if (!pMedia) {
+               MSG_DEBUG("pMedia is NULL");
+               return false;
+       }
+
+       snprintf(pMedia->szFilePath, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_DATA_PATH, pMedia->szSrc);
+       MSG_DEBUG("pMedia's filePath: %s", pMedia->szFilePath);
+
+       __MmsGetRealFileName(pMedia->mediatype, pMedia->szSrc, pMedia->szFileName, msgID);
+       MSG_DEBUG("pMedia's fileName: %s", pMedia->szFileName);
+
+       snprintf(pMedia->szContentID, MSG_MSG_ID_LEN+1, "%s", pszTemp);
+       MSG_DEBUG("pMedia's ContentID: %s", pMedia->szContentID);
+
+       return true;
+}
+
+
+/**    @fn             bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
+ *     @brief  Forms Smil Buffer using pstMsgBody. \n
+ *     @param[in/out]  pstMsgBody is Message handle. \n
+ *     @retval TRUE                            In case of Success. \n
+ *     @retval FALSE                           In case of failure. \n
+ */
+bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
+{
+       HMmsSmil hSmilDoc = INVALID_HOBJ;
+       int nIndex;
+       int nMediaIndex;
+       int nTotalPageNum;
+       int nTotalMediaNum;
+       int nRegionCount;
+       MMS_PAGE_S *pstPage;
+       MMS_MEDIA_S *pstMedia;
+       MMS_SMIL_REGION *pstRegion;
+       char *pszRawData;
+
+       MSG_BEGIN();
+
+       hSmilDoc = MmsSmilCreateEmptySmilDoc();
+       MSG_DEBUG("Smil Doc =%d",hSmilDoc);
+       if (INVALID_HOBJ == hSmilDoc) {
+               MSG_DEBUG("Invalid SmilDoc[%d]",hSmilDoc);
+               return false;
+       }
+       // Add Root Layout to Smil Document
+       if (false == MmsSmilAddRootLayout(hSmilDoc, &(pstMsgBody->rootlayout))) {
+               MSG_DEBUG("MmsSmilAddRootLayout Failed");
+               MmsSmilDestroyDoc(hSmilDoc);
+       }
+       //Add Region list to Smil Document
+       nRegionCount = pstMsgBody->regionCnt;
+       MSG_DEBUG(" Region Count =%d",nRegionCount);
+       for (nIndex = 0; nIndex < nRegionCount; nIndex++) {
+               MSG_DEBUG("Calling _MsgMmsGetSmilRegion");
+               pstRegion = _MsgMmsGetSmilRegion(pstMsgBody, nIndex);
+               if (NULL == pstRegion) {
+                       MSG_DEBUG("pstRegion is NULL");
+                       MmsSmilDestroyDoc(hSmilDoc);
+                       return false;
+               }
+               MSG_DEBUG("Calling MmsSmilAddRegion");
+               if (false == MmsSmilAddRegion(hSmilDoc, pstRegion)) {
+                       MSG_DEBUG("Adding Region to smil doc failed");
+                       MmsSmilDestroyDoc(hSmilDoc);
+                       return false;
+               }
+       }
+       // Add page list to Smil Document
+        nTotalPageNum = pstMsgBody->pageCnt ;
+       MSG_DEBUG(" Page Count =%d",nTotalPageNum);
+       for (nIndex = 0; nIndex < nTotalPageNum; nIndex++) {
+               MSG_DEBUG("Calling _MsgMmsGetPage");
+               pstPage = _MsgMmsGetPage(pstMsgBody, nIndex);
+               if (NULL == pstPage) {
+                       MSG_DEBUG("pstPage is NULL");
+                       MmsSmilDestroyDoc(hSmilDoc);
+                       return false;
+               }
+               // Add page to smil doc
+               MSG_DEBUG("Calling MmsSmilAddPage");
+               if (false == MmsSmilAddPage(hSmilDoc, pstPage)) {
+                       MSG_DEBUG("Adding page to smil doc failed");
+                       MmsSmilDestroyDoc(hSmilDoc);
+                       return false;
+               }
+               nTotalMediaNum = pstPage->mediaCnt;
+               MSG_DEBUG(" Media Count =%d",nTotalMediaNum);
+               for (nMediaIndex = 0; nMediaIndex < nTotalMediaNum; nMediaIndex++) {
+                       MSG_DEBUG("Calling _MsgMmsGetMedia");
+                       pstMedia = _MsgMmsGetMedia(pstPage, nMediaIndex);
+                       if (NULL == pstMedia) {
+                               MSG_DEBUG("pMedia is NULL");
+                               MmsSmilDestroyDoc(hSmilDoc);
+                               return false;
+                       }
+                       MSG_DEBUG("Calling MmsSmilAddMedia");
+                       if (false == MmsSmilAddMedia(hSmilDoc, nIndex, nMediaIndex, pstMedia, pstMedia->szContentID)) {
+                               MSG_DEBUG("MmsSmilAddMedia failed");
+                               MmsSmilDestroyDoc(hSmilDoc);
+                               return false;
+                       }
+               }
+       }
+       MSG_DEBUG("MMSGenerateSmilBuffer: Start update template");
+       pszRawData = MmsSmilGetRawData(hSmilDoc);
+       if (NULL == pszRawData) {
+               MSG_DEBUG("MMSGenerateSmilBuffer: MmsSmilGetRawData failed");
+               MmsSmilDestroyDoc(hSmilDoc);
+               return false;
+       }
+
+       char fullpath[MSG_FILEPATH_LEN_MAX] = {0,};
+       snprintf(fullpath, MSG_FILEPATH_LEN_MAX, MSG_SMIL_FILE_PATH"%s", pstMsgBody->szSmilFilePath);
+
+       if (MsgWriteSmilFile(fullpath, pszRawData, strlen(pszRawData) + 1) == false) {
+               MSG_DEBUG("MMSGenerateSmilBuffer: MsgWriteSmilFile failed");
+               xmlFree((xmlChar*)pszRawData);
+               MmsSmilDestroyDoc(hSmilDoc);
+               return false;
+       }
+
+       MSG_DEBUG("MMSGenerateSmilBuffer: complete update template\n");
+       xmlFree((xmlChar*)pszRawData);
+       MmsSmilDestroyDoc(hSmilDoc);
+       MSG_END();
+       return true;
+}
+
+/**    @fn             static HMmsSmil MmsSmilCreateEmptySmilDoc(void)
+ *     @brief  Creates default Smil Doc based on input gszEmptyRawDoc. \n
+ *     @retval Returns Smil Document number. \n
+ */
+HMmsSmil MmsSmilCreateEmptySmilDoc(void)
+{
+       HMmsSmil hMmsSmil;
+
+       MSG_BEGIN();
+
+       hMmsSmil = MmsSmilCreateSmilDoc(gszEmptyRawDoc);
+
+       MSG_DEBUG("Create an empty smilDoc.(Handle = %d)", hMmsSmil);
+
+       MSG_END();
+
+       return hMmsSmil;
+}
+
+/**    @fn                     static HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
+ *     @brief          Creates Smil Doc based on input pszRawData. \n
+ *     @param[in]      pszRawData is smil buffer. \n
+ *     @retval         Returns Smil Document number. \n
+ */
+HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
+{
+       int nSmilDocNo = 0;
+       xmlNodePtr stRootNode;
+
+       MSG_BEGIN();
+
+       // Destroy smil doc if present
+       if (NULL != __gpaMmsSmilDoc[nSmilDocNo]) {
+               MSG_DEBUG("Calling MmsSmilDestroyDoc");
+               if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
+                       MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
+               }
+       }
+
+       for (nSmilDocNo = 0; nSmilDocNo < MMS_SMIL_MAX_DOC; nSmilDocNo++) {
+               if (NULL == __gpaMmsSmilDoc[nSmilDocNo])
+                       break;
+       }
+
+       if (MMS_SMIL_MAX_DOC == nSmilDocNo) {
+               MSG_DEBUG("SmilDoc table is full. Can't create.");
+               return INVALID_HOBJ;
+       }
+       __gpaMmsSmilDoc[nSmilDocNo] = (MmsSmilDoc*)malloc(sizeof(MmsSmilDoc));
+       if (NULL ==  __gpaMmsSmilDoc[nSmilDocNo]) {
+               MSG_DEBUG("Memory Allocation Failed.");
+               return INVALID_HOBJ;
+       }
+       memset(__gpaMmsSmilDoc[nSmilDocNo], 0, sizeof(MmsSmilDoc));
+
+       __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc = xmlParseMemory(pszRawData, strlen(pszRawData));
+       if (NULL == __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
+               MSG_DEBUG("Document not parsed successfully.");
+               if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
+                       MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
+               }
+               return INVALID_HOBJ;
+       }
+       stRootNode = xmlDocGetRootElement(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc);
+       if (NULL == stRootNode) {
+               MSG_DEBUG("Empty document\n");
+               if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
+                       MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
+               }
+               return INVALID_HOBJ;
+       }
+       if (xmlStrcmp(stRootNode->name, (const xmlChar *) "smil")) {
+               MSG_DEBUG("Document of the wrong type, root node != smil");
+               if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
+                       MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
+               }
+               return INVALID_HOBJ;
+       }
+
+       __gpaMmsSmilDoc[nSmilDocNo]->pstRootNode = stRootNode;
+
+       MSG_END();
+       return ((HMmsSmil)nSmilDocNo);
+}
+
+/**    @fn                     static bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
+ *     @brief          Destroys Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @retval TRUE                            In case of Success. \n
+ *     @retval FALSE                           In case of failure. \n
+ */
+bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
+{
+       int nSmilDocNo = (int)hSmilDoc;
+       bool bFlag = true;
+       MSG_BEGIN();
+
+       if (0 <= nSmilDocNo &&
+               nSmilDocNo < MMS_SMIL_MAX_DOC &&
+               __gpaMmsSmilDoc[nSmilDocNo]) {
+               if (__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
+                       xmlFreeDoc(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc);
+               }
+
+               if (__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode) {
+                       //Need to Check
+               }
+               free(__gpaMmsSmilDoc[nSmilDocNo]);
+               __gpaMmsSmilDoc[nSmilDocNo] = NULL;
+       } else {
+               MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
+               bFlag =  false;
+       }
+
+       MSG_END();
+       return bFlag;
+}
+
+/**    @fn                     static bool IsValidSmilDocNo(int nSmilDocNo)
+ *     @brief          Form Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @retval         Returns Smil Buffer     In case of success. \n
+ *     @retval         Returns NULL                    In case of failure. \n
+ */
+bool IsValidSmilDocNo(int nSmilDocNo)
+{
+       bool bIsValidSmil = false;
+
+       MSG_BEGIN();
+
+       if (0 <= nSmilDocNo &&
+               nSmilDocNo < MMS_SMIL_MAX_DOC &&
+               __gpaMmsSmilDoc[nSmilDocNo] &&
+               __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
+               bIsValidSmil = true;
+       }
+
+       MSG_END();
+       return bIsValidSmil;
+}
+
+/**    @fn                     static char  MmsSmilGetRawData(HMmsSmil hSmilDoc)
+ *     @brief          Form Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @retval         Returns Smil Buffer     In case of success. \n
+ *     @retval         Returns NULL                    In case of failure. \n
+ */
+char *MmsSmilGetRawData(HMmsSmil hSmilDoc)
+{
+       int nSmilDocNo = (int)hSmilDoc;
+       char *pszRawData = NULL;
+
+       MSG_BEGIN();
+
+       if (IsValidSmilDocNo(nSmilDocNo)) {
+               xmlSaveFormatFileEnc("-", __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc, "UTF-8", 1);
+               xmlDocDumpMemory(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc, (xmlChar **)(&pszRawData) , NULL);
+               if (NULL == pszRawData) {
+                       MSG_DEBUG("Invalid pSmilDoc (now wellformed document)");
+               }
+               MSG_END();
+       } else {
+               MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
+       }
+       return pszRawData;
+}
+
+/**    @fn                     static bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
+ *     @brief          Add Page to Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @param[in]      pstSmilPage specifies page information. \n
+ *     @retval         TRUE                            In case of Success. \n
+ *     @retval         FALSE                           In case of failure. \n
+ */
+bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
+{
+       int nSmilDocNo = hSmilDoc;
+
+       MSG_BEGIN();
+
+       bool ret = true;
+
+       if (IsValidSmilDocNo(nSmilDocNo)) {
+               xmlNodePtr pstParElement;
+               xmlNodePtr pstBodyElement;
+               xmlNodePtr pstParList;
+               char szBuf[MSG_STDSTR_SHORT] = {0, };
+
+               pstBodyElement = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"body");
+
+               if (NULL == pstBodyElement) {
+                       MSG_DEBUG("There is no <body> node. Can't create <par> node.");
+                       return false;
+               }
+               MSG_DEBUG("Body Element Name = %s", (char *)pstBodyElement->name);
+               /* Create "par"  node and insert it */
+               pstParElement = xmlNewNode(NULL, (xmlChar *)"par");
+
+               if (NULL == pstParElement) {
+                       MSG_DEBUG("Can't create <par> node. (from XmlParser) \n");
+                       return false;
+               }
+               MSG_DEBUG("Par Element Name = %s", (char *)pstParElement->name);
+
+               /* Add attributes to "par" */
+               if (pstSmilPage->nDur > 0) {
+                       snprintf(szBuf, MSG_STDSTR_SHORT, "%dms", pstSmilPage->nDur);
+                       xmlSetProp(pstParElement, (const xmlChar *)"dur", (const xmlChar *)szBuf);
+               }
+               /* Find the insertion point : right sibling of the last <par> node or first child of <body> */
+
+               pstParList = xmlGetLastChild(pstBodyElement);
+
+               if (pstParList) {
+                       ret = __MmsSmilInsertNode(pstBodyElement, pstParList, pstParElement);
+               } else {
+                       ret = __MmsInsertFirstChild(pstBodyElement, pstParElement);
+               }
+       } else {
+               MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
+               return false;
+       }
+
+       return ret;
+}
+
+/**    @fn                     static bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
+ *     @brief          Add Rootlayout to Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @param[in]      pstSmilRootLayout specifies RootLayout information. \n
+ *     @retval         TRUE                            In case of Success. \n
+ *     @retval         FALSE                           In case of failure. \n
+ */
+bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
+{
+       int nSmilDocNo = hSmilDoc;
+       xmlNodePtr pstRootLayout = NULL;
+       xmlNodePtr pstLayoutList = NULL;
+       xmlNodePtr pstRootLayoutList = NULL;
+       char szBuf[MSG_STDSTR_SHORT] = {0, };
+
+       MSG_BEGIN();
+
+       if (IsValidSmilDocNo(nSmilDocNo)) {
+               pstLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"layout");
+
+               if (NULL == pstLayoutList) {
+                       MSG_DEBUG("There is no <layout> node. Can't create <root-layout> node.");
+                       return false;
+               }
+               MSG_DEBUG("Layout Element Name = %s ", (char *)pstLayoutList->name);
+
+               pstRootLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"root-layout");
+
+               if (NULL != pstRootLayoutList) {
+                       MSG_DEBUG("MmsSmilAddRootLayout: There is <root-layout> node already");
+                       MSG_DEBUG("Root Layout Element Name = %s  type=%d\n", (char *)pstRootLayoutList->name);
+                       return false;
+               }
+               /* Create "root-layout" node and insert it */
+               pstRootLayout = xmlNewNode(NULL, (xmlChar *)"root-layout");
+               if (NULL == pstRootLayout) {
+                       MSG_DEBUG("Can't create <root-layout> node. (from XmlParser)");
+                       return false;
+               }
+               MSG_DEBUG("Root Layout Element Name = %s", (char *)pstRootLayout->name);
+
+               if (pstSmilRootLayout->bgColor != SP_NO_COLOR_SET) {    // Replace value later
+                       xmlSetProp(pstRootLayout, (const xmlChar *)"backgroundColor", (const xmlChar *)__MmsSmilFindColorValue(pstSmilRootLayout->bgColor));
+               }
+               MSG_DEBUG(" Set Width");
+               if (true == pstSmilRootLayout->width.bUnitPercent) {
+                       snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRootLayout->width.value);
+                       xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)szBuf);
+               } else {
+                       if (pstSmilRootLayout->width.value > 0) {
+                               snprintf(szBuf, MSG_STDSTR_SHORT, "%d", pstSmilRootLayout->width.value);
+                               xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)szBuf);
+                       } else {
+                               xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)"100%");
+                       }
+               }
+               MSG_DEBUG(" Set Height");
+               if (true == pstSmilRootLayout->height.bUnitPercent) {
+                       snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRootLayout->height.value);
+                       xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)szBuf);
+               } else {
+                       if (pstSmilRootLayout->height.value > 0) {
+                               snprintf(szBuf, MSG_STDSTR_SHORT, "%d", pstSmilRootLayout->height.value);
+                               xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)szBuf);
+                       } else {
+                               xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)"100%");
+                       }
+               }
+               __MmsInsertFirstChild(pstLayoutList, pstRootLayout);
+
+               return true;
+       } else {
+               MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
+               return false;
+       }
+
+}
+
+
+/**    @fn                     static bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
+ *     @brief          Add Region to Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @param[in]      pstSmilRegion specifies Region information. \n
+ *     @retval         TRUE                            In case of Success. \n
+ *     @retval         FALSE                           In case of failure. \n
+ */
+bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
+{
+       int nSmilDocNo = hSmilDoc;
+
+       MSG_BEGIN();
+
+       if (IsValidSmilDocNo(nSmilDocNo)) {
+               int nRootWidth = 0;
+               int nRootHeight = 0;
+               xmlNodePtr pstRegion;
+               xmlNodePtr pstLayoutList;
+               xmlNodePtr pstRootLayoutList;
+               xmlAttrPtr pAttribute;
+               char szBuf[MSG_STDSTR_SHORT] = {0, };
+
+               pstLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"layout");
+               if (NULL == pstLayoutList) {
+                       MSG_DEBUG(" There is no <layout> node. Can't create <region> node");
+                       return false;
+               }
+               MSG_DEBUG("Layout Element Name = %s ", (char *)pstLayoutList->name);
+
+               /* Find the insertion point : right sibling of the last root-layout node or first child of pLayout */
+               pstRootLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"root-layout");
+
+               if (NULL == pstRootLayoutList) {
+                       MSG_DEBUG("There is no <root-layout> node. Can't create <root-layout> node.");
+                       return false;
+               } else {
+                       MSG_DEBUG("Root Layout Element Name = %s ", (char *)pstRootLayoutList->name);
+                       pAttribute =  pstRootLayoutList->properties;
+               }
+
+               if (NULL == pAttribute) {
+                       MSG_DEBUG("There is no Attribute in <root-layout> node.");
+                       return false;
+               }
+
+               xmlAttrPtr pstAttr = pAttribute;
+               for ( ; pstAttr; pstAttr = pstAttr->next) {
+                       int     attrType;
+                       MSG_DEBUG("AttributeType: (%s, %s) ", pstAttr->name, pstAttr->children->content);
+                       switch (attrType = MmsSmilGetAttrID((char *)pstAttr->name)) {
+                       case ATTRIBUTE_WIDTH:
+                               {
+                                       int bUnitPercent;
+
+                                       if (strchr((char *)pstAttr->children->content, '%'))
+                                               bUnitPercent = true;
+                                       else
+                                               bUnitPercent = false;
+
+                                       nRootWidth = atoi((char *)pstAttr->children->content);
+                               }
+                               break;
+
+                       case ATTRIBUTE_HEIGHT:
+                               {
+                                       int bUnitPercent;
+
+                                       if (strchr((char *)pstAttr->children->content, '%'))
+                                               bUnitPercent = true;
+                                       else
+                                               bUnitPercent = false;
+
+                                       nRootHeight = atoi((char *)pstAttr->children->content);
+                               }
+                               break;
+                       }
+               }
+
+               /* Create "region" node and insert it */
+               MSG_DEBUG("Create Region Node");
+               pstRegion = xmlNewNode(NULL, (xmlChar *)"region");
+               if (NULL == pstRegion) {
+                       MSG_DEBUG("Can't create <region> node. (from XmlParser)");
+                       return false;
+               }
+               /* Add attributes */
+               if (pstSmilRegion) {
+                       MSG_DEBUG(" [Set Attribute] : Region Id");
+                       if (strlen(pstSmilRegion->szID) > 0) {
+                               xmlSetProp(pstRegion, (const xmlChar *)"id", (const xmlChar *)pstSmilRegion->szID);
+                       }
+                       MSG_DEBUG(" [Set Attribute] : BkGrd Color");
+                       // Default Color WHITE, always send
+                       if (pstSmilRegion->bgColor != SP_NO_COLOR_SET) {
+                               xmlSetProp(pstRegion, (const xmlChar *)"backgroundColor", (const xmlChar *)__MmsSmilFindColorValue(pstSmilRegion->bgColor));
+                       }
+                       MSG_DEBUG(" [Set Attribute] : Width");
+
+                       if (true == pstSmilRegion->width.bUnitPercent) {
+                               if (pstSmilRegion->width.value > 0) {
+                                       snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->width.value);
+                                       xmlSetProp(pstRegion, (const xmlChar *)"width", (const xmlChar *)szBuf);
+                                       MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->width = %d   \n", pstSmilRegion->width.value);
+                               }
+                       } else {
+                               // Note: nRootWidth should be in terms of value(pixel) not unitpercent(%)
+                               // Validation should be done before this.
+                               if (pstSmilRegion->width.value >= 0 &&
+                                       pstSmilRegion->width.value <= nRootWidth) {
+                                       int iWidth = (pstSmilRegion->width.value * 100) / nRootWidth;
+
+                                       snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iWidth);
+                                       xmlSetProp(pstRegion, (const xmlChar *)"width", (const xmlChar *)szBuf);
+                                       MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->width= %d  iWidth = %d \n", pstSmilRegion->width.value, iWidth);
+                               }
+                       }
+                       MSG_DEBUG(" [Set Attribute] : Height");
+                       if (true == pstSmilRegion->height.bUnitPercent) {
+                               if (pstSmilRegion->height.value > 0) {
+                                       snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->height.value);
+                                       xmlSetProp(pstRegion, (const xmlChar *)"height", (const xmlChar *)szBuf);
+                                       MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->height = %d   \n", pstSmilRegion->height.value);
+                               }
+                       } else {
+                               // Note: nRootHeight should be in terms of value(pixel) not unitpercent(%)
+                               // Validation should be done before this.
+                               if (pstSmilRegion->height.value >= 0 &&
+                                       pstSmilRegion->height.value <= nRootHeight) {
+                                       int iHeight = (pstSmilRegion->height.value * 100) / nRootHeight;
+
+                                       snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iHeight);
+                                       xmlSetProp(pstRegion, (const xmlChar *)"height", (const xmlChar *)szBuf);
+                                       MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->height = %d  iHeight = %d \n", pstSmilRegion->height.value, iHeight);
+                               }
+                       }
+                       MSG_DEBUG(" [Set Attribute] : Left");
+                       if (true == pstSmilRegion->nLeft.bUnitPercent) {
+                               if (pstSmilRegion->nLeft.value > 0) {
+                                       snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->nLeft.value);
+                                       xmlSetProp(pstRegion, (const xmlChar *)"left", (const xmlChar *)szBuf);
+                                       MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->left = %d   \n", pstSmilRegion->nLeft.value);
+                               }
+                       } else {
+                               // Note: nRootWidth should be in terms of value(pixel) not unitpercent(%)
+                               // Validation should be done before this.
+                               if (pstSmilRegion->nLeft.value >= 0) {
+                                       int iLeft = (pstSmilRegion->nLeft.value * 100) / nRootWidth;
+
+                                       snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iLeft);
+                                       xmlSetProp(pstRegion, (const xmlChar *)"left", (const xmlChar *)szBuf);
+                                       MSG_DEBUG("MmsSmilAddRegion: SmilRegion->iLeft = %d       iLeft = %d \n", pstSmilRegion->nLeft.value, iLeft);
+                               }
+                       }
+                       MSG_DEBUG(" [Set Attribute] : Top");
+                       if (true == pstSmilRegion->nTop.bUnitPercent) {
+                               if (pstSmilRegion->nTop.value > 0) {
+                                       snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->nTop.value);
+                                       xmlSetProp(pstRegion, (const xmlChar *)"top", (const xmlChar *)szBuf);
+                                       MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->nTop= %d   \n", pstSmilRegion->nTop.value);
+                               }
+                       } else {
+                               // Note: nRootHeight should be in terms of value(pixel) not unitpercent(%)
+                               // Validation should be done before this.
+                               if (pstSmilRegion->nTop.value >= 0) {
+                                       int iTop = (pstSmilRegion->nTop.value * 100) / nRootHeight;
+
+                                       snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iTop);
+                                       xmlSetProp(pstRegion, (const xmlChar *)"top", (const xmlChar *)szBuf);
+                                       MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->nTop= %d  iTop = %d \n", pstSmilRegion->nTop.value, iTop);
+                               }
+                       }
+                       MSG_DEBUG(" [Set Attribute] : Fit");
+                       //Fit Attribute
+                       if (MMSUI_IMAGE_REGION_FIT_MEET == pstSmilRegion->fit) {
+                               xmlSetProp(pstRegion, (const xmlChar *)"fit", (const xmlChar *)"meet");
+                       } else if (MMSUI_IMAGE_REGION_FIT_HIDDEN == pstSmilRegion->fit) {
+                               xmlSetProp(pstRegion, (const xmlChar *)"fit", (const xmlChar *)"hidden");
+                       }
+               } else
+                       MSG_DEBUG("There is no attribute in <region> node\n");
+
+               __MmsSmilInsertNode(pstLayoutList, pstRootLayoutList, pstRegion);
+
+               MSG_END();
+               return true;
+       } else {
+               MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)\n", nSmilDocNo);
+               return false;
+       }
+}
+
+/**    @fn                     static bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
+ *     @brief          Add Media to Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @param[in]      nPageNo specifies page number to which media belongs. \n
+ *     @param[in]      pstSmilMedia specifies Media information. \n
+ *     @param[in]      pszContentID specifies Content ID of media. \n
+ *     @retval         TRUE                            In case of Success. \n
+ *     @retval         FALSE                           In case of failure. \n
+ */
+bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, int nMediaIdx, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
+{
+       int nSmilDocNo = hSmilDoc;
+
+       MSG_BEGIN();
+
+       if (NULL == pszContentID) {
+               MSG_DEBUG(" Content Id is NULL");
+               return false;
+       }
+       memset(pszContentID, 0, MMS_CONTENT_ID_LEN + 1);
+       if (IsValidSmilDocNo(nSmilDocNo)) {
+               int nIndex = 0;
+               xmlNode *pstMedia;
+               xmlNode *pstLastChild;
+               xmlNodePtr pstParList;
+               char *pszExt ;
+
+               pstParList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"par");
+               if (NULL == pstParList) {
+                       MSG_DEBUG("There is no <par> node. Can't create <media> node.");
+                       return false;
+               }
+               MSG_DEBUG("Par Element Name = %s ", (char *)pstParList->name);
+               for (nIndex = 0; (pstParList &&  nIndex < nPageNo); nIndex++) {
+                       pstParList = pstParList->next;
+               }
+               if (NULL == pstParList) {
+                       MSG_DEBUG("There is no such page node. Can't insert <media> node.");
+                       return false;
+               }
+               MSG_DEBUG("Par Element Name = %s ", (char *)pstParList->name);
+               /* Find insertion point and make a contentID */
+
+               pstLastChild = xmlGetLastChild(pstParList);
+
+               pszExt = strrchr(pstSmilMedia->szFileName, '.');
+               if (pszExt && !strrchr(pszExt, '/'))
+                       snprintf(pszContentID, MSG_MSG_ID_LEN+1, "%lu_%lu%s", (ULONG)nPageNo, (ULONG)nMediaIdx, pszExt);
+               else
+                       snprintf(pszContentID, MSG_MSG_ID_LEN+1, "%lu_%lu", (ULONG)nPageNo, (ULONG)nMediaIdx);
+
+               /* Create <media> node and insert set attribute */
+               MSG_DEBUG(" Create Media Node");
+               switch (pstSmilMedia->mediatype) {
+               case MMS_SMIL_MEDIA_TEXT:
+                       pstMedia = __MmsCreateTextNode(pstSmilMedia, pszContentID);
+                       break;
+               case MMS_SMIL_MEDIA_AUDIO:
+               case MMS_SMIL_MEDIA_VIDEO:
+               case MMS_SMIL_MEDIA_IMG:
+                       pstMedia = __MmsCreateMMNode(pstSmilMedia, pszContentID);
+                       break;
+               default:
+                       MSG_DEBUG("Invalid media type. Can't insert such-<media> node.");
+                       return false;
+               }
+
+               if (NULL == pstMedia) {
+                       MSG_DEBUG("Can't create <media> node. (from XmlParser) (media-type:%d)", pstSmilMedia->mediatype);
+                       return false;
+               }
+
+               /* Find the insertion point : the last child of <par> node */
+               if (pstLastChild)
+                       __MmsSmilInsertNode(pstParList, pstLastChild, pstMedia);
+               else
+                       __MmsInsertFirstChild(pstParList, pstMedia);
+
+               MSG_END();
+               return true;
+       } else {
+               MSG_DEBUG("MmsSmilAddMedia: Invalid SmilDoc(hSmilDoc:%d)\n", nSmilDocNo);
+               return false;
+       }
+}
+
+/**    @fn                     static xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
+ *     @brief          Create Text Element. \n
+ *     @param[in]      pstSmilMedia specifies Media information. \n
+ *     @param[in]      pszContentID specifies Content ID of media. \n
+ *     @retval         Text Element node               In case of Success. \n
+ *     @retval         NULL                            In case of failure. \n
+ */
+xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
+{
+       xmlNode *pstMedia = NULL;
+       xmlNode *pstParam = NULL;
+       char szBuf[MSG_STDSTR_SHORT] = {0, };
+       char szSizeBuf[MSG_STDSTR_SHORT] = {0, };
+
+       MSG_BEGIN();
+
+       pstMedia = xmlNewNode(NULL, (xmlChar *)"text");
+       if (NULL == pstMedia) {
+               MSG_DEBUG("Can't create <Text> node.");
+               return NULL;
+       }
+       MSG_DEBUG("Text Element Name = %s ", (char *)pstMedia->name);
+
+       /* Add attributes */
+       if (pstSmilMedia) {
+               MSG_DEBUG("[Set Attribute] Region Id ");
+               if (strlen(pstSmilMedia->regionId) > 0) {
+                       xmlSetProp(pstMedia, (const xmlChar *)"region", (const xmlChar *)pstSmilMedia->regionId);
+               }
+               MSG_DEBUG("[Set Attribute] Begin ");
+               if (pstSmilMedia->sMedia.sText.nBegin > 0) {
+                       snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sText.nBegin);
+                       xmlSetProp(pstMedia, (const xmlChar *)"begin", (const xmlChar *) szBuf);
+               }
+               MSG_DEBUG("[Set Attribute] Duration");
+               if (pstSmilMedia->sMedia.sText.nDurTime > 0) {
+                       snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sText.nDurTime);
+                       xmlSetProp(pstMedia, (const xmlChar *)"dur", (const xmlChar *)szBuf);
+               }
+               MSG_DEBUG("[Set Attribute] Alternate");
+               if (strlen(pstSmilMedia->szAlt) > 0) {
+                       snprintf (szBuf, sizeof(szBuf), "%s", pstSmilMedia->szAlt);
+                       xmlSetProp(pstMedia, (const xmlChar *)"alt", (const xmlChar *)szBuf);
+               }
+               MSG_DEBUG("[Set Attribute] Src");
+
+               char szFilePathWithCid[MMS_CONTENT_ID_LEN + 5]; // for "cid:"
+
+               snprintf (szFilePathWithCid, sizeof(szFilePathWithCid), "cid:%s", pszContentID);
+               _MmsSmilSetAttribute(pstMedia, (char *)"src", szFilePathWithCid);
+
+               MSG_DEBUG("[Set Attribute] Font Foreground Color");
+
+               if (pstSmilMedia->sMedia.sText.nColor!= SP_BLACK) {     // Chnage after getting exact values
+                       pstParam = xmlNewNode(NULL, (xmlChar *)"param");
+
+                       if (NULL == pstParam) {
+                               MSG_DEBUG("Cannot create <param> node");
+                               return false;
+                       }
+                       xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"foreground-color");
+                       xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)__MmsSmilFindColorValue(pstSmilMedia->sMedia.sText.nColor));
+                       __MmsInsertFirstChild(pstMedia, pstParam);
+               }
+
+               MSG_DEBUG("[Set Attribute] Font Background Color");
+
+               if (pstSmilMedia->sMedia.sText.nBgColor != SP_BLACK) {  // Chnage after getting exact values
+                       pstParam = xmlNewNode(NULL, (xmlChar *)"param");
+
+                       if (NULL == pstParam) {
+                               MSG_DEBUG("Cannot create <param> node");
+                               return false;
+                       }
+                       xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"background-color");
+                       xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)__MmsSmilFindColorValue(pstSmilMedia->sMedia.sText.nBgColor));
+                       __MmsInsertFirstChild(pstMedia, pstParam);
+               }
+
+               MSG_DEBUG("[Set Attribute] Size");
+               if (pstSmilMedia->sMedia.sText.nSize > 0) {
+                       pstParam = xmlNewNode(NULL, (xmlChar *)"param");
+                       if (NULL == pstParam) {
+                               MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
+                               return false;
+                       }
+
+                       if (pstSmilMedia->sMedia.sText.nSize  <= MMS_SMIL_FONT_SIZE_SMALL)
+                               strcpy(szSizeBuf, "small");
+                       else if ((pstSmilMedia->sMedia.sText.nSize  > MMS_SMIL_FONT_SIZE_SMALL) && (pstSmilMedia->sMedia.sText.nSize  < MMS_SMIL_FONT_SIZE_LARGE))
+                               strcpy(szSizeBuf, "normal");
+                       else
+                               strcpy(szSizeBuf, "large");
+
+                       xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textsize");
+                       xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
+                       __MmsInsertFirstChild(pstMedia, pstParam);
+               }
+
+               if (pstSmilMedia->sMedia.sText.bBold == true) {
+                       pstParam = xmlNewNode(NULL, (xmlChar *)"param");
+                       if (NULL == pstParam) {
+                               MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
+                               return false;
+                       }
+
+                       strcpy(szSizeBuf, "bold");
+
+                       xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
+                       xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
+                       __MmsInsertFirstChild(pstMedia, pstParam);
+               }
+
+               if (pstSmilMedia->sMedia.sText.bItalic == true) {
+                       pstParam = xmlNewNode(NULL, (xmlChar *)"param");
+                       if (NULL == pstParam) {
+                               MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
+                               return false;
+                       }
+
+                       strcpy(szSizeBuf, "italic");
+
+                       xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
+                       xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
+                       __MmsInsertFirstChild(pstMedia, pstParam);
+               }
+
+               if (pstSmilMedia->sMedia.sText.bUnderLine == true) {
+                       pstParam = xmlNewNode(NULL, (xmlChar *)"param");
+                       if (NULL == pstParam) {
+                               MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
+                               return false;
+                       }
+
+                       strcpy(szSizeBuf, "underline");
+
+                       xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
+                       xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
+                       __MmsInsertFirstChild(pstMedia, pstParam);
+               }
+       }
+
+       MSG_END();
+       return pstMedia;
+}
+
+/**    @fn                     static xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
+ *     @brief          Create Image/Audio/Video Element. \n
+ *     @param[in]      pstSmilMedia specifies Media information. \n
+ *     @param[in]      pszContentID specifies Content ID of media. \n
+ *     @retval         Image/Audio/Video Element node  In case of Success. \n
+ *     @retval         NULL                                                    In case of failure. \n
+ */
+xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
+{
+       xmlNode *pstMedia = NULL;
+       char szBuf[MSG_STDSTR_SHORT] = {0, };
+
+       MSG_BEGIN();
+
+       if (!pstSmilMedia)
+               return NULL;
+
+       switch (pstSmilMedia->mediatype) {
+       case MMS_SMIL_MEDIA_AUDIO:
+               pstMedia = xmlNewNode(NULL, (xmlChar *)"audio");
+               break;
+
+       case MMS_SMIL_MEDIA_VIDEO:
+               pstMedia = xmlNewNode(NULL, (xmlChar *)"video");
+               break;
+
+       case MMS_SMIL_MEDIA_IMG:
+               pstMedia = xmlNewNode(NULL, (xmlChar *)"img");
+               break;
+
+       default:
+               MSG_DEBUG("Invalid media type. Can't insert such-<media> node.");
+               return NULL;
+       }
+
+       if (pstSmilMedia) {
+               char szFilePathWithCid[MMS_CONTENT_ID_LEN + 5];         // for "cid:"
+
+               MSG_DEBUG("[Set Attribute] Region Id ");
+               if (strlen(pstSmilMedia->regionId) > 0) {
+                       xmlSetProp(pstMedia, (const xmlChar *)"region", (const xmlChar *)pstSmilMedia->regionId);
+               }
+               MSG_DEBUG("[Set Attribute] Src ");
+               snprintf (szFilePathWithCid, sizeof(szFilePathWithCid), "cid:%s", pszContentID);
+               _MmsSmilSetAttribute(pstMedia, (char *)"src", szFilePathWithCid);
+
+               MSG_DEBUG("[Set Attribute] Begin ");
+               if (pstSmilMedia->sMedia.sAVI.nBegin > 0) {
+                       snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sAVI.nBegin);
+                       xmlSetProp(pstMedia, (const xmlChar *)"begin", (const xmlChar *)szBuf);
+               }
+               MSG_DEBUG("[Set Attribute] Duration ");
+               if (pstSmilMedia->sMedia.sAVI.nDurTime > 0) {
+                       snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sAVI.nDurTime);
+                       xmlSetProp(pstMedia, (const xmlChar *)"dur", (const xmlChar *)szBuf);
+               }
+               MSG_DEBUG("[Set Attribute] Alt ");
+               if (strlen(pstSmilMedia->szAlt) > 0) {
+                       snprintf (szBuf, sizeof(szBuf), "%s", pstSmilMedia->szAlt);
+                       xmlSetProp(pstMedia, (const xmlChar *)"alt", (const xmlChar *)szBuf);
+               }
+       } else {
+               MSG_DEBUG("There is no attribute in such-<media> node");
+       }
+
+       MSG_END();
+       return pstMedia;
+}
+
+/**    @fn                     static bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pstCurr)
+ *     @brief          Inserts first child to parent node. \n
+ *     @param[in]      pstParent specifies Parent node. \n
+ *     @param[in]      pstCurr specifies Child node. \n
+ *     @retval         TRUE                            In case of Success. \n
+ *     @retval         FALSE                           In case of failure. \n
+ */
+bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pstCurr)
+{
+       bool bFlag = true;
+
+       MSG_BEGIN();
+
+        if (NULL == xmlAddChild(pstParent, pstCurr)) {
+               MSG_DEBUG("%s Node not added", pstCurr->name);
+               bFlag = false;
+        }
+
+        MSG_END();
+        return bFlag;
+}
+
+
+/**    @fn                     static bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pstCurr)
+ *     @brief          Inserts node. \n
+ *     @param[in]      pstParent specifies Parent node. \n
+ *     @param[in]      pstLeftSibling specifies Left Sibling node. \n
+ *     @param[in]      pstCurr specifies Child node. \n
+ *     @retval         TRUE                            In case of Success. \n
+ *     @retval         FALSE                           In case of failure. \n
+ */
+bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pstCurr)
+{
+       MSG_BEGIN();
+       bool bFlag = true;
+
+       if (pstLeftSibling) {
+               /* Parent Node is Unused */
+
+               while (pstLeftSibling->next !=NULL)
+                       pstLeftSibling = pstLeftSibling->next;
+
+                if (NULL == xmlAddNextSibling(pstLeftSibling, pstCurr)) {
+                       MSG_DEBUG("%s Node not added", pstCurr->name);
+                       bFlag = false;
+                }
+       } else {
+                if (NULL == xmlAddChild(pstParent, pstCurr)) {
+                        MSG_DEBUG("%s Node not added", pstCurr->name);
+                       bFlag = false;
+                }
+       }
+       MSG_END();
+       return bFlag;
+}
+
+
+bool __MmsGetRealFileName(MmsSmilMediaType mediaType, char *pszSrc, char *pszName, int msgID)
+{
+       MsgType partHeader;
+       int partCnt;
+       int i;
+
+       MSG_DEBUG("__MmsUiGetRealFileName: mediaType[%d]", mediaType);
+       MSG_DEBUG("__MmsUiGetRealFileName: pszSrc[%s]\n", pszSrc);
+
+       if (!pszName) {
+               MSG_DEBUG("__MmsUiGetRealFileName: pszName is null\n");
+               return false;
+       }
+
+       if (mediaType == MMS_SMIL_MEDIA_TEXT || mediaType == MMS_SMIL_MEDIA_INVALID) {
+               MSG_DEBUG("__MmsUiGetRealFileName: invalid mediaType(=%d)\n", mediaType);
+               return false;
+       }
+
+       partCnt = MmsGetMediaPartCount(msgID);
+
+       if (partCnt < 0) {
+               MSG_DEBUG("__MmsUiGetRealFileName: partCnt < 0, (=%d)\n", partCnt);
+               return false;
+       }
+
+       for (i = 0; i < partCnt; i++) {
+               MmsGetMediaPartHeader(i, &partHeader);
+
+               if (mediaType == MMS_SMIL_MEDIA_AUDIO ||
+                       mediaType == MMS_SMIL_MEDIA_VIDEO ||
+                       mediaType == MMS_SMIL_MEDIA_IMG) {
+                       if (!strcmp(partHeader.param.szFileName , pszSrc)) {
+                               // Found
+                               MSG_DEBUG("__MmsUiGetRealFileName: pszSrc[%s]\n", pszSrc);
+                               break;
+                       }
+               }
+       }
+
+       if (i == partCnt)
+               return false;
+
+       if (partHeader.param.szName[0] != '\0') {
+               int nameLen = strlen(partHeader.param.szName);
+
+               if (nameLen > MSG_FILENAME_LEN_MAX - 1) {
+                       ;//Need to check
+               } else {
+                       strcpy(pszName, partHeader.param.szName);
+               }
+
+               return true;
+       }
+       return false;
+}
+
+/**    @fn                     static void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
+ *     @brief          Sets Attribute. \n
+ *     @param[in]      pNode specifies node. \n
+ *     @param[in]      szField specifies attribute field. \n
+ *     @param[in]      szValue specifies value of field \n
+ */
+void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
+{
+       MSG_BEGIN();
+
+       if (pNode && szField && strlen(szField)) {
+               if (szValue && strlen(szValue)) {
+                       xmlSetProp(pNode, (const xmlChar *)szField, (const xmlChar *)szValue);
+               } else {
+                       xmlSetProp(pNode, (const xmlChar *)szField, (const xmlChar *)"");
+               }
+       }
+
+       MSG_END();
+}
+
+/**    @fn                     static char *__MmsSmilFindColorValue(int nValue)
+ *     @brief          Converts color to RGB. \n
+ *     @param[in]      nValue specifies color value. \n
+ *     @retval         RGB value. \n
+ */
+char *__MmsSmilFindColorValue(int nValue)
+{
+       unsigned char red = (nValue & 0xFF0000) >> 16;
+       unsigned char green = (nValue & 0x00FF00) >> 8;
+       unsigned char blue = nValue & 0x0000FF;
+
+       MSG_BEGIN();
+
+       snprintf(gszColor,MMS_SMIL_COLOR_SIZE, "#%02x%02x%02x", red, green, blue);
+       MSG_DEBUG("__MmsSmilFindColorValue: gszColor %s \n", gszColor);
+
+       MSG_END();
+       return gszColor;
+}
+
+/**    @fn                     static xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszValue)
+ *     @brief          Get node based on pszValue. \n
+ *     @param[in]      pNode specifies node. \n
+ *     @param[in]      pszName specifies name field. \n
+ *     @retval         RGB value. \n
+ */
+xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszName)
+{
+       MSG_BEGIN();
+
+       if ((NULL != pstNode) && (NULL != pszName)) {
+               xmlNodePtr pstTempNode;
+               xmlNodePtr pstReturnNode;
+
+               pstTempNode = pstNode;
+
+               for ( ; pstTempNode; pstTempNode = pstTempNode->next) {
+                       MSG_DEBUG("\n Node Name = %s[%p] children =%p \n", (char *)pstTempNode->name, pstTempNode, pstTempNode->children);
+                       MSG_DEBUG("\n Compare Parent Node = %s[%p] \n", (char *)pstTempNode->name, pstTempNode);
+                       if (0 == strcasecmp((char *)pstTempNode->name, pszName)) {
+                               return pstTempNode;
+                       }
+
+                       if (pstTempNode->children) {
+                               MSG_DEBUG("\n Enter Inside\n");
+                               pstReturnNode = UtilxmlStringGetNodeList(pstTempNode->children, pszName);
+                               if (NULL != pstReturnNode) {
+                                       return pstReturnNode;
+                               }
+                       }
+
+               }
+       }
+       return NULL;
+}
+
diff --git a/plugin/mms_plugin/MmsPluginStorage.cpp b/plugin/mms_plugin/MmsPluginStorage.cpp
new file mode 100755 (executable)
index 0000000..150deb9
--- /dev/null
@@ -0,0 +1,1682 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include <mm_file.h>
+#include <mm_util_jpeg.h>
+
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MsgUtilFile.h"
+#include "MsgMmsMessage.h"
+#include "MsgNotificationWrapper.h"
+#include "MsgUtilStorage.h"
+
+#include "MmsPluginStorage.h"
+#include "MmsPluginSetup.h"
+#include "MmsPluginStorage.h"
+#include "MmsPluginCodec.h"
+#include "MmsPluginSmil.h"
+#include "MmsPluginDrm.h"
+
+#include "media-thumbnail.h"
+#include <mm_util_imgp.h>
+#include <mm_util_jpeg.h>
+
+#include "MsgHelper.h"
+
+
+static void __MmsReleaseMmsLists(MMS_MESSAGE_DATA_S *mms_data)
+{
+       _MsgMmsReleasePageList(mms_data);
+       _MsgMmsReleaseRegionList(mms_data);
+       _MsgMmsReleaseAttachList(mms_data);
+       _MsgMmsReleaseTransitionList(mms_data);
+       _MsgMmsReleaseMetaList(mms_data);
+}
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginStorage - Member Functions
+==================================================================================================*/
+MmsPluginStorage *MmsPluginStorage::pInstance = NULL;
+
+
+MmsPluginStorage::MmsPluginStorage()
+{
+       memset(&mmsMsg, 0, sizeof(MmsMsg));
+}
+
+
+MmsPluginStorage::~MmsPluginStorage()
+{
+       if (dbHandle.disconnect() != MSG_SUCCESS) {
+               MSG_DEBUG("DB Disconnect Fail");
+       }
+}
+
+
+MmsPluginStorage *MmsPluginStorage::instance()
+{
+       if (!pInstance)
+               pInstance = new MmsPluginStorage();
+
+       return pInstance;
+}
+
+
+void MmsPluginStorage::getMmsMessage(MmsMsg **pMmsMsg)
+{
+       *pMmsMsg = &mmsMsg;
+}
+
+
+void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T     err;
+
+       MmsMsg mmsMsg;
+
+       bzero(&mmsMsg, sizeof(mmsMsg));
+
+       mode_t file_mode = (S_IRUSR | S_IWUSR);
+
+       if (pMsgInfo->msgType.subType == MSG_SENDREQ_MMS) {
+
+               char szTemp[MAX_MSG_DATA_LEN + 1];
+
+               MMS_MESSAGE_DATA_S mmsMsgData;
+
+               if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) {
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+
+                       MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                       __MmsReleaseMmsLists(&mmsMsgData);
+
+                       THROW(MsgException::MMS_PLG_ERROR, "MMS Message Compose Error");
+               }
+
+               if (pMsgInfo->msgId == pMsgInfo->referenceId) {
+                       char fileName[MSG_FILENAME_LEN_MAX+1] = {0,};
+
+                       FILE *pFile = NULL;
+
+                       strcpy(szTemp,pMsgInfo->msgData);
+
+                       snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId);
+
+                       if (addMmsMsgToDB(&mmsMsg, pMsgInfo, _MsgMmsGetAttachCount(&mmsMsgData)) != MSG_SUCCESS) {
+                               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                               MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                               __MmsReleaseMmsLists(&mmsMsgData);
+
+                               THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
+                       }
+
+                       strcpy((char *)pMsgInfo->msgData,szTemp);
+
+                       snprintf(fileName, MSG_FILENAME_LEN_MAX+1, MSG_DATA_PATH"%d", mmsMsg.msgID);
+
+                       pFile = MsgOpenMMSFile(fileName);
+                       if (!pFile) {
+                               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                               MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                               __MmsReleaseMmsLists(&mmsMsgData);
+                               THROW(MsgException::MMS_PLG_ERROR, "MMS File open Error");
+                       }
+
+                       if (fchmod(fileno(pFile), file_mode) < 0) {
+                               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                               MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                               __MmsReleaseMmsLists(&mmsMsgData);
+                               MsgCloseFile(pFile);
+
+                               THROW(MsgException::MMS_PLG_ERROR, "chmod() error: %s", strerror(errno));
+                       }
+
+                       if (_MmsEncodeSendReq(pFile, &mmsMsg) != true) {
+                               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                               MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                               __MmsReleaseMmsLists(&mmsMsgData);
+                               MsgCloseFile(pFile);
+
+                               THROW(MsgException::MMS_PLG_ERROR, "MMS Message Encode Send Req Error");
+                       }
+
+                       MsgFsync(pFile);        //file is written to device immediately, it prevents missing file data from unexpected power off
+                       MsgCloseFile(pFile);
+
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                       __MmsReleaseMmsLists(&mmsMsgData);
+               } else {
+                       char szTemp[MAX_MSG_DATA_LEN + 1];
+
+                       strcpy(szTemp,pMsgInfo->msgData);
+
+                       snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pMsgInfo->referenceId);
+
+                       if (addMmsMsgToDB(&mmsMsg, pMsgInfo, _MsgMmsGetAttachCount(&mmsMsgData)) != MSG_SUCCESS) {
+                               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                               MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                               __MmsReleaseMmsLists(&mmsMsgData);
+
+                               THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
+                       }
+
+                       strcpy((char *)pMsgInfo->msgData,szTemp);
+
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeAttrib(&mmsMsg.mmsAttrib);
+
+                       __MmsReleaseMmsLists(&mmsMsgData);
+               }
+       } else if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) {
+               MSG_DEBUG("######## MmsPlgAddMessage -> MSG_NOTIFICATIONIND_MMS ###########");
+
+               MmsComposeNotiMessage(&mmsMsg, pMsgInfo->msgId);
+
+               //Need to store mms specific data (contents location, TrID, ExpiryTime, Delivery Report, message ID)
+               if (addMmsMsgToDB(&mmsMsg, pMsgInfo) != MSG_SUCCESS) {
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
+               }
+       } else if (pMsgInfo->msgType.subType == MSG_SENDCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS) {
+               MmsMsg *pMsg = NULL;
+               char szTemp[MAX_MSG_DATA_LEN + 1]= {0, };
+
+               if (!_MmsReadMsgBody(pMsgInfo->msgId, true, true, pFileData))
+                       THROW(MsgException::MMS_PLG_ERROR, "_MmsReadMsgBody Error");
+
+               MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+
+               if (pMsgInfo->msgType.subType == MSG_SENDCONF_MMS)
+                       pMsgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS;
+               else
+                       pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS;
+
+               strcpy(szTemp,pMsgInfo->msgData);
+               memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
+               strncpy(pMsgInfo->msgData, pFileData, MAX_MSG_DATA_LEN);
+
+               MmsPluginStorage *pStorage = MmsPluginStorage::instance();
+
+               MMS_MESSAGE_DATA_S mmsMsgData;
+               if (mmsHeader.msgType.type == MIME_MULTIPART_RELATED || mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
+                       char *pSmilDoc;
+                       MmsMsg *pMsg = NULL;
+                       char szFileName[MSG_FILENAME_LEN_MAX] = {0, };
+
+                       mmsMsgData.regionCnt = 0;
+                       mmsMsgData.pageCnt = 0;
+                       mmsMsgData.attachCnt = 0;
+                       mmsMsgData.transitionCnt = 0;
+                       mmsMsgData.metaCnt = 0;
+                       memset(mmsMsgData.szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX);
+
+                       pSmilDoc = MmsSmilGetPresentationData(pMsgInfo->msgId);
+                       MmsSmilParseSmilDoc(&mmsMsgData, pSmilDoc);
+                       MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+                       strcpy(szFileName, pMsg->szFileName);
+
+                       err = pStorage->getMsgText(&mmsMsgData, pMsgInfo->msgText);
+                       err = pStorage->makeThumbnail(&mmsMsgData, pMsgInfo->thumbPath, szFileName);
+
+                       __MmsReleaseMmsLists(&mmsMsgData);
+               }
+
+               if (addMmsMsgToDB(pMsg, pMsgInfo) != MSG_SUCCESS) {
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+
+                       THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
+               }
+               memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
+               strcpy((char *)pMsgInfo->msgData,szTemp);
+
+               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+
+       } else if (pMsgInfo->msgType.subType == MSG_READREPLY_MMS || pMsgInfo->msgType.subType == MSG_READRECIND_MMS) {
+               MSG_DEBUG("######## MmsPlgAddMessage -> MSG_READREPLY_MMS || MSG_READRECIND_MMS ###########");
+
+               char filePath[MAX_FULL_PATH_SIZE+1] = {0, };
+               FILE *pFile = NULL;
+
+               MSG_READ_REPORT_STATUS_T readStatus;
+               MSG_MESSAGE_ID_T selectedMsgId;
+               int     version;
+
+               memcpy(&readStatus, pMsgInfo->msgData, sizeof(MSG_READ_REPORT_STATUS_T));
+               memcpy(&selectedMsgId, pMsgInfo->msgData + sizeof(MSG_READ_REPORT_STATUS_T), sizeof(MSG_MESSAGE_ID_T));
+
+               version = MmsPluginStorage::instance()->getMmsVersion(selectedMsgId);
+
+               snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId);
+
+               MmsComposeReadReportMessage(&mmsMsg, pMsgInfo, selectedMsgId);
+
+               if (addMmsMsgToDB(&mmsMsg, pMsgInfo) != MSG_SUCCESS) {
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeAttrib(&mmsMsg.mmsAttrib);
+
+                       THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
+               }
+
+               snprintf(filePath, MAX_FULL_PATH_SIZE+1, MSG_DATA_PATH"%d", mmsMsg.msgID);
+               pFile = MsgOpenMMSFile(filePath);
+               if (!pFile) {
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                       MsgCloseFile(pFile);
+                       pFile = NULL;
+
+                       THROW(MsgException::MMS_PLG_ERROR, "MsgOpenMMSFile error");
+               }
+
+               if (fchmod(fileno(pFile), file_mode) < 0) {
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                       MsgCloseFile(pFile);
+                       pFile = NULL;
+
+                       THROW(MsgException::MMS_PLG_ERROR, "chmod() error: %s", strerror(errno));
+               }
+
+               if (version == 0x90) {
+                       MSG_DEBUG("### version 1.0 ###");
+                       if (_MmsEncodeReadReport10(pFile, &mmsMsg, readStatus) != true) {
+                               MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                               MsgCloseFile(pFile);
+                               pFile = NULL;
+
+                               THROW(MsgException::MMS_PLG_ERROR, "MMS Encode Read Report 1.0 Error");
+                       }
+               } else {
+                       MSG_DEBUG("### version 1.1 ###");
+                       if (_MmsEncodeReadReport11(pFile, &mmsMsg, readStatus) != true) {
+                               MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                               MsgCloseFile(pFile);
+                               pFile = NULL;
+
+                               THROW(MsgException::MMS_PLG_ERROR, "MMS Encode Read Report 1.1 Error");
+                       }
+               }
+
+               MsgFsync(pFile);
+               MsgCloseFile(pFile);
+               pFile = NULL;
+
+               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+
+               MsgFreeAttrib(&mmsMsg.mmsAttrib);
+
+       } else if (pMsgInfo->msgType.subType == MSG_FORWARD_MMS) {
+               MSG_DEBUG("######## MmsPlgAddMessage -> MSG_FORWARD_MMS ###########");
+
+               char filePath[MAX_FULL_PATH_SIZE + 1] = {0, };
+               char szTemp[MAX_MSG_DATA_LEN + 1] = {0, };
+               FILE *pFile = NULL;
+               MMS_MESSAGE_DATA_S mmsMsgData;
+
+               if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) {
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                       __MmsReleaseMmsLists(&mmsMsgData);
+
+                       THROW(MsgException::MMS_PLG_ERROR, "MMS Message Compose Error");
+               }
+
+               strcpy(szTemp,pMsgInfo->msgData);
+
+               snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN + 1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId);
+
+               if (addMmsMsgToDB(&mmsMsg, pMsgInfo, _MsgMmsGetAttachCount(&mmsMsgData)) != MSG_SUCCESS) {
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                       __MmsReleaseMmsLists(&mmsMsgData);
+
+                       THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
+               }
+
+               strcpy((char *)pMsgInfo->msgData,szTemp);
+
+               snprintf(filePath, MAX_FULL_PATH_SIZE + 1 , MSG_DATA_PATH"%d", mmsMsg.msgID);
+
+               pFile = MsgOpenMMSFile(filePath);
+               if (!pFile) {
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                       __MmsReleaseMmsLists(&mmsMsgData);
+                       MsgCloseFile(pFile);
+                       pFile = NULL;
+
+                       THROW(MsgException::MMS_PLG_ERROR, "MsgOpenMMSFile error");
+               }
+
+               if (fchmod(fileno(pFile), file_mode) < 0) {
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                       __MmsReleaseMmsLists(&mmsMsgData);
+                       MsgCloseFile(pFile);
+                       pFile = NULL;
+
+                       THROW(MsgException::MMS_PLG_ERROR, "chmod() error: %s", strerror(errno));
+               }
+
+               if (_MmsEncodeSendReq(pFile, &mmsMsg) != true) {
+                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeAttrib(&mmsMsg.mmsAttrib);
+                       __MmsReleaseMmsLists(&mmsMsgData);
+                       MsgCloseFile(pFile);
+                       pFile = NULL;
+
+                       THROW(MsgException::MMS_PLG_ERROR, "MMS Message Encode Send Req Error");
+               }
+               MsgFsync(pFile);
+               MsgCloseFile(pFile);
+               pFile = NULL;
+
+               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+               MsgFreeAttrib(&mmsMsg.mmsAttrib);
+               __MmsReleaseMmsLists(&mmsMsgData);
+       }
+
+       MSG_END();
+}
+
+
+void MmsPluginStorage::composeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       char filePath[MAX_FULL_PATH_SIZE+1] = {0, };
+       FILE *pFile = NULL;
+
+       MSG_READ_REPORT_STATUS_T readStatus;
+       int     version;
+
+       memcpy(&readStatus, pMsgInfo->msgData, sizeof(MSG_READ_REPORT_STATUS_T));
+
+       MSG_DEBUG("pMsgInfo->msgId = %d", pMsgInfo->msgId);
+
+       version = MmsPluginStorage::instance()->getMmsVersion(pMsgInfo->msgId);
+
+       snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId);
+
+       if (version == 0x90)
+               pMsgInfo->msgType.subType = MSG_READREPLY_MMS;
+       else
+               pMsgInfo->msgType.subType = MSG_READRECIND_MMS;
+
+       MmsComposeReadReportMessage(&mmsMsg, pMsgInfo, pMsgInfo->msgId);
+
+       snprintf(filePath, MAX_FULL_PATH_SIZE+1, MSG_DATA_PATH"%d", mmsMsg.msgID);
+       pFile = MsgOpenMMSFile(filePath);
+       if (!pFile)
+               THROW(MsgException::MMS_PLG_ERROR, "MsgOpenMMSFile Error");
+
+       if (version == 0x90) {
+               MSG_DEBUG("### version 1.0 ###");
+               if (_MmsEncodeReadReport10(pFile, &mmsMsg, readStatus) != true) {
+                       MsgCloseFile(pFile);
+                       THROW(MsgException::MMS_PLG_ERROR, "MMS Encode Read Report 1.0 Error");
+               }
+       } else {
+               MSG_DEBUG("### version 1.1 ###");
+               if (_MmsEncodeReadReport11(pFile, &mmsMsg, readStatus) != true) {
+                       MsgCloseFile(pFile);
+                       THROW(MsgException::MMS_PLG_ERROR, "MMS Encode Read Report 1.1 Error");
+               }
+       }
+
+       MsgCloseFile(pFile);
+}
+
+
+MSG_ERROR_T MmsPluginStorage::addMmsMsgToDB(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, int attachCnt)
+{
+       MSG_BEGIN();
+
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       // Add Message
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       if (checkExistedMessage(pMmsMsg->msgID) == false) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, '%s', '%s', '%s', '%s', '%s');",
+                                       MMS_PLUGIN_MESSAGE_TABLE_NAME, pMmsMsg->msgID, pMmsMsg->szTrID, pMmsMsg->szMsgID, pMmsMsg->szForwardMsgID, pMmsMsg->szContentLocation, pMsgInfo->msgData);
+
+               dbHandle.beginTrans();
+
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %ld, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d);",
+                                       MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, pMmsMsg->msgID, pMmsMsg->mmsAttrib.version, pMmsMsg->mmsAttrib.dataType,
+                                                                                               pMmsMsg->mmsAttrib.date, pMmsMsg->mmsAttrib.bHideAddress, pMmsMsg->mmsAttrib.bAskDeliveryReport,
+                                                                                               pMmsMsg->mmsAttrib.bReportAllowed, pMmsMsg->mmsAttrib.readReportAllowedType, pMmsMsg->mmsAttrib.bAskReadReply,
+                                                                                               pMmsMsg->mmsAttrib.bRead, pMmsMsg->mmsAttrib.readReportSendStatus, pMmsMsg->mmsAttrib.bReadReportSent,
+                                                                                               pMmsMsg->mmsAttrib.priority, pMmsMsg->mmsAttrib.bLeaveCopy, pMmsMsg->mmsAttrib.msgSize, pMmsMsg->mmsAttrib.msgClass,
+                                                                                               pMmsMsg->mmsAttrib.expiryTime.time,     pMmsMsg->mmsAttrib.bUseDeliveryCustomTime, pMmsMsg->mmsAttrib.deliveryTime.time,
+                                                                                               pMmsMsg->mmsAttrib.msgStatus);
+
+               MSG_DEBUG("\n!!!!!!!!! QUERY : %s\n", sqlQuery);
+
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+
+               if (updateMmsAttachCount(pMmsMsg->msgID, attachCnt) != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+
+               dbHandle.endTrans(true);
+       } else {
+               MSG_DEBUG("Already existed message");
+
+               if (updateMmsAttachCount(pMmsMsg->msgID, attachCnt) != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T    MmsPluginStorage::plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T     err = MSG_SUCCESS;
+
+       int partCnt = 0;
+       unsigned int nSize = 0;
+
+       MsgType partHeader;
+       MmsAttrib pMmsAttrib;
+
+       char szBuf[MSG_FILEPATH_LEN_MAX] = {0, };
+       bool bMultipartRelated = false;
+
+       if (pSendOptInfo != NULL) {
+               char sqlQuery[MAX_QUERY_LEN + 1];
+
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ASK_DELIVERY_REPORT, KEEP_COPY, ASK_READ_REPLY, PRIORITY, EXPIRY_TIME, CUSTOM_DELIVERY_TIME, DELIVERY_TIME FROM %s WHERE REFERENCE_ID IN \
+                                                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                                               MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId);
+
+               MSG_DEBUG("### SQLQuery = %s ###", sqlQuery);
+
+               if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+                       MSG_DEBUG("MSG_ERR_DB_PREPARE");
+
+               if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+                       pSendOptInfo->bDeliverReq = dbHandle.columnInt(0);
+                       MSG_DEBUG("## delivery = %d ##", pSendOptInfo->bDeliverReq);
+
+                       pSendOptInfo->bKeepCopy = dbHandle.columnInt(1);
+                       MSG_DEBUG("## bKeepCopy = %d ##", pSendOptInfo->bKeepCopy);
+
+                       pSendOptInfo->option.mmsSendOptInfo.bReadReq = dbHandle.columnInt(2);
+                       MSG_DEBUG("## bReadReq = %d ##", pSendOptInfo->option.mmsSendOptInfo.bReadReq);
+
+                       pSendOptInfo->option.mmsSendOptInfo.priority = dbHandle.columnInt(3);
+                       MSG_DEBUG("## priority = %d ##", pSendOptInfo->option.mmsSendOptInfo.priority);
+
+                       pSendOptInfo->option.mmsSendOptInfo.expiryTime.time = (unsigned int)dbHandle.columnInt(4);
+                       MSG_DEBUG("## expiryTime = %d ##", pSendOptInfo->option.mmsSendOptInfo.expiryTime.time);
+
+                       pSendOptInfo->option.mmsSendOptInfo.bUseDeliveryCustomTime = (unsigned int)dbHandle.columnInt(5);
+                       MSG_DEBUG("## bUseDeliveryCustomTime = %d ##", pSendOptInfo->option.mmsSendOptInfo.bUseDeliveryCustomTime);
+
+                       pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time = (unsigned int)dbHandle.columnInt(6);
+                       MSG_DEBUG("## deliveryTime = %d ##", pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time);
+               } else {
+                       dbHandle.finalizeQuery();
+
+                       return MSG_ERR_DB_STEP;
+               }
+
+               dbHandle.finalizeQuery();
+       }
+
+       if (_MmsReadMsgBody(pMsg->msgId, true, false, NULL) == false) {
+               MSG_DEBUG("The MMS Message might include drm contents!!!");
+
+#ifdef __SUPPORT_DRM__
+               if (MmsDrm2GetConvertState() == MMS_DRM2_CONVERT_REQUIRED) {
+                       bool bRetToConvert = true;
+
+                       bRetToConvert = MmsDrm2ConvertMsgBody(mmsHeader.msgType.szOrgFilePath);
+
+                       MmsDrm2SetConvertState(MMS_DRM2_CONVERT_FINISH);
+
+                       if (bRetToConvert) {
+                               remove(mmsHeader.msgType.szOrgFilePath);
+                               rename(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, mmsHeader.msgType.szOrgFilePath);
+
+                               if (MmsDrm2ReadMsgConvertedBody(pMsg, true, false, NULL) == false) {
+                                       MSG_DEBUG("MmsLoadMsg:MmsDrm2ReadMsgConvertedBody() returns false\n");
+                                       goto L_CATCH;
+                               }
+                       } else {
+                               goto L_CATCH;
+                       }
+               }
+#endif
+       }
+
+       MmsGetMsgAttrib(pMsg->msgId, &pMmsAttrib);
+
+       pMmsMsg->regionCnt = 0;
+       pMmsMsg->pageCnt = 0;
+       pMmsMsg->attachCnt = 0;
+       pMmsMsg->transitionCnt = 0;
+       pMmsMsg->metaCnt = 0;
+       memset(pMmsMsg->szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX);
+
+       if (pMmsAttrib.contentType == MIME_MULTIPART_RELATED || pMmsAttrib.contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
+               char *pSmilDoc = NULL;
+
+               pSmilDoc = MmsSmilGetPresentationData(pMsg->msgId);
+               if (!pSmilDoc) {
+                       goto L_CATCH;
+               }
+
+               MmsSmilParseSmilDoc(pMmsMsg, pSmilDoc);
+               bMultipartRelated = true;
+       }
+
+       partCnt = MmsGetMediaPartCount(pMsg->msgId);
+       MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt);
+
+       if (partCnt < 0) {
+               MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt);
+               goto FREE_CATCH;
+       }
+
+       for (int i = 0; i < partCnt; ++i) {
+               if (!MmsGetMediaPartHeader(i, &partHeader)) {
+                       MSG_DEBUG("MmsUiGetMediaAttachInfo: MmsGetMediaPartHeader failed\n");
+                       goto FREE_CATCH;
+               }
+
+               if (partHeader.contentSize > 0) {
+                       if (!strcasecmp(partHeader.param.szFileName, "cid:")) {
+                               strncpy((char *)szBuf, &partHeader.param.szFileName[4], MSG_FILEPATH_LEN_MAX - 1);
+                       } else {
+                               strcpy((char *)szBuf, partHeader.param.szFileName);
+                       }
+                       sprintf(partHeader.param.szFileName, MSG_DATA_PATH"%s", szBuf);
+
+                       if (!bMultipartRelated || MmsCheckAdditionalMedia(pMmsMsg, &partHeader)) {
+
+                               MMS_ATTACH_S *attachment = NULL;
+                               int tempType;
+
+                               attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1);
+
+                               MsgGetTypeByFileName(&tempType, partHeader.param.szFileName);
+                               attachment->mediatype = (MimeType)tempType;
+
+                               strcpy(attachment->szFilePath, partHeader.param.szFileName);
+
+                               strncpy(attachment->szFileName, partHeader.param.szName, MSG_FILENAME_LEN_MAX -1);
+
+                               attachment->fileSize = partHeader.contentSize;
+
+                               _MsgMmsAddAttachment(pMmsMsg, attachment);
+                       }
+               }
+       }
+
+       *pDestMsg = _MsgMmsSerializeMessageData(pMmsMsg, &nSize);
+
+       __MmsReleaseMmsLists(pMmsMsg);
+
+
+       MmsMsg *pStoMmsMsg;
+       MmsPluginStorage::instance()->getMmsMessage(&pStoMmsMsg);
+       _MmsInitHeader();
+       _MmsUnregisterDecodeBuffer();
+#ifdef __SUPPORT_DRM__
+       _MsgFreeDRMInfo(&pStoMmsMsg->msgType.drmInfo);
+#endif
+       _MsgFreeBody(&pStoMmsMsg->msgBody, pStoMmsMsg->msgType.type);
+
+       pMsg->dataSize = nSize;
+
+       if (err != MSG_SUCCESS)
+               MSG_DEBUG("MmsPlgUpdateMessage : Update MMS Message Failed");
+
+       MSG_END();
+
+       return err;
+
+FREE_CATCH:
+       if (bMultipartRelated) {
+               __MmsReleaseMmsLists(pMmsMsg);
+       }
+
+L_CATCH:
+       {
+               MmsMsg *pMsg;
+               MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+               _MmsInitHeader();
+
+               _MmsUnregisterDecodeBuffer();
+#ifdef __SUPPORT_DRM__
+               _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
+#endif
+               _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
+
+               return MSG_ERR_STORAGE_ERROR;
+       }
+       MSG_END();
+}
+
+
+MSG_ERROR_T MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T     err = MSG_SUCCESS;
+
+       MmsMsg mmsMsg;
+       bzero(&mmsMsg, sizeof(mmsMsg));
+
+       char filePath[MAX_FULL_PATH_SIZE+1] = {0, };
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       unsigned int addrId = 0;
+       FILE *pFile = NULL;
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET ASK_DELIVERY_REPORT = %d, KEEP_COPY = %d, ASK_READ_REPLY = %d, EXPIRY_TIME = %d, CUSTOM_DELIVERY_TIME = %d, DELIVERY_TIME= %d, PRIORITY = %d \
+                                                                       WHERE REFERENCE_ID IN \
+                                                                       (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                               MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, pSendOptInfo->bDeliverReq, pSendOptInfo->bKeepCopy, pSendOptInfo->option.mmsSendOptInfo.bReadReq,
+                                                                                               pSendOptInfo->option.mmsSendOptInfo.expiryTime.time, pSendOptInfo->option.mmsSendOptInfo.bUseDeliveryCustomTime,
+                                                                                               pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time, pSendOptInfo->option.mmsSendOptInfo.priority,
+                                                                                               MSGFW_MESSAGE_TABLE_NAME, pMsgInfo->msgId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       MMS_MESSAGE_DATA_S mmsMsgData;
+
+       if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) {
+               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+               MsgFreeAttrib(&mmsMsg.mmsAttrib);
+               __MmsReleaseMmsLists(&mmsMsgData);
+
+               THROW(MsgException::MMS_PLG_ERROR, "MMS Message Compose Error");
+       }
+
+       snprintf(filePath, MAX_FULL_PATH_SIZE+1, MSG_DATA_PATH"%d", mmsMsg.msgID);
+
+       pFile = MsgOpenMMSFile(filePath);
+
+       if (_MmsEncodeSendReq(pFile, &mmsMsg) != true) {
+               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+               MsgFreeAttrib(&mmsMsg.mmsAttrib);
+               __MmsReleaseMmsLists(&mmsMsgData);
+               MsgCloseFile(pFile);
+
+               THROW(MsgException::MMS_PLG_ERROR, "MMS Message Encode Send Req Error");
+       }
+
+       MsgCloseFile(pFile);
+
+       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+       MsgFreeAttrib(&mmsMsg.mmsAttrib);
+
+       __MmsReleaseMmsLists(&mmsMsgData);
+
+       MSG_END();
+
+       return err;
+}
+
+
+MSG_ERROR_T MmsPluginStorage::updateConfMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_BEGIN();
+
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       MMS_RECV_DATA_S *pMmsRecvData = (MMS_RECV_DATA_S *)pMsgInfo->msgData;
+
+       MSG_DEBUG("###### pMsgInfo->msgData = %s #######", pMmsRecvData->retrievedFilePath);
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MESSAGE_ID = '%s', FILE_PATH = '%s' WHERE REFERENCE_ID IN \
+                                       (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                       MMS_PLUGIN_MESSAGE_TABLE_NAME, pMmsRecvData->szMsgID, pMmsRecvData->retrievedFilePath,
+                                       MSGFW_MESSAGE_TABLE_NAME, pMsgInfo->msgId);
+
+       MSG_DEBUG("SQLQuery = %s", sqlQuery);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsPluginStorage::updateMsgServerID(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo)
+{
+       MSG_BEGIN();
+
+       char sqlQuery[MAX_QUERY_LEN + 1];
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       MMS_RECV_DATA_S *pMmsRecvData = (MMS_RECV_DATA_S *)pMsgInfo->msgData;
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MESSAGE_ID = '%s' WHERE REFERENCE_ID IN \
+                                       (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                       MMS_PLUGIN_MESSAGE_TABLE_NAME, pMmsRecvData->szMsgID,
+                                       MSGFW_MESSAGE_TABLE_NAME, pMsgInfo->msgId);
+
+       MSG_DEBUG("SQLQuery = %s", sqlQuery);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       if (pSendOptInfo != NULL) {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET ASK_DELIVERY_REPORT = %d, ASK_READ_REPLY = %d, PRIORITY = %d, EXPIRY_TIME = %d WHERE REFERENCE_ID IN \
+                                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                               MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, pSendOptInfo->bDeliverReq, pSendOptInfo->option.mmsSendOptInfo.bReadReq,
+                                               pSendOptInfo->option.mmsSendOptInfo.priority, pSendOptInfo->option.mmsSendOptInfo.expiryTime.time,
+                                               MSGFW_MESSAGE_TABLE_NAME, pMsgInfo->msgId);
+
+               MSG_DEBUG("SQLQuery = %s", sqlQuery);
+
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                       return MSG_ERR_DB_EXEC;
+               }
+       }
+
+       dbHandle.finalizeQuery();
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsPluginStorage::updateNetStatus(MSG_MESSAGE_ID_T msgId, MSG_NETWORK_STATUS_T netStatus)
+{
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET NETWORK_STATUS = %d WHERE MSG_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, netStatus, msgId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsPluginStorage::updateDeliveryReport(MSG_MESSAGE_ID_T msgId, MmsMsgMultiStatus *pStatus)
+{
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET DELIVERY_REPORT_STATUS = %d, DELIVERY_REPORT_TIME = %ld \
+                                     WHERE MSG_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, pStatus->msgStatus, pStatus->handledTime, msgId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsPluginStorage::updateReadReport(MSG_MESSAGE_ID_T msgId, MmsMsgMultiStatus *pStatus)
+{
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET READ_REPORT_STATUS = %d, READ_REPORT_TIME = %lu \
+                                     WHERE MSG_ID = %d;",
+                       MSGFW_MESSAGE_TABLE_NAME, pStatus->readStatus, pStatus->readTime, msgId);
+
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsPluginStorage::updateMmsAttrib(MSG_MESSAGE_ID_T msgId, MmsAttrib *attrib, MSG_SUB_TYPE_T msgSubType)
+{
+       MSG_BEGIN();
+
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       if (msgSubType == MSG_NOTIFICATIONIND_MMS) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET EXPIRY_TIME = %d WHERE REFERENCE_ID IN \
+                                                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                                               MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, attrib->expiryTime.time,
+                                                               MSGFW_MESSAGE_TABLE_NAME, msgId);
+       } else if (msgSubType == MSG_RETRIEVE_AUTOCONF_MMS || msgSubType == MSG_RETRIEVE_MANUALCONF_MMS) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET ASK_DELIVERY_REPORT = %d, ASK_READ_REPLY = %d, PRIORITY = %d WHERE REFERENCE_ID IN \
+                                                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                                               MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, attrib->bAskDeliveryReport, attrib->bAskReadReply, attrib->priority,
+                                                               MSGFW_MESSAGE_TABLE_NAME, msgId);
+       }
+
+       MSG_DEBUG("QUERY : [%s]", sqlQuery);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsPluginStorage::updateMmsAttachCount(MSG_MESSAGE_ID_T msgId, int count)
+{
+       MSG_BEGIN();
+
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET ATTACHMENT_COUNT = %d WHERE MSG_ID = %d;",
+                                                               MSGFW_MESSAGE_TABLE_NAME, count, msgId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+               MSG_DEBUG("Fail to execute query [%s]", sqlQuery);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+MmsMsgMultiStatus *MmsPluginStorage::getMultiStatus(MSG_MESSAGE_ID_T msgId)
+{
+       MSG_BEGIN();
+
+       MmsMsgMultiStatus *pMultiStatus = NULL;
+
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT B.ADDRESS_VAL, A.DELIVERY_REPORT_STATUS, A.DELIVERY_REPORT_TIME, \
+                                                 A.READ_REPORT_STATUS, A.READ_REPORT_TIME \
+                                       FROM %s A, %s B \
+                                    WHERE A.MSG_ID = %d AND A.ADDRESS_ID = B.ADDRESS_ID;",
+                               MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               MSG_DEBUG("MSG_ERR_DB_PREPARE");
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               pMultiStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus));
+
+               memset(pMultiStatus, 0, sizeof(MmsMsgMultiStatus));
+
+               if (dbHandle.columnText(0) != NULL) {
+                       strncpy(pMultiStatus->szTo, (char *)dbHandle.columnText(0), (strlen((char *)dbHandle.columnText(0)) > MAX_ADDRESS_VAL_LEN ? MAX_ADDRESS_VAL_LEN : strlen((char *)dbHandle.columnText(0))));
+                       MSG_DEBUG("### szTo = %s ###", pMultiStatus->szTo);
+               }
+
+               pMultiStatus->msgStatus = (MSG_DELIVERY_REPORT_STATUS_T)dbHandle.columnInt(1);
+               pMultiStatus->handledTime = dbHandle.columnInt(2);
+               pMultiStatus->readStatus = (MSG_READ_REPORT_STATUS_T)dbHandle.columnInt(3);
+               pMultiStatus->readTime = dbHandle.columnInt(4);
+       } else {
+               MSG_DEBUG("MSG_ERR_DB_STEP");
+       }
+
+       /* possible NULL pointer dereference*/
+       if (pMultiStatus != NULL)
+               pMultiStatus->pNext = NULL;
+
+       dbHandle.finalizeQuery();
+
+       return pMultiStatus;
+}
+
+
+void MmsPluginStorage::getMmsAttrib(MSG_MESSAGE_ID_T msgId, MmsMsg *pMmsMsg)
+{
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE REFERENCE_ID IN \
+                                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                               MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               MSG_DEBUG("MSG_ERR_DB_PREPARE");
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               pMmsMsg->mmsAttrib.version = dbHandle.columnInt(1);
+               pMmsMsg->mmsAttrib.dataType = (MmsDataType)dbHandle.columnInt(2);
+               pMmsMsg->mmsAttrib.date = dbHandle.columnInt(3);
+               pMmsMsg->mmsAttrib.bHideAddress = dbHandle.columnInt(4);
+               pMmsMsg->mmsAttrib.bAskDeliveryReport = dbHandle.columnInt(5);
+               pMmsMsg->mmsAttrib.bReportAllowed = dbHandle.columnInt(6);
+               pMmsMsg->mmsAttrib.readReportAllowedType = (MmsRecvReadReportType)dbHandle.columnInt(7);
+               pMmsMsg->mmsAttrib.bAskReadReply = dbHandle.columnInt(8);
+               pMmsMsg->mmsAttrib.bRead = dbHandle.columnInt(9);
+               pMmsMsg->mmsAttrib.readReportSendStatus = (MmsRecvReadReportSendStatus)dbHandle.columnInt(10);
+               pMmsMsg->mmsAttrib.bReadReportSent = dbHandle.columnInt(11);
+               pMmsMsg->mmsAttrib.priority = (MmsPriority)dbHandle.columnInt(12);
+               pMmsMsg->mmsAttrib.msgSize = dbHandle.columnInt(13);
+               pMmsMsg->mmsAttrib.msgClass = (MmsMsgClass)dbHandle.columnInt(14);
+               pMmsMsg->mmsAttrib.expiryTime.time = dbHandle.columnInt(15);
+               pMmsMsg->mmsAttrib.deliveryTime.time = dbHandle.columnInt(17);
+               pMmsMsg->mmsAttrib.msgStatus = (MSG_DELIVERY_REPORT_STATUS_T)dbHandle.columnInt(18);
+       }
+
+       dbHandle.finalizeQuery();
+}
+
+
+MSG_ERROR_T MmsPluginStorage::getMmsMessageId(MSG_MESSAGE_ID_T selectedMsgId, MmsMsg *pMmsMsg)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int rowCnt = 0;
+
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MESSAGE_ID FROM %s WHERE REFERENCE_ID IN \
+                                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                               MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, selectedMsgId);
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
+               dbHandle.freeTable();
+               MSG_DEBUG("[Error]Failed to Get Table");
+               return MSG_ERR_DB_NORECORD;
+       }
+
+       if (rowCnt != 1) {
+               dbHandle.freeTable();
+               MSG_DEBUG("[Error] MSG_ERR_DB_NORECORD");
+               return MSG_ERR_DB_NORECORD;
+       }
+
+       dbHandle.getColumnToString(1, MMS_MSG_ID_LEN + 1, pMmsMsg->szMsgID);
+
+       dbHandle.freeTable();
+
+       return MSG_SUCCESS;
+}
+
+
+int MmsPluginStorage::getMmsVersion(MSG_MESSAGE_ID_T selectedMsgId)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+       int rowCnt = 0;
+
+       int     version = 0;
+
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT VERSION FROM %s WHERE REFERENCE_ID IN \
+                                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                               MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, selectedMsgId);
+
+       MSG_DEBUG("SqlQuery = %s", sqlQuery);
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
+               dbHandle.freeTable();
+               MSG_DEBUG("[Error]Failed to Get Table");
+               return version;
+       }
+
+       if (rowCnt != 1) {
+               dbHandle.freeTable();
+               MSG_DEBUG("[Error]MSG_ERR_DB_NORECORD");
+               return version;
+       }
+
+       version = dbHandle.getColumnToInt(1);
+
+       dbHandle.freeTable();
+
+       return version;
+}
+
+
+MSG_ERROR_T MmsPluginStorage::getContentLocation(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONTENTS_LOCATION FROM %s WHERE REFERENCE_ID IN \
+                                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                               MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, pMsgInfo->msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               if (dbHandle.columnText(0) != NULL) {
+                       strncpy(pMsgInfo->msgData, (char *)dbHandle.columnText(0), (strlen((char *)dbHandle.columnText(0)) > MAX_MSG_DATA_LEN ? MAX_MSG_DATA_LEN : strlen((char *)dbHandle.columnText(0))));
+                       pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
+               }
+       } else {
+               dbHandle.finalizeQuery();
+
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+/* reject_msg_support */
+MSG_ERROR_T MmsPluginStorage::getTrID(MSG_MESSAGE_INFO_S *pMsgInfo,char *pszTrID,int nBufferLen)
+{
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT TRANSACTION_ID FROM %s WHERE REFERENCE_ID IN \
+                                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                               MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, pMsgInfo->msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               if (dbHandle.columnText(0) != NULL) {
+                       strncpy(pszTrID, (char *)dbHandle.columnText(0), nBufferLen - 1);
+                       pszTrID[nBufferLen-1] = '\0';
+               }
+       } else {
+               dbHandle.finalizeQuery();
+
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+/* reject_msg_support */
+
+
+MSG_ERROR_T MmsPluginStorage::getMmsRawFilePath(MSG_MESSAGE_ID_T msgId, char *pFilepath)
+{
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILE_PATH FROM %s WHERE REFERENCE_ID IN \
+                                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                               MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               if (dbHandle.columnText(0) != NULL) {
+                       strcpy(pFilepath, (char *)dbHandle.columnText(0));
+               }
+       } else {
+               dbHandle.finalizeQuery();
+
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+int MmsPluginStorage::searchMsgId(char *toNumber, char *szMsgID)
+{
+       int msgId = -1;
+
+       MSG_FOLDER_ID_T folderId = MSG_SENTBOX_ID;
+
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       MmsAddrUtilRemovePlmnString(toNumber);
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.MSG_ID FROM %s A, %s B \
+                                WHERE A.REFERENCE_ID = B.REFERENCE_ID AND A.FOLDER_ID = %d AND B.MESSAGE_ID LIKE '%%%s%%'",
+                               MSGFW_MESSAGE_TABLE_NAME, MMS_PLUGIN_MESSAGE_TABLE_NAME, folderId, szMsgID);
+
+       MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               msgId = dbHandle.columnInt(0);
+       }
+
+       dbHandle.finalizeQuery();
+
+       return msgId;
+}
+
+
+MSG_ERROR_T MmsPluginStorage::setReadReportSendStatus(MSG_MESSAGE_ID_T msgId, int readReportSendStatus)
+{
+       bool bReadReportSent = false;
+
+       if ((MmsRecvReadReportSendStatus)readReportSendStatus == MMS_RECEIVE_READ_REPORT_SENT)
+               bReadReportSent = true;
+       else
+               bReadReportSent = false;
+
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET READ_REPORT_SEND_STATUS = %d, READ_REPORT_SENT = %d WHERE REFERENCE_ID IN \
+                                       (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                       MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, (MmsRecvReadReportSendStatus)readReportSendStatus, (int)bReadReportSent,
+                                       MSGFW_MESSAGE_TABLE_NAME, msgId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       return MSG_SUCCESS;
+}
+
+
+bool MmsPluginStorage::checkExistedMessage(MSG_MESSAGE_ID_T msgId)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN + 1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT REFERENCE_ID FROM %s WHERE REFERENCE_ID IN \
+                                       (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                                       MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, msgId);
+
+       int rowCnt = 0;
+       int refId = 0;
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       // No record or other error
+       if (err != MSG_SUCCESS) {
+               MSG_DEBUG("result error");
+               dbHandle.freeTable();
+               return false;
+       }
+
+       refId = dbHandle.getColumnToInt(1);
+
+       MSG_DEBUG("refId : [%d]", refId);
+
+       if (rowCnt > 0) {
+               dbHandle.freeTable();
+               return true;
+       } else {
+               dbHandle.freeTable();
+               return false;
+       }
+}
+
+
+MSG_ERROR_T MmsPluginStorage::getMsgText(MMS_MESSAGE_DATA_S *pMmsMsg, char *pMsgText)
+{
+       MMS_PAGE_S *pPage = NULL;
+       MMS_MEDIA_S *pMedia = NULL;
+       char *pMmsMsgText = NULL;
+       int textLen = 0;
+       bool bText = false;
+
+       // Get the text data from the 1st slide.
+       for (int i = 0; i< pMmsMsg->pageCnt; ++i) {
+               pPage = _MsgMmsGetPage(pMmsMsg, i);
+
+               for (int j = 0; j < pPage->mediaCnt; ++j) {
+                       pMedia = _MsgMmsGetMedia(pPage, j);
+
+                       if (pMedia->mediatype == MMS_SMIL_MEDIA_TEXT && pMedia->szFilePath != NULL) {
+                               pMmsMsgText = MsgOpenAndReadMmsFile(pMedia->szFilePath, 0, -1, &textLen);
+                               if (pMmsMsgText)
+                                       strncpy(pMsgText, pMmsMsgText, MAX_MSG_TEXT_LEN);
+
+                               // for avoiding break character end of the string.
+                               if ((textLen >= MAX_MSG_TEXT_LEN) && pMsgText[MAX_MSG_TEXT_LEN - 1] >= 0x80) { // if it is multibyte chars by UTF8, it would be presendted by 1xxx xxxx
+                                       for (int k = 1; k < 5; k++) {
+                                               // the first byte of multi-byte chars of UTF8, should be larger than 1100 0000
+                                               // (two byte chars start with 110x xxxx, and three byte chars start with 1110 xxxx,
+                                               // four byte chars start with 1111 0xxx)
+                                               if ((pMsgText[MAX_MSG_TEXT_LEN - k] >= 0xC0)) {
+                                                       pMsgText[MAX_MSG_TEXT_LEN - k] = '\0';
+                                                       break;
+                                               }
+                                       }
+                               }
+
+                               if (pMmsMsgText) {
+                                       free(pMmsMsgText);
+                                       pMmsMsgText = NULL;
+                               }
+                               bText = true;
+                               break;
+                       }
+               }
+
+               if (bText)
+                       break;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsPluginStorage::makeThumbnail(MMS_MESSAGE_DATA_S *pMmsMsg, char *pThumbnailPath, char *szFileName)
+{
+       MMS_PAGE_S *pPage = NULL;
+       MMS_MEDIA_S *pMedia = NULL;
+
+       bool bThumbnail = false;
+
+       for (int i = 0; i < pMmsMsg->pageCnt; i++) {
+               pPage = _MsgMmsGetPage(pMmsMsg, i);
+               for (int j = 0; j < pPage->mediaCnt; j++) {
+                       pMedia = _MsgMmsGetMedia(pPage, j);
+
+                       MSG_DEBUG("pMedia's Name: %s", pMedia->szFilePath);
+
+                       if (pMedia->mediatype == MMS_SMIL_MEDIA_IMG) {
+                               MSG_DEBUG("Make thumbnail: image");
+
+                               char thumbPath[MSG_FILEPATH_LEN_MAX] = {0, };
+
+                               snprintf(thumbPath, MSG_FILEPATH_LEN_MAX, MSG_THUMBNAIL_PATH"/%s.jpg", szFileName);
+                               int err = -1;
+                               err = thumbnail_request_save_to_file(pMedia->szFilePath, MEDIA_THUMB_LARGE, thumbPath);
+                               if (err < 0) {
+                                       MSG_DEBUG("Make thumbnail: image failed");
+                                       continue;
+                               }
+
+                               strncpy(pThumbnailPath, thumbPath, MSG_FILEPATH_LEN_MAX);
+
+                               bThumbnail = true;
+
+                               break;
+                       } else if (pMedia->mediatype == MMS_SMIL_MEDIA_VIDEO) {
+                               MSG_DEBUG("Make thumbnail: video");
+
+                               MMHandleType content_attrs = (MMHandleType)NULL;
+                               char *err_attr_name = NULL;
+
+                               int fileRet = 0;
+
+                               int trackCount = 0;
+
+                               mm_file_create_content_attrs(&content_attrs, pMedia->szFilePath);
+
+                               fileRet = mm_file_get_attrs(content_attrs, &err_attr_name, MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &trackCount, NULL);
+
+                               if (fileRet != 0) {
+                                       MSG_DEBUG("mm_file_get_attrs fails [%s]", err_attr_name);
+                                       if (err_attr_name) {
+                                               free(err_attr_name);
+                                               err_attr_name = NULL;
+                                       }
+
+                                       mm_file_destroy_content_attrs(content_attrs);
+
+                                       continue;
+                               }
+
+                               MSG_DEBUG("video track num: %d", trackCount);
+
+                               if (trackCount > 0) {
+                                       int thumbnailWidth = 0;
+                                       int thumbnailHeight = 0;
+                                       int thumbnailSize = 0;
+
+                                       void *thumbnail = NULL;
+
+                                       fileRet = mm_file_get_attrs(content_attrs, &err_attr_name, MM_FILE_CONTENT_VIDEO_WIDTH, &thumbnailWidth,
+                                                                                                                       MM_FILE_CONTENT_VIDEO_HEIGHT, &thumbnailHeight,
+                                                                                                                       MM_FILE_CONTENT_VIDEO_THUMBNAIL, &thumbnail, &thumbnailSize,
+                                                                                                                       NULL);
+
+                                       if (fileRet != 0) {
+                                               MSG_DEBUG("mm_file_get_attrs fails [%s]", err_attr_name);
+                                               if (err_attr_name) {
+                                                       free(err_attr_name);
+                                                       err_attr_name = NULL;
+                                               }
+
+                                               mm_file_destroy_content_attrs(content_attrs);
+
+                                               continue;
+                                       }
+
+                                       MSG_DEBUG("video width: %d", thumbnailWidth);
+                                       MSG_DEBUG("video height: %d", thumbnailHeight);
+                                       MSG_DEBUG("video thumbnail: %p", thumbnail);
+
+                                       if (thumbnail) {
+                                               char thumbPath[MSG_FILEPATH_LEN_MAX] = {0, };
+
+                                               snprintf(thumbPath, MSG_FILEPATH_LEN_MAX, MSG_THUMBNAIL_PATH"%s.jpg", szFileName);
+
+                                               fileRet = mm_util_jpeg_encode_to_file (thumbPath, thumbnail, thumbnailWidth, thumbnailHeight, MM_UTIL_JPEG_FMT_RGB888, 70);
+
+                                               if (fileRet != 0) {
+                                                       MSG_DEBUG("mm_util_jpeg_encode_to_file fails [%d]", fileRet);
+
+                                                       mm_file_destroy_content_attrs(content_attrs);
+
+                                                       continue;
+                                               }
+
+                                               memset(pThumbnailPath, 0x00, MSG_FILEPATH_LEN_MAX);
+
+                                               strncpy(pThumbnailPath, thumbPath, MSG_FILEPATH_LEN_MAX);
+
+                                               bThumbnail = true;
+
+                                       }
+
+                                       mm_file_destroy_content_attrs(content_attrs);
+
+                                       break;
+                               }
+
+                               mm_file_destroy_content_attrs(content_attrs);
+                       } else if (pMedia->mediatype == MMS_SMIL_MEDIA_AUDIO) {
+                               MSG_DEBUG("Make thumbnail: %s", "audio");
+
+                               MMHandleType tag_attrs = (MMHandleType)NULL;
+                               char *err_attr_name = NULL;
+                               void *artwork = NULL;
+                               int artworkSize = 0;
+                               int tmpLen = 0;
+                               int fileRet = 0;
+
+                               if (mm_file_create_tag_attrs(&tag_attrs, pMedia->szFilePath) == 0) {
+
+
+                                       fileRet = mm_file_get_attrs(tag_attrs, &err_attr_name, MM_FILE_TAG_ARTWORK, &artwork, &tmpLen,
+                                                                                                               MM_FILE_TAG_ARTWORK_SIZE, &artworkSize,
+                                                                                                               NULL);
+
+                                       mm_file_destroy_tag_attrs(tag_attrs);
+
+                                       if (fileRet != 0) {
+                                               MSG_DEBUG("mm_file_get_attrs fails [%s]", err_attr_name);
+                                               if (err_attr_name) {
+                                                       free(err_attr_name);
+                                                       err_attr_name = NULL;
+                                               }
+
+                                               continue;
+                                       }
+                               } else {
+                                       MSG_DEBUG("mm_file_create_tag_attrs fails");
+                                       continue;
+                               }
+
+                               MSG_DEBUG("artwork: %p", artwork);
+                               MSG_DEBUG("artwork_size: %d", artworkSize);
+
+                               if (artwork) {
+                                       char thumbPath[MSG_FILEPATH_LEN_MAX] = {0, };
+
+                                       snprintf(thumbPath, MSG_FILEPATH_LEN_MAX, MSG_THUMBNAIL_PATH"%s.jpg", szFileName);
+
+                                       FILE *tmp = MsgOpenFile(thumbPath, "wb+");
+
+                                       if(!tmp) {
+                                               MSG_DEBUG("MsgOpenFile file error");
+                                               return MSG_ERR_STORAGE_ERROR;
+                                       }
+
+                                       if (MsgWriteFile((char*)artwork, 1, artworkSize, tmp) != (size_t)artworkSize) {
+                                               MSG_DEBUG("MsgWriteFile error");
+                                               MsgCloseFile(tmp);
+                                               return MSG_ERR_STORAGE_ERROR;
+                                       }
+                                       MsgFsync(tmp);
+                                       MsgCloseFile(tmp);
+
+                                       strncpy(pThumbnailPath, thumbPath, MSG_FILEPATH_LEN_MAX);
+
+                                       bThumbnail = true;
+
+                                       break;
+                               }
+                       }
+               }
+
+               if (bThumbnail == true)
+                       break;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MmsPluginStorage::addMmsNoti(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T     err = MSG_SUCCESS;
+
+       err = MsgInsertMmsReportToNoti(&dbHandle, pMsgInfo);
+
+       MSG_END();
+
+       return err;
+}
+
+/* This API is not used anywhere now */
+MSG_ERROR_T    MmsPluginStorage::plgGetRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg, char *filePath)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T     err = MSG_SUCCESS;
+       int partCnt = 0;
+       MsgType partHeader;
+       MmsAttrib pMmsAttrib;
+       char szBuf[MSG_FILEPATH_LEN_MAX] = {0, };
+       unsigned int nSize;
+       bool bMultipartRelated = false;
+
+       if (_MmsReadMsgBody(pMsg->msgId, true, true, filePath) == false) {
+               MSG_DEBUG("The MMS Message might include drm contents!!!");
+
+#ifdef __SUPPORT_DRM__
+               if (MmsDrm2GetConvertState() == MMS_DRM2_CONVERT_REQUIRED) {
+                       bool bRetToConvert = true;
+
+                       bRetToConvert = MmsDrm2ConvertMsgBody(mmsHeader.msgType.szOrgFilePath);
+
+                       MmsDrm2SetConvertState(MMS_DRM2_CONVERT_FINISH);
+
+                       if (bRetToConvert) {
+                               remove(mmsHeader.msgType.szOrgFilePath);
+                               rename(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, mmsHeader.msgType.szOrgFilePath);
+
+                               if (MmsDrm2ReadMsgConvertedBody(pMsg, true, false, NULL) == false) {
+                                       MSG_DEBUG("MmsLoadMsg:MmsDrm2ReadMsgConvertedBody() returns false\n");
+                                       goto L_CATCH;
+                               }
+                       } else {
+                               goto L_CATCH;
+                       }
+               }
+#endif
+       }
+
+       MmsGetMsgAttrib(pMsg->msgId, &pMmsAttrib);
+
+       pMmsMsg->regionCnt = 0;
+       pMmsMsg->pageCnt = 0;
+       pMmsMsg->attachCnt = 0;
+       pMmsMsg->transitionCnt = 0;
+       pMmsMsg->metaCnt = 0;
+       memset(pMmsMsg->szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX);
+
+       if (pMmsAttrib.contentType == MIME_MULTIPART_RELATED || pMmsAttrib.contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
+               char *pSmilDoc = NULL;
+
+               pSmilDoc = MmsSmilGetPresentationData(pMsg->msgId);
+               if (!pSmilDoc) {
+                       goto L_CATCH;
+               }
+
+               MmsSmilParseSmilDoc(pMmsMsg, pSmilDoc);
+               bMultipartRelated = true;
+       }
+
+       partCnt = MmsGetMediaPartCount(pMsg->msgId);
+       MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt);
+
+       if (partCnt < 0) {
+               MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt);
+               goto FREE_CATCH;
+       }
+
+       for (int i = 0; i < partCnt; ++i) {
+               if (!MmsGetMediaPartHeader(i, &partHeader)) {
+                       MSG_DEBUG("MmsUiGetMediaAttachInfo: MmsGetMediaPartHeader failed\n");
+                       goto FREE_CATCH;
+               }
+
+               if (partHeader.contentSize > 0) {
+                       if (!strcasecmp(partHeader.param.szFileName, "cid:")) {
+                               strncpy((char *)szBuf, &partHeader.param.szFileName[4], MSG_FILEPATH_LEN_MAX - 1);
+                       } else {
+                               strcpy((char *)szBuf, partHeader.param.szFileName);
+                       }
+                       sprintf(partHeader.param.szFileName, MSG_DATA_PATH"%s", szBuf);
+
+                       if (!bMultipartRelated || MmsCheckAdditionalMedia(pMmsMsg, &partHeader)) {
+                               MMS_ATTACH_S *attachment = NULL;
+                               int tempType;
+
+                               attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1);
+
+                               MsgGetTypeByFileName(&tempType, partHeader.param.szFileName);
+                               attachment->mediatype = (MimeType)tempType;
+
+                               strcpy(attachment->szFilePath, partHeader.param.szFileName);
+
+                               strncpy(attachment->szFileName, partHeader.param.szName, MSG_FILENAME_LEN_MAX - 1);
+
+                               attachment->fileSize = partHeader.contentSize;
+
+                               _MsgMmsAddAttachment(pMmsMsg, attachment);
+                       }
+               }
+       }
+
+       *pDestMsg = _MsgMmsSerializeMessageData(pMmsMsg, &nSize);
+
+       __MmsReleaseMmsLists(pMmsMsg);
+
+       MmsMsg *pStoMmsMsg;
+       MmsPluginStorage::instance()->getMmsMessage(&pStoMmsMsg);
+       _MmsInitHeader();
+       _MmsUnregisterDecodeBuffer();
+#ifdef __SUPPORT_DRM__
+       _MsgFreeDRMInfo(&pStoMmsMsg->msgType.drmInfo);
+#endif
+       _MsgFreeBody(&pStoMmsMsg->msgBody, pStoMmsMsg->msgType.type);
+
+
+       pMsg->dataSize = nSize;
+
+       if (err != MSG_SUCCESS)
+               MSG_DEBUG("MmsPlgUpdateMessage : Update MMS Message Failed");
+
+       MSG_END();
+
+       return err;
+
+FREE_CATCH:
+       if (bMultipartRelated) {
+               __MmsReleaseMmsLists(pMmsMsg);
+
+       }
+
+L_CATCH:
+       {
+               MmsMsg *pMsg;
+               MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+               _MmsInitHeader();
+
+               _MmsUnregisterDecodeBuffer();
+#ifdef __SUPPORT_DRM__
+               _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
+#endif
+               _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
+
+               return MSG_ERR_STORAGE_ERROR;
+       }
+       MSG_END();
+}
+/* This API is not used anywhere now */
+
diff --git a/plugin/mms_plugin/MmsPluginTransport.cpp b/plugin/mms_plugin/MmsPluginTransport.cpp
new file mode 100755 (executable)
index 0000000..d7fc5cf
--- /dev/null
@@ -0,0 +1,138 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include "MmsPluginEventHandler.h"
+#include "MmsPluginTransport.h"
+#include "MsgUtilFile.h"
+#include "MmsPluginCodec.h"
+#include "MmsPluginMessage.h"
+#include "MmsPluginUserAgent.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MmsPluginTransport - Member Functions
+==================================================================================================*/
+MmsPluginTransport *MmsPluginTransport::pInstance = NULL;
+
+
+MmsPluginTransport::MmsPluginTransport()
+{
+
+}
+
+
+MmsPluginTransport::~MmsPluginTransport()
+{
+
+}
+
+
+MmsPluginTransport *MmsPluginTransport::instance()
+{
+       if (!pInstance)
+               pInstance = new MmsPluginTransport();
+
+       return pInstance;
+}
+
+
+void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo)
+{
+       mmsTranQEntity reqItem = {0};
+
+       reqItem.isCompleted = false;
+       reqItem.reqID = pReqInfo->reqId;
+
+       MSG_DEBUG("pReqInfo->msgInfo.msgType.subType [%d]", pReqInfo->msgInfo.msgType.subType);
+
+       switch (pReqInfo->msgInfo.msgType.subType) {
+       case MSG_SENDREQ_MMS:
+       case MSG_SENDREQ_JAVA_MMS:
+               MSG_DEBUG("######### SEND REQUEST : POST TRANSACTION");
+               reqItem.msgId = pReqInfo->msgInfo.msgId;
+               reqItem.eMmsPduType = eMMS_SEND_REQ;
+               reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
+               reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
+               break;
+
+       case MSG_GET_MMS:
+               MSG_DEBUG("######### AUTO RETRIEVE : GET TRANSACTION");
+               reqItem.msgId = pReqInfo->msgInfo.msgId;
+               reqItem.eMmsPduType = eMMS_RETRIEVE_AUTO;
+               reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION;
+               reqItem.getDataLen = pReqInfo->msgInfo.dataSize;
+               reqItem.pGetData = (char *)malloc(reqItem.getDataLen);
+               memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen);
+               break;
+
+       case MSG_NOTIFYRESPIND_MMS:
+               MSG_DEBUG("######### MANUAL RETRIEVE : SEND NOTIFY RESPONSE IND");
+               reqItem.msgId = pReqInfo->msgInfo.msgId;
+               reqItem.eMmsPduType = eMMS_NOTIFYRESP_IND;
+               reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
+               reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
+               remove(pReqInfo->msgInfo.msgData);
+               break;
+
+       case MSG_RETRIEVE_MMS:
+               MSG_DEBUG("######### MANUAL RETRIEVE : GET TRANSACTION");
+               reqItem.msgId = pReqInfo->msgInfo.msgId;
+               reqItem.eMmsPduType = eMMS_RETRIEVE_MANUAL;
+               reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION;
+               reqItem.getDataLen = pReqInfo->msgInfo.dataSize;
+               reqItem.pGetData = (char *)malloc(reqItem.getDataLen);
+               memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen);
+               break;
+
+       case MSG_READREPLY_MMS:
+               MSG_DEBUG("######### SEND READ REPORT : POST TRANSACTION");
+               reqItem.msgId = pReqInfo->msgInfo.msgId;
+               reqItem.eMmsPduType = eMMS_READREPORT_REQ;
+               reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
+               reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
+               // remove mms file
+               remove(pReqInfo->msgInfo.msgData);
+               break;
+
+       case MSG_READRECIND_MMS:
+               MSG_DEBUG("######### SEND READREC IND : POST TRANSACTION");
+               reqItem.msgId = pReqInfo->msgInfo.msgId;
+               reqItem.eMmsPduType = eMMS_READREC_IND;
+               reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
+               reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
+               break;
+
+       case MSG_FORWARD_MMS:
+               MSG_DEBUG("######### SEND FORWARD MSG : POST TRANSACTION");
+               reqItem.msgId = pReqInfo->msgInfo.msgId;
+               reqItem.eMmsPduType = eMMS_SEND_REQ;
+               reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
+               reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
+               break;
+       }
+
+       MmsPluginUaManager::instance()->addMmsReqEntity(reqItem);
+       MmsPluginUaManager::instance()->start();
+}
+
+
+void MmsPluginTransport::cancelRequest(MSG_REQUEST_ID_T reqId)
+{
+
+
+}
+
diff --git a/plugin/mms_plugin/MmsPluginUserAgent.cpp b/plugin/mms_plugin/MmsPluginUserAgent.cpp
new file mode 100755 (executable)
index 0000000..9fa7ceb
--- /dev/null
@@ -0,0 +1,658 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <glib.h>
+#include <curl/curl.h>
+#include "MmsPluginUserAgent.h"
+#include "MmsPluginEventHandler.h"
+#include "MsgGconfWrapper.h"
+#include "MmsPluginInternal.h"
+#include "MsgUtilFile.h"
+#include "MmsPluginCodec.h"
+#include "MsgException.h"
+#include "MmsPluginDrm.h"
+#include "MmsPluginStorage.h"
+
+
+extern MmsHeader mmsHeader;
+
+void PRINT_PDU_TYPE(MMS_PDU_TYPE_T pduType)
+{
+       switch (pduType) {
+       case eMMS_SEND_REQ:
+               MSG_DEBUG("[SEND_REQ]");
+               break;
+       case eMMS_SEND_CONF:
+               MSG_DEBUG("[MMS_SEND_CONF]");
+               break;
+       case eMMS_RETRIEVE_AUTO:
+               MSG_DEBUG("[MMS_RETRIEVE_AUTO]");
+               break;
+       case eMMS_RETRIEVE_MANUAL:
+               MSG_DEBUG("[MMS_RETRIEVE_MANUAL]");
+               break;
+       case eMMS_RETRIEVE_AUTO_CONF:
+               MSG_DEBUG("[MMS_RETRIEVE_AUTO_CONF]");
+               break;
+       case eMMS_RETRIEVE_MANUAL_CONF:
+               MSG_DEBUG("[MMS_RETRIEVE_MANUAL_CONF]");
+               break;
+       case eMMS_DELIVERY_IND:
+               MSG_DEBUG("[MMS_DELIVERY_IND]");
+               break;
+       case eMMS_NOTIFICATION_IND:
+               MSG_DEBUG("[MMS_NOTIFICATION_IND]");
+               break;
+       case eMMS_NOTIFYRESP_IND:
+               MSG_DEBUG("[MMS_NOTIFYRESP_IND]");
+               break;
+       case eMMS_ACKNOWLEDGE_IND:
+               MSG_DEBUG("[MMS_ACKNOWLEDGE_IND]");
+               break;
+       case eMMS_FORWARD_REQ:
+               MSG_DEBUG("[MMS_FORWARD_REQ]");
+               break;
+       case eMMS_FORWARD_CONF:
+               MSG_DEBUG("[MMS_FORWARD_CONF]");
+               break;
+       case eMMS_CANCEL_REQ:
+               MSG_DEBUG("[MMS_CANCEL_REQ]");
+               break;
+       case eMMS_CANCEL_CONF:
+               MSG_DEBUG("[MMS_CANCEL_CONF]");
+               break;
+       case eMMS_DELETE_REQ:
+               MSG_DEBUG("[MMS_DELETE_REQ]");
+               break;
+       case eMMS_DELETE_CONF:
+               MSG_DEBUG("[MMS_DELETE_CONF]");
+               break;
+       case eMMS_READREC_IND:
+               MSG_DEBUG("[MMS_READREC_IND]");
+               break;
+       case eMMS_READORIG_IND:
+               MSG_DEBUG("[MMS_READORIG_IND]");
+               break;
+       case eMMS_MBOX_STORE_REQ:
+               MSG_DEBUG("[MMS_MBOX_STORE_REQ]");
+               break;
+       case eMMS_MBOX_STORE_CONF:
+               MSG_DEBUG("[MMS_MBOX_STORE_CONF]");
+               break;
+       case eMMS_MBOX_VIEW_REQ:
+               MSG_DEBUG("[MMS_MBOX_VIEW_REQ]");
+               break;
+       case eMMS_MBOX_VIEW_CONF:
+               MSG_DEBUG("[MMS_MBOX_VIEW_CONF]");
+               break;
+       case eMMS_MBOX_UPLOAD_REQ:
+               MSG_DEBUG("[MMS_MBOX_UPLOAD_REQ]");
+               break;
+       case eMMS_MBOX_UPLOAD_CONF:
+               MSG_DEBUG("[MMS_MBOX_UPLOAD_CONF]");
+               break;
+       case eMMS_MBOX_DELETE_REQ:
+               MSG_DEBUG("[MMS_MBOX_DELETE_REQ]");
+               break;
+       case eMMS_MBOX_DELETE_CONF:
+               MSG_DEBUG("[MMS_MBOX_DELETE_CONF]");
+               break;
+       default:
+               MSG_DEBUG("[Unknown PDU Type]");
+               break;
+       }
+}
+
+
+void PRINT_QUEUE_ENTITY(mmsTranQEntity *entity)
+{
+       MSG_DEBUG("Entity: msgId: %d", entity->msgId);
+       MSG_DEBUG("Entity: completed: %d", entity->isCompleted);
+       MSG_DEBUG("Entity: eMmsPduType: %d", entity->eMmsPduType);
+       MSG_DEBUG("Entity: eHttpCmdType: %d", entity->eHttpCmdType);
+       MSG_DEBUG("Entity: GetLen: %d", entity->getDataLen);
+       MSG_DEBUG("Entity: GetData: (%s)", entity->pGetData);
+       MSG_DEBUG("Entity: postLen: %d", entity->postDataLen);
+       MSG_DEBUG("Entity: pPostData: (%s)", entity->pPostData);
+}
+
+void updatePduType(mmsTranQEntity *qEntity)
+{
+       switch(qEntity->eMmsPduType) {
+       case eMMS_SEND_REQ:
+               qEntity->eMmsPduType = eMMS_SEND_CONF;
+               break;
+       case eMMS_RETRIEVE_AUTO:
+               qEntity->eMmsPduType = eMMS_RETRIEVE_AUTO_CONF;
+               break;
+       case eMMS_RETRIEVE_MANUAL:
+               qEntity->eMmsPduType = eMMS_RETRIEVE_MANUAL_CONF;
+               break;
+       case eMMS_RETRIEVE_AUTO_CONF:
+               qEntity->eMmsPduType = eMMS_NOTIFYRESP_IND;
+               break;
+       case eMMS_READREC_IND:
+               qEntity->eMmsPduType = eMMS_SEND_CONF;
+               break;
+       case eMMS_READREPORT_REQ:
+               qEntity->eMmsPduType = eMMS_SEND_CONF;
+               break;
+       case eMMS_RETRIEVE_MANUAL_CONF:
+               qEntity->eMmsPduType = eMMS_ACKNOWLEDGE_IND;
+               break;
+       case eMMS_DELETE_REQ:
+               qEntity->eMmsPduType = eMMS_DELETE_CONF;
+               break;
+       case eMMS_FORWARD_REQ:
+               qEntity->eMmsPduType = eMMS_FORWARD_CONF;
+               break;
+       case eMMS_MBOX_STORE_REQ:
+               qEntity->eMmsPduType = eMMS_MBOX_STORE_CONF;
+               break;
+       case eMMS_MBOX_VIEW_REQ:
+               qEntity->eMmsPduType = eMMS_MBOX_VIEW_CONF;
+               break;
+       case eMMS_MBOX_UPLOAD_REQ:
+               qEntity->eMmsPduType = eMMS_MBOX_UPLOAD_CONF;
+               break;
+       case eMMS_MBOX_DELETE_REQ:
+               qEntity->eMmsPduType = eMMS_MBOX_DELETE_CONF;
+               break;
+
+       MSG_DEBUG("Update PDU Type:");
+       PRINT_PDU_TYPE(qEntity->eMmsPduType);
+
+       default:
+               break;
+       }
+
+}
+
+MmsPluginUaManager *MmsPluginUaManager::pInstance = NULL;
+
+MmsPluginUaManager::MmsPluginUaManager()
+{
+       running = false;
+       mmsTranQ.clear();
+}
+
+MmsPluginUaManager::~MmsPluginUaManager()
+{
+       if (pInstance) {
+               delete pInstance;
+               pInstance = NULL;
+       }
+}
+
+MmsPluginUaManager *MmsPluginUaManager::instance()
+{
+       if (!pInstance)
+               pInstance = new MmsPluginUaManager();
+
+       return pInstance;
+}
+
+void MmsPluginUaManager::start()
+{
+       bool bStart = true;
+
+       MutexLocker lock(mx);
+
+       if (!running) {
+
+               running = true;
+               MsgThread::start();
+       }
+}
+
+MMS_NET_ERROR_T MmsPluginUaManager::submitHandler(mmsTranQEntity *qEntity)
+{
+       MMS_NET_ERROR_T ret = eMMS_UNKNOWN;
+       int retryCount = 0;
+
+       MSG_DEBUG("request Submit:");
+       PRINT_PDU_TYPE(qEntity->eMmsPduType);
+       PRINT_QUEUE_ENTITY(qEntity);
+
+       MmsPluginHttpAgent*     httpAgent = MmsPluginHttpAgent::instance();
+
+       while (retryCount < RETRY_MAX) {
+               ret = httpAgent->cmdRequest(qEntity->eHttpCmdType);
+
+               // Process result
+               if (ret == eMMS_HTTP_SENT_SUCCESS) {
+                       MSG_DEBUG("Submit request sent");
+                       break;
+               } else if (ret == eMMS_HTTP_ERROR_NETWORK) {
+                       retryCount++;
+                       MSG_DEBUG("HTTP sent timeout and try again: %d", retryCount);
+                       continue;
+               } else {
+                       MSG_DEBUG("Unexpected Error %d", ret);
+                       break;
+               }
+       }
+
+       return ret;
+}
+
+MMS_NET_ERROR_T MmsPluginUaManager::waitingConf(mmsTranQEntity *qEntity)
+{
+       MMS_NET_ERROR_T ret = eMMS_HTTP_ERROR_UNKNOWN;
+       MmsPluginHttpAgent *pHttpAgent = MmsPluginHttpAgent::instance();
+       MMS_PLUGIN_HTTP_CONTEXT_S *pMmsPldCd = NULL;
+
+       pMmsPldCd = pHttpAgent->getMmsPldCd();
+
+       if (qEntity->pGetData) {
+               free(qEntity->pGetData);
+               qEntity->pGetData = NULL;
+       }
+       qEntity->getDataLen = pMmsPldCd->bufOffset;
+       qEntity->pGetData = (char *)calloc(1, pMmsPldCd->bufOffset + 1);
+
+       memcpy(qEntity->pGetData, pMmsPldCd->final_content_buf, pMmsPldCd->bufOffset);
+       free(pMmsPldCd->final_content_buf);
+       pMmsPldCd->final_content_buf = NULL;
+       pMmsPldCd->bufOffset = 0;
+
+       MSG_DEBUG("dataLen:%d  pData:(%s)", qEntity->getDataLen, qEntity->pGetData);
+
+       ret = eMMS_HTTP_CONF_SUCCESS;
+
+       return ret;
+}
+
+void MmsPluginUaManager::run()
+{
+       MSG_BEGIN();
+
+       MmsPluginCmAgent *cmAgent = MmsPluginCmAgent::instance();
+       MmsPluginHttpAgent *httpAgent = MmsPluginHttpAgent::instance();
+
+       int trId;
+       CURL *session = NULL;
+
+       int msgId;
+
+       while (1) {
+               if (mmsTranQ.empty()) {
+                       lock();
+                       wait();
+                       unlock();
+               }
+
+               // Request CM Open
+               if (!(cmAgent->open())) {
+                       MSG_DEBUG("Cm Open Failed");
+
+                       // delete all request from reqQEntities
+                       goto CLEANUP;
+               }
+
+               httpAgent->SetMMSProfile();
+
+               while (!mmsTranQ.empty()) {
+
+                       MSG_DEBUG("###### mmsTranQ.size [%d]", mmsTranQ.size());
+
+                       mmsTranQEntity reqEntity;
+                       memset(&reqEntity, 0, sizeof(mmsTranQEntity));
+
+                       mmsTranQ.front(&reqEntity);
+
+                       reqEntity.isCompleted = false;
+
+                       PRINT_QUEUE_ENTITY(&reqEntity);
+
+                       if (reqEntity.eMmsPduType == eMMS_RETRIEVE_AUTO) {
+                               msgId = reqEntity.msgId;
+                               MmsPluginStorage::instance()->updateNetStatus(msgId, MSG_NETWORK_RETRIEVING);
+                       }
+
+                       if (httpAgent->cmdRequest(eHTTP_CMD_INIT_SESSION) == eMMS_HTTP_SESSION_OPEN_FAILED) {
+                               MSG_DEBUG("HTTP session open failed");
+                               // cm close
+                               cmAgent->close();
+                               // delete all request from reqQEntities
+                               goto CLEANUP;
+                       }
+
+                       // MMS Transaction
+                       MSG_DEBUG("\n\n ===================  MMS Transaction Start ========================");
+
+                       do {
+                               httpAgent->setSession(&reqEntity);
+
+                               if (submitHandler(&reqEntity) != eMMS_HTTP_SENT_SUCCESS) {
+                                       MSG_DEBUG("Transaction Error: submit failed");
+
+                                       MmsPluginEventHandler::instance()->handleMmsError(&reqEntity);
+                                       mmsTranQ.pop_front();
+                                       //try to next mmsTranQ
+                                       break;
+                               }
+
+                               MSG_DEBUG("submitHandler(&reqEntity) success.");
+                               trId = httpAgent->getHttpConfigData()->transactionId;
+
+                               MSG_DEBUG("#### MMS PDU TYPE = %d ####", reqEntity.eMmsPduType);
+
+                               if (reqEntity.eMmsPduType == eMMS_NOTIFYRESP_IND ||
+                                       reqEntity.eMmsPduType == eMMS_ACKNOWLEDGE_IND ||
+                                       reqEntity.eMmsPduType == eMMS_READREC_IND ||
+                                       reqEntity.eMmsPduType == eMMS_CANCEL_CONF) {
+                                       reqEntity.isCompleted = true;
+
+                                       mmsTranQ.pop_front();
+
+                                       MSG_DEBUG("Transaction Completed");
+                                       break;
+                               } else {
+                                       // change MmsPduType from XXX.req to XXX.conf for waiting
+                                       MSG_DEBUG("Update Pdutype");
+                                       updatePduType(&reqEntity);
+                                       MSG_DEBUG("Waiting Conf");
+                               }
+
+                               mmsTranQ.pop_front();
+
+                               //////// Waiting Conf //////////////////////
+                               MMS_NET_ERROR_T networkErr;
+
+                               if ((networkErr = waitingConf(&reqEntity)) == eMMS_HTTP_CONF_SUCCESS) {
+                                       bool bReportAllowed;
+                                       char retrievedFilePath[MAX_FULL_PATH_SIZE+1] = {0,};
+
+                                       // process Http data
+                                       try {
+                                               if (processReceivedData(reqEntity.msgId, reqEntity.pGetData, reqEntity.getDataLen, retrievedFilePath) == false) {
+                                                       MmsPluginEventHandler::instance()->handleMmsError(&reqEntity);
+                                                       break;
+                                               }
+                                       } catch (MsgException& e) {
+                                               MSG_FATAL("%s", e.what());
+                                               MmsPluginEventHandler::instance()->handleMmsError(&reqEntity);
+                                               break;
+
+                                       } catch (exception& e) {
+                                               MSG_FATAL("%s", e.what());
+                                               MmsPluginEventHandler::instance()->handleMmsError(&reqEntity);
+                                               break;
+                                       }
+
+                                       if (reqEntity.eMmsPduType != (MMS_PDU_TYPE_T)mmsHeader.type) {
+                                               if (!(reqEntity.eMmsPduType == eMMS_RETRIEVE_MANUAL_CONF && mmsHeader.type == MMS_MSGTYPE_RETRIEVE_CONF)) {
+                                                       MSG_DEBUG("FAIL::type mismatched req:%d received:%d", reqEntity.eMmsPduType, mmsHeader.type);
+
+                                                       MmsPluginEventHandler::instance()->handleMmsError(&reqEntity);
+                                                       break;
+                                               }
+                                       }
+
+                                       MSG_DEBUG("conf received successfully");
+
+                                       try {
+                                               MmsPluginEventHandler::instance()->handleMmsReceivedData(&reqEntity, retrievedFilePath);
+                                       } catch (MsgException& e) {
+                                               MSG_FATAL("%s", e.what());
+                                               break;
+                                       } catch (exception& e) {
+                                               MSG_FATAL("%s", e.what());
+                                               break;
+                                       }
+
+                                       MsgSettingGetBool(MMS_RECV_DELIVERY_RECEIPT, &bReportAllowed);
+
+                                       MSG_DEBUG("conf received successfully -2");
+                                       MSG_DEBUG("reqEntity.eMmsPduType [%d]", reqEntity.eMmsPduType);
+
+                                       // send NotifyResponseInd
+                                       if (reqEntity.eMmsPduType == eMMS_RETRIEVE_AUTO_CONF) {
+                                               char filepath[MAX_FULL_PATH_SIZE] = {0};
+                                               // change MmsPduType for ind or ack
+                                               // make the PDU and then attach to reqEntity also.
+                                               updatePduType(&reqEntity);
+
+                                               MSG_DEBUG("#### eMmsPduType:%d ####", reqEntity.eMmsPduType);
+
+                                               //update http command type & encode m-notify-response-ind
+                                               reqEntity.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
+
+                                               try {
+                                                       MmsPluginInternal::instance()->encodeNotifyRespInd(reqEntity.transactionId, MMS_MSGSTATUS_RETRIEVED, bReportAllowed, filepath);
+                                                       //m-notification-resp-ind encoding      if err is not MSG_SUCCESS then should set x-mms-status to deferred
+                                                       if (MsgGetFileSize(filepath, &reqEntity.postDataLen) == false) {
+                                                               MSG_DEBUG("MsgGetFileSize: failed");
+                                                               break;
+                                                       }
+                                               } catch (MsgException& e) {
+                                                       MSG_FATAL("%s", e.what());
+                                                       break;
+                                               } catch (exception& e) {
+                                                       MSG_FATAL("%s", e.what());
+                                                       break;
+                                               }
+
+                                               if (reqEntity.pPostData) {
+                                                       free(reqEntity.pPostData);
+                                                       reqEntity.pPostData = NULL;
+                                               }
+
+                                               reqEntity.pPostData = MsgOpenAndReadMmsFile(filepath, 0, -1, &reqEntity.postDataLen);
+
+                                               mmsTranQ.push_front(reqEntity);
+
+                                               remove(filepath);
+
+                                               MSG_DEBUG("Submit Ind");
+                                       } else if (reqEntity.eMmsPduType == eMMS_RETRIEVE_MANUAL_CONF) {
+                                               /* saved msg trId should be checked  */
+                                               // Send Acknowledge Ind
+                                               char filepath[MAX_FULL_PATH_SIZE] = {0};
+                                               // change MmsPduType for ind or ack
+                                               // make the PDU and then attach to reqEntity also.
+                                               updatePduType(&reqEntity);
+
+                                               MSG_DEBUG("#### eMmsPduType:%d ####", reqEntity.eMmsPduType);
+
+                                               //update http command type & encode m-notify-response-ind
+                                               reqEntity.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
+
+                                               try {
+                                                       MmsPluginInternal::instance()->encodeAckInd(reqEntity.transactionId, bReportAllowed, filepath);
+                                                       if (MsgGetFileSize(filepath, &reqEntity.postDataLen) == false) {
+                                                               MSG_DEBUG("MsgGetFileSize: failed");
+                                                               break;
+                                                       }
+                                               } catch (MsgException& e) {
+                                                       MSG_FATAL("%s", e.what());
+                                                       break;
+                                               } catch (exception& e) {
+                                                       MSG_FATAL("%s", e.what());
+                                                       break;
+                                               }
+
+                                               if (reqEntity.pPostData) {
+                                                       free(reqEntity.pPostData);
+                                                       reqEntity.pPostData = NULL;
+                                               }
+
+                                               reqEntity.pPostData = MsgOpenAndReadMmsFile(filepath, 0, -1, &reqEntity.postDataLen);
+
+                                               mmsTranQ.push_front(reqEntity);
+
+                                               remove(filepath); // not ipc
+
+                                               MSG_DEBUG("Submit Ack");
+                                       } else {
+                                               reqEntity.isCompleted = true;
+
+                                               MSG_DEBUG("Transaction complete");
+                                       }
+                               } else {
+                                       MmsPluginEventHandler::instance()->handleMmsError(&reqEntity);
+                                       break;
+                               }
+                       } while (reqEntity.isCompleted == false);
+
+                       MSG_DEBUG("==== MMS Transaction Completed ====\n\n");
+
+                       if (reqEntity.pPostData) {
+                               free(reqEntity.pPostData);
+                               reqEntity.pPostData = NULL;
+                       }
+
+                       if (reqEntity.pGetData) {
+                               free(reqEntity.pGetData);
+                               reqEntity.pGetData = NULL;
+                       }
+
+                       // Http Session Close
+                       httpAgent->clearSession();
+               }
+
+               // Request CM Close
+               cmAgent->close();
+
+       }
+
+CLEANUP:
+       MSG_DEBUG("CLEANUP");
+
+       while (!mmsTranQ.empty()) {
+               MSG_DEBUG("clear mmsTranQ");
+
+               mmsTranQEntity reqEntity;
+               memset(&reqEntity, 0, sizeof(mmsTranQEntity));
+
+               mmsTranQ.front(&reqEntity);
+
+               // notify send fail to APP
+               MmsPluginEventHandler::instance()->handleMmsError(&reqEntity);
+
+               if (reqEntity.pGetData) {
+                       MSG_DEBUG("free pGetData");
+                       free(reqEntity.pGetData);
+                       reqEntity.pGetData = NULL;
+               }
+
+               if (reqEntity.pPostData) {
+                       MSG_DEBUG("free pPostData");
+                       free(reqEntity.pPostData);
+                       reqEntity.pPostData = NULL;
+               }
+
+               mmsTranQ.pop_front();
+       }
+
+       mmsTranQ.clear();
+       MutexLocker locker(mx);
+       running = false;
+
+       MSG_END();
+
+       return;
+}
+
+void MmsPluginUaManager::getMmsPduData(mmsTranQEntity *qEntity)
+{
+       mmsTranQ.front(qEntity);
+}
+
+void MmsPluginUaManager::addMmsReqEntity(mmsTranQEntity req)
+{
+       MSG_DEBUG("New MMS Tran Added");
+       mmsTranQ.push_back(req);
+       lock();
+       signal();
+       unlock();
+}
+
+bool MmsPluginUaManager::processReceivedData(int msgId, char *pRcvdBody, int rcvdBodyLen, char *retrievedFilePath)
+{
+       MSG_BEGIN();
+
+       char fileName[MSG_FILENAME_LEN_MAX] = {0};
+       FILE *pFile = NULL;
+
+       MSG_DEBUG(":::%d :%s ", rcvdBodyLen, pRcvdBody);
+
+       _MmsInitHeader();
+       _MmsRegisterDecodeBuffer(gszMmsLoadBuf1,  gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX);
+
+       if (MsgCreateFileName(fileName) == false)
+               return false;
+
+       snprintf(retrievedFilePath, MSG_FILEPATH_LEN_MAX, MSG_DATA_PATH"%s", fileName);
+
+       MSG_DEBUG("retrievedFilePaths [%s]", retrievedFilePath);
+
+       // create temp file
+       if (!MsgOpenCreateAndOverwriteFile(retrievedFilePath, (char *)pRcvdBody, rcvdBodyLen)) {
+               MSG_DEBUG( "_MmsUaInitMsgDecoder: creating temporary file failed(msgID=%d)\n", msgId);
+               return false;
+       }
+
+       if (_MmsReadMsgBody(msgId, true, true, retrievedFilePath) == false) {
+               MSG_DEBUG("The MMS Message might include drm contents!!!");
+
+#ifdef __SUPPORT_DRM__
+               if (MmsDrm2GetConvertState() == MMS_DRM2_CONVERT_REQUIRED) {
+                       bool bRetToConvert = true;
+                       MSG_MESSAGE_INFO_S pMsg = {0, };
+
+                       pMsg.msgId = msgId;
+
+                       bRetToConvert = MmsDrm2ConvertMsgBody(mmsHeader.msgType.szOrgFilePath);
+
+                       MmsDrm2SetConvertState(MMS_DRM2_CONVERT_FINISH);
+
+                       if (bRetToConvert) {
+                               remove(mmsHeader.msgType.szOrgFilePath);
+                               rename(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, mmsHeader.msgType.szOrgFilePath);
+
+                               if (MmsDrm2ReadMsgConvertedBody(&pMsg, true, true, retrievedFilePath) == false) {
+                                       MSG_DEBUG("MmsLoadMsg:MmsDrm2ReadMsgConvertedBody() returns false\n");
+                                       goto ERR_MMS_UA_PROCESS_CONF;
+                               }
+                       }
+               }
+#endif
+       }
+
+       MSG_END();
+
+       return true;
+
+ERR_MMS_UA_PROCESS_CONF:
+       {
+               MmsMsg *pMsg;
+               MmsPluginStorage::instance()->getMmsMessage(&pMsg);
+
+
+               _MmsInitHeader();
+               _MmsUnregisterDecodeBuffer();
+
+#ifdef __SUPPORT_DRM__
+               _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
+#endif
+               _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
+
+               return false;
+       }
+}
+
diff --git a/plugin/mms_plugin/include/MmsPluginAvCodec.h b/plugin/mms_plugin/include/MmsPluginAvCodec.h
new file mode 100755 (executable)
index 0000000..8e1b35f
--- /dev/null
@@ -0,0 +1,92 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgTypes.h"
+
+#define        FILEEXT_MAX     5
+
+typedef enum {
+       AV_CODEC_NONE                                           = 0x00000000,
+       AV_CODEC_AUDIO_REAL                                     = 0x00000001,
+       AV_CODEC_AUDIO_AMR                                      = 0x00000002,           // AMR
+       AV_CODEC_AUDIO_G723_1                           = 0x00000004,           // G723.1
+       AV_CODEC_AUDIO_MP3                                      = 0x00000008,           // MP3
+       AV_CODEC_AUDIO_AAC                                      = 0x00000010,           // AAC
+       AV_CODEC_AUDIO_MIDI                                     = 0x00000020,           // MIDI
+       AV_CODEC_AUDIO_MMF                                      = 0x00000040,           // MMF
+       AV_CODEC_AUDIO_MMF_PHRASE_L1            = 0x00000080,           // YAMAHA Phrase L1
+       AV_CODEC_AUDIO_ADPCM                            = 0x00000100,           // ADPCM
+       AV_CODEC_AUDIO_WAVE                                     = 0x00000200,           // WAVE
+       AV_CODEC_AUDIO_IMELODY                          = 0x00000400,           // IMELODY
+       AV_CODEC_AUDIO_DTMF_TONE                        = 0x00000800,           // DTMF
+       AV_CODEC_AUDIO_DTMF_TONE_ID                     = 0x00001000,
+       AV_CODEC_AUDIO_DTMF_TONE_FREQ           = 0x00002000,
+       AV_CODEC_AUDIO_DTMF_SOUND_ID            = 0x00004000,
+       AV_CODEC_AUDIO_DTMF_TONE_FLEX           = 0x00008000,           // DTMF
+       AV_CODEC_AUDIO_MPEG4                            = 0x00010000,           // MPEG4 audio
+       AV_CODEC_AUDIO_SPM                                      = 0x00020000,           // SPM(SP-MIDI)
+       AV_CODEC_AUDIO_PCM                                      = 0x00040000,
+       AV_CODEC_AUDIO_XMF                                      = 0x00080000,           // XMF
+       AV_CODEC_VIDEO_H263                                     = 0x00400000,           // H.26L
+       AV_CODEC_VIDEO_MPEG4                            = 0x02000000,           // MPEG4 video
+       AV_CODEC_VIDEO_AVI                                      = 0x04000000,           // MPEG4 video
+       AV_CODEC_VIDEO_MPEG1                            = 0x08000000,           // MPEG4 video
+       AV_CODEC_VIDEO_REAL                                     = 0x10000000,
+       AV_CODEC_VIDEO_PVX                                      = 0x20000000,            // for Fast Track .PVX type
+
+       AV_ENC_AUDIO_AMR                                        = AV_CODEC_AUDIO_AMR,           // AMR
+       AV_ENC_AUDIO_G723_1                                     = AV_CODEC_AUDIO_G723_1,        // G723.1
+       AV_ENC_AUDIO_MP3                                        = AV_CODEC_AUDIO_MP3,           // MP3
+       AV_ENC_AUDIO_AAC                                        = AV_CODEC_AUDIO_AAC,           // AAC
+       AV_ENC_AUDIO_ADPCM                                      = AV_CODEC_AUDIO_ADPCM,         // ADPCM
+       AV_ENC_AUDIO_WAVE                                       = AV_CODEC_AUDIO_WAVE,          // WAVE
+       AV_ENC_VIDEO_H263                                       = AV_CODEC_VIDEO_H263,          // H.263
+       AV_ENC_VIDEO_MPEG4                                      = AV_CODEC_VIDEO_MPEG4,         // MPEG4
+       AV_ENC_VIDEO_AVI                                        = AV_CODEC_VIDEO_AVI,           // AVI
+       AV_ENC_VIDEO_MPEG1                                      = AV_CODEC_VIDEO_MPEG1,         // MPEG1
+
+       AV_DEC_AUDIO_DTMF_TONE_FLEX                     = AV_CODEC_AUDIO_DTMF_TONE_FLEX,        // DTMF
+       AV_DEC_AUDIO_AMR                                        = AV_CODEC_AUDIO_AMR,           // AMR
+       AV_DEC_AUDIO_G723_1                                     = AV_CODEC_AUDIO_G723_1,        // G723.1
+       AV_DEC_AUDIO_MP3                                        = AV_CODEC_AUDIO_MP3,           // MP3
+       AV_DEC_AUDIO_AAC                                        = AV_CODEC_AUDIO_AAC,           // AAC
+       AV_DEC_AUDIO_MIDI                                       = AV_CODEC_AUDIO_MIDI,          // MIDI
+       AV_DEC_AUDIO_MMF                                        = AV_CODEC_AUDIO_MMF,           // MMF
+       AV_DEC_AUDIO_MMF_PHRASE_L1                      = AV_CODEC_AUDIO_MMF_PHRASE_L1,         // YAMAHA Phrase L1
+       AV_DEC_AUDIO_ADPCM                                      = AV_CODEC_AUDIO_ADPCM,         // ADPCM
+       AV_DEC_AUDIO_WAVE                                       = AV_CODEC_AUDIO_WAVE,          // WAVE
+       AV_DEC_AUDIO_IMELODY                            = AV_CODEC_AUDIO_IMELODY,               // IMELODY
+       AV_DEC_AUDIO_DTMF_TONE                          = AV_CODEC_AUDIO_DTMF_TONE,             // DTMF
+       AV_DEC_AUDIO_DTMF_TONE_ID                       = AV_CODEC_AUDIO_DTMF_TONE_ID,
+       AV_DEC_AUDIO_DTMF_TONE_FREQ                     = AV_CODEC_AUDIO_DTMF_TONE_FREQ,
+       AV_DEC_AUDIO_DTMF_SOUND_ID                      = AV_CODEC_AUDIO_DTMF_SOUND_ID,
+       AV_DEC_AUDIO_MPEG4                                      = AV_CODEC_AUDIO_MPEG4,         // MPEG4 audio
+       AV_DEC_AUDIO_SPM                                        = AV_CODEC_AUDIO_SPM,           // SPM(SP-MIDI)
+       AV_DEC_AUDIO_XMF                                        = AV_CODEC_AUDIO_XMF,           // XMF
+       AV_DEC_AUDIO_REAL                                       = AV_CODEC_AUDIO_REAL,          // MPEG4 video
+
+       AV_DEC_VIDEO_H263                                       = AV_CODEC_VIDEO_H263,          // H.26L
+       AV_DEC_VIDEO_MPEG4                                      = AV_CODEC_VIDEO_MPEG4,         // MPEG4 video
+       AV_DEC_VIDEO_AVI                                        = AV_CODEC_VIDEO_AVI,           // AVI
+       AV_DEC_VIDEO_MPEG1                                      = AV_CODEC_VIDEO_MPEG1,         // MPEG1
+
+       AV_DEC_VIDEO_REAL                                       = AV_CODEC_VIDEO_REAL,                  // REAL VIDEO DEC
+
+       AV_DEC_VIDEO_PVX                                        = AV_CODEC_VIDEO_PVX,                //for .PVX
+
+} AvCodecType;
+
+AvCodecType    AvGetFileCodecType(const char *szFileName);
diff --git a/plugin/mms_plugin/include/MmsPluginCodec.h b/plugin/mms_plugin/include/MmsPluginCodec.h
new file mode 100755 (executable)
index 0000000..9e50704
--- /dev/null
@@ -0,0 +1,379 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMS_PLUGIN_CODEC_H
+#define MMS_PLUGIN_CODEC_H
+
+
+/*==================================================================================================
+                                                       HEADER
+==================================================================================================*/
+
+#include <glib.h>
+#include <vconf.h>
+#include "MsgMmsTypes.h"
+#include "MmsPluginMessage.h"
+#include "MsgTransportTypes.h"
+
+/*==================================================================================================
+                                                       DEFINE
+==================================================================================================*/
+
+#define        MMS_MAJOR_VERSION                       1
+
+#if defined(MMS_V1_1)
+#define        MMS_MINOR_VERSION                       1
+#define        MMS_VERSION                                     0x91
+
+#elif defined(MMS_V1_2)
+#define        MMS_MINOR_VERSION                       2
+#define        MMS_VERSION                                     0x92
+
+#else
+#define        MMS_MINOR_VERSION                       0
+#define        MMS_VERSION                                     0x90
+#endif
+
+#define        MMS_SIGN_TEXT_LEN                       100
+#define        MMS_MAX_FIELD_VALUE_COUNT       74
+#define        MMS_MAX_FIELD_TYPE_COUNT        21
+#define        MSG_MMS_ENCODE_BUFFER_MAX       (2 * 1024)
+#define        MSG_MMS_DECODE_BUFFER_MAX       (2 * 1024)
+#define        MSB                                                             0x80
+#define        QUOTE                                                   0x7F
+#define        MARK                                                    0x22    // "
+#define        NO_VALUE                                                0x00
+#define        LENGTH_QUOTE                                    0x1F
+#define        MSG_STDSTR_LONG                         0xFF
+#define        INVALID_VALUE                                   -1
+#define        MSG_INVALID_VALUE                               -1
+
+#define        MMS_MAX_FIELD_VALUE_COUNT       74
+#define        MMS_MAX_FIELD_TYPE_COUNT        21
+
+#define MSG_LOCAL_TEMP_BUF_SIZE 1024
+#define MSG_INBOX_DIRECTORY                    "/User/Msg/Inbox"
+/*==================================================================================================
+                                                       ENUMS
+==================================================================================================*/
+
+typedef enum {
+       MMS_CODE_BCC,
+       MMS_CODE_CC,
+       MMS_CODE_CONTENTLOCATION,
+       MMS_CODE_CONTENTTYPE,
+       MMS_CODE_DATE,
+       MMS_CODE_DELIVERYREPORT,
+       MMS_CODE_DELIVERYTIME,
+       MMS_CODE_EXPIRYTIME,
+       MMS_CODE_FROM,
+       MMS_CODE_MSGCLASS,
+       MMS_CODE_MSGID,
+       MMS_CODE_MSGTYPE,
+       MMS_CODE_VERSION,
+       MMS_CODE_MSGSIZE,
+       MMS_CODE_PRIORITY,
+       MMS_CODE_READREPLY,
+       MMS_CODE_REPORTALLOWED,
+       MMS_CODE_RESPONSESTATUS,
+       MMS_CODE_RETRIEVESTATUS,                /* Add by MMSENC v1.1 */
+       MMS_CODE_RESPONSETEXT,
+       MMS_CODE_RETRIEVETEXT,                  /* Add by MMSENC v1.1 */
+       MMS_CODE_SENDERVISIBILLITY,
+       MMS_CODE_MSGSTATUS,
+       MMS_CODE_SUBJECT,
+       MMS_CODE_TO,
+       MMS_CODE_TRID,
+
+       /* Add by MMSENC v1.1 */
+       MMS_CODE_READSTATUS,
+       MMS_CODE_REPLYCHARGING,
+       MMS_CODE_REPLYCHARGINGDEADLINE,
+       MMS_CODE_REPLYCHARGINGID,
+       MMS_CODE_REPLYCHARGINGSIZE,
+       MMS_CODE_PREVIOUSLYSENTBY,
+       MMS_CODE_PREVIOUSLYSENTDATE,
+
+       MMS_CODE_TRANSFERENCODING,
+       MMS_CODE_DISPOSITION,
+       MMS_CODE_CONTENT_ID
+} MmsFieldCode;
+
+enum {
+       MMS_BODYHDR_TRANSFERENCODING,
+       MMS_BODYHDR_DISPOSITION,
+       MMS_BODYHDR_CONTENTID,
+       MMS_BODYHDR_CONTENTLOCATION,
+       MMS_BODYHDR_X_OMA_DRM_SEPARATE_DELIVERY,        // DRM RO WAITING
+};
+
+typedef enum {
+       //code
+       MmsCodeFieldCode,
+       MmsCodeParameterCode,
+       MmsCodeMsgBodyHeaderCode,
+
+       //Data
+       MmsCodeMsgType,
+       MmsCodeDeliveryReport,
+       MmsCodeTimeType,
+       MmsCodeMsgClass,
+       MmsCodePriority,
+       MmsCodeResponseStatus,
+       MmsCodeRetrieveStatus,
+       MmsCodeReadReply,
+       MmsCodeReportAllowed,
+       MmsCodeSenderVisibility,
+       MmsCodeMsgStatus,
+       MmsCodeReadStatus,
+       MmsCodeAddressType,
+       MmsCodeCharSet,
+       MmsCodeReplyCharging,
+
+       MmsCodeContentType,
+
+       MmsCodeMsgDisposition,
+       MmsCodeContentTransferEncoding
+} MmsCode;
+
+typedef enum {
+       MSG_PRESENTATION_NONE = -1,
+       MSG_PRESENTATION_FIRSTPART,             //Content-type == type parameter
+       MSG_PRESENTATION_TYPE_BASE,             //Content-type == type parameter
+       MSG_PRESENTATION_LOCATION,              //Content-Location == start parameter
+       MSG_PRESENTATION_ID,                    //Content-ID == start parameter
+} MsgPresentationFactor;
+
+/*==================================================================================================
+                                                       Structures
+==================================================================================================*/
+
+typedef struct {
+       const char *szText;
+       UINT16 binary;
+} MmsField;
+
+
+typedef struct {
+       char *pData;
+       UINT32 length;
+} EncodedPData;
+
+typedef struct {
+       MsgPresentationFactor factor;
+       MsgMultipart *pPrevPart;
+       MsgMultipart *pCurPresentation;
+} MsgPresentaionInfo;
+
+// for Decoding & Encoding
+typedef struct {
+       bool bActive;
+       char *pszOwner;
+       int msgID;              // if noti.ind, msgID is -1.
+
+       MmsMsgType type;
+       char szTrID[MMS_TR_ID_LEN+1];
+       UINT8 version;
+       UINT32 date;
+
+       MsgHeaderAddress *pFrom;                //"/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6"
+       MsgHeaderAddress *pTo;
+       MsgHeaderAddress *pCc;
+       MsgHeaderAddress *pBcc;
+       char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
+       MmsResponseStatus responseStatus;
+       MmsRetrieveStatus retrieveStatus;
+       char szResponseText[MMS_LOCALE_RESP_TEXT_LEN + 1];
+       char szRetrieveText[MMS_LOCALE_RESP_TEXT_LEN + 1];
+
+       MmsMsgClass msgClass;
+       MmsTimeStruct expiryTime;
+       MmsTimeStruct deliveryTime;
+       MmsPriority priority;
+       MmsSenderVisible hideAddress;
+       MmsReport deliveryReport;
+       MmsReport readReply;
+       MmsReportAllowed reportAllowed;
+       char szContentLocation[MMS_LOCATION_LEN + 1];
+
+       MSG_DELIVERY_REPORT_STATUS_T msgStatus;
+       MSG_READ_REPORT_STATUS_T readStatus;
+
+       MmsReplyCharge replyCharge;
+
+       // only used at Decoding module
+       char szMsgID[MMS_MSG_ID_LEN + 1];
+       UINT32 msgSize;
+
+#ifdef __SUPPORT_DRM__
+       MsgDrmType drmType;
+#endif
+
+       // dependent to Client implementation
+       MsgType msgType;
+       MsgBody msgBody;
+} MmsHeader;
+
+extern const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT];
+extern char gszMmsLoadBuf1[MSG_MMS_DECODE_BUFFER_MAX + 1];
+extern char gszMmsLoadBuf2[MSG_MMS_DECODE_BUFFER_MAX + 1];
+
+extern MmsHeader mmsHeader;
+
+/* Common */
+char *_MmsGetTextValue(MmsCode i, int j);
+char *_MmsGetTextValuebyField(int field, int value);
+int _MmsGetTextType(MmsCode i, char *pValue);
+UINT16 _MmsGetBinaryValue(MmsCode i, int j);
+int _MmsGetBinaryType(MmsCode i, UINT16 value);
+UINT8 _MmsGetVersion(MmsMsg *pMsg);
+bool _MmsSetVersion(int majorVer, int minorVer);
+
+
+/* Decoding */
+void _MmsInitHeader();
+void _MmsCleanDecodeBuff(void);
+bool _MmsDecodeInitialize(void);
+void _MmsRegisterDecodeBuffer(char *pInBuff1, char *pInBuffer2, int maxLen);
+void _MmsUnregisterDecodeBuffer(void);
+int _MmsGetDecodeOffset(void);
+
+bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength);
+bool MmsBinaryDecodeContentType(FILE *pFile, char *szFilePath, int totalLength); // for JAVA MMS AppId
+
+bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength);
+int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength);
+bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, int totalLength);
+bool MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalLength);
+bool MmsBinaryDecodeEntries(FILE *pFile, UINT32 *npEntries, int totalLength);
+bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength);
+
+bool MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength);
+
+
+/* Encoding */
+void _MmsRegisterEncodeBuffer(char *pInBuff, int maxLen);
+void _MmsUnregisterEncodeBuffer(void);
+int _MmsGetEncodeOffset(void);
+
+bool _MmsEncodeMsg(void);
+bool _MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg);
+bool _MmsEncodeTemplate(FILE *pFile, MmsMsg *pMsg);    // just encode MMS Body without any header.
+bool _MmsEncodeAckInd(FILE *pFile, char *szTrID, bool bReportAllowed);
+bool _MmsEncodeNotiRespInd(FILE *pFile, char *szTrID, MSG_DELIVERY_REPORT_STATUS_T iStatus, bool bReportAllowed);
+bool _MmsEncodeForwardReq(FILE *pFile, char *szContentLocation, char *szForwardTo, char *szForwardCc, char *szForwardBcc);
+bool _MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, MSG_READ_REPORT_STATUS_T mmsReadStatus);
+bool _MmsEncodeReadReport11(FILE *pFile, MmsMsg *pMsg, MSG_READ_REPORT_STATUS_T mmsReadStatus);
+
+
+bool MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPartCount, bool bTemplate);//NEW_TEMPLATE
+
+int MmsBinaryEncodeContentTypeLen(MsgType *pType);
+bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength);
+int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType, bool bMultipart);
+bool MmsBinaryEncodeContentHeader(FILE *pFile, MsgContentType contentType, MsgType *pType, bool bMultipart);
+bool MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody);
+bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBody *pBody);
+bool MmsBinaryEncodeSendReqHdrwithinBufRegi(FILE *pFile, MmsMsg *pMsg);
+bool MsgWriteDataFromEncodeBuffer(FILE *pFile, char *pInBuffer, int *pPtr, int maxLen, int *pOffset);
+bool MsgLoadDataToDecodeBuffer(FILE *pFile, char **ppBuf, int *pPtr, int *pOffset, char *pInBuf1, char *pInBuf2, int maxLen, int *npRead, int endOfFile);
+bool MsgFreeHeaderAddress(MsgHeaderAddress *pAddr);
+bool MsgCheckFileNameHasInvalidChar(char *szName);
+bool _MsgReplaceInvalidFileNameChar(char *szInText, char replaceChar);
+char *_MsgGetStringUntilDelimiter(char *pszString, char delimiter);
+char *MsgChangeHexString(char *pOrg);
+bool _MsgParseParameter(MsgType *pType, char *pSrc);
+char *_MsgSkipWS(char *s);
+char *__MsgSkipComment(char *s, long trim);
+int _MsgGetCode(MsgHeaderField tableId, char *pStr);
+char *MsgConvertLatin2UTF8FileName(char *pSrc);
+bool _MsgChangeSpace(char *pOrg, char **ppNew);
+void _MsgRemoveFilePath(char *pSrc);
+bool MsgIsUTF8String(unsigned char *szSrc, int nChar);
+bool MsgIsPercentSign(char *pSrc);
+MsgMultipart *MsgAllocMultipart(void);
+bool _MsgInitMsgType(MsgType *pMsgType);
+bool _MsgInitMsgBody(MsgBody *pMsgBody);
+MsgPresentationFactor MsgIsPresentationEx(MsgType *multipartType, char *szStart, MsgContentType typeParam);
+void MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresentaionInfo *pPresentationInfo);
+bool MsgIsMultipartRelated(int type);
+bool MsgIsPresentablePart(int type);
+bool MsgIsText(int type);
+bool _MsgFreeBody(MsgBody *pBody, int type);
+bool MsgFreeAttrib(MmsAttrib *pAttrib);
+bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody);
+char *MsgResolveContentURI(char *szSrc);
+bool _MsgParsePartHeader(MsgType *pType, const char *pRawData, int nRawData);
+char *MsgRemoveQuoteFromFilename(char *pSrc);
+MmsMsg *MmsGetMsgById(MmsMsgID msgID, bool msgLock);
+bool MsgIsMultipart(int type);
+bool MsgIsHexChar(char *pSrc);
+char _MsgConvertHexValue(char *pSrc);
+int __MsgConvertCharToInt(char ch);
+bool __MsgInitMsgContentParam(MsgContentParam *pMsgContentParam);
+bool MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2);
+bool MsgCopyNestedMsgParam(MsgContentParam *pParam1, MsgContentParam *pParam2);
+bool MsgIsMultipartMixed(int type);
+bool MsgStrcpyWithoutCRLF(char *pOrg, char **ppNew);
+bool __MsgIsInvalidFileNameChar(char ch);
+bool MmsAddrUtilCompareAddr(char *pszAddr1, char *pszAddr2);
+bool _MmsDataUpdateLastStatus(MmsMsg *pMsg);
+
+bool _MsgEncodeBase64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret);
+void *_MsgDecodeBase64(unsigned char *pSrc, unsigned long srcLen, unsigned long *len);
+bool _MsgEncodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret);
+unsigned char *_MsgDecodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len);
+bool _MsgEncode2Base64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret);
+char *_MsgDecodeText(char *pOri);
+char *MsgEncodeText(char *pOri);
+int MsgGetLatin2UTFCodeSize(unsigned char *szSrc, int nChar);
+int MsgLatin5code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar);
+int MsgGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar);
+int MsgLatin2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar);
+int MsgLatin7code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar);
+int MsgGetLatin72UTFCodeSize(unsigned char *szSrc, int nChar);
+int MsgUnicode2UTF(unsigned char *des, int outBufSize, unsigned short *szSrc, int nChar);
+int MsgGetUnicode2UTFCodeSize(unsigned short *szSrc, int nChar);
+bool MmsAddrUtilCheckEmailAddress(char *pszAddr);
+bool MmsAddrUtilRemovePlmnString(char *pszAddr);
+int MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar);
+void MsgMIMERemoveQuote(char *szSrc);
+bool _MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *pszMailboxPath, char *pszMsgFilename, int index, bool bSave);
+bool MsgGetTypeByFileName(int *type, char *szFileName);
+bool MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE *pFile);
+char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msgTypeValue, int msgCharsetValue, int *npRead);
+#ifndef        __SUPPORT_DRM__
+bool MsgMakeFileName(int iMsgType, char *szFileName, int nUntitleIndex);
+#else
+bool MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex);
+#endif
+bool MsgGetFileNameWithoutExtension(char *szOutputName, char *szName);
+int MmsGetMediaPartCount(MSG_MESSAGE_ID_T msgId);
+bool MmsGetMediaPartHeader(int index, MsgType *pHeader);
+bool MmsGetMsgAttrib(MmsMsgID msgID, MmsAttrib *pAttrib);
+bool _MmsReadMsgBody(MSG_MESSAGE_ID_T msgID, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath);
+
+#ifdef __SUPPORT_DRM__
+void _MsgFreeDRMInfo(MsgDRMInfo *pDrmInfo);
+bool MsgCopyDrmInfo(MsgType *pPartType);
+bool MmsDrm2ConvertMsgBody(char *szOriginFilePath);
+bool MmsDrm2ReadMsgConvertedBody(MSG_MESSAGE_INFO_S *pMsg, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath);
+bool MmsDrm2DecodeConvertedMsg(int msgID, char *pszFullPath);
+#endif
+
+bool MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index);
+
+#endif
diff --git a/plugin/mms_plugin/include/MmsPluginConnManWrapper.h b/plugin/mms_plugin/include/MmsPluginConnManWrapper.h
new file mode 100755 (executable)
index 0000000..3c6cb03
--- /dev/null
@@ -0,0 +1,73 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMSPLUGINCONNMANWRAPPER_H
+#define MMSPLUGINCONNMANWRAPPER_H
+
+#include <network-cm-intf.h>
+#include <network-pm-intf.h>
+
+#include "MsgDebug.h"
+
+#include "MmsPluginTypes.h"
+#include "MsgMutex.h"
+
+
+class MmsPluginCmAgent
+{
+public:
+       static MmsPluginCmAgent *instance();
+
+       /* open and close are occasionally called when transaction begins and ends */
+       bool open();
+       void close();
+
+       bool getCmStatus() { return isCmOpened; }
+
+       void processCBdatas(net_event_info_t *event_cb, void *user_data);
+
+       bool getDeviceName(char *deviceName);
+       bool getHomeURL(char *homeURL);
+       bool getProxyAddr(char *proxyAddr);
+       int getProxyPort();
+
+private:
+       MmsPluginCmAgent();
+       ~MmsPluginCmAgent();
+
+       static MmsPluginCmAgent *pInstance;
+
+       /* register/deregister is called once at initialization/finalization of MMS plugin */
+       bool registration();
+       void deregistration();
+
+
+       void lock() { mx.lock(); }
+       void unlock() { mx.unlock(); }
+       void signal() { cv.signal(); }
+       void setCmStatus() { isCmOpened = true; }
+       void resetCmStatus() { isCmOpened = false; }
+
+       // shared variable between CmAgent and Dnet callback
+       bool isCmOpened;
+       Mutex mx;
+       CndVar cv;
+
+       net_profile_info_t mmsProfile;
+};
+
+#endif
+
diff --git a/plugin/mms_plugin/include/MmsPluginData.h b/plugin/mms_plugin/include/MmsPluginData.h
new file mode 100755 (executable)
index 0000000..860fd15
--- /dev/null
@@ -0,0 +1,42 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#define        MMS_INVALID_MSG_ID      -1
+
+/* Mailbox type */
+#define MSG_UI_MAILBOX_MY_FOLDER_MAX   10
+
+typedef enum {
+       MSG_MAILBOX_ROOT                = -1,
+       MSG_MAILBOX_WRITE               = 0,
+       MSG_MAILBOX_INBOX               = 1,
+       MSG_MAILBOX_DRAFT               = 2,
+       MSG_MAILBOX_SENT                = 3,
+       MSG_MAILBOX_MAILBOX             = 4,
+#ifdef _MSG_DB_INCLUDE_OUTBOX
+       MSG_MAILBOX_OUTBOX              = 5,
+#endif
+       MSG_MAILBOX_TEMPLATE            = 6,            //NEW_TEMPLATE
+       MSG_MAILBOX_MYFOLDER            = 7,
+       MSG_MAILBOX_MYFOLDER_LIST       = 8,
+
+
+       MSG_MAILBOX_PRESET                      = (MSG_MAILBOX_MYFOLDER_LIST  + MSG_UI_MAILBOX_MY_FOLDER_MAX),
+
+       MSG_MAILBOX_NONE
+
+} MsgMailboxType;
+
diff --git a/plugin/mms_plugin/include/MmsPluginDebug.h b/plugin/mms_plugin/include/MmsPluginDebug.h
new file mode 100755 (executable)
index 0000000..7b9cfe8
--- /dev/null
@@ -0,0 +1,65 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMS_PLUGIN_DEBUG_H
+#define        MMS_PLUGIN_DEBUG_H
+
+const char *MmsDebugGetMimeType(MimeType mimeType);
+const char *MmsDebugGetMmsReport(MmsReport report);
+const char *MmsDebugGetMmsReportAllowed(MmsReportAllowed reportAllowed);
+const char *MmsDebugGetMmsReadStatus(MSG_READ_REPORT_STATUS_T readStatus);
+const char *MmsDebugGetMsgType(MmsMsgType msgType);
+const char *MmsDebugGetResponseStatus(MmsResponseStatus responseStatus);
+const char *MmsDebugGetRetrieveStatus(MmsRetrieveStatus retrieveStatus);
+const char *MmsDebugGetMsgStatus(MSG_DELIVERY_REPORT_STATUS_T msgStatus);
+const char *MmsDebugGetMsgClass(MmsMsgClass msgClass);
+const char *MmsDebugGetDataType(MmsDataType dataType);
+#ifdef MMS_PLUGIN_DEBUG_ENABLE
+bool MmsDebugPrintMsgAttributes(char *pszFunc, MmsAttrib *pAttrib, bool bAll);
+char *MmsDebugGetMsgDrmType(MsgDrmType drmType);
+char *MmsDebugGetDrmDeliveryMode(DrmDeliveryMode deliveryMode);
+char *MmsDebugGetDrmRightState(DrmRightState rightState);
+bool MmsDebugPrintDrmRight(DrmRight *pDrmRight);
+char *MmsDebugPrintMsgDRMStatus(MsgDRMStatus status);
+bool MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index);
+char *DebugPrintGetRmResultInd(MmsRmResultInd indType);
+char *DebugPrintHttpStatusCode(int status);
+char *DebugPrintRmMethodType(MmsRmMethodType method);
+char *DebugPrintGetMmsRmNetState(MmsRmNetState state);
+char *DebugPrintGetMmsRmEntityState(MmsRmExEntityState stateEx);
+char *MmsDebugPrintMmsRmResult(MmsRmResult result);
+void MmsDebugPrintReqEntityInfo(MmsRmRequest *pEntity);
+char *MmsDebugPrintHttpErrorCode(int errCode);
+char *MmsDebugPrintProtoErrorCode(int errCode);
+char *DebugPrintWspResult(WspResult wspResult);
+char *DebugPrintWspState(MmsRmWapState wspState);
+char *MmsDebugPrintRmPduType(MmsRmPduType pduType);
+char *MmsDebugPrintMailboxType(MsgMailboxType mailboxType);
+#endif
+
+typedef enum {
+       MMS_DEBUG_EV_NONE,
+       MMS_DEBUG_EV_MMS,
+       MMS_DEBUG_EV_SMS,
+       MMS_DEBUG_EV_COMMON,
+       MMS_DEBUG_EV_EMAIL
+
+} MmsDebugEvType;
+
+bool MmsDebugPrintCurrentEventHandler(char *pszFunc, MmsDebugEvType evType);
+
+#endif //MMS_PLUGIN_DEBUG_H
+
diff --git a/plugin/mms_plugin/include/MmsPluginDrm.h b/plugin/mms_plugin/include/MmsPluginDrm.h
new file mode 100755 (executable)
index 0000000..0cb66d1
--- /dev/null
@@ -0,0 +1,39 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgMmsTypes.h"
+#include "MmsPluginMessage.h"
+
+#ifdef __SUPPORT_DRM__
+
+#define        MMS_DECODE_DRM_CONVERTED_TEMP_FILE MSG_DATA_PATH"Mms_Decode_Drm_Converted"
+#define        MMS_MIMETYPELENGTH 50
+
+typedef        enum {
+       MMS_DRM2_CONVERT_NONE,
+       MMS_DRM2_CONVERT_NOT_FIXED,
+       MMS_DRM2_CONVERT_REQUIRED,
+       MMS_DRM2_CONVERT_FINISH
+} MmsDrm2ConvertState;
+
+MsgDrmType MsgGetDRMType(MsgType *pMsgType, MsgBody *pMsgBody);
+void MmsDrm2SetConvertState(MmsDrm2ConvertState newConvertState);
+MmsDrm2ConvertState MmsDrm2GetConvertState(void);
+bool MsgDRM2GetDRMInfo(char *szFilePath, MsgType *pMsgType);
+bool MsgDRMIsForwardLockType(MsgDrmType drmType);
+bool MsgChangeDrm2FileName(char *szFileName);
+bool MsgIsDCFFile(char *szFilePath);
+#endif
diff --git a/plugin/mms_plugin/include/MmsPluginEventHandler.h b/plugin/mms_plugin/include/MmsPluginEventHandler.h
new file mode 100755 (executable)
index 0000000..2b9bf8b
--- /dev/null
@@ -0,0 +1,51 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMS_PLUGIN_EVENT_HANDLER_H
+#define MMS_PLUGIN_EVENT_HANDLER_H
+
+
+/*==================================================================================================
+                                                       INCLUDE FILES
+==================================================================================================*/
+#include "MsgPluginInterface.h"
+#include "MmsPluginTypes.h"
+#include "MmsPluginMessage.h"
+
+/*==================================================================================================
+                                                       CLASS DEFINITIONS
+==================================================================================================*/
+class MmsPluginEventHandler
+{
+public:
+       static MmsPluginEventHandler *instance();
+
+       void registerListener(MSG_PLUGIN_LISTENER_S *pListener);
+       void handleSentStatus(int TapiReqId, MSG_NETWORK_STATUS_T NetStatus);
+       void handleMmsReceivedData(mmsTranQEntity *pRequest, char *pRetrivedFilePath);
+       void handleMmsError(mmsTranQEntity *pRequest);
+
+private:
+       MmsPluginEventHandler();
+       virtual ~MmsPluginEventHandler();
+
+       static MmsPluginEventHandler *pInstance;
+
+       MSG_PLUGIN_LISTENER_S listener;
+};
+
+#endif //MMS_PLUGIN_EVENT_HANDLER_H
+
diff --git a/plugin/mms_plugin/include/MmsPluginHttp.h b/plugin/mms_plugin/include/MmsPluginHttp.h
new file mode 100755 (executable)
index 0000000..bee0dc5
--- /dev/null
@@ -0,0 +1,98 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMSPLUGINHTTP_H
+#define MMSPLUGINHTTP_H
+
+#include <map>
+
+#include "MsgDebug.h"
+#include "MmsPluginTypes.h"
+#include "MsgMutex.h"
+
+#include <curl/curl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+class MmsPluginHttpAgent
+{
+       public:
+               static MmsPluginHttpAgent *instance();
+
+
+               void setHttpWaitingFlag(bool val);
+               bool getHttpWaitingFlag();
+
+               int cmdRequest(MMS_HTTP_CMD_TYPE_T cmdType);
+
+               int setSession(mmsTranQEntity *qEntity);
+               void clearSession();
+
+               void SetMMSProfile();
+
+               MMS_PLUGIN_HTTP_DATA_S *getHttpConfigData();
+               MMS_PLUGIN_HTTP_CONTEXT_S *getMmsPldCd();
+
+               MMS_PLUGIN_HTTP_DATA_S httpConfigData;
+
+       private:
+               static MmsPluginHttpAgent *pInstance;
+
+
+               MmsPluginHttpAgent();
+               ~MmsPluginHttpAgent();
+
+               bool waiting;
+
+               MMS_PLUGIN_HTTP_CONTEXT_S mmsPlgCd;
+
+               std::map<MMS_HTTP_CMD_TYPE_T,int(*)(MMS_PLUGIN_HTTP_DATA_S *)> httpCmdHandler;
+};
+
+
+#define MSG_MMS_HH_CONTENT_TYPE     "application/vnd.wap.mms-message"
+#define MSG_MMS_HH_ACCEPT           "application/vnd.wap.mms-message, */*"
+#define MSG_MMS_HH_CHARSET          "utf-8"
+#define MSG_MMS_HH_LANGUAGE         "zh-cn, en"
+#define MSG_MMS_HH_ENCODING         "deflate,gzip"
+
+#define MSG_MMS_HH_USER_AGENT          "Tizen", "Mozilla/5.0 (Linux; U; Tizen 1.0; en-us) AppleWebKit/534.46 (KHTML, like Gecko) Mobile Tizen Browser/1.0"
+#define MSG_MMS_WAP_PROFILE         ""
+
+typedef unsigned int MMS_HTTP_HEADER_FIELD_T;
+
+enum _MMS_HTTP_HEADER_FIELD_E {
+       MMS_HH_CONTENT_TYPE,
+       MMS_HH_HOST,
+       MMS_HH_ACCEPT,
+       MMS_HH_ACCEPT_CHARSET,
+       MMS_HH_ACCEPT_LANGUAGE,
+       MMS_HH_ACCEPT_ENCODING,
+       MMS_HH_USER_AGENT,
+       MMS_HH_WAP_PROFILE
+};
+void HttpHeaderInfo(curl_slist *responseHeaders, char *szUrl, int ulContentLen);
+bool MsgMmsGetCustomHTTPHeader(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *szHeaderBuffer);
+void MsgMmsGetHost(char *szHost, int nBufferLen);
+
+#endif
diff --git a/plugin/mms_plugin/include/MmsPluginInternal.h b/plugin/mms_plugin/include/MmsPluginInternal.h
new file mode 100755 (executable)
index 0000000..a22cf27
--- /dev/null
@@ -0,0 +1,58 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMS_PLUGIN_INTERNAL_H
+#define MMS_PLUGIN_INTERNAL_H
+
+/*==================================================================================================
+                                                       INCLUDE FILES
+==================================================================================================*/
+#include "MsgStorageTypes.h"
+#include "MsgTypes.h"
+#include "MsgTransportTypes.h"
+#include "MmsPluginMessage.h"
+#include "MmsPluginTypes.h"
+
+/*==================================================================================================
+                                                       CLASS DEFINITIONS
+==================================================================================================*/
+class MmsPluginInternal
+{
+       public:
+               static MmsPluginInternal *instance();
+
+               void processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject);
+               void processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest);
+               void processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest, char *pRetrivedFilePath);
+               void processForwardConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest);
+               bool encodeNotifyRespInd(char *szTrID, MSG_DELIVERY_REPORT_STATUS_T iStatus, bool bReportAllowed, char *pSendFilePath);
+               bool encodeAckInd(char *szTrID, bool bReportAllowed, char *pSendFilePath);
+
+       private:
+               static MmsPluginInternal *pInstance;
+
+               MmsPluginInternal();
+               ~MmsPluginInternal();
+
+               bool processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest);
+               void processDeliveryInd(MSG_MESSAGE_INFO_S *pMsgInfo);
+               void processReadOrgInd(MSG_MESSAGE_INFO_S *pMsgInfo);
+               bool checkRejectNotiInd(int roamState, bool bReportAllowed, char *pSendFilePath);
+               bool getMmsReport(MmsReport mmsReport);
+               const char *getMmsDeliveryStatus(MSG_DELIVERY_REPORT_STATUS_T deliveryStatus);
+               const char *getMmsReadStatus(MSG_READ_REPORT_STATUS_T readStatus);
+};
+#endif
diff --git a/plugin/mms_plugin/include/MmsPluginMIME.h b/plugin/mms_plugin/include/MmsPluginMIME.h
new file mode 100755 (executable)
index 0000000..8e9a652
--- /dev/null
@@ -0,0 +1,284 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef _UTY_MIME_H_
+#define _UTY_MIME_H_
+
+#include "MsgMmsTypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define                MSG_CH_CR                                               '\r'
+#define                MSG_CH_LF                                               '\n'
+#define                MSG_CH_SP                                               ' '
+#define                MSG_CH_TAB                                              '\t'
+#define                MSG_CH_NULL                                             '\0'
+#define                MSG_CH_COLON                                    ':'
+#define                MSG_CH_SEMICOLON                                ';'
+#define                MSG_CH_UNDERLINE                                '_'
+#define                MSG_CH_COMMA                                    ','
+#define                MSG_CH_BASE64_LOWER                             'b'
+#define                MSG_CH_BASE64_UPPER                             'B'
+#define                MSG_CH_QPRINT_LOWER                             'Q'
+#define                MSG_CH_QPRINT_UPPER                             'q'
+
+#define                MSG_CH_QUESTION                                 '?'
+#define                MSG_CH_QUOT                                             '"'
+#define                MSG_CH_EQUAL                                    '='
+#define                MSG_CH_BRACKET_S                                '<'
+#define                MSG_CH_BRACKET_E                                '>'
+
+#define                MSG_STR_DEC_START                       "=?"
+#define                MSG_STR_DEC_END                         "?="
+#define                MSG_STR_CRLF                            "\r\n"
+#define                MSG_END_OF_HEADER                       "\r\n\r\n"
+#define                MSG_STR_DOUBLE_HYPEN            "--"
+#define                MSG_STR_BOUNDARY_DEL            "\r\n--"
+
+#define                MSG_MMS_STR_ADDR_DELIMETER      MSG_STR_ADDR_DELIMETER
+#define                MSG_MMS_CH_ADDR_DELIMETER       MSG_CH_ADDR_DELIMETER
+#define                MSG_MMS_CH_EMAIL_AT                     '@'
+
+
+/* character-set parameter value of content-type header field */
+enum {
+       MSG_CHARSET_US_ASCII,                   //0
+       MSG_CHARSET_UTF16,
+       MSG_CHARSET_USC2,
+       MSG_CHARSET_UTF8,
+       /* MIME character-set value */
+
+       MSG_CHARSET_ISO_2022_KR,
+       MSG_CHARSET_KS_C_5601_1987,
+       MSG_CHARSET_EUC_KR,     // KS_C5861-1992
+       MSG_CHARSET_ISO_2022_JP,
+       MSG_CHARSET_ISO_2022_JP_2,
+       MSG_CHARSET_ISO_8859_1,                 //Latin1
+       MSG_CHARSET_ISO_8859_2,
+       MSG_CHARSET_ISO_8859_3,
+       MSG_CHARSET_ISO_8859_4,
+       MSG_CHARSET_ISO_8859_5,
+       MSG_CHARSET_ISO_8859_6,
+       MSG_CHARSET_ISO_8859_6_E,
+       MSG_CHARSET_ISO_8859_6_I,
+       MSG_CHARSET_ISO_8859_7,
+       MSG_CHARSET_ISO_8859_8,
+       MSG_CHARSET_ISO_8859_8_I,
+       MSG_CHARSET_ISO_8859_9,
+       MSG_CHARSET_ISO_8859_10,
+       MSG_CHARSET_ISO_8859_15,
+       MSG_CHARSET_Shift_JIS,
+       MSG_CHARSET_EUC_JP,
+       MSG_CHARSET_GB2312,
+       MSG_CHARSET_BIG5,
+       MSG_CHARSET_WIN1251,
+       MSG_CHARSET_WINDOW_1251,
+       MSG_CHARSET_WINDOWS_1251, // same: WIN1251, WINDOW-1251, WINDOWS-1251
+       MSG_CHARSET_KOI8_R,
+       MSG_CHARSET_KOI8_U,
+
+       MSG_CHARSET_NUM,
+       MSG_CHARSET_UNKNOWN
+};
+
+/* Content-Transfer-Encoding header field value */
+enum {
+       MSG_ENCODING_7BIT,
+       MSG_ENCODING_8BIT,
+       MSG_ENCODING_BINARY,
+       MSG_ENCODING_BASE64,
+       MSG_ENCODING_QUOTE_PRINTABLE,
+       MSG_ENCODING_NUM,
+       MSG_ENCODING_OTHER,
+};
+
+
+/* Content-Disposition header field value */
+enum {
+       MSG_DISPOSITION_FORMDATA,
+       MSG_DISPOSITION_ATTACHMENT,
+       MSG_DISPOSITION_INLINE,
+       MSG_DISPOSITION_NUM
+};
+
+#define                UNDEFINED_BINARY        0xFF
+#define                MSG_UNKNOWN_TYPE_STRING         "unknown"
+
+typedef enum _MimeMainType {
+       MIME_MAINTYPE_APPLICATION,
+       MIME_MAINTYPE_AUDIO,
+       MIME_MAINTYPE_IMAGE,
+       MIME_MAINTYPE_MESSAGE,
+       MIME_MAINTYPE_MULTIPART,
+       MIME_MAINTYPE_TEXT,
+       MIME_MAINTYPE_VIDEO,
+       MIME_MAINTYPE_THEME,
+       MIME_MAINTYPE_ETC
+} MimeMainType;
+
+typedef enum _MimeAppType {
+       MIME_APPLICATION_NONE,
+
+       MIME_APPLICATION_CAMERA,
+       MIME_APPLICATION_VIDEORECORDER,
+
+       MIME_APPLICATION_IMAGEVIEWER,
+       MIME_APPLICATION_FLASHVIEWER,
+       MIME_APPLICATION_IMAGEEDITOR,
+       MIME_APPLICATION_THEMEVIEWER,
+
+       MIME_APPLICATION_SOUNDPLAYER,
+       MIME_APPLICATION_MEDIAPLAYER,
+       MIME_APPLICATION_VOICEMEMO,
+
+       MIME_APPLICATION_PICSELVIEWER,
+
+       MIME_APPLICATION_CONTACT,
+       MIME_APPLICATION_ORGANIZER,
+
+       MIME_APPLICATION_MAX
+} MimeAppType;
+
+
+typedef struct _MimeTable {
+       const char *szMIME;
+       const char *szExt;
+       bool bDownloadable;
+       MimeType mime;                  /* index of mime type */
+       MimeType contentType;   /* representative mime type */
+       MimeAppType appType;
+       MimeMainType mainType;
+       int binary;
+} MimeTable;
+
+typedef struct _ExtTable {
+       const char *szExt;
+       MimeType mimeType;
+} ExtTable;
+
+/* MIME string table ID */
+typedef enum {
+       MSG_ENCODING,
+       MSG_DISPOSITION,
+       MSG_FIELD,
+       MSG_PARAM,
+       MSG_TYPE,
+       MSG_CHARSET,
+       MSG_ADDR_TYPE,
+} MsgHeaderField;
+
+typedef enum {
+       MSG_ADDR_TYPE_ERROR = -1,               // error return in Get method
+       MSG_ADDR_TYPE_PHONE = 0,
+       MSG_ADDR_TYPE_EMAIL = 1,
+       MSG_ADDR_TYPE_IPV4  = 2,
+       MSG_ADDR_TYPE_IPV6  = 3,
+       MSG_ADDR_TYPE_ALIAS = 4,
+       MSG_ADDR_TYPE_NUM   = 5,
+} MsgAddrType;
+
+/* MIME header field */
+enum {
+       MSG_FIELD_RETURN_PATH,
+       MSG_FIELD_MESSAGE_ID,
+       MSG_FIELD_FROM,
+       MSG_FIELD_TO,
+       MSG_FIELD_CC,
+       MSG_FIELD_SUBJECT,
+       MSG_FIELD_DATE,
+       MSG_FIELD_MIME_VERSION,
+       MSG_FIELD_CONTENT_TYPE,
+       MSG_FIELD_CONTENT_TRANSFER_ENCODING,
+       MSG_FIELD_CONTENT_DISPOSITION, //If start param is given in multipart/related, this field will be ignored
+       MSG_FIELD_CONTENT_ID,
+       MSG_FIELD_CONTENT_LOCATION,
+       MSG_FIELD_CONTENT_NAME,
+       MSG_FIELD_CONTENT_DESCRIPTION,
+       MSG_FIELD_CONTENT_VENDOR,
+       MSG_FIELD_RIGHT_ISSUER,
+
+       MSG_FIELD_RETURN_RECEIPT_TO,                    /* for Delivery confirm */
+       MSG_FIELD_DISPOSITION_NOTIFICATION_TO,  /* for Read confirm */
+
+       MSG_FILED_CONTENT_REPLACE_POS,
+       MSG_FILED_CONTENT_REPLACE_SIZE,
+       MSG_FILED_CONTENT_REPLACE_INDEX,
+#ifdef __SUPPORT_DRM__
+       MSG_FIELD_DRM_CONVERTED,
+#endif
+       MSG_FIELD_NUM,
+       MSG_FIELD_UNKNOWN,
+};
+
+/* MIME header field parameter */
+enum {
+       MSG_PARAM_CHARSET,
+       MSG_PARAM_NAME,
+       MSG_PARAM_FILENAME,
+       MSG_PARAM_TYPE,                 // only used as parameter of Content-Type: multipart/related
+       MSG_PARAM_START,                // Only if content-type is multipart/related
+       MSG_PARAM_START_INFO,   // Only if content-type is multipart/related
+       MSG_PARAM_BOUNDARY,
+       MSG_PARAM_REPORT_TYPE,  // only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
+#ifdef FEATURE_JAVA_MMS
+       MSG_PARAM_APPLICATION_ID,
+       MSG_PARAM_REPLY_TO_APPLICATION_ID,
+#endif
+       MSG_PARAM_NUM,
+       MSG_PARAM_UNKNOWN,
+};
+
+/********************          API definition           ************************/
+
+bool MimeIsDownloadableInt(MimeType mime);
+bool MimeIsDownloadableString(const char *szMime);
+char *MimeGetExtFromMimeInt(MimeType mime);
+char *MimeGetExtFromMimeString(const char *szMime);
+char *MimeGetMimeFromExtString(const char *szExt);
+MimeType MimeGetMimeFromExtInt(const char *szExt);
+MimeMainType MimeGetMainTypeInt(MimeType mime);
+MimeMainType MimeGetMainTypeString(const char *szMime);
+MimeType MimeGetMimeIntFromBi(int binCode);
+char *MimeGetMimeStringFromBi(int binCode);
+int MimeGetBinaryValueFromMimeInt(MimeType mime);
+int MimeGetBinaryValueFromMimeString(const char *szMime);
+
+// Append the functions on MimeAppType
+MimeAppType MimeGetAppTypeFromInt(MimeType mime);
+MimeAppType MimeGetAppTypeFromString(const char *szMime);
+MimeAppType MimeGetAppTypeFromExtString(const char *szExt);
+
+// Append the functions returning index and content type
+
+MimeType MimeGetContentTypeFromInt(MimeType mime);
+MimeType MimeGetContentTypeFromString(const char *szMime);
+MimeType MimeGetMimeTypeFromString(const char *szMime);
+
+MimeType MimeGetMimeIntFromMimeString(char *szMimeStr);
+char *MimeGetMimeStringFromMimeInt(int mimeType);
+
+char *MsgGetString(MsgHeaderField tableId, int code);
+char *_MsgSkipWS3(char *s);
+int    _MsgGetCode(MsgHeaderField tableId, char *pStr);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif // _UTY_MIME_H_
+
+
diff --git a/plugin/mms_plugin/include/MmsPluginMain.h b/plugin/mms_plugin/include/MmsPluginMain.h
new file mode 100755 (executable)
index 0000000..a90a347
--- /dev/null
@@ -0,0 +1,62 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMS_PLUGIN_MAIN_H
+#define MMS_PLUGIN_MAIN_H
+
+/*==================================================================================================
+                                                       INCLUDE FILES
+==================================================================================================*/
+#include "MsgTypes.h"
+#include "MsgPluginInterface.h"
+
+#ifdef __cplusplus
+
+extern "C"
+{
+#endif
+
+/*==================================================================================================
+                                                       FUNCTION PROTOTYPES
+==================================================================================================*/
+MSG_ERROR_T MmsInitialize();
+
+MSG_ERROR_T MmsFinalize();
+
+MSG_ERROR_T MmsRegisterListener(MSG_PLUGIN_LISTENER_S *pListener);
+
+MSG_ERROR_T MmsSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo, bool bReqCb);
+
+MSG_ERROR_T MmsAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData);
+
+MSG_ERROR_T MmsProcessReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject);
+
+MSG_ERROR_T MmsUpdateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData);
+
+MSG_ERROR_T MmsGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg,  MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg);
+
+MSG_ERROR_T MmsUpdateRejectStatus(MSG_MESSAGE_INFO_S *pMsgInfo);
+
+MSG_ERROR_T MmsComposeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo);
+
+MSG_ERROR_T MmsRestoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char *pRcvBody, int rcvdBodyLen, char *filePath);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //MMS_PLUGIN_MAIN_H
+
diff --git a/plugin/mms_plugin/include/MmsPluginMessage.h b/plugin/mms_plugin/include/MmsPluginMessage.h
new file mode 100755 (executable)
index 0000000..afd68e8
--- /dev/null
@@ -0,0 +1,560 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMS_PLUGIN_MESSAGE_H
+#define MMS_PLUGIN_MESSAGE_H
+
+
+/*==================================================================================================
+                                                       INCLUDE FILES
+==================================================================================================*/
+#include "MsgTypes.h"
+#include "MsgInternalTypes.h"
+#include "MsgMmsTypes.h"
+#include "MsgSettingTypes.h"
+#include "MmsPluginMIME.h"
+#include "MsgMmsTypes.h"
+
+/*==================================================================================================
+                                                       DEFINES
+==================================================================================================*/
+#define                MMS_CONTENT_ID_LEN                              100
+#define                MMS_LOCALE_RESP_TEXT_LEN                90
+#define                MMS_TEXT_LEN                                            2000
+#define                MMS_READ_REPORT_STRING_READ             "Read:"
+#define                MMS_READ_REPORT_STRING_DELETED  "Deleted:"
+
+#define                MSG_ATTACH_MAX          20
+#define                MSG_LINE_LEN                                            1024
+#define                MSG_SUBJ_LEN                                            40
+#define                MSG_DATE_LEN                                            50
+#define                MSG_BOUNDARY_LEN                                        70
+#define                MSG_LOCALE_NAME_LEN                             150
+#define                MSG_LOCALE_SUBJ_LEN                             (3 * MSG_SUBJ_LEN)
+#define                MSG_ADDR_LEN                                            MAX_ADDRESS_VAL_LEN
+#define                MSG_LOCALE_ADDR_LEN                             (3 * MAX_ADDRESS_VAL_LEN)
+#define                MSG_LOCALE_FILENAME_LEN_MAX             (3 * 255)
+#define                MSG_LOCALE_SIGN_LEN                                     (3 * MAX_SIGN_VAL_LEN)
+#define                MSG_MAILBOX_NAME_LEN            10
+
+#define                MsgContentType                                          MimeType
+#define                MsgRecipientType                                        MSG_RECIPIENT_TYPE_T
+#define                MMS_VERSION                                             0x92
+#define                MSG_STR_ADDR_DELIMETER                  ";"
+#define                MSG_CH_ADDR_DELIMETER                   ';'
+#ifdef __SUPPORT_DRM__
+#define                MSG_DRM_MAX_CMD                                 (2 * 1024)
+#endif
+
+#define                MSG_MMS_DECODE_BUFFER_MAX       (2 * 1024)
+#define                MSG_MMS_ENCODE_BUFFER_MAX       (2 * 1024)
+
+/*==================================================================================================
+                                                       TYPES
+==================================================================================================*/
+typedef unsigned int                   UINT;
+typedef unsigned long int              UINT32;
+typedef unsigned char                  UINT8;
+typedef unsigned short int             UINT16;
+typedef unsigned long                  ULONG;
+typedef unsigned char                  UCHAR;
+typedef unsigned short                 MCHAR;
+typedef unsigned short                 USHORT;
+
+typedef int                                            MmsMsgID;
+
+typedef        struct _MsgAddress      MsgAddress;
+typedef struct _MsgBody                MsgBody;
+typedef struct _MsgMultipart   MsgMultipart;
+typedef struct _MsgMessage     MsgMessage;
+
+typedef struct _MsgHeaderAddress       MsgHeaderAddress;
+
+/*==================================================================================================
+                                                       ENUMS
+==================================================================================================*/
+
+typedef enum {
+       MMS_DATATYPE_NONE = -1,
+       MMS_DATATYPE_READ = 0,
+       MMS_DATATYPE_SENT = 1,
+       MMS_DATATYPE_NOTIFY = 2,
+       MMS_DATATYPE_UNSENT = 3,
+       MMS_DATATYPE_DRAFT = 4,
+       MMS_DATATYPE_SENDING = 6,
+       MMS_DATATYPE_RETRIEVING = 7,
+       MMS_DATATYPE_UNRETV = 8,
+       MMS_DATATYPE_TEMPLATE = 9,
+       MMS_DATATYPE_DRM_RO_WAITING = 10        // DRM RO WAITING
+
+} MmsDataType;
+
+typedef        enum {
+       MMS_MSGTYPE_ERROR = -1, // error return in Get method
+       MMS_MSGTYPE_SEND_REQ = 0,       // default
+       MMS_MSGTYPE_SEND_CONF = 1,
+       MMS_MSGTYPE_NOTIFICATION_IND = 2,
+       MMS_MSGTYPE_NOTIFYRESP_IND = 3,
+       MMS_MSGTYPE_RETRIEVE_CONF = 4,
+       MMS_MSGTYPE_ACKNOWLEDGE_IND = 5,
+       MMS_MSGTYPE_DELIVERY_IND = 6,
+       MMS_MSGTYPE_READREC_IND = 7,
+       MMS_MSGTYPE_READORG_IND = 8,
+       MMS_MSGTYPE_FORWARD_REQ = 9,
+       MMS_MSGTYPE_FORWARD_CONF = 10,
+       MMS_MSGTYPE_READ_REPLY = 11,    // for internal use
+
+       MMS_MSGTYPE_MAX
+} MmsMsgType;
+
+typedef        enum {
+       MMS_PRIORITY_ERROR = -1,                        // error return in Get method
+       MMS_PRIORITY_LOW = 0,                   // default
+       MMS_PRIORITY_NORMAL = 1,
+       MMS_PRIORITY_HIGH = 2
+} MmsPriority;
+
+
+typedef enum {
+       MMS_SENDER_VISIBLE_ERROR = -1,  // error return in Get method
+       MMS_SENDER_SHOW = 0,
+       MMS_SENDER_HIDE = 1
+} MmsSenderVisible;
+
+
+typedef        enum {
+       MMS_REPORT_ERROR = -1,  // error return in Get method
+       MMS_REPORT_YES = 0,
+       MMS_REPORT_NO = 1
+} MmsReport;
+
+
+typedef enum {
+       MMS_REPORTALLOWED_ERROR = -1,   // error return in Get method
+       MMS_REPORTALLOWED_YES = 0,
+       MMS_REPORTALLOWED_NO = 1
+} MmsReportAllowed;
+
+
+typedef enum {
+       MMS_RECEIVE_READ_REPORT_ALLOWED,
+       MMS_RECEIVE_READ_REPORT_PROMPT,
+       MMS_RECEIVE_READ_REPORT_NOT_ALLOWED,
+} MmsRecvReadReportType ;
+
+
+typedef enum {
+       MMS_MSGSTATUS_NONE = -1,        // backward compatibility
+       MMS_MSGSTATUS_ERROR = -1,       // error return in Get method
+       MMS_MSGSTATUS_EXPIRED = 0,
+       MMS_MSGSTATUS_RETRIEVED = 1,
+       MMS_MSGSTATUS_REJECTED = 2,
+       MMS_MSGSTATUS_DEFERRED = 3,
+       MMS_MSGSTATUS_UNRECOGNISED = 4, // This value SHALL not be used in the M-Delivery.ind PDU.
+       MMS_MSGSTATUS_INDETERMINATE = 5,
+       MMS_MSGSTATUS_FORWARDED = 6,
+       MMS_MSGSTATUS_UNREACHABLE = 7
+} MmsMsgStatus;
+
+
+typedef        enum {
+       MMS_READSTATUS_NONE = -1,                       // no touch status
+       MMS_IS_READ = 0,
+       MMS_IS_DELETED = 1
+} MmsReadStatus;
+
+
+typedef enum {
+       MMS_ADDRESS_PRESENT_TOKEN,
+       MMS_INSERT_ADDRESS_TOKEN
+} MmsAddressType;
+
+typedef enum {
+       MSG_PARAM_REPORT_TYPE_DELIVERY_STATUS,
+       MSG_PARAM_REPORT_TYPE_NUM,
+       MSG_PARAM_REPORT_TYPE_UNKNOWN,
+} MsgParamReportType;
+
+/* Response status */
+typedef        enum {
+       MMS_RESPSTATUS_ERROR = -1,      // error return in Get method
+       MMS_RESPSTATUS_OK = 0,  // default value
+       MMS_RESPSTAUTS_ERROR_UNSPECIFIED = 1,
+       MMS_RESPSTAUTS_ERROR_SERVICEDENIED = 2,
+       MMS_RESPSTAUTS_ERROR_MESSAGEFORMATCORRUPT = 3,
+       MMS_RESPSTAUTS_ERROR_SENDINGADDRESSUNRESOLVED = 4,
+       MMS_RESPSTAUTS_ERROR_MESSAGENOTFOUND = 5,
+       MMS_RESPSTAUTS_ERROR_NETWORKPROBLEM = 6,
+       MMS_RESPSTAUTS_ERROR_CONTENTNOTACCEPTED = 7,
+       MMS_RESPSTAUTS_ERROR_UNSUPPORTEDMESSAGE = 8,
+
+       MMS_RESPSTAUTS_ERROR_TRANSIENT_FAILURE = 9,
+       MMS_RESPSTAUTS_ERROR_TRANSIENT_SENDING_ADDRESS_UNRESOLVED = 10,
+       MMS_RESPSTAUTS_ERROR_TRANSIENT_MESSAGE_NOT_FOUND = 11,
+       MMS_RESPSTAUTS_ERROR_TRANSIENT_NETWORK_PROBLEM = 12,
+
+       MMS_RESPSTAUTS_ERROR_PERMANENT_FAILURE = 13,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_SERVICE_DENIED = 14,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_FORMAT_CORRUPT = 15,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_SENDING_ADDRESS_UNRESOLVED = 16,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_NOT_FOUND = 17,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_CONTENT_NOT_ACCEPTED = 18,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_LIMITATIONS_NOT_MET = 19,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_REQUEST_NOT_ACCEPTED = 20,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_FORWARDING_DENIED = 21,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_NOT_SUPPORTED = 22
+} MmsResponseStatus;
+
+
+typedef        enum {
+       MMS_RETRSTATUS_ERROR = -1,      // error return in Get method
+       MMS_RETRSTATUS_OK = 0,
+       MMS_RETRSTATUS_TRANSIENT_FAILURE = 1,
+       MMS_RETRSTATUS_TRANSIENT_MESSAGE_NOT_FOUND = 2,
+       MMS_RETRSTATUS_TRANSIENT_NETWORK_PROBLEM = 3,
+       MMS_RETRSTATUS_PERMANENT_FAILURE = 4,
+       MMS_RETRSTATUS_PERMANENT_SERVICE_DENIED = 5,
+       MMS_RETRSTATUS_PERMANENT_MESSAGE_NOT_FOUND = 6,
+       MMS_RETRSTATUS_PERMANENT_CONTENT_UNSUPPORT = 7
+} MmsRetrieveStatus;
+
+
+typedef enum {
+       MMS_REPLY_NONE = -1,    // error return in Get method
+       MMS_REPLY_REQUESTED = 0,
+       MMS_REPLY_REQUESTED_TEXT_ONLY = 1,
+       MMS_REPLY_ACCEPTED = 2,
+       MMS_REPLY_ACCEPTED_TEXT_ONLY = 3
+} MmsReplyChargeType;
+
+
+typedef enum {
+       MMS_STATUS_ERROR = -1,  // error return in Get method
+       MMS_STATUS_INITIAL = 0,
+       MMS_STATUS_REQUESTING = 1,
+       MMS_STATUS_SUCCESS = 2,
+       MMS_STATUS_FAIL = 3,
+       MMS_STATUS_NUM = 4,
+} MmsDataStatus;
+
+
+typedef enum {
+       MMS_EDIT_STYLE_THIS_PAGE = 0,
+       MMS_EDIT_STYLE_ALL_PAGE,
+} MmsEditStyleMode;
+
+typedef enum {
+       MMS_SPECIAL_MSG_TYPE_NONE = 0,
+       MMS_SPECIAL_MSG_TYPE_SYSTEM_TEMPLATE,   // system template .
+       MMS_SPECIAL_MSG_TYPE_VOICE_MESSAGE,             //voice message service
+
+       MMS_SPECIAL_MSG_TYPE_VDF_POSTCARD,              //postcard service, or Generic Postcard Service
+       MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT1,             //Stickers Service
+       MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT2,             //Photo 10x15
+       MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT3,             //8 Photos
+       MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT4,             // 4 Photos
+} MmsSpecialMsgType;
+
+typedef enum {
+       MMS_MM_CLASS_TEXT,
+       MMS_MM_CLASS_IMAGE_BASIC,
+       MMS_MM_CLASS_IMAGE_RICH,
+       MMS_MM_CLASS_VIDEO_BASIC,
+       MMS_MM_CLASS_VIDEO_RICH,
+       MMS_MM_CLASS_MEGAPIXEL,
+       MMS_MM_CLASS_CONTENT_BASIC,
+       MMS_MM_CLASS_CONTENT_RICH,
+       MMS_MM_CLASS_OTHER
+} MmsUiMmClass;
+
+typedef enum {
+       MMS_MSGCLASS_ERROR = -1,        // error return in Get method
+       MMS_MSGCLASS_PERSONAL = 0,      // default
+       MMS_MSGCLASS_ADVERTISEMENT = 1,
+       MMS_MSGCLASS_INFORMATIONAL = 2,
+       MMS_MSGCLASS_AUTO = 3
+} MmsMsgClass;
+
+
+/*==================================================================================================
+                                                       Structures
+==================================================================================================*/
+
+typedef struct {
+       MmsReplyChargeType chargeType;
+       MmsTimeStruct deadLine;
+       int chargeSize;
+       char szChargeID[MMS_MSG_ID_LEN + 1];
+} MmsReplyCharge;
+
+
+typedef        struct _MmsMsgMultiStatus {
+       char szTo[MAX_ADDRESS_VAL_LEN + 1];
+       bool bDeliveryReportIsRead;
+       bool bDeliveyrReportIsLast;
+       MSG_DELIVERY_REPORT_STATUS_T msgStatus;
+       UINT32 handledTime;
+
+       bool bReadReplyIsRead;
+       bool bReadReplyIsLast;
+       MSG_READ_REPORT_STATUS_T readStatus;
+       UINT32 readTime;
+
+       struct _MmsMsgMultiStatus *pNext;
+} MmsMsgMultiStatus;
+
+typedef        struct _MMS_ATTRIB_S {
+       MsgContentType contentType;
+       MmsDataType dataType;
+       UINT32 date;
+       UINT8 version;
+
+       char szFrom[MSG_LOCALE_ADDR_LEN + 11];          //"/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6"
+       char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
+       char *szTo;
+       char *szCc;
+       char *szBcc;
+
+       MmsPriority priority;
+
+       MmsReplyCharge replyCharge;
+       bool bChargingMsgReplied;
+
+       bool bHideAddress;
+       bool bAskDeliveryReport;
+       bool bReportAllowed;
+       MmsRecvReadReportType readReportAllowedType;
+
+       bool bAskReadReply;
+       bool bRead;
+
+       MmsRecvReadReportSendStatus readReportSendStatus;
+
+       bool bReadReportSent;
+
+       bool bLeaveCopy;
+       bool bUseExpiryCustomTime;              // for expiry custom time
+       bool bUseDeliveryCustomTime;    // for expiry custom time
+       MmsEditStyleMode editStyleMode;                 //editStyle on All Page
+
+       MmsSpecialMsgType specialMsgType;                       // instead of bPostcard
+
+#ifdef __SUPPORT_DRM__
+       MsgDrmType drmType;
+       int roWaitingTimerMax;          // DRM RO WAITING
+       char *pszDrmData;                       // DRM Data to draw mailbox icon
+#endif
+
+       int msgSize;
+       MmsMsgClass msgClass;
+       MmsTimeStruct expiryTime;
+       MmsTimeStruct expiryCustomTime;         // for expiry custom time,
+       MmsTimeStruct deliveryTime;
+       MmsTimeStruct deliveryCustomTime;       // for expiry custom time
+
+       //for ReadMsg, When Sending notifyResp.ind
+       MSG_DELIVERY_REPORT_STATUS_T msgStatus;
+
+       MmsResponseStatus responseStatus;
+       MmsRetrieveStatus retrieveStatus;
+       char szResponseText[MMS_LOCALE_RESP_TEXT_LEN + 1];
+       char szRetrieveText[MMS_LOCALE_RESP_TEXT_LEN + 1];
+
+       MmsMsgMultiStatus *pMultiStatus;
+       bool bRetrieveNow;
+} MmsAttrib;
+
+
+typedef struct _MsgContentParam {
+       int charset;
+       char szBoundary[MSG_BOUNDARY_LEN + 1];
+       char szFileName[MSG_FILENAME_LEN_MAX + 1];
+       char szName[MSG_LOCALE_FILENAME_LEN_MAX + 1];
+
+#ifdef FEATURE_JAVA_MMS
+       char *szApplicationID;
+       char *szReplyToApplicationID;
+#endif
+
+       int type;
+       void *pPresentation;
+       char szStart[MSG_MSG_ID_LEN + 1];
+       char szStartInfo[MSG_MSG_ID_LEN + 1];
+
+       MsgParamReportType reportType; //only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
+} MsgContentParam;
+
+#ifdef __SUPPORT_DRM__
+typedef struct _MsgDRMInfo {
+       MsgDrmType drmType;
+       MsgContentType contentType;
+       char *szContentURI;
+       char *szContentName;
+       char *szContentDescription;
+       char *szContentVendor;
+       char *szRightIssuer;
+       char *szDrm2FullPath;
+       int roWaitingTimerMax;          // DRM RO WAITING
+       bool bFwdLock;
+       char *pszContentType;
+       bool bNoRingTone;
+       bool bNoScreen;
+} MsgDRMInfo;
+#endif
+
+typedef struct _MsgType {
+       int offset;
+       int size;
+       int contentSize;
+       int section;
+       int type;
+#ifdef __SUPPORT_DRM__
+       MsgDRMInfo drmInfo;
+#endif
+       int encoding;
+       int disposition;
+       char szContentID[MSG_MSG_ID_LEN + 1];
+       char szContentLocation[MSG_MSG_ID_LEN + 1];
+       char szOrgFilePath[MSG_FILEPATH_LEN_MAX];
+
+       char szContentRepPos[30];
+       char szContentRepSize[30];
+       char szContentRepIndex[8];
+#ifdef __SUPPORT_DRM__
+       int nDrmConvertedStatus;
+#endif
+
+       MsgContentParam param;
+} MsgType;
+
+struct _MsgAddress {
+       int type;                                       //MSG_ADDR_TYPE_PHONE/EMAIL/IPV4/IPV6
+       MsgRecipientType recipientType;                 // TO, CC, BCC
+       char szName[MSG_LOCALE_NAME_LEN + 1];
+       char szAddr[MSG_ADDR_LEN + 1];
+       MsgAddress *pNext;
+       bool bDoNotShow;                                // temporary clip
+
+       // sorting
+       ULONG uLastRecentTime;          // last recent time save item
+       ULONG uMostUseCount;                    // most use count item.
+       int index;                                      // index sorting..
+};
+
+typedef struct _MsgHeader {
+       MsgAddress *pFrom;
+       MsgAddress *pTo;
+       MsgAddress *pCC;
+       char szReturnPath[MSG_ADDR_LEN + 1];
+       char szDate[MSG_DATE_LEN];
+       char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
+       char szMsgID[MSG_MSG_ID_LEN + 1];
+} MsgHeader;
+
+
+struct _MsgBody {
+       int offset;
+       int size;
+       char szOrgFilePath[MSG_FILEPATH_LEN_MAX];
+       MsgType presentationType;
+       MsgBody *pPresentationBody;
+
+       union {
+               char *pText;
+               void *pBinary;
+               MsgMultipart *pMultipart;
+               MsgMessage *pMessage;
+       } body;
+};
+
+struct _MsgMultipart {
+       MsgType type;
+       MsgBody *pBody;
+       MsgMultipart *pNext;
+};
+
+struct _MsgMessage {
+       MsgHeader header;
+       MsgType type;
+       MsgBody *pBody;
+};
+
+
+typedef        struct _MMS_MESSAGE_S {
+       MmsAttrib mmsAttrib;
+       MSG_MESSAGE_ID_T msgID;
+       int mailbox;            // mailbox type,MMS_MAILBOX_XXX
+       char szFileName[MSG_FILENAME_LEN_MAX];
+       char szTrID[MMS_TR_ID_LEN + 1];
+       char szMsgID[MMS_MSG_ID_LEN + 1];
+       char szForwardMsgID[MMS_MSG_ID_LEN + 1];
+       char szContentLocation[MMS_LOCATION_LEN + 1];
+       int nPartCount;
+       MsgType msgType;
+       MsgBody msgBody;
+} MmsMsg;
+
+struct _MsgHeaderAddress {
+       char *szAddr;
+       MsgHeaderAddress *pNext;
+};
+
+
+bool MmsInitMsgType(MsgType *pMsgType);
+bool MmsInitMsgBody(MsgBody *pMsgBody);
+bool MmsInitMsgContentParam(MsgContentParam *pMsgContentParam);
+bool MmsInitMsgAttrib(MmsAttrib *pAttrib);
+bool MmsSetMsgAddressList(MmsAttrib *pAttrib, const MSG_MESSAGE_INFO_S *pMsgInfo);
+char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType);
+bool MmsGetMsgBodyfromMsgInfo(const MSG_MESSAGE_INFO_S *pMsgInfo, MMS_MESSAGE_DATA_S *pMsgBody, char *pFileData);
+bool MmsGetSmilRawData(MMS_MESSAGE_DATA_S *pMsgBody, char *pRawData, int *nSize);
+bool MmsInsertPresentation(MmsMsg *pMsg, MsgContentType mimeType, char *pData, int size);
+bool MmsInsertPartFromFile(MmsMsg *pMsg, char *szTitleName, char *szOrgFilePath, char *szContentID);
+bool MmsIsMultipart(int type);
+bool MmsGetTypeByFileName(int *type, char *szFileName);
+MsgMultipart *MmsMakeMultipart(MsgContentType mimeType, char *szTitleName, char *szOrgFilePath, void *pData, int offset, int size, char *szContentID);
+bool MmsIsText(int type);
+bool MmsIsVitemContent(int type, char *pszName);
+bool MmsComposeMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMsgData, char *pFileData);
+void MmsComposeNotiMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_ID_T msgID);
+bool MmsGetMmsMessageBody(MmsMsg *pMmsMsg, char *retrievedFilePath);
+bool MmsComposeForwardHeader(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo);
+bool MmsComposeForwardMessage(MmsMsg *pMmsMsg, char *retrievedFilePath);
+#ifdef MMS_DELIEVERY_IND_ENABLED
+MmsMsgMultiStatus *MmsComposeDeliveryIndMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_ID_T msgId);
+#endif
+void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, MSG_MESSAGE_ID_T selectedMsgId);
+MmsMsgMultiStatus *MmsGetMultiStatus(MSG_MESSAGE_ID_T msgId);
+int MmsSearchMsgId(char *toNumber, char *szMsgID);
+void MmsUpdateDeliveryReport(MSG_MESSAGE_ID_T msgId, MmsMsgMultiStatus *pStatus);
+void MmsUpdateReadReport(MSG_MESSAGE_ID_T msgId, MmsMsgMultiStatus *pStatus);
+MsgMultipart *MmsAllocMultipart(void);
+bool _MsgIsASCII(char *pszText);
+bool _MsgReplaceNonAscii(char *szInText, char **szOutText, char replaceChar);
+bool _MsgIsSpace(char *pszText);
+bool _MsgReplaceSpecialChar(char *szInText, char **szOutText, char specialChar);
+char *MsgStrAppend(char *szInputStr1, char *szInputStr2);
+char *MsgStrCopy(const char *string);
+char *MsgStrNCopy(const char *string, int length);
+int    MsgStrlen(char *pStr);
+bool _MsgConvertCharToHex(char pSrc, char *pDest);
+MSG_ERROR_T MmsAddAttachment(MMS_MESSAGE_DATA_S *pMsgData, MMS_MEDIA_S *pMedia);
+bool MmsCheckAdditionalMedia(MMS_MESSAGE_DATA_S *pMsgData, MsgType *partHeader);
+#ifdef __SUPPORT_DRM__
+bool __MsgInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo);
+#endif
+
+#endif
diff --git a/plugin/mms_plugin/include/MmsPluginSMILValidate.h b/plugin/mms_plugin/include/MmsPluginSMILValidate.h
new file mode 100755 (executable)
index 0000000..00b7df5
--- /dev/null
@@ -0,0 +1,177 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMS_PLUGIN_SMIL_VALIDATE_H
+#define MMS_PLUGIN_SMIL_VALIDATE_H
+
+
+/*==================================================================================================
+ *                                     HEADER
+ *==================================================================================================*/
+#include "MsgTypes.h"
+#include "MsgMmsTypes.h"
+#include "MmsPluginMessage.h"
+
+/*==================================================================================================
+ *                                     DEFINE
+ *==================================================================================================*/
+/**
+ *     @brief  Represents the default values of SMIL root layout. \n
+ */
+#define MSG_SMIL_ROOT_LAYOUT_WIDTH     (100)
+#define MSG_SMIL_ROOT_LAYOUT_HEIGHT    (100)
+#define MSG_SMIL_ROOT_LAYOUT_IN_PERCENT        (true)
+#define MSG_SMIL_ROOT_LAYOUT_BG_COLOR  "#FFFFFF"
+
+/**
+ *     @brief  Represents the default values of SMIL Region \n
+ */
+#define MSG_SMIL_DEFAULT_TXT_REG       "text"
+#define MSG_SMIL_DEFAULT_IMG_REG       "image"
+#define MSG_SMIL_DEFAULT_FULL_REG      "full"
+#define MSG_SMIL_REG_FIT_TYPE          "meet"
+#define MSG_SMIL_REG_BG_COLOR          "#FFFFFF"
+
+#define MSG_SMIL_FULL_REG_LEFT                         (0)
+#define MSG_SMIL_FULL_REG_TOP                          (0)
+#define MSG_SMIL_FULL_REG_WIDTH                                (100)
+#define MSG_SMIL_FULL_REG_HEIGHT                       (100)
+
+#define MSG_SMIL_FIRST_REG_LEFT                                (0)
+#define MSG_SMIL_FIRST_REG_TOP                         (0)
+#define MSG_SMIL_FIRST_REG_WIDTH                       (100)
+#define MSG_SMIL_FIRST_REG_HEIGHT                      (50)
+
+#define MSG_SMIL_SECOND_REG_LEFT                       (0)
+#define MSG_SMIL_SECOND_REG_TOP                                (50)
+#define MSG_SMIL_SECOND_REG_WIDTH                      (100)
+#define MSG_SMIL_SECOND_REG_HEIGHT                     (50)
+
+/**
+ *     @brief  Represents the default values of SMIL Media \n
+ */
+#define MSG_SMIL_REG_POSITION_IS_DEFAULT       (true)
+#define MSG_SMIL_TEXT_ON_TOP                           (true)
+
+
+/*==================================================================================================
+ *                                     ENUMS
+ *==================================================================================================*/
+
+/**
+ *     @brief  Represents the values of an smil error code. \n
+ *     Success code is zero, but all error codes SHOULD be negative and smaller than MSG_SMIL_ERR_BEGIN. \n
+ */
+enum MSG_SMIL_ERR_E {
+       MSG_SMIL_SUCCESS = 0,
+       MSG_SMIL_ERR_UNKNOWN = -255,
+       MSG_SMIL_ERR_INVALID_ROOTLAYOUT,
+       MSG_SMIL_ERR_INVALID_REGION_INFO,
+       MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS,
+       MSG_SMIL_ERR_INVALID_SMIL_FILE_PATH,
+       MSG_SMIL_ERR_INVALID_PAGE_INFO,
+       MSG_SMIL_ERR_INVALID_PAGE_DUR,
+       MSG_SMIL_ERR_INVALID_PARAM,
+};
+
+/*==================================================================================================
+ *                                     FUNCTIONS
+ *==================================================================================================*/
+
+/**    @fn             MSG_SMIL_ERR_E MsgMMSCreateSMIL(MMS_MESSAGE_DATA_S *pMsgData)
+ *     @brief  Creates a SMIL buffer based on the Message handle.
+ *     @param  pMsgData is Message handle. \n
+ *     @param  pError is a pointer to a SMIL error type. \n
+ *     @return MSG_SMIL_ERR_E \n
+ *     @retval MSG_SMIL_SUCCESS                Success in operation. \n
+ *     @retval MSG_SMIL_ERR_UNKNOWN                            Encoding failed \n
+ *     @retval MSG_SMIL_ERR_INVALID_ROOTLAYOUT         Invalid Root Layout \n
+  *    @retval MSG_SMIL_ERR_INVALID_REGION_INFO        Invalid Region \n
+ *     @retval MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS       Duplicate media \n
+ *     @retval MSG_SMIL_ERR_INVALID_SMIL_FILE_PATH     Invalid Smil Path \n
+ *     @retval MSG_SMIL_ERR_INVALID_PAGE_INFO          Invalid Page Info \n
+ *     @retval MSG_SMIL_ERR_INVALID_PAGE_DUR           Invalid Page Duration \n
+ *     @retval MSG_SMIL_ERR_INVALID_PARAM                      Invalid Parameter \n
+ */
+MSG_SMIL_ERR_E MsgMMSCreateSMIL(MMS_MESSAGE_DATA_S *pMsgData);
+
+/**    @fn             MSG_SMIL_ERR_E _MsgMMSValidateSMILRootLayout(MMS_MESSAGE_DATA_S *pMsgData)
+ *     @brief  Validates the Root layout information present in the Message handle.
+ *     @param  pMsgData is Message handle. \n
+ *     @return MSG_SMIL_ERR_E \n
+ *     @retval MSG_SMIL_SUCCESS                                                Success in operation. \n
+ *     @retval MSG_SMIL_ERR_INVALID_ROOTLAYOUT                 Failure in operation. \n
+ */
+MSG_SMIL_ERR_E _MsgMMSValidateSMILRootLayout(MMS_MESSAGE_DATA_S *pMsgData);
+
+/**    @fn             MSG_SMIL_ERR_E _MsgMMSAddDefaultSMILRegions(MMS_MESSAGE_DATA_S *pMsgData)
+ *     @brief  Adds the default Region information based on the Message handle.
+ *     @param  pMsgData is Message handle. \n
+ *     @return MSG_SMIL_ERR_E \n
+ *     @retval MSG_SMIL_SUCCESS                                                Success in operation. \n
+ *     @retval MSG_SMIL_ERR_INVALID_ROOTLAYOUT                 Failure in operation. \n
+ */
+MSG_SMIL_ERR_E _MsgMMSAddDefaultSMILRootLayout(MMS_MESSAGE_DATA_S *pMsgData);
+
+/**    @fn             MSG_SMIL_ERR_E _MsgMMSValidateSMILRegion(MMS_MESSAGE_DATA_S *pMsgData, bool *pbRegAdded)
+ *     @brief  Validates the Region information present in the Message handle.
+ *     @param  pMsgData is Message handle. \n
+ *     @return MSG_SMIL_ERR_E \n
+ *     @retval MSG_SMIL_SUCCESS                                                Success in operation. \n
+ *     @retval MSG_SMIL_ERR_INVALID_REGION_INFO                Failure in operation. \n
+ *     @retval MSG_SMIL_ERR_INVALID_PAGE_INFO                  Failure in operation. \n
+ */
+MSG_SMIL_ERR_E _MsgMMSValidateSMILRegion(MMS_MESSAGE_DATA_S *pMsgData, bool *pbRegAdded);
+
+/**    @fn             MSG_SMIL_ERR_E _MsgMMSAddDefaultFirstSMILRegion(MMS_MESSAGE_DATA_S *pMsgData, bool bTextReg)
+ *     @brief  Adds the default first Region information when two regions are present in a page based on the Message handle.
+ *     @param  pMsgData is Message handle. \n
+ *     @return MSG_SMIL_ERR_E \n
+ *     @retval MSG_SMIL_SUCCESS                                                Success in operation. \n
+ *     @retval MSG_SMIL_ERR_INVALID_REGION_INFO                Failure in operation. \n
+ */
+MSG_SMIL_ERR_E _MsgMMSAddDefaultFirstSMILRegion(MMS_MESSAGE_DATA_S *pMsgData, bool bTextReg);
+
+/**    @fn             MSG_SMIL_ERR_E _MsgMMSAddDefaultSecondSMILRegion(MMS_MESSAGE_DATA_S *pMsgData, bool bTextReg)
+ *     @brief  Adds the default second Region information when two regions are present in a page based on the Message handle.
+ *     @param  pMsgData is Message handle. \n
+ *     @return MSG_SMIL_ERR_E \n
+ *     @retval MSG_SMIL_SUCCESS                                                Success in operation. \n
+ *     @retval MSG_SMIL_ERR_INVALID_REGION_INFO                Failure in operation. \n
+ */
+MSG_SMIL_ERR_E _MsgMMSAddDefaultSecondSMILRegion(MMS_MESSAGE_DATA_S *pMsgData, bool bTextReg);
+
+/**    @fn             MSG_SMIL_ERR_E _MsgMMSAddDefaultFullSMILRegion(MMS_MESSAGE_DATA_S *pMsgData)
+ *     @brief  Adds the default full Region information when only region is present in a page based on the Message handle.
+ *     @param  pMsgData is Message handle. \n
+ *     @return MSG_SMIL_ERR_E \n
+ *     @retval MSG_SMIL_SUCCESS                                                Success in operation. \n
+ *     @retval MSG_SMIL_ERR_INVALID_REGION_INFO                Failure in operation. \n
+ */
+MSG_SMIL_ERR_E _MsgMMSAddDefaultFullSMILRegion(MMS_MESSAGE_DATA_S *pMsgData);
+
+/**    @fn             MSG_SMIL_ERR_E _MsgMMSValidateSMILPage(MMS_MESSAGE_DATA_S *pMsgData, bool bRegAdded)
+ *     @brief  Validates the Page information present in the Message handle.
+ *     @param  pMsgData is Message handle. \n
+ *     @return MSG_SMIL_ERR_E \n
+ *     @retval MSG_SMIL_SUCCESS                                                Success in operation. \n
+ *     @retval MSG_SMIL_ERR_INVALID_PAGE_INFO                  Failure in operation. \n
+ *     @retval MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS               Same Kind of Media Exists in SMIL page. \n
+ *     @retval MSG_SMIL_ERR_INVALID_REGION_INFO                Failure in operation. \n
+ */
+MSG_SMIL_ERR_E _MsgMMSValidateSMILPage(MMS_MESSAGE_DATA_S *pMsgData, bool bRegAdded);
+
+#endif // MMS_PLUGIN_SMIL_ENCODE_H
diff --git a/plugin/mms_plugin/include/MmsPluginSetup.h b/plugin/mms_plugin/include/MmsPluginSetup.h
new file mode 100755 (executable)
index 0000000..da97405
--- /dev/null
@@ -0,0 +1,150 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MmsPluginMessage.h"
+
+#define MSG_STDSTR_SHORT                       0x7F
+
+/*
+ * structures for setup
+ */
+
+typedef enum {
+       MMS_RECEIVE_AUTO,
+       MMS_RECEIVE_MANUAL,
+       MMS_RECEIVE_RESTRICT,
+       MMS_RECEIVE_REJECT,
+       MMS_RECEIVE_CNT,
+} MmsRecvType;
+
+typedef enum {
+       MMS_RESTRICTED_MODE,
+       MMS_WARNING_MODE,
+       MMS_FREE_MODE
+} MmsUiMsgCreationMode;
+
+typedef        enum {
+       MMS_OPCO_DEFAULT        = 0,
+       MMS_OPCO_FRANCE         = 1,
+       MMS_OPCO_GERMAN         = 2,
+       MMS_OPCO_GREECE         = 3,
+       MMS_OPCO_IRELANDS       = 4,
+       MMS_OPCO_ITALY          = 5,
+       MMS_OPCO_NETHERLANDS = 6,
+       MMS_OPCO_PORTUGAL       = 7,
+       MMS_OPCO_SPAIN          = 8,
+       MMS_OPCO_SWEDEN         = 9,
+       MMS_OPCO_SWISS          = 10,
+       MMS_OPCO_UK                     = 11,
+       MMS_OPCO_AUSTRIA        = 12,
+       MMS_OPCO_BELGIUM        = 13,
+       MMS_OPCO_HUNGARY        = 14,
+       MMS_OPCO_NUM
+} MmsOpCo;
+
+typedef        struct {
+       bool bHideAddress;
+       bool bAskDeliveyReport;
+       bool bAskReadReply;
+       MmsPriority priority;
+       char szFrom[MSG_LOCALE_ADDR_LEN + 10];
+       MmsMsgClass msgClass;
+       MmsTimeStruct expiryTime;
+       MmsTimeStruct deliveryTime;
+       bool bLeaveCopy;
+       bool bAttachVcard;
+       bool bAttachSign;
+       bool bExpiryUseCustomTime;
+
+       bool bDeliveryUseCustomTime;
+
+       MmsTimeStruct expiryCustomTime;
+       MmsTimeStruct deliveryCustomTime;
+
+       char szSign[MSG_LOCALE_SIGN_LEN + 1];
+
+       //MMS_V1_1
+       MmsReplyCharge replyCharge;
+
+       int creationMode; // Creation Mode
+} MmsSendSetup;
+
+typedef struct {
+       bool bSendDeliveryReport;
+       bool bSendReadReply;
+       bool bAnonymousReject;
+       bool bRejectAdvertisement;
+       MmsRecvType recvHomeNetwork;
+       MmsRecvType recvRoamingNetwork;
+} MmsRecvSetup;
+
+typedef        struct {
+       bool bUserSettingMsgMaxSize;
+       int msgMmsMaxSize;
+} MmsMsgSizeSetup;
+
+
+typedef struct {
+       MmsUiMsgCreationMode creationMode;
+} MmsCreationModeSetup;
+
+
+typedef struct {
+       bool bCustomTime;
+       int slideIntervalTime;
+       int customTime;
+} MmsSlideSetup;
+
+typedef struct {
+       int     postcardName;
+       int     postcardAdditionalInfo;
+       int     postcardStreet;
+       int     postcardZip;
+       int     postcardCity;
+       int     postcardStateNProvince;
+       int     postcardCountry;
+} MmsPostcardSetup;
+
+typedef struct {
+       MmsSendSetup sendSetup;
+       MmsRecvSetup recvSetup;
+       MmsMsgSizeSetup msgSizeSetup;
+       MmsPostcardSetup postcardSetup[5];                                                                      // ref) POSTCARD_EDIT_TYPE_EXTENDED4
+
+       MmsCreationModeSetup creationModeSetup;
+
+       int autoResizeSize;
+
+       /* UI not-visible fields ------------------------------------ */
+
+       MmsOpCo nOpCo;
+       int maxSendSize;
+       char szPostcardOffice[MSG_STDSTR_SHORT + 1];                            // Only Privosioning can change this field
+       char szPostcardOfficeExtend01[MSG_STDSTR_SHORT + 1];
+       char szPostcardOfficeExtend02[MSG_STDSTR_SHORT + 1];
+       char szPostcardOfficeExtend03[MSG_STDSTR_SHORT + 1];
+       char szPostcardOfficeExtend04[MSG_STDSTR_SHORT + 1];
+       bool bPostcardAvailable;                                                                        // Only Privosioning can change this field
+       char szMmlUrl[MSG_STDSTR_SHORT + 1];                                    //MML Home Url
+       char szMmlPhoneNumber[MSG_STDSTR_SHORT + 1];                    //MML Upload phonenumber
+
+       char szMmsTmplDownloadURL[MSG_STDSTR_SHORT + 1];        //  for MMS More Templates
+
+} MmsSetup;
+
+/* global Setting */
+extern MmsSetup gMmsSetup;
+
diff --git a/plugin/mms_plugin/include/MmsPluginSmil.h b/plugin/mms_plugin/include/MmsPluginSmil.h
new file mode 100755 (executable)
index 0000000..9bb5162
--- /dev/null
@@ -0,0 +1,276 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include "MsgTypes.h"
+#include "MsgMmsTypes.h"
+#include "MmsPluginCodec.h"
+
+#ifndef MMS_PLUGIN_SMIL_H
+#define MMS_PLUGIN_SMIL_H
+
+typedef enum _SMIL_ELEMENT_T {
+       ELEMENT_SMIL,
+       ELEMENT_HEAD,
+       ELEMENT_LAYOUT,
+       ELEMENT_ROOTLAYOUT,
+       ELEMENT_REGION,
+       ELEMENT_TRANSITION,
+       ELEMENT_META,
+       ELEMENT_BODY,
+       ELEMENT_PAR,
+       ELEMENT_PARAM,
+       ELEMENT_TEXT,
+       ELEMENT_IMG,
+       ELEMENT_AUDIO,
+       ELEMENT_VIDEO,
+       ELEMENT_REF,
+       ELEMENT_ANIMATE,
+       ELEMENT_MAX,
+} SMIL_ELEMENT_T;
+
+typedef        int     HMmsSmil;                       // SmilDoc Handle
+
+#define MMS_SMIL_MAX_DOC       1
+#define MMS_SMIL_COLOR_SIZE    10
+#define INVALID_HOBJ   -1
+#define SP_NO_COLOR_SET        -1
+#define SP_BLACK       0
+
+/* Structures */
+/**
+ *     @brief  Represents Smil Doc Information. \n
+ */
+typedef struct _MmsSmilDoc {
+       xmlDocPtr pSmilDoc;
+       xmlNodePtr pstRootNode;
+} MmsSmilDoc;
+
+typedef enum _SMIL_ATTRIBUTE_T {
+       ATTRIBUTE_UNKNOWN = -1,
+       ATTRIBUTE_ID,
+       ATTRIBUTE_TOP,
+       ATTRIBUTE_LEFT,
+       ATTRIBUTE_WIDTH,
+       ATTRIBUTE_HEIGHT,
+       ATTRIBUTE_FIT,
+       ATTRIBUTE_BGCOLOR,
+       ATTRIBUTE_DUR,
+       ATTRIBUTE_SRC,
+       ATTRIBUTE_COLOR,
+       ATTRIBUTE_BOLD,
+       ATTRIBUTE_UNDERLINE,
+       ATTRIBUTE_ITALIC,
+       ATTRIBUTE_REVERSE,
+       ATTRIBUTE_DIRECTION,
+       ATTRIBUTE_SIZE,
+       ATTRIBUTE_FONT,
+       ATTRIBUTE_REGION,
+       ATTRIBUTE_NAME,
+       ATTRIBUTE_VALUE,
+       ATTRIBUTE_ALT,
+       ATTRIBUTE_TYPE,
+       ATTRIBUTE_SUBTYPE,
+       ATTRIBUTE_CONTENT,
+       ATTRIBUTE_FGCOLOR,
+       ATTRIBUTE_TEXTFORMAT,
+       ATTRIBUTE_TRANSIN,
+       ATTRIBUTE_TRANSOUT,
+       ATTRIBUTE_BEGIN,
+       ATTRIBUTE_END,
+       ATTRIBUTE_REPEAT_COUNT,
+#ifdef MMS_SMIL_ANIMATE
+       ATTRIBUTE_ATTRIBUTE_NAME,
+       ATTRIBUTE_ATTRIBUTE_TYPE,
+       ATTRIBUTE_TARGET_ELEMENT,
+       ATTRIBUTE_FROM,
+       ATTRIBUTE_TO,
+       ATTRIBUTE_BY,
+       ATTRIBUTE_VALUES,
+       ATTRIBUTE_CALCMODE,
+#endif
+} SMIL_ATTRIBUTE_T;
+
+char *MmsSmilGetPresentationData(MSG_MESSAGE_ID_T msgId);
+bool MmsSmilParseSmilDoc(MMS_MESSAGE_DATA_S *pMmsMsg, char *pSmilDoc);
+void MmsSmilGetElement(MMS_MESSAGE_DATA_S *pMmsMsg, xmlNode *a_node);
+int MmsSmilGetColorValue(xmlChar *content);
+int MmsSmilGetTime(char *pValue);
+int MmsSmilAtoIHexa(char *pInput);
+#ifndef __SUPPORT_DRM__
+int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart);
+#else
+int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart, MMS_MEDIA_S *pMedia);
+#endif
+int MmsSmilGetElementID(char *pString);
+int MmsSmilGetAttrID(char *pString);
+bool MmsSmilGetFontAttrib(char *pString);
+MmsTextDirection MmsSmilGetFontDirection(char *pString);
+int MmsSmilGetFontSizeValue(char *pString);
+MmsSmilFontType MmsSmilGetFontTypeValue(char *pString);
+bool MmsSmilGetMediaFilePath(MMS_MEDIA_S *pMedia, char *pszTemp, int msgID);
+bool __MmsGetRealFileName(MmsSmilMediaType mediaType, char *pszSrc, char *pszName, int msgID);
+/**    @fn             bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
+ *     @brief  Forms Smil Buffer using pstMsgBody. \n
+ *     @param[in/out]  pstMsgBody is Message handle. \n
+ *     @retval TRUE                            In case of Success. \n
+ *     @retval FALSE                           In case of failure. \n
+ */
+bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody);
+
+/**    @fn             HMmsSmil MmsSmilCreateEmptySmilDoc(void)
+ *     @brief  Creates default Smil Doc based on input gszEmptyRawDoc. \n
+ *     @retval Returns Smil Document number. \n
+ */
+HMmsSmil MmsSmilCreateEmptySmilDoc(void);
+
+ /**   @fn                     HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
+ *     @brief          Creates Smil Doc based on input pszRawData. \n
+ *     @param[in]      pszRawData is smil buffer. \n
+ *     @retval         Returns Smil Document number. \n
+ */
+HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData);
+
+ /**   @fn                     BOOL MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
+ *     @brief          Destroys Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @retval TRUE                            In case of Success. \n
+ *     @retval FALSE                           In case of failure. \n
+ */
+bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc);
+
+/**    @fn                     static bool IsValidSmilDocNo(int nSmilDocNo)
+ *     @brief          Form Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @retval         Returns Smil Buffer     In case of success. \n
+ *     @retval         Returns NULL                    In case of failure. \n
+ */
+bool IsValidSmilDocNo(int nSmilDocNo);
+
+/**    @fn                     static char * MmsSmilGetRawData( HMmsSmil hSmilDoc )
+ *     @brief          Form Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @retval         Returns Smil Buffer             In case of success. \n
+ *     @retval         Returns NULL                    In case of failure. \n
+ */
+char *MmsSmilGetRawData(HMmsSmil hSmilDoc);
+
+/**    @fn                     static bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
+ *     @brief          Add Page to Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @param[in]      pstSmilPage specifies page information. \n
+ *     @retval         TRUE                            In case of Success. \n
+ *     @retval         FALSE                           In case of failure. \n
+ */
+bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage);
+
+/**    @fn                     static bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
+ *     @brief          Add Rootlayout to Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @param[in]      pstSmilRootLayout specifies RootLayout information. \n
+ *     @retval         TRUE                            In case of Success. \n
+ *     @retval         FALSE                           In case of failure. \n
+ */
+bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout);
+
+/**    @fn                     static bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
+ *     @brief          Add Region to Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @param[in]      pstSmilRegion specifies Region information. \n
+ *     @retval         TRUE                            In case of Success. \n
+ *     @retval         FALSE                           In case of failure. \n
+ */
+bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion);
+
+/**    @fn                     static bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
+ *     @brief          Add Media to Smil Doc. \n
+ *     @param[in]      hSmilDoc is smil doc number. \n
+ *     @param[in]      nPageNo specifies page number to which media belongs. \n
+ *     @param[in]      nMediaIdx specifies medi ID. \n
+ *     @param[in]      pstSmilMedia specifies Media information. \n
+ *     @param[in]      pszContentID specifies Content ID of media. \n
+ *     @retval         TRUE                            In case of Success. \n
+ *     @retval         FALSE                           In case of failure. \n
+ */
+bool MmsSmilAddMedia(HMmsSmil hSmilDoc, int nPageNo, int nMediaIdx, MMS_MEDIA_S *pstSmilMedia, char *pszContentID);
+
+/**    @fn                     static xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
+ *     @brief          Create Text Element. \n
+ *     @param[in]      pstSmilMedia specifies Media information. \n
+ *     @param[in]      pszContentID specifies Content ID of media. \n
+ *     @retval         Text Element node               In case of Success. \n
+ *     @retval         NULL                            In case of failure. \n
+ */
+xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID);
+
+/**    @fn                     static xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
+ *     @brief          Create Image/Audio/Video Element. \n
+ *     @param[in]      pstSmilMedia specifies Media information. \n
+ *     @param[in]      pszContentID specifies Content ID of media. \n
+ *     @retval         Image/Audio/Video Element node  In case of Success. \n
+ *     @retval         NULL                                                    In case of failure. \n
+ */
+xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID);
+
+/**    @fn                     static bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pNode)
+ *     @brief          Inserts first child to parent node. \n
+ *     @param[in]      pstParent specifies Parent node. \n
+ *     @param[in]      pNode specifies Child node. \n
+ *     @retval         TRUE                            In case of Success. \n
+ *     @retval         FALSE                           In case of failure. \n
+ */
+bool __MmsInsertFirstChild(xmlNode *pParent, xmlNode *pNode);
+
+/**    @fn                     static bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pNode)
+ *     @brief          Inserts node. \n
+ *     @param[in]      pstParent specifies Parent node. \n
+ *     @param[in]      pstLeftSibling specifies Left Sibling node. \n
+ *     @param[in]      pNode specifies Child node. \n
+ *     @retval         TRUE                            In case of Success. \n
+ *     @retval         FALSE                           In case of failure. \n
+ */
+bool __MmsSmilInsertNode(xmlNode *pParent, xmlNode *pLeftSibling, xmlNode *pNode);
+
+/**    @fn                     static void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
+ *     @brief          Sets Attribute. \n
+ *     @param[in]      pNode specifies node. \n
+ *     @param[in]      szField specifies attribute field. \n
+ *     @param[in]      szValue specifies value of field \n
+ */
+void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue);
+
+/**    @fn                     static char *__MmsSmilFindColorValue(int nValue)
+ *     @brief          Converts color to RGB. \n
+ *     @param[in]      nValue specifies color value. \n
+ *     @retval         RGB value. \n
+ */
+char *__MmsSmilFindColorValue(int nValue);
+
+/**    @fn                     static xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszName)
+ *     @brief          Get node based on pszValue. \n
+ *     @param[in]      pNode specifies node. \n
+ *     @param[in]      pszName specifies name field. \n
+ *     @retval         RGB value. \n
+ */
+xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszName);
+
+#endif//MMS_PLUGIN_SMIL_H
+
+
diff --git a/plugin/mms_plugin/include/MmsPluginStorage.h b/plugin/mms_plugin/include/MmsPluginStorage.h
new file mode 100755 (executable)
index 0000000..a482181
--- /dev/null
@@ -0,0 +1,83 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMS_PLUGIN_STORAGE_H
+#define MMS_PLUGIN_STORAGE_H
+
+/*==================================================================================================
+                                                       INCLUDE FILES
+==================================================================================================*/
+#include "MsgStorageTypes.h"
+#include "MsgSqliteWrapper.h"
+#include "MmsPluginMessage.h"
+
+
+/*==================================================================================================
+                                                       CLASS DEFINITIONS
+==================================================================================================*/
+class MmsPluginStorage
+{
+public:
+       static MmsPluginStorage *instance();
+
+       MmsPluginStorage();
+       ~MmsPluginStorage();
+
+       void addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData);
+       void getMmsMessage(MmsMsg **pMmsMsg);
+       void getMmsAttrib(MSG_MESSAGE_ID_T msgId, MmsMsg *pMmsMsg);
+       MSG_ERROR_T getMmsMessageId(MSG_MESSAGE_ID_T selectedMsgId, MmsMsg *pMmsMsg);
+       void composeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo);
+
+       int searchMsgId(char *toNumber, char *szMsgID);
+       int     getMmsVersion(MSG_MESSAGE_ID_T selectedMsgId);
+
+       MSG_ERROR_T     updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData);
+       MSG_ERROR_T     updateConfMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
+       MSG_ERROR_T     updateMmsAttrib(MSG_MESSAGE_ID_T msgId, MmsAttrib *attrib, MSG_SUB_TYPE_T msgSubType);
+       MSG_ERROR_T updateMmsAttachCount(MSG_MESSAGE_ID_T msgId, int count);
+       MSG_ERROR_T     updateNetStatus(MSG_MESSAGE_ID_T msgId, MSG_NETWORK_STATUS_T netStatus);
+       MSG_ERROR_T updateDeliveryReport(MSG_MESSAGE_ID_T msgId, MmsMsgMultiStatus *pStatus);
+       MSG_ERROR_T     updateReadReport(MSG_MESSAGE_ID_T msgId, MmsMsgMultiStatus *pStatus);
+       MSG_ERROR_T     setReadReportSendStatus(MSG_MESSAGE_ID_T msgId, int readReportSendStatus);
+       MSG_ERROR_T     plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg,  MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg);
+       MSG_ERROR_T     getContentLocation(MSG_MESSAGE_INFO_S *pMsgInfo);
+       MSG_ERROR_T getMmsRawFilePath(MSG_MESSAGE_ID_T msgId, char *pFilepath);
+       MSG_ERROR_T     plgGetRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg, char *filePath);
+       /* reject_msg_support */
+       MSG_ERROR_T getTrID(MSG_MESSAGE_INFO_S *pMsgInfo, char *pszTrID, int nBufferLen);
+       /* reject_msg_support */
+
+       MSG_ERROR_T updateMsgServerID(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo);
+
+       MmsMsgMultiStatus *getMultiStatus(MSG_MESSAGE_ID_T msgId);
+       MSG_ERROR_T     getMsgText(MMS_MESSAGE_DATA_S *pMmsMsg, char *pMsgText);
+       MSG_ERROR_T     makeThumbnail(MMS_MESSAGE_DATA_S *pMmsMsg, char *pThumbnailPath, char *szFileName);
+       MSG_ERROR_T addMmsNoti(MSG_MESSAGE_INFO_S *pMsgInfo);
+
+private:
+       bool checkExistedMessage(MSG_MESSAGE_ID_T msgId);
+       MSG_ERROR_T addMmsMsgToDB(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, int attachCnt = 0);
+
+       static MmsPluginStorage *pInstance;
+
+       MsgDbHandler dbHandle;
+
+       MmsMsg mmsMsg;
+};
+
+#endif //MMS_PLUGIN_STORAGE_H
+
diff --git a/plugin/mms_plugin/include/MmsPluginTransport.h b/plugin/mms_plugin/include/MmsPluginTransport.h
new file mode 100755 (executable)
index 0000000..6209991
--- /dev/null
@@ -0,0 +1,53 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMS_PLUGIN_TRANSPORT_H
+#define MMS_PLUGIN_TRANSPORT_H
+
+
+/*==================================================================================================
+                                                       INCLUDE FILES
+==================================================================================================*/
+#include <map>
+
+#include "MsgTransportTypes.h"
+#include "MmsPluginTypes.h"
+
+
+/*==================================================================================================
+                                                       CLASS DEFINITIONS
+==================================================================================================*/
+class MmsPluginTransport
+{
+       public:
+               static MmsPluginTransport *instance();
+
+               void submitRequest(const MSG_REQUEST_INFO_S *pReqInfo);
+               void cancelRequest(MSG_REQUEST_ID_T reqId);
+
+       private:
+               MmsPluginTransport();
+               ~MmsPluginTransport();
+
+               void submitProcess(mmsTranQEntity req);
+               MMS_NET_ERROR_T submitHandler(mmsTranQEntity *qEntity);
+               bool processReceivedData(int msgId, char *pRcvdBody, int rcvdBodyLen, char *retrievedFilePath);
+
+               static MmsPluginTransport *pInstance;
+};
+
+#endif //MMS_PLUGIN_TRANSPORT_H
+
diff --git a/plugin/mms_plugin/include/MmsPluginTypes.h b/plugin/mms_plugin/include/MmsPluginTypes.h
new file mode 100755 (executable)
index 0000000..f56dc1f
--- /dev/null
@@ -0,0 +1,292 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMSTPDUTYPES_H
+#define MMSTPDUTYPES_H
+
+#define        __SUPPORT_LIBCURL__
+
+#include "MmsPluginMessage.h"
+#include "MsgStorageTypes.h"
+
+
+typedef enum _E_UA_STATE {
+       eUA_IDLE = 0,
+       eUA_READY,
+       eUA_WAITING
+} E_UA_STATE;
+
+
+typedef unsigned int MMS_NET_ERROR_T;
+
+typedef unsigned int MMS_PDU_TYPE_T;
+
+typedef unsigned char MMS_HTTP_CMD_TYPE_T;
+
+
+enum _MMS_NET_ERROR_E {
+       eMMS_SUCCESS = 0,
+       eMMS_CM_OPEN_SUCCESS,
+       eMMS_CM_OPEN_FAILED,
+       eMMS_CM_CLOSE_IND,
+       eMMS_CM_CLOSE_RSP,
+       eMMS_CM_CLOSE_FAILED,   //5
+       eMMS_CM_KILL_RSP,
+       eMMS_CM_KILL_FAILED,
+
+       eMMS_HTTP_SESSION_INIT,
+       eMMS_HTTP_SESSION_CLOSED,
+       eMMS_HTTP_SESSION_OPEN_FAILED, //10
+       eMMS_HTTP_SENT_SUCCESS,
+       eMMS_HTTP_CONF_SUCCESS,
+       eMMS_HTTP_ERROR_NETWORK,
+       eMMS_HTTP_CONF_RECEIVED_TIMEOUT,
+       eMMS_HTTP_RECV_DATA,    //15
+       eMMS_HTTP_EVENT_RECV_DATA_PROGRESS,
+       eMMS_HTTP_EVENT_RECV_DATA_ERROR,
+       eMMS_HTTP_EVENT_SENT_ACK_COMPLETED,
+       eMMS_HTTP_ERROR_UNKNOWN,
+       eMMS_EXCEPTIONAL_ERROR, //20
+
+       eMMS_UNKNOWN
+};
+
+typedef struct _MMS_COND_S {
+       bool valid;
+       MMS_NET_ERROR_T reason;
+
+} MMS_COND_S;
+
+enum _MMS_PDU_TYPE_E {
+       eMMS_SEND_REQ = 0,
+       eMMS_SEND_CONF,
+       eMMS_NOTIFICATION_IND,
+       eMMS_NOTIFYRESP_IND,
+       eMMS_RETRIEVE_AUTO_CONF,
+       eMMS_ACKNOWLEDGE_IND,
+       eMMS_DELIVERY_IND,
+       eMMS_READREC_IND,
+       eMMS_READORIG_IND,
+       eMMS_READREPORT_REQ,
+       eMMS_READREPORT_CONF,   //10
+       eMMS_FORWARD_REQ,
+       eMMS_FORWARD_CONF,
+       eMMS_RETRIEVE_AUTO,
+       eMMS_RETRIEVE_MANUAL,
+       eMMS_RETRIEVE_MANUAL_CONF,
+       eMMS_CANCEL_REQ,
+       eMMS_CANCEL_CONF,
+       eMMS_DELETE_REQ,
+       eMMS_DELETE_CONF,
+       eMMS_MBOX_STORE_REQ,    // 20
+       eMMS_MBOX_STORE_CONF,
+       eMMS_MBOX_VIEW_REQ,
+       eMMS_MBOX_VIEW_CONF,
+       eMMS_MBOX_UPLOAD_REQ,
+       eMMS_MBOX_UPLOAD_CONF,
+       eMMS_MBOX_DELETE_REQ,
+       eMMS_MBOX_DELETE_CONF,
+};
+
+enum _MMS_HTTP_CMD_TYPE_E {
+       eHTTP_CMD_REGISTER = 0,
+       eHTTP_CMD_DEREGISTER,
+       eHTTP_CMD_INIT_SESSION,
+       eHTTP_CMD_CANCEL_SESSION,
+       eHTTP_CMD_CLOSE_SESSION,
+       eHTTP_CMD_DELETE_SESSION,
+       eHTTP_CMD_POST_TRANSACTION,
+       eHTTP_CMD_GET_TRANSACTION,
+       eHTTP_CMD_DELETE_TRANSACTION
+};
+
+typedef enum {
+       MSG_CHECK_ADDR_TYPE_PHONE = 0x01,
+       MSG_CHECK_ADDR_TYPE_EMAIL = 0x02,
+       MSG_CHECK_ADDR_TYPE_IPV4  = 0x04,
+       MSG_CHECK_ADDR_TYPE_IPV6  = 0x08,
+       MSG_CHECK_ADDR_TYPE_NUM   = 0x10,
+       MSG_CHECK_ADDR_TYPE_ALIAS = 0x20
+} MsgAddrCheckType;
+
+typedef struct _mmsTranQEntity {
+       bool isCompleted;
+       MSG_REQUEST_ID_T reqID;
+       int msgId;
+       unsigned int sessionId;
+       char transactionId[MMS_TR_ID_LEN + 1];
+
+       MMS_PDU_TYPE_T eMmsPduType;
+       MMS_HTTP_CMD_TYPE_T eHttpCmdType;
+
+       MMS_PDU_TYPE_T eMmsTransactionStatus;
+
+       int postDataLen;
+       char *pPostData;
+
+       int getDataLen;
+       char *pGetData;
+} mmsTranQEntity;
+
+typedef enum {
+       MMS_RM_PDU_TYPE,
+
+       MMS_RM_SEND_REQ,
+       MMS_RM_GET_REQ_AUTO,
+       MMS_RM_GET_REQ_MANUAL,
+       MMS_RM_NOTIFY_RESP_IND,
+       MMS_RM_ACK_IND,
+
+       MMS_RM_NOTI_IND,
+       MMS_RM_RETRIEVE_CONF,
+
+       MMS_RM_READ_REPORT_V10,
+       MMS_RM_READ_REPORT_V11
+} MmsRmPduType;
+
+/// CM //////////////////////////////////////////////////////
+
+#define MAX_PROFILE_ID 1
+
+#define MAX_URL_LENGTH 1024
+#define MAX_IPV4_LENGTH 30
+
+typedef struct _MMS_NETWORK_PROFILE_S {
+       int profileId[MAX_PROFILE_ID];
+       int profileCount;
+} MMS_NETWORK_PROFILE_S;
+
+
+
+/// HTTP ////////////////////////////////////////////////////
+
+enum _E_MMS_CONNECTION_MODE {
+       eTCP_WITH_PROXY = 0,  /** Means HTTP Proxy/Gateway are available */
+       eTCP_WITHOUT_PROXY = 1   /**  Means HTTP Proxy/Gateway is not available */
+};
+
+typedef unsigned int E_MMS_CONNECTION_MODE; /**< Values from \ref  _E_MMS_CONNECTION_MODE   */
+
+enum _E_MMS_NETWORK_ACCESS_POINT {
+       eNETWORK_ACCESS_POINT_ACKTIVE = 1
+};
+
+typedef unsigned int E_MMS_NETWORK_ACCESS_POINT;
+
+typedef struct  _MMSC_CONFIG_DATA_S {
+       char mmscUrl[MAX_URL_LENGTH + 1];                       /** if break, change it to NETPM_HOME_URL_LEN_MAX   */
+       char httpProxyIpAddr[MAX_IPV4_LENGTH + 1];      /**   HTTP Proxy's URL or IP address */
+
+       unsigned int proxyPortNo;       /** MMS HTTP proxy Port number  */
+       E_MMS_CONNECTION_MODE connectionMode;   /**   Values must be from ENUM list -\ref E_MMS_CONNECTION_MODE  */
+       E_MMS_NETWORK_ACCESS_POINT networkAccessPoint;  /**   Values must be from \ref E_MMS_NETWORK_ACCESS_POINT  */
+       unsigned int bAutoRetrieveFlag; /**  Value's shall be true or false */
+       unsigned int profileId;                 /** Profile is for CM Conn open*/
+} MMSC_CONFIG_DATA_S;
+
+typedef struct _MMS_PLUGIN_HTTP_DATA_S {
+       int profileId;
+       int profileCount;
+       int currentProfileId;
+       int sessionId;
+       int transactionId;
+       void *session;
+       void *sessionHeader;
+       MMSC_CONFIG_DATA_S mmscConfig;
+} MMS_PLUGIN_HTTP_DATA_S;
+
+typedef struct _MMS_PLUGIN_HTTP_CONTEXT_S {
+       char *recv_header_buf ;
+       int header_bufsize;
+       unsigned char *final_content_buf; // Final Concatenated Buffer
+       unsigned long ulContentLength;  // Content Leght Value received in HTTP OK Header
+       unsigned long bufOffset; /** < Incremented once received Content_receiving or Content_received Event */
+} MMS_PLUGIN_HTTP_CONTEXT_S;
+
+typedef struct _MMS_PLUGIN_PROCESS_DATA_S {
+       unsigned char *pData;
+       unsigned long dataLen;
+} MMS_PLUGIN_PROCESS_DATA_S;
+
+
+///////////////////////////////////////////////////////////////
+
+#define RETRY_MAX 1
+
+typedef enum {
+       MMS_HTTP_GET = 1,               /* GET  */
+       MMS_HTTP_POST = 2               /* POST */
+} MMS_HTTP_METHOD;
+
+#define MAX_MMSC_URL_LEN       100     /**   MAX URL Length includes NULL char */
+#define MAX_HTTP_PROXY_IPADDR_LEN      100     /**   MAX  HTTP Proxy IP addres length  includes NULL char */
+
+#define HTTP_REQUEST_LEN   1024
+#define HTTP_VER     "HTTP/1.1"
+#define CRLF             "\r\n"
+#define CRLFCRLF     "\r\n\r\n"
+
+/*  URL of  IIS Server - Where CGI script located */
+#define IIS_PostURI   "/mms/post.exe"
+#define OperatorPostUrl   "/mms/"
+#define MAX_MMSC_IPADDR_LEN   512
+#define        POST_URI   OperatorPostUrl
+
+
+
+//////////////////////////////////////////////////////////
+#define HTTP_RESP_SUCCESS    200
+#define HTTP_PROB_RESP_SUCCESS    100
+
+
+#define MMS_HTTP_HDR_CONNECTION "Keep-Alive"
+
+/********* HTTP HEADER MACROS *********/
+#define MMS_HTTP_HDR_CONTENT_TYPE "application/vnd.wap.mms-message"
+
+#define MMS_HTTP_HDR_USER_AGENT "AX355"
+
+#define MMS_HTTP_HDR_ACCEPT "application/vnd.wap.mms-message"
+
+#define MMS_HTTP_HDR_ACCEPT_LANGUAGE "en"
+
+#define MMS_HTTP_HDR_ACCEPT_CHARSET "US-ASCII, ISO-8859-1, UTF-8"
+
+//  MMSC Address
+#define NOW_MMSC_URL    "http://165.213.73.234:7082/01030016028=01030016028"
+#define NOW_MMSC_IP      "165.213.73.234"
+#define NOW_MMSC_PROXY   "165.213.73.234"
+#define NOW_MMSC_PROXY_PORT  7082
+
+#define DEFAULT_MMSC_URL               NOW_MMSC_URL
+#define DEFAULT_MMSC_IP                NOW_MMSC_IP
+#define DEFAULT_MMSC_PORT      7082
+#define DEFAULT_HTTP_PROXY     NOW_MMSC_PROXY
+#define DEFAULT_HTTP_PROXY_PORT        NOW_MMSC_PROXY_PORT
+
+typedef struct _S_HTTP_UA_RECVING_DATA {
+       int curr_len_recv;
+       int total_data_len;
+} S_HTTP_UA_RECVING_DATA;
+
+/////////////////////////////////////////////////////
+
+#define IN        /*! Pfrefix*/
+#define OUT       /*! Pfrefix*/
+#define INOUT     /*! Pfrefix*/
+
+#endif
+
diff --git a/plugin/mms_plugin/include/MmsPluginUserAgent.h b/plugin/mms_plugin/include/MmsPluginUserAgent.h
new file mode 100755 (executable)
index 0000000..2d3e46b
--- /dev/null
@@ -0,0 +1,67 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef MMSPLUGINUSERAGENT_H
+#define MMSPLUGINUSERAGENT_H
+
+#include <pthread.h>
+#include <vector>
+
+#include "MsgDebug.h"
+#include "MsgMutex.h"
+#include "MsgQueue.h"
+#include "MmsPluginTypes.h"
+#include "MmsPluginConnManWrapper.h"
+#include "MmsPluginHttp.h"
+#include "MsgThread.h"
+
+class MmsPluginUaManager: public MsgThread
+{
+       public:
+               static MmsPluginUaManager *instance();
+               virtual void start();
+
+               void addMmsReqEntity(mmsTranQEntity req);
+               void getMmsPduData(mmsTranQEntity *qEntity);
+               bool processReceivedData(int msgId, char *pRcvdBody, int rcvdBodyLen, char *retrievedFilePath);
+
+               void lock(){ mx.lock(); }
+               void unlock(){ mx.unlock(); }
+               void wait(){ cv.wait(mx.pMutex()); }
+               void signal(){ cv.signal(); }
+
+       private:
+               MmsPluginUaManager();
+               ~MmsPluginUaManager();
+
+               static MmsPluginUaManager *pInstance;
+               virtual void run();
+
+               Mutex mx;
+               CndVar cv;
+
+               MMS_NET_ERROR_T submitHandler(mmsTranQEntity *qEntity);
+               MMS_NET_ERROR_T waitingConf(mmsTranQEntity *qEntity);
+
+               // condition values
+               bool running;           // flag for thread running
+
+               MsgThdSafeQ <mmsTranQEntity> mmsTranQ; // transaction q for mms plugin
+};
+
+bool MsgOpenCreateAndOverwriteFile(char *szFullPath, char *szBuff, int totalLength);
+
+#endif // MMSPLUGINUSERAGENT_H
diff --git a/plugin/mms_plugin/include/MmsPluginWmLngPack.h b/plugin/mms_plugin/include/MmsPluginWmLngPack.h
new file mode 100755 (executable)
index 0000000..79ff390
--- /dev/null
@@ -0,0 +1,94 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef _MMS_PLUGIN_WM_LNG_PACK_H_
+#define _MMS_PLUGIN_WM_LNG_PACK_H_
+
+#include "MmsPluginMessage.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#define LOCALCODE_BYTE_MAX     3
+
+#define WmSizeof(size)         \
+               sizeof(size)/2
+
+/* Code Convert */
+bool  WmConvert2PCode( MCHAR* pmszOutText, int outBufSize, char* szInText);
+bool  WmConvert2LCode( char* pszOutText, int outBufSize, MCHAR* mszInText);
+bool  WmConvert2PCodeN( MCHAR* pmszOutText, int outBufSize, char*  szInText, int byteCount );
+bool  WmConvert2LCodeN( char* pszOutText, int outBufSize, MCHAR* mszInText, int charCount );
+bool  WmConvertPCode2UTF( UCHAR *pszOutText, int outBufSize, MCHAR *mszInText, int charCount );
+bool  WmConvertUTF2PCode( MCHAR *pmszOutText,int outBufSize, UCHAR *szInText, int byteCount );
+int   WmGetLCodeSize( MCHAR * mszText );
+int   WmGetLCodeSizeN( MCHAR *mszText, int charCount );
+bool  WmConvertLatinCode2PCode( MCHAR* pmszOutText, int outBufSize, char*  szInText);
+bool  WmConvertLatinCode2PCodeN( MCHAR* pmszOutText, int outBufSize, char*  szInText, int charCount );
+
+
+/* latin2 <-> PCode */
+bool   WmConvertLatin2Code2PCode( MCHAR* pmszOutText, int outBufSize, char*  szInText);
+
+/* latin3 <-> PCode */
+bool   WmConvertLatin3Code2PCode( MCHAR* pmszOutText, int outBufSize, char*  szInText);
+
+/* latin4 <-> PCode */
+bool   WmConvertLatin4Code2PCode( MCHAR* pmszOutText, int outBufSize, char*  szInText);
+
+/* latin8 <-> PCode */
+bool   WmConvertLatin8Code2PCode( MCHAR* pmszOutText, int outBufSize, char*  szInText);
+
+/* latin15 <-> PCode */
+bool   WmConvertLatin15Code2PCode( MCHAR* pmszOutText, int outBufSize, char*  szInText);
+
+/* latin5 <-> PCode */
+bool   WmConvertLatin5Code2PCode( MCHAR* pmszOutText, int outBufSize, char*  szInText);
+
+/* win1251 <-> PCode */
+bool   WmConvertWin1251Code2PCode( MCHAR* pmszOutText, int outBufSize, char*  szInText);
+
+/* Koi8-r <-> PCode */
+bool   WmConvertKoi8rCode2PCode( MCHAR* pmszOutText, int outBufSize, char*  szInText);
+
+/* Koi8-u <-> PCode */
+bool   WmConvertKoi8uCode2PCode( MCHAR* pmszOutText, int outBufSize, char*  szInText);
+
+
+/* String Handling */
+int    WmStrlen( const MCHAR* mszInText );
+int    WmStrncmp( const MCHAR* mszInText1, const MCHAR* mszInText2, UINT charCount );
+
+
+int WmGetLatin32UTFCodeSize( unsigned char* szSrc, int nChar ); //ISO 8859-3
+int WmGetLatin42UTFCodeSize( unsigned char* szSrc, int nChar ); //ISO 8859-4
+int WmGetLatin82UTFCodeSize( unsigned char* szSrc, int nChar ); //ISO 8859-8
+int WmGetLatin152UTFCodeSize( unsigned char* szSrc, int nChar ); //ISO 8859-15
+int WmGetLatin52UTFCodeSize( unsigned char* szSrc, int nChar ); //ISO 8859-9
+
+
+bool __WmConvertCodeBufferSizeCheck( char* ftnName, int outBufSize, int requiredBufSize );
+bool _WmT9ChangeUniToGSMCode( MCHAR* pmszOutText, MCHAR* mszInText, int length );
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _WM_LNG_PACK_H_ */
+
+
diff --git a/plugin/sms_plugin/CMakeLists.txt b/plugin/sms_plugin/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..6bc6dae
--- /dev/null
@@ -0,0 +1,59 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(sms-plugin CXX)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall")
+
+##########################################################
+# Define SMS Plugin
+##########################################################
+
+SET(SMS-PLUGIN-SRCS
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginTextConvert.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginUDCodec.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginParamCodec.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginTpduCodec.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginSatHandler.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginCbMsgHandler.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginWapPushHandler.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginConcatHandler.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginSetting.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginSimMsg.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginStorage.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginTransport.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginEventHandler.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginUAManager.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginCallback.cpp
+       ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginMain.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include/common
+       ${CMAKE_SOURCE_DIR}/include/utils
+       ${CMAKE_CURRENT_SOURCE_DIR}/include
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 drm-client dlog vconf)
+
+FOREACH(flag ${sms_plugin_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${SMS-PLUGIN-LIB} SHARED ${SMS-PLUGIN-SRCS})
+TARGET_LINK_LIBRARIES(${SMS-PLUGIN-LIB} ${sms_plugin_pkgs_LDFLAGS} ${UTILS-LIB})
+
+INSTALL(TARGETS ${SMS-PLUGIN-LIB} LIBRARY DESTINATION lib)
+
diff --git a/plugin/sms_plugin/SmsPluginCallback.cpp b/plugin/sms_plugin/SmsPluginCallback.cpp
new file mode 100755 (executable)
index 0000000..91eb50f
--- /dev/null
@@ -0,0 +1,862 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <glib.h>
+#include <pthread.h>
+
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "SmsPluginEventHandler.h"
+#include "SmsPluginCbMsgHandler.h"
+#include "SmsPluginConcatHandler.h"
+#include "SmsPluginWapPushHandler.h"
+#include "SmsPluginSatHandler.h"
+#include "SmsPluginParamCodec.h"
+#include "SmsPluginTpduCodec.h"
+#include "SmsPluginSimMsg.h"
+#include "SmsPluginSetting.h"
+#include "SmsPluginCallback.h"
+
+extern "C"
+{
+       #include <ITapiProductivity.h>
+}
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+int TapiEventDeviceReady(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventDeviceReady is called. : request id = [%d] status = [%d]", pEvent->RequestId, pEvent->Status);
+
+       try
+       {
+               // Call Event Handler
+               SmsPluginEventHandler::instance()->setDeviceStatus();
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return e.errorCode();
+       }
+
+       return 0;
+}
+
+
+int TapiEventSentStatus(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventSentStatus is called. : request id = [%d] status = [%d]", pEvent->RequestId, pEvent->Status);
+
+       MSG_NETWORK_STATUS_T netStatus;
+
+       // Convert TAPI status -> Messaging status
+       if ((TelSmsResponse_t)pEvent->Status == TAPI_NETTEXT_SENDSMS_SUCCESS)
+               netStatus = MSG_NETWORK_SEND_SUCCESS;
+       else
+               netStatus = MSG_NETWORK_SEND_FAIL;
+
+       try
+       {
+               // Call Event Handler
+               SmsPluginEventHandler::instance()->handleSentStatus(pEvent->RequestId, netStatus);
+
+               // Call SAT Handler
+               SmsPluginSatHandler::instance()->ctrlSms(netStatus);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return e.errorCode();
+       }
+
+       return 0;
+}
+
+
+int TapiEventMsgIncoming(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventMsgIncoming is called. Red Id [%d]", pEvent->RequestId);
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+               return 0;
+       }
+
+       TelSmsDatapackageInfo_t* pDataPackage = (TelSmsDatapackageInfo_t*)pEvent->pData;
+
+       SMS_TPDU_S tpdu;
+
+       // Decode Incoming Message
+       SmsPluginTpduCodec::decodeTpdu(pDataPackage->szData, pDataPackage->MsgLength, &tpdu);
+
+       /// Print tpdu
+       if (tpdu.tpduType == SMS_TPDU_DELIVER)
+       {
+               MSG_DEBUG("############# SMS_TPDU_DELIVER Incoming decoded tpdu values ####################");
+               MSG_DEBUG("tpdu.data.deliver.bMoreMsg : %d", tpdu.data.deliver.bMoreMsg);
+               MSG_DEBUG("tpdu.data.deliver.bStatusReport : %d", tpdu.data.deliver.bStatusReport);
+               MSG_DEBUG("tpdu.data.deliver.bHeaderInd : %d", tpdu.data.deliver.bHeaderInd);
+               MSG_DEBUG("tpdu.data.deliver.bReplyPath : %d", tpdu.data.deliver.bReplyPath);
+               MSG_DEBUG("tpdu.data.deliver.pid : %d", tpdu.data.deliver.pid);
+               MSG_DEBUG("tpdu.data.deliver.dcs.bCompressed : %d", tpdu.data.deliver.dcs.bCompressed);
+               MSG_DEBUG("tpdu.data.deliver.dcs.msgClass : %d", tpdu.data.deliver.dcs.msgClass);
+               MSG_DEBUG("tpdu.data.deliver.dcs.codingScheme : %d", tpdu.data.deliver.dcs.codingScheme);
+               MSG_DEBUG("tpdu.data.deliver.dcs.codingGroup : %d", tpdu.data.deliver.dcs.codingGroup);
+               MSG_DEBUG("tpdu.data.deliver.originAddress.address : %s", tpdu.data.deliver.originAddress.address);
+               MSG_DEBUG("tpdu.data.deliver.timeStamp.time : %d/%d/%d %d:%d:%d ", tpdu.data.deliver.timeStamp.time.absolute.year, tpdu.data.deliver.timeStamp.time.absolute.month, tpdu.data.deliver.timeStamp.time.absolute.day,
+                       tpdu.data.deliver.timeStamp.time.absolute.hour, tpdu.data.deliver.timeStamp.time.absolute.minute, tpdu.data.deliver.timeStamp.time.absolute.second);
+               MSG_DEBUG("tpdu.data.deliver.userData.headerCnt : %d", tpdu.data.deliver.userData.headerCnt);
+               MSG_DEBUG("tpdu.data.deliver.userData.length : %d", tpdu.data.deliver.userData.length);
+               MSG_DEBUG("tpdu.data.deliver.userData.data : %s", tpdu.data.deliver.userData.data);
+               MSG_DEBUG("#####################################################");
+       }
+       else if (tpdu.tpduType == SMS_TPDU_STATUS_REP)
+       {
+               MSG_DEBUG("############# SMS_TPDU_STATUS_REP Incoming decoded tpdu values ####################");
+               MSG_DEBUG("tpdu.data.statusRep.msgRef : %d", tpdu.data.statusRep.msgRef);
+               MSG_DEBUG("tpdu.data.statusRep.bMoreMsg : %d", tpdu.data.statusRep.bMoreMsg);
+               MSG_DEBUG("tpdu.data.statusRep.bStatusReport : %d", tpdu.data.statusRep.bStatusReport);
+               MSG_DEBUG("tpdu.data.statusRep.statusRep : %d", tpdu.data.statusRep.bHeaderInd);
+               MSG_DEBUG("tpdu.data.statusRep.status : %02x", tpdu.data.statusRep.status);
+               MSG_DEBUG("tpdu.data.statusRep.pid : %d", tpdu.data.statusRep.pid);
+               MSG_DEBUG("tpdu.data.statusRep.dcs.bCompressed : %d", tpdu.data.statusRep.dcs.bCompressed);
+               MSG_DEBUG("tpdu.data.statusRep.dcs.msgClass : %d", tpdu.data.statusRep.dcs.msgClass);
+               MSG_DEBUG("tpdu.data.statusRep.dcs.codingScheme : %d", tpdu.data.statusRep.dcs.codingScheme);
+               MSG_DEBUG("tpdu.data.statusRep.dcs.codingGroup : %d", tpdu.data.statusRep.dcs.codingGroup);
+               MSG_DEBUG("tpdu.data.statusRep.recipAddress.address : %s", tpdu.data.statusRep.recipAddress.address);
+               MSG_DEBUG("tpdu.data.statusRep.timeStamp.time : %d/%d/%d %d:%d:%d ", tpdu.data.statusRep.timeStamp.time.absolute.year, tpdu.data.statusRep.timeStamp.time.absolute.month, tpdu.data.statusRep.timeStamp.time.absolute.day,
+                       tpdu.data.statusRep.timeStamp.time.absolute.hour, tpdu.data.statusRep.timeStamp.time.absolute.minute, tpdu.data.statusRep.timeStamp.time.absolute.second);
+               MSG_DEBUG("tpdu.data.statusRep.dischargeTime.time : %d/%d/%d %d:%d:%d ", tpdu.data.statusRep.dischargeTime.time.absolute.year, tpdu.data.statusRep.dischargeTime.time.absolute.month, tpdu.data.statusRep.dischargeTime.time.absolute.day,
+                       tpdu.data.statusRep.dischargeTime.time.absolute.hour, tpdu.data.statusRep.dischargeTime.time.absolute.minute, tpdu.data.statusRep.dischargeTime.time.absolute.second);
+               MSG_DEBUG("tpdu.data.statusRep.userData.headerCnt : %d", tpdu.data.statusRep.userData.headerCnt);
+               MSG_DEBUG("tpdu.data.statusRep.userData.length : %d", tpdu.data.statusRep.userData.length);
+               MSG_DEBUG("tpdu.data.statusRep.userData.data : %s", tpdu.data.statusRep.userData.data);
+               MSG_DEBUG("#####################################################");
+       }
+
+       try
+       {
+               if (tpdu.tpduType == SMS_TPDU_DELIVER)
+               {
+                       if (SmsPluginConcatHandler::instance()->IsConcatMsg(&(tpdu.data.deliver.userData)) == true ||
+                               SmsPluginWapPushHandler::instance()->IsWapPushMsg(&(tpdu.data.deliver.userData)) == true)
+                       {
+                               SmsPluginConcatHandler::instance()->handleConcatMsg(&tpdu); // Call Concat Msg Handler
+                       }
+                       else
+                       {
+                               SmsPluginEventHandler::instance()->handleMsgIncoming(&tpdu); // Call Event Handler
+                       }
+               }
+               else if (tpdu.tpduType == SMS_TPDU_STATUS_REP)
+               {
+                       SmsPluginEventHandler::instance()->handleMsgIncoming(&tpdu); // Call Event Handler
+               }
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return e.errorCode();
+       }
+
+       return 0;
+}
+
+
+int TapiEventCbMsgIncoming(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventCbMsgIncoming is called.");
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+               return 0;
+       }
+
+       TelSmsCbMsg_t *pCbMsg = (TelSmsCbMsg_t*)pEvent->pData;
+
+       try
+       {
+               SmsPluginCbMsgHandler::instance()->handleCbMsg(pCbMsg);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return 0;
+       }
+
+       return 0;
+}
+
+
+int TapiEventDeliveryReportCNF(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventDeliveryReportCNF is called. : request id = [%d] status = [%d]", pEvent->RequestId, pEvent->Status);
+
+       return 0;
+}
+
+
+int TapiEventGetSimMsgCnt(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventGetSimMsgCnt is called.");
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+               MSG_SIM_COUNT_S simCnt;
+               memset(&simCnt, 0x00, sizeof(MSG_SIM_COUNT_S));
+               SmsPluginSimMsg::instance()->setSimMsgCntEvent(&simCnt);
+               return 0;
+       }
+
+       SmsPluginSimMsg::instance()->setSimMsgCntEvent((MSG_SIM_COUNT_S *)pEvent->pData);
+
+       return 0;
+}
+
+
+int TapiEventGetSimMsg(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventGetSimMsg is called.");
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error!! pEvent->Status [%d]", pEvent->Status);
+
+               SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
+
+               return 0;
+       }
+
+       TelSmsData_t* pSmsTpdu = (TelSmsData_t*)pEvent->pData;
+
+       // Reading TelSmsData_t
+       MSG_DEBUG ("sim index %d", pSmsTpdu->SimIndex);
+       MSG_DEBUG ("status %d", pSmsTpdu->MsgStatus);
+
+       // Reading TelSmsDatapackageInfo_t
+       if (pSmsTpdu->SmsData.MsgLength > MAX_TPDU_DATA_LEN)
+       {
+               MSG_DEBUG ("WARNING: tpdu_len > MAX_SMS_TPDU_SIZE [%d] bytes. setting to 0.", pSmsTpdu->SmsData.MsgLength);
+
+               SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
+
+               return 0;
+       }
+
+       SMS_TPDU_S tpdu;
+
+       // decode Tpdu
+       SmsPluginTpduCodec::decodeTpdu(pSmsTpdu->SmsData.szData, pSmsTpdu->SmsData.MsgLength, &tpdu);
+
+       MSG_DEBUG("Sim Message Type [%d]", tpdu.tpduType);
+
+       bool bRead = false;
+
+       // set read status
+       if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_READ)
+               bRead = true;
+       else if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_UNREAD)
+               bRead = false;
+
+       if (tpdu.tpduType == SMS_TPDU_DELIVER)
+       {
+               MSG_DEBUG("headerCnt [%d]", tpdu.data.deliver.userData.headerCnt);
+
+               for (int i = 0; i < tpdu.data.deliver.userData.headerCnt; i++)
+               {
+                       // Handler Concatenated Message
+                       if (tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
+                               tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT)
+                       {
+                               SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
+                               return 0;
+                       }
+               }
+       }
+       else if (tpdu.tpduType == SMS_TPDU_SUBMIT)
+       {
+               MSG_DEBUG("headerCnt [%d]", tpdu.data.submit.userData.headerCnt);
+
+               for (int i = 0; i < tpdu.data.submit.userData.headerCnt; i++)
+               {
+                       // Handler Concatenated Message
+                       if (tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
+                               tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT)
+                       {
+                               SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
+                               return 0;
+                       }
+               }
+       }
+
+       // Make MSG_MESSAGE_INFO_S
+       MSG_MESSAGE_INFO_S msgInfo;
+       memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+       SmsPluginEventHandler::instance()->convertTpduToMsginfo(&tpdu, &msgInfo);
+
+       // set Sim Message ID
+       msgInfo.msgId = pSmsTpdu->SimIndex;
+
+       // set read status
+       msgInfo.bRead = bRead;
+
+       // set storage id
+       msgInfo.storageId = MSG_STORAGE_SIM;
+
+       /// Print MSG_MESSAGE_INFO_S
+       MSG_DEBUG("############# Convert  tpdu values to Message Info values ####################");
+       MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
+       MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
+       MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
+       MSG_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
+       MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
+       MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
+       MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
+       MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
+       MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
+       MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
+       MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
+       MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
+       MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
+       MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
+       if (msgInfo.bTextSms == true)
+               MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
+       else
+       MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
+       MSG_DEBUG("###############################################################");
+
+       SmsPluginSimMsg::instance()->setSimMsgEvent(&msgInfo, true); // Call Event Handler
+
+       return 0;
+}
+
+
+int TapiEventSaveSimMsg(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventSaveSimMsg is called. Red Id [%d]", pEvent->RequestId);
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+               SmsPluginSimMsg::instance()->setSimEvent((MSG_SIM_ID_T)0, false);
+               return 0;
+       }
+
+       int simId = *((int*)pEvent->pData);
+
+       MSG_DEBUG("sim ID : [%d], status : [%d]", simId, (TelSmsCause_t)pEvent->Status);
+
+       SmsPluginSimMsg::instance()->setSimEvent((MSG_SIM_ID_T)simId, true);
+
+       return 0;
+}
+
+
+int TapiEventDeleteSimMsg(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventDeleteSimMsg is called. Red Id [%d]", pEvent->RequestId);
+       MSG_DEBUG("status : [%d]", (TelSmsCause_t)pEvent->Status);
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+               SmsPluginSimMsg::instance()->setSimEvent((MSG_SIM_ID_T)0, false);
+               return 0;
+       }
+
+       int sim_id = *((int*)pEvent->pData);
+
+       SmsPluginSimMsg::instance()->setSimEvent((MSG_SIM_ID_T)sim_id, true);
+
+       return 0;
+}
+
+
+int TapiEventSetConfigData(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventSetConfigData is called.");
+
+       if (pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+               return 0;
+       }
+
+       TelSmsSetResponse* responseType = (TelSmsSetResponse*)pEvent->pData;
+
+       MSG_DEBUG("responseType : [%d]", *responseType);
+
+       switch (*responseType)
+       {
+               case TAPI_NETTEXT_SETPREFERREDBEARER_RSP :
+                       MSG_DEBUG("TAPI_NETTEXT_SETPREFERREDBEARER_RSP is called");
+               break;
+
+               case TAPI_NETTEXT_SETPARAMETERS_RSP :
+                       MSG_DEBUG("TAPI_NETTEXT_SETPARAMETERS_RSP is called");
+               break;
+
+               case TAPI_NETTEXT_CBSETCONFIG_RSP :
+                       MSG_DEBUG("TAPI_NETTEXT_CBSETCONFIG_RSP is called");
+               break;
+
+               case TAPI_NETTEXT_SETMEMORYSTATUS_RSP :
+                       MSG_DEBUG("TAPI_NETTEXT_SETMEMORYSTATUS_RSP is called");
+               break;
+
+               case TAPI_NETTEXT_SETMESSAGESTATUS_RSP :
+                       MSG_DEBUG("TAPI_NETTEXT_SETMESSAGESTATUS_RSP is called");
+               break;
+
+               default :
+                       MSG_DEBUG("Unknown Response is called [%d]", *responseType);
+               break;
+       }
+
+       bool bRet = true;
+
+       MSG_DEBUG("status : [%d]", (TelSmsCause_t)pEvent->Status);
+
+       if ((TelSmsCause_t)pEvent->Status != TAPI_NETTEXT_SUCCESS) bRet = false;
+
+       if (*responseType == TAPI_NETTEXT_SETMESSAGESTATUS_RSP)
+               SmsPluginSimMsg::instance()->setSimEvent(0, bRet);
+       else
+               SmsPluginSetting::instance()->setResultFromSim(bRet);
+
+       return 0;
+}
+
+
+int TapiEventGetParamCnt(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventGetParamCnt is called.");
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+               SmsPluginSetting::instance()->setParamCntEvent(0);
+               return 0;
+       }
+
+       int paramCnt = 0;
+       paramCnt = *((int*)pEvent->pData);
+
+       SmsPluginSetting::instance()->setParamCntEvent(paramCnt);
+
+       return 0;
+}
+
+
+int TapiEventGetParam(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventGetConfigData is called.");
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+               SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
+               return 0;
+       }
+
+       TelSmsParams_t* smsParam = (TelSmsParams_t*)pEvent->pData;
+
+       int alphaIdLen = 0;
+       int addrLen = 0;
+       MSG_SMSC_DATA_S smscData = {};
+
+       /*Check Alpha ID value*/
+       alphaIdLen = smsParam->AlphaIdLen;
+       MSG_DEBUG("alphaId_len[%d]", alphaIdLen);
+
+       if (alphaIdLen < 0 || alphaIdLen > SMSC_NAME_MAX)
+       {
+               MSG_DEBUG("Wrong Alpha ID Length[%d]", alphaIdLen);
+
+               SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
+
+               return 0;
+       }
+
+
+       /*Check Address value*/
+       addrLen = smsParam->TpSvcCntrAddr.DialNumLen;
+
+       if(addrLen > SMSC_ADDR_MAX)
+       {
+               MSG_DEBUG("addrLen is too long: %d", addrLen);
+               SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
+               return 0;
+       }
+       else if(addrLen < 2)
+       {
+               MSG_DEBUG("addrLen is too short: %d", addrLen);
+               SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
+               return 0;
+       }
+
+       MSG_DEBUG("addrLen : %d", addrLen);
+
+
+       /*SMSP Parameter Indicator value*/
+       MSG_DEBUG("ParamIndicator[%02x]", smsParam->ParamIndicator);
+
+       /*Get SMSC Address*/
+       if(0x00 == (0x02 & smsParam->ParamIndicator))
+       {
+               MSG_DEBUG("record index[%d]", (int)smsParam->RecordIndex);
+
+               MSG_DEBUG("TON : %d", smsParam->TpSvcCntrAddr.Ton);
+               MSG_DEBUG("NPI : %d", smsParam->TpSvcCntrAddr.Npi);
+
+               smscData.smscAddr.ton = smsParam->TpSvcCntrAddr.Ton;
+               smscData.smscAddr.npi = smsParam->TpSvcCntrAddr.Npi;
+
+               SmsPluginParamCodec paramCodec;
+
+               memset(smscData.smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
+               paramCodec.decodeSMSC(smsParam->TpSvcCntrAddr.szDiallingNum, addrLen, smscData.smscAddr.ton, smscData.smscAddr.address);
+
+               MSG_DEBUG("SMSC Address : [%s]", smscData.smscAddr.address);
+
+               memset(smscData.name, 0x00, SMSC_NAME_MAX+1);
+               memcpy(smscData.name, smsParam->szAlphaId, alphaIdLen);
+               smscData.name[alphaIdLen] = '\0';
+
+               MSG_DEBUG("SMSC Name : [%s]", smscData.name);
+       }
+       else
+       {
+               MSG_DEBUG("SMSC Address is not present");
+
+               SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
+
+               return 0;
+       }
+
+       /*Get the PID value*/
+       if (0x00 == (0x04 & smsParam->ParamIndicator))
+       {
+               SMS_PID_T pid = (SMS_PID_T)smsParam->TpProtocolId;
+
+               MSG_DEBUG("smsParam->TpProtocolId : %d", smsParam->TpProtocolId);
+
+               switch (pid)
+               {
+                       case SMS_PID_NORMAL:
+                               smscData.pid = MSG_PID_TEXT;
+                       break;
+                       case SMS_PID_VOICE:
+                               smscData.pid = MSG_PID_VOICE;
+                       break;
+                       case SMS_PID_TELEX:
+                               smscData.pid = MSG_PID_FAX;
+                       break;
+                       case SMS_PID_x400:
+                               smscData.pid = MSG_PID_X400;
+                       break;
+                       case SMS_PID_ERMES:
+                               smscData.pid = MSG_PID_ERMES;
+                       break;
+                       case SMS_PID_EMAIL:
+                               smscData.pid = MSG_PID_EMAIL;
+                       break;
+                       default:
+                               smscData.pid = MSG_PID_TEXT;
+                       break;
+               }
+
+               MSG_DEBUG("smscData.pid : %d", smscData.pid);
+       }
+       else
+       {
+               MSG_DEBUG("PID is not present");
+               smscData.pid = MSG_PID_TEXT;
+               MSG_DEBUG("MSG_PID_TEXT is inserted to PID");
+       }
+
+       /*Get the ValidityPeriod value*/
+       if (0x00 == (0x10 & smsParam->ParamIndicator))
+       {
+               smscData.valPeriod = smsParam->TpValidityPeriod;
+               MSG_DEBUG("valPeriod : %d", smscData.valPeriod);
+       }
+       else
+       {
+               smscData.valPeriod = 0;
+               MSG_DEBUG("Validity Period is not present");
+       }
+
+       SmsPluginSetting::instance()->setParamEvent(&smscData, (int)smsParam->RecordIndex, true);
+
+       return 0;
+}
+
+
+int TapiEventGetCBConfig(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventGetCBConfig is called.");
+
+       MSG_CBMSG_OPT_S cbOpt = {0};
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+
+               SmsPluginSetting::instance()->setCbConfigEvent(NULL, false);
+
+               return 0;
+       }
+
+       TelSmsCbConfig_t* pCBConfig = (TelSmsCbConfig_t*)pEvent->pData;
+
+       cbOpt.bReceive = (bool)pCBConfig->bCBEnabled;
+
+       if (pCBConfig->SelectedId == 0x01)
+               cbOpt.bAllChannel = true;
+       else if (pCBConfig->SelectedId == 0x02)
+               cbOpt.bAllChannel = false;
+
+       cbOpt.maxSimCnt = pCBConfig->MsgIdMaxCount;
+
+       MSG_DEBUG("Receive [%d], All Channel [%d], Max SIM Count [%d]", cbOpt.bReceive, cbOpt.bAllChannel, cbOpt.maxSimCnt);
+
+       cbOpt.channelData.channelCnt = pCBConfig->MsgIdCount;
+
+       if (cbOpt.channelData.channelCnt > CB_CHANNEL_MAX)
+       {
+               MSG_DEBUG("Channel Count [%d] from TAPI is over MAX", cbOpt.channelData.channelCnt);
+               cbOpt.channelData.channelCnt = CB_CHANNEL_MAX;
+       }
+
+       MSG_DEBUG("Channel Count [%d]", cbOpt.channelData.channelCnt);
+
+       for (int i = 0; i < cbOpt.channelData.channelCnt; i++)
+       {
+               cbOpt.channelData.channelInfo[i].bActivate = cbOpt.bReceive;
+               cbOpt.channelData.channelInfo[i].id = pCBConfig->MsgIDs[i];
+               memset(cbOpt.channelData.channelInfo[i].name, 0x00, CB_CHANNEL_NAME_MAX+1);
+
+               MSG_DEBUG("Channel ID [%d]", cbOpt.channelData.channelInfo[i].id);
+       }
+
+       SmsPluginSetting::instance()->setCbConfigEvent(&cbOpt, true);
+
+       return 0;
+}
+
+
+int TapiEventSatSmsRefresh(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventSatSmsRefresh is called.");
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+               return 0;
+       }
+
+       try
+       {
+               SmsPluginSatHandler::instance()->refreshSms(pEvent->pData);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return e.errorCode();
+       }
+
+       return 0;
+}
+
+
+int TapiEventSatSendSms(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventSatSendSms is called.");
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+               return 0;
+       }
+
+       try
+       {
+               SmsPluginSatHandler::instance()->sendSms(pEvent->pData);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return e.errorCode();
+       }
+
+       return 0;
+}
+
+
+int TapiEventSatMoSmsCtrl(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventSatMoSmsCtrl is called.");
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+               return 0;
+       }
+
+       try
+       {
+               SmsPluginSatHandler::instance()->ctrlSms(pEvent->pData);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return e.errorCode();
+       }
+
+       return 0;
+
+}
+
+
+int TapiEventFactoryDftSms(const TelTapiEvent_t *pEvent, void*)
+{
+       MSG_DEBUG("TapiEventFactoryDftSms is called.");
+
+       if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
+       {
+               MSG_DEBUG("Error. evt->pData is NULL.");
+               return 0;
+       }
+
+       TelFactoryDftSmsInfo_t* pSmsInfo = (TelFactoryDftSmsInfo_t *)pEvent->pData;
+
+       MSG_FOLDER_ID_T folderId = MSG_INBOX_ID;
+
+       if (pSmsInfo->option == TAPI_FACTORY_DFT_SMS_INBOX)
+       {
+               folderId = MSG_INBOX_ID;
+       }
+       else if (pSmsInfo->option == TAPI_FACTORY_DFT_SMS_DRAFTS)
+       {
+               folderId = MSG_DRAFT_ID;
+       }
+       else if (pSmsInfo->option == TAPI_FACTORY_DFT_SMS_OUTBOX)
+       {
+               folderId = MSG_OUTBOX_ID;
+       }
+       else if (pSmsInfo->option == TAPI_FACTORY_DFT_SMS_SENTBOX)
+       {
+               folderId = MSG_SENTBOX_ID;
+       }
+
+       try
+       {
+               SmsPluginEventHandler::instance()->handleDftSms(folderId, pSmsInfo->number, pSmsInfo->data); // Call Event Handler
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return e.errorCode();
+       }
+
+       return 0;
+}
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginCallback - Member Functions
+==================================================================================================*/
+SmsPluginCallback* SmsPluginCallback::pInstance = NULL;
+
+
+SmsPluginCallback::SmsPluginCallback()
+{
+
+
+}
+
+
+SmsPluginCallback::~SmsPluginCallback()
+{
+       if (pInstance != NULL)
+       {
+               delete pInstance;
+               pInstance = NULL;
+       }
+}
+
+
+SmsPluginCallback* SmsPluginCallback::instance()
+{
+       if (!pInstance)
+               pInstance = new SmsPluginCallback();
+
+       return pInstance;
+}
+
+
+void SmsPluginCallback::registerEvent()
+{
+       unsigned int tempId = 0;
+
+       tel_register_event(TAPI_EVENT_NETTEXT_DEVICE_READY_IND, &tempId, (TelAppCallback)&TapiEventDeviceReady, NULL);
+
+       tel_register_event(TAPI_EVENT_NETTEXT_SENTSTATUS_CNF, &tempId, (TelAppCallback)&TapiEventSentStatus, NULL);
+       tel_register_event(TAPI_EVENT_NETTEXT_INCOM_IND, &tempId, (TelAppCallback)&TapiEventMsgIncoming, NULL);
+       tel_register_event(TAPI_EVENT_NETTEXT_CB_INCOM_IND, &tempId, (TelAppCallback)&TapiEventCbMsgIncoming, NULL);
+       tel_register_event(TAPI_EVENT_NETTEXT_DELIVERY_REPORT_CNF, &tempId, (TelAppCallback)&TapiEventDeliveryReportCNF, NULL);
+
+       tel_register_event(TAPI_EVENT_NETTEXT_SAVE_STATUS_CNF, &tempId, (TelAppCallback)&TapiEventSaveSimMsg, NULL);
+       tel_register_event(TAPI_EVENT_NETTEXT_DELETE_STATUS_CNF, &tempId, (TelAppCallback)&TapiEventDeleteSimMsg, NULL);
+       tel_register_event(TAPI_EVENT_NETTEXT_GET_COUNT_CNF, &tempId, (TelAppCallback)&TapiEventGetSimMsgCnt, NULL);
+       tel_register_event(TAPI_EVENT_NETTEXT_READ_SMS_CNF, &tempId, (TelAppCallback)&TapiEventGetSimMsg, NULL);
+
+       tel_register_event(TAPI_EVENT_NETTEXT_SET_REQUEST_CNF, &tempId, (TelAppCallback)&TapiEventSetConfigData, NULL);
+       tel_register_event(TAPI_EVENT_NETTEXT_PARAM_COUNT_IND, &tempId, (TelAppCallback)&TapiEventGetParamCnt, NULL);
+       tel_register_event(TAPI_EVENT_NETTEXT_GET_PARAM_CNF, &tempId, (TelAppCallback)&TapiEventGetParam, NULL);
+       tel_register_event(TAPI_EVENT_NETTEXT_GET_CB_CONFIG_CNF, &tempId, (TelAppCallback)&TapiEventGetCBConfig, NULL);
+
+       tel_register_event(TAPI_EVENT_SAT_SMS_REFRESH_IND, &tempId, (TelAppCallback)&TapiEventSatSmsRefresh, NULL);
+       tel_register_event(TAPI_EVENT_SAT_SEND_SMS_IND, &tempId, (TelAppCallback)&TapiEventSatSendSms, NULL);
+       tel_register_event(TAPI_EVENT_SAT_MO_SMS_CONTROL_IND, &tempId, (TelAppCallback)&TapiEventSatMoSmsCtrl, NULL);
+
+       tel_register_event(TAPI_EVENT_FACTORY_DFT_SMS, &tempId, (TelAppCallback)&TapiEventFactoryDftSms, NULL);
+
+       int tapiRet = TAPI_API_SUCCESS;
+
+       // Register app name to telephony server
+       tapiRet = tel_register_app_name((char*)"org.tizen.msgfw");
+
+       if (tapiRet != TAPI_API_SUCCESS)
+       {
+                THROW(MsgException::SMS_PLG_ERROR, "Failed to register applicatoin name on Telephony Server [%d]", tapiRet);
+       }
+}
+
+
+void SmsPluginCallback::deRegisterEvent()
+{
+
+
+}
+
diff --git a/plugin/sms_plugin/SmsPluginCbMsgHandler.cpp b/plugin/sms_plugin/SmsPluginCbMsgHandler.cpp
new file mode 100755 (executable)
index 0000000..b456670
--- /dev/null
@@ -0,0 +1,776 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <time.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "MsgUtilFile.h"
+#include "SmsPluginTextConvert.h"
+#include "SmsPluginUDCodec.h"
+#include "SmsPluginStorage.h"
+#include "SmsPluginEventHandler.h"
+#include "SmsPluginCbMsgHandler.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginCbMsgHandler - Member Functions
+==================================================================================================*/
+SmsPluginCbMsgHandler* SmsPluginCbMsgHandler::pInstance = NULL;
+
+
+SmsPluginCbMsgHandler::SmsPluginCbMsgHandler()
+{
+       pageList.clear();
+}
+
+
+SmsPluginCbMsgHandler::~SmsPluginCbMsgHandler()
+{
+
+}
+
+
+SmsPluginCbMsgHandler* SmsPluginCbMsgHandler::instance()
+{
+       if (!pInstance)
+               pInstance = new SmsPluginCbMsgHandler();
+
+       return pInstance;
+}
+
+
+void SmsPluginCbMsgHandler::handleCbMsg(TelSmsCbMsg_t *pCbMsg)
+{
+       MSG_BEGIN();
+
+       SMS_CB_NETWORK_TYPE_T type = pCbMsg->CbMsgType;
+
+       SMS_CBMSG_PAGE_S CbMsgPage = {0};
+
+       switch (type)
+       {
+               case SMS_CB_NETWORK_TYPE_2G_GSM :
+                       Decode2gCbMsg(pCbMsg, &CbMsgPage);
+               break;
+
+               case SMS_CB_NETWORK_TYPE_3G_UMTS :
+                       Decode3gCbMsg(pCbMsg, &CbMsgPage);
+               break;
+       }
+
+       // Check CB Msg Options
+       bool bJavaMsg = false;
+
+       if (!checkCbOpt(CbMsgPage, &bJavaMsg))
+       {
+               MSG_DEBUG("The CB Msg is not supported by option.");
+               return;
+       }
+
+       if (bJavaMsg == true)
+       {
+               MSG_DEBUG("JAVA CB Msg.");
+               CbMsgPage.cbMsgType = SMS_CBMSG_TYPE_JAVACBS;
+       }
+
+       // Check CB Pages
+       unsigned char pageCnt = checkCbPage(CbMsgPage);
+
+       if (pageCnt == CbMsgPage.pageHeader.totalPages)
+       {
+               MSG_DEBUG("RECEIVED LAST MSG : %d", pageCnt);
+
+               SMS_CBMSG_S cbMsg = {};
+               MSG_MESSAGE_INFO_S msgInfo = {};
+
+               // Make CB Msg Structure
+               MakeCbMsg(CbMsgPage, &cbMsg);
+
+               // Convert to MSG_MESSAGE_INFO_S
+               convertCbMsgToMsginfo(cbMsg, &msgInfo);
+
+               // Add CB Msg into DB
+               MSG_ERROR_T err = MSG_SUCCESS;
+
+               err = SmsPluginStorage::instance()->addMessage(&msgInfo);
+
+               if (err == MSG_SUCCESS)
+               {
+                       // Callback
+                       err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+
+                       if (err != MSG_SUCCESS)
+                       {
+                               MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+                       }
+               }
+               else
+               {
+                       MSG_DEBUG("addMessage() Error !! [%d]", err);
+               }
+
+               // Remove From List
+               removeFromPageList(CbMsgPage);
+       }
+       MSG_END();
+}
+
+
+void SmsPluginCbMsgHandler::Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_S *pCbPage)
+{
+       if (pCbMsg->Length > MAX_CBMSG_PAGE_SIZE)
+               THROW(MsgException::SMS_PLG_ERROR, "CB Msg Size is over MAX [%d]", pCbMsg->Length);
+
+       unsigned char cbData[pCbMsg->Length+1];
+
+       memset(cbData, 0x00, sizeof(cbData));
+       memcpy(cbData, pCbMsg->szMsgData, pCbMsg->Length);
+       cbData[pCbMsg->Length] = '\0';
+
+       pCbPage->cbMsgType = SMS_CBMSG_TYPE_CBS;
+
+       // Serial Number
+       pCbPage->pageHeader.serialNum.geoScope = (cbData[0] & 0xC0) >> 6;
+
+       pCbPage->pageHeader.serialNum.msgCode = (cbData[0] & 0x3F) << 4;
+       pCbPage->pageHeader.serialNum.msgCode |= (cbData[1] & 0xF0) >> 4;
+
+       pCbPage->pageHeader.serialNum.updateNum = cbData[1] & 0x0F;
+
+MSG_DEBUG("geoScope : [%d], msgCode : [%d], updateNum : [%d]", pCbPage->pageHeader.serialNum.geoScope, pCbPage->pageHeader.serialNum.msgCode, pCbPage->pageHeader.serialNum.updateNum);
+
+       pCbPage->pageHeader.msgId = (cbData[2] << 8) | cbData[3];
+
+MSG_DEBUG("MSG ID : [%d]", pCbPage->pageHeader.msgId);
+
+       // DCS
+       decodeCbMsgDCS(cbData[4], (unsigned char*)cbData[6], &(pCbPage->pageHeader.dcs));
+
+       // Page Parameter
+       pCbPage->pageHeader.totalPages = cbData[5] & 0x0F;
+       pCbPage->pageHeader.page = (cbData[5] & 0xF0) >> 4;
+
+       if (pCbPage->pageHeader.totalPages > MAX_CBMSG_PAGE_NUM)
+               THROW(MsgException::SMS_PLG_ERROR, "CB Page Count is over MAX[%d]", pCbPage->pageHeader.totalPages);
+
+MSG_DEBUG("Total Page : [%d], Page : [%d]", pCbPage->pageHeader.totalPages, pCbPage->pageHeader.page);
+
+       // Convert Language Type
+       convertLangType(pCbPage->pageHeader.dcs.langType, &(pCbPage->pageHeader.langType));
+
+MSG_DEBUG("In Language Type : [%d], Out Language Type : [%d]", pCbPage->pageHeader.dcs.langType, pCbPage->pageHeader.langType);
+
+       // Get Receive Time
+       pCbPage->pageHeader.recvTime = getRecvTime();
+
+       // Decode CB Data
+       int dataLen = pCbMsg->Length - 6;
+
+       switch (pCbPage->pageHeader.dcs.codingScheme)
+       {
+               case SMS_CHARSET_7BIT :
+               {
+                       MSG_DEBUG("GSM 7 BIT");
+
+                       dataLen = (dataLen*8) / 7;
+
+                       SmsPluginUDCodec udCodec;
+                       int unpackLen = udCodec.unpack7bitChar(&cbData[6], dataLen, 0, pCbPage->pageData);
+
+MSG_DEBUG("dataLen : [%d]", dataLen);
+MSG_DEBUG("unpackLen : [%d]", unpackLen);
+
+                       pCbPage->pageLength = unpackLen;
+                       pCbPage->pageData[unpackLen] = '\0';
+
+               }
+               break;
+
+               case SMS_CHARSET_8BIT :
+               case SMS_CHARSET_UCS2 :
+               {
+                       MSG_DEBUG("UCS2");
+
+                       memcpy(pCbPage->pageData, &cbData[6], dataLen);
+
+                       pCbPage->pageLength = strlen(pCbPage->pageData);
+
+                       pCbPage->pageData[pCbPage->pageLength] = '\0';
+               }
+               break;
+       }
+
+MSG_DEBUG("Page Length : [%d], Page Data : [%s]", pCbPage->pageLength, pCbPage->pageData);
+}
+
+
+void SmsPluginCbMsgHandler::Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_S *pCbPage)
+{
+       if (pCbMsg->Length > (MAX_CBMSG_PAGE_SIZE*MAX_CBMSG_PAGE_NUM))
+               THROW(MsgException::SMS_PLG_ERROR, "CB Msg Size is over MAX [%d]", pCbMsg->Length);
+
+       char cbData[(MAX_CBMSG_PAGE_SIZE*MAX_CBMSG_PAGE_NUM)+1];
+
+       memset(cbData, 0x00, sizeof(cbData));
+       memcpy(cbData, pCbMsg->szMsgData, pCbMsg->Length);
+       cbData[pCbMsg->Length] = '\0';
+
+       pCbPage->cbMsgType = (SMS_CBMSG_TYPE_T)cbData[0];
+
+       pCbPage->pageHeader.msgId = (cbData[1] << 8) | cbData[2];
+
+MSG_DEBUG("MSG ID : [%d]", pCbPage->pageHeader.msgId);
+
+       // Serial Number
+       pCbPage->pageHeader.serialNum.geoScope = (cbData[3] & 0xC0) >> 6;
+
+       pCbPage->pageHeader.serialNum.msgCode = (cbData[3] & 0x3F) << 4;
+       pCbPage->pageHeader.serialNum.msgCode |= (cbData[4] & 0xF0) >> 4;
+
+       pCbPage->pageHeader.serialNum.updateNum = cbData[4] & 0x0F;
+
+MSG_DEBUG("geoScope : [%d], msgCode : [%d], updateNum : [%d]", pCbPage->pageHeader.serialNum.geoScope, pCbPage->pageHeader.serialNum.msgCode, pCbPage->pageHeader.serialNum.updateNum);
+
+       // DCS
+       decodeCbMsgDCS(cbData[5], (unsigned char*)cbData[6], &(pCbPage->pageHeader.dcs));
+
+       // Convert Language Type
+       convertLangType(pCbPage->pageHeader.dcs.langType, &(pCbPage->pageHeader.langType));
+
+MSG_DEBUG("In Language Type : [%d], Out Language Type : [%d]", pCbPage->pageHeader.dcs.langType, pCbPage->pageHeader.langType);
+
+       // Get Receive Time
+       pCbPage->pageHeader.recvTime = getRecvTime();
+
+}
+
+
+bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S CbPage, bool *pJavaMsg)
+{
+       bool bReceive = false;
+       MsgSettingGetBool(CB_RECEIVE, &bReceive);
+
+       // Receive CB Msg = FALSE
+       if (!bReceive)
+       {
+               MSG_DEBUG("RECEIVE CB = FALSE");
+               return false;
+       }
+
+       char keyName[128];
+
+       // check Language
+       memset(keyName, 0x00, sizeof(keyName));
+       sprintf(keyName, "%s/%d", CB_LANGUAGE, MSG_CBLANG_TYPE_ALL);
+
+       bool bAllLang = false;
+       MsgSettingGetBool(keyName, &bAllLang);
+
+       if (!bAllLang)
+       {
+               MSG_DEBUG("ALL LANGUAGE = FALSE");
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_LANGUAGE, CbPage.pageHeader.langType);
+
+               bool bLang = false;
+
+               MsgSettingGetBool(keyName, &bLang);
+
+               if (!bLang || CbPage.pageHeader.langType == MSG_CBLANG_TYPE_MAX)
+               {
+                       MSG_DEBUG("LANGUAGE [%d] = FALSE", CbPage.pageHeader.langType);
+                       return false;
+               }
+       }
+
+       bool bAllChannel = false;
+       MsgSettingGetBool(CB_ALL_CHANNEL, &bAllChannel);
+
+       // Receive All Channel = FALSE
+       if (!bAllChannel)
+       {
+               MSG_DEBUG("RECEIVE ALL CHANNEL = FALSE");
+
+               int MsgIdCnt = MsgSettingGetInt(CB_CHANNEL_COUNT);
+
+               bool bActivate = false;
+               int MsgId = 0;
+
+               for (int i = 0; i < MsgIdCnt; i++)
+               {
+                       memset(keyName, 0x00, sizeof(keyName));
+                       sprintf(keyName, "%s/%d", CB_CHANNEL_ACTIVATE, i);
+
+                       MsgSettingGetBool(keyName, &bActivate);
+
+                       memset(keyName, 0x00, sizeof(keyName));
+                       sprintf(keyName, "%s/%d", CB_CHANNEL_ID, i);
+
+                       MsgId = MsgSettingGetInt(keyName);
+
+                       if (bActivate == true && CbPage.pageHeader.msgId == MsgId)
+                       {
+                               MSG_DEBUG("FIND CHANNEL = [%d]", MsgId);
+                               return true;
+                       }
+               }
+       }
+       else    // Receive All Channel = TRUE
+       {
+               MSG_DEBUG("RECEIVE ALL CHANNEL = TRUE");
+               return true;
+       }
+
+       return false;
+}
+
+
+unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S CbPage)
+{
+       unsigned char currPageCnt = 0;
+
+       bool bFind = false;
+
+       if (CbPage.pageHeader.totalPages > 1)
+       {
+               for (unsigned int i = 0; i < pageList.size(); i++)
+               {
+                       if (pageList[i].geoScope == CbPage.pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage.pageHeader.serialNum.msgCode)
+                       {
+                               MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[i].geoScope, pageList[i].msgCode);
+
+                               if (pageList[i].msgId == CbPage.pageHeader.msgId)
+                               {
+                                       int updateNum = CbPage.pageHeader.serialNum.updateNum - pageList[i].updateNum;
+
+                                       if (updateNum > 0) // New Message Content
+                                       {
+                                               break;
+                                       }
+                                       else if (updateNum == 0) // Same Message Content
+                                       {
+                                               if (pageList[i].data.count(CbPage.pageHeader.page) != 0)
+                                               {
+                                                       MSG_DEBUG("The Page Number already exists [%d]", CbPage.pageHeader.page);
+                                                       return 0;
+                                               }
+
+                                               pair<unsigned char, string> newData(CbPage.pageHeader.page, CbPage.pageData);
+                                               pageList[i].data.insert(newData);
+
+                                               MSG_DEBUG("PAGE DATA : %s", CbPage.pageData);
+                                               MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.c_str());
+
+                                               pageList[i].pageCnt++;
+                                               pageList[i].totalSize += CbPage.pageLength;
+
+                                               currPageCnt = pageList[i].pageCnt;
+
+                                               bFind = true;
+
+                                               break;
+                                       }
+                                       else // Old Message Content
+                                       {
+                                               return 0;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       if (bFind == false || CbPage.pageHeader.totalPages == 1)
+       {
+               addToPageLiat(CbPage);
+               return 1;
+       }
+
+       return currPageCnt;
+}
+
+
+void SmsPluginCbMsgHandler::MakeCbMsg(SMS_CBMSG_PAGE_S CbPage, SMS_CBMSG_S *pCbMsg)
+{
+       pCbMsg->cbMsgType = CbPage.cbMsgType;
+       pCbMsg->msgId = CbPage.pageHeader.msgId;
+       pCbMsg->classType = CbPage.pageHeader.dcs.classType;
+       pCbMsg->codingScheme = CbPage.pageHeader.dcs.codingScheme;
+       pCbMsg->recvTime = CbPage.pageHeader.recvTime;
+
+       cbPageMap::iterator it;
+       string tmpStr ("");
+
+       for (unsigned int i = 0; i < pageList.size(); i++)
+       {
+               if (pageList[i].geoScope == CbPage.pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage.pageHeader.serialNum.msgCode)
+               {
+                       MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[i].geoScope, pageList[i].msgCode);
+
+                       if (pageList[i].msgId == CbPage.pageHeader.msgId)
+                       {
+                               for (it = pageList[i].data.begin(); it != pageList[i].data.end(); it++)
+                               {
+                                       tmpStr += it->second;
+                               }
+                       }
+               }
+       }
+
+       pCbMsg->msgLength = tmpStr.size();
+
+       memcpy(pCbMsg->msgData, tmpStr.c_str(), tmpStr.size());
+       pCbMsg->msgData[tmpStr.size()] = '\0';
+
+       MSG_DEBUG("SIZE : [%d] TOTAL MSG : %s", tmpStr.size(), tmpStr.c_str());
+}
+
+
+void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S cbMsg, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       pMsgInfo->msgId = (MSG_MESSAGE_ID_T)cbMsg.msgId;
+
+       pMsgInfo->folderId = MSG_CBMSGBOX_ID;
+
+       // Convert Type values
+       pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
+
+       if (cbMsg.cbMsgType == SMS_CBMSG_TYPE_CBS)
+               pMsgInfo->msgType.subType = MSG_CB_SMS;
+       else if (cbMsg.cbMsgType == SMS_CBMSG_TYPE_JAVACBS)
+               pMsgInfo->msgType.subType = MSG_JAVACB_SMS;
+
+       switch(cbMsg.classType)
+       {
+               case SMS_MSG_CLASS_0:
+                       pMsgInfo->msgType.classType = MSG_CLASS_0;
+                       break;
+               case SMS_MSG_CLASS_1:
+                       pMsgInfo->msgType.classType = MSG_CLASS_1;
+                       break;
+               case SMS_MSG_CLASS_2:
+                       pMsgInfo->msgType.classType = MSG_CLASS_2;
+                       break;
+               case SMS_MSG_CLASS_3:
+                       pMsgInfo->msgType.classType = MSG_CLASS_3;
+                       break;
+               default:
+                       pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+       }
+
+       pMsgInfo->storageId = MSG_STORAGE_PHONE;
+       pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+       pMsgInfo->bRead = false;
+       pMsgInfo->bProtected = false;
+       pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+       pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
+
+       // Temporary
+       pMsgInfo->nAddressCnt = 1;
+
+       pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
+       pMsgInfo->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_UNKNOWN;
+
+       getDisplayName(cbMsg.msgId, pMsgInfo->addressList[0].addressVal);
+       MSG_DEBUG("%s", pMsgInfo->addressList[0].addressVal);
+
+       pMsgInfo->msgPort.valid = false;
+       pMsgInfo->msgPort.dstPort = 0;
+       pMsgInfo->msgPort.srcPort = 0;
+
+       pMsgInfo->displayTime = cbMsg.recvTime;
+       MSG_DEBUG("recvTime is %s", ctime(&pMsgInfo->displayTime));
+
+       int bufSize = cbMsg.msgLength*2;
+
+       char tmpBuf[bufSize];
+       memset(tmpBuf, 0x00, sizeof(tmpBuf));
+
+       MSG_DEBUG("LENGTH %d CB MSG %s", cbMsg.msgLength, cbMsg.msgData);
+
+       SMS_LANG_INFO_S langInfo = {0};
+
+       langInfo.bSingleShift = false;
+       langInfo.bLockingShift = false;
+
+       // Convert Data values
+       if (cbMsg.codingScheme == SMS_CHARSET_7BIT)
+               pMsgInfo->dataSize = SmsPluginTextConvert::instance()->convertGSM7bitToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)cbMsg.msgData, cbMsg.msgLength, &langInfo);
+       else if (cbMsg.codingScheme == SMS_CHARSET_UCS2)
+               pMsgInfo->dataSize = SmsPluginTextConvert::instance()->convertUCS2ToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)cbMsg.msgData, cbMsg.msgLength);
+
+       if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN)
+       {
+               pMsgInfo->bTextSms = false;
+
+               // Save Message Data into File
+               char fileName[MAX_COMMON_INFO_SIZE+1];
+               memset(fileName, 0x00, sizeof(fileName));
+
+               if (MsgCreateFileName(fileName) == false)
+                       THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+
+               MSG_DEBUG("Save Message Data into file : size[%d] name[%s]\n", pMsgInfo->dataSize, fileName);
+               if (MsgWriteIpcFile(fileName, tmpBuf, pMsgInfo->dataSize) == false)
+                       THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+
+               strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
+       }
+       else
+       {
+               pMsgInfo->bTextSms = true;
+
+               memset(pMsgInfo->msgText, 0x00, sizeof(pMsgInfo->msgText));
+               memcpy(pMsgInfo->msgText, tmpBuf, pMsgInfo->dataSize);
+       }
+}
+
+
+void SmsPluginCbMsgHandler::addToPageLiat(SMS_CBMSG_PAGE_S CbPage)
+{
+       CB_PAGE_INFO_S tmpInfo;
+
+       tmpInfo.geoScope = CbPage.pageHeader.serialNum.geoScope;
+       tmpInfo.msgCode = CbPage.pageHeader.serialNum.msgCode;
+       tmpInfo.updateNum = CbPage.pageHeader.serialNum.updateNum;
+       tmpInfo.msgId = CbPage.pageHeader.msgId;
+       tmpInfo.totalPages = CbPage.pageHeader.totalPages;
+
+       tmpInfo.pageCnt = 1;
+       tmpInfo.totalSize = CbPage.pageLength;
+
+       pair<unsigned char, string> newData(CbPage.pageHeader.page, CbPage.pageData);
+       tmpInfo.data.insert(newData);
+
+       MSG_DEBUG("MSG DATA : %s", CbPage.pageData);
+       MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.c_str());
+
+       pageList.push_back(tmpInfo);
+}
+
+
+void SmsPluginCbMsgHandler::removeFromPageList(SMS_CBMSG_PAGE_S CbPage)
+{
+       unsigned int index;
+
+       for (index = 0; index < pageList.size(); index++)
+       {
+               if (pageList[index].geoScope == CbPage.pageHeader.serialNum.geoScope && pageList[index].msgCode == CbPage.pageHeader.serialNum.msgCode)
+               {
+                       MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[index].geoScope, pageList[index].msgCode);
+
+                       if (pageList[index].msgId == CbPage.pageHeader.msgId) break;
+               }
+       }
+
+       MSG_DEBUG("remove index [%d]", index);
+
+       pageList.erase(pageList.begin()+index);
+}
+
+
+void SmsPluginCbMsgHandler::decodeCbMsgDCS(unsigned char dcsData, const unsigned char *pMsgData, SMS_CBMSG_DCS_S* pDcs)
+{
+       pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
+       pDcs->classType = SMS_MSG_CLASS_NONE;
+       pDcs->bCompressed = false;
+       pDcs->codingScheme = SMS_CHARSET_7BIT;
+       pDcs->langType = SMS_CBMSG_LANG_UNSPECIFIED;
+       memset(pDcs->iso639Lang, 0x00, sizeof(pDcs->iso639Lang));
+       pDcs->bUDH = false;
+       pDcs->rawData = dcsData;
+
+       unsigned char codingGrp = (dcsData & 0xF0) >> 4;
+
+       switch (codingGrp)
+       {
+               case 0x00 :
+               case 0x02 :
+               case 0x03 :
+               {
+                       pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
+                       pDcs->langType = (SMS_CBMSG_LANG_TYPE_T)dcsData;
+               }
+               break;
+
+               case 0x01 :
+               {
+                       if (dcsData == 0x10 || dcsData == 0x11)
+                       {
+                               pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
+                               pDcs->codingScheme = (dcsData & 0x01) ? SMS_CHARSET_UCS2 : SMS_CHARSET_7BIT;
+                               pDcs->langType = SMS_CBMSG_LANG_ISO639;
+
+                               if (pMsgData != NULL)
+                               {
+                                       pDcs->iso639Lang[0] = pMsgData[0] & 0x7F;
+                                       pDcs->iso639Lang[1] = (pMsgData[0] & 0x80) >> 7;
+                                       pDcs->iso639Lang[1] |= (pMsgData[1] & 0x3F) << 1;
+                                       pDcs->iso639Lang[2]  = 0x13; /* CR char in GSM 7-bit Alphabet */
+                               }
+                               else
+                               {
+                                       /* Default it to English if pMsgData is NULL */
+                                       pDcs->iso639Lang[0] = 0x45;  /* E */
+                                       pDcs->iso639Lang[1] = 0x4E;  /* N */
+                                       pDcs->iso639Lang[2] = 0x13;  /* CR */
+                               }
+                       }
+               }
+               break;
+
+               case 0x04 :
+               case 0x05 :
+               case 0x06 :
+               case 0x07 :
+               {
+                       pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
+
+                       pDcs->bCompressed = (dcsData & 0x20) ? true : false;
+
+                       if (dcsData & 0x10)
+                               pDcs->classType = (SMS_MSG_CLASS_T)(dcsData & 0x03);
+
+                       pDcs->codingScheme = (SMS_CODING_SCHEME_T)(dcsData & 0x0C);
+               }
+               break;
+
+               case 0x09 :
+               {
+                       pDcs->bUDH = true;
+               }
+               break;
+
+               case 0x14 :
+               {
+                       pDcs->codingGroup = SMS_CBMSG_CODGRP_WAP;
+               }
+               break;
+
+               case 0x15 :
+               {
+                       pDcs->codingGroup = SMS_CBMSG_CODGRP_CLASS_CODING;
+                       pDcs->codingScheme = (dcsData & 0x04) ? SMS_CHARSET_UCS2 : SMS_CHARSET_7BIT;
+                       pDcs->classType = (MSG_CLASS_TYPE_T)(dcsData & 0x03);
+               }
+               break;
+       }
+}
+
+
+void SmsPluginCbMsgHandler::convertLangType(SMS_CBMSG_LANG_TYPE_T InType , MSG_CB_LANGUAGE_TYPE_T *pOutType)
+{
+       switch (InType)
+       {
+               case SMS_CBMSG_LANG_GERMAN :
+                       *pOutType = MSG_CBLANG_TYPE_GER;
+               break;
+
+               case SMS_CBMSG_LANG_ENGLISH :
+                       *pOutType = MSG_CBLANG_TYPE_ENG;
+               break;
+
+               case SMS_CBMSG_LANG_ITALIAN :
+                       *pOutType = MSG_CBLANG_TYPE_ITA;
+               break;
+
+               case SMS_CBMSG_LANG_FRENCH :
+                       *pOutType = MSG_CBLANG_TYPE_FRE;
+               break;
+
+               case SMS_CBMSG_LANG_SPANISH :
+                       *pOutType = MSG_CBLANG_TYPE_SPA;
+               break;
+
+               case SMS_CBMSG_LANG_DUTCH :
+                       *pOutType = MSG_CBLANG_TYPE_NED;
+               break;
+
+               case SMS_CBMSG_LANG_SWEDISH :
+                       *pOutType = MSG_CBLANG_TYPE_SWE;
+               break;
+
+               case SMS_CBMSG_LANG_PORTUGUESE :
+                       *pOutType = MSG_CBLANG_TYPE_POR;
+               break;
+
+               case SMS_CBMSG_LANG_TURKISH :
+                       *pOutType = MSG_CBLANG_TYPE_TUR;
+               break;
+
+               default :
+                       *pOutType = MSG_CBLANG_TYPE_MAX;
+               break;
+       }
+}
+
+
+unsigned long SmsPluginCbMsgHandler::getRecvTime()
+{
+       time_t recvTime;
+
+       recvTime = time(NULL);
+
+       return (unsigned long)recvTime;
+}
+
+
+void SmsPluginCbMsgHandler::getDisplayName(unsigned short      MsgId, char *pDisplayName)
+{
+       int MsgIdCnt = MsgSettingGetInt(CB_CHANNEL_COUNT);
+
+       char keyName[128];
+       char strTmp[CB_CHANNEL_NAME_MAX+1];
+
+       for (int i = 0; i < MsgIdCnt; i++)
+       {
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_CHANNEL_ID, i);
+
+               if (MsgId == MsgSettingGetInt(keyName))
+               {
+                       char *channelName = NULL;
+                       MSG_DEBUG("FIND MSG ID = [%d]", MsgId);
+
+                       memset(keyName, 0x00, sizeof(keyName));
+                       sprintf(keyName, "%s/%d", CB_CHANNEL_NAME, i);
+
+                       memset(strTmp, 0x00, sizeof(strTmp));
+
+                       channelName = MsgSettingGetString(keyName);
+
+                       strncpy(strTmp, channelName, CB_CHANNEL_NAME_MAX);
+
+                       if (channelName) {
+                               free(channelName);
+                               channelName = NULL;
+                       }
+
+                       if (strlen(strTmp) > 0)
+                               sprintf(pDisplayName, "[%s]", strTmp);
+                       else
+                               sprintf(pDisplayName, "[%d]", MsgId);
+
+                       return;
+               }
+       }
+
+       sprintf(pDisplayName, "[%d]", MsgId);
+}
+
diff --git a/plugin/sms_plugin/SmsPluginConcatHandler.cpp b/plugin/sms_plugin/SmsPluginConcatHandler.cpp
new file mode 100755 (executable)
index 0000000..edab5c3
--- /dev/null
@@ -0,0 +1,402 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgUtilFile.h"
+#include "SmsPluginTextConvert.h"
+#include "SmsPluginStorage.h"
+#include "SmsPluginTransport.h"
+#include "SmsPluginEventHandler.h"
+#include "SmsPluginWapPushHandler.h"
+#include "SmsPluginConcatHandler.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginConcatHandler - Member Functions
+==================================================================================================*/
+SmsPluginConcatHandler* SmsPluginConcatHandler::pInstance = NULL;
+
+
+SmsPluginConcatHandler::SmsPluginConcatHandler()
+{
+       concatList.clear();
+}
+
+
+SmsPluginConcatHandler::~SmsPluginConcatHandler()
+{
+       concatList.clear();
+}
+
+
+SmsPluginConcatHandler* SmsPluginConcatHandler::instance()
+{
+       if (!pInstance)
+               pInstance = new SmsPluginConcatHandler();
+
+       return pInstance;
+}
+
+
+bool SmsPluginConcatHandler::IsConcatMsg(SMS_USERDATA_S *pUserData)
+{
+       MSG_BEGIN();
+
+       MSG_DEBUG("headerCnt [%d]", pUserData->headerCnt);
+
+       for (int i = 0; i < pUserData->headerCnt; i++) {
+               /**  Handler Concatenated Message */
+               if (pUserData->header[i].udhType == SMS_UDH_CONCAT_8BIT) {
+                       return true;
+               } else if (pUserData->header[i].udhType == SMS_UDH_CONCAT_16BIT) {
+                       return true;
+               }
+       }
+
+       MSG_END();
+
+       return false;
+}
+
+
+void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+       bool noneConcatTypeHeader = true;
+
+       if (pTpdu->tpduType != SMS_TPDU_DELIVER) {
+               MSG_DEBUG("The TPDU type is not deliver [%d]", pTpdu->tpduType);
+               return;
+       }
+
+       SMS_CONCAT_MSG_S msg = {0};
+
+       for (int i = 0; i < pTpdu->data.deliver.userData.headerCnt; i++) {
+               if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT) {
+                       msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat8bit.msgRef;
+                       msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat8bit.totalSeg;
+                       msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat8bit.seqNum;
+
+                       memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
+                       memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_ADDRESS_S));
+                       memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_DCS_S));
+
+                       if (msg.totalSeg > MAX_SEGMENT_NUM) {
+                               MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
+                               return;
+                       }
+
+                       /**  check noneConcatTypeHeader */
+                       noneConcatTypeHeader = false;
+
+                       break;
+               } else if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
+                       msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat16bit.msgRef;
+                       msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat16bit.totalSeg;
+                       msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat16bit.seqNum;
+
+                       memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
+                       memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_ADDRESS_S));
+                       memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_DCS_S));
+
+                       if (msg.totalSeg > MAX_SEGMENT_NUM) {
+                               MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
+                               return;
+                       }
+
+                       /**  check noneConcatTypeHeader */
+                       noneConcatTypeHeader = false;
+
+                       break;
+               }
+       }
+
+       unsigned char segCnt = checkConcatMsg(&msg, &(pTpdu->data.deliver.userData));
+
+       MSG_DEBUG("segCnt [%d]", segCnt);
+       MSG_DEBUG("msg.totalSeg [%d]", msg.totalSeg);
+
+       if ((segCnt == msg.totalSeg) || noneConcatTypeHeader) {
+               MSG_DEBUG("RECEIVED LAST CONCAT : %d", segCnt);
+
+               int dataSize = 0;
+               char* pUserData = NULL;
+               AutoPtr<char> dataBuf(&pUserData);
+
+               MSG_MESSAGE_INFO_S msgInfo = {0};
+
+               dataSize = makeConcatUserData(msg.msgRef, &pUserData);
+
+               if (dataSize > 0) {
+                       if (SmsPluginWapPushHandler::instance()->IsWapPushMsg(&(pTpdu->data.deliver.userData)) == true) {
+                               SmsPluginWapPushHandler::instance()->copyDeliverData(&(pTpdu->data.deliver));
+                               SmsPluginWapPushHandler::instance()->handleWapPushMsg(pUserData, dataSize);
+                       } else {
+                               convertConcatToMsginfo(&(pTpdu->data.deliver), pUserData, dataSize, &msgInfo);
+
+                               if (msgInfo.msgPort.valid == false) {
+                                       /** Add Concat Msg into DB */
+                                       err = SmsPluginStorage::instance()->addMessage(&msgInfo);
+                               }
+
+                               if (err == MSG_SUCCESS) {
+                                       /** Callback */
+                                       err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+
+                                       if (err != MSG_SUCCESS) {
+                                               MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+                                       }
+                               } else {
+                                       MSG_DEBUG("addMessage() Error !! [%d]", err);
+                               }
+                       }
+               }
+
+               removeFromConcatList(msg.msgRef);
+       }
+
+       /** Send Deliver Report */
+       SmsPluginTransport::instance()->sendDeliverReport(err);
+
+       MSG_END();
+}
+
+
+unsigned char SmsPluginConcatHandler::checkConcatMsg(SMS_CONCAT_MSG_S *pConcatMsg, SMS_USERDATA_S *pUserData)
+{
+       if (pConcatMsg == NULL || pUserData == NULL) {
+               MSG_DEBUG("In Parameter is NULL");
+               return 0;
+       }
+
+       unsigned char currSegCnt = 0;
+
+       bool bFind = false;
+
+       for (unsigned int i = 0; i < concatList.size(); i++) {
+               if (concatList[i].msgRef == pConcatMsg->msgRef) {
+                       if (concatList[i].data.count(pConcatMsg->seqNum) != 0) {
+                               MSG_DEBUG("The Sequence Number already exists [%d]", pConcatMsg->seqNum);
+                               return 0;
+                       }
+
+                       CONCAT_DATA_S concatData = {0};
+
+                       memcpy(concatData.data, pUserData->data, pUserData->length);
+                       concatData.length = pUserData->length;
+
+                       pair<unsigned char, CONCAT_DATA_S> newData(pConcatMsg->seqNum, concatData);
+                       concatList[i].data.insert(newData);
+
+                       MSG_DEBUG("MSG DATA : %s", pUserData->data);
+                       MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.data);
+
+                       concatList[i].segCnt++;
+                       concatList[i].totalSize += pUserData->length;
+
+                       currSegCnt = concatList[i].segCnt;
+
+                       bFind = true;
+
+                       break;
+               }
+       }
+
+       /** New Concat Msg */
+       if (bFind == false) {
+               SMS_CONCAT_INFO_S tmpInfo;
+
+               tmpInfo.msgRef = pConcatMsg->msgRef;
+               tmpInfo.totalSeg = pConcatMsg->totalSeg;
+               tmpInfo.segCnt = 1;
+
+               memcpy(&(tmpInfo.timeStamp.time.absolute), &(pConcatMsg->timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
+               memcpy(&(tmpInfo.originAddress), &(pConcatMsg->originAddress), sizeof(SMS_ADDRESS_S));
+               memcpy(&(tmpInfo.dcs), &(pConcatMsg->dcs), sizeof(SMS_DCS_S));
+
+               tmpInfo.totalSize = pUserData->length;
+
+               CONCAT_DATA_S concatData = {0};
+
+               memcpy(concatData.data, pUserData->data, pUserData->length);
+               concatData.length = pUserData->length;
+
+               pair<unsigned char, CONCAT_DATA_S> newData(pConcatMsg->seqNum, concatData);
+               tmpInfo.data.insert(newData);
+
+               MSG_DEBUG("MSG DATA : %s", pUserData->data);
+               MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.data);
+
+               concatList.push_back(tmpInfo);
+
+               currSegCnt = tmpInfo.segCnt;
+       }
+
+       return currSegCnt;
+}
+
+
+int SmsPluginConcatHandler::makeConcatUserData(unsigned short MsgRef, char **ppTotalData)
+{
+       concatDataMap::iterator it;
+
+       int totalSize = 0, offset = 0;
+
+       for (unsigned int i = 0; i < concatList.size(); i++) {
+               if (concatList[i].msgRef == MsgRef) {
+                       totalSize = concatList[i].totalSize;
+
+                       if (totalSize <= 0) {
+                               MSG_DEBUG("Size Error : totalSize <= 0");
+                               return 0;
+                       }
+
+                       MSG_DEBUG("totalSize [%d]", totalSize);
+
+                       *ppTotalData = new char[totalSize];
+
+                       for (it = concatList[i].data.begin(); it != concatList[i].data.end(); it++) {
+                               memcpy(*ppTotalData+offset, it->second.data, it->second.length);
+                               offset += it->second.length;
+                       }
+               }
+       }
+
+       return totalSize;
+}
+
+
+void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_DELIVER_S *pTpdu, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       /** Convert Type  values */
+       pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
+       pMsgInfo->msgType.subType = MSG_NORMAL_SMS;
+
+       /** set folder id (temporary) */
+       pMsgInfo->folderId = MSG_INBOX_ID;
+
+       switch(pTpdu->dcs.msgClass)
+       {
+               case SMS_MSG_CLASS_0:
+                       pMsgInfo->msgType.classType = MSG_CLASS_0;
+                       break;
+               case SMS_MSG_CLASS_1:
+                       pMsgInfo->msgType.classType = MSG_CLASS_1;
+                       break;
+               case SMS_MSG_CLASS_2:
+                       pMsgInfo->msgType.classType = MSG_CLASS_2;
+                       break;
+               case SMS_MSG_CLASS_3:
+                       pMsgInfo->msgType.classType = MSG_CLASS_3;
+                       break;
+               default:
+                       pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+       }
+
+       pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+       pMsgInfo->bRead = false;
+       pMsgInfo->bProtected = false;
+       pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+       pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
+
+
+       time_t rawtime = time(NULL);
+
+       pMsgInfo->displayTime = rawtime;
+
+       /** Convert Address values */
+       pMsgInfo->nAddressCnt = 1;
+       pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+       strncpy(pMsgInfo->addressList[0].addressVal, pTpdu->originAddress.address, MAX_ADDRESS_VAL_LEN);
+
+       pMsgInfo->msgPort.valid = false;
+       pMsgInfo->msgPort.dstPort = 0;
+       pMsgInfo->msgPort.srcPort = 0;
+
+       for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
+               /** Convert UDH values - Port Number */
+               if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
+                       pMsgInfo->msgPort.valid = true;
+                       pMsgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
+                       pMsgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
+               } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
+                       pMsgInfo->msgPort.valid = true;
+                       pMsgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
+                       pMsgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
+               }
+       }
+
+       int bufSize = (MAX_MSG_DATA_LEN*MAX_SEGMENT_NUM) + 1;
+
+       char tmpBuf[bufSize];
+       memset(tmpBuf, 0x00, sizeof(tmpBuf));
+
+       /** Convert Data values */
+       if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
+               SMS_LANG_INFO_S langInfo = {0};
+
+               langInfo.bSingleShift = false;
+               langInfo.bLockingShift = false;
+
+               pMsgInfo->encodeType = MSG_ENCODE_GSM7BIT;
+               pMsgInfo->dataSize = SmsPluginTextConvert::instance()->convertGSM7bitToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize, &langInfo);
+       } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_8BIT) {
+               pMsgInfo->encodeType = MSG_ENCODE_8BIT;
+               memcpy(tmpBuf, pUserData, DataSize);
+               pMsgInfo->dataSize = DataSize;
+       } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
+               pMsgInfo->encodeType = MSG_ENCODE_UCS2;
+               pMsgInfo->dataSize = SmsPluginTextConvert::instance()->convertUCS2ToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize);
+       }
+
+       MSG_DEBUG("Data Size [%d]", pMsgInfo->dataSize);
+       MSG_DEBUG("Data [%s]", tmpBuf);
+
+       if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN) {
+               pMsgInfo->bTextSms = false;
+
+               /** Save Message Data into File */
+               char fileName[MAX_COMMON_INFO_SIZE+1];
+               memset(fileName, 0x00, sizeof(fileName));
+
+               MsgCreateFileName(fileName);
+
+               MSG_DEBUG("Save Message Data into file : size[%d] name[%s]\n", pMsgInfo->dataSize, fileName);
+               MsgWriteIpcFile(fileName, tmpBuf, pMsgInfo->dataSize);
+
+               strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
+       } else {
+               pMsgInfo->bTextSms = true;
+
+               memset(pMsgInfo->msgText, 0x00, sizeof(pMsgInfo->msgText));
+               memcpy(pMsgInfo->msgText, tmpBuf, pMsgInfo->dataSize);
+       }
+}
+
+
+void SmsPluginConcatHandler::removeFromConcatList(unsigned short MsgRef)
+{
+       for (int index = concatList.size(); index >= 0 ; index--) {
+               if (concatList[index].msgRef == MsgRef) {
+                       MSG_DEBUG("remove concatlist of the index [%d]", index);
+                       concatList.erase(concatList.begin()+index);
+                       break;
+               }
+       }
+}
diff --git a/plugin/sms_plugin/SmsPluginEventHandler.cpp b/plugin/sms_plugin/SmsPluginEventHandler.cpp
new file mode 100755 (executable)
index 0000000..ec24fd6
--- /dev/null
@@ -0,0 +1,723 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include<time.h>
+#include<stdio.h>
+#include<stdlib.h>
+#include <errno.h>
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "SmsPluginTextConvert.h"
+#include "SmsPluginTransport.h"
+#include "SmsPluginSimMsg.h"
+#include "SmsPluginStorage.h"
+#include "SmsPluginConcatHandler.h"
+#include "SmsPluginEventHandler.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginEventHandler - Member Functions
+==================================================================================================*/
+SmsPluginEventHandler* SmsPluginEventHandler::pInstance = NULL;
+
+
+SmsPluginEventHandler::SmsPluginEventHandler()
+{
+       /**  Initialize global parameters */
+       memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S));
+
+       pSimCnt = NULL;
+       devStatus = false;
+}
+
+
+SmsPluginEventHandler::~SmsPluginEventHandler()
+{
+
+}
+
+
+SmsPluginEventHandler* SmsPluginEventHandler::instance()
+{
+       if (!pInstance)
+               pInstance = new SmsPluginEventHandler();
+
+       return pInstance;
+}
+
+
+void SmsPluginEventHandler::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
+{
+       listener = *pListener;
+}
+
+
+void SmsPluginEventHandler::handleSentStatus(int TapiReqId, MSG_NETWORK_STATUS_T NetStatus)
+{
+       MSG_DEBUG("TapiReqId [%d], NetStatus[%d]", TapiReqId, NetStatus);
+
+       SmsPluginTransport::instance()->setNetStatus(NetStatus);
+
+       if (sentInfo.bLast == true || NetStatus != MSG_NETWORK_SEND_SUCCESS) {
+               /** Update Msg Status */
+               if (sentInfo.reqInfo.msgInfo.msgPort.valid == false){
+                       SmsPluginStorage::instance()->updateSentMsg(&(sentInfo.reqInfo.msgInfo), NetStatus);
+                       sentInfo.reqInfo.msgInfo.networkStatus = NetStatus;
+                       callbackStorageChange(MSG_STORAGE_CHANGE_UPDATE, &(sentInfo.reqInfo.msgInfo));
+               }
+
+               MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bSetting [%d]", sentInfo.reqInfo.sendOptInfo.bSetting);
+               MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bKeepCopy [%d]", sentInfo.reqInfo.sendOptInfo.bKeepCopy);
+               /** Check sending options */
+               if (sentInfo.reqInfo.sendOptInfo.bSetting && !sentInfo.reqInfo.sendOptInfo.bKeepCopy && NetStatus == MSG_NETWORK_SEND_SUCCESS) {
+                       SmsPluginStorage::instance()->deleteSmsMessage(sentInfo.reqInfo.msgInfo.msgId);
+                       callbackStorageChange(MSG_STORAGE_CHANGE_DELETE, &(sentInfo.reqInfo.msgInfo));
+               }
+
+               /** Callback to MSG FW */
+               if (sentInfo.reqInfo.bReqCb == true || NetStatus != MSG_NETWORK_SEND_SUCCESS) {
+                       MSG_SENT_STATUS_S msgStatus;
+
+                       msgStatus.reqId = sentInfo.reqInfo.reqId;
+                       msgStatus.status = NetStatus;
+
+                       MSG_DEBUG("sentStatus.reqId : %d", msgStatus.reqId);
+                       MSG_DEBUG("sentStatus.status : %d", msgStatus.status);
+
+                       listener.pfSentStatusCb(&msgStatus);
+               }
+       }
+}
+
+
+void SmsPluginEventHandler::handleMsgIncoming(SMS_TPDU_S *pTpdu)
+{
+       /** Make MSG_MESSAGE_INFO_S */
+       MSG_MESSAGE_INFO_S msgInfo;
+
+       /** initialize msgInfo */
+       memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+       /** convert to msgInfo */
+       convertTpduToMsginfo(pTpdu, &msgInfo);
+
+       /** Short Message Type 0 - Just Send Deliver Report */
+       if (msgInfo.msgType.subType == MSG_TYPE0_SMS) {
+               SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS);
+               return;
+       }
+
+       /** Print MSG_MESSAGE_INFO_S */
+       MSG_DEBUG("############# Convert  tpdu values to Message Info values ####################");
+       MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
+       MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
+       MSG_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
+       MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
+       MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
+       MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
+       MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
+       MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
+       MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
+       MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
+       MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
+       MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
+       MSG_DEBUG("msgInfo.msgPort.valid : %d", msgInfo.msgPort.valid);
+       MSG_DEBUG("msgInfo.encodeType : %d", msgInfo.encodeType);
+       MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
+
+       if (msgInfo.bTextSms == true) {
+               MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
+       } else {
+               MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
+       }
+
+       MSG_DEBUG("###############################################################");
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       /** Update Status in Report Table */
+       if (msgInfo.msgType.subType == MSG_STATUS_REPORT_SMS) {
+
+               err = SmsPluginStorage::instance()->addMessage(&msgInfo);
+
+               if (err == MSG_SUCCESS) {
+                       MSG_DEBUG("callback to msg fw");
+                       err = listener.pfMsgIncomingCb(&msgInfo);
+               }
+
+               /** Handling of Fail Case ?? */
+               SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS);
+       } else { /** SMS Deliver */
+               /** Class 2 Msg */
+               if (msgInfo.msgType.classType == MSG_CLASS_2) {
+                       if (msgInfo.bTextSms == false) { /** Concat Msg cannot be saved in SIM */
+                               msgInfo.msgType.classType = MSG_CLASS_NONE;
+                               msgInfo.storageId = MSG_STORAGE_PHONE;
+                       }
+               }
+
+               if (msgInfo.msgPort.valid == false) {
+                       err = SmsPluginStorage::instance()->addMessage(&msgInfo);
+               }
+
+               /** Callback to MSG FW */
+               if (msgInfo.msgType.classType != MSG_CLASS_2) {
+                       if (err == MSG_SUCCESS) {
+                               MSG_DEBUG("callback to msg fw");
+                               err = listener.pfMsgIncomingCb(&msgInfo);
+                       }
+
+                       /** Send Deliver Report */
+                       SmsPluginTransport::instance()->sendDeliverReport(err);
+               }
+       }
+}
+
+
+void SmsPluginEventHandler::handleSyncMLMsgIncoming(MSG_SYNCML_MESSAGE_TYPE_T msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen)
+{
+       MSG_SYNCML_MESSAGE_DATA_S syncMLData;
+
+       memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
+
+       /** set syncML data */
+       syncMLData.syncmlType = msgType;
+
+       syncMLData.pushBodyLen = PushBodyLen;
+       memcpy(syncMLData.pushBody, pPushBody, PushBodyLen);
+
+       syncMLData.wspHeaderLen= WspHeaderLen;
+       memcpy(syncMLData.wspHeader, pWspHeader, WspHeaderLen);
+
+       /** Callback to MSG FW */
+       listener.pfSyncMLMsgIncomingCb(&syncMLData);
+}
+
+
+void SmsPluginEventHandler::handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen)
+{
+       MSG_LBS_MESSAGE_DATA_S lBSData;
+
+       memset(&lBSData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
+
+       /** set LBA data */
+       memcpy(&lBSData.pushHeader, pPushHeader, strlen(pPushHeader));
+
+       lBSData.pushBodyLen = pushBodyLen;
+       memcpy(lBSData.pushBody, pPushBody, pushBodyLen);
+
+       /** Callback to MSG FW */
+       listener.pfLBSMsgIncomingCb(&lBSData);
+}
+
+
+void SmsPluginEventHandler::handleDftSms(MSG_FOLDER_ID_T FolderId, char* pNumber, char* pData)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_MESSAGE_INFO_S msgInfo;
+       memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+       /** Set SMS Type */
+       msgInfo.msgType.mainType = MSG_SMS_TYPE;
+       msgInfo.msgType.subType = MSG_NORMAL_SMS;
+       msgInfo.msgType.classType = MSG_CLASS_NONE;
+
+       /** Set Folder ID */
+       msgInfo.folderId = FolderId;
+
+       msgInfo.networkStatus = MSG_NETWORK_RECEIVED;
+       msgInfo.bRead = false;
+       msgInfo.bProtected = false;
+       msgInfo.priority = MSG_MESSAGE_PRIORITY_NORMAL;
+
+       /** Set SMS Direction */
+       if (FolderId == MSG_INBOX_ID)
+               msgInfo.direction = MSG_DIRECTION_TYPE_MT;
+       else
+               msgInfo.direction = MSG_DIRECTION_TYPE_MO;
+
+       /** Set SMS Time Info */
+       time_t curTime;
+       time(&curTime);
+
+       msgInfo.displayTime = curTime;
+
+       /** Set Address Info */
+       msgInfo.nAddressCnt = 1;
+       msgInfo.addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+
+       if (pNumber != NULL) {
+               strncpy(msgInfo.addressList[0].addressVal, pNumber, MAX_ADDRESS_VAL_LEN);
+       }
+
+       /** Set Port */
+       msgInfo.msgPort.valid = false;
+       msgInfo.msgPort.dstPort = 0;
+       msgInfo.msgPort.srcPort = 0;
+
+       /** Set Subject */
+       memset(msgInfo.subject, 0x00, MAX_SUBJECT_LEN+1);
+
+       /** Set SMS Text */
+       msgInfo.bTextSms = true;
+
+       if (pData != NULL) {
+               strncpy(msgInfo.msgText, pData, MAX_MSG_TEXT_LEN);
+               msgInfo.dataSize = strlen(msgInfo.msgText);
+       } else {
+               memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
+               msgInfo.dataSize = 0;
+       }
+
+       /** Print MSG_MESSAGE_INFO_S */
+       MSG_DEBUG("############# Convert  tpdu values to Message Info values ####################");
+       MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
+       MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
+       MSG_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
+       MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
+       MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
+       MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
+       MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
+       MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
+       MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
+       MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
+       MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
+       MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
+       MSG_DEBUG("msgInfo.msgPort.valid : %d", msgInfo.msgPort.valid);
+       MSG_DEBUG("msgInfo.encodeType : %d", msgInfo.encodeType);
+       MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
+       if (msgInfo.bTextSms == true)
+               MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
+       else
+               MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
+       MSG_DEBUG("###############################################################");
+
+       /** Callback to MSG FW */
+       err = listener.pfMsgIncomingCb(&msgInfo);
+}
+
+
+MSG_ERROR_T SmsPluginEventHandler::callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       /** Callback to MSG FW */
+       err = listener.pfMsgIncomingCb(pMsgInfo);
+
+       MSG_END();
+
+       return err;
+}
+
+
+MSG_ERROR_T SmsPluginEventHandler::callbackInitSimBySat()
+{
+       /** Callback to MSG FW */
+       return listener.pfInitSimBySatCb();
+}
+
+
+MSG_ERROR_T SmsPluginEventHandler::callbackStorageChange(MSG_STORAGE_CHANGE_TYPE_T storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       /** Callback to MSG FW */
+       listener.pfStorageChangeCb(storageChangeType, pMsgInfo);
+}
+
+
+void SmsPluginEventHandler::convertTpduToMsginfo(SMS_TPDU_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
+{
+       memset(msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+       switch(pTpdu->tpduType)
+       {
+               case SMS_TPDU_SUBMIT :
+                       convertSubmitTpduToMsginfo(&pTpdu->data.submit, msgInfo);
+                       break;
+               case SMS_TPDU_DELIVER :
+                       convertDeliverTpduToMsginfo(&pTpdu->data.deliver, msgInfo);
+                       break;
+               case SMS_TPDU_STATUS_REP :
+                       convertStatusRepTpduToMsginfo(&pTpdu->data.statusRep, msgInfo);
+                       break;
+       }
+}
+
+
+void SmsPluginEventHandler::convertSubmitTpduToMsginfo(const SMS_SUBMIT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
+{
+       int addressListCnt = 0;
+
+       /** Convert Type  values */
+       msgInfo->msgType.mainType = MSG_SMS_TYPE;
+       msgInfo->msgType.subType = convertMsgSubType(pTpdu->pid);
+
+       /** set folder id (temporary) */
+       msgInfo->folderId = MSG_OUTBOX_ID;
+
+       switch(pTpdu->dcs.msgClass)
+       {
+               case SMS_MSG_CLASS_0:
+                       msgInfo->msgType.classType = MSG_CLASS_0;
+                       break;
+               case SMS_MSG_CLASS_1:
+                       msgInfo->msgType.classType = MSG_CLASS_1;
+                       break;
+               case SMS_MSG_CLASS_2:
+                       msgInfo->msgType.classType = MSG_CLASS_2;
+                       break;
+               case SMS_MSG_CLASS_3:
+                       msgInfo->msgType.classType = MSG_CLASS_3;
+                       break;
+               default:
+                       msgInfo->msgType.classType = MSG_CLASS_NONE;
+       }
+
+       msgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS;
+       msgInfo->bRead = false;
+       msgInfo->bProtected = false;
+       msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+       msgInfo->direction = MSG_DIRECTION_TYPE_MT;
+       msgInfo->bTextSms = true;
+
+       memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
+
+       /** What kind of time has to be saved?? (temporary store time) */
+
+       time_t curTime;
+       localtime(&curTime);
+
+       msgInfo->displayTime = curTime;
+
+       /** Convert Address values */
+       msgInfo->nAddressCnt = 1;
+       msgInfo->addressList[addressListCnt].addressType = MSG_ADDRESS_TYPE_PLMN;
+       strncpy(msgInfo->addressList[addressListCnt].addressVal, pTpdu->destAddress.address, MAX_ADDRESS_VAL_LEN);
+
+       /**exception operation for none userdata */
+       if (pTpdu->userData.length == 0) {
+               sprintf(msgInfo->msgText, "[Broken Message]");
+               msgInfo->dataSize = strlen(msgInfo->msgText);
+               return;
+       }
+
+       /** Convert Data values */
+       if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
+               SMS_LANG_INFO_S langInfo = {0};
+
+               langInfo.bSingleShift = false;
+               langInfo.bLockingShift = false;
+
+               msgInfo->dataSize = SmsPluginTextConvert::instance()->convertGSM7bitToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length, &langInfo);
+       } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
+               msgInfo->dataSize = SmsPluginTextConvert::instance()->convertUCS2ToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length);
+       }
+}
+
+
+void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
+{
+       /** Convert Type  values */
+       msgInfo->msgType.mainType = MSG_SMS_TYPE;
+       msgInfo->msgType.subType = convertMsgSubType(pTpdu->pid);
+
+       /** set folder id (temporary) */
+       msgInfo->folderId = MSG_INBOX_ID;
+
+       msgInfo->storageId = MSG_STORAGE_PHONE;
+
+       switch(pTpdu->dcs.msgClass)
+       {
+               case SMS_MSG_CLASS_0:
+                       msgInfo->msgType.classType = MSG_CLASS_0;
+                       break;
+               case SMS_MSG_CLASS_1:
+                       msgInfo->msgType.classType = MSG_CLASS_1;
+                       break;
+               case SMS_MSG_CLASS_2:
+                       msgInfo->msgType.classType = MSG_CLASS_2;
+                       msgInfo->storageId = MSG_STORAGE_SIM;
+                       break;
+               case SMS_MSG_CLASS_3:
+                       msgInfo->msgType.classType = MSG_CLASS_3;
+                       break;
+               default:
+                       msgInfo->msgType.classType = MSG_CLASS_NONE;
+       }
+
+       if (pTpdu->dcs.bMWI) {
+               msgInfo->msgType.subType = (pTpdu->dcs.indType + MSG_MWI_VOICE_SMS);
+       }
+
+       msgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+       msgInfo->bRead = false;
+       msgInfo->bProtected = false;
+       msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+       msgInfo->direction = MSG_DIRECTION_TYPE_MT;
+       msgInfo->bTextSms = true;
+
+       memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
+
+       time_t rawtime = time(NULL);
+
+       msgInfo->displayTime = rawtime;
+
+       /** Convert Address values */
+       msgInfo->nAddressCnt = 1;
+       msgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+       strncpy(msgInfo->addressList[0].addressVal, pTpdu->originAddress.address, MAX_ADDRESS_VAL_LEN);
+
+       msgInfo->msgPort.valid = false;
+       msgInfo->msgPort.dstPort = 0;
+       msgInfo->msgPort.srcPort = 0;
+
+       for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
+               /** Convert UDH values - Port Number */
+               if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
+                       msgInfo->msgPort.valid = true;
+                       msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
+                       msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
+               } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
+                       msgInfo->msgPort.valid = true;
+                       msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
+                       msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
+               } else if (pTpdu->userData.header[i].udhType == SMS_UDH_SPECIAL_SMS) {
+                       msgInfo->msgType.subType = (pTpdu->userData.header[i].udh.specialInd.msgInd+MSG_MWI_VOICE_SMS);
+
+                       if (pTpdu->userData.length == 0) {
+                               sprintf(msgInfo->msgText,"[MWI Message] Total %d Message is waiting.", pTpdu->userData.header[i].udh.specialInd.waitMsgNum);
+                               msgInfo->dataSize = strlen(msgInfo->msgText);
+                               return;
+                       }
+
+               } else if (pTpdu->userData.header[i].udhType == SMS_UDH_ALTERNATE_REPLY_ADDRESS) {
+                       strncpy(msgInfo->addressList[0].addressVal, pTpdu->userData.header[i].udh.alternateAddress.address, MAX_ADDRESS_VAL_LEN);
+               }
+       }
+
+       /**length 0 - no user data - msg should be received */
+       if (pTpdu->userData.length <= 0) {
+               memset(msgInfo->msgText, 0x00, sizeof(msgInfo->msgText));
+               msgInfo->dataSize = 0;
+
+               switch(pTpdu->dcs.codingScheme)
+               {
+                       case SMS_CHARSET_7BIT:
+                               msgInfo->encodeType = MSG_ENCODE_GSM7BIT;
+                               break;
+                       case SMS_CHARSET_8BIT:
+                               msgInfo->encodeType = MSG_ENCODE_8BIT;
+                               break;
+                       case SMS_CHARSET_UCS2:
+                               msgInfo->encodeType = MSG_ENCODE_UCS2;
+                               break;
+                       default:
+                               msgInfo->encodeType = MSG_ENCODE_8BIT;
+               }
+
+               return;
+       } else if (pTpdu->userData.length > MAX_MSG_TEXT_LEN) {
+               sprintf(msgInfo->msgText, "[Broken Message]");
+               msgInfo->dataSize = strlen(msgInfo->msgData);
+               return;
+       }
+
+       /** Convert Data values */
+       if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
+               SMS_LANG_INFO_S langInfo = {0};
+
+               langInfo.bSingleShift = false;
+               langInfo.bLockingShift = false;
+
+               for (int i = 0; i < pTpdu->userData.headerCnt; i++)     {
+                       if (pTpdu->userData.header[i].udhType == SMS_UDH_SINGLE_SHIFT) {
+                               langInfo.bSingleShift = true;
+                               langInfo.singleLang = pTpdu->userData.header[i].udh.singleShift.langId;
+                       } else if (pTpdu->userData.header[i].udhType == SMS_UDH_LOCKING_SHIFT) {
+                               langInfo.bLockingShift = true;
+                               langInfo.lockingLang = pTpdu->userData.header[i].udh.lockingShift.langId;
+                       }
+               }
+
+               msgInfo->encodeType = MSG_ENCODE_GSM7BIT;
+               msgInfo->dataSize = SmsPluginTextConvert::instance()->convertGSM7bitToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length, &langInfo);
+       } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_8BIT) {
+               msgInfo->encodeType = MSG_ENCODE_8BIT;
+               memcpy(msgInfo->msgText, pTpdu->userData.data, pTpdu->userData.length);
+               msgInfo->dataSize = pTpdu->userData.length;
+       } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
+               msgInfo->encodeType = MSG_ENCODE_UCS2;
+               msgInfo->dataSize = SmsPluginTextConvert::instance()->convertUCS2ToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length);
+       }
+}
+
+
+void SmsPluginEventHandler::convertStatusRepTpduToMsginfo(const SMS_STATUS_REPORT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
+{
+       /** Convert Type  values */
+       msgInfo->msgType.mainType = MSG_SMS_TYPE;
+       msgInfo->msgType.subType = MSG_STATUS_REPORT_SMS;
+
+       /** set folder id (temporary) */
+       msgInfo->folderId = MSG_INBOX_ID;
+
+       switch(pTpdu->dcs.msgClass)
+       {
+               case SMS_MSG_CLASS_0:
+                       msgInfo->msgType.classType = MSG_CLASS_0;
+                       break;
+               case SMS_MSG_CLASS_1:
+                       msgInfo->msgType.classType = MSG_CLASS_1;
+                       break;
+               case SMS_MSG_CLASS_2:
+                       msgInfo->msgType.classType = MSG_CLASS_2;
+                       break;
+               case SMS_MSG_CLASS_3:
+                       msgInfo->msgType.classType = MSG_CLASS_3;
+                       break;
+               default:
+                       msgInfo->msgType.classType = MSG_CLASS_NONE;
+       }
+
+       MSG_DEBUG("delivery status : [%d]", pTpdu->status);
+
+       if (pTpdu->status == SMS_STATUS_RECEIVE_SUCCESS) {
+               msgInfo->networkStatus = MSG_NETWORK_DELIVER_SUCCESS;
+       } else {
+               msgInfo->networkStatus = MSG_NETWORK_DELIVER_FAIL;
+       }
+
+       msgInfo->bRead = false;
+       msgInfo->bProtected = false;
+       msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+       msgInfo->direction = MSG_DIRECTION_TYPE_MT;
+       msgInfo->bTextSms = true;
+
+       memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
+
+       time_t rawtime = time(NULL);
+
+       msgInfo->displayTime = rawtime;
+
+       /** Convert Address values */
+       msgInfo->nAddressCnt = 1;
+       msgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+       strncpy(msgInfo->addressList[0].addressVal, pTpdu->recipAddress.address, MAX_ADDRESS_VAL_LEN);
+
+       msgInfo->msgPort.valid = false;
+       msgInfo->msgPort.dstPort = 0;
+       msgInfo->msgPort.srcPort = 0;
+
+       for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
+               /** Convert UDH values - Port Number */
+               if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
+                       msgInfo->msgPort.valid = true;
+                       msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
+                       msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
+               } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
+                       msgInfo->msgPort.valid = true;
+                       msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
+                       msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
+               }
+       }
+
+       memset(msgInfo->msgText, 0x00, sizeof(MAX_MSG_TEXT_LEN+1));
+       msgInfo->dataSize = 0;
+
+       if (pTpdu->status <= SMS_STATUS_SMSC_SPECIFIC_LAST) {
+               strncpy(msgInfo->msgText, "Message delivered.", MAX_MSG_TEXT_LEN);
+               msgInfo->dataSize = strlen(msgInfo->msgText);
+       } else if (pTpdu->status == SMS_STATUS_TEMP_SERVICE_REJECTED) {
+               strncpy(msgInfo->msgText, "Message delivery rejected.", MAX_MSG_TEXT_LEN);
+               msgInfo->dataSize = strlen(msgInfo->msgText);
+       } else if (pTpdu->status == SMS_STATUS_PERM_MSG_VAL_PERIOD_EXPIRED) {
+               strncpy(msgInfo->msgText, "Message delivery expired.", MAX_MSG_TEXT_LEN);
+               msgInfo->dataSize = strlen(msgInfo->msgText);
+       } else {
+               strncpy(msgInfo->msgText, "Message delivery failed.", MAX_MSG_TEXT_LEN);
+               msgInfo->dataSize = strlen(msgInfo->msgText);
+       }
+}
+
+
+MSG_SUB_TYPE_T SmsPluginEventHandler::convertMsgSubType(SMS_PID_T pid)
+{
+       switch (pid)
+       {
+               case SMS_PID_TYPE0 :
+                       return MSG_TYPE0_SMS;
+               case SMS_PID_REPLACE_TYPE1 :
+                       return MSG_REPLACE_TYPE1_SMS;
+               case SMS_PID_REPLACE_TYPE2 :
+                       return MSG_REPLACE_TYPE2_SMS;
+               case SMS_PID_REPLACE_TYPE3 :
+                       return MSG_REPLACE_TYPE3_SMS;
+               case SMS_PID_REPLACE_TYPE4 :
+                       return MSG_REPLACE_TYPE4_SMS;
+               case SMS_PID_REPLACE_TYPE5 :
+                       return MSG_REPLACE_TYPE5_SMS;
+               case SMS_PID_REPLACE_TYPE6 :
+                       return MSG_REPLACE_TYPE6_SMS;
+               case SMS_PID_REPLACE_TYPE7 :
+                       return MSG_REPLACE_TYPE7_SMS;
+               case SMS_PID_RETURN_CALL :
+                       return MSG_MWI_OTHER_SMS;
+               default :
+                       return MSG_NORMAL_SMS;
+       }
+
+}
+
+
+void SmsPluginEventHandler::SetSentInfo(SMS_SENT_INFO_S *pSentInfo)
+{
+       memset(&sentInfo, 0x00, sizeof(SMS_SENT_INFO_S));
+       memcpy(&sentInfo, pSentInfo, sizeof(SMS_SENT_INFO_S));
+
+       MSG_DEBUG("sentInfo.reqId : %d", sentInfo.reqInfo.reqId);
+       MSG_DEBUG("sentInfo.bLast : %d", sentInfo.bLast);
+}
+
+
+void SmsPluginEventHandler::setDeviceStatus()
+{
+       mx.lock();
+       devStatus = true;
+       cv.signal();
+       mx.unlock();
+}
+
+
+bool SmsPluginEventHandler::getDeviceStatus()
+{
+       int ret = 0;
+
+       mx.lock();
+
+       ret = cv.timedwait(mx.pMutex(), 10);
+
+       mx.unlock();
+
+       if (ret == ETIMEDOUT) {
+               MSG_DEBUG("WARNING: DEVICE STATUS TIME-OUT");
+               devStatus = false;
+       }
+
+       return devStatus;
+}
diff --git a/plugin/sms_plugin/SmsPluginMain.cpp b/plugin/sms_plugin/SmsPluginMain.cpp
new file mode 100755 (executable)
index 0000000..d068e09
--- /dev/null
@@ -0,0 +1,463 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+
+#include "SmsPluginTransport.h"
+#include "SmsPluginSimMsg.h"
+#include "SmsPluginStorage.h"
+#include "SmsPluginSetting.h"
+#include "SmsPluginCallback.h"
+#include "SmsPluginEventHandler.h"
+#include "SmsPluginUAManager.h"
+#include "SmsPluginMain.h"
+
+extern "C"
+{
+       #include <ITapiSim.h>
+       #include <ITapiNetText.h>
+}
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgPlgCreateHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
+{
+       if (pPluginHandle == NULL)
+       {
+               MSG_DEBUG("SMS plugin: create handler error ");
+               return MSG_ERR_NULL_POINTER;
+       }
+       else
+       {
+               pPluginHandle->pfInitialize = SmsPlgInitialize;
+               pPluginHandle->pfFinalize = SmsPlgFinalize;
+               pPluginHandle->pfRegisterListener = SmsPlgRegisterListener;
+               pPluginHandle->pfCheckSimStatus = SmsPlgCheckSimStatus;
+               pPluginHandle->pfCheckDeviceStatus = SmsPlgCheckDeviceStatus;
+               pPluginHandle->pfSubmitRequest = SmsPlgSubmitRequest;
+               pPluginHandle->pfInitSimMessage = SmsPlgInitSimMessage;
+               pPluginHandle->pfSaveSimMessage = SmsPlgSaveSimMessage;
+               pPluginHandle->pfDeleteSimMessage = SmsPlgDeleteSimMessage;
+               pPluginHandle->pfSetReadStatus = SmsPlgSetReadStatus;
+               pPluginHandle->pfSetMemoryStatus = SmsPlgSetMemoryStatus;
+               pPluginHandle->pfInitConfigData = SmsPlgInitConfigData;
+               pPluginHandle->pfSetConfigData = SmsPlgSetConfigData;
+               pPluginHandle->pfGetConfigData = SmsPlgGetConfigData;
+
+               pPluginHandle->pfRestoreMsg = NULL;
+
+               MSG_DEBUG("SMS plugin: create handler OK");
+               MSG_DEBUG ("SMS plugin %p", pPluginHandle);
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgPlgDestroyHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
+{
+       if (pPluginHandle != NULL)
+       {
+               free(pPluginHandle);
+               pPluginHandle = NULL;
+       }
+
+       MSG_DEBUG("SMS plugin: destory handler OK");
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgInitialize()
+{
+       MSG_BEGIN();
+
+       int tapiRet = TAPI_API_SUCCESS;
+
+       tapiRet = tel_init();
+
+       if (tapiRet != TAPI_API_SUCCESS)
+               return MSG_ERR_PLUGIN_TAPIINIT;
+
+       try
+       {
+               SmsPluginCallback::instance()->registerEvent();
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_REGEVENT;
+       }
+       catch (exception& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_REGEVENT;
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgFinalize()
+{
+       MSG_BEGIN();
+
+       SmsPluginCallback::instance()->deRegisterEvent();
+
+        tel_deinit();
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgRegisterListener(MSG_PLUGIN_LISTENER_S *pListener)
+{
+       MSG_BEGIN();
+
+       SmsPluginEventHandler::instance()->registerListener(pListener);
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgCheckSimStatus(MSG_SIM_STATUS_T *pStatus)
+{
+       MSG_BEGIN();
+
+       int tryNum = 0, tapiRet = TAPI_API_SUCCESS;
+
+       TelSimCardStatus_t status = TAPI_SIM_STATUS_CARD_ERROR;
+       int cardChanged = 0;
+
+       // Check SIM Status
+       while (1)
+       {
+               if (tryNum > 30) return MSG_ERR_PLUGIN_TAPIINIT;
+
+               tapiRet = tel_get_sim_init_info(&status, &cardChanged);
+
+               if (tapiRet == TAPI_API_SUCCESS)
+               {
+                       if (status == TAPI_SIM_STATUS_SIM_PIN_REQUIRED || status == TAPI_SIM_STATUS_SIM_PUK_REQUIRED)
+                       {
+                               MSG_DEBUG("PIN or PUK is required [%d]", status);
+
+                               sleep(3);
+
+                               continue;
+                       }
+
+                       if (status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED)
+                       {
+                               MSG_DEBUG("SIM status is OK [%d]", status);
+
+                               MSG_DEBUG("SIM Changed [%d]", cardChanged);
+
+                               if (cardChanged == 1)
+                                       *pStatus = MSG_SIM_STATUS_CHANGED;
+                               else
+                                       *pStatus = MSG_SIM_STATUS_NORMAL;
+
+                               break;
+                       }
+                       else if (status == TAPI_SIM_STATUS_CARD_NOT_PRESENT)
+                       {
+                               MSG_DEBUG("SIM is not present [%d]", status);
+
+                               *pStatus = MSG_SIM_STATUS_NOT_FOUND;
+
+                               break;
+                       }
+                       else
+                       {
+                               MSG_DEBUG("SIM status is not OK [%d]", status);
+
+                               tryNum++;
+
+                               sleep(3);
+                       }
+               }
+               else if (tapiRet == TAPI_API_SIM_NOT_FOUND)
+               {
+                       MSG_DEBUG("tel_get_sim_init_info() result is TAPI_API_SIM_NOT_FOUND");
+
+                       *pStatus = MSG_SIM_STATUS_NOT_FOUND;
+
+                       break;
+               }
+               else
+               {
+                       MSG_DEBUG("tel_get_sim_init_info() result is unknown!!!!!!!!!! [%d]", tapiRet);
+
+                       tryNum++;
+
+                       sleep(3);
+               }
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgCheckDeviceStatus()
+{
+       MSG_BEGIN();
+
+       int status = 0, tapiRet = TAPI_API_SUCCESS;
+
+       tapiRet = tel_check_sms_device_status(&status);
+
+       if (tapiRet != TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("tel_check_sms_device_status() Error! [%d], Status [%d]", tapiRet, status);
+
+               return MSG_ERR_PLUGIN_TAPI_FAILED;
+       }
+
+       if (status == TAPI_NETTEXT_DEVICE_READY)
+       {
+               MSG_DEBUG("Device Is Ready");
+               return MSG_SUCCESS;
+       }
+       else if (status == TAPI_NETTEXT_DEVICE_NOT_READY)
+       {
+               MSG_DEBUG("Device Is Not Ready.. Waiting For Ready Callback");
+
+               if (SmsPluginEventHandler::instance()->getDeviceStatus() == true)
+               {
+                       MSG_DEBUG("Device Is Ready");
+                       return MSG_SUCCESS;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo, bool bReqCb)
+{
+       // Add Submit SMS into DB
+       if ((pReqInfo->msgInfo.msgId == 0) && pReqInfo->msgInfo.msgPort.valid == false) {
+               if (SmsPluginStorage::instance()->addMessage(&(pReqInfo->msgInfo)) != MSG_SUCCESS) {
+                       MSG_DEBUG("########  addMessage Fail !!");
+                       return MSG_ERR_PLUGIN_STORAGE;
+               }
+       }
+
+       // Check SIM is present or not
+       MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(MSG_SIM_CHANGED);
+
+       if (simStatus == MSG_SIM_STATUS_NOT_FOUND)
+       {
+               MSG_DEBUG("SIM is not present..");
+
+               // Update Msg Status
+               if (pReqInfo->msgInfo.msgPort.valid == false)
+                       SmsPluginStorage::instance()->updateSentMsg(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+
+               return MSG_ERR_NO_SIM;
+       }
+
+       SMS_REQUEST_INFO_S request = {};
+
+       request.reqId = pReqInfo->reqId;
+
+       memcpy(&(request.msgInfo), &(pReqInfo->msgInfo), sizeof(MSG_MESSAGE_INFO_S));
+       memcpy(&(request.sendOptInfo), &(pReqInfo->sendOptInfo), sizeof(MSG_SENDINGOPT_INFO_S));
+
+       request.bReqCb = bReqCb;
+
+       // Add Request into Queue and Start UA Manger
+       SmsPluginUAManager::instance()->addReqEntity(request);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgInitSimMessage()
+{
+       try
+       {
+               SmsPluginSimMsg::instance()->initSimMessage();
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       }
+       catch (exception& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgSaveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = SmsPluginSimMsg::instance()->saveSimMessage(pMsgInfo, pSimIdList);
+
+       return err;
+}
+
+
+MSG_ERROR_T SmsPlgDeleteSimMessage(MSG_SIM_ID_T SimMsgId)
+{
+       try
+       {
+               SmsPluginSimMsg::instance()->deleteSimMessage(SimMsgId);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       }
+       catch (exception& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgSetReadStatus(MSG_SIM_ID_T SimMsgId)
+{
+       try
+       {
+               SmsPluginSimMsg::instance()->setReadStatus(SimMsgId);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       }
+       catch (exception& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_STORAGE;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgSetMemoryStatus(MSG_ERROR_T Error)
+{
+       int tapiRet = TAPI_API_SUCCESS, reqId = 0;
+       int status = TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE;
+
+       if (Error == MSG_ERR_SIM_STORAGE_FULL || Error == MSG_ERR_MESSAGE_COUNT_FULL)
+       {
+               status = TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL;
+       }
+
+       MSG_DEBUG("Set Status : [%d]", status);
+
+       tapiRet = tel_set_sms_memory_status(status, &reqId);
+
+       if (tapiRet == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId);
+       }
+       else
+       {
+               MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgInitConfigData(MSG_SIM_STATUS_T SimStatus)
+{
+       try
+       {
+               SmsPluginSetting::instance()->initConfigData(SimStatus);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_SETTING;
+       }
+       catch (exception& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_SETTING;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgSetConfigData(const MSG_SETTING_S *pSetting)
+{
+       try
+       {
+               SmsPluginSetting::instance()->setConfigData(pSetting);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_SETTING;
+       }
+       catch (exception& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_SETTING;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPlgGetConfigData(MSG_SETTING_S *pSetting)
+{
+       try
+       {
+               SmsPluginSetting::instance()->getConfigData(pSetting);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_SETTING;
+       }
+       catch (exception& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_PLUGIN_SETTING;
+       }
+
+       return MSG_SUCCESS;
+}
+
diff --git a/plugin/sms_plugin/SmsPluginParamCodec.cpp b/plugin/sms_plugin/SmsPluginParamCodec.cpp
new file mode 100755 (executable)
index 0000000..6a1a863
--- /dev/null
@@ -0,0 +1,518 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "MsgDebug.h"
+#include "SmsPluginUDCodec.h"
+#include "SmsPluginTextConvert.h"
+#include "SmsPluginParamCodec.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginParamCodec - Member Functions
+==================================================================================================*/
+SmsPluginParamCodec::SmsPluginParamCodec()
+{
+
+
+}
+
+
+SmsPluginParamCodec::~SmsPluginParamCodec()
+{
+
+
+}
+
+
+/*==================================================================================================
+                                     Encode Functions
+==================================================================================================*/
+int SmsPluginParamCodec::encodeAddress(const SMS_ADDRESS_S *pAddress, char **ppParam)
+{
+       int offset = 0, length = 0;
+       char *temp = (char *)pAddress->address;
+
+       SMS_TON_T ton;
+
+       *ppParam = new char[MAX_ADD_PARAM_LEN];
+
+       // Set Address Length
+       if (temp[0] == '+')
+       {
+               (*ppParam)[offset++] = strlen(temp) - 1;
+               temp++;
+
+               ton = SMS_TON_INTERNATIONAL;
+       }
+       else
+       {
+               (*ppParam)[offset++] = strlen(temp);
+
+               ton = pAddress->ton;
+       }
+
+       // Set TON, NPI
+       (*ppParam)[offset++] = 0x80 + (ton << 4) + pAddress->npi;
+
+       MSG_DEBUG("Address length is %d.", (*ppParam)[0]);
+       MSG_DEBUG("pAddress->ton : %d.", ton);
+       MSG_DEBUG("pAddress->npi : %d.", pAddress->npi);
+
+       length = convertDigitToBcd(temp, strlen(temp), (unsigned char *) &((*ppParam)[offset]));
+
+       offset += length;
+
+       return offset ;
+}
+
+
+int SmsPluginParamCodec::encodeTime(const SMS_TIMESTAMP_S *pTimeStamp, char **ppParam)
+{
+       int offset = 0;
+
+       if(pTimeStamp->format == SMS_TIME_ABSOLUTE)
+       {
+               int timeZone = pTimeStamp->time.absolute.timeZone;
+               *ppParam = new char[MAX_ABS_TIME_PARAM_LEN];
+
+               (*ppParam)[offset++] = ((pTimeStamp->time.absolute.year % 10)  << 4) + (pTimeStamp->time.absolute.year / 10);
+               (*ppParam)[offset++] = ((pTimeStamp->time.absolute.month % 10) << 4) + (pTimeStamp->time.absolute.month / 10);
+               (*ppParam)[offset++] = ((pTimeStamp->time.absolute.day % 10) << 4) + (pTimeStamp->time.absolute.day / 10);
+               (*ppParam)[offset++] = ((pTimeStamp->time.absolute.hour % 10) << 4) + (pTimeStamp->time.absolute.hour / 10);
+               (*ppParam)[offset++] = ((pTimeStamp->time.absolute.minute % 10) << 4) + (pTimeStamp->time.absolute.minute / 10);
+               (*ppParam)[offset++] = ((pTimeStamp->time.absolute.second % 10) << 4) + (pTimeStamp->time.absolute.second / 10);
+
+               if(timeZone < 0)
+               {
+                       timeZone *= -1;
+                       (*ppParam)[offset] = 0x08;
+               }
+               (*ppParam)[offset++] += ((pTimeStamp->time.absolute.timeZone % 10) << 4) + (pTimeStamp->time.absolute.timeZone / 10);
+
+
+               return offset;
+       }
+       else if(pTimeStamp->format == SMS_TIME_RELATIVE)
+       {
+               *ppParam = new char[MAX_REL_TIME_PARAM_LEN+1];
+
+               memcpy(*ppParam, &(pTimeStamp->time.relative.time), MAX_REL_TIME_PARAM_LEN);
+
+               return MAX_REL_TIME_PARAM_LEN;
+       }
+
+       return offset;
+}
+
+
+int SmsPluginParamCodec::encodeDCS(const SMS_DCS_S *pDCS, char **ppParam)
+{
+       *ppParam = new char;
+
+       **ppParam = 0x00;
+
+       switch (pDCS->codingGroup)
+       {
+               case SMS_GROUP_GENERAL:
+               {
+                       if (pDCS->msgClass != SMS_MSG_CLASS_NONE)
+                       {
+                               **ppParam = 0x10 + pDCS->msgClass;
+                       }
+
+                       if (pDCS->bCompressed)
+                       {
+                               **ppParam |= 0x20;
+                       }
+               }
+               break;
+
+               case SMS_GROUP_CODING_CLASS:
+               {
+                       **ppParam = 0xF0 + pDCS->msgClass;
+               }
+               break;
+
+               case SMS_GROUP_DELETION:
+                       //not supported
+               break;
+
+               case SMS_GROUP_DISCARD:
+                       //not supported
+               break;
+
+               case SMS_GROUP_STORE:
+                       //not supported
+               break;
+
+               default:
+                       return 0;
+       }
+
+       switch (pDCS->codingScheme)
+       {
+               case SMS_CHARSET_7BIT:
+
+               break;
+
+               case SMS_CHARSET_8BIT:
+                       **ppParam |= 0x04;
+               break;
+
+               case SMS_CHARSET_UCS2:
+                       **ppParam |= 0x08;
+               break;
+
+               default:
+                       return 0;
+       }
+
+       return 1;
+}
+
+
+int SmsPluginParamCodec::encodeSMSC(const char *pAddress, unsigned char *pEncodeAddr)
+{
+       char newAddr[MAX_SMSC_LEN+1];
+       memset(newAddr, 0x00, sizeof(newAddr));
+
+       if (pAddress[0] == '+')
+       {
+               strncpy(newAddr, pAddress+1, MAX_SMSC_LEN);
+       }
+       else
+       {
+               strncpy(newAddr, pAddress, MAX_SMSC_LEN);
+       }
+
+       // Set Address
+       int encodeLen = convertDigitToBcd(newAddr, strlen(newAddr), pEncodeAddr);
+
+       pEncodeAddr[encodeLen] = '\0';
+
+       return encodeLen;
+}
+
+
+int SmsPluginParamCodec::encodeSMSC(const SMS_ADDRESS_S *pAddress, unsigned char *pSMSC)
+{
+       char newAddr[MAX_SMSC_LEN+1];
+       memset(newAddr, 0x00, sizeof(newAddr));
+
+       int dataSize = 0, addrLen = 0;
+
+       if (pAddress->address[0] == '+')
+               memcpy(newAddr, pAddress->address+1, strlen(pAddress->address)-1);
+       else
+               memcpy(newAddr, pAddress->address, strlen(pAddress->address));
+
+       addrLen = strlen(newAddr);
+
+       if (addrLen % 2 == 0)
+               dataSize = 2 + (addrLen/2);
+       else
+               dataSize = 2 + (addrLen/2) + 1;
+
+       if (dataSize > MAX_SMSC_LEN)
+       {
+               MSG_DEBUG("addrLen is too long [%d]", addrLen);
+               MSG_DEBUG("dataSize is too long [%d]", dataSize);
+
+               return 0;
+       }
+
+       // Set Address Length
+       // Check IPC 4.0 -> addrLen/2
+       pSMSC[0] = addrLen;
+
+       // Set TON, NPI
+       pSMSC[1] = 0x80 + (pAddress->ton << 4) + pAddress->npi;
+
+       // Set Address
+       convertDigitToBcd(newAddr, addrLen, &(pSMSC[2]));
+
+       pSMSC[dataSize] = '\0';
+
+       return dataSize;
+}
+
+
+/*==================================================================================================
+                                     Decode Functions
+==================================================================================================*/
+int SmsPluginParamCodec::decodeAddress(const unsigned char *pTpdu, SMS_ADDRESS_S *pAddress)
+{
+       int offset = 0, addrLen = 0, bcdLen = 0;
+       memset(pAddress->address, 0x00, sizeof(pAddress->address));
+
+       addrLen = (int)pTpdu[offset++];
+
+       if (addrLen % 2 == 0)
+               bcdLen = addrLen/2;
+       else
+               bcdLen = addrLen/2 + 1;
+
+       pAddress->ton = (pTpdu[offset] & 0x70) >> 4;
+       pAddress->npi = pTpdu[offset++] & 0x0F;
+
+MSG_DEBUG("ton [%d]", pAddress->ton);
+MSG_DEBUG("npi [%d]", pAddress->npi);
+
+       if (pAddress->ton == SMS_TON_ALPHANUMERIC)
+       {
+               MSG_DEBUG("Alphanumeric address");
+
+               char* tmpAddress = new char[MAX_ADDRESS_LEN];
+               int tmplength = 0;
+
+               tmplength = SmsPluginUDCodec::unpack7bitChar(&(pTpdu[offset]), bcdLen, 0, tmpAddress);
+
+               SMS_LANG_INFO_S langInfo = {0};
+
+               langInfo.bSingleShift = false;
+               langInfo.bLockingShift = false;
+
+               SmsPluginTextConvert::instance()->convertGSM7bitToUTF8((unsigned char*)pAddress->address, MAX_ADDRESS_LEN, (unsigned char*)tmpAddress, tmplength, &langInfo);
+       }
+       else if (pAddress->ton == SMS_TON_INTERNATIONAL)
+       {
+               (pAddress->address)[0] = '+';
+               convertBcdToDigit(&(pTpdu[offset]), bcdLen, &((pAddress->address)[1]));
+       }
+       else
+       {
+               convertBcdToDigit(&(pTpdu[offset]), bcdLen, &((pAddress->address)[0]));
+       }
+
+       offset +=       bcdLen;
+
+       return offset;
+}
+
+
+int SmsPluginParamCodec::decodeTime(const unsigned char *pTpdu, SMS_TIMESTAMP_S *pTimeStamp)
+{
+       int offset = 0;
+
+       // decode in ABSOLUTE time type.
+       pTimeStamp->format = SMS_TIME_ABSOLUTE;
+
+       pTimeStamp->time.absolute.year = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+       offset++;
+
+       pTimeStamp->time.absolute.month = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+       offset++;
+
+       pTimeStamp->time.absolute.day = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+       offset++;
+
+       pTimeStamp->time.absolute.hour = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+       offset++;
+
+       pTimeStamp->time.absolute.minute = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+       offset++;
+
+       pTimeStamp->time.absolute.second = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+       offset++;
+
+       pTimeStamp->time.absolute.timeZone = (pTpdu[offset] & 0x07)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+
+       if (pTpdu[offset] & 0x08)
+               pTimeStamp->time.absolute.timeZone *= (-1);
+
+       offset++;
+
+       return offset;
+}
+
+
+int SmsPluginParamCodec::decodeDCS(const unsigned char *pTpdu, SMS_DCS_S *pDCS)
+{
+       int offset = 0;
+       char dcs = pTpdu[offset++];
+
+       pDCS->bMWI = false;
+       pDCS->bIndActive = false;
+       pDCS->indType = SMS_OTHER_INDICATOR;
+
+       if (((dcs & 0xC0) >> 6) == 0)
+       {
+               pDCS->codingGroup = SMS_GROUP_GENERAL;
+               pDCS->bCompressed = (dcs & 0x20) >> 5;
+               pDCS->codingScheme = (dcs & 0x0C) >> 2;
+
+               if (((dcs & 0x10) >> 4) == 0)
+                       pDCS->msgClass = SMS_MSG_CLASS_NONE;
+               else
+                       pDCS->msgClass = dcs & 0x03;
+       }
+       else if (((dcs & 0xF0) >> 4) == 0x0F)
+       {
+               pDCS->codingGroup = SMS_GROUP_CODING_CLASS;
+               pDCS->bCompressed = false;
+               pDCS->codingScheme = (dcs & 0x0C) >> 2;
+
+               pDCS->msgClass = dcs & 0x03;
+       }
+       else if (((dcs & 0xC0) >> 6) == 1)
+       {
+               pDCS->codingGroup = SMS_GROUP_DELETION;
+               pDCS->bCompressed = false;
+               pDCS->msgClass = SMS_MSG_CLASS_NONE;
+
+               // TODO: finish here. ??
+       }
+       else if (((dcs & 0xF0) >> 4) == 0x0C)
+       {
+               pDCS->codingGroup = SMS_GROUP_DISCARD;
+               pDCS->bCompressed = false;
+               pDCS->msgClass = SMS_MSG_CLASS_NONE;
+
+               pDCS->bMWI = true;
+               pDCS->bIndActive = (((dcs & 0x08) >> 3) == 1)? false:true;
+               pDCS->indType = (SMS_INDICATOR_TYPE_T)(dcs & 0x03);
+       }
+       else if (((dcs & 0xF0) >> 4) == 0x0D)
+       {
+               pDCS->codingGroup = SMS_GROUP_STORE;
+               pDCS->codingScheme = SMS_CHARSET_7BIT;
+               pDCS->bCompressed = false;
+               pDCS->msgClass = SMS_MSG_CLASS_NONE;
+
+               pDCS->bMWI = true;
+               pDCS->bIndActive = (((dcs & 0x08) >> 3) == 1)? false:true;
+               pDCS->indType = (SMS_INDICATOR_TYPE_T)(dcs & 0x03);
+       }
+       else if (((dcs & 0xF0) >> 4) == 0x0E)
+       {
+               pDCS->codingGroup = SMS_GROUP_STORE;
+               pDCS->codingScheme = SMS_CHARSET_UCS2;
+               pDCS->bCompressed = false;
+               pDCS->msgClass = SMS_MSG_CLASS_NONE;
+
+               pDCS->bMWI = true;
+               pDCS->bIndActive = (((dcs & 0x08) >> 3) == 1)? false:true;
+               pDCS->indType = (SMS_INDICATOR_TYPE_T)(dcs & 0x03);
+       }
+       else
+       {
+               pDCS->codingGroup = SMS_GROUP_UNKNOWN;
+
+               pDCS->bCompressed = (dcs & 0x20) >> 5;
+               pDCS->codingScheme = (dcs & 0x0C) >> 2;
+
+               pDCS->msgClass = SMS_MSG_CLASS_NONE;
+       }
+
+       return offset;
+}
+
+
+void SmsPluginParamCodec::decodeSMSC(unsigned char* pAddress, int AddrLen, MSG_SMS_TON_T ton, char *pDecodeAddr)
+{
+       if (pAddress == NULL || AddrLen == 0)
+               return;
+
+       if (ton == SMS_TON_INTERNATIONAL)
+       {
+               pDecodeAddr[0] = '+';
+               convertBcdToDigit(pAddress, AddrLen, &(pDecodeAddr[1]));
+       }
+       else
+       {
+               convertBcdToDigit(pAddress, AddrLen, pDecodeAddr);
+       }
+}
+
+
+/*==================================================================================================
+                                     Util Functions
+==================================================================================================*/
+int SmsPluginParamCodec::convertDigitToBcd(char *pDigit, int DigitLen, unsigned char *pBcd)
+{
+       int offset = 0;
+       unsigned char temp;
+
+       for (int i = 0; i < DigitLen; i++)
+       {
+               if (pDigit[i] == '*')
+                       temp = 0x0A;
+               else if (pDigit[i] == '#')
+                       temp = 0x0B;
+               else if (pDigit[i] == 'P' || pDigit[i] == 'p')
+                       temp = 0x0C;
+               else
+                       temp = pDigit[i] - '0';
+
+               if ((i%2) == 0)
+                       pBcd[offset] = temp & 0x0F;
+               else
+                       pBcd[offset++] |= ((temp & 0x0F) << 4);
+       }
+
+       if ((DigitLen%2) == 1)
+       {
+               pBcd[offset++] |= 0xF0;
+       }
+
+       return offset;
+}
+
+
+int SmsPluginParamCodec::convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit)
+{
+       int offset = 0;
+       unsigned char temp;
+
+       for (int i = 0; i < BcdLen; i++)
+       {
+               temp = pBcd[i] & 0x0F;
+
+               if (temp == 0x0A)
+                       pDigit[offset++] = '*';
+               else if (temp == 0x0B)
+                       pDigit[offset++] = '#';
+               else if (temp == 0x0C)
+                       pDigit[offset++] = 'P';
+               else
+                       pDigit[offset++] = temp + '0';
+
+               temp = (pBcd[i] & 0xF0) >> 4;
+
+               if (temp == 0x0F)
+               {
+                       pDigit[offset] = '\0';
+                       return offset;
+               }
+
+               if (temp == 0x0A)
+                       pDigit[offset++] = '*';
+               else if (temp == 0x0B)
+                       pDigit[offset++] = '#';
+               else if (temp == 0x0C)
+                       pDigit[offset++] = 'P';
+               else
+                       pDigit[offset++] = temp + '0';
+       }
+
+       pDigit[offset] = '\0';
+
+       return offset;
+}
+
diff --git a/plugin/sms_plugin/SmsPluginSatHandler.cpp b/plugin/sms_plugin/SmsPluginSatHandler.cpp
new file mode 100755 (executable)
index 0000000..1ff65f7
--- /dev/null
@@ -0,0 +1,607 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "SmsPluginParamCodec.h"
+#include "SmsPluginUDCodec.h"
+#include "SmsPluginSetting.h"
+#include "SmsPluginTransport.h"
+#include "SmsPluginEventHandler.h"
+#include "SmsPluginSatHandler.h"
+
+extern "C"
+{
+       #include <ITapiNetText.h>
+       #include <ITapiSat.h>
+}
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginCbMsgHandler - Member Functions
+==================================================================================================*/
+SmsPluginSatHandler* SmsPluginSatHandler::pInstance = NULL;
+
+
+SmsPluginSatHandler::SmsPluginSatHandler()
+{
+       commandId = 0;
+
+       bSendSms = false;
+       bInitSim = false;
+       bSMSPChanged = false;
+       bCBMIChanged = false;
+}
+
+
+SmsPluginSatHandler::~SmsPluginSatHandler()
+{
+
+}
+
+
+SmsPluginSatHandler* SmsPluginSatHandler::instance()
+{
+       if (!pInstance)
+               pInstance = new SmsPluginSatHandler();
+
+       return pInstance;
+}
+
+
+void SmsPluginSatHandler::refreshSms(void *pData)
+{
+       TelSatRefreshInd_t* pRefreshData = (TelSatRefreshInd_t*)pData;
+
+       if (pRefreshData->appType != TAPI_SAT_REFRESH_MSG)
+       {
+               MSG_DEBUG("App Type is wrong. [%d]", pRefreshData->appType);
+               return;
+       }
+
+       commandId = pRefreshData->commandId;
+
+       switch (pRefreshData->refreshMode)
+       {
+               case TAPI_SAT_REFRESH_SIM_INIT_AND_FULL_FCN :
+               case TAPI_SAT_REFRESH_SIM_INIT_AND_FCN :
+               {
+                       for (int i = 0; i < pRefreshData->fileCount; i++)
+                       {
+                               if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_SMSP ||
+                                       (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_SMSP)
+                               {
+                                       bSMSPChanged = true;
+                               }
+                               else if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_CBMI ||
+                                       (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_CBMI)
+                               {
+                                       bCBMIChanged = true;
+                               }
+                       }
+
+                       initSim();
+               }
+               break;
+
+               case TAPI_SAT_REFRESH_FCN :
+               {
+                       for (int i = 0; i < pRefreshData->fileCount; i++)
+                       {
+                               if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_SMSP ||
+                                       (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_SMSP)
+                               {
+                                       bSMSPChanged = true;
+                               }
+                               else if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_CBMI ||
+                                       (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_CBMI)
+                               {
+                                       bCBMIChanged = true;
+                               }
+                       }
+               }
+               break;
+
+               case TAPI_SAT_REFRESH_SIM_INIT :
+               {
+                       initSim();
+               }
+               break;
+
+               default:
+               break;
+       }
+}
+
+
+void SmsPluginSatHandler::sendSms(void *pData)
+{
+       TelSatSendSmsIndSmsData_t* pSmsData = (TelSatSendSmsIndSmsData_t*)pData;
+
+       bSendSms = true;
+
+       commandId = pSmsData->commandId;
+
+       MSG_DEBUG("commandId [%d]", commandId);
+
+       // The TPDU Maximum Length at SAT side is 175
+       // This is because Sat can send 160 bytes unpacked and header
+       unsigned char tpdu[MAX_SAT_TPDU_LEN+1];
+       int tpduLen = 0;
+
+       memset(tpdu, 0x00, sizeof(tpdu));
+       memcpy(tpdu, pSmsData->smsTpdu.data, pSmsData->smsTpdu.dataLen);
+
+       // Modify Parameters, Pack User Data
+       tpduLen = handleSatTpdu(tpdu, pSmsData->smsTpdu.dataLen, pSmsData->bIsPackingRequired);
+
+       if (tpduLen <= 0 || tpduLen > MAX_TPDU_DATA_LEN)
+       {
+               sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_BEYOND_ME_CAPABILITIES);
+               return;
+       }
+
+       // Make Telephony Structure
+       TelSmsDatapackageInfo_t pkgInfo;
+
+       // Set TPDU data
+       memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
+       memcpy((void*)pkgInfo.szData, tpdu, tpduLen);
+
+       pkgInfo.szData[tpduLen] = '\0';
+       pkgInfo.MsgLength = tpduLen;
+
+       // Set SMSC Address
+       SMS_ADDRESS_S smsc;
+
+       if (pSmsData->address.diallingNumberLen > 0)
+       {
+               smsc.ton = pSmsData->address.ton;
+               smsc.npi = pSmsData->address.npi;
+               memcpy(smsc.address, pSmsData->address.diallingNumber, pSmsData->address.diallingNumberLen);
+               smsc.address[pSmsData->address.diallingNumberLen] = '\0';
+
+               MSG_DEBUG("SCA TON[%d], NPI[%d], LEN[%d], ADDR[%s]", smsc.ton, smsc.npi, strlen(smsc.address), smsc.address);
+       }
+       else
+       {
+               // Set SMSC Options
+               SmsPluginTransport::instance()->setSmscOptions(&smsc);
+       }
+
+       unsigned char smscAddr[MAX_SMSC_LEN];
+       memset(smscAddr, 0x00, sizeof(smscAddr));
+
+       int smscLen = SmsPluginParamCodec::encodeSMSC(&smsc, smscAddr);
+
+       if (smscLen <= 0) return;
+
+       // Set SMSC Address
+       memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
+       memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
+       pkgInfo.Sca[smscLen] = '\0';
+
+       int reqId = 0, tapiRet = TAPI_API_SUCCESS;
+
+       // Send SMS
+       tapiRet = tel_send_sms(&pkgInfo, 0, &reqId);
+
+       if (tapiRet == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("########  TelTapiSmsSend Success !!! return : %d #######", tapiRet);
+       }
+       else
+       {
+               MSG_DEBUG("########  TelTapiSmsSend Fail !!! return : %d #######", tapiRet);
+               sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_BEYOND_ME_CAPABILITIES);
+       }
+}
+
+
+void SmsPluginSatHandler::ctrlSms(void *pData)
+{
+       TelSatMoSmCtrlIndData_t* pCtrlData = (TelSatMoSmCtrlIndData_t*)pData;
+
+       if (bSendSms == true) // Send SMS By SAT
+       {
+               if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED)
+               {
+                       MSG_DEBUG("SIM does not allow to send SMS");
+
+                       sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM);
+               }
+               else if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD)
+               {
+                       MSG_DEBUG("SIM allows to send SMS with modification");
+
+                       sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SUCCESS);
+               }
+       }
+       else // Send SMS By APP
+       {
+               MSG_NETWORK_STATUS_T netStatus = MSG_NETWORK_NOT_SEND;
+
+               if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED)
+               {
+                       MSG_DEBUG("SIM does not allow to send SMS");
+
+                       netStatus = MSG_NETWORK_SEND_FAIL;
+               }
+               else if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD)
+               {
+                       MSG_DEBUG("SIM allows to send SMS with modification");
+
+                       netStatus = MSG_NETWORK_SEND_SUCCESS;
+               }
+
+               // Call Event Handler
+               SmsPluginEventHandler::instance()->handleSentStatus(-1, netStatus);
+       }
+}
+
+
+void SmsPluginSatHandler::ctrlSms(MSG_NETWORK_STATUS_T netStatus)
+{
+       if (bSendSms == true) // Send SMS By SAT
+       {
+               if (netStatus == MSG_NETWORK_SEND_SUCCESS)
+               {
+                       MSG_DEBUG("Sending SMS by SAT is OK");
+
+                       sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SUCCESS);
+               }
+               else if (netStatus == MSG_NETWORK_SEND_FAIL)
+               {
+                       MSG_DEBUG("Sending SMS by SAT is failed");
+
+                       sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SMS_RP_ERROR);
+               }
+       }
+}
+
+
+void SmsPluginSatHandler::finishSimMsgInit(MSG_ERROR_T Err)
+{
+       // SAT Handler is initializing SIM now
+       if (bInitSim == true)
+       {
+               // Init SMSC List and CB ID Info
+               try
+               {
+                       if (bSMSPChanged == true) initSMSCList();
+               }
+               catch (MsgException& e)
+               {
+                       // Send Result to TAPI
+                       sendResult(SMS_SAT_CMD_REFRESH, TAPI_SAT_R_ME_UNABLE_TO_PROCESS_COMMAND);
+
+                       MSG_FATAL("%s", e.what());
+                       return;
+               }
+
+               try
+               {
+                       if (bCBMIChanged == true) initCBConfig();
+               }
+               catch (MsgException& e)
+               {
+                       // Send Result to TAPI
+                       sendResult(SMS_SAT_CMD_REFRESH, TAPI_SAT_R_ME_UNABLE_TO_PROCESS_COMMAND);
+
+                       MSG_FATAL("%s", e.what());
+                       return;
+               }
+
+               // Send Result to TAPI
+               sendResult(SMS_SAT_CMD_REFRESH, TAPI_SAT_R_SUCCESS);
+       }
+}
+
+
+void SmsPluginSatHandler::initSim()
+{
+       bInitSim = true;
+
+       // Init SIM Message
+       if (SmsPluginEventHandler::instance()->callbackInitSimBySat() != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Init Sim Error");
+
+               // Send Result to TAPI
+               sendResult(SMS_SAT_CMD_REFRESH, TAPI_SAT_R_ME_UNABLE_TO_PROCESS_COMMAND);
+       }
+}
+
+
+void   SmsPluginSatHandler::initSMSCList()
+{
+       MSG_SETTING_S settingData;
+
+       settingData.type = MSG_SMSC_LIST;
+
+       // Get Data From SIM
+       SmsPluginSetting::instance()->getConfigData(&settingData);
+
+       MSG_DEBUG("total_count[%d]", settingData.option.smscList.totalCnt);
+       MSG_DEBUG("selected[%d]", settingData.option.smscList.selected);
+
+       for (int i = 0; i < settingData.option.smscList.totalCnt; i++)
+       {
+               MSG_DEBUG("pid[%d]", settingData.option.smscList.smscData[i].pid);
+               MSG_DEBUG("val_period[%d]", settingData.option.smscList.smscData[i].valPeriod);
+               MSG_DEBUG("name[%s]", settingData.option.smscList.smscData[i].name);
+
+               MSG_DEBUG("ton[%d]", settingData.option.smscList.smscData[i].smscAddr.ton);
+               MSG_DEBUG("npi[%d]", settingData.option.smscList.smscData[i].smscAddr.npi);
+               MSG_DEBUG("address[%s]", settingData.option.smscList.smscData[i].smscAddr.address);
+       }
+
+       if (MsgSettingSetInt(SMSC_SELECTED, settingData.option.smscList.selected) != MSG_SUCCESS)
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", SMSC_SELECTED);
+               return;
+       }
+
+       if (MsgSettingSetInt(SMSC_TOTAL_COUNT, settingData.option.smscList.totalCnt) != MSG_SUCCESS)
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", SMSC_TOTAL_COUNT);
+               return;
+       }
+
+       char keyName[128];
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       for (int i = 0; i < settingData.option.smscList.totalCnt; i++)
+       {
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_PID, i);
+
+               if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].pid)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_VAL_PERIOD, i);
+
+               if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].valPeriod)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_NAME, i);
+
+               if ((err = MsgSettingSetString(keyName, settingData.option.smscList.smscData[i].name)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_TON, i);
+
+               if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].smscAddr.ton)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_NPI, i);
+
+               if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].smscAddr.npi)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_ADDRESS, i);
+
+               if ((err = MsgSettingSetString(keyName, settingData.option.smscList.smscData[i].smscAddr.address)) != MSG_SUCCESS)
+                       break;
+       }
+
+       if (err != MSG_SUCCESS)
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", keyName);
+       }
+}
+
+
+void   SmsPluginSatHandler::initCBConfig()
+{
+       MSG_SETTING_S settingData;
+
+       settingData.type = MSG_CBMSG_OPT;
+
+       // Get Data From SIM
+       SmsPluginSetting::instance()->getConfigData(&settingData);
+
+       if (MsgSettingSetBool(CB_RECEIVE, settingData.option.cbMsgOpt.bReceive) != MSG_SUCCESS)
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", CB_RECEIVE);
+               return;
+       }
+
+       if (MsgSettingSetBool(CB_ALL_CHANNEL, settingData.option.cbMsgOpt.bAllChannel) != MSG_SUCCESS)
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", CB_ALL_CHANNEL);
+               return;
+       }
+
+       if (MsgSettingSetInt(CB_MAX_SIM_COUNT, settingData.option.cbMsgOpt.maxSimCnt) != MSG_SUCCESS)
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", CB_MAX_SIM_COUNT);
+               return;
+       }
+
+       if (MsgSettingSetInt(CB_CHANNEL_COUNT, settingData.option.cbMsgOpt.channelData.channelCnt) != MSG_SUCCESS)
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", CB_CHANNEL_COUNT);
+               return;
+       }
+
+       char keyName[128];
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       for (int i = 0; i < settingData.option.cbMsgOpt.channelData.channelCnt; i++)
+       {
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_CHANNEL_ACTIVATE, i);
+
+               if ((err = MsgSettingSetBool(keyName, settingData.option.cbMsgOpt.channelData.channelInfo[i].bActivate)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_CHANNEL_ID, i);
+
+               if ((err = MsgSettingSetInt(keyName, settingData.option.cbMsgOpt.channelData.channelInfo[i].id)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_CHANNEL_NAME, i);
+
+               if ((err = MsgSettingSetString(keyName, settingData.option.cbMsgOpt.channelData.channelInfo[i].name)) != MSG_SUCCESS)
+                       break;
+       }
+
+       if (err != MSG_SUCCESS)
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", keyName);
+       }
+}
+
+
+int SmsPluginSatHandler::handleSatTpdu(unsigned char *pTpdu, unsigned char TpduLen, int bIsPackingRequired)
+{
+       if (pTpdu == NULL)
+               THROW(MsgException::SMS_PLG_ERROR, "SAT TPDU is NULL");
+
+       int pos = 0;
+
+       // TP-MTI, TP-RD, TP-VPF,  TP-RP, TP-UDHI, TP-SRR
+       // TP-VPF
+       SMS_VPF_T vpf = (SMS_VPF_T)(pTpdu[pos++] & 0x18);
+
+       // TP-MR
+       unsigned char tmpRef = pTpdu[pos];
+
+       MSG_DEBUG("current Msg Ref : %d", tmpRef);
+
+       pTpdu[pos] = tmpRef + 1;
+
+       MSG_DEBUG("new Msg Ref : %d", pTpdu[pos]);
+
+       pos++;
+
+       // TP-DA
+       SMS_ADDRESS_S destAddr = {0};
+       int addrLen = SmsPluginParamCodec::decodeAddress(&pTpdu[pos], &destAddr);
+
+       pos += addrLen;
+
+       // TP-PID
+       pos++;
+
+       // TP-DCS
+       SMS_DCS_S dcs = {0};
+
+       int dcsLen = SmsPluginParamCodec::decodeDCS(&pTpdu[pos], &dcs);
+
+       if (bIsPackingRequired == true)
+       {
+               dcs.codingScheme = SMS_CHARSET_7BIT;
+
+               char* pDcs = NULL;
+               AutoPtr<char> dcsBuf(&pDcs);
+
+               SmsPluginParamCodec::encodeDCS(&dcs, &pDcs);
+
+               memcpy(&(pTpdu[pos]), pDcs, dcsLen);
+       }
+
+       pos++;
+
+       // TP-VP
+       if (vpf == SMS_VPF_RELATIVE)
+       {
+               pos += MAX_REL_TIME_PARAM_LEN;
+       }
+       else if (vpf == SMS_VPF_ABSOLUTE)
+       {
+               pos += MAX_ABS_TIME_PARAM_LEN;
+       }
+
+       // TP-UDL
+       int udl = pTpdu[pos];
+
+       int retLen = 0;
+
+       if (bIsPackingRequired == true)
+       {
+               SMS_USERDATA_S userData = {0};
+
+               userData.headerCnt = 0;
+               userData.length = udl;
+               memcpy(userData.data, &pTpdu[pos+1], udl);
+               userData.data[udl] = '\0';
+
+MSG_DEBUG("user data : %s", userData.data);
+
+               int encodeSize = SmsPluginUDCodec::encodeUserData(&userData, dcs.codingScheme, (char*)&pTpdu[pos]);
+
+               retLen = pos + encodeSize;
+       }
+       else
+       {
+               retLen = TpduLen;
+       }
+
+       return retLen;
+}
+
+
+void SmsPluginSatHandler::sendResult(SMS_SAT_CMD_TYPE_T CmdType, int ResultType)
+{
+       TelSatAppsRetInfo_t satRetInfo;
+
+       satRetInfo.commandId = commandId;
+
+       MSG_DEBUG("satRetInfo.commandId [%d]", satRetInfo.commandId);
+
+       if (CmdType == SMS_SAT_CMD_REFRESH)
+       {
+               satRetInfo.commandType = TAPI_SAT_CMD_TYPE_REFRESH;
+
+               satRetInfo.appsRet.refresh.appType = TAPI_SAT_REFRESH_MSG;
+               satRetInfo.appsRet.refresh.resp = (TelSatResultType_t)ResultType;
+       }
+       else if (CmdType == SMS_SAT_CMD_SEND_SMS)
+       {
+               satRetInfo.commandType = TAPI_SAT_CMD_TYPE_SEND_SMS;
+
+               satRetInfo.appsRet.sendSms.resp = (TelSatResultType_t)ResultType;
+       }
+
+       int tapiRet = TAPI_API_SUCCESS;
+
+       tapiRet = tel_send_sat_app_exec_result(&satRetInfo);
+
+       if (tapiRet == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("TelTapiSatSendAppExecutionResult() SUCCESS");
+       }
+       else
+       {
+               MSG_DEBUG("TelTapiSatSendAppExecutionResult() FAIL [%d]", tapiRet);
+       }
+
+       bSendSms = false;
+       bInitSim = false;
+       bSMSPChanged = false;
+       bCBMIChanged = false;
+}
+
diff --git a/plugin/sms_plugin/SmsPluginSetting.cpp b/plugin/sms_plugin/SmsPluginSetting.cpp
new file mode 100755 (executable)
index 0000000..b45c038
--- /dev/null
@@ -0,0 +1,873 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <errno.h>
+
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "SmsPluginParamCodec.h"
+#include "SmsPluginSetting.h"
+
+
+extern "C"
+{
+#ifndef _TAPI_NETTEXT_H_
+       #include "ITapiNetText.h"
+       #include "ITapiSim.h"
+#endif
+}
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginSetting - Member Functions
+==================================================================================================*/
+SmsPluginSetting* SmsPluginSetting::pInstance = NULL;
+
+
+SmsPluginSetting::SmsPluginSetting()
+{
+       // Initialize member variables
+       memset(&smscData, 0x00, sizeof(MSG_SMSC_DATA_S));
+       memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
+
+       bTapiResult = false;
+       paramCnt = 0;
+       selectedParam = 0;
+}
+
+
+SmsPluginSetting::~SmsPluginSetting()
+{
+
+
+}
+
+
+SmsPluginSetting* SmsPluginSetting::instance()
+{
+       if (!pInstance)
+               pInstance = new SmsPluginSetting();
+
+       return pInstance;
+}
+
+
+void SmsPluginSetting::initConfigData(MSG_SIM_STATUS_T SimStatus)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T     err = MSG_SUCCESS;
+
+       // Init SMS Parameter
+       int paramCnt = 0;
+       int failCnt = 0;
+
+       paramCnt = getParamCount();
+
+       MSG_DEBUG("Parameter Count [%d]", paramCnt);
+
+       MSG_SMSC_DATA_S tmpSmscData = {};
+       MSG_SMSC_LIST_S tmpSmscList = {};
+
+       for (int index = 0; index < paramCnt; index++)
+       {
+               if (getParam(index, &tmpSmscData) == false)
+               {
+                       failCnt++;
+                       continue;
+               }
+
+               memcpy(&(tmpSmscList.smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S));
+
+               MSG_DEBUG("pid[%d]", tmpSmscList.smscData[index].pid);
+               MSG_DEBUG("val_period[%d]", tmpSmscList.smscData[index].valPeriod);
+               MSG_DEBUG("name[%s]", tmpSmscList.smscData[index].name);
+
+               MSG_DEBUG("ton[%d]", tmpSmscList.smscData[index].smscAddr.ton);
+               MSG_DEBUG("npi[%d]", tmpSmscList.smscData[index].smscAddr.npi);
+               MSG_DEBUG("address[%s]", tmpSmscList.smscData[index].smscAddr.address);
+       }
+
+       tmpSmscList.totalCnt = (paramCnt - failCnt);
+       tmpSmscList.selected = selectedParam;
+
+       if (paramCnt > 0)
+       {
+               err = addSMSCList(&tmpSmscList);
+
+               if (err == MSG_SUCCESS)
+               {
+                       MSG_DEBUG("########  Add SMSC List Success !!! #######");
+               }
+               else
+               {
+                       MSG_DEBUG("########  Add SMSC List Fail !!! return : %d #######", err);
+               }
+       }
+
+       // Init CB Config
+       if (SimStatus == MSG_SIM_STATUS_CHANGED)
+       {
+               MSG_DEBUG("simStatus == MSG_SIM_STATUS_CHANGED");
+
+               MSG_CBMSG_OPT_S cbMsgOpt = {};
+
+               if (getCbConfig(&cbMsgOpt) == true)
+               {
+                       err = addCbOpt(&cbMsgOpt);
+
+                       if (err == MSG_SUCCESS)
+                       {
+                               MSG_DEBUG("########  Add CB Option Success !!! #######");
+                       }
+                       else
+                       {
+                               MSG_DEBUG("########  Add CB Option Fail !!! return : %d #######", err);
+                       }
+               }
+       }
+       else if (SimStatus == MSG_SIM_STATUS_NORMAL)
+       {
+               MSG_DEBUG("simStatus == MSG_SIM_STATUS_NORMAL");
+
+               // Set CB Data into SIM in case of same SIM
+               MSG_SETTING_S cbSetting;
+               cbSetting.type = MSG_CBMSG_OPT;
+
+               getCbOpt(&cbSetting);
+
+               setCbConfig(&(cbSetting.option.cbMsgOpt));
+       }
+
+       MSG_END();
+}
+
+
+void SmsPluginSetting::setConfigData(const MSG_SETTING_S *pSetting)
+{
+       MSG_DEBUG("Setting Type : [%d]", pSetting->type);
+
+       switch (pSetting->type)
+       {
+               case MSG_SMSC_LIST :
+                       setParamList(&pSetting->option.smscList);
+               break;
+
+               case MSG_CBMSG_OPT :
+                       setCbConfig(&pSetting->option.cbMsgOpt);
+               break;
+
+               default :
+                       THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
+               break;
+       }
+}
+
+
+void SmsPluginSetting::getConfigData(MSG_SETTING_S *pSetting)
+{
+       MSG_DEBUG("Setting Type : [%d]", pSetting->type);
+
+       switch (pSetting->type)
+       {
+               case MSG_SMSC_LIST :
+                       getParamList(&pSetting->option.smscList);
+               break;
+
+               case MSG_CBMSG_OPT :
+                       getCbConfig(&pSetting->option.cbMsgOpt);
+               break;
+
+               default :
+                       THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
+               break;
+       }
+}
+
+
+MSG_ERROR_T SmsPluginSetting::addSMSCList(MSG_SMSC_LIST_S *pSmscList)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_DEBUG("total_count[%d]", pSmscList->totalCnt);
+       MSG_DEBUG("selected index[%d]", pSmscList->selected);
+
+       for (int i = 0; i < pSmscList->totalCnt; i++)
+       {
+               MSG_DEBUG("pid[%d]", pSmscList->smscData[i].pid);
+               MSG_DEBUG("val_period[%d]", pSmscList->smscData[i].valPeriod);
+               MSG_DEBUG("name[%s]", pSmscList->smscData[i].name);
+
+               MSG_DEBUG("ton[%d]", pSmscList->smscData[i].smscAddr.ton);
+               MSG_DEBUG("npi[%d]", pSmscList->smscData[i].smscAddr.npi);
+               MSG_DEBUG("address[%s]", pSmscList->smscData[i].smscAddr.address);
+       }
+
+       char keyName[128];
+
+       if (MsgSettingSetInt(SMSC_TOTAL_COUNT, pSmscList->totalCnt) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", SMSC_TOTAL_COUNT);
+               return MSG_ERR_SET_SETTING;
+       }
+
+       if (MsgSettingSetInt(SMSC_SELECTED, pSmscList->selected) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", SMSC_SELECTED);
+               return MSG_ERR_SET_SETTING;
+       }
+
+       for (int i = 0; i < pSmscList->totalCnt; i++)
+       {
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_PID, i);
+
+               if ((err = MsgSettingSetInt(keyName, (int)pSmscList->smscData[i].pid)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_VAL_PERIOD, i);
+
+               if ((err = MsgSettingSetInt(keyName, (int)pSmscList->smscData[i].valPeriod)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_NAME, i);
+
+               if ((err = MsgSettingSetString(keyName, pSmscList->smscData[i].name)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_TON, i);
+
+               if (pSmscList->smscData[i].smscAddr.address[0] == '+')
+                       pSmscList->smscData[i].smscAddr.ton = MSG_TON_INTERNATIONAL;
+               else
+                       pSmscList->smscData[i].smscAddr.ton = MSG_TON_NATIONAL;
+
+               if ((err = MsgSettingSetInt(keyName, (int)pSmscList->smscData[i].smscAddr.ton)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_NPI, i);
+
+               pSmscList->smscData[i].smscAddr.npi = MSG_NPI_ISDN; // app cannot set this value
+
+               if ((err = MsgSettingSetInt(keyName, (int)pSmscList->smscData[i].smscAddr.npi)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_ADDRESS, i);
+
+               if ((err = MsgSettingSetString(keyName, pSmscList->smscData[i].smscAddr.address)) != MSG_SUCCESS)
+                       break;
+       }
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", keyName);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T SmsPluginSetting::addCbOpt(MSG_CBMSG_OPT_S *pCbOpt)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_DEBUG("Receive [%d], All Channel [%d], Max SIM Count [%d]", pCbOpt->bReceive, pCbOpt->bAllChannel, pCbOpt->maxSimCnt);
+
+       MSG_DEBUG("Channel Count [%d]", pCbOpt->channelData.channelCnt);
+
+       for (int i = 0; i < pCbOpt->channelData.channelCnt; i++)
+       {
+               MSG_DEBUG("Channel ID [%d]", pCbOpt->channelData.channelInfo[i].id);
+       }
+
+       // Set Setting Data into Vconf
+       if (MsgSettingSetBool(CB_RECEIVE, pCbOpt->bReceive) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", CB_RECEIVE);
+               return MSG_ERR_SET_SETTING;
+       }
+
+       if (MsgSettingSetBool(CB_ALL_CHANNEL, pCbOpt->bAllChannel) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", CB_ALL_CHANNEL);
+               return MSG_ERR_SET_SETTING;
+       }
+
+       if (MsgSettingSetInt(CB_MAX_SIM_COUNT, pCbOpt->maxSimCnt) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", CB_MAX_SIM_COUNT);
+               return MSG_ERR_SET_SETTING;
+       }
+
+       if (MsgSettingSetInt(CB_CHANNEL_COUNT, pCbOpt->channelData.channelCnt) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", CB_CHANNEL_COUNT);
+               return MSG_ERR_SET_SETTING;
+       }
+
+       char keyName[128];
+
+       for (int i = 0; i < pCbOpt->channelData.channelCnt; i++)
+       {
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_CHANNEL_ACTIVATE, i);
+
+               if ((err = MsgSettingSetBool(keyName, pCbOpt->channelData.channelInfo[i].bActivate)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_CHANNEL_ID, i);
+
+               if ((err = MsgSettingSetInt(keyName, pCbOpt->channelData.channelInfo[i].id)) != MSG_SUCCESS)
+                       break;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_CHANNEL_NAME, i);
+
+               if ((err = MsgSettingSetString(keyName, pCbOpt->channelData.channelInfo[i].name)) != MSG_SUCCESS)
+                       break;
+       }
+
+       return err;
+}
+
+
+void SmsPluginSetting::getCbOpt(MSG_SETTING_S *pSetting)
+{
+       char keyName[128];
+       char *tmpValue = NULL;
+
+       memset(&(pSetting->option.cbMsgOpt), 0x00, sizeof(MSG_CBMSG_OPT_S));
+
+       MsgSettingGetBool(CB_RECEIVE, &pSetting->option.cbMsgOpt.bReceive);
+
+       MsgSettingGetBool(CB_ALL_CHANNEL, &pSetting->option.cbMsgOpt.bAllChannel);
+
+       pSetting->option.cbMsgOpt.maxSimCnt = MsgSettingGetInt(CB_MAX_SIM_COUNT);
+
+       pSetting->option.cbMsgOpt.channelData.channelCnt = MsgSettingGetInt(CB_CHANNEL_COUNT);
+
+       for (int i = 0; i < pSetting->option.cbMsgOpt.channelData.channelCnt; i++)
+       {
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_CHANNEL_ACTIVATE, i);
+
+               MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.channelData.channelInfo[i].bActivate);
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_CHANNEL_ID, i);
+
+               pSetting->option.cbMsgOpt.channelData.channelInfo[i].id = MsgSettingGetInt(keyName);
+
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_CHANNEL_NAME, i);
+
+               tmpValue = MsgSettingGetString(keyName);
+
+               if (tmpValue != NULL)
+               {
+                       strncpy(pSetting->option.cbMsgOpt.channelData.channelInfo[i].name, tmpValue, CB_CHANNEL_NAME_MAX);
+                       free(tmpValue);
+                       tmpValue = NULL;
+               }
+       }
+
+       for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++)
+       {
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_LANGUAGE, i);
+
+               MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]);
+       }
+
+}
+
+
+void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
+{
+       MSG_BEGIN();
+
+       TelSmsParams_t smsParam = {0};
+
+       int ret = TAPI_API_SUCCESS;
+       int reqId = 0;
+
+       for (int index = 0; index < pSMSCList->totalCnt; index++)
+       {
+               /*Setting the SMSP Record index value*/
+               smsParam.RecordIndex = (unsigned char)index;
+
+               /*Setting the SMSP Record Length value = 28 + alphaId_len*/
+               smsParam.RecordLen = 28 + strlen(pSMSCList->smscData[index].name);
+
+               /*Setting the SMSP Alpha ID value*/
+               smsParam.AlphaIdLen = strlen(pSMSCList->smscData[index].name);
+               MSG_DEBUG("AlphaIdLen = %ld", smsParam.AlphaIdLen);
+
+               if (smsParam.AlphaIdLen > 0 &&  smsParam.AlphaIdLen <= SMSC_NAME_MAX)
+               {
+                       memcpy(smsParam.szAlphaId, pSMSCList->smscData[index].name, smsParam.AlphaIdLen);
+                       smsParam.szAlphaId[smsParam.AlphaIdLen] = '\0';
+                       MSG_DEBUG("szAlphaId = %s", smsParam.szAlphaId);
+               }
+
+               smsParam.ParamIndicator = 0x00;
+
+               if (strlen(pSMSCList->smscData[index].smscAddr.address) > 0)
+               {
+                       smsParam.ParamIndicator |= 0x02 ;  //enable 2nd Bit
+                       MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
+
+                       if (pSMSCList->smscData[index].smscAddr.address[0] == '+')
+                               smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_INTERNATIONAL;
+                       else
+                               smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_NATIONAL;
+
+                       smsParam.TpSvcCntrAddr.Npi = TAPI_SIM_NPI_ISDN_TEL; // app cannot set this value
+
+                       MSG_DEBUG("SMSC TON = [%d] NPI = [%d]", smsParam.TpSvcCntrAddr.Ton, smsParam.TpSvcCntrAddr.Npi);
+
+                       MSG_DEBUG("address = %s", pSMSCList->smscData[index].smscAddr.address);
+
+                       smsParam.TpSvcCntrAddr.DialNumLen = SmsPluginParamCodec::encodeSMSC(pSMSCList->smscData[index].smscAddr.address, smsParam.TpSvcCntrAddr.szDiallingNum);
+               }
+               else
+               {
+                       MSG_DEBUG("SMSC Addr is not present");
+               }
+
+               /*Setting the PID value*/
+               smsParam.ParamIndicator |= 0x04 ;  //enable 3nd Bit
+               MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
+
+               smsParam.TpProtocolId = (unsigned short)convertPid(pSMSCList->smscData[index].pid);
+
+               /*Setting the ValidityPeriod value*/
+               smsParam.ParamIndicator |= 0x10 ;  //enable 5nd Bit
+               MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
+
+               smsParam.TpValidityPeriod = (unsigned short)pSMSCList->smscData[index].valPeriod;
+
+               smsParam.ParamIndicator = ~(smsParam.ParamIndicator);
+               MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
+
+               ret = tel_set_sms_parameters((const TelSmsParams_t*)&smsParam, &reqId);
+
+               if (ret != TAPI_API_SUCCESS)
+                       THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_parameters() Error. [%d]", ret);
+
+               if (!getResultFromSim())
+                       THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_parameters() Result Error.");
+       }
+
+       MSG_END();
+}
+
+
+void SmsPluginSetting::getParamList(MSG_SMSC_LIST_S *pSMSCList)
+{
+       MSG_BEGIN();
+
+       int paramCnt = 0;
+
+       paramCnt = getParamCount();
+
+       MSG_DEBUG("Parameter Count [%d]", paramCnt);
+
+       int ret = TAPI_API_SUCCESS;
+       int reqId = 0;
+
+       MSG_SMSC_DATA_S tmpSmscData = {};
+
+       for (int index = 0; index < paramCnt; index++)
+       {
+               ret = tel_get_sms_parameters(index, &reqId);
+
+               if (ret == TAPI_API_SUCCESS)
+               {
+                       MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
+               }
+               else
+               {
+                       THROW(MsgException::SMS_PLG_ERROR, "######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
+               }
+
+               if (getParamEvent(&tmpSmscData) == true)
+               {
+                       MSG_DEBUG("######## Get Parameter was Successful !!! #######");
+               }
+               else
+               {
+                       THROW(MsgException::SMS_PLG_ERROR, "######## Get Parameter was Failed !!! #######");
+               }
+
+               memcpy(&(pSMSCList->smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S));
+
+               MSG_DEBUG("pid[%d]", pSMSCList->smscData[index].pid);
+               MSG_DEBUG("val_period[%d]", pSMSCList->smscData[index].valPeriod);
+               MSG_DEBUG("name[%s]", pSMSCList->smscData[index].name);
+
+               MSG_DEBUG("ton[%d]", pSMSCList->smscData[index].smscAddr.ton);
+               MSG_DEBUG("npi[%d]", pSMSCList->smscData[index].smscAddr.npi);
+               MSG_DEBUG("address[%s]", pSMSCList->smscData[index].smscAddr.address);
+       }
+
+       pSMSCList->totalCnt = paramCnt;
+       pSMSCList->selected = selectedParam;
+
+       MSG_DEBUG("total_count[%d]", pSMSCList->totalCnt);
+
+       MSG_END();
+}
+
+
+int SmsPluginSetting::getParamCount()
+{
+       int reqId = 0;
+
+       int ret = TAPI_API_SUCCESS;
+
+       ret = tel_get_sms_parameter_count(&reqId);
+
+       if (ret == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("######## tel_get_sms_parameter_count() Success !!! #######");
+       }
+       else
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "tel_get_sms_parameter_count() Error. [%d]", ret);
+       }
+
+       return getParamCntEvent();
+}
+
+
+bool SmsPluginSetting::getParam(int Index, MSG_SMSC_DATA_S *pSmscData)
+{
+       int reqId = 0;
+
+       int ret = TAPI_API_SUCCESS;
+
+       ret = tel_get_sms_parameters(Index, &reqId);
+
+       if (ret == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
+       }
+       else
+       {
+               MSG_DEBUG("######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
+               return false;
+       }
+
+       if (getParamEvent(pSmscData) == true)
+       {
+               MSG_DEBUG("######## Get Parameter was Successful !!! #######");
+       }
+       else
+       {
+               MSG_DEBUG("######## Get Parameter was Failed !!! #######");
+               return false;
+       }
+
+       return true;
+}
+
+
+bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
+{
+       int reqId = 0;
+
+       int ret = TAPI_API_SUCCESS;
+
+       TelSmsCbConfig_t cbConfig = {};
+
+       cbConfig.bCBEnabled = (int)pCbOpt->bReceive;
+
+       if (pCbOpt->bAllChannel == true)
+               cbConfig.SelectedId = 0x01;
+       else
+               cbConfig.SelectedId = 0x02;
+
+       cbConfig.MsgIdCount = pCbOpt->channelData.channelCnt;
+
+       for (int i = 0; i < cbConfig.MsgIdCount; i++)
+       {
+               cbConfig.MsgIDs[i] = (unsigned short)pCbOpt->channelData.channelInfo[i].id;
+       }
+
+       ret = tel_set_sms_cb_config(&cbConfig, &reqId);
+
+       if (ret == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("######## tel_set_sms_cb_config() Success !!! #######");
+       }
+       else
+       {
+               MSG_DEBUG("######## tel_set_sms_cb_config() Fail !!! return : %d #######", ret);
+               return false;
+       }
+
+       if (getResultFromSim() == true)
+       {
+               MSG_DEBUG("######## Set Cb Config was Successful !!! #######");
+       }
+       else
+       {
+               MSG_DEBUG("######## Set Cb Config was Failed !!! #######");
+               return false;
+       }
+
+       return true;
+}
+
+
+bool SmsPluginSetting::getCbConfig(MSG_CBMSG_OPT_S *pCbOpt)
+{
+       int reqId = 0;
+
+       int ret = TAPI_API_SUCCESS;
+
+       ret = tel_get_sms_cb_config(&reqId);
+
+       if (ret == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("######## tel_get_sms_cb_config() Success !!! #######");
+       }
+       else
+       {
+               MSG_DEBUG("######## tel_get_sms_cb_config() Fail !!! return : %d #######", ret);
+               return false;
+       }
+
+       if (getCbConfigEvent(pCbOpt) == true)
+       {
+               MSG_DEBUG("######## Get Cb Config was Successful !!! #######");
+       }
+       else
+       {
+               MSG_DEBUG("######## Get Cb Config was Failed !!! #######");
+               return false;
+       }
+
+       return true;
+}
+
+
+void SmsPluginSetting::setParamCntEvent(int ParamCnt)
+{
+       mx.lock();
+
+       paramCnt = ParamCnt;
+
+       cv.signal();
+
+       mx.unlock();
+}
+
+
+int SmsPluginSetting::getParamCntEvent()
+{
+       int ret = 0;
+
+       mx.lock();
+
+       ret = cv.timedwait(mx.pMutex(), 10);
+
+       mx.unlock();
+
+       if (ret == ETIMEDOUT)
+       {
+               MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+               return 0;
+       }
+
+       return paramCnt;
+}
+
+
+void SmsPluginSetting::setParamEvent(const MSG_SMSC_DATA_S *pSmscData, int RecordIdx, bool bSuccess)
+{
+       mx.lock();
+
+       bTapiResult = bSuccess;
+
+       memset(&smscData, 0x00, sizeof(MSG_SMSC_DATA_S));
+
+       if (bTapiResult == true)
+       {
+               MSG_DEBUG("Success to get parameter data");
+
+               selectedParam = RecordIdx;
+
+               memcpy(&smscData, pSmscData, sizeof(MSG_SMSC_DATA_S));
+       }
+
+       cv.signal();
+
+       mx.unlock();
+}
+
+
+bool SmsPluginSetting::getParamEvent(MSG_SMSC_DATA_S *pSmscData)
+{
+       int ret = 0;
+
+       bTapiResult = false;
+
+       mx.lock();
+
+       ret = cv.timedwait(mx.pMutex(), 10);
+
+       mx.unlock();
+
+       if (ret == ETIMEDOUT)
+       {
+               MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+               return false;
+       }
+
+       memset(pSmscData, 0x00, sizeof(MSG_SMSC_DATA_S));
+
+       if (bTapiResult == true)
+       {
+               memcpy(pSmscData, &smscData, sizeof(MSG_SMSC_DATA_S));
+       }
+
+       return bTapiResult;
+}
+
+
+void SmsPluginSetting::setCbConfigEvent(const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess)
+{
+       mx.lock();
+
+       bTapiResult = bSuccess;
+
+       memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
+
+       if (bTapiResult == true)
+       {
+               MSG_DEBUG("Success to get cb config data");
+
+               memcpy(&cbOpt, pCbOpt, sizeof(MSG_CBMSG_OPT_S));
+       }
+
+       cv.signal();
+
+       mx.unlock();
+}
+
+
+bool SmsPluginSetting::getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt)
+{
+       int ret = 0;
+
+       bTapiResult = false;
+
+       mx.lock();
+
+       ret = cv.timedwait(mx.pMutex(), 10);
+
+       mx.unlock();
+
+       if (ret == ETIMEDOUT)
+       {
+               MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+               return false;
+       }
+
+       memset(pCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
+
+       if (bTapiResult == true)
+       {
+               memcpy(pCbOpt, &cbOpt, sizeof(MSG_CBMSG_OPT_S));
+       }
+
+       return bTapiResult;
+}
+
+
+void SmsPluginSetting::setResultFromSim(bool bResult)
+{
+       mx.lock();
+
+       bTapiResult = bResult;
+
+       cv.signal();
+
+       mx.unlock();
+}
+
+
+bool SmsPluginSetting::getResultFromSim()
+{
+       int ret = 0;
+
+       mx.lock();
+
+       ret = cv.timedwait(mx.pMutex(), 10);
+
+       mx.unlock();
+
+       if (ret == ETIMEDOUT)
+       {
+               MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+               return false;
+       }
+
+       return bTapiResult;
+}
+
+
+SMS_PID_T SmsPluginSetting::convertPid(MSG_SMS_PID_T pid)
+{
+       SMS_PID_T retPid;
+
+       switch (pid)
+       {
+               case MSG_PID_TEXT :
+                       retPid = SMS_PID_NORMAL;
+               break;
+               case MSG_PID_VOICE :
+                       retPid = SMS_PID_VOICE;
+               break;
+               case MSG_PID_FAX :
+                       retPid = SMS_PID_TELEX;
+               break;
+               case MSG_PID_X400 :
+                       retPid = SMS_PID_x400;
+               break;
+               case MSG_PID_ERMES :
+                       retPid = SMS_PID_ERMES;
+               break;
+               case MSG_PID_EMAIL :
+                       retPid = SMS_PID_EMAIL;
+               break;
+               default :
+                       retPid = SMS_PID_NORMAL;
+               break;
+       }
+
+       return retPid;
+}
+
diff --git a/plugin/sms_plugin/SmsPluginSimMsg.cpp b/plugin/sms_plugin/SmsPluginSimMsg.cpp
new file mode 100755 (executable)
index 0000000..73c6a7c
--- /dev/null
@@ -0,0 +1,727 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <errno.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "SmsPluginParamCodec.h"
+#include "SmsPluginTpduCodec.h"
+#include "SmsPluginTransport.h"
+#include "SmsPluginStorage.h"
+#include "SmsPluginEventHandler.h"
+#include "SmsPluginSimMsg.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginSimMsg - Member Functions
+==================================================================================================*/
+SmsPluginSimMsg* SmsPluginSimMsg::pInstance = NULL;
+
+
+SmsPluginSimMsg::SmsPluginSimMsg()
+{
+       // Initialize member variables
+       simMsgId = 0;
+       usedCnt = 0;
+       totalCnt = 0;
+       bTapiResult = false;
+       bClass2Msg = false;
+}
+
+
+SmsPluginSimMsg::~SmsPluginSimMsg()
+{
+
+
+}
+
+
+SmsPluginSimMsg* SmsPluginSimMsg::instance()
+{
+       if (!pInstance)
+               pInstance = new SmsPluginSimMsg();
+
+       return pInstance;
+}
+
+
+void SmsPluginSimMsg::initSimMessage()
+{
+       MSG_BEGIN();
+
+       MSG_SIM_COUNT_S tmpMsgCnt = {};
+
+       getSimMsgCount(&tmpMsgCnt);
+
+       MSG_MESSAGE_INFO_S tmpMsgInfo = {};
+
+       for (int i = 0; i < tmpMsgCnt.usedCount; i++)
+       {
+               // Get SIM Msg
+               if (getSimMsg(tmpMsgCnt.indexList[i], &tmpMsgInfo) == false)
+                       continue;
+
+               if (SmsPluginStorage::instance()->addSimMessage(&tmpMsgInfo) != MSG_SUCCESS)
+               {
+                       MSG_DEBUG("Fail to addSimMessage()");
+               }
+       }
+
+       MSG_END();
+}
+
+
+MSG_ERROR_T SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList)
+{
+       // Reset Out Parameter
+       pSimIdList->count = 0;
+
+       SMS_TPDU_S tpdu;
+
+       tpdu.tpduType = SMS_TPDU_DELIVER;
+
+       // Set SMS TPDU Options
+       setSmsOptions(&(tpdu.data.deliver));
+
+       // Set TimeStamp
+       convertTimeStamp(pMsgInfo, &(tpdu.data.deliver));
+
+       // Set SMSC Options
+       SMS_ADDRESS_S smsc;
+       SmsPluginTransport::instance()->setSmscOptions(&smsc);
+
+       // Make SMS_SUBMIT_DATA_S from MSG_REQUEST_INFO_S
+       SMS_SUBMIT_DATA_S submitData;
+       SmsPluginTransport::instance()->msgInfoToSubmitData(pMsgInfo, &submitData, &(tpdu.data.deliver.dcs.codingScheme));
+
+       // Check sim message full.
+       if (checkSimMsgFull(submitData.segCount) == true)
+       {
+               MSG_DEBUG("SIM storage is full.");
+
+               return MSG_ERR_SIM_STORAGE_FULL;
+       }
+
+       tpdu.data.deliver.userData.headerCnt = 0;
+
+       if (submitData.segCount > 1)
+               tpdu.data.deliver.bHeaderInd = true;
+
+       int bufLen = 0, reqId = 0;
+
+       char buf[MAX_TPDU_DATA_LEN];
+
+       int addLen = strlen(submitData.destAddress.address);
+
+       tpdu.data.deliver.originAddress.ton = submitData.destAddress.ton;
+       tpdu.data.deliver.originAddress.npi = submitData.destAddress.npi;
+
+       memcpy(tpdu.data.deliver.originAddress.address, submitData.destAddress.address, addLen);
+       tpdu.data.deliver.originAddress.address[addLen] = '\0';
+
+       for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++)
+       {
+               if (submitData.userData[segCnt].header[0].udhType == SMS_UDH_CONCAT_8BIT ||
+                       submitData.userData[segCnt].header[0].udhType == SMS_UDH_CONCAT_16BIT)
+               {
+                       tpdu.data.deliver.userData.headerCnt = 1;
+
+                       SmsPluginTransport::instance()->setConcatHeader(&(submitData.userData[segCnt].header[0]), &(tpdu.data.deliver.userData.header[0]));
+               }
+
+               tpdu.data.deliver.userData.length = submitData.userData[segCnt].length;
+               memcpy(tpdu.data.deliver.userData.data, submitData.userData[segCnt].data, submitData.userData[segCnt].length);
+
+               memset(buf, 0x00, sizeof(buf));
+
+               // Encode SMS-DELIVER TPDU
+               bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
+
+               // Make Telephony Structure
+               TelSmsData_t simSmsData;
+               memset((void*)&simSmsData, 0x00, sizeof(simSmsData));
+
+               // Set TPDU data
+               memcpy((void*)simSmsData.SmsData.szData, buf, bufLen);
+
+               simSmsData.SmsData.szData[bufLen] = 0;
+               simSmsData.SmsData.MsgLength = bufLen;
+
+               MSG_DEBUG("Read Status [%d]", pMsgInfo->bRead);
+
+               if (pMsgInfo->bRead == true)
+                       simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_READ;
+               else
+                       simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNREAD;
+
+               // Save SMS in SIM
+               int ret = 0;
+
+               ret = tel_write_sms_in_sim(&simSmsData, &reqId);
+
+               if (ret == TAPI_API_SUCCESS)
+               {
+                       MSG_DEBUG("########  tel_write_sms_in_sim Success !!! req Id : [%d] #######", reqId);
+               }
+               else
+               {
+                       MSG_DEBUG("########  tel_write_sms_in_sim Fail !!! req Id : [%d] return : [%d] #######", reqId, ret);
+
+                       return MSG_ERR_PLUGIN_STORAGE;
+               }
+
+               MSG_SIM_ID_T SimId = 0;
+
+               bool bResult = false;
+
+               bResult = getSimEvent(&SimId);
+
+               int usedCnt = 0;
+
+               if (bResult == true)
+               {
+                       MSG_DEBUG("########  Saving Msg was Successful !!! req Id : [%d] SIM ID : [%d] #######", reqId, SimId);
+
+                       usedCnt = MsgSettingGetInt(SIM_USED_COUNT);
+
+                       usedCnt++;
+
+                       if (MsgSettingSetInt(SIM_USED_COUNT, usedCnt) != MSG_SUCCESS)
+                       {
+                               MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
+                       }
+
+                       pSimIdList->simId[pSimIdList->count] = SimId;
+                       pSimIdList->count++;
+               }
+               else
+               {
+                       MSG_DEBUG("########  Saving Msg was Failed !!! req Id : [%d] SIM ID : [%d] #######", reqId, SimId);
+
+                       return MSG_ERR_PLUGIN_STORAGE;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       // Reset Flag
+       bClass2Msg = false;
+
+       SMS_TPDU_S tpdu;
+
+       tpdu.tpduType = SMS_TPDU_DELIVER;
+
+       // Set SMS TPDU Options
+       setSmsOptions(&(tpdu.data.deliver));
+
+       // Set TimeStamp
+       convertTimeStamp(pMsgInfo, &(tpdu.data.deliver));
+
+       // Set SMSC Options
+       SMS_ADDRESS_S smsc;
+       SmsPluginTransport::instance()->setSmscOptions(&smsc);
+
+       // Make SMS_SUBMIT_DATA_S from MSG_REQUEST_INFO_S
+       SMS_SUBMIT_DATA_S submitData;
+       SmsPluginTransport::instance()->msgInfoToSubmitData(pMsgInfo, &submitData, &(tpdu.data.deliver.dcs.codingScheme));
+
+       // Check sim message full.
+       if (checkSimMsgFull(submitData.segCount) == true)
+       {
+               MSG_DEBUG("SIM storage is full.");
+
+               return MSG_ERR_SIM_STORAGE_FULL;
+       }
+
+       tpdu.data.deliver.userData.headerCnt = 0;
+
+       int bufLen = 0, reqId = 0;
+
+       char buf[MAX_TPDU_DATA_LEN];
+
+       int addrLen = strlen(submitData.destAddress.address);
+
+       tpdu.data.deliver.originAddress.ton = submitData.destAddress.ton;
+       tpdu.data.deliver.originAddress.npi = submitData.destAddress.npi;
+
+       memcpy(tpdu.data.deliver.originAddress.address, submitData.destAddress.address, addrLen);
+       tpdu.data.deliver.originAddress.address[addrLen] = '\0';
+
+       tpdu.data.deliver.userData.length = submitData.userData[0].length;
+       memcpy(tpdu.data.deliver.userData.data, submitData.userData[0].data, submitData.userData[0].length);
+
+       memset(buf, 0x00, sizeof(buf));
+
+       // Encode SMS-DELIVER TPDU
+       bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
+
+       // Make Telephony Structure
+       TelSmsData_t simSmsData;
+       memset((void*)&simSmsData, 0x00, sizeof(simSmsData));
+
+       // Set TPDU data
+       memcpy((void*)simSmsData.SmsData.szData, buf, bufLen);
+
+       simSmsData.SmsData.szData[bufLen] = 0;
+       simSmsData.SmsData.MsgLength = bufLen;
+
+       simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNREAD;
+
+       // Save Class 2 Msg in SIM
+       int tapiRet = TAPI_API_SUCCESS;
+
+       tapiRet = tel_write_sms_in_sim(&simSmsData, &reqId);
+
+       if (tapiRet == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("########  tel_write_sms_in_sim Success !!! req Id : [%d] #######", reqId);
+
+               // Set Flag
+               bClass2Msg = true;
+
+               memset(&simMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+               memcpy(&simMsgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+
+               usedCnt = MsgSettingGetInt(SIM_USED_COUNT);
+
+               usedCnt++;
+
+               if (MsgSettingSetInt(SIM_USED_COUNT, usedCnt) != MSG_SUCCESS)
+               {
+                       MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
+               }
+       }
+       else
+       {
+               MSG_DEBUG("########  tel_write_sms_in_sim Fail !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+
+               SmsPluginTransport::instance()->sendDeliverReport(MSG_ERR_STORAGE_ERROR);
+
+               return MSG_ERR_PLUGIN_STORAGE;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+void SmsPluginSimMsg::deleteSimMessage(MSG_SIM_ID_T SimMsgId)
+{
+       int tapiRet = TAPI_API_SUCCESS;
+       int reqId = 0;
+
+       tapiRet = tel_delete_sms_in_sim((int)SimMsgId, &reqId);
+
+       if (tapiRet == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("########  tel_delete_sms_in_sim Success !!! req Id : [%d] #######", reqId);
+       }
+       else
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "########  tel_delete_sms_in_sim Fail !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+       }
+
+       MSG_SIM_ID_T SimId = 0;
+       bool bResult = false;
+
+       bResult = getSimEvent(&SimId);
+
+       int usedCnt = 0, totalCnt = 0;
+
+       if (bResult == true)
+       {
+               MSG_DEBUG("########  Deleting Msg was Successful !!! req Id : [%d] SIM ID : [%d] #######", reqId, SimId);
+
+               usedCnt = MsgSettingGetInt(SIM_USED_COUNT);
+               totalCnt = MsgSettingGetInt(SIM_TOTAL_COUNT);
+
+               if (usedCnt == totalCnt)
+               {
+                       tapiRet = tel_set_sms_memory_status(TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, &reqId);
+
+                       if (tapiRet == TAPI_API_SUCCESS)
+                       {
+                               MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId);
+                       }
+                       else
+                       {
+                               MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+                       }
+               }
+
+               usedCnt--;
+
+               if (MsgSettingSetInt(SIM_USED_COUNT, usedCnt) != MSG_SUCCESS)
+               {
+                       MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
+               }
+       }
+       else
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "########  Deleting Msg was Failed !!! req Id : [%d] SIM ID : [%d] #######", reqId, SimId);
+       }
+}
+
+
+bool SmsPluginSimMsg::checkSimMsgFull(unsigned int SegCnt)
+{
+       int usedCnt = 0, totalCnt = 0;
+
+       usedCnt = MsgSettingGetInt(SIM_USED_COUNT);
+       totalCnt = MsgSettingGetInt(SIM_TOTAL_COUNT);
+
+       MSG_DEBUG("Segment Count [%d]", SegCnt);
+       MSG_DEBUG("usedCnt [%d], totalCnt [%d]", usedCnt, totalCnt);
+
+       if ((usedCnt + (int)SegCnt) <= totalCnt)
+               return false;
+       else
+               return true;
+}
+
+
+void SmsPluginSimMsg::setReadStatus(MSG_SIM_ID_T SimMsgId)
+{
+       MSG_DEBUG("Sim Message ID [%d]", SimMsgId);
+
+       int reqId = 0;
+
+       int ret = TAPI_API_SUCCESS;
+
+       ret = tel_set_sms_message_status((int)SimMsgId, TAPI_NETTEXT_STATUS_READ, &reqId);
+
+       if (ret == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("########  tel_set_sms_message_status Success !!! return : %d #######", ret);
+       }
+       else
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "########  tel_set_sms_message_status Fail !!! return : %d #######", ret);
+       }
+
+       MSG_SIM_ID_T SimId = 0;
+       bool bResult = false;
+
+       bResult = getSimEvent(&SimId);
+
+       if (bResult == true)
+       {
+               MSG_DEBUG("######## Setting Read Status was Successful !!! req Id : [%d] #######", reqId);
+       }
+       else
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "######## Setting Read Status was Failed !!! req Id : [%d] #######", reqId);
+       }
+}
+
+
+void SmsPluginSimMsg::getSimMsgCount(MSG_SIM_COUNT_S *pSimMsgCnt)
+{
+       int reqId = 0;
+
+       int ret = TAPI_API_SUCCESS;
+
+       ret = tel_get_sms_count(&reqId);
+
+       if (ret == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("######## tel_get_sms_count() Success !!! #######");
+       }
+       else
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "########  tel_get_sms_count() Fail !!! return : %d #######", ret);
+       }
+
+       if (getSimMsgCntEvent(pSimMsgCnt) == true)
+       {
+               MSG_DEBUG("######## Get Sim Msg Count was Successful !!! #######");
+       }
+       else
+       {
+               THROW(MsgException::SMS_PLG_ERROR, "######## Get Sim Msg Count was Failed !!! #######");
+       }
+}
+
+
+bool SmsPluginSimMsg::getSimMsg(MSG_SIM_ID_T SimMsgId, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       int reqId = 0;
+
+       int ret = TAPI_API_SUCCESS;
+
+       ret = tel_read_sms_in_sim(SimMsgId, &reqId);
+
+       if (ret == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("######## tel_read_sms_in_sim() Success !!! Sim ID : [%d] #######", SimMsgId);
+       }
+       else
+       {
+               MSG_DEBUG("########  tel_read_sms_in_sim() Fail !!! return : %d #######", ret);
+               return false;
+       }
+
+       if (getSimMsgEvent(pMsgInfo) == true)
+       {
+               MSG_DEBUG("######## Get Sim Msg was Successful !!! #######");
+       }
+       else
+       {
+               MSG_DEBUG("######## Get Sim Msg was Failed !!! #######");
+               return false;
+       }
+
+       return true;
+}
+
+
+void SmsPluginSimMsg::setSmsOptions(SMS_DELIVER_S *pDeliver)
+{
+       pDeliver->bMoreMsg = false;
+       pDeliver->bStatusReport = false;
+       pDeliver->bHeaderInd = false;
+       pDeliver->bReplyPath = false;
+
+       pDeliver->dcs.bCompressed = false;
+       pDeliver->dcs.msgClass = SMS_MSG_CLASS_NONE;
+       pDeliver->dcs.codingGroup = SMS_GROUP_GENERAL;
+
+       pDeliver->dcs.codingScheme = (SMS_CODING_SCHEME_T)MsgSettingGetInt(SMS_SEND_DCS);
+
+       MSG_DEBUG("DCS : %d", pDeliver->dcs.codingScheme);
+
+       pDeliver->pid = SMS_PID_NORMAL;
+
+       MSG_DEBUG("PID : %d", pDeliver->pid);
+}
+
+
+void SmsPluginSimMsg::convertTimeStamp(const MSG_MESSAGE_INFO_S* pMsgInfo, SMS_DELIVER_S *pDeliver)
+{
+       MSG_BEGIN();
+
+       // encode time stamp
+       pDeliver->timeStamp.format = SMS_TIME_ABSOLUTE;
+
+       // encode absolute time
+       struct tm timeinfo = {0,};
+       gmtime_r(&pMsgInfo->displayTime, &timeinfo);
+
+       pDeliver->timeStamp.time.absolute.year = timeinfo.tm_year - 100;
+       MSG_DEBUG("pDeliver->timeStamp.time.absolute.year is %d",pDeliver->timeStamp.time.absolute.year);
+
+       pDeliver->timeStamp.time.absolute.month = timeinfo.tm_mon + 1;
+       MSG_DEBUG("pDeliver->timeStamp.time.absolute.month is %d",pDeliver->timeStamp.time.absolute.month);
+
+       pDeliver->timeStamp.time.absolute.day = timeinfo.tm_mday;
+       MSG_DEBUG("pDeliver->timeStamp.time.absolute.day is %d",pDeliver->timeStamp.time.absolute.day);
+
+       pDeliver->timeStamp.time.absolute.hour = timeinfo.tm_hour;
+       MSG_DEBUG("pDeliver->timeStamp.time.absolute.hour is %d",pDeliver->timeStamp.time.absolute.hour);
+
+       pDeliver->timeStamp.time.absolute.minute = timeinfo.tm_min;
+       MSG_DEBUG("pDeliver->timeStamp.time.absolute.minute is %d",pDeliver->timeStamp.time.absolute.minute);
+
+       pDeliver->timeStamp.time.absolute.second = timeinfo.tm_sec;
+       MSG_DEBUG("pDeliver->timeStamp.time.absolute.second is %d",pDeliver->timeStamp.time.absolute.second);
+
+       pDeliver->timeStamp.time.absolute.timeZone = 0;
+       MSG_DEBUG("pDeliver->timeStamp.time.absolute.timeZone is %d",pDeliver->timeStamp.time.absolute.timeZone);
+
+       MSG_END();
+}
+
+
+void SmsPluginSimMsg::setSimMsgCntEvent(const MSG_SIM_COUNT_S *pSimMsgCnt)
+{
+       mx.lock();
+
+       MSG_DEBUG("Sim Message Count is %d.", pSimMsgCnt->usedCount);
+
+       for (int i=0; i < pSimMsgCnt->usedCount; i++)
+       {
+               MSG_DEBUG("Sim Message Index is %d.", pSimMsgCnt->indexList[i]);
+       }
+
+       if (MsgSettingSetInt(SIM_USED_COUNT, pSimMsgCnt->usedCount) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
+       }
+
+       if (MsgSettingSetInt(SIM_TOTAL_COUNT, (int)pSimMsgCnt->totalCount) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", SIM_TOTAL_COUNT);
+       }
+
+       memset(&simMsgCnt, 0x00, sizeof(MSG_SIM_COUNT_S));
+       memcpy(&simMsgCnt, pSimMsgCnt, sizeof(MSG_SIM_COUNT_S));
+
+       cv.signal();
+
+       mx.unlock();
+}
+
+
+bool SmsPluginSimMsg::getSimMsgCntEvent(MSG_SIM_COUNT_S *pSimMsgCnt)
+{
+       int ret = 0;
+
+       mx.lock();
+
+       ret = cv.timedwait(mx.pMutex(), 10);
+
+       mx.unlock();
+
+       if (ret == ETIMEDOUT)
+       {
+               MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+               return false;
+       }
+
+       memcpy(pSimMsgCnt, &simMsgCnt, sizeof(MSG_SIM_COUNT_S));
+
+       return true;
+}
+
+
+void SmsPluginSimMsg::setSimMsgEvent(const MSG_MESSAGE_INFO_S *pMsgInfo, bool bSuccess)
+{
+       mx.lock();
+
+       bTapiResult = bSuccess;
+
+       memset(&simMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+       if (bTapiResult  == true)
+       {
+               MSG_DEBUG("Success to get sim msg - Id : [%d]", pMsgInfo->msgId);
+
+               memcpy(&simMsgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+       }
+
+       cv.signal();
+
+       mx.unlock();
+}
+
+
+bool SmsPluginSimMsg::getSimMsgEvent(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       int ret = 0;
+
+       bTapiResult = false;
+
+       mx.lock();
+
+       ret = cv.timedwait(mx.pMutex(), 10);
+
+       mx.unlock();
+
+       if (ret == ETIMEDOUT)
+       {
+               MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+               return false;
+       }
+
+       memset(pMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+       if (bTapiResult == true)
+       {
+               memcpy(pMsgInfo, &simMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+       }
+
+       return bTapiResult;
+}
+
+
+void SmsPluginSimMsg::setSimEvent(MSG_SIM_ID_T SimId, bool bResult)
+{
+       if (bClass2Msg == true)
+       {
+               MSG_ERROR_T err = MSG_SUCCESS;
+
+               simMsgInfo.msgId = SimId;
+
+               // Add Deliver Class2 Msg into DB
+               err = SmsPluginStorage::instance()->addSmsMessage(&simMsgInfo);
+
+               if (err == MSG_SUCCESS)
+               {
+                       MSG_DEBUG("addMessage() Success !!");
+
+                       // Callback
+                       err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&simMsgInfo);
+
+                       if (err != MSG_SUCCESS)
+                       {
+                               MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+                       }
+               }
+               else
+               {
+                       MSG_DEBUG("addMessage() Error !! [%d]", err);
+               }
+
+               // Send Deliver Report
+               SmsPluginTransport::instance()->sendDeliverReport(err);
+
+               bClass2Msg = false;
+       }
+       else
+       {
+               mx.lock();
+
+               simMsgId = SimId;
+               bTapiResult = bResult;
+
+               cv.signal();
+
+               mx.unlock();
+       }
+}
+
+
+bool SmsPluginSimMsg::getSimEvent(MSG_SIM_ID_T *pSimId)
+{
+       int ret = 0;
+
+       bTapiResult = false;
+
+       mx.lock();
+
+       ret = cv.timedwait(mx.pMutex(), 10);
+
+       mx.unlock();
+
+       if (ret == ETIMEDOUT)
+       {
+               MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+               return false;
+       }
+
+       *pSimId = simMsgId;
+
+       MSG_DEBUG("Returned SimMsgId is %d.", simMsgId);
+
+       return bTapiResult;
+}
+
diff --git a/plugin/sms_plugin/SmsPluginStorage.cpp b/plugin/sms_plugin/SmsPluginStorage.cpp
new file mode 100755 (executable)
index 0000000..b6511a6
--- /dev/null
@@ -0,0 +1,1056 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <errno.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgContact.h"
+#include "MsgUtilFile.h"
+#include "MsgUtilStorage.h"
+#include "MsgGconfWrapper.h"
+#include "MsgNotificationWrapper.h"
+#include "SmsPluginMain.h"
+#include "SmsPluginSimMsg.h"
+#include "SmsPluginStorage.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginStorage - Member Functions
+==================================================================================================*/
+SmsPluginStorage* SmsPluginStorage::pInstance = NULL;
+
+
+SmsPluginStorage::SmsPluginStorage()
+{
+}
+
+
+SmsPluginStorage::~SmsPluginStorage()
+{
+       if (dbHandle.disconnect() != MSG_SUCCESS) {
+               MSG_DEBUG("DB Disconnect Fail");
+       }
+}
+
+
+SmsPluginStorage* SmsPluginStorage::instance()
+{
+       if (!pInstance) {
+               MSG_DEBUG("pInstance is NULL. Now creating instance.");
+               pInstance = new SmsPluginStorage();
+       }
+
+       return pInstance;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::updateSentMsg(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_NETWORK_STATUS_T Status)
+{
+       MSG_BEGIN();
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       MSG_DEBUG("Update Msg ID : [%d], Network Status : [%d] ", pMsgInfo->msgId, Status);
+
+       /** Move Msg to SENTBOX */
+       if (Status == MSG_NETWORK_SEND_SUCCESS) {
+               snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET NETWORK_STATUS = %d, FOLDER_ID = %d WHERE MSG_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, Status, MSG_SENTBOX_ID, pMsgInfo->msgId);
+       } else {
+               snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET NETWORK_STATUS = %d WHERE MSG_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, Status, pMsgInfo->msgId);
+       }
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+               MSG_DEBUG("MsgExecQuery() : [%s]", sqlQuery);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::addSimMessage(MSG_MESSAGE_INFO_S *pSimMsgInfo)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       unsigned int msgId = 0;
+       unsigned int addrId = 0;
+       unsigned int simId = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       dbHandle.beginTrans();
+
+       err = MsgStoAddAddress(&dbHandle, &(pSimMsgInfo->addressList[0]), &addrId);
+
+       if (err != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return err;
+       }
+
+       err = dbHandle.getRowId(MSGFW_MESSAGE_TABLE_NAME, &msgId);
+
+       if (err != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return err;
+       }
+
+       simId = pSimMsgInfo->msgId;
+       pSimMsgInfo->msgId = (MSG_MESSAGE_ID_T)msgId;
+
+       SMS_CONCAT_SIM_MSG_S concatSimMsg = {0};
+
+       /** Get Data from Concat SIM Msg */
+       if (pSimMsgInfo->msgType.subType == MSG_CONCAT_SIM_SMS && pSimMsgInfo->bTextSms == false) {
+
+               int fileSize = 0;
+
+               char* pFileData = NULL;
+               AutoPtr<char> buf(&pFileData);
+
+               if (MsgOpenAndReadFile(pSimMsgInfo->msgData, &pFileData, &fileSize) == false) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_STORAGE_ERROR;
+               }
+
+
+               memcpy(&concatSimMsg, (SMS_CONCAT_SIM_MSG_S*)pFileData, fileSize);
+
+               /** Delete temporary file */
+               MsgDeleteFile(pSimMsgInfo->msgData); /** ipc */
+
+               MSG_DEBUG("SIM ID [%d], MSG DATA [%s]", concatSimMsg.simIdCnt, concatSimMsg.msgData);
+       }
+
+       /**  Add Message */
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d, %d, %d, %ld, %d, %d, %d, %d, %d, %d, %ld, %d, ?, '', '', ?, %d, 0, %d, 0, 0);",
+                               MSGFW_MESSAGE_TABLE_NAME, msgId, addrId, pSimMsgInfo->folderId, 0, pSimMsgInfo->storageId,
+                               pSimMsgInfo->msgType.mainType, pSimMsgInfo->msgType.subType, pSimMsgInfo->displayTime, pSimMsgInfo->dataSize,
+                               pSimMsgInfo->networkStatus, pSimMsgInfo->bRead, pSimMsgInfo->bProtected, pSimMsgInfo->priority,
+                               pSimMsgInfo->direction, pSimMsgInfo->scheduledTime, pSimMsgInfo->bBackup, MSG_DELIVERY_REPORT_NONE, MSG_READ_REPORT_NONE);
+
+       MSG_DEBUG("QUERY : %s", sqlQuery);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_PREPARE;
+       }
+
+       dbHandle.bindText(pSimMsgInfo->subject, 1);
+
+       if (pSimMsgInfo->msgType.subType == MSG_CONCAT_SIM_SMS && pSimMsgInfo->bTextSms == false)
+               dbHandle.bindText(concatSimMsg.msgData, 2);
+       else
+               dbHandle.bindText(pSimMsgInfo->msgText, 2);
+
+       if (dbHandle.stepQuery() != MSG_ERR_DB_DONE) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       /** Insert to Sim table */
+       if (pSimMsgInfo->msgType.subType == MSG_CONCAT_SIM_SMS && pSimMsgInfo->bTextSms == false) {
+
+               MSG_DEBUG("sim count : %d", concatSimMsg.simIdCnt);
+
+               for (unsigned int i = 0; i < concatSimMsg.simIdCnt; i++) {
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d);",
+                                               MSGFW_SIM_MSG_TABLE_NAME, msgId, concatSimMsg.simIdList[i]);
+
+                       MSG_DEBUG("QUERY : %s", sqlQuery);
+
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               dbHandle.endTrans(false);
+                               return MSG_ERR_DB_EXEC;
+                       }
+               }
+       } else {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d);",
+                                       MSGFW_SIM_MSG_TABLE_NAME, msgId, simId);
+
+               MSG_DEBUG("QUERY : %s", sqlQuery);
+
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+       }
+
+       /**  Update Address Info. */
+       if (MsgStoUpdateAddress(&dbHandle, addrId) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       dbHandle.endTrans(true);
+
+       return err;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       /**  Check whether storage is full or not */
+       err = checkStorageStatus(pMsgInfo);
+
+       if (err != MSG_SUCCESS) {
+               return err;
+       }
+
+       if (pMsgInfo->msgType.subType == MSG_NORMAL_SMS || pMsgInfo->msgType.subType == MSG_REJECT_SMS) {
+
+               MSG_DEBUG("Add Normal SMS");
+
+               if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
+                       err = SmsPluginSimMsg::instance()->saveClass2Message(pMsgInfo);
+
+                       if (err == MSG_SUCCESS) {
+                               MSG_DEBUG("Success to saveSimMessage.");
+                       } else {
+                               MSG_DEBUG("Fail to saveSimMessage : [%d]", err);
+                       }
+               } else {
+                       /** Class 0 Msg should be saved in hidden folder */
+                       if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
+                               pMsgInfo->folderId = 0;
+                       }
+
+                       /**  Add into DB */
+                       err = addSmsMessage(pMsgInfo);
+               }
+
+       } else if ((pMsgInfo->msgType.subType == MSG_CB_SMS) || (pMsgInfo->msgType.subType == MSG_JAVACB_SMS)) {
+               MSG_DEBUG("Add CB Message");
+               err = addCbMessage(pMsgInfo);
+       } else if ((pMsgInfo->msgType.subType >= MSG_REPLACE_TYPE1_SMS) && (pMsgInfo->msgType.subType <= MSG_REPLACE_TYPE7_SMS)) {
+               MSG_DEBUG("Add Replace SM Type [%d]", pMsgInfo->msgType.subType-3);
+               err = addReplaceTypeMsg(pMsgInfo);
+       } else if ((pMsgInfo->msgType.subType >= MSG_MWI_VOICE_SMS) && (pMsgInfo->msgType.subType <= MSG_MWI_OTHER_SMS)) {
+               MSG_DEBUG("Add MWI Message");
+               err = addSmsMessage(pMsgInfo);
+       } else if ((pMsgInfo->msgType.subType == MSG_WAP_SI_SMS) || (pMsgInfo->msgType.subType == MSG_WAP_CO_SMS)) {
+               MSG_DEBUG("Add WAP Push Message");
+               switch (pMsgInfo->msgType.subType)
+               {
+                       case MSG_WAP_SI_SMS:
+                       {
+                               // save push message information
+                               err = addWAPMessage(pMsgInfo);
+                       }
+                       break;
+
+                       case MSG_WAP_CO_SMS:
+                       {
+                               err = handleCOWAPMessage(pMsgInfo);
+                       }
+                       break;
+               }
+       } else if (pMsgInfo->msgType.subType == MSG_STATUS_REPORT_SMS) {
+               MSG_DEBUG("Add Status Report");
+               err = addSmsMessage(pMsgInfo);
+       }
+
+       if (err == MSG_SUCCESS) {
+               MSG_DEBUG("Success to add message !!");
+       } else {
+               MSG_DEBUG("fail to add message !! : [%d]", err);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::addSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       unsigned int rowId = 0;
+       unsigned int addrId = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       dbHandle.beginTrans();
+
+       if (pMsgInfo->nAddressCnt > 0) {
+
+               err = MsgStoAddAddress(&dbHandle, &(pMsgInfo->addressList[0]), &addrId);
+
+               if (err != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return err;
+               }
+
+               pMsgInfo->addressList[0].threadId = (MSG_THREAD_ID_T)addrId;
+       }
+
+       /**  Add Message Table */
+       rowId = MsgStoAddMessageTable(&dbHandle, pMsgInfo, addrId);
+
+       if (rowId <= 0) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_ROW;
+       }
+
+       /** Update Address table */
+       err = MsgStoUpdateAddress(&dbHandle, addrId);
+
+       if (err != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return err;
+       }
+
+       dbHandle.endTrans(true);
+
+       pMsgInfo->msgId = (MSG_MESSAGE_ID_T)rowId;
+       pMsgInfo->referenceId = (MSG_REFERENCE_ID_T)rowId;
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::updateSmsMessage(MSG_MESSAGE_INFO_S *pMsg)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       unsigned int addrId = 0;
+
+       dbHandle.beginTrans();
+
+       if (pMsg->nAddressCnt > 0) {
+
+               err = MsgStoAddAddress(&dbHandle, &(pMsg->addressList[0]), &addrId);
+
+               if (err != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return err;
+               }
+       }
+
+       int fileSize = 0;
+
+       char* pFileData = NULL;
+       AutoPtr<char> buf(&pFileData);
+
+       /**  Get File Data */
+       if (pMsg->bTextSms == false) {
+               if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_STORAGE_ERROR;
+               }
+       }
+
+       /**  Update Message */
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET ADDRESS_ID = %d, FOLDER_ID = %d, STORAGE_ID = %d, MAIN_TYPE = %d, SUB_TYPE = %d, \
+                                                                       DISPLAY_TIME = %lu, DATA_SIZE = %d, NETWORK_STATUS = %d, READ_STATUS = %d, \
+                                                                       PROTECTED = %d, PRIORITY = %d, MSG_DIRECTION = %d, SCHEDULED_TIME = %lu, BACKUP = %d, SUBJECT = ?, MSG_DATA = ?, THUMB_PATH = ?, MSG_TEXT = ? \
+                                                                       WHERE MSG_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, addrId, pMsg->folderId, pMsg->storageId, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->displayTime, pMsg->dataSize,
+                               pMsg->networkStatus, pMsg->bRead, pMsg->bProtected, pMsg->priority, pMsg->direction, pMsg->scheduledTime, pMsg->bBackup, pMsg->msgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       dbHandle.bindText(pMsg->subject, 1);
+
+       dbHandle.bindText(pMsg->msgData, 2);
+
+       dbHandle.bindText(pMsg->thumbPath, 3);
+
+       if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->bTextSms == false)
+               dbHandle.bindText(pFileData, 4);
+       else
+               dbHandle.bindText(pMsg->msgText, 4);
+
+       MSG_DEBUG("%s", sqlQuery);
+
+       if (dbHandle.stepQuery() != MSG_ERR_DB_DONE) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       dbHandle.finalizeQuery();
+
+       err = MsgStoUpdateAddress(&dbHandle, addrId);
+
+       if (err != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       err = MsgStoClearAddressTable(&dbHandle);
+
+       if (err != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       dbHandle.endTrans(true);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::deleteSmsMessage(MSG_MESSAGE_ID_T MsgId)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+        /**  Get SUB_TYPE, STORAGE_ID */
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MAIN_TYPE, SUB_TYPE, FOLDER_ID, ADDRESS_ID \
+                                       FROM %s WHERE MSG_ID = %d;",
+                       MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       MSG_MESSAGE_TYPE_S msgType;
+       MSG_FOLDER_ID_T folderId;
+
+       unsigned int addrId;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+               msgType.mainType = dbHandle.columnInt(0);
+               msgType.subType = dbHandle.columnInt(1);
+               folderId = dbHandle.columnInt(2);
+               addrId = dbHandle.columnInt(3);
+
+               MSG_DEBUG("Main Type:[%d] SubType:[%d] FolderId:[%d] AddressId:[%d]", msgType.mainType, msgType.subType, folderId, addrId);
+       } else {
+               MSG_DEBUG("MsgStepQuery() Error [%s]", sqlQuery);
+               dbHandle.finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbHandle.finalizeQuery();
+
+       dbHandle.beginTrans();
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SCHEDULED_MSG_TABLE_NAME, MsgId);
+
+       /** Delete Message from scheduled msg table */
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SMS_SENDOPT_TABLE_NAME, MsgId);
+
+       /**  Delete SMS Send Option */
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       if (msgType.subType == MSG_CB_SMS || msgType.subType == MSG_JAVACB_SMS) {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_CB_MSG_TABLE_NAME, MsgId);
+
+               /** Delete Push Message from push table */
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+       } else if (msgType.subType >= MSG_WAP_SI_SMS && msgType.subType <= MSG_WAP_CO_SMS) {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_PUSH_MSG_TABLE_NAME, MsgId);
+
+               /**  Delete Push Message from push table */
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+       } else if (msgType.subType == MSG_SYNCML_CP) {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SYNCML_MSG_TABLE_NAME, MsgId);
+
+               /**  Delete SyncML Message from syncML table */
+               if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+       }
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+       /** Delete Message from msg table */
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       /**  Clear Address table */
+       if (MsgStoClearAddressTable(&dbHandle) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       /**  Update Address Info.*/
+       if (MsgStoUpdateAddress(&dbHandle, addrId) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       dbHandle.endTrans(true);
+
+       if (folderId == MSG_INBOX_ID) {
+               msgType.classType = MSG_CLASS_NONE;
+
+               /**  Set memory status in SIM */
+               if (MsgStoCheckMsgCntFull(&dbHandle, &msgType, folderId) == MSG_SUCCESS) {
+                       MSG_DEBUG("Set Memory Status");
+                       SmsPlgSetMemoryStatus(MSG_SUCCESS);
+               }
+       }
+
+       int smsCnt = 0, mmsCnt = 0;
+
+       smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE);
+       mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
+
+       MsgSettingHandleNewMsg(smsCnt, mmsCnt);
+       MsgDeleteNotiByMsgId(MsgId);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::addCbMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       unsigned int rowId = 0, addrId = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       dbHandle.beginTrans();
+
+       if (pMsgInfo->nAddressCnt > 0) {
+               err = MsgStoAddAddress(&dbHandle, &(pMsgInfo->addressList[0]), &addrId);
+
+               if (err != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return err;
+               }
+
+               pMsgInfo->addressList[0].threadId = (MSG_THREAD_ID_T)addrId;
+       }
+
+       /**  Add Message Table */
+       rowId = MsgStoAddMessageTable(&dbHandle, pMsgInfo, addrId);
+
+       if (rowId <= 0) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_ROW;
+       }
+
+       /**  Get CB Msg ID */
+       unsigned short cbMsgId = (unsigned short)pMsgInfo->msgId;
+
+       /** Add CB Msg in MSG_CBMSG_TABLE */
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       sprintf(sqlQuery, "INSERT INTO %s VALUES (%d, %d);",
+                               MSGFW_CB_MSG_TABLE_NAME, rowId, cbMsgId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       /**  Update Address Info. */
+       if (MsgStoUpdateAddress(&dbHandle, addrId) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       dbHandle.endTrans(true);
+
+       /** Assign Msg ID */
+       pMsgInfo->msgId = (MSG_MESSAGE_ID_T)rowId;
+       pMsgInfo->referenceId = (MSG_REFERENCE_ID_T)rowId;
+
+       return err;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::addReplaceTypeMsg(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       unsigned int addrId = 0, retCnt = 0;
+
+       /** Check if new address or not */
+       if (MsgExistAddress(&dbHandle, pMsgInfo->addressList[0].addressVal, &addrId) == true) {
+               MSG_DEBUG("Address Info. exists [%d] [%s]", addrId, pMsgInfo->addressList[0].addressVal);
+
+               /**  Find Replace Type Msg : Same Replace Type, Same Origin Address */
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*), A.MSG_ID FROM %s A, %s B \
+                                            WHERE A.ADDRESS_ID = B.ADDRESS_ID AND A.SUB_TYPE = %d AND B.ADDRESS_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, pMsgInfo->msgType.subType, addrId);
+
+               if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_PREPARE;
+
+               if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
+                       retCnt = dbHandle.columnInt(0);
+                       pMsgInfo->msgId = dbHandle.columnInt(1);
+               } else {
+                       dbHandle.finalizeQuery();
+                       return MSG_ERR_DB_STEP;
+               }
+
+               dbHandle.finalizeQuery();
+       }
+
+       /** Update New Replace Type Msg */
+       if (retCnt == 1) {
+               MSG_DEBUG("Update Replace Type Msg");
+               err = updateSmsMessage(pMsgInfo);
+       } else if (retCnt == 0) { /** Insert New Replace Type Msg */
+               MSG_DEBUG("Insert Replace Type Msg");
+               err = addSmsMessage(pMsgInfo);
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::addWAPMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_PUSH_MESSAGE_S pushMsg = {};
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       int fileSize = 0;
+
+       char* pFileData = NULL;
+       AutoPtr<char> buf(&pFileData);
+
+       if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false)
+               return MSG_ERR_STORAGE_ERROR;
+
+       MSG_DEBUG("fileSize : %d", fileSize);
+
+       memcpy(&pushMsg, pFileData, fileSize);
+
+       /** Delete temporary file */
+       MsgDeleteFile(pMsgInfo->msgData);
+
+       /** check pPushMsg data */
+
+       MSG_DEBUG("check pushMsg data");
+       MSG_DEBUG("pushMsg.action : [%d]", pushMsg.action);
+       MSG_DEBUG("pushMsg.received : [%d]", pushMsg.received);
+       MSG_DEBUG("pushMsg.created : [%d]", pushMsg.created);
+       MSG_DEBUG("pushMsg.expires : [%d]", pushMsg.expires);
+       MSG_DEBUG("pushMsg.id : [%s]", pushMsg.id);
+       MSG_DEBUG("pushMsg.href : [%s]", pushMsg.href);
+       MSG_DEBUG("pushMsg.contents : [%s]", pushMsg.contents);
+
+       bool bProceed = true;
+
+       /**  check validation of contents */
+       if (checkPushMsgValidation(&pushMsg, &bProceed) != MSG_SUCCESS) {
+               MSG_DEBUG("Fail to check Push Message validation.");
+       }
+
+       /**  if validation check value is false */
+       /** return and drop message. */
+       if (bProceed == false)
+               return MSG_ERR_INVALID_MESSAGE;
+
+       /**  update subject */
+       int len = strlen(pushMsg.contents);
+
+       if (len > MAX_SUBJECT_LEN) {
+               memcpy(pMsgInfo->subject, pushMsg.contents, MAX_SUBJECT_LEN);
+               pMsgInfo->subject[MAX_SUBJECT_LEN] = '\0';
+       } else {
+               strncpy(pMsgInfo->subject, pushMsg.contents, MAX_SUBJECT_LEN);
+       }
+
+       /**  Update Msg Text - remove */
+       strncpy(pMsgInfo->msgText, pushMsg.href, MAX_MSG_TEXT_LEN);
+       pMsgInfo->dataSize = strlen(pMsgInfo->msgText);
+
+       pMsgInfo->bTextSms = true;
+       pMsgInfo->folderId = MSG_INBOX_ID;
+       pMsgInfo->storageId = MSG_STORAGE_PHONE;
+
+       unsigned int addrId = 0;
+
+       dbHandle.beginTrans();
+
+       if (pMsgInfo->nAddressCnt > 0) {
+
+               err = MsgStoAddAddress(&dbHandle, &(pMsgInfo->addressList[0]), &addrId);
+
+               if (err != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return err;
+               }
+       }
+
+       /**  get last row count for Message id */
+       unsigned int rowId = 0;
+
+       /** Add Message Table */
+       rowId = MsgStoAddMessageTable(&dbHandle, pMsgInfo, addrId);
+
+       if (rowId <= 0) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_ROW;
+       }
+
+       /**  add msg_push_table */
+       snprintf (sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %lu, %lu, ?, ?, ?)",
+                                   MSGFW_PUSH_MSG_TABLE_NAME, pMsgInfo->msgId, pushMsg.action, pushMsg.created, pushMsg.expires);
+
+       if ((err = dbHandle.prepareQuery(sqlQuery)) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return err;
+       }
+
+       dbHandle.bindText(pushMsg.id, 1);
+
+       dbHandle.bindText(pushMsg.href, 2);
+
+       dbHandle.bindText(pushMsg.contents, 3);
+
+       if ((err = dbHandle.stepQuery()) != MSG_ERR_DB_DONE) {
+               dbHandle.endTrans(false);
+               return err;
+       }
+
+       /** Update Address Info. */
+       if (MsgStoUpdateAddress(&dbHandle, addrId) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       dbHandle.endTrans(true);
+
+       pMsgInfo->msgId = (MSG_MESSAGE_ID_T)rowId;
+       pMsgInfo->referenceId = (MSG_REFERENCE_ID_T)rowId;
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::handleCOWAPMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char href[MAX_PUSH_CACHEOP_MAX_URL_LEN+1];
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       int fileSize = 0;
+
+       char* pFileData = NULL;
+       AutoPtr<char> buf(&pFileData);
+
+       if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false)
+               return MSG_ERR_STORAGE_ERROR;
+
+       MSG_PUSH_CACHEOP_S *pPushMsg;
+
+       pPushMsg = (MSG_PUSH_CACHEOP_S*)pFileData;
+
+       for (int i = 0; i < pPushMsg->invalObjectCnt; i++) {
+
+               int msgid = -1;
+
+               memset(href, 0x00, sizeof(href));
+               strncpy(href, &(pPushMsg->invalObjectUrl[i][0]), MAX_PUSH_CACHEOP_MAX_URL_LEN);
+
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf (sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE HREF LIKE '%%%s%%';",
+                                       MSGFW_PUSH_MSG_TABLE_NAME, href);
+
+               dbHandle.beginTrans();
+
+               err = dbHandle.prepareQuery(sqlQuery);
+
+               if ((dbHandle.stepQuery() == MSG_ERR_DB_ROW) && err == MSG_SUCCESS) {
+
+                       msgid = dbHandle.getColumnToInt(1);
+
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID= %d;",
+                                               MSGFW_PUSH_MSG_TABLE_NAME, msgid);
+
+                       /** Delete Message from Push table */
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               dbHandle.finalizeQuery();
+                               dbHandle.endTrans(false);
+                               continue;
+                       }
+
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;",
+                                               MSGFW_MESSAGE_TABLE_NAME, msgid);
+
+                       /** Delete Message from msg table */
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               dbHandle.finalizeQuery();
+                               dbHandle.endTrans(false);
+                               continue;
+                       }
+
+                       /** Update all Address */
+                       if (updateAllAddress() != MSG_SUCCESS) {
+                               dbHandle.finalizeQuery();
+                               dbHandle.endTrans(false);
+                               continue;
+                       }
+
+                       /** Clear Address table */
+                       if (MsgStoClearAddressTable(&dbHandle) != MSG_SUCCESS) {
+                               dbHandle.finalizeQuery();
+                               dbHandle.endTrans(false);
+                               continue;
+                       }
+               }
+
+               dbHandle.finalizeQuery();
+
+               dbHandle.endTrans(true);
+       }
+
+       for (int i = 0; i < pPushMsg->invalServiceCnt; i++) {
+
+               int msgid = -1;
+
+               memset(href, 0x00, sizeof(href));
+               strncpy(href, &(pPushMsg->invalObjectUrl[i][0]), MAX_PUSH_CACHEOP_MAX_URL_LEN);
+
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE HREF LIKE '%%%s%%'",
+                                       MSGFW_PUSH_MSG_TABLE_NAME, href);
+
+               dbHandle.beginTrans();
+
+               err = dbHandle.prepareQuery(sqlQuery);
+
+               if ((dbHandle.stepQuery() == MSG_ERR_DB_ROW) && err == MSG_SUCCESS) {
+
+                       msgid = dbHandle.getColumnToInt(1);
+
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       sprintf(sqlQuery, "DELETE FROM %s WHERE MSG_ID='%d'",
+                                               MSGFW_PUSH_MSG_TABLE_NAME, msgid);
+
+                       /** Delete Message from Push table */
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               dbHandle.finalizeQuery();
+                               dbHandle.endTrans(false);
+                               continue;
+                       }
+
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;",
+                                               MSGFW_MESSAGE_TABLE_NAME, msgid);
+
+                       /** Delete Message from msg table */
+                       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+                               dbHandle.finalizeQuery();
+                               dbHandle.endTrans(false);
+                               continue;
+                       }
+
+                       /**  Update all Address */
+                       if (updateAllAddress() != MSG_SUCCESS) {
+                               dbHandle.finalizeQuery();
+                               dbHandle.endTrans(false);
+                               continue;
+                       }
+
+                       /** Clear Address table */
+                       if (MsgStoClearAddressTable(&dbHandle) != MSG_SUCCESS) {
+                               dbHandle.finalizeQuery();
+                               dbHandle.endTrans(false);
+                               continue;
+                       }
+               }
+
+               dbHandle.finalizeQuery();
+
+               dbHandle.endTrans(true);
+       }
+
+       /** delete temporary file */
+       MsgDeleteFile(pMsgInfo->msgData);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::checkPushMsgValidation(MSG_PUSH_MESSAGE_S *pPushMsg, bool *pbProceed)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       unsigned long oldExpireTime = 0;
+       int rowCnt = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       /**  is push message is expired?? */
+       if (pPushMsg->received > pPushMsg->expires) {
+               MSG_DEBUG("Push Message is expired.");
+               pbProceed = false;
+               return err;
+       }
+
+
+       if (pPushMsg->action == MSG_PUSH_SL_ACTION_EXECUTE_LOW) {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT EXPIRES FROM %s WHERE ID = '%s' AND ACTION = %d",
+                                       MSGFW_PUSH_MSG_TABLE_NAME, pPushMsg->id, pPushMsg->action);
+       } else {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT EXPIRES FROM %s WHERE ID = '%s'",
+                                       MSGFW_PUSH_MSG_TABLE_NAME, pPushMsg->id);
+       }
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (rowCnt < 1) {
+               dbHandle.freeTable();
+               return MSG_SUCCESS;
+       }
+
+       oldExpireTime = dbHandle.getColumnToInt(1);
+
+       dbHandle.freeTable();
+
+       if (pPushMsg->created < oldExpireTime) {
+               MSG_DEBUG("Push Message is expired.");
+               pbProceed = false;
+               return err;
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::checkStorageStatus(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = MsgStoCheckMsgCntFull(&dbHandle, &(pMsgInfo->msgType), pMsgInfo->folderId);
+
+       if (err != MSG_SUCCESS) {
+
+               if (err == MSG_ERR_MESSAGE_COUNT_FULL) {
+                       bool bAutoErase = false;
+
+                       MsgSettingGetBool(MSG_AUTO_ERASE, &bAutoErase);
+
+                       MSG_DEBUG("bAutoErase: %d", bAutoErase);
+
+                       if (bAutoErase == true) {
+                               MSG_MESSAGE_ID_T msgId;
+
+                               /** Find the oldest message's msgId */
+                               err = MsgStoGetOldestMessage(&dbHandle, pMsgInfo, &msgId);
+
+                               if (err != MSG_SUCCESS)
+                                       return err;
+
+                               /** Delete the corresponding message. */
+                               err = deleteSmsMessage(msgId);
+                       }
+               }
+
+               return err;
+       }
+
+       return err;
+}
+
+
+MSG_ERROR_T SmsPluginStorage::updateAllAddress()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int rowCnt = 0, index = 1;
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ADDRESS_ID FROM %s",
+                               MSGFW_ADDRESS_TABLE_NAME);
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err == MSG_ERR_DB_NORECORD) {
+               dbHandle.freeTable();
+               return MSG_SUCCESS;
+       } else if ( err != MSG_SUCCESS) {
+               dbHandle.freeTable();
+               return err;
+       }
+
+
+       for (int i = 0; i < rowCnt; i++) {
+
+               err = MsgStoUpdateAddress(&dbHandle, index++);
+
+               if (err != MSG_SUCCESS)
+                       break;
+       }
+
+       dbHandle.freeTable();
+
+       return err;
+}
diff --git a/plugin/sms_plugin/SmsPluginTextConvert.cpp b/plugin/sms_plugin/SmsPluginTextConvert.cpp
new file mode 100755 (executable)
index 0000000..8129fbf
--- /dev/null
@@ -0,0 +1,896 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <glib.h>
+
+#include "MsgDebug.h"
+#include "SmsPluginTextConvert.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgConvertText - Member Functions
+==================================================================================================*/
+SmsPluginTextConvert* SmsPluginTextConvert::pInstance = NULL;
+
+
+SmsPluginTextConvert* SmsPluginTextConvert::instance()
+{
+       if (!pInstance)
+               pInstance = new SmsPluginTextConvert();
+
+       return pInstance;
+}
+
+
+int SmsPluginTextConvert::convertUTF8ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, OUT SMS_LANGUAGE_ID_T *pLangId)
+{
+       int utf8Length = 0;
+       int gsm7bitLength = 0;
+       int ucs2Length = 0;
+
+       if (srcTextLen <= 0)
+       {
+               utf8Length = strlen((char*)pSrcText);
+               srcTextLen = utf8Length;
+       }
+       else
+       {
+               utf8Length = srcTextLen;
+       }
+
+       int maxUCS2Length = utf8Length;         // max # of UCS2 chars, NOT bytes. when all utf8 chars are only one byte, UCS2Length is maxUCS2 Length. otherwise (ex: 2 bytes of UTF8 is one char) UCS2Length must be  less than utf8Length
+       WCHAR pUCS2Text[maxUCS2Length];
+       memset(pUCS2Text, 0x00, maxUCS2Length * sizeof(WCHAR));
+
+       MSG_DEBUG("srcTextLen = %d", srcTextLen);
+       MSG_DEBUG("temp buffer size = %d", maxUCS2Length * sizeof(WCHAR));
+       MSG_DEBUG("max dest Length = %d", maxLength);
+
+       ucs2Length = convertUTF8ToUCS2((unsigned char*)pUCS2Text, maxUCS2Length * sizeof(WCHAR), pSrcText, srcTextLen);
+       gsm7bitLength = convertUCS2ToGSM7bit(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length, pLangId);
+
+       return gsm7bitLength;
+}
+
+
+/**
+       if srcTextLen ispSrcText should be null terminated
+return :
+               byte length of converted UCS2 characters
+                       -1 : converting error
+*/
+int SmsPluginTextConvert::convertUTF8ToUCS2(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen)
+{
+       int i, j;
+       int textLen;
+       unsigned char *unicodeTemp = (unsigned char*)pDestText;
+       int ucs2Length = 0;
+       int remainedBuffer = maxLength;
+
+       i = j = 0;
+
+       if(maxLength == 0 || pSrcText == NULL || pDestText ==  NULL)
+       {
+               MSG_DEBUG("UTF8 to UCS2 Failed as text length is 0\n");
+               return -1;
+       }
+
+       // null terminated string
+       if ( srcTextLen == -1 )
+       {
+               textLen = strlen((char*)pSrcText);
+               srcTextLen = textLen;
+       }
+       else
+       {
+               textLen = srcTextLen;
+       }
+
+       GIConv cd;
+       int err=0;
+
+       cd = g_iconv_open("UCS-2BE", "UTF8");
+
+       if (cd > 0)
+       {
+               err = g_iconv(cd, (char**)&pSrcText, (gsize*)&textLen, (char**)&unicodeTemp, (gsize*)&remainedBuffer);
+       }
+
+       if(err < 0)
+       {
+               MSG_DEBUG("Error in g_iconv.");
+               ucs2Length = -1;
+       }
+       else
+       {
+               ucs2Length = maxLength - remainedBuffer;
+       }
+
+       g_iconv_close(cd);
+
+       return ucs2Length;
+}
+
+
+int SmsPluginTextConvert::convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_ENCODE_TYPE_T *pCharType)
+{
+       int utf8Length = 0;
+       int gsm7bitLength = 0;
+       int ucs2Length = 0;
+
+       bool bUnknown = false;
+
+       utf8Length = srcTextLen;
+
+       int maxUCS2Length = utf8Length;         // max # of UCS2 chars, NOT bytes. when all utf8 chars are only one byte, UCS2Length is maxUCS2 Length. otherwise (ex: 2 bytes of UTF8 is one char) UCS2Length must be  less than utf8Length
+       WCHAR pUCS2Text[maxUCS2Length];
+       memset(pUCS2Text, 0x00, maxUCS2Length * sizeof(WCHAR));
+
+       MSG_DEBUG("srcTextLen = %d", srcTextLen);
+       MSG_DEBUG("temp buffer size = %d", maxUCS2Length * sizeof(WCHAR));
+       MSG_DEBUG("max dest Length = %d", maxLength);
+
+       ucs2Length = convertUTF8ToUCS2((unsigned char*)pUCS2Text, maxUCS2Length * sizeof(WCHAR), pSrcText, srcTextLen);
+
+       if(ucs2Length < 0)
+       {
+               *pCharType = MSG_ENCODE_8BIT;
+
+               memcpy(pDestText, pSrcText, srcTextLen);
+               return srcTextLen;
+       }
+       else
+       {
+               gsm7bitLength = convertUCS2ToGSM7bitAuto(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length, &bUnknown);
+
+               if (bUnknown == true)
+               {
+                       *pCharType = MSG_ENCODE_UCS2;
+
+                       if (ucs2Length > 0)
+                               memcpy(pDestText, pUCS2Text, ucs2Length);
+
+                       return ucs2Length;
+               }
+               else
+               {
+                       *pCharType = MSG_ENCODE_GSM7BIT;
+               }
+
+               return gsm7bitLength;
+       }
+}
+
+
+/**
+return:
+               bytelength of UTF8 text
+*/
+int SmsPluginTextConvert::convertGSM7bitToUTF8(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, IN SMS_LANG_INFO_S *pLangInfo)
+{
+       int utf8Length = 0;
+       int ucs2Length = 0;
+       int maxUCS2Length = srcTextLen;         // max # of UCS2 chars, NOT bytes. when all gsm7 chars are only one byte(-there is no extenstion), UCS2Length is maxUCS2 Length. otherwise(ex: gsm7 char starts with 0x1b) UCS2Length must be less than gsm7 legnth
+
+       WCHAR pUCS2Text[maxUCS2Length];
+       memset(pUCS2Text, 0x00, maxUCS2Length * sizeof(WCHAR));
+
+       MSG_DEBUG("srcTextLen = %d\n", srcTextLen);
+       MSG_DEBUG("max dest Length = %d\n", maxLength);
+
+       ucs2Length = convertGSM7bitToUCS2((unsigned char*)pUCS2Text, maxUCS2Length * sizeof(WCHAR), pSrcText, srcTextLen, pLangInfo);
+       utf8Length = convertUCS2ToUTF8(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length);
+
+       return utf8Length;
+}
+
+
+/**
+args:
+       OUT unsigned char *pDestText
+       IN int maxLength                : max byte length of destination text
+       IN const unsigned char *pSrcText
+       IN  int srcTextLen              : byte length of UCS2 source text
+return :
+               byte length of converted UTF8 characters
+                       -1 : The alpha isn't the gsm 7bit code
+*/
+int SmsPluginTextConvert::convertUCS2ToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN  int srcTextLen)
+{
+       int remainedBuffer = maxLength;
+       int utf8Length;
+
+       unsigned char * pTempDestText = pDestText;
+
+       if (srcTextLen == 0 || pSrcText == NULL || pDestText ==  NULL || maxLength == 0)
+       {
+               MSG_DEBUG("UCS2 to UTF8 Failed as text length is 0\n");
+               return false;
+       }
+
+       GIConv cd;
+       int err=0;
+
+       cd = g_iconv_open( "UTF8", "UCS-2BE" );
+
+       if (cd > 0)
+       {
+               err = g_iconv(cd, (char**)&pSrcText, (gsize*)&srcTextLen, (char**)&pDestText, (gsize*)&remainedBuffer);
+       }
+
+       utf8Length = maxLength - remainedBuffer;
+       pTempDestText[utf8Length] = 0x00;
+
+       g_iconv_close(cd);
+
+       return utf8Length;
+}
+
+
+int SmsPluginTextConvert::convertEUCKRToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN  int srcTextLen)
+{
+       int remainedBuffer = maxLength;
+       int utf8Length;
+
+       unsigned char * pTempDestText = pDestText;
+
+       if(srcTextLen == 0 || pSrcText == NULL || pDestText ==  NULL || maxLength == 0)
+       {
+               MSG_DEBUG("EUCKR to UTF8 Failed as text length is 0\n");
+               return false;
+       }
+
+       GIConv cd;
+       int err=0;
+
+       cd = g_iconv_open( "UTF8", "EUCKR" );
+
+       if (cd > 0)
+       {
+               err = g_iconv(cd, (char**)&pSrcText, (gsize*)&srcTextLen, (char**)&pDestText, (gsize*)&remainedBuffer);
+       }
+
+       utf8Length = maxLength - remainedBuffer;
+       pTempDestText[utf8Length] = 0x00;
+
+       g_iconv_close(cd);
+
+       return utf8Length;
+}
+
+
+/**
+
+args:
+               unsigned char *pDestText
+               int maxLength                           : max destination buffer size
+               const unsigned char *pSrcText
+               int srcTextLen                          : BYTE length of src text (UCS2)
+return:
+               bytelength of gsm7bit text
+               -1 : converting error
+*/
+int SmsPluginTextConvert::convertUCS2ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT SMS_LANGUAGE_ID_T *pLangId)
+{
+       // for UNICODE
+       int outTextLen = 0;
+       unsigned char lowerByte, upperByte;
+
+       if (srcTextLen == 0 || pSrcText == NULL || pDestText ==  NULL || maxLength == 0)
+       {
+               MSG_DEBUG("UCS2 to GSM7bit Failed as text length is 0\n");
+               return -1;
+       }
+
+       std::map<unsigned short, unsigned char>::iterator itChar;
+       std::map<unsigned short, unsigned char>::iterator itExt;
+
+       SMS_CHAR_TYPE_T currType = SMS_CHAR_DEFAULT;
+       SMS_CHAR_TYPE_T newType = SMS_CHAR_DEFAULT;
+
+       unsigned short inText;
+
+       // Get Language Type by checking each character
+       for (int index = 0; index < srcTextLen; index++)
+       {
+               upperByte = pSrcText[index++];
+               lowerByte = pSrcText[index];
+
+               inText = (upperByte << 8) & 0xFF00;
+
+               inText = inText | lowerByte;
+
+               itExt = extCharList.find(inText);
+
+               if (itExt != extCharList.end())
+               {
+                       newType = (SMS_CHAR_TYPE_T)itExt->second;
+
+                       if (newType >= currType)
+                       {
+                               currType = newType;
+                       }
+               }
+       }
+
+MSG_DEBUG("charType : [%d]", currType);
+
+       for (int index = 0; index < srcTextLen; index++)
+       {
+               upperByte = pSrcText[index++];
+               lowerByte = pSrcText[index];
+
+               inText = (upperByte << 8) & 0xFF00;
+               inText = inText | lowerByte;
+
+MSG_DEBUG("inText : [%04x]", inText);
+
+               // Check Default Char
+               itChar = ucs2toGSM7DefList.find(inText);
+
+               if (itChar != ucs2toGSM7DefList.end())
+               {
+MSG_DEBUG("default char");
+                       pDestText[outTextLen++] = (unsigned char)itChar->second;
+               }
+               else
+               {
+                       if (currType == SMS_CHAR_GSM7EXT)
+                       {
+                               itExt = ucs2toGSM7ExtList.find(inText);
+
+                               if (itExt != ucs2toGSM7ExtList.end())
+                               {
+                                       // prevent buffer overflow
+                                       if (maxLength <= outTextLen + 1)
+                                       {
+                                               MSG_DEBUG("Buffer Full");
+                                               break;
+                                       }
+
+                                       pDestText[outTextLen++] = 0x1B;
+                                       pDestText[outTextLen++] = (unsigned char)itExt->second;
+                               }
+                               else
+                               {
+                                       pDestText[outTextLen++] = 0x20;
+                               }
+                       }
+                       else if (currType == SMS_CHAR_TURKISH)
+                       {
+                               *pLangId = SMS_LANG_ID_TURKISH;
+
+                               itExt = ucs2toTurkishList.find(inText);
+
+                               if (itExt != ucs2toTurkishList.end())
+                               {
+                                       // prevent buffer overflow
+                                       if (maxLength <= outTextLen + 1)
+                                       {
+                                               MSG_DEBUG("Buffer Full");
+                                               break;
+                                       }
+
+                                       pDestText[outTextLen++] = 0x1B;
+                                       pDestText[outTextLen++] = (unsigned char)itExt->second;
+                               }
+                               else
+                               {
+                                       pDestText[outTextLen++] = 0x20;
+                               }
+                       }
+                       else if (currType == SMS_CHAR_SPANISH)
+                       {
+                               *pLangId = SMS_LANG_ID_SPANISH;
+
+                               itExt = ucs2toSpanishList.find(inText);
+
+                               if (itExt != ucs2toSpanishList.end())
+                               {
+                                       // prevent buffer overflow
+                                       if (maxLength <= outTextLen + 1)
+                                       {
+                                               MSG_DEBUG("Buffer Full");
+                                               break;
+                                       }
+
+                                       pDestText[outTextLen++] = 0x1B;
+                                       pDestText[outTextLen++] = (unsigned char)itExt->second;
+                               }
+                               else
+                               {
+                                       pDestText[outTextLen++] = 0x20;
+                               }
+                       }
+                       else if (currType == SMS_CHAR_PORTUGUESE)
+                       {
+                               *pLangId = SMS_LANG_ID_PORTUGUESE;
+
+                               itExt = ucs2toPortuList.find(inText);
+
+                               if (itExt != ucs2toPortuList.end())
+                               {
+                                       // prevent buffer overflow
+                                       if (maxLength <= outTextLen + 1)
+                                       {
+                                               MSG_DEBUG("Buffer Full");
+                                               break;
+                                       }
+
+MSG_DEBUG("ucs2toPortuList : [%02x]", (unsigned char)itExt->second);
+
+                                       pDestText[outTextLen++] = 0x1B;
+                                       pDestText[outTextLen++] = (unsigned char)itExt->second;
+                               }
+                               else
+                               {
+MSG_DEBUG("no char");
+                                       pDestText[outTextLen++] = 0x20;
+                               }
+                       }
+                       else
+                       {
+                               pDestText[outTextLen++] = 0x20;
+                       }
+               }
+
+               // prevent buffer overflow
+               if (maxLength <= outTextLen)
+               {
+                       MSG_DEBUG("Buffer full\n");
+                       break;
+               }
+       }
+
+       return outTextLen;
+}
+
+
+int SmsPluginTextConvert::convertUCS2ToGSM7bitAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT bool *pUnknown)
+{
+       // for UNICODE
+       int outTextLen = 0;
+       unsigned char lowerByte, upperByte;
+
+       if (srcTextLen == 0 || pSrcText == NULL || pDestText ==  NULL || maxLength == 0)
+       {
+               MSG_DEBUG("UCS2 to GSM7bit Failed as text length is 0\n");
+               return -1;
+       }
+
+       std::map<unsigned short, unsigned char>::iterator itChar;
+       std::map<unsigned short, unsigned char>::iterator itExt;
+
+       unsigned short inText;
+
+       for (int index = 0; index < srcTextLen; index++)
+       {
+               upperByte = pSrcText[index++];
+               lowerByte = pSrcText[index];
+
+               inText = (upperByte << 8) & 0xFF00;
+               inText = inText | lowerByte;
+
+               // Check Default Char
+               itChar = ucs2toGSM7DefList.find(inText);
+
+               if (itChar != ucs2toGSM7DefList.end())
+               {
+                       pDestText[outTextLen++] = (unsigned char)itChar->second;
+               }
+               else
+               {
+                       itExt = ucs2toGSM7ExtList.find(inText);
+
+                       if (itExt != ucs2toGSM7ExtList.end())
+                       {
+                               // prevent buffer overflow
+                               if (maxLength <= outTextLen + 1)
+                               {
+                                       MSG_DEBUG("Buffer Full");
+                                       break;
+                               }
+
+                               pDestText[outTextLen++] = 0x1B;
+                               pDestText[outTextLen++] = (unsigned char)itExt->second;
+                       }
+                       else
+                       {
+                               *pUnknown = true;
+                               return 0;
+                       }
+               }
+
+               // prevent buffer overflow
+               if (maxLength <= outTextLen)
+               {
+                       MSG_DEBUG("Buffer full\n");
+                       break;
+               }
+       }
+
+       return outTextLen;
+}
+
+
+/**
+ args :
+               unsigned char *pDestText                                : destination text (UCS2) - byte order depends on local byte order
+               const unsigned char *pSrcText           : source text (gsm7bit)
+               int maxLength                   : max destination buffer size
+               int srcTextLen                  : byte length of source text (gsm7bit)
+ return :
+               byte length of converted UCS2 characters
+                       -1 : The alpha isn't the gsm 7bit code
+*/
+int SmsPluginTextConvert::convertGSM7bitToUCS2(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, IN SMS_LANG_INFO_S *pLangInfo)
+{
+       int outTextLen = 0;
+       unsigned char lowerByte = 0, upperByte = 0;
+
+       if (srcTextLen == 0 || pSrcText == NULL || pDestText ==  NULL || maxLength == 0)
+       {
+               MSG_DEBUG("UCS2 to GSM7bit Failed as text length is 0\n");
+               return -1;
+       }
+
+       for (int i = 0; i<srcTextLen; i++)
+       {
+               if (maxLength == 0)
+               {
+                       break;
+               }
+
+               if (pSrcText[i] >= 0x80)
+               {
+                       //error
+                       MSG_DEBUG(">>>>>>>a_pTextString[i]=%x, The alpha isn't the gsm 7bit code, Never Come here!!!\n", pSrcText[i]);
+                       return -1;
+               }
+
+               if (pLangInfo->bLockingShift == true) // National Language Locking Shift
+               {
+                       MSG_DEBUG("Locking Shift [%d]", pLangInfo->lockingLang);
+
+                       if (pLangInfo->lockingLang == SMS_LANG_ID_TURKISH)
+                       {
+                               // Check Escape
+                               if (g_TurkishLockingToUCS2[pSrcText[i]] == 0x001B)
+                               {
+                                       i++;
+
+                                       if (pLangInfo->bSingleShift == true) // National Language Single Shift
+                                       {
+                                               MSG_DEBUG("Single Shift [%d]", pLangInfo->singleLang);
+
+                                               if (pLangInfo->singleLang == SMS_LANG_ID_TURKISH)
+                                               {
+                                                       lowerByte = g_TurkishSingleToUCS2[pSrcText[i]] & 0x00FF;
+                                                       upperByte = (g_TurkishSingleToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                               }
+                                               else if (pLangInfo->singleLang == SMS_LANG_ID_SPANISH)
+                                               {
+                                                       lowerByte = g_SpanishSingleToUCS2[pSrcText[i]] & 0x00FF;
+                                                       upperByte = (g_SpanishSingleToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                               }
+                                               else if (pLangInfo->singleLang == SMS_LANG_ID_PORTUGUESE)
+                                               {
+                                                       lowerByte = g_PortuSingleToUCS2[pSrcText[i]] & 0x00FF;
+                                                       upperByte = (g_PortuSingleToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                               }
+                                               else
+                                               {
+                                                       lowerByte = g_GSM7BitExtToUCS2[pSrcText[i]] & 0x00FF;
+                                                       upperByte = (g_GSM7BitExtToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                               }
+                                       }
+                                       else // GSM 7 bit Default Alphabet Extension Table
+                                       {
+                                               lowerByte = g_GSM7BitExtToUCS2[pSrcText[i]] & 0x00FF;
+                                               upperByte = (g_GSM7BitExtToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                       }
+                               }
+                               else // TURKISH - National Language Locking Shift
+                               {
+                                       lowerByte = g_TurkishLockingToUCS2[pSrcText[i]] & 0x00FF;
+                                       upperByte = (g_TurkishLockingToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                               }
+                       }
+                       else if (pLangInfo->lockingLang == SMS_LANG_ID_PORTUGUESE)
+                       {
+                               // Check Escape
+                               if (g_PortuLockingToUCS2[pSrcText[i]] == 0x001B)
+                               {
+                                       i++;
+
+                                       if (pLangInfo->bSingleShift == true) // National Language Single Shift
+                                       {
+                                               MSG_DEBUG("Single Shift [%d]", pLangInfo->singleLang);
+
+                                               if (pLangInfo->singleLang == SMS_LANG_ID_TURKISH)
+                                               {
+                                                       lowerByte = g_TurkishSingleToUCS2[pSrcText[i]] & 0x00FF;
+                                                       upperByte = (g_TurkishSingleToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                               }
+                                               else if (pLangInfo->singleLang == SMS_LANG_ID_SPANISH)
+                                               {
+                                                       lowerByte = g_SpanishSingleToUCS2[pSrcText[i]] & 0x00FF;
+                                                       upperByte = (g_SpanishSingleToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                               }
+                                               else if (pLangInfo->singleLang == SMS_LANG_ID_PORTUGUESE)
+                                               {
+                                                       lowerByte = g_PortuSingleToUCS2[pSrcText[i]] & 0x00FF;
+                                                       upperByte = (g_PortuSingleToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                               }
+                                               else
+                                               {
+                                                       lowerByte = g_GSM7BitExtToUCS2[pSrcText[i]] & 0x00FF;
+                                                       upperByte = (g_GSM7BitExtToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                               }
+                                       }
+                                       else // GSM 7 bit Default Alphabet Extension Table
+                                       {
+                                               lowerByte = g_GSM7BitExtToUCS2[pSrcText[i]] & 0x00FF;
+                                               upperByte = (g_GSM7BitExtToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                       }
+                               }
+                               else // PORTUGUESE - National Language Locking Shift
+                               {
+                                       lowerByte = g_PortuLockingToUCS2[pSrcText[i]] & 0x00FF;
+                                       upperByte = (g_PortuLockingToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                               }
+                       }
+               }
+               else
+               {
+                       // Check Escape
+                       if (g_GSM7BitToUCS2[pSrcText[i]] == 0x001B)
+                       {
+                               i++;
+
+                               if (pLangInfo->bSingleShift == true) // National Language Single Shift
+                               {
+                                       MSG_DEBUG("Single Shift [%d]", pLangInfo->singleLang);
+
+                                       if (pLangInfo->singleLang == SMS_LANG_ID_TURKISH)
+                                       {
+                                               lowerByte = g_TurkishSingleToUCS2[pSrcText[i]] & 0x00FF;
+                                               upperByte = (g_TurkishSingleToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                       }
+                                       else if (pLangInfo->singleLang == SMS_LANG_ID_SPANISH)
+                                       {
+                                               lowerByte = g_SpanishSingleToUCS2[pSrcText[i]] & 0x00FF;
+                                               upperByte = (g_SpanishSingleToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                       }
+                                       else if (pLangInfo->singleLang == SMS_LANG_ID_PORTUGUESE)
+                                       {
+                                               lowerByte = g_PortuSingleToUCS2[pSrcText[i]] & 0x00FF;
+                                               upperByte = (g_PortuSingleToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                       }
+                                       else
+                                       {
+                                               lowerByte = g_GSM7BitExtToUCS2[pSrcText[i]] & 0x00FF;
+                                               upperByte = (g_GSM7BitExtToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                                       }
+                               }
+                               else // GSM 7 bit Default Alphabet Extension Table
+                               {
+                                       lowerByte = g_GSM7BitExtToUCS2[pSrcText[i]] & 0x00FF;
+                                       upperByte = (g_GSM7BitExtToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                               }
+                       }
+                       else
+                       {
+                               lowerByte = g_GSM7BitToUCS2[pSrcText[i]] & 0x00FF;
+                               upperByte = (g_GSM7BitToUCS2[pSrcText[i]] & 0xFF00) >> 8;
+                       }
+               }
+
+               pDestText[outTextLen++] = upperByte;
+               pDestText[outTextLen++] = lowerByte;
+               maxLength -= 2;
+       }
+
+       return outTextLen;
+}
+
+
+void SmsPluginTextConvert::convertDumpTextToHex(const unsigned char *pText, int length)
+{
+       printf("\n=======================================\n");
+       printf("   Dump Text To Hex - Length :%d\n", length);
+       printf("=======================================");
+
+       for (int i = 0; i < length; i++ )
+       {
+               if ( i % MAX_DUMP_COLUMN == 0 )
+               {
+                       printf("\n\t");
+               }
+               printf("%02x ", pText[i]);
+       }
+
+       printf("\n=======================================\n\n");
+}
+
+
+SmsPluginTextConvert::SmsPluginTextConvert()
+{
+       extCharList.clear();
+       ucs2toGSM7DefList.clear();
+       ucs2toGSM7ExtList.clear();
+       ucs2toTurkishList.clear();
+       ucs2toSpanishList.clear();
+       ucs2toPortuList.clear();
+
+       extCharList[0x000C] = SMS_CHAR_GSM7EXT;
+       extCharList[0x005B] = SMS_CHAR_GSM7EXT;
+       extCharList[0x005C] = SMS_CHAR_GSM7EXT;
+       extCharList[0x005D] = SMS_CHAR_GSM7EXT;
+       extCharList[0x005E] = SMS_CHAR_GSM7EXT;
+       extCharList[0x007B] = SMS_CHAR_GSM7EXT;
+       extCharList[0x007C] = SMS_CHAR_GSM7EXT;
+       extCharList[0x007D] = SMS_CHAR_GSM7EXT;
+       extCharList[0x007E] = SMS_CHAR_GSM7EXT;
+       extCharList[0x20AC] = SMS_CHAR_GSM7EXT; // ï¿½ï¿½
+
+       extCharList[0x00E7] = SMS_CHAR_TURKISH;
+       extCharList[0x011E] = SMS_CHAR_TURKISH;
+       extCharList[0x011F] = SMS_CHAR_TURKISH;
+       extCharList[0x01E6] = SMS_CHAR_TURKISH;
+       extCharList[0x01E7] = SMS_CHAR_TURKISH;
+       extCharList[0x0130] = SMS_CHAR_TURKISH;
+       extCharList[0x0131] = SMS_CHAR_TURKISH;
+       extCharList[0x015E] = SMS_CHAR_TURKISH;
+       extCharList[0x015F] = SMS_CHAR_TURKISH;
+
+       extCharList[0x00C1] = SMS_CHAR_SPANISH;
+       extCharList[0x00E1] = SMS_CHAR_SPANISH;
+       extCharList[0x00CD] = SMS_CHAR_SPANISH;
+       extCharList[0x00ED] = SMS_CHAR_SPANISH;
+       extCharList[0x00D3] = SMS_CHAR_SPANISH;
+       extCharList[0x00F3] = SMS_CHAR_SPANISH;
+       extCharList[0x00DA] = SMS_CHAR_SPANISH;
+       extCharList[0x00FA] = SMS_CHAR_SPANISH;
+
+       extCharList[0x00D4] = SMS_CHAR_PORTUGUESE;
+       extCharList[0x00F4] = SMS_CHAR_PORTUGUESE;
+       extCharList[0x00CA] = SMS_CHAR_PORTUGUESE;
+       extCharList[0x00EA] = SMS_CHAR_PORTUGUESE;
+       extCharList[0x00C0] = SMS_CHAR_PORTUGUESE;
+       extCharList[0x00E7] = SMS_CHAR_PORTUGUESE;
+       extCharList[0x00C3] = SMS_CHAR_PORTUGUESE;
+       extCharList[0x00E3] = SMS_CHAR_PORTUGUESE;
+       extCharList[0x00D5] = SMS_CHAR_PORTUGUESE;
+       extCharList[0x00F5] = SMS_CHAR_PORTUGUESE;
+       extCharList[0x00C2] = SMS_CHAR_PORTUGUESE;
+       extCharList[0x00E2] = SMS_CHAR_PORTUGUESE;
+
+       for (unsigned char i = 0; i < 128; i++)
+       {
+               ucs2toGSM7DefList[g_GSM7BitToUCS2[i]] = i;
+       }
+
+       // GSM 7 bit Extension
+       ucs2toGSM7ExtList[0x005B] = 0x3C; // [
+       ucs2toGSM7ExtList[0x005D] = 0x3E; // ]
+       ucs2toGSM7ExtList[0x007B] = 0x28; // {
+       ucs2toGSM7ExtList[0x007D] = 0x29; // }
+       ucs2toGSM7ExtList[0x000C] = 0x0A; // Page Break
+       ucs2toGSM7ExtList[0x005C] = 0x2F; /* \ */
+       ucs2toGSM7ExtList[0x005E] = 0x14; // ^
+       ucs2toGSM7ExtList[0x007C] = 0x40; // |
+       ucs2toGSM7ExtList[0x007E] = 0x3D; // ~
+       ucs2toGSM7ExtList[0x20AC] = 0x65; // ï¿½ï¿½
+
+       // Turkish
+       ucs2toTurkishList[0x005B] = 0x3C; // [
+       ucs2toTurkishList[0x005D] = 0x3E; // ]
+       ucs2toTurkishList[0x007B] = 0x28; // {
+       ucs2toTurkishList[0x007D] = 0x29; // }
+       ucs2toTurkishList[0x000C] = 0x0A; // Page Break
+       ucs2toTurkishList[0x005C] = 0x2F; /* \ */
+       ucs2toTurkishList[0x005E] = 0x14; // ^
+       ucs2toTurkishList[0x007C] = 0x40; // |
+       ucs2toTurkishList[0x007E] = 0x3D; // ~
+       ucs2toTurkishList[0x20AC] = 0x65; // ï¿½ï¿½
+       ucs2toTurkishList[0x00E7] = 0x63; // c LATIN SMALL LETTER S WITH CEDILLA *
+       ucs2toTurkishList[0x011E] = 0x47; // G LATIN CAPITAL LETTER G WITH BREVE
+       ucs2toTurkishList[0x011F] = 0x67; // g LATIN SMALL LETTER G WITH BREVE
+       ucs2toTurkishList[0x01E6] = 0x47; // G LATIN CAPITAL LETTER G WITH CARON
+       ucs2toTurkishList[0x01E7] = 0x67; // g LATIN SMALL LETTER G WITH CARON
+       ucs2toTurkishList[0x0130] = 0x49; // I LATIN CAPITAL LETTER I WITH DOT ABOVE
+       ucs2toTurkishList[0x0131] = 0x69; // i LATIN SMALL LETTER DOTLESS
+       ucs2toTurkishList[0x015E] = 0x53; // S LATIN CAPITAL LETTER S WITH CEDILLA *
+       ucs2toTurkishList[0x015F] = 0x73; // s LATIN SMALL LETTER S WITH CEDILLA *
+
+       // Spanish
+       ucs2toSpanishList[0x005B] = 0x3C; // [
+       ucs2toSpanishList[0x005D] = 0x3E; // ]
+       ucs2toSpanishList[0x007B] = 0x28; // {
+       ucs2toSpanishList[0x007D] = 0x29; // }
+       ucs2toSpanishList[0x000C] = 0x0A; // Page Break
+       ucs2toSpanishList[0x005C] = 0x2F; /* \ */
+       ucs2toSpanishList[0x005E] = 0x14; // ^
+       ucs2toSpanishList[0x007C] = 0x40; // |
+       ucs2toSpanishList[0x007E] = 0x3D; // ~
+       ucs2toSpanishList[0x20AC] = 0x65; // ï¿½ï¿½
+       ucs2toSpanishList[0x00C1] = 0x41; // A
+       ucs2toSpanishList[0x00E1] = 0x61; // a
+       ucs2toSpanishList[0x00CD] = 0x49; // I
+       ucs2toSpanishList[0x00ED] = 0x69; // i
+       ucs2toSpanishList[0x00D3] = 0x4F; // O
+       ucs2toSpanishList[0x00F3] = 0x6F; // o
+       ucs2toSpanishList[0x00DA] = 0x55; // U
+       ucs2toSpanishList[0x00FA] = 0x75; // u
+
+       // Portuguese
+       ucs2toPortuList[0x005B] = 0x3C; // [
+       ucs2toPortuList[0x005D] = 0x3E; // ]
+       ucs2toPortuList[0x007B] = 0x28; // {
+       ucs2toPortuList[0x007D] = 0x29; // }
+       ucs2toPortuList[0x000C] = 0x0A; // Page Break
+       ucs2toPortuList[0x005C] = 0x2F; /* \ */
+       ucs2toPortuList[0x005E] = 0x14; // ^
+       ucs2toPortuList[0x007C] = 0x40; // |
+       ucs2toPortuList[0x007E] = 0x3D; // ~
+       ucs2toPortuList[0x20AC] = 0x65; // ï¿½ï¿½
+       ucs2toPortuList[0x00D4] = 0x0B; // O
+       ucs2toPortuList[0x00F4] = 0x0C; // o
+       ucs2toPortuList[0x00C1] = 0x0E; // A
+       ucs2toPortuList[0x00E1] = 0x0F; // a
+       ucs2toPortuList[0x00CA] = 0x1F; // E
+       ucs2toPortuList[0x00EA] = 0x05; // e
+       ucs2toPortuList[0x00C0] = 0x41; // A
+       ucs2toPortuList[0x00E7] = 0x09; // c
+       ucs2toPortuList[0x00CD] = 0x49; // I
+       ucs2toPortuList[0x00ED] = 0x69; // i
+       ucs2toPortuList[0x00D3] = 0x4F; // O
+       ucs2toPortuList[0x00F3] = 0x6F; // o
+       ucs2toPortuList[0x00DA] = 0x55; // U
+       ucs2toPortuList[0x00FA] = 0x75; // u
+       ucs2toPortuList[0x00C3] = 0x61; // A
+       ucs2toPortuList[0x00E3] = 0x7B; // a
+       ucs2toPortuList[0x00D5] = 0x5C; // O
+       ucs2toPortuList[0x00F5] = 0x7C; // o
+       ucs2toPortuList[0x00C2] = 0x61; // A
+       ucs2toPortuList[0x00E2] = 0x7F; // a
+       ucs2toPortuList[0x03A6] = 0x12; // ï¿½ï¿½
+       ucs2toPortuList[0x0393] = 0x13; // ï¿½ï¿½
+       ucs2toPortuList[0x03A9] = 0x15; // ï¿½ï¿½
+       ucs2toPortuList[0x03A0] = 0x16; // ï¿½ï¿½
+       ucs2toPortuList[0x03A8] = 0x17; // ï¿½ï¿½
+       ucs2toPortuList[0x03A3] = 0x18; // ï¿½ï¿½
+       ucs2toPortuList[0x0398] = 0x19; // ï¿½ï¿½
+}
+
+
+SmsPluginTextConvert::~SmsPluginTextConvert()
+{
+       extCharList.clear();
+       ucs2toGSM7DefList.clear();
+       ucs2toGSM7ExtList.clear();
+       ucs2toTurkishList.clear();
+       ucs2toSpanishList.clear();
+       ucs2toPortuList.clear();
+
+       if (pInstance)
+       {
+               delete pInstance;
+               pInstance = NULL;
+       }
+}
+
diff --git a/plugin/sms_plugin/SmsPluginTpduCodec.cpp b/plugin/sms_plugin/SmsPluginTpduCodec.cpp
new file mode 100755 (executable)
index 0000000..ad9899c
--- /dev/null
@@ -0,0 +1,610 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "MsgUtilFile.h"
+
+#include "SmsPluginTpduCodec.h"
+#include "SmsPluginParamCodec.h"
+#include "SmsPluginUDCodec.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginTpduCodec - Member Functions
+==================================================================================================*/
+SmsPluginTpduCodec::SmsPluginTpduCodec()
+{
+
+
+}
+
+
+SmsPluginTpduCodec::~SmsPluginTpduCodec()
+{
+
+
+}
+
+
+int SmsPluginTpduCodec::encodeTpdu(const SMS_TPDU_S *pSmsTpdu, char *pTpdu)
+{
+       int tpduLen = 0;
+
+       switch (pSmsTpdu->tpduType)
+       {
+               case SMS_TPDU_SUBMIT:
+                       tpduLen = encodeSubmit(&(pSmsTpdu->data.submit), pTpdu);
+               break;
+
+               case SMS_TPDU_DELIVER:
+                       tpduLen = encodeDeliver(&(pSmsTpdu->data.deliver), pTpdu);
+               break;
+
+               case SMS_TPDU_DELIVER_REP:
+                       tpduLen = encodeDeliverReport(&(pSmsTpdu->data.deliverRep), pTpdu);
+               break;
+
+               case SMS_TPDU_STATUS_REP:
+                       tpduLen = encodeStatusReport(&(pSmsTpdu->data.statusRep), pTpdu);
+               break;
+       }
+
+       return tpduLen;
+}
+
+
+int SmsPluginTpduCodec::decodeTpdu(const unsigned char *pTpdu, int TpduLen, SMS_TPDU_S *pSmsTpdu)
+{
+       int decodeLen = 0;
+
+       char mti = pTpdu[0] & 0x03;
+
+       switch (mti)
+       {
+               case 0x00:
+                       pSmsTpdu->tpduType = SMS_TPDU_DELIVER;
+                       decodeLen = decodeDeliver(pTpdu, TpduLen, &(pSmsTpdu->data.deliver));
+               break;
+
+               case 0x01:
+                       pSmsTpdu->tpduType = SMS_TPDU_SUBMIT;
+                       decodeLen = decodeSubmit(pTpdu, TpduLen, &(pSmsTpdu->data.submit));
+               break;
+
+               case 0x02:
+                       pSmsTpdu->tpduType = SMS_TPDU_STATUS_REP;
+                       decodeLen = decodeStatusReport(pTpdu, TpduLen, &(pSmsTpdu->data.statusRep));
+               break;
+       }
+
+       return decodeLen;
+}
+
+
+int SmsPluginTpduCodec::encodeSubmit(const SMS_SUBMIT_S *pSubmit, char *pTpdu)
+{
+       int offset = 0, length = 0, encodeSize = 0;
+
+       char* address = NULL;
+       AutoPtr<char> addressBuf(&address);
+
+       char* dcs = NULL;
+       AutoPtr<char> dcsBuf(&dcs);
+
+       char* vpTime = NULL;
+       AutoPtr<char> vpBuf(&vpTime);
+
+       //TP-MTI
+       pTpdu[offset] = 0x01;
+
+       //TP-RD
+       if(pSubmit->bRejectDup == false)
+               pTpdu[offset] |= 0x04;
+
+       //TP-VPF
+       switch (pSubmit->vpf)
+       {
+               case SMS_VPF_NOT_PRESENT:
+                       break;
+               case SMS_VPF_ENHANCED:
+                       pTpdu[offset] |= 0x08;
+                       break;
+               case SMS_VPF_RELATIVE:
+                       pTpdu[offset] |= 0x10;
+                       break;
+               case SMS_VPF_ABSOLUTE:
+                       pTpdu[offset] |= 0x18;
+                       break;
+               default:
+                       break;
+       }
+
+       //TP-SRR
+       if (pSubmit->bStatusReport == true)
+               pTpdu[offset] |= 0x20;
+
+       MSG_DEBUG("TP-SRR pSubmit->bStatusReport : %d.", pSubmit->bStatusReport);
+
+       //TP-UDHI
+       if (pSubmit->bHeaderInd == true)
+               pTpdu[offset] |= 0x40;
+
+       //TP-RP
+       if (pSubmit->bReplyPath == true)
+               pTpdu[offset] |= 0x80;
+
+       offset++;
+
+       //TP-MR
+       pTpdu[offset++] = pSubmit->msgRef;
+
+       MSG_DEBUG("TP-MR pSubmit->msgRef : %d.", pSubmit->msgRef);
+
+       //TP-DA
+       length = SmsPluginParamCodec::encodeAddress(&pSubmit->destAddress, &address);
+       memcpy(&(pTpdu[offset]), address, length);
+       offset += length;
+
+       MSG_DEBUG("TP-DA length : %d.", length);
+
+       //TP-PID
+       pTpdu[offset++] = pSubmit->pid;
+
+       MSG_DEBUG("TP-PID pSubmit->pid : %d.", pSubmit->pid);
+
+       //TP-DCS
+       length = SmsPluginParamCodec::encodeDCS(&pSubmit->dcs, &dcs);
+       memcpy(&(pTpdu[offset]), dcs, length);
+       offset += length;
+
+       MSG_DEBUG("TP-DCS length : %d.", length);
+
+       //TP-VP
+       if (pSubmit->vpf != SMS_VPF_NOT_PRESENT)
+       {
+               length = SmsPluginParamCodec::encodeTime(&pSubmit->validityPeriod, &vpTime);
+
+               if (length > 0)
+               {
+                       memcpy(&(pTpdu[offset]), vpTime, length);
+                       offset += length;
+               }
+       }
+
+       encodeSize = SmsPluginUDCodec::encodeUserData(&(pSubmit->userData), pSubmit->dcs.codingScheme, &(pTpdu[offset]));
+
+MSG_DEBUG("encodeSize : %d", encodeSize);
+
+       offset += encodeSize;
+
+       return offset;
+}
+
+
+int SmsPluginTpduCodec::encodeDeliver(const SMS_DELIVER_S *pDeliver, char *pTpdu)
+{
+       int offset = 0, length = 0, encodeSize = 0;
+
+       char* address = NULL;
+       AutoPtr<char> addressBuf(&address);
+
+       char* dcs = NULL;
+       AutoPtr<char> dcsBuf(&dcs);
+
+       char* scts = NULL;
+       AutoPtr<char> timeBuf(&scts);
+
+       // TP-MTI : 00
+       pTpdu[offset] = 0x00;
+
+       // TP-MMS
+       if (pDeliver->bMoreMsg == false)
+               pTpdu[offset] |= 0x04;
+
+       // TP-SRI
+       if (pDeliver->bStatusReport == true)
+               pTpdu[offset] |= 0x20;
+
+       // TP-UDHI
+       if (pDeliver->bHeaderInd == true)
+               pTpdu[offset] |= 0x40;
+
+       // TP-RP
+       if (pDeliver->bReplyPath == true)
+               pTpdu[offset] |= 0x80;
+
+       offset++;
+
+       // TP-OA
+       length = SmsPluginParamCodec::encodeAddress(&pDeliver->originAddress, &address);
+       memcpy(&(pTpdu[offset]), address, length);
+       offset += length;
+
+       // TP-PID
+       pTpdu[offset++] = pDeliver->pid;
+
+       // TP-DCS
+       length = SmsPluginParamCodec::encodeDCS(&pDeliver->dcs, &dcs);
+       memcpy(&(pTpdu[offset]), dcs, length);
+       offset += length;
+
+       // TP-SCTS
+       length = SmsPluginParamCodec::encodeTime(&pDeliver->timeStamp, &scts);
+       memcpy(&(pTpdu[offset]), scts, length);
+       offset += length;
+
+       // TP-UDL & TP-UD
+       encodeSize = SmsPluginUDCodec::encodeUserData(&(pDeliver->userData), pDeliver->dcs.codingScheme, &(pTpdu[offset]));
+
+       MSG_DEBUG("encodeSize : %d", encodeSize);
+
+       offset += encodeSize;
+
+       return offset;
+}
+
+
+int SmsPluginTpduCodec::encodeDeliverReport(const SMS_DELIVER_REPORT_S *pDeliverRep, char *pTpdu)
+{
+       int offset = 0;
+
+       // TP-MTI : 00
+       pTpdu[offset] = 0x00;
+
+       // TP-UDHI
+       if (pDeliverRep->bHeaderInd == true)
+               pTpdu[offset] |= 0x40;
+
+       offset++;
+
+       // TP-FCS
+       if (pDeliverRep->reportType == SMS_REPORT_NEGATIVE)
+               pTpdu[offset++] = pDeliverRep->failCause;
+
+       // TP-PI
+       pTpdu[offset++] = pDeliverRep->paramInd;
+
+       // TP-PID
+       if (pDeliverRep->paramInd & 0x01)
+               pTpdu[offset++] = pDeliverRep->pid;
+
+       // TP-DCS
+       if (pDeliverRep->paramInd & 0x02)
+       {
+               int length = 0;
+
+               char* dcs = NULL;
+               AutoPtr<char> dcsBuf(&dcs);
+
+               length = SmsPluginParamCodec::encodeDCS(&pDeliverRep->dcs, &dcs);
+               memcpy(&(pTpdu[offset]), dcs, length);
+
+               offset += length;
+       }
+
+       // TP-UDL & TP-UD
+       if (pDeliverRep->paramInd & 0x04)
+       {
+               int encodeSize = 0;
+
+               encodeSize = SmsPluginUDCodec::encodeUserData(&(pDeliverRep->userData), pDeliverRep->dcs.codingScheme, &(pTpdu[offset]));
+
+               MSG_DEBUG("encodeSize : %d", encodeSize);
+
+               offset += encodeSize;
+       }
+
+       pTpdu[offset] = '\0';
+
+       return offset;
+}
+
+
+int SmsPluginTpduCodec::encodeStatusReport(const SMS_STATUS_REPORT_S *pStatusRep, char *pTpdu)
+{
+       int offset = 0, length = 0;
+
+       char* address = NULL;
+       AutoPtr<char> addressBuf(&address);
+
+       char* scts = NULL;
+       AutoPtr<char> sctsBuf(&scts);
+
+       char* dt = NULL;
+       AutoPtr<char> dtBuf(&dt);
+
+       // TP-MTI : 10
+       pTpdu[offset] = 0x02;
+
+       // TP-MMS
+       if (pStatusRep->bMoreMsg == true)
+               pTpdu[offset] |= 0x04;
+
+       // TP-SRQ
+       if (pStatusRep->bStatusReport == true)
+               pTpdu[offset] |= 0x20;
+
+       // TP-UDHI
+       if (pStatusRep->bHeaderInd == true)
+               pTpdu[offset] |= 0x40;
+
+       offset++;
+
+       // TP-MR
+       pTpdu[offset++] = pStatusRep->msgRef;
+
+       // TP-RA
+       length = SmsPluginParamCodec::encodeAddress(&pStatusRep->recipAddress, &address);
+       memcpy(&(pTpdu[offset]), address, length);
+       offset += length;
+
+       // TP-SCTS
+       length = SmsPluginParamCodec::encodeTime(&pStatusRep->timeStamp, &scts);
+       memcpy(&(pTpdu[offset]), scts, length);
+       offset += length;
+
+       // TP-DT
+       length = SmsPluginParamCodec::encodeTime(&pStatusRep->dischargeTime, &dt);
+       memcpy(&(pTpdu[offset]), dt, length);
+       offset += length;
+
+       // TP-Status
+       pTpdu[offset++] = pStatusRep->status;
+
+       // TP-PI
+       pTpdu[offset++] = pStatusRep->paramInd;
+
+       // TP-PID
+       if (pStatusRep->paramInd & 0x01)
+               pTpdu[offset++] = pStatusRep->pid;
+
+       // TP-DCS
+       if (pStatusRep->paramInd & 0x02)
+       {
+               int length = 0;
+
+               char* dcs = NULL;
+               AutoPtr<char> dcsBuf(&dcs);
+
+               length = SmsPluginParamCodec::encodeDCS(&pStatusRep->dcs, &dcs);
+               memcpy(&(pTpdu[offset]), dcs, length);
+
+               offset += length;
+       }
+
+       // TP-UDL & TP-UD
+       if (pStatusRep->paramInd & 0x04)
+       {
+               int encodeSize = 0;
+
+               encodeSize = SmsPluginUDCodec::encodeUserData(&(pStatusRep->userData), pStatusRep->dcs.codingScheme, &(pTpdu[offset]));
+
+               MSG_DEBUG("encodeSize : %d", encodeSize);
+
+               offset += encodeSize;
+       }
+
+       pTpdu[offset] = '\0';
+
+       return offset;
+}
+
+
+int SmsPluginTpduCodec::decodeSubmit(const unsigned char *pTpdu, int TpduLen, SMS_SUBMIT_S *pSubmit)
+{
+       int offset = 0, udLen = 0;
+
+       // TP-RD
+       if (pTpdu[offset] & 0x04)
+               pSubmit->bRejectDup = false;
+       else
+               pSubmit->bRejectDup = true;
+
+       // TP-VPF
+       pSubmit->vpf = (SMS_VPF_T)(pTpdu[offset] & 0x18);
+
+       // TP-SRR
+       if (pTpdu[offset] & 0x20)
+               pSubmit->bStatusReport = true;
+       else
+               pSubmit->bStatusReport = false;
+
+       // TP-UDHI
+       if (pTpdu[offset] & 0x40)
+               pSubmit->bHeaderInd = true;
+       else
+               pSubmit->bHeaderInd = false;
+
+       // TP-RP
+       if (pTpdu[offset] & 0x80)
+               pSubmit->bReplyPath = true;
+       else
+               pSubmit->bReplyPath = false;
+
+       offset++;
+
+       // TP-MR
+       pSubmit->msgRef = pTpdu[offset++];
+
+       // TP-DA
+       offset += SmsPluginParamCodec::decodeAddress(pTpdu+offset, &(pSubmit->destAddress));
+
+       // TP-PID
+       pSubmit->pid = pTpdu[offset++];
+
+       // TP-DCS
+       offset += SmsPluginParamCodec::decodeDCS(pTpdu+offset, &(pSubmit->dcs));
+
+       // TP-VP
+       if (pSubmit->vpf != SMS_VPF_NOT_PRESENT)
+       {
+               // Decode VP
+       }
+
+       // TP-UDL & TP-UD
+       udLen = SmsPluginUDCodec::decodeUserData(pTpdu+offset, TpduLen, pSubmit->bHeaderInd, pSubmit->dcs.codingScheme, &(pSubmit->userData));
+
+       return udLen;
+}
+
+
+int SmsPluginTpduCodec::decodeDeliver(const unsigned char *pTpdu, int TpduLen, SMS_DELIVER_S *pDeliver)
+{
+       int offset = 0, udLen = 0;
+
+       // TP-MMS
+       if (pTpdu[offset] & 0x04)
+               pDeliver->bMoreMsg = false;
+       else
+               pDeliver->bMoreMsg = true;
+
+       // TP-SRI
+       if (pTpdu[offset] & 0x20)
+               pDeliver->bStatusReport = true;
+       else
+               pDeliver->bStatusReport = false;
+
+       // TP-UDHI
+       if (pTpdu[offset] & 0x40)
+               pDeliver->bHeaderInd = true;
+       else
+               pDeliver->bHeaderInd = false;
+
+       // TP-RP
+       if (pTpdu[offset] & 0x80)
+               pDeliver->bReplyPath = true;
+       else
+               pDeliver->bReplyPath = false;
+
+       offset++;
+
+       // TP-OA
+       offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pDeliver->originAddress));
+
+       // TP-PID
+       pDeliver->pid = pTpdu[offset++];
+
+       // TP-DCS
+       offset += SmsPluginParamCodec::decodeDCS(&pTpdu[offset], &(pDeliver->dcs));
+
+       // TP-SCTS
+       offset += SmsPluginParamCodec::decodeTime(&pTpdu[offset], &(pDeliver->timeStamp));
+
+       // TP-UD
+       udLen = SmsPluginUDCodec::decodeUserData(&pTpdu[offset], TpduLen, pDeliver->bHeaderInd, pDeliver->dcs.codingScheme, &(pDeliver->userData), &(pDeliver->udData));
+
+       return udLen;
+}
+
+
+int SmsPluginTpduCodec::decodeStatusReport(const unsigned char *pTpdu, int TpduLen, SMS_STATUS_REPORT_S *pStatusRep)
+{
+       int offset = 0, udLen = 0;
+
+       char* address = NULL;
+       AutoPtr<char> addressBuf(&address);
+
+       char* scts = NULL;
+       AutoPtr<char> sctsBuf(&scts);
+
+       char* dt = NULL;
+       AutoPtr<char> dtBuf(&dt);
+
+       // TP-MMS
+       if (pTpdu[offset] & 0x04)
+               pStatusRep->bMoreMsg = false;
+       else
+               pStatusRep->bMoreMsg = true;
+
+       // TP-SRQ
+       if (pTpdu[offset] & 0x20)
+               pStatusRep->bStatusReport = true;
+       else
+               pStatusRep->bStatusReport = false;
+
+       // TP-UDHI
+       if (pTpdu[offset] & 0x40)
+               pStatusRep->bHeaderInd = true;
+       else
+               pStatusRep->bHeaderInd = false;
+
+       offset++;
+
+       // TP-MR
+       pStatusRep->msgRef = pTpdu[offset++];
+
+       // TP-RA
+       offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pStatusRep->recipAddress));
+
+       // TP-SCTS
+       // Decode timestamp
+       offset += SmsPluginParamCodec::decodeTime(&pTpdu[offset], &(pStatusRep->timeStamp));
+
+       // TP-DT
+       // Decode timestamp
+       offset += SmsPluginParamCodec::decodeTime(&pTpdu[offset], &(pStatusRep->dischargeTime));
+
+       // TP-Status
+       pStatusRep->status = pTpdu[offset++];
+
+       // TP-PI
+       pStatusRep->paramInd = pTpdu[offset++];
+
+       // No Parameters
+       if (pStatusRep->paramInd == 0)
+       {
+               pStatusRep->pid = SMS_PID_NORMAL;
+
+               pStatusRep->dcs.bCompressed = false;
+               pStatusRep->dcs.bMWI = false;
+               pStatusRep->dcs.bIndActive = false;
+
+               pStatusRep->dcs.msgClass = MSG_CLASS_NONE;
+               pStatusRep->dcs.codingScheme = SMS_CHARSET_7BIT;
+               pStatusRep->dcs.codingGroup = SMS_GROUP_GENERAL;
+               pStatusRep->dcs.indType = SMS_OTHER_INDICATOR;
+
+               pStatusRep->userData.headerCnt = 0;
+               pStatusRep->userData.length = 0;
+               memset(pStatusRep->userData.data, 0x00, MAX_USER_DATA_LEN+1);
+       }
+
+       // TP-PID
+       if (pStatusRep->paramInd & 0x01)
+               pStatusRep->pid = pTpdu[offset++];
+
+       // TP-DCS
+       if (pStatusRep->paramInd & 0x02)
+       {
+               offset += SmsPluginParamCodec::decodeDCS(&pTpdu[offset], &(pStatusRep->dcs));
+       }
+
+       // TP-UDL & TP-UD
+       if (pStatusRep->paramInd & 0x04)
+       {
+               // Decode User Data
+               udLen = SmsPluginUDCodec::decodeUserData(&pTpdu[offset], TpduLen, pStatusRep->bHeaderInd, pStatusRep->dcs.codingScheme, &(pStatusRep->userData));
+       }
+
+       return udLen;
+}
+
diff --git a/plugin/sms_plugin/SmsPluginTransport.cpp b/plugin/sms_plugin/SmsPluginTransport.cpp
new file mode 100755 (executable)
index 0000000..1532e60
--- /dev/null
@@ -0,0 +1,777 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <errno.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "MsgUtilFile.h"
+#include "SmsPluginTextConvert.h"
+#include "SmsPluginParamCodec.h"
+#include "SmsPluginTpduCodec.h"
+#include "SmsPluginEventHandler.h"
+#include "SmsPluginStorage.h"
+#include "SmsPluginTransport.h"
+
+extern "C"
+{
+       #include <ITapiNetText.h>
+}
+
+#define MSG_DEBUG_BY_FILE
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginTransport - Member Functions
+==================================================================================================*/
+SmsPluginTransport* SmsPluginTransport::pInstance = NULL;
+
+
+SmsPluginTransport::SmsPluginTransport()
+{
+       msgRef          = 0x00;
+       msgRef8bit      = 0x00;
+       msgRef16bit     = 0x0000;
+}
+
+
+SmsPluginTransport::~SmsPluginTransport()
+{
+
+}
+
+
+SmsPluginTransport* SmsPluginTransport::instance()
+{
+       if (!pInstance)
+               pInstance = new SmsPluginTransport();
+
+       return pInstance;
+}
+
+
+void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo)
+{
+       MSG_BEGIN();
+
+       SMS_TPDU_S tpdu;
+
+       tpdu.tpduType = SMS_TPDU_SUBMIT;
+
+       // Set SMS Send Options - Setting
+       setSmsSendOptions(&(tpdu.data.submit));
+
+       // Set SMS Send Options - Each Message
+       if (pReqInfo->sendOptInfo.bSetting == true)
+       {
+               tpdu.data.submit.bStatusReport = pReqInfo->sendOptInfo.bDeliverReq;
+               tpdu.data.submit.bReplyPath = pReqInfo->sendOptInfo.option.smsSendOptInfo.bReplyPath;
+       }
+
+       // Set Coding Scheme for apps that use port number
+       if (pReqInfo->msgInfo.msgPort.valid == true)
+       {
+               tpdu.data.submit.dcs.codingScheme = (SMS_CODING_SCHEME_T)pReqInfo->msgInfo.encodeType;
+
+               MSG_DEBUG("DCS is changed by application : [%d]", tpdu.data.submit.dcs.codingScheme);
+       }
+
+       // Set SMSC Options
+       SMS_ADDRESS_S smsc;
+       setSmscOptions(&smsc);
+
+       // Make SMS_SUBMIT_DATA_S from MSG_REQUEST_INFO_S
+       SMS_SUBMIT_DATA_S submitData = {{0},};
+       msgInfoToSubmitData(&(pReqInfo->msgInfo), &submitData, &(tpdu.data.submit.dcs.codingScheme));
+
+       // Encode SMSC Address
+       unsigned char smscAddr[MAX_SMSC_LEN];
+       memset(smscAddr, 0x00, sizeof(smscAddr));
+
+       int smscLen = SmsPluginParamCodec::encodeSMSC(&smsc, smscAddr);
+
+       if (smscLen <= 0) return;
+
+       for (int i = 0; i < smscLen; i++)
+       {
+               MSG_DEBUG("pSCAInfo [%02x]", smscAddr[i]);
+       }
+
+       int bufLen = 0, reqId = 0;
+
+       char buf[MAX_TPDU_DATA_LEN];
+
+       int addLen = strlen(submitData.destAddress.address);
+
+       tpdu.data.submit.destAddress.ton = submitData.destAddress.ton;
+       tpdu.data.submit.destAddress.npi = submitData.destAddress.npi;
+
+       memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, addLen);
+       tpdu.data.submit.destAddress.address[addLen] = '\0';
+
+       for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++)
+       {
+               if (submitData.userData[segCnt].headerCnt > 0)
+               {
+                       tpdu.data.submit.bHeaderInd = true;
+               }
+               else
+               {
+                       tpdu.data.submit.bHeaderInd = false;
+               }
+
+               memset(&(tpdu.data.submit.userData), 0x00, sizeof(SMS_USERDATA_S));
+               memcpy(&(tpdu.data.submit.userData), &(submitData.userData[segCnt]), sizeof(SMS_USERDATA_S));
+
+               // Encode SMS-SUBMIT TPDU
+               memset(buf, 0x00, sizeof(buf));
+
+               bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
+
+               // Make Telephony Structure
+               TelSmsDatapackageInfo_t pkgInfo;
+
+               // Set TPDU data
+               memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
+               memcpy((void*)pkgInfo.szData, buf, bufLen);
+
+               pkgInfo.szData[bufLen] = 0;
+               pkgInfo.MsgLength = bufLen;
+
+               // Set SMSC data
+               memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
+               memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
+               pkgInfo.Sca[smscLen] = '\0';
+
+               MSG_DEBUG("bReqCb [%d]", pReqInfo->bReqCb);
+
+               SMS_SENT_INFO_S sentInfo = {};
+
+               TS_BOOL bMoreMsg = FALSE;
+
+               memcpy(&(sentInfo.reqInfo), pReqInfo, sizeof(SMS_REQUEST_INFO_S));
+
+               if ((segCnt+1) == submitData.segCount)
+               {
+                       sentInfo.bLast = true;
+
+                       bMoreMsg = FALSE;
+               }
+               else
+               {
+                       sentInfo.bLast = false;
+
+                       bMoreMsg = TRUE;
+               }
+
+               SmsPluginEventHandler::instance()->SetSentInfo(&sentInfo);
+
+               curStatus = MSG_NETWORK_SENDING;
+
+               // Send SMS
+               int tapiRet = TAPI_API_SUCCESS;
+
+               tapiRet = tel_send_sms(&pkgInfo, bMoreMsg, &reqId);
+
+               if (tapiRet == TAPI_API_SUCCESS)
+               {
+                       MSG_DEBUG("########  TelTapiSmsSend Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+               }
+               else
+               {
+                       SmsPluginEventHandler::instance()->handleSentStatus(reqId, MSG_NETWORK_SEND_FAIL);
+
+                       THROW(MsgException::SMS_PLG_ERROR, "########  TelTapiSmsSend Fail !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+               }
+
+               MSG_NETWORK_STATUS_T retStatus = getNetStatus();
+
+               if (retStatus == MSG_NETWORK_SEND_SUCCESS)
+               {
+                       MSG_DEBUG("########  Msg Sent was Successful !!! req Id : [%d] return : [%d] #######", reqId, retStatus);
+               }
+               else
+               {
+                       THROW(MsgException::SMS_PLG_ERROR, "########  Msg Sent was Failed !!! req Id : [%d] return : [%d] #######", reqId, retStatus);
+               }
+
+               if (tpdu.data.submit.userData.headerCnt > 0) tpdu.data.submit.userData.headerCnt--;
+       }
+
+       MSG_END();
+}
+
+
+void SmsPluginTransport::sendDeliverReport(MSG_ERROR_T err)
+{
+       MSG_BEGIN();
+
+       SMS_TPDU_S tpdu;
+
+       tpdu.tpduType = SMS_TPDU_DELIVER_REP;
+
+       TelSmsResponse_t response;
+
+       int tapiRet = TAPI_API_SUCCESS, reqId = 0;
+
+       if (err == MSG_SUCCESS)
+       {
+               tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
+               response = TAPI_NETTEXT_SENDSMS_SUCCESS;
+
+               tapiRet = tel_set_sms_memory_status(TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, &reqId);
+
+               if (tapiRet == TAPI_API_SUCCESS)
+               {
+                       MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId);
+               }
+               else
+               {
+                       MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+               }
+       }
+       else if (err == MSG_ERR_SIM_STORAGE_FULL)
+       {
+               tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
+               tpdu.data.deliverRep.failCause = SMS_FC_MSG_CAPA_EXCEEDED;
+               response = TAPI_NETTEXT_SIM_FULL;
+
+               tapiRet = tel_set_sms_memory_status(TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, &reqId);
+
+               if (tapiRet == TAPI_API_SUCCESS)
+               {
+                       MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId);
+               }
+               else
+               {
+                       MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+               }
+       }
+       else if (err == MSG_ERR_MESSAGE_COUNT_FULL)
+       {
+               tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
+               tpdu.data.deliverRep.failCause = SMS_FC_MSG_CAPA_EXCEEDED;
+               response = TAPI_NETTEXT_ME_FULL;
+
+               tapiRet = tel_set_sms_memory_status(TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, &reqId);
+
+               if (tapiRet == TAPI_API_SUCCESS)
+               {
+                       MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId);
+               }
+               else
+               {
+                       MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+               }
+       }
+       else
+       {
+               tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
+               tpdu.data.deliverRep.failCause = SMS_FC_UNSPEC_ERROR;
+               response = TAPI_NETTEXT_SIM_FULL;
+
+       }
+
+       MSG_DEBUG("err : [%d], response : [%02x]", err, response);
+
+       tpdu.data.deliverRep.bHeaderInd = false;
+       tpdu.data.deliverRep.paramInd = 0x00;
+
+       // Encode SMS-DELIVER-REPORT TPDU
+       int bufLen = 0;
+
+       char buf[MAX_TPDU_DATA_LEN];
+       memset(buf, 0x00, sizeof(buf));
+
+       bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
+
+       // Make Telephony Structure
+       TelSmsDatapackageInfo_t pkgInfo;
+
+       // Set TPDU data
+       memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
+       memcpy((void*)pkgInfo.szData, buf, bufLen);
+
+       pkgInfo.szData[bufLen] = 0;
+       pkgInfo.MsgLength = bufLen;
+
+       // Set SMSC Address
+       SMS_ADDRESS_S smsc;
+
+       // Set SMSC Options
+       setSmscOptions(&smsc);
+
+       // Encode SMSC Address
+       unsigned char smscAddr[MAX_SMSC_LEN];
+       memset(smscAddr, 0x00, sizeof(smscAddr));
+
+       int smscLen = SmsPluginParamCodec::encodeSMSC(&smsc, smscAddr);
+
+       if (smscLen <= 0) return;
+
+       // Set SMSC data
+       memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
+       memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
+       pkgInfo.Sca[smscLen] = '\0';
+
+       // Send Deliver Report
+       tapiRet = tel_send_sms_deliver_report(&pkgInfo, response, &reqId);
+
+       if (tapiRet == TAPI_API_SUCCESS)
+       {
+               MSG_DEBUG("########  tel_send_sms_deliver_report() Success !!! req Id : [%d] #######", reqId);
+       }
+       else
+       {
+               MSG_DEBUG("########  tel_send_sms_deliver_report() Fail !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+       }
+
+       MSG_END();
+}
+
+
+void SmsPluginTransport::setSmsSendOptions(SMS_SUBMIT_S *pSubmit)
+{
+       // Set SMS Send Options
+       pSubmit->bRejectDup = false;
+       pSubmit->bHeaderInd = false;
+
+       MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSubmit->bStatusReport);
+       MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSubmit->bReplyPath);
+
+       pSubmit->msgRef = msgRef++;
+
+       pSubmit->dcs.bCompressed = false;
+       pSubmit->dcs.msgClass = SMS_MSG_CLASS_NONE;
+       pSubmit->dcs.codingGroup = SMS_GROUP_GENERAL;
+
+       pSubmit->dcs.codingScheme = (SMS_CODING_SCHEME_T)MsgSettingGetInt(SMS_SEND_DCS);
+
+       MSG_DEBUG("DCS : %d", pSubmit->dcs.codingScheme);
+
+       int selectIdx = MsgSettingGetInt(SMSC_SELECTED);
+
+       char keyName[128];
+
+       memset(keyName, 0x00, sizeof(keyName));
+       sprintf(keyName, "%s/%d", SMSC_PID, selectIdx);
+       MSG_SMS_PID_T pid = (MSG_SMS_PID_T)MsgSettingGetInt(keyName);
+
+       pSubmit->pid = convertPid(pid);
+       MSG_DEBUG("PID : %d", pSubmit->pid);
+
+       memset(keyName, 0x00, sizeof(keyName));
+       sprintf(keyName, "%s/%d", SMSC_VAL_PERIOD, selectIdx);
+       int valPeriod = MsgSettingGetInt(keyName);
+
+       MSG_DEBUG("valPeriod : %d", valPeriod);
+
+       if (valPeriod == 0)
+       {
+               pSubmit->vpf = SMS_VPF_NOT_PRESENT;
+       }
+       else
+       {
+               pSubmit->vpf = SMS_VPF_RELATIVE;
+               pSubmit->validityPeriod.format = SMS_TIME_RELATIVE;
+               pSubmit->validityPeriod.time.relative.time = valPeriod;
+       }
+}
+
+
+void SmsPluginTransport::setSmscOptions(SMS_ADDRESS_S *pSmsc)
+{
+       // Set SMSC Options
+       int selectIdx = MsgSettingGetInt(SMSC_SELECTED);
+
+       char keyName[128];
+
+       memset(keyName, 0x00, sizeof(keyName));
+       sprintf(keyName, "%s/%d", SMSC_ADDRESS, selectIdx);
+
+       char* tmpValue = NULL;
+
+       tmpValue = MsgSettingGetString(keyName);
+
+       if (tmpValue != NULL)
+       {
+               memset(pSmsc->address, 0x00, sizeof(pSmsc->address));
+               strncpy(pSmsc->address, tmpValue, MAX_ADDRESS_LEN);
+
+               MSG_DEBUG("address : %s", pSmsc->address);
+       }
+       else
+       {
+               strncpy(pSmsc->address, "", MAX_ADDRESS_LEN);
+       }
+
+       memset(keyName, 0x00, sizeof(keyName));
+       sprintf(keyName, "%s/%d", SMSC_TON, selectIdx);
+       pSmsc->ton = (SMS_TON_T)MsgSettingGetInt(keyName);
+
+       MSG_DEBUG("ton : %d", pSmsc->ton);
+
+       memset(keyName, 0x00, sizeof(keyName));
+       sprintf(keyName, "%s/%d", SMSC_NPI, selectIdx);
+       pSmsc->npi = (SMS_NPI_T)MsgSettingGetInt(keyName);
+
+       MSG_DEBUG("npi : %d", pSmsc->npi);
+
+       if (tmpValue != NULL)
+       {
+               free(tmpValue);
+               tmpValue = NULL;
+       }
+}
+
+
+void SmsPluginTransport::msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SUBMIT_DATA_S *pData, SMS_CODING_SCHEME_T *pCharType)
+{
+       // Destination Address
+       pData->destAddress.ton = SMS_TON_NATIONAL;
+       pData->destAddress.npi = SMS_NPI_ISDN;
+
+       memset(pData->destAddress.address, 0x00, MAX_ADDRESS_LEN+1);
+       memcpy(pData->destAddress.address, pMsgInfo->addressList[0].addressVal, MAX_ADDRESS_LEN);
+
+       MSG_DEBUG("ton [%d]", pData->destAddress.ton);
+       MSG_DEBUG("npi [%d]", pData->destAddress.npi);
+       MSG_DEBUG("address [%s]", pData->destAddress.address);
+
+       int decodeLen = 0, bufSize = (MAX_GSM_7BIT_DATA_LEN*MAX_SEGMENT_NUM) + 1;       // SMS_CHARSET_7BIT
+
+       unsigned char decodeData[bufSize];
+       memset(decodeData, 0x00, sizeof(decodeData));
+
+       MSG_ENCODE_TYPE_T encodeType = MSG_ENCODE_GSM7BIT;
+
+       SMS_LANGUAGE_ID_T langId = SMS_LANG_ID_RESERVED;
+
+       // User Data
+       if (pMsgInfo->bTextSms == true)
+       {
+               if (*pCharType == SMS_CHARSET_7BIT)
+               {
+                       decodeLen = SmsPluginTextConvert::instance()->convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, pMsgInfo->dataSize, &langId);
+               }
+               else if (*pCharType == SMS_CHARSET_8BIT)
+               {
+                       memcpy(decodeData, pMsgInfo->msgText, pMsgInfo->dataSize);
+                       decodeLen = pMsgInfo->dataSize;
+               }
+               else if (*pCharType == SMS_CHARSET_UCS2)
+               {
+                       decodeLen = SmsPluginTextConvert::instance()->convertUTF8ToUCS2(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, pMsgInfo->dataSize);
+               }
+               else if (*pCharType == SMS_CHARSET_AUTO)
+               {
+                       decodeLen = SmsPluginTextConvert::instance()->convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, pMsgInfo->dataSize, &encodeType);
+                       *pCharType = encodeType;
+               }
+       }
+       else
+       {
+               int fileSize = 0;
+
+               char* pFileData = NULL;
+               AutoPtr<char> FileBuf(&pFileData);
+
+               // Read Message Data from File
+               if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false)
+               THROW(MsgException::FILE_ERROR, "MsgOpenAndReadFile error");
+
+               MSG_DEBUG("file size : [%d] file data : [%s]", fileSize, pFileData);
+
+               if (*pCharType == SMS_CHARSET_7BIT)
+               {
+                       decodeLen = SmsPluginTextConvert::instance()->convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pFileData, fileSize, &langId);
+               }
+               else if (*pCharType == SMS_CHARSET_8BIT)
+               {
+                       memcpy(decodeData, pFileData, fileSize);
+                       decodeLen = fileSize;
+               }
+               else if (*pCharType == SMS_CHARSET_UCS2)
+               {
+                       decodeLen = SmsPluginTextConvert::instance()->convertUTF8ToUCS2(decodeData, bufSize, (unsigned char*)pFileData, fileSize);
+               }
+               else if (*pCharType == SMS_CHARSET_AUTO)
+               {
+                       decodeLen = SmsPluginTextConvert::instance()->convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pFileData, fileSize, &encodeType);
+                       *pCharType = encodeType;
+               }
+
+               // Delete File
+               MsgDeleteFile(pMsgInfo->msgData);
+       }
+
+MSG_DEBUG("decode length : [%d]", decodeLen);
+MSG_DEBUG("character type : [%d]", *pCharType);
+MSG_DEBUG("Language Identifier : [%d]", langId);
+MSG_DEBUG("reply address : [%s]", pMsgInfo->replyAddress);
+
+       int addrLen = 0;
+
+       char* encodedAddr = NULL;
+       AutoPtr<char> addressBuf(&encodedAddr);
+
+       if (strlen(pMsgInfo->replyAddress) > 0)
+       {
+               SMS_ADDRESS_S replyAddr = {};
+
+               replyAddr.ton = SMS_TON_NATIONAL;
+               replyAddr.npi = SMS_NPI_ISDN;
+
+               memset(replyAddr.address, 0x00, MAX_ADDRESS_LEN+1);
+               memcpy(replyAddr.address, pMsgInfo->replyAddress, MAX_ADDRESS_LEN);
+
+               addrLen = SmsPluginParamCodec::encodeAddress(&replyAddr, &encodedAddr);
+
+               MSG_DEBUG("reply addr length : [%d]", addrLen);
+       }
+
+       int segSize = 0, index = 0;
+
+       segSize = getSegmentSize(*pCharType, decodeLen, pMsgInfo->msgPort.valid, langId, addrLen);
+
+       if (segSize >= decodeLen)
+               pData->segCount = 1;
+       else
+               pData->segCount = (decodeLen/segSize) + 1;
+
+MSG_DEBUG("segment size : [%d], pData->segCount : [%d]", segSize, pData->segCount);
+
+       if (pData->segCount > MAX_SEGMENT_NUM)
+               THROW(MsgException::SMS_PLG_ERROR, "Segment Count is over maximum : %d", pData->segCount);
+
+       int headerCnt = 0;
+
+       for (unsigned int i = 0; i < pData->segCount; i++)
+       {
+               headerCnt = 0;
+
+               if ((i + 1) == pData->segCount)
+                       pData->userData[i].length = decodeLen - (i*segSize);
+               else
+                       pData->userData[i].length = segSize;
+
+               memset(pData->userData[i].data, 0x00, MAX_USER_DATA_LEN+1);
+               memcpy(pData->userData[i].data, &(decodeData[index]), pData->userData[i].length);
+               pData->userData[i].data[pData->userData[i].length] = 0;
+
+MSG_DEBUG("user data len [%d]", pData->userData[i].length);
+MSG_DEBUG("user data [%s]", pData->userData[i].data);
+
+               index += segSize;
+
+               // Set User Data Header for Concatenated Message
+               if (pData->segCount > 1)
+               {
+                       pData->userData[i].header[headerCnt].udhType = SMS_UDH_CONCAT_8BIT;
+                       pData->userData[i].header[headerCnt].udh.concat8bit.msgRef = msgRef8bit;
+                       pData->userData[i].header[headerCnt].udh.concat8bit.totalSeg = pData->segCount;
+                       pData->userData[i].header[headerCnt].udh.concat8bit.seqNum = i + 1;
+
+                       headerCnt++;
+               }
+
+               // Set User Data Header Port Information
+               if (pMsgInfo->msgPort.valid == true)
+               {
+                       pData->userData[i].header[headerCnt].udhType = SMS_UDH_APP_PORT_16BIT;
+                       pData->userData[i].header[headerCnt].udh.appPort16bit.destPort = pMsgInfo->msgPort.dstPort;
+                       pData->userData[i].header[headerCnt].udh.appPort16bit.originPort = pMsgInfo->msgPort.srcPort;
+
+                       headerCnt++;
+               }
+
+               // Set User Data Header for Alternate Reply Address
+               if (strlen(pMsgInfo->replyAddress) > 0)
+               {
+                       pData->userData[i].header[headerCnt].udhType = SMS_UDH_ALTERNATE_REPLY_ADDRESS;
+
+                       pData->userData[i].header[headerCnt].udh.alternateAddress.ton = SMS_TON_NATIONAL;
+                       pData->userData[i].header[headerCnt].udh.alternateAddress.npi = SMS_NPI_ISDN;
+
+                       memset(pData->userData[i].header[headerCnt].udh.alternateAddress.address, 0x00, MAX_ADDRESS_LEN+1);
+                       memcpy(pData->userData[i].header[headerCnt].udh.alternateAddress.address, pMsgInfo->replyAddress, MAX_ADDRESS_LEN);
+
+                       headerCnt++;
+               }
+
+               // Set User Data Header for National Language Single Shift
+               if (*pCharType == SMS_CHARSET_7BIT && langId != SMS_LANG_ID_RESERVED)
+               {
+                       pData->userData[i].header[headerCnt].udhType = SMS_UDH_SINGLE_SHIFT;
+                       pData->userData[i].header[headerCnt].udh.singleShift.langId = langId;
+
+                       headerCnt++;
+               }
+
+               pData->userData[i].headerCnt = headerCnt;
+       }
+
+       msgRef8bit++;
+}
+
+
+int SmsPluginTransport::getSegmentSize(SMS_CODING_SCHEME_T CodingScheme, int DataLen, bool bPortNum, SMS_LANGUAGE_ID_T LangId, int ReplyAddrLen)
+{
+       int headerLen = 1, concat = 5, port = 6, lang = 3, reply = 2;
+       int headerSize = 0, segSize = 0, maxSize = 0;
+
+       if (CodingScheme == SMS_CHARSET_7BIT)
+       {
+               MSG_DEBUG("SMS_CHARSET_7BIT");
+               maxSize = MAX_GSM_7BIT_DATA_LEN;
+       }
+       else if (CodingScheme == SMS_CHARSET_8BIT || CodingScheme == SMS_CHARSET_UCS2)
+       {
+               MSG_DEBUG("SMS_CHARSET_8BIT or SMS_CHARSET_UCS2 [%d]", CodingScheme);
+               maxSize = MAX_UCS2_DATA_LEN;
+       }
+
+       if (bPortNum == true)
+       {
+               MSG_DEBUG("Port Number Exists");
+               headerSize += port;
+       }
+
+       if (LangId != SMS_LANG_ID_RESERVED)
+       {
+               MSG_DEBUG("National Language Exists");
+               headerSize += lang;
+       }
+
+       if (ReplyAddrLen > 0)
+       {
+               MSG_DEBUG("Reply Address Exists");
+               headerSize += reply;
+               headerSize += ReplyAddrLen;
+       }
+
+       if (CodingScheme == SMS_CHARSET_7BIT)
+       {
+               if (((DataLen+headerSize)/maxSize) >= 1)
+                       segSize = ((140*8) - ((headerLen + concat + headerSize)*8)) / 7;
+               else
+                       segSize = DataLen;
+       }
+       else if (CodingScheme == SMS_CHARSET_8BIT || CodingScheme == SMS_CHARSET_UCS2)
+       {
+               if (((DataLen+headerSize)/maxSize) >= 1)
+                       segSize = 140 - (headerLen + concat + headerSize);
+               else
+                       segSize = DataLen;
+       }
+
+       return segSize;
+}
+
+
+void SmsPluginTransport::setConcatHeader(SMS_UDH_S *pSrcHeader, SMS_UDH_S *pDstHeader)
+{
+       pDstHeader->udhType = pSrcHeader->udhType;
+
+       switch (pDstHeader->udhType)
+       {
+               case SMS_UDH_CONCAT_8BIT :
+               {
+                       pDstHeader->udh.concat8bit.msgRef = pSrcHeader->udh.concat8bit.msgRef;
+                       pDstHeader->udh.concat8bit.totalSeg = pSrcHeader->udh.concat8bit.totalSeg;
+                       pDstHeader->udh.concat8bit.seqNum = pSrcHeader->udh.concat8bit.seqNum;
+               }
+               break;
+
+               case SMS_UDH_CONCAT_16BIT :
+               {
+                       pDstHeader->udh.concat16bit.msgRef = pSrcHeader->udh.concat16bit.msgRef;
+                       pDstHeader->udh.concat16bit.totalSeg = pSrcHeader->udh.concat16bit.totalSeg;
+                       pDstHeader->udh.concat16bit.seqNum = pSrcHeader->udh.concat16bit.seqNum;
+               }
+               break;
+       }
+}
+
+
+void SmsPluginTransport::setNetStatus(MSG_NETWORK_STATUS_T netStatus)
+{
+       mx.lock();
+       curStatus = netStatus;
+       cv.signal();
+       mx.unlock();
+}
+
+
+MSG_NETWORK_STATUS_T SmsPluginTransport::getNetStatus()
+{
+       mx.lock();
+
+       int ret = 0;
+
+       if (curStatus == MSG_NETWORK_SENDING)
+               ret = cv.timedwait(mx.pMutex(), 65);
+
+       mx.unlock();
+
+       if (ret == ETIMEDOUT)
+       {
+               MSG_DEBUG("WARNING: SENT STATUS TIME-OUT");
+               curStatus = MSG_NETWORK_SEND_TIMEOUT;
+       }
+
+       return curStatus;
+}
+
+
+unsigned char SmsPluginTransport::getMsgRef()
+{
+       return msgRef++;
+}
+
+
+SMS_PID_T SmsPluginTransport::convertPid(MSG_SMS_PID_T pid)
+{
+       SMS_PID_T retPid;
+
+       switch (pid)
+       {
+               case MSG_PID_TEXT :
+                       retPid = SMS_PID_NORMAL;
+               break;
+               case MSG_PID_VOICE :
+                       retPid = SMS_PID_VOICE;
+               break;
+               case MSG_PID_FAX :
+                       retPid = SMS_PID_TELEX;
+               break;
+               case MSG_PID_X400 :
+                       retPid = SMS_PID_x400;
+               break;
+               case MSG_PID_ERMES :
+                       retPid = SMS_PID_ERMES;
+               break;
+               case MSG_PID_EMAIL :
+                       retPid = SMS_PID_EMAIL;
+               break;
+               default :
+                       retPid = SMS_PID_NORMAL;
+               break;
+       }
+
+       return retPid;
+}
diff --git a/plugin/sms_plugin/SmsPluginUAManager.cpp b/plugin/sms_plugin/SmsPluginUAManager.cpp
new file mode 100755 (executable)
index 0000000..41d4561
--- /dev/null
@@ -0,0 +1,93 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "SmsPluginEventHandler.h"
+#include "SmsPluginWapPushHandler.h"
+#include "SmsPluginConcatHandler.h"
+#include "SmsPluginTransport.h"
+#include "SmsPluginUAManager.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginUAManager - Member Functions
+==================================================================================================*/
+SmsPluginUAManager* SmsPluginUAManager::pInstance = NULL;
+
+
+SmsPluginUAManager::SmsPluginUAManager() : mx(), cv()
+{
+       start();
+}
+
+
+SmsPluginUAManager::~SmsPluginUAManager()
+{
+
+}
+
+
+SmsPluginUAManager* SmsPluginUAManager::instance()
+{
+       if (!pInstance)
+               pInstance = new SmsPluginUAManager();
+
+       return pInstance;
+}
+
+
+void SmsPluginUAManager::run()
+{
+       while (1)
+       {
+               if (smsTranQ.empty())
+                       cv.wait(mx.pMutex());
+
+               SMS_REQUEST_INFO_S request;
+               smsTranQ.front(&request);
+
+               try
+               {
+                       SmsPluginTransport::instance()->submitRequest(&request);
+               }
+               catch (MsgException& e)
+               {
+                       MSG_FATAL("%s", e.what());
+
+                       smsTranQ.pop_front();
+                       continue;
+               }
+               catch (exception& e)
+               {
+                       MSG_FATAL("%s", e.what());
+
+                       smsTranQ.pop_front();
+                       continue;
+               }
+
+               smsTranQ.pop_front();
+       }
+}
+
+
+void SmsPluginUAManager::addReqEntity(SMS_REQUEST_INFO_S request)
+{
+       smsTranQ.push_back(request);
+       cv.signal();
+}
+
diff --git a/plugin/sms_plugin/SmsPluginUDCodec.cpp b/plugin/sms_plugin/SmsPluginUDCodec.cpp
new file mode 100755 (executable)
index 0000000..3207eb1
--- /dev/null
@@ -0,0 +1,806 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "SmsPluginParamCodec.h"
+#include "SmsPluginUDCodec.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginUDCodec - Member Functions
+==================================================================================================*/
+SmsPluginUDCodec::SmsPluginUDCodec()
+{
+
+}
+
+
+SmsPluginUDCodec::~SmsPluginUDCodec()
+{
+
+}
+
+
+int SmsPluginUDCodec::encodeUserData(const SMS_USERDATA_S *pUserData, SMS_CODING_SCHEME_T CodingScheme, char *pEncodeData)
+{
+       int encodeSize = 0;
+
+       switch (CodingScheme)
+       {
+               case SMS_CHARSET_7BIT:
+                       encodeSize = encodeGSMData(pUserData, pEncodeData);
+                       break;
+               case SMS_CHARSET_8BIT:
+                       encodeSize = encode8bitData(pUserData, pEncodeData);
+                       break;
+               case SMS_CHARSET_UCS2:
+                       encodeSize = encodeUCS2Data(pUserData, pEncodeData);
+                       break;
+       }
+
+       return encodeSize;
+}
+
+
+int SmsPluginUDCodec::decodeUserData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_CODING_SCHEME_T CodingScheme, SMS_USERDATA_S *pUserData)
+{
+       int decodeSize = 0;
+
+       memset(pUserData, 0x00, sizeof(SMS_USERDATA_S));
+
+       switch (CodingScheme)
+       {
+               case SMS_CHARSET_7BIT:
+                       decodeSize = decodeGSMData(pTpdu, tpduLen, bHeaderInd, pUserData, NULL);
+                       break;
+               case SMS_CHARSET_8BIT:
+                       decodeSize = decode8bitData(pTpdu, bHeaderInd, pUserData, NULL);
+                       break;
+               case SMS_CHARSET_UCS2:
+                       decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, NULL);
+                       break;
+       }
+
+       return decodeSize;
+}
+
+
+int SmsPluginUDCodec::decodeUserData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_CODING_SCHEME_T CodingScheme, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD)
+{
+       int decodeSize = 0;
+
+       memset(pUserData, 0x00, sizeof(SMS_USERDATA_S));
+
+       switch (CodingScheme)
+       {
+               case SMS_CHARSET_7BIT:
+                       decodeSize = decodeGSMData(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
+                       break;
+               case SMS_CHARSET_8BIT:
+                       decodeSize = decode8bitData(pTpdu, bHeaderInd, pUserData, pTPUD);
+                       break;
+               case SMS_CHARSET_UCS2:
+                       decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
+                       break;
+       }
+
+       return decodeSize;
+}
+
+
+int SmsPluginUDCodec::encodeGSMData(const SMS_USERDATA_S *pUserData, char *pEncodeData)
+{
+       int headerLen = 0, offset = 0, fillBits = 0, packSize = 0, encodeLen = 0;
+       unsigned char udhl = 0x00;
+
+       if (pUserData->headerCnt > 0)
+               offset = 2;
+       else
+               offset = 1;
+
+MSG_DEBUG("pUserData->headerCnt [%d]", pUserData->headerCnt);
+
+       // Encode User Data Header
+       for (int i = 0; i < pUserData->headerCnt; i++)
+       {
+               headerLen = encodeHeader(pUserData->header[i], &(pEncodeData[offset]));
+
+MSG_DEBUG("headerLen [%d]", headerLen);
+
+               udhl += headerLen;
+               offset += headerLen;
+       }
+
+MSG_DEBUG("udhl [%d]", udhl);
+
+       if (udhl > 0)
+               fillBits = ((udhl+1)*8)%7; // + UDHL
+
+       if (fillBits > 0)
+               fillBits = 7 - fillBits;
+
+MSG_DEBUG("fillBits [%d]", fillBits);
+MSG_DEBUG("dataLen [%d]", pUserData->length);
+
+       // Set UDL, UDHL
+       if (udhl > 0)
+       {
+               pEncodeData[0] = (((udhl+1)*8) + fillBits + (pUserData->length*7)) / 7;
+               pEncodeData[1] =  udhl;
+       }
+       else
+       {
+               pEncodeData[0] = (char)pUserData->length;
+       }
+
+       packSize = pack7bitChar((unsigned char*)pUserData->data, pUserData->length, fillBits, &(pEncodeData[offset]));
+
+       encodeLen = offset + packSize;
+
+MSG_DEBUG("packSize [%d]", packSize);
+MSG_DEBUG("encodeLen [%d]", encodeLen);
+
+       return encodeLen;
+}
+
+
+int SmsPluginUDCodec::encode8bitData(const SMS_USERDATA_S *pUserData, char *pEncodeData)
+{
+       int headerLen = 0, offset = 2, fillBits = 0, encodeLen = 0;
+       unsigned char udhl = 0x00;
+
+       if (pUserData->headerCnt > 0)
+               offset = 2;
+       else
+               offset = 1;
+
+       // Encode User Data Header
+       for (int i = 0; i < pUserData->headerCnt; i++)
+       {
+               headerLen = encodeHeader(pUserData->header[i], &(pEncodeData[offset]));
+
+               udhl += headerLen;
+               offset += headerLen;
+       }
+
+MSG_DEBUG("fillBits [%d]", fillBits);
+MSG_DEBUG("dataLen [%d]", pUserData->length);
+
+       // Set UDL, UDHL
+       if (udhl > 0)
+       {
+               pEncodeData[0] = (udhl+1) + fillBits + pUserData->length;
+               pEncodeData[1] =  udhl;
+       }
+       else
+       {
+               pEncodeData[0] = (char)pUserData->length;
+       }
+
+       memcpy(&(pEncodeData[offset]), pUserData->data, pUserData->length);
+
+       encodeLen = offset + pUserData->length;
+
+       return encodeLen;
+}
+
+
+int SmsPluginUDCodec::encodeUCS2Data(const SMS_USERDATA_S *pUserData, char *pEncodeData)
+{
+       int headerLen = 0, offset = 2, fillBits = 0, encodeLen = 0;
+       unsigned char udhl = 0x00;
+
+       if (pUserData->headerCnt > 0)
+               offset = 2;
+       else
+               offset = 1;
+
+       // Encode User Data Header
+       for (int i = 0; i < pUserData->headerCnt; i++)
+       {
+               headerLen = encodeHeader(pUserData->header[i], &(pEncodeData[offset]));
+
+               udhl += headerLen;
+               offset += headerLen;
+       }
+
+MSG_DEBUG("fillBits [%d]", fillBits);
+MSG_DEBUG("dataLen [%d]", pUserData->length);
+
+       // Set UDL, UDHL
+       if (udhl > 0)
+       {
+               pEncodeData[0] = (udhl+1) + fillBits + pUserData->length;
+               pEncodeData[1] =  udhl;
+       }
+       else
+       {
+               pEncodeData[0] = (char)pUserData->length;
+       }
+
+       memcpy(&(pEncodeData[offset]), pUserData->data, pUserData->length);
+
+       encodeLen = offset + pUserData->length;
+
+       return encodeLen;
+}
+
+
+int SmsPluginUDCodec::decodeGSMData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD)
+{
+       int offset = 0, udl = 0, udhl = 0, headerLen = 0, fillBits = 0, octetUdl = 0;
+
+       // UDL
+       udl = pTpdu[offset++];
+       octetUdl = (udl*7)/8;
+
+MSG_DEBUG("udl = %d, tpdulen = %d, octetUdl = %d.", udl, tpduLen, octetUdl);
+MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
+
+       if (udl > MAX_GSM_7BIT_DATA_LEN || octetUdl > tpduLen)
+       {
+               pUserData->length = 0;
+               pUserData->headerCnt = 0;
+               return 0;
+       }
+
+       // Setting for Wap Push
+       if (pTPUD != NULL)
+       {
+               pTPUD->udl = udl;
+
+               memcpy(pTPUD->ud, &(pTpdu[offset]), udl);
+               pTPUD->ud[udl] = '\0';
+       }
+
+       // Decode User Data Header
+       if (bHeaderInd == true)
+       {
+               // UDHL
+               udhl = pTpdu[offset++];
+
+               MSG_DEBUG("udhl = %d", udhl);
+
+               pUserData->headerCnt = 0;
+
+               for (int i = 0; offset < udhl; i++)
+               {
+                       headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
+
+                       if (headerLen <= 0)
+                       {
+                               MSG_DEBUG("Error to decode User Data Header");
+
+                               pUserData->length = 0;
+                               memset(pUserData->data, 0x00, sizeof(pUserData->data));
+
+                               return 0;
+                       }
+
+                       offset += headerLen;
+
+                       pUserData->headerCnt++;
+               }
+       }
+       else
+               pUserData->headerCnt = 0;
+
+       MSG_DEBUG("headerCnt = %d", pUserData->headerCnt);
+
+       if (udhl > 0)
+       {
+               fillBits = ((udl*7) - ((udhl+1)*8)) % 7;
+               udl = ((udl*7) - ((udhl+1)*8)) / 7;
+       }
+
+MSG_DEBUG("fillBits = %d", fillBits);
+MSG_DEBUG("udhl = %d", udhl);
+MSG_DEBUG("udl = %d", udl);
+
+MSG_DEBUG("offset = %d", offset);
+
+       pUserData->length = unpack7bitChar(&(pTpdu[offset]), udl, fillBits, pUserData->data);
+
+       return pUserData->length;
+}
+
+
+int SmsPluginUDCodec::decode8bitData(const unsigned char *pTpdu, bool bHeaderInd, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD)
+{
+       int offset = 0, udl = 0, udhl = 0, headerLen = 0;
+
+       // UDL
+       udl = pTpdu[offset++];
+
+       if (udl > MAX_UCS2_DATA_LEN)
+       {
+               pUserData->length = 0;
+               return 0;
+       }
+
+       // Setting for Wap Push
+       if (pTPUD != NULL)
+       {
+               pTPUD->udl = udl;
+
+               memcpy(pTPUD->ud, &(pTpdu[offset]), udl);
+               pTPUD->ud[udl] = '\0';
+       }
+
+MSG_DEBUG("udl = %d", udl);
+MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
+
+       // Decode User Data Header
+       if (bHeaderInd == true)
+       {
+               // UDHL
+               udhl = pTpdu[offset++];
+
+               MSG_DEBUG("udhl = %d", udhl);
+
+               pUserData->headerCnt = 0;
+
+               for (int i = 0; offset < udhl; i++)
+               {
+                       headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
+
+                       if (headerLen <= 0)
+                       {
+                               MSG_DEBUG("Error to decode User Data Header");
+
+                               pUserData->length = 0;
+                               memset(pUserData->data, 0x00, sizeof(pUserData->data));
+
+                               return 0;
+                       }
+
+                       offset += headerLen;
+
+                       pUserData->headerCnt++;
+               }
+       }
+       else
+               pUserData->headerCnt = 0;
+
+MSG_DEBUG("headerCnt = %d", pUserData->headerCnt);
+
+       if (udhl > 0)
+               pUserData->length = (udl) - (udhl+1);
+       else
+               pUserData->length = udl;
+
+MSG_DEBUG("pUserData->length = %d", pUserData->length);
+MSG_DEBUG("offset = %d", offset);
+
+       memcpy(pUserData->data, &(pTpdu[offset]), pUserData->length);
+
+       return pUserData->length;
+}
+
+
+int SmsPluginUDCodec::decodeUCS2Data(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD)
+{
+       int offset = 0, udl = 0, udhl = 0, headerLen = 0;
+
+       // UDL
+       udl = pTpdu[offset++];
+
+MSG_DEBUG("udl = %d, tpdulen = %d.", udl, tpduLen);
+MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
+
+       if (udl > MAX_UCS2_DATA_LEN || udl > tpduLen)
+       {
+               pUserData->length = 0;
+               pUserData->headerCnt = 0;
+               return 0;
+       }
+
+       // Setting for Wap Push
+       if (pTPUD != NULL)
+       {
+               pTPUD->udl = udl;
+
+               memcpy(pTPUD->ud, &(pTpdu[offset]), udl);
+               pTPUD->ud[udl] = '\0';
+       }
+
+       // Decode User Data Header
+       if (bHeaderInd == true)
+       {
+               // UDHL
+               udhl = pTpdu[offset++];
+
+               MSG_DEBUG("udhl = %d", udhl);
+
+               pUserData->headerCnt = 0;
+
+               for (int i = 0; offset < udhl; i++)
+               {
+                       headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
+
+                       if (headerLen <= 0)
+                       {
+                               MSG_DEBUG("Error to decode User Data Header");
+
+                               pUserData->length = 0;
+                               memset(pUserData->data, 0x00, sizeof(pUserData->data));
+
+                               return 0;
+                       }
+
+                       offset += headerLen;
+
+                       pUserData->headerCnt++;
+               }
+       }
+       else
+               pUserData->headerCnt = 0;
+
+       if (udhl > 0)
+               pUserData->length = (udl) - (udhl+1);
+       else
+               pUserData->length = udl;
+
+MSG_DEBUG("pUserData->length = %d", pUserData->length);
+MSG_DEBUG("offset = %d", offset);
+
+       memcpy(pUserData->data, &(pTpdu[offset]), pUserData->length);
+       pUserData->data[pUserData->length] = 0;
+
+       return pUserData->length;
+}
+
+
+int SmsPluginUDCodec::encodeHeader(const SMS_UDH_S header, char *pEncodeHeader)
+{
+       int offset = 0, addrLen = 0;
+
+       char* encodedAddr = NULL;
+       AutoPtr<char> addressBuf(&encodedAddr);
+
+       switch (header.udhType)
+       {
+               case SMS_UDH_CONCAT_8BIT :
+                       // IEI
+                       pEncodeHeader[offset++] = SMS_UDH_CONCAT_8BIT;
+
+                       // IEDL
+                       pEncodeHeader[offset++] = 0x03;
+
+                       // Reference Number
+                       pEncodeHeader[offset++] = header.udh.concat8bit.msgRef;
+
+                       // Number of Segments
+                       pEncodeHeader[offset++] = header.udh.concat8bit.totalSeg;
+
+                       // Sequence Number
+                       pEncodeHeader[offset++] = header.udh.concat8bit.seqNum;
+               break;
+
+               case SMS_UDH_CONCAT_16BIT :
+                       // IEI
+                       pEncodeHeader[offset++] = SMS_UDH_CONCAT_16BIT;
+
+                       // IEDL
+                       pEncodeHeader[offset++] = 0x04;
+
+                       // Reference Number
+                       pEncodeHeader[offset++] = (char)(header.udh.concat16bit.msgRef >> 8);
+                       pEncodeHeader[offset++] = header.udh.concat16bit.msgRef & 0x00FF;
+
+                       // Number of Segments
+                       pEncodeHeader[offset++] = header.udh.concat16bit.totalSeg;
+
+                       // Sequence Number
+                       pEncodeHeader[offset++] = header.udh.concat16bit.seqNum;
+               break;
+
+               case SMS_UDH_APP_PORT_8BIT :
+                       // IEI
+                       pEncodeHeader[offset++] = SMS_UDH_APP_PORT_8BIT;
+
+                       // IEDL
+                       pEncodeHeader[offset++] = 0x02;
+
+                       // Dest Port
+                       pEncodeHeader[offset++] = header.udh.appPort8bit.destPort;
+
+                       // Origin Port
+                       pEncodeHeader[offset++] = header.udh.appPort8bit.originPort;
+               break;
+
+               case SMS_UDH_APP_PORT_16BIT :
+                       // IEI
+                       pEncodeHeader[offset++] = SMS_UDH_APP_PORT_16BIT;
+
+                       // IEDL
+                       pEncodeHeader[offset++] = 0x04;
+
+                       // Dest Port
+                       pEncodeHeader[offset++] = (char)(header.udh.appPort16bit.destPort >> 8);
+                       pEncodeHeader[offset++] = header.udh.appPort16bit.destPort & 0x00FF;
+
+                       // Origin Port
+                       pEncodeHeader[offset++] = (char)(header.udh.appPort16bit.originPort >> 8);
+                       pEncodeHeader[offset++] = header.udh.appPort16bit.originPort & 0x00FF;
+               break;
+
+               case SMS_UDH_ALTERNATE_REPLY_ADDRESS :
+                       // IEI
+                       pEncodeHeader[offset++] = SMS_UDH_ALTERNATE_REPLY_ADDRESS;
+
+                       addrLen = SmsPluginParamCodec::encodeAddress(&(header.udh.alternateAddress), &encodedAddr);
+
+                       // IEDL
+                       pEncodeHeader[offset++] = addrLen;
+
+                       // Alternate Reply Address
+                       memcpy(&pEncodeHeader[offset], encodedAddr, addrLen);
+
+                       offset += addrLen;
+               break;
+
+               case SMS_UDH_SINGLE_SHIFT :
+                       // IEI
+                       pEncodeHeader[offset++] = SMS_UDH_SINGLE_SHIFT;
+
+                       // IEDL
+                       pEncodeHeader[offset++] = 0x01;
+
+                       // National Language Identifier
+                       pEncodeHeader[offset++] = header.udh.singleShift.langId;
+               break;
+
+               case SMS_UDH_LOCKING_SHIFT :
+                       // IEI
+                       pEncodeHeader[offset++] = SMS_UDH_LOCKING_SHIFT;
+
+                       // IEDL
+                       pEncodeHeader[offset++] = 0x01;
+
+                       // National Language Identifier
+                       pEncodeHeader[offset++] = header.udh.lockingShift.langId;
+               break;
+
+               case SMS_UDH_NONE :
+               default :
+               break;
+       }
+
+       return offset;
+}
+
+
+int SmsPluginUDCodec::decodeHeader(const unsigned char *pTpdu, SMS_UDH_S *pHeader)
+{
+       int offset = 0;
+       unsigned char IEDL = 0;
+
+       pHeader->udhType = pTpdu[offset++];
+
+       switch (pHeader->udhType)
+       {
+               case SMS_UDH_CONCAT_8BIT :
+               {
+                       IEDL = pTpdu[offset++];
+
+                       if (IEDL == 0) return 0;
+
+                       pHeader->udh.concat8bit.msgRef = pTpdu[offset++];
+                       pHeader->udh.concat8bit.totalSeg = pTpdu[offset++];
+                       pHeader->udh.concat8bit.seqNum = pTpdu[offset++];
+
+MSG_DEBUG("concat8bit.msgRef [%02x]", pHeader->udh.concat8bit.msgRef);
+MSG_DEBUG("concat8bit.totalSeg [%02x]", pHeader->udh.concat8bit.totalSeg);
+MSG_DEBUG("concat8bit.seqNum [%02x]", pHeader->udh.concat8bit.seqNum);
+               }
+               break;
+
+               case SMS_UDH_CONCAT_16BIT :
+               {
+                       IEDL = pTpdu[offset++];
+
+                       if (IEDL == 0) return 0;
+
+                       pHeader->udh.concat16bit.msgRef = pTpdu[offset++];
+                       pHeader->udh.concat16bit.msgRef = (unsigned short)((pHeader->udh.concat16bit.msgRef << 8) | pTpdu[offset++]);
+                       pHeader->udh.concat16bit.totalSeg = pTpdu[offset++];
+                       pHeader->udh.concat16bit.seqNum = pTpdu[offset++];
+
+MSG_DEBUG("concat16bit.msgRef [%04x]", pHeader->udh.concat16bit.msgRef);
+MSG_DEBUG("concat16bit.totalSeg [%02x]", pHeader->udh.concat16bit.totalSeg);
+MSG_DEBUG("concat16bit.seqNum [%02x]", pHeader->udh.concat16bit.seqNum);
+               }
+               break;
+
+               case SMS_UDH_APP_PORT_8BIT :
+               {
+                       IEDL = pTpdu[offset++];
+
+                       if (IEDL == 0) return 0;
+
+                       pHeader->udh.appPort8bit.destPort = pTpdu[offset++];
+                       pHeader->udh.appPort8bit.originPort = pTpdu[offset++];
+
+MSG_DEBUG("appPort8bit.destPort [%02x]", pHeader->udh.appPort8bit.destPort);
+MSG_DEBUG("appPort8bit.originPort [%02x]", pHeader->udh.appPort8bit.originPort);
+               }
+               break;
+
+               case SMS_UDH_APP_PORT_16BIT :
+               {
+                       IEDL = pTpdu[offset++];
+
+                       if (IEDL == 0) return 0;
+
+                       pHeader->udh.appPort16bit.destPort = pTpdu[offset++];
+                       pHeader->udh.appPort16bit.destPort = (unsigned short)((pHeader->udh.appPort16bit.destPort << 8) | pTpdu[offset++]);
+                       pHeader->udh.appPort16bit.originPort = pTpdu[offset++];
+                       pHeader->udh.appPort16bit.originPort = (unsigned short)((pHeader->udh.appPort16bit.originPort << 8) | pTpdu[offset++]);
+
+MSG_DEBUG("appPort16bit.destPort [%04x]", pHeader->udh.appPort16bit.destPort);
+MSG_DEBUG("appPort16bit.originPort [%04x]", pHeader->udh.appPort16bit.originPort);
+               }
+               break;
+
+               case SMS_UDH_SPECIAL_SMS :
+               {
+                       IEDL = pTpdu[offset++];
+
+                       if (IEDL != 2) return 0;
+MSG_DEBUG("Decoding special sms udh.");
+
+                       pHeader->udh.specialInd.bStore = (bool) (pTpdu[offset] & 0x80);
+                       pHeader->udh.specialInd.msgInd = (unsigned short) (pTpdu[offset++] & 0x7F);
+                       pHeader->udh.specialInd.waitMsgNum = (unsigned short) pTpdu[offset];
+               }
+               break;
+
+               case SMS_UDH_ALTERNATE_REPLY_ADDRESS :
+               {
+                       IEDL = pTpdu[offset++];
+
+                       if (IEDL == 0) return 0;
+
+                       offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pHeader->udh.alternateAddress));
+
+MSG_DEBUG("alternate reply address [%s]", pHeader->udh.alternateAddress.address);
+               }
+               break;
+
+               case SMS_UDH_SINGLE_SHIFT :
+               {
+                       IEDL = pTpdu[offset++];
+
+                       if (IEDL == 0) return 0;
+
+                       pHeader->udh.singleShift.langId = pTpdu[offset++];
+
+MSG_DEBUG("singleShift.langId [%02x]", pHeader->udh.singleShift.langId);
+               }
+               break;
+
+               case SMS_UDH_LOCKING_SHIFT :
+               {
+                       IEDL = pTpdu[offset++];
+
+                       if (IEDL == 0) return 0;
+
+                       pHeader->udh.lockingShift.langId = pTpdu[offset++];
+
+MSG_DEBUG("lockingShift.langId [%02x]", pHeader->udh.lockingShift.langId);
+               }
+               break;
+
+               default :
+               {
+                       MSG_DEBUG("Not Supported Header Type [%02x]", pHeader->udhType);
+                       return 0;
+               }
+               break;
+       }
+
+       return offset;
+}
+
+
+int SmsPluginUDCodec::pack7bitChar(const unsigned char *pUserData, int dataLen, int fillBits, char *pPackData)
+{
+       int srcIdx = 0, dstIdx = 0, shift = fillBits;
+
+       if (shift > 0)
+               dstIdx = 1;
+
+       while (srcIdx < dataLen)
+       {
+               if (shift == 0)
+               {
+                       pPackData[dstIdx] = pUserData[srcIdx];
+
+                       if (srcIdx >= dataLen) break;
+
+                       shift = 7;
+                       srcIdx++;
+                       dstIdx++;
+               }
+
+               if (shift > 1)
+               {
+
+                       pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
+                       pPackData[dstIdx] = pUserData[srcIdx] >> (8-shift);
+                       shift--;
+
+                       srcIdx++;
+                       dstIdx++;
+               }
+               else if (shift == 1)
+               {
+                       pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
+
+
+                       srcIdx++;
+
+                       shift--;
+               }
+       }
+
+
+       return dstIdx;
+}
+
+
+int SmsPluginUDCodec::unpack7bitChar(const unsigned char *pTpdu, unsigned char dataLen, int fillBits, char *pUnpackData)
+{
+       int srcIdx = 0, dstIdx = 0, shift = fillBits;
+
+MSG_DEBUG("dataLen = %d", dataLen);
+
+       if (shift > 0)
+               srcIdx = 1;
+
+       for (; dstIdx < dataLen; dstIdx++)
+       {
+               if (shift == 0)
+               {
+
+                       pUnpackData[dstIdx] = pTpdu[srcIdx] & 0x7F;
+
+                       shift = 7;
+                       srcIdx++;
+                       dstIdx++;
+
+                       if (dstIdx >= dataLen) break;
+               }
+
+               if (shift > 0)
+               {
+
+                       pUnpackData[dstIdx] = (pTpdu[srcIdx-1] >> shift) + (pTpdu[srcIdx] << (8 - shift));
+
+                       pUnpackData[dstIdx] &= 0x7F;
+
+
+                       shift--;
+
+                       if (shift > 0) srcIdx++;
+               }
+       }
+
+       return dstIdx;
+}
+
diff --git a/plugin/sms_plugin/SmsPluginWapPushHandler.cpp b/plugin/sms_plugin/SmsPluginWapPushHandler.cpp
new file mode 100755 (executable)
index 0000000..1c0859c
--- /dev/null
@@ -0,0 +1,3024 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgGconfWrapper.h"
+#include "MsgException.h"
+#include "MsgUtilFile.h"
+#include "SmsPluginStorage.h"
+#include "SmsPluginTransport.h"
+#include "SmsPluginEventHandler.h"
+#include "SmsPluginWapPushHandler.h"
+
+
+#include <drm_client.h>
+
+static unsigned short wapPushPortList [] = {0x0b84, 0x0b85, 0x23F0, 0x23F1, 0x23F2, 0x23F3, 0xC34F};
+
+const SMS_PUSH_APP_INFO_S pushDefaultApplication [] =
+{
+       {(char*)"text/vnd.wap.si", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SI},
+       {(char*)"application/vnd.wap.sic", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SIC},
+       {(char*)"text/vnd.wap.sl", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SL},
+       {(char*)"application/vnd.wap.slc", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SLC},
+       {(char*)"text/vnd.wap.co", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_CO},
+       {(char*)"application/vnd.wap.coc", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_COC},
+
+       {(char*)"application/vnd.wap.mms-message", (char*)"X-Wap-Application-Id: x-wap-application:mms.ua\r\n", SMS_WAP_APPLICATION_MMS_UA},
+
+       {(char*)"application/vnd.wap.sia", (char*)"X-Wap-Application-Id: x-wap-application:push.sia\r\n", SMS_WAP_APPLICATION_PUSH_SIA},
+
+       {(char*)"application/vnd.syncml.dm+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.dm\r\n", SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP},
+       {(char*)"application/vnd.syncml.dm+xml", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.dm\r\n", SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML},
+       {(char*)"application/vnd.syncml.notification", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.dm\r\n", SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION},
+       {(char*)"application/vnd.syncml.ds.notification", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.ds\r\n", SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION},
+       {(char*)"application/vnd.syncml+wbxml", (char*)"X-Wap-Application-Id:x-wap-application:push.syncml", SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML},
+
+       {(char*)"application/vnd.wap.locc+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:loc.ua\r\n", SMS_WAP_APPLICATION_LOC_UA_WBXML},
+       {(char*)"application/vnd.wap.loc+xml", (char*)"X-Wap-Application-Id: x-wap-application:loc.ua\r\n", SMS_WAP_APPLICATION_LOC_UA_XML},
+
+       {(char*)"application/vnd.oma.dd+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_XML},
+       {(char*)"application/vnd.oma.drm.message", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_MESSAGE},
+       {(char*)"application/vnd.oma.drm.content", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_CONETENT},
+       {(char*)"application/vnd.oma.drm.rights+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML},
+       {(char*)"application/vnd.oma.drm.rights+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML},
+       {(char*)"application/vnd.oma.drm.ro+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_V2_RO_XML},
+       {(char*)"application/vnd.oma.drm.roap-pdu+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML},
+       {(char*)"application/vnd.oma.drm.roap-trigger+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML},
+       {(char*)"application/vnd.oma.drm.roap-trigger+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML},
+
+       {(char*)"text/vnd.wap.emn+xml", (char*)"X-Wap-Application-Id: x-wap-application:emn.ua\r\n", SMS_WAP_APPLICATION_PUSH_EMAIL_XML},
+       {(char*)"application/vnd.wap.emn+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:emn.ua\r\n", SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML},
+       {(char*)"application/vnd.wv.csp.cir", (char*)"X-Wap-Application-Id: x-wap-application:wv.ua\r\n", SMS_WAP_APPLICATION_PUSH_IMPS_CIR},
+       {(char*)"application/vnd.omaloc-supl-init", (char*)"X-Wap-Application-Id: x-oma-application:ulp.ua\r\n", SMS_WAP_APPLICATION_LBS},
+       {NULL, NULL}
+};
+
+
+char gWapCodeBufferLeft[WSP_CODE_BUFFER_LEFT_LEN_MAX];
+char gWapCodeBufferRight[WSP_CODE_BUFFER_RIGHT_LEN_MAX];
+
+const unsigned long wspUintvarDecodeTable[] = { 0x00000001, 0x00000080, 0x00004000, 0x00200000, 0x10000000};
+
+const unsigned char wspHeaderFieldCount  = 0x43;
+const unsigned char wspContentsTypeCount = 0x34;
+const unsigned long wspLanguageCount    = 0x11a;
+const unsigned char wspSecurityTypeCount = 0x04;
+
+
+static const SMS_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] =
+{
+       { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
+       { (char*)"application/vnd.wap.connectivity-wbxml", 0x36 },
+       { (char*)"application/pkcs7-mime",  0x37 },
+       { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
+       { (char*)"application/vnd.wap.signed-certificate", 0x39  },
+       { (char*)"application/vnd.wap.cert-response", 0x3A },
+       { (char*)"application/xhtml+xml", 0x3B },
+       { (char*)"application/wml+xml", 0x3C  },
+       { (char*)"text/css", 0x3D },
+
+       { (char*)"application/vnd.wap.mms-message", 0x3E },
+
+       { (char*)"application/vnd.wap.rollover-certificate", 0x3F  },
+       { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
+       { (char*)"application/vnd.wap.loc+xml", 0x41 },
+       { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
+       { (char*)"application/vnd.syncml.dm+xml", 0x43 },
+       { (char*)"application/vnd.syncml.notification", 0x44 },
+       { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
+       { (char*)"application/vnd.wv.csp.cir", 0x46 },
+
+       { (char*)"application/vnd.oma.dd+xml", 0x47},
+       { (char*)"application/vnd.oma.drm.message", 0x48 },
+       { (char*)"application/vnd.oma.drm.content", 0x49 },
+       { (char*)"application/vnd.oma.drm.rights+xml", 0x4A },
+       { (char*)"application/vnd.oma.drm.rights+wbxml", 0x4B },
+       { (char*)"application/vnd.syncml.ds.notification", 0x4E},
+       { (char*)"application/mikey", 0x52},
+       { (char*)"", 0xff }
+};
+
+
+const char* wspHeaderFieldName[] =
+{
+       (char*)"Accept",  //0x00
+       (char*)"Accept-Charset",
+       (char*)"Accept-Encoding",
+       (char*)"Accept-Language",
+       (char*)"Accept-Ranges",
+       (char*)"Age", //0x05
+       (char*)"Allow",
+       (char*)"Authorization",
+       (char*)"Cache-Control",
+       (char*)"Connection",
+       (char*)"Content-Base", //0x0a
+       (char*)"Content-Encoding",
+       (char*)"Content-Language",
+       (char*)"Content-Length",
+       (char*)"Content-Location",
+       (char*)"Content-MD5",
+       (char*)"Content-Range", //0x10
+       (char*)"Content-Type",
+       (char*)"Date",
+       (char*)"ETag",
+       (char*)"Expires",
+       (char*)"From", //0x15
+       (char*)"Host",
+       (char*)"If-Modified-Since",
+       (char*)"If-Match",
+       (char*)"If-None-Match",
+       (char*)"If-Range", //0x1a
+       (char*)"If-Unmodified-Since",
+       (char*)"Location",
+       (char*)"Last-Modified",
+       (char*)"Max-Forwards",
+       (char*)"Pragma",
+       (char*)"Proxy-Authenticate", //0x20
+       (char*)"Proxy-Authorization",
+       (char*)"Public",
+       (char*)"Range",
+       (char*)"Referer",
+       (char*)"Retry-After", //0x25
+       (char*)"Server",
+       (char*)"Transfer-Encodig",
+       (char*)"Upgrade",
+       (char*)"User-Agent",
+       (char*)"Vary", //0x2a
+       (char*)"Via",
+       (char*)"Warning",
+       (char*)"Www-Authenticate",
+       (char*)"Content-Disposition",
+       (char*)"X-Wap-Application-Id",
+       (char*)"X-Wap-Content-URI", //0x30
+       (char*)"X-Wap-Iinitiator-URI",
+       (char*)"Accept-Application", // Back
+       (char*)"Bearer-Indication",
+       (char*)"Push-Flag",
+       (char*)"Profile", //0x35
+       (char*)"Profile-Diff",
+       (char*)"Profile-Warning", // end of WAP 1.2
+       (char*)"Expect",
+       (char*)"Te",
+       (char*)"Trailer", //0x3a
+       (char*)"Accept-Charset", //Back
+       (char*)"Accept-Encoding", // Back
+       (char*)"Cache-Control", // back
+       (char*)"Content-Range",
+       (char*)"X-Wap-Tod",
+       (char*)"Content-ID", //x40
+       (char*)"Set-Cookie",
+       (char*)"Cookie",
+       (char*)"Encoding-Version"
+};
+
+
+const SMS_WSP_CHARSET_S wspCharset[] =
+{
+       { (char*)"big5", 0x07ea },
+       { (char*)"iso-10646-ucs-2", 0x03e8 },
+       { (char*)"iso-8859-1", 0x04 },
+       { (char*)"iso-8859-2", 0x05 },
+       { (char*)"iso-8859-3", 0x06 },
+       { (char*)"iso-8859-4", 0x07 },
+       { (char*)"iso-8859-5", 0x08 },
+       { (char*)"iso-8859-6", 0x09 },
+       { (char*)"iso-8859-7", 0x0a },
+       { (char*)"iso-8859-8", 0x0b },
+       { (char*)"iso-8859-9", 0x0c },
+       { (char*)"shift-JIS", 0x11 },
+       { (char*)"us-ascii", 0x03 },
+       { (char*)"utf-8", 0x6a },
+       { (char*)"none", 0x26 },
+       { (char*)"", 0xffff }
+};
+
+
+
+const char* wspEncodeMethod[] =
+{
+       (char*)"Gzip",
+       (char*)"Compress",
+       (char*)"Deflate"
+};
+
+
+const SMS_WSP_CONTENTS_TYPE_S wspContentsType[] =
+{
+       { (char*)"*/*", 0x00 },
+       { (char*)"text/*", 0x01 },
+       { (char*)"text/html", 0x02 },
+       { (char*)"text/plain", 0x03 },
+       { (char*)"text/x-hdml", 0x04 },
+       { (char*)"text/x-ttml", 0x05 },
+       { (char*)"text/x-vCalendar", 0x06 },
+       { (char*)"text/x-vCard", 0x07 },
+       { (char*)"text/vnd.wap.wml", 0x08 },
+       { (char*)"text/vnd.wap.wmlscript", 0x09 },
+       { (char*)"text/vnd.wap.wta-event", 0x0a },
+       { (char*)"multipart/*", 0x0b },
+       { (char*)"multipart/mixed", 0x0c },
+       { (char*)"multipart/form-data", 0x0d },
+       { (char*)"multipart/byteranges", 0x0e },
+       { (char*)"multipart/alternative", 0x0f },
+       { (char*)"application/*", 0x10 },
+       { (char*)"application/java-vm", 0x11 },
+       { (char*)"application/x-www-form-urlencoded", 0x12 },
+       { (char*)"application/x-hdmlc", 0x13 },
+       { (char*)"application/vnd.wap.wmlc", 0x14 },
+       { (char*)"application/vnd.wap.wmlscriptc", 0x15 },
+       { (char*)"application/vnd.wap.wta-eventc", 0x16 },
+       { (char*)"application/vnd.wap.uaprof", 0x17 },
+       { (char*)"application/vnd.wap.wtls-ca-certificate", 0x18 },
+       { (char*)"application/vnd.wap.wtls-user-certificate", 0x19 },
+       { (char*)"application/x-x509-ca-cert", 0x1a },
+       { (char*)"application/x-x509-user-cert", 0x1b },
+       { (char*)"image/*", 0x1c },
+       { (char*)"image/gif", 0x1d },
+       { (char*)"image/jpeg", 0x1e },
+       { (char*)"image/tiff", 0x1f },
+       { (char*)"image/png", 0x20 },
+       { (char*)"image/vnd.wap.wbmp", 0x21 },
+       { (char*)"application/vnd.wap.multipart.*", 0x22 },
+       { (char*)"application/vnd.wap.multipart.mixed", 0x23 },
+       { (char*)"application/vnd.wap.multipart.form-data", 0x24 },
+       { (char*)"application/vnd.wap.multipart.byteranges", 0x25 },
+       { (char*)"application/vnd.wap.multipart.alternative", 0x26 },
+       { (char*)"application/xml", 0x27 },
+       { (char*)"text/xml",0x28 },
+       { (char*)"application/vnd.wap.wbxml", 0x29 },
+       { (char*)"application/x-x968-cross-cert", 0x2a },
+       { (char*)"application/x-x968-ca-cert", 0x2b },
+       { (char*)"application/x-x968-user-cert", 0x2c },
+       { (char*)"text/vnd.wap.si", 0x2d },
+       { (char*)"application/vnd.wap.sic", 0x2e },
+       { (char*)"text/vnd.wap.sl", 0x2f },
+       { (char*)"application/vnd.wap.slc", 0x30 },
+       { (char*)"text/vnd.wap.co", 0x31 },
+       { (char*)"application/vnd.wap.coc", 0x32 },
+       { (char*)"application/vnd.wap.multipart.related", 0x33 },
+       { (char*)"application/vnd.wap.sia", 0x34 },
+
+       { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
+       { (char*)"application/vnd.connectivity-wbxml", 0x36 },
+       { (char*)"application/pkcs7-mime",  0x37 },
+       { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
+       { (char*)"application/vnd.wap.signed-certificate", 0x39  },
+       { (char*)"application/vnd.wap.cert-response", 0x3A },
+       { (char*)"application/xhtml+xml", 0x3B },
+       { (char*)"application/wml+xml", 0x3C  },
+       { (char*)"text/css", 0x3D },
+
+       { (char*)"application/vnd.wap.mms-message", 0x3E },
+
+       { (char*)"application/vnd.wap.rollover-certificate", 0x3F  },
+       { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
+       { (char*)"application/vnd.wap.loc+xml", 0x41 },
+       { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
+       { (char*)"application/vnd.syncml.dm+xml", 0x43 },
+       { (char*)"application/vnd.syncml.notification", 0x44 },
+       { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
+       { (char*)"application/vnd.wv.csp.cir", 0x46 }
+};
+
+static const SMS_WAP_UNREGISTER_CONTENTS_TYPE_S wspUnregisterContentsType[]=
+{
+       { (char*)"application/vnd.wap.emn+wbxml", 0x30A},
+       { (char*)"application/vnd.omaloc-supl-init", 0x312},
+       { (char*)"application/vnd.oma.drm.roap-trigger+wbxml", 0x316}
+};
+
+const unsigned long wspUnregisteredContentsTypeCount = sizeof(wspUnregisterContentsType)/sizeof(SMS_WAP_UNREGISTER_CONTENTS_TYPE_S);
+
+const SMS_WSP_LANGUAGE_S wspLanguage[] =
+{
+       { (char*)"English", 0x19 },
+       { (char*)"en", 0x19 },
+       { (char*)"Korean", 0x3d },
+       { (char*)"*", 0x00 },
+       { (char*)"Afar", 0x01 },
+       { (char*)"aa", 0x01 },
+       { (char*)"Abkhazian", 0x02 },
+       { (char*)"ab", 0x02 },
+       { (char*)"Afrikaans", 0x03 },
+       { (char*)"af", 0x03 },
+       { (char*)"Amharic", 0x04 },
+       { (char*)"am", 0x04 },
+       { (char*)"Arabic", 0x05 },
+       { (char*)"ar", 0x05 },
+       { (char*)"Assamese", 0x06 },
+       { (char*)"as", 0x06 },
+       { (char*)"Aymara", 0x07 },
+       { (char*)"ay", 0x07 },
+       { (char*)"Azerbaijani", 0x08 },
+       { (char*)"az", 0x08 },
+       { (char*)"Bashkir", 0x09 },
+       { (char*)"ba", 0x09 },
+       { (char*)"Byelorussian", 0x0a },
+       { (char*)"be", 0x0a },
+       { (char*)"Bulgarian", 0x0b },
+       { (char*)"bg", 0x0b },
+       { (char*)"Bihari", 0x0c },
+       { (char*)"bh", 0x0c },
+       { (char*)"Bislama", 0x0d },
+       { (char*)"bi", 0x0f },
+       { (char*)"Bengali", 0x0e },
+       { (char*)"Bangla", 0x0e },
+       { (char*)"bn", 0x0e },
+       { (char*)"Tibetan", 0x0f },
+       { (char*)"bo", 0x0f },
+       { (char*)"Breton", 0x10 },
+       { (char*)"br", 0x10 },
+       { (char*)"Catalan", 0x11 },
+       { (char*)"ca", 0x11 },
+       { (char*)"Corsican", 0x12 },
+       { (char*)"co", 0x12 },
+       { (char*)"Czech", 0x13 },
+       { (char*)"cs", 0x13 },
+       { (char*)"Welsh", 0x14 },
+       { (char*)"cy", 0x14 },
+       { (char*)"Denish", 0x15 },
+       { (char*)"da", 0x15 },
+       { (char*)"German", 0x16 },
+       { (char*)"de", 0x16 },
+       { (char*)"Bhutani", 0x17 },
+       { (char*)"dz", 0x17 },
+       { (char*)"Greek", 0x18 },
+       { (char*)"el", 0x18 },
+       { (char*)"Esperanto", 0x81 },
+       { (char*)"eo", 0x1a },
+       { (char*)"Spanish", 0x1b },
+       { (char*)"es", 0x1b },
+       { (char*)"Estonian", 0x1c },
+       { (char*)"et", 0x1c },
+       { (char*)"Basque", 0x1d },
+       { (char*)"eu", 0x1d },
+       { (char*)"Persian", 0x1e },
+       { (char*)"fa", 0x1e },
+       { (char*)"Finnish", 0x1f },
+       { (char*)"fi", 0x1f },
+       { (char*)"Fiji", 0x20 },
+       { (char*)"fj", 0x20 },
+       { (char*)"Faeroese", 0x82 },
+       { (char*)"fo", 0x82 },
+       { (char*)"French", 0x22 },
+       { (char*)"fr", 0x22 },
+       { (char*)"Frisian", 0x83 },
+       { (char*)"fy", 0x83 },
+       { (char*)"Irish", 0x24 },
+       { (char*)"ga", 0x24 },
+       { (char*)"Scots Gaelic", 0x25 },
+       { (char*)"gd", 0x25 },
+       { (char*)"Galician", 0x26 },
+       { (char*)"gl", 0x26 },
+       { (char*)"Guarani", 0x27 },
+       { (char*)"gn", 0x27 },
+       { (char*)"Gujarati", 0x28 },
+       { (char*)"gu", 0x28 },
+       { (char*)"Hausa", 0x29 },
+       { (char*)"ha", 0x29 },
+       { (char*)"Hebrew", 0x2a },
+       { (char*)"he", 0x2a },
+       { (char*)"Hindi", 0x2b },
+       { (char*)"hi", 0x2b },
+       { (char*)"Croatian", 0x2c },
+       { (char*)"hr", 0x2c },
+       { (char*)"Hungarian", 0x2d },
+       { (char*)"hu", 0x2d },
+       { (char*)"Armenian", 0x2e },
+       { (char*)"hy", 0x2e },
+       { (char*)"Interlingua", 0x84 },
+       { (char*)"ia", 0x84 },
+       { (char*)"Indonesian", 0x30 },
+       { (char*)"id", 0x30 },
+       { (char*)"Interlingue", 0x86 },
+       { (char*)"ie", 0x86 },
+       { (char*)"Maori", 0x47 },
+       { (char*)"mi", 0x47 },
+       { (char*)"Macedonian", 0x48 },
+       { (char*)"mk", 0x48 },
+       { (char*)"Malayalam", 0x49 },
+       { (char*)"ml", 0x49 },
+       { (char*)"Mongolian", 0x4a },
+       { (char*)"mn", 0x4a },
+       { (char*)"Moldavian", 0x4b },
+       { (char*)"mo", 0x4d },
+       { (char*)"Marathi", 0x4c },
+       { (char*)"mr", 0x4c },
+       { (char*)"Malay", 0x4d },
+       { (char*)"ms", 0x4d },
+       { (char*)"Maltese", 0x4e },
+       { (char*)"mt", 0x4e },
+       { (char*)"Burmese", 0x4f },
+       { (char*)"my", 0x4f },
+       { (char*)"Nauru", 0x50 },
+       { (char*)"na", 0x50 },
+       { (char*)"Nepali", 0x51 },
+       { (char*)"ne", 0x51 },
+       { (char*)"Dutch", 0x52 },
+       { (char*)"nl", 0x52 },
+       { (char*)"Norwegian", 0x53 },
+       { (char*)"no", 0x53 },
+       { (char*)"Occitan", 0x54 },
+       { (char*)"oc", 0x54 },
+       { (char*)"(Afan) Oromo", 0x55 },
+       { (char*)"(Afan)Oromo", 0x55 },
+       { (char*)"om", 0x55 },
+       { (char*)"Oriya", 0x56 },
+       { (char*)"or", 0x56 },
+       { (char*)"Punjabi", 0x57 },
+       { (char*)"pa", 0x57 },
+       { (char*)"Polish", 0x58 },
+       { (char*)"po", 0x58 },
+       { (char*)"Pashto", 0x59 },
+       { (char*)"Pushto", 0x59 },
+       { (char*)"ps", 0x59 },
+       { (char*)"Portugurse", 0x5a },
+       { (char*)"pt", 0x5a },
+       { (char*)"Quechua", 0x5b },
+       { (char*)"qu", 0x5b },
+       { (char*)"Rhaeto-Romance", 0x8c },
+       { (char*)"rm", 0x8c },
+       { (char*)"Kirundi", 0x5d },
+       { (char*)"rn", 0x5d },
+       { (char*)"Romanian", 0x5e },
+       { (char*)"ro", 0x5e },
+       { (char*)"Russian", 0x5f },
+       { (char*)"ru", 0x5f },
+       { (char*)"Kinyarwanda", 0x60 },
+       { (char*)"rw", 0x60 },
+       { (char*)"Sanskrit", 0x61 },
+       { (char*)"sa", 0x61 },
+       { (char*)"Sindhi", 0x62 },
+       { (char*)"sd", 0x62 },
+       { (char*)"Sangho", 0x63 },
+       { (char*)"sg", 0x63 },
+       { (char*)"Serbo-Croatian", 0x64 },
+       { (char*)"sh", 0x64 },
+       { (char*)"Sinhalese", 0x65 },
+       { (char*)"si", 0x65 },
+       { (char*)"Slovak", 0x66 },
+       { (char*)"sk", 0x66 },
+       { (char*)"Slovenian", 0x67 },
+       { (char*)"sl", 0x67 },
+       { (char*)"Samoan", 0x68 },
+       { (char*)"sm", 0x68 },
+       { (char*)"Shona", 0x69 },
+       { (char*)"sn", 0x69 },
+       { (char*)"Somali", 0x6a },
+       { (char*)"so", 0x6a },
+       { (char*)"Albanian", 0x6b },
+       { (char*)"sq", 0x6b },
+       { (char*)"Serbian", 0x6c },
+       { (char*)"sr", 0x6c },
+       { (char*)"Siswati", 0x6d },
+       { (char*)"ss", 0x6d },
+       { (char*)"Sesotho", 0x6e },
+       { (char*)"st", 0x6e },
+       { (char*)"Sundanese", 0x6f },
+       { (char*)"su", 0x6f },
+       { (char*)"Swedish", 0x70 },
+       { (char*)"sv", 0x70 },
+       { (char*)"Swahili", 0x71 },
+       { (char*)"sw", 0x71 },
+       { (char*)"Tamil", 0x72 },
+       { (char*)"ta", 0x72 },
+       { (char*)"Telugu", 0x73 },
+       { (char*)"te", 0x73 },
+       { (char*)"Tajik", 0x74 },
+       { (char*)"tg", 0x74 },
+       { (char*)"Thai", 0x75 },
+       { (char*)"th", 0x75 },
+       { (char*)"Tigrinya", 0x76 },
+       { (char*)"ti", 0x76 },
+       { (char*)"Turkmen", 0x77 },
+       { (char*)"tk", 0x77 },
+       { (char*)"Inupiak", 0x87 },
+       { (char*)"ik", 0x87 },
+       { (char*)"Icelandic", 0x33 },
+       { (char*)"is", 0x33 },
+       { (char*)"Italian", 0x34 },
+       { (char*)"it", 0x34 },
+       { (char*)"Inuktitut", 0x89 },
+       { (char*)"iu", 0x89 },
+       { (char*)"Japanese", 0x36 },
+       { (char*)"ja", 0x36 },
+       { (char*)"Javanese", 0x37 },
+       { (char*)"jw", 0x37 },
+       { (char*)"Georgian", 0x38 },
+       { (char*)"ka", 0x38 },
+       { (char*)"Kazakh", 0x39 },
+       { (char*)"kk", 0x39 },
+       { (char*)"Gerrnlandic", 0x8a },
+       { (char*)"kl", 0x8a },
+       { (char*)"Cambodian", 0x3b },
+       { (char*)"km", 0x3b },
+       { (char*)"Kannada", 0x3c },
+       { (char*)"kn", 0x3c },
+       { (char*)"Kashmiri", 0x3e },
+       { (char*)"ks", 0x3e },
+       { (char*)"Kurdish", 0x3f },
+       { (char*)"ku", 0x3f },
+       { (char*)"Kirghiz", 0x40 },
+       { (char*)"ky", 0x40 },
+       { (char*)"Latin", 0x8b },
+       { (char*)"la", 0x8b },
+       { (char*)"Lingala", 0x42 },
+       { (char*)"ln", 0x42 },
+       { (char*)"Laothian", 0x43 },
+       { (char*)"lo", 0x43 },
+       { (char*)"Lithuanian", 0x44 },
+       { (char*)"lt", 0x44 },
+       { (char*)"Lavian", 0x45 },
+       { (char*)"Lettish", 0x45 },
+       { (char*)"lv", 0x45 },
+       { (char*)"Malagasy", 0x46 },
+       { (char*)"mg", 0x46 },
+       { (char*)"Tagalog", 0x78 },
+       { (char*)"tl", 0x78 },
+       { (char*)"Setswana", 0x79 },
+       { (char*)"tn", 0x79 },
+       { (char*)"Tonga", 0x7a },
+       { (char*)"to", 0x7a },
+       { (char*)"Turkish", 0x7b },
+       { (char*)"tr", 0x7b },
+       { (char*)"Tsonga", 0x7c },
+       { (char*)"ts", 0x7c },
+       { (char*)"Tatar", 0x7d },
+       { (char*)"tt", 0x7d },
+       { (char*)"Twi", 0x7e },
+       { (char*)"tw", 0x7e },
+       { (char*)"Uighur", 0x7f },
+       { (char*)"ug", 0x7f },
+       { (char*)"Ukrainian", 0x1a },
+       { (char*)"uk", 0x1a },
+       { (char*)"Urdu", 0x21 },
+       { (char*)"ur", 0x21 },
+       { (char*)"Uzbek", 0x23 },
+       { (char*)"uz", 0x23 },
+       { (char*)"Vietnamese", 0x2f },
+       { (char*)"vi", 0x2f },
+       { (char*)"Volapuk", 0x85 },
+       { (char*)"vo", 0x85 },
+       { (char*)"Wolof", 0x31 },
+       { (char*)"wo" , 0x31 },
+       { (char*)"Xhosa", 0x32 },
+       { (char*)"xh", 0x32 },
+       { (char*)"Yiddish", 0x88 },
+       { (char*)"yi", 0x88 },
+       { (char*)"Yoruba", 0x35 },
+       { (char*)"yo", 0x35 },
+       { (char*)"Zhuang", 0x3a },
+       { (char*)"z", 0x3a },
+       { (char*)"Chinese", 0x41 },
+       { (char*)"ch", 0x41 },
+       { (char*)"Zulu", 0x5c },
+       { (char*)"zu", 0x5c },
+       { (char*)"Ko", 0x3d }
+};
+
+
+const SMS_WSP_HEADER_PARAMETER_S wspHeaderApplId[] =
+{
+       { (char*)"x-wap-application:*",  0x00 },
+       { (char*)"x-wap-application:push.sia",  0x01},
+       { (char*)"x-wap-application:wml.ua",  0x02 },
+       { (char*)"x-wap-application:wta.ua", 0x03 },
+       { (char*)"x-wap-application:mms.ua", 0x04 },
+       { (char*)"x-wap-application:push.syncml", 0x05 },
+       { (char*)"x-wap-application:loc.ua",  0x06 },
+       { (char*)"x-wap-application:syncml.dm", 0x07 },
+       { (char*)"x-wap-application:drm.ua", 0x08 },
+       { (char*)"x-wap-application:emn.ua", 0x09 }
+};
+
+
+const char* wspCacheControl[] =
+{
+       (char*)"No-cache",
+       (char*)"No-store",
+       (char*)"Max-age",
+       (char*)"Max-stale",
+       (char*)"Min-fresh",
+       (char*)"Only-if-cached",
+       (char*)"Public",
+       (char*)"Private",
+       (char*)"No-transform",
+       (char*)"Must-revalidate",
+       (char*)"Proxy-revalidate"
+};
+
+const SMS_WSP_METHOD_TYPE_S wspMethodType[] =
+{
+       { (char*)"GET", 0x40 },
+       { (char*)"OPTIONS", 0x41 },
+       { (char*)"HEAD", 0x42 },
+       { (char*)"DELETE", 0x43 },
+       { (char*)"TRACE", 0x44 },
+       { (char*)"POST", 0x60 },
+       { (char*)"PUT", 0x61 }
+};
+
+
+const SMS_WSP_SECURITY_TYPE_S wspSecurityType[] =
+{
+       {(char*)"NETWPIN",0x00},
+       {(char*)"USERPIN",0x01},
+       {(char*)"USERNETWPIN",0x02},
+       {(char*)"USERPINMAC",0x03}
+};
+
+
+
+const char* wspWeek[] =
+{
+       (char*)"Sun",
+       (char*)"Mon",
+       (char*)"Tue",
+       (char*)"Wed",
+       (char*)"Thu",
+       (char*)"Fri",
+       (char*)"Sat"
+};
+
+
+const char* wspWeekDay[] =
+{
+       (char*)"Sunday",
+       (char*)"Monday",
+       (char*)"Tuesday",
+       (char*)"Wednesday",
+       (char*)"Thursday",
+       (char*)"Friday",
+       (char*)"Saturday"
+};
+
+const char* wspMonth[] =
+{
+       (char*)"Jan",
+       (char*)"Feb",
+       (char*)"Mar",
+       (char*)"Apr",
+       (char*)"May",
+       (char*)"Jun",
+       (char*)"Jul",
+       (char*)"Aug",
+       (char*)"Sep",
+       (char*)"Oct",
+       (char*)"Nov",
+       (char*)"Dec"
+};
+
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF SmsPluginWapPushHandler - Member Functions
+==================================================================================================*/
+SmsPluginWapPushHandler* SmsPluginWapPushHandler::pInstance = NULL;
+
+
+SmsPluginWapPushHandler::SmsPluginWapPushHandler()
+{
+       memset(&tmpAddress, 0x00, sizeof(tmpAddress));
+}
+
+
+SmsPluginWapPushHandler::~SmsPluginWapPushHandler()
+{
+
+}
+
+
+SmsPluginWapPushHandler* SmsPluginWapPushHandler::instance()
+{
+       if (!pInstance)
+               pInstance = new SmsPluginWapPushHandler();
+
+       return pInstance;
+}
+
+
+bool SmsPluginWapPushHandler::IsWapPushMsg(SMS_USERDATA_S *pUserData)
+{
+       MSG_BEGIN();
+
+       if (pUserData == NULL) {
+               MSG_DEBUG("pUserData is NULL");
+               return false;
+       }
+
+       int PortCount = sizeof(wapPushPortList)/sizeof(wapPushPortList[0]);
+
+       MSG_DEBUG("Port Count [%d]", PortCount);
+
+       for (int i = 0; i < pUserData->headerCnt; i++) {
+               if (pUserData->header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
+                       /** Have to check something??? */
+               } else if (pUserData->header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
+
+                       for (int j = 0; j < PortCount; j++) {
+                               if (pUserData->header[i].udh.appPort16bit.destPort == wapPushPortList[j]) {
+                                       MSG_DEBUG("Wap Push Msg : [%04x]", wapPushPortList[j]);
+                                       return true;
+                               }
+                       }
+               }
+       }
+
+       MSG_END();
+
+       return false;
+}
+
+
+SMS_WAP_APP_CODE_T SmsPluginWapPushHandler::getAppCode(const char *pPushHeader)
+{
+       int appCount = sizeof(pushDefaultApplication)/sizeof(pushDefaultApplication[0]) - 1;
+
+       unsigned char *header = NULL;
+       SMS_WAP_APP_CODE_T      appCode = SMS_WAP_APPLICATION_DEFAULT;
+
+       MSG_DEBUG("Application Count [%d]", appCount);
+
+       for (int i = 0; i < appCount; i++) {
+
+               header = (unsigned char*)strcasestr(pPushHeader, pushDefaultApplication[i].pContentType);
+
+               if (header != NULL) {
+                       appCode = pushDefaultApplication[i].appCode;
+                       break;
+               }
+       }
+
+       if (appCode == SMS_WAP_APPLICATION_DEFAULT) {
+               MSG_DEBUG("Application Type is not supported");
+       } else {
+               MSG_DEBUG("Find Application [%d]", appCode);
+       }
+
+       return appCode;
+}
+
+
+void SmsPluginWapPushHandler::copyDeliverData(SMS_DELIVER_S *pDeliver)
+{
+       tmpAddress.ton = pDeliver->originAddress.ton;
+       tmpAddress.npi = pDeliver->originAddress.npi;
+
+       strncpy(tmpAddress.address, pDeliver->originAddress.address, MAX_ADDRESS_LEN);
+
+       MSG_DEBUG("Address [%s]", tmpAddress.address);
+
+       tmpTimeStamp.format = pDeliver->timeStamp.format;
+
+       if (tmpTimeStamp.format == SMS_TIME_ABSOLUTE) {
+               tmpTimeStamp.time.absolute.year = pDeliver->timeStamp.time.absolute.year;
+               tmpTimeStamp.time.absolute.month = pDeliver->timeStamp.time.absolute.month;
+               tmpTimeStamp.time.absolute.day = pDeliver->timeStamp.time.absolute.day;
+               tmpTimeStamp.time.absolute.hour = pDeliver->timeStamp.time.absolute.hour;
+               tmpTimeStamp.time.absolute.minute = pDeliver->timeStamp.time.absolute.minute;
+               tmpTimeStamp.time.absolute.second = pDeliver->timeStamp.time.absolute.second;
+               tmpTimeStamp.time.absolute.timeZone = pDeliver->timeStamp.time.absolute.timeZone;
+       }
+}
+
+
+void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSize)
+{
+       MSG_BEGIN();
+
+       unsigned char* pPDUTypeData = (unsigned char*)pUserData;
+       unsigned long PDUTypeDataLen = DataSize;
+
+       char* pPushHeader = NULL;
+       AutoPtr<char> pushHeaderBuf(&pPushHeader);
+       unsigned long pushHeaderLen = 0;
+
+       char* pPushBody = NULL;
+       AutoPtr<char> PushBodyBuf(&pPushBody);
+       unsigned long pushBodyLen = 0;
+
+       unsigned long iPDU = 1;
+
+       char* pWspHeader = NULL;
+       AutoPtr<char> WspHeaderBuf(&pWspHeader);
+       unsigned long   wspHeaderLen = 0;
+
+       char* pWspBody = NULL;
+       AutoPtr<char> WspBodyBuf(&pWspBody);
+       unsigned long wspBodyLen = 0;
+
+       /** pass PDU type */
+       iPDU++;
+
+       pushHeaderLen = wspRetriveUintvarDecode( pPDUTypeData, &iPDU );
+
+       MSG_DEBUG("PDUTypeDataLen [%d]", PDUTypeDataLen);
+       MSG_DEBUG("pushHeaderLen [%d]", pushHeaderLen);
+       MSG_DEBUG("iPDU [%d]", iPDU);
+
+       wspHeaderLen = pushHeaderLen + iPDU;
+
+       MSG_DEBUG("wspBodyLen [%d]", wspBodyLen);
+
+       if (wspHeaderLen > 0) {
+
+               pWspHeader = new char[wspHeaderLen];
+
+               if (pWspHeader == NULL) {
+                       MSG_DEBUG("pWspHeader Memory Allocation Failed");
+                       return;
+               } else {
+                       memcpy(pWspHeader, pPDUTypeData, wspHeaderLen);
+               }
+       }
+
+       /** return if it is below case error */
+       if (PDUTypeDataLen < wspHeaderLen) {
+               MSG_DEBUG("PDUTypeDataLen < wspHeaderLen !!!");
+               return;
+       }
+
+       /** Finding wspBody Information */
+       wspBodyLen = PDUTypeDataLen - wspHeaderLen;
+
+       if (wspBodyLen > 0) {
+
+               pWspBody = new char[wspBodyLen];
+
+               if (pWspBody == NULL) {
+                       MSG_DEBUG("pWspBody Memory Allocation Failed");
+                       return;
+               } else {
+                       memcpy(pWspBody, pPDUTypeData + wspHeaderLen, wspBodyLen);
+               }
+       } else {
+               pWspBody = NULL;
+       }
+
+       wspDecodeHeader(pPDUTypeData + iPDU, pushHeaderLen, PDUTypeDataLen - (iPDU + pushHeaderLen), TRUE, &pPushHeader);
+
+       iPDU = iPDU + pushHeaderLen;
+
+       pushBodyLen = PDUTypeDataLen - iPDU ;
+
+       if (pushBodyLen > 0) {
+               pPushBody = new char[pushBodyLen];
+
+               if (pPushBody == NULL)  {
+                       MSG_DEBUG("pPushBody Memory Allocation Failed");
+                       return;
+               } else {
+                       memcpy(pPushBody, pPDUTypeData+ iPDU, pushBodyLen);
+               }
+       } else {
+               pPushBody = NULL;
+               return;
+       }
+
+       handleWapPushCallback((char *)pPushHeader, (char *)pPushBody, (int)pushBodyLen, (char *)pWspHeader, (int)wspHeaderLen, (char *)pWspBody, (int)wspBodyLen);
+
+       MSG_END();
+}
+
+
+void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen)
+{
+       MSG_BEGIN();
+
+       if (pPushBody == NULL) {
+               MSG_DEBUG("pPushBody is NULL");
+               return;
+       }
+
+       SMS_WAP_APP_CODE_T      appCode = getAppCode(pPushHeader);
+
+       /**  check Push message receive setting */
+       bool bPushRecv = false;
+
+       MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv);
+
+       if ((bPushRecv == false) && (appCode != SMS_WAP_APPLICATION_MMS_UA)) {
+               MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
+               return;
+       }
+
+       switch (appCode) {
+       case SMS_WAP_APPLICATION_MMS_UA:
+               MSG_DEBUG("Received MMS Notification");
+
+               handleMMSNotification(pPushBody, PushBodyLen);
+               break;
+
+       case SMS_WAP_APPLICATION_PUSH_SI:
+               MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
+               handleSIMessage(pPushBody, PushBodyLen, true);
+               break;
+
+       case SMS_WAP_APPLICATION_PUSH_SIC:
+               MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
+               handleSIMessage(pPushBody, PushBodyLen, false);
+               break;
+
+       case SMS_WAP_APPLICATION_PUSH_SL:
+               MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
+               handleSLMessage(pPushBody, PushBodyLen, true);
+               break;
+
+       case SMS_WAP_APPLICATION_PUSH_SLC:
+               MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
+               handleSLMessage(pPushBody, PushBodyLen, false);
+               break;
+
+       case SMS_WAP_APPLICATION_PUSH_CO:
+               MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
+               handleCOMessage(pPushBody, PushBodyLen, true);
+               break;
+
+       case SMS_WAP_APPLICATION_PUSH_COC:
+               MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
+               handleCOMessage(pPushBody, PushBodyLen, false);
+               break;
+
+       case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
+               MSG_DEBUG("Received DM BOOTSTRAP");
+               SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+               break;
+
+       case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
+               MSG_DEBUG("Received DM BOOTSTRAP");
+               SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+               break;
+
+       case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
+               MSG_DEBUG("Received Provisioning");
+               SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+               break;
+
+       case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
+               MSG_DEBUG("Received Provisioning");
+               SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+               break;
+
+       case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
+       case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
+               MSG_DEBUG("Received Provisioning");
+               SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+               break;
+
+       case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
+               MSG_DEBUG("Received DM Notification");
+               SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+               break;
+
+       case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
+               MSG_DEBUG("Received DS Notification");
+               SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+               break;
+
+       case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
+               MSG_DEBUG("Received DS Notification");
+               SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+               break;
+
+       case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
+       case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
+               MSG_DEBUG("Received DRM UA");
+
+               if (pPushBody != NULL)
+                       handleDrmVer1(pPushBody, PushBodyLen);
+
+               break;
+
+       case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
+       case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
+       case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
+       case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
+               MSG_DEBUG("Received DRM V2");
+               // TODO: DRM V2
+               break;
+
+       case SMS_WAP_APPLICATION_PUSH_EMAIL:
+       case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
+       case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
+               MSG_DEBUG("Received Email");
+               // TODO: Email
+               break;
+
+       case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
+               MSG_DEBUG("Received IMPS CIR");
+               // TODO: IMPS CIR
+               break;
+
+       case SMS_WAP_APPLICATION_LBS :
+               MSG_DEBUG("Received LBS related message");
+               SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
+               // TODO: LBS
+               break;
+
+       case SMS_WAP_APPLICATION_PUSH_SIA :
+               MSG_DEBUG("Received SIA");
+               // TODO: SIA
+               break;
+
+       default:
+               MSG_DEBUG("Unknown Application [%d]", appCode);
+               break;
+       }
+
+       MSG_END();
+}
+
+
+void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int PushBodyLen)
+{
+       MSG_BEGIN();
+
+       /** Make MSG_MESSAGE_INFO_S */
+       MSG_MESSAGE_INFO_S msgInfo;
+
+       createMsgInfo(&msgInfo);
+
+       /** Convert Type values */
+       msgInfo.msgType.mainType = MSG_MMS_TYPE;
+       msgInfo.msgType.subType = MSG_NOTIFICATIONIND_MMS;
+
+       msgInfo.dataSize = PushBodyLen;
+
+       if (msgInfo.dataSize > MAX_MSG_TEXT_LEN) {
+               msgInfo.bTextSms = false;
+
+               /** Save Message Data into File */
+               char fileName[MAX_COMMON_INFO_SIZE+1];
+               memset(fileName, 0x00, sizeof(fileName));
+
+               if (MsgCreateFileName(fileName) == false)
+                       THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+
+               if (MsgWriteIpcFile(fileName, pPushBody, msgInfo.dataSize) == false)
+                       THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+
+               strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+       } else {
+               msgInfo.bTextSms = true;
+
+               memcpy(msgInfo.msgText, pPushBody, msgInfo.dataSize);
+               msgInfo.msgText[msgInfo.dataSize] = '\0';
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       /** Add MMS Noti Msg into DB */
+       err = SmsPluginStorage::instance()->addMessage(&msgInfo);
+
+       if (err == MSG_SUCCESS) {
+               /**  Callback */
+               err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+
+               if (err != MSG_SUCCESS) {
+                       MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+               }
+       } else {
+               MSG_DEBUG("addMessage() Error !! [%d]", err);
+       }
+
+       MSG_END();
+}
+
+void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen, bool isText)
+{
+       MSG_BEGIN();
+
+       MSG_PUSH_MESSAGE_S pushMsg = {};
+
+       xmlDocPtr       xmlDoc = NULL;
+       xmlNodePtr      topNode = NULL;
+       xmlNodePtr      indNode = NULL;
+
+       xmlChar*                tmpXmlChar = NULL;
+
+       if (pPushBody == NULL) {
+               MSG_DEBUG("pPushBody is NULL");
+               return;
+       }
+
+       getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
+
+       if (xmlDoc == NULL) {
+               MSG_DEBUG("xmlDoc is NULL");
+               return;
+       }
+
+       topNode = xmlDocGetRootElement(xmlDoc);
+
+       if (xmlDoc == NULL) {
+               MSG_DEBUG("Empty Document");
+               xmlFreeDoc(xmlDoc);
+               return;
+       }
+
+       indNode = topNode->xmlChildrenNode;
+
+       while (indNode != NULL) {
+               if (!xmlStrcmp(indNode->name, (const xmlChar*) "indication")) {
+                       MSG_DEBUG("indNode->name = %s\n", indNode->name);
+                       break;
+               }
+
+               indNode = indNode->next;
+       }
+
+       if (indNode == NULL) {
+               MSG_DEBUG("indNode is NULL.");
+               return;
+       }
+
+       /**  temporary set to max. */
+       pushMsg.expires = 0xFFFFFFFF;
+
+       /** setting received time */
+       time_t  t               =       time(NULL);
+       time_t  utfTime =       time(&t);
+
+       pushMsg.received = (unsigned long)utfTime;
+
+       tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
+
+       if (tmpXmlChar == NULL) {
+               MSG_DEBUG("href is NULL.");
+               return;
+       }
+
+       if (tmpXmlChar != NULL)
+               strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
+
+       tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_SI_ID_TAG);
+
+       if (tmpXmlChar != NULL)
+               strncpy(pushMsg.id, (char*)tmpXmlChar, MAX_WAPPUSH_ID_LEN-1);
+
+       tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CREATED_TAG);
+
+       if (tmpXmlChar != NULL)
+               pushMsg.created = convertXmlCharToSec((char*)tmpXmlChar);
+
+       if (pushMsg.created == 0)
+               pushMsg.created = pushMsg.received;
+
+       tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_EXPIRES_TAG);
+
+       if (tmpXmlChar != NULL)
+               pushMsg.expires = convertXmlCharToSec((char*)tmpXmlChar);
+
+       tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
+
+       pushMsg.action = convertSIActionStrToEnum((char*)tmpXmlChar);
+
+       tmpXmlChar = xmlNodeListGetString(xmlDoc, indNode->xmlChildrenNode, 1);
+
+       if (tmpXmlChar == NULL) {
+               MSG_DEBUG("contents is NULL.");
+               return;
+       }
+
+       strncpy(pushMsg.contents, (char*)tmpXmlChar, MAX_WAPPUSH_CONTENTS_LEN-1);
+
+       /** Write push Msg to file */
+       char fileName[MAX_COMMON_INFO_SIZE+1];
+       memset(fileName, 0x00, sizeof(fileName));
+
+       if (MsgCreateFileName(fileName) == false) {
+               xmlFree(xmlDoc);
+               xmlFree(tmpXmlChar);
+               THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+       }
+
+       if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false) {
+               xmlFree(xmlDoc);
+               xmlFree(tmpXmlChar);
+               THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+       }
+
+       /**  Pack Message Info Structure */
+       MSG_MESSAGE_INFO_S msgInfo;
+
+       createMsgInfo(&msgInfo);
+
+       strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+
+       /**  Convert Type values */
+       msgInfo.msgType.mainType = MSG_SMS_TYPE;
+       msgInfo.msgType.subType = MSG_WAP_SI_SMS;
+
+       msgInfo.dataSize = sizeof(pushMsg);
+
+       xmlFree(xmlDoc);
+       xmlFree(tmpXmlChar);
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       /** Add WAP Push Msg into DB */
+       err = SmsPluginStorage::instance()->addMessage(&msgInfo);
+
+       if (err == MSG_SUCCESS) {
+               /** Callback */
+               err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+
+               if (err != MSG_SUCCESS){
+                       MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+               }
+       } else {
+               MSG_DEBUG("addMessage() Error !! [%d]", err);
+       }
+
+       MSG_END();
+
+       return;
+}
+
+
+void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen, bool isText)
+{
+       MSG_BEGIN();
+
+       MSG_PUSH_MESSAGE_S pushMsg = {};
+
+       xmlDocPtr       xmlDoc = NULL;
+       xmlNodePtr      topNode = NULL;
+       xmlNodePtr      indNode = NULL;
+
+       xmlChar*                tmpXmlChar = NULL;
+
+       if (pPushBody == NULL) {
+               MSG_DEBUG("pPushBody is NULL \n" );
+               return;
+       }
+
+       getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
+
+       if (xmlDoc == NULL) {
+               MSG_DEBUG("xmlDoc is NULL \n" );
+               return;
+       }
+
+       topNode = xmlDocGetRootElement(xmlDoc);
+
+       if (topNode == NULL) {
+               MSG_DEBUG("Empty Document." );
+               xmlFreeDoc(xmlDoc);
+               return;
+       } else {
+               MSG_DEBUG("Not an empty Document and topNode->name = %s \n",topNode->name );
+       }
+
+       indNode = topNode;
+
+       while (indNode != NULL) {
+               if (!xmlStrcmp(indNode->name, (const xmlChar*) "sl")) {
+                       MSG_DEBUG("indNode->name = %s\n",indNode->name);
+                       break;
+               }
+
+               indNode = indNode->next;
+       }
+
+       /**  setting received time setting */
+       time_t  t               =       time(NULL);
+       time_t  utfTime =       time(&t);
+
+       pushMsg.received = (unsigned long)utfTime;
+
+       tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
+
+       if (tmpXmlChar == NULL) {
+               MSG_DEBUG("href is NULL.");
+               return;
+       }
+
+       strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
+
+       tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
+       pushMsg.action = convertSLActionStrToEnum((char*)tmpXmlChar);
+
+       /** Setting other parameters in default values */
+       pushMsg.created = pushMsg.received;
+       /** temporary set to MAX value. */
+       pushMsg.expires = 0xFFFFFFFF;
+
+       MSG_DEBUG("check pushMsg data");
+       MSG_DEBUG("pushMsg.action : [%d]", pushMsg.action);
+       MSG_DEBUG("pushMsg.received : [%d]", pushMsg.received);
+       MSG_DEBUG("pushMsg.created : [%d]", pushMsg.created);
+       MSG_DEBUG("pushMsg.expires : [%d]", pushMsg.expires);
+       MSG_DEBUG("pushMsg.id : [%s]", pushMsg.id);
+       MSG_DEBUG("pushMsg.href : [%s]", pushMsg.href);
+       MSG_DEBUG("pushMsg.contents : [%s]", pushMsg.contents);
+
+       /** Write push Msg to file */
+       char fileName[MAX_COMMON_INFO_SIZE+1];
+       memset(fileName, 0x00, sizeof(fileName));
+
+       if (MsgCreateFileName(fileName) == false)
+               THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+
+       if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false)
+               THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+
+       /** Pack Message Info Structure */
+       MSG_MESSAGE_INFO_S msgInfo;
+
+       createMsgInfo(&msgInfo);
+
+       strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+
+       /** Convert Type values */
+       msgInfo.msgType.mainType = MSG_SMS_TYPE;
+       msgInfo.msgType.subType = MSG_WAP_SL_SMS;
+
+       /**  Update Msg Text */
+       strncpy(msgInfo.msgText, pushMsg.href, MAX_MSG_TEXT_LEN);
+
+       msgInfo.dataSize = sizeof(pushMsg);
+
+       MSG_DEBUG("dataSize : %d", msgInfo.dataSize);
+
+       /** Callback to MSG FW */
+       SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+
+       xmlFree(xmlDoc);
+       xmlFree(tmpXmlChar);
+
+       MSG_END();
+
+       return;
+}
+
+void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen, bool isText)
+{
+       MSG_PUSH_CACHEOP_S cacheOp;
+
+       xmlDocPtr       xmlDoc = NULL;
+       xmlNodePtr      topNode = NULL;
+       xmlNodePtr      indNode = NULL;
+
+       memset(&cacheOp, 0x00, sizeof(cacheOp));
+
+       MSG_DEBUG("Enter handleCOMessage");
+
+       if (pPushBody == NULL) {
+               MSG_DEBUG("pPushBody is NULL \n" );
+               return;
+       }
+
+       getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
+
+       if (xmlDoc == NULL) {
+               MSG_DEBUG("xmlDoc is NULL \n" );
+               return;
+       }
+
+       topNode = xmlDocGetRootElement(xmlDoc);
+       if (topNode == NULL) {
+               MSG_DEBUG("Warning:Empty Document\n" );
+               xmlFreeDoc(xmlDoc);
+               return;
+       }
+
+       indNode = topNode->xmlChildrenNode;
+
+
+       while(indNode != NULL) {
+
+               xmlChar* tmpUrl = NULL;
+               if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_OBJ)) {
+                       MSG_DEBUG("indNode->name = %s\n", indNode->name);
+
+                       tmpUrl = xmlGetProp(indNode, (xmlChar*) SMS_PUSH_XML_CO_URI);
+
+                       if (tmpUrl != NULL) {
+                               strncpy(cacheOp.invalObjectUrl[cacheOp.invalObjectCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
+
+                               MSG_DEBUG("%dth invalObjectUrl is <%s>\n", cacheOp.invalObjectCnt, cacheOp.invalObjectUrl[cacheOp.invalObjectCnt-1]);
+                       } else {
+                               MSG_DEBUG("NO href value from the xmlDoc\n");
+                       }
+               } else if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_SVC)) {
+                       MSG_DEBUG("indNode->name = %s\n",indNode->name);
+                       tmpUrl = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CO_URI);
+
+                       if (tmpUrl != NULL) {
+                               strncpy(cacheOp.invalServiceUrl[cacheOp.invalServiceCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
+                               MSG_DEBUG("%dth invalServiceUrl is <%s>\n", cacheOp.invalServiceCnt, cacheOp.invalServiceUrl[cacheOp.invalServiceCnt-1]);
+                       } else {
+                               MSG_DEBUG("NO href value from the xmlDoc\n");
+                       }
+               }
+
+               if (tmpUrl != NULL)
+                       xmlFree(tmpUrl);
+
+               indNode = indNode->next;
+       }
+
+       /**  Write push Msg to file */
+       char fileName[MAX_COMMON_INFO_SIZE+1];
+       memset(fileName, 0x00, sizeof(fileName));
+
+       if (MsgCreateFileName(fileName) == false) {
+               xmlFree(xmlDoc);
+               THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+       }
+
+       if (MsgWriteIpcFile(fileName, (char*)(&cacheOp), sizeof(cacheOp)) == false) {
+               xmlFree(xmlDoc);
+               THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+       }
+
+       /**  Pack Message Info Structure */
+       MSG_MESSAGE_INFO_S msgInfo;
+
+       createMsgInfo(&msgInfo);
+
+       strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+
+       /**  Convert Type values */
+       msgInfo.msgType.mainType = MSG_SMS_TYPE;
+       msgInfo.msgType.subType = MSG_WAP_CO_SMS;
+
+       msgInfo.dataSize = sizeof(cacheOp);
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       /** Add WAP Push Msg into DB */
+       err = SmsPluginStorage::instance()->addMessage(&msgInfo);
+
+       if (err == MSG_SUCCESS) {
+               /** Callback */
+               err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+
+               if (err != MSG_SUCCESS) {
+                       MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+               }
+       } else {
+               MSG_DEBUG("addMessage() Error !! [%d]", err);
+       }
+
+       xmlFree(xmlDoc);
+
+       return;
+}
+
+
+void SmsPluginWapPushHandler::handleDrmVer1(char* pPushBody, int PushBodyLen)
+{
+       int drmRt = DRM_RETURN_SUCCESS;
+       char* cid = NULL;
+       AutoPtr<char> buf(&cid);
+
+       MSG_DEBUG("Received DRM RIGHTS OBJECT Type WAP Push Message.");
+       drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE;
+       drm_register_lic_info_s lic_req_info;
+       drm_register_lic_resp_s lic_resp_info;
+
+       bzero(&lic_req_info, sizeof(drm_register_lic_info_s));
+       bzero(&lic_resp_info, sizeof(drm_register_lic_resp_s));
+       bzero(lic_req_info.lic_data, sizeof(lic_req_info.lic_data));
+
+       memcpy(lic_req_info.lic_data, pPushBody, PushBodyLen);
+
+       lic_req_info.lic_version = DRM_OMA_DRMV1_RIGHTS;
+       lic_req_info.roap_init_src = DRM_ROAP_INIT_FROM_WAPPUSH;
+       lic_req_info.operation_callback.callback = NULL;
+
+       drmRt = drm_process_request(request_type, &lic_req_info, &lic_resp_info);
+       if (drmRt == DRM_RETURN_SUCCESS) {
+               MSG_DEBUG("DRM successfully registed to drm-service.");
+       } else {
+               MSG_DEBUG("Fail to regist DRM to drm-service.");
+       }
+
+       return;
+}
+
+
+void SmsPluginWapPushHandler::createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo)
+{
+       /** Convert class Type values */
+       pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+
+       /**  set folder id (temporary) */
+       pMsgInfo->folderId = MSG_INBOX_ID;
+
+       pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+       pMsgInfo->bRead = false;
+       pMsgInfo->bProtected = false;
+       pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+       pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
+
+
+       time_t rawtime = time(NULL);
+
+       pMsgInfo->displayTime = rawtime;
+
+       /**  Convert Address values */
+       pMsgInfo->nAddressCnt = 1;
+       pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+       strncpy(pMsgInfo->addressList[0].addressVal, tmpAddress.address, MAX_ADDRESS_VAL_LEN);
+
+       pMsgInfo->msgPort.valid = false;
+       pMsgInfo->msgPort.dstPort = 0;
+       pMsgInfo->msgPort.srcPort = 0;
+
+}
+
+void SmsPluginWapPushHandler::getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText)
+{
+       if (pPushBody == NULL) {
+               MSG_DEBUG("pPushBody is NULL");
+               return;
+       }
+
+
+       if (isText) {
+               *pXmlDoc = xmlParseMemory(pPushBody, strlen(pPushBody));
+       } else {
+               WB_UTINY*       xmldata = NULL;
+               WBXMLConvWBXML2XML *conv = NULL;
+               WBXMLError ret = WBXML_OK;
+
+               ret = wbxml_conv_wbxml2xml_create(&conv);
+               if (ret != WBXML_OK)
+                       return;
+
+               ret = wbxml_conv_wbxml2xml_run(conv, (WB_UTINY*)pPushBody, (WB_ULONG)PushBodyLen, &xmldata, NULL);
+
+               wbxml_conv_wbxml2xml_destroy(conv);
+
+               if (ret != WBXML_OK ||xmldata == NULL) {
+                       MSG_DEBUG("xmldata is NULL. Error code is [%d].\n", ret);
+                       return;
+               }
+
+               MSG_DEBUG("xmldata : \n%s\n", xmldata);
+
+               *pXmlDoc = xmlParseMemory((char*)xmldata, strlen((char*)xmldata));
+       }
+
+}
+
+unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
+{
+       struct tm       timeStruct;
+       time_t          nTimeInSec = 0;
+       char                    tmpBuf[10];
+       int                     i = 0, index = 0;
+
+       memset(tmpBuf, 0x00, sizeof(tmpBuf));
+       memset(&timeStruct, 0x00, sizeof(&timeStruct));
+
+       /** check pDate */
+       if (strlen(pDate)<20)
+               return 0;
+
+       MSG_DEBUG("pDate [%s]", pDate);
+
+       /** Year */
+       for (i = 0; i < 4; i++) {
+               tmpBuf[i] = pDate[index++];
+       }
+       tmpBuf[i] = '\0';
+       index++;
+       timeStruct.tm_year = (atoi( tmpBuf)-1900);
+
+       /**  Month */
+       for (i = 0; i < 2; i++) {
+               tmpBuf[i] = pDate[index++];
+       }
+       tmpBuf[i] = '\0';
+       index++;
+       timeStruct.tm_mon = (atoi( tmpBuf) - 1);
+
+       /** Date */
+       for (i = 0; i < 2; i++) {
+               tmpBuf[i] = pDate[index++];
+       }
+       tmpBuf[i] = '\0';
+       index++;
+       timeStruct.tm_mday = atoi( tmpBuf);
+
+       /** Hours */
+       for (i = 0; i < 2; i++) {
+               tmpBuf[i] = pDate[index++];
+       }
+       tmpBuf[i] = '\0';
+       index++;
+       timeStruct.tm_hour = atoi( tmpBuf);
+
+       /** Minites */
+       for (i = 0; i < 2; i++) {
+               tmpBuf[i] = pDate[index++];
+       }
+       tmpBuf[i] = '\0';
+       index++;
+       timeStruct.tm_min = atoi( tmpBuf);
+
+       /** Seconds */
+       for (i = 0; i < 2; i++) {
+               tmpBuf[i] = pDate[index++];
+       }
+       tmpBuf[i] = '\0';
+       index++;
+       timeStruct.tm_sec = atoi( tmpBuf);
+
+       nTimeInSec = mktime(&timeStruct);
+
+       return nTimeInSec;
+}
+
+MSG_PUSH_ACTION_T SmsPluginWapPushHandler::convertSIActionStrToEnum(char* pAction)
+{
+       int comp = 0;
+
+       if (pAction == NULL) {
+               MSG_DEBUG("pAction is NULL. Setting to default action type.");
+               return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
+       }
+
+       /** compare  with signal-none. */
+       comp = strcmp( "signal-none", pAction );
+       if (comp == 0)
+               return MSG_PUSH_SI_ACTION_SIGNAL_NONE;
+
+       /** compare  with signal-low. */
+       comp = strcmp( "signal-low", pAction );
+       if (comp == 0)
+               return MSG_PUSH_SI_ACTION_SIGNAL_LOW;
+
+       /**  compare  with signal-medium. */
+       comp = strcmp( "signal-medium", pAction );
+       if (comp == 0)
+               return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
+
+       /**  compare  with signal-high. */
+       comp = strcmp( "signal-high", pAction );
+       if (comp == 0)
+               return MSG_PUSH_SI_ACTION_SIGNAL_HIGH;
+
+       /**  compare  with delete. */
+       comp = strcmp( "delete", pAction );
+       if (comp == 0)
+               return MSG_PUSH_SI_ACTION_DELETE;
+
+       /**  signal-medium is default action value. */
+       return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
+
+}
+
+MSG_PUSH_ACTION_T SmsPluginWapPushHandler::convertSLActionStrToEnum(char* pAction)
+{
+       int comp = 0;
+
+       if (pAction == NULL) {
+               MSG_DEBUG( "MSG_DEBUG is NULL. Setting to default action type.\n" );
+               return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
+       }
+
+       /**  compare pSrcStr with execute-low. */
+       comp = strcmp( "execute-low", pAction );
+       if (comp == 0)
+               return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
+
+       /**  compare pSrcStr with execute-high. */
+       comp = strcmp( "execute-high", pAction );
+       if (comp == 0)
+               return MSG_PUSH_SL_ACTION_EXECUTE_HIGH;
+
+       /** compare pSrcStr with cache. */
+       comp = strcmp( "cache", pAction );
+       if (comp == 0)
+               return MSG_PUSH_SL_ACTION_CACHE;
+
+       /** default SL action value is execute-low. */
+       return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
+
+}
+
+
+unsigned long SmsPluginWapPushHandler::wspRetriveUintvarDecode( unsigned char* sourceData, unsigned long* currentPointer )
+{
+       unsigned long i = 0;
+       unsigned long decodedValue;
+
+       while (sourceData[*currentPointer +i] >= 0x80) i++;
+
+       decodedValue = wspDecodeUintvar( i+1, sourceData + *currentPointer );
+       *currentPointer = *currentPointer + i + 1;
+       MSG_DEBUG("wspRetriveUintvarDecode: decodedValue=%d .\n",decodedValue );
+       return decodedValue;
+}
+
+
+unsigned long SmsPluginWapPushHandler::wspDecodeUintvar(unsigned long length, unsigned char* userVar )
+{
+       unsigned long i;
+       unsigned long decodedUintvar = 0;
+
+
+       for (i = 0 ; i < length; i++) {
+               decodedUintvar = decodedUintvar +  ( wspUintvarDecodeTable[i] * (userVar[length-(i+1)] & 0x7f ));
+       }
+
+       return decodedUintvar;
+}
+
+
+void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader)
+{
+       unsigned long iField;
+       bool   continueField = FALSE;
+       unsigned long currentLength;
+
+       char* encodedHeader = NULL;
+       AutoPtr<char> encodedHeaderbuf(&encodedHeader);
+
+       char* outTemper = NULL;
+
+       char* temper = NULL;
+       AutoPtr<char> temperbuf(&temper);
+
+       unsigned char track;
+       unsigned long iEncodedHeader = 0;
+       unsigned char fieldCode = 0xff;
+
+       /* outTemper is Decoded Headers.
+           temper is Single Decoded Header.
+       */
+       if (NULL == ( outTemper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ])) {
+               MSG_DEBUG("outTemper Memory allocation is failed.\n" );
+               return;
+       }
+       memset(outTemper, 0, (WSP_STANDARD_STR_LEN_MAX * 5));
+       currentLength = WSP_STANDARD_STR_LEN_MAX;
+
+       MSG_DEBUG("wspDecodeHeader: Message header decoding started.\n" );
+
+       int loop;
+       char szBuf[64];
+
+       szBuf[0] = 0x00;
+       MSG_DEBUG("wspDecodeHeader: RAW data \n" );
+       for (loop = 0 ; loop<(int)encodedHeaderLen; loop++) {
+               char szTempBuf[5];
+               szTempBuf[0] = 0x00;
+               sprintf( szTempBuf, "%2X ", sEncodedHeader[loop] );
+
+               if (AcStrlen( szBuf ) + 7 < 64) {
+                       strncat( szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1 );
+               } else {
+                       strncat( szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1 );
+                       MSG_DEBUG("[%s]", szBuf);
+                       szBuf[0] = 0x00;
+                       strncat( szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1 );
+               }
+       }
+       strncat( szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1 );
+       MSG_DEBUG("[%s]", szBuf);
+       MSG_DEBUG("fContentType=%d  \n",fContentType );
+       /* operation for content-type */
+       /* makes psuedo- content-type fieldcode */
+       /* content - type is processed with header. But it's come without field code. So existence of fContentType can decide adding content type header field code whether ContentType + general header is or not. */
+
+       if (fContentType) {
+               encodedHeader = new char[ encodedHeaderLen + 1 ];
+               if (encodedHeader == NULL)      {
+                       MSG_DEBUG("encodedHeader Memory allocation is failed.\n" );
+                       return;
+               }
+               encodedHeader[0] = 0x91;
+               memcpy( encodedHeader + 1, sEncodedHeader, (size_t)encodedHeaderLen );
+       } else {
+               encodedHeader = new char[ encodedHeaderLen ];
+               if (encodedHeader == NULL)      {
+                       MSG_DEBUG("encodedHeader Memory allocation is failed.\n" );
+                       return;
+               }
+
+               memcpy( encodedHeader, sEncodedHeader, (size_t)encodedHeaderLen );
+       }
+
+       /* Is it reacehd end of header? */
+       while (iEncodedHeader < encodedHeaderLen) {
+               /* Get memory for single header */
+               temper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ];
+               if (temper == NULL) {
+                       MSG_DEBUG("temper Memory allocation is failed.\n" );
+                       return;
+               }
+
+               memset(temper, 0x00, (WSP_STANDARD_STR_LEN_MAX * 5));
+
+               /* this section presents header code page shifting procedure
+                  This part can be implemented by future request.
+               if (track == 0x 7f )
+               */
+               track = encodedHeader[iEncodedHeader];
+
+               if (track == 0x00) {
+                       MSG_DEBUG("WspLDecodeHeader: fieldcode  is 0 \n" );
+                       strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
+                       fieldCode = 0xff;
+                       iEncodedHeader++;
+               } else if (( track > 0 ) && ( track < 0x20 )) {
+                       iEncodedHeader++;
+               } else if (( track < 0x7f ) && ( track > 0x1f )) { /* In this case, first byte is normal string. So it's considered to unknown header. */
+                       unsigned char* fieldName = (unsigned char*)gWapCodeBufferLeft;
+                       unsigned char* fieldValue = (unsigned char*)gWapCodeBufferRight;
+
+                       strncpy( (char*)fieldName, (char*)(encodedHeader + iEncodedHeader ),WSP_CODE_BUFFER_LEFT_LEN_MAX-1);
+                       fieldName[WSP_CODE_BUFFER_LEFT_LEN_MAX-1] = '\0';
+                       iEncodedHeader = iEncodedHeader + AcStrlen( (char*)fieldName ) + 1;
+                       strncpy( (char*)fieldValue, (char*)(encodedHeader + iEncodedHeader ), WSP_CODE_BUFFER_RIGHT_LEN_MAX-1);
+                       fieldValue[WSP_CODE_BUFFER_RIGHT_LEN_MAX-1] = '\0';
+                       iEncodedHeader = iEncodedHeader + AcStrlen( (char*)fieldValue ) + 1;
+
+                       strncat((char*)temper, (char*)fieldName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                       strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                       strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                       /* this means 'don't process anymore.' */
+                       fieldCode = 0xff;
+
+               } else if (track > 0x7f) {
+                       /* In case of first byte is field code, else case is error. */
+
+                       /*if (( track & 0x7f ) <= wspHeaderFieldCount ) */
+                       {
+
+                               unsigned long  fieldValueLen = encodedHeader[iEncodedHeader + 1];
+                               unsigned char fieldValue[1275];
+                               fieldCode = track & 0x7f;
+                               /*
+                               if (( fieldValueLen == 0 ) || ( fieldValueLen == 0x80 ))
+                               {
+                                       dprint( DNET_WAP,DNET_DBG_HIGH, "%X %X %X %X %X %X\n" , fieldCode, encodedHeader[iEncodedHeader + 1], encodedHeader[iEncodedHeader + 2],encodedHeader[iEncodedHeader + 3],encodedHeader[iEncodedHeader + 4], encodedHeader[iEncodedHeader + 5] );
+                               }
+                               */
+                               memset(fieldValue, 0, 1275);
+                               {
+                                       /* add field name */
+                                       /* This continueField flag show whether previous field code and current field code are same or not. If it's same, there are some sequential display effect by omitting field name addition process. The reason why it should be do that can be found in encoding example of spec. */
+                                       if (!continueField) {
+                                               strncat( (char*)temper, (char*)wspHeaderFieldName[fieldCode], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               strncat( (char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               continueField = FALSE;
+                                       }
+
+                                       /* field value is string */
+                                       /* In this case, it just copy field value. */
+                                       if (( fieldValueLen > LENGTH_QUOTE ) && ( fieldValueLen < 0x80 )) {
+
+                                               /* string field value should be NULL terminated */
+                                               strncat( (char*)temper, (char*)(encodedHeader + iEncodedHeader + 1 ), (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+
+                                               iEncodedHeader = iEncodedHeader + AcStrlen( (char*)encodedHeader + iEncodedHeader + 1 ) + 2;
+                                               fieldCode = 0xff;
+                                       }
+                                       /* first field value is length */
+                                       /* If first byte of field value is length value, allocate field value by the length.
+                                       In field value, data is
+                                       1D 03 8F 24 24  - Then 8F 24 24 is field value.
+                                       1D 1F 33.... - Then  allocate 33H for FieldValue.
+                                       1D 8F - Then 8F
+                                       1D 'Hi man!' Like 00, if string is come, then process without calculating field value.
+                                       1D 8F 24 24 - In this case, original data is wrong.
+                                       If  accept-charset: ISO-10646-ucs-2;Q=0.7 is
+                                       01 03 03 E8 47
+                                       01 - field code
+                                       03 - field value length
+                                       03 E8 47 - field value
+                                       it's decoded by above value.
+                                       */
+                                       if (fieldValueLen < 0x20) {
+
+                                               if (fieldValueLen  == LENGTH_QUOTE) {
+
+                                                       /* field length is encoded in UINTVAR */
+                                                       unsigned long  uintvarLen = 0;
+                                                       fieldValueLen = wspRetriveUintvarDecode((unsigned char*) encodedHeader + iEncodedHeader + 2, &uintvarLen );
+                                                       memcpy( fieldValue, encodedHeader + iEncodedHeader + 2 + uintvarLen, (size_t)fieldValueLen );
+                                                       iEncodedHeader = iEncodedHeader + fieldValueLen + uintvarLen + 2;
+
+                                               } else {
+
+                                                       if (fieldValueLen == 1) {
+                                                               /* field value is one byte integer over 0x80 */
+                                                               /** make it two byte integer */
+                                                               fieldValue[0] = 0x00;
+                                                               memcpy( fieldValue + 1, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
+                                                               fieldValueLen = 2;
+                                                               iEncodedHeader = iEncodedHeader + 1 + 2;
+                                                       } else {
+                                                               memcpy( fieldValue, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen );
+                                                               fieldValue[fieldValueLen] = 0;
+                                                               iEncodedHeader = iEncodedHeader + fieldValueLen + 2;
+                                                               if (( fieldValueLen == 0 ) || ( fieldValueLen == 0x80 )) {
+                                                                       MSG_DEBUG("%X \n",  encodedHeader[iEncodedHeader] );
+                                                               }
+                                                       }
+                                               }
+                                       }
+                                       /* field value is single encoded */
+                                       if (fieldValueLen > 0x7f) {
+                                               fieldValue[0] = encodedHeader[iEncodedHeader + 1];
+                                               fieldValueLen = 1;
+                                               iEncodedHeader = iEncodedHeader + 2;
+                                       }
+                                       /* processing normal pre-defined field decoding */
+
+                                       MSG_DEBUG("WspLDecodeHeader: FieldCode %X\n", fieldCode );
+                                       MSG_DEBUG("WspLDecodeHeader: fieldSize %d\n", fieldValueLen );
+
+                                       if (( fieldCode  > wspHeaderFieldCount ) && ( fieldCode != 0xff )) {
+                                               MSG_DEBUG("WspLDecodeHeader: unknown fieldcode %X \n", track );
+                                               strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
+                                               fieldCode = 0xff;
+                                       }
+
+
+                                       switch ( fieldCode )
+                                       {
+                                               /* accept charset */
+                                               /* It's normal way of field process. */
+                                               case 0x01 :
+                                                       {
+                                                               unsigned long  i = 0;
+                                                               unsigned long  code;
+
+                                                               /* Case of length of charset greater than 1 are two thigins.
+                                                               1. code length of charset is greater than 1.
+                                                               2. It include parameter.
+                                                               3. Or both of two
+                                                               */
+                                                               if (1 != fieldValueLen) {
+                                                                       code = wspHeaderDecodeInteger( fieldValue );
+                                                                       /* Calculate iField. */
+                                                                       if (fieldValue[0] < 0x80 )
+                                                                               iField = fieldValue[0];
+                                                                       else
+                                                                               iField = 1;
+
+                                                                       while ( wspCharset[i].charsetCode != code )
+                                                                               i++;
+                                                                       strncat( (char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                       /* If parameter exist */
+                                                                       if (iField < fieldValueLen) {
+                                                                               char* param = NULL;
+                                                                               AutoPtr<char> parambuf(&param);
+                                                                               wspHeaderDecodeQValue( fieldValueLen - iField, fieldValue + iField, &param);
+                                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                       }
+                                                               } else {
+                                                                       code = fieldValue[0] & 0x7f;
+
+                                                                       while (( wspCharset[i].charsetCode != code ) && ( wspCharset[i].charsetCode != 0xffff  )) i++;
+                                                                       strncat( (char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                               }
+
+                                                       }
+                                                       break;
+
+                                               /* type encoding */
+                                               /* Like below routine, Same decoding routine process together. */
+                                               /* Accept-encoding */
+                                               case 0x02 :
+                                               /* content-encoding */
+                                               case 0x0b :
+                                                       {
+                                                               int integerValue;
+
+                                                               integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen );
+                                                               if (integerValue > 2) {
+                                                                       MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(2).\n");
+                                                                       break;
+                                                               }
+                                                               strncat( (char*)temper, (char*)wspEncodeMethod[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                       }
+                                                       break;
+                                               /* contents type decoder */
+                                               /* accept */
+                                               case 0x00 :
+                                               /* content-type */
+                                               case 0x11 :
+                                                       {
+                                                               unsigned long  contentsTypeCode;
+                                                               unsigned long  i = 0;
+                                                               /* encoded content type length body */
+                                                               unsigned long  tempLen;
+
+                                                               /* Like HTTP result state 304, it's for processing without Content type. This part doesn't defined. */
+                                                               if (0 == fieldValueLen) {
+                                                                       strncat( (char*)temper, (char*)"None" , (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                                       break;
+                                                               }
+                                                               /* 01 AE --> 00 AE --> AE*/
+                                                               if (fieldValueLen == 2  &&  fieldValue[0] == 0) {
+                                                                       memcpy( fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1 );
+                                                                       MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n" );
+                                                               }
+
+                                                               if ((fieldValue[0] < 0x20 ) || (fieldValue[0] > 0x80 )) {
+                                                                       if (fieldValue[0] > 0x80) {
+                                                                               tempLen = 1;
+                                                                       } else if (fieldValueLen == 2 && fieldValue[0] == 0x03 && fieldValue[1] == 0x0A) { /** 06 05 02 03 0A AF 89 */
+                                                                               fieldValue[3] = fieldValue[2];
+                                                                               fieldValue[2] = fieldValue[1];
+                                                                               fieldValue[1] = fieldValue[0];
+                                                                               fieldValue[0] = 0x02;
+                                                                               tempLen = 2;
+                                                                               fieldValueLen = 3;
+                                                                               MSG_DEBUG("WspLDecodeHeader:For CPE problem\r\n" );
+                                                                       } else {
+                                                                               tempLen = fieldValue[0]; /** 06 06 03 02 03 16 AF 88 */
+                                                                       }
+
+                                                                       if (tempLen == 1) {
+
+                                                                               char* szExtendedContent;
+
+                                                                               contentsTypeCode = fieldValue[0] & 0x7f;
+                                                                               while (( wspContentsType[i].contentsTypeCode != contentsTypeCode ) && ( i < wspContentsTypeCount )) i++;
+
+                                                                               /* If specified content type doesn't exist */
+                                                                               if (i < wspContentsTypeCount)
+                                                                                       strncat( (char*)temper, (char*)wspContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+
+                                                                               szExtendedContent =  wspExtendedDecodeType( (char)contentsTypeCode );
+
+                                                                               if (szExtendedContent != NULL) {
+                                                                                       MSG_DEBUG("WspLDecodeHeader: Tele2 server problem \n " );
+                                                                                       strncat( (char*)temper, (char*)szExtendedContent, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                               }
+                                                                       } else {
+                                                                               contentsTypeCode = wspHeaderDecodeInteger(fieldValue);
+
+                                                                               while ((wspUnregisterContentsType[i].contentsTypeCode != contentsTypeCode) && (i < wspUnregisteredContentsTypeCount)) i++;
+
+                                                                               /** If there is a Content-Type assigned, */
+                                                                               if (i < wspUnregisteredContentsTypeCount)
+                                                                                       strncat ((char*)temper, (char*)wspUnregisterContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+                                                                               tempLen +=1;
+                                                                       }
+                                                               } else {
+                                                                       tempLen = AcStrlen( (char*)fieldValue ) + 1;
+
+                                                                       strncat ((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                                       MSG_DEBUG("WspLDecodeHeader: Attention, Decoding Check of Content-Type\n ", tempLen);
+                                                               }
+
+                                                               /* If there is a parameter */
+                                                               if (tempLen < fieldValueLen) {
+                                                                       char* param = NULL;
+                                                                       AutoPtr<char> parambuf(&param);
+                                                                       wspHeaderDecodeParameter( fieldValue + tempLen, fieldValueLen - tempLen, &param);
+                                                                       if (param != NULL) {
+                                                                               strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                       }
+                                                               }
+                                                       }
+                                                       break;
+
+                                               /* language */
+                                               /* content-language */
+                                               case 0x0c :
+                                               /* accept-language */
+                                               case 0x03 :
+                                                       {
+                                                               unsigned long i = 0;
+                                                               unsigned long code;
+                                                               unsigned long tempLen;
+                                                               if ((fieldValue[0] < 0x20 ) || (fieldValue[0] > 0x80 )) {
+                                                                       if (fieldValue[0] > 0x80 )
+                                                                               tempLen = 1;
+                                                                       else
+                                                                               tempLen = fieldValue[0];
+                                                               } else {
+                                                                       tempLen = AcStrlen( (char*)fieldValue ) + 1;
+                                                               }
+
+                                                               if (tempLen == 1) {
+
+                                                                       code = wspHeaderDecodeInteger( fieldValue );
+                                                                       while ( wspLanguage[i].languageCode != code) {
+                                                                               i++;
+                                                                               if (i == wspLanguageCount)
+                                                                                       break;
+                                                                       }
+
+                                                                       if (i < wspLanguageCount) {
+                                                                               strncat( (char*)temper, (char*)wspLanguage[i].languageName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                       }
+                                                               } else {
+                                                                       strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                               }
+
+                                                               if (tempLen < fieldValueLen) {
+                                                                       char* param = NULL;
+                                                                       AutoPtr<char> parambuf(&param);
+                                                                       wspHeaderDecodeQValue(  fieldValueLen - tempLen, fieldValue + tempLen, &param );
+                                                                       strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                               }
+                                                       }
+                                                       break;
+
+                                               /* integer */
+                                               /* Max-forwards */
+                                               case 0x1e :
+                                               /* content-length */
+                                               case 0x0d :
+                                               /* age */
+                                               case 0x05 :
+                                               /* Bearer-indication */
+                                               case 0x33 :
+                                               /* Push-Flag */
+                                               case 0x34 :
+                                                       {
+
+                                                               unsigned char temp[16];
+                                                               /*
+                                                               if (( fieldValueLen == 2 ) && ( fieldValue[0] > 0x7f ))
+                                                                       AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[1]);
+                                                               else
+                                                               */
+                                                               sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ));
+                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       }
+                                                       break;
+                                               /* X-Wap-Application-Id */
+                                               case 0x2f :
+                                                       {
+                                                               unsigned char temp[64];
+                                                               int         integerValue;
+
+                                                               if (fieldValueLen == 2 &&  fieldValue[0] == 0) {
+                                                                       memcpy( fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1 );
+                                                                       MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n" );
+                                                                       fieldValueLen = 1;
+                                                               }
+
+                                                               integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
+
+                                                               if (integerValue > 0x0A) {
+                                                                       MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(0x0A).\n");
+                                                                       break;
+                                                               }
+
+                                                               snprintf((char*)temp, 64, "%s", wspHeaderApplId[integerValue].parameterToken);
+                                                               strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1);
+                                                       }
+                                                       break;
+                                               /* Accept-Application */
+                                               case 0x32 :
+                                                       if (0x80 == fieldValue[0]) {
+                                                               strncat( (char*)temper, "*", (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
+                                                       } else {
+
+                                                               unsigned char temp[16];
+                                                               /*
+                                if (( fieldValueLen == 2 ) && ( fieldValue[0] == 1 ))
+                                       AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[0]);
+                                else
+                                                               */
+                                                               sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ));
+                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1);
+                                                       }
+                                                       break;
+
+
+                                               /* date */
+                                               /* last-modified */
+                                               case 0x1d :
+                                               /* if-unmodified-since */
+                                               case 0x1b :
+                                               /* if-range */
+                                               case 0x1a :
+                                               /* if-modified-since */
+                                               case 0x17 :
+                                               /* expires */
+                                               case 0x14 :
+                                               /* date */
+                                               case 0x12 :
+                                                       {
+                                                               char* decodedString = NULL;
+                                                               AutoPtr<char> decodedStringbuf(&decodedString);
+                                                               wspHeaderDecodeDateValue( fieldValueLen, fieldValue, &decodedString);
+                                                               strncat( (char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
+                                                       }
+                                                       break;
+
+                                               /* connection */
+                                               case 0x09 :
+                                                       if (fieldValue[0] == 0x80 )
+                                                               strncat( (char*)temper, "Close", (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
+                                                       break;
+                                               /* accept-ranges */
+                                               case 0x04 :
+                                                       if (fieldValue[0] == 0x80 )
+                                                               strncat( (char*)temper, "None", (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
+                                                       if (fieldValue[0] == 0x81 )
+                                                               strncat( (char*)temper, "Bytes", (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
+                                                       break;
+                                               /* content-md5 */
+                                               case 0x0f :
+                                                       {
+                                                               unsigned char temp[1275];
+                                                               memcpy( temp, fieldValue, (size_t)fieldValueLen );
+                                                               temp[fieldValueLen] = 0;
+                                                               wspHeaderCopyDecodedString( temp, &currentLength, &temper );
+                                                       }
+                                                       break;
+                                               /* Credential */
+                                               /* authorization */
+                                               case 0x07 :
+                                               /* proxy - authorization */
+                                               case 0x21 :
+                                                       if (fieldValue[0] == 0x80) {
+                                                               char* addString = NULL;
+                                                               AutoPtr<char> addStringbuf(&addString);
+                                                               wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString );
+                                                               strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       } else {
+                                                               iField = AcStrlen( (char*)fieldValue) + 1;
+
+                                                               strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                               if (iField < fieldValueLen) {
+                                                                       char* param = NULL;
+                                                                       AutoPtr<char> parambuf(&param);
+                                                                       wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, &param );
+                                                                       if (param != NULL) {
+                                                                               strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                       }
+                                                               }
+                                                       }
+                                                       break;
+
+
+                                               /* Challenge */
+                                               /* www - auth */
+                                               case 0x2d :
+                                               /* Proxy-authenticate */
+                                               case 0x20 :
+                                                       if (0 == fieldValueLen )
+                                                               break;
+                                                       if (fieldValue[0] == 0x80) {
+                                                               char* addString = NULL;
+                                                               AutoPtr<char> addStringbuf(&addString);
+                                                               wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString );
+                                                               strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       } else {
+                                                               unsigned char  authScheme[WSP_STANDARD_STR_LEN_MAX + 1];
+                                                               unsigned char  realmValue[WSP_STANDARD_STR_LEN_MAX];
+                                                               unsigned char  addedString[WSP_STANDARD_STR_LEN_MAX];
+
+                                                               strncpy( (char*)authScheme, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX -1);
+                                                               iField = AcStrlen( (char*)authScheme ) + 1;
+                                                               strncpy( (char*)realmValue, (char*)(fieldValue + iField ), WSP_STANDARD_STR_LEN_MAX-1);
+                                                               iField = iField + AcStrlen( (char*)realmValue ) + 1;
+                                                               sprintf( (char*)addedString, "%s %s", authScheme, realmValue );
+                                                               wspHeaderCopyDecodedString( addedString, &currentLength, &temper );
+
+                                                               if (iField < fieldValueLen) {
+                                                                       char* param = NULL;
+                                                                       AutoPtr<char> parambuf(&param);
+                                                                       wspHeaderDecodeParameter( fieldValue + iField, fieldValueLen - iField, &param );
+                                                                       if (param != NULL) {
+                                                                               strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                               wspHeaderCopyDecodedString( (unsigned char*)param, &currentLength, &temper );
+                                                                       }
+                                                               }
+                                                       }
+                                                       break;
+
+                                               /* content -range */
+                                               case 0x10 :
+                                                       {
+                                                               unsigned long  first, len, last;
+
+                                                               unsigned char  temp[16];
+                                                               iField = 0;
+
+                                                               strncat( (char*)temper," bytes ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+
+                                                               first = wspRetriveUintvarDecode( fieldValue, &iField );
+                                                               len = wspRetriveUintvarDecode( fieldValue, &iField );
+                                                               /* Originally range of HTTP include entity length. But WSP omit it. Finally to calculate this, it should be get content length from export. If this field is included without content length, then it can get wrong result. This content length can be get by calculating PDU length.
+                                                               */
+                                                               last = first + contentsLength - 1;
+
+                                                               sprintf( (char*)temp, "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len );
+                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       }
+                                                       break;
+
+                                               /* cache-control */
+                                               case 0x08 :
+                                                       {
+                                                               char* cacheString = NULL;
+                                                               AutoPtr<char> cacheStringbuf(&cacheString);
+
+                                                               wspHeaderDecodeCacheControl( fieldValue, fieldValueLen, &cacheString );
+                                                               strncat( (char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       }
+                                                       break;
+
+                                               /* pragma */
+                                               case 0x1f :
+                                                       if (fieldValue[0] == 0x80) {
+                                                               strncat( (char*)temper, (char*)wspCacheControl[0], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       } else {
+                                                               if (1 < fieldValueLen) {
+                                                                       char* param = NULL;
+                                                                       AutoPtr<char> parambuf(&param);
+                                                                       wspHeaderDecodeParameter( fieldValue, fieldValueLen, &param );
+
+                                                                       if (param != NULL) {
+                                                                               strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                       }
+                                                               }
+                                                       }
+
+                                                       break;
+                                               /* public */
+                                               case 0x22 :
+                                               /* allow */
+                                               case 0x06 :
+                                                       {
+                                                               unsigned long  i = 0;
+                                                               while ( wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ) != wspMethodType[i].methodCode ) i++;
+                                                               strncat( (char*)temper, (char*)wspMethodType[i].methodName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       }
+                                                       break;
+                                               /* range */
+                                               case 0x23 :
+                                                       strncat( (char*)temper, "bytes=", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       if (fieldValue[0] == 0x80) {
+                                                               unsigned char temp[16];
+                                                               unsigned long  first, last;
+                                                               iField = 0;
+
+                                                               first = wspRetriveUintvarDecode( fieldValue, &iField );
+                                                               last = wspRetriveUintvarDecode( fieldValue, &iField );
+
+                                                               sprintf( (char*)temp, "%u-%u", (unsigned int)first, (unsigned int)last );
+                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       }
+                                                       if (fieldValue[0] == 0x81) {
+                                                               unsigned char temp[16];
+                                                               unsigned long  suffix;
+
+                                                               suffix = wspRetriveUintvarDecode( fieldValue, &iField );
+
+                                                               sprintf( (char*)temp, "-%u", (unsigned int)suffix );
+
+                                                       }
+                                                       break;
+                                               /* retry-after */
+                                               case 0x25 :
+                                                       if (fieldValue[0] == 0x80) {
+                                                               char* temp = NULL;
+                                                               AutoPtr<char> tempbuf(&temp);
+
+                                                               wspHeaderDecodeDateValue( fieldValueLen - 1, fieldValue + 1, &temp );
+                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       }
+
+                                                       if (fieldValue[0] == 0x81) {
+                                                               unsigned char temp[16];
+
+                                                               sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen ));
+                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       }
+                                                       break;
+                                               /* transfer-encoding */
+                                               case 0x27 :
+                                                       /* No other cases allowed */
+                                                       if (fieldValue[0] == 0x80 )
+                                                               strncat( (char*)temper, "chunked", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+
+                                                       break;
+                                               /* vary */
+                                               case 0x2a :
+                                                       {
+                                                               int integerValue = wspHeaderDecodeIntegerByLength(fieldValue,fieldValueLen );
+                                                               if (integerValue > wspHeaderFieldCount) {
+                                                                       MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(0x%x).\n",wspHeaderFieldCount);
+                                                                       break;
+                                                               }
+                                                               strncat( (char*)temper, (char*)wspHeaderFieldName[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       }
+                                                       break;
+                                               /* warning */
+                                               case 0x2c :
+                                                       {
+
+                                                               unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
+
+                                                               if (fieldValue[0] < 0x20 )
+                                                                       iField = fieldValue[0];
+                                                               else
+                                                                       iField = 1;
+                                                               sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, iField ));
+                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                               if (iField < fieldValueLen) {
+                                                                       unsigned char agent[WSP_STANDARD_STR_LEN_MAX];
+                                                                       unsigned char text[WSP_STANDARD_STR_LEN_MAX];
+                                                                       strncpy( (char*)agent, (char*)(fieldValue + iField ),WSP_STANDARD_STR_LEN_MAX-1);
+                                                                       iField = iField + AcStrlen((char*)agent ) + 1;
+                                                                       strncpy((char*)text, (char*)(fieldValue + iField ),WSP_STANDARD_STR_LEN_MAX-1);
+
+                                                                       sprintf( (char*)temp, " %s %s", agent, text );
+                                                                       wspHeaderCopyDecodedString( temp, &currentLength, &temper );
+                                                               }
+                                                       }
+                                                       break;
+                                               /* content-disposition */
+                                               case 0x2e :
+                                                       if (fieldValue[0] == 0x80 )
+                                                               strncat( (char*)temper, "form-data", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+
+                                                       if (fieldValue[0] == 0x81 )
+                                                               strncat( (char*)temper, "attachment", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+
+                                                       if (1 < fieldValueLen) {
+                                                               char* param = NULL;
+                                                               AutoPtr<char> parambuf(&param);
+                                                               wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, &param );
+
+                                                               if (param != NULL) {
+                                                                       strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                       strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                               }
+                                                       }
+                                                       break;
+                                               /* Profile-diff */
+                                               case 0x36 :
+                                                       temper[AcStrlen((char*)temper) + fieldValueLen] = '\0';
+                                                       memcpy( temper, fieldValue, (size_t)fieldValueLen );
+                                                       break;
+                                               /* Profile-Warning */
+                                               case 0x37 :
+                                                       {
+                                                               unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
+
+                                                               sprintf( (char*)temp, "%lX", wspHeaderDecodeInteger(fieldValue ));
+                                                               temp[2] = temp[1];
+                                                               temp[1] = (unsigned char)0x30;
+                                                               temp[3] = '\0';
+                                                               if (fieldValueLen > 1) {
+                                                                       /* copy warn-target - URI */
+                                                                       strncat( (char*)temp, (char*)(fieldValue + 1), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 );
+                                                                       if (fieldValueLen > ( AcStrlen( (char*)(fieldValue + 1)) + 1 )) {
+                                                                               /* copy warn-date */
+                                                                               char* decodedString = NULL;
+                                                                               AutoPtr<char> decodedStringbuf(&decodedString);
+                                                                               wspHeaderDecodeDateValue( fieldValueLen - ( AcStrlen( (char*)(fieldValue + 1)) + 2 ), fieldValue + AcStrlen( (char*)(fieldValue + 1)) + 1, &decodedString );
+                                                                               strncat( (char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 );
+                                                                       }
+                                                               }
+                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       }
+                                                       break;
+
+                                               default :
+                                                       break;
+                                       }
+
+                               }
+                       }
+               }
+               /* It deosn't finished decoding yet. */
+               if (( iEncodedHeader < encodedHeaderLen ) && ( fieldCode != 0xff )) {
+                       /* In here, iEncodedHeader already point next field code to be decoded. */
+                       /* If this code is same, then set continueField else add CRLF. */
+                       if (fieldCode == (encodedHeader[iEncodedHeader] & 0x7f )) {
+                               strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                               continueField = TRUE;
+                       } else {
+                               strncat( (char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                               continueField = FALSE;
+                       }
+               } else {
+                       strncat( (char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+               }
+
+               /* add single header to total headers */
+               strncat( (char*)outTemper, (char*)temper, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)outTemper)-1 );
+               MSG_DEBUG("WspLDecodeHeader: Single Header : %s\r\n", temper );
+
+       }
+
+
+       MSG_DEBUG("WspLDecodeHeader: Header decoding ended.\n" );
+
+       *pHeader = outTemper;
+
+       return;
+
+}
+
+
+unsigned long SmsPluginWapPushHandler::wspHeaderDecodeInteger( unsigned char* data )
+{
+       /* we only can handle max 32bit integer */
+       unsigned long i;
+
+       union {
+               unsigned long integer;
+               unsigned char seg[4];
+       } returner;
+
+       returner.integer = 0;
+
+       if (data[0] < 0x80) {
+               unsigned long IntLen = 0;
+
+               IntLen = (data[0]>0x04) ? 0x04:data[0];
+
+               MSG_DEBUG("WspLHeaderDecodeInteger: input %d , length %d\n", data[0], IntLen);
+
+               for (i=0; i<IntLen; i++)
+                       returner.seg[IntLen-( i+1)] = data[i+1];
+
+               return returner.integer;
+       }
+
+       return data[0] & 0x7f;
+}
+
+
+void SmsPluginWapPushHandler::wspHeaderDecodeQValue( unsigned long length, unsigned char* data, char** pDecodedString)
+{
+       unsigned short qBase = 0;
+       float  qValue;
+
+       *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+       if (*pDecodedString == NULL) {
+               MSG_DEBUG("WspLHeaderDecodeQValue:MemAlloc failed\n");
+               return;
+       }
+
+       memcpy( &qBase, data, (size_t)length );
+       qValue = (float)qBase;
+       if (qValue > 100) {
+               qValue = qValue - 100;
+               qValue = qValue / 1000;
+               sprintf( (char*)*pDecodedString, "; q=%.3f", qValue );
+       } else {
+               /* qValue variable is divided by 100. And it's multiplied by 100.
+                  It's to resolve problem of changed 0.01 of qValue. */
+               unsigned long qValueTemp;
+               qValue = qValue - 1;
+               qValue = qValue / 100;
+               qValueTemp = (unsigned long)(qValue * 100);
+               if (0 == (qValueTemp % 10 ))
+                       sprintf( (char*)*pDecodedString, "; q=%.1f", qValue );
+               else
+                       sprintf( (char*)*pDecodedString, "; q=%.2f", qValue );
+       }
+       return;
+}
+
+
+unsigned long SmsPluginWapPushHandler::wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length )
+{
+       unsigned long i;
+
+       union {
+               unsigned long integer;
+               unsigned short  seg[4];
+       } returner;
+
+       returner.integer = 0;
+
+       if (length == 1 )
+               return data[0] & 0x7f;
+
+       returner.integer = 0;
+
+       for (i = 0 ; i < length; i++) {
+               returner.integer  =  returner.integer + ( data[i]  *  (0x1  << ( ( length - ( i + 1)) * 8 )));
+               MSG_DEBUG("WspLHeaderDecodeIntegerByLength: %d \n", returner.integer );
+       }
+
+       return returner.integer;
+}
+
+
+char* SmsPluginWapPushHandler::wspExtendedDecodeType(char contentType  )
+{
+       int i = 0;
+
+       while ( wspExtendedContentsType[i].contentsTypeCode != contentType) {
+               if (wspExtendedContentsType[i].contentsTypeCode == 0xff)
+                       return NULL;
+               i++;
+       }
+
+       return (char*)wspExtendedContentsType[i].contentsTypeName;
+}
+
+
+void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, unsigned long length, char** pParam)
+{
+       char* param = *pParam;
+
+       unsigned long SecurityTypeCode;
+       unsigned long  i = 0;
+
+       if (data[0] < 0x80) {
+               /* unknown parameter type */
+               param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+               if (param == NULL) {
+                       MSG_DEBUG("WspLHeaderDecodeParameter:MemAlloc failed\n" );
+                       return;
+               }
+
+               strncpy( (char*)param, (char*)data, WSP_STANDARD_STR_LEN_MAX - 1);
+
+               if (NO_VALUE == data[AcStrlen( (char*)param ) + 1]) {
+                       *pParam = param;
+                       return;
+               }
+
+               strncat( (char*)param, "=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 );
+               strncat( (char*)param, (char*)(data + AcStrlen( (char*)param )), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+
+               *pParam = param;
+
+               return;
+       }
+
+       switch ( data[0] & 0x7f )
+       {
+               case 0x00 :
+                       wspHeaderDecodeQValue(  length - 1, data + 1, &param);
+                       break;
+               case 0x01 :
+                       wspHeaderDecodeCharset( length - 1 , data + 1, &param);
+                       break;
+               case 0x02 :
+                       wspHeaderDecodeVersion( length - 1, data + 1, &param);
+                       break;
+                       /* integer */
+               case 0x03 :
+                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+                       if (param == NULL) {
+                               MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n");
+                               return;
+                       } else {
+                               sprintf( (char*)param, "Type=%i", (int)wspHeaderDecodeInteger( data + 1 ));
+                       }
+                       break;
+               case 0x08 :
+                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+                       if (param == NULL) {
+                               MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n");
+                               return;
+                       } else {
+                               sprintf( (char*)param, "Padding=%i", (int)wspHeaderDecodeInteger( data + 1 ));
+                       }
+                       break;
+               case 0x05 :
+                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+                       if (param == NULL) {
+                               MSG_DEBUG("WspLHeaderDecodeParameter:0x05 MemAlloc failed\n");
+                               return;
+                       } else {
+                               strncpy( (char*)param, "Name=", WSP_STANDARD_STR_LEN_MAX-1);
+                               memcpy( param + 5, data + 1, length - 1 );
+                               param[5 + length - 1] = '\0';
+                       }
+                       break;
+               case 0x06 :
+                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+                       if (param == NULL) {
+                               MSG_DEBUG("WspLHeaderDecodeParameter:0x06 MemAlloc failed\n");
+                               return;
+                       } else {
+                               strncpy( (char*)param, "Filename=", WSP_STANDARD_STR_LEN_MAX-1);
+                               memcpy( param + 9, (char*)(data + 1), (size_t)(length - 1) );
+                               param[9 + length - 1] = '\0';
+                       }
+                       break;
+               case 0x07 :
+                       param = NULL;
+                       /* TBI */
+                       break;
+                       /*OMA Provisioning*/
+               case 0x11 :
+                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+                       if (param == NULL) {
+                               MSG_DEBUG("WspLHeaderDecodeParameter:0x11 MemAlloc failed\n");
+                               return;
+                       } else {
+                               strncpy((char*)param, "SEC=", WSP_STANDARD_STR_LEN_MAX-1);
+                               SecurityTypeCode = data[1] & 0x7f;
+                               while (( i < wspSecurityTypeCount ) && ( wspSecurityType[i].SecurityTypeCode != SecurityTypeCode )) i++;
+
+                               if (i < wspSecurityTypeCount) {
+                                       strncat( (char*)param, (char*)wspSecurityType[i].SecurityTypeName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+                               }
+
+                               if (0x12 == (data[2] & 0x7f)) {
+                                       strncat( (char*)param, "; MAC=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 );
+                                       memcpy(param+AcStrlen( (char*)param),(char*)(data+3),(size_t)length-3 );
+                               }
+                       }
+                       break;
+
+               default :
+                       param = NULL;
+                       break;
+       }
+
+       *pParam = param;
+       return;
+}
+
+
+void SmsPluginWapPushHandler::wspHeaderDecodeCharset( unsigned long length, unsigned char* data, char**pDecodedString)
+{
+
+       *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+
+       if (*pDecodedString == NULL) {
+               MSG_DEBUG("WspLHeaderDecodeCharset:MemAlloc failed\n");
+               return;
+       }
+
+       strncpy( (char*)*pDecodedString, "charset=", WSP_STANDARD_STR_LEN_MAX-1);
+
+       if (data[0] > 0x80) {
+               unsigned long code = wspHeaderDecodeInteger(data );
+               unsigned long i = 0;
+               while (wspCharset[i].charsetCode !=  code) {
+                       if (wspCharset[i].charsetCode == 0xffff) {
+                               return;
+                       }
+                       i++;
+               }
+               strncat( (char*)*pDecodedString, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pDecodedString)-1 );
+       } else {
+               unsigned long  lastLen = AcStrlen((char*)*pDecodedString);
+               memcpy( (char*)(*pDecodedString + lastLen), data, (size_t)length );
+               *pDecodedString[length + lastLen] = '\0';
+       }
+
+       return;
+}
+
+
+
+void SmsPluginWapPushHandler::wspHeaderDecodeVersion( unsigned long length, unsigned char* data, char** pDecodedString )
+{
+       *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+
+       if (*pDecodedString == NULL) {
+               MSG_DEBUG("WspLHeaderDecodeVersion:MemAlloc failed\n");
+               return;
+       }
+
+       if (length > 1) {
+               /* untyped version */
+               memcpy( *pDecodedString, data, (size_t)length );
+       } else {
+               /* typed version */
+               unsigned char majorVer  = ((data[0] & 0x7f ) >> 4 );
+               unsigned char minorVer = data[0] & 0x0f;
+               sprintf( (char*)*pDecodedString, "level=%u.%u", majorVer, minorVer );
+       }
+
+       return;
+}
+
+
+void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, unsigned char* data, char** pDecodedString )
+{
+       time_t  lTime;
+       struct  tm* pTMData;
+
+       MSG_DEBUG("WspLHeaderDecodeDateValue:   \n" );
+
+       *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+
+       if (*pDecodedString == NULL) {
+               MSG_DEBUG( "WspLHeaderDecodeDateValue:MemAlloc failed\n");
+               return;
+       }
+
+       lTime = wspHeaderDecodeIntegerByLength(data, length);
+
+       pTMData = (struct tm*)gmtime((const time_t* )&lTime);
+
+       if (pTMData == NULL) {
+               MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail \n" );
+               strncpy( (char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
+               return;
+       }
+
+       /* check date value validity */
+       {
+               if (( pTMData->tm_wday > 6 ) || (pTMData->tm_mon > 12 ) || (pTMData->tm_mday >  31 ))
+               {
+                       MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData->tm_wday, pTMData->tm_mon, pTMData->tm_mday );
+                       strncpy( (char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
+                       return;
+               }
+       }
+
+       /**UNIX_DATE_TYPE : */
+       sprintf( (char*)*pDecodedString, "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon],
+                                                                                       pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900 );
+
+       return;
+
+}
+
+void SmsPluginWapPushHandler::wspHeaderCopyDecodedString( unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper )
+{
+       unsigned long elementLen = AcStrlen( (char*)szDecodedString );
+       char* temper2 = NULL;
+
+       /**  // CR+LF */
+       *currentLen = *currentLen + elementLen + 2;
+
+       if ( *currentLen > AcStrlen( (char*)* pTemper ) + 2) {
+               temper2 = new char[(*currentLen + 1 )];
+
+               if (temper2 == NULL) {
+                       MSG_DEBUG( "WspLHeaderCopyDecodedString:MemAlloc failed\n");
+                       return;
+               }
+               strncpy( (char*)temper2, (char*)* pTemper, *currentLen);
+               delete[] *pTemper;
+               strncpy( (char*)temper2, (char*)szDecodedString, *currentLen);
+       }
+
+       *pTemper = temper2;
+
+       return;
+}
+
+
+void SmsPluginWapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString )
+{
+       unsigned char  userId[WSP_STANDARD_STR_LEN_MAX];
+       unsigned char  passWd[WSP_STANDARD_STR_LEN_MAX];
+       unsigned long iField = 0;
+
+       *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX * 2];
+
+       if (*pDecodedString == NULL) {
+               MSG_DEBUG("WspLHeaderDecodeAuth:MemAlloc failed\n" );
+               return;
+       }
+
+       /* skip 'basic' code */
+       iField++;
+       sscanf((char*)(fieldValue + iField), "%s", userId );
+       iField = iField + AcStrlen( (char*)userId ) + 1;
+       sscanf( (char*)(fieldValue + iField), "%s", passWd );
+       iField = iField + AcStrlen( (char*)userId ) + 1;
+       sprintf( (char*)*pDecodedString, "basic %s/%s", userId, passWd );
+
+       return;
+}
+
+
+void SmsPluginWapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString )
+{
+       unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
+       unsigned long iField = 0;
+
+       *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+
+       if (*pDecodedString == NULL) {
+               MSG_DEBUG( "WspLHeaderDecodeChallenge:MemAlloc failed\n");
+               return;
+       }
+
+       /* skip 'basic' code */
+       iField++;
+       sscanf( (char*)(fieldValue + iField), "%s", userId );
+       iField = iField + AcStrlen( (char*)userId ) + 1;
+
+       sprintf( (char*)*pDecodedString, "basic realm=\"%s\"", userId );
+
+       return;
+}
+
+
+void SmsPluginWapPushHandler::wspHeaderDecodeCacheControl(unsigned char* fieldValue, unsigned long fieldValueLen, char** pCacheString)
+{
+       unsigned char  paramString[WSP_STANDARD_STR_LEN_MAX];
+       unsigned char  cacheCode;
+
+       *pCacheString = new char[WSP_STANDARD_STR_LEN_MAX];
+       if (*pCacheString == NULL) {
+               MSG_DEBUG( "WspLHeaderDecodeCacheControl:MemAlloc failed\n");
+               return;
+       }
+
+       if (1 == fieldValueLen) {
+               /* only one directive */
+               if (fieldValue[0] > 0x8b) {
+                       return; /* It's error detection. can be omitted. */
+               }
+               strncpy( (char*)*pCacheString, (char*)wspCacheControl[fieldValue[0] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
+               return;
+       }
+
+       if (fieldValue[0] > 0x7f) {
+               /* directive that has parameter */
+               cacheCode = fieldValue[0] & 0x7f;
+               switch ( cacheCode )
+               {
+                               /* field name */
+                               /* no-cache */
+                       case 0x00 :
+                               /* private */
+                       case 0x07 :
+                               if (fieldValue[1] > 0x7f) {
+                                       /* well known field name */
+                                       strncpy( (char*)paramString, (char*)wspHeaderFieldName[fieldValue[1] & 0x7f],WSP_STANDARD_STR_LEN_MAX-1 );
+                                       paramString[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
+                               } else {
+                                       /* unknown field name */
+                                       strncpy( (char*)paramString, (char*)fieldValue + 1 , WSP_STANDARD_STR_LEN_MAX-1);
+                               }
+                               break;
+                               /* secound */
+                               /* max-age */
+                       case 0x02 :
+                               /* max- stale */
+                       case 0x03 :
+                               /* min-fresh */
+                       case 0x04 :
+                               sprintf( (char*)paramString, "%u", (unsigned int)wspHeaderDecodeInteger( fieldValue + 1));
+                               break;
+
+                       default :
+                               break;
+
+               }
+               sprintf((char*)*pCacheString, "%s=%s", (char*)wspCacheControl[cacheCode], (char*)paramString );
+       } else {
+               /* cache extentions */
+               /* In case of come directive of doesn't specified string style */
+
+               unsigned long stringLen;
+               char szString[32];
+               strncpy( (char*)*pCacheString, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX-1);
+               stringLen = AcStrlen((char*)*pCacheString );
+
+               if (stringLen + 1 < fieldValueLen) {
+
+                       if (fieldValue[stringLen+ 1] > 0x7f) {
+                               int untyped = (int)wspHeaderDecodeIntegerByLength( fieldValue + stringLen + 1, fieldValueLen - (stringLen + 1 ));
+
+                               sprintf( szString, "%d", untyped );
+                               strncat( (char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1 );
+                               strncat( (char*)*pCacheString, (char*)szString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1 );
+                       } else {
+                               if (fieldValue[fieldValueLen] == 0) {
+                                       strncat( (char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1 );
+                                       strncat( (char*)*pCacheString, (char*)fieldValue + stringLen + 1 , WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
+                               }
+                       }
+               }
+       }
+
+       return;
+}
diff --git a/plugin/sms_plugin/include/SmsPluginCallback.h b/plugin/sms_plugin/include/SmsPluginCallback.h
new file mode 100755 (executable)
index 0000000..f1b5075
--- /dev/null
@@ -0,0 +1,83 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_CALLBACK_H
+#define SMS_PLUGIN_CALLBACK_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <map>
+#include <vector>
+
+extern "C"
+{
+       #include <TapiEvent.h>
+}
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+int TapiEventDeviceReady(const TelTapiEvent_t *pEvent, void*);
+
+int TapiEventSentStatus(const TelTapiEvent_t *pEvent, void*);
+int TapiEventMsgIncoming(const TelTapiEvent_t *pEvent, void*);
+int TapiEventCbMsgIncoming(const TelTapiEvent_t *pEvent, void*);
+int TapiEventDeliveryReportCNF(const TelTapiEvent_t *pEvent, void*);
+
+int TapiEventGetSimMsgCnt(const TelTapiEvent_t *pEvent, void*);
+int TapiEventGetSimMsg(const TelTapiEvent_t *pEvent, void*);
+int TapiEventSaveSimMsg(const TelTapiEvent_t *pEvent, void*);
+int TapiEventDeleteSimMsg(const TelTapiEvent_t *pEvent, void*);
+
+int TapiEventSetConfigData(const TelTapiEvent_t *pEvent, void*);
+
+int TapiEventGetCBConfig(const TelTapiEvent_t *pEvent, void*);
+
+int TapiEventGetParamCnt(const TelTapiEvent_t *pEvent, void*);
+int TapiEventGetParam(const TelTapiEvent_t *pEvent, void*);
+
+int TapiEventSatSmsRefresh(const TelTapiEvent_t *pEvent, void*);
+int TapiEventSatSendSms(const TelTapiEvent_t *pEvent, void*);
+int TapiEventSatMoSmsCtrl(const TelTapiEvent_t *pEvent, void*);
+
+int TapiEventSimFileInfo(const TelTapiEvent_t *pEvent, void*);
+int TapiEventSimReadFile(const TelTapiEvent_t *pEvent, void*);
+
+int TapiEventFactoryDftSms(const TelTapiEvent_t *pEvent, void*);
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginCallback
+{
+public:
+       static SmsPluginCallback* instance();
+
+       void registerEvent();
+       void deRegisterEvent();
+
+private:
+       SmsPluginCallback();
+       ~SmsPluginCallback();
+
+       static SmsPluginCallback* pInstance;
+};
+
+#endif //SMS_PLUGIN_CALLBACK_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginCbMsgHandler.h b/plugin/sms_plugin/include/SmsPluginCbMsgHandler.h
new file mode 100755 (executable)
index 0000000..bac47f9
--- /dev/null
@@ -0,0 +1,95 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_CBMSG_HANDLER_H
+#define SMS_PLUGIN_CBMSG_HANDLER_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <map>
+#include <vector>
+
+using namespace std;
+
+#include "SmsPluginTypes.h"
+
+extern "C"
+{
+#ifndef _TAPI_NETTEXT_H_
+       #include "ITapiNetText.h"
+//     #include "ITapi_common.h"
+#endif
+}
+
+
+/*==================================================================================================
+                                         VARIABLES
+==================================================================================================*/
+typedef map<unsigned char, string> cbPageMap;
+
+
+typedef struct _CB_PAGE_INFO_S
+{
+       unsigned char           geoScope;
+       unsigned char           updateNum;
+       unsigned short          msgCode;
+       unsigned short          msgId;
+       unsigned char           totalPages;
+
+       unsigned char           pageCnt;
+       unsigned int            totalSize;
+       cbPageMap               data;
+} CB_PAGE_INFO_S;
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginCbMsgHandler
+{
+public:
+       static SmsPluginCbMsgHandler* instance();
+
+       void handleCbMsg(TelSmsCbMsg_t *pCbMsg);
+
+private:
+       SmsPluginCbMsgHandler();
+       virtual ~SmsPluginCbMsgHandler();
+
+       static SmsPluginCbMsgHandler* pInstance;
+
+       void Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_S *pCbPage);
+       void Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_S *pCbPage);
+
+       bool checkCbOpt(SMS_CBMSG_PAGE_S CbPage, bool *pJavaMsg);
+       unsigned char checkCbPage(SMS_CBMSG_PAGE_S CbPage);
+       void MakeCbMsg(SMS_CBMSG_PAGE_S CbPage, SMS_CBMSG_S *pCbMsg);
+       void convertCbMsgToMsginfo(SMS_CBMSG_S cbMsg, MSG_MESSAGE_INFO_S *pMsgInfo);
+       void addToPageLiat(SMS_CBMSG_PAGE_S CbPage);
+       void removeFromPageList(SMS_CBMSG_PAGE_S CbPage);
+
+       void decodeCbMsgDCS(unsigned char dcsData, const unsigned char *pMsgData, SMS_CBMSG_DCS_S* pDcs);
+       void convertLangType(SMS_CBMSG_LANG_TYPE_T InType , MSG_CB_LANGUAGE_TYPE_T *pOutType);
+       unsigned long getRecvTime();
+       void getDisplayName(unsigned short      MsgId, char *pDisplayName);
+
+       vector<CB_PAGE_INFO_S> pageList;
+};
+
+#endif //SMS_PLUGIN_CBMSG_HANDLER_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginConcatHandler.h b/plugin/sms_plugin/include/SmsPluginConcatHandler.h
new file mode 100755 (executable)
index 0000000..4973f63
--- /dev/null
@@ -0,0 +1,108 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_CONCAT_HANDLER_H
+#define SMS_PLUGIN_CONCAT_HANDLER_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <string>
+#include <map>
+#include <vector>
+
+using namespace std;
+
+#include "SmsPluginTypes.h"
+
+
+/*==================================================================================================
+                                         VARIABLES AND DEFINES
+==================================================================================================*/
+#define MAX_CONCAT_LIST        10
+
+struct CONCAT_DATA_S
+{
+       int     length;
+       char data[MAX_USER_DATA_LEN+1];
+};
+
+typedef map<unsigned char, CONCAT_DATA_S> concatDataMap;
+
+typedef struct _SMS_CONCAT_MSG_S
+{
+       unsigned short          msgRef;
+       unsigned char           totalSeg;
+       unsigned char           seqNum;
+
+       SMS_TIMESTAMP_S timeStamp;
+       SMS_ADDRESS_S   originAddress;
+       SMS_DCS_S               dcs;
+       bool                            bRead;
+} SMS_CONCAT_MSG_S;
+
+typedef struct _SMS_CONCAT_INFO_S
+{
+       unsigned short          msgRef;
+       unsigned char           totalSeg;
+       unsigned char           segCnt;
+
+       SMS_TIMESTAMP_S timeStamp;
+       SMS_ADDRESS_S   originAddress;
+       SMS_DCS_S               dcs;
+       bool                            bRead;
+
+       unsigned int            totalSize;
+       concatDataMap   data;
+} SMS_CONCAT_INFO_S;
+
+typedef struct _SMS_SIM_ID_S
+{
+       unsigned short          msgRef;
+       MSG_SIM_ID_T            simId;
+} SMS_SIM_ID_S;
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginConcatHandler
+{
+public:
+       static SmsPluginConcatHandler* instance();
+
+       bool IsConcatMsg(SMS_USERDATA_S *pUserData);
+       void handleConcatMsg(SMS_TPDU_S *pTpdu);
+
+private:
+       SmsPluginConcatHandler();
+       virtual ~SmsPluginConcatHandler();
+
+       static SmsPluginConcatHandler* pInstance;
+
+       unsigned char checkConcatMsg(SMS_CONCAT_MSG_S *pConcatMsg, SMS_USERDATA_S *pUserData);
+       int makeConcatUserData(unsigned short MsgRef, char **ppTotalData);
+
+       void convertConcatToMsginfo(const SMS_DELIVER_S *pTpdu, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo);
+
+       void removeFromConcatList(unsigned short MsgRef);
+
+
+       vector<SMS_CONCAT_INFO_S> concatList;
+};
+
+#endif //SMS_PLUGIN_CONCAT_HANDLER_H
diff --git a/plugin/sms_plugin/include/SmsPluginEventHandler.h b/plugin/sms_plugin/include/SmsPluginEventHandler.h
new file mode 100755 (executable)
index 0000000..0b87220
--- /dev/null
@@ -0,0 +1,77 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_EVENT_HANDLER_H
+#define SMS_PLUGIN_EVENT_HANDLER_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgMutex.h"
+#include "MsgPluginInterface.h"
+#include "SmsPluginTypes.h"
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginEventHandler
+{
+public:
+       static SmsPluginEventHandler* instance();
+
+       void registerListener(MSG_PLUGIN_LISTENER_S *pListener);
+       void handleSentStatus(int TapiReqId, MSG_NETWORK_STATUS_T NetStatus);
+       void handleMsgIncoming(SMS_TPDU_S *pTpdu);
+       void handleSyncMLMsgIncoming(MSG_SYNCML_MESSAGE_TYPE_T msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen);
+       void handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen);
+       void handleDftSms(MSG_FOLDER_ID_T FolderId, char* pNumber, char* pData);
+
+       MSG_ERROR_T callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgInfo);
+       MSG_ERROR_T callbackInitSimBySat();
+       MSG_ERROR_T callbackStorageChange(MSG_STORAGE_CHANGE_TYPE_T storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo);
+
+       void SetSentInfo(SMS_SENT_INFO_S *pSentInfo);
+
+       void setDeviceStatus();
+       bool getDeviceStatus();
+
+       void convertTpduToMsginfo(SMS_TPDU_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo); // temp
+
+private:
+       SmsPluginEventHandler();
+       virtual ~SmsPluginEventHandler();
+
+       void convertSubmitTpduToMsginfo(const SMS_SUBMIT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo);
+       void convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo);
+       void convertStatusRepTpduToMsginfo(const SMS_STATUS_REPORT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo);
+       MSG_SUB_TYPE_T convertMsgSubType(SMS_PID_T pid);
+
+       static SmsPluginEventHandler* pInstance;
+
+       MSG_PLUGIN_LISTENER_S listener;
+       MSG_SIM_COUNT_S* pSimCnt;
+       SMS_SENT_INFO_S sentInfo;
+
+       bool devStatus;
+
+       Mutex mx;
+       CndVar cv;
+};
+
+#endif //SMS_PLUGIN_EVENT_HANDLER_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginMain.h b/plugin/sms_plugin/include/SmsPluginMain.h
new file mode 100755 (executable)
index 0000000..4cc6293
--- /dev/null
@@ -0,0 +1,74 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_MAIN_H
+#define SMS_PLUGIN_MAIN_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "SmsPluginTypes.h"
+#include "MsgPluginInterface.h"
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+MSG_ERROR_T SmsPlgInitialize();
+
+MSG_ERROR_T SmsPlgFinalize();
+
+MSG_ERROR_T SmsPlgRegisterListener(MSG_PLUGIN_LISTENER_S *pListener);
+
+MSG_ERROR_T SmsPlgCheckSimStatus(MSG_SIM_STATUS_T *pStatus);
+
+MSG_ERROR_T SmsPlgCheckDeviceStatus();
+
+MSG_ERROR_T SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo, bool bReqCb);
+
+MSG_ERROR_T SmsPlgInitSimMessage();
+
+MSG_ERROR_T SmsPlgSaveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList);
+
+MSG_ERROR_T SmsPlgDeleteSimMessage(MSG_SIM_ID_T SimMsgId);
+
+MSG_ERROR_T SmsPlgGetSimMessage(MSG_SIM_ID_T SimMsgId);
+
+MSG_ERROR_T SmsPlgGetSimMessageCount();
+
+MSG_ERROR_T SmsPlgSetReadStatus(MSG_SIM_ID_T SimMsgId);
+
+MSG_ERROR_T SmsPlgSetMemoryStatus(MSG_ERROR_T Error);
+
+MSG_ERROR_T SmsPlgInitConfigData(MSG_SIM_STATUS_T SimStatus);
+
+MSG_ERROR_T SmsPlgSetConfigData(const MSG_SETTING_S *pSetting);
+
+MSG_ERROR_T SmsPlgGetConfigData(MSG_SETTING_S *pSetting);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //SMS_PLUGIN_MAIN_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginParamCodec.h b/plugin/sms_plugin/include/SmsPluginParamCodec.h
new file mode 100755 (executable)
index 0000000..980d44a
--- /dev/null
@@ -0,0 +1,52 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_PARAMCODEC_H
+#define SMS_PLUGIN_PARAMCODEC_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "SmsPluginTypes.h"
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginParamCodec
+{
+public:
+       SmsPluginParamCodec();
+       virtual ~SmsPluginParamCodec();
+
+       static int encodeAddress(const SMS_ADDRESS_S *pAddress, char **ppParam);
+       static int encodeTime(const SMS_TIMESTAMP_S *pTimeStamp, char **ppParam);
+       static int encodeDCS(const SMS_DCS_S *pDCS, char **ppParam);
+       static int encodeSMSC(const char *pAddress, unsigned char *pEncodeAddr);
+       static int encodeSMSC(const SMS_ADDRESS_S *pAddress, unsigned char *pSMSC);
+
+       static int decodeAddress(const unsigned char *pTpdu, SMS_ADDRESS_S *pAddress);
+       static int decodeTime(const unsigned char *pTpdu, SMS_TIMESTAMP_S *pTimeStamp);
+       static int decodeDCS(const unsigned char *pTpdu, SMS_DCS_S *pDCS);
+       static void decodeSMSC(unsigned char* pAddress, int AddrLen, MSG_SMS_TON_T ton, char *pDecodeAddr);
+
+private:
+       static int convertDigitToBcd(char *pDigit, int DigitLen, unsigned char *pBcd);
+       static int convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit);
+};
+
+#endif //SMS_PLUGIN_PARAMCODEC_H
diff --git a/plugin/sms_plugin/include/SmsPluginSatHandler.h b/plugin/sms_plugin/include/SmsPluginSatHandler.h
new file mode 100755 (executable)
index 0000000..84f0e32
--- /dev/null
@@ -0,0 +1,65 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_SAT_HANDLER_H
+#define SMS_PLUGIN_SAT_HANDLER_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "SmsPluginTypes.h"
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginSatHandler
+{
+public:
+       static SmsPluginSatHandler* instance();
+
+       void refreshSms(void *pData);
+       void sendSms(void *pData);
+       void ctrlSms(void *pData);
+       void ctrlSms(MSG_NETWORK_STATUS_T netStatus);
+
+       void finishSimMsgInit(MSG_ERROR_T Err);
+
+private:
+       SmsPluginSatHandler();
+       virtual ~SmsPluginSatHandler();
+
+       void initSim();
+
+       void    initSMSCList();
+       void    initCBConfig();
+
+       int handleSatTpdu(unsigned char *pTpdu, unsigned char TpduLen, int bIsPackingRequired);
+
+       void sendResult(SMS_SAT_CMD_TYPE_T CmdType, int ResultType);
+
+       static SmsPluginSatHandler* pInstance;
+
+       int commandId;
+
+       bool bSendSms;
+       bool bInitSim;
+       bool bSMSPChanged;
+       bool bCBMIChanged;
+};
+
+#endif //SMS_PLUGIN_SAT_HANDLER_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginSetting.h b/plugin/sms_plugin/include/SmsPluginSetting.h
new file mode 100755 (executable)
index 0000000..1aea56f
--- /dev/null
@@ -0,0 +1,85 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_SETTING_H
+#define SMS_PLUGIN_SETTING_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgMutex.h"
+#include "MsgSettingTypes.h"
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginSetting
+{
+public:
+       static SmsPluginSetting* instance();
+
+       void initConfigData(MSG_SIM_STATUS_T SimStatus);
+
+       void setConfigData(const MSG_SETTING_S *pSetting);
+       void getConfigData(MSG_SETTING_S *pSetting);
+
+       void setParamCntEvent(int ParamCnt);
+       void setParamEvent(const MSG_SMSC_DATA_S *pSmscData, int RecordIdx, bool bSuccess);
+       void setCbConfigEvent(const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess);
+       void setResultFromSim(bool bResult);
+
+private:
+       SmsPluginSetting();
+       ~SmsPluginSetting();
+
+       MSG_ERROR_T addSMSCList(MSG_SMSC_LIST_S *pSmscList);
+
+       MSG_ERROR_T addCbOpt(MSG_CBMSG_OPT_S *pCbOpt);
+       void getCbOpt(MSG_SETTING_S *pSetting);
+
+       void setParamList(const MSG_SMSC_LIST_S *pSMSCList);
+       void getParamList(MSG_SMSC_LIST_S *pSMSCList);
+
+       int getParamCount();
+       bool getParam(int Index, MSG_SMSC_DATA_S *pSmscData);
+
+       bool setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt);
+       bool getCbConfig(MSG_CBMSG_OPT_S *pCbOpt);
+
+       int getParamCntEvent();
+       bool getParamEvent(MSG_SMSC_DATA_S *pSmscData);
+       bool getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt);
+       bool getResultFromSim();
+
+       SMS_PID_T convertPid(MSG_SMS_PID_T pid);
+
+       static SmsPluginSetting* pInstance;
+
+       MSG_SMSC_DATA_S         smscData;
+       MSG_CBMSG_OPT_S         cbOpt;
+
+       bool            bTapiResult;
+       int             paramCnt;
+       int             selectedParam;
+
+       Mutex mx;
+       CndVar cv;
+};
+
+#endif //SMS_PLUGIN_SETTING_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginSimMsg.h b/plugin/sms_plugin/include/SmsPluginSimMsg.h
new file mode 100755 (executable)
index 0000000..73094fc
--- /dev/null
@@ -0,0 +1,91 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_SIMMSG_H
+#define SMS_PLUGIN_SIMMSG_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgMutex.h"
+
+#include "MsgStorageTypes.h"
+#include "SmsPluginTypes.h"
+#include "MsgInternalTypes.h"
+
+extern "C"
+{
+#ifndef _TAPI_NETTEXT_H_
+       #include "ITapiNetText.h"
+       #include "ITapiSim.h"
+#endif
+}
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginSimMsg
+{
+public:
+       static SmsPluginSimMsg* instance();
+
+       void initSimMessage();
+       MSG_ERROR_T saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList);
+       MSG_ERROR_T saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInfo);
+       void deleteSimMessage(MSG_SIM_ID_T SimMsgId);
+       void getSimMessageList(MSG_SIM_MSG_INFO_LIST_S **ppSimMsgList);
+       void setReadStatus(MSG_SIM_ID_T SimMsgId);
+       bool checkSimMsgFull(unsigned int SegCnt);
+
+       void setSimMsgCntEvent(const MSG_SIM_COUNT_S *pSimMsgCnt);
+       void setSimMsgEvent(const MSG_MESSAGE_INFO_S *pMsgInfo, bool bSuccess);
+       void setSimEvent(MSG_SIM_ID_T SimId, bool bResult);
+
+private:
+       SmsPluginSimMsg();
+       ~SmsPluginSimMsg();
+
+       void getSimMsgCount(MSG_SIM_COUNT_S *pSimMsgCnt);
+       bool getSimMsg(MSG_SIM_ID_T SimMsgId, MSG_MESSAGE_INFO_S* pMsgInfo);
+
+       void setSmsOptions(SMS_DELIVER_S *pDeliver);
+       void convertTimeStamp(const MSG_MESSAGE_INFO_S* pMsgInfo, SMS_DELIVER_S *pDeliver);
+
+       bool getSimMsgCntEvent(MSG_SIM_COUNT_S *pSimMsgCnt);
+       bool getSimMsgEvent(MSG_MESSAGE_INFO_S *pMsgInfo);
+       bool getSimEvent(MSG_SIM_ID_T *pSimId);
+
+       static SmsPluginSimMsg* pInstance;
+
+       MSG_SIM_ID_T                    simMsgId;
+
+       MSG_SIM_COUNT_S                 simMsgCnt;
+
+       MSG_MESSAGE_INFO_S              simMsgInfo;
+
+       unsigned int                            usedCnt;
+       unsigned int                            totalCnt;
+
+       bool                                            bTapiResult;
+       bool                                            bClass2Msg;
+
+       Mutex mx;
+       CndVar cv;
+};
+
+#endif //SMS_PLUGIN_SIMMSG_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginStorage.h b/plugin/sms_plugin/include/SmsPluginStorage.h
new file mode 100755 (executable)
index 0000000..73d11d1
--- /dev/null
@@ -0,0 +1,78 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_STORAGE_H
+#define SMS_PLUGIN_STORAGE_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgMutex.h"
+
+#include "MsgStorageTypes.h"
+#include "SmsPluginTypes.h"
+#include "MsgInternalTypes.h"
+#include "MsgSqliteWrapper.h"
+
+extern "C"
+{
+#ifndef _TAPI_NETTEXT_H_
+       #include "ITapiNetText.h"
+       #include "ITapiSim.h"
+#endif
+}
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginStorage
+{
+public:
+       static SmsPluginStorage* instance();
+
+       MSG_ERROR_T updateSentMsg(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_NETWORK_STATUS_T Status);
+
+       MSG_ERROR_T addSimMessage(MSG_MESSAGE_INFO_S *pSimMsgInfo);
+
+       MSG_ERROR_T addMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
+       MSG_ERROR_T addSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
+
+       MSG_ERROR_T deleteSmsMessage(MSG_MESSAGE_ID_T MsgId);
+
+private:
+       SmsPluginStorage();
+       ~SmsPluginStorage();
+
+       MSG_ERROR_T updateSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
+
+       MSG_ERROR_T addCbMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
+       MSG_ERROR_T addReplaceTypeMsg(MSG_MESSAGE_INFO_S *pMsgInfo);
+       MSG_ERROR_T addWAPMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
+       MSG_ERROR_T handleCOWAPMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
+       MSG_ERROR_T checkPushMsgValidation(MSG_PUSH_MESSAGE_S *pPushMsg, bool *pbProceed);
+
+       MSG_ERROR_T checkStorageStatus(MSG_MESSAGE_INFO_S *pMsgInfo);
+       MSG_ERROR_T updateAllAddress();
+
+       static SmsPluginStorage* pInstance;
+
+       MsgDbHandler dbHandle;
+
+};
+
+#endif //SMS_PLUGIN_STORAGE_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginTextConvert.h b/plugin/sms_plugin/include/SmsPluginTextConvert.h
new file mode 100755 (executable)
index 0000000..740ffe2
--- /dev/null
@@ -0,0 +1,247 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_TEXT_CONVERT_H
+#define SMS_PLUGIN_TEXT_CONVERT_H
+
+
+/*==================================================================================================
+                               INCLUDE FILES
+==================================================================================================*/
+#include <map>
+
+#include "SmsPluginTypes.h"
+
+
+/*==================================================================================================
+                                DEFINES
+==================================================================================================*/
+#define IN
+#define OUT
+#define INOUT
+
+#define MAX_DUMP_COLUMN        16
+
+typedef unsigned short WCHAR;
+
+typedef unsigned char SMS_CHAR_TYPE_T;
+
+
+/*==================================================================================================
+                                ENUMS
+==================================================================================================*/
+enum _SMS_CHAR_TYPE_E
+{
+       SMS_CHAR_DEFAULT = 0,
+       SMS_CHAR_GSM7EXT,
+       SMS_CHAR_TURKISH,
+       SMS_CHAR_SPANISH,
+       SMS_CHAR_PORTUGUESE
+};
+
+
+/*==================================================================================================
+                                     STRUCTURES
+==================================================================================================*/
+// ETSI GSM 03.38 GSM 7 bit Default Alphabet Table -> UCS2
+static const WCHAR g_GSM7BitToUCS2[] =
+{
+       /* @ */
+       0x0040, 0x00A3, 0x0024, 0x00A5, 0x00E8, 0x00E9, 0x00F9, 0x00EC, 0x00F2, 0x00C7, 0x000A, 0x00D8, 0x00F8, 0x000D, 0x00C5, 0x00E5,
+       /* Â¥Ã„*/
+       0x0394, 0x005F, 0x03A6, 0x0393, 0x039B, 0x03A9, 0x03A0,         0x03A8, 0x03A3, 0x0398, 0x039E, 0x001B, 0x00C6, 0x00E6, 0x00DF, 0x00C9,
+       /* SP */
+       0x0020, 0x0021, 0x0022, 0x0023, 0x00A4, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+       /* 0 */
+       0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+       /* Â¢Â®*/
+       0x00A1, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+       /* P */
+       0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x00C4, 0x00D6, 0x00D1, 0x00DC, 0x00A7,
+       /* Â¢Â¯*/
+       0x00BF, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+       /* p */
+       0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x00E4, 0x00F6, 0x00F1, 0x00FC, 0x00E0
+};
+
+
+//GSM 7 bit Default Alphabet Extension Table -> UCS2
+static const WCHAR g_GSM7BitExtToUCS2[] =
+{
+       // 0x0020 -> (SP) for invalid code
+                                                                                                                                    /* Page Break */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x000C, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
+                                                         /* ^ */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x005E, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x001B, 0x0020, 0x0020, 0x0020, 0x0020,
+                                                                                                           /* { */ /* } */                                                               /* \ */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007B, 0x007D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x005C,
+                                                                                                                                                             /* [ */ /* ~ */ /* ] */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x005B, 0x007E, 0x005D, 0x0020,
+       /* | */
+       0x007C, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
+                                                                     /* Â¢Ã¦*/
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x20AC, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020
+};
+
+
+//Turkish National Language Single Shift Table -> UCS2
+static const WCHAR g_TurkishSingleToUCS2[] =
+{
+       // 0x0020 -> (SP) for invalid code
+                                                                                                                                    /* Page Break */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x000C, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
+                                                         /* ^ */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x005E, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x001B, 0x0020, 0x0020, 0x0020, 0x0020,
+                                                                                                           /* { */ /* } */                                                               /* \ */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007B, 0x007D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x005C,
+                                                                                                                                                             /* [ */ /* ~ */ /* ] */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x005B, 0x007E, 0x005D, 0x0020,
+       /* | */
+       0x007C, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x011E, 0x0020, 0x0130, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
+       0x0020, 0x0020, 0x0020, 0x015E, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
+                                                                     /* Â¢Ã¦*/
+       0x0020, 0x0020, 0x0020, 0x00E7, 0x0020, 0x20AC, 0x0020, 0x011F, 0x0020, 0x0131, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
+       0x0020, 0x0020, 0x0020, 0x015F, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020
+};
+
+
+// Turkish National Language Locking Shift Table -> UCS2
+static const WCHAR g_TurkishLockingToUCS2[] =
+{
+       /* @ */
+       0x0040, 0x00A3, 0x0024, 0x00A5, 0x20AC, 0x00E9, 0x00F9, 0x00EC, 0x00F2, 0x00C7, 0x000A, 0x011E, 0x011F, 0x000D, 0x00C5, 0x00E5,
+       /* Â¥Ã„*/
+       0x0394, 0x005F, 0x03A6, 0x0393, 0x039B, 0x03A9, 0x03A0,         0x03A8, 0x03A3, 0x0398, 0x039E, 0x001B, 0x015E, 0x015F, 0x00DF, 0x00C9,
+       /* SP */
+       0x0020, 0x0021, 0x0022, 0x0023, 0x00A4, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+       /* 0 */
+       0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+       /* Â¢Â®*/
+       0x0130, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+       /* P */
+       0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x00C4, 0x00D6, 0x00D1, 0x00DC, 0x00A7,
+       /* c */
+       0x00E7, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+       /* p */
+       0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x00E4, 0x00F6, 0x00F1, 0x00FC, 0x00E0
+};
+
+
+// Spanish National Language Single Shift Table -> UCS2
+static const WCHAR g_SpanishSingleToUCS2[] =
+{
+       // 0x0020 -> (SP) for invalid code
+                                                                                                                                    /* Page Break */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00E7, 0x000C, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
+                                                         /* ^ */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x005E, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x001B, 0x0020, 0x0020, 0x0020, 0x0020,
+                                                                                                           /* { */ /* } */                                                               /* \ */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007B, 0x007D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x005C,
+                                                                                                                                                             /* [ */ /* ~ */ /* ] */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x005B, 0x007E, 0x005D, 0x0020,
+       /* | */
+       0x007C, 0x00C1, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00CD, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00D3,
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00DA, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
+                                                                     /* Â¢Ã¦*/
+       0x0020, 0x00E1, 0x0020, 0x0020, 0x0020, 0x20AC, 0x0020, 0x0020, 0x0020, 0x00ED, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00F3,
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00FA, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020
+};
+
+
+// Portuguese National Language Single Shift Table -> UCS2
+static const WCHAR g_PortuSingleToUCS2[] =
+{
+       // 0x0020 -> (SP) for invalid code
+                                                                                                                                    /* Page Break */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00EA, 0x0020, 0x0020, 0x0020, 0x00E7, 0x000C, 0x00D4, 0x00F4, 0x0020, 0x00C1, 0x00E1,
+                                                         /* ^ */
+       0x0020, 0x0020, 0x03A6, 0x0393, 0x005E, 0x03A9, 0x03A0, 0x03A8, 0x03A3, 0x0398, 0x0020, 0x001B, 0x0020, 0x0020, 0x0020, 0x00CA,
+                                                                                                           /* { */ /* } */                                                               /* \ */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x007B, 0x007D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x005C,
+                                                                                                                                                             /* [ */ /* ~ */ /* ] */
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x005B, 0x007E, 0x005D, 0x0020,
+       /* | */
+       0x007C, 0x00C0, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00CD, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00D3,
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00DA, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00C3, 0x00D5, 0x0020, 0x0020, 0x0020,
+                                                                     /* Â¢Ã¦*/
+       0x0020, 0x00C2, 0x0020, 0x0020, 0x0020, 0x20AC, 0x0020, 0x0020, 0x0020, 0x00ED, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00F3,
+       0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00FA, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00E3, 0x00F5, 0x0020, 0x0020, 0x00E2
+};
+
+
+// Portuguese National Language Locking Shift Table -> UCS2
+static const WCHAR g_PortuLockingToUCS2[] =
+{
+       /* @ */
+       0x0040, 0x00A3, 0x0024, 0x00A5, 0x00EA, 0x00E9, 0x00FA, 0x00ED, 0x00F3, 0x00E7, 0x000A, 0x00D4, 0x00F4, 0x000D, 0x00C1, 0x00E1,
+       /* Â¥Ã„*/
+       0x0394, 0x005F, 0x0020, 0x00C7, 0x00C0, 0x0020, 0x005E,         0x005C, 0x20AC, 0x00D3, 0x007C, 0x001B, 0x00C2, 0x00E2, 0x00CA, 0x00C9,
+       /* SP */
+       0x0020, 0x0021, 0x0022, 0x0023, 0x00A4, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+       /* 0 */
+       0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+       /* Â¢Â®*/
+       0x00CD, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+       /* P */
+       0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x00C3, 0x00D5, 0x00DA, 0x00DC, 0x00A7,
+       /* Â¢Â¯*/
+       0x00BF, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+       /* p */
+       0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x00E3, 0x00F5, 0x0020, 0x00FC, 0x00E0
+};
+
+
+/*==================================================================================================
+                                CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginTextConvert
+{
+public:
+       static SmsPluginTextConvert* instance();
+
+       int convertUTF8ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, OUT SMS_LANGUAGE_ID_T *pLangId);
+       int convertUTF8ToUCS2(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen);
+       int convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_ENCODE_TYPE_T *pCharType);
+
+       int convertGSM7bitToUTF8(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, IN SMS_LANG_INFO_S *pLangInfo);
+       int convertUCS2ToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN  int srcTextLen);
+       int convertEUCKRToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN  int srcTextLen);
+
+private:
+       SmsPluginTextConvert();
+       virtual ~SmsPluginTextConvert();
+
+       static SmsPluginTextConvert* pInstance;
+
+       int convertUCS2ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT SMS_LANGUAGE_ID_T *pLangId);
+       int convertUCS2ToGSM7bitAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT bool *pUnknown);
+
+       int convertGSM7bitToUCS2(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, IN SMS_LANG_INFO_S *pLangInfo);
+
+       void convertDumpTextToHex(const unsigned char *pText, int length);
+
+       std::map<unsigned short, unsigned char> extCharList;
+       std::map<unsigned short, unsigned char> ucs2toGSM7DefList;
+       std::map<unsigned short, unsigned char> ucs2toGSM7ExtList;
+       std::map<unsigned short, unsigned char> ucs2toTurkishList;
+       std::map<unsigned short, unsigned char> ucs2toSpanishList;
+       std::map<unsigned short, unsigned char> ucs2toPortuList;
+};
+
+#endif //SMS_PLUGIN_TEXT_CONVERT_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginTpduCodec.h b/plugin/sms_plugin/include/SmsPluginTpduCodec.h
new file mode 100755 (executable)
index 0000000..c013409
--- /dev/null
@@ -0,0 +1,51 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_TPDU_CODEC_H
+#define SMS_PLUGIN_TPDU_CODEC_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "SmsPluginTypes.h"
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginTpduCodec
+{
+public:
+       SmsPluginTpduCodec();
+       virtual ~SmsPluginTpduCodec();
+
+       static int encodeTpdu(const SMS_TPDU_S *pSmsTpdu, char *pTpdu);
+       static int decodeTpdu(const unsigned char *pTpdu, int TpduLen, SMS_TPDU_S *pSmsTpdu);
+
+private:
+       static int encodeSubmit(const SMS_SUBMIT_S *pSubmit, char *pTpdu);
+       static int encodeDeliver(const SMS_DELIVER_S *pDeliver, char *pTpdu);
+       static int encodeDeliverReport(const SMS_DELIVER_REPORT_S *pDeliverRep, char *pTpdu);
+       static int encodeStatusReport(const SMS_STATUS_REPORT_S *pStatusRep, char *pTpdu);
+
+       static int decodeSubmit(const unsigned char *pTpdu, int TpduLen, SMS_SUBMIT_S *pSubmit);
+       static int decodeDeliver(const unsigned char *pTpdu, int TpduLen, SMS_DELIVER_S *pDeliver);
+       static int decodeStatusReport(const unsigned char *pTpdu, int TpduLen, SMS_STATUS_REPORT_S *pStatusRep);
+};
+
+#endif //SMS_PLUGIN_TPDU_CODEC_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginTransport.h b/plugin/sms_plugin/include/SmsPluginTransport.h
new file mode 100755 (executable)
index 0000000..a521f95
--- /dev/null
@@ -0,0 +1,73 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_TRANSPORT_H
+#define SMS_PLUGIN_TRANSPORT_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgMutex.h"
+#include "MsgTransportTypes.h"
+#include "MsgSettingTypes.h"
+#include "SmsPluginTypes.h"
+#include "MsgInternalTypes.h"
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginTransport
+{
+public:
+       static SmsPluginTransport* instance();
+
+       void submitRequest(SMS_REQUEST_INFO_S *pReqInfo);
+       void sendDeliverReport(MSG_ERROR_T err);
+
+       void setSmsSendOptions(SMS_SUBMIT_S *pSubmit);
+       void setSmscOptions(SMS_ADDRESS_S *pSmsc);
+
+       void msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SUBMIT_DATA_S *pData, SMS_CODING_SCHEME_T *pCharType);
+       void setConcatHeader(SMS_UDH_S *pSrcHeader, SMS_UDH_S *pDstHeader);
+
+       void setNetStatus(MSG_NETWORK_STATUS_T netStatus);
+       MSG_NETWORK_STATUS_T getNetStatus();
+
+       unsigned char getMsgRef();
+
+private:
+       SmsPluginTransport();
+       ~SmsPluginTransport();
+
+       int getSegmentSize(SMS_CODING_SCHEME_T CodingScheme, int DataLen, bool bPortNum, SMS_LANGUAGE_ID_T LangId, int ReplyAddrLen);
+       SMS_PID_T convertPid(MSG_SMS_PID_T pid);
+
+       static SmsPluginTransport* pInstance;
+
+       unsigned char           msgRef;
+
+       unsigned char           msgRef8bit;
+       unsigned short  msgRef16bit;
+
+       MSG_NETWORK_STATUS_T curStatus;
+
+       Mutex mx;
+       CndVar cv;
+};
+
+#endif //SMS_PLUGIN_TRANSPORT_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginTypes.h b/plugin/sms_plugin/include/SmsPluginTypes.h
new file mode 100755 (executable)
index 0000000..bc206df
--- /dev/null
@@ -0,0 +1,939 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_TYPES_H
+#define SMS_PLUGIN_TYPES_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgInternalTypes.h"
+#include "MsgStorageTypes.h"
+#include "MsgSettingTypes.h"
+
+
+/*==================================================================================================
+                                    DEFINES
+==================================================================================================*/
+#define MAX_ADDRESS_LEN                        21 // including '+'
+#define MAX_USER_DATA_LEN                      160
+#define MAX_GSM_7BIT_DATA_LEN          160
+#define MAX_UCS2_DATA_LEN                      140
+#define MAX_TPDU_DATA_LEN                      165
+#define MAX_SMSC_LEN                           20
+#define MAX_ADD_PARAM_LEN                      12
+#define MAX_ABS_TIME_PARAM_LEN         7
+#define MAX_REL_TIME_PARAM_LEN         1
+#define MAX_UD_HEADER_NUM                      7
+#define MAX_SAT_TPDU_LEN                       175
+#define MAX_CBMSG_PAGE_SIZE            93
+#define MAX_CBMSG_PAGE_NUM             15
+#define MAX_SIM_SMS_NUM                        90
+
+#define SMS_PUSH_XML_HREF_TAG          "href"
+#define SMS_PUSH_XML_SI_ID_TAG         "si-id"
+#define SMS_PUSH_XML_CREATED_TAG       "created"
+#define SMS_PUSH_XML_EXPIRES_TAG       "si-expires"
+#define SMS_PUSH_XML_ACTION_TAG        "action"
+
+#define SMS_PUSH_XML_INVAL_OBJ         "invalidate-object"
+#define SMS_PUSH_XML_INVAL_SVC         "invalidate-service"
+#define SMS_PUSH_XML_CO_URI            "uri"
+
+
+/*==================================================================================================
+                                         TYPES
+==================================================================================================*/
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_TPDU_TYPE_T;
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_VPF_T;
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_TON_T;
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_NPI_T;
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_PID_T;
+
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_MSG_CLASS_T;
+
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_CODING_SCHEME_T;
+
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_CODING_GROUP_T;
+
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_INDICATOR_TYPE_T;
+
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_TIME_FORMAT_T;
+
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_FAIL_CAUSE_T;
+
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_STATUS_T;
+
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_REF_NUMBER_T;
+
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_REPORT_TYPE_T;
+
+
+/**
+\brief Represents TPDU Type.
+*/
+typedef unsigned char SMS_UDH_TYPE_T;
+
+
+/**
+\brief Represents WAP Push App Code.
+*/
+typedef unsigned char SMS_WAP_APP_CODE_T;
+
+
+typedef unsigned char SMS_CB_NETWORK_TYPE_T;
+
+
+typedef unsigned char SMS_CBMSG_TYPE_T;
+
+
+typedef unsigned char SMS_CBMSG_LANG_TYPE_T;
+
+
+typedef unsigned char SMS_CBMSG_CODING_GROUP_T;
+
+
+typedef unsigned char SMS_SAT_CMD_TYPE_T;
+
+
+typedef unsigned short SMS_SIM_EFILE_NAME_T;
+
+
+typedef unsigned char SMS_LANGUAGE_ID_T;
+
+
+/*==================================================================================================
+                                    ENUMS
+==================================================================================================*/
+enum _SMS_TPDU_TYPE_E
+{
+       SMS_TPDU_SUBMIT,
+       SMS_TPDU_DELIVER,
+       SMS_TPDU_DELIVER_REP,
+       SMS_TPDU_STATUS_REP,
+};
+
+
+enum _SMS_VPF_E
+{
+       SMS_VPF_NOT_PRESENT = 0,
+       SMS_VPF_ENHANCED,
+       SMS_VPF_RELATIVE,
+       SMS_VPF_ABSOLUTE,
+};
+
+
+enum _SMS_TON_E
+{
+       SMS_TON_UNKNOWN = 0,            /* unknown */
+       SMS_TON_INTERNATIONAL,  /* international */
+       SMS_TON_NATIONAL,                       /* national */
+       SMS_TON_NETWORK,                        /* network */
+       SMS_TON_SUBSCRIBER,             /* subscriber */
+       SMS_TON_ALPHANUMERIC,           /* alpha numberic */
+       SMS_TON_ABBREVIATED,            /* abbreviated */
+       SMS_TON_RESERVE,                        /* reserve */
+};
+
+
+enum _SMS_NPI_E
+{
+       SMS_NPI_UNKNOWN = 0,            /* unknown */
+       SMS_NPI_ISDN = 1,                       /* idsn */
+       SMS_NPI_DATA = 3,                       /* data */
+       SMS_NPI_TELEX = 4,                      /* telex */
+       SMS_NPI_SMSC = 5,                       /* smsc */
+       SMS_NPI_NATIONAL = 8,           /* national */
+       SMS_NPI_PRIVATE = 9,                    /* private */
+       SMS_NPI_ERMES = 10,                     /* ermes */
+};
+
+
+enum _SMS_PID_E
+{
+       SMS_PID_NORMAL = 0x00,
+
+       SMS_PID_TELEX = 0x21,
+       SMS_PID_GROUP3_TELEX = 0x22,
+       SMS_PID_GROUP4_TELEX = 0x23,
+       SMS_PID_VOICE = 0x24,
+       SMS_PID_ERMES = 0x25,
+       SMS_PID_NPS = 0x26,
+       SMS_PID_VIDEO = 0x27,
+       SMS_PID_TELETEX_UNSPEC = 0x28,
+       SMS_PID_TELETEX_PSPDN = 0x29,
+       SMS_PID_TELETEX_CSPDN = 0x2A,
+       SMS_PID_TELETEX_PSTN = 0x2B,
+       SMS_PID_TELETEX_ISDN = 0x2C,
+       SMS_PID_UCI = 0x2D,
+       SMS_PID_x400 = 0x31,
+       SMS_PID_EMAIL = 0x32,
+
+       SMS_PID_TYPE0 = 0x40,
+       SMS_PID_REPLACE_TYPE1 = 0x41,
+       SMS_PID_REPLACE_TYPE2 = 0x42,
+       SMS_PID_REPLACE_TYPE3 = 0x43,
+       SMS_PID_REPLACE_TYPE4 = 0x44,
+       SMS_PID_REPLACE_TYPE5 = 0x45,
+       SMS_PID_REPLACE_TYPE6 = 0x46,
+       SMS_PID_REPLACE_TYPE7 = 0x47,
+
+       SMS_PID_RETURN_CALL = 0x5F,
+};
+
+
+enum _SMS_MSG_CLASS_E
+{
+       SMS_MSG_CLASS_0 = 0,
+       SMS_MSG_CLASS_1,
+       SMS_MSG_CLASS_2,
+       SMS_MSG_CLASS_3,
+       SMS_MSG_CLASS_NONE,
+};
+
+
+enum _SMS_CODING_SCHEME_E
+{
+       SMS_CHARSET_7BIT = 0,
+       SMS_CHARSET_8BIT,
+       SMS_CHARSET_UCS2,
+       SMS_CHARSET_AUTO,
+};
+
+
+enum _SMS_CODING_GROUP_E
+{
+       SMS_GROUP_GENERAL = 0,
+       SMS_GROUP_CODING_CLASS,
+       SMS_GROUP_DELETION,
+       SMS_GROUP_DISCARD,
+       SMS_GROUP_STORE,
+       SMS_GROUP_UNKNOWN,
+};
+
+
+enum _SMS_INDICATOR_TYPE_E
+{
+       SMS_VOICE_INDICATOR = 0,
+       SMS_FAX_INDICATOR,
+       SMS_EMAIL_INDICATOR,
+       SMS_OTHER_INDICATOR,
+};
+
+
+enum _SMS_TIME_FORMAT_E
+{
+       SMS_TIME_RELATIVE = 0,
+       SMS_TIME_ABSOLUTE
+};
+
+
+enum _SMS_FAIL_CAUSE_E
+{
+       SMS_FC_MSG_TYPE0_NOT_SUPPORTED = 0x81,
+       SMS_FC_SM_CANNOT_BE_REPLACED = 0x82,
+       SMS_FC_UNSPEC_PID_ERROR = 0x8F,
+       SMS_FC_MSG_CLASS_NOT_SUPPORTED = 0x91,
+       SMS_FC_UNSPEC_DCS_ERROR = 0x9F,
+       SMS_FC_TPDU_NOT_SUPPORTED = 0xB0,
+       SMS_FC_SIM_STORAGE_FULL = 0xD0,
+       SMS_FC_NO_STORAGE_IN_SIM = 0xD1,
+       SMS_FC_ERROR_IN_MS = 0xD2,
+       SMS_FC_MSG_CAPA_EXCEEDED = 0xD3,
+       SMS_FC_SAT_BUSY = 0xD4,
+       SMS_FC_SIM_DOWNLOAD_ERROR = 0xD5,
+       SMS_FC_UNSPEC_ERROR = 0xFF,
+};
+
+
+enum _SMS_STATUS_E
+{
+       SMS_STATUS_RECEIVE_SUCCESS = 0x00,
+       SMS_STATUS_UNABLE_TO_CONFIRM_DELIVER = 0x01,
+       SMS_STATUS_REPLACED = 0x02,
+       SMS_STATUS_SMSC_SPECIFIC_LAST = 0x1F,
+
+       SMS_STATUS_TRY_CONGESTION = 0x20,
+       SMS_STATUS_TRY_SME_BUSY = 0x21,
+       SMS_STATUS_TRY_NO_RESPONSE = 0x22,
+       SMS_STATUS_TRY_SERVICE_REJECTED = 0x23,
+       SMS_STATUS_TRY_QOS_NOT_AVAILABLE = 0x24,
+
+       SMS_STATUS_PERM_REMOTE_ERROR = 0x40,
+       SMS_STATUS_PERM_IMCOMPATIBLE_DEST = 0x41,
+       SMS_STATUS_PERM_CONNECTION_REJECTED = 0x42,
+       SMS_STATUS_PERM_NOT_OBTAINABLE = 0x43,
+       SMS_STATUS_PERM_QOS_NOT_AVAILABLE = 0x44,
+       SMS_STATUS_PERM_NO_INTERWORK_AVAILABLE = 0x45,
+       SMS_STATUS_PERM_MSG_VAL_PERIOD_EXPIRED = 0x46,
+       SMS_STATUS_PERM_MSG_DEL_BY_ORIGIN_SME = 0x47,
+       SMS_STATUS_PERM_MSG_DEL_BY_SMSC_ADMIN = 0x48,
+       SMS_STATUS_PERM_MSG_NOT_EXIST = 0x49,
+
+       SMS_STATUS_TEMP_CONGESTION = 0x60,
+       SMS_STATUS_TEMP_SME_BUSY = 0x61,
+       SMS_STATUS_TEMP_NO_RESPONSE = 0x62,
+       SMS_STATUS_TEMP_SERVICE_REJECTED = 0x63,
+       SMS_STATUS_TEMP_QOS_NOT_AVAILABLE = 0x64,
+       SMS_STATUS_TEMP_ERROR_IN_SME = 0x65,
+};
+
+
+enum _SMS_REF_NUMBER_E
+{
+       SMS_REF_NUM_8BIT = 0,
+       SMS_REF_NUM_16BIT
+};
+
+
+enum _SMS_REPORT_TYPE_E
+{
+       SMS_REPORT_POSITIVE = 0,
+       SMS_REPORT_NEGATIVE
+};
+
+
+enum _SMS_UDH_TYPE_E
+{
+       SMS_UDH_CONCAT_8BIT = 0x00,
+       SMS_UDH_SPECIAL_SMS = 0x01,
+       // 0x02, 0x03 - Reserved
+       SMS_UDH_APP_PORT_8BIT = 0x04,
+       SMS_UDH_APP_PORT_16BIT = 0x05,
+       SMS_UDH_SC_CONTROL = 0x06,
+       SMS_UDH_SRC_IND = 0x07,
+       SMS_UDH_CONCAT_16BIT = 0x08,
+       SMS_UDH_WCMP = 0x09,
+       SMS_UDH_ALTERNATE_REPLY_ADDRESS = 0x22,
+       SMS_UDH_SINGLE_SHIFT = 0x24,
+       SMS_UDH_LOCKING_SHIFT = 0x25,
+       SMS_UDH_NONE = 0xFF,
+};
+
+
+enum _SMS_WAP_APP_CODE_E
+{
+       SMS_WAP_APPLICATION_DEFAULT = 0x00,
+
+       SMS_WAP_APPLICATION_PUSH_SI,
+       SMS_WAP_APPLICATION_PUSH_SIC,
+
+       SMS_WAP_APPLICATION_PUSH_SL,
+       SMS_WAP_APPLICATION_PUSH_SLC,
+
+       SMS_WAP_APPLICATION_PUSH_CO,
+       SMS_WAP_APPLICATION_PUSH_COC,
+
+       SMS_WAP_APPLICATION_MMS_UA,
+
+       SMS_WAP_APPLICATION_PUSH_SIA,
+
+       SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP,
+       SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML,
+       SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION,
+       SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION,
+       SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML,
+
+       SMS_WAP_APPLICATION_LOC_UA_WBXML,
+       SMS_WAP_APPLICATION_LOC_UA_XML,
+
+       SMS_WAP_APPLICATION_DRM_UA_XML,
+       SMS_WAP_APPLICATION_DRM_UA_MESSAGE,
+       SMS_WAP_APPLICATION_DRM_UA_CONETENT,
+       SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML,
+       SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML,
+       SMS_WAP_APPLICATION_DRM_V2_RO_XML,
+       SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML,
+       SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML,
+       SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML,
+
+       SMS_WAP_APPLICATION_PUSH_PROVISIONING,
+       SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML,
+       SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML,
+
+       SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS,
+       SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS,
+       SMS_WAP_APPLICATION_PUSH_SYNCSET_WBXML,
+       SMS_WAP_APPLICATION_PUSH_SYNCSET_XML,
+
+       SMS_WAP_APPLICATION_PUSH_EMAIL_XML,
+       SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML,
+
+       SMS_WAP_APPLICATION_PUSH_IMPS_CIR,
+
+       SMS_WAP_APPLICATION_PUSH_WAP_WMLC,
+
+       SMS_WAP_APPLICATION_WML_UA,
+       SMS_WAP_APPLICATION_WTA_UA,
+
+       SMS_WAP_APPLICATION_PUSH_SYNCML,
+       SMS_WAP_APPLICATION_LOC_UA,
+       SMS_WAP_APPLICATION_SYNCML_DM,
+       SMS_WAP_APPLICATION_PUSH_EMAIL,
+
+       SMS_OMA_APPLICATION_ULP_UA,
+       SMS_OMA_APPLICATION_DLOTA_UA,
+
+       SMS_WAP_APPLICATION_LBS,
+};
+
+
+enum _SMS_CB_NETWORK_TYPE_E
+{
+       SMS_CB_NETWORK_TYPE_2G_GSM = 1,
+       SMS_CB_NETWORK_TYPE_3G_UMTS,
+};
+
+
+enum _SMS_CBMSG_TYPE_E
+{
+       SMS_CBMSG_TYPE_CBS = 1,         /**< CBS */
+       SMS_CBMSG_TYPE_SCHEDULE,                /**< Schedule */
+       SMS_CBMSG_TYPE_CBS41,                   /**< CBS41 */
+       SMS_CBMSG_TYPE_JAVACBS,         /**< JAVA-CB Message*/
+};
+
+
+enum _SMS_CBMSG_LANG_TYPE_E
+{
+       SMS_CBMSG_LANG_GERMAN                   = 0x00,
+       SMS_CBMSG_LANG_ENGLISH                  = 0x01,
+       SMS_CBMSG_LANG_ITALIAN                  = 0x02,
+       SMS_CBMSG_LANG_FRENCH                   = 0x03,
+       SMS_CBMSG_LANG_SPANISH                  = 0x04,
+       SMS_CBMSG_LANG_DUTCH                    = 0x05,
+       SMS_CBMSG_LANG_SWEDISH          = 0x06,
+       SMS_CBMSG_LANG_DANISH                   = 0x07,
+       SMS_CBMSG_LANG_PORTUGUESE       = 0x08,
+       SMS_CBMSG_LANG_FINNISH                  = 0x09,
+       SMS_CBMSG_LANG_NORWEGIAN        = 0x0a,
+       SMS_CBMSG_LANG_GREEK                    = 0x0b,
+       SMS_CBMSG_LANG_TURKISH                  = 0x0c,
+       SMS_CBMSG_LANG_HUNGARIAN        = 0x0d,
+       SMS_CBMSG_LANG_POLISH                   = 0x0e,
+       SMS_CBMSG_LANG_UNSPECIFIED      = 0x0f,
+
+       SMS_CBMSG_LANG_ISO639           = 0x10,
+
+       SMS_CBMSG_LANG_CZECH                    = 0x20,
+       SMS_CBMSG_LANG_HEBREW           = 0x21,
+       SMS_CBMSG_LANG_ARABIC           = 0x22,
+       SMS_CBMSG_LANG_RUSSIAN          = 0x23,
+       SMS_CBMSG_LANG_ICELANDIC                = 0x24,
+       SMS_CBMSG_LANG_RESERVED_25      = 0x25,
+       SMS_CBMSG_LANG_RESERVED_26      = 0x26,
+       SMS_CBMSG_LANG_RESERVED_27      = 0x27,
+       SMS_CBMSG_LANG_RESERVED_28      = 0x28,
+       SMS_CBMSG_LANG_RESERVED_29      = 0x29,
+       SMS_CBMSG_LANG_RESERVED_2A      = 0x2a,
+       SMS_CBMSG_LANG_RESERVED_2B      = 0x2b,
+       SMS_CBMSG_LANG_RESERVED_2C      = 0x2c,
+       SMS_CBMSG_LANG_RESERVED_2D      = 0x2d,
+       SMS_CBMSG_LANG_RESERVED_2E      = 0x2e,
+       SMS_CBMSG_LANG_RESERVED_2F      = 0x2f,
+
+       SMS_CBMSG_LANG_DUMMY                    = 0xFF
+};
+
+
+enum _SMS_CBMSG_CODING_GROUP_E
+{
+       SMS_CBMSG_CODGRP_GENERAL_DCS,                   /**< Bits 7..4 00xx */
+       SMS_CBMSG_CODGRP_WAP,                                   /**< 1110 Cell Broadcast */
+       SMS_CBMSG_CODGRP_CLASS_CODING,                  /**< 1111 Cell Broadcast */
+};
+
+
+enum _SMS_SAT_CMD_TYPE_E
+{
+       SMS_SAT_CMD_REFRESH,
+       SMS_SAT_CMD_SEND_SMS,
+       SMS_SAT_CMD_SMS_CTRL,
+};
+
+
+enum _SMS_SIM_EFILE_NAME_E
+{
+       SMS_SIM_EFILE_USIM_SMS  = 0x6A3C,               /** < USIM Short Messages file */
+       SMS_SIM_EFILE_USIM_SMSP = 0x6A42,               /** < USIM SMS parameter */
+       SMS_SIM_EFILE_USIM_SMSS = 0x6A43,               /** < USIM SMS status */
+       SMS_SIM_EFILE_USIM_CBMI = 0x6A45,               /** < USIM Cell Broadcast Message Identifier */
+       SMS_SIM_EFILE_USIM_MBDN = 0x6FC7,               /** < USIM Mail Box Dialing Number */
+       SMS_SIM_EFILE_SMS                       = 0x6F3C,               /** < Short Messages file */
+       SMS_SIM_EFILE_SMSP                      = 0x6F42,               /** < SMS Parameter */
+       SMS_SIM_EFILE_SMSS                      = 0x6F43,               /** < SMS Status */
+       SMS_SIM_EFILE_CBMI                      = 0x6F45,               /** < Cell Broadcast Message Identifier */
+       SMS_SIM_EFILE_MBDN              = 0x6FC7,               /** < Mail Box Dialing Number */
+};
+
+
+enum _SMS_LANGUAGE_ID_E
+{
+       SMS_LANG_ID_RESERVED = 0,
+       SMS_LANG_ID_TURKISH,
+       SMS_LANG_ID_SPANISH,
+       SMS_LANG_ID_PORTUGUESE,
+       SMS_LANG_ID_BENGALI,
+       SMS_LANG_ID_GUJARATI,
+       SMS_LANG_ID_HINDI,
+       SMS_LANG_ID_KANNADA,
+       SMS_LANG_ID_MALAYALAM,
+       SMS_LANG_ID_ORIYA,
+       SMS_LANG_ID_PUNJABI,
+       SMS_LANG_ID_TAMIL,
+       SMS_LANG_ID_TELUGU,
+       SMS_LANG_ID_URDU,
+};
+
+
+/*==================================================================================================
+                                         STRUCTURES
+==================================================================================================*/
+typedef struct _SMS_ADDRESS_S
+{
+       SMS_TON_T               ton;
+       SMS_NPI_T               npi;
+       char                            address[MAX_ADDRESS_LEN+1];        /* < null terminated string */
+} SMS_ADDRESS_S;
+
+
+typedef struct _SMS_DCS_S
+{
+       bool                                            bCompressed;
+       bool                                            bMWI;
+       bool                                            bIndActive;
+       SMS_MSG_CLASS_T                 msgClass;
+       SMS_CODING_SCHEME_T     codingScheme;
+       SMS_CODING_GROUP_T              codingGroup;
+       SMS_INDICATOR_TYPE_T            indType;
+} SMS_DCS_S;
+
+
+typedef struct _SMS_TIME_REL_S
+{
+       unsigned char time;
+} SMS_TIME_REL_S;
+
+
+typedef struct _SMS_TIME_ABS_S
+{
+       unsigned char year;
+       unsigned char month;
+       unsigned char day;
+       unsigned char hour;
+       unsigned char minute;
+       unsigned char second;
+       unsigned char timeZone;
+} SMS_TIME_ABS_S;
+
+
+typedef struct _SMS_TIMESTAMP_S
+{
+       SMS_TIME_FORMAT_T format;
+
+       union
+       {
+               SMS_TIME_REL_S  relative;
+               SMS_TIME_ABS_S  absolute;
+       } time;
+} SMS_TIMESTAMP_S;
+
+
+typedef struct _SMS_CONCAT_8BIT_S
+{
+       unsigned char           msgRef;
+       unsigned char           totalSeg;
+       unsigned char           seqNum;
+} SMS_CONCAT_8BIT_S;
+
+
+typedef struct _SMS_CONCAT_16BIT_S
+{
+       unsigned short          msgRef;
+       unsigned char           totalSeg;
+       unsigned char           seqNum;
+} SMS_CONCAT_16BIT_S;
+
+
+typedef struct _SMS_APP_PORT_8BIT_S
+{
+       unsigned char           destPort;
+       unsigned char           originPort;
+} SMS_APP_PORT_8BIT_S;
+
+
+typedef struct _SMS_APP_PORT_16BIT_S
+{
+       unsigned short          destPort;
+       unsigned short          originPort;
+} SMS_APP_PORT_16BIT_S;
+
+
+typedef struct _SMS_SPECIAL_INDICATION_S
+{
+       bool                            bStore;
+       unsigned short          msgInd;
+       unsigned short          waitMsgNum;
+} SMS_SPECIAL_INDICATION_S;
+
+
+typedef struct _SMS_SINGLE_SHIFT_S
+{
+       SMS_LANGUAGE_ID_T       langId;
+} SMS_SINGLE_SHIFT_S;
+
+
+typedef struct _SMS_LOCKING_SHIFT_S
+{
+       SMS_LANGUAGE_ID_T       langId;
+} SMS_LOCKING_SHIFT_S;
+
+
+typedef struct _SMS_UDH_S
+{
+       SMS_UDH_TYPE_T udhType;
+
+       union
+       {
+               SMS_CONCAT_8BIT_S                       concat8bit;
+               SMS_CONCAT_16BIT_S                      concat16bit;
+               SMS_APP_PORT_8BIT_S             appPort8bit;
+               SMS_APP_PORT_16BIT_S            appPort16bit;
+               SMS_SPECIAL_INDICATION_S        specialInd;
+               SMS_SINGLE_SHIFT_S                      singleShift;
+               SMS_LOCKING_SHIFT_S                     lockingShift;
+               SMS_ADDRESS_S                           alternateAddress;
+       } udh;
+} SMS_UDH_S;
+
+
+typedef struct _SMS_USERDATA_S
+{
+       int                     headerCnt;
+       SMS_UDH_S       header[MAX_UD_HEADER_NUM];
+       int                     length;
+       char                    data[MAX_USER_DATA_LEN+1];
+} SMS_USERDATA_S;
+
+
+typedef struct _SMS_TPUD_S
+{
+       int             udl;
+       char            ud[MAX_USER_DATA_LEN+1];
+} SMS_TPUD_S;
+
+
+typedef struct _SMS_SUBMIT_S
+{
+       bool                            bRejectDup;
+       bool                            bStatusReport;
+       bool                            bHeaderInd;
+       bool                            bReplyPath;
+       unsigned char           msgRef;
+       SMS_VPF_T               vpf;
+       SMS_ADDRESS_S   destAddress;
+       SMS_PID_T               pid;
+       SMS_DCS_S               dcs;
+       SMS_TIMESTAMP_S validityPeriod;
+       SMS_USERDATA_S  userData;
+} SMS_SUBMIT_S;
+
+
+typedef struct _SMS_SUBMIT_DATA_S
+{
+       SMS_ADDRESS_S   destAddress;
+       unsigned int            segCount;
+       SMS_USERDATA_S  userData[MAX_SEGMENT_NUM];
+} SMS_SUBMIT_DATA_S;
+
+
+typedef struct _SMS_DELIVER_S
+{
+       bool                            bMoreMsg;
+       bool                            bStatusReport;
+       bool                            bHeaderInd;
+       bool                            bReplyPath;
+       SMS_ADDRESS_S   originAddress;
+       SMS_PID_T               pid;
+       SMS_DCS_S               dcs;
+       SMS_TIMESTAMP_S timeStamp;
+       SMS_USERDATA_S  userData;
+       SMS_TPUD_S              udData;
+} SMS_DELIVER_S;
+
+
+typedef struct _SMS_DELIVER_REPORT_S
+{
+       SMS_REPORT_TYPE_T       reportType;
+       bool                                    bHeaderInd;
+       SMS_FAIL_CAUSE_T                failCause;
+       unsigned char                   paramInd;
+       SMS_PID_T                       pid;
+       SMS_DCS_S                       dcs;
+       SMS_USERDATA_S          userData;
+} SMS_DELIVER_REPORT_S;
+
+
+typedef struct _SMS_STATUS_REPORT_S
+{
+       bool                            bMoreMsg;
+       bool                            bStatusReport;
+       bool                            bHeaderInd;
+       unsigned char           msgRef;
+       SMS_ADDRESS_S   recipAddress;
+       SMS_TIMESTAMP_S timeStamp;
+       SMS_TIMESTAMP_S dischargeTime;
+       SMS_STATUS_T    status;
+       unsigned char           paramInd;
+       SMS_PID_T               pid;
+       SMS_DCS_S               dcs;
+       SMS_USERDATA_S  userData;
+} SMS_STATUS_REPORT_S;
+
+
+typedef struct _SMS_TPDU_S
+{
+       SMS_TPDU_TYPE_T tpduType;
+
+       union
+       {
+               SMS_SUBMIT_S                    submit;
+               SMS_DELIVER_S                   deliver;
+               SMS_DELIVER_REPORT_S    deliverRep;
+               SMS_STATUS_REPORT_S             statusRep;
+       } data;
+} SMS_TPDU_S;
+
+
+typedef struct
+{
+       MSG_REQUEST_ID_T                reqId;          /**< Indicates the request ID, which is unique.
+                                                                               When applications submit a request to the framework, this value will be set by the framework. */
+       MSG_MESSAGE_INFO_S              msgInfo;        /**< Indicates the message structure to be sent by applications. */
+       MSG_SENDINGOPT_INFO_S   sendOptInfo;
+
+       bool                                            bReqCb;
+} SMS_REQUEST_INFO_S;
+
+
+typedef struct _SMS_SENT_INFO_S
+{
+       SMS_REQUEST_INFO_S              reqInfo;                /**< Indicates the corresponding request structure. */
+       bool                                            bLast;
+} SMS_SENT_INFO_S;
+
+
+typedef struct _SMS_PUSH_APP_INFO_S
+{
+       char*                           pContentType;
+       char*                           pAppId;
+       SMS_WAP_APP_CODE_T      appCode;
+} SMS_PUSH_APP_INFO_S;
+
+
+typedef struct _SMS_CBMSG_SERIAL_NUM_S
+{
+       unsigned char           geoScope;
+       unsigned char           updateNum;
+       unsigned short          msgCode;
+} SMS_CBMSG_SERIAL_NUM_S;
+
+
+typedef struct _SMS_CBMSG_DCS_S
+{
+       SMS_CBMSG_CODING_GROUP_T                codingGroup;            /**< Coding group, GSM 03.38 */
+       SMS_MSG_CLASS_T                                 classType;              /**< The message class */
+       bool                                                            bCompressed;            /**< if text is compressed this is TRUE */
+       SMS_CODING_SCHEME_T                     codingScheme;   /**< How to encode a message. */
+       SMS_CBMSG_LANG_TYPE_T                           langType;
+       unsigned char                                           iso639Lang[3];  /* 2 GSM chars and a CR char */
+       bool                                                            bUDH;
+       unsigned char                                           rawData;
+} SMS_CBMSG_DCS_S;
+
+
+typedef struct _SMS_CBMSG_HEADER_S
+{
+       SMS_CBMSG_SERIAL_NUM_S          serialNum;              /**< Cell Broadcast Serial number */
+       unsigned short                                  msgId;                  /**< Message identifier code */
+       MSG_CB_LANGUAGE_TYPE_T          langType;               /**< Languages in CB Messages */
+       SMS_CBMSG_DCS_S                 dcs;                            /**< Data coding scheme */
+       unsigned char                                   page;                   /**< current page number */
+       unsigned char                                   totalPages;             /**< Total number of pages in this messages */
+       time_t                                          recvTime;               /**< Msg Recv Time */
+} SMS_CBMSG_HEADER_S;
+
+
+typedef struct _SMS_CBMSG_PAGE_S
+{
+       SMS_CBMSG_TYPE_T                        cbMsgType;                                                      /*CBS Msg or SCHEDULE Msg or CBS41 Msg */
+       SMS_CBMSG_HEADER_S                      pageHeader;                                                     /**< CB Message Header */
+       int                                                     pageLength;                                                     /**< message string length */
+       char                                                    pageData[MAX_CBMSG_PAGE_SIZE+1];                /**< user data */
+} SMS_CBMSG_PAGE_S;
+
+
+typedef struct _SMS_CBMSG_S
+{
+       SMS_CBMSG_TYPE_T                        cbMsgType;                                                      /*CBS Msg or SCHEDULE Msg or CBS41 Msg */
+       unsigned short                                  msgId;                                                          /**< Message identifier code */
+       SMS_MSG_CLASS_T                         classType;                                                      /**< The message class */
+       SMS_CODING_SCHEME_T             codingScheme;                                           /**< How to encode a message. */
+       time_t                                          recvTime;                                                       /**< Msg Recv Time */
+       int                                                     msgLength;                                                      /**< message string length */
+       char                                                    msgData[MAX_CBMSG_PAGE_SIZE*MAX_CBMSG_PAGE_NUM+1];              /**< user data */
+} SMS_CBMSG_S;
+
+
+typedef struct _SMS_LANG_INFO_S
+{
+       bool                                                    bSingleShift;
+       bool                                                    bLockingShift;
+
+       SMS_LANGUAGE_ID_T                       singleLang;
+       SMS_LANGUAGE_ID_T                       lockingLang;
+} SMS_LANG_INFO_S;
+
+
+typedef struct _SMS_WSP_CONTENTS_TYPE_S
+{
+       char*         contentsTypeName;
+       unsigned char contentsTypeCode;
+} SMS_WSP_CONTENTS_TYPE_S;
+
+
+typedef struct _SMS_WSP_CHARSET_S
+{
+       char*  charsetName;
+       unsigned short charsetCode;
+} SMS_WSP_CHARSET_S;
+
+
+typedef struct _SMS_WAP_UNREGISTER_CONTENTS_TYPE_S
+{
+       char*         contentsTypeName;
+       unsigned short contentsTypeCode;
+} SMS_WAP_UNREGISTER_CONTENTS_TYPE_S;
+
+
+typedef struct _SMS_WSP_LANGUAGE_S
+{
+       char*         languageName;
+       unsigned char languageCode;
+} SMS_WSP_LANGUAGE_S;
+
+
+typedef struct _SMS_WSP_HEADER_PARAMETER_S
+{
+       char*         parameterToken;
+       unsigned char parameterCode;
+} SMS_WSP_HEADER_PARAMETER_S;
+
+
+typedef struct _SMS_WSP_METHOD_TYPE_S
+{
+       char*         methodName;
+       unsigned char methodCode;
+} SMS_WSP_METHOD_TYPE_S;
+
+
+typedef struct _SMS_WSP_SECURITY_TYPE_S
+{
+       char*         SecurityTypeName;
+       unsigned char SecurityTypeCode;
+}SMS_WSP_SECURITY_TYPE_S;
+
+
+/**
+ *     @brief  Represents SIM count information.
+ */
+typedef struct
+{
+       unsigned int    totalCount;                     /**< The total number of SIM */
+       int                     usedCount;                      /**< The used number of SIM */
+       int                     indexList[MAX_SIM_SMS_NUM];     /**< The SIM index list */
+}MSG_SIM_COUNT_S;
+
+
+/**
+ *     @brief  Represents Concat SIM Msg information.
+ */
+typedef struct
+{
+       unsigned int            simIdCnt;                                                                                       /**< The total number of SIM Msg ID*/
+       MSG_SIM_ID_T            simIdList[MAX_SEGMENT_NUM];                                                     /**< The SIM Msg ID List */
+       char                            msgData[(MAX_MSG_DATA_LEN*MAX_SEGMENT_NUM)+1];          /**< user data */
+} SMS_CONCAT_SIM_MSG_S;
+
+#endif //SMS_PLUGIN_TYPES_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginUAManager.h b/plugin/sms_plugin/include/SmsPluginUAManager.h
new file mode 100755 (executable)
index 0000000..f0a610f
--- /dev/null
@@ -0,0 +1,59 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_UA_MANAGER_H
+#define SMS_PLUGIN_UA_MANAGER_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgMutex.h"
+#include "MsgQueue.h"
+#include "MsgThread.h"
+#include "SmsPluginTypes.h"
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginUAManager : public MsgThread
+{
+public:
+       static SmsPluginUAManager* instance();
+
+       //virtual void start();
+
+       void addReqEntity(SMS_REQUEST_INFO_S request);
+
+private:
+       SmsPluginUAManager();
+       ~SmsPluginUAManager();
+
+       virtual void run();
+
+       static SmsPluginUAManager* pInstance;
+
+       bool bRunning;
+
+       MsgThdSafeQ <SMS_REQUEST_INFO_S> smsTranQ;
+
+       Mutex mx;
+       CndVar cv;
+};
+
+#endif //SMS_PLUGIN_UA_MANAGER_H
+
diff --git a/plugin/sms_plugin/include/SmsPluginUDCodec.h b/plugin/sms_plugin/include/SmsPluginUDCodec.h
new file mode 100755 (executable)
index 0000000..b5fc77a
--- /dev/null
@@ -0,0 +1,57 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_UDCODEC_H
+#define SMS_PLUGIN_UDCODEC_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "SmsPluginTypes.h"
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginUDCodec
+{
+public:
+       SmsPluginUDCodec();
+       virtual ~SmsPluginUDCodec();
+
+       static int encodeUserData(const SMS_USERDATA_S *pUserData, SMS_CODING_SCHEME_T CodingScheme, char *pEncodeData);
+       static int decodeUserData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_CODING_SCHEME_T CodingScheme, SMS_USERDATA_S *pUserData);
+       static int decodeUserData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_CODING_SCHEME_T CodingScheme, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD);
+
+       static int pack7bitChar(const unsigned char *pUserData, int dataLen, int fillBits, char *pPackData);
+       static int unpack7bitChar(const unsigned char *pTpdu, unsigned char dataLen, int fillBits, char *pUnpackData);
+
+private:
+       static int encodeGSMData(const SMS_USERDATA_S *pUserData, char *pEncodeData);
+       static int encode8bitData(const SMS_USERDATA_S *pUserData, char *pEncodeData);
+       static int encodeUCS2Data(const SMS_USERDATA_S *pUserData, char *pEncodeData);
+
+       static int decodeGSMData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD);
+       static int decode8bitData(const unsigned char *pTpdu, bool bHeaderInd, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD);
+       static int decodeUCS2Data(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD);
+
+       static int encodeHeader(const SMS_UDH_S header, char *pEncodeHeader);
+       static int decodeHeader(const unsigned char *pTpdu, SMS_UDH_S *pHeader);
+};
+
+#endif
+
diff --git a/plugin/sms_plugin/include/SmsPluginWapPushHandler.h b/plugin/sms_plugin/include/SmsPluginWapPushHandler.h
new file mode 100755 (executable)
index 0000000..5185d44
--- /dev/null
@@ -0,0 +1,102 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#ifndef SMS_PLUGIN_WAPPUSH_HANDLER_H
+#define SMS_PLUGIN_WAPPUSH_HANDLER_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <wbxml/wbxml.h>
+#include <libxml/parser.h>
+
+
+#include "SmsPluginTypes.h"
+
+
+/*==================================================================================================
+                                         DEFINES
+==================================================================================================*/
+#define WSP_STANDARD_STR_LEN_MAX        255
+#define LENGTH_QUOTE  0x1F
+#define        NO_VALUE                                                0x00
+
+#define WSP_CODE_BUFFER_LEFT_LEN_MAX   1024
+#define WSP_CODE_BUFFER_RIGHT_LEN_MAX  2048
+
+#define  MemFree(x)  {if(x != NULL) free(x);x=NULL;}
+#define  AcStrlen(x) ((x==NULL)?0:strlen(x))
+#define MIN(a,b)  (((a)  <  (b)) ? (a)  :  (b))
+
+
+/*==================================================================================================
+                                     CLASS DEFINITIONS
+==================================================================================================*/
+class SmsPluginWapPushHandler
+{
+public:
+       static SmsPluginWapPushHandler* instance();
+
+       //void registerPushCallback();
+       bool IsWapPushMsg(SMS_USERDATA_S *pUserData);
+
+       void copyDeliverData(SMS_DELIVER_S *pDeliver);
+       void handleWapPushMsg(const char *pUserData, int DataSize);
+       void handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen);
+
+private:
+       SmsPluginWapPushHandler();
+       virtual ~SmsPluginWapPushHandler();
+
+       static SmsPluginWapPushHandler* pInstance;
+
+       SMS_WAP_APP_CODE_T getAppCode(const char *pPushHeader);
+
+       void handleMMSNotification(const char *pPushBody, int PushBodyLen);
+       void handleSIMessage(char* pPushBody, int PushBodyLen, bool isText);
+       void handleSLMessage(char* pPushBody, int PushBodyLen, bool isText);
+       void handleCOMessage(char* pPushBody, int PushBodyLen, bool isText);
+       void handleDrmVer1(char* pPushBody, int PushBodyLen);
+       void getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText);
+       void createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo);
+       unsigned long convertXmlCharToSec(char* pDate);
+       MSG_PUSH_ACTION_T convertSIActionStrToEnum(char* pAction);
+       MSG_PUSH_ACTION_T convertSLActionStrToEnum(char* pAction);
+
+       unsigned long wspRetriveUintvarDecode( unsigned char* sourceData, unsigned long* currentPointer );
+       unsigned long wspDecodeUintvar(unsigned long length, unsigned char* userVar );
+       void wspDecodeHeader( unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader);
+       unsigned long wspHeaderDecodeInteger( unsigned char* data );
+       void wspHeaderDecodeQValue( unsigned long length, unsigned char* data, char** pDecodedString);
+       unsigned long wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length );
+       char* wspExtendedDecodeType(char contentType  );
+       void wspHeaderDecodeParameter( unsigned char* data, unsigned long length, char** pParam);
+       void wspHeaderDecodeCharset( unsigned long length, unsigned char* data, char**pDecodedString);
+       void wspHeaderDecodeVersion( unsigned long length, unsigned char* data, char** pDecodedString );
+       void wspHeaderDecodeDateValue( unsigned long length, unsigned char* data, char** pDecodedString );
+       void wspHeaderCopyDecodedString( unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper );
+       void wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString );
+       void wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString );
+       void wspHeaderDecodeCacheControl(unsigned char* fieldValue, unsigned long fieldValueLen, char** pCacheString);
+
+
+       SMS_ADDRESS_S   tmpAddress;
+       SMS_TIMESTAMP_S tmpTimeStamp;
+};
+
+#endif //SmsPluginWapPushHandler
+
diff --git a/proxy/CMakeLists.txt b/proxy/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..e0adc2e
--- /dev/null
@@ -0,0 +1,49 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(msg-server CXX)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Debug")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall")
+
+##########################################################
+# Define Transaction Proxy
+##########################################################
+
+SET(TRANS-PROXY-SRCS
+       ${CMAKE_SOURCE_DIR}/proxy/MsgProxyListener.cpp
+       ${CMAKE_SOURCE_DIR}/proxy/MsgHandleControl.cpp
+       ${CMAKE_SOURCE_DIR}/proxy/MsgHandleSetting.cpp
+       ${CMAKE_SOURCE_DIR}/proxy/MsgHandleStorage.cpp
+       ${CMAKE_SOURCE_DIR}/proxy/MsgHandleTransport.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include/common
+       ${CMAKE_SOURCE_DIR}/include/framework
+       ${CMAKE_SOURCE_DIR}/include/utils
+       ${CMAKE_SOURCE_DIR}/include/proxy
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(trans_proxy_pkgs REQUIRED glib-2.0 dlog vconf security-server)
+
+FOREACH(flag ${trans_proxy_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${TRANS-PROXY-LIB} SHARED ${TRANS-PROXY-SRCS})
+TARGET_LINK_LIBRARIES(${TRANS-PROXY-LIB} ${trans_proxy_pkgs_LDFLAGS} ${UTILS-LIB} ${FW-HANDLER-LIB})
+
+INSTALL(TARGETS ${TRANS-PROXY-LIB} DESTINATION lib COMPONENT RuntimeLibraries)
+
diff --git a/proxy/MsgHandleControl.cpp b/proxy/MsgHandleControl.cpp
new file mode 100755 (executable)
index 0000000..9ae3bcd
--- /dev/null
@@ -0,0 +1,488 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <errno.h>
+#include <stdlib.h>
+
+#include <security-server.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgUtilFile.h"
+#include "MsgGconfWrapper.h"
+#include "MsgProxyListener.h"
+#include "MsgHandle.h"
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgHandle - Control Member Functions
+==================================================================================================*/
+MsgHandle::MsgHandle() : mCounter(0), mClientSock()
+{
+       memset(mConnectionId, 0x00, sizeof(mConnectionId));
+}
+
+
+MsgHandle::~MsgHandle()
+{
+
+}
+
+
+void MsgHandle::openHandle()
+{
+       int ret = 0;
+       size_t cookieSize;
+
+       bool bReady = false;
+
+       // server is currently booting and service is not available until the end of booting
+       MsgSettingGetBool(VCONFKEY_MSG_SERVER_READY, &bReady);
+
+       if (bReady == false) {
+               THROW(MsgException::SERVER_READY_ERROR, "Msg Server is not ready !!!!!");
+       } else {
+               MSG_DEBUG("Msg Server is ready !!!!!");
+       }
+
+       // Get Cookie Size
+       cookieSize = security_server_get_cookie_size();
+
+       MSG_DEBUG("cookie size : [%d]", cookieSize);
+
+       // Request Cookie
+       ret = security_server_request_cookie(mCookie, cookieSize);
+
+       if (ret < 0) {
+
+               MSG_DEBUG("security_server_request_cookie() error!! [%d]", ret);
+               return;
+       }
+
+       // Open Socket IPC
+       connectSocket();
+}
+
+
+void MsgHandle::closeHandle(MsgHandle* pHandle)
+{
+       MSG_BEGIN();
+
+       //Remove CB List of closing Handle
+       MsgProxyListener* eventListener = MsgProxyListener::instance();
+
+       eventListener->clearListOfClosedHandle(pHandle);
+       //eventListener->stop();
+
+       // Close Socket IPC
+       disconnectSocket();
+
+       MSG_END();
+}
+
+
+void MsgHandle::connectSocket()
+{
+       mClientSock.connect(MSG_SOCKET_PATH);
+}
+
+
+void MsgHandle::disconnectSocket()
+{
+       mClientSock.close();
+}
+
+
+void MsgHandle::write(const char *pCmdData, int cmdSize, char **ppEvent)
+{
+       if (pCmdData == NULL || ppEvent == NULL) {
+               THROW(MsgException::INVALID_PARAM, "Param is NULL");
+       }
+
+       // Send Command to MSG FW
+       mClientSock.write(pCmdData, cmdSize);
+
+       // Receive Result from MSG FW
+       read(ppEvent);
+
+       if (ppEvent == NULL) {
+               THROW(MsgException::INVALID_RESULT, "event is NULL");
+       }
+}
+
+
+void MsgHandle::read(char **ppEvent)
+{
+       int dataSize = 0;
+
+       dataSize = mClientSock.read(ppEvent, &dataSize);
+
+       if (dataSize == 0) {
+               THROW(MsgException::IPC_ERROR, "Server closed connection");
+       } else if(dataSize < 0) {
+               THROW(MsgException::IPC_ERROR, "negative length??? %d", dataSize);
+       }
+}
+
+
+void MsgHandle::convertMsgStruct(const MSG_MESSAGE_S *pSrc, MSG_MESSAGE_INFO_S *pDest)
+{
+       MSG_BEGIN();
+
+       pDest->msgId = pSrc->msgId;
+       pDest->folderId = pSrc->folderId;
+       pDest->referenceId = pSrc->referenceId;
+       pDest->msgType.mainType = pSrc->msgType.mainType;
+       pDest->msgType.subType = pSrc->msgType.subType;
+       pDest->msgType.classType= pSrc->msgType.classType;
+       pDest->storageId = pSrc->storageId;
+
+       pDest->nAddressCnt = pSrc->nAddressCnt;
+
+       for (int i = 0; i < pSrc->nAddressCnt; i++)
+       {
+               pDest->addressList[i].threadId = pSrc->addressList[i].threadId;
+               pDest->addressList[i].addressType = pSrc->addressList[i].addressType;
+               pDest->addressList[i].recipientType = pSrc->addressList[i].recipientType;
+               pDest->addressList[i].contactId = pSrc->addressList[i].contactId;
+               strncpy(pDest->addressList[i].addressVal, pSrc->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN);
+               strncpy(pDest->addressList[i].displayName, pSrc->addressList[i].displayName, MAX_DISPLAY_NAME_LEN);
+               pDest->addressList[i].displayName[MAX_DISPLAY_NAME_LEN] = '\0';
+       }
+
+       strncpy(pDest->replyAddress, pSrc->replyAddress, MAX_PHONE_NUMBER_LEN);
+       strncpy(pDest->subject, pSrc->subject, MAX_SUBJECT_LEN);
+
+       pDest->scheduledTime = pSrc->scheduledTime;
+       pDest->displayTime = pSrc->displayTime;
+       pDest->networkStatus = pSrc->networkStatus;
+       pDest->encodeType = pSrc->encodeType;
+       pDest->bRead = pSrc->bRead;
+       pDest->bProtected = pSrc->bProtected;
+       pDest->bBackup = pSrc->bBackup;
+       pDest->priority = pSrc->priority;
+       pDest->direction = pSrc->direction;
+
+       // Set Port Info.
+       pDest->msgPort.valid = pSrc->msgPort.valid;
+
+       if (pDest->msgPort.valid == true) {
+               pDest->msgPort.dstPort = pSrc->msgPort.dstPort;
+               pDest->msgPort.srcPort = pSrc->msgPort.srcPort;
+       }
+
+       MSG_DEBUG("nSize = %d",  pSrc->dataSize);
+
+       if (pSrc->msgType.mainType == MSG_SMS_TYPE){
+               pDest->bTextSms = true;
+               pDest->dataSize = pSrc->dataSize;
+
+               memset(pDest->msgText, 0x00, sizeof(pDest->msgText));
+
+               if (pSrc->dataSize > MAX_MSG_TEXT_LEN) {
+                       // Save Message Data into File
+                       char fileName[MAX_COMMON_INFO_SIZE+1];
+                       memset(fileName, 0x00, sizeof(fileName));
+
+                       if(MsgCreateFileName(fileName) == false)
+                               THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+
+                       MSG_DEBUG("Save pSrc->pData into file : size[%d] name[%s]", pDest->dataSize, fileName);
+
+                       if (MsgWriteIpcFile(fileName, (char*)pSrc->pData, pSrc->dataSize) == false)
+                               THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+
+                       memset(pDest->msgData, 0x00, sizeof(pDest->msgData));
+                       strncpy(pDest->msgData, fileName, MAX_MSG_DATA_LEN);
+
+                       pDest->bTextSms = false;
+
+               } else {
+                       if (pDest->encodeType == MSG_ENCODE_8BIT)
+                               memcpy(pDest->msgText, pSrc->pData, pSrc->dataSize);
+                       else
+                               strncpy(pDest->msgText, (char*)pSrc->pData, pSrc->dataSize);
+               }
+
+               MSG_DEBUG("pData = %s",  pSrc->pData);
+               MSG_DEBUG("msgText = %s",  pDest->msgText);
+       } else if (pSrc->msgType.mainType == MSG_MMS_TYPE) {
+
+               pDest->bTextSms = false;
+               pDest->dataSize = pSrc->dataSize;
+
+               if(pSrc->msgType.subType == MSG_READREPLY_MMS) {
+                       memset(pDest->msgData, 0x00, sizeof(pDest->msgData));
+                       memcpy(pDest->msgData, pSrc->pMmsData, pSrc->dataSize);
+               } else {
+                       // Save Message Data into File
+                       char fileName[MAX_COMMON_INFO_SIZE+1];
+                       memset(fileName, 0x00, sizeof(fileName));
+
+                       if(MsgCreateFileName(fileName) == false)
+                               THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+
+                       // change file extension in case of java MMS msg
+                       if (pSrc->msgType.subType == MSG_SENDREQ_JAVA_MMS) {
+                               char* pFileNameExt;
+                               pFileNameExt = strstr(fileName,"DATA");
+                               strncpy(pFileNameExt,"JAVA", MAX_COMMON_INFO_SIZE);
+                       }
+
+                       MSG_DEBUG("Save Message Data into file : size[%d] name[%s]", pDest->dataSize, fileName);
+
+                       if (MsgWriteIpcFile(fileName, (char*)pSrc->pMmsData, pSrc->dataSize) == false)
+                               THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+
+                       memset(pDest->msgData, 0x00, sizeof(pDest->msgData));
+                       strncpy(pDest->msgData, fileName, MAX_MSG_DATA_LEN);
+               }
+       }
+
+       MSG_END();
+}
+
+
+void MsgHandle::convertMsgStruct(const MSG_MESSAGE_INFO_S *pSrc, MSG_MESSAGE_S *pDest)
+{
+       MSG_BEGIN();
+
+       pDest->msgId = pSrc->msgId;
+       pDest->folderId = pSrc->folderId;
+       pDest->referenceId = pSrc->referenceId;
+       pDest->msgType.mainType = pSrc->msgType.mainType;
+       pDest->msgType.subType = pSrc->msgType.subType;
+       pDest->storageId = pSrc->storageId;
+
+       pDest->nAddressCnt = pSrc->nAddressCnt;
+
+       for (int i = 0; i < pSrc->nAddressCnt; i++)
+       {
+               pDest->addressList[i].threadId = pSrc->addressList[i].threadId;
+               pDest->addressList[i].addressType = pSrc->addressList[i].addressType;
+               pDest->addressList[i].recipientType = pSrc->addressList[i].recipientType;
+               pDest->addressList[i].contactId = pSrc->addressList[i].contactId;
+               strncpy(pDest->addressList[i].addressVal, pSrc->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN);
+               strncpy(pDest->addressList[i].displayName, pSrc->addressList[i].displayName, MAX_DISPLAY_NAME_LEN);
+               pDest->addressList[i].displayName[MAX_DISPLAY_NAME_LEN] = '\0';
+       }
+
+       strncpy(pDest->replyAddress, pSrc->replyAddress, MAX_PHONE_NUMBER_LEN);
+       strncpy(pDest->subject, pSrc->subject, MAX_SUBJECT_LEN);
+
+       pDest->displayTime = pSrc->displayTime;
+       pDest->scheduledTime = pSrc->scheduledTime;
+       pDest->networkStatus = pSrc->networkStatus;
+       pDest->encodeType = pSrc->encodeType;
+       pDest->bRead = pSrc->bRead;
+       pDest->bProtected = pSrc->bProtected;
+       pDest->bBackup = pSrc->bBackup;
+       pDest->priority = pSrc->priority;
+       pDest->direction = pSrc->direction;
+
+       // Set Port Info.
+       pDest->msgPort.valid = pSrc->msgPort.valid;
+
+       if (pDest->msgPort.valid == true) {
+               pDest->msgPort.dstPort = pSrc->msgPort.dstPort;
+               pDest->msgPort.srcPort = pSrc->msgPort.srcPort;
+       }
+
+       if(pSrc->thumbPath[0] != '\0')
+               strncpy(pDest->thumbPath, pSrc->thumbPath, MSG_FILEPATH_LEN_MAX);
+
+       if (pSrc->bTextSms == false) {
+               int fileSize = 0;
+
+               char* pFileData = NULL;
+               AutoPtr<char> buf(&pFileData);
+
+               pDest->dataSize = pSrc->dataSize;
+
+               // Get Message Data from File
+               if (pSrc->networkStatus != MSG_NETWORK_RETRIEVE_FAIL) {
+                       MSG_DEBUG("Get Message Data from file : size[%d] name[%s]\n", pDest->dataSize, pSrc->msgData);
+                       if (MsgOpenAndReadFile(pSrc->msgData, &pFileData, &fileSize) == false)
+                               THROW(MsgException::FILE_ERROR, "MsgOpenAndReadFile error");
+
+                       if (pSrc->msgType.mainType == MSG_SMS_TYPE) {
+                               if (pDest->encodeType == MSG_ENCODE_8BIT) {
+                                       pDest->pData = (void*)new char[fileSize];
+                                       memset(pDest->pData, 0x00, fileSize);
+                                       memcpy(pDest->pData, pFileData, fileSize);
+                               } else {
+                                       pDest->pData = (void*)new char[fileSize+1];
+                                       memset(pDest->pData, 0x00, fileSize+1);
+                                       strncpy((char*)pDest->pData, pFileData, fileSize);
+                               }
+                       } else {
+                               if (pSrc->msgText[0] != '\0') {
+                                       pDest->pData = (void*)new char[strlen(pSrc->msgText)+1];
+                                       memset(pDest->pData, 0x00, strlen(pSrc->msgText)+1);
+                                       strncpy((char*)pDest->pData, pSrc->msgText, strlen(pSrc->msgText));
+                               }
+                               pDest->pMmsData = (void*)new char[fileSize];
+                               memset(pDest->pMmsData, 0x00, fileSize);
+                               memcpy(pDest->pMmsData, pFileData, fileSize);
+                       }
+               }
+       } else {
+               pDest->dataSize = pSrc->dataSize;
+
+               if (pSrc->msgType.mainType == MSG_SMS_TYPE) {
+                       if (pDest->encodeType == MSG_ENCODE_8BIT) {
+                               pDest->pData = (void*)new char[pDest->dataSize];
+                               memset(pDest->pData, 0x00, pDest->dataSize);
+                               memcpy(pDest->pData, pSrc->msgText, pDest->dataSize);
+                       } else {
+                               pDest->pData = (void*)new char[pDest->dataSize+1];
+                               memset(pDest->pData, 0x00, pDest->dataSize+1);
+                               strncpy((char*)pDest->pData, pSrc->msgText, pDest->dataSize);
+                       }
+               } else {
+                       if (pSrc->msgText[0] != '\0') {
+                               pDest->pData = (void*)new char[strlen(pSrc->msgText)+1];
+                               memset(pDest->pData, 0x00, strlen(pSrc->msgText)+1);
+                               strncpy((char*)pDest->pData, pSrc->msgText, strlen(pSrc->msgText));
+                       }
+
+                       pDest->pMmsData = (void*)new char[pDest->dataSize];
+                       memset(pDest->pMmsData, 0x00, pDest->dataSize);
+                       memcpy(pDest->pMmsData, pSrc->msgData, pDest->dataSize);
+               }
+       }
+
+       MSG_END();
+}
+
+
+void MsgHandle::convertSendOptStruct(const MSG_SENDINGOPT_S* pSrc, MSG_SENDINGOPT_INFO_S* pDest, MSG_MESSAGE_TYPE_S msgType)
+{
+       MSG_BEGIN();
+
+       pDest->bSetting = pSrc->bSetting;
+
+       if (pDest->bSetting == false) {
+               MSG_DEBUG("No Sending Option");
+               return;
+       }
+
+       pDest->bDeliverReq = pSrc->bDeliverReq;
+       pDest->bKeepCopy = pSrc->bKeepCopy;
+
+       MSG_DEBUG("pDest->bSetting = %d", pDest->bSetting);
+       MSG_DEBUG("pDest->bDeliverReq = %d", pDest->bDeliverReq);
+       MSG_DEBUG("pDest->bKeepCopy = %d", pDest->bKeepCopy);
+
+       if (msgType.mainType == MSG_SMS_TYPE) {
+               pDest->option.smsSendOptInfo.bReplyPath = pSrc->option.smsSendOpt.bReplyPath;
+       } else if (msgType.mainType == MSG_MMS_TYPE) {
+               pDest->option.mmsSendOptInfo.priority = pSrc->option.mmsSendOpt.priority;
+               pDest->option.mmsSendOptInfo.bReadReq = pSrc->option.mmsSendOpt.bReadReq;
+
+               MSG_DEBUG("pDest->option.mmsSendOpt.priority = %d", pDest->option.mmsSendOptInfo.priority);
+               MSG_DEBUG("pDest->option.mmsSendOpt.bReadReq = %d", pDest->option.mmsSendOptInfo.bReadReq);
+
+               if (pSrc->option.mmsSendOpt.expiryTime == 0) {
+                       pDest->option.mmsSendOptInfo.expiryTime.type = MMS_TIMETYPE_NONE;
+                       pDest->option.mmsSendOptInfo.expiryTime.time = pSrc->option.mmsSendOpt.expiryTime;
+               } else {
+                       pDest->option.mmsSendOptInfo.expiryTime.type = MMS_TIMETYPE_RELATIVE;
+                       pDest->option.mmsSendOptInfo.expiryTime.time = pSrc->option.mmsSendOpt.expiryTime;
+               }
+
+               if (pSrc->option.mmsSendOpt.bUseDeliveryCustomTime == true) {
+                       pDest->option.mmsSendOptInfo.bUseDeliveryCustomTime = true;
+               } else {
+                       pDest->option.mmsSendOptInfo.bUseDeliveryCustomTime = false;
+               }
+               pDest->option.mmsSendOptInfo.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
+               pDest->option.mmsSendOptInfo.deliveryTime.time = pSrc->option.mmsSendOpt.deliveryTime;
+
+               MSG_DEBUG("pDest->option.mmsSendOpt.expiryTime = %d", pDest->option.mmsSendOptInfo.expiryTime.time);
+       }
+
+       MSG_END();
+}
+
+
+void MsgHandle::convertSendOptStruct(const MSG_SENDINGOPT_INFO_S* pSrc, MSG_SENDINGOPT_S* pDest, MSG_MESSAGE_TYPE_S msgType)
+{
+       MSG_BEGIN();
+
+       pDest->bDeliverReq = pSrc->bDeliverReq;
+       pDest->bKeepCopy = pSrc->bKeepCopy;
+
+       MSG_DEBUG("pDest->bDeliverReq = %d", pDest->bDeliverReq);
+       MSG_DEBUG("pDest->bKeepCopy = %d", pDest->bKeepCopy);
+
+       if (msgType.mainType == MSG_SMS_TYPE) {
+               pDest->option.smsSendOpt.bReplyPath = pSrc->option.smsSendOptInfo.bReplyPath;
+       } else if (msgType.mainType == MSG_MMS_TYPE) {
+               pDest->option.mmsSendOpt.priority = pSrc->option.mmsSendOptInfo.priority;
+               pDest->option.mmsSendOpt.bReadReq = pSrc->option.mmsSendOptInfo.bReadReq;
+               pDest->option.mmsSendOpt.expiryTime = pSrc->option.mmsSendOptInfo.expiryTime.time;
+               pDest->option.mmsSendOpt.deliveryTime = pSrc->option.mmsSendOptInfo.deliveryTime.time;
+
+               MSG_DEBUG("pDest->option.mmsSendOpt.priority = %d", pDest->option.mmsSendOpt.priority);
+               MSG_DEBUG("pDest->option.mmsSendOpt.bReadReq = %d", pDest->option.mmsSendOpt.bReadReq);
+               MSG_DEBUG("pDest->option.mmsSendOpt.expiryTime = %d", pDest->option.mmsSendOpt.expiryTime);
+       }
+
+       MSG_END();
+}
+
+
+int MsgHandle::getSettingCmdSize(MSG_OPTION_TYPE_T optionType)
+{
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
+
+       switch (optionType)
+       {
+               case MSG_GENERAL_OPT :
+                       cmdSize += sizeof(MSG_GENERAL_OPT_S);
+               break;
+               case MSG_SMS_SENDOPT :
+                       cmdSize += sizeof(MSG_SMS_SENDOPT_S);
+               break;
+               case MSG_SMSC_LIST :
+                       cmdSize += sizeof(MSG_SMSC_LIST_S);
+               break;
+               case MSG_MMS_SENDOPT :
+                       cmdSize += sizeof(MSG_MMS_SENDOPT_S);
+               break;
+               case MSG_MMS_RECVOPT :
+                       cmdSize += sizeof(MSG_MMS_RECVOPT_S);
+               break;
+               case MSG_MMS_STYLEOPT :
+                       cmdSize += sizeof(MSG_MMS_STYLEOPT_S);
+               break;
+               case MSG_PUSHMSG_OPT :
+                       cmdSize += sizeof(MSG_PUSHMSG_OPT_S);
+               break;
+               case MSG_CBMSG_OPT :
+                       cmdSize += sizeof(MSG_CBMSG_OPT_S);
+               break;
+               case MSG_VOICEMAIL_OPT :
+                       cmdSize += sizeof(MSG_VOICEMAIL_OPT_S);
+               break;
+               case MSG_MSGSIZE_OPT :
+                       cmdSize += sizeof(MSG_MSGSIZE_OPT_S);
+               break;
+       }
+
+       return cmdSize;
+}
diff --git a/proxy/MsgHandleSetting.cpp b/proxy/MsgHandleSetting.cpp
new file mode 100755 (executable)
index 0000000..14edb5c
--- /dev/null
@@ -0,0 +1,101 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgUtilFunction.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgHandle.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgHandle - Setting Member Functions
+==================================================================================================*/
+MSG_ERROR_T MsgHandle::setConfig(const MSG_SETTING_S *pSetting)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = getSettingCmdSize(pSetting->type);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_SET_CONFIG;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy(pCmd->cmdData, pSetting, cmdSize-sizeof(MSG_CMD_S));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_SET_CONFIG)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::getConfig(MSG_SETTING_S *pSetting)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_GET_CONFIG;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &(pSetting->type), sizeof(MSG_OPTION_TYPE_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_GET_CONFIG)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       if (pEvent->result == MSG_SUCCESS)
+               MsgDecodeSetting(pEvent->data, pSetting);
+
+       return pEvent->result;
+}
+
diff --git a/proxy/MsgHandleStorage.cpp b/proxy/MsgHandleStorage.cpp
new file mode 100755 (executable)
index 0000000..5af0dc8
--- /dev/null
@@ -0,0 +1,1192 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgUtilFunction.h"
+#include "MsgProxyListener.h"
+#include "MsgHandle.h"
+
+#include "MsgStorageHandler.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgHandle - Storage Member Functions
+==================================================================================================*/
+int MsgHandle::addMessage(const MSG_MESSAGE_S *pMsg, const MSG_SENDINGOPT_S *pSendOpt)
+{
+       MSG_MESSAGE_INFO_S msgInfo = {0};
+       MSG_SENDINGOPT_INFO_S sendOptInfo;
+
+       // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
+       convertMsgStruct(pMsg, &msgInfo);
+
+       // Covert MSG_SENDINGOPT_S to MSG_SENDINGOPT_INFO_S
+       convertSendOptStruct(pSendOpt, &sendOptInfo, pMsg->msgType);
+
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(MSG_SENDINGOPT_INFO_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_ADD_MSG;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msgInfo, sizeof(MSG_MESSAGE_INFO_S));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), &sendOptInfo, sizeof(MSG_SENDINGOPT_INFO_S));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_ADD_MSG)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       if (pEvent->result != MSG_SUCCESS) return pEvent->result;
+
+       MSG_MESSAGE_ID_T msgId = 0;
+
+       // Decode Return Data
+       MsgDecodeMsgId(pEvent->data, &msgId);
+
+       return (int)msgId;
+}
+
+
+MSG_ERROR_T MsgHandle::addSyncMLMessage(const MSG_SYNCML_MESSAGE_S *pSyncMLMsg)
+{
+       MSG_MESSAGE_INFO_S msgInfo;
+
+       // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
+       convertMsgStruct((MSG_MESSAGE_S*)pSyncMLMsg->msg, &msgInfo);
+
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + sizeof(int) + sizeof(MSG_MESSAGE_INFO_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_ADD_SYNCML_MSG;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &pSyncMLMsg->extId, sizeof(int));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), &pSyncMLMsg->pinCode, sizeof(int));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+sizeof(int)), &msgInfo, sizeof(MSG_MESSAGE_INFO_S));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_ADD_SYNCML_MSG)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::updateMessage(const MSG_MESSAGE_S *pMsg, const MSG_SENDINGOPT_S *pSendOpt)
+{
+       MSG_MESSAGE_INFO_S msgInfo;
+       MSG_SENDINGOPT_INFO_S sendOptInfo;
+
+       // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
+       convertMsgStruct(pMsg, &msgInfo);
+
+       if(pSendOpt != NULL)
+               convertSendOptStruct(pSendOpt, &sendOptInfo, pMsg->msgType);
+
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(MSG_SENDINGOPT_INFO_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_UPDATE_MSG;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msgInfo, sizeof(MSG_MESSAGE_INFO_S));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), &sendOptInfo, sizeof(MSG_SENDINGOPT_INFO_S));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_UPDATE_MSG)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::updateReadStatus(MSG_MESSAGE_ID_T MsgId, bool bRead)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T) + sizeof(bool);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_UPDATE_READ;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(MSG_MESSAGE_ID_T));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), &bRead, sizeof(bool));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_UPDATE_READ)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::updateProtectedStatus(MSG_MESSAGE_ID_T MsgId, bool bProtected)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T) + sizeof(bool);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_UPDATE_PROTECTED;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(MSG_MESSAGE_ID_T));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), &bProtected, sizeof(bool));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_UPDATE_PROTECTED)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::deleteMessage(MSG_MESSAGE_ID_T MsgId)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_DELETE_MSG;
+
+       // Copy Cookie
+       memcpy((void*)pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(MSG_MESSAGE_ID_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_DELETE_MSG)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::deleteAllMessagesInFolder(MSG_FOLDER_ID_T FolderId, bool bOnlyDB)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_ID_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_DELALL_MSGINFOLDER;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(MSG_FOLDER_ID_T));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_FOLDER_ID_T)), &bOnlyDB, sizeof(bool));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_DELALL_MSGINFOLDER)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::moveMessageToFolder(MSG_MESSAGE_ID_T MsgId, MSG_FOLDER_ID_T DestFolderId)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T) + sizeof(MSG_FOLDER_ID_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_MOVE_MSGTOFOLDER;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(MSG_MESSAGE_ID_T));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+sizeof(MSG_MESSAGE_ID_T)+MAX_COOKIE_LEN), &DestFolderId, sizeof(MSG_FOLDER_ID_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_MOVE_MSGTOFOLDER)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::moveMessageToStorage(MSG_MESSAGE_ID_T MsgId, MSG_STORAGE_ID_T DestStorageId)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T) + sizeof(MSG_STORAGE_ID_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_MOVE_MSGTOSTORAGE;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(MSG_MESSAGE_ID_T));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_ID_T)), &DestStorageId, sizeof(MSG_STORAGE_ID_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_MOVE_MSGTOSTORAGE)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::countMessage(MSG_FOLDER_ID_T FolderId, MSG_COUNT_INFO_S *pCountInfo)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_ID_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_COUNT_MSG;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(MSG_FOLDER_ID_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_COUNT_MSG)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       if(pEvent->result != MSG_SUCCESS) return pEvent->result;
+
+       // Decode Return Data
+       MsgDecodeCountInfo(pEvent->data, pCountInfo);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgHandle::countMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCount)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_TYPE_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_COUNT_BY_MSGTYPE;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsgType, sizeof(MSG_MESSAGE_TYPE_S));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_COUNT_BY_MSGTYPE)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       if(pEvent->result != MSG_SUCCESS) return pEvent->result;
+
+       // Decode Return Data
+       memcpy(pMsgCount, (void*)((char*)pEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(MSG_ERROR_T)), sizeof(int));
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgHandle::countMsgByContact(const MSG_THREAD_LIST_INDEX_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pMsgThreadCountList)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) +  sizeof(MSG_THREAD_LIST_INDEX_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_GET_CONTACT_COUNT;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pAddrInfo, sizeof(MSG_THREAD_LIST_INDEX_S));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_GET_CONTACT_COUNT)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       if(pEvent->result != MSG_SUCCESS) return pEvent->result;
+
+       // Decode Return Data
+       MsgDecodeContactCount(pEvent->data, pMsgThreadCountList);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgHandle::getMessage(MSG_MESSAGE_ID_T MsgId, MSG_MESSAGE_S *pMsg, MSG_SENDINGOPT_S *pSendOpt)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_GET_MSG;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(MSG_MESSAGE_ID_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_GET_MSG)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       if(pEvent->result != MSG_SUCCESS)
+               return pEvent->result;
+
+       // Decode Return Data
+       MSG_MESSAGE_INFO_S msgInfo;
+       MSG_SENDINGOPT_INFO_S sendOptInfo;
+       MsgDecodeMsgInfo(pEvent->data, &msgInfo, &sendOptInfo);
+
+       // Covert MSG_MESSAGE_INFO_S to MSG_MESSAGE_S
+       convertMsgStruct(&msgInfo, pMsg);
+
+       if(pSendOpt != NULL)
+               convertSendOptStruct(&sendOptInfo, pSendOpt, pMsg->msgType);
+
+       // Delete Temp File
+       if (msgInfo.bTextSms == false)
+       {
+               // Delete Temp File
+               MsgDeleteFile(msgInfo.msgData); //ipc
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgHandle::getFolderViewList(MSG_FOLDER_ID_T FolderId, const MSG_SORT_RULE_S *pSortRule, MSG_LIST_S *pMsgFolderViewList)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = MsgStoConnectDB();
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgStoConnectDB() Error!!");
+               return err;
+       }
+
+       err = MsgStoGetFolderViewList(FolderId, (MSG_SORT_RULE_S *)pSortRule, pMsgFolderViewList);
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgStoGetFolderViewList() Error!!");
+               return err;
+       }
+
+       MsgStoDisconnectDB();
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgHandle::addFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_INFO_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_ADD_FOLDER;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pFolderInfo, sizeof(MSG_FOLDER_INFO_S));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_ADD_FOLDER)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::updateFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_INFO_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_UPDATE_FOLDER;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pFolderInfo, sizeof(MSG_FOLDER_INFO_S));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_UPDATE_FOLDER)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;;
+}
+
+
+MSG_ERROR_T MsgHandle::deleteFolder(MSG_FOLDER_ID_T FolderId)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_ID_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_DELETE_FOLDER;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(MSG_FOLDER_ID_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_DELETE_FOLDER)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::getFolderList(MSG_FOLDER_LIST_S *pFolderList)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_GET_FOLDERLIST;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_GET_FOLDERLIST)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       if(pEvent->result != MSG_SUCCESS) return pEvent->result;
+
+       // Decode Return Data
+       MsgDecodeFolderList(pEvent->data, pFolderList);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgHandle::getThreadViewList(const MSG_SORT_RULE_S *pSortRule, MSG_THREAD_VIEW_LIST_S *pThreadViewList)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       err = MsgStoConnectDB();
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgStoConnectDB() Error!!");
+               return err;
+       }
+
+       err = MsgStoGetThreadViewList(pSortRule, pThreadViewList);
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgStoGetThreadViewList() Error!!");
+               return err;
+       }
+
+       MsgStoDisconnectDB();
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgHandle::getConversationViewList(MSG_THREAD_ID_T ThreadId, MSG_LIST_S *pConvViewList)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       MsgStoConnectDB();
+       err = MsgStoGetConversationViewList(ThreadId, pConvViewList);
+       MsgStoDisconnectDB();
+
+       if(err != MSG_SUCCESS)
+               return err;
+
+
+// Update Read Status for the Thead ID
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_THREAD_ID_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_UPDATE_THREAD_READ;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &ThreadId, sizeof(MSG_THREAD_ID_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_UPDATE_THREAD_READ)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       MSG_END();
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgHandle::deleteThreadMessageList(MSG_THREAD_ID_T ThreadId)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_THREAD_LIST_INDEX_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_DELETE_THREADMESSAGELIST;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &ThreadId, sizeof(MSG_THREAD_ID_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_DELETE_THREADMESSAGELIST)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       if(pEvent->result != MSG_SUCCESS) return pEvent->result;
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgHandle::getQuickPanelData(MSG_QUICKPANEL_TYPE_T Type, MSG_MESSAGE_S *pMsg)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_QUICKPANEL_TYPE_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_GET_QUICKPANEL_DATA;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &Type, sizeof(MSG_QUICKPANEL_TYPE_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_GET_QUICKPANEL_DATA)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       if(pEvent->result != MSG_SUCCESS) return pEvent->result;
+
+       // Decode Return Data
+       MSG_MESSAGE_INFO_S msgInfo;
+
+       memcpy(&msgInfo, (void*)((char*)pEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(MSG_ERROR_T)), sizeof(MSG_MESSAGE_INFO_S));
+
+       // Covert MSG_MESSAGE_INFO_S to MSG_MESSAGE_S
+       convertMsgStruct(&msgInfo, pMsg);
+
+       // Delete Temp File
+       if (msgInfo.bTextSms == false)
+       {
+               // Delete Temp File
+               MsgDeleteFile(msgInfo.msgData); //ipc
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgHandle::resetDatabase()
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_RESET_DB;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_RESET_DB)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::getMemSize(unsigned int* memsize)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_GET_MEMSIZE;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_GET_MEMSIZE)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       if(pEvent->result != MSG_SUCCESS) return pEvent->result;
+
+       // Decode Return Data
+       MsgDecodeMemSize(pEvent->data, memsize);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgHandle::searchMessage(const char *pSearchString, MSG_THREAD_VIEW_LIST_S *pThreadViewList)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       err = MsgStoConnectDB();
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgStoConnectDB() Error!!");
+               return err;
+       }
+
+       err = MsgStoSearchMessage(pSearchString, pThreadViewList);
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgStoSearchMessage() Error!!");
+               return err;
+       }
+
+       MsgStoDisconnectDB();
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgHandle::searchMessage(const MSG_SEARCH_CONDITION_S *pSearchCon, int offset, int limit, MSG_LIST_S *pMsgList)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       err = MsgStoConnectDB();
+
+       if (err != MSG_SUCCESS) {
+               MSG_DEBUG("MsgStoConnectDB() Error!!");
+               return err;
+       }
+
+       err = MsgStoSearchMessage(pSearchCon, offset, limit, pMsgList);
+
+       if (err != MSG_SUCCESS) {
+               MSG_DEBUG("MsgStoSearchMessage() Error!!");
+               return err;
+       }
+
+       MsgStoDisconnectDB();
+
+       return err;
+}
+
+
+
+MSG_ERROR_T MsgHandle::getMsgIdList(MSG_REFERENCE_ID_T RefId, MSG_MSGID_LIST_S *pMsgIdList)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       err = MsgStoConnectDB();
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgStoConnectDB() Error!!");
+               return err;
+       }
+
+       err = MsgStoGetMsgIdList(RefId, pMsgIdList);
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgStoSearchMessage() Error!!");
+               return err;
+       }
+
+       MsgStoDisconnectDB();
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgHandle::getRejectMsgList(const char *pNumber, MSG_REJECT_MSG_LIST_S *pRejectMsgList)
+{
+       MSG_ERROR_T err =  MSG_SUCCESS;
+
+       err = MsgStoConnectDB();
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgStoConnectDB() Error!!");
+               return err;
+       }
+
+       err = MsgStoGetRejectMsgList(pNumber, pRejectMsgList);
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgStoGetRejectMsgList() Error!!");
+               return err;
+       }
+
+       MsgStoDisconnectDB();
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgHandle::regStorageChangeCallback(msg_storage_change_cb onStorageChange, void *pUserParam)
+{
+       if (!onStorageChange)
+               THROW(MsgException::INVALID_PARAM, "onStorageChange is null");
+
+       MsgProxyListener* eventListener = MsgProxyListener::instance();
+
+       eventListener->start();
+
+       if (eventListener->regStorageChangeEventCB(this, onStorageChange, pUserParam) == false) // callback was already registered, just return SUCCESS
+               return MSG_SUCCESS;
+
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); // cmd type, listenerFd
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_REG_STORAGE_CHANGE_CB;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       int listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+
+       MSG_DEBUG("remote fd %d", listenerFd);
+
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &listenerFd, sizeof(listenerFd));
+
+       MSG_DEBUG("reg status [%d : %s], %d", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType), listenerFd);
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_REG_STORAGE_CHANGE_CB)
+       {
+               THROW(MsgException::INVALID_PARAM, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::getReportStatus(MSG_MESSAGE_ID_T msg_id, MSG_REPORT_STATUS_INFO_S *pReport_status)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_GET_REPORT_STATUS;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msg_id, sizeof(MSG_MESSAGE_ID_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_GET_REPORT_STATUS)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       if(pEvent->result != MSG_SUCCESS) return pEvent->result;
+
+       // Decode Return Data
+       MsgDecodeReportStatus(pEvent->data, pReport_status);
+
+       return MSG_SUCCESS;
+}
diff --git a/proxy/MsgHandleTransport.cpp b/proxy/MsgHandleTransport.cpp
new file mode 100755 (executable)
index 0000000..03ca13f
--- /dev/null
@@ -0,0 +1,541 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <time.h>
+#include <errno.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgProxyListener.h"
+#include "MsgHandle.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgHandle - Transport Member Functions
+==================================================================================================*/
+MSG_ERROR_T MsgHandle::submitReq(MSG_REQUEST_S* pReq)
+{
+       MSG_BEGIN();
+
+       if (pReq == NULL)
+               THROW(MsgException::INVALID_PARAM, "pReq is NULL");
+
+       MSG_REQUEST_INFO_S reqInfo = {0};
+       char trId[MMS_TR_ID_LEN+1] = {0};
+
+       MSG_MESSAGE_S *reqmsg = (MSG_MESSAGE_S*) pReq->msg;
+
+       if (reqmsg->msgType.subType != MSG_SENDREQ_JAVA_MMS) {
+               // In case MMS read report, get address value later.
+               if(reqmsg->msgType.subType != MSG_READREPLY_MMS) {
+                       if ((reqmsg->nAddressCnt == 0) || (reqmsg->nAddressCnt > MAX_TO_ADDRESS_CNT)) {
+                               MSG_DEBUG("Recipient address count error [%d]", reqmsg->nAddressCnt );
+                               return MSG_ERR_INVALID_MESSAGE;
+                       }
+               }
+
+               /* Begin: Setting default values for submit request */
+       //      pReq->msg.msgId = 0;    // Set Request ID: internal use
+       //      pReq->msg.folderId = MSG_OUTBOX_ID;     // Set Folder ID
+               if (reqmsg->msgType.subType == MSG_RETRIEVE_MMS) {
+                       reqmsg->networkStatus = MSG_NETWORK_RETRIEVING;
+               } else {
+                       reqmsg->networkStatus = MSG_NETWORK_SENDING;
+               }
+
+               reqmsg->bRead = false;
+               reqmsg->bProtected = false;
+               reqmsg->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+               reqmsg->direction = MSG_DIRECTION_TYPE_MO;
+               reqmsg->storageId = MSG_STORAGE_PHONE;
+
+               time_t curTime = time(NULL);
+
+               if (curTime < 0)
+                       THROW(MsgException::INVALID_RESULT, "time error : %s", strerror(errno));
+
+               reqmsg->displayTime = curTime;
+               /* End : Setting default values for submit request */
+       } else {
+               //in case of JAVA MMS msg, parse mms transaction id from pMmsData
+               reqmsg->networkStatus = MSG_NETWORK_SENDING;
+               strncpy(trId, (char*)reqmsg->pMmsData+3,MMS_TR_ID_LEN);
+               MSG_DEBUG("JavaMMS transaction Id:%s ",trId);
+       }
+
+       // Convert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
+       convertMsgStruct(reqmsg, &(reqInfo.msgInfo));
+
+       convertSendOptStruct(&(pReq->sendOpt), &(reqInfo.sendOptInfo), reqmsg->msgType);
+
+       reqInfo.reqId = 0;
+
+       /* Register proxy info used for receiving sent status */
+       MSG_PROXY_INFO_S chInfo = {0};
+
+       chInfo.listenerFd = MsgProxyListener::instance()->getRemoteFd();
+
+       chInfo.handleAddr = (unsigned int) this;
+
+       /* Allocate Memory to Command Data */
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_REQUEST_INFO_S) + sizeof(MSG_PROXY_INFO_S);
+
+       // In case of JAVA MMS msg, add trId
+       if (reqmsg->msgType.subType == MSG_SENDREQ_JAVA_MMS)
+               cmdSize += sizeof(trId);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_SUBMIT_REQ;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &reqInfo, sizeof(MSG_REQUEST_INFO_S));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_REQUEST_INFO_S)), &chInfo, sizeof(MSG_PROXY_INFO_S));
+
+       // In case of JAVA MMS msg, add trId
+       if (reqmsg->msgType.subType == MSG_SENDREQ_JAVA_MMS)
+               memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_REQUEST_INFO_S)+sizeof(MSG_PROXY_INFO_S)), &trId, sizeof(trId));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*) pEventData;
+
+       int* pReqId = (int*) pEvent->data;
+       pReq->reqId = *pReqId;
+       MSG_DEBUG("SENT_REQ_ID: %d", pReq->reqId);
+
+       if (pEvent->eventType != MSG_EVENT_SUBMIT_REQ)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       MSG_END();
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::cancelReq(MSG_REQUEST_ID_T reqId)
+{
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_REQUEST_ID_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_CANCEL_REQ;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &reqId, sizeof(MSG_REQUEST_ID_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_CANCEL_REQ)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::regSentStatusCallback(msg_sent_status_cb onStatusChanged, void *pUserParam)
+{
+       if (!onStatusChanged)
+               THROW(MsgException::INVALID_PARAM, "onStatusChanged is null");
+
+       MsgProxyListener* eventListener = MsgProxyListener::instance();
+
+       eventListener->start();
+
+       if (eventListener->regSentStatusEventCB(this, onStatusChanged, pUserParam) == false) // callback was already registered, just return SUCCESS
+               return MSG_SUCCESS;
+
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); // cmd type, listenerFd
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_REG_SENT_STATUS_CB;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       int listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+
+       MSG_DEBUG("remote fd %d", listenerFd);
+
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &listenerFd, sizeof(listenerFd));
+
+       MSG_DEBUG("reg status [%d : %s], %d", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType), listenerFd);
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_REG_SENT_STATUS_CB)
+       {
+               THROW(MsgException::INVALID_PARAM, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::regSmsMessageCallback(msg_sms_incoming_cb onMsgIncoming, unsigned short port, void *pUserParam)
+{
+       if( (!onMsgIncoming) )
+               THROW(MsgException::INVALID_PARAM, "Param %p", onMsgIncoming);
+
+       MsgProxyListener* eventListener = MsgProxyListener::instance();
+
+       eventListener->start();
+
+       if (eventListener->regMessageIncomingEventCB(this, onMsgIncoming, port, pUserParam) == false) // callback was already registered, just return SUCCESS
+               return MSG_SUCCESS;
+
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_MSG_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_REG_INCOMING_MSG_CB;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       MSG_CMD_REG_INCOMING_MSG_CB_S cmdParam = {0};
+
+       cmdParam.listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       cmdParam.msgType = MSG_SMS_TYPE;
+       cmdParam.port = port;
+
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &cmdParam, sizeof(cmdParam));
+
+       MSG_DEBUG("reg new msg [%s], fd %d, port %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd, cmdParam.port);
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_MSG_CB)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::regMmsConfMessageCallback(msg_mms_conf_msg_incoming_cb onMMSConfMsgIncoming, const char *pAppId, void *pUserParam)
+{
+       if( (!onMMSConfMsgIncoming) )
+               THROW(MsgException::INVALID_PARAM, "Param %p", onMMSConfMsgIncoming);
+
+       MsgProxyListener* eventListener = MsgProxyListener::instance();
+
+       eventListener->start();
+
+       if (eventListener->regMMSConfMessageIncomingEventCB(this, onMMSConfMsgIncoming, pAppId, pUserParam) == false) // callback was already registered, just return SUCCESS
+               return MSG_SUCCESS;
+
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S cmdParam = {0};
+
+       cmdParam.listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       cmdParam.msgType = MSG_MMS_TYPE;
+
+       if (pAppId)
+               strncpy(cmdParam.appId, pAppId, MAX_MMS_JAVA_APPID_LEN);
+
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &cmdParam, sizeof(cmdParam));
+
+       MSG_DEBUG("reg new msg [%s], fd:%d, appId:%s", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd,  (pAppId)? cmdParam.appId:"NULL" );
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::regSyncMLMessageCallback(msg_syncml_msg_incoming_cb onSyncMLMsgIncoming, void *pUserParam)
+{
+       if( (!onSyncMLMsgIncoming) )
+               THROW(MsgException::INVALID_PARAM, "Param %p", onSyncMLMsgIncoming);
+
+       MsgProxyListener* eventListener = MsgProxyListener::instance();
+
+       eventListener->start();
+
+       if (eventListener->regSyncMLMessageIncomingEventCB(this, onSyncMLMsgIncoming, pUserParam) == false) // callback was already registered, just return SUCCESS
+               return MSG_SUCCESS;
+
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_REG_INCOMING_SYNCML_MSG_CB;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S cmdParam = {0};
+
+       cmdParam.listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       cmdParam.msgType = MSG_SMS_TYPE;
+
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &cmdParam, sizeof(cmdParam));
+
+       MSG_DEBUG("reg new msg [%s], fd %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd);
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::regLBSMessageCallback(msg_lbs_msg_incoming_cb onLBSMsgIncoming, void *pUserParam)
+{
+       if( (!onLBSMsgIncoming) )
+               THROW(MsgException::INVALID_PARAM, "Param %p", onLBSMsgIncoming);
+
+       MsgProxyListener* eventListener = MsgProxyListener::instance();
+
+       eventListener->start();
+
+       if (eventListener->regLBSMessageIncomingEventCB(this, onLBSMsgIncoming, pUserParam) == false) // callback was already registered, just return SUCCESS
+               return MSG_SUCCESS;
+
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_LBS_MSG_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_REG_INCOMING_LBS_MSG_CB;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       MSG_CMD_REG_INCOMING_LBS_MSG_CB_S cmdParam = {0};
+
+       cmdParam.listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       cmdParam.msgType = MSG_SMS_TYPE;
+
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &cmdParam, sizeof(cmdParam));
+
+       MSG_DEBUG("reg new msg [%s], fd %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd);
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_LBS_MSG_CB)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::regSyncMLMessageOperationCallback(msg_syncml_msg_operation_cb onSyncMLMsgOperation, void *pUserParam)
+{
+       if( (!onSyncMLMsgOperation) )
+               THROW(MsgException::INVALID_PARAM, "Param %p", onSyncMLMsgOperation);
+
+       MsgProxyListener* eventListener = MsgProxyListener::instance();
+
+       eventListener->start();
+
+       if (eventListener->regSyncMLMessageOperationEventCB(this, onSyncMLMsgOperation, pUserParam) == false) // callback was already registered, just return SUCCESS
+               return MSG_SUCCESS;
+
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_REG_SYNCML_MSG_OPERATION_CB;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S cmdParam = {0};
+
+       cmdParam.listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       cmdParam.msgType = MSG_SMS_TYPE;
+
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &cmdParam, sizeof(cmdParam));
+
+       MSG_DEBUG("register syncML msg operation callback [%s], fd %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd);
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
+
+MSG_ERROR_T MsgHandle::operateSyncMLMessage(MSG_MESSAGE_ID_T msgId)
+{
+       if( msgId < 1)
+               THROW(MsgException::INVALID_PARAM, "Param msgId %d", msgId);
+
+       // Allocate Memory to Command Data
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_SYNCML_OPERATION;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // Copy Command Data
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msgId, sizeof(MSG_MESSAGE_ID_T));
+
+       // Send Command to Messaging FW
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent->eventType != MSG_EVENT_SYNCML_OPERATION)
+       {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
+
diff --git a/proxy/MsgProxyListener.cpp b/proxy/MsgProxyListener.cpp
new file mode 100755 (executable)
index 0000000..5293dc6
--- /dev/null
@@ -0,0 +1,752 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <errno.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgUtilFile.h"
+#include "MsgProxyListener.h"
+
+
+gboolean readSocket(GIOChannel *source, GIOCondition condition, gpointer data)
+{
+       MSG_BEGIN();
+
+       if (G_IO_ERR & condition)
+       {
+               MSG_DEBUG("IO Error!!! [%d]", condition);
+
+               MsgProxyListener::instance()->stop();
+               return FALSE;
+       }
+
+       if (G_IO_HUP & condition)
+       {
+               MSG_DEBUG("socket fd Error!!! [%d]", condition);
+
+               MsgProxyListener::instance()->stop();
+               return FALSE;
+       }
+
+       if (G_IO_NVAL & condition)
+       {
+               MSG_DEBUG("Invaild socket Error!!! [%d]", condition);
+
+               MsgProxyListener::instance()->stop();
+               return FALSE;
+       }
+
+       char* buf = NULL;
+       int len;
+
+       int n = MsgProxyListener::instance()->readFromSocket(&buf, &len);
+
+       if (n > 0)
+       {
+               MSG_DEBUG(">>Receiving %d bytes", n);
+               MsgProxyListener::instance()->handleEvent((MSG_EVENT_S*)buf);
+       }
+       else if (n == 0)
+       {
+               MSG_DEBUG("Server closed connection");
+               MsgProxyListener::instance()->stop();
+               return FALSE;
+       }
+       else // dataSize < 0
+       {
+               MSG_DEBUG("Data is not for Listener");
+       }
+
+       if (buf)
+       {
+               delete [] buf;
+               buf = NULL;
+       }
+
+       MSG_END();
+
+       return TRUE;
+}
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgListenerThread - Member Functions
+==================================================================================================*/
+MsgProxyListener* MsgProxyListener::pInstance = NULL;
+
+
+MsgProxyListener::MsgProxyListener() : running(0)
+{
+       sentStatusCBList.clear();
+       newMessageCBList.clear();
+       newMMSConfMessageCBList.clear();
+       newSyncMLMessageCBList.clear();
+       newLBSMessageCBList.clear();
+}
+
+
+MsgProxyListener::~MsgProxyListener()
+{
+       sentStatusCBList.clear();
+       newMessageCBList.clear();
+       newMMSConfMessageCBList.clear();
+       newSyncMLMessageCBList.clear();
+       newLBSMessageCBList.clear();
+}
+
+
+MsgProxyListener* MsgProxyListener::instance()
+{
+       static Mutex mm;
+       MutexLocker lock(mm);
+
+       if (!pInstance)
+               pInstance = new MsgProxyListener();
+
+       return pInstance;
+}
+
+
+void MsgProxyListener::start()
+{
+       if (running == 0)
+       {
+               mx.lock();
+               cliSock.connect(MSG_SOCKET_PATH);
+               cv.signal(); // wake up the waiting thread
+               mx.unlock();
+
+               int fd = cliSock.fd();
+
+               MSG_DEBUG("Socket Fd : %d", fd);
+
+               channel = g_io_channel_unix_new(fd); // initializes ref_count = 1
+
+               eventSourceId = g_io_add_watch(channel, (GIOCondition)(G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL), &readSocket, NULL); // increments ref_count =2
+
+               MSG_DEBUG("Call g_io_add_watch() : %d", eventSourceId);
+       }
+
+       running++;
+       MSG_DEBUG("add Listener and [%d] are running.", running);
+}
+
+
+void MsgProxyListener::stop()
+{
+       MSG_BEGIN();
+
+       if (running > 1)
+       {
+               running--;
+               MSG_DEBUG("There are still running Listener. [%d] left.", running);
+       }
+       else if (running == 1)
+       {
+               MutexLocker lock(mx);
+
+               running--;
+
+               g_io_channel_unref(channel); // decrements ref_count = 1
+
+               g_source_remove(eventSourceId);
+
+               cliSock.close();
+
+               MSG_DEBUG("client Listener is terminated.");
+       }
+
+       MSG_END();
+}
+
+
+bool MsgProxyListener::regSentStatusEventCB(MsgHandle* pMsgHandle, msg_sent_status_cb pfSentStatus, void *pUserParam)
+{
+       MutexLocker lock(mx);
+
+       std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
+
+       for (; it != sentStatusCBList.end(); it++)
+       {
+               if (it->hAddr == pMsgHandle && it->pfSentStatusCB == pfSentStatus)
+               {
+                       MSG_DEBUG("msg_sent_status_cb() callback : [%p] is already registered!!!", pfSentStatus);
+
+                       it->userParam = pUserParam;
+
+                       return false;
+               }
+       }
+
+       MSG_SENT_STATUS_CB_ITEM_S sentStatusCB = {pMsgHandle, pfSentStatus, pUserParam};
+
+       sentStatusCBList.push_back(sentStatusCB);
+
+       return true;
+}
+
+
+bool MsgProxyListener::regMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_sms_incoming_cb pfNewMessage, int port, void *pUserParam)
+{
+       MutexLocker lock(mx);
+
+       std::list<MSG_INCOMING_CB_ITEM_S>::iterator it = newMessageCBList.begin();
+
+       for (; it != newMessageCBList.end(); it++)
+       {
+               if (it->port == port && it->pfIncomingCB == pfNewMessage)
+               {
+                       MSG_DEBUG("msg_sms_incoming_cb() callback : Port Number [%d] is already registered!!!", port);
+
+                       it->userParam = pUserParam;
+
+                       return false;
+               }
+       }
+
+       MSG_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewMessage, port, pUserParam};
+
+       newMessageCBList.push_back(incomingCB);
+
+       return true;
+}
+
+
+bool MsgProxyListener::regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_mms_conf_msg_incoming_cb pfNewMMSConfMessage, const char *pAppId, void *pUserParam)
+{
+       MutexLocker lock(mx);
+
+       std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it = newMMSConfMessageCBList.begin();
+
+       for (; it != newMMSConfMessageCBList.end(); it++)
+       {
+               if (it->pfMMSConfIncomingCB == pfNewMMSConfMessage)
+               {
+
+                       if(pAppId == NULL)
+                       {
+                               MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback is already registered!!!");
+
+                               return false;
+                       }
+                       else if(!strncmp(it->appId, pAppId, MAX_MMS_JAVA_APPID_LEN))
+                       {
+                               MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback : AppId [%s] is already registered!!!", pAppId);
+
+                               it->userParam = pUserParam;
+
+                               return false;
+                       }
+               }
+       }
+
+       MSG_MMS_CONF_INCOMING_CB_ITEM_S incomingConfCB = {pMsgHandle, pfNewMMSConfMessage, {0}, pUserParam};
+
+       if (pAppId != NULL)
+               strncpy(incomingConfCB.appId, pAppId, MAX_MMS_JAVA_APPID_LEN);
+
+       newMMSConfMessageCBList.push_back(incomingConfCB);
+
+       return true;
+}
+
+
+bool MsgProxyListener::regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_incoming_cb pfNewSyncMLMessage, void *pUserParam)
+{
+       MutexLocker lock(mx);
+
+       std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it = newSyncMLMessageCBList.begin();
+
+       for (; it != newSyncMLMessageCBList.end(); it++)
+       {
+               if (it->pfSyncMLIncomingCB == pfNewSyncMLMessage)
+               {
+                       MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewSyncMLMessage);
+
+                       it->userParam = pUserParam;
+
+                       return false;
+               }
+       }
+
+       MSG_SYNCML_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewSyncMLMessage, pUserParam};
+
+       newSyncMLMessageCBList.push_back(incomingCB);
+
+       return true;
+}
+
+
+bool MsgProxyListener::regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_lbs_msg_incoming_cb pfNewLBSMsgIncoming, void *pUserParam)
+{
+       MutexLocker lock(mx);
+
+       std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it = newLBSMessageCBList.begin();
+
+       for (; it != newLBSMessageCBList.end(); it++)
+       {
+               if (it->pfLBSMsgIncoming == pfNewLBSMsgIncoming)
+               {
+                       MSG_DEBUG("msg_lbs_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewLBSMsgIncoming);
+
+                       it->userParam = pUserParam;
+
+                       return false;
+               }
+       }
+
+       MSG_LBS_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewLBSMsgIncoming, pUserParam};
+
+       newLBSMessageCBList.push_back(incomingCB);
+
+       return true;
+}
+
+
+bool MsgProxyListener::regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_operation_cb pfSyncMLMessageOperation, void *pUserParam)
+{
+       MutexLocker lock(mx);
+
+       std::list<MSG_SYNCML_OPERATION_CB_ITEM_S>::iterator it = operationSyncMLMessageCBList.begin();
+
+       for (; it != operationSyncMLMessageCBList.end(); it++)
+       {
+               if (it->pfSyncMLOperationCB == pfSyncMLMessageOperation)
+               {
+                       MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfSyncMLMessageOperation);
+
+                       it->userParam = pUserParam;
+
+                       return false;
+               }
+       }
+
+       MSG_SYNCML_OPERATION_CB_ITEM_S incomingCB = {pMsgHandle, pfSyncMLMessageOperation, pUserParam};
+
+       operationSyncMLMessageCBList.push_back(incomingCB);
+
+       return true;
+}
+
+
+bool MsgProxyListener::regStorageChangeEventCB(MsgHandle* pMsgHandle, msg_storage_change_cb pfStorageChangeOperation, void *pUserParam)
+{
+       MutexLocker lock(mx);
+
+       std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it = storageChangeCBList.begin();
+
+       for (; it != storageChangeCBList.end(); it++)
+       {
+               if (it->pfStorageChangeCB == pfStorageChangeOperation)
+               {
+                       MSG_DEBUG("msg_storage_change_cb() callback : [%p] is already registered!!!", pfStorageChangeOperation);
+
+                       it->userParam = pUserParam;
+
+                       return false;
+               }
+       }
+
+       MSG_STORAGE_CHANGE_CB_ITEM_S changeCB = {pMsgHandle, pfStorageChangeOperation, pUserParam};
+
+       storageChangeCBList.push_back(changeCB);
+
+       return true;
+}
+
+
+void MsgProxyListener::clearListOfClosedHandle(MsgHandle* pMsgHandle)
+{
+       MSG_BEGIN();
+
+       // sent status CB list
+       std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
+
+       for (; it != sentStatusCBList.end(); it++)
+       {
+               if (it->hAddr == pMsgHandle)
+               {
+                       sentStatusCBList.erase(it);
+                       it = sentStatusCBList.begin();
+
+                       //Stop client Listener
+                       stop();
+               }
+       }
+
+       // new message CB list
+       std::list<MSG_INCOMING_CB_ITEM_S>::iterator it2 = newMessageCBList.begin();
+
+       for (; it2 != newMessageCBList.end(); it2++)
+       {
+               if (it2->hAddr == pMsgHandle)
+               {
+                       newMessageCBList.erase(it2);
+                       it2 = newMessageCBList.begin();
+
+                       //Stop client Listener
+                       stop();
+               }
+       }
+
+       // MMS conf Message CB list
+       std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it3 = newMMSConfMessageCBList.begin();
+
+       for (; it3 != newMMSConfMessageCBList.end(); it3++)
+       {
+               if (it3->hAddr == pMsgHandle)
+               {
+                       newMMSConfMessageCBList.erase(it3);
+                       it3 = newMMSConfMessageCBList.begin();
+
+                       //Stop client Listener
+                       stop();
+               }
+       }
+
+       // SyncML Message CB list
+       std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it4 = newSyncMLMessageCBList.begin();
+
+       for (; it4 != newSyncMLMessageCBList.end(); it4++)
+       {
+               if (it4->hAddr == pMsgHandle)
+               {
+                       newSyncMLMessageCBList.erase(it4);
+                       it4 = newSyncMLMessageCBList.begin();
+
+                       //Stop client Listener
+                       stop();
+               }
+       }
+
+       // LBS Message CB list
+       std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it5 = newLBSMessageCBList.begin();
+
+       for (; it5 != newLBSMessageCBList.end(); it5++)
+       {
+               if (it5->hAddr == pMsgHandle)
+               {
+                       newLBSMessageCBList.erase(it5);
+                       it5 = newLBSMessageCBList.begin();
+
+                       //Stop client Listener
+                       stop();
+               }
+       }
+
+       // Storage change Message CB list
+       std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it6 = storageChangeCBList.begin();
+
+       for (; it6 != storageChangeCBList.end(); it6++)
+       {
+               if (it6->hAddr == pMsgHandle)
+               {
+                       storageChangeCBList.erase(it6);
+                       it6 = storageChangeCBList.begin();
+
+                       //Stop client Listener
+                       stop();
+               }
+       }
+
+       MSG_END();
+}
+
+void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
+{
+       MSG_BEGIN();
+
+       if (!pMsgEvent)
+               THROW(MsgException::INVALID_PARAM, "pMsgEvent is NULL");
+
+       if (pMsgEvent->eventType == MSG_EVENT_PLG_SENT_STATUS_CNF)
+       {
+               unsigned int chInfo[3] = {0}; //3// reqid, status, object
+
+//             unsigned int* pChInfo = (unsigned int*) pMsgEvent->data;
+
+               memcpy(&chInfo, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(MSG_ERROR_T)), sizeof(chInfo));
+
+               //      [0] = pStatus->reqId;   [1] = pStatus->status;  [2] = chInfo.handleAddr;
+               MSG_SENT_STATUS_S status = {(MSG_REQUEST_ID_T)chInfo[0], (MSG_NETWORK_STATUS_T)chInfo[1]};
+
+               mx.lock();
+
+               MsgSentStatusCBList::iterator it = sentStatusCBList.begin();
+
+               for( ; it != sentStatusCBList.end() ; it++)
+               {
+                       MsgHandle* pHandle = it->hAddr;
+
+                       msg_sent_status_cb pfunc = it->pfSentStatusCB;
+
+                       void* param = it->userParam;
+
+                       pfunc((MSG_HANDLE_T)pHandle, &status, param);
+               }
+
+               mx.unlock();
+       }
+       else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MSG_IND )
+       {
+               MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
+               int portKey = (pMsgInfo->msgPort.valid)? pMsgInfo->msgPort.dstPort: 0;
+
+               mx.lock();
+
+               MsgNewMessageCBList::iterator it = newMessageCBList.begin();
+               MsgNewMessageCBList matchList;
+
+               for( ; it != newMessageCBList.end() ; it++)
+               {
+                       if( portKey == it->port)
+                       {
+                               matchList.push_back(*it);
+                       }
+               }
+
+               mx.unlock();
+
+               it = matchList.begin();
+
+               for( ; it != matchList.end(); it++ )
+               {
+                       MsgHandle* pHandle = it->hAddr;
+
+                       MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
+                       MSG_MESSAGE_S msg = {0};
+
+                       msg.pData = NULL;
+                       msg.pMmsData = NULL;
+
+                       pHandle->convertMsgStruct(pMsgInfo, &msg);
+
+                       msg_sms_incoming_cb pfunc = it->pfIncomingCB;
+
+                       void* param = it->userParam;
+
+                       pfunc((MSG_HANDLE_T)pHandle, (msg_message_t) &msg, param);
+
+                       delete [] (char*)msg.pData;
+                       if (msg.pMmsData != NULL)
+                               delete [] (char*)msg.pMmsData;
+               }
+
+       }
+       else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MMS_CONF )
+       {
+               MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
+               MMS_RECV_DATA_S* pMmsRecvData = ( MMS_RECV_DATA_S*)pMsgInfo->msgData;
+
+               char* appIdKey = (pMmsRecvData->msgAppId.valid)? pMmsRecvData->msgAppId.appId: NULL;
+
+               mx.lock();
+
+               MsgNewMMSConfMessageCBList::iterator it = newMMSConfMessageCBList.begin();
+               MsgNewMMSConfMessageCBList matchList;
+
+               for( ; it != newMMSConfMessageCBList.end() ; it++)
+               {
+                       if(appIdKey)
+                       {
+                               if(!strcmp(appIdKey, it->appId))
+                                       matchList.push_back(*it);
+                       }
+                       else//(appIdKey == NULL && it->appId[0] == 0)
+                       {
+                               if(it->appId[0] == 0)
+                                       matchList.push_back(*it);
+                       }
+               }
+
+               mx.unlock();
+
+               // Contents of msgData removed and replaced to retrievedFilePath for convertMsgStruct
+               // it is moved from UpdateMessage in MmsPluginStorage.cpp
+               char tempFileName[MSG_FILENAME_LEN_MAX+1] = {0};  // check MSG_FILENAME_LEN_MAX
+
+               strncpy(tempFileName, pMmsRecvData->retrievedFilePath, MSG_FILENAME_LEN_MAX);
+
+               memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN+1);
+               memcpy(pMsgInfo->msgData, tempFileName + strlen(MSG_DATA_PATH), strlen(tempFileName));
+
+               it = matchList.begin();
+
+               for( ; it != matchList.end() ; it++)
+               {
+                       MsgHandle* pHandle = it->hAddr;
+
+                       MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
+                       MSG_MESSAGE_S msg = {0};
+
+                       msg.pData = NULL;
+                       msg.pMmsData = NULL;
+
+                       pHandle->convertMsgStruct(pMsgInfo, &msg);
+
+                       msg_mms_conf_msg_incoming_cb pfunc = it->pfMMSConfIncomingCB;
+
+                       void* param = it->userParam;
+
+                       pfunc((MSG_HANDLE_T)pHandle, (msg_message_t) &msg, param);
+
+                       delete [] (char*)msg.pData;
+                       if (msg.pMmsData != NULL)
+                               delete [] (char*)msg.pMmsData;
+
+                       // Here the retrieved message will be deleted from native storage.
+                       // as of now, msg which have appId is considered as JAVA MMS message and it will be sent and handled in JAVA app.
+                       if(appIdKey)
+                       {
+                               MSG_DEBUG("delete received JAVA MMS message:%s from native storage",tempFileName);
+                               pHandle->deleteMessage(pMsgInfo->msgId);
+                       }
+               }
+       }
+       else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND )
+       {
+               MSG_SYNCML_MESSAGE_DATA_S* pSyncMLData = (MSG_SYNCML_MESSAGE_DATA_S *)pMsgEvent->data;
+
+               MSG_DEBUG("msgType [%d]", pSyncMLData->syncmlType);
+
+               mx.lock();
+
+               MsgNewSyncMLMessageCBList::iterator it = newSyncMLMessageCBList.begin();
+
+               for( ; it != newSyncMLMessageCBList.end() ; it++)
+               {
+                       MsgHandle* pHandle = it->hAddr;
+
+                       msg_syncml_msg_incoming_cb pfunc = it->pfSyncMLIncomingCB;
+
+                       void* param = it->userParam;
+
+                       pfunc((MSG_HANDLE_T)pHandle, pSyncMLData->syncmlType, pSyncMLData->pushBody, pSyncMLData->pushBodyLen, pSyncMLData->wspHeader, pSyncMLData->wspHeaderLen, param);
+               }
+
+               mx.unlock();
+       }
+       else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_LBS_MSG_IND )
+       {
+               MSG_LBS_MESSAGE_DATA_S* pLBSData = (MSG_LBS_MESSAGE_DATA_S *)pMsgEvent->data;
+
+               mx.lock();
+
+               MsgNewLBSMessageCBList::iterator it = newLBSMessageCBList.begin();
+
+               for( ; it != newLBSMessageCBList.end() ; it++)
+               {
+                       MsgHandle* pHandle = it->hAddr;
+
+                       msg_lbs_msg_incoming_cb pfunc = it->pfLBSMsgIncoming;
+
+                       void* param = it->userParam;
+
+                       pfunc((MSG_HANDLE_T)pHandle, pLBSData->pushHeader, pLBSData->pushBody, pLBSData->pushBodyLen, param);
+               }
+
+               mx.unlock();
+       }
+       else if ( pMsgEvent->eventType == MSG_EVENT_SYNCML_OPERATION )
+       {
+               int msgId;
+               int extId;
+
+               memcpy(&msgId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(MSG_ERROR_T)), sizeof(int));
+               memcpy(&extId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(MSG_ERROR_T)+sizeof(int)), sizeof(int));
+
+               MSG_DEBUG("msgId [%d]", msgId);
+               MSG_DEBUG("extId [%d]", extId);
+
+               mx.lock();
+
+               MsgOperationSyncMLMessageCBList::iterator it = operationSyncMLMessageCBList.begin();
+
+               for( ; it != operationSyncMLMessageCBList.end() ; it++)
+               {
+                       MsgHandle* pHandle = it->hAddr;
+
+                       msg_syncml_msg_operation_cb pfunc = it->pfSyncMLOperationCB;
+
+                       void* param = it->userParam;
+
+                       pfunc((MSG_HANDLE_T)pHandle, msgId, extId, param);
+               }
+
+               mx.unlock();
+       }
+       else if (pMsgEvent->eventType == MSG_EVENT_PLG_STORAGE_CHANGE_IND)
+       {
+               MSG_STORAGE_CHANGE_TYPE_T storageChangeType;
+               MSG_MSGID_LIST_S msgIdList;
+               memset(&msgIdList, 0x00, sizeof(MSG_MSGID_LIST_S));
+
+               // Decode event data
+               memcpy(&storageChangeType, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(MSG_ERROR_T)), sizeof(MSG_STORAGE_CHANGE_TYPE_T));
+               memcpy(&msgIdList.nCount, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(MSG_ERROR_T)+sizeof(MSG_STORAGE_CHANGE_TYPE_T)), sizeof(int));
+
+               if(msgIdList.nCount > 0)
+                       msgIdList.msgIdList = (MSG_MESSAGE_ID_T*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(MSG_ERROR_T)+sizeof(MSG_STORAGE_CHANGE_TYPE_T)+sizeof(int));
+               else
+                       msgIdList.msgIdList = NULL;
+
+               MSG_DEBUG("storageChangeType [%d], msgIdList.nCount [%d]", storageChangeType, msgIdList.nCount);
+
+               mx.lock();
+
+               MsgStorageChangeCBList::iterator it = storageChangeCBList.begin();
+
+               for( ; it != storageChangeCBList.end() ; it++)
+               {
+                       MsgHandle* pHandle = it->hAddr;
+
+                       msg_storage_change_cb pfunc = it->pfStorageChangeCB;
+
+                       void* param = it->userParam;
+
+                       pfunc((MSG_HANDLE_T)pHandle, storageChangeType, &msgIdList, param);
+               }
+
+               mx.unlock();
+       }
+
+       MSG_END();
+}
+
+
+int  MsgProxyListener::getRemoteFd()
+{
+       MutexLocker lock(mx);
+
+       int tmpFd = cliSock.getRemoteFd();
+
+       MSG_DEBUG("listener fd [%d]", tmpFd);
+
+       if( tmpFd == -1 )
+       {
+               cv.wait(mx.pMutex());
+       }
+
+       return cliSock.getRemoteFd();
+}
+
+
+int MsgProxyListener::readFromSocket(char** buf, int* len)
+{
+       return cliSock.read(buf, len);
+}
diff --git a/test_app/CMakeLists.txt b/test_app/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..1f3d70c
--- /dev/null
@@ -0,0 +1,48 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(msg-server CXX)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Debug")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall")
+
+##########################################################
+# Define Test App
+##########################################################
+
+SET(TEST-APP-SRCS
+       ${CMAKE_SOURCE_DIR}/test_app/MsgTestSetting.cpp
+       ${CMAKE_SOURCE_DIR}/test_app/MsgTestStorage.cpp
+       ${CMAKE_SOURCE_DIR}/test_app/MsgTestTransport.cpp
+#      ${CMAKE_SOURCE_DIR}/test_app/MsgTestConvert.cpp
+       ${CMAKE_SOURCE_DIR}/test_app/MsgTestThreadView.cpp
+       ${CMAKE_SOURCE_DIR}/test_app/main.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include/common
+       ${CMAKE_SOURCE_DIR}/include/mapi
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(test_app_pkgs REQUIRED glib-2.0)
+
+FOREACH(flag ${test_app_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_EXECUTABLE(msg-test-app ${TEST-APP-SRCS})
+TARGET_LINK_LIBRARIES(msg-test-app ${test_app_pkgs_LDFLAGS} ${MAPI-LIB})
+
+INSTALL(TARGETS msg-test-app DESTINATION bin)
+
diff --git a/test_app/MsgTestConvert.cpp b/test_app/MsgTestConvert.cpp
new file mode 100755 (executable)
index 0000000..7ba4126
--- /dev/null
@@ -0,0 +1,395 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+//#include <time.h>
+#include <iostream>
+#include <stdio.h>
+#include <string>
+#include <stdlib.h>
+using namespace std;
+
+#include "MsgConvertText.h"
+#include "MsgTestConvert.h"
+#include "main.h"
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+
+#define MAX_DUMP_COLUMN        16
+void MsgDumpTextToHex(const unsigned char *pText, int length)
+{
+       printf("\n\n=======================================\n");
+       printf("   Dump Text To Hex - Length :%d\n", length);
+       printf("=======================================");
+
+       for (int i = 0; i < length; i++ )
+       {
+               if ( i % MAX_DUMP_COLUMN == 0 )
+               {
+                       printf("\n\t");
+               }
+
+               printf("%02x ", pText[i]);
+       }
+
+       printf("\n=======================================\n\n");
+}
+
+
+const int MAX_TEST_BUFFER = 1000;
+
+void MsgTestConvertLocaleToUTF8()
+{
+       int localeStrLen = 0;
+       unsigned char localeString[MAX_TEST_BUFFER];
+       int utf8StrLen;
+       unsigned char utf8String[MAX_TEST_BUFFER];
+
+       printf("Input :\n");
+       cin.getline((char*)localeString, MAX_TEST_BUFFER);
+
+       localeStrLen = strlen((char*)localeString);
+       utf8StrLen = MsgConvertLocaleToUTF8(utf8String, MAX_TEST_BUFFER, localeString, localeStrLen);
+       if ( utf8StrLen <= 0 )
+       {
+               printf("MsgConvertLocaleToUTF8() failed. src string [%s]\n", localeString);
+               return;
+       }
+
+       printf("=== STRING DUMP ===\n");
+       printf("src : [%s]\n", localeString);
+       printf("dst : [%s]\n", utf8String);
+       MsgDumpTextToHex(localeString, localeStrLen);
+       MsgDumpTextToHex(utf8String, utf8StrLen);
+}
+
+
+/*
+File Format Example
+------
+(total bytes)
+(hexadecimal integer for 1 byte)s
+------
+4
+4D 61 69 6E
+------
+
+*/
+/**
+return:
+       byte length
+*/
+int MsgTestConvertReadTextFromFile(unsigned char *pStr)
+{
+       FILE *fp;
+       char filename[100];
+       int byteLength;
+       int i;
+       int c;
+
+       printf("Input file name: \n");
+       scanf("%s", filename);
+       if ( (fp = fopen(filename, "r")) == NULL )
+       {
+               printf("File Open failed. file name [%s]\n", filename);
+               return -1;
+       }
+
+       // read byte length of input text
+       fscanf(fp, "%d", &byteLength);
+
+       printf("read text from file[%s] - size:%d\n", filename, byteLength);
+       // read text
+       for ( i = 0; i < byteLength; i++ )
+       {
+               if ( fscanf(fp, "%x", &c) == EOF )
+                       break;
+               if ( c > 0xFF )
+               {
+                       printf("Wrong Input : index[%d] value [%x]\n", i, c);
+                       byteLength = -1;
+                       break;
+               }
+               pStr[i] = (char)(c & 0xFF);
+               //printf("%x\n", pStr[i]);
+       }
+
+       fclose(fp);
+
+       return byteLength;
+}
+
+void MsgTestConvertUTF8ToUCS2()
+{
+       int utf8StrLen = 0;
+       unsigned char utf8String[MAX_TEST_BUFFER];
+       int ucs2StrLen = 0;
+       WCHAR ucs2String[MAX_TEST_BUFFER];
+
+       utf8StrLen = MsgTestConvertReadTextFromFile(utf8String);
+       if ( utf8StrLen < 0 )
+       {
+               printf("Error - Read Text from File\n");
+               return;
+       }
+
+       //ucs2StrLen = MsgConvertUTF8toUCS2(ucs2String, MAX_TEST_BUFFER, utf8String);   // for null terminated utf8 string
+       ucs2StrLen = MsgConvertUTF8toUCS2((unsigned char *)ucs2String, MAX_TEST_BUFFER, utf8String, utf8StrLen);
+
+       printf("=== STRING DUMP ===\n");
+       printf("src: [%s]", utf8String);
+       MsgDumpTextToHex(utf8String, utf8StrLen);
+       MsgDumpTextToHex((unsigned char*)ucs2String, ucs2StrLen);
+
+}
+
+void MsgTestConvertUCS2ToUTF8()
+{
+       int utf8StrLen = 0;
+       unsigned char utf8String[MAX_TEST_BUFFER];
+       int ucs2StrLen = 0;
+       WCHAR ucs2String[MAX_TEST_BUFFER];
+
+       ucs2StrLen = MsgTestConvertReadTextFromFile((unsigned char*)ucs2String);
+       if ( ucs2StrLen < 0 )
+       {
+               printf("Error - Read Text from File\n");
+               return;
+       }
+
+       utf8StrLen = MsgConvertUCS2toUTF8(utf8String, MAX_TEST_BUFFER, (unsigned char *)ucs2String, ucs2StrLen);
+
+       printf("=== STRING DUMP ===\n");
+       printf("dst: [%s]", utf8String);
+       MsgDumpTextToHex((unsigned char*)ucs2String, ucs2StrLen);
+       MsgDumpTextToHex(utf8String, utf8StrLen);
+}
+
+void MsgTestConvertGSM7bitToUCS2()
+{
+       int gsm7bitStrLen = 0;
+       unsigned char gsm7bitString[MAX_TEST_BUFFER];
+       int ucs2StrLen = 0;
+       WCHAR ucs2String[MAX_TEST_BUFFER];
+
+       gsm7bitStrLen = MsgTestConvertReadTextFromFile(gsm7bitString);
+       if ( gsm7bitStrLen < 0 )
+       {
+               printf("Error - Read Text from File\n");
+               return;
+       }
+
+       ucs2StrLen = MsgConvertGSM7bitToUCS2((unsigned char *)ucs2String, MAX_TEST_BUFFER, gsm7bitString, gsm7bitStrLen);
+
+       printf("=== STRING DUMP ===\n");
+       MsgDumpTextToHex(gsm7bitString, gsm7bitStrLen);
+       MsgDumpTextToHex((unsigned char*)ucs2String, ucs2StrLen);
+}
+
+void MsgTestConvertUCS2ToGSM7bit()
+{
+       int ucs2StrLen = 0;
+       WCHAR ucs2String[MAX_TEST_BUFFER];
+       int gsm7bitStrLen = 0;
+       unsigned char gsm7bitString[MAX_TEST_BUFFER];
+
+       ucs2StrLen = MsgTestConvertReadTextFromFile((unsigned char*)ucs2String);
+       if ( ucs2StrLen < 0 )
+       {
+               printf("Error - Read Text from File\n");
+               return;
+       }
+
+       bool bUnknown = false;
+       MSG_LANGUAGE_ID_T langId = MSG_LANG_ID_RESERVED;
+       gsm7bitStrLen = MsgConvertUCS2toGSM7bit(gsm7bitString, MAX_TEST_BUFFER, (unsigned char *)ucs2String, ucs2StrLen, &bUnknown, &langId);
+
+       printf("=== STRING DUMP ===");
+       MsgDumpTextToHex((unsigned char*)ucs2String, ucs2StrLen);
+       MsgDumpTextToHex(gsm7bitString, gsm7bitStrLen);
+}
+
+void MsgTestConvertGSM7BitToUTF8()
+{
+       int gsm7bitStrLen = 0;
+       unsigned char gsm7bitString[MAX_TEST_BUFFER];
+       int utf8StrLen = 0;
+       unsigned char utf8String[MAX_TEST_BUFFER];
+
+       gsm7bitStrLen = MsgTestConvertReadTextFromFile(gsm7bitString);
+       if ( gsm7bitStrLen < 0 )
+       {
+               printf("Error - Read Text from File\n");
+               return;
+       }
+
+       memset(utf8String, 0x00, sizeof(utf8String));
+       utf8StrLen = MsgConvertGSM7bitToUTF8(utf8String, MAX_TEST_BUFFER, gsm7bitString, gsm7bitStrLen);
+
+       printf("=== STRING DUMP ===\n");
+       printf("dest(UTF8) : [%s]\n", utf8String);
+       MsgDumpTextToHex(gsm7bitString, gsm7bitStrLen);
+       MsgDumpTextToHex(utf8String, utf8StrLen);
+}
+
+void MsgTestConvertUTF8ToGSM7bit()
+{
+       int utf8StrLen = 0;
+       unsigned char utf8String[MAX_TEST_BUFFER];
+       int gsm7bitStrLen = 0;
+       unsigned char gsm7bitString[MAX_TEST_BUFFER];
+
+       utf8StrLen = MsgTestConvertReadTextFromFile(utf8String);
+       if ( utf8StrLen < 0 )
+       {
+               printf("Error - Read Text from File\n");
+               return;
+       }
+
+       MSG_LANGUAGE_ID_T langId = MSG_LANG_ID_RESERVED;
+       gsm7bitStrLen = MsgConvertUTF8ToGSM7bit(gsm7bitString, MAX_TEST_BUFFER, utf8String, utf8StrLen, &langId);
+
+       printf("=== STRING DUMP ===\n");
+       MsgDumpTextToHex(utf8String, utf8StrLen);
+       MsgDumpTextToHex(gsm7bitString, gsm7bitStrLen);
+}
+
+void MsgTestConvertUTF8ToUCS2Key()
+{
+       int utf8StrLen = 0;
+       unsigned char utf8String[MAX_TEST_BUFFER];
+       int ucs2StrLen = 0;
+       WCHAR ucs2String[MAX_TEST_BUFFER];
+
+       printf("Input :\n");
+       cin.getline((char *)utf8String, MAX_TEST_BUFFER);
+
+       utf8StrLen = strlen((char *)utf8String);
+
+       ucs2StrLen = MsgConvertUTF8toUCS2((unsigned char *)ucs2String, MAX_TEST_BUFFER, utf8String);    // for null terminated utf8 string
+       //ucs2StrLen = MsgConvertUTF8toUCS2(ucs2String, MAX_TEST_BUFFER, utf8String, utf8StrLen);
+
+       printf("=== STRING DUMP ===\n");
+       printf("src: [%s]", utf8String);
+       MsgDumpTextToHex(utf8String, utf8StrLen);
+       MsgDumpTextToHex((unsigned char*)ucs2String, ucs2StrLen);
+
+}
+
+void MsgTestConvertUTF8ToGSM7bitKey()
+{
+       int utf8StrLen = 0;
+       unsigned char utf8String[MAX_TEST_BUFFER];
+       int gsm7bitStrLen = 0;
+       unsigned char gsm7bitString[MAX_TEST_BUFFER];
+
+       printf("Input :\n");
+       cin.getline((char *)utf8String, MAX_TEST_BUFFER);
+
+       utf8StrLen = strlen((char *)utf8String);
+
+       MSG_LANGUAGE_ID_T langId = MSG_LANG_ID_RESERVED;
+       gsm7bitStrLen = MsgConvertUTF8ToGSM7bit(gsm7bitString, MAX_TEST_BUFFER, utf8String, utf8StrLen, &langId);       // for null terminated utf8 string
+
+       printf("=== STRING DUMP ===\n");
+       MsgDumpTextToHex(utf8String, utf8StrLen);
+       MsgDumpTextToHex(gsm7bitString, gsm7bitStrLen);
+}
+
+
+void MsgTestConvertSelectMenu( char *pMenu)
+{
+       int menuNum = atoi(pMenu);
+
+       switch ( menuNum )
+       {
+               case 0: // quit
+                       return;
+               case 1: // Locale -> UTF8
+                       MsgTestConvertLocaleToUTF8();
+                       break;
+               case 2: // UTF-8 -> UCS2
+                       MsgTestConvertUTF8ToUCS2();
+                       break;
+               case 3: // UCS2 -> UTF-8
+                       MsgTestConvertUCS2ToUTF8();
+                       break;
+               case 4: // GSM 7bit -> UCS2
+                       MsgTestConvertGSM7bitToUCS2();
+                       break;
+               case 5: // UCS2 -> GSM 7bit
+                       MsgTestConvertUCS2ToGSM7bit();
+                       break;
+               case 6: // GSM 7bit -> UTF-8
+                       MsgTestConvertGSM7BitToUTF8();
+                       break;
+               case 7: // UTF-8 -> GSM 7bit
+                       MsgTestConvertUTF8ToGSM7bit();
+                       break;
+               case 8:
+                       MsgTestConvertUTF8ToUCS2Key();
+                       break;
+               case 9:
+                       MsgTestConvertUTF8ToGSM7bitKey();
+                       break;
+               default:
+                       printf("Invalid Menu. Select Again\n");
+                       break;
+       }
+}
+
+// main function for testing converting
+MSG_ERROR_T MsgTestConvertMain()
+{
+       char menu[3];
+
+       do
+       {
+//             system("clear");
+
+               printf("=======================\n");
+               printf("    Convert Test                     \n");
+               printf("=======================\n");
+               printf("[1] locale -> UTF8 - (Keyboard input)\n");
+               printf("[2] UTF8 -> UCS2 - (File)\n");
+               printf("[3] UCS2 -> UTF8 - (File)\n");
+               printf("[4] GSM 7bit -> UCS2 - (File)\n");
+               printf("[5] UCS2 -> GSM 7bit - (File)\n");
+               printf("[6] GSM 7bit -> UTF8 - (File)\n");
+               printf("[7] UTF8 -> GSM 7bit - (File)\n");
+               printf("[8] UTF8 -> UCS2 - (Keyboard)\n");
+               printf("[9] UTF8 -> GSM 7bit - (Keyboard)\n");
+               printf("[0] Return to Main Menu\n");
+               printf("=======================\n");
+
+               printf("Select Test Menu : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 3);
+
+               MsgTestConvertSelectMenu(menu);
+       }
+       while ( strcmp(menu, "0") != 0 );
+
+       return 0;
+}
+
+
diff --git a/test_app/MsgTestConvert.h b/test_app/MsgTestConvert.h
new file mode 100755 (executable)
index 0000000..8e0be80
--- /dev/null
@@ -0,0 +1,36 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+#ifndef MSG_TEST_CONVERT_H
+#define MSG_TEST_CONVERT_H
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgTypes.h"
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+
+
+MSG_ERROR_T MsgTestConvertMain();
+
+
+#endif //MSG_TEST_CONVERT_H
+
diff --git a/test_app/MsgTestSetting.cpp b/test_app/MsgTestSetting.cpp
new file mode 100755 (executable)
index 0000000..5f8fc59
--- /dev/null
@@ -0,0 +1,1082 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <iostream>
+#include <string>
+#include <stdlib.h>
+using namespace std;
+
+#include "MapiSetting.h"
+#include "MsgTestSetting.h"
+#include "main.h"
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+void MsgTestSettingMain(MSG_HANDLE_T hMsgHandle)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       char menu[2];
+
+       do
+       {
+               system ("clear");
+
+               print("======================================");
+               print("============ Setting Menu ============");
+               print("======================================");
+               print("[1] General Options");
+               print("[2] SMS Send Options");
+               print("[3] SMSC List");
+               print("[4] MMS Send Options");
+               print("[5] MMS Recv Options");
+               print("[6] MMS Style Options");
+               print("[7] Push Msg Options");
+               print("[8] CB Msg Options");
+               print("[0] Voice Mail Option");
+               print("[A] Msg Size Option");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 2);
+
+               MsgSelectMenu(hMsgHandle, menu);
+       }
+       while (strcmp(menu, "B"));
+}
+
+
+void MsgSelectMenu(MSG_HANDLE_T hMsgHandle, char *pMenu)
+{
+       if (!strcmp(pMenu, "1"))
+       {
+               MsgTestGeneralOpt(hMsgHandle);
+       }
+       else if (!strcmp(pMenu, "2"))
+       {
+               MsgTestSMSSendOpt(hMsgHandle);
+       }
+       else if (!strcmp(pMenu, "3"))
+       {
+               MsgTestSMSCList(hMsgHandle);
+       }
+       else if (!strcmp(pMenu, "4"))
+       {
+               MsgTestMMSSendOpt(hMsgHandle);
+       }
+       else if (!strcmp(pMenu, "5"))
+       {
+               MsgTestMMSRecvOpt(hMsgHandle);
+       }
+       else if (!strcmp(pMenu, "6"))
+       {
+               MsgTestMMSStyleOpt(hMsgHandle);
+       }
+       else if (!strcmp(pMenu, "7"))
+       {
+               MsgTestPushMsgOpt(hMsgHandle);
+       }
+       else if (!strcmp(pMenu, "8"))
+       {
+               MsgTestCBMsgOpt(hMsgHandle);
+       }
+       else if (!strcmp(pMenu, "0"))
+       {
+               MsgTestVoiceMailOpt(hMsgHandle);
+       }
+       else if (!strcmp(pMenu, "A"))
+       {
+               MsgTestMsgSizeOpt(hMsgHandle);
+       }
+}
+
+
+void MsgTestGeneralOpt(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char menu[2];
+       char strPrint [512];
+
+       MSG_SETTING_S setting;
+
+       do
+       {
+               memset(&setting, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_GENERAL_OPT_S));
+
+               setting.type = MSG_GENERAL_OPT;
+
+               err = msg_get_config(hMsgHandle, &setting);
+
+               system ("clear");
+
+               print("======================================");
+               print("=========== General Option ===========");
+               print("======================================");
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Keep a Copy : [%d]", setting.option.generalOpt.bKeepCopy);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Alert Tone : [%d]", setting.option.generalOpt.alertTone);
+               print(strPrint);
+
+               print("======================================");
+               print("================ Menu ================");
+               print("[U] Update Options");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 2);
+
+               if (!strcmp(menu, "U"))
+               {
+                       memset(&setting, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_GENERAL_OPT_S));
+
+                       setting.type = MSG_GENERAL_OPT;
+
+                       setting.option.generalOpt.bKeepCopy = true;
+                       setting.option.generalOpt.alertTone = MSG_ALERT_TONE_ONCE;
+               }
+               else if (!strcmp(menu, "B"))
+               {
+                       break;
+               }
+               else
+               {
+                       continue;
+               }
+
+               err = msg_set_config(hMsgHandle, &setting);
+
+               if (err == MSG_SUCCESS)
+                       print("Setting Config Data is OK!");
+               else
+                       print("Setting Config Data is failed!");
+       }
+       while (1);
+}
+
+
+void MsgTestSMSSendOpt(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char menu[2];
+       char strPrint [512];
+
+       MSG_SETTING_S setting;
+
+       do
+       {
+               memset(&setting, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_SMS_SENDOPT_S));
+
+               setting.type = MSG_SMS_SENDOPT;
+
+               err = msg_get_config(hMsgHandle, &setting);
+
+               system ("clear");
+
+               print("======================================");
+               print("=========== SMS Send Option ===========");
+               print("======================================");
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "DCS : [%d]", setting.option.smsSendOpt.dcs);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Network Selection : [%d]", setting.option.smsSendOpt.netMode);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Reply Path : [%d]", setting.option.smsSendOpt.bReplyPath);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Delivery Report : [%d]", setting.option.smsSendOpt.bDeliveryReport);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Save Storage : [%d]", setting.option.smsSendOpt.saveStorage);
+               print(strPrint);
+
+               print("======================================");
+               print("================ Menu ================");
+               print("[U] Update Options");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 2);
+
+               if (!strcmp(menu, "U"))
+               {
+                       memset(&setting, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_SMS_SENDOPT_S));
+
+                       setting.type = MSG_SMS_SENDOPT;
+
+                       setting.option.smsSendOpt.dcs = MSG_ENCODE_AUTO;
+                       setting.option.smsSendOpt.netMode = MSG_SMS_NETWORK_CS_ONLY;
+                       setting.option.smsSendOpt.bReplyPath = false;
+                       setting.option.smsSendOpt.bDeliveryReport = true;
+                       setting.option.smsSendOpt.saveStorage = MSG_SMS_SAVE_STORAGE_PHONE;
+               }
+               else if (!strcmp(menu, "B"))
+               {
+                       break;
+               }
+               else
+               {
+                       continue;
+               }
+
+               err = msg_set_config(hMsgHandle, &setting);
+
+               if (err == MSG_SUCCESS)
+                       print("Setting Config Data is OK!");
+               else
+                       print("Setting Config Data is failed!");
+       }
+       while (1);
+}
+
+
+void MsgTestSMSCList(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char menu[2];
+       char strPrint [512];
+
+       MSG_SETTING_S setting;
+
+       do
+       {
+               memset(&setting, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_SMSC_LIST_S));
+
+               setting.type = MSG_SMSC_LIST;
+
+               err = msg_get_config(hMsgHandle, &setting);
+
+               system ("clear");
+
+               print("======================================");
+               print("============== SMSC List ==============");
+               print("======================================");
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Total Count : [%d]", setting.option.smscList.totalCnt);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Selected SMSC : [%d]", setting.option.smscList.selected);
+               print(strPrint);
+
+               for (int i = 0; i < setting.option.smscList.totalCnt; i++)
+               {
+                       print("======================================");
+
+                       memset(strPrint, 0x00, sizeof(strPrint));
+                       snprintf(strPrint, sizeof(strPrint), "SMSC Name : [%s]", setting.option.smscList.smscData[i].name);
+                       print(strPrint);
+
+                       memset(strPrint, 0x00, sizeof(strPrint));
+                       snprintf(strPrint, sizeof(strPrint), "SMSC Address : [%s]", setting.option.smscList.smscData[i].smscAddr.address);
+                       print(strPrint);
+
+                       memset(strPrint, 0x00, sizeof(strPrint));
+                       snprintf(strPrint, sizeof(strPrint), "SMSC PID : [%d]", setting.option.smscList.smscData[i].pid);
+                       print(strPrint);
+
+                       memset(strPrint, 0x00, sizeof(strPrint));
+                       snprintf(strPrint, sizeof(strPrint), "SMSC VAL PERIOD : [%d]", setting.option.smscList.smscData[i].valPeriod);
+                       print(strPrint);
+
+                       memset(strPrint, 0x00, sizeof(strPrint));
+                       snprintf(strPrint, sizeof(strPrint), "SMSC TON : [%d]", setting.option.smscList.smscData[i].smscAddr.ton);
+                       print(strPrint);
+
+                       memset(strPrint, 0x00, sizeof(strPrint));
+                       snprintf(strPrint, sizeof(strPrint), "SMSC NPI : [%d]", setting.option.smscList.smscData[i].smscAddr.npi);
+                       print(strPrint);
+               }
+
+               print("======================================");
+               print("================ Menu ================");
+               print("[A] Add New SMSC");
+               print("[U] Update SMSC");
+               print("[D] Delete SMSC");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 2);
+
+               if (!strcmp(menu, "A"))
+               {
+                       continue;
+               }
+               else if (!strcmp(menu, "U"))
+               {
+                       memset(&setting, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_SMSC_LIST_S));
+
+                       setting.type = MSG_SMSC_LIST;
+
+                       setting.option.smscList.selected = 0;
+                       setting.option.smscList.totalCnt = 1;
+                       setting.option.smscList.smscData[0].pid = MSG_PID_TEXT;
+                       setting.option.smscList.smscData[0].valPeriod = MSG_VAL_MAXIMUM;
+                       snprintf(setting.option.smscList.smscData[0].name, SMSC_NAME_MAX, "%s", "SMS Centre 1");
+
+                       setting.option.smscList.smscData[0].smscAddr.ton = MSG_TON_INTERNATIONAL;
+                       setting.option.smscList.smscData[0].smscAddr.npi = MSG_NPI_ISDN;
+                       snprintf(setting.option.smscList.smscData[0].smscAddr.address, SMSC_ADDR_MAX, "%s", "1111");
+               }
+               else if (!strcmp(menu, "D"))
+               {
+                       continue;
+               }
+               else if (!strcmp(menu, "B"))
+               {
+                       break;
+               }
+               else
+               {
+                       continue;
+               }
+
+               err = msg_set_config(hMsgHandle, &setting);
+
+               if (err == MSG_SUCCESS)
+                       print("Setting Config Data is OK!");
+               else
+                       print("Setting Config Data is failed!");
+       }
+       while (1);
+}
+
+
+void MsgTestMMSSendOpt(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char menu[2];
+       char strPrint [512];
+
+       MSG_SETTING_S setting;
+
+       do
+       {
+               memset(&setting, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_MMS_SENDOPT_S));
+
+               setting.type = MSG_MMS_SENDOPT;
+
+               err = msg_get_config(hMsgHandle, &setting);
+
+               system ("clear");
+
+               print("======================================");
+               print("=========== MMS Send Option ===========");
+               print("======================================");
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Msg Class : [%d]", setting.option.mmsSendOpt.msgClass);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Priority : [%d]", setting.option.mmsSendOpt.priority);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Expiry Time : [%d]", setting.option.mmsSendOpt.expiryTime);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Delivery Time : [%d]", setting.option.mmsSendOpt.deliveryTime);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Custom Delivery Time : [%d]", setting.option.mmsSendOpt.customDeliveryTime);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Sender Visibility : [%d]", setting.option.mmsSendOpt.bSenderVisibility);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Delivery Report : [%d]", setting.option.mmsSendOpt.bDeliveryReport);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Read Reply : [%d]", setting.option.mmsSendOpt.bReadReply);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Keep Copy : [%d]", setting.option.mmsSendOpt.bKeepCopy);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Body Replying : [%d]", setting.option.mmsSendOpt.bBodyReplying);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Hide Recipients : [%d]", setting.option.mmsSendOpt.bHideRecipients);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Reply Charging : [%d]", setting.option.mmsSendOpt.replyCharging);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Reply Charging Deadline : [%d]", setting.option.mmsSendOpt.replyChargingDeadline);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Reply Charging Size : [%d]", setting.option.mmsSendOpt.replyChargingSize);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Creation Mode : [%d]", setting.option.mmsSendOpt.creationMode);
+               print(strPrint);
+
+               print("======================================");
+               print("================ Menu ================");
+               print("[U] Update Options");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 2);
+
+               if (!strcmp(menu, "U"))
+               {
+                       memset(&setting, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_MMS_SENDOPT_S));
+
+                       setting.type = MSG_MMS_SENDOPT;
+
+                       setting.option.mmsSendOpt.msgClass = MSG_CLASS_AUTO;
+                       setting.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_NORMAL;
+                       setting.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_1DAY;
+                       setting.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_IMMEDIATLY;
+                       setting.option.mmsSendOpt.customDeliveryTime = 0;
+                       setting.option.mmsSendOpt.bSenderVisibility = false;
+                       setting.option.mmsSendOpt.bDeliveryReport = true;
+                       setting.option.mmsSendOpt.bReadReply = false;
+                       setting.option.mmsSendOpt.bKeepCopy = false;
+                       setting.option.mmsSendOpt.bBodyReplying = false;
+                       setting.option.mmsSendOpt.bHideRecipients = false;
+                       setting.option.mmsSendOpt.replyCharging = MSG_REPLY_CHARGING_NONE;
+                       setting.option.mmsSendOpt.replyChargingDeadline = 0;
+                       setting.option.mmsSendOpt.replyChargingSize = 0;
+                       setting.option.mmsSendOpt.creationMode = MSG_CREATION_MODE_FREE;
+               }
+               else if (!strcmp(menu, "B"))
+               {
+                       break;
+               }
+               else
+               {
+                       continue;
+               }
+
+               err = msg_set_config(hMsgHandle, &setting);
+
+               if (err == MSG_SUCCESS)
+                       print("Setting Config Data is OK!");
+               else
+                       print("Setting Config Data is failed!");
+       }
+       while (1);
+}
+
+
+void MsgTestMMSRecvOpt(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char menu[2];
+       char strPrint [512];
+
+       MSG_SETTING_S setOption;
+       MSG_SETTING_S getOption;
+
+       do
+       {
+               memset(&getOption, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_MMS_RECVOPT_S));
+
+               getOption.type = MSG_MMS_RECVOPT;
+
+               err = msg_get_config(hMsgHandle, &getOption);
+
+               system ("clear");
+
+               print("======================================");
+               print("=========== MMS Recv Option ===========");
+               print("======================================");
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Home Network : [%d]", getOption.option.mmsRecvOpt.homeNetwork);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Abroad Network : [%d]", getOption.option.mmsRecvOpt.abroadNetwok);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Read Receipt : [%d]", getOption.option.mmsRecvOpt.readReceipt);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Delivery Receipt : [%d]", getOption.option.mmsRecvOpt.bDeliveryReceipt);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Reject Unknown : [%d]", getOption.option.mmsRecvOpt.bRejectUnknown);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Reject Advertisement : [%d]", getOption.option.mmsRecvOpt.bRejectAdvertisement);
+               print(strPrint);
+
+               print("======================================");
+               print("================ Menu ================");
+               print("[U] Update Options");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 2);
+
+               if (!strcmp(menu, "U"))
+               {
+                       memset(&setOption, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_MMS_RECVOPT_S));
+
+                       setOption.type = MSG_MMS_RECVOPT;
+
+                       setOption.option.mmsRecvOpt.homeNetwork = MSG_HOME_AUTO_DOWNLOAD;
+                       setOption.option.mmsRecvOpt.abroadNetwok = MSG_ABROAD_RESTRICTED;
+                       setOption.option.mmsRecvOpt.readReceipt = false;
+                       setOption.option.mmsRecvOpt.bDeliveryReceipt = true;
+                       setOption.option.mmsRecvOpt.bRejectUnknown = false;
+                       setOption.option.mmsRecvOpt.bRejectAdvertisement = false;
+
+                       err = msg_set_config(hMsgHandle, &setOption);
+
+                       if (err == MSG_SUCCESS)
+                               print("Setting Config Data is OK!");
+                       else
+                               print("Setting Config Data is failed!");
+               }
+               else if (!strcmp(menu, "B"))
+               {
+                       break;
+               }
+               else
+               {
+                       continue;
+               }
+       }
+       while (1);
+}
+
+
+void MsgTestMMSStyleOpt(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char menu[2];
+       char strPrint [512];
+
+       MSG_SETTING_S setOption;
+       MSG_SETTING_S getOption;
+
+       do
+       {
+               memset(&getOption, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_MMS_STYLEOPT_S));
+
+               getOption.type = MSG_MMS_STYLEOPT;
+
+               err = msg_get_config(hMsgHandle, &getOption);
+
+               system ("clear");
+
+               print("======================================");
+               print("=========== MMS Style Option ===========");
+               print("======================================");
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Font Size : [%d]", getOption.option.mmsStyleOpt.fontSize);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Font Style (Bold) : [%d]", getOption.option.mmsStyleOpt.bFontStyleBold);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Font Style (Italic) : [%d]", getOption.option.mmsStyleOpt.bFontStyleItalic);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Font Style (Underline) : [%d]", getOption.option.mmsStyleOpt.bFontStyleUnderline);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Font Color (Red) : [%d]", getOption.option.mmsStyleOpt.fontColorRed);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Font Color (Green) : [%d]", getOption.option.mmsStyleOpt.fontColorGreen);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Font Color (Blue) : [%d]", getOption.option.mmsStyleOpt.fontColorBlue);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Font Color (Hue) : [%d]", getOption.option.mmsStyleOpt.fontColorHue);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "BG Color (Red) : [%d]", getOption.option.mmsStyleOpt.bgColorRed);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "BG Color (Green) : [%d]", getOption.option.mmsStyleOpt.bgColorGreen);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "BG Color (Blue) : [%d]", getOption.option.mmsStyleOpt.bgColorBlue);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "BG Color (Hue) : [%d]", getOption.option.mmsStyleOpt.bgColorHue);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Page Duration : [%d]", getOption.option.mmsStyleOpt.pageDur);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Page Custom Duration : [%d]", getOption.option.mmsStyleOpt.pageCustomDur);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Page Duration Manual : [%d]", getOption.option.mmsStyleOpt.pageDurManual);
+               print(strPrint);
+
+               print("======================================");
+               print("================ Menu ================");
+               print("[U] Update Options");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 2);
+
+               if (!strcmp(menu, "U"))
+               {
+                       memset(&setOption, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_MMS_STYLEOPT_S));
+
+                       setOption.type = MSG_MMS_STYLEOPT;
+
+                       setOption.option.mmsStyleOpt.fontSize = 30;
+                       setOption.option.mmsStyleOpt.bFontStyleBold = true;
+                       setOption.option.mmsStyleOpt.bFontStyleItalic = true;
+                       setOption.option.mmsStyleOpt.bFontStyleUnderline = false;
+                       setOption.option.mmsStyleOpt.fontColorRed = 0;
+                       setOption.option.mmsStyleOpt.fontColorGreen = 0;
+                       setOption.option.mmsStyleOpt.fontColorBlue = 0;
+                       setOption.option.mmsStyleOpt.fontColorHue = 255;
+                       setOption.option.mmsStyleOpt.bgColorRed = 255;
+                       setOption.option.mmsStyleOpt.bgColorGreen = 255;
+                       setOption.option.mmsStyleOpt.bgColorBlue = 255;
+                       setOption.option.mmsStyleOpt.bgColorHue = 255;
+                       setOption.option.mmsStyleOpt.pageDur = 2;
+                       setOption.option.mmsStyleOpt.pageCustomDur = 0;
+                       setOption.option.mmsStyleOpt.pageDurManual = 0;
+
+                       err = msg_set_config(hMsgHandle, &setOption);
+
+                       if (err == MSG_SUCCESS)
+                               print("Setting Config Data is OK!");
+                       else
+                               print("Setting Config Data is failed!");
+               }
+               else if (!strcmp(menu, "B"))
+               {
+                       break;
+               }
+               else
+               {
+                       continue;
+               }
+       }
+       while (1);
+}
+
+
+void MsgTestPushMsgOpt(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char menu[2];
+       char strPrint [512];
+
+       MSG_SETTING_S setOption;
+       MSG_SETTING_S getOption;
+
+       do
+       {
+               memset(&getOption, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_PUSHMSG_OPT_S));
+
+               getOption.type = MSG_PUSHMSG_OPT;
+
+               err = msg_get_config(hMsgHandle, &getOption);
+
+               system ("clear");
+
+               print("======================================");
+               print("=========== Push Msg Option ===========");
+               print("======================================");
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Receive Option : [%d]", getOption.option.pushMsgOpt.bReceive);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Service Load : [%d]", getOption.option.pushMsgOpt.serviceType);
+               print(strPrint);
+
+               print("======================================");
+               print("================ Menu ================");
+               print("[U] Update Options");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 2);
+
+               if (!strcmp(menu, "U"))
+               {
+                       memset(&setOption, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_PUSHMSG_OPT_S));
+
+                       setOption.type = MSG_PUSHMSG_OPT;
+
+                       setOption.option.pushMsgOpt.bReceive = false;
+                       setOption.option.pushMsgOpt.serviceType = MSG_PUSH_SERVICE_PROMPT;
+
+                       err = msg_set_config(hMsgHandle, &setOption);
+
+                       if (err == MSG_SUCCESS)
+                               print("Setting Config Data is OK!");
+                       else
+                               print("Setting Config Data is failed!");
+               }
+               else if (!strcmp(menu, "B"))
+               {
+                       break;
+               }
+               else
+               {
+                       continue;
+               }
+       }while (1);
+}
+
+
+void MsgTestCBMsgOpt(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char menu[2];
+       char strPrint [512];
+
+       MSG_SETTING_S setOption;
+       MSG_SETTING_S getOption;
+
+       do
+       {
+               memset(&getOption, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_CBMSG_OPT_S));
+
+               getOption.type = MSG_CBMSG_OPT;
+
+               err = msg_get_config(hMsgHandle, &getOption);
+
+               system ("clear");
+
+               print("======================================");
+               print("=========== CB Msg Option ===========");
+               print("======================================");
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Receive : [%d]", getOption.option.cbMsgOpt.bReceive);
+               print(strPrint);
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "All Channel : [%d]", getOption.option.cbMsgOpt.bAllChannel);
+               print(strPrint);
+
+                       memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Channel Count : [%d]", getOption.option.cbMsgOpt.channelData.channelCnt);
+                       print(strPrint);
+
+               for (int i = 0; i < getOption.option.cbMsgOpt.channelData.channelCnt; i++)
+               {
+                       memset(strPrint, 0x00, sizeof(strPrint));
+                       snprintf(strPrint, sizeof(strPrint), "Channel Activate : [%d]", getOption.option.cbMsgOpt.channelData.channelInfo[i].bActivate);
+                       print(strPrint);
+
+                       memset(strPrint, 0x00, sizeof(strPrint));
+                       snprintf(strPrint, sizeof(strPrint), "Channel ID : [%d]", getOption.option.cbMsgOpt.channelData.channelInfo[i].id);
+                       print(strPrint);
+
+                       memset(strPrint, 0x00, sizeof(strPrint));
+                       snprintf(strPrint, sizeof(strPrint), "Channel Name : [%s]", getOption.option.cbMsgOpt.channelData.channelInfo[i].name);
+                       print(strPrint);
+               }
+
+               for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++)
+               {
+                       memset(strPrint, 0x00, sizeof(strPrint));
+                       snprintf(strPrint, sizeof(strPrint), "Language[%d] : [%d]", i, getOption.option.cbMsgOpt.bLanguage[i]);
+                       print(strPrint);
+               }
+
+               print("======================================");
+               print("================ Menu ================");
+               print("[U] Update Options");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 2);
+
+               if (!strcmp(menu, "U"))
+               {
+                       memset(&setOption, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_CBMSG_OPT_S));
+
+                       setOption.type = MSG_CBMSG_OPT;
+
+                       setOption.option.cbMsgOpt.bReceive = true;
+                       setOption.option.cbMsgOpt.bAllChannel = true;
+
+                       setOption.option.cbMsgOpt.channelData.channelCnt = 3;
+
+                       setOption.option.cbMsgOpt.channelData.channelInfo[0].bActivate = true;
+                       setOption.option.cbMsgOpt.channelData.channelInfo[0].id = 10;
+                       memset(setOption.option.cbMsgOpt.channelData.channelInfo[0].name, 0x00, CB_CHANNEL_NAME_MAX+1);
+                       strncpy(setOption.option.cbMsgOpt.channelData.channelInfo[0].name, "CB MSG", CB_CHANNEL_NAME_MAX);
+
+                       setOption.option.cbMsgOpt.channelData.channelInfo[1].bActivate = true;
+                       setOption.option.cbMsgOpt.channelData.channelInfo[1].id = 50;
+                       memset(setOption.option.cbMsgOpt.channelData.channelInfo[1].name, 0x00, CB_CHANNEL_NAME_MAX+1);
+                       strncpy(setOption.option.cbMsgOpt.channelData.channelInfo[1].name, "CB TEST", CB_CHANNEL_NAME_MAX);
+
+                       setOption.option.cbMsgOpt.channelData.channelInfo[2].bActivate = false;
+                       setOption.option.cbMsgOpt.channelData.channelInfo[2].id = 60;
+                       memset(setOption.option.cbMsgOpt.channelData.channelInfo[2].name, 0x00, CB_CHANNEL_NAME_MAX+1);
+
+//                     memcpy(&setOption.option.cbMsgOpt.channelData, &getOption.option.cbMsgOpt.channelData, sizeof(MSG_CB_CHANNEL_S));
+
+                       setOption.option.cbMsgOpt.bLanguage[MSG_CBLANG_TYPE_ALL] = false;
+                       setOption.option.cbMsgOpt.bLanguage[MSG_CBLANG_TYPE_ENG] = true;
+                       setOption.option.cbMsgOpt.bLanguage[MSG_CBLANG_TYPE_GER] = false;
+                       setOption.option.cbMsgOpt.bLanguage[MSG_CBLANG_TYPE_FRE] = false;
+                       setOption.option.cbMsgOpt.bLanguage[MSG_CBLANG_TYPE_ITA] = false;
+                       setOption.option.cbMsgOpt.bLanguage[MSG_CBLANG_TYPE_NED] = false;
+                       setOption.option.cbMsgOpt.bLanguage[MSG_CBLANG_TYPE_SPA] = false;
+                       setOption.option.cbMsgOpt.bLanguage[MSG_CBLANG_TYPE_POR] = false;
+                       setOption.option.cbMsgOpt.bLanguage[MSG_CBLANG_TYPE_SWE] = false;
+                       setOption.option.cbMsgOpt.bLanguage[MSG_CBLANG_TYPE_TUR] = false;
+
+                       err = msg_set_config(hMsgHandle, &setOption);
+
+                       if (err == MSG_SUCCESS)
+                               print("Setting Config Data is OK!");
+                       else
+                               print("Setting Config Data is failed!");
+               }
+               else if (!strcmp(menu, "B"))
+               {
+                       break;
+               }
+               else
+               {
+                       continue;
+               }
+       }while (1);
+}
+
+
+void MsgTestVoiceMailOpt(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char menu[2];
+       char strPrint [512];
+
+       MSG_SETTING_S setOption;
+       MSG_SETTING_S getOption;
+
+       do
+       {
+               memset(&getOption, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_VOICEMAIL_OPT_S));
+
+               getOption.type = MSG_VOICEMAIL_OPT;
+
+               err = msg_get_config(hMsgHandle, &getOption);
+
+               system ("clear");
+
+               print("======================================");
+               print("=========== Voice Mail Option ===========");
+               print("======================================");
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Voice Mail Number : [%s]", getOption.option.voiceMailOpt.mailNumber);
+               print(strPrint);
+
+               print("======================================");
+               print("================ Menu ================");
+               print("[U] Update Options");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 2);
+
+               if (!strcmp(menu, "U"))
+               {
+                       memset(&setOption, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_VOICEMAIL_OPT_S));
+
+                       setOption.type = MSG_VOICEMAIL_OPT;
+
+                       memset(setOption.option.voiceMailOpt.mailNumber, 0x00, sizeof(MAX_PHONE_NUMBER_LEN));
+                       strncpy(setOption.option.voiceMailOpt.mailNumber, "11111", MAX_PHONE_NUMBER_LEN);
+
+                       err = msg_set_config(hMsgHandle, &setOption);
+
+                       if (err == MSG_SUCCESS)
+                               print("Setting Config Data is OK!");
+                       else
+                               print("Setting Config Data is failed!");
+               }
+               else if (!strcmp(menu, "B"))
+               {
+                       break;
+               }
+               else
+               {
+                       continue;
+               }
+       }while (1);
+}
+
+
+void MsgTestMsgSizeOpt(MSG_HANDLE_T hMsgHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char menu[2];
+       char strPrint [512];
+
+       MSG_SETTING_S setOption;
+       MSG_SETTING_S getOption;
+
+       do
+       {
+               memset(&getOption, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_MSGSIZE_OPT_S));
+
+               getOption.type = MSG_MSGSIZE_OPT;
+
+               err = msg_get_config(hMsgHandle, &getOption);
+
+               system ("clear");
+
+               memset(strPrint, 0x00, sizeof(strPrint));
+               snprintf(strPrint, sizeof(strPrint), "Message Size : [%d]", getOption.option.msgSizeOpt.nMsgSize);
+               print(strPrint);
+
+               print("======================================");
+               print("================ Menu ================");
+               print("[U] Update Options");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 2);
+
+               if (!strcmp(menu, "U"))
+               {
+                       memset(&setOption, 0x00, sizeof(MSG_OPTION_TYPE_T)+sizeof(MSG_MSGSIZE_OPT_S));
+
+                       setOption.type = MSG_MSGSIZE_OPT;
+
+                       setOption.option.msgSizeOpt.nMsgSize = 100;
+
+                       err = msg_set_config(hMsgHandle, &setOption);
+
+                       if (err == MSG_SUCCESS)
+                               print("Setting Config Data is OK!");
+                       else
+                               print("Setting Config Data is failed!");
+               }
+               else if (!strcmp(menu, "B"))
+               {
+                       break;
+               }
+               else
+               {
+                       continue;
+               }
+       }while (1);
+}
+
diff --git a/test_app/MsgTestSetting.h b/test_app/MsgTestSetting.h
new file mode 100755 (executable)
index 0000000..96ebd06
--- /dev/null
@@ -0,0 +1,139 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+/**
+ *     @file           MsgTestSetting.h
+ *     @brief          Defines setting test function of messaging framework
+ *     @version                1.0
+ */
+
+#ifndef MSG_TEST_SETTING_H
+#define MSG_TEST_SETTING_H
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Messaging Setting Test Function
+ *     @section                Program
+ *     - Program : Messaging Setting Test Function Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include "MsgTypes.h"
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_SETTING_TEST_FUNCTION Messaging Setting Test Function
+ *     @{
+ */
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**    @fn             void MsgTestSettingMain(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Shows a setting menu.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestSettingMain(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgSelectMenu(MSG_HANDLE_T hMsgHandle, char *pMenu)
+ *     @brief  Selects a setting menu.
+ *     @param[in]      hMsgHandle is Message handle. \n
+ *     @param[in]      pMenu is a pointer that indicates which menu is selected. \n
+ */
+void MsgSelectMenu(MSG_HANDLE_T hMsgHandle, char *pMenu);
+
+
+/**    @fn             void MsgTestGeneralOpt(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgGetConfig and MsgSetConfig.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestGeneralOpt(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgTestSMSSendOpt(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgGetConfig and MsgSetConfig.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestSMSSendOpt(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgTestSMSCList(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgGetConfig and MsgSetConfig.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestSMSCList(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgTestMMSSendOpt(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgGetConfig and MsgSetConfig.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestMMSSendOpt(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgTestMMSRecvOpt(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgGetConfig and MsgSetConfig.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestMMSRecvOpt(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgTestMMSStyleOpt(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgGetConfig and MsgSetConfig.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestMMSStyleOpt(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgTestPushMsgOpt(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgGetConfig and MsgSetConfig.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestPushMsgOpt(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgTestCBMsgOpt(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgGetConfig and MsgSetConfig.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestCBMsgOpt(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgTestVoiceMailOpt(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgGetConfig and MsgSetConfig.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestVoiceMailOpt(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgTestMsgSizeOpt(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgGetConfig and MsgSetConfig.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestMsgSizeOpt(MSG_HANDLE_T hMsgHandle);
+
+/**
+ *     @}
+ */
+
+#endif // MSG_TEST_SETTING_H
+
diff --git a/test_app/MsgTestStorage.cpp b/test_app/MsgTestStorage.cpp
new file mode 100755 (executable)
index 0000000..0460fae
--- /dev/null
@@ -0,0 +1,1911 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <time.h>
+#include <iostream>
+#include <string>
+#include <stdlib.h>
+using namespace std;
+
+#include "MsgMmsTypes.h"
+#include "MsgSettingTypes.h"
+#include "MapiStorage.h"
+#include "MapiSetting.h"
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+#include "MsgTestStorage.h"
+#include "MsgTestTransport.h"
+#include "main.h"
+
+MSG_FOLDER_LIST_S g_folderList;
+
+#define MSG_PROFILE_BEGIN(pfid) \
+       unsigned int __prf_l1_##pfid = __LINE__;    \
+       struct timeval __prf_1_##pfid;              \
+       struct timeval __prf_2_##pfid;              \
+       do {                                        \
+               gettimeofday(&__prf_1_##pfid, 0);       \
+       } while (0)
+
+#define MSG_PROFILE_END(pfid) \
+       unsigned int __prf_l2_##pfid = __LINE__;\
+       do { \
+               gettimeofday(&__prf_2_##pfid, 0);\
+               long __ds = __prf_2_##pfid.tv_sec - __prf_1_##pfid.tv_sec;\
+               long __dm = __prf_2_##pfid.tv_usec - __prf_1_##pfid.tv_usec;\
+               if ( __dm < 0 ) { __ds--; __dm = 1000000 + __dm; } \
+               printf("**PROFILE** [MSGFW: %s: %s() %u ~ %u] " #pfid " -> Elapsed Time: %u.%06u seconds\n",                    \
+               rindex(__FILE__, '/')+1,                \
+               __FUNCTION__, \
+               __prf_l1_##pfid,                                         \
+               __prf_l2_##pfid,                                         \
+               (unsigned int)(__ds),                                    \
+               (unsigned int)(__dm));                                   \
+       } while (0)
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+void MsgTestAddMessage(MSG_HANDLE_T hMsgHandle)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       // Make Message
+       msg_message_t msgInfo = msg_new_message();
+       MSG_SENDINGOPT_S sendOpt = {0, };
+
+       print("\n===== Input Message =====");
+       print("Input Message Type 0:SMS 1:MMS :");
+       unsigned int msgType;
+       msgType = cin.get();    //&msgType, 1);
+       cin.get(); // consume "enter key"
+
+       if( msgType == '0' )
+       {
+               msg_set_message_type(msgInfo, MSG_TYPE_SMS);
+       }
+       else if ( msgType == '1' )
+       {
+               msg_set_message_type(msgInfo, MSG_TYPE_MMS);
+       }
+       else
+       {
+               MSG_DEBUG("Msg Type input error %d", msgType);
+       }
+
+       print("\nInput Message Sending Option ?. 'Y' : Yes 'N' : No  ");
+
+       char bSendOpt = 0, ch = 0;
+       cin >> bSendOpt;
+       ch = cin.get();
+
+       if( bSendOpt == 'Y' || bSendOpt == 'y')
+       {
+               sendOpt.bSetting = true;
+
+               /* EX : Set SendingOption */
+               if( msg_is_sms(msgInfo) ) //msgInfo.msgType.mainType == MSG_SMS_TYPE)
+               {
+                       print("\nRequest Delivery Report? Press 'Y' or 'N' :");
+                       char bDelivery = 0;
+                       ch = 0;
+                       cin >> bDelivery;
+                       ch = cin.get();
+
+                       if( bDelivery == 'Y' || bDelivery == 'y')
+                               sendOpt.bDeliverReq = true;
+                       else
+                               sendOpt.bDeliverReq = false;
+
+                       print("\nKeep a Copy? Press 'Y' or 'N' :");
+                       char bKeepCopy = 0;
+                       ch = 0;
+                       cin >> bKeepCopy;
+                       ch = cin.get();
+
+                       if( bKeepCopy == 'Y' || bKeepCopy == 'y')
+                               sendOpt.bKeepCopy = true;
+                       else
+                               sendOpt.bKeepCopy = false;
+
+                       print("\nSet Reply Path? Press 'Y' or 'N' :");
+                       char bReplyPath = 0;
+                       ch = 0;
+                       cin >> bReplyPath;
+                       ch = cin.get();
+
+                       if( bReplyPath == 'Y' || bReplyPath == 'y')
+                               sendOpt.option.smsSendOpt.bReplyPath = true;
+                       else
+                               sendOpt.option.smsSendOpt.bReplyPath = false;
+               }
+               else if( msg_is_mms(msgInfo) )//msgInfo.msgType.mainType == MSG_MMS_TYPE)
+               {
+                       print("\nRequest Delivery Report? Press 'Y' or 'N' :");
+                       char bDelivery = 0;
+                       ch = 0;
+                       cin >> bDelivery;
+                       ch = cin.get();
+
+                       if( bDelivery == 'Y' || bDelivery == 'y')
+                               sendOpt.bDeliverReq = true;
+                       else
+                               sendOpt.bDeliverReq = false;
+
+                       print("\nKeep a Copy? Press 'Y' or 'N' :");
+                       char bKeepCopy = 0;
+                       ch = 0;
+                       cin >> bKeepCopy;
+                       ch = cin.get();
+
+                       if( bKeepCopy == 'Y' || bKeepCopy == 'y')
+                               sendOpt.bKeepCopy = true;
+                       else
+                               sendOpt.bKeepCopy = false;
+
+                       print("\nRequest Read Report? Press 'Y' or 'N' :");
+                       char bRead = 0;
+                       ch = 0;
+                       cin >> bRead;
+                       ch = cin.get();
+
+                       if( bRead == 'Y' || bRead == 'y')
+                               sendOpt.option.mmsSendOpt.bReadReq = true;
+                       else
+                               sendOpt.option.mmsSendOpt.bReadReq = false;
+
+                       print("\nSet Priority? 'U' : Ugent, 'N' : Normal, 'L' : Low");
+                       char priority = 0;
+                       ch = 0;
+                       cin >> priority;
+                       ch = cin.get();
+
+                       if( priority == 'U' || priority == 'u')
+                               sendOpt.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_HIGH;
+                       else if( priority == 'N' || priority == 'n')
+                               sendOpt.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_NORMAL;
+                       else if( priority == 'L' || priority == 'l')
+                               sendOpt.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_LOW;
+
+                       print("\nSet Expiry Time? '0' : Max '1' : 1 Day, '2' : 2 Days, '3' : 1 Week, '4' : 2 Weeks ");
+                       char expiryTime = 0;
+                       ch = 0;
+                       cin >> expiryTime;
+                       ch = cin.get();
+
+                       if( expiryTime == '0')
+                               sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_MAXIMUM;
+                       else if( expiryTime == '1')
+                               sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_1DAY;
+                       else if( expiryTime == '2')
+                               sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_2DAYS;
+                       else if( expiryTime == '3')
+                               sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_1WEEK;
+                       else if( expiryTime == '4')
+                               sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_2WEEKS;
+
+                       print("\nSet Delivery Time? '0' : Immediately '1' : 1 Hour, '2' : 1 Day, '3' : 1 Week ");
+                       char deliveryTime = 0;
+                       ch = 0;
+                       cin >> deliveryTime;
+                       ch = cin.get();
+
+                       if( deliveryTime == '0')
+                               sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_IMMEDIATLY;
+                       else if( deliveryTime == '1')
+                               sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_1HOUR;
+                       else if( deliveryTime == '2')
+                               sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_1DAY;
+                       else if( deliveryTime == '3')
+                               sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_1WEEK;
+
+                       MSG_DEBUG("sendOpt.option.mmsSendOpt.deliveryTime = %lu", sendOpt.option.mmsSendOpt.deliveryTime);
+               }
+       }
+       else            /* In case of No setting per Message, Set Message option with Global Setting value */
+       {
+               sendOpt.bSetting = false;
+       }
+
+       MSG_DEBUG("### bSetting = %d ###", sendOpt.bSetting);
+       MSG_DEBUG("MsgType [%d]", msg_get_message_type(msgInfo));
+
+       if(msg_is_sms(msgInfo)) //msgInfo.msgType.mainType == MSG_SMS_TYPE)
+       {
+               print("\n===== Input Message =====");
+               print("Input Message Text :");
+
+               char strMsg[1200];
+               memset(strMsg, 0x00, sizeof(strMsg));
+
+//             strcpy(strMsg, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+//             strcpy(strMsg, "ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNO");
+//             strcpy(strMsg, "ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNO ABCDEFGHIJKLMNO ABCDEFGHIJKLMNO ABCDEFGHIJKLMNO ABCDEFGHIJKLMNO ABCDEFGHIJKLMNO");
+//             strcpy(strMsg, "AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA");
+
+               cin.getline(strMsg, 1024);
+
+               if (msg_sms_set_message_body(msgInfo, strMsg, strlen(strMsg)) != MSG_SUCCESS)
+               {
+                       return;
+               }
+       }
+
+       else if(msg_is_mms(msgInfo)) //msgInfo.msgType.mainType == MSG_MMS_TYPE)
+       {
+               // Compose MMS Message Body (Text, Image, Sound, Video)
+               //MMS_MESSAGE_DATA_S    msgData ={0, };
+               MMS_MESSAGE_DATA_S*      mms_data;//msgHandle;
+               MMS_PAGE_S* page[2];
+               MMS_MEDIA_S* media[5];
+               MMS_ATTACH_S* attachment[5];
+               int nSize = 0;
+
+               print("\n===== Input Subject =====");
+
+               char                                    strSubject[120];
+               int                                             subjectLen;
+               memset(strSubject, 0x00, sizeof(strSubject));
+
+               cin.getline(strSubject, 120);
+               subjectLen = strlen(strSubject);
+
+               msg_set_subject(msgInfo, strSubject);
+
+               mms_data = msg_mms_create_message();
+
+               print("\n===== Input Message =====");
+               print("Input Multipart type 0: Multiprat Related, 1:Multipart Mixed");
+
+               unsigned int multipartType;
+               multipartType = cin.get();
+               cin.get(); // consume "enter key"
+
+               if(multipartType == '0')
+               {
+                       msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+                       msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+                       msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+
+                       //------------>  1st Slide Composing
+                       page[0] = msg_mms_add_page(mms_data, 5440);
+
+                       media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+                       media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+                       media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+                       media[2]->sMedia.sText.nColor = 0x000000;
+                       media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+                       media[2]->sMedia.sText.bBold = true;
+
+                       //------------>  2nd Slide Composing
+                       page[1] = msg_mms_add_page(mms_data, 4544);
+
+                       media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+                       media[3]->sMedia.sText.nColor = 0x000000;
+                       media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+                       media[3]->sMedia.sText.bItalic = true;
+                       media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+                       strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+               }
+               else
+               {
+                       attachment[0] = msg_mms_add_attachment(mms_data, (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+                       attachment[1] = msg_mms_add_attachment(mms_data, (char*)"/opt/etc/msg-service/audio.amr");
+                       attachment[2] = msg_mms_add_attachment(mms_data, (char*)"/opt/etc/msg-service/Temp0_2.txt");
+                       attachment[3] = msg_mms_add_attachment(mms_data, (char*)"/opt/etc/msg-service/Temp1_0.txt");
+                       attachment[4] = msg_mms_add_attachment(mms_data, (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+               }
+
+               MSG_DEBUG("nSize = %d",  nSize);
+
+               msg_mms_set_message_body(msgInfo, mms_data);
+
+               msg_mms_release_page_list(mms_data);
+               msg_mms_release_region_list(mms_data);
+               msg_mms_release_attachment_list(mms_data);
+               msg_mms_release_transition_list(mms_data);
+               msg_mms_release_meta_list(mms_data);
+
+               msg_mms_destroy_message(mms_data);
+       }
+
+       int nToCnt = 0;
+
+       char strNumber[MAX_ADDRESS_VAL_LEN];
+       memset(strNumber, 0x00, MAX_ADDRESS_VAL_LEN);
+
+       print("\n===== Add Recipient =====");
+
+       while (nToCnt < MAX_TO_ADDRESS_CNT)
+       {
+               print("\nInput Recipient Number. Press 'N' if you don't want : ");
+
+               cin.getline(strNumber, 1024);
+
+               if (!strcmp(strNumber, "N")) break;
+
+               MSG_DEBUG("strNumber [%s]", strNumber);
+
+               if(msg_is_mms(msgInfo)) // in case of MMS
+               {
+                       print("\n===== Input Recipient Type =====");
+                       print("Input Message Type 0:To 1:Cc 2: Bcc :");
+
+                       unsigned int recipientType;
+                       recipientType = cin.get();      //&msgType, 1);
+                       cin.get(); // consume "enter key"
+
+                       if(recipientType == '0')
+                               msg_add_address(msgInfo, strNumber, MSG_RECIPIENTS_TYPE_TO);
+                       else if(recipientType == '1')
+                               msg_add_address(msgInfo, strNumber, MSG_RECIPIENTS_TYPE_CC);
+                       else if(recipientType == '2')
+                               msg_add_address(msgInfo, strNumber, MSG_RECIPIENTS_TYPE_BCC);
+                       else
+                               MSG_DEBUG("Recipient Type input error %d", recipientType);
+               }
+               else // in case of SMS
+                       msg_add_address(msgInfo, strNumber, MSG_RECIPIENTS_TYPE_TO);
+
+               nToCnt++;
+       }
+
+       MSG_DEBUG("nToContactCnt [%d]", msg_get_address_count(msgInfo));
+
+       if(msg_is_sms(msgInfo))
+       {
+               char strReplyAddr[MAX_PHONE_NUMBER_LEN];
+               memset(strReplyAddr, 0x00, MAX_PHONE_NUMBER_LEN);
+
+               print("\n===== Set Reply Address =====");
+
+               print("\nInput Reply Number. Press 'N' if you don't want : ");
+
+               cin.getline(strReplyAddr, 1024);
+
+               if (!strcmp(strReplyAddr, "N"))
+               {
+                       print("\nReply Number is not set.");
+               }
+               else
+               {
+                       MSG_DEBUG("strReplyAddr [%s]", strReplyAddr);
+
+                       msg_set_reply_address(msgInfo, strReplyAddr);
+               }
+
+               // for test
+//             msg_set_backup_status(msgInfo, true);
+       }
+
+       // Port Number Test
+//     msg_set_port(msgInfo, 4010, 0);
+
+       print("\n======================================");
+       print("[1] Send Message");
+       print("[2] Save Message into Draft");
+       print("[3] Scheduled Message Send");
+       print("======================================");
+       print("Input : ");
+
+       int select = 0;
+       char ch1 = 0;
+
+       cin >> select;
+       ch1 = cin.get();
+
+       if (select == 1)
+       {
+               MsgTestSubmitReq(hMsgHandle, msgInfo, &sendOpt);
+       }
+       else if (select == 2)
+       {
+               print("Start Saving Message...");
+
+               int MsgId = 0;
+
+               MsgId = msg_add_message(hMsgHandle, msgInfo, &sendOpt);
+
+               MSG_DEBUG("Saving Message is Finished![%d]", MsgId);
+       }
+
+       else if (select == 3)
+       {
+               MsgTestScheduledSubmitReq(hMsgHandle, msgInfo, &sendOpt);
+       }
+
+       msg_release_message(&msgInfo);
+}
+
+void MsgTestMsgGen(MSG_HANDLE_T hMsgHandle)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       char menu[5];
+
+       print("Input Message Count: ");
+
+       memset(menu, 0x00, sizeof(menu));
+       cin.getline(menu, 5);
+
+       unsigned int count = atoi(menu);
+
+       print("Input Message Type(SMS[1], MMS[2]): ");
+
+       memset(menu, 0x00, sizeof(menu));
+       cin.getline(menu, 5);
+
+       MSG_MESSAGE_TYPE_T msgType = MSG_TYPE_INVALID;
+
+       if (atoi(menu) == 1)
+               msgType = MSG_TYPE_SMS;
+       else if (atoi(menu) == 2)
+               msgType = MSG_TYPE_MMS;
+
+       print("Input folder(INBOX[1], OUTBOX[2], SENTBOX[3], DRAFTBOX[4]): ");
+
+       memset(menu, 0x00, sizeof(menu));
+       cin.getline(menu, 5);
+
+       MSG_FOLDER_ID_T folderId = atoi(menu);
+
+       MSG_ERROR_T err = msg_generate_message(hMsgHandle, msgType, folderId, count);
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("err [%d]", err);
+       }
+}
+
+
+void MsgTestGetMessage(MSG_HANDLE_T hMsgHandle, int MsgId)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       msg_message_t msg = msg_new_message();
+       MSG_SENDINGOPT_S sendOpt = {0, };
+
+       err = msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)MsgId, msg, &sendOpt);
+
+       if (err != MSG_SUCCESS)
+       {
+               msg_release_message(&msg);
+               return;
+       }
+
+       // Update Read Status
+       msg_update_read_status(hMsgHandle, MsgId, true);
+
+       // Send Read Report
+       if (msg_is_mms(msg))
+       {
+               int folder_id = msg_get_folder_id(msg);
+               if (folder_id == MSG_INBOX_ID) {
+                       msg_mms_send_read_report(hMsgHandle, MsgId, MSG_READ_REPORT_IS_READ);
+               }
+       }
+
+       MsgPrintMessage(hMsgHandle, msg, &sendOpt);
+
+       msg_release_message(&msg);
+}
+
+
+void MsgTestGetMessageList(MSG_HANDLE_T hMsgHandle, int FolderId)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       char menu[5];
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_SORT_RULE_S sortRule = {0};
+
+       sortRule.sortType               = MSG_SORT_BY_READ_STATUS;
+       sortRule.bAscending     = false;
+
+       MSG_LIST_S folderViewList;
+
+       MSG_MESSAGE_TYPE_T MsgType;
+       MSG_NETWORK_STATUS_T NetworkStatus;
+
+       char displayTime[32];
+       memset(displayTime, 0x00, sizeof(displayTime));
+
+       do
+       {
+               err = msg_get_folder_view_list(hMsgHandle, (MSG_FOLDER_ID_T)FolderId, NULL, &folderViewList);
+
+               if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
+               {
+                       print("Get Message List is failed!");
+                       return;
+               }
+
+               system ("clear" );
+
+               printf("======================================\n");
+               for (int i = 0; i < g_folderList.nCount; i++)
+               {
+                       if (FolderId == g_folderList.folderInfo[i].folderId)
+                       {
+                               printf("=============== %s ===============\n", g_folderList.folderInfo[i].folderName);
+                               break;
+                       }
+               }
+               printf("======================================\n");
+
+               if (folderViewList.nCount <= 0)
+               {
+                       printf("Empty...\n");
+               }
+               else
+               {
+                       MSG_PROFILE_BEGIN(2);
+
+                       for (int i = 0; i < folderViewList.nCount; i++)
+                       {
+                               memset(displayTime, 0x00, sizeof(displayTime));
+
+                               MsgConvertTime(msg_get_time(folderViewList.msgInfo[i]), displayTime);
+
+                               const char* msgText = NULL;
+
+                               int msgType = msg_get_message_type(folderViewList.msgInfo[i]);
+
+                               if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
+                                       msgText = msg_mms_get_text_contents(folderViewList.msgInfo[i]);
+                               else
+                                       msgText = msg_sms_get_message_body(folderViewList.msgInfo[i]);
+
+                               printf("[%02d]\t[%s %s %s %s] [%s]\t[%s]\nDate [%s]\nMessage Text [%s] \tMessage data size [%d]\n",
+                                               msg_get_message_id(folderViewList.msgInfo[i]),
+                                               MsgConvertMsgType(msg_get_message_type(folderViewList.msgInfo[i])),
+                                               MsgConvertStorageId(msg_get_storage_id(folderViewList.msgInfo[i])),
+                                               MsgConvertReadStatus(msg_is_read(folderViewList.msgInfo[i])),
+                                               MsgConvertProtectedStatus(msg_is_protected(folderViewList.msgInfo[i])),
+                                               MsgConvertNetworkStatus(msg_get_network_status(folderViewList.msgInfo[i])),
+                                               msg_get_ith_address(folderViewList.msgInfo[i], 0),
+                                               displayTime,
+                                               msgText,
+                                               msg_get_message_body_size(folderViewList.msgInfo[i]));
+                               printf("--------------------------------------------------------\n");
+                       }
+
+                       MSG_PROFILE_END(2);
+               }
+
+               printf("======================================\n");
+               printf("================ Menu ================\n");
+               printf("======================================\n");
+               printf("[C] Create Message\n");
+               printf("[D] Delete All Messages\n");
+               printf("[B] Back\n");
+               printf("======================================\n");
+
+               printf("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 5);
+
+               if (!strcmp(menu, "C") || !strcmp(menu, "c")) // Add Message
+               {
+                       MsgTestAddMessage(hMsgHandle);
+               }
+               else if (!strcmp(menu, "D") || !strcmp(menu, "d"))
+               {
+                       char menu[2];
+
+                       printf("Do you really wanna delete all messages [Y or N] ?\n");
+
+                       memset(menu, 0x00, sizeof(menu));
+                       cin.getline(menu, 2);
+
+                       if (!strcmp(menu, "Y"))
+                               msg_delete_all_msgs_in_folder(hMsgHandle, (MSG_FOLDER_ID_T)FolderId, false);
+               }
+               else if (!strcmp(menu, "B") || !strcmp(menu, "b"))
+               {
+                       break;
+               }
+               else
+               {
+                       int msgId = atoi(menu);
+
+                       for (int i = 0; i < folderViewList.nCount; i++)
+                       {
+                               if ( msg_get_message_id( folderViewList.msgInfo[i] ) == msgId)
+                               {
+                                       MsgType = msg_get_message_type(folderViewList.msgInfo[i]);
+                                       NetworkStatus = msg_get_network_status(folderViewList.msgInfo[i]);
+
+                                       MsgRunMsgListMenu(hMsgHandle, msgId, FolderId, MsgType, NetworkStatus);
+
+                                       break;
+                               }
+                       }
+               }
+
+               msg_release_message_list(&folderViewList);
+               printf("release folderview list [%d]\n", folderViewList.nCount);
+       }
+       while (strcmp(menu, "B"));
+}
+
+
+void MsgTestUpdateMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_SENDINGOPT_S sendOpt = {0, };
+
+       print("\n===== Input Message =====");
+       print("Input Message Text :");
+
+       char strMsg[1024] = {0};
+
+//     strcpy(strMsg, "ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ");
+       cin.getline(strMsg, 1024);
+
+       msg_sms_set_message_body(pMsg, strMsg, strlen(strMsg));
+
+       int nToCnt = msg_get_address_count(pMsg);
+
+       char strNumber[MAX_ADDRESS_VAL_LEN] = {0};
+
+       printf("\n===== Add Recipient =====\n");
+
+       MSG_DEBUG("address count [%d]", nToCnt);
+
+       if (nToCnt > 0)
+       {
+               msg_reset_address(pMsg);
+       }
+
+       printf("\nInput Recipient Number. Press 'N' if you don't want : \n");
+
+       cin.getline(strNumber, 1024);
+
+       if (strcmp(strNumber, "N"))
+       {
+               MSG_DEBUG("strNumber [%s]", strNumber);
+
+               msg_add_address(pMsg, strNumber, MSG_RECIPIENTS_TYPE_TO);
+
+               MSG_DEBUG("contactVal [%s]", msg_get_ith_address(pMsg, 0));
+
+               MSG_DEBUG("nToContactCnt [%d]", msg_get_address_count(pMsg));
+       }
+
+       print("\nInput Message Sending Option ?. 'Y' : Yes 'N' : No  ");
+
+       char bSendOpt = 0, ch = 0;
+       cin >> bSendOpt;
+       ch = cin.get();
+
+       if( bSendOpt == 'Y' || bSendOpt == 'y')
+       {
+               sendOpt.bSetting = true;
+
+               /* EX : Set SendingOption */
+               if( msg_is_sms(pMsg) )
+               {
+                       printf("\nRequest Delivery Report? Press 'Y' or 'N' :\n");
+                       char bDelivery = 0;
+                       ch = 0;
+                       cin >> bDelivery;
+                       ch = cin.get();
+
+                       if( bDelivery == 'Y' || bDelivery == 'y')
+                               sendOpt.bDeliverReq = true;
+                       else
+                               sendOpt.bDeliverReq = false;
+
+                       print("\nKeep a Copy? Press 'Y' or 'N' :");
+                       char bKeepCopy = 0;
+                       ch = 0;
+                       cin >> bKeepCopy;
+                       ch = cin.get();
+
+                       if( bKeepCopy == 'Y' || bKeepCopy == 'y')
+                               sendOpt.bKeepCopy = true;
+                       else
+                               sendOpt.bKeepCopy = false;
+
+                       print("\nSet Reply Path? Press 'Y' or 'N' :");
+                       char bReplyPath = 0;
+                       ch = 0;
+                       cin >> bReplyPath;
+                       ch = cin.get();
+
+                       if( bReplyPath == 'Y' || bReplyPath == 'y')
+                               sendOpt.option.smsSendOpt.bReplyPath = true;
+                       else
+                               sendOpt.option.smsSendOpt.bReplyPath = false;
+               }
+               else if( msg_is_mms(pMsg) )
+               {
+                       print("\nRequest Delivery Report? Press 'Y' or 'N' :");
+                       char bDelivery = 0;
+                       ch = 0;
+                       cin >> bDelivery;
+                       ch = cin.get();
+
+                       if( bDelivery == 'Y' || bDelivery == 'y')
+                               sendOpt.bDeliverReq = true;
+                       else
+                               sendOpt.bDeliverReq = false;
+
+                       print("\nKeep a Copy? Press 'Y' or 'N' :");
+                       char bKeepCopy = 0;
+                       ch = 0;
+                       cin >> bKeepCopy;
+                       ch = cin.get();
+
+                       if( bKeepCopy == 'Y' || bKeepCopy == 'y')
+                               sendOpt.bKeepCopy = true;
+                       else
+                               sendOpt.bKeepCopy = false;
+
+                       print("\nRequest Read Report? Press 'Y' or 'N' :");
+                       char bRead = 0;
+                       ch = 0;
+                       cin >> bRead;
+                       ch = cin.get();
+
+                       if( bRead == 'Y' || bRead == 'y')
+                               sendOpt.option.mmsSendOpt.bReadReq = true;
+                       else
+                               sendOpt.option.mmsSendOpt.bReadReq = false;
+
+                       print("\nSet Priority? 'U' : Ugent, 'N' : Normal, 'L' : Low");
+                       char priority = 0;
+                       ch = 0;
+                       cin >> priority;
+                       ch = cin.get();
+
+                       if( priority == 'U' || priority == 'u')
+                               sendOpt.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_HIGH;
+                       else if( priority == 'N' || priority == 'n')
+                               sendOpt.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_NORMAL;
+                       else if( priority == 'L' || priority == 'l')
+                               sendOpt.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_LOW;
+
+                       print("\nSet Expiry Time? '0' : Max '1' : 1 Day, '2' : 2 Days, '3' : 1 Week, '4' : 2 Weeks ");
+                       char expiryTime = 0;
+                       ch = 0;
+                       cin >> expiryTime;
+                       ch = cin.get();
+
+                       if( expiryTime == '0')
+                               sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_MAXIMUM;
+                       else if( expiryTime == '1')
+                               sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_1DAY;
+                       else if( expiryTime == '2')
+                               sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_2DAYS;
+                       else if( expiryTime == '3')
+                               sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_1WEEK;
+                       else if( expiryTime == '4')
+                               sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_2WEEKS;
+
+                       print("\nSet Delivery Time? '0' : Immediately '1' : 1 Hour, '2' : 1 Day, '3' : 1 Week ");
+                       char deliveryTime = 0;
+                       ch = 0;
+                       cin >> deliveryTime;
+                       ch = cin.get();
+
+                       if( expiryTime == '0')
+                               sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_IMMEDIATLY;
+                       else if( expiryTime == '1')
+                               sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_1HOUR;
+                       else if( expiryTime == '2')
+                               sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_1DAY;
+                       else if( expiryTime == '3')
+                               sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_1WEEK;
+
+               }
+       }
+       else            /* In case of No setting per Message, Set Message option with Global Setting value */
+       {
+               sendOpt.bSetting = false;
+       }
+
+       err = msg_update_message(hMsgHandle, pMsg, &sendOpt);
+
+       if (err == MSG_SUCCESS)
+               print("Update Message is OK!");
+       else
+               print("Update Message is failed!");
+}
+
+
+void MsgTestMoveMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T MsgId)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char strFolder[3];
+
+       print("======================================");
+
+       for (int i = 3; i < g_folderList.nCount; i++)
+               printf("[%d] %s", g_folderList.folderInfo[i].folderId, g_folderList.folderInfo[i].folderName);
+
+       print("======================================");
+
+       print("Select Folder :");
+
+       memset(strFolder, 0x00, sizeof(strFolder));
+       cin.getline(strFolder, 3);
+
+       int nFolder = atoi(strFolder);
+
+       if (nFolder <= 3 || nFolder > g_folderList.nCount)
+       {
+               print("Select Wrong Folder!!!");
+       }
+       else
+       {
+               err = msg_move_msg_to_folder(hMsgHandle, MsgId, nFolder);
+
+               if (err == MSG_SUCCESS)
+                       print("Moving Message is OK!");
+               else
+                       print("Moving Message is failed!");
+       }
+}
+
+void MsgTestMoveStorageMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pmsg)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       if(msg_is_in_sim(pmsg))
+               err = msg_move_msg_to_storage( hMsgHandle, msg_get_message_id(pmsg), MSG_STORAGE_PHONE);
+       else
+               err = msg_move_msg_to_storage( hMsgHandle, msg_get_message_id(pmsg), MSG_STORAGE_SIM);
+
+       if (err == MSG_SUCCESS)
+               print("Moving Message is OK!");
+       else
+               print("Moving Message is failed!");
+}
+
+
+void MsgTestAddFolder(MSG_HANDLE_T hMsgHandle)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       // Make Folder
+       MSG_FOLDER_INFO_S folderInfo = {};
+
+       folderInfo.folderId = 0;
+       folderInfo.folderType = MSG_FOLDER_TYPE_USER_DEF;
+
+       print("Input Folder Name :");
+
+       char strName[MAX_FOLDER_NAME_SIZE+1];
+       memset(strName, 0x00, sizeof(strName));
+
+       cin.getline(strName, MAX_FOLDER_NAME_SIZE);
+
+       strncpy(folderInfo.folderName, strName, MAX_FOLDER_NAME_SIZE);
+
+       MSG_DEBUG("folderId [%d]", folderInfo.folderId);
+       MSG_DEBUG("folderType [%d]", folderInfo.folderType);
+       MSG_DEBUG("folderName [%s]", folderInfo.folderName);
+
+       print("Start Creating New Folder...");
+
+       err = msg_add_folder(hMsgHandle, &folderInfo);
+
+       if (err == MSG_SUCCESS)
+               print("Creating New Folder is OK!");
+       else
+               print("Creating New Folder is failed!");
+}
+
+
+void MsgTestUpdateFolder(MSG_HANDLE_T hMsgHandle)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       // Make Folder
+       MSG_FOLDER_INFO_S folderInfo;
+
+       print("Select Folder to Update :");
+
+       char strId[3];
+       memset(strId, 0x00, sizeof(strId));
+
+       cin.getline(strId, 3);
+
+       folderInfo.folderId = atoi(strId);
+
+       if (folderInfo.folderId <= MSG_DRAFT_ID)
+       {
+               print("Wrong Folder ID!!");
+               return;
+       }
+
+       folderInfo.folderType = g_folderList.folderInfo[folderInfo.folderId-1].folderType;
+
+       print("Input New Folder Name :");
+
+       char strName[MAX_FOLDER_NAME_SIZE+1];
+       memset(strName, 0x00, sizeof(strName));
+
+       cin.getline(strName, MAX_FOLDER_NAME_SIZE);
+
+       strncpy(folderInfo.folderName, strName, MAX_FOLDER_NAME_SIZE);
+
+       MSG_DEBUG("folderId [%d]", folderInfo.folderId);
+       MSG_DEBUG("folderType [%d]", folderInfo.folderType);
+       MSG_DEBUG("folderName [%s]", folderInfo.folderName);
+
+       print("Start Updating Folder...");
+
+       err = msg_update_folder(hMsgHandle, &folderInfo);
+
+       if (err == MSG_SUCCESS)
+               print("Updating Folder is OK!");
+       else
+               print("Updating Folder is failed!");
+}
+
+
+void MsgTestDeleteFolder(MSG_HANDLE_T hMsgHandle)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       print("Select Folder to Delete :");
+
+       char strId[3];
+       memset(strId, 0x00, sizeof(strId));
+
+       cin.getline(strId, 3);
+
+       MSG_FOLDER_ID_T folderId = atoi(strId);
+
+       if (folderId <= MSG_DRAFT_ID)
+       {
+               print("Wrong Folder ID!!");
+               return;
+       }
+
+       print("Start Deleting Folder...");
+
+       err = msg_delete_folder(hMsgHandle, folderId);
+
+       if (err == MSG_SUCCESS)
+               print("Deleting Folder is OK!");
+       else
+               print("Deleting Folder is failed!");
+}
+
+
+void MsgTestDeleteMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
+{
+       msg_mms_send_read_report(hMsgHandle, nMsgId, MSG_READ_REPORT_IS_DELETED);
+
+       if (msg_delete_message(hMsgHandle, nMsgId) != MSG_SUCCESS)
+               print("Failed to delete Message");
+}
+
+
+void MsgTestForwardMMSMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
+{
+       msg_message_t msg = msg_new_message();
+
+       MSG_SENDINGOPT_S sendOpt = {0};
+
+       if (msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)nMsgId, msg, &sendOpt) != MSG_SUCCESS)
+       {
+               print("Failed to get Message");
+               msg_release_message(&msg);
+               return;
+       }
+
+       // Update Read Status
+       msg_update_read_status(hMsgHandle, msg_get_message_id(msg), true);
+
+       // send read report
+       msg_mms_send_read_report(hMsgHandle, nMsgId, MSG_READ_REPORT_IS_READ);
+
+       // read address from stdin
+       char strNumber[MAX_ADDRESS_VAL_LEN];
+
+       memset(strNumber, 0x00, sizeof(strNumber));
+
+       printf("\nInput Recipient Number. Press 'N' if you don't want : \n");
+
+       cin.getline(strNumber, 1024);
+
+       if (!strcmp(strNumber, "N"))
+       {
+               msg_release_message(&msg);
+               return;
+       }
+
+       // write address
+       msg_reset_address(msg);
+       msg_add_address(msg, strNumber, MSG_RECIPIENTS_TYPE_TO);
+
+       // write subject for forward msg
+       char strSubject[MAX_SUBJECT_LEN] = {0};
+       snprintf(strSubject, MAX_SUBJECT_LEN, "FW: %s", msg_get_subject(msg));
+       msg_set_subject(msg, strSubject);
+
+       // forward the message
+       MSG_REQUEST_S req = {0};
+       req.msg = msg;
+       req.sendOpt = sendOpt;
+
+       if (msg_mms_forward_message(hMsgHandle, &req) != MSG_SUCCESS)
+               printf("Failed to Forward Message\n");
+
+       msg_release_message(&msg);
+}
+
+
+void MsgTestRetrieveMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       msg_message_t msg = msg_new_message();
+       MSG_SENDINGOPT_S sendOpt = {0};
+
+       err = msg_get_message(hMsgHandle, nMsgId, msg, &sendOpt);
+
+       msg_update_read_status(hMsgHandle, msg_get_message_id(msg), true);
+
+       if( err != MSG_SUCCESS)
+               print("Get Message Failed!");
+
+       MSG_REQUEST_S req = {0, msg, sendOpt};
+
+       err = msg_mms_retrieve_message(hMsgHandle, &req);
+
+       if( err != MSG_SUCCESS)
+               print("Retrieve MMS Message Failed!");
+}
+
+/* reject_msg_support */
+void MsgTestRejectMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       msg_message_t msg = msg_new_message();
+       MSG_SENDINGOPT_S sendOpt = {0, };
+
+       err = msg_get_message(hMsgHandle, nMsgId, msg, &sendOpt);
+
+       if( err != MSG_SUCCESS)
+               print("Get Message Failed!");
+
+       MSG_REQUEST_S req = {0};
+       req.msg = msg;
+       req.sendOpt = sendOpt;
+
+       err = msg_mms_reject_message(hMsgHandle, &req);
+
+       if( err != MSG_SUCCESS)
+               print("Retrieve MMS Message Failed!");
+
+       msg_release_message(&msg);
+}
+/* reject_msg_support */
+
+void MsgTestUpdateMMSMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
+{
+       MSG_DEBUG("Update MMS Message");
+
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       msg_message_t msg = msg_new_message();
+
+       MSG_SENDINGOPT_S sendOpt = {0};
+
+       err = msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)nMsgId, msg, &sendOpt);
+
+       if (err != MSG_SUCCESS)
+       {
+               print("Get Message Failed!");
+               msg_release_message(&msg);
+
+               return;
+       }
+
+       MMS_MESSAGE_DATA_S *msgBody = msg_mms_create_message();
+
+       msg_mms_get_message_body(msg, msgBody);
+
+       msg_mms_add_attachment(msgBody, (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+       msg_mms_add_attachment(msgBody, (char*)"/opt/etc/msg-service/audio.amr");
+
+       msg_mms_set_message_body(msg, msgBody);
+
+       time_t curTime = time(NULL);
+       msg_set_time(msg, curTime);
+       msg_set_network_status(msg, MSG_NETWORK_NOT_SEND);
+       msg_set_read_status(msg, false);
+       msg_set_protect_status(msg, false);
+       msg_set_direction_info(msg, MSG_DIRECTION_TYPE_MO);
+
+       err= msg_update_message(hMsgHandle, msg, &sendOpt);
+
+       msg_mms_destroy_message(msgBody);
+
+       msg_release_message(&msg);
+}
+
+
+void MsgPrintMMSBody(msg_message_t pMsg)
+{
+       MMS_MESSAGE_DATA_S *msgBody = msg_mms_create_message();
+       msg_mms_get_message_body(pMsg, msgBody);
+
+       //Multipart Related
+       if (msgBody->pageCnt)
+       {
+               printf("multipart type: Multipart Related\n");
+
+               //Print root-layout info
+               printf("\n** ROOT LAYOUT INFO **\n");
+               printf("width: %d %s\nheight: %d %s\nbgColor:%x\n", msgBody->rootlayout.width.value, msgBody->rootlayout.width.bUnitPercent ? "%" : "",
+                        msgBody->rootlayout.height.value,  msgBody->rootlayout.height.bUnitPercent ? "%" : "", msgBody->rootlayout.bgColor);
+
+               // Print Region Info
+               printf("\n** REGION INFO **\n");
+               printf("Region Count: %d\n", msgBody->regionCnt);
+
+               for(int i = 0; i < msgBody->regionCnt; ++i)
+               {
+                       MMS_SMIL_REGION *pRegion = msg_mms_get_smil_region(msgBody, i);
+
+                       printf("%d region id: %s\n%d region left : %d %s\n%d region top : %d %s\n%d region width : %d %s\n%d region height : %d %s\n%d region bgColor : %x\n%d region fit : %s\n",
+                               i, pRegion->szID, i, pRegion->nLeft.value, pRegion->nLeft.bUnitPercent ? "%": "", i, pRegion->nTop.value, pRegion->nTop.bUnitPercent ? "%": "",
+                               i, pRegion->width.value, pRegion->width.bUnitPercent ? "%": "", i, pRegion->height.value, pRegion->height.bUnitPercent ? "%": "",
+                               i, pRegion->bgColor, i, (pRegion->fit == MMSUI_IMAGE_REGION_FIT_MEET) ? "MEET" : "HIDDEN");
+               }
+
+               printf("\n** PAGES & CONTENTS INFO **\n");
+               printf("PAGE Count: %d\n", msgBody->pageCnt);
+
+               // Print Page info
+               for(int i = 0; i< msgBody->pageCnt; ++i)
+               {
+                       MMS_PAGE_S *pPage = msg_mms_get_page(msgBody, i);
+
+                       printf("%d page's duration: %d msec \n%d page's media count: %d\n", i, pPage->nDur, i, pPage->mediaCnt);
+
+                       // Print Contents Info
+                       for(int j = 0; j < pPage->mediaCnt; ++j)
+                       {
+                               MMS_MEDIA_S *pMedia = msg_mms_get_media(pPage, j);
+                               printf("%d media's filename: %s\n%d media's filepath: %s\n%d media's regionId: %s\n Bold: %d\n Italic: %d\n", j, pMedia->szFileName, j, pMedia->szFilePath, j, pMedia->regionId, pMedia->sMedia.sText.bBold, pMedia->sMedia.sText.bItalic);
+
+                               if (pMedia->drmType != MSG_DRM_TYPE_NONE)
+                               {
+                                       printf("%d media's drmtype: %d (1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery\n%d media's drmpath: %s\n", j, pMedia->drmType, j, pMedia->szDrm2FullPath);
+                               }
+                       }
+                       printf("\n");
+               }
+       }
+       else
+       {
+               printf("multipart type: Multipart Mixed\n");
+       }
+
+       printf("Attachment Count: %d\n", msgBody->attachCnt);
+
+       for(int i = 0; i < msgBody->attachCnt; ++i)
+       {
+               MMS_ATTACH_S *pAttach = msg_mms_get_attachment(msgBody, i);
+               printf("Attachment file Name: %s\n", pAttach->szFileName);
+               printf("Attachment file Path: %s\n", pAttach->szFilePath);
+               printf("Attached file size: %d\n", pAttach->fileSize);
+
+               if (pAttach->drmType != MSG_DRM_TYPE_NONE)
+                       printf("%d media's drmtype: %d (1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery\n%d media's drmpath: %s\n", i, pAttach->drmType, i, pAttach->szDrm2FullPath);
+       }
+
+       /*destroy and free message data*/
+       msg_mms_destroy_message(msgBody);
+
+}
+
+
+void MsgPrintMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg, MSG_SENDINGOPT_S* pSendOpt)
+{
+       MSG_FOLDER_ID_T folderId = msg_get_folder_id(pMsg);
+
+       system ("clear" );
+
+       printf("======================================\n");
+       printf("============== Message ==============\n");
+       printf("======================================\n");
+
+       if (msg_is_mms(pMsg) && msg_get_message_type(pMsg) == MSG_TYPE_MMS_NOTI)
+       {
+               MMS_MESSAGE_DATA_S *msgBody = msg_mms_create_message();
+
+               msg_mms_get_message_body(pMsg, msgBody);
+
+               //Multipart Related
+               if (msgBody->pageCnt)
+               {
+                       printf("multipart type: Multipart Related\n");
+
+                       //Print root-layout info
+                       printf("\n** ROOT LAYOUT INFO **\n");
+                       printf("width: %d %s\nheight: %d %s\nbgColor:%x\n", msgBody->rootlayout.width.value, msgBody->rootlayout.width.bUnitPercent ? "%" : "",
+                                msgBody->rootlayout.height.value,  msgBody->rootlayout.height.bUnitPercent ? "%" : "", msgBody->rootlayout.bgColor);
+
+                       // Print Region Info
+                       printf("\n** REGION INFO **\n");
+                       printf("Region Count: %d\n", msgBody->regionCnt);
+
+                       for(int i = 0; i < msgBody->regionCnt; ++i)
+                       {
+                               MMS_SMIL_REGION* pRegion = msg_mms_get_smil_region(msgBody, i);
+
+                               printf("%d region id: %s\n%d region left : %d %s\n%d region top : %d %s\n%d region width : %d %s\n%d region height : %d %s\n%d region bgColor : %x\n %d region fit : %s\n",
+                                       i, pRegion->szID, i, pRegion->nLeft.value, pRegion->nLeft.bUnitPercent ? "%": "", i, pRegion->nTop.value, pRegion->nTop.bUnitPercent ? "%": "",
+                                       i, pRegion->width.value, pRegion->width.bUnitPercent ? "%": "", i, pRegion->height.value, pRegion->height.bUnitPercent ? "%": "",
+                                       i, pRegion->bgColor, i, (pRegion->fit == MMSUI_IMAGE_REGION_FIT_MEET) ? "MEET" : "HIDDEN");
+                       }
+
+                       printf("\n** PAGES & CONTENTS INFO **\n");
+                       printf("PAGE Count: %d\n", msgBody->pageCnt);
+
+                       // Print Page info
+                       for(int i = 0; i< msgBody->pageCnt; ++i)
+                       {
+                               MMS_PAGE_S* pPage = msg_mms_get_page(msgBody, i);
+
+                               printf("%d page's duration: %d msec \n%d page's media count: %d\n", i, pPage->nDur, i, pPage->mediaCnt);
+
+                               // Print Contents Info
+                               for(int j = 0; j < pPage->mediaCnt; ++j)
+                               {
+                                       MMS_MEDIA_S* pMedia = msg_mms_get_media(pPage, j);
+                                       printf("%d media's filename: %s\n%d media's filepath: %s\n%d media's regionId: %s\n Bold: %d\n Italic: %d\n", j, pMedia->szFileName, j, pMedia->szFilePath, j, pMedia->regionId, pMedia->sMedia.sText.bBold, pMedia->sMedia.sText.bItalic);
+
+                                       if(pMedia->drmType != MSG_DRM_TYPE_NONE)
+                                       {
+                                               printf("%d media's drmtype: %d (1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery\n%d media's drmpath: %s\n", j, pMedia->drmType, j, pMedia->szDrm2FullPath);
+                                       }
+
+                               }
+                               printf("\n");
+                       }
+               }
+
+               else
+               {
+                       printf("multipart type: Multipart Mixed\n");
+               }
+
+               for(int i = 0; i < msgBody->attachCnt; ++i)
+               {
+                       MMS_ATTACH_S*   pAttach = msg_mms_get_attachment(msgBody, i);
+                       printf("Attachment file Name: %s\n", pAttach->szFileName);
+                       printf("Attachment file Path: %s\n", pAttach->szFilePath);
+                       printf("Attached file size: %d\n", pAttach->fileSize);
+
+                       if(pAttach->drmType != MSG_DRM_TYPE_NONE)
+                               printf("%d media's drmtype: %d (1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery\n%d media's drmpath: %s\n", i, pAttach->drmType, i, pAttach->szDrm2FullPath);
+               }
+
+               char displayTime[32];
+               memset(displayTime, 0x00, sizeof(displayTime));
+
+               MsgConvertTime(msg_get_time(pMsg), displayTime);
+
+               printf("date & time: %s\n", displayTime);
+               printf("from address: %s\n", msg_get_ith_address(pMsg, 0));
+
+               if(msg_is_sms(pMsg))
+               {
+                       printf("*** SMS Setting Value ***\n");
+                       printf("Delivery Request : %d\n", pSendOpt->bDeliverReq);
+                       printf("Reply Path : %d\n", pSendOpt->option.smsSendOpt.bReplyPath);
+               }
+               else if(msg_is_mms(pMsg))
+               {
+                       printf("Subject: %s\n", msg_get_subject(pMsg));
+
+                       char expiryTime[32];
+                       memset(expiryTime, 0x00, sizeof(expiryTime));
+
+                       MsgConvertTime(&(pSendOpt->option.mmsSendOpt.expiryTime), expiryTime);
+
+                       printf("*** MMS Setting Value ***\n ");
+                       printf("Delivery Requeset : %d\n Read Report Request : %d\n Priority : %d\n ExpiryTime : %s\n\n",
+                               pSendOpt->bDeliverReq, pSendOpt->option.mmsSendOpt.bReadReq, pSendOpt->option.mmsSendOpt.priority, expiryTime);
+
+                       MSG_REPORT_STATUS_INFO_S reportStatus = {};
+
+                       msg_get_report_status(hMsgHandle, msg_get_message_id(pMsg), &reportStatus);
+
+                       memset(expiryTime, 0x00, sizeof(expiryTime));
+                       MsgConvertTime(&(reportStatus.deliveryStatusTime), expiryTime);
+
+                       printf("Delivery Report Status : %d\n Delivery Report Status Time: %s\n ",
+                               reportStatus.deliveryStatus, expiryTime);
+
+                       memset(expiryTime, 0x00, sizeof(expiryTime));
+                       MsgConvertTime(&(reportStatus.readStatusTime), expiryTime);
+
+                       printf("Read Report Status : %d\n Read Report Status Time: %s\n ",
+                               reportStatus.readStatus, expiryTime);
+               }
+
+               printf("======================================\n");
+               printf("[R] Reply\n[T] rTreive MMS\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Sim\n[P] Protect\n[B] Back");
+
+               /*destroy and free message data*/
+               msg_mms_destroy_message(msgBody);
+       }
+       else if (folderId == MSG_INBOX_ID)
+       {
+               char displayTime[32];
+               memset(displayTime, 0x00, sizeof(displayTime));
+
+               MsgConvertTime(msg_get_time(pMsg), displayTime);
+
+               const char* msgText = NULL;
+
+               int msgType = msg_get_message_type(pMsg);
+
+               if (msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS) {
+                       msgText = msg_mms_get_text_contents(pMsg);
+               } else {
+                       msgText = msg_sms_get_message_body(pMsg);
+               }
+
+               printf("message text\n[%s]\n\ndate & time : [%s]\n\naddress : [%s]\nname : [%s]\ncontact ID : [%d]\n",
+                                          msgText, displayTime, msg_get_ith_address(pMsg, 0), msg_get_ith_name(pMsg, 0), msg_get_ith_contact_id(pMsg, 0));
+
+               if (msg_is_mms(pMsg)) {
+                       printf("Subject: %s\n", msg_get_subject(pMsg));
+                       MsgPrintMMSBody(pMsg);
+               }
+
+               if(msg_is_in_sim(pMsg))
+               {
+                       printf("\nstorage : [Sim Card]\n");
+                       printf("======================================\n");
+//                     if(msg_get_message_type(pMsg) == MSG_TYPE_SMS_SYNCML)
+                               printf("[R] Reply\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Phone\n[P] Protect\n[B] Back\n[I] Install CP Message");
+//                     else
+//                             printf("[R] Reply\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Phone\n[P] Protect\n[B] Back");
+               }
+               else
+               {
+                       printf("======================================\n");
+//                     if(msg_get_message_type(pMsg) == MSG_TYPE_SMS_SYNCML)
+                               printf("[R] Reply\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Sim\n[P] Protect\n[B] Back\n[I] Install CP Message");
+//                     else
+//                             printf("[R] Reply\n[T] rTreive MMS\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Sim\n[P] Protect\n[B] Back");
+               }
+       }
+       else if (folderId == MSG_OUTBOX_ID)
+       {
+               char displayTime[32];
+               memset(displayTime, 0x00, sizeof(displayTime));
+
+               MsgConvertTime(msg_get_time(pMsg), displayTime);
+
+               const char* msgText = NULL;
+
+               int msgType = msg_get_message_type(pMsg);
+
+               if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
+                       msgText = msg_mms_get_text_contents(pMsg);
+               else
+                       msgText = msg_sms_get_message_body(pMsg);
+
+               printf("message text\n[%s]\n\ndate & time : [%s]\n\n", msgText, displayTime);
+
+               int addr_count = msg_get_address_count(pMsg);
+               for (int i = 0; i < addr_count; i++)
+                       printf("address : [%s]\nname : [%s]\ncontact ID : [%d]\n\n", msg_get_ith_address(pMsg, i), msg_get_ith_name (pMsg, i), msg_get_ith_contact_id(pMsg, i) );
+
+
+               if(msg_is_in_sim(pMsg))
+               {
+                       printf("\nstorage : [Sim Card]\n");
+                       printf("======================================\n");
+                       printf("[S] Send\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Phone\n[P] Protect\n[B] Back");
+               }
+               else
+               {
+                       printf("======================================\n");
+                       printf("[S] Send\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Sim\n[P] Protect\n[B] Back");
+               }
+       }
+       else if (folderId == MSG_DRAFT_ID)
+       {
+               char displayTime[32];
+               memset(displayTime, 0x00, sizeof(displayTime));
+
+               MsgConvertTime(msg_get_time(pMsg), displayTime);
+
+               const char* msgText = NULL;
+
+               int msgType = msg_get_message_type(pMsg);
+
+               if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
+                       msgText = msg_mms_get_text_contents(pMsg);
+               else
+                       msgText = msg_sms_get_message_body(pMsg);
+
+               printf("message text\n[%s]\n\ndate & time : [%s]\n\n", msgText, displayTime);
+
+               int addr_count = msg_get_address_count(pMsg);
+               for (int i = 0; i < addr_count; i++)
+                       printf("address : [%s]\nname : [%s]\ncontact ID : [%d]\n\n", msg_get_ith_address(pMsg, i), msg_get_ith_name (pMsg, i), msg_get_ith_contact_id(pMsg, i));
+
+               printf("======================================\n");
+               printf("[S] Send\n[E] Edit\n[D] Delete\n[C] Change Folder\n[P] Protect\n[B] Back");
+       }
+       else
+       {
+               char displayTime[32];
+               memset(displayTime, 0x00, sizeof(displayTime));
+
+               MsgConvertTime(msg_get_time(pMsg), displayTime);
+
+               const char* msgText = NULL;
+
+               int msgType = msg_get_message_type(pMsg);
+
+               if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
+                       msgText = msg_mms_get_text_contents(pMsg);
+               else
+                       msgText = msg_sms_get_message_body(pMsg);
+
+               printf("message text\n[%s]\n\ndate & time : [%s]\n\n", msgText, displayTime);
+
+               int addr_count = msg_get_address_count(pMsg);
+               for (int i = 0; i < addr_count; i++)
+                       printf("address : [%s]\nname : [%s]\ncontact ID : [%d]\n\n", msg_get_ith_address(pMsg, i), msg_get_ith_name(pMsg, i), msg_get_ith_contact_id(pMsg, i));
+
+               if(msg_is_sms(pMsg))
+               {
+                       printf("*** SMS Setting Value ***\n");
+                       printf("Delivery Requeset : %d\nReply Path : %d\n", pSendOpt->bDeliverReq, pSendOpt->option.smsSendOpt.bReplyPath);
+               }
+               else if(msg_is_mms(pMsg))
+               {
+                       printf("Subject: %s\n", msg_get_subject(pMsg));
+
+                       char expiryTime[32];
+                       memset(expiryTime, 0x00, sizeof(expiryTime));
+
+                       MsgConvertTime(&(pSendOpt->option.mmsSendOpt.expiryTime), expiryTime);
+
+                       printf("*** MMS Setting Value ***\n ");
+                       printf("Delivery Requeset : %d\n Read Report Request : %d\n Priority : %d\n ExpiryTime : %s\n\n",
+                               pSendOpt->bDeliverReq, pSendOpt->option.mmsSendOpt.bReadReq, pSendOpt->option.mmsSendOpt.priority, expiryTime);
+
+                       MSG_REPORT_STATUS_INFO_S reportStatus = {};
+
+                       msg_get_report_status(hMsgHandle, msg_get_message_id(pMsg), &reportStatus);
+
+                       memset(expiryTime, 0x00, sizeof(expiryTime));
+                       MsgConvertTime(&(reportStatus.deliveryStatusTime), expiryTime);
+
+                       printf("Delivery Report Status : %d\n Delivery Report Status Time: %s\n ",
+                               reportStatus.deliveryStatus, expiryTime);
+
+                       memset(expiryTime, 0x00, sizeof(expiryTime));
+                       MsgConvertTime(&(reportStatus.readStatusTime), expiryTime);
+
+                       printf("Read Report Status : %d\n Read Report Status Time: %s\n ",
+                               reportStatus.readStatus, expiryTime);
+
+                       MsgPrintMMSBody(pMsg);
+               }
+
+
+               printf("======================================\n");
+               printf("[D] Delete\n[P] Protect\n[B] Back");
+       }
+
+       printf("\n======================================\n");
+       print("Input : ");
+
+       char select = 0, ch = 0;
+
+       cin >> select;
+       ch = cin.get();
+
+       MsgRunMsgMenu(hMsgHandle, select, pMsg, pSendOpt);
+}
+
+
+void MsgRunMsgMenu(MSG_HANDLE_T hMsgHandle, char Menu, msg_message_t pMsg, MSG_SENDINGOPT_S *pSendOpt)
+{
+       switch (Menu)
+       {
+               case 'R' :
+               {
+
+
+               }
+               break;
+
+               case 'T' :
+               {
+
+               }
+
+               case 'F' :
+               {
+
+
+               }
+               break;
+
+               case 'D' : // Delete Message
+               {
+                       if ( msg_is_protected(pMsg))
+                               print("The message is protected. You cannot delete.");
+                       else
+                               msg_delete_message(hMsgHandle, msg_get_message_id(pMsg));
+               }
+               break;
+
+               case 'C' : // Move Message to other folder
+               {
+                       MsgTestMoveMessage(hMsgHandle, msg_get_message_id(pMsg));
+               }
+               break;
+
+               case 'M' : // Move to Sim
+               {
+                       MsgTestMoveStorageMessage(hMsgHandle, pMsg);
+               }
+               break;
+
+               case 'P' :  // Set Protect
+               {
+                       if (msg_is_protected(pMsg))
+                               msg_update_protected_status(hMsgHandle, msg_get_message_id(pMsg), false);
+                       else
+                               msg_update_protected_status(hMsgHandle, msg_get_message_id(pMsg), true);
+               }
+               break;
+
+               case 'S' :
+               {
+                       MsgTestSubmitReq(hMsgHandle, pMsg, NULL); // fuction call to "MsgTestTransport.cpp"
+               }
+               break;
+
+               case 'E' :
+               {
+                       MsgTestUpdateMessage(hMsgHandle, pMsg);
+               }
+               break;
+
+               case 'B' :
+               break;
+
+               case 'I' :
+               {
+                       //if(msg_get_message_type(pMsg) == MSG_TYPE_SMS_SYNCML)
+                               msg_syncml_message_operation(hMsgHandle, (MSG_MESSAGE_ID_T)msg_get_message_id(pMsg));
+               }
+               break;
+
+               default :
+               {
+                       print("Not Supported Menu");
+               }
+               break;
+       }
+}
+
+
+void MsgRunMsgListMenu(MSG_HANDLE_T hMsgHandle, int MsgId, int FolderId, MSG_MESSAGE_TYPE_T MsgType, MSG_NETWORK_STATUS_T NetworkStatus)
+{
+       if (MsgType == MSG_TYPE_SMS || MsgType == MSG_TYPE_SMS_CB || MsgType == MSG_TYPE_SMS_JAVACB ||
+               MsgType == MSG_TYPE_SMS_MWI || MsgType == MSG_TYPE_SMS_SYNCML || MsgType == MSG_TYPE_SMS_WAPPUSH)
+       {
+               if (MsgId > 0 && MsgId <= 9999)
+               {
+                       MsgTestGetMessage(hMsgHandle, MsgId);
+               }
+               else
+               {
+                       print("Not Supported Msg Id");
+                       return;
+               }
+       }
+       else if (MsgType == MSG_TYPE_MMS || MsgType == MSG_TYPE_MMS_JAVA || MsgType == MSG_TYPE_MMS_NOTI)
+       {
+               char menu[2];
+
+               if(NetworkStatus == MSG_NETWORK_RETRIEVE_SUCCESS  ||NetworkStatus == MSG_NETWORK_SEND_SUCCESS ||
+                       NetworkStatus == MSG_NETWORK_SEND_FAIL || NetworkStatus == MSG_NETWORK_SENDING)
+               {
+                       print("======== Select ========");
+                       print("[R] Read MMS Message");
+                       print("[F] Forward MMS Message");
+                       print("[D] Delete MMS Message");
+                       print("[B] BACK");
+                       print("====================");
+                       print("Input : ");
+               }
+               else if(NetworkStatus == MSG_NETWORK_RETRIEVE_FAIL || NetworkStatus == MSG_NETWORK_RECEIVED)
+               {
+                       print("======== Select ========");
+                       print("[T] Retrieve MMS Message");
+                       print("[J] Reject MMS Message");
+                       print("[D] Delete MMS Message");
+                       print("[B] BACK");
+                       print("====================");
+                       print("Input : ");
+               }
+               else if(NetworkStatus == MSG_NETWORK_NOT_SEND)
+               {
+                       print("======== Select ========");
+                       print("[R] Read MMS Message");
+                       print("[U] Update MMS Message");
+                       print("[B] BACK");
+                       print("====================");
+                       print("Input : ");
+               }
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 2);
+
+               if (MsgId <= 0 || MsgId > 9999)
+               {
+                       print("Not Supported Msg Id");
+                       return;
+               }
+
+               if (!strcmp(menu, "R"))
+               {
+                       MsgTestGetMessage(hMsgHandle, MsgId);
+               }
+               else if (!strcmp(menu, "D"))
+               {
+                       MsgTestDeleteMessage(hMsgHandle, MsgId);
+               }
+               else if(!strcmp(menu, "F"))
+               {
+                       MsgTestForwardMMSMessage(hMsgHandle, MsgId);
+               }
+               else if(!strcmp(menu, "T"))
+               {
+                       MsgTestRetrieveMessage(hMsgHandle, MsgId);
+               }
+               /* reject_msg_support */
+               else if(!strcmp(menu, "J"))
+               {
+                       MsgTestRejectMessage(hMsgHandle, MsgId);
+               }
+               /* reject_msg_support */
+               else if(!strcmp(menu, "U"))
+               {
+                       MsgTestUpdateMMSMessage(hMsgHandle, MsgId);
+               }
+               else if (!strcmp(menu, "B"))
+               {
+                       return;
+               }
+       }
+}
+
+
+void MsgGetCurrentTime(time_t *pTime)
+{
+
+       time_t curTime;
+       time(&curTime);
+       //struct tm timeStruct = {0};
+       //localtime_r(&curTime, &timeStruct);
+
+       //memset(pTime, 0x00, sizeof(pTime));
+       //sprintf(pTime, "%04d-%02d-%02d %02d:%02d:%02d",
+       //      timeStruct.tm_year+1900, timeStruct.tm_mon+1, timeStruct.tm_mday,
+       //      timeStruct.tm_hour, timeStruct.tm_min, timeStruct.tm_sec);
+
+       *pTime = curTime;
+       MSG_DEBUG("Current time is %s", ctime(&curTime));
+}
+
+
+const char* MsgConvertMsgType(MSG_MESSAGE_TYPE_T MsgType)
+{
+       if (MsgType == MSG_TYPE_SMS)
+                       return "SMS";
+       else if (MsgType == MSG_TYPE_SMS_CB || MsgType == MSG_TYPE_SMS_JAVACB)
+                       return "CB";
+       else if (MsgType == MSG_TYPE_SMS_WAPPUSH)
+                       return "WAP";
+       else if (MsgType == MSG_TYPE_SMS_MWI)
+                       return "MWI";
+       else if (MsgType == MSG_TYPE_MMS || MsgType == MSG_TYPE_MMS_NOTI)
+               return "MMS";
+
+       return "UNKNOWN";
+}
+
+
+const char* MsgConvertStorageId(MSG_STORAGE_ID_T StorageId)
+{
+       if (StorageId == MSG_STORAGE_PHONE)
+               return "PHONE";
+       else if (StorageId == MSG_STORAGE_SIM)
+               return "SIM";
+
+       return "PHONE";
+}
+
+
+const char* MsgConvertNetworkStatus(MSG_NETWORK_STATUS_T status)
+{
+       switch (status)
+       {
+               case MSG_NETWORK_NOT_SEND :
+                       return "NOT SEND";
+               case MSG_NETWORK_SENDING :
+                       return "SENDING";
+               case MSG_NETWORK_SEND_SUCCESS :
+                       return "SENT";
+               case MSG_NETWORK_SEND_FAIL :
+                       return "FAIL TO SEND";
+               case MSG_NETWORK_DELIVER_SUCCESS :
+                       return "DELIVERED";
+               case MSG_NETWORK_DELIVER_FAIL :
+                       return "FAIL TO DELIVER";
+               case MSG_NETWORK_RECEIVED :
+                       return "RECEIVED";
+               case MSG_NETWORK_RETRIEVE_FAIL:
+                       return "NOT YET RETRIEVED";
+               case MSG_NETWORK_RETRIEVE_SUCCESS :
+                       return "RETRIEVED";
+               case MSG_NETWORK_RETRIEVING:
+                       return "RETRIEVING";
+               default :
+                       return "NOT SEND";
+       }
+
+       return "NOT SEND";
+}
+
+
+const char* MsgConvertReadStatus(bool ReadStatus)
+{
+       if (ReadStatus == true)
+               return "READ";
+       else if (ReadStatus == false)
+               return "UNREAD";
+
+       return "UNREAD";
+}
+
+
+const char* MsgConvertProtectedStatus(bool ProtectedStatus)
+{
+       if (ProtectedStatus == true)
+               return "PROTECTED";
+       else if (ProtectedStatus == false)
+               return "UNPROTECTED";
+
+       return "PROTECTED";
+}
+
+
+void MsgConvertTime(time_t *pTime, char *pDisplayTme)
+{
+       struct tm * timeinfo;
+
+       tzset();
+
+       timeinfo = localtime(pTime);
+
+//     MSG_DEBUG("time  zone is %s", timeinfo->tm_zone);
+
+       memset(pDisplayTme, 0x00, sizeof(pDisplayTme));
+
+//     strftime(timeBuff, 32, "%c", timeinfo);
+
+       strftime(pDisplayTme, 32, "%Y-%02m-%02d %T %z", timeinfo);
+}
+
diff --git a/test_app/MsgTestStorage.h b/test_app/MsgTestStorage.h
new file mode 100755 (executable)
index 0000000..71e8dea
--- /dev/null
@@ -0,0 +1,264 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+/**
+ *     @file           MsgTestStorage.h
+ *     @brief          Defines storage test function of messaging framework
+ *     @version                1.0
+ */
+
+#ifndef MSG_TEST_STORAGE_H
+#define MSG_TEST_STORAGE_H
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Messaging Storage Test Function
+ *     @section                Program
+ *     - Program : Messaging Storage Test Function Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include "MsgTypes.h"
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_STORAGE_TEST_FUNCTION Messaging Storage Test Function
+ *     @{
+ */
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**    @fn             void MsgTestAddMessage(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgAddMessage.
+ *     @param[in]      hMsgHandle is Message handle. \n
+ */
+void MsgTestAddMessage(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgTestGetMessage(MSG_HANDLE_T hMsgHandle, int MsgId)
+ *     @brief  Tests MsgGetMessage.
+ *     @param[in]      hMsgHandle is Message handle. \n
+ *     @param[in]      MsgId is the ID of the message to be returned. \n
+ */
+void MsgTestGetMessage(MSG_HANDLE_T hMsgHandle, int MsgId);
+
+
+/**    @fn             void MsgTestGetMessageList(MSG_HANDLE_T hMsgHandle, int FolderId)
+ *     @brief  Tests MsgGetMsgCommInfoList.
+ *     @param[in]      hMsgHandle is Message handle. \n
+ *     @param[in]      FolderId is the ID of the folder to be returned. \n
+ */
+void MsgTestGetMessageList(MSG_HANDLE_T hMsgHandle, int FolderId);
+
+
+/**    @fn             void MsgTestUpdateMessage(MSG_HANDLE_T hMsgHandle, msg_message_t *pMsg)
+ *     @brief  Tests MsgUpdateMessage.
+ *     @param[in]      hMsgHandle is Message handle. \n
+ *     @param[in]      pMsg is a pointer to an msg_message_t structure. \n
+ */
+void MsgTestUpdateMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg);
+
+/**    @fn             void MsgTestUpdateMMSMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
+ *     @brief  Tests MsgUpdateMessage.
+ *     @param[in]      hMsgHandle is Message handle. \n
+ *     @param[in]      pMsg is a pointer to an msg_message_t structure. \n
+ */
+void MsgTestUpdateMMSMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId);
+
+/**    @fn             void MsgTestMoveMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T MsgId)
+ *     @brief  Tests MsgMoveMessageToFolder.
+ *     @param[in]      hMsgHandle is Message handle. \n
+ *     @param[in]      MsgId is the ID of the message to be moved. \n
+ */
+void MsgTestMoveMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T MsgId);
+
+
+/**    @fn             void MsgTestMoveStorageMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T MsgId, MSG_STORAGE_ID_T storageId)
+ *     @brief  Tests MsgMoveMessageToStorage.
+ *     @param[in]      hMsgHandle is Message handle. \n
+ *     @param[in]      MsgId is the ID of the message to be moved. \n
+ *     @param[in]      storageId is the destination storage ID. \n
+ */
+void MsgTestMoveStorageMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg);
+
+
+/**    @fn             void MsgTestAddFolder(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgAddFolder.
+ *     @remarks
+       Pre-condition : The storage has to be properly setup and initialized. \n
+       The code below is to create folder.
+ *     @code
+       void MsgTestAddFolder(MSG_HANDLE_T hMsgHandle)
+       {
+               if (hMsgHandle == NULL)
+               {
+                       MSG_DEBUG("Handle is NULL");
+                       return;
+               }
+
+               MSG_ERROR_T err = MSG_SUCCESS;
+
+               // Make Folder
+               MSG_FOLDER_INFO_S folderInfo;
+
+               folderInfo.folderId = g_folderList.nCount + 1;
+               folderInfo.folderType = MSG_FOLDER_TYPE_USER_DEF;
+
+               char strName[MAX_FOLDER_NAME_SIZE+1];
+               memset(strName, 0x00, sizeof(strName));
+               cin.getline(strName, MAX_FOLDER_NAME_SIZE);
+               strncpy(folderInfo.folderName, strName, MAX_FOLDER_NAME_SIZE);
+
+               MSG_DEBUG("folderId [%d]", folderInfo.folderId);
+               MSG_DEBUG("folderType [%d]", folderInfo.folderType);
+               MSG_DEBUG("folderName [%s]", folderInfo.folderName);
+
+               print("Start Creating New Folder...");
+
+               // Create Folder
+               err = MsgAddFolder(hMsgHandle, &folderInfo);
+
+               if (err == MSG_SUCCESS)
+                       print("Creating New Folder is OK!");
+               else
+                       print("Creating New Folder is failed!");
+       }
+ *     @endcode
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestAddFolder(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgTestUpdateFolder(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgUpdateFolder.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestUpdateFolder(MSG_HANDLE_T hMsgHandle);
+
+
+/**    @fn             void MsgTestDeleteFolder(MSG_HANDLE_T hMsgHandle)
+ *     @brief  Tests MsgDeleteFolder.
+ *     @param[in]      hMsgHandle is Message handle.
+ */
+void MsgTestDeleteFolder(MSG_HANDLE_T hMsgHandle);
+
+void MsgTestDeleteMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId);
+
+/**    @fn             void MsgPrintMMSBody(msg_message_t pMsg)
+ *     @brief  Prints mms body's (content) information.
+ *     @param[in]      pMsg is a pointer to an msg_message_t structure. \n
+ */
+void MsgPrintMMSBody(msg_message_t pMsg);
+
+/**    @fn             void MsgPrintMessage(MSG_HANDLE_T hMsgHandle, msg_message_t *pMsg)
+ *     @brief  Prints message information.
+ *     @param[in]      hMsgHandle is Message handle. \n
+ *     @param[in]      pMsg is a pointer to an msg_message_t structure. \n
+ */
+void MsgPrintMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg, MSG_SENDINGOPT_S* pSendOpt);
+
+
+/**    @fn             void MsgRunMsgMenu(MSG_HANDLE_T hMsgHandle, char Menu, msg_message_t *pMsg)
+ *     @brief  Runs the selected function in the message menu.
+ *     @param[in]      hMsgHandle is Message handle. \n
+ *     @param[in]      Menu indicates which menu is selected. \n
+ *     @param[in]      pMsg is a pointer to an msg_message_t structure. \n
+ */
+void MsgRunMsgMenu(MSG_HANDLE_T hMsgHandle, char Menu, msg_message_t pMsg, MSG_SENDINGOPT_S *pSendOpt);
+
+
+/**    @fn             void MsgRunMsgListMenu(MSG_HANDLE_T hMsgHandle, char *pMenu, int FolderId, MSG_MAIN_TYPE_T mainType, MSG_NETWORK_STATUS_T NetworkStatus)
+ *     @brief  Runs the selected function in the message list menu.
+ *     @param[in]      hMsgHandle is Message handle. \n
+ *     @param[in]      pMenu is a pointer that indicates which menu is selected. \n
+ *     @param[in]      FolderId is the ID of the folder to be run. \n
+ */
+void MsgRunMsgListMenu(MSG_HANDLE_T hMsgHandle, int MsgId, int FolderId, MSG_MESSAGE_TYPE_T MsgType, MSG_NETWORK_STATUS_T NetworkStatus);
+
+
+/**    @fn             void MsgGetCurrentTime(time_t *pTime)
+ *     @brief  Gets the current time.
+ *     @param[out]     pTime is a pointer that indicates the current time.
+ */
+void MsgGetCurrentTime(time_t *pTime);
+
+
+/**    @fn             char* MsgConvertMsgType(MSG_MAIN_TYPE_T MainType)
+ *     @brief  Converts the message type.
+ *     @param[in]      MainType indicates the message type to be returned.
+ *     @retval SMS \n
+ *     @retval MMS \n
+ *     @retval EMAIL \n
+ */
+const char* MsgConvertMsgType(MSG_MESSAGE_TYPE_T MsgType);
+
+const char* MsgConvertStorageId(MSG_STORAGE_ID_T StorageId);
+
+const char* MsgConvertNetworkStatus(MSG_NETWORK_STATUS_T status);
+
+/**    @fn             char* MsgConvertReadStatus(bool ReadStatus)
+ *     @brief  Converts the read status of a message.
+ *     @param[in]      ReadStatus indicates whether a message is read or not.
+ *     @retval READ \n
+ *     @retval UNREAD \n
+ */
+const char* MsgConvertReadStatus(bool ReadStatus);
+
+
+/**    @fn             char* MsgConvertProtectedStatus(bool ProtectedStatus)
+ *     @brief  Converts the protected status of a message.
+ *     @param[in]      ProtectedStatus indicates whether a message is protected or not.
+ *     @retval PROTECTED \n
+ *     @retval UNPROTECTED \n
+ */
+const char* MsgConvertProtectedStatus(bool ProtectedStatus);
+
+
+/**    @fn             char* MsgConvertTime(const time_t *pTime)
+ *     @brief  Converts the time_t value to string.
+ *     @param[in]      time_t value.
+ *     @retval String type time present. \n
+ */
+void MsgConvertTime(time_t *pTime, char *pDisplayTme);
+
+//MSG_ERROR_T convertMsgStruct(const msg_message_t *pSource, MSG_MESSAGE_INFO_S *pDest);
+
+MSG_ERROR_T MsgTestSendReadReport(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg, int mmsReadStatus, int version);
+
+void MsgTestForwardMMSMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId);
+
+void MsgTestRetrieveMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId);
+
+void MsgTestMsgGen(MSG_HANDLE_T hMsgHandle);
+
+//thread view
+void MsgThreadViewMain(MSG_HANDLE_T hMsgHandle);
+
+void MsgRunThreadViewMenu(MSG_HANDLE_T  hMsgHandle, MSG_THREAD_LIST_INDEX_S *pAddrList);
+
+/**
+ *     @}
+ */
+
+
+#endif //MSG_TEST_STORAGE_H
+
diff --git a/test_app/MsgTestThreadView.cpp b/test_app/MsgTestThreadView.cpp
new file mode 100755 (executable)
index 0000000..2f41146
--- /dev/null
@@ -0,0 +1,602 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <time.h>
+#include <iostream>
+#include <string>
+#include <stdlib.h>
+using namespace std;
+
+#include "MsgMmsTypes.h"
+#include "MsgTypes.h"
+#include "MapiStorage.h"
+#include "MapiSetting.h"
+#include "MapiMessage.h"
+#include "MsgTestStorage.h"
+#include "MsgTestTransport.h"
+#include "MsgTestThreadView.h"
+#include "main.h"
+
+
+#define MSG_PROFILE_BEGIN(pfid) \
+       unsigned int __prf_l1_##pfid = __LINE__;    \
+       struct timeval __prf_1_##pfid;              \
+       struct timeval __prf_2_##pfid;              \
+       do {                                        \
+               gettimeofday(&__prf_1_##pfid, 0);       \
+       } while (0)
+
+#define MSG_PROFILE_END(pfid) \
+       unsigned int __prf_l2_##pfid = __LINE__;\
+       do { \
+               gettimeofday(&__prf_2_##pfid, 0);\
+               long __ds = __prf_2_##pfid.tv_sec - __prf_1_##pfid.tv_sec;\
+               long __dm = __prf_2_##pfid.tv_usec - __prf_1_##pfid.tv_usec;\
+               if ( __dm < 0 ) { __ds--; __dm = 1000000 + __dm; } \
+               printf("**PROFILE** [MSGFW: %s: %s() %u ~ %u] " #pfid " -> Elapsed Time: %u.%06u seconds\n",                    \
+               rindex(__FILE__, '/')+1,                \
+               __FUNCTION__, \
+               __prf_l1_##pfid,                                         \
+               __prf_l2_##pfid,                                         \
+               (unsigned int)(__ds),                                    \
+               (unsigned int)(__dm));                                   \
+       } while (0)
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+void MsgThreadViewMain(MSG_HANDLE_T hMsgHandle)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       char menu[5];
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_SORT_RULE_S sortRule = {0};
+
+       // Set Sort Rule
+       sortRule.sortType = MSG_SORT_BY_THREAD_DATE;
+       sortRule.bAscending = false;
+
+       MSG_THREAD_VIEW_LIST_S threadViewList;
+
+       char displayTime[32];
+
+       do
+       {
+               err = msg_get_thread_view_list(hMsgHandle, NULL, &threadViewList);
+
+               if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
+               {
+                       print("Get Message List is failed!");
+                       return;
+               }
+
+               system ("clear" );
+
+               print("======================================");
+               print("============ Thread View =============");
+               print("======================================");
+
+               if (threadViewList.nCount <= 0)
+               {
+                       print("Empty...");
+               }
+               else
+               {
+                       MSG_PROFILE_BEGIN(1);
+
+                       for (int i = 0; i < threadViewList.nCount; i++)
+                       {
+                               memset(displayTime, 0x00, sizeof(displayTime));
+
+                               MsgConvertTime(msg_thread_view_get_time(threadViewList.msgThreadInfo[i]), displayTime);
+
+                               printf("[%04d]\tUnread Msg [%d]\t[%s] [%s] [%s]\n[%s]\tType [%s]\tMessage Text [%s]\n",
+                                               msg_thread_view_get_thread_id(threadViewList.msgThreadInfo[i]),
+                                               msg_thread_view_get_unread_cnt(threadViewList.msgThreadInfo[i]),
+                                               msg_thread_view_get_address(threadViewList.msgThreadInfo[i]),
+                                               msg_thread_view_get_name(threadViewList.msgThreadInfo[i]),
+                                               displayTime,
+                                               MsgConvertDirection(msg_thread_view_get_direction(threadViewList.msgThreadInfo[i])),
+                                               MsgConvertType(msg_thread_view_get_message_type(threadViewList.msgThreadInfo[i])),
+                                               msg_thread_view_get_data(threadViewList.msgThreadInfo[i]));
+
+                               printf("--------------------------------------------------------\n");
+                       }
+                       MSG_PROFILE_END(1);
+               }
+
+               print("======================================");
+               print("================ Menu ================");
+               print("======================================");
+               print("[C] Create Message");
+               print("[D] Delete Thread");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 5);
+
+               if (!strcmp(menu, "C") || !strcmp(menu, "c")) // Add Message
+               {
+                       MsgTestAddMessage(hMsgHandle);
+               }
+               else if (!strcmp(menu, "D") || !strcmp(menu, "d"))
+               {
+                       print("Choose Thread ID : ");
+
+                       char id[5];
+
+                       memset(id, 0x00, sizeof(id));
+                       cin.getline(id, 5);
+
+                       print("Do you really wanna delete messages in thread [Y or N] ?");
+
+                       char select[2];
+
+                       memset(select, 0x00, sizeof(select));
+                       cin.getline(select, 2);
+
+MSG_PROFILE_BEGIN(3);
+                       if (!strcmp(select, "Y") || !strcmp(select, "y"))
+                               msg_delete_thread_message_list(hMsgHandle, (MSG_THREAD_ID_T)atoi(id));
+MSG_PROFILE_END(3);
+               }
+               else if (!strcmp(menu, "B") || !strcmp(menu, "b"))
+               {
+                       msg_release_thread_view_list(&threadViewList);
+                       MSG_DEBUG("release thread view list [%d]", threadViewList.nCount);
+                       break;
+               }
+               else
+               {
+                       MSG_THREAD_ID_T threadId = atoi(menu);
+
+                       for (int i = 0; i < threadViewList.nCount; i++)
+                       {
+                               if ((MSG_THREAD_ID_T)msg_thread_view_get_thread_id(threadViewList.msgThreadInfo[i]) == threadId)
+                               {
+                                       MsgRunConversationView(hMsgHandle, threadId, msg_thread_view_get_address(threadViewList.msgThreadInfo[i]), msg_thread_view_get_name(threadViewList.msgThreadInfo[i]));
+
+                                       break;
+                               }
+                       }
+               }
+
+               msg_release_thread_view_list(&threadViewList);
+               MSG_DEBUG("release thread view list [%d]", threadViewList.nCount);
+       }
+       while (strcmp(menu, "B"));
+}
+
+
+void MsgSearchViewMain(MSG_HANDLE_T hMsgHandle)
+{
+       if (hMsgHandle == NULL)
+       {
+               MSG_DEBUG("Handle is NULL");
+               return;
+       }
+
+       char menu[5], displayTime[32], searchString[1024];
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       do
+       {
+               print("Search Mode 0:Message 1:Thread :");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 4);
+
+               int searchType = atoi(menu);
+
+
+               print("Input String to Search :");
+
+               memset(searchString, 0x00, sizeof(searchString));
+
+               cin.getline(searchString, 1024);
+
+
+               if(searchType == 0)
+               {
+
+                       MSG_LIST_S msgList;
+
+                       print("Target folder (0:ALLBOX 1:INBOX 2:OUTBOX 3:SENTBOX) :");
+
+                       memset(menu, 0x00, sizeof(menu));
+                       cin.getline(menu, 4);
+
+                       int folderId = atoi(menu);
+
+
+                       print("Target message type (0:ALLTYPE 1:SMS 9:MMS) :");
+
+                       memset(menu, 0x00, sizeof(menu));
+                       cin.getline(menu, 4);
+
+                       int msgType = atoi(menu);
+
+
+                       print("Search Result offset (0~) :");
+
+                       memset(menu, 0x00, sizeof(menu));
+                       cin.getline(menu, 4);
+
+                       int offset = atoi(menu);
+
+
+                       print("Search Result limit (0~) :");
+
+                       memset(menu, 0x00, sizeof(menu));
+                       cin.getline(menu, 4);
+
+                       int limit = atoi(menu);
+
+                       MSG_SEARCH_CONDITION_S searchCon;
+                       memset(&searchCon, 0x00, sizeof(MSG_SEARCH_CONDITION_S));
+
+                       searchCon.msgType = msgType;
+                       searchCon.folderId = folderId;
+                       searchCon.pSearchVal = searchString;
+                       searchCon.pAddressVal = searchString;
+
+                       MSG_PROFILE_BEGIN(_msg_search_message_);
+                       err = msg_search_message(hMsgHandle, &searchCon, offset, limit, &msgList);
+                       MSG_PROFILE_END(_msg_search_message_);
+
+                       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
+                       {
+                               print("Get Message List is failed!");
+                               return;
+                       }
+
+
+                       system ("clear" );
+
+                       print("======================================");
+                       print("============ Search View =============");
+                       print("======================================");
+
+                       if (msgList.nCount <= 0)
+                       {
+                               print("Empty...");
+                       }
+                       else
+                       {
+
+                               for (int i = 0; i < msgList.nCount; i++)
+                               {
+                                       memset(displayTime, 0x00, sizeof(displayTime));
+
+                                       MsgConvertTime(msg_get_time(msgList.msgInfo[i]), displayTime);
+
+                                       const char* msgText = NULL;
+
+                                       int msgType = msg_get_message_type(msgList.msgInfo[i]);
+
+                                       if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
+                                               msgText = msg_mms_get_text_contents(msgList.msgInfo[i]);
+                                       else
+                                               msgText = msg_sms_get_message_body(msgList.msgInfo[i]);
+
+                                       printf("[%02d]\t[%s %s %s %s] [%s]\t[%s]\nDate [%s]\nMessage Text [%s] \tMessage data size [%d]\n",
+                                                       msg_get_message_id(msgList.msgInfo[i]),
+                                                       MsgConvertMsgType(msg_get_message_type(msgList.msgInfo[i])),
+                                                       MsgConvertStorageId(msg_get_storage_id(msgList.msgInfo[i])),
+                                                       MsgConvertReadStatus(msg_is_read(msgList.msgInfo[i])),
+                                                       MsgConvertProtectedStatus(msg_is_protected(msgList.msgInfo[i])),
+                                                       MsgConvertNetworkStatus(msg_get_network_status(msgList.msgInfo[i])),
+                                                       msg_get_ith_address(msgList.msgInfo[i], 0),
+                                                       displayTime,
+                                                       msgText,
+                                                       msg_get_message_body_size(msgList.msgInfo[i]));
+                                       printf("--------------------------------------------------------\n");
+                               }
+                       }
+
+                       print("======================================");
+                       print("================ Menu ================");
+                       print("======================================");
+                       print("[S] Search Again");
+                       print("[B] Back");
+                       print("======================================");
+
+                       print("Input : ");
+
+                       memset(menu, 0x00, sizeof(menu));
+                       cin.getline(menu, 5);
+
+                       if (!strcmp(menu, "S") || !strcmp(menu, "s"))
+                       {
+                               continue;
+                       }
+                       else if (!strcmp(menu, "B") || !strcmp(menu, "b"))
+                       {
+                               msg_release_message_list(&msgList);
+                               MSG_DEBUG("release msg list [%d]", msgList.nCount);
+                               break;
+                       }
+                       else
+                       {
+                               int msgId = atoi(menu);
+
+                               MsgTestGetMessage(hMsgHandle, msgId);
+                               break;
+                       }
+
+                       msg_release_message_list(&msgList);
+                       MSG_DEBUG("release msg list [%d]", msgList.nCount);
+               }
+               else if(searchType == 1)
+               {
+
+                       MSG_THREAD_VIEW_LIST_S threadViewList;
+
+               MSG_PROFILE_BEGIN(1);
+
+                       err = msg_search_message_for_thread_view(hMsgHandle, searchString, &threadViewList);
+
+               MSG_PROFILE_END(1);
+
+               if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
+               {
+                       print("Get Message List is failed!");
+                       return;
+               }
+
+               system ("clear" );
+
+               print("======================================");
+               print("============ Search View =============");
+               print("======================================");
+
+               if (threadViewList.nCount <= 0)
+               {
+                       print("Empty...");
+               }
+               else
+               {
+
+                       for (int i = 0; i < threadViewList.nCount; i++)
+                       {
+                               memset(displayTime, 0x00, sizeof(displayTime));
+
+                               MsgConvertTime(msg_thread_view_get_time(threadViewList.msgThreadInfo[i]), displayTime);
+
+                               printf("[%04d]\tUnread Msg [%d]\t[%s] [%s] [%s] [%s]\n[%s]\tMessage Text [%s]\n",
+                                               msg_thread_view_get_thread_id(threadViewList.msgThreadInfo[i]),
+                                               msg_thread_view_get_unread_cnt(threadViewList.msgThreadInfo[i]),
+                                               msg_thread_view_get_address(threadViewList.msgThreadInfo[i]),
+                                               msg_thread_view_get_name(threadViewList.msgThreadInfo[i]),
+                                               msg_thread_view_get_image_path(threadViewList.msgThreadInfo[i]),
+                                               displayTime,
+                                               MsgConvertDirection(msg_thread_view_get_direction(threadViewList.msgThreadInfo[i])),
+                                               msg_thread_view_get_data(threadViewList.msgThreadInfo[i]));
+
+                               printf("--------------------------------------------------------\n");
+                       }
+               }
+
+               print("======================================");
+               print("================ Menu ================");
+               print("======================================");
+               print("[C] Create Message");
+               print("[D] Delete Thread");
+               print("[S] Search Again");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 5);
+
+               if (!strcmp(menu, "C") || !strcmp(menu, "c")) // Add Message
+               {
+                       MsgTestAddMessage(hMsgHandle);
+               }
+               else if (!strcmp(menu, "D") || !strcmp(menu, "d"))
+               {
+                       print("Choose Thread ID : ");
+
+                       char id[5];
+
+                       memset(id, 0x00, sizeof(id));
+                       cin.getline(id, 5);
+
+                       print("Do you really wanna delete messages in thread [Y or N] ?");
+
+                       char select[2];
+
+                       memset(select, 0x00, sizeof(select));
+                       cin.getline(select, 2);
+
+                       if (!strcmp(select, "Y") || !strcmp(select, "y"))
+                               msg_delete_thread_message_list(hMsgHandle, (MSG_THREAD_ID_T)atoi(id));
+               }
+               else if (!strcmp(menu, "S") || !strcmp(menu, "s"))
+               {
+                       continue;
+               }
+               else if (!strcmp(menu, "B") || !strcmp(menu, "b"))
+               {
+                       msg_release_thread_view_list(&threadViewList);
+                       MSG_DEBUG("release thread view list [%d]", threadViewList.nCount);
+                       break;
+               }
+               else
+               {
+                       MSG_THREAD_ID_T threadId = atoi(menu);
+
+                       for (int i = 0; i < threadViewList.nCount; i++)
+                       {
+                               if ((MSG_THREAD_ID_T)msg_thread_view_get_thread_id(threadViewList.msgThreadInfo[i]) == threadId)
+                               {
+                                       MsgRunConversationView(hMsgHandle, threadId, msg_thread_view_get_address(threadViewList.msgThreadInfo[i]), msg_thread_view_get_name(threadViewList.msgThreadInfo[i]));
+
+                                       break;
+                               }
+                       }
+               }
+
+               msg_release_thread_view_list(&threadViewList);
+               MSG_DEBUG("release thread view list [%d]", threadViewList.nCount);
+       }
+       }
+       while (strcmp(menu, "B"));
+}
+
+
+void MsgRunConversationView(MSG_HANDLE_T hMsgHandle, MSG_THREAD_ID_T ThreadId, const char *pAddress, const char *pName)
+{
+       char menu[5];
+
+       char displayTime[32];
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_LIST_S convViewList;
+
+       do
+       {
+               err = msg_get_conversation_view_list(hMsgHandle, ThreadId, &convViewList);
+
+               if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
+               {
+                       print("Get Message List is failed!");
+                       return;
+               }
+
+               system ("clear" );
+
+               printf("======================================\n");
+               printf("============ %s ============\n", pAddress);
+               printf("============ %s ============\n", pName);
+               printf("======================================\n");
+
+               if (convViewList.nCount <= 0)
+               {
+                       print("Empty...");
+               }
+               else
+               {
+                       for (int i = 0; i < convViewList.nCount; i++)
+                       {
+                               memset(displayTime, 0x00, sizeof(displayTime));
+
+                               MsgConvertTime(msg_get_time(convViewList.msgInfo[i]), displayTime);
+
+                               const char* msgText = NULL;
+
+                               int msgType = msg_get_message_type(convViewList.msgInfo[i]);
+
+                               if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
+                                       msgText = msg_mms_get_text_contents(convViewList.msgInfo[i]);
+                               else
+                                       msgText = msg_sms_get_message_body(convViewList.msgInfo[i]);
+
+                               printf("[%04d]\t[%s] [%s]\tText [%s] Attachment count [%d] Date [%s]\n",
+                                               msg_get_message_id(convViewList.msgInfo[i]),
+                                               MsgConvertDirection(msg_get_direction_info(convViewList.msgInfo[i])),
+                                               MsgConvertMsgType(msg_get_message_type(convViewList.msgInfo[i])),
+                                               msgText,
+                                               msg_get_attachment_count(convViewList.msgInfo[i]),
+                                               displayTime);
+
+                               printf("--------------------------------------------------------\n");
+                       }
+               }
+
+               print("======================================");
+               print("================ Menu ================");
+               print("======================================");
+               print("[R] Reply");
+               print("[D] Delete Message");
+               print("[B] Back");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 5);
+
+               if (!strcmp(menu, "R") || !strcmp(menu, "r"))
+               {
+
+               }
+               else if (!strcmp(menu, "D") || !strcmp(menu, "d"))
+               {
+
+               }
+
+               msg_release_message_list(&convViewList);
+               MSG_DEBUG("release conversation view list [%d]", convViewList.nCount);
+       }
+       while (strcmp(menu, "B") && strcmp(menu, "b"));
+}
+
+
+const char* MsgConvertDirection(MSG_DIRECTION_TYPE_T Direction)
+{
+       if (Direction == MSG_DIRECTION_TYPE_MO)
+               return "SENT";
+       else if (Direction == MSG_DIRECTION_TYPE_MT)
+               return "RECEIVED";
+
+       return "RECEIVED";
+}
+
+
+const char* MsgConvertType(MSG_MESSAGE_TYPE_T MsgType)
+{
+       if (MsgType == MSG_TYPE_SMS)
+               return "SMS";
+       else if (MsgType == MSG_TYPE_SMS_CB ||MsgType == MSG_TYPE_SMS_JAVACB)
+               return "CB";
+       else if (MsgType == MSG_TYPE_SMS_WAPPUSH)
+               return "WAP Push";
+       else if (MsgType == MSG_TYPE_SMS_MWI)
+               return "MWI";
+       else if (MsgType == MSG_TYPE_SMS_SYNCML)
+               return "SyncML";
+       else if (MsgType == MSG_TYPE_SMS_REJECT)
+               return "Reject SMS";
+       else if (MsgType == MSG_TYPE_MMS)
+               return "MMS";
+       else if (MsgType == MSG_TYPE_MMS_NOTI)
+               return "MMS Noti";
+       else if (MsgType == MSG_TYPE_MMS_JAVA)
+               return "Java MMS";
+
+       return "SMS";
+}
+
diff --git a/test_app/MsgTestThreadView.h b/test_app/MsgTestThreadView.h
new file mode 100755 (executable)
index 0000000..5ddc417
--- /dev/null
@@ -0,0 +1,67 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+/**
+ *     @file           MsgTestStorage.h
+ *     @brief          Defines storage test function of messaging framework
+ *     @version                1.0
+ */
+
+#ifndef MSG_TEST_THREAD_VIEW_H
+#define MSG_TEST_THREAD_VIEW_H
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Messaging Storage Test Function
+ *     @section                Program
+ *     - Program : Messaging Storage Test Function Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include "MsgTypes.h"
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_STORAGE_TEST_FUNCTION Messaging Thread View Test Function
+ *     @{
+ */
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+void MsgThreadViewMain(MSG_HANDLE_T hMsgHandle);
+
+void MsgSearchViewMain(MSG_HANDLE_T hMsgHandle);
+
+void MsgRunThreadViewMenu(MSG_HANDLE_T  hMsgHandle, MSG_THREAD_LIST_INDEX_S *pAddrList);
+
+void MsgRunConversationView(MSG_HANDLE_T hMsgHandle, MSG_THREAD_ID_T ThreadId, const char *pAddress, const char *pName);
+
+const char* MsgConvertDirection(MSG_DIRECTION_TYPE_T Direction);
+
+const char* MsgConvertType(MSG_MESSAGE_TYPE_T MsgType);
+
+/**
+ *     @}
+ */
+
+
+#endif //MSG_TEST_THREAD_VIEW_H
+
diff --git a/test_app/MsgTestTransport.cpp b/test_app/MsgTestTransport.cpp
new file mode 100755 (executable)
index 0000000..f43cafc
--- /dev/null
@@ -0,0 +1,139 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include "MsgSettingTypes.h"
+#include "MapiTransport.h"
+#include "MapiSetting.h"
+#include "MsgTestTransport.h"
+#include "main.h"
+#include "MapiMessage.h"
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+
+MSG_ERROR_T MsgTestSubmitReq(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg, MSG_SENDINGOPT_S* pSendOpt)
+{
+       if ( !hMsgHandle || !pMsg )
+       {
+               MSG_DEBUG("Handle or pMsg is NULL");
+               return MSG_ERR_NULL_MSGHANDLE;
+       }
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       MSG_REQUEST_S req = {0};
+
+       req.msg = pMsg;
+
+       if( pSendOpt )
+               memcpy(&req.sendOpt, pSendOpt, sizeof(req.sendOpt));
+
+       MSG_DEBUG("==== [MsgTestSubmitReq] MSG ID = [%d] ====", msg_get_message_id(req.msg));
+       MSG_DEBUG("==== [MsgTestSubmitReq] Folder ID = [%d] ====", msg_get_folder_id(req.msg));
+       MSG_DEBUG("==== [MsgTestSubmitReq] Message Type = [%d] ====", msg_get_message_type(req.msg));
+       MSG_DEBUG("==== [MsgTestSubmitReq] # number = [%d] ====", msg_get_address_count(req.msg));
+       MSG_DEBUG("==== [MsgTestSubmitReq] to = [%s] ====", msg_get_ith_address(req.msg, 0));
+//     MSG_DEBUG("==== [MsgTestSubmitReq] Message Data = [%s] ====", msg_sms_get_message_body(req.msg));
+       MSG_DEBUG("==== [MsgTestSubmitReq] Message Data size = [%d] ====", msg_get_message_body_size(req.msg));
+
+       MSG_DEBUG("==== [MsgTestSubmitReq] sendOpt : bSetting = [%d] ====", req.sendOpt.bSetting);
+       MSG_DEBUG("==== [MsgTestSubmitReq] sendOpt : bDelivery = [%d] ====", req.sendOpt.bDeliverReq);
+       MSG_DEBUG("==== [MsgTestSubmitReq] sendOpt : bKeepCopy = [%d] ====", req.sendOpt.bKeepCopy);
+
+       if(msg_is_sms(pMsg))
+               MSG_DEBUG("==== [MsgTestSubmitReq] sendOpt : bReplyPath = [%d] ====", req.sendOpt.option.smsSendOpt.bReplyPath);
+       else if(msg_is_mms(pMsg))
+       {
+               MSG_DEBUG("==== [MsgTestSubmitReq] sendOpt : bReadReq = [%d] ====", req.sendOpt.option.mmsSendOpt.bReadReq);
+               MSG_DEBUG("==== [MsgTestSubmitReq] sendOpt : priority = [%d] ====", req.sendOpt.option.mmsSendOpt.priority);
+               MSG_DEBUG("==== [MsgTestSubmitReq] sendOpt : expiryTime = [%lu] ====", req.sendOpt.option.mmsSendOpt.expiryTime);
+               MSG_DEBUG("==== [MsgTestSubmitReq] sendOpt : deliveryTime = [%lu] ====", req.sendOpt.option.mmsSendOpt.deliveryTime);
+       }
+
+       print("Start Sending Message...");
+
+       if (msg_is_mms(req.msg))
+       {
+               if (msg_get_message_type(req.msg) == MSG_TYPE_MMS)
+                       err = msg_mms_send_message(hMsgHandle, &req);
+               else
+                       err = msg_mms_retrieve_message(hMsgHandle, &req);
+       }
+       else
+               err = msg_sms_send_message(hMsgHandle, &req);
+
+       if (err == MSG_SUCCESS)
+               printf("Sending Message is successful!!!");
+       else
+               printf("Sending Message is failed!!! %d", err);
+
+       return err;
+}
+
+MSG_ERROR_T MsgTestScheduledSubmitReq(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg, MSG_SENDINGOPT_S* pSendOpt)
+{
+       if ( !hMsgHandle || !pMsg )
+       {
+               MSG_DEBUG("Handle is NULL");
+               return MSG_ERR_NULL_MSGHANDLE;
+       }
+
+       MSG_REQUEST_S req = {0};
+
+       req.msg = pMsg;
+       if( pSendOpt )
+               req.sendOpt = *pSendOpt; //     memcpy(&req.sendOpt, pSendOpt, sizeof(req.sendOpt));
+
+               time_t scheduledTime;
+
+               time(&scheduledTime);
+               scheduledTime = scheduledTime + 180;
+       msg_set_scheduled_time(req.msg, scheduledTime);
+
+       MSG_DEBUG("==== [MsgTestSubmitReq] MSG ID = [%d] ====", msg_get_message_id(req.msg));
+       MSG_DEBUG("==== [MsgTestSubmitReq] Folder ID = [%d] ====", msg_get_folder_id(req.msg));
+       MSG_DEBUG("==== [MsgTestSubmitReq] Msg Type = [%d] ====", msg_get_message_type(req.msg));
+//     MSG_DEBUG("==== [MsgTestSubmitReq] Message Data = [%s] ====", msg_sms_get_message_body(req.msg));
+       MSG_DEBUG("==== [MsgTestSubmitReq] Message Data size = [%d] ====", msg_get_message_body_size(req.msg));
+
+       print("Start Sending Message...");
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       if (msg_is_mms(req.msg))
+               {
+               if (msg_get_message_type(req.msg) == MSG_TYPE_MMS)
+                       err = msg_mms_send_message(hMsgHandle, &req);
+               else
+                       err = msg_mms_retrieve_message(hMsgHandle, &req);
+       }
+       else
+               err = msg_sms_send_message(hMsgHandle, &req);
+
+       if (err == MSG_SUCCESS)
+               print("Sending Message is OK!");
+       else
+               print("Sending Message is failed!");
+
+       return err;
+}
+
diff --git a/test_app/MsgTestTransport.h b/test_app/MsgTestTransport.h
new file mode 100755 (executable)
index 0000000..d2ce670
--- /dev/null
@@ -0,0 +1,199 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+/**
+ *     @file           MsgTestTransport.h
+ *     @brief          Defines transport test function of messaging framework
+ *     @version                1.0
+ */
+
+#ifndef MSG_TEST_TRANSPORT_H
+#define MSG_TEST_TRANSPORT_H
+
+/**
+ *     @section                Introduction
+ *     - Introduction : Overview on Messaging Transport Test Function
+ *     @section                Program
+ *     - Program : Messaging Transport Test Function Reference
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include "MsgTypes.h"
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_TRANSPORT_TEST_FUNCTION       Messaging Transport Test Function
+ *     @{
+ */
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**    @fn             MSG_ERROR_T MsgTestSubmitReq(MSG_HANDLE_T hMsgHandle, msg_message_t *pMsg)
+ *     @brief  Tests MsgSubmitReq.
+ *     @remarks
+       This function requires two pieces of elements ready.
+       One is message structure which is composed on application, and the other is message handle.
+       An connected message handle is required for both sending a message, and receiving a message. \n
+       To send a SMS, precondition : there should be SMS plugin already plugged into framework.
+       The SMS plugin should provide SMS extension structure, subtypes, and classtypes. \n
+       To get the result, application MUST implement the callback function, MsgOnStatusChangedCallback(), and register it to message handle. \n
+       To receive messages, an application MUST also implement the callback function, MsgOnMessageIncomingCallback(), and register it to message handle.
+       In this example, only SMS is interested to receive and process, while other types of messages would be ignored by the application.
+       Besides that, an application MAY set a filter list, in this way, only incoming messages which satisfy the filter list will be passed to the registered callback function. \n
+       Supposing the subtype are defined as below, and the callback functions, MsgOnStatusChangedCallback() and MsgOnMessageIncomingCallback(), are defined too.
+ *     @code
+       enum _MSG_SUB_TYPE_E
+       {
+               MSG_NORMAL_SMS = 0,     // Text SMS message
+               MSG_WAPPUSH_SMS,                // WAP Push message
+               MSG_CB_SMS,                     // Cell Broadcasting message
+       };
+
+       enum _MSG_CLASS_TYPE_E
+       {
+               MSG_CLASS_0 = 0,                // Immediately presented on the recipient device display
+               MSG_CLASS_1,                    // Stored in the mobile equipment or SIM (depending on memory availability)
+               MSG_CLASS_2,                    // Stored in SIM
+               MSG_CLASS_3,                    // Transferred to the terminal equipment (such as PDA or PC) which is connected to the mobile equipment
+               MSG_CLASS_NONE,
+       };
+
+       void sentStatusCB(MSG_HANDLE_T hMsgHandle, MSG_SENT_STATUS_S* pMsgStatus)
+       {
+               print("sentStatusCB() called");
+               printf("reqId : %d status : %d", pMsgStatus->reqId, pMsgStatus->status);
+       }
+
+       void incomingMessageCB (MSG_HANDLE_T hMsgHandle, msg_message_t* pNewMsg)
+       {
+               cout << "New Message Received" << endl;
+               MSG_DEBUG("msgId : %d", pNewMsg->msgId);
+               MSG_DEBUG("folderId : %d", pNewMsg->folderId);
+               MSG_DEBUG("msgType.mainType = %d", pNewMsg->msgType.mainType);
+               MSG_DEBUG("msgType.subType = %d", pNewMsg->msgType.subType);
+               MSG_DEBUG("nAddressCnt = %d", pNewMsg->nAddressCnt);
+               MSG_DEBUG("addressList[0].addressType = %d", pNewMsg->addressList[0].addressType);
+               MSG_DEBUG("addressList[0].addressVal = %s", pNewMsg->addressList[0].addressVal);
+               MSG_DEBUG("displayTime = %s", pNewMsg->displayTime);
+               MSG_DEBUG("networkStatus = %d", pNewMsg->networkStatus);
+               MSG_DEBUG("bRead = %d", pNewMsg->bRead);
+               MSG_DEBUG("bProtected = %d", pNewMsg->bProtected);
+               MSG_DEBUG("bHasAttach = %d", pNewMsg->bHasAttach);
+               MSG_DEBUG("bHasDrm = %d", pNewMsg->bHasDrm);
+               MSG_DEBUG("priority = %d", pNewMsg->priority);
+               MSG_DEBUG("dataSize = %d", pNewMsg->dataSize);
+               MSG_DEBUG("msgData = %s", (char*)pNewMsg->pData);
+       }
+
+       MSG_ERROR_T MsgTestSubmitReq(MSG_HANDLE_T hMsgHandle, msg_message_t *pMsg)
+       {
+               if (hMsgHandle == NULL)
+               {
+                       MSG_DEBUG("Handle is NULL");
+                       return MSG_ERR_NULL_MSGHANDLE;
+               }
+
+               MSG_ERROR_T err = MSG_SUCCESS;
+
+               MSG_REQUEST_S req;
+
+               // Make Request Message
+               if (pMsg == NULL)
+               {
+                       MSG_DEBUG("Message is NULL");
+                       return MSG_ERR_NULL_MESSAGE;
+               }
+               else
+               {
+                       req.reqId = 1; // arbitrary number
+                       req.msg.msgId = pMsg->msgId;
+                       req.msg.folderId = MSG_OUTBOX_ID; // outbox fixed
+                       req.msg.msgType = pMsg->msgType;
+                       req.msg.accountId = pMsg->accountId;
+                       req.msg.storageId = pMsg->storageId;
+
+                       req.msg.nAddressCnt = pMsg->nAddressCnt;
+
+                       for (int i = 0; i < pMsg->nAddressCnt; i++)
+                       {
+                               req.msg.addressList[i].addressType = pMsg->addressList[i].addressType;
+                               strncpy(req.msg.addressList[i].addressVal, pMsg->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN);
+                       }
+
+                       strncpy(req.msg.displayTime, pMsg->displayTime, MAX_DISPLAY_TIME_LEN);
+
+                       req.msg.networkStatus = MSG_NETWORK_SENDING;
+                       req.msg.bRead = pMsg->bRead;
+                       req.msg.bProtected = pMsg->bProtected;
+                       req.msg.bHasAttach = pMsg->bHasAttach;
+                       req.msg.bHasDrm = pMsg->bHasDrm;
+                       req.msg.priority = pMsg->priority;
+                       req.msg.direction = pMsg->direction;
+                       req.msg.dataSize = pMsg->dataSize;
+
+                       req.msg.pData = (void*)new char[req.msg.dataSize];
+                       strncpy((char*)req.msg.pData, (char*)pMsg->pData, pMsg->dataSize);
+               }
+
+               MSG_DEBUG("==== [MsgTestSubmitReq] Message ID = [%d] ====", req.msg.msgId);
+               MSG_DEBUG("==== [MsgTestSubmitReq] Folder ID = [%d] ====", req.msg.folderId);
+               MSG_DEBUG("==== [MsgTestSubmitReq] Main Type = [%d] ====", req.msg.msgType.mainType);
+               MSG_DEBUG("==== [MsgTestSubmitReq] Sub Type = [%d] ====", req.msg.msgType.subType);
+               MSG_DEBUG("==== [MsgTestSubmitReq] Message Data = [%s] ====", (char*)req.msg.pData);
+
+               print("Start Sending Message...");
+
+               // Submit Request
+               err = MsgSubmitReq(hMsgHandle, &req);
+
+               if (err == MSG_SUCCESS)
+                       print("Sending Message is OK!");
+               else
+                       print("Sending Message is failed!");
+
+               return err;
+       }
+ *     @endcode
+ *     @param[in]      hMsgHandle is Message handle. \n
+ *     @param[in]      pMsg is a pointer to an msg_message_t structure. \n
+ *     @return MSG_ERROR_T
+ *     @retval MSG_SUCCESS                             Success in operation. \n
+ *     @retval MSG_ERR_NULL_MSGHANDLE          Message handle is NULL. \n
+ *     @retval MSG_ERR_MEMORY_ERROR            Memory is error. \n
+ *     @retval MSG_ERR_NULL_MESSAGE            Message is NULL. \n
+ *     @retval MSG_ERR_INVALID_MSGHANDLE       Message handle is invalid. \n
+ *     @retval MSG_ERR_NULL_POINTER            pMsg is NULL. \n
+ *     @retval MSG_ERR_PLUGIN                          Generic error code for plugin. \n
+ */
+MSG_ERROR_T MsgTestSubmitReq(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg, MSG_SENDINGOPT_S* pSendOpt);
+
+MSG_ERROR_T MsgRetreiveMMSMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg);
+
+MSG_ERROR_T MsgTestScheduledSubmitReq(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg, MSG_SENDINGOPT_S* pSendOpt);
+
+
+/**
+ *     @}
+ */
+
+#endif //MSG_TEST_TRANSPORT_H
+
diff --git a/test_app/main.cpp b/test_app/main.cpp
new file mode 100755 (executable)
index 0000000..c40a007
--- /dev/null
@@ -0,0 +1,505 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include <iostream>
+#include <list>
+#include <vector>
+#include <string>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/syscall.h>
+#include <glib.h>
+
+using namespace std;
+
+#include "MapiControl.h"
+#include "MapiStorage.h"
+#include "MapiTransport.h"
+#include "MapiMessage.h"
+#include "MsgTestStorage.h"
+#include "MsgTestSetting.h"
+#include "MsgTestThreadView.h"
+#include "MsgTestConvert.h"
+#include "main.h"
+#include <stdio.h>
+
+/*==================================================================================================
+                                         VARIABLES
+==================================================================================================*/
+extern MSG_FOLDER_LIST_S g_folderList;
+
+static MSG_HANDLE_T msgHandle = NULL;
+
+GMainLoop *mainloop;
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+int main(void)
+{
+       print("======================================");
+       print("==== Start Messaging FW Test App. ====");
+       print("======================================");
+
+       if (init_app() != MSG_SUCCESS)
+               return -1;
+
+       return 0;
+}
+
+
+void print(const char* string)
+{
+       cout << string << endl;
+}
+
+
+void print(int i)
+{
+       cout << i << endl;
+}
+
+
+int get_tid()
+{
+    return syscall(__NR_gettid);
+}
+
+
+void printMessageS(msg_message_t pNewMsg)
+{
+       MSG_DEBUG("msgId = %d", msg_get_message_id(pNewMsg));
+       MSG_DEBUG("folderId = %d", msg_get_folder_id(pNewMsg));
+       MSG_DEBUG("msgType = %d", msg_get_message_type(pNewMsg));
+       MSG_DEBUG("nAddressCnt = %d", msg_get_address_count(pNewMsg));
+       MSG_DEBUG("addressList[0].threadId = %d", msg_get_ith_thread_id(pNewMsg, 0));
+       MSG_DEBUG("addressList[0].addressVal = %s", msg_get_ith_address(pNewMsg, 0));
+       MSG_DEBUG("addressList[0].displayname = %s", msg_get_ith_name(pNewMsg, 0));
+       MSG_DEBUG("displayTime = %s", ctime(msg_get_time(pNewMsg)));
+       MSG_DEBUG("networkStatus = %d", msg_get_network_status(pNewMsg));
+       MSG_DEBUG("bRead = %d", msg_is_read(pNewMsg));
+       MSG_DEBUG("bProtected = %d", msg_is_protected(pNewMsg));
+       MSG_DEBUG("priority = %d", msg_get_priority_info(pNewMsg));
+       MSG_DEBUG("dataSize = %d", msg_get_message_body_size(pNewMsg));
+
+       int msgType = msg_get_message_type(pNewMsg);
+
+       if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
+               MSG_DEBUG("msgData = %s", msg_mms_get_text_contents(pNewMsg));
+       else
+               MSG_DEBUG("msgData = %s", msg_sms_get_message_body(pNewMsg));
+}
+
+
+void sentStatusCB(MSG_HANDLE_T Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam)
+{
+       MSG_DEBUG("Receive SentStatus !!!!!!!!!!!!!!!!!");
+
+       if (pStatus->status == MSG_NETWORK_SEND_SUCCESS)
+               MSG_DEBUG("reqId : %d  MSG SENT SUCCESS !!! ", pStatus->reqId);
+       else
+               MSG_DEBUG("reqId : %d  MSG SENT FAIL !!! [%d]", pStatus->reqId, pStatus->status);
+
+       MSG_DEBUG("User Param [%s]", (char*)pUserParam);
+}
+
+
+void incomingSmsCB(MSG_HANDLE_T Handle, msg_message_t msg, void *pUserParam)
+{
+       MSG_DEBUG("Receive New Message !!!!!!!!!!!!!!!!!");
+
+       printMessageS(msg);
+
+       MSG_DEBUG("User Param [%s]", (char*)pUserParam);
+}
+
+
+void incomingMmsConfCB(MSG_HANDLE_T Handle, msg_message_t msg, void *pUserParam)
+{
+       if ( msg_get_network_status(msg) == MSG_NETWORK_RETRIEVE_SUCCESS)
+       {
+               MSG_DEBUG("Receive New MMS Message !!!!!!!!!!!!!!!!!msg Id [%d]", msg_get_message_id(msg));
+       }
+       else
+               MSG_DEBUG("MMS RETRIEVE FAIL !!!!!!! [%d]", msg_get_network_status(msg));
+}
+
+
+void appPortCB (MSG_HANDLE_T Handle, msg_message_t msg, void *pUserParam)
+{
+       MSG_DEBUG("Receive App Port Message - Port Number [%d] !!!!!!!!!!!!!!!!!", msg_get_dest_port(msg));
+
+       printMessageS(msg);
+}
+
+
+void syncMLCB(MSG_HANDLE_T hMsgHandle, MSG_SYNCML_MESSAGE_TYPE_T msgType, const char* pPushBody, int PushBodyLen, const char* wspHeader, int wspHeaderLen, void *pUserParam)
+{
+       MSG_DEBUG("syncMLCB() called");
+
+       MSG_DEBUG("msgType [%d]", msgType);
+
+//     MSG_DEBUG("PushHeaderLen [%d]", PushHeaderLen);
+
+//     MSG_DEBUG("pPushHeader [%s]", pPushHeader);
+
+       MSG_DEBUG("PushBodyLen [%d]", PushBodyLen);
+
+       MSG_DEBUG("[pPushBody]");
+       for (int i = 0; i < PushBodyLen; i++)
+       {
+               printf("[%02x]", pPushBody[i]);
+       }
+       printf("\n\n");
+
+       MSG_SYNCML_MESSAGE_S syncMLMsg;
+
+       memset(&syncMLMsg, 0x00, sizeof(MSG_SYNCML_MESSAGE_S));
+
+       syncMLMsg.extId = 11;
+       syncMLMsg.pinCode = 1111;
+
+       syncMLMsg.msg = msg_new_message();
+
+       msg_set_folder_id(syncMLMsg.msg, MSG_INBOX_ID); //      syncMLMsg.msg.folderId = 1;
+       msg_set_message_type(syncMLMsg.msg, MSG_TYPE_SMS_SYNCML);
+       msg_set_network_status(syncMLMsg.msg, MSG_NETWORK_RECEIVED);    //syncMLMsg.msg.networkStatus = MSG_NETWORK_RECEIVED;
+       msg_set_direction_info(syncMLMsg.msg, MSG_DIRECTION_TYPE_MT);
+
+       msg_add_address(syncMLMsg.msg, "+1004", MSG_RECIPIENTS_TYPE_TO);
+
+       // setting received time
+       time_t t                =       time(NULL);
+       time_t utfTime  =       time(&t);
+       msg_set_time(syncMLMsg.msg, utfTime);
+
+       char msg_body[]="SyncML Message";
+       msg_sms_set_message_body(syncMLMsg.msg, msg_body, strlen(msg_body));
+
+       int err = msg_add_syncml_message(msgHandle, &syncMLMsg);
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgAddSyncMLMessage() Fail [%d]", err);
+               return;
+       }
+}
+
+
+void syncMLOperationCB(MSG_HANDLE_T handle, int msgId, int extId, void *user_param)
+{
+       MSG_DEBUG("syncMLOperationCB() called");
+
+       MSG_DEBUG("msgId [%d]", msgId);
+
+       MSG_DEBUG("extId [%d]", extId);
+
+       //SyncML operation proccess hsa to be place here.
+}
+
+
+void lbsCB(MSG_HANDLE_T hMsgHandle, const char* pPushHeader, const char* pPushBody, int pushBodyLen, void *pUserParam)
+{
+       MSG_DEBUG("lbsCB() called");
+
+       MSG_DEBUG("pPushHeader : [%s]", pPushHeader);
+
+       MSG_DEBUG("pushBodyLen [%d]", pushBodyLen);
+
+       MSG_DEBUG("[pPushBody]");
+       for (int i = 0; i < pushBodyLen; i++)
+       {
+               printf("[%02x]", pPushBody[i]);
+       }
+       printf("\n\n");
+}
+
+
+void storageChangeCB(MSG_HANDLE_T hMsgHandle, MSG_STORAGE_CHANGE_TYPE_T storageChangeType, MSG_MSGID_LIST_S *pMsgIdList, void *pUserParam)
+{
+       MSG_DEBUG("storageChangeCB() called");
+
+       MSG_DEBUG("storageChangeType[%d]", storageChangeType);
+
+       MSG_DEBUG("pMsgIdList->nCount [%d]", pMsgIdList->nCount);
+
+       if (pMsgIdList->nCount > 0) {
+               for (int i = 0; i < pMsgIdList->nCount; i++)
+                       MSG_DEBUG("pMsgIdList->msgIdList[%d] [%d]", i, pMsgIdList->msgIdList[i]);
+       }
+}
+
+
+MSG_ERROR_T init_app()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char str[TEST_APP_PIRNT_STR_LEN+1] = {0,};
+
+       err = msg_open_msg_handle(&msgHandle);
+
+       if (err != MSG_SUCCESS)
+       {
+               snprintf(str, TEST_APP_PIRNT_STR_LEN+1, "msg_open_msg_handle() Fail [%d]", err);
+               print(str);
+
+               return err;
+       }
+
+       err = msg_reg_sent_status_callback(msgHandle, &sentStatusCB, (void*)"sent status callback");
+
+       if (err != MSG_SUCCESS)
+       {
+               snprintf(str, TEST_APP_PIRNT_STR_LEN+1, "msg_reg_sent_status_callback() Fail [%d]", err);
+               print(str);
+
+               return err;
+       }
+
+       err = msg_reg_sms_message_callback(msgHandle, &incomingSmsCB, 0, (void*)"sms message callback");
+
+       if (err != MSG_SUCCESS)
+       {
+               snprintf(str, TEST_APP_PIRNT_STR_LEN+1, "msg_reg_sms_message_callback() Fail [%d]", err);
+               print(str);
+
+               return err;
+       }
+
+       err = msg_reg_sms_message_callback(msgHandle, &appPortCB, 4010, (void*)"sms message callback with port");
+
+       if (err != MSG_SUCCESS)
+       {
+               snprintf(str, TEST_APP_PIRNT_STR_LEN+1, "msg_reg_sms_message_callback() Fail [%d]", err);
+               print(str);
+
+               return err;
+       }
+
+        err = msg_reg_syncml_message_callback(msgHandle, &syncMLCB, NULL);
+
+       if (err != MSG_SUCCESS)
+       {
+               snprintf(str, TEST_APP_PIRNT_STR_LEN+1, "msg_reg_syncml_message_callback() Fail [%d]", err);
+               print(str);
+
+               return err;
+       }
+
+       err = msg_reg_syncml_message_operation_callback(msgHandle, &syncMLOperationCB, NULL);
+
+       if (err != MSG_SUCCESS)
+       {
+               snprintf(str, TEST_APP_PIRNT_STR_LEN+1, "msg_reg_syncml_message_operation_callback() Fail [%d]", err);
+               print(str);
+
+               return err;
+       }
+
+       err = msg_reg_lbs_message_callback(msgHandle, &lbsCB, NULL);
+
+       if (err != MSG_SUCCESS)
+       {
+               snprintf(str, TEST_APP_PIRNT_STR_LEN+1, "msg_reg_lbs_message_callback() Fail [%d]", err);
+               print(str);
+
+               return err;
+       }
+
+       err = msg_reg_mms_conf_message_callback(msgHandle, &incomingMmsConfCB, NULL, NULL);
+
+       if (err != MSG_SUCCESS)
+       {
+               snprintf(str, TEST_APP_PIRNT_STR_LEN+1, "msg_reg_mms_conf_message_callback() Fail [%d]", err);
+               print(str);
+
+               return err;
+       }
+
+       err = msg_reg_storage_change_callback(msgHandle, &storageChangeCB, NULL);
+
+       if (err != MSG_SUCCESS)
+       {
+               snprintf(str, TEST_APP_PIRNT_STR_LEN+1, "msg_reg_storage_change_callback() Fail [%d]", err);
+               print(str);
+
+               return err;
+       }
+
+       pthread_t tid;
+
+       if (pthread_create(&tid, NULL, show_menu, NULL) != 0)
+       {
+               MSG_DEBUG("MsgInitThread not invoked: %s", strerror(errno));
+               return MSG_ERR_UNKNOWN;
+       }
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       MSG_DEBUG("Entering GMain Loop to Receive Notifications...");
+
+       g_main_loop_run(mainloop);
+
+       return err;
+}
+
+
+void* show_menu(void*)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char menu[3];
+
+       char strPrint[TEST_APP_PIRNT_STR_LEN+1] = {0,};
+
+       // Get Message Count
+       MSG_COUNT_INFO_S countInfo;
+
+       do
+       {
+               msg_release_folder_list(&g_folderList);
+
+               // Get Folder List
+               err = msg_get_folder_list(msgHandle, &g_folderList);
+
+               if (err != MSG_SUCCESS)
+               {
+                       MSG_DEBUG("MsgGetFolderList() Fail [%d]", err);
+                       return (void*)1;
+               }
+
+               system ("clear");
+
+               print("======================================");
+               print("============== Box List ==============");
+               print("======================================");
+
+               for (int i = 0; i < g_folderList.nCount; i++)
+               {
+                       if (msg_count_message(msgHandle, g_folderList.folderInfo[i].folderId, &countInfo) != MSG_SUCCESS)
+                               return (void*)1;
+
+                       memset(strPrint, 0x00, sizeof(strPrint));
+                       snprintf(strPrint, TEST_APP_PIRNT_STR_LEN+1, "[%d] %s \t [%d/%d] [SMS %d/MMS %d]",
+                               g_folderList.folderInfo[i].folderId, g_folderList.folderInfo[i].folderName, countInfo.nUnreadCnt, countInfo.nUnreadCnt + countInfo.nReadCnt, countInfo.nSms, countInfo.nMms);
+                       print(strPrint);
+               }
+
+               print("======================================");
+               print("================ Menu ================");
+               print("======================================");
+               print("[C] Create Message");
+               print("[S] Setting");
+               print("[A] Add New Folder");
+               print("[D] Delete a Folder");
+               print("[U] Update Folder Name");
+               print("[V] Convert(Encode/Decode) Charset");
+               print("[M] Msg Generator");
+               print("[T] Thread View Test");
+               print("[G] Search Message");
+               print("[Q] Quit");
+               print("======================================");
+
+               print("Input : ");
+
+               memset(menu, 0x00, sizeof(menu));
+               cin.getline(menu, 3);
+
+               run_app(menu);
+       }
+       while (strcmp(menu, "Q"));
+
+       msg_release_folder_list(&g_folderList);
+
+       msg_close_msg_handle(&msgHandle);
+
+       if (msgHandle != NULL)
+       {
+               MSG_DEBUG("msgHandle is not NULL [%p]", msgHandle);
+       }
+
+       if (g_main_loop_is_running(mainloop))
+               g_main_loop_quit(mainloop);
+
+       print("======================================");
+       print("==== End Messaging FW Test App. Bye===");
+       print("======================================");
+
+       exit(0);
+}
+
+
+void run_app(char *pMenu)
+{
+       if (!strcmp(pMenu, "C") || !strcmp(pMenu, "c"))
+       {
+               MsgTestAddMessage(msgHandle);
+       }
+       else if (!strcmp(pMenu, "S") || !strcmp(pMenu, "s"))
+       {
+               MsgTestSettingMain(msgHandle);
+       }
+       else if (!strcmp(pMenu, "A") || !strcmp(pMenu, "a"))
+       {
+               MsgTestAddFolder(msgHandle);
+       }
+       else if (!strcmp(pMenu, "D") || !strcmp(pMenu, "d"))
+       {
+               MsgTestDeleteFolder(msgHandle);
+       }
+       else if (!strcmp(pMenu, "U") || !strcmp(pMenu, "u"))
+       {
+               MsgTestUpdateFolder(msgHandle);
+       }
+       else if (!strcmp(pMenu, "V") || !strcmp(pMenu, "v"))
+       {
+//             MsgTestConvertMain();
+       }
+       else if (!strcmp(pMenu, "M") || !strcmp(pMenu, "m"))
+       {
+               MsgTestMsgGen(msgHandle);
+       }
+       else if (!strcmp(pMenu, "T") || !strcmp(pMenu, "t"))
+       {
+               MsgThreadViewMain(msgHandle);
+       }
+       else if (!strcmp(pMenu, "G") || !strcmp(pMenu, "g"))
+       {
+               MsgSearchViewMain(msgHandle);
+       }
+       else if (!strcmp(pMenu, "Q") || !strcmp(pMenu, "q"))
+       {
+               return;
+       }
+       else
+       {
+               int folderId = atoi(pMenu);
+
+               if (folderId > 0 && folderId < 100)
+               {
+                       // Query Msg List in Msg Box
+                       MsgTestGetMessageList(msgHandle, folderId);
+               }
+               else
+                       print("Not Supported");
+       }
+}
+
diff --git a/test_app/main.h b/test_app/main.h
new file mode 100755 (executable)
index 0000000..49158e2
--- /dev/null
@@ -0,0 +1,203 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+
+/**
+ *     @file           Main.h
+ *     @brief          Defines function for test application of messaging framework
+ *     @version                1.0
+ */
+
+#ifndef MSG_TEST_MAIN_H
+#define MSG_TEST_MAIN_H
+
+/**
+ *     @mainpage
+ *     @section                Introduction
+ *     - This document includes as follows : \n
+ *     What is Messaging API \n
+ *     What are included in Messaging API, such as data types, functions, and so on \n
+ *     @section                Contents
+ *     - Modules
+ *     - Structure
+ *     - MessageHandle
+ *     - Request
+ *     - Callback
+ *     - Filter
+ *     - Storage
+ *     - Extendability
+ *     @section                Modules
+ *     MAPI provides a service to send, receive, parse and assemble messages over arbitrary message delivery mechanisms such as SMS, MMS, and E-mail.
+ *     Messaging Service consists of a collection of common functionality and sets of service specific functionality.
+ *     Use of particular messaging service specific functionality shall be possible.
+ *     MAPI provides a collection of data structures as well as functions to implement the functionality. \n\n
+ *     The data structures and functions are grouped into modules, as listed below:
+ *     - Message sending and reception
+ *     - Storage management
+ *     - Message storage
+ *     - Folder storage
+ *     @section                Structure
+ *     Message \n\n
+ *     A message represents a generic data collection of SMS, MMS, and E-mail.
+ *     This is not specific to any service, but supports the extension of this structure.
+ *     For service specific message, please refer to extendability of common structure.
+ *     Each message has a unique message ID in the entire messaging framework.
+ *     The message information can be retrieved from the storage by its message ID. \n\n
+ *     This concept is defined in MsgTypes.h. \n\n
+ *     Folder \n
+ *     A folder represents a container of messages.
+ *     Each folder has a unique folder ID in the entire messaging framework.
+ *     The folder information can be retrieved from the storage by its folder ID.
+ *     A folder can specify where it is stored.
+ *     The storage where a folder is stored can be different from the storage where its containing messages are stored. \n\n
+ *     This concept is defined in MsgStorageTypes.h. \n\n
+ *     @section                MessageHandle
+ *     MessageHandle is the connection between application and MAPI.
+ *     When an application wants to send, receive, add, or get a message, it must open a MessageHandle first.
+ *     To know how to use asynchronous callback for communication between application and framework, please refer to Callback. \n\n
+ *     A MessageHandle can be assigned with following information: \n
+ *     - Register MsgOnMessageIncomingCallback function.
+ *     - Register MsgOnStatusChangedCallback function.
+ *     - Set filter rule.
+ *     @section                Request
+ *     A request contains the information that is used to command framework for services, such as sending a message.
+ *     A request is sent to Messaging Framework via a MessageHandle, and Messaging Framework chooses proper plugin to handle the request.
+ *     A common usage for the request is to send a message. \n\n
+ *     This concept is defined in MsgTypes.h. \n\n
+ *     @section                Callback
+ *     Callback is used by application to detect incoming message and underlayer status change.
+ *     Two callback functions are implemented by applications and should be bound to a MessageHandle.
+ *     Both prototypes are provided: \n
+ *     - One is MsgOnMessageIncomingCallback, which is to listen incoming message.
+ *     - The other is MsgOnStatusChangedCallback, which is to listen underlayer status change.
+ *     @section                Filter
+ *     When an application is only interested in some kinds of messages, filter list is used to filter these specific messages and return them to the application.
+ *     Noted that filter is for filtering incoming messages, not a storage concept.
+ *     Filter is the basic unit to set the rules, it tells the filter service how to filter the message.
+ *     Filter list is composed of various filters. \n\n
+ *     They are defined in MsgFilterTypes.h. \n\n
+ *     Application can set a filter list for a MessageHandle to get the interesting message.
+ *     Please refer to MSG_FILTER_S and MSG_FILTER_LIST_S for details.
+ *     MAPI does NOT define any filters.
+ *     Application developers should refer to the specific implementation of filter service to get the supported filters.
+ *     @section                Storage
+ *     Storage is a collection of messages and related information that are stored on one storage media.
+ *     Storage media is the physical data storage device, such as SD card and Flash.
+ *     One storage media can have more than one storages.
+ *     Since storage media can be removable, the storages on the media can be detached and attached dynamically.
+ *     For instance, user plugs out SD card from UE 1 and plugs in this card into UE 2, all the messages stored in this card will be hidden from UE 1 and be visible to UE 2.
+ *     For details information, please refer to MSG_STORAGE_LIST_S.
+ *     Application can query supported storages by MAPI method MsgGetStorageList.
+ *     @section                Extendability
+ *     There are several structures in LiMo Messageing designed to be extended. They are: \n
+ *     - MSG_FOLDER_INFO_S
+ *     - msg_message_t
+ *     - MSG_REQUEST_S
+ */
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/time.h>
+#include <time.h>
+
+#include "MsgTypes.h"
+
+#define TEST_APP_PIRNT_STR_LEN                 128
+
+/**
+ *     @ingroup                MESSAGING_FRAMEWORK
+ *     @defgroup       MESSAGING_TEST_APPLICATION_BASIC_FUNCTION       Messaging Test Application Basic Function
+ *     @{
+ */
+
+
+/*==================================================================================================
+                                         DEFINES
+==================================================================================================*/
+#define MSG_FATAL(fmt, ...) \
+       do \
+       {\
+               printf("\n[%d] [MSGFW: %s: %s(): %d] *FAILED* << " fmt" >>\n", get_tid(), rindex(__FILE__, '/')+1,  __FUNCTION__, __LINE__,  ##__VA_ARGS__);\
+       } while (0)
+
+#define MSG_DEBUG(fmt, ...) \
+       do\
+       {\
+               printf("\n[%d] [MSGFW: %s: %s(): %d] " fmt"\n", get_tid(), rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__);\
+       } while (0)
+
+#define MSG_BEGIN() \
+       do\
+    {\
+        printf("\n[%d] BEGIN >>>> %s() at [MSGFW: %s: %d]\n", get_tid(),__FUNCTION__, rindex(__FILE__, '/')+1,  __LINE__ );\
+    } while( 0 )
+
+#define MSG_END() \
+       do\
+    {\
+        printf("\n[%d] END   <<<< %s() at [MSGFW: %s: %d]\n", get_tid(), __FUNCTION__, rindex(__FILE__, '/')+1,  __LINE__); \
+    } \
+    while( 0 )
+
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+
+void print(const char* string);
+
+
+void print(int i);
+
+
+int get_tid();
+
+
+/**    @fn             MSG_ERROR_T init_app()
+ *     @brief  Initializes a test application.
+ *     @return MSG_ERROR_T
+ *     @retval MSG_SUCCESS                             Success in operation. \n
+ *     @retval MSG_ERR_NULL_POINTER            pMsg is NULL. \n
+ *     @retval MSG_ERR_MEMORY_ERROR            Memory is error. \n
+ *     @retval MSG_ERR_INVALID_MSGHANDLE       Message handle is invalid. \n
+ *     @retval MSG_ERR_INVALID_PARAMETER       Parameter is invalid. \n
+ */
+MSG_ERROR_T init_app();
+
+
+/**    @fn             void show_menu()
+ *     @brief  Shows folder information and the test menu list.
+ */
+void* show_menu(void*);
+
+
+/**    @fn             void run_app(char menu)
+ *     @brief  Runs a selected menu in the test menu list.
+ *     @param[in]      Menu indicates which menu is selected.
+ */
+void run_app(char *pMenu);
+
+/**
+ *     @}
+ */
+
+#endif //MSG_TEST_MAIN_H
+
diff --git a/test_app/mms_files/A.smi b/test_app/mms_files/A.smi
new file mode 100755 (executable)
index 0000000..9714462
--- /dev/null
@@ -0,0 +1,26 @@
+<smil>\r
+<head>\r
+<layout>\r
+<root-layout backgroundColor="#ffffff"/>\r
+<region id="Image" top="50%" left="0%" width="100%" height="50%" fit="meet" backgroundColor="#ffffff"/>\r
+<region id="Text" top="0%" left="0%" width="100%" height="50%" backgroundColor="#ffffff"/>\r
+</layout>\r
+</head>\r
+<body>\r
+<par dur="5440ms">\r
+<text src="Temp0_2.txt" color="#000000" size="20" region="Text">\r
+<param name="foreground-color" value="#000000"/>\r
+<param name="textsize" value="20"/>\r
+</text>\r
+<img src="P091120_104633.jpg" region="Image"/>\r
+<audio src="audio.amr"/>\r
+</par>\r
+<par dur="4544ms">\r
+<text src="Temp1_0.txt" color="#000000" size="20" region="Text">\r
+<param name="foreground-color" value="#000000"/>\r
+<param name="textsize" value="20"/>\r
+</text>\r
+<video src="V091120_104905.3gp" region="Text" alt="Video Load Fail"/>\r
+</par>\r
+</body>\r
+</smil>\r
diff --git a/test_app/mms_files/P091120_104633.jpg b/test_app/mms_files/P091120_104633.jpg
new file mode 100755 (executable)
index 0000000..c241c2a
Binary files /dev/null and b/test_app/mms_files/P091120_104633.jpg differ
diff --git a/test_app/mms_files/Temp0_2.txt b/test_app/mms_files/Temp0_2.txt
new file mode 100755 (executable)
index 0000000..74c7dd8
--- /dev/null
@@ -0,0 +1 @@
+Test MMS Message
\ No newline at end of file
diff --git a/test_app/mms_files/Temp1_0.txt b/test_app/mms_files/Temp1_0.txt
new file mode 100755 (executable)
index 0000000..f6d6f92
--- /dev/null
@@ -0,0 +1 @@
+Second Slide
\ No newline at end of file
diff --git a/test_app/mms_files/V091120_104905.3gp b/test_app/mms_files/V091120_104905.3gp
new file mode 100755 (executable)
index 0000000..7cdcb31
Binary files /dev/null and b/test_app/mms_files/V091120_104905.3gp differ
diff --git a/test_app/mms_files/audio.amr b/test_app/mms_files/audio.amr
new file mode 100755 (executable)
index 0000000..645ec5d
Binary files /dev/null and b/test_app/mms_files/audio.amr differ
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..2c6df8e
--- /dev/null
@@ -0,0 +1,58 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(msg-server CXX)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Debug")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall")
+
+##########################################################
+# Define Framework Utils
+##########################################################
+
+SET(UTILS-SRCS 
+       ${CMAKE_SOURCE_DIR}/utils/MsgDebug.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgException.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgUtilFunction.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgIpcSocket.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgUtilFile.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgSqliteWrapper.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgSoundPlayer.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgUtilStorage.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgContact.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgGconfWrapper.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgNotificationWrapper.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgMemory.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgMmsMessage.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgDrmWrapper.cpp
+)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/include/common
+       ${CMAKE_SOURCE_DIR}/include/framework
+       ${CMAKE_SOURCE_DIR}/include/msg_helper
+       ${CMAKE_SOURCE_DIR}/include/utils
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(utils_pkgs REQUIRED glib-2.0 vconf db-util contacts-service dlog pmapi mm-session alarm-service notification drm-client drm-trusted)
+
+FOREACH(flag ${utils_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${UTILS-LIB} SHARED ${UTILS-SRCS})
+TARGET_LINK_LIBRARIES(${UTILS-LIB} ${utils_pkgs_LDFLAGS} rt)
+
+INSTALL(TARGETS ${UTILS-LIB} DESTINATION lib COMPONENT RuntimeLibraries)
+
diff --git a/utils/MsgContact.cpp b/utils/MsgContact.cpp
new file mode 100755 (executable)
index 0000000..519139f
--- /dev/null
@@ -0,0 +1,460 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+extern "C"
+{
+       #include <contacts-svc.h>
+}
+
+#include "MsgDebug.h"
+#include "MsgUtilStorage.h"
+#include "MsgGconfWrapper.h"
+#include "MsgContact.h"
+
+
+/*==================================================================================================
+                                     VARIABLES
+==================================================================================================*/
+static bool isContactSvcOpened = false;
+
+MsgDbHandler ContactDbHandle;
+
+MsgContactChangeCB cbFunction = NULL;
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+static void MsgContactSvcCallback(void *pData)
+{
+       MSG_DEBUG("Contact Data is Changed!!!");
+
+       MsgSyncContact();
+
+       if (ContactDbHandle.disconnect() != MSG_SUCCESS)
+       {
+               MSG_DEBUG("DB Disconnect Fail");
+       }
+}
+
+
+MSG_ERROR_T MsgOpenContactSvc()
+{
+       int errCode = CTS_SUCCESS;
+
+       if(!isContactSvcOpened)
+       {
+               errCode = contacts_svc_connect();
+
+               if (errCode == CTS_SUCCESS)
+               {
+                       MSG_DEBUG("Connect to Contact Service Success");
+                       isContactSvcOpened = true;
+               }
+               else
+               {
+                       MSG_DEBUG("Connect to Contact Service Fail [%d]", errCode);
+                       isContactSvcOpened = false;
+                       return MSG_ERR_DB_CONNECT;
+               }
+       }
+       else
+       {
+               MSG_DEBUG("Already connected to Contact Service.");
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgCloseContactSvc()
+{
+       int errCode = CTS_SUCCESS;
+
+       if(isContactSvcOpened)
+       {
+               errCode = contacts_svc_disconnect();
+
+               if (errCode == CTS_SUCCESS)
+               {
+                       MSG_DEBUG("Disconnect to Contact Service Success");
+               }
+               else
+               {
+                       MSG_DEBUG("Disconnect to Contact Service Fail [%d]", errCode);
+                       return MSG_ERR_DB_DISCONNECT;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgInitContactSvc(MsgContactChangeCB cb)
+{
+       int errCode = CTS_SUCCESS;
+
+       if (cb != NULL)
+               cbFunction = cb;
+
+       // Register callback function
+       errCode = contacts_svc_subscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE, MsgContactSvcCallback, NULL);
+
+       if (errCode == CTS_SUCCESS)
+       {
+               MSG_DEBUG("Register Contact Service Callback");
+       }
+       else
+       {
+               MSG_DEBUG("Fail to Register Contact Service Callback [%d]", errCode);
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_INFO_S *pContactInfo)
+{
+       MSG_BEGIN();
+
+       MSG_DEBUG("Address Type [%d], Address Value [%s]", pAddrInfo->addressType, pAddrInfo->addressVal);
+
+       memset(pContactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
+
+       if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_PLMN && strlen(pAddrInfo->addressVal) > (MAX_PHONE_NUMBER_LEN+1))
+       {
+               MSG_DEBUG("Phone Number is too long [%s]", pAddrInfo->addressVal);
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       int index, ret = -1;
+
+       CTSstruct* contact = NULL;
+
+       cts_find_op recordType;
+
+       if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_EMAIL)
+               recordType = CTS_FIND_BY_EMAIL;
+       else
+               recordType = CTS_FIND_BY_NUMBER;
+
+       index = contacts_svc_find_contact_by(recordType, (char*)pAddrInfo->addressVal);
+
+       if (index > CTS_SUCCESS)
+       {
+               MSG_DEBUG("Index : [%d]", index);
+               ret = contacts_svc_get_contact(index, &contact);
+       }
+
+       if (ret < 0)
+       {
+               MSG_DEBUG("No Contact Info");
+               return MSG_SUCCESS;
+       }
+
+       CTSvalue* name = NULL;
+
+       ret = contacts_svc_struct_get_value(contact, CTS_CF_NAME_VALUE, &name);
+
+       if (ret != CTS_SUCCESS)
+       {
+               MSG_DEBUG("contacts_svc_struct_get_value() Error [%d]", ret);
+               return MSG_SUCCESS;
+       }
+
+       const char* strDisplayName = contacts_svc_value_get_str(name, CTS_NAME_VAL_DISPLAY_STR);
+       const char* strFirstName = contacts_svc_value_get_str(name, CTS_NAME_VAL_FIRST_STR);
+       const char* strLastName = contacts_svc_value_get_str(name, CTS_NAME_VAL_LAST_STR);
+
+       MSG_DEBUG("Display Name : [%s], First Name : [%s], Last Name : [%s]", strDisplayName, strFirstName, strLastName);
+
+       if (strDisplayName != NULL)
+       {
+               strncpy(pContactInfo->displayName, strDisplayName, MAX_DISPLAY_NAME_LEN);
+       }
+
+       if (strFirstName != NULL)
+       {
+               strncpy(pContactInfo->firstName, strFirstName, MAX_DISPLAY_NAME_LEN);
+       }
+
+       if (strLastName != NULL)
+       {
+               strncpy(pContactInfo->lastName, strLastName, MAX_DISPLAY_NAME_LEN);
+       }
+
+       CTSvalue* base = NULL;
+
+       ret = contacts_svc_struct_get_value(contact, CTS_CF_BASE_INFO_VALUE, &base);
+
+       if (ret != CTS_SUCCESS)
+       {
+               MSG_DEBUG("contacts_svc_struct_get_value() Error [%d]", ret);
+               return MSG_SUCCESS;
+       }
+
+       pContactInfo->contactId = contacts_svc_value_get_int(base, CTS_BASE_VAL_ID_INT);
+
+       MSG_DEBUG("Contact ID [%d]", pContactInfo->contactId);
+
+       const char* strImagePath = contacts_svc_value_get_str(base, CTS_BASE_VAL_IMG_PATH_STR);
+
+       if (strImagePath != NULL)
+       {
+               strncpy(pContactInfo->imagePath , strImagePath, MAX_IMAGE_PATH_LEN);
+       }
+
+       MSG_DEBUG("Image Path [%s]", pContactInfo->imagePath);
+
+       contacts_svc_value_free(base);
+       contacts_svc_value_free(name);
+
+       contacts_svc_struct_free(contact);
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+void MsgSyncContact()
+{
+       int ret = -1;
+       int index_num = 0;
+       int changed_count = 0;
+       int lastSyncTime = 0;
+
+       /* get contact sync time */
+       lastSyncTime = MsgSettingGetInt(CONTACT_SYNC_TIME);
+
+       if (lastSyncTime < 0) {
+               MSG_DEBUG("Fail to get CONTACT_SYNC_TIME.");
+               lastSyncTime = 0;
+       }
+
+       CTSiter* pIter;
+
+       ret = contacts_svc_get_updated_contacts(0, lastSyncTime, &pIter);
+
+       if (ret != CTS_SUCCESS)
+       {
+               MSG_DEBUG("contacts_svc_get_updated_contacts() Error [%d]", ret);
+               return;
+       }
+
+       while (contacts_svc_iter_next(pIter) == CTS_SUCCESS)
+       {
+               CTSvalue *row_info = NULL;
+
+               row_info = contacts_svc_iter_get_info(pIter);
+
+               index_num = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_ID_INT);
+
+               MSG_DEBUG("index (%d)", index_num);
+
+               int type = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_TYPE_INT);
+
+               if (type == CTS_OPERATION_UPDATED || type == CTS_OPERATION_INSERTED)
+               {
+                       MsgUpdateContact(index_num, type);
+               }
+               else // Delete
+               {
+                       MSG_DEBUG("Delete Contact");
+
+                       MsgDeleteContact(index_num);
+               }
+
+               if(lastSyncTime < contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_VER_INT))
+                       lastSyncTime = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_VER_INT);
+
+               contacts_svc_value_free(row_info);
+
+               changed_count++;
+
+       }
+
+       MsgSettingSetInt(CONTACT_SYNC_TIME, lastSyncTime);
+       MSG_DEBUG("lastSyncTime : %d", lastSyncTime);
+
+       contacts_svc_iter_remove(pIter);
+
+       if(changed_count > 0)
+               cbFunction();
+}
+
+
+bool MsgInsertContact(MSG_CONTACT_INFO_S *pContactInfo, const char *pNumber)
+{
+       if (!pNumber || strlen(pNumber) <= 0)
+               return false;
+
+       if (MsgStoAddContactInfo(&ContactDbHandle, pContactInfo, pNumber) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Fail to add contact info.");
+               return false;
+       }
+
+       return true;
+}
+
+
+bool MsgUpdateContact(int index, int type)
+{
+       int ret = -1;
+
+       CTSstruct *contact = NULL;
+
+       ret = contacts_svc_get_contact(index, &contact);
+
+       if (ret != CTS_SUCCESS)
+       {
+               MSG_DEBUG("contacts_svc_get_contact() Error [%d]", ret);
+               return false;
+       }
+
+       // Base Info
+       CTSvalue *base = NULL;
+
+       ret = contacts_svc_struct_get_value(contact, CTS_CF_BASE_INFO_VALUE, &base);
+
+       if (ret != CTS_SUCCESS)
+       {
+               MSG_DEBUG("contacts_svc_struct_get_value() Error [%d]", ret);
+               return false;
+       }
+
+       MSG_CONTACT_INFO_S contactInfo = {0};
+
+       contactInfo.contactId = contacts_svc_value_get_int(base, CTS_BASE_VAL_ID_INT);
+
+       MSG_DEBUG("Contact ID [%d]", contactInfo.contactId);
+
+       const char* strImagePath = contacts_svc_value_get_str(base, CTS_BASE_VAL_IMG_PATH_STR);
+
+       if (strImagePath != NULL)
+       {
+               strncpy(contactInfo.imagePath , strImagePath, MAX_IMAGE_PATH_LEN);
+       }
+
+       MSG_DEBUG("Image Path [%s]", contactInfo.imagePath);
+
+       // Name Info
+       CTSvalue* name = NULL;
+
+       ret = contacts_svc_struct_get_value(contact, CTS_CF_NAME_VALUE, &name);
+
+       if (ret != CTS_SUCCESS)
+       {
+               MSG_DEBUG("contacts_svc_struct_get_value() Error [%d]", ret);
+               return MSG_SUCCESS;
+       }
+
+       const char* strDisplayName = contacts_svc_value_get_str(name, CTS_NAME_VAL_DISPLAY_STR);
+       const char* strFirstName = contacts_svc_value_get_str(name, CTS_NAME_VAL_FIRST_STR);
+       const char* strLastName = contacts_svc_value_get_str(name, CTS_NAME_VAL_LAST_STR);
+
+       MSG_DEBUG("Display Name : [%s], First Name : [%s], Last Name : [%s]", strDisplayName, strFirstName, strLastName);
+
+       if (strDisplayName != NULL)
+       {
+               strncpy(contactInfo.displayName, strDisplayName, MAX_DISPLAY_NAME_LEN);
+       }
+
+       if (strFirstName != NULL)
+       {
+               strncpy(contactInfo.firstName, strFirstName, MAX_DISPLAY_NAME_LEN);
+       }
+
+       if (strLastName != NULL)
+       {
+               strncpy(contactInfo.lastName, strLastName, MAX_DISPLAY_NAME_LEN);
+       }
+
+       MsgStoClearContactInfo(&ContactDbHandle, index);
+
+       GSList *get_list, *cursor;
+
+       get_list = NULL;
+
+       contacts_svc_struct_get_list(contact, CTS_CF_NUMBER_LIST, &get_list);
+
+       cursor = get_list;
+
+       // No phone number in contact
+       if (cursor == NULL)
+       {
+                contacts_svc_struct_free(contact);
+
+               return true;
+       }
+
+       for(; cursor; cursor = g_slist_next(cursor))
+       {
+               MSG_DEBUG("Add Contact Data");
+
+               const char* strNumber = contacts_svc_value_get_str((CTSvalue*)cursor->data, CTS_NUM_VAL_NUMBER_STR);
+
+               MSG_DEBUG("Number = %s", strNumber);
+
+               if (MsgInsertContact(&contactInfo, strNumber) == false)
+               {
+                       continue;
+               }
+       }
+
+       contacts_svc_struct_free(contact);
+
+       return true;
+}
+
+
+bool MsgDeleteContact(int index)
+{
+       if (MsgStoClearContactInfo(&ContactDbHandle, index) != MSG_SUCCESS)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+
+int MsgGetContactNameOrder()
+{
+       int ret = 0;
+
+       cts_order_type order = CTS_ORDER_NAME_FIRSTLAST;
+
+       order = contacts_svc_get_order(CTS_ORDER_OF_DISPLAY);
+
+       if (order == CTS_ORDER_NAME_FIRSTLAST)
+               ret = 0;
+       else if (order == CTS_ORDER_NAME_LASTFIRST)
+               ret = 1;
+
+       return ret;
+}
+
+
+int MsgContactSVCBeginTrans()
+{
+       return contacts_svc_begin_trans();
+}
+
+
+int MsgContactSVCEndTrans(bool bSuccess)
+{
+       return contacts_svc_end_trans(bSuccess);
+}
diff --git a/utils/MsgDebug.cpp b/utils/MsgDebug.cpp
new file mode 100755 (executable)
index 0000000..fa63eff
--- /dev/null
@@ -0,0 +1,290 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include <sys/syscall.h>
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+const char * MsgDbgCmdStr(MSG_CMD_TYPE_T cmdType)
+{
+       switch ( cmdType )
+       {
+// 0
+               case MSG_CMD_OPEN_HANDLE:
+                       return "MSG_CMD_OPEN_HANDLE";
+               case MSG_CMD_CLOSE_HANDLE:
+                       return "MSG_CMD_CLOSE_HANDLE";
+               case MSG_CMD_GET_STORAGELIST:
+                       return "MSG_CMD_GET_STORAGELIST";
+               case MSG_CMD_ADD_MSG:
+                       return "MSG_CMD_ADD_MSG";
+               case MSG_CMD_ADD_SYNCML_MSG:
+                       return "MSG_CMD_ADD_SYNCML_MSG";
+
+// 5
+               case MSG_CMD_UPDATE_MSG:
+                       return "MSG_CMD_UPDATE_MSG";
+               case MSG_CMD_UPDATE_READ:
+                       return "MSG_CMD_UPDATE_READ";
+               case MSG_CMD_UPDATE_PROTECTED:
+                       return "MSG_CMD_UPDATE_PROTECTED";
+               case MSG_CMD_DELETE_MSG:
+                       return "MSG_CMD_DELETE_MSG";
+               case MSG_CMD_DELALL_MSGINFOLDER:
+                       return "MSG_CMD_DELALL_MSGINFOLDER";
+
+// 10
+               case MSG_CMD_MOVE_MSGTOFOLDER:
+                       return "MSG_CMD_MOVE_MSGTOFOLDER";
+               case MSG_CMD_MOVE_MSGTOSTORAGE:
+                       return "MSG_CMD_MOVE_MSGTOSTORAGE";
+               case MSG_CMD_COUNT_MSG:
+                       return "MSG_CMD_COUNT_MSG";
+               case MSG_CMD_GET_MSG:
+                       return "MSG_CMD_GET_MSG";
+               case MSG_CMD_GET_FOLDERVIEWLIST:
+                       return "MSG_CMD_GET_FOLDERVIEWLIST";
+
+// 15
+               case MSG_CMD_ADD_FOLDER:
+                       return "MSG_CMD_ADD_FOLDER";
+               case MSG_CMD_UPDATE_FOLDER:
+                       return "MSG_CMD_UPDATE_FOLDER";
+               case MSG_CMD_DELETE_FOLDER:
+                       return "MSG_CMD_DELETE_FOLDER";
+               case MSG_CMD_GET_FOLDERLIST:
+                       return "MSG_CMD_GET_FOLDERLIST";
+               case MSG_CMD_SET_CONFIG:
+                       return "MSG_CMD_SET_CONFIG";
+
+// 20
+               case MSG_CMD_GET_CONFIG:
+                       return "MSG_CMD_GET_CONFIG";
+               case MSG_CMD_GET_MSG_TYPE:
+                       return "MSG_CMD_GET_MSG_TYPE";
+               case MSG_CMD_SUBMIT_REQ:
+                       return "MSG_CMD_SUBMIT_REQ";
+               case MSG_CMD_CANCEL_REQ:
+                       return "MSG_CMD_CANCEL_REQ";
+               case MSG_CMD_REG_SENT_STATUS_CB:
+                       return "MSG_CMD_REG_SENT_STATUS_CB";
+
+// 25
+               case MSG_CMD_REG_STORAGE_CHANGE_CB:
+                       return "MSG_CMD_REG_STORAGE_CHANGE_CB";
+               case MSG_CMD_REG_INCOMING_MSG_CB:
+                       return "MSG_CMD_REG_INCOMING_MSG_CB";
+               case MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB:
+                       return "MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB";
+               case MSG_CMD_REG_INCOMING_SYNCML_MSG_CB:
+                       return "MSG_CMD_REG_INCOMING_SYNCML_MSG_CB";
+               case MSG_CMD_REG_INCOMING_LBS_MSG_CB:
+                       return "MSG_CMD_REG_INCOMING_LBS_MSG_CB";
+
+// 30
+               case MSG_CMD_PLG_SENT_STATUS_CNF:
+                       return "MSG_CMD_PLG_SENT_STATUS_CNF";
+               case MSG_CMD_PLG_STORAGE_CHANGE_IND:
+                       return "MSG_CMD_PLG_STORAGE_CHANGE_IND";
+               case MSG_CMD_PLG_INCOMING_MSG_IND:
+                       return "MSG_CMD_PLG_INCOMING_MSG_IND";
+               case MSG_CMD_PLG_INCOMING_MMS_CONF:
+                       return "MSG_CMD_PLG_INCOMING_MMS_CONF";
+               case MSG_CMD_PLG_INCOMING_SYNCML_IND:
+                       return "MSG_CMD_PLG_INCOMING_SYNCML_IND";
+
+// 35
+               case MSG_CMD_PLG_INCOMING_LBS_IND:
+                       return "MSG_CMD_PLG_INCOMING_LBS_IND";
+               case MSG_CMD_PLG_INIT_SIM_BY_SAT:
+                       return "MSG_CMD_PLG_INIT_SIM_BY_SAT";
+               case MSG_CMD_GET_THREADVIEWLIST:
+                       return "MSG_CMD_GET_THREADVIEWLIST";
+               case MSG_CMD_GET_CONVERSATIONVIEWLIST:
+                       return "MSG_CMD_GET_CONVERSATIONVIEWLIST";
+               case MSG_CMD_DELETE_THREADMESSAGELIST:
+                       return "MSG_CMD_DELETE_THREADMESSAGELIST";
+
+// 40
+               case MSG_CMD_GET_CONTACT_COUNT:
+                       return "MSG_CMD_GET_CONTACT_COUNT";
+               case MSG_CMD_GET_QUICKPANEL_DATA:
+                       return "MSG_CMD_GET_QUICKPANEL_DATA";
+               case MSG_CMD_COUNT_BY_MSGTYPE:
+                       return "MSG_CMD_COUNT_BY_MSGTYPE";
+               case MSG_CMD_RESET_DB:
+                       return "MSG_CMD_RESET_DB";
+               case MSG_CMD_GET_MEMSIZE:
+                       return "MSG_CMD_GET_MEMSIZE";
+
+// 45
+               case MSG_CMD_BACKUP_MESSAGE:
+                       return "MSG_CMD_BACKUP_MESSAGE";
+               case MSG_CMD_RESTORE_MESSAGE:
+                       return "MSG_CMD_RESTORE_MESSAGE";
+               case MSG_CMD_UPDATE_THREAD_READ:
+                       return "MSG_CMD_UPDATE_THREAD_READ";
+               case MSG_CMD_REG_SYNCML_MSG_OPERATION_CB:
+                       return "MSG_CMD_REG_SYNCML_MSG_OPERATION_CB";
+               case MSG_CMD_SYNCML_OPERATION:
+                       return "MSG_CMD_SYNCML_OPERATION";
+
+// 50
+               case MSG_CMD_GET_REPORT_STATUS:
+                       return "MSG_CMD_GET_REPORT_STATUS";
+
+               default:
+                       return "Unknown Command Type!!!";
+       }
+
+       return NULL;
+}
+
+const char * MsgDbgEvtStr(MSG_EVENT_TYPE_T evtType)
+{
+       switch ( evtType )
+       {
+// 0
+               case MSG_EVENT_OPEN_HANDLE:
+                       return "MSG_EVENT_OPEN_HANDLE";
+               case MSG_EVENT_CLOSE_HANDLE:
+                       return "MSG_EVENT_CLOSE_HANDLE";
+               case MSG_EVENT_GET_STORAGELIST:
+                       return "MSG_EVENT_GET_STORAGELIST";
+               case MSG_EVENT_ADD_MSG:
+                       return "MSG_EVENT_ADD_MSG";
+               case MSG_EVENT_ADD_SYNCML_MSG:
+                       return "MSG_EVENT_ADD_SYNCML_MSG";
+// 5
+               case MSG_EVENT_UPDATE_MSG:
+                       return "MSG_EVENT_UPDATE_MSG";
+               case MSG_EVENT_UPDATE_READ:
+                       return "MSG_EVENT_UPDATE_READ";
+               case MSG_EVENT_UPDATE_PROTECTED:
+                       return "MSG_EVENT_UPDATE_PROTECTED";
+               case MSG_EVENT_DELETE_MSG:
+                       return "MSG_EVENT_DELETE_MSG";
+               case MSG_EVENT_DELALL_MSGINFOLDER:
+                       return "MSG_EVENT_DELALL_MSGINFOLDER";
+// 10
+               case MSG_EVENT_MOVE_MSGTOFOLDER:
+                       return "MSG_EVENT_MOVE_MSGTOFOLDER";
+               case MSG_EVENT_MOVE_MSGTOSTORAGE:
+                       return "MSG_EVENT_MOVE_MSGTOSTORAGE";
+               case MSG_EVENT_COUNT_MSG:
+                       return "MSG_EVENT_COUNT_MSG";
+               case MSG_EVENT_GET_MSG:
+                       return "MSG_EVENT_GET_MSG";
+               case MSG_EVENT_GET_FOLDERVIEWLIST:
+                       return "MSG_EVENT_GET_FOLDERVIEWLIST";
+// 15
+               case MSG_EVENT_ADD_FOLDER:
+                       return "MSG_EVENT_ADD_FOLDER";
+               case MSG_EVENT_UPDATE_FOLDER:
+                       return "MSG_EVENT_UPDATE_FOLDER";
+               case MSG_EVENT_DELETE_FOLDER:
+                       return "MSG_EVENT_DELETE_FOLDER";
+               case MSG_EVENT_GET_FOLDERLIST:
+                       return "MSG_EVENT_GET_FOLDERLIST";
+               case MSG_EVENT_SET_CONFIG:
+                       return "MSG_EVENT_SET_CONFIG";
+// 20
+               case MSG_EVENT_GET_CONFIG:
+                       return "MSG_EVENT_GET_CONFIG";
+               case MSG_EVENT_GET_MSG_TYPE:
+                       return "MSG_EVENT_GET_MSG_TYPE";
+               case MSG_EVENT_SUBMIT_REQ:
+                       return "MSG_EVENT_SUBMIT_REQ";
+               case MSG_EVENT_CANCEL_REQ:
+                       return "MSG_EVENT_CANCEL_REQ";
+               case MSG_EVENT_REG_SENT_STATUS_CB:
+                       return "MSG_EVENT_REG_SENT_STATUS_CB";
+// 25
+               case MSG_EVENT_REG_STORAGE_CHANGE_CB:
+                       return "MSG_EVENT_REG_STORAGE_CHANGE_CB";
+               case MSG_EVENT_REG_INCOMING_MSG_CB:
+                       return "MSG_EVENT_REG_INCOMING_MSG_CB";
+               case MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB:
+                       return "MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB";
+               case MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB:
+                       return "MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB";
+               case MSG_EVENT_REG_INCOMING_LBS_MSG_CB:
+                       return "MSG_EVENT_REG_INCOMING_LBS_MSG_CB";
+// 30
+               case MSG_EVENT_PLG_SENT_STATUS_CNF:
+                       return "MSG_EVENT_PLG_SENT_STATUS_CNF";
+               case MSG_EVENT_PLG_STORAGE_CHANGE_IND:
+                       return "MSG_EVENT_STORAGE_CHANGE_CB";
+               case MSG_EVENT_PLG_INCOMING_MSG_IND:
+                       return "MSG_EVENT_PLG_INCOMING_MSG_IND";
+               case MSG_EVENT_PLG_INCOMING_MMS_CONF:
+                       return "MSG_EVENT_PLG_INCOMING_MMS_CONF";
+               case MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND:
+                       return "MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND";
+// 35
+               case MSG_EVENT_PLG_INCOMING_LBS_MSG_IND:
+                       return "MSG_EVENT_PLG_INCOMING_LBS_MSG_IND";
+               case MSG_EVENT_PLG_INIT_SIM_BY_SAT:
+                       return "MSG_EVENT_PLG_INIT_SIM_BY_SAT";
+               case MSG_EVENT_GET_THREADVIEWLIST:
+                       return "MSG_EVENT_GET_THREADVIEWLIST";
+               case MSG_EVENT_GET_CONVERSATIONVIEWLIST:
+                       return "MSG_EVENT_GET_CONVERSATIONVIEWLIST";
+               case MSG_EVENT_DELETE_THREADMESSAGELIST:
+                       return "MSG_EVENT_DELETE_THREADMESSAGELIST";
+// 40
+               case MSG_EVENT_GET_CONTACT_COUNT:
+                       return "MSG_EVENT_GET_CONTACT_COUNT";
+               case MSG_EVENT_GET_QUICKPANEL_DATA:
+                       return "MSG_EVENT_GET_QUICKPANEL_DATA";
+               case MSG_EVENT_COUNT_BY_MSGTYPE:
+                       return "MSG_EVENT_COUNT_BY_MSGTYPE";
+               case MSG_EVENT_RESET_DB:
+                       return "MSG_EVENT_RESET_DB";
+               case MSG_EVENT_GET_MEMSIZE:
+                       return "MSG_EVENT_GET_MEMSIZE";
+// 45
+               case MSG_EVENT_BACKUP_MESSAGE:
+                       return "MSG_EVENT_BACKUP_MESSAGE";
+               case MSG_EVENT_RESTORE_MESSAGE:
+                       return "MSG_EVENT_RESTORE_MESSAGE";
+               case MSG_EVENT_UPDATE_THREAD_READ:
+                       return "MSG_EVENT_UPDATE_THREAD_READ";
+               case MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB:
+                       return "MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB";
+               case MSG_EVENT_SYNCML_OPERATION:
+                       return "MSG_EVENT_SYNCML_OPERATION";
+// 50
+               case MSG_EVENT_GET_REPORT_STATUS:
+                       return "MSG_EVENT_GET_REPORT_STATUS";
+
+
+               default:
+                       return "Unknown Event Type!!!";
+       }
+
+       return NULL;
+}
+
+
+int get_tid()
+{
+    return syscall(__NR_gettid);
+}
+
diff --git a/utils/MsgDrmWrapper.cpp b/utils/MsgDrmWrapper.cpp
new file mode 100755 (executable)
index 0000000..64a8acf
--- /dev/null
@@ -0,0 +1,327 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgDrmWrapper.h"
+#include "MsgUtilFile.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/vfs.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <drm_client_types.h>
+#include <drm_client.h>
+#include <drm_trusted_client_types.h>
+#include <drm_trusted_client.h>
+
+#define MSG_MAX_DRM_FILE_PATH MSG_FILEPATH_LEN_MAX
+
+bool MsgDrmRegisterFile(MSG_DRM_OPENMODE eMode, char *pBuffer, int nSize)
+{
+       if (eMode == MSG_MODE_STREAM) {
+               MSG_DEBUG("Fail(eMode == MSG_MODE_STREAM)");
+               return false;
+       }
+
+       if (pBuffer == NULL) {
+               MSG_DEBUG("[Error] pBuffer is NULL");
+               return false;
+       }
+
+       MSG_DEBUG("buffer = %s, nSize = %d", pBuffer, nSize);
+
+       drm_bool_type_e isDrm;
+       int eDRMResult = drm_is_drm_file(pBuffer, &isDrm);
+
+       if (eDRMResult != DRM_RETURN_SUCCESS || isDrm != DRM_TRUE) {
+               MSG_DEBUG("file is not drm file");
+               return false;
+       }
+
+       drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_FILE;
+
+       eDRMResult = drm_process_request(request_type, pBuffer, NULL);
+       if (DRM_RETURN_SUCCESS != eDRMResult) {
+               MSG_DEBUG("drm_process_request is failed : %d", eDRMResult);
+               return false;
+       }
+       MSG_END();
+       return true;
+}
+
+bool MsgDrmUnregisterFile(char *szFilename)
+{
+       if (szFilename == NULL) {
+               MSG_DEBUG("[Error] szFilename is NULL");
+               return false;
+       }
+
+       MSG_DEBUG("szFilename = %s", szFilename);
+
+       drm_request_type_e request_type = DRM_REQUEST_TYPE_UNREGISTER_FILE;
+
+       int eDRMResult = drm_process_request(request_type, szFilename, NULL); // Unregister a DCF file
+       if (DRM_RETURN_SUCCESS != eDRMResult) {
+               MSG_DEBUG("drm_process_request : %d", eDRMResult);
+               return false;
+       }
+
+       return true;
+}
+
+bool MsgDrmIsDrmFile(const char *szFilePath)
+{
+       drm_bool_type_e isDrm;
+       int eDRMResult = drm_is_drm_file(szFilePath, &isDrm);
+
+       if (eDRMResult != DRM_RETURN_SUCCESS || isDrm != DRM_TRUE) {
+               MSG_DEBUG("file is not drm file");
+               return false;
+       }
+
+       return true;
+}
+
+/*Added to convert the .dm files in to .dcf files since our platform supports only .dcf :: Start*/
+bool MsgDrmConvertDmtoDcfType(char *inputFile, char *outputFile)
+{
+       if ((NULL == inputFile) || (NULL == outputFile)) {
+               MSG_DEBUG("Invalid Input parameters");
+               return false;
+       }
+
+       if (strstr(inputFile, ".dm")) {
+               MSG_DEBUG("Current File extension is .dm %s", inputFile);
+               int ret;
+
+               FILE *fp = MsgOpenFile(inputFile, "rb");//Check fp
+
+               if (fp == NULL) {
+                       MSG_DEBUG("[File Open Fail(Errno=%d)][ErrStr=%s]", errno, strerror(errno));
+                       strncpy(outputFile, inputFile, MSG_MAX_DRM_FILE_PATH);
+                       return false;
+               }
+
+               if (MsgFseek(fp, 0L, SEEK_END) < 0) {
+                       MsgCloseFile(fp);
+                       MSG_DEBUG("MsgFseek() returns negative value!!!");
+                       return false;
+               }
+               long retVal = MsgFtell(fp);
+
+               if (retVal < 0) {
+                       MsgCloseFile(fp);
+                       MSG_DEBUG("ftell() returns negative value: [%ld]!!!", retVal);
+                       strncpy(outputFile, inputFile, MSG_MAX_DRM_FILE_PATH);
+                       return false;
+               }
+
+               unsigned long bufLen = retVal;
+               MSG_DEBUG("fopen buffer len = %d", bufLen);
+               if (MsgFseek(fp, 0, SEEK_SET) < 0) {
+                       MsgCloseFile(fp);
+                       MSG_DEBUG("MsgFseek() returns negative value!!!");
+                       return false;
+               }
+
+               unsigned char *buffer = (unsigned char*)malloc(bufLen);
+               int readed_size = 0;
+               int pathLen = strlen(inputFile);
+
+               if (buffer == NULL) {
+                       MsgCloseFile(fp);
+                       MSG_DEBUG("malloc is failed ");
+                       strncpy(outputFile, inputFile, MSG_MAX_DRM_FILE_PATH);
+                       return false;
+               }
+
+               strncpy(outputFile, inputFile, pathLen - 2);
+               strncat(outputFile, "dcf", 3);
+
+               readed_size = MsgReadFile(buffer, 1, bufLen, fp);//Check for error
+               MSG_DEBUG("fread read size = %d", readed_size);
+               if (readed_size == 0) {
+                       MsgCloseFile(fp);
+                       free(buffer);
+                       MSG_DEBUG("MsgReadFile returns 0");
+                       return false;
+               }
+
+               DRM_TRUSTED_CONVERT_HANDLE hConvert = NULL;
+               drm_trusted_opn_conv_info_s trusted_open_conv_input;
+               bzero(&trusted_open_conv_input, sizeof(drm_trusted_opn_conv_info_s));
+
+               strncpy(trusted_open_conv_input.filePath, outputFile, DRM_TRUSTED_MAX_FILEPATH_LEN);
+               trusted_open_conv_input.install_RO = DRM_TRUSTED_TRUE;
+
+               ret = drm_trusted_open_convert(&trusted_open_conv_input, &hConvert);
+               if (ret != DRM_RETURN_SUCCESS) {
+                       free(buffer);
+                       MsgCloseFile(fp);
+                       MSG_DEBUG("drm_trusted_open_convert() return = failed (%d)", ret);
+                       strncpy(outputFile, inputFile, MSG_MAX_DRM_FILE_PATH);
+                       return false;
+               }
+
+               drm_trusted_write_conv_info_s trusted_write_conv_input;
+               drm_trusted_write_conv_resp_s trusted_write_conv_output;
+
+               bzero(&trusted_write_conv_input, sizeof(drm_trusted_write_conv_info_s));
+               bzero(&trusted_write_conv_output, sizeof(drm_trusted_write_conv_resp_s));
+
+               trusted_write_conv_input.data = buffer;
+               trusted_write_conv_input.data_len = bufLen;
+
+               /*We can call drm_trusted_write_convert in loop if file size is large*/
+               ret = drm_trusted_write_convert(&trusted_write_conv_input, &trusted_write_conv_output, hConvert);
+               if (ret != DRM_RETURN_SUCCESS) {
+                       free(buffer);
+                       MsgCloseFile(fp);
+                       MSG_DEBUG("drm_trusted_write_convert() return = failed (%d)", ret);
+                       strncpy(outputFile, inputFile, MSG_MAX_DRM_FILE_PATH);
+                       return false;
+               }
+
+               ret = drm_trusted_close_convert(&hConvert);
+               if (ret != DRM_RETURN_SUCCESS) {
+                       free(buffer);
+                       MsgCloseFile(fp);
+                       MSG_DEBUG("drm_trusted_close_convert() return = failed (%d)", ret);
+                       strncpy(outputFile, inputFile, MSG_MAX_DRM_FILE_PATH);
+                       return false;
+               }
+
+               MsgCloseFile(fp);
+               free(buffer);
+       } else {
+               MSG_DEBUG("Current File extension is not .dm");
+
+               MSG_DEBUG("inputFile = (%s)", inputFile);
+               strncpy(outputFile, inputFile, MSG_MAX_DRM_FILE_PATH);
+
+               return false;
+       }
+
+       return true;
+}
+
+bool MsgDrmGetDrmType(const char *szFileName, MSG_DRM_TYPE *eDRMType)
+{
+       if (szFileName == NULL || eDRMType == NULL) {
+               MSG_DEBUG("Param is NULL");
+               return false;
+       }
+
+       drm_file_type_e file_type;
+       int result = drm_get_file_type(szFileName, &file_type);
+       if (result != DRM_RETURN_SUCCESS) {
+               MSG_DEBUG("drm_get_file_type is failed %d", result);
+               return false;
+       }
+
+       if (file_type == DRM_TYPE_OMA_V1) {
+               drm_file_info_s drmInfo;
+               bzero(&drmInfo, sizeof(drm_file_info_s));
+               int eDRMResult = drm_get_file_info(szFileName, &drmInfo);
+               if (DRM_RETURN_SUCCESS != eDRMResult) {
+                       MSG_DEBUG("drm_get_file_info is Fail eDRMResult = %d", eDRMResult);
+                       return false;
+               }
+
+               // Convert DRM_METHOD into MSG_DRM_TYPE
+               switch (drmInfo.oma_info.method) {
+               case DRM_METHOD_TYPE_FORWARD_LOCK:
+                       *eDRMType = MSG_DRM_FORWARD_LOCK;
+                       break;
+               case DRM_METHOD_TYPE_COMBINED_DELIVERY:
+                       *eDRMType = MSG_DRM_COMBINED_DELIVERY;
+                       break;
+               case DRM_METHOD_TYPE_SEPARATE_DELIVERY:
+                       *eDRMType = MSG_DRM_SEPARATE_DELIVERY;
+                       break;
+               default:
+                       *eDRMType = MSG_DRM_NONE;
+                       break;
+               }
+               MSG_DEBUG("eDRMType : %d", *eDRMType);
+       } else {
+               MSG_DEBUG("This is not a DRM_TYPE_OMA_V1 type");
+               return false;
+       }
+
+       return true;
+}
+
+bool MsgDrmGetMimeTypeEx(const char *szFileName, char *szMimeType, int nMimeTypeLen)
+{
+       if (!szFileName || !szMimeType || !nMimeTypeLen) {
+               MSG_DEBUG("param is NULL");
+               return false;
+       }
+
+       char strTemp[MSG_MAX_DRM_FILE_PATH + 1] = {0,};
+
+       strncpy(strTemp, szFileName, strlen(szFileName));
+
+       drm_content_info_s tdcfContentinfo;
+       memset(&tdcfContentinfo, 0x00, sizeof(drm_content_info_s));
+       int eDRMResult = drm_get_content_info(strTemp, &tdcfContentinfo); // Get attribute of DRM File
+       if (DRM_RETURN_SUCCESS == eDRMResult) {
+               MSG_DEBUG("contentType = %s", tdcfContentinfo.mime_type);
+               snprintf(szMimeType, nMimeTypeLen, "%s", tdcfContentinfo.mime_type);
+
+       } else {
+               MSG_DEBUG("drm_get_content_info is failed %d", eDRMResult);
+               return false;
+       }
+
+       return true;
+}
+
+bool MsgDrmGetContentID(const char *szFileName, char *szContentID, int nContentIDLen)
+{
+       if (!szFileName || !szContentID || !nContentIDLen) {
+               MSG_DEBUG("param is NULL");
+               return false;
+       }
+
+       char strTemp[MSG_MAX_DRM_FILE_PATH + 1] = {0,};
+
+       strncpy(strTemp, szFileName, sizeof(strTemp));
+
+       drm_content_info_s  content_info;
+       memset(&content_info, 0x00, sizeof(drm_content_info_s));
+
+       int result = drm_get_content_info(strTemp, &content_info);
+       if (DRM_RETURN_SUCCESS == result) {
+               MSG_DEBUG("contentID = %s", content_info.content_id);
+        snprintf(szContentID, nContentIDLen, "%s", content_info.content_id);
+       } else {
+               MSG_DEBUG("drm_get_content_info is failed %d", result);
+               return false;
+       }
+
+       return true;
+}
+
diff --git a/utils/MsgException.cpp b/utils/MsgException.cpp
new file mode 100755 (executable)
index 0000000..8b85869
--- /dev/null
@@ -0,0 +1,43 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgException.h"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+string MsgException::errorStrings[NUM_ERRORS] =
+{
+       "SUCCESS",
+
+       "INVALID_PARAM",
+       "INVALID_RESULT",
+       "SELECT_ERROR",
+       "IPC_ERROR",
+       "OUT_OF_RANGE" , //5
+
+       "SMS_PLG_ERROR",
+       "MMS_PLG_ERROR",
+       "PLUGIN_ERROR",
+       "SENT_STATUS_ERROR",
+       "INCOMING_MSG_ERROR", //10
+
+       "FILE_OPERATION_ERROR",
+       "SECURITY_ERROR"
+       "SERVER_READY_ERROR"
+};
+
diff --git a/utils/MsgGconfWrapper.cpp b/utils/MsgGconfWrapper.cpp
new file mode 100755 (executable)
index 0000000..29683dc
--- /dev/null
@@ -0,0 +1,171 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+
+#include <pmapi.h>
+
+#include "MsgDebug.h"
+#include "MsgUtilStorage.h"
+#include "MsgGconfWrapper.h"
+
+
+/*==================================================================================================
+                                     DEFINES
+==================================================================================================*/
+#define MSG_UNREAD_CNT         "db/badge/org.tizen.message"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgSettingSetString(const char *pKey, const char *pSetValue)
+{
+       if (pKey == NULL || pSetValue == NULL)
+       {
+               MSG_DEBUG("IN Parameter is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       if (vconf_set_str(pKey, pSetValue) != 0)
+               return MSG_ERR_SET_SETTING;
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgSettingSetInt(const char *pKey, int nSetValue)
+{
+       if (pKey == NULL)
+       {
+               MSG_DEBUG("IN Parameter is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       if (vconf_set_int(pKey, nSetValue) != 0)
+               return MSG_ERR_SET_SETTING;
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgSettingSetBool(const char *pKey, bool bSetValue)
+{
+       if (pKey == NULL)
+       {
+               MSG_DEBUG("IN Parameter is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       if (vconf_set_bool(pKey, bSetValue) != 0)
+               return MSG_ERR_SET_SETTING;
+
+       return MSG_SUCCESS;
+}
+
+
+char* MsgSettingGetString(const char *pKey)
+{
+       if (pKey == NULL)
+       {
+               MSG_DEBUG("IN Parameter is NULL");
+               return NULL;
+       }
+
+       return vconf_get_str(pKey);
+}
+
+
+int MsgSettingGetInt(const char *pKey)
+{
+       if (pKey == NULL)
+       {
+               MSG_DEBUG("IN Parameter is NULL");
+               return -1;
+       }
+
+       int retVal = 0;
+
+       if (vconf_get_int(pKey, &retVal) < 0)
+               return -1;
+
+       return retVal;
+}
+
+
+int MsgSettingGetBool(const char *pKey, bool *pVal)
+{
+       if (pKey == NULL)
+       {
+               MSG_DEBUG("IN Parameter is NULL");
+               return -1;
+       }
+
+       int retVal = 0, param = 0;
+
+       if (vconf_get_bool(pKey, &param) < 0)
+               return -1;
+
+       *pVal = (bool)param;
+
+       return retVal;
+}
+
+
+MSG_ERROR_T MsgSettingHandleNewMsg(int SmsCnt, int MmsCnt)
+{
+       MSG_BEGIN();
+
+       MSG_DEBUG("smsCnt = %d, mmsCnt = %d ##", SmsCnt, MmsCnt);
+
+       // Set Msg Count into VConf
+       if (MsgSettingSetIndicator(SmsCnt, MmsCnt) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgSettingSetIndicator() FAILED");
+               return MSG_ERR_SET_SETTING;
+       }
+
+       if (SmsCnt == 0 && MmsCnt == 0)
+       {
+               MSG_DEBUG("No New Message.");
+       }
+       else
+       {
+               MSG_DEBUG("New Message.");
+               pm_change_state(LCD_NORMAL);
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgSettingSetIndicator(int SmsCnt, int MmsCnt)
+{
+
+       if (MsgSettingSetInt(VCONFKEY_MESSAGE_RECV_SMS_STATE, SmsCnt) != 0)
+               return MSG_ERR_SET_SETTING;
+       if (MsgSettingSetInt(VCONFKEY_MESSAGE_RECV_MMS_STATE, MmsCnt) != 0)
+               return MSG_ERR_SET_SETTING;
+
+       int sumCnt = SmsCnt + MmsCnt;
+
+       if (MsgSettingSetInt(MSG_UNREAD_CNT, sumCnt) != 0)
+               return MSG_ERR_SET_SETTING;
+
+       return MSG_SUCCESS;
+}
diff --git a/utils/MsgIpcSocket.cpp b/utils/MsgIpcSocket.cpp
new file mode 100755 (executable)
index 0000000..e3793db
--- /dev/null
@@ -0,0 +1,505 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MsgIpcSocket.h"
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgIpcClientSocket - Member Functions
+==================================================================================================*/
+MsgIpcClientSocket::MsgIpcClientSocket() : sockfd(-1), remotefd(-1), maxfd(-1)
+{
+       FD_ZERO(&fds);
+}
+
+
+MSG_ERROR_T MsgIpcClientSocket::connect(const char* path)
+{
+       MSG_BEGIN();
+
+       if (!path || strlen(path) > strlen(MSG_SOCKET_PATH)) {
+               THROW(MsgException::IPC_ERROR, "path is null");
+       }
+
+       sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
+
+       if (sockfd < 0) {
+               THROW(MsgException::IPC_ERROR,"socket not opened %s",strerror(errno));
+       }
+
+       struct sockaddr_un serverSA = {0, };
+       serverSA.sun_family = AF_UNIX;
+
+       memset(serverSA.sun_path, 0x00, sizeof(serverSA.sun_path));
+       strncpy(serverSA.sun_path, path, sizeof(serverSA.sun_path)-1);  /* // "./socket" */
+
+       int len = strlen(serverSA.sun_path) + sizeof(serverSA.sun_family);
+
+       if (::connect(sockfd, (struct sockaddr *)&serverSA, len) == CUSTOM_SOCKET_ERROR) {
+               THROW(MsgException::IPC_ERROR,"cannot connect server %s", strerror(errno));
+       }
+
+       /* add fd for select() */
+       addfd(sockfd);
+
+       /* read remote fd for reg func */
+       char *rfd = NULL;
+       AutoPtr<char> wrap(&rfd);
+       int rlen;
+
+       read(&rfd, &rlen);
+
+       if (rfd == NULL) {
+               THROW(MsgException::IPC_ERROR,"rfd is NULL %s", strerror(errno));
+       }
+
+       memcpy(&remotefd, rfd, sizeof(rlen));
+
+       MSG_DEBUG("Connected: client fd [%d] <----> remote fd [%d]", sockfd, remotefd);
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgIpcClientSocket::close()
+{
+       if (sockfd < 0) {
+               MSG_FATAL("Client socket is not opened (check if you call close twice by accident) [%d]", sockfd);
+               return MSG_ERR_UNKNOWN;
+       }
+
+       /* it means that client is going to close the connection.*/
+       int cmd = CLOSE_CONNECTION_BY_USER;
+       int len = sizeof(cmd);
+
+       char cmdbuf[len];
+       bzero(cmdbuf, len);
+       memcpy(cmdbuf, &cmd, len);
+
+       ::close(sockfd);
+       sockfd = CUSTOM_SOCKET_ERROR;
+
+       return MSG_SUCCESS;
+}
+
+void MsgIpcClientSocket::addfd(int fd)
+{
+       MSG_DEBUG("%d added", fd);
+       FD_SET(fd, &fds);
+       if (fd > maxfd)
+               maxfd = fd;
+}
+
+int MsgIpcClientSocket::writen (const char *buf, int len)
+{
+       int nleft, nwrite;
+
+       nleft = len;
+       while (nleft > 0) {
+               nwrite = ::write(sockfd, (const void*) buf, nleft);
+               if (nwrite < 0) {
+                       MSG_FATAL("writen: sockfd [%d] error [%s]",  sockfd, strerror(errno));
+                       return nwrite;
+               }
+               else if (nwrite == 0)
+                       break;
+
+               nleft -= nwrite;
+               buf += nwrite;
+       }
+       return (len-nleft);
+}
+
+int MsgIpcClientSocket::write(const char* buf, int len)
+{
+       if (sockfd < 0) {
+               MSG_FATAL("sockfd is not opened [%d]", sockfd);
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       if (!buf || len <= 0) {
+               MSG_FATAL("buf[%p]      and len[%d] MUST NOT NULL", buf, len);
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       /* send the data size first */
+       int n = writen((const char*)&len, sizeof(len));
+       if (n != sizeof(len)) {
+               MSG_FATAL("WARNING: write header_size[%d] not matched [%d]", n, sizeof(len));
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       /* send the data in subsequence */
+       n = writen(buf, len);
+       if (n != len) {
+               MSG_FATAL("WARNING: write data_size[%d] not matched [%d]", n, len);
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       return len;
+}
+
+int MsgIpcClientSocket::readn( char *buf, int len )
+{
+       int nleft, nread;
+
+       nleft = len;
+       while (nleft > 0) {
+               nread = ::read(sockfd, (void*) buf, nleft);
+               if (nread < 0) {
+                       MSG_FATAL("WARNING read value %d: %s", nread, strerror(errno));
+                       return nread;
+               }
+               else if( nread == 0 )
+                       break;
+
+               nleft -= nread;
+               buf += nread;
+       }
+       return (len-nleft);
+}
+
+
+/* what if the buf is shorter than data? */
+int MsgIpcClientSocket::read(char** buf, int* len)
+{
+       if (sockfd < 0) {
+               MSG_FATAL("socket is not opened [%d]", sockfd);
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       if (!buf || !len) {
+               MSG_FATAL("rbuf and rlen MUST NOT NULL");
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       /* read the data size first */
+       int n = readn((char*) len, sizeof(int));
+       if (n == CLOSE_CONNECTION_BY_SIGNAL) { /* if msgfw gets down, it signals to all IPC clients */
+               MSG_FATAL("sockfd [%d] CLOSE_CONNECTION_BY_SIGNAL", sockfd);
+               return n;
+       }
+
+       else if (n != sizeof(int)) {
+               MSG_FATAL("WARNING: read header_size[%d] not matched [%d]", n, sizeof(int));
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       /*  read the data in subsequence */
+       if ((*len) > 0) {
+               *buf = new char[*len+1];
+               bzero(*buf, *len+1);
+               n = readn(*buf, *len);
+
+               if (n !=  *len) {
+                       MSG_FATAL("WARNING: read data_size [%d] not matched [%d]", n, *len);
+                       return CUSTOM_SOCKET_ERROR;
+               }
+       }
+
+       return n;
+}
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgIpcServerSocket - Member Functions
+==================================================================================================*/
+MsgIpcServerSocket::MsgIpcServerSocket() : sockfd(-1), maxfd(-1)
+{
+       FD_ZERO(&fds);
+}
+
+void MsgIpcServerSocket::addfd(int fd)
+{
+       MSG_DEBUG("%d added", fd);
+       FD_SET(fd, &fds);
+
+       std::map<int, int>::iterator it = mapFds.find(fd);
+       if (it != mapFds.end())
+               MSG_FATAL("Duplicate FD %d", fd);
+       else
+               mapFds[fd] = fd;
+
+       if (fd > maxfd)
+               maxfd = fd;
+}
+
+MSG_ERROR_T MsgIpcServerSocket::open(const char* path)
+{
+       MSG_BEGIN();
+
+       if (!path || strlen(path) > strlen(MSG_SOCKET_PATH)) {
+               MSG_FATAL("path is null");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       if (sockfd != CUSTOM_SOCKET_ERROR) {
+               MSG_FATAL("WARNING: server_socket already opened %d at %p", sockfd,  &sockfd);
+               return MSG_ERR_UNKNOWN;
+       }
+
+       sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
+
+       if (sockfd == CUSTOM_SOCKET_ERROR) {
+               MSG_FATAL("socket failed: %s", strerror(errno));
+               return MSG_ERR_UNKNOWN;
+       }
+
+       MSG_DEBUG("server_socket(%p) opened : %d", &sockfd, sockfd);
+
+       struct sockaddr_un local = {0, };
+
+       local.sun_family = AF_UNIX;
+       memset(local.sun_path, 0x00, sizeof(local.sun_path));
+       strncpy(local.sun_path, path, sizeof(local.sun_path)-1);
+
+       unlink(local.sun_path);
+
+       int len = strlen(local.sun_path) + sizeof(local.sun_family);
+
+       if (bind(sockfd, (struct sockaddr *)&local, len) == CUSTOM_SOCKET_ERROR) {
+               MSG_FATAL("bind: %s", strerror(errno));
+               return MSG_ERR_UNKNOWN;
+       }
+
+       /**
+        * determine permission of socket file
+        *
+        *  - S_IRWXU : for user, allow read and write and execute
+        *  - S_IRWXG : for group, allow read and write and execute
+        *  - S_IRWXO : for other, allow read and write and execute
+        *
+        *  - S_IRUSR, S_IWUSR, S_IXUSR : for user, allow only read, write, execute respectively
+        *  - S_IRGRP, S_IWGRP, S_IXGRP : for group, allow only read, write, execute respectively
+        *  - S_IROTH, S_IWOTH, S_IXOTH : for other, allow only read, write, execute respectively
+        */
+       mode_t sock_mode = (S_IRWXU | S_IRWXG | S_IRWXO); /* has 777 permission */
+
+       if (chmod(path, sock_mode) == CUSTOM_SOCKET_ERROR) {
+               MSG_FATAL("chmod: %s", strerror(errno));
+               return MSG_ERR_UNKNOWN;
+       }
+
+       if (listen(sockfd, CUSTOM_SOCKET_BACKLOG) == CUSTOM_SOCKET_ERROR) {
+               MSG_FATAL("listen: %s", strerror(errno));
+               return MSG_ERR_UNKNOWN;
+       }
+
+       addfd(sockfd);
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T MsgIpcServerSocket::accept()
+{
+       MSG_BEGIN();
+
+       if (sockfd == CUSTOM_SOCKET_ERROR) {
+               MSG_FATAL("server_socket not init");
+               return MSG_ERR_UNKNOWN;
+       }
+
+       struct sockaddr_un remote;
+
+       int t = sizeof(remote);
+       int fd = ::accept(sockfd, (struct sockaddr *)&remote, (socklen_t*) &t);
+       if (fd < 0) {
+               MSG_FATAL("accept: %s", strerror(errno));
+               return MSG_ERR_UNKNOWN;
+       }
+
+       addfd(fd);
+       MSG_DEBUG("%d is added", fd);
+
+       /* write the registerd fd */
+       write(fd, (const char*) &fd, sizeof(fd));
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+void MsgIpcServerSocket::close(int fd)
+{
+       MSG_BEGIN();
+
+       if (sockfd == CUSTOM_SOCKET_ERROR) {
+               MSG_FATAL("server_socket not init");
+               return;
+       }
+
+       MSG_DEBUG("%d to be removed", fd);
+       FD_CLR(fd, &fds);
+
+       std::map<int, int>::iterator it = mapFds.find(fd);
+       if (it == mapFds.end())
+               MSG_FATAL("No FD %d", fd);
+       else
+               mapFds.erase(it);
+
+       if (fd == maxfd) {
+               int newmax = 0;
+               for (it = mapFds.begin() ; it != mapFds.end() ; it++)
+                       newmax = (it->second > newmax )? it->second : newmax;
+               maxfd = newmax;
+       }
+       MSG_DEBUG("fd %d removal done", fd);
+       ::close(fd);
+
+       MSG_END();
+}
+
+int MsgIpcServerSocket::readn( int fd, char *buf, int len )
+{
+       int nleft, nread;
+
+       nleft = len;
+       while (nleft > 0) {
+               nread = ::read(fd, (void*)buf, nleft);
+               if (nread < 0) {
+                       MSG_FATAL("read: %s", strerror(errno));
+                       return nread;
+               }
+               else if (nread == 0)
+                       break;
+
+               nleft -= nread;
+               buf += nread;
+       }
+       return (len-nleft);
+}
+
+int MsgIpcServerSocket::read(int fd, char** buf, int* len )
+{
+       if (sockfd == CUSTOM_SOCKET_ERROR) {
+               MSG_FATAL("server_socket(%p) is not initd %d", &sockfd, sockfd);
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       if (!buf || !len) {
+               MSG_FATAL("buf[%p] and len[%p] MUST NOT NULL", buf, len);
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       /* read the data size first */
+       int n = readn(fd, (char*) len, sizeof(int));
+
+       if (n == CLOSE_CONNECTION_BY_SIGNAL) {
+               MSG_FATAL("fd %d CLOSE_CONNECTION_BY_SIGNAL", fd);
+               return n;
+       }
+
+       else if (n != sizeof(int)) {
+               MSG_FATAL("readn %d(%d)", n, sizeof(int));
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       MSG_DEBUG("MsgLen %d", *len);
+       if (*len == CLOSE_CONNECTION_BY_USER)
+               return *len;
+
+       if ((*len) > 0) {
+               /* read the data in subsequence */
+               *buf = new char[*len+1];
+               bzero(*buf, *len+1);
+               n = readn(fd, *buf, *len);
+
+               if (n != *len) {
+                       MSG_FATAL("WARNING: read data_size [%d] not matched [%d]", n, *len);
+                       return CUSTOM_SOCKET_ERROR;
+               }
+       }
+
+       return n;
+}
+
+int MsgIpcServerSocket::writen(int fd, const char *buf, int len)
+{
+       int nleft, nwrite;
+
+       nleft = len;
+
+       while (nleft > 0) {
+               /*  MSG_NOSIGNAL to prevent SIGPIPE Error */
+               /*  MSG_DONTWAIT to avoid socket block */
+               nwrite = ::send(fd, (const void*) buf, nleft, MSG_NOSIGNAL|MSG_DONTWAIT);
+
+               if (nwrite < 0) {
+                       MSG_FATAL("write: %s", strerror(errno));
+                       return nwrite;
+               }
+               else if (nwrite == 0) { /* Nothing is send. */
+                       break;
+               }
+               else {
+                       nleft -= nwrite;
+                       buf += nwrite;
+               }
+       }
+
+       return (len-nleft);
+}
+
+
+int MsgIpcServerSocket::write(int fd, const char* buf, int len)
+{
+       MSG_BEGIN();
+
+       if (!buf || len <= 0) {
+               MSG_FATAL("buf [%p] and len [%d] MUST NOT NULL", buf, len);
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       MSG_DEBUG("for debug - fd : [%d], buf : [%p], len : [%d]", fd, buf, len);
+
+       /* send the data size first */
+       int n = writen(fd, (const char*)&len, sizeof(len));
+
+       if (n != sizeof(len)) {
+               MSG_FATAL("WARNING: write header_size[%d] not matched [%d]", n, sizeof(len));
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       /*  send the data in subsequence */
+       n = writen(fd, buf, len);
+
+       MSG_DEBUG("Writing %d bytes", n);
+
+       if (n != len) {
+               MSG_FATAL("Written byte (%d) is not matched to input byte (%d)", n, len);
+               return CUSTOM_SOCKET_ERROR;
+       }
+
+       MSG_END();
+
+       return len;
+}
diff --git a/utils/MsgMemory.cpp b/utils/MsgMemory.cpp
new file mode 100755 (executable)
index 0000000..43e1b9e
--- /dev/null
@@ -0,0 +1,41 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <malloc.h>
+
+#include "MsgDebug.h"
+#include "MsgSqliteWrapper.h"
+#include "MsgMemory.h"
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+void MsgReleaseMemory()
+{
+       MSG_BEGIN();
+
+       // Release Malloc Memory
+       malloc_trim(0);
+
+       // Release Stack Memory
+//     stack_trim();
+
+       // Release Memory using in sqlite
+       MsgReleaseMemoryDB();
+
+       MSG_END();
+}
+
diff --git a/utils/MsgMmsMessage.cpp b/utils/MsgMmsMessage.cpp
new file mode 100755 (executable)
index 0000000..a712609
--- /dev/null
@@ -0,0 +1,1165 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <time.h>
+#include <stdlib.h>
+
+#include "MsgTypes.h"
+#include "MsgMmsTypes.h"
+#include "MsgMmsMessage.h"
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgStorageTypes.h"
+#include "MsgInternalTypes.h"
+
+
+MMS_SMIL_ROOTLAYOUT    rootlayout;
+
+static void __release_glist_element(gpointer data, gpointer user_data);
+static void __release_page_element(gpointer data, gpointer user_data);
+
+int msg_verify_number(const char *raw, char *trimmed)
+{
+       if (!(raw && trimmed)) {
+               MSG_DEBUG("Phone Number is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       for (int i = 0, j = 0; raw[i]; i++) {
+               if ((raw[i] >= '0' && raw[i] <= '9') || (raw[i] == ',') || raw[i] == ' ' || raw[i] == '+') {
+                       trimmed[j++] = raw[i];
+               } else if (raw[i] == '-') {
+                       continue;
+               } else {
+                       MSG_DEBUG("Unacceptable character in telephone number: [%c]", raw[i]);
+                       return MSG_ERR_INVALID_PARAMETER;
+               }
+       }
+
+       MSG_DEBUG("Trimming [%s]->[%s]", raw, trimmed);
+       return MSG_SUCCESS;
+}
+
+int msg_verify_email(const char *raw)
+{
+       bool onlyNum = true;
+       bool atExist = false;
+
+       if (!raw) {
+               MSG_DEBUG("Email is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       for (int i = 0; raw[i]; i++) {
+
+               if (raw[i] == '@') {
+                       onlyNum = false;
+
+                       if (atExist == false) {
+                               atExist = true;
+                               continue;
+                       } else {
+                               MSG_DEBUG("Character [@] is included more than twice in email address.");
+                               return MSG_ERR_INVALID_PARAMETER;
+                       }
+               }
+
+               if ((raw[i] >= '0' && raw[i] <= '9') || raw[i] == ' ' || raw[i] == '+') {
+                       continue;
+               } else if ((raw[i] >= 'a' && raw[i] <= 'z') ||(raw[i] >= 'A' && raw[i] <= 'Z') ||(raw[i] == '.') || raw[i] == '_' || raw[i] == '-') {
+                       onlyNum = false;
+                       continue;
+               } else if (raw[i] == ',') {
+                       if (onlyNum == false && atExist == false) {
+                               MSG_DEBUG("Unacceptable type in address.");
+                               return MSG_ERR_INVALID_PARAMETER;
+                       }
+                       atExist = false;
+                       onlyNum = true;
+                       continue;
+               } else {
+                       MSG_DEBUG("Unacceptable character in address : [%c]", raw[i]);
+                       return MSG_ERR_INVALID_PARAMETER;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+static void __release_glist_element(gpointer data, gpointer user_data)
+{
+       if(data != NULL) {
+               free(data);
+       }
+}
+
+static void __release_page_element(gpointer data, gpointer user_data)
+{
+       if(data != NULL) {
+               MMS_PAGE_S *page = (MMS_PAGE_S *)data;
+
+               if (page->medialist) {
+                       MMS_MEDIA_S *media = NULL;
+                       int mediaCnt = g_list_length(page->medialist);
+
+                       for (int i = 0; i < mediaCnt; i++) {
+                               media = (MMS_MEDIA_S *)g_list_nth_data(page->medialist, i);
+                               if (media)
+                                       free(media);
+                       }
+
+                       g_list_free(page->medialist);
+                       page->medialist = NULL;
+                       page->mediaCnt = 0;
+               }
+
+               free(page);
+       }
+}
+
+MSG_ERROR_T _MsgMmsReleasePageList(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       if (pMsgData->pagelist) {
+               g_list_foreach(pMsgData->pagelist, __release_page_element, NULL);
+               g_list_free(pMsgData->pagelist);
+               pMsgData->pagelist = NULL;
+       }
+
+       pMsgData->pageCnt = 0;
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T _MsgMmsReleaseRegionList(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       if (pMsgData->regionlist) {
+               g_list_foreach(pMsgData->regionlist, __release_glist_element, NULL);
+               g_list_free(pMsgData->regionlist);
+               pMsgData->regionlist = NULL;
+       }
+
+       pMsgData->regionCnt = 0;
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T _MsgMmsReleaseAttachList(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       if (pMsgData->attachlist) {
+               g_list_foreach(pMsgData->attachlist, __release_glist_element, NULL);
+               g_list_free(pMsgData->attachlist);
+               pMsgData->attachlist = NULL;
+       }
+
+       pMsgData->attachCnt = 0;
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T _MsgMmsReleaseTransitionList(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       if (pMsgData->transitionlist) {
+               g_list_foreach(pMsgData->transitionlist, __release_glist_element, NULL);
+               g_list_free(pMsgData->transitionlist);
+               pMsgData->transitionlist = NULL;
+       }
+
+       pMsgData->transitionCnt = 0;
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T _MsgMmsReleaseMetaList(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       if (pMsgData->metalist) {
+               g_list_foreach(pMsgData->metalist, __release_glist_element, NULL);
+               g_list_free(pMsgData->metalist);
+               pMsgData->metalist = NULL;
+       }
+
+       pMsgData->metaCnt = 0;
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T _MsgMmsAddRegion(MMS_MESSAGE_DATA_S *pMsgData, MMS_SMIL_REGION* pRegion)
+{
+       if(pMsgData == NULL || pRegion == NULL)
+               return MSG_ERR_INVALID_PARAMETER;
+
+       pMsgData->regionlist = g_list_append(pMsgData->regionlist, pRegion);
+       pMsgData->regionCnt++;
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T _MsgMmsAddPage(MMS_MESSAGE_DATA_S *pMsgData, MMS_PAGE_S *pPage)
+{
+       if(pMsgData == NULL || pPage == NULL)
+               return MSG_ERR_INVALID_PARAMETER;
+
+       pMsgData->pagelist = g_list_append(pMsgData->pagelist, pPage);
+       pMsgData->pageCnt++;
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T _MsgMmsAddMedia(MMS_PAGE_S* pPage, MMS_MEDIA_S *pMedia)
+{
+       if(pPage == NULL || pMedia == NULL)
+               return MSG_ERR_INVALID_PARAMETER;
+
+       pPage->medialist = g_list_append(pPage->medialist, pMedia);
+       pPage->mediaCnt++;
+               MSG_DEBUG("media's mediatype: %d", pMedia->mediatype);
+               MSG_DEBUG("media's filename: %s", pMedia->szFileName);
+               MSG_DEBUG("media's filepath: %s", pMedia->szFilePath);
+               MSG_DEBUG("media's contentId: %s", pMedia->szContentID);
+       MSG_DEBUG("page's media count: %d", pPage->mediaCnt);
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T _MsgMmsAddTransition(MMS_MESSAGE_DATA_S *pMsgData, MMS_SMIL_TRANSITION* pTransition)
+{
+       if(pMsgData == NULL || pTransition == NULL)
+               return MSG_ERR_INVALID_PARAMETER;
+
+       pMsgData->transitionlist = g_list_append(pMsgData->transitionlist, pTransition);
+       pMsgData->transitionCnt++;
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T _MsgMmsAddMeta(MMS_MESSAGE_DATA_S *pMsgData, MMS_SMIL_META* pMeta)
+{
+       if(pMsgData == NULL || pMeta == NULL)
+               return MSG_ERR_INVALID_PARAMETER;
+
+       pMsgData->metalist = g_list_append(pMsgData->metalist, pMeta);
+       pMsgData->metaCnt++;
+
+       return MSG_SUCCESS;
+}
+
+MSG_ERROR_T _MsgMmsAddAttachment(MMS_MESSAGE_DATA_S *pMsgData, MMS_ATTACH_S *pAttach)
+{
+       if(pMsgData == NULL || pAttach == NULL)
+               return MSG_ERR_INVALID_PARAMETER;
+
+       pMsgData->attachlist = g_list_append(pMsgData->attachlist, pAttach);
+       pMsgData->attachCnt++;
+
+       return MSG_SUCCESS;
+}
+
+bool _MsgMmsFindMatchedMedia(MMS_MESSAGE_DATA_S *pMsgData, char *pszFilePath)
+{
+       if (pMsgData == NULL || pszFilePath == NULL)
+               return false;
+
+       if (pMsgData->pagelist) {
+               for (int pageIdx = 0; pageIdx < pMsgData->pageCnt; pageIdx++) {
+                       MMS_PAGE_S *page = (MMS_PAGE_S *)g_list_nth_data(pMsgData->pagelist, pageIdx);
+
+                       if (page && page->medialist) {
+                               for (int mediaIdx = 0; mediaIdx < page->mediaCnt; mediaIdx++) {
+                                       MMS_MEDIA_S *media = (MMS_MEDIA_S *)g_list_nth_data(page->medialist, mediaIdx);
+                                       if (media) {
+                                               if (strcmp(pszFilePath, media->szFilePath) == 0)
+                                                       return true;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       return false;
+}
+
+MSG_ERROR_T _MsgMmsAddSmilDoc(char* pSmil, MMS_MESSAGE_DATA_S* pMsgData)
+{
+       MSG_DEBUG("MsgMmsAddSmilDoc");
+
+       if(pSmil == NULL || pMsgData == NULL)
+               return MSG_ERR_INVALID_PARAMETER;
+
+       char    fullpath[MSG_FILEPATH_LEN_MAX] = {0,};
+       char smilFileName[MSG_FILENAME_LEN_MAX+1] = {0,};
+       time_t  RawTime = 0;
+
+       //Create smilFileName
+       time(&RawTime);
+       snprintf(smilFileName, MSG_FILENAME_LEN_MAX+1, "%lu", RawTime);
+       snprintf(fullpath, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_SMIL_FILE_PATH, smilFileName);
+
+       if (MsgWriteSmilFile(fullpath, pSmil, strlen(pSmil)) == false) {
+               MSG_DEBUG("MsgWriteSmilFile error");
+               return MSG_ERR_MMS_ERROR;
+       }
+       strncpy(pMsgData->szSmilFilePath, smilFileName, MSG_FILEPATH_LEN_MAX-1);
+
+       return MSG_SUCCESS;
+}
+
+
+char* _MsgMmsSerializeMessageData(const MMS_MESSAGE_DATA_S* pMsgData, unsigned int *pSize)
+{
+       MSG_DEBUG("MsgMmsSerializeMessageData");
+
+       if (pMsgData == NULL)
+               return NULL;
+
+       int bufsize = 0;
+       int offset = 0;
+       int pageCnt = 0;
+       char *buf = NULL;
+
+       pageCnt = pMsgData->pageCnt;
+
+       int mediaCnt = 0;
+
+       if (pMsgData->pagelist) {
+               for (int pageIdx = 0; pageIdx < pageCnt; pageIdx++) {
+                       bufsize += sizeof(int); // Media cnt
+
+                       MMS_PAGE_S *page = (MMS_PAGE_S *)g_list_nth_data(pMsgData->pagelist, pageIdx);
+                       mediaCnt = page->mediaCnt;
+
+                       if (page->medialist) {
+                               for (int i = 0; i < mediaCnt; i++) {
+                                       MMS_MEDIA_S *media = (MMS_MEDIA_S *)g_list_nth_data(page->medialist, i);
+
+                                       if (media->mediatype == MMS_SMIL_MEDIA_TEXT) {
+                                               bufsize += (sizeof(MmsSmilMediaType) + MSG_FILENAME_LEN_MAX + 2 * MSG_FILEPATH_LEN_MAX + MSG_MSG_ID_LEN + 1
+                                                       + MAX_SMIL_ALT_LEN + MAX_SMIL_REGION_ID
+#ifdef __SUPPORT_DRM__
+                                                       + sizeof(MsgDrmType) + MSG_FILEPATH_LEN_MAX
+#endif
+                                                       + MAX_SMIL_TRANSIN_ID + MAX_SMIL_TRANSOUT_ID +
+                                                       7 * sizeof(int) + 3* sizeof(bool) + sizeof(MmsTextDirection) + sizeof(MmsSmilFontType));
+                                       } else {
+                                               bufsize += (sizeof(MmsSmilMediaType) + MSG_FILENAME_LEN_MAX + 2 * MSG_FILEPATH_LEN_MAX + MSG_MSG_ID_LEN + 1
+                                                       + MAX_SMIL_ALT_LEN + MAX_SMIL_REGION_ID
+#ifdef __SUPPORT_DRM__
+                                                       + sizeof(MsgDrmType) + MSG_FILEPATH_LEN_MAX
+#endif
+                                                       + MAX_SMIL_TRANSIN_ID + MAX_SMIL_TRANSOUT_ID + 5 * sizeof(int)
+                                                       );
+                                       }
+                               }
+                       }
+
+                       bufsize += sizeof(int) * 6;
+               }
+       }
+
+       bufsize += sizeof(int); // region count;
+       if (pMsgData->regionlist) {
+               int elementSize = g_list_length(pMsgData->regionlist);
+               bufsize += elementSize * (MAX_SMIL_REGION_ID + 4 * sizeof(MMS_LENGTH) + sizeof(int) + sizeof(REGION_FIT_TYPE_T));
+       }
+
+       bufsize += sizeof(int); // attachment count;
+       if (pMsgData->attachlist) {
+               int elementSize = g_list_length(pMsgData->attachlist);
+               bufsize += elementSize * (sizeof(MimeType) + MSG_FILENAME_LEN_MAX + MSG_FILEPATH_LEN_MAX + sizeof(int)
+#ifdef __SUPPORT_DRM__
+                               + sizeof(MsgDrmType) + MSG_FILEPATH_LEN_MAX
+#endif
+                               );
+       }
+
+       bufsize += sizeof(int); // transition count;
+       if (pMsgData->transitionlist) {
+               int elementSize = g_list_length(pMsgData->transitionlist);
+               bufsize += elementSize * (MAX_SMIL_TRANSITION_ID + sizeof(MmsSmilTransType) + sizeof(MmsSmilTransSubType) + sizeof(int));
+       }
+
+       bufsize += sizeof(int); // meta count;
+       if (pMsgData->metalist) {
+               int elementSize = g_list_length(pMsgData->metalist);
+               bufsize += elementSize * (MAX_SMIL_META_ID + MAX_SMIL_META_NAME + MAX_SMIL_META_CONTENT);
+       }
+
+       bufsize += sizeof(MMS_SMIL_ROOTLAYOUT);
+
+#ifdef FEATURE_JAVA_MMS
+       bufsize += sizeof(MMS_APPID_INFO_S);
+#endif
+
+       int filePathLen = strlen(pMsgData->szSmilFilePath);
+
+       bufsize += sizeof(int) + filePathLen + sizeof(int);
+
+       MSG_DEBUG("MsgMmsSerializeMessageData: bufsize = %d", bufsize);
+
+       buf = (char *)calloc(bufsize, 1);
+
+       // copy file path length
+       MSG_DEBUG("MsgMmsSerializeMessageData: smilFilePath Length = %d",  filePathLen);
+
+       memcpy(buf, &filePathLen, sizeof(int));
+
+       offset += sizeof(int);
+
+       // copy file path
+       MSG_DEBUG("MsgMmsSerializeMessageData: smilFilePath = %s",  pMsgData->szSmilFilePath);
+
+       if (filePathLen > 0) {
+               memcpy(buf + offset, pMsgData->szSmilFilePath, filePathLen);
+
+               offset += filePathLen;
+       }
+
+       // copy page count
+       MSG_DEBUG("MsgMmsSerializeMessageData: pageCnt = %d",  pMsgData->pageCnt);
+
+       memcpy(buf + offset, &(pMsgData->pageCnt), sizeof(int));
+
+       offset += sizeof(int);
+
+       if (pMsgData->pagelist) {
+               for (int pageIdx = 0; pageIdx < pageCnt; pageIdx++)
+               {
+                       MMS_PAGE_S *page = (MMS_PAGE_S *)g_list_nth_data(pMsgData->pagelist, pageIdx);
+                       mediaCnt = page->mediaCnt;
+
+                       memcpy(buf + offset, &mediaCnt, sizeof(int));
+                       offset += sizeof(int);
+
+                       MSG_DEBUG("MsgMmsSerializeMessageData: mediaCnt = %d",  mediaCnt);
+                       if (page->medialist) {
+                               for (int i = 0; i < mediaCnt; ++ i) {
+                                       MMS_MEDIA_S *media = (MMS_MEDIA_S *)g_list_nth_data(page->medialist, i);
+
+                                       memcpy(buf + offset, &(media->mediatype), sizeof(MmsSmilMediaType));
+                                       offset += sizeof(MmsSmilMediaType);
+                                       MSG_DEBUG("%d media's mediatype = %d", i, media->mediatype);
+
+                                       memcpy(buf + offset, media->szSrc, MSG_FILEPATH_LEN_MAX);
+                                       offset +=  MSG_FILEPATH_LEN_MAX;
+
+                                       memcpy(buf + offset, media->szFileName, MSG_FILENAME_LEN_MAX);
+                                       offset += MSG_FILENAME_LEN_MAX;
+                                       MSG_DEBUG("%d media's filename = %s", i, media->szFileName);
+
+                                       memcpy(buf + offset, media->szFilePath, MSG_FILEPATH_LEN_MAX);
+                                       offset += MSG_FILEPATH_LEN_MAX;
+                                       MSG_DEBUG("%d media's filepath = %s", i, media->szFilePath);
+
+                                       memcpy(buf + offset, media->szContentID, MSG_MSG_ID_LEN + 1);
+                                       offset +=  MSG_MSG_ID_LEN + 1;
+                                       MSG_DEBUG("%d media's contentID = %s", i, media->szContentID);
+
+                                       memcpy(buf + offset, media->regionId, MAX_SMIL_REGION_ID);
+                                       offset +=  MAX_SMIL_REGION_ID;
+                                       MSG_DEBUG("%d media's regionId = %s", i, media->regionId);
+
+                                       memcpy(buf + offset, media->szAlt, MAX_SMIL_ALT_LEN);
+                                       offset +=  MAX_SMIL_ALT_LEN;
+
+#ifdef __SUPPORT_DRM__
+                                       memcpy(buf + offset, &(media->drmType), sizeof(MsgDrmType));
+                                       offset +=  sizeof(MsgDrmType);
+                                       memcpy(buf + offset, media->szDrm2FullPath, MSG_FILEPATH_LEN_MAX);
+                                       offset += MSG_FILEPATH_LEN_MAX;
+#endif
+
+                                       if (media->mediatype == MMS_SMIL_MEDIA_TEXT) {
+                                               MSG_DEBUG("##### Media = TEXT #####");
+                                               memcpy(buf + offset, media->sMedia.sText.szTransInId, MAX_SMIL_TRANSIN_ID);
+                                               offset +=  MAX_SMIL_TRANSIN_ID;
+
+                                               memcpy(buf + offset, media->sMedia.sText.szTransOutId, MAX_SMIL_TRANSOUT_ID);
+                                               offset +=  MAX_SMIL_TRANSOUT_ID;
+
+                                               memcpy(buf + offset, &(media->sMedia.sText.nRepeat), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sText.nBegin), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sText.nEnd), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sText.nDurTime), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sText.nBgColor), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sText.bBold), sizeof(bool));
+                                               offset += sizeof(bool);
+
+                                               memcpy(buf + offset, &(media->sMedia.sText.bUnderLine), sizeof(bool));
+                                               offset += sizeof(bool);
+
+                                               memcpy(buf + offset, &(media->sMedia.sText.bItalic), sizeof(bool));
+                                               offset += sizeof(bool);
+
+                                               memcpy(buf + offset, &(media->sMedia.sText.bReverse), sizeof(bool));
+                                               offset += sizeof(bool);
+
+                                               memcpy(buf + offset, &(media->sMedia.sText.nDirection), sizeof(MmsTextDirection));
+                                               offset += sizeof(MmsTextDirection);
+
+                                               //memcpy(buf + offset, &(media->sMedia.sText.nFont), sizeof(MmsSmilFontType));
+                                               //offset += sizeof(MmsSmilFontType);
+
+                                               memcpy(buf + offset, &(media->sMedia.sText.nSize), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sText.nColor), sizeof(int));
+                                               offset += sizeof(int);
+                                       } else {
+                                               MSG_DEBUG("##### Media = IMAGE, AUDIO, VIDEO #####");
+                                               memcpy(buf + offset, media->sMedia.sAVI.szTransInId, MAX_SMIL_TRANSIN_ID);
+                                               offset +=  MAX_SMIL_TRANSIN_ID;
+
+                                               memcpy(buf + offset, media->sMedia.sAVI.szTransOutId, MAX_SMIL_TRANSOUT_ID);
+                                               offset +=  MAX_SMIL_TRANSOUT_ID;
+
+                                               memcpy(buf + offset, &(media->sMedia.sAVI.nRepeat), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sAVI.nBegin), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sAVI.nEnd), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sAVI.nDurTime), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sAVI.nBgColor), sizeof(int));
+                                               offset += sizeof(int);
+                                       }
+                               }
+                       }
+
+                       memcpy(buf + offset, &page->nDur, sizeof(int));
+                       offset += sizeof(int);
+                       memcpy(buf + offset, &page->nBegin, sizeof(int));
+                       offset += sizeof(int);
+                       memcpy(buf + offset, &page->nEnd, sizeof(int));
+                       offset += sizeof(int);
+                       memcpy(buf + offset, &page->nMin, sizeof(int));
+                       offset += sizeof(int);
+                       memcpy(buf + offset, &page->nMax, sizeof(int));
+                       offset += sizeof(int);
+                       memcpy(buf + offset, &page->nRepeat, sizeof(int));
+                       offset += sizeof(int);
+               }
+       }
+
+       memcpy(buf + offset, &pMsgData->regionCnt, sizeof(int));
+       offset += sizeof(int);
+       MSG_DEBUG("pMsgData->regionCnt: %d", pMsgData->regionCnt);
+
+       if (pMsgData->regionlist) {
+               for (int i = 0; i < pMsgData->regionCnt; ++ i) {
+                       MMS_SMIL_REGION *region = (MMS_SMIL_REGION *)g_list_nth_data(pMsgData->regionlist, i);
+
+                       memcpy(buf + offset, region->szID, MAX_SMIL_REGION_ID);
+                       offset += MAX_SMIL_REGION_ID;
+                       MSG_DEBUG("%d region's ID = %s", i, region->szID);
+                       memcpy(buf + offset, &region->nLeft, sizeof(MMS_LENGTH));
+                       offset += sizeof(MMS_LENGTH);
+                       memcpy(buf + offset, &region->nTop, sizeof(MMS_LENGTH));
+                       offset += sizeof(MMS_LENGTH);
+                       memcpy(buf + offset, &region->width, sizeof(MMS_LENGTH));
+                       offset += sizeof(MMS_LENGTH);
+                       memcpy(buf + offset, &region->height, sizeof(MMS_LENGTH));
+                       offset += sizeof(MMS_LENGTH);
+                       memcpy(buf + offset, &region->bgColor, sizeof(int));
+                       offset += sizeof(int);
+                       memcpy(buf + offset, &region->fit, sizeof(REGION_FIT_TYPE_T));
+                       offset += sizeof(REGION_FIT_TYPE_T);
+               }
+       }
+
+       memcpy(buf + offset, &pMsgData->attachCnt, sizeof(int));
+       offset += sizeof(int);
+       MSG_DEBUG("pMsgData->attachCnt: %d", pMsgData->attachCnt);
+
+       if (pMsgData->attachlist) {
+               for (int i = 0; i < pMsgData->attachCnt; ++ i) {
+                       MMS_ATTACH_S *attach = (MMS_ATTACH_S *)g_list_nth_data(pMsgData->attachlist, i);
+
+                       memcpy(buf + offset, &(attach->mediatype), sizeof(MimeType));
+                       offset += sizeof(MimeType);
+                       MSG_DEBUG("%d attachment's mediatype = %d", i, attach->mediatype);
+
+                       memcpy(buf + offset, attach->szFileName, MSG_FILENAME_LEN_MAX);
+                       offset += MSG_FILENAME_LEN_MAX;
+                       MSG_DEBUG("%d attachment's filename = %s", i, attach->szFileName);
+
+                       memcpy(buf + offset, attach->szFilePath, MSG_FILEPATH_LEN_MAX);
+                       offset += MSG_FILEPATH_LEN_MAX;
+                       MSG_DEBUG("%d attachment's filepath = %s", i, attach->szFilePath);
+
+                       memcpy(buf + offset, &(attach->fileSize), sizeof(int));
+                       offset +=  sizeof(int);
+                       MSG_DEBUG("%d attachment's file size = %d", i, attach->fileSize);
+
+#ifdef __SUPPORT_DRM__
+                       memcpy(buf + offset, &(attach->drmType), sizeof(MsgDrmType));
+                       offset +=  sizeof(MsgDrmType);
+                       memcpy(buf + offset, attach->szDrm2FullPath, MSG_FILEPATH_LEN_MAX);
+                       offset += MSG_FILEPATH_LEN_MAX;
+#endif
+               }
+       }
+
+       memcpy(buf + offset, &pMsgData->transitionCnt, sizeof(int));
+       offset += sizeof(int);
+       MSG_DEBUG("pMsgData->transitionCnt: %d", pMsgData->transitionCnt);
+
+       if (pMsgData->transitionlist) {
+               for (int i = 0; i < pMsgData->transitionCnt; ++ i) {
+                       MMS_SMIL_TRANSITION *transition = (MMS_SMIL_TRANSITION *)g_list_nth_data(pMsgData->transitionlist, i);
+
+                       memcpy(buf + offset, transition->szID, MAX_SMIL_TRANSITION_ID);
+                       offset += MAX_SMIL_TRANSITION_ID;
+                       MSG_DEBUG("%d transition's ID = %s", i, transition->szID);
+
+                       memcpy(buf + offset, &transition->nType, sizeof(MmsSmilTransType));
+                       offset += sizeof(MmsSmilTransType);
+                       memcpy(buf + offset, &transition->nSubType, sizeof(MmsSmilTransSubType));
+                       offset += sizeof(MmsSmilTransSubType);
+                       memcpy(buf + offset, &transition->nDur, sizeof(int));
+                       offset += sizeof(int);
+               }
+       }
+
+       memcpy(buf + offset, &pMsgData->metaCnt, sizeof(int));
+       offset += sizeof(int);
+       MSG_DEBUG("pMsgData->metaCnt: %d", pMsgData->metaCnt);
+
+       if (pMsgData->metalist) {
+               for (int i = 0; i < pMsgData->metaCnt; ++ i) {
+                       MMS_SMIL_META *meta = (MMS_SMIL_META *)g_list_nth_data(pMsgData->metalist, i);
+
+                       memcpy(buf + offset, meta->szID, MAX_SMIL_META_ID);
+                       offset += MAX_SMIL_META_ID;
+                       MSG_DEBUG("%d meta's ID = %s", i, meta->szID);
+
+                       memcpy(buf + offset, meta->szName, MAX_SMIL_META_NAME);
+                       offset += MAX_SMIL_META_NAME;
+                       MSG_DEBUG("%d meta's ID = %s", i, meta->szID);
+
+                       memcpy(buf + offset, meta->szContent, MAX_SMIL_META_CONTENT);
+                       offset += MAX_SMIL_META_CONTENT;
+                       MSG_DEBUG("%d meta's ID = %s", i, meta->szID);
+               }
+       }
+
+       memcpy(buf + offset, &pMsgData->rootlayout, sizeof(MMS_SMIL_ROOTLAYOUT));
+       offset += sizeof(MMS_SMIL_ROOTLAYOUT);
+
+#ifdef FEATURE_JAVA_MMS
+       memcpy(buf + offset, &pMsgData->msgAppId, sizeof(MMS_APPID_INFO_S));
+       offset += sizeof(MMS_APPID_INFO_S);
+#endif
+
+       *pSize = offset;
+
+       return buf;
+}
+
+int _MsgMmsGetPageCount(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return 0;
+       }
+
+       int count = 0;
+
+       if (pMsgData->pagelist)
+               count = g_list_length(pMsgData->pagelist);
+
+       MSG_DEBUG("Page Count: %d", count);
+       return count;
+}
+
+MMS_PAGE_S *_MsgMmsGetPage(MMS_MESSAGE_DATA_S *pMsgData, int pageIdx)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return NULL;
+       }
+
+       MMS_PAGE_S *page = NULL;
+
+       if (pMsgData->pagelist)
+               page = (MMS_PAGE_S *)g_list_nth_data(pMsgData->pagelist, pageIdx);
+
+       return page;
+}
+
+int _MsgMmsGetAttachCount(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return 0;
+       }
+
+       int count = 0;
+
+       if (pMsgData->attachlist)
+               count = g_list_length(pMsgData->attachlist);
+
+       MSG_DEBUG("Attachment Count: %d", count);
+       return count;
+}
+
+MMS_ATTACH_S *_MsgMmsGetAttachment(MMS_MESSAGE_DATA_S *pMsgData, int attachIdx)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return NULL;
+       }
+
+       MMS_ATTACH_S *attach = NULL;
+       if (pMsgData->attachlist)
+               attach = (MMS_ATTACH_S *)g_list_nth_data(pMsgData->attachlist, attachIdx);
+
+       return attach;
+}
+
+MMS_SMIL_REGION *_MsgMmsGetSmilRegion(MMS_MESSAGE_DATA_S *pMsgData, int regionIdx)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return NULL;
+       }
+
+       MMS_SMIL_REGION *region = NULL;
+
+       if (pMsgData->regionlist)
+               region = (MMS_SMIL_REGION *)g_list_nth_data(pMsgData->regionlist, regionIdx);
+
+       return region;
+}
+
+MMS_MEDIA_S *_MsgMmsGetMedia(MMS_PAGE_S *pPage, int mediaIdx)
+{
+       if (!pPage) {
+               MSG_FATAL("pPage is NULL");
+               return NULL;
+       }
+
+       if (mediaIdx > pPage->mediaCnt || mediaIdx < 0) {
+               MSG_FATAL("Invalid media index = %d", mediaIdx);
+               return NULL;
+       }
+
+       MMS_MEDIA_S *media = NULL;
+       if (pPage->medialist)
+               media = (MMS_MEDIA_S *)g_list_nth_data(pPage->medialist, mediaIdx);
+
+       return media;
+
+}
+
+int _MsgMmsGetTransitionCount(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return 0;
+       }
+
+       int count = 0;
+
+       if (pMsgData->transitionlist)
+               count = g_list_length(pMsgData->transitionlist);
+
+       MSG_DEBUG("Transition Count: %d", count);
+       return count;
+}
+
+MMS_SMIL_TRANSITION *_MsgMmsGetTransition(MMS_MESSAGE_DATA_S *pMsgData, int transitionIdx)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return NULL;
+       }
+
+       MMS_SMIL_TRANSITION *transition = NULL;
+       if (pMsgData->transitionlist)
+               transition = (MMS_SMIL_TRANSITION *)g_list_nth_data(pMsgData->transitionlist, transitionIdx);
+
+       return transition;
+}
+
+MMS_SMIL_META *_MsgMmsGetMeta(MMS_MESSAGE_DATA_S *pMsgData, int metaIdx)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return NULL;
+       }
+
+       MMS_SMIL_META *meta = NULL;
+
+       if (pMsgData->metalist)
+               meta = (MMS_SMIL_META *)g_list_nth_data(pMsgData->metalist, metaIdx);
+
+       return meta;
+}
+
+int    _MsgMmsGetMetaCount(MMS_MESSAGE_DATA_S *pMsgData)
+{
+       if (pMsgData == NULL) {
+               MSG_DEBUG("pMsgData is NULL");
+               return 0;
+       }
+
+       int count = 0;
+
+       if (pMsgData->metalist)
+               count = g_list_length(pMsgData->metalist);
+
+       MSG_DEBUG("Meta Count: %d", count);
+       return count;
+}
+
+
+bool           _MsgMmsDeserializeMessageData(MMS_MESSAGE_DATA_S* pBody, char* pData)
+{
+       MSG_DEBUG("MmsGetMsgBodyfromFile");
+
+       if (pBody == NULL || pData == NULL) {
+               MSG_DEBUG("param is NULL. pBody = %x, pData = %x", pBody, pData);
+               return false;
+       }
+
+       int offset = 0;
+       int pageCnt = 0;
+       int filePathLen = 0;
+
+       MMS_PAGE_S *pPage = NULL;
+       MMS_MEDIA_S *pMedia = NULL;
+       MMS_SMIL_REGION *pRegion = NULL;
+       MMS_ATTACH_S *pAttach = NULL;
+       MMS_SMIL_TRANSITION *pTransition = NULL;
+       MMS_SMIL_META *pMeta = NULL;
+
+       memcpy(&filePathLen, pData, sizeof(int));
+
+       offset += sizeof(int);
+
+       MSG_DEBUG("Smil File Path Length : %d", filePathLen);
+
+       if (filePathLen > MSG_FILEPATH_LEN_MAX) {
+               MSG_DEBUG("Smil File Path Length is abnormal.");
+               return false;
+       }
+
+       memset(pBody->szSmilFilePath, 0x00, MSG_FILEPATH_LEN_MAX);
+
+       if (filePathLen > 0) {
+               memcpy(pBody->szSmilFilePath, pData + offset, filePathLen);
+
+               offset += filePathLen;
+       }
+
+       memcpy(&(pBody->pageCnt), pData + offset, sizeof(int));
+
+       offset += sizeof(int);
+
+       pageCnt = pBody->pageCnt;
+
+       MSG_DEBUG("MMS PAGE COUNT: %d", pageCnt);
+
+       for (int j = 0; j < pageCnt; ++j) {
+               pPage = (MMS_PAGE_S *)calloc(sizeof(MMS_PAGE_S), 1);
+
+               memcpy(&pPage->mediaCnt, pData + offset, sizeof(int));
+               offset += sizeof(int);
+               MSG_DEBUG("MMS MEDIA COUNT: %d", pPage->mediaCnt);
+
+               for (int i = 0; i < pPage->mediaCnt; ++i) {
+                       pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
+
+                       memcpy(&pMedia->mediatype, pData + offset, sizeof(int));
+                       offset += sizeof(int);
+
+                       memcpy(pMedia->szSrc, pData + offset, MSG_FILEPATH_LEN_MAX);
+                       offset += MSG_FILEPATH_LEN_MAX;
+
+                       memcpy(pMedia->szFileName, pData + offset, MSG_FILENAME_LEN_MAX);
+                       offset += MSG_FILENAME_LEN_MAX;
+
+                       memcpy(pMedia->szFilePath, pData + offset, MSG_FILEPATH_LEN_MAX);
+                       offset += MSG_FILEPATH_LEN_MAX;
+
+                       memcpy(pMedia->szContentID, pData + offset, MSG_MSG_ID_LEN+1);
+                       offset += MSG_MSG_ID_LEN + 1;
+
+                       memcpy(pMedia->regionId, pData + offset, MAX_SMIL_REGION_ID);
+                       offset += MAX_SMIL_REGION_ID;
+
+                       memcpy(pMedia->szAlt, pData + offset, MAX_SMIL_ALT_LEN);
+                       offset += MAX_SMIL_ALT_LEN;
+
+#ifdef __SUPPORT_DRM__
+                       memcpy(&pMedia->drmType, pData + offset, sizeof(MsgDrmType));
+                       offset += sizeof(MsgDrmType);
+
+                       memcpy(pMedia->szDrm2FullPath, pData + offset, MSG_FILEPATH_LEN_MAX);
+                       offset += MSG_FILEPATH_LEN_MAX;
+#endif
+
+                       if (pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) {
+                               MSG_DEBUG("##### MEDIA TYPE = TEXT #####");
+                               memcpy(pMedia->sMedia.sText.szTransInId, pData + offset, MAX_SMIL_TRANSIN_ID);
+                               offset += MAX_SMIL_TRANSIN_ID;
+
+                               memcpy(pMedia->sMedia.sText.szTransOutId, pData + offset, MAX_SMIL_TRANSOUT_ID);
+                               offset += MAX_SMIL_TRANSOUT_ID;
+
+                               memcpy(&pMedia->sMedia.sText.nRepeat, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sText.nBegin, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sText.nEnd, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sText.nDurTime, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sText.nBgColor, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sText.bBold, pData + offset, sizeof(bool));
+                               offset += sizeof(bool);
+
+                               memcpy(&pMedia->sMedia.sText.bUnderLine, pData + offset, sizeof(bool));
+                               offset += sizeof(bool);
+
+                               memcpy(&pMedia->sMedia.sText.bItalic, pData + offset, sizeof(bool));
+                               offset += sizeof(bool);
+
+                               memcpy(&pMedia->sMedia.sText.bReverse, pData + offset, sizeof(bool));
+                               offset += sizeof(bool);
+
+                               memcpy(&pMedia->sMedia.sText.nDirection, pData + offset, sizeof(MmsTextDirection));
+                               offset += sizeof(MmsTextDirection);
+
+                               //memcpy(&pMedia->sMedia.sText.nFont, pData + offset, sizeof(MmsSmilFontType));
+                               //offset += sizeof(MmsSmilFontType);
+
+                               memcpy(&pMedia->sMedia.sText.nSize, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sText.nColor, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+                       } else {
+                               MSG_DEBUG("##### MEDIA TYPE = IMAGE, AUDIO, VIDEO #####");
+                               memcpy(pMedia->sMedia.sAVI.szTransInId, pData + offset, MAX_SMIL_TRANSIN_ID);
+                               offset += MAX_SMIL_TRANSIN_ID;
+
+                               memcpy(pMedia->sMedia.sAVI.szTransOutId, pData + offset, MAX_SMIL_TRANSOUT_ID);
+                               offset += MAX_SMIL_TRANSOUT_ID;
+
+                               memcpy(&pMedia->sMedia.sAVI.nRepeat, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sAVI.nBegin, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sAVI.nEnd, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sAVI.nDurTime, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sAVI.nBgColor, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+                       }
+                       pPage->medialist = g_list_append(pPage->medialist, pMedia);
+               }
+
+               memcpy(&pPage->nDur , pData + offset, sizeof(int));
+               offset += sizeof(int);
+               memcpy(&pPage->nBegin , pData + offset, sizeof(int));
+               offset += sizeof(int);
+               memcpy(&pPage->nEnd , pData + offset, sizeof(int));
+               offset += sizeof(int);
+               memcpy(&pPage->nMin , pData + offset, sizeof(int));
+               offset += sizeof(int);
+               memcpy(&pPage->nMax , pData + offset, sizeof(int));
+               offset += sizeof(int);
+               memcpy(&pPage->nRepeat , pData + offset, sizeof(int));
+               offset += sizeof(int);
+
+               pBody->pagelist = g_list_append(pBody->pagelist, pPage);
+       }
+
+       //Processing Region List
+       memcpy(&pBody->regionCnt, pData + offset, sizeof(int));
+       offset += sizeof(int);
+
+       MSG_DEBUG(" pBody->regionCnt: %d", pBody->regionCnt);
+
+       for (int i = 0; i < pBody->regionCnt; ++i) {
+               pRegion = (MMS_SMIL_REGION *)calloc(sizeof(MMS_SMIL_REGION), 1);
+
+               memcpy(pRegion->szID, pData + offset, MAX_SMIL_REGION_ID);
+               offset += MAX_SMIL_REGION_ID;
+               memcpy(&pRegion->nLeft, pData + offset, sizeof(MMS_LENGTH));
+               offset += sizeof(MMS_LENGTH);
+               memcpy(&pRegion->nTop, pData + offset, sizeof(MMS_LENGTH));
+               offset += sizeof(MMS_LENGTH);
+               memcpy(&pRegion->width, pData + offset, sizeof(MMS_LENGTH));
+               offset += sizeof(MMS_LENGTH);
+               memcpy(&pRegion->height, pData + offset, sizeof(MMS_LENGTH));
+               offset += sizeof(MMS_LENGTH);
+               memcpy(&pRegion->bgColor, pData + offset, sizeof(int));
+               offset += sizeof(int);
+               memcpy(&pRegion->fit, pData + offset, sizeof(REGION_FIT_TYPE_T));
+               offset += sizeof(REGION_FIT_TYPE_T);
+
+               pBody->regionlist = g_list_append(pBody->regionlist, pRegion);
+       }
+
+       //Processing Attachment List
+       memcpy(&pBody->attachCnt, pData + offset, sizeof(int));
+       offset += sizeof(int);
+
+       MSG_DEBUG(" pBody->attachCnt: %d", pBody->attachCnt);
+
+       for (int i = 0; i < pBody->attachCnt; ++i) {
+               pAttach = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1);
+
+               memcpy(&pAttach->mediatype, pData + offset, sizeof(MimeType));
+               offset += sizeof(MimeType);
+
+               memcpy(pAttach->szFileName, pData + offset, MSG_FILENAME_LEN_MAX);
+               offset += MSG_FILENAME_LEN_MAX;
+
+               memcpy(pAttach->szFilePath, pData + offset, MSG_FILEPATH_LEN_MAX);
+               offset += MSG_FILEPATH_LEN_MAX;
+
+               memcpy(&pAttach->fileSize, pData + offset, sizeof(int));
+               offset += sizeof(int);
+
+#ifdef __SUPPORT_DRM__
+               memcpy(&pAttach->drmType, pData + offset, sizeof(MsgDrmType));
+               offset += sizeof(MsgDrmType);
+
+               memcpy(pAttach->szDrm2FullPath, pData + offset, MSG_FILEPATH_LEN_MAX);
+               offset += MSG_FILEPATH_LEN_MAX;
+#endif
+
+               pBody->attachlist = g_list_append(pBody->attachlist, pAttach);
+       }
+
+       //Processing Transition List
+       memcpy(&pBody->transitionCnt, pData + offset, sizeof(int));
+       offset += sizeof(int);
+
+       MSG_DEBUG(" pBody->transitionCnt: %d", pBody->transitionCnt);
+
+       for (int i = 0; i < pBody->transitionCnt; ++i) {
+               pTransition = (MMS_SMIL_TRANSITION *)calloc(sizeof(MMS_SMIL_TRANSITION), 1);
+
+               memcpy(pTransition->szID, pData + offset, MAX_SMIL_TRANSITION_ID);
+               offset += MAX_SMIL_TRANSITION_ID;
+
+               memcpy(&pTransition->nType, pData + offset, sizeof(MmsSmilTransType));
+               offset += sizeof(MmsSmilTransType);
+               memcpy(&pTransition->nSubType, pData + offset, sizeof(MmsSmilTransSubType));
+               offset += sizeof(MmsSmilTransSubType);
+               memcpy(&pTransition->nDur, pData + offset, sizeof(int));
+               offset += sizeof(int);
+
+               pBody->transitionlist = g_list_append(pBody->transitionlist, pTransition);
+       }
+
+       //Processing Meta List
+       memcpy(&pBody->metaCnt, pData + offset, sizeof(int));
+       offset += sizeof(int);
+
+       MSG_DEBUG(" pBody->metaCnt: %d", pBody->metaCnt);
+
+       for (int i = 0; i < pBody->metaCnt; ++i) {
+               pMeta = (MMS_SMIL_META *)calloc(sizeof(MMS_SMIL_META), 1);
+
+               memcpy(pMeta->szID, pData + offset, MAX_SMIL_META_ID);
+               offset += MAX_SMIL_META_ID;
+
+               memcpy(pMeta->szName, pData + offset, MAX_SMIL_META_NAME);
+               offset += MAX_SMIL_META_NAME;
+
+               memcpy(pMeta->szContent, pData + offset, MAX_SMIL_META_CONTENT);
+               offset += MAX_SMIL_META_CONTENT;
+
+               pBody->metalist = g_list_append(pBody->metalist, pMeta);
+       }
+
+       memcpy(&pBody->rootlayout, pData + offset, sizeof(MMS_SMIL_ROOTLAYOUT));
+       offset += sizeof(MMS_SMIL_ROOTLAYOUT);
+
+#ifdef FEATURE_JAVA_MMS
+       memcpy(&pBody->msgAppId, pData + offset, sizeof(MMS_APPID_INFO_S));
+       offset += sizeof(MMS_APPID_INFO_S);
+       MSG_DEBUG("java_app_id valid:%d, appId:%s repleToAppId:%s", pBody->msgAppId.valid, pBody->msgAppId.appId, pBody->msgAppId.replyToAppId);
+#endif
+       //free(pData);
+
+       return true;
+}
+
+bool   _MsgMmsSetRootLayout(MMS_MESSAGE_DATA_S* pMmsMsg, MMS_SMIL_ROOTLAYOUT* pRootlayout)
+{
+       memcpy(&pMmsMsg->rootlayout, pRootlayout, sizeof(MMS_SMIL_ROOTLAYOUT));
+       return true;
+}
+
diff --git a/utils/MsgMutex.cpp b/utils/MsgMutex.cpp
new file mode 100755 (executable)
index 0000000..ff54533
--- /dev/null
@@ -0,0 +1,31 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <fcntl.h>     /* O_RDWR */
+#include <sys/mman.h>
+#include <errno.h>
+
+#include "MsgDebug.h"
+#include "MsgMutex.h"
+
+#define MSG_SHM_NAME "/msg_fw_shm"
+
+typedef struct {
+       pthread_mutex_t mutex;
+       pthread_cond_t  condvar;
+       int ready;
+} MSG_MUTEX_S;
+
diff --git a/utils/MsgNotificationWrapper.cpp b/utils/MsgNotificationWrapper.cpp
new file mode 100755 (executable)
index 0000000..ab6e54e
--- /dev/null
@@ -0,0 +1,629 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgContact.h"
+#include "MsgStorageTypes.h"
+#include "MsgNotificationWrapper.h"
+
+extern "C"
+{
+       #include <notification.h>
+}
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+MSG_ERROR_T MsgInsertNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
+{
+
+       notification_h noti = NULL;
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+       bundle* args;
+
+       int contactId = 0;
+       int threadId = 0;
+       time_t msgTime = 0;
+       char tempId[6];
+       char addressVal[MAX_ADDRESS_VAL_LEN+1];
+       char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
+       char displayName[MAX_DISPLAY_NAME_LEN+1];
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(tempId, 0x00, sizeof(tempId));
+       memset(addressVal, 0x00, sizeof(addressVal));
+       memset(firstName, 0x00, sizeof(firstName));
+       memset(lastName, 0x00, sizeof(lastName));
+       memset(displayName, 0x00, sizeof(displayName));
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.ADDRESS_ID, A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, \
+                                               B.DISPLAY_TIME, A.CONTACT_ID \
+                                               FROM %s A, %s B \
+                                            WHERE B.MSG_ID=%d AND A.ADDRESS_ID=B.ADDRESS_ID;",
+               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) {
+               threadId = pDbHandle->columnInt(0);
+
+               if (pDbHandle->columnText(1) != NULL)
+                       strncpy(addressVal, (char*)pDbHandle->columnText(1), MAX_ADDRESS_VAL_LEN);
+
+
+               char *pTempDisplayName = (char *)pDbHandle->columnText(2);
+               if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
+                       strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
+               } else {
+                       if (pDbHandle->columnText(3) != NULL)
+                               strncpy(firstName, (char*)pDbHandle->columnText(3), MAX_DISPLAY_NAME_LEN);
+
+                       if (pDbHandle->columnText(4) != NULL)
+                               strncpy(lastName, (char*)pDbHandle->columnText(4), MAX_DISPLAY_NAME_LEN);
+
+                       int order = MsgGetContactNameOrder();
+
+                       if (order == 0) {
+                               if (firstName[0] != '\0') {
+                                       strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
+                               }
+
+                               if (lastName[0] != '\0') {
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                                       strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       } else if (order == 1) {
+                               if (lastName[0] != '\0') {
+                                       strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+
+                               if (firstName[0] != '\0') {
+                                       strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       }
+               }
+
+               msgTime = (time_t)pDbHandle->columnInt(5);
+
+               contactId = pDbHandle->columnInt(6);
+       } else {
+               pDbHandle->finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+
+       args = bundle_create();
+
+       if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->msgType.subType == MSG_CB_SMS) {
+
+               noti = notification_new(NOTIFICATION_TYPE_NOTI, 1, pMsg->msgId);
+               if (noti == NULL) {
+                       MSG_DEBUG("notification_new is failed.");
+                       bundle_free(args);
+                       return MSG_ERR_UNKNOWN;
+               }
+
+               noti_err = notification_set_application(noti, "org.tizen.message");
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
+               }
+
+               noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, CB_MSG_ICON_PATH);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
+               }
+
+               memset(&tempId, 0x00, sizeof(tempId));
+
+               snprintf(tempId, 5, "%d", threadId);
+               bundle_add(args, "threadId", tempId);
+       } else if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->msgType.classType == MSG_CLASS_0) {
+
+               noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+               if (noti == NULL) {
+                       MSG_DEBUG("notification_new is failed.");
+                       bundle_free(args);
+                       return MSG_ERR_UNKNOWN;
+               }
+
+               noti_err = notification_set_application(noti, "org.tizen.msg-ui-class0");
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
+               }
+
+               snprintf(tempId, 5, "%d", pMsg->msgId);
+               bundle_add(args, "msg_id", tempId);
+       } else if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->msgType.subType == MSG_MWI_VOICE_SMS) {
+
+               noti = notification_new(NOTIFICATION_TYPE_NOTI, 1, pMsg->msgId);
+               if (noti == NULL) {
+                       MSG_DEBUG("notification_new is failed.");
+                       bundle_free(args);
+                       return MSG_ERR_UNKNOWN;
+               }
+
+               noti_err = notification_set_application(noti, "org.tizen.message");
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
+               }
+
+               noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, VOICE_MSG_ICON_PATH);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
+               }
+
+               memset(&tempId, 0x00, sizeof(tempId));
+
+               snprintf(tempId, 5, "%d", threadId);
+               bundle_add(args, "threadId", tempId);
+       } else {
+               MSG_DEBUG("notification_new pMsg->msgId [%d]", pMsg->msgId);
+               noti = notification_new(NOTIFICATION_TYPE_NOTI, 1, pMsg->msgId);
+               if (noti == NULL) {
+                       MSG_DEBUG("notification_new is failed.");
+                       bundle_free(args);
+                       return MSG_ERR_UNKNOWN;
+               }
+
+               noti_err = notification_set_application(noti, "org.tizen.message");
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
+               }
+
+               noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
+               }
+
+               memset(&tempId, 0x00, sizeof(tempId));
+
+               snprintf(tempId, 5, "%d", threadId);
+               bundle_add(args, "threadId", tempId);
+       }
+
+       bundle_add(args, "type", "msg_id");
+
+       snprintf(tempId, 5, "%d", pMsg->msgId);
+       bundle_add(args, "msgId", tempId);
+
+       if (displayName[0] == '\0')
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+       else
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+       if (pMsg->msgType.mainType == MSG_SMS_TYPE)
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+       else
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+
+       if (args != NULL) {
+               noti_err = notification_set_args(noti, args, NULL);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
+               }
+       }
+
+       noti_err = notification_set_time(noti, msgTime);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_time : %d", noti_err);
+       }
+
+       noti_err = notification_insert(noti, NULL);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_insert");
+       }
+
+       noti_err = notification_free(noti);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_free");
+       }
+
+       bundle_free(args);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgInsertSmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_ID_T MsgId, MSG_DELIVERY_REPORT_STATUS_T Status)
+{
+       notification_h noti = NULL;
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+       char addressVal[MAX_ADDRESS_VAL_LEN+1];
+       char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
+       char displayName[MAX_DISPLAY_NAME_LEN+1];
+       char contents[MAX_DISPLAY_NAME_LEN+1];
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(addressVal, 0x00, sizeof(addressVal));
+       memset(firstName, 0x00, sizeof(firstName));
+       memset(lastName, 0x00, sizeof(lastName));
+       memset(displayName, 0x00, sizeof(displayName));
+       memset(contents, 0x00, sizeof(contents));
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME \
+                                                                      FROM %s A, %s B \
+                                                                   WHERE B.MSG_ID = %d \
+                                                                        AND A.ADDRESS_ID = B.ADDRESS_ID;",
+                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) {
+               if (pDbHandle->columnText(0) != NULL)
+                       strncpy(addressVal, (char*)pDbHandle->columnText(0), MAX_ADDRESS_VAL_LEN);
+
+               if (pDbHandle->columnText(1) != NULL) {
+                       strncpy(displayName, (char*)pDbHandle->columnText(1), MAX_DISPLAY_NAME_LEN);
+               } else {
+                       if (pDbHandle->columnText(2) != NULL)
+                               strncpy(firstName, (char*)pDbHandle->columnText(2), MAX_DISPLAY_NAME_LEN);
+
+                       if (pDbHandle->columnText(3) != NULL)
+                               strncpy(lastName, (char*)pDbHandle->columnText(3), MAX_DISPLAY_NAME_LEN);
+
+                       int order = MsgGetContactNameOrder();
+
+                       if (order == 0) {
+                               if (firstName[0] != '\0') {
+                                       strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
+                               }
+
+                               if (lastName[0] != '\0') {
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                                       strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       } else if (order == 1) {
+                               if (lastName[0] != '\0') {
+                                       strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+
+                               if (firstName[0] != '\0') {
+                                       strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       }
+               }
+       } else {
+               MSG_DEBUG("query : %s", sqlQuery);
+
+               pDbHandle->finalizeQuery();
+
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+
+       noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+       if (noti == NULL) {
+               MSG_DEBUG("notification_new is failed.");
+               return MSG_ERR_UNKNOWN;
+       }
+
+       noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NOTI_MSG_ICON_PATH);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
+       }
+
+       if (displayName[0] == '\0')
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+       else
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+
+       if (Status == MSG_DELIVERY_REPORT_SUCCESS)
+               snprintf(contents, MAX_DISPLAY_NAME_LEN, "Delivered.");
+       else
+               snprintf(contents, MAX_DISPLAY_NAME_LEN, "Deliver Failed.");
+
+       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+       noti_err = notification_insert(noti, NULL);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_insert");
+       }
+
+       noti_err = notification_free(noti);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_free");
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
+{
+
+       notification_h noti = NULL;
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+       MSG_DELIVERY_REPORT_STATUS_T    deliveryStatus;
+       MSG_READ_REPORT_STATUS_T                readStatus;
+
+       char addressVal[MAX_ADDRESS_VAL_LEN+1];
+       char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
+       char displayName[MAX_DISPLAY_NAME_LEN+1];
+       char contents[MAX_DISPLAY_NAME_LEN+1];
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(addressVal, 0x00, sizeof(addressVal));
+       memset(firstName, 0x00, sizeof(firstName));
+       memset(lastName, 0x00, sizeof(lastName));
+       memset(displayName, 0x00, sizeof(displayName));
+       memset(contents, 0x00, sizeof(contents));
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.DELIVERY_REPORT_STATUS, B.READ_REPORT_STATUS \
+                                                                      FROM %s A, %s B \
+                                                                       WHERE B.MSG_ID=%d AND A.ADDRESS_ID=B.ADDRESS_ID;",
+                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) {
+               if (pDbHandle->columnText(0) != NULL)
+                       strncpy(addressVal, (char*)pDbHandle->columnText(0), MAX_ADDRESS_VAL_LEN);
+
+
+               char *pTempDisplayName = (char *)pDbHandle->columnText(1);
+               if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
+                       strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
+               } else {
+                       if (pDbHandle->columnText(2) != NULL)
+                               strncpy(firstName, (char*)pDbHandle->columnText(2), MAX_DISPLAY_NAME_LEN);
+
+                       if (pDbHandle->columnText(3) != NULL)
+                               strncpy(lastName, (char*)pDbHandle->columnText(3), MAX_DISPLAY_NAME_LEN);
+
+                       int order = MsgGetContactNameOrder();
+
+                       if (order == 0) {
+                               if (firstName[0] != '\0') {
+                                       strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
+                               }
+
+                               if (lastName[0] != '\0') {
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                                       strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       } else if (order == 1) {
+                               if (lastName[0] != '\0') {
+                                       strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+
+                               if (firstName[0] != '\0') {
+                                       strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       }
+               }
+
+               deliveryStatus = (MSG_DELIVERY_REPORT_STATUS_T)pDbHandle->columnInt(4);
+               readStatus = (MSG_READ_REPORT_STATUS_T)pDbHandle->columnInt(5);
+
+       } else {
+               pDbHandle->finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+       if (noti == NULL) {
+               MSG_DEBUG("notification_new is failed.");
+               return MSG_ERR_UNKNOWN;
+       }
+
+       noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NOTI_MSG_ICON_PATH);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
+       }
+
+       if (displayName[0] == '\0')
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+       else
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+       if (pMsg->msgType.subType == MSG_DELIVERYIND_MMS) {
+
+               switch(deliveryStatus) {
+               case MSG_DELIVERY_REPORT_NONE:
+                       noti_err = notification_free(noti);
+                       if (noti_err != NOTIFICATION_ERROR_NONE) {
+                               MSG_DEBUG("Fail to notification_free");
+                       }
+
+                       return MSG_ERR_UNKNOWN;
+
+               case MSG_DELIVERY_REPORT_EXPIRED:
+                       snprintf(contents, MAX_DISPLAY_NAME_LEN, "Expired.");
+                       break;
+
+               case MSG_DELIVERY_REPORT_REJECTED:
+                       snprintf(contents, MAX_DISPLAY_NAME_LEN, "Rejected.");
+                       break;
+
+               case MSG_DELIVERY_REPORT_DEFERRED:
+                       snprintf(contents, MAX_DISPLAY_NAME_LEN, "Deferred.");
+                       break;
+
+               case MSG_DELIVERY_REPORT_UNRECOGNISED:
+                       snprintf(contents, MAX_DISPLAY_NAME_LEN, "Unrecognised.");
+                       break;
+
+               case MSG_DELIVERY_REPORT_INDETERMINATE:
+                       snprintf(contents, MAX_DISPLAY_NAME_LEN, "Indeterminate.");
+                       break;
+
+               case MSG_DELIVERY_REPORT_FORWARDED:
+                       snprintf(contents, MAX_DISPLAY_NAME_LEN, "Forwarded.");
+                       break;
+
+               case MSG_DELIVERY_REPORT_UNREACHABLE:
+                       snprintf(contents, MAX_DISPLAY_NAME_LEN, "Unreachable.");
+                       break;
+
+               case MSG_DELIVERY_REPORT_ERROR:
+                       snprintf(contents, MAX_DISPLAY_NAME_LEN, "Error.");
+                       break;
+
+               default :
+                       snprintf(contents, MAX_DISPLAY_NAME_LEN, "Delivered.");
+               }
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               noti_err = notification_insert(noti, NULL);
+               if (noti_err != NOTIFICATION_ERROR_NONE)
+                       MSG_DEBUG("Fail to notification_insert");
+
+       } else if (pMsg->msgType.subType == MSG_READORGIND_MMS) {
+
+               switch(readStatus) {
+               case MSG_READ_REPORT_NONE:
+                       noti_err = notification_free(noti);
+                       if (noti_err != NOTIFICATION_ERROR_NONE)
+                               MSG_DEBUG("Fail to notification_free");
+
+                       return MSG_ERR_UNKNOWN;
+
+               case MSG_READ_REPORT_IS_DELETED:
+                       snprintf(contents, MAX_DISPLAY_NAME_LEN, "Deleted.");
+                       break;
+
+               default :
+                       snprintf(contents, MAX_DISPLAY_NAME_LEN, "Read.");
+               }
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               noti_err = notification_insert(noti, NULL);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_insert");
+               }
+       } else {
+               MSG_DEBUG("No matching subtype. subtype [%d]", pMsg->msgType.subType);
+
+               noti_err = notification_free(noti);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_free");
+               }
+               return MSG_SUCCESS;
+       }
+
+       noti_err = notification_free(noti);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_free");
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgDeleteNotiByMsgId(MSG_MESSAGE_ID_T msgId)
+{
+
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+       MSG_DEBUG("notification_delete_by_priv_id msgId [%d]", msgId);
+
+       noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, msgId);
+
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_delete_by_priv_id noti_err [%d]", noti_err);
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgDeleteNotiByThreadId(MSG_THREAD_ID_T ThreadId)
+{
+       notification_delete_group_by_group_id(NULL, NOTIFICATION_TYPE_NOTI, ThreadId);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg)
+{
+
+       MSG_DEBUG("pTickerMsg [%s]", pTickerMsg);
+       MSG_DEBUG("pLocaleTickerMsg [%s]", pLocaleTickerMsg);
+
+       notification_h noti = NULL;
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+       noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+       if (noti == NULL) {
+               MSG_DEBUG("notification_new is failed.");
+               return MSG_ERR_UNKNOWN;
+       }
+
+       noti_err = notification_set_application(noti, "org.tizen.message");
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
+       }
+
+       noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, CB_MSG_ICON_PATH);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
+       }
+
+       noti_err = notification_set_text_domain(noti, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_text_domain.");
+       }
+
+       noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, pTickerMsg, pLocaleTickerMsg, NOTIFICATION_VARIABLE_TYPE_NONE);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_text : %d", noti_err);
+       }
+
+       noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, pTickerMsg, pLocaleTickerMsg, NOTIFICATION_VARIABLE_TYPE_NONE);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_text : %d", noti_err);
+       }
+
+       noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_display_applist : %d", noti_err);
+       }
+
+       noti_err = notification_insert(noti, NULL);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_text_domain");
+       }
+
+       noti_err = notification_free(noti);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_text_domain");
+       }
+
+       return MSG_SUCCESS;
+}
diff --git a/utils/MsgSoundPlayer.cpp b/utils/MsgSoundPlayer.cpp
new file mode 100755 (executable)
index 0000000..1b4dcca
--- /dev/null
@@ -0,0 +1,258 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <wait.h>
+
+#include "MsgHelper.h"
+#include "MsgDebug.h"
+#include "MsgGconfWrapper.h"
+#include "MsgSettingTypes.h"
+#include "MsgSoundPlayer.h"
+
+#include <alarm.h>
+
+
+ /*==================================================================================================
+                                     VARIABLES
+==================================================================================================*/
+static bool g_bRepeat = false;
+static alarm_id_t g_alarmId = 0;
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+
+
+void MsgSoundPlayStart()
+{
+       MSG_BEGIN();
+
+       // Run helper App
+       pid_t childpid;
+       childpid = fork();
+
+       if (childpid == -1)
+       {
+               MSG_DEBUG("Failed to fork");
+       }
+
+       if (childpid == 0)
+       {
+               MSG_DEBUG("Child Process - Run helper app for Sound");
+
+               execl("/usr/bin/msg-helper", MSG_SOUND_START, NULL);
+
+               MSG_DEBUG("Faild to run helper app for Sound");
+
+               exit(0);
+       }
+       else if (childpid != 0)
+       {
+               MSG_DEBUG("Parent Process - Mms Plugin Storage.");
+       }
+
+       if (g_bRepeat == false)
+               g_bRepeat = MsgSoundSetRepeatAlarm();
+
+       MSG_END();
+}
+
+void MsgSoundPlayStop()
+{
+       MSG_BEGIN();
+
+       // Run helper App
+       pid_t childpid;
+       childpid = fork();
+
+       if (childpid == -1)
+       {
+               MSG_DEBUG("Failed to fork");
+       }
+
+       if (childpid == 0)
+       {
+               MSG_DEBUG("Child Process - Run helper app for Sound");
+
+               execl("/usr/bin/msg-helper", MSG_SOUND_STOP, NULL);
+
+               MSG_DEBUG("Faild to run helper app for Sound");
+
+               exit(0);
+       }
+       else if (childpid != 0)
+       {
+               MSG_DEBUG("Parent Process - Mms Plugin Storage.");
+       }
+
+       MSG_END();
+}
+
+
+bool MsgSoundSetRepeatAlarm()
+{
+       bool bRet = false;
+
+       int nRepeatValue = 0;
+       long    nRepeatTime = 0;
+
+       nRepeatValue = MsgSettingGetInt(MSG_ALERT_TONE);
+
+       switch (nRepeatValue)
+       {
+               case MSG_ALERT_TONE_ONCE:
+                       nRepeatTime = 0;
+               break;
+
+               case MSG_ALERT_TONE_2MINS:
+                       nRepeatTime = 2;
+               break;
+
+               case MSG_ALERT_TONE_5MINS:
+                       nRepeatTime = 5;
+               break;
+
+               case MSG_ALERT_TONE_10MINS:
+                       nRepeatTime = 10;
+               break;
+
+               default:
+                       MSG_DEBUG("Invalid Repetition time");
+               break;
+       }
+
+       MSG_DEBUG("nRepeatTime = %d", nRepeatTime);
+
+       if (nRepeatTime > 0)
+       {
+               bRet = MsgSoundCreateRepeatAlarm(nRepeatTime);
+       }
+
+       return bRet;
+}
+
+
+bool MsgSoundCreateRepeatAlarm(int RepeatTime)
+{
+       MSG_BEGIN();
+
+       time_t current_time;
+       struct tm current_tm;
+
+       time(&current_time);
+
+       localtime_r(&current_time, &current_tm);
+
+       int retval =0;
+
+       retval = alarmmgr_init("msg-service-tools");
+
+       if (retval != 0)
+       {
+               MSG_FATAL("alarmmgr_init() error [%d]", retval);
+               return false;
+       }
+
+       alarm_info_t* alarm_info;
+       alarm_date_t target_time;
+
+       alarm_info = alarmmgr_create_alarm();
+
+       target_time.year = 0;
+       target_time.month = 0;
+       target_time.day = 0;
+
+       if (current_tm.tm_min+RepeatTime < 60)
+       {
+               target_time.hour = current_tm.tm_hour;
+               target_time.min = current_tm.tm_min+RepeatTime;
+       }
+       else
+       {
+               if (current_tm.tm_hour < 12)
+               {
+                       target_time.hour = current_tm.tm_hour+1;
+               }
+               else
+               {
+                       target_time.hour = (current_tm.tm_hour+1)%12;
+               }
+
+               target_time.min = (current_tm.tm_min+RepeatTime)%60;
+       }
+
+       target_time.sec = current_tm.tm_sec;
+
+       alarmmgr_set_time(alarm_info, target_time);
+       alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_ONCE, 0);
+       alarmmgr_set_type(alarm_info, ALARM_TYPE_VOLATILE);
+       alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &g_alarmId);
+
+       retval = alarmmgr_set_cb(MsgSoundRepeatAlarmCB, NULL);
+
+       if (retval != 0)
+       {
+               MSG_DEBUG("alarmmgr_set_cb() error [%d]", retval);
+               return false;
+       }
+
+       MSG_DEBUG("Repeat Alarm Time : [%d-%d-%d %d:%d:%d]",
+               target_time.year,target_time.month,target_time.day,
+               target_time.hour, target_time.min, target_time.sec);
+
+       MSG_END();
+
+       return true;
+}
+
+
+int MsgSoundRepeatAlarmCB(int TimerId, void *pUserParam)
+{
+       MSG_BEGIN();
+
+       g_bRepeat = false;
+
+       if (MsgSoundGetUnreadMsgCnt() <= 0)
+       {
+               MSG_DEBUG("no unread msg");
+
+               return 0;
+       }
+
+       MsgSoundPlayStart();
+
+       MSG_END();
+
+       return 0;
+}
+
+
+int MsgSoundGetUnreadMsgCnt()
+{
+       int unreadCnt = 0;
+
+       // Get SMS Count
+       unreadCnt = MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_SMS_STATE);
+
+       // Get MMS Count
+       unreadCnt += MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_MMS_STATE);
+
+       MSG_DEBUG("unread count : [%d]", unreadCnt);
+
+       return unreadCnt;
+}
+
diff --git a/utils/MsgSqliteWrapper.cpp b/utils/MsgSqliteWrapper.cpp
new file mode 100755 (executable)
index 0000000..deb9781
--- /dev/null
@@ -0,0 +1,472 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "MsgDebug.h"
+#include "MsgSqliteWrapper.h"
+
+extern "C"
+{
+       #include <db-util.h>
+}
+
+
+/*==================================================================================================
+                                     VARIABLES
+==================================================================================================*/
+__thread sqlite3 *handle = NULL;
+__thread sqlite3_stmt *stmt = NULL;
+__thread char **result = NULL;
+
+
+/*==================================================================================================
+                                     IMPLEMENTATION OF MsgDbHandler - Member Functions
+==================================================================================================*/
+MsgDbHandler::MsgDbHandler()
+{
+       handle = NULL;
+       stmt = NULL;
+       result = NULL;
+}
+
+
+MsgDbHandler::~MsgDbHandler()
+{
+       if(handle != NULL)
+               disconnect();
+
+       if(stmt != NULL)
+               finalizeQuery();
+
+       if(result != NULL)
+               freeTable();
+}
+
+
+MSG_ERROR_T MsgDbHandler::connect()
+{
+       int ret = 0;
+
+       if (handle == NULL)
+       {
+               char strDBName[64];
+
+               memset(strDBName, 0x00, sizeof(strDBName));
+               snprintf(strDBName, 64, "%s", MSGFW_DB_NAME);
+
+               ret = db_util_open(strDBName, &handle, DB_UTIL_REGISTER_HOOK_METHOD);
+
+               if (ret == SQLITE_OK)
+               {
+                       MSG_DEBUG("DB Connect Success : [%p]", handle);
+                       return MSG_SUCCESS;
+               }
+               else
+               {
+                       MSG_DEBUG("DB Connect Fail [%d]", ret);
+                       return MSG_ERR_DB_CONNECT;
+               }
+       }
+       else
+       {
+               MSG_DEBUG("DB Connect exist : [%p]", handle);
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgDbHandler::disconnect()
+{
+       int ret = 0;
+
+       if (handle != NULL)
+       {
+               ret = db_util_close(handle);
+
+               if (ret == SQLITE_OK)
+               {
+                       handle = NULL;
+                       MSG_DEBUG("DB Disconnect Success");
+                       return MSG_SUCCESS;
+               }
+               else
+               {
+                       MSG_DEBUG("DB Disconnect Fail [%d]", ret);
+                       return MSG_ERR_DB_DISCONNECT;
+               }
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+bool MsgDbHandler::checkTableExist(const char *pTableName)
+{
+       char strQuery[256];
+       int nRowCnt = 0, nResult = 0;
+
+       /* Formulate the Query */
+       memset(strQuery, 0x00, sizeof(strQuery));
+       snprintf(strQuery, sizeof(strQuery), "select count(name) from sqlite_master where name='%s'", pTableName);
+
+       if (getTable(strQuery, &nRowCnt) != MSG_SUCCESS)
+       {
+               freeTable();
+               return false;
+       }
+
+       nResult = getColumnToInt(1);
+       MSG_DEBUG("Result [%d]", nResult);
+
+       freeTable();
+
+       if (nResult > 0)
+               return true;
+       else
+               return false;
+}
+
+
+MSG_ERROR_T MsgDbHandler::execQuery(const char *pQuery)
+{
+       int ret = 0;
+
+       if (!pQuery)
+               return MSG_ERR_INVALID_PARAMETER;
+
+       if(connect() != MSG_SUCCESS)
+               return MSG_ERR_DB_DISCONNECT;
+
+       ret = sqlite3_exec(handle, pQuery, 0, 0, NULL);
+
+       if (ret == SQLITE_OK)
+       {
+               MSG_DEBUG("Execute Query Success");
+               return MSG_SUCCESS;
+       }
+       else
+       {
+               MSG_DEBUG("Execute Query Fail [%d]", ret);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgDbHandler::getTable(const char *pQuery, int *pRowCnt)
+{
+       int ret = 0;
+
+       *pRowCnt = 0;
+
+       if(connect() != MSG_SUCCESS)
+               return MSG_ERR_DB_DISCONNECT;
+
+
+       ret = sqlite3_get_table(handle, pQuery, &result, pRowCnt, 0, NULL);
+
+       if (ret == SQLITE_OK)
+       {
+               if (*pRowCnt == 0)    // when the no record return 'MSG_ERR_DB_NORECORD'
+               {
+                       MSG_DEBUG("No Query Result");
+                       return MSG_ERR_DB_NORECORD;
+               }
+
+               MSG_DEBUG("Get Table Success");
+               return MSG_SUCCESS;
+       }
+       else
+       {
+               MSG_DEBUG("Get Table Fail [%d]", ret);
+               return MSG_ERR_DB_GETTABLE;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+void MsgDbHandler::freeTable()
+{
+       if (result)
+       {
+               sqlite3_free_table(result);
+               result = NULL;
+       }
+}
+
+
+MSG_ERROR_T MsgDbHandler::bindText(const char *pBindStr, int index)
+{
+       int ret = 0;
+
+       if (pBindStr != NULL)
+               ret = sqlite3_bind_text(stmt, index, pBindStr, (strlen(pBindStr) + sizeof(unsigned char)), SQLITE_STATIC);
+
+       return ret;
+}
+
+
+MSG_ERROR_T MsgDbHandler::bindBlob(const void * pBindBlob, int size, int index)
+{
+       int ret = 0;
+
+       ret = sqlite3_bind_blob(stmt, index, pBindBlob, size, SQLITE_STATIC);
+
+       return ret;
+}
+
+
+MSG_ERROR_T MsgDbHandler::prepareQuery(const char *pQuery)
+{
+       int ret = 0;
+
+       stmt = NULL;
+
+       if(connect() != MSG_SUCCESS)
+               return MSG_ERR_DB_DISCONNECT;
+
+
+       if ((ret = sqlite3_prepare_v2(handle, pQuery, strlen(pQuery), &stmt, NULL)) == SQLITE_OK)
+       {
+               MSG_DEBUG("Prepare Query Success");
+               return MSG_SUCCESS;
+       }
+       else
+       {
+               MSG_DEBUG("Prepare Query Fail [%d]", ret);
+               return MSG_ERR_DB_PREPARE;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgDbHandler::stepQuery()
+{
+       int ret = 0;
+
+       ret = sqlite3_step(stmt);
+
+       if (ret == SQLITE_ROW)
+       {
+               MSG_DEBUG("MsgStepQuery() SQLITE_ROW");
+               return MSG_ERR_DB_ROW;
+       }
+       else if (ret == SQLITE_DONE)
+       {
+               MSG_DEBUG("MsgStepQuery() SQLITE_DONE");
+               return MSG_ERR_DB_DONE;
+       }
+       else
+       {
+               MSG_DEBUG("MsgStepQuery() Fail [%d]", ret);
+               return MSG_ERR_DB_STEP;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+void MsgDbHandler::finalizeQuery()
+{
+       if(stmt != NULL)
+               sqlite3_finalize(stmt);
+       stmt = NULL;
+}
+
+
+int MsgDbHandler::columnInt(int ColumnIndex)
+{
+       return sqlite3_column_int(stmt, ColumnIndex);
+}
+
+
+const unsigned char* MsgDbHandler::columnText(int ColumnIndex)
+{
+       return sqlite3_column_text(stmt, ColumnIndex);
+}
+
+
+const void* MsgDbHandler::columnBlob(int ColumnIndex)
+{
+       return sqlite3_column_blob(stmt, ColumnIndex);
+}
+
+
+MSG_ERROR_T MsgDbHandler::beginTrans()
+{
+       int ret = 0;
+
+       if(connect() != MSG_SUCCESS)
+               return MSG_ERR_DB_DISCONNECT;
+
+
+       ret = sqlite3_exec(handle, "BEGIN deferred;", 0, 0, NULL);
+
+       if (ret == SQLITE_OK)
+       {
+               MSG_DEBUG("Begin Transaction Success");
+               return MSG_SUCCESS;
+       }
+       else
+       {
+               MSG_DEBUG("Begin Transaction Fail [%d]", ret);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgDbHandler::endTrans(bool Success)
+{
+       int ret = 0;
+
+       if(connect() != MSG_SUCCESS)
+               return MSG_ERR_DB_DISCONNECT;
+
+
+       if (Success == true)
+       {
+               ret = sqlite3_exec(handle, "END;", 0, 0, NULL);
+       }
+       else
+       {
+               ret = sqlite3_exec(handle, "rollback", 0, 0, NULL);
+               ret = sqlite3_exec(handle, "END;", 0, 0, NULL);
+       }
+
+       if (ret == SQLITE_OK)
+       {
+               MSG_DEBUG("End Transaction Success");
+               return MSG_SUCCESS;
+       }
+       else
+       {
+               MSG_DEBUG("End Transaction Fail [%d]", ret);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+int MsgDbHandler::getColumnToInt(int RowIndex)
+{
+       char* pTemp = result[RowIndex];
+
+       int nTemp = 0;
+
+       if (pTemp == NULL)
+       {
+               MSG_DEBUG("NULL");
+               return nTemp;
+       }
+
+       nTemp = (int)strtol(pTemp, (char**)NULL, 10);
+
+       return nTemp;
+}
+
+
+char MsgDbHandler::getColumnToChar(int RowIndex)
+{
+       char* pTemp = result[RowIndex];
+
+       if (pTemp == NULL)
+       {
+               MSG_DEBUG("NULL");
+               return '\0';
+       }
+
+       return *pTemp;
+}
+
+
+void MsgDbHandler::getColumnToString(int RowIndex, int Length, char *pString)
+{
+       char* pTemp = result[RowIndex];
+
+       if (pTemp == NULL)
+       {
+               MSG_DEBUG("NULL");
+               return;
+       }
+
+       strncpy(pString, pTemp, Length);
+}
+
+
+MSG_ERROR_T MsgDbHandler::getRowId(const char *pTableName, unsigned int *pRowId)
+{
+       int ret = 0, nRowId = 0, nRowCnt = 0;
+       char strQuery[256];
+
+       if (pTableName == NULL || pRowId == NULL)
+               return MSG_ERR_INVALID_PARAMETER;
+
+       MSG_DEBUG("Table Name [%s]", pTableName);
+
+       memset(strQuery, 0x00, sizeof(strQuery));
+       snprintf(strQuery, sizeof(strQuery), "select max(rowid) from %s", pTableName);
+
+       ret = getTable(strQuery, &nRowCnt);
+
+       if (ret == SQLITE_OK)
+       {
+               nRowId = getColumnToInt(1);
+
+               if ((nRowCnt <= 1) && (nRowId == 0))
+                       *pRowId = 1;
+               else
+                       *pRowId = nRowId + 1;
+       }
+       else
+       {
+               MSG_DEBUG("MsgGetRowId failed");
+               *pRowId = 0;
+               freeTable();
+               return MSG_ERR_DB_GETTABLE;
+       }
+
+       freeTable();
+
+       MSG_DEBUG("Row ID [%d]", *pRowId);
+
+       return MSG_SUCCESS;
+}
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+void MsgReleaseMemoryDB()
+{
+       int freeSize = 0;
+
+       freeSize = sqlite3_release_memory(-1);
+
+       MSG_DEBUG("freed memory size (bytes) : [%d]", freeSize);
+}
+
diff --git a/utils/MsgUtilFile.cpp b/utils/MsgUtilFile.cpp
new file mode 100755 (executable)
index 0000000..08eec9a
--- /dev/null
@@ -0,0 +1,910 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include <stdio.h>
+#include <stddef.h>
+#include <time.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <dirent.h>
+#include <unistd.h>    //sync()
+
+#include "MsgStorageTypes.h"
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MsgUtilFile.h"
+#include "MsgMmsTypes.h"
+#include "MsgInternalTypes.h"
+#include "MsgDrmWrapper.h"
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+// File operation wrappers
+FILE *MsgOpenFile(const char *filepath, const char *opt)
+{
+       if (!filepath || !opt) {
+               MSG_FATAL("Null parameter");
+               return NULL;
+       }
+
+       MSG_DEBUG("[FILE] filepath : [%s], opt [%s]", filepath, opt);
+
+       FILE *pFile = NULL;
+
+       try {
+               pFile = fopen(filepath, opt);
+               MSG_DEBUG("[FILE] pFile [%p]", pFile);
+       } catch (exception &e) {
+               MSG_FATAL("%s", e.what());
+               return NULL;
+       }
+
+       return pFile;
+}
+
+void MsgCloseFile(FILE *pFile)
+{
+       if (!pFile) {
+               MSG_FATAL("NULL parameter");
+               return;
+       }
+
+       MSG_DEBUG("[FILE] pFile [%p]", pFile);
+
+       try {
+               fclose(pFile);
+       } catch (exception &e) {
+               MSG_FATAL("%s", e.what());
+       }
+}
+
+int MsgFseek(FILE *pFile, long int offset, int origin)
+{
+       if (!pFile) {
+               MSG_FATAL("pFile NULL");
+               return -1;
+       }
+
+       int ret = -1;
+
+       MSG_DEBUG("[FILE] pFile [%p], offset [%d], origin [%d]", pFile, offset, origin);
+
+       try {
+               ret = fseek(pFile, offset, origin);             // return 0, if success.
+       } catch (exception &e) {
+               MSG_FATAL("%s", e.what());
+               return -1;
+       }
+
+       return ret;
+}
+
+size_t MsgWriteFile(const char *pData, size_t size, size_t count, FILE *pFile)
+{
+       if (!pData || !pFile) {
+               MSG_FATAL("pData or pFile NULL");
+               return 0;
+       }
+
+       size_t nWrite = 0;
+
+       MSG_DEBUG("[FILE] pData [%p], size [%d], count [%d], pFile [%p]", pData, size, count, pFile);
+
+       try {
+               nWrite = fwrite(pData, size, count, pFile);
+       } catch (exception &e) {
+               MSG_FATAL("%s", e.what());
+       }
+
+       return nWrite;
+}
+
+size_t MsgReadFile(void *pData, size_t size, size_t count, FILE *pFile)
+{
+       if (!pData || !pFile) {
+               MSG_FATAL("pData or pFile NULL");
+               return 0;
+       }
+
+       size_t nRead = 0;
+
+       try {
+               nRead = fread(pData, size, count, pFile);
+       } catch (exception &e) {
+               MSG_FATAL("%s", e.what());
+       }
+
+       return nRead;
+}
+
+long int MsgFtell(FILE *pFile)
+{
+       if (!pFile) {
+               MSG_FATAL("pFile NULL");
+               return -1L;
+       }
+
+       long int ret = -1L; // -1L return if error occured.
+
+       try {
+               ret = ftell(pFile);
+       } catch (exception &e) {
+               MSG_FATAL("%s", e.what());
+       }
+
+       return ret;
+}
+
+int MsgFflush(FILE *pFile)
+{
+       if(!pFile) {
+               MSG_FATAL("pFile NULL");
+               return -1;
+       }
+
+       int ret = -1;
+
+       try {
+               ret = fflush(pFile);            // return 0 if success
+       } catch (exception &e) {
+               MSG_FATAL("%s", e.what());
+       }
+
+       return ret;
+}
+
+int MsgFsync(FILE *pFile)
+{
+       if(!pFile) {
+               MSG_FATAL("pFile NULL");
+               return -1;
+       }
+
+       int ret = -1;
+
+       try {
+               ret = fdatasync(pFile->_fileno);        // return 0 if success
+       } catch (exception &e) {
+               MSG_FATAL("%s", e.what());
+       }
+
+       return ret;
+}
+
+bool MsgCreateFileName(char *pFileName)
+{
+       if (pFileName == NULL) {
+               MSG_DEBUG("[ERROR] pFileName is NULL");
+               return false;
+       }
+
+       struct timespec ts;
+
+       try {
+               if (clock_gettime(CLOCK_REALTIME, &ts) < 0) {
+                       MSG_DEBUG("clock_gettime() error: %s", strerror(errno));
+                       return false;
+               }
+
+               // Create Random Number
+               srandom((unsigned int)ts.tv_nsec);
+
+               MSG_DEBUG("ts.tv_nsec : %d", ts.tv_nsec);
+
+               // between 1 - 1000000000
+               snprintf(pFileName, MSG_FILENAME_LEN_MAX, "MSG_%lu.DATA", random()%1000000000+1);
+       } catch (exception& e) {
+               MSG_FATAL("%s", e.what());
+               return false;
+       }
+
+       return true;
+}
+
+
+bool MsgOpenAndReadFile(const char *pFileName, char **ppData, int *pDataSize)
+{
+       MSG_DEBUG("MsgOpenAndReadFile");
+
+       FILE *pFile = NULL;
+
+       char fullPath[MAX_FULL_PATH_SIZE] = {0};
+
+       snprintf(fullPath, MAX_FULL_PATH_SIZE, MSG_IPC_DATA_PATH"%s", pFileName);
+       MSG_DEBUG("open file name: %s", fullPath);
+
+
+       pFile = MsgOpenFile(fullPath, "rb");
+
+       if (pFile == NULL) {
+               MSG_DEBUG("File Open Error: %s", strerror(errno));
+               return false;
+       }
+
+       if (MsgFseek(pFile, 0L, SEEK_END) < 0) {
+               MsgCloseFile(pFile);
+               MSG_DEBUG("File Read Error: %s", strerror(errno));
+               return false;
+       }
+
+       int FileSize = MsgFtell(pFile);
+
+       if (FileSize <= 0) {
+               MSG_DEBUG("Filesize is error : %d", FileSize);
+               *pDataSize = 0;
+               MsgCloseFile(pFile);
+               return false;
+       }
+
+       *ppData = new char[FileSize];
+
+       if (MsgFseek(pFile, 0L, SEEK_SET) < 0) {
+               MsgCloseFile(pFile);
+               MSG_DEBUG("File seek Error: %s", strerror(errno));
+               return false;
+       }
+
+       if (MsgReadFile(*ppData, sizeof(char), FileSize, pFile) != (size_t)FileSize) {
+               MsgCloseFile(pFile);
+               MSG_DEBUG("File Read Error: %s", strerror(errno));
+               return false;
+       }
+
+       *pDataSize = FileSize;
+
+       MsgCloseFile(pFile);
+
+       return true;
+}
+
+
+bool MsgReadFileForDecode(FILE *pFile, char *pBuf, int length, int *nSize)
+{
+       MSG_BEGIN();
+
+       if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) {
+               MSG_DEBUG("File Seek Error: %s", strerror(errno));
+               MsgCloseFile(pFile);
+               return false;
+       }
+
+       *nSize = MsgReadFile(pBuf, sizeof(char), length, pFile);
+
+       MSG_END();
+       return true;
+}
+
+
+bool MsgWriteIpcFile(const char *pFileName, const char *pData, int DataSize)
+{
+       if (!pFileName) {
+               MSG_DEBUG("NULL parameter, pFileName [%p], pData [%p]", pFileName, pData);
+               return false;
+       }
+
+       char fullPath[MAX_FULL_PATH_SIZE] = {0};
+
+       snprintf(fullPath, MAX_FULL_PATH_SIZE, MSG_IPC_DATA_PATH"%s", pFileName);
+
+       FILE *pFile = MsgOpenFile(fullPath, "wb+");
+
+       if (pFile == NULL) {
+               MSG_DEBUG("File Open Error: %s", strerror(errno));
+               return false;
+       }
+
+       if (MsgFseek(pFile, 0L, SEEK_SET) < 0) {
+               MsgCloseFile(pFile);
+               MSG_DEBUG("File Seek Error: %s", strerror(errno));
+               return false;
+       }
+
+       if (MsgWriteFile(pData, sizeof(char), DataSize, pFile) != (size_t)DataSize) {
+               MsgCloseFile(pFile);
+               MSG_DEBUG("File Write Error: %s", strerror(errno));
+               return false;
+       }
+
+       MsgFflush(pFile);
+       MsgCloseFile(pFile);
+
+       if (chmod(fullPath, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP ) != 0) {
+               MSG_DEBUG("File chmod Error: %s", strerror(errno));
+       }
+
+       if (chown(fullPath, 0, 6502 ) != 0) {
+               MSG_DEBUG("File chown Error: %s", strerror(errno));
+       }
+
+       return true;
+}
+
+int MsgReadSmilFile(const char *pFileName, char **ppData)
+{
+       if (!pFileName) {
+               MSG_DEBUG("pFileName is NULL");
+               return -1;
+       }
+
+       int     nSize = 0;
+       char fullPath[MAX_FULL_PATH_SIZE] = {0};
+
+       snprintf(fullPath, MAX_FULL_PATH_SIZE, MSG_SMIL_FILE_PATH"%s", pFileName);
+
+       MSG_DEBUG("open file name: %s", fullPath);
+
+       FILE *pFile = MsgOpenFile(fullPath, "rb");
+
+       if (pFile == NULL) {
+               MSG_DEBUG("File Open Error: %s", strerror(errno));
+               return -1;
+       }
+
+       if (MsgFseek(pFile, 0L, SEEK_END) < 0) {
+               MsgCloseFile(pFile);
+               MSG_DEBUG("File Seek Error: %s", strerror(errno));
+               return -1;
+       }
+
+       int FileSize = MsgFtell(pFile);
+
+       if (FileSize <= 0) {
+               MSG_DEBUG("Filesize is error : %d", FileSize);
+               MsgCloseFile(pFile);
+               return FileSize;
+       }
+
+       *ppData = new char[FileSize + 1];
+
+       if (MsgFseek(pFile, 0L, SEEK_SET) < 0) {
+               MsgCloseFile(pFile);
+               MSG_DEBUG("File Sead Error: %s", strerror(errno));
+               return -1;
+       }
+
+       if (MsgReadFile(*ppData, sizeof(char), FileSize, pFile) != (size_t)FileSize) {
+               MsgCloseFile(pFile);
+               MSG_DEBUG("File Read Error: %s", strerror(errno));
+               return -1;
+       }
+
+       ppData[FileSize] = '\0';
+
+       nSize = FileSize;
+
+       MsgCloseFile(pFile);
+
+       return nSize;
+}
+
+
+bool MsgWriteSmilFile(const char *pFilePath,char *pData, int DataSize)
+{
+       if(!pFilePath) {
+               MSG_DEBUG("pFilePath is NULL");
+               return false;
+       }
+
+       if (mkdir(MSG_SMIL_FILE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
+               if (errno == EEXIST) {
+                       MSG_DEBUG("The %s already exists", MSG_SMIL_FILE_PATH);
+               } else {
+                       MSG_DEBUG("Error while mkdir %s", MSG_SMIL_FILE_PATH);
+               }
+       }
+
+       FILE *pFile = MsgOpenFile(pFilePath, "wb+");
+
+       if (pFile == NULL) {
+               MSG_DEBUG("File Open Error: %s", strerror(errno));
+               return false;
+       }
+
+       if (MsgFseek(pFile, 0L, SEEK_SET) < 0) {
+               MsgCloseFile(pFile);
+               MSG_DEBUG("File Seek Error: %s", strerror(errno));
+               return false;
+       }
+
+       if (MsgWriteFile(pData, sizeof(char), DataSize, pFile) != (size_t)DataSize) {
+               MsgCloseFile(pFile);
+               MSG_DEBUG("File Write Error: %s", strerror(errno));
+               return false;
+       }
+
+       MsgFflush(pFile);
+       MsgCloseFile(pFile);
+
+       return true;
+}
+
+
+void MsgDeleteFile(const char *pFileName)
+{
+       if (!pFileName) {
+               MSG_FATAL("pFileName is NULL");
+               return;
+       }
+
+       if (strlen(pFileName) == 0) {
+               MSG_FATAL("pFileName has zero length");
+               return;
+       }
+
+       char fullPath[MAX_FULL_PATH_SIZE] = {0};
+
+       try {
+               snprintf(fullPath, MAX_FULL_PATH_SIZE, MSG_IPC_DATA_PATH"%s", pFileName);
+
+               MSG_DEBUG("%s", fullPath);
+
+               if (remove(fullPath) != 0)
+                       MSG_FATAL("File Delete Error [%s]: %s", fullPath, strerror(errno));
+       } catch (exception &e) {
+               MSG_FATAL ("%s", e.what());
+       }
+
+}
+
+
+void MsgDeleteSmilFile(const char *pFileName)
+{
+       if (!pFileName ) {
+               MSG_FATAL("pFileName NULL");
+               return;
+       }
+
+       try {
+               char fullPath[MAX_FULL_PATH_SIZE] = {0};
+
+               snprintf(fullPath, MAX_FULL_PATH_SIZE, MSG_SMIL_FILE_PATH"%s", pFileName);
+
+               if (remove(fullPath) != 0)
+                       MSG_FATAL("File Delete Error [%s]: %s", fullPath, strerror(errno));
+       } catch (exception &e) {
+               MSG_FATAL("%s", e.what());
+       }
+}
+
+
+bool MsgGetFileSize(const char *pFilePath, int *nSize)
+{
+       if (!pFilePath) {
+               MSG_FATAL("pFileName NULL");
+               return false;
+       }
+
+       FILE *pFile = NULL;
+
+       pFile = MsgOpenFile(pFilePath, "rb");
+
+       if (!pFile) {
+               MSG_DEBUG("File Open error: %s", strerror(errno));
+               return false;
+       }
+
+       if (MsgFseek(pFile, 0L, SEEK_END) < 0) {
+               MsgCloseFile(pFile);
+               MSG_FATAL("File Read Error: %s", strerror(errno));
+               return false;
+       }
+
+       *nSize = MsgFtell(pFile);
+
+       MsgCloseFile(pFile);
+
+       return true;
+}
+
+
+FILE *MsgOpenMMSFile(char *pFileName)
+{
+       int len;
+
+       if (!pFileName) {
+               MSG_DEBUG("pFileName NULL: %s", strerror(errno));
+               return NULL;
+       }
+
+       len = strlen(pFileName);
+
+       for (int i = 0; i < len; i++) {
+               switch (pFileName[i]) {
+               case '*':
+                       pFileName[i] = '-';
+                       break;
+               }
+       }
+
+       MSG_DEBUG("pFileName = %s", pFileName);
+
+       char fullPath[MAX_FULL_PATH_SIZE+1] = {0};
+
+       snprintf(fullPath, MAX_FULL_PATH_SIZE+1, "%s.mms", pFileName);
+
+       FILE *pFile = MsgOpenFile(fullPath, "wb+");
+
+       if (pFile == NULL) {
+               MSG_FATAL("File Open Error: %s", strerror(errno));
+               return NULL;
+       }
+
+       if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) {
+               MsgCloseFile(pFile);
+               MSG_DEBUG("File Read Error: %s", strerror(errno));
+               return NULL;
+       }
+
+       return pFile;
+}
+
+
+bool MsgWriteDataFromEncodeBuffer(FILE *pFile, char *pInBuffer, int *pPtr, int maxLen, int *pOffset )
+{
+       if (!pFile || !pPtr || !pInBuffer || !pOffset) {
+               MSG_FATAL(" NULL parameter passed");
+               return false;
+       }
+
+       MSG_DEBUG("MsgWriteDataFromEncodeBuffer:");
+       MSG_DEBUG("pInBuffer %x", pInBuffer);
+       MSG_DEBUG("pPtr %d",  (*pPtr));
+       MSG_DEBUG("before to fwite %x", pFile);
+
+       if (MsgWriteFile(pInBuffer, sizeof(char), (*pPtr), pFile) != (size_t)(*pPtr)) {
+               MSG_FATAL("MsgWriteFile failed");
+               return false;
+       }
+
+       MSG_DEBUG("after to fwite \n");
+
+       MsgFflush(pFile);
+
+       memset( pInBuffer, 0, maxLen );
+
+       *pPtr = 0;
+
+       if (MsgFseek(pFile, 0L, SEEK_END) < 0) {
+               MSG_FATAL("MsgFseek failed");
+               return false;
+       }
+
+       *pOffset = MsgFtell(pFile);
+
+       if (*pOffset == -1L) {
+               MSG_FATAL("MsgFtell failed");
+               return false;
+       }
+
+       return true;
+}
+
+
+bool MsgOpenCreateAndOverwriteFile(char *pFullPath, char *pBuff, int TotalLength)
+{
+       FILE *pFile = NULL ;
+       mode_t file_mode;
+
+       file_mode = (S_IRUSR | S_IWUSR);
+
+       if ((pFile = MsgOpenFile(pFullPath, "wb+")) == NULL) {
+               MSG_FATAL("MsgOpenFile errer");
+               return false;
+       }
+
+       if (MsgWriteFile(pBuff, sizeof(char), TotalLength, pFile) != (size_t)TotalLength) {
+               MsgCloseFile( pFile );
+               return false;
+       }
+
+       MsgFsync(pFile);        //file is written to device immediately, it prevents missing file data from unexpected power off
+       MsgFflush(pFile);
+       MsgCloseFile(pFile);
+
+       if (chmod(pFullPath, file_mode) < 0)
+               MSG_FATAL("File chmod Error: %s", strerror(errno));
+
+       return true;
+}
+
+
+char *MsgOpenAndReadMmsFile( const char *szFilePath, int offset, int size, int *npSize )
+{
+       FILE *pFile = NULL;
+       char *pData = NULL;
+       int     readSize = 0;
+
+       if (szFilePath == NULL) {
+               MSG_DEBUG("MsgOpenAndReadMmsFile: [ERROR] szFilePath id NULL");
+               goto __CATCH;
+       }
+
+       *npSize = 0;
+
+       pFile = MsgOpenFile( szFilePath, "rb" );
+
+       if (pFile == NULL) {
+               MSG_DEBUG("MsgOpenAndReadMmsFile: [ERROR] Can't open filepath", strerror(errno));
+               goto __CATCH;
+       }
+
+       if( size == -1 ) {
+               if (MsgGetFileSize(szFilePath, & readSize) == false) {
+                       MSG_DEBUG("MsgGetFileSize: failed");
+                       goto __CATCH;
+               }
+       } else {
+               readSize = size;
+       }
+
+       if (readSize > FM_READ_WRITE_BUFFER_MAX) {
+               MSG_DEBUG("MsgOpenAndReadMmsFile: File size tried to read too big");
+               goto __CATCH;
+       }
+
+       pData = (char *)malloc(readSize + 1);
+       if ( NULL == pData ) {
+               MSG_DEBUG( "MsgOpenAndReadMmsFile: [ERROR] pData MemAlloc Fail", strerror(errno) );
+               goto __CATCH;
+       }
+       memset( pData, 0, readSize + 1 );
+
+       if (MsgFseek( pFile, offset, SEEK_SET) < 0) {
+               MSG_DEBUG( "MsgOpenAndReadMmsFile: [ERROR] FmSeekFile failed", strerror(errno) );
+               goto __CATCH;
+       }
+
+       *npSize = MsgReadFile(pData, sizeof(char), readSize, pFile);
+
+       MsgCloseFile(pFile);
+
+       pFile = NULL;
+
+       *(pData + (*npSize)) = '\0';
+
+       return pData;
+
+__CATCH:
+
+       if (pData) {
+               free( pData );
+               pData = NULL;
+       }
+
+       *npSize = 0;
+
+       if (pFile != NULL) {
+               MsgCloseFile( pFile );
+               pFile = NULL;
+       }
+
+       return NULL;
+}
+
+// it is equivalent to "rm -rf pDirPath"
+int MsgRmRf(char *pDirPath)
+{
+       struct dirent *d;
+       DIR *dir;
+
+       dir = opendir(pDirPath);
+
+       if (dir == NULL) {
+               MSG_FATAL("error opendir: %s", strerror(errno));
+               return -1;
+       }
+
+       int size = strlen(pDirPath) + 256;
+
+       char *path = (char*)malloc(size);
+
+       if (path == NULL) {
+               MSG_DEBUG("path is NULL");
+               return -1;
+       }
+
+       bzero(path, size);
+
+       while ((d = readdir(dir)) != NULL) {
+               if (d->d_type == DT_DIR) {
+                       snprintf(path, size, "%s/%s", pDirPath, d->d_name);
+
+                       if ((strcmp(".", d->d_name) == 0) || (strcmp("..", d->d_name) == 0))
+                               continue;
+
+                       MsgRmRf(path);
+
+                       if (rmdir(path) != 0) {
+
+                               if (path != NULL)
+                                       free(path);
+
+                               closedir(dir);
+
+                               MSG_FATAL("error rmdir: %s", strerror(errno));
+
+                               return -1;
+                       }
+               } else {
+                       snprintf(path, size, "%s/%s", pDirPath, d->d_name);
+
+                       if (MsgDrmIsDrmFile(path))
+                               MsgDrmUnregisterFile(path);
+
+                       if (remove(path) != 0) {
+
+                               if (path != NULL)
+                                       free(path);
+
+                               closedir(dir);
+
+                               MSG_FATAL("error remove: %s", strerror(errno));
+
+                               return -1;
+                       }
+               }
+       }
+
+       closedir(dir);
+
+       if (path != NULL)
+               free(path);
+
+       return 0;
+}
+
+
+int MsgGetFileSize(const char *pFileName)
+{
+       struct stat file_stat;
+
+       if (lstat(pFileName, &file_stat)) {
+               MSG_FATAL("error lstat: %s", strerror(errno));
+               return -1;
+       }
+
+       return file_stat.st_size;
+}
+
+
+// it is equivalent to "du dir_path"
+unsigned int MsgDu(const char *pDirPath)
+{
+       struct dirent *d;
+       DIR *dir;
+
+       dir = opendir(pDirPath);
+
+       if (dir == NULL) {
+               MSG_FATAL("error opendir: %s", strerror(errno));
+               return -1;
+       }
+
+       int size = strlen(pDirPath) + 256;
+       char *path = (char*)malloc(size);
+       bzero(path, size);
+
+       unsigned int totalFileSize = 0;
+
+       while ((d = readdir(dir)) != NULL) {
+               if( d->d_type == DT_DIR) {
+                       snprintf(path, size, "%s/%s", pDirPath, d->d_name);
+
+                       if ((strcmp(".", d->d_name) == 0) || (strcmp("..", d->d_name) == 0))
+                               continue;
+
+                       unsigned int dirSize = MsgDu(path);
+
+                       if (dirSize == 0) {
+                               MSG_FATAL("error MsgDu");
+                               return dirSize;
+                       }
+
+                       totalFileSize += dirSize;
+               } else {
+                       snprintf(path, size, "%s/%s", pDirPath, d->d_name);
+                       int fileSize = MsgGetFileSize(path);
+
+                       if (fileSize < 0) {
+                               MSG_FATAL("error MsgGetFileSize");
+                               return fileSize;
+                       }
+
+                       totalFileSize += fileSize;
+               }
+       }
+
+       closedir(dir);
+
+       free(path);
+
+       return totalFileSize;
+}
+
+
+bool MsgAppendFile(const char *pFilePath, const char *pData, int DataSize)
+{
+       if (!pFilePath) {
+               MSG_FATAL("NULL check error, pFileName %p, pData %p", pFilePath, pData);
+               return false;
+       }
+
+       char fullPath[MAX_FULL_PATH_SIZE] = {0};
+
+       snprintf(fullPath, MAX_FULL_PATH_SIZE, "%s", pFilePath);
+
+       FILE *pFile = MsgOpenFile(fullPath, "a+");
+
+       if (pFile == NULL) {
+               MSG_FATAL("File Open Error: %s", strerror(errno));
+               return false;
+       }
+
+       if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) {
+               MsgCloseFile(pFile);
+               MSG_FATAL("File Sead Error: %s", strerror(errno));
+               return false;
+       }
+
+       if (MsgWriteFile(pData, sizeof(char), DataSize, pFile) != (size_t)DataSize) {
+               MsgCloseFile(pFile);
+               MSG_FATAL("File Write Error: %s", strerror(errno));
+               return false;
+       }
+
+       MsgFsync(pFile);        //file is written to device immediately, it prevents missing file data from unexpected power off
+       MsgFflush(pFile);
+       MsgCloseFile(pFile);
+       return true;
+}
+
+/**
+* Remove temporal Mms folder (/opt/data/msg-service/msgdata/*.dir)
+*/
+
+void MsgMmsInitDir()
+{
+       struct dirent *d = NULL;
+       DIR* dir = NULL;
+
+       dir = opendir(MSG_DATA_PATH);
+
+       if (dir == NULL) {
+               MSG_FATAL("error opendir: %s", strerror(errno));
+               return;
+       }
+
+       while ((d = readdir(dir)) != NULL) {
+               if (d->d_type == DT_DIR) {
+                       if ((strcmp(".", d->d_name) == 0) || (strcmp("..", d->d_name) == 0))
+                               continue;
+
+                       if(strstr(d->d_name, ".dir") != NULL) {
+                               char filePath[MSG_FILEPATH_LEN_MAX] = {0,};
+                               snprintf(filePath, MSG_FILEPATH_LEN_MAX, MSG_DATA_PATH"%s", d->d_name);
+
+                               MsgRmRf(filePath);
+                               rmdir(filePath);
+                       }
+               }
+       }
+
+       closedir(dir);
+}
diff --git a/utils/MsgUtilFunction.cpp b/utils/MsgUtilFunction.cpp
new file mode 100755 (executable)
index 0000000..b54e77a
--- /dev/null
@@ -0,0 +1,689 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgUtilFunction.h"
+
+ /*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+
+// Encoders
+int MsgEncodeCountInfo(MSG_COUNT_INFO_S *pCountInfo, char **ppDest)
+{
+       int dataSize = 0;
+
+       dataSize = sizeof(MSG_COUNT_INFO_S);
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, pCountInfo, dataSize);
+
+       return dataSize;
+}
+
+
+int MsgEncodeRecipientList(MSG_RECIPIENTS_LIST_S *pRecipientList, char **ppDest)
+{
+       int count = 0, dataSize = 0;
+
+       count = pRecipientList->recipientCnt;
+       dataSize = sizeof(int) + (sizeof(MSG_ADDRESS_INFO_S)*count);
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, &count, sizeof(int));
+       p = (void*)((char*)p + sizeof(int));
+
+       for (int i = 0; i < count; i++)
+       {
+               memcpy(p, &(pRecipientList->recipientAddr[i]), sizeof(MSG_ADDRESS_INFO_S));
+               p = (void*)((char*)p + sizeof(MSG_ADDRESS_INFO_S));
+       }
+
+       return dataSize;
+}
+
+
+int MsgEncodeCountByMsgType(int MsgCount, char **ppDest)
+{
+       int dataSize = 0;
+
+       dataSize = sizeof(int);
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, &MsgCount, dataSize);
+
+       return dataSize;
+}
+
+
+int MsgEncodeMsgId(MSG_MESSAGE_ID_T *pMsgId, char **ppDest)
+{
+       int dataSize = 0;
+
+       dataSize = (sizeof(MSG_MESSAGE_ID_T));
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, pMsgId, dataSize);
+
+       return dataSize;
+}
+
+
+int MsgEncodeMsgInfo(MSG_MESSAGE_INFO_S *pMsgInfo, char **ppDest)
+{
+       int dataSize = 0;
+
+       dataSize = sizeof(MSG_MESSAGE_INFO_S);
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+
+       p = (void*)((char*)p + sizeof(MSG_MESSAGE_INFO_S));
+
+       return dataSize;
+}
+
+
+int MsgEncodeMsgInfo(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S* pSendOptInfo, char **ppDest)
+{
+       int dataSize = 0;
+
+       dataSize = (sizeof(MSG_MESSAGE_INFO_S) + sizeof(MSG_SENDINGOPT_INFO_S));
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+
+       p = (void*)((char*)p + sizeof(MSG_MESSAGE_INFO_S));
+
+       memcpy(p, pSendOptInfo, sizeof(MSG_SENDINGOPT_INFO_S));
+
+       return dataSize;
+}
+
+
+int MsgEncodeFolderViewList(MSG_LIST_S *pFolderViewList, char **ppDest)
+{
+       int count = 0, dataSize = 0;
+
+       count = pFolderViewList->nCount;
+
+       dataSize = sizeof(int) + (sizeof(MSG_MESSAGE_S)*count);
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, &count, sizeof(int));
+       p = (void*)((char*)p + sizeof(int));
+
+       for (int i = 0; i < count; i++)
+       {
+               memcpy(p, &(pFolderViewList->msgInfo[i]), sizeof(MSG_MESSAGE_S));
+               p = (void*)((char*)p + sizeof(MSG_MESSAGE_S));
+       }
+
+       return dataSize;
+}
+
+
+int MsgEncodeFolderList(MSG_FOLDER_LIST_S *pFolderList, char **ppDest)
+{
+       int count = 0, dataSize = 0;
+
+       count = pFolderList->nCount;
+       dataSize = sizeof(int) + (sizeof(MSG_FOLDER_INFO_S)*count);
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, &count, sizeof(int));
+       p = (void*)((char*)p + sizeof(int));
+
+       for (int i = 0; i < count; i++)
+       {
+               memcpy(p, &(pFolderList->folderInfo[i]), sizeof(MSG_FOLDER_INFO_S));
+               p = (void*)((char*)p + sizeof(MSG_FOLDER_INFO_S));
+       }
+
+       return dataSize;
+}
+
+
+int MsgEncodeSetting(MSG_SETTING_S *pSetting, char **ppDest)
+{
+       int dataSize = sizeof(MSG_OPTION_TYPE_T);
+
+       switch (pSetting->type)
+       {
+               case MSG_GENERAL_OPT :
+                       dataSize += sizeof(MSG_GENERAL_OPT_S);
+               break;
+               case MSG_SMS_SENDOPT :
+                       dataSize += sizeof(MSG_SMS_SENDOPT_S);
+               break;
+               case MSG_SMSC_LIST :
+                       dataSize += sizeof(MSG_SMSC_LIST_S);
+               break;
+               case MSG_MMS_SENDOPT :
+                       dataSize += sizeof(MSG_MMS_SENDOPT_S);
+               break;
+               case MSG_MMS_RECVOPT :
+                       dataSize += sizeof(MSG_MMS_RECVOPT_S);
+               break;
+               case MSG_MMS_STYLEOPT :
+                       dataSize += sizeof(MSG_MMS_STYLEOPT_S);
+               break;
+               case MSG_PUSHMSG_OPT :
+                       dataSize += sizeof(MSG_PUSHMSG_OPT_S);
+               break;
+               case MSG_CBMSG_OPT :
+                       dataSize += sizeof(MSG_CBMSG_OPT_S);
+               break;
+               case MSG_VOICEMAIL_OPT :
+                       dataSize += sizeof(MSG_VOICEMAIL_OPT_S);
+               break;
+               case MSG_MSGSIZE_OPT :
+                       dataSize += sizeof(MSG_MSGSIZE_OPT_S);
+               break;
+       }
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, pSetting, dataSize);
+
+       return dataSize;
+}
+
+
+int MsgEncodeMsgType(MSG_MESSAGE_TYPE_S *pMsgType, char **ppDest)
+{
+       int dataSize = 0;
+
+       dataSize = (sizeof(MSG_MESSAGE_TYPE_S));
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, pMsgType, dataSize);
+
+       return dataSize;
+}
+
+
+int MsgEncodeThreadViewList(MSG_THREAD_VIEW_LIST_S *pThreadViewList, char **ppDest)
+{
+       int count = 0, dataSize = 0;
+
+       count = pThreadViewList->nCount;
+
+       dataSize = sizeof(int) + (sizeof(MSG_THREAD_VIEW_S)*count);
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, &count, sizeof(int));
+       p = (void*)((char*)p + sizeof(int));
+
+       for (int i = 0; i < count; i++)
+       {
+               memcpy(p, &(pThreadViewList->msgThreadInfo[i]), sizeof(MSG_THREAD_VIEW_S));
+               p = (void*)((char*)p + sizeof(MSG_THREAD_VIEW_S));
+       }
+
+       return dataSize;
+}
+
+
+int MsgEncodeConversationViewList(MSG_LIST_S *pConvViewList, char **ppDest)
+{
+       int count = 0, dataSize = 0;
+
+       count = pConvViewList->nCount;
+
+       dataSize = sizeof(int) + (sizeof(MSG_LIST_S)*count);
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, &count, sizeof(int));
+       p = (void*)((char*)p + sizeof(int));
+
+       for (int i = 0; i < count; i++)
+       {
+               memcpy(p, &(pConvViewList->msgInfo[i]), sizeof(MSG_LIST_S));
+               p = (void*)((char*)p + sizeof(MSG_LIST_S));
+       }
+
+       return dataSize;
+}
+
+
+int MsgEncodeMsgGetContactCount(MSG_THREAD_COUNT_INFO_S *threadCountInfo, char **ppDest)
+{
+       int dataSize = sizeof(int) + sizeof(int) + sizeof(int) + sizeof(int);
+
+       MSG_DEBUG("datasize = [%d] \n", dataSize);
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, &(threadCountInfo->totalCount), sizeof(int));
+       p = (void*)((char*)p + sizeof(int));
+
+       memcpy(p, &(threadCountInfo->unReadCount), sizeof(int));
+       p = (void*)((char*)p + sizeof(int));
+
+       memcpy(p, &(threadCountInfo->mmsMsgCount), sizeof(int));
+       p = (void*)((char*)p + sizeof(int));
+
+       memcpy(p, &(threadCountInfo->smsMsgCount), sizeof(int));
+       p = (void*)((char*)p + sizeof(int));
+
+       return dataSize;
+}
+
+int MsgEncodeMemSize(unsigned int *memsize, char **ppDest)
+{
+       int dataSize = 0;
+
+       dataSize = sizeof(unsigned int);
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, memsize, dataSize);
+
+       return dataSize;
+}
+
+
+int MsgEncodeSyncMLOperationData(int msgId, int extId, char **ppDest)
+{
+       int dataSize = 0;
+
+       dataSize = sizeof(int) + sizeof(int);
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, &msgId, sizeof(int));
+       p = (void*)((char*)p + sizeof(int));
+
+       memcpy(p, &extId, sizeof(int));
+
+       return dataSize;
+}
+
+
+int MsgEncodeStorageChangeData(const MSG_STORAGE_CHANGE_TYPE_T storageChangeType, const MSG_MSGID_LIST_S *pMsgIdList, char **ppDest)
+{
+       int dataSize = 0;
+       int count = 0;
+
+       count = pMsgIdList->nCount;
+
+       dataSize = sizeof(MSG_STORAGE_CHANGE_TYPE_T) + sizeof(int) + (sizeof(MSG_MESSAGE_ID_T)*count);
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, &storageChangeType, sizeof(MSG_STORAGE_CHANGE_TYPE_T));
+       p = (void*)((char*)p + sizeof(MSG_STORAGE_CHANGE_TYPE_T));
+
+       memcpy(p, &count, sizeof(int));
+       p = (void*)((char*)p + sizeof(int));
+
+       for (int i = 0; i < count; i++) {
+               memcpy(p, &(pMsgIdList->msgIdList[i]), sizeof(MSG_MESSAGE_ID_T));
+               p = (void*)((char*)p + sizeof(MSG_MESSAGE_ID_T));
+       }
+
+       return dataSize;
+}
+
+
+int MsgEncodeReportStatus(MSG_REPORT_STATUS_INFO_S* pReportStatus, char **ppDest)
+{
+       int dataSize = 0;
+
+       dataSize = (sizeof(MSG_REPORT_STATUS_INFO_S));
+
+       *ppDest = (char*)new char[dataSize];
+
+       void* p = (void*)*ppDest;
+
+       memcpy(p, pReportStatus, dataSize);
+
+       return dataSize;
+}
+
+
+// Decoders
+void MsgDecodeMsgId(char *pSrc, MSG_MESSAGE_ID_T *pMsgId)
+{
+       memcpy(pMsgId, pSrc, sizeof(MSG_MESSAGE_ID_T));
+}
+
+
+void MsgDecodeCountInfo(char *pSrc, MSG_COUNT_INFO_S *pCountInfo)
+{
+       memcpy(pCountInfo, pSrc, sizeof(MSG_COUNT_INFO_S));
+}
+
+
+void MsgDecodeMemSize(char *pSrc, unsigned int *memsize)
+{
+       memcpy(memsize, pSrc, sizeof(unsigned int));
+}
+
+
+void MsgDecodeMsgInfo(char *pSrc, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S* pSendOptInfo)
+{
+       memcpy(pMsgInfo, pSrc, sizeof(MSG_MESSAGE_INFO_S));
+
+       pSrc = pSrc + sizeof(MSG_MESSAGE_INFO_S);
+
+       memcpy(pSendOptInfo, pSrc, sizeof(MSG_SENDINGOPT_INFO_S));
+}
+
+
+void MsgDecodeFolderViewList(char *pSrc, MSG_LIST_S *pFolderViewList)
+{
+       int count = 0;
+
+       memcpy(&count, pSrc, sizeof(int));
+       pSrc = pSrc + sizeof(int);
+
+       if( count > 0 )
+       {
+               pFolderViewList->nCount = count;
+               pFolderViewList->msgInfo = (msg_message_t*)new char[sizeof(MSG_MESSAGE_S)*count];
+
+               MSG_MESSAGE_S* pInfoTmp = (MSG_MESSAGE_S*)pFolderViewList->msgInfo;
+
+               for (int i = 0; i < count; i++)
+               {
+                       memcpy(pInfoTmp, pSrc, sizeof(MSG_MESSAGE_S));
+                       pSrc = pSrc + sizeof(MSG_MESSAGE_S);
+                       pInfoTmp++;
+               }
+       }
+       else if ( count == 0 )
+       {
+               pFolderViewList->nCount = count;
+               pFolderViewList->msgInfo = NULL;
+       }
+}
+
+
+void MsgDecodeRecipientList(char *pSrc, MSG_RECIPIENTS_LIST_S *pRecipientList)
+{
+       int count = 0;
+
+       memcpy(&count, pSrc, sizeof(int));
+       pSrc = pSrc + sizeof(int);
+
+       pRecipientList->recipientCnt= count;
+       pRecipientList->recipientAddr = (MSG_ADDRESS_INFO_S*)new char[sizeof(MSG_ADDRESS_INFO_S)*count];
+
+       MSG_ADDRESS_INFO_S* pInfoTmp = pRecipientList->recipientAddr;
+
+       for (int i = 0; i < count; i++)
+       {
+               memcpy(pInfoTmp, pSrc, sizeof(MSG_ADDRESS_INFO_S));
+               pSrc = pSrc + sizeof(MSG_ADDRESS_INFO_S);
+               pInfoTmp++;
+       }
+}
+
+
+void MsgDecodeFolderList(char *pSrc, MSG_FOLDER_LIST_S *pFolderList)
+{
+       int count = 0;
+
+       memcpy(&count, pSrc, sizeof(int));
+       pSrc = pSrc + sizeof(int);
+
+       pFolderList->nCount = count;
+       pFolderList->folderInfo = (MSG_FOLDER_INFO_S*)new char[sizeof(MSG_FOLDER_INFO_S)*count];
+
+       MSG_FOLDER_INFO_S* pInfoTmp = pFolderList->folderInfo;
+
+       for (int i = 0; i < count; i++)
+       {
+               memcpy(pInfoTmp, pSrc, sizeof(MSG_FOLDER_INFO_S));
+               pSrc = pSrc + sizeof(MSG_FOLDER_INFO_S);
+               pInfoTmp++;
+       }
+}
+
+
+void MsgDecodeSetting(char *pSrc, MSG_SETTING_S *pSetting)
+{
+       int dataSize = sizeof(MSG_OPTION_TYPE_T);
+
+       switch (pSetting->type)
+       {
+               case MSG_GENERAL_OPT :
+                       dataSize += sizeof(MSG_GENERAL_OPT_S);
+               break;
+               case MSG_SMS_SENDOPT :
+                       dataSize += sizeof(MSG_SMS_SENDOPT_S);
+               break;
+               case MSG_SMSC_LIST :
+                       dataSize += sizeof(MSG_SMSC_LIST_S);
+               break;
+               case MSG_MMS_SENDOPT :
+                       dataSize += sizeof(MSG_MMS_SENDOPT_S);
+               break;
+               case MSG_MMS_RECVOPT :
+                       dataSize += sizeof(MSG_MMS_RECVOPT_S);
+               break;
+               case MSG_MMS_STYLEOPT :
+                       dataSize += sizeof(MSG_MMS_STYLEOPT_S);
+               break;
+               case MSG_PUSHMSG_OPT :
+                       dataSize += sizeof(MSG_PUSHMSG_OPT_S);
+               break;
+               case MSG_CBMSG_OPT :
+                       dataSize += sizeof(MSG_CBMSG_OPT_S);
+               break;
+               case MSG_VOICEMAIL_OPT :
+                       dataSize += sizeof(MSG_VOICEMAIL_OPT_S);
+               break;
+               case MSG_MSGSIZE_OPT :
+                       dataSize += sizeof(MSG_MSGSIZE_OPT_S);
+               break;
+       }
+
+       memcpy(pSetting, pSrc, dataSize);
+}
+
+
+void MsgDecodeMsgType(char *pSrc, MSG_MESSAGE_TYPE_S* pMsgType)
+{
+       memcpy(pMsgType, pSrc, sizeof(MSG_MESSAGE_TYPE_S));
+}
+
+
+void MsgDecodeThreadViewList(char *pSrc, MSG_THREAD_VIEW_LIST_S *pThreadViewList)
+{
+       int count = 0;
+
+       memcpy(&count, pSrc, sizeof(int));
+       pSrc = pSrc + sizeof(int);
+
+       if (count > 0)
+       {
+               pThreadViewList->nCount = count;
+               pThreadViewList->msgThreadInfo = (msg_thread_view_t*)new char[sizeof(MSG_THREAD_VIEW_S)*count];
+
+               MSG_THREAD_VIEW_S* pInfoTmp = (MSG_THREAD_VIEW_S*)pThreadViewList->msgThreadInfo;
+
+               for (int i = 0; i < count; i++)
+               {
+                       memcpy(pInfoTmp, pSrc, sizeof(MSG_THREAD_VIEW_S));
+                       pSrc = pSrc + sizeof(MSG_THREAD_VIEW_S);
+                       pInfoTmp++;
+               }
+       }
+       else if (count == 0)
+       {
+               pThreadViewList->nCount = count;
+               pThreadViewList->msgThreadInfo = NULL;
+       }
+}
+
+
+void MsgDecodeConversationViewList(char *pSrc, MSG_LIST_S *pConvViewList)
+{
+       int count = 0;
+
+       memcpy(&count, pSrc, sizeof(int));
+       pSrc = pSrc + sizeof(int);
+
+       if (count > 0)
+       {
+               pConvViewList->nCount = count;
+               pConvViewList->msgInfo = (msg_message_t*)new char[sizeof(MSG_MESSAGE_S)*count];
+
+               MSG_MESSAGE_S* pInfoTmp = (MSG_MESSAGE_S*)pConvViewList->msgInfo;
+
+               for (int i = 0; i < count; i++)
+               {
+                       memcpy(pInfoTmp, pSrc, sizeof(MSG_MESSAGE_S));
+                       pSrc = pSrc + sizeof(MSG_MESSAGE_S);
+                       pInfoTmp++;
+               }
+       }
+       else if (count == 0)
+       {
+               pConvViewList->nCount = count;
+               pConvViewList->msgInfo = NULL;
+       }
+}
+
+
+void   MsgDecodeContactCount(char *pSrc,  MSG_THREAD_COUNT_INFO_S *pMsgThreadCountList)
+{
+       int count = 0;
+
+       if(pSrc == NULL)
+               return;
+
+       memcpy(&count, pSrc, sizeof(int));
+       pSrc = pSrc + sizeof(int);
+       pMsgThreadCountList->totalCount = count;
+
+
+       memcpy(&count, pSrc, sizeof(int));
+       pSrc = pSrc + sizeof(int);
+       pMsgThreadCountList->unReadCount        = count;
+
+
+       memcpy(&count, pSrc, sizeof(int));
+       pSrc = pSrc + sizeof(int);
+       pMsgThreadCountList->mmsMsgCount        = count;
+
+
+       memcpy(&count, pSrc, sizeof(int));
+       pSrc = pSrc + sizeof(int);
+       pMsgThreadCountList->smsMsgCount        = count;
+
+
+       return;
+}
+
+
+void   MsgDecodeReportStatus(char *pSrc,  MSG_REPORT_STATUS_INFO_S *pReportStatus)
+{
+       int count = 0;
+
+       if(pSrc == NULL)
+               return;
+
+       memcpy(&count, pSrc, sizeof(MSG_DELIVERY_REPORT_STATUS_T));
+       pSrc = pSrc + sizeof(MSG_DELIVERY_REPORT_STATUS_T);
+       pReportStatus->deliveryStatus = count;
+
+
+       memcpy(&count, pSrc, sizeof(time_t));
+       pSrc = pSrc + sizeof(time_t);
+       pReportStatus->deliveryStatusTime = count;
+
+
+       memcpy(&count, pSrc, sizeof(MSG_READ_REPORT_STATUS_T));
+       pSrc = pSrc + sizeof(MSG_READ_REPORT_STATUS_T);
+       pReportStatus->readStatus = count;
+
+
+       memcpy(&count, pSrc, sizeof(time_t));
+       pSrc = pSrc + sizeof(time_t);
+       pReportStatus->readStatusTime = count;
+
+
+       return;
+}
+
+
+// Event Encoder
+int MsgMakeEvent(const void *pData, int DataSize, MSG_EVENT_TYPE_T MsgEvent, MSG_ERROR_T MsgError, void **ppEvent)
+{
+       MSG_EVENT_S* pMsgEvent = NULL;
+
+       *ppEvent = (MSG_EVENT_S*)new char[sizeof(MSG_EVENT_S) + DataSize];
+
+       pMsgEvent = (MSG_EVENT_S*)*ppEvent;
+
+       pMsgEvent->eventType = MsgEvent;
+       pMsgEvent->result = MsgError;
+
+       MSG_DEBUG("eventType [%d : %s]", pMsgEvent->eventType, MsgDbgEvtStr(pMsgEvent->eventType));
+       MSG_DEBUG("result [%d]", pMsgEvent->result);
+
+       if (DataSize > 0)
+               memcpy((void*)pMsgEvent->data, pData, DataSize);
+
+       return (sizeof(MSG_EVENT_S) + DataSize);
+}
diff --git a/utils/MsgUtilStorage.cpp b/utils/MsgUtilStorage.cpp
new file mode 100755 (executable)
index 0000000..c706151
--- /dev/null
@@ -0,0 +1,995 @@
+ /*
+  * Copyright 2012  Samsung Electronics Co., Ltd
+  *
+  * Licensed under the Flora License, Version 1.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *    http://www.tizenopensource.org/license
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgContact.h"
+#include "MsgCppTypes.h"
+#include "MsgGconfWrapper.h"
+#include "MsgNotificationWrapper.h"
+#include "MsgUtilStorage.h"
+
+#include <sys/stat.h>
+#include <sys/vfs.h>
+
+
+static int msgCntLimit[MSG_COUNT_LIMIT_MAILBOX_TYPE_MAX][MSG_COUNT_LIMIT_MSG_TYPE_MAX] = {{1500, 500, 0, 50, 50}, {50, 50, 0, 0, 0}, {1000, 250, 0, 0, 0}, {50, 50, 0, 0, 0}, {0, 0, 200, 0, 0}};
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+unsigned int MsgStoAddMessageTable(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsgInfo, unsigned int AddrId)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       unsigned int msgId = 0;
+
+       err = pDbHandle->getRowId(MSGFW_MESSAGE_TABLE_NAME, &msgId);
+
+       if (err != MSG_SUCCESS)
+       {
+               return 0;
+       }
+
+       int fileSize = 0;
+
+       char* pFileData = NULL;
+       AutoPtr<char> buf(&pFileData);
+
+       // Get File Data
+       if (pMsgInfo->bTextSms == false)
+       {
+               if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false)
+                       return 0;
+
+               MSG_DEBUG("file size [%d]", fileSize);
+       }
+
+       // Add Message
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d, %d, %d, %ld, %d, %d, %d, %d, %d, %d, %ld, %d, ?, ?, ?, ?, %d, 0, %d, 0, 0);",
+                               MSGFW_MESSAGE_TABLE_NAME, msgId, AddrId, pMsgInfo->folderId, msgId, pMsgInfo->storageId,
+                               pMsgInfo->msgType.mainType, pMsgInfo->msgType.subType, pMsgInfo->displayTime, pMsgInfo->dataSize,
+                               pMsgInfo->networkStatus, pMsgInfo->bRead, pMsgInfo->bProtected, pMsgInfo->priority,
+                               pMsgInfo->direction, pMsgInfo->scheduledTime, pMsgInfo->bBackup, MSG_DELIVERY_REPORT_NONE, MSG_READ_REPORT_NONE);
+
+       MSG_DEBUG("QUERY : %s", sqlQuery);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+       {
+               return 0;
+       }
+
+       pDbHandle->bindText(pMsgInfo->subject, 1);
+
+       pDbHandle->bindText(pMsgInfo->msgData, 2);
+
+       pDbHandle->bindText(pMsgInfo->thumbPath, 3);
+
+       if (pMsgInfo->bTextSms == false)
+               pDbHandle->bindText(pFileData, 4);
+       else
+               pDbHandle->bindText(pMsgInfo->msgText, 4);
+
+       if (pDbHandle->stepQuery() != MSG_ERR_DB_DONE)
+       {
+               pDbHandle->finalizeQuery();
+               return 0;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       return msgId;
+}
+
+
+MSG_ERROR_T MsgStoSetReadStatus(MsgDbHandler *pDbHandle, MSG_MESSAGE_ID_T MsgId, bool bRead)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET READ_STATUS = %d WHERE MSG_ID = %d;",
+                                       MSGFW_MESSAGE_TABLE_NAME, (int)bRead, MsgId);
+
+       if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       // Get MAIN_TYPE, SUB_TYPE, STORAGE_ID
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.MAIN_TYPE, A.SUB_TYPE, B.CONTACT_ID, B.ADDRESS_ID \
+                                       FROM %s A, %s B \
+                                    WHERE A.MSG_ID = %d AND A.ADDRESS_ID = B.ADDRESS_ID;",
+                       MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, MsgId);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       MSG_MESSAGE_TYPE_S msgType;
+       MSG_CONTACT_ID_T contactId;
+       unsigned int addrId;
+
+       if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW)
+       {
+               msgType.mainType = pDbHandle->columnInt(0);
+               msgType.subType = pDbHandle->columnInt(1);
+               contactId = pDbHandle->columnInt(2);
+               addrId = pDbHandle->columnInt(3);
+       }
+       else
+       {
+               pDbHandle->finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       MSG_DEBUG("Main Type:[%d] SubType:[%d] ContactId:[%d] AddrId:[%d]", msgType.mainType, msgType.subType, contactId, addrId);
+
+       if (MsgStoUpdateAddress(pDbHandle, addrId) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgStoUpdateAddress() Error");
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       int smsCnt = 0, mmsCnt = 0;
+
+       smsCnt = MsgStoGetUnreadCnt(pDbHandle, MSG_SMS_TYPE);
+       mmsCnt = MsgStoGetUnreadCnt(pDbHandle, MSG_MMS_TYPE);
+
+       MsgSettingSetIndicator(smsCnt, mmsCnt);
+
+       MsgDeleteNotiByMsgId(MsgId);
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetOldestMessage(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsgInfo, MSG_MESSAGE_ID_T *pMsgId)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID \
+                                                                      FROM %s \
+                                                                   WHERE SUB_TYPE = %d AND FOLDER_ID = %d AND STORAGE_ID = %d AND PROTECTED = 0 \
+                                                                    ORDER BY DISPLAY_TIME ASC",
+                               MSGFW_MESSAGE_TABLE_NAME, pMsgInfo->msgType.subType, pMsgInfo->folderId, MSG_STORAGE_PHONE);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW)
+       {
+               *pMsgId = pDbHandle->columnInt(0);
+       }
+       else
+       {
+               pDbHandle->finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoCheckMsgCntFull(MsgDbHandler *pDbHandle, const MSG_MESSAGE_TYPE_S* pMsgType, MSG_FOLDER_ID_T FolderId)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       struct statfs buf = {0};
+
+       if (statfs(MSG_DATA_ROOT_PATH, &buf) == -1)
+       {
+               MSG_DEBUG("statfs(\"%s\") failed - %d", MSG_DATA_ROOT_PATH);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       unsigned long freeSpace = (buf.f_bfree * buf.f_bsize);
+
+       MSG_DEBUG("f_bfree [%d] f_bsize [%d]", buf.f_bfree, buf.f_bsize);
+       MSG_DEBUG("Free space of storage is [%ul] MB.", freeSpace);
+
+       if (freeSpace < SMS_MINIMUM_SPACE && pMsgType->mainType == MSG_SMS_TYPE)
+               err = MSG_ERR_MESSAGE_COUNT_FULL;
+       else if(freeSpace < MMS_MINIMUM_SPACE && pMsgType->mainType == MSG_MMS_TYPE)
+               err = MSG_ERR_MESSAGE_COUNT_FULL;
+
+       return err;
+
+       MSG_END();
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgStoCountMsgByLimitCategory(MsgDbHandler *pDbHandle, const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCount, MSG_FOLDER_ID_T folderId )
+{
+       if (pMsgType == NULL)
+       {
+               MSG_DEBUG("pMsgType is NULL");
+               return MSG_ERR_NULL_POINTER;
+       }
+
+       *pMsgCount = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       if ((pMsgType->mainType == MSG_SMS_TYPE) && (pMsgType->subType == MSG_WAP_SI_SMS ||pMsgType->subType == MSG_WAP_SL_SMS)) // PUSH
+       {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE MAIN_TYPE = %d AND SUB_TYPE IN (%d, %d) AND FOLDER_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, pMsgType->mainType, MSG_WAP_SI_SMS, MSG_WAP_SL_SMS, MSG_INBOX_ID);
+       }
+       else if ((pMsgType->mainType == MSG_SMS_TYPE) && (pMsgType->subType == MSG_CB_SMS)) // CB
+       {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE MAIN_TYPE = %d AND SUB_TYPE IN (%d) AND FOLDER_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, pMsgType->mainType, MSG_CB_SMS, MSG_CBMSGBOX_ID);
+       }
+       else if ((pMsgType->mainType == MSG_SMS_TYPE) && (pMsgType->subType == MSG_SYNCML_CP)) // Provision
+       {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE MAIN_TYPE = %d AND SUB_TYPE IN (%d) AND FOLDER_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, pMsgType->mainType, MSG_SYNCML_CP, MSG_INBOX_ID);
+       }
+       else if ((pMsgType->mainType == MSG_SMS_TYPE)) // SMS
+       {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE MAIN_TYPE = %d AND SUB_TYPE NOT IN (%d, %d, %d, %d) AND FOLDER_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, pMsgType->mainType, MSG_WAP_SI_SMS, MSG_WAP_SL_SMS, MSG_CB_SMS, MSG_SYNCML_CP, MSG_INBOX_ID); // etc SMS
+       }
+       else if ((pMsgType->mainType == MSG_MMS_TYPE) && (pMsgType->subType == MSG_SENDREQ_MMS || pMsgType->subType == MSG_SENDCONF_MMS || pMsgType->subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgType->subType == MSG_RETRIEVE_MANUALCONF_MMS || pMsgType->subType == MSG_NOTIFICATIONIND_MMS)) // MMS
+       {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE MAIN_TYPE = %d AND SUB_TYPE IN (%d, %d, %d, %d, %d) AND FOLDER_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, pMsgType->mainType, MSG_SENDREQ_MMS, MSG_SENDCONF_MMS, MSG_RETRIEVE_AUTOCONF_MMS, MSG_RETRIEVE_MANUALCONF_MMS, MSG_NOTIFICATIONIND_MMS, folderId);
+       }
+       else
+       {
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW)
+       {
+               *pMsgCount = pDbHandle->columnInt(0);
+       }
+       else
+       {
+               pDbHandle->finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+int MsgStoCheckMsgCntLimit(const MSG_MESSAGE_TYPE_S* pMsgType, MSG_FOLDER_ID_T FolderId)
+{
+       int msgboxType = -1;
+       int msgType= -1;
+
+       switch (FolderId)
+       {
+               case MSG_INBOX_ID :
+                       msgboxType = MSG_COUNT_LIMIT_INBOX_TYPE;
+               break;
+
+               case MSG_OUTBOX_ID :
+                       msgboxType = MSG_COUNT_LIMIT_OUTBOX_TYPE;
+               break;
+
+               case MSG_SENTBOX_ID :
+                       msgboxType = MSG_COUNT_LIMIT_SENTBOX_TYPE;
+               break;
+
+               case MSG_DRAFT_ID :
+                       msgboxType = MSG_COUNT_LIMIT_DRAFTBOX_TYPE;
+               break;
+
+               case MSG_CBMSGBOX_ID :
+                       msgboxType = MSG_COUNT_LIMIT_CBMSGBOX_TYPE;
+               break;
+
+               default:
+                       MSG_DEBUG("Unknown mailbox Type [%d]", FolderId);
+               return -1;
+       }
+
+       switch (pMsgType->subType)
+       {
+               case MSG_NORMAL_SMS:
+               case MSG_REPLACE_TYPE1_SMS:
+               case MSG_REPLACE_TYPE2_SMS:
+               case MSG_REPLACE_TYPE3_SMS:
+               case MSG_REPLACE_TYPE4_SMS:
+               case MSG_REPLACE_TYPE5_SMS:
+               case MSG_REPLACE_TYPE6_SMS:
+               case MSG_REPLACE_TYPE7_SMS:
+               case MSG_MWI_VOICE_SMS:
+               case MSG_MWI_FAX_SMS:
+               case MSG_MWI_EMAIL_SMS:
+               case MSG_MWI_OTHER_SMS:
+               case MSG_STATUS_REPORT_SMS:
+                       msgType = MSG_COUNT_LIMIT_SMS_TYPE;
+               break;
+
+               case MSG_CB_SMS:
+                       msgType = MSG_COUNT_LIMIT_CB_TYPE;
+               break;
+
+               case MSG_WAP_SI_SMS:
+               case MSG_WAP_SL_SMS:
+                       msgType = MSG_COUNT_LIMIT_WAPPUSH_TYPE;
+               break;
+
+               case MSG_SYNCML_CP:
+                       msgType = MSG_COUNT_LIMIT_PROVISION_TYPE;
+               break;
+
+               case MSG_SENDREQ_MMS:
+               case MSG_SENDCONF_MMS:
+               case MSG_NOTIFICATIONIND_MMS:
+               case MSG_RETRIEVE_AUTOCONF_MMS:
+               case MSG_RETRIEVE_MANUALCONF_MMS:
+                       msgType = MSG_COUNT_LIMIT_MMS_TYPE;
+               break;
+
+               default:
+                       MSG_DEBUG("Unknown Message Type [%d]", pMsgType->subType);
+               return -1;
+       }
+
+       return msgCntLimit[msgboxType][msgType];
+}
+
+
+MSG_ERROR_T MsgStoAddAddress(MsgDbHandler *pDbHandle, const MSG_ADDRESS_INFO_S *pAddrInfo, unsigned int *pAddrId)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       // Check if new address or not
+       if (MsgExistAddress(pDbHandle, pAddrInfo->addressVal, pAddrId) == true)
+       {
+               MSG_DEBUG("The address already exists. ID : [%d], Value : [%s]", *pAddrId, pAddrInfo->addressVal);
+               return err;
+       }
+
+       // Get Contact Info
+       MSG_CONTACT_INFO_S contactInfo = {0};
+
+       err = MsgGetContactInfo(pAddrInfo, &contactInfo);
+
+       if (err != MSG_SUCCESS)
+       {
+               MSG_DEBUG("MsgGetContactInfo() fail [%d]", err);
+               return err;
+       }
+
+       if (pDbHandle->getRowId(MSGFW_ADDRESS_TABLE_NAME, pAddrId) != MSG_SUCCESS)
+       {
+               return err;
+       }
+
+       // Add Address
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, '%s', %d, ?, ?, ?, '%s', 0, 0, 0, 0, 0, 0, 0, 0, '');",
+                               MSGFW_ADDRESS_TABLE_NAME, *pAddrId, pAddrInfo->addressType, pAddrInfo->recipientType, pAddrInfo->addressVal,
+                               contactInfo.contactId, contactInfo.imagePath);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       pDbHandle->bindText(contactInfo.displayName, 1);
+       pDbHandle->bindText(contactInfo.firstName, 2);
+       pDbHandle->bindText(contactInfo.lastName, 3);
+
+       if (pDbHandle->stepQuery() != MSG_ERR_DB_DONE)
+       {
+               pDbHandle->finalizeQuery();
+               MSG_DEBUG("Add Address Info. Fail [%s]", sqlQuery);
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       return err;
+}
+
+
+MSG_ERROR_T MsgStoUpdateAddress(MsgDbHandler *pDbHandle, unsigned int AddrId)
+{
+       MSG_BEGIN();
+
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       int unreadCnt = 0, smsCnt = 0, mmsCnt = 0;
+
+       char msgText[MAX_THREAD_DATA_LEN+1];
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       // Get Unread Count
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s \
+                                                               WHERE ADDRESS_ID = %d \
+                                                                    AND FOLDER_ID = %d \
+                                                                    AND READ_STATUS = 0;",
+                               MSGFW_MESSAGE_TABLE_NAME, AddrId, MSG_INBOX_ID);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       err = pDbHandle->stepQuery();
+
+       if (err == MSG_ERR_DB_ROW)
+       {
+               unreadCnt = pDbHandle->columnInt(0);
+       }
+       else if (err != MSG_ERR_DB_DONE)
+       {
+               pDbHandle->finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       // Get SMS Count
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s \
+                                                               WHERE ADDRESS_ID = %d \
+                                                                    AND MAIN_TYPE = %d \
+                                                                    AND FOLDER_ID > 0 AND FOLDER_ID < %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, AddrId, MSG_SMS_TYPE, MSG_CBMSGBOX_ID);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       err = pDbHandle->stepQuery();
+
+       if (err == MSG_ERR_DB_ROW)
+       {
+               smsCnt = pDbHandle->columnInt(0);
+       }
+       else if (err != MSG_ERR_DB_DONE)
+       {
+               pDbHandle->finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       // Get MMS Count
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s \
+                                                               WHERE ADDRESS_ID = %d \
+                                                                    AND MAIN_TYPE = %d \
+                                                                    AND SUB_TYPE NOT IN (%d, %d, %d) \
+                                                                    AND FOLDER_ID > 0 AND FOLDER_ID < %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, AddrId, MSG_MMS_TYPE, MSG_DELIVERYIND_MMS,
+                               MSG_READRECIND_MMS, MSG_READORGIND_MMS, MSG_CBMSGBOX_ID);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       err = pDbHandle->stepQuery();
+
+       if (err == MSG_ERR_DB_ROW)
+       {
+               mmsCnt = pDbHandle->columnInt(0);
+       }
+       else if (err != MSG_ERR_DB_DONE)
+       {
+               pDbHandle->finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       // Get Latest Msg Data
+       MSG_MAIN_TYPE_T mainType = MSG_UNKNOWN_TYPE;
+       MSG_SUB_TYPE_T subType = MSG_NORMAL_SMS;
+       MSG_DIRECTION_TYPE_T direction = MSG_DIRECTION_TYPE_MO;
+       time_t msgTime = 0;
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MAIN_TYPE, SUB_TYPE, MSG_DIRECTION, DISPLAY_TIME, SUBJECT, MSG_TEXT FROM %s \
+                                     WHERE ADDRESS_ID = %d \
+                                     AND FOLDER_ID > 0 AND FOLDER_ID < %d \
+                                     ORDER BY DISPLAY_TIME DESC;",
+                               MSGFW_MESSAGE_TABLE_NAME, AddrId, MSG_CBMSGBOX_ID);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       err = pDbHandle->stepQuery();
+
+       if (err == MSG_ERR_DB_ROW)
+       {
+               mainType = pDbHandle->columnInt(0);
+               subType = pDbHandle->columnInt(1);
+               direction = pDbHandle->columnInt(2);
+
+               msgTime = (time_t)pDbHandle->columnInt(3);
+
+               memset(msgText, 0x00, sizeof(msgText));
+
+               if (mainType == MSG_SMS_TYPE)
+               {
+                       if (pDbHandle->columnText(5) != NULL)
+                               strncpy(msgText, (char*)pDbHandle->columnText(5), MAX_THREAD_DATA_LEN);
+               }
+               else if (mainType == MSG_MMS_TYPE)
+               {
+                       if (pDbHandle->columnText(4) != NULL)
+                       {
+                               strncpy(msgText, (char*)pDbHandle->columnText(4), MAX_THREAD_DATA_LEN);
+                       }
+
+                       if ((strlen(msgText) <= 0) && (pDbHandle->columnText(5) != NULL) && (subType != MSG_NOTIFICATIONIND_MMS))
+                       {
+                               memset(msgText, 0x00, sizeof(msgText));
+                               strncpy(msgText, (char*)pDbHandle->columnText(5), MAX_THREAD_DATA_LEN);
+                       }
+               }
+       }
+       else if (err != MSG_ERR_DB_DONE)
+       {
+               pDbHandle->finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       // Update Address Table
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET UNREAD_CNT = %d, SMS_CNT = %d, MMS_CNT = %d, MAIN_TYPE = %d, SUB_TYPE = %d, MSG_DIRECTION = %d, MSG_TIME = %ld, MSG_TEXT = ? \
+                                     WHERE ADDRESS_ID = %d;",
+                               MSGFW_ADDRESS_TABLE_NAME, unreadCnt, smsCnt, mmsCnt, mainType, subType, direction, msgTime, AddrId);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       pDbHandle->bindText(msgText, 1);
+
+       if (pDbHandle->stepQuery() != MSG_ERR_DB_DONE)
+       {
+               pDbHandle->finalizeQuery();
+               MSG_DEBUG("Update Address Info. Fail [%d] [%s]", err, sqlQuery);
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoClearAddressTable(MsgDbHandler *pDbHandle)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s \
+                                    WHERE ADDRESS_ID NOT IN (SELECT ADDRESS_ID FROM %s) \
+                                         AND ADDRESS_ID <> 0;",
+                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME);
+
+       err = pDbHandle->execQuery(sqlQuery);
+
+       return err;
+}
+
+
+void MsgConvertNumber(const char* pSrcNum, char* pDestNum)
+{
+       int overLen = 0;
+       int i = 0;
+
+       overLen = strlen(pSrcNum) - MAX_PRECONFIG_NUM;
+
+       for (i = 0; i < MAX_PRECONFIG_NUM; i++)
+               pDestNum[i] = pSrcNum[i+overLen];
+
+       pDestNum[i] = '\0';
+}
+
+
+bool MsgExistAddress(MsgDbHandler *pDbHandle, const char *pAddress, unsigned int *pAddrId)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       *pAddrId = 0;
+
+       if (strlen(pAddress) > MAX_PRECONFIG_NUM)
+       {
+               char newPhoneNum[MAX_PRECONFIG_NUM+1];
+
+               memset(newPhoneNum, 0x00, sizeof(newPhoneNum));
+
+               MsgConvertNumber(pAddress, newPhoneNum);
+
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ADDRESS_ID FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s';",
+                                               MSGFW_ADDRESS_TABLE_NAME, newPhoneNum);
+       }
+       else
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ADDRESS_ID FROM %s WHERE ADDRESS_VAL = '%s';",
+                                               MSGFW_ADDRESS_TABLE_NAME, pAddress);
+       }
+
+       int rowCnt = 0, addrId = 0;
+
+       err = pDbHandle->getTable(sqlQuery, &rowCnt);
+
+       // No record or other error
+       if (err != MSG_SUCCESS)
+       {
+               pDbHandle->freeTable();
+               return false;
+       }
+
+       addrId = pDbHandle->getColumnToInt(1);
+
+       MSG_DEBUG("AddressId : [%d]", addrId);
+
+       if (addrId > 0)
+       {
+               *pAddrId = addrId;
+
+               pDbHandle->freeTable();
+               return true;
+       }
+       else
+       {
+               pDbHandle->freeTable();
+               return false;
+       }
+
+       pDbHandle->freeTable();
+
+       return false;
+}
+
+
+int MsgStoGetUnreadCnt(MsgDbHandler *pDbHandle, MSG_MAIN_TYPE_T MsgType)
+{
+       int msgCnt = 0;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       if (MsgType == MSG_SMS_TYPE)
+       {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s \
+                                                                       WHERE MAIN_TYPE = %d AND SUB_TYPE IN (%d, %d, %d, %d, %d, %d, %d) AND \
+                                                                       FOLDER_ID = %d AND READ_STATUS = 0;",
+                                                                       MSGFW_MESSAGE_TABLE_NAME, MSG_SMS_TYPE, MSG_NORMAL_SMS, MSG_STATUS_REPORT_SMS, MSG_CONCAT_SIM_SMS, MSG_WAP_SI_SMS, MSG_WAP_SL_SMS, MSG_MWI_VOICE_SMS, MSG_SYNCML_CP, MSG_INBOX_ID);
+       }
+       else if (MsgType == MSG_MMS_TYPE)
+       {
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s \
+                                                                       WHERE MAIN_TYPE = %d AND SUB_TYPE IN (%d, %d, %d) AND \
+                                                                       FOLDER_ID = %d AND READ_STATUS = 0;",
+                                                                       MSGFW_MESSAGE_TABLE_NAME, MSG_MMS_TYPE, MSG_RETRIEVE_AUTOCONF_MMS, MSG_RETRIEVE_MANUALCONF_MMS, MSG_NOTIFICATIONIND_MMS, MSG_INBOX_ID);
+       }
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return 0;
+
+       if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW)
+       {
+               msgCnt = pDbHandle->columnInt(0);
+       }
+       else
+       {
+               pDbHandle->finalizeQuery();
+               return 0;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       return msgCnt;
+}
+
+
+MSG_ERROR_T MsgStoAddContactInfo(MsgDbHandler *pDbHandle, MSG_CONTACT_INFO_S *pContactInfo, const char *pNumber)
+{
+       char newPhoneNum[MAX_PRECONFIG_NUM+1];
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       if (strlen(pNumber) > MAX_PRECONFIG_NUM)
+       {
+               memset(newPhoneNum, 0x00, sizeof(newPhoneNum));
+               MsgConvertNumber(pNumber, newPhoneNum);
+
+               MSG_DEBUG("Phone Number to Compare : [%s]", newPhoneNum);
+
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE MSG_ADDRESS_TABLE SET CONTACT_ID = %d, DISPLAY_NAME = ?, FIRST_NAME = ?, LAST_NAME = ?, IMAGE_PATH = '%s' \
+                                                                               WHERE ADDRESS_VAL LIKE '%%%%%s';",
+                                                                       pContactInfo->contactId,
+                                                                       pContactInfo->imagePath,
+                                                                       newPhoneNum);
+       }
+       else
+       {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE MSG_ADDRESS_TABLE SET CONTACT_ID = %d, DISPLAY_NAME = ?, FIRST_NAME = ?, LAST_NAME = ?, IMAGE_PATH = '%s' \
+                                                                               WHERE ADDRESS_VAL = '%s';",
+                                                                       pContactInfo->contactId,
+                                                                       pContactInfo->imagePath,
+                                                                       pNumber);
+       }
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       pDbHandle->bindText(pContactInfo->displayName, 1);
+
+       pDbHandle->bindText(pContactInfo->firstName, 2);
+
+       pDbHandle->bindText(pContactInfo->lastName, 3);
+
+       if (pDbHandle->stepQuery() != MSG_ERR_DB_DONE)
+       {
+               pDbHandle->finalizeQuery();
+               MSG_DEBUG("Update contact Info. Fail [%s]", sqlQuery);
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoClearContactInfo(MsgDbHandler *pDbHandle, int ContactId)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE MSG_ADDRESS_TABLE SET CONTACT_ID = 0, DISPLAY_NAME = '', FIRST_NAME = '', LAST_NAME = '', IMAGE_PATH = '' \
+                               WHERE CONTACT_ID = %d;", ContactId);
+
+       if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Fail to execute query");
+               return MSG_ERR_DB_EXEC;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoClearContactInfo(MsgDbHandler *pDbHandle, int ContactId, const char *pNumber)
+{
+       char newPhoneNum[MAX_PRECONFIG_NUM+1];
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(newPhoneNum, 0x00, sizeof(newPhoneNum));
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       if (strlen(pNumber) > MAX_PRECONFIG_NUM)
+       {
+               MsgConvertNumber(pNumber, newPhoneNum);
+
+               MSG_DEBUG("Phone Number to Compare : [%s]", newPhoneNum);
+
+               snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE MSG_ADDRESS_TABLE SET CONTACT_ID = 0, DISPLAY_NAME = '', FIRST_NAME = '', LAST_NAME = '', IMAGE_PATH = '' \
+                               WHERE CONTACT_ID = %d AND ADDRESS_VAL NOT LIKE '%%%s';", ContactId, newPhoneNum);
+       }
+       else
+       {
+               snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE MSG_ADDRESS_TABLE SET CONTACT_ID = 0, DISPLAY_NAME = '', FIRST_NAME = '', LAST_NAME = '', IMAGE_PATH = '' \
+                               WHERE CONTACT_ID = %d AND ADDRESS_VAL <> '%s';", ContactId, pNumber);
+       }
+
+       if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Fail to execute query");
+               return MSG_ERR_DB_EXEC;
+       }
+
+       return MSG_SUCCESS;
+}
+
+
+MSG_ERROR_T MsgStoGetMmsRawFilePath(MsgDbHandler *pDbHandle, MSG_MESSAGE_ID_T msgId, char *pFilePath)
+{
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILE_PATH FROM %s WHERE REFERENCE_ID IN \
+                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                               MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, msgId);
+
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW)
+       {
+               if (pDbHandle->columnText(0) != NULL)
+               {
+                       strncpy(pFilePath, (char*)pDbHandle->columnText(0), MSG_FILEPATH_LEN_MAX);
+               }
+       }
+       else
+       {
+               pDbHandle->finalizeQuery();
+               return MSG_ERR_DB_STEP;
+       }
+
+       pDbHandle->finalizeQuery();
+
+       return MSG_SUCCESS;
+}
+
+
+bool MsgStoCheckReadReportRequested(MsgDbHandler *pDbHandle, MSG_MESSAGE_ID_T MsgId)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+       int rowCnt = 0;
+       bool bReadReportRequested = false;
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ASK_READ_REPLY FROM %s WHERE REFERENCE_ID IN \
+                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                               MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+       err = pDbHandle->getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
+       {
+               pDbHandle->freeTable();
+               MSG_DEBUG("[Error]Failed to Get Table");
+               return bReadReportRequested;
+       }
+
+       if (rowCnt != 1)
+       {
+               pDbHandle->freeTable();
+               MSG_DEBUG("[Error]MSG_ERR_DB_NORECORD");
+               return bReadReportRequested;
+       }
+
+       bReadReportRequested = pDbHandle->getColumnToInt(1);
+
+       pDbHandle->freeTable();
+
+       return bReadReportRequested;
+}
+
+
+bool MsgStoCheckReadReportIsSent(MsgDbHandler *pDbHandle, MSG_MESSAGE_ID_T MsgId)
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       int rowCnt = 0;
+       bool bReadReportIsSent = true;
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT READ_REPORT_SENT FROM %s WHERE REFERENCE_ID IN \
+                               (SELECT REFERENCE_ID FROM %s WHERE MSG_ID = %d);",
+                               MMS_PLUGIN_ATTRIBUTE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MsgId);
+
+       err = pDbHandle->getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
+       {
+               pDbHandle->freeTable();
+               MSG_DEBUG("[Error]Failed to Get Table");
+               return bReadReportIsSent;
+       }
+
+       if (rowCnt != 1)
+       {
+               pDbHandle->freeTable();
+               MSG_DEBUG("[Error]MSG_ERR_DB_NORECORD");
+               return bReadReportIsSent;
+       }
+
+       bReadReportIsSent = (bool)pDbHandle->getColumnToInt(1);
+
+       pDbHandle->freeTable();
+
+       return bReadReportIsSent;
+}
+
+char *MsgStoReplaceString(const char *origStr, const char *oldStr, const char *newStr)
+{
+       if (origStr == NULL)
+               return NULL;
+
+       char *replaceStr = NULL;
+       char *pTemp = NULL;
+       int i = 0;
+       int matchedCnt = 0;
+       int oldStrLen = 0;
+       int newStrLen = 0;
+       int replaceSize = 0;
+
+       if (g_strcmp0(oldStr, newStr) != 0) {
+               oldStrLen = strlen(oldStr);
+               newStrLen = strlen(newStr);
+
+               for (i = 0; origStr[i] != '\0';) {
+                       if (memcmp(&origStr[i], oldStr, oldStrLen) == 0) {
+                               matchedCnt++;
+                               i += oldStrLen;
+                       } else {
+                               i++;
+                       }
+               }
+       } else {
+               return g_strdup(origStr);
+       }
+
+       replaceStr = (char *)calloc(1, i + sizeof(char) * (matchedCnt * (newStrLen - oldStrLen) + 1));
+       if (replaceStr == NULL)
+               return NULL;
+
+       pTemp = replaceStr;
+
+       while (*origStr) {
+               if (memcmp(origStr, oldStr, oldStrLen) == 0) {
+                       memcpy(pTemp, newStr, newStrLen);
+                       pTemp += newStrLen;
+                       origStr += oldStrLen;
+               } else {
+                       *pTemp++ = *origStr++;
+               }
+       }
+
+       return replaceStr;
+}
diff --git a/version.sh b/version.sh
new file mode 100755 (executable)
index 0000000..b503b14
--- /dev/null
@@ -0,0 +1 @@
+sed -n '1p' ./debian/changelog  | cut -f2 -d "(" | cut -f1 -d ")"