diff options
author | Sangkoo Kim <sangkoo.kim@samsung.com> | 2015-12-17 14:13:37 +0900 |
---|---|---|
committer | Sangkoo Kim <sangkoo.kim@samsung.com> | 2015-12-17 20:16:26 +0900 |
commit | 8dbef3f5ff22ff48e219ee40d507102d69194a69 (patch) | |
tree | 4869dfd441bd46a300691ef773dfea26035467d1 /mapi | |
parent | 2d9d6f6b2b40e44d1d69e79b0a25b54ce186c7d8 (diff) | |
download | msg-service-8dbef3f5ff22ff48e219ee40d507102d69194a69.tar.gz msg-service-8dbef3f5ff22ff48e219ee40d507102d69194a69.tar.bz2 msg-service-8dbef3f5ff22ff48e219ee40d507102d69194a69.zip |
Change type of input parameter for string setter API
Change-Id: I9234185b0331ee3320a077aca296377c09b76b15
Diffstat (limited to 'mapi')
-rwxr-xr-x | mapi/msg_filter.cpp | 2 | ||||
-rwxr-xr-x | mapi/msg_message.cpp | 2 | ||||
-rwxr-xr-x | mapi/msg_mms.cpp | 56 | ||||
-rwxr-xr-x | mapi/msg_setting.cpp | 10 | ||||
-rwxr-xr-x | mapi/msg_storage.cpp | 70 | ||||
-rwxr-xr-x | mapi/msg_svc.cpp | 12 |
6 files changed, 88 insertions, 64 deletions
diff --git a/mapi/msg_filter.cpp b/mapi/msg_filter.cpp index e2f07e6..81e444a 100755 --- a/mapi/msg_filter.cpp +++ b/mapi/msg_filter.cpp @@ -327,7 +327,7 @@ int msg_set_filter_info_int(void *filter, int field, int value) return err; } -int msg_set_filter_info_str(void *filter, int field, char *value, int size) +int msg_set_filter_info_str(void *filter, int field, const char *value, int size) { if (!filter || !value) return MSG_ERR_NULL_POINTER; diff --git a/mapi/msg_message.cpp b/mapi/msg_message.cpp index 9c0073c..8ba2cd1 100755 --- a/mapi/msg_message.cpp +++ b/mapi/msg_message.cpp @@ -516,7 +516,7 @@ int msg_message_set_bool_value(void *data, int field, bool value) return ret; } -int msg_message_set_str_value(void *data, int field, char *value, int size) +int msg_message_set_str_value(void *data, int field, const char *value, int size) { if (!data || !value) return MSG_ERR_NULL_POINTER; diff --git a/mapi/msg_mms.cpp b/mapi/msg_mms.cpp index 9137133..7073543 100755 --- a/mapi/msg_mms.cpp +++ b/mapi/msg_mms.cpp @@ -993,8 +993,11 @@ int msg_mms_set_int_value(msg_struct_s *msg_struct, int field, int value) return err; } -int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int size) +int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, const char *value, int size) { + if (value == NULL) + return MSG_ERR_NULL_POINTER; + msg_error_t err = MSG_SUCCESS; switch (msg_struct->type) { @@ -1005,21 +1008,18 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int else if (field == MSG_MMS_MEDIA_FILENAME_STR) { strncpy(mms_media_data->szFileName, value, MSG_FILEPATH_LEN_MAX); } else if (field == MSG_MMS_MEDIA_FILEPATH_STR) { + MSG_SEC_DEBUG("media file path = %s", value); + strncpy(mms_media_data->szFilePath, value, MSG_FILEPATH_LEN_MAX); + char *filename = NULL; - if (value != NULL) { - MSG_SEC_DEBUG("media file path = %s", value); - strncpy(mms_media_data->szFilePath, value, MSG_FILEPATH_LEN_MAX); - filename = strrchr(value, '/'); - if (filename != NULL) { - strncpy(mms_media_data->szFileName, filename + 1, MSG_FILENAME_LEN_MAX); - strncpy(mms_media_data->szContentID, filename + 1, MSG_MSG_ID_LEN); - } else { - strncpy(mms_media_data->szFileName, value + 1, MSG_FILENAME_LEN_MAX); - strncpy(mms_media_data->szContentID, value + 1, MSG_MSG_ID_LEN); - } + filename = (char *)strrchr(value, '/'); + + if (filename != NULL) { + strncpy(mms_media_data->szFileName, filename + 1, MSG_FILENAME_LEN_MAX); + strncpy(mms_media_data->szContentID, filename + 1, MSG_MSG_ID_LEN); } else { - MSG_DEBUG("media file path is NULL"); - err = MSG_ERR_INVALID_PARAMETER; + strncpy(mms_media_data->szFileName, value, MSG_FILENAME_LEN_MAX); + strncpy(mms_media_data->szContentID, value, MSG_MSG_ID_LEN); } } else if (field == MSG_MMS_MEDIA_CONTENT_ID_STR) __removeLessGreaterMark(value, mms_media_data->szContentID, MSG_MSG_ID_LEN); @@ -1042,26 +1042,18 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int if (field == MSG_MMS_ATTACH_FILENAME_STR) { strncpy(mms_attach_data->szFileName, value, MSG_FILENAME_LEN_MAX); } else if (field == MSG_MMS_ATTACH_FILEPATH_STR) { - char *filename = NULL; - char *filepath = value; - - if (filepath != NULL) { - MSG_SEC_DEBUG("attach file path = %s", filepath); - mms_attach_data->mediatype = MIME_UNKNOWN; - mms_attach_data->fileSize = -1; + MSG_SEC_DEBUG("attach file path = %s", value); + mms_attach_data->mediatype = MIME_UNKNOWN; + mms_attach_data->fileSize = -1; - strncpy(mms_attach_data->szFilePath, filepath, MSG_FILEPATH_LEN_MAX); - - filename = strrchr(filepath, '/'); - if (filename != NULL) { - strncpy(mms_attach_data->szFileName, filename + 1, MSG_FILENAME_LEN_MAX); - } else { - strncpy(mms_attach_data->szFileName, filepath, MSG_FILENAME_LEN_MAX); - } + strncpy(mms_attach_data->szFilePath, value, MSG_FILEPATH_LEN_MAX); + char *filename = NULL; + filename = (char *)strrchr(value, '/'); + if (filename != NULL) { + strncpy(mms_attach_data->szFileName, filename + 1, MSG_FILENAME_LEN_MAX); } else { - MSG_DEBUG("attach file path is NULL"); - err = MSG_ERR_INVALID_PARAMETER; + strncpy(mms_attach_data->szFileName, value, MSG_FILENAME_LEN_MAX); } } else if (field == MSG_MMS_ATTACH_DRM_FULLPATH_STR) { strncpy(mms_attach_data->szDrm2FullPath, value, MSG_FILEPATH_LEN_MAX); @@ -1567,7 +1559,7 @@ int msg_multipart_get_int_value(void *data, int field, int *value) return ret; } -int msg_multipart_set_str_value(void *data, int field, char *value, int size) +int msg_multipart_set_str_value(void *data, int field, const char *value, int size) { if (!data || !value) return MSG_ERR_NULL_POINTER; diff --git a/mapi/msg_setting.cpp b/mapi/msg_setting.cpp index 1bdf954..946c128 100755 --- a/mapi/msg_setting.cpp +++ b/mapi/msg_setting.cpp @@ -197,7 +197,7 @@ int msg_setting_set_int_value(msg_struct_s *msg_struct, int field, int value) return err; } -int msg_setting_set_str_value(msg_struct_s *msg_struct, int field, char *value, int size) +int msg_setting_set_str_value(msg_struct_s *msg_struct, int field, const char *value, int size) { int err = MSG_SUCCESS; @@ -464,7 +464,7 @@ int msg_get_smsc_info_str(void *smsc_info, int field, char *value, int size) return MSG_SUCCESS; } -int msg_set_smsc_info_str(void *smsc_info, int field, char *val, int size) +int msg_set_smsc_info_str(void *smsc_info, int field, const char *val, int size) { if (!smsc_info) return MSG_ERR_NULL_POINTER; @@ -824,7 +824,7 @@ int msg_get_cb_channel_info_str(void *cb_ch_info, int field, char *value, int si return MSG_SUCCESS; } -int msg_set_cb_channel_info_str(void *cb_ch_info, int field, char *val, int size) +int msg_set_cb_channel_info_str(void *cb_ch_info, int field, const char *val, int size) { if (!cb_ch_info) return MSG_ERR_NULL_POINTER; @@ -1635,7 +1635,7 @@ int msg_get_voice_msg_opt_str(void *voice_msg_opt, int field, char *value, int s return MSG_SUCCESS; } -int msg_set_voice_msg_opt_str(void *voice_msg_opt, int field, char *val, int size) +int msg_set_voice_msg_opt_str(void *voice_msg_opt, int field, const char *val, int size) { if (!voice_msg_opt) return MSG_ERR_NULL_POINTER; @@ -1859,7 +1859,7 @@ int msg_get_general_opt_str(void *general_opt, int field, char *value, int size) return MSG_SUCCESS; } -int msg_set_general_opt_str(void *general_opt, int field, char *val, int size) +int msg_set_general_opt_str(void *general_opt, int field, const char *val, int size) { if (!general_opt) return MSG_ERR_NULL_POINTER; diff --git a/mapi/msg_storage.cpp b/mapi/msg_storage.cpp index 0a42eff..ed679f6 100755 --- a/mapi/msg_storage.cpp +++ b/mapi/msg_storage.cpp @@ -1976,7 +1976,7 @@ int msg_sendopt_get_struct_handle(msg_struct_s *msg_struct, int field, void **va *value = (void *)sendopt->smsSendOpt; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -1997,7 +1997,7 @@ int msg_syncml_get_struct_handle(msg_struct_s *msg_struct, int field, void **val *value = (void *)pSync->msg; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -2018,7 +2018,7 @@ int msg_thread_index_get_struct_handle(msg_struct_s *msg_struct, int field, void *value = (void *)pIndex->msgAddrInfo; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -2040,7 +2040,7 @@ int msg_list_condition_get_struct_handle(msg_struct_s *msg_struct, int field, vo *value = (void *)pCond->sortRule; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -2227,7 +2227,7 @@ int msg_syncml_info_set_int(void *syncml_info, int field, int value) pSync->pinCode = value; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -2257,7 +2257,7 @@ int msg_count_info_set_int(void *count_info, int field, int value) pCount->nMms = value; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -2287,7 +2287,7 @@ int msg_thread_count_set_int(void *count_info, int field, int value) pCount->mmsMsgCount = value; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -2308,7 +2308,7 @@ int msg_thread_index_set_int(void *index_info, int field, int value) pIndex->contactId = value; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -2329,7 +2329,7 @@ int msg_sortrule_set_int(void *sort_info, int field, int value) pSort->sortType = value; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -2353,7 +2353,7 @@ int msg_folder_info_set_int(void *folder_info, int field, int value) pFolder->folderType = value; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -2399,7 +2399,7 @@ int msg_list_condition_set_int(void *condition_info, int field, int value) pCond->simIndex = value; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -2427,14 +2427,14 @@ int msg_report_status_set_int(void *report_info, int field, int value) pReport->statusTime = value; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } return err; } -int msg_folder_info_set_str(void *folder_info, int field, char *value, int size) +int msg_folder_info_set_str(void *folder_info, int field, const char *value, int size) { msg_error_t err = MSG_SUCCESS; @@ -2451,7 +2451,7 @@ int msg_folder_info_set_str(void *folder_info, int field, char *value, int size) strncpy(pFolder->folderName, value, _len); break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -2459,26 +2459,48 @@ int msg_folder_info_set_str(void *folder_info, int field, char *value, int size) } -int msg_list_condition_set_str(void *condition_info, int field, char *value, int size) +int msg_list_condition_set_str(void *condition_info, int field, const char *value, int size) { msg_error_t err = MSG_SUCCESS; if (!condition_info || !value) return MSG_ERR_NULL_POINTER; + if (size <= 0) { + return MSG_ERR_INVALID_PARAMETER; + } + MSG_LIST_CONDITION_S *cond = (MSG_LIST_CONDITION_S *)condition_info; switch (field) { case MSG_LIST_CONDITION_ADDRESS_VALUE_STR: - if (size) - cond->pAddressVal = value; + if (size) { + if (cond->pAddressVal) { + delete cond->pAddressVal; + cond->pAddressVal = NULL; + } + cond->pAddressVal = (char *)new char[size+1]; + if (cond->pAddressVal) + memcpy(cond->pAddressVal, value, sizeof(char)*size); + else + return MSG_ERR_MEMORY_ERROR; + } break; case MSG_LIST_CONDITION_TEXT_VALUE_STR: - if (size) - cond->pTextVal = value; + if (size) { + if (cond->pTextVal) { + delete cond->pTextVal; + cond->pTextVal = NULL; + } + cond->pTextVal = (char *)new char[size+1]; + if (cond->pTextVal) + memcpy(cond->pTextVal, value, sizeof(char)*size); + else + return MSG_ERR_MEMORY_ERROR; + } break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -2743,7 +2765,7 @@ int msg_reject_message_set_int(void *msg_info, int field, int value) return err; } -int msg_address_info_set_str(void *addr_info, int field, char *value, int size) +int msg_address_info_set_str(void *addr_info, int field, const char *value, int size) { msg_error_t err = MSG_SUCCESS; @@ -2772,7 +2794,7 @@ int msg_address_info_set_str(void *addr_info, int field, char *value, int size) return err; } -int msg_media_info_set_str(void *media_info, int field, char *value, int size) +int msg_media_info_set_str(void *media_info, int field, const char *value, int size) { msg_error_t err = MSG_SUCCESS; @@ -2806,7 +2828,7 @@ int msg_media_info_set_str(void *media_info, int field, char *value, int size) return err; } -int msg_reject_message_set_str(void *msg_info, int field, char *value, int size) +int msg_reject_message_set_str(void *msg_info, int field, const char *value, int size) { msg_error_t err = MSG_SUCCESS; @@ -3010,7 +3032,7 @@ int msg_push_config_get_bool(void *event_info, int field, bool *value) return ret; } -int msg_push_config_set_str(void *event_info, int field, char *value, int size) +int msg_push_config_set_str(void *event_info, int field, const char *value, int size) { msg_error_t err = MSG_SUCCESS; diff --git a/mapi/msg_svc.cpp b/mapi/msg_svc.cpp index 14b52c5..bc96798 100755 --- a/mapi/msg_svc.cpp +++ b/mapi/msg_svc.cpp @@ -460,6 +460,16 @@ static int _release_msg_struct(msg_struct_t *msg_struct_handle) delete (msg_struct_s *)pCond->sortRule; pCond->sortRule = NULL; + if (pCond->pAddressVal) { + delete pCond->pAddressVal; + pCond->pAddressVal = NULL; + } + + if (pCond->pTextVal) { + delete pCond->pTextVal; + pCond->pTextVal = NULL; + } + delete (MSG_LIST_CONDITION_S*)(msg_struct->data); msg_struct->data = NULL; @@ -1152,7 +1162,7 @@ EXPORT_API int msg_set_int_value(msg_struct_t msg_struct_handle, int field, int return err; } -EXPORT_API int msg_set_str_value(msg_struct_t msg_struct_handle, int field, char *value, int size) +EXPORT_API int msg_set_str_value(msg_struct_t msg_struct_handle, int field, const char *value, int size) { CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; |