[ACR-193] Remove inhose API (phone_number_replace_extra_location_data)
authorSunggoo Kim <sung.goo.kim@samsung.com>
Thu, 30 Apr 2015 07:21:50 +0000 (16:21 +0900)
committerJiwon Park <jiwon44.park@samsung.com>
Fri, 5 Jun 2015 10:53:53 +0000 (19:53 +0900)
Change-Id: I573bd93b84ecf6f270e94ee848d76e9b63c2e4c8

include/phone_number.h
packaging/phonenumber-utils.spec
src/phn.c
src/phn_location.c
src/phn_location.h

index b8d927e8ff618a8f93c4c56ea117e1720eb53cd4..f90f678bc2daf34febc709e9d118b73bc7a2506b 100644 (file)
@@ -89,32 +89,6 @@ int phone_number_get_location_from_number(const char *number, phone_number_regio
  */
 int phone_number_get_formatted_number(const char *number, phone_number_region_e region, char **formatted_number);
 
-/**
- * @internal
- * @brief Replace the extra location file that includes updated table of region and area code match,
- * used in phone_number_get_location_from_number. Please refer to programming guide for extra location file format.
- *
- * @since_tizen 2.4
- *
- * @param[in]  region      The region of extra location data
- * @param[in]  file_name   The file name of extra location data
- *
- * @return     @c 0 on success,
- *             otherwise a negative error value
- *
- * @retval  #PHONE_NUMBER_ERROR_NONE                          Successful
- * @retval  #PHONE_NUMBER_ERROR_OUT_OF_MEMORY                 Out of memory
- * @retval  #PHONE_NUMBER_ERROR_INVALID_PARAMETER             Invalid parameter
- * @retval  #PHONE_NUMBER_ERROR_FILE_NO_SPACE_ON_DEVICE       FS Full
- * @retval  #PHONE_NUMBER_ERROR_PERMISSION_DENIED             Permission denied
- * @retval  #PHONE_NUMBER_ERROR_NOT_SUPPORTED                 Not supported
- * @retval  #PHONE_NUMBER_ERROR_IO_ERROR                      I/O error
- *
- * @see phone_number_get_location_from_number()
- *
- */
-int phone_number_replace_extra_location_data(phone_number_region_e region, const char *file_name);
-
 /**
  * @}
  */
index 1ef16f74ec8e1383fcbed66e160945988000126f..f42cffaf2f3dcf37aa108ae2a5578a3a12a4240d 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       phonenumber-utils
 Summary:    Phone Number Utilities
-Version:    0.1.1
+Version:    0.1.2
 Release:    0
 Group:      Telephony/Utilities
 License:    Apache-2.0
index 9bd6420336a035b716354aaf3dc0104757f17e9a..2e72dc5fee528fe4f19a026db5f4f3d55a7187d9 100644 (file)
--- a/src/phn.c
+++ b/src/phn.c
 #include "phn_location.h"
 #include "phn_region_data.h"
 
-API int phone_number_replace_extra_location_data(phone_number_region_e region, const char *file_name)
-{
-       RETVM_IF(PHONE_NUMBER_REGION_CHINA != region, PHONE_NUMBER_ERROR_NOT_SUPPORTED,
-                       "Not supported region(%d)", region);
-       RETVM_IF(NULL == file_name, PHONE_NUMBER_ERROR_INVALID_PARAMETER, "Invalid parameter (file_name is NULL)");
-       RETVM_IF(strchr(file_name, '/'), PHONE_NUMBER_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
-       int ret;
-       ret = phn_location_validate_extra_data(region, file_name);
-       RETVM_IF(PHONE_NUMBER_ERROR_NONE != ret, ret, "phn_location_validate_extra_data() Fail(%d)", ret);
-
-       ret = phn_location_replace_extra_data(region, file_name);
-       RETVM_IF(PHONE_NUMBER_ERROR_NONE != ret, ret, "phn_location_replace_extra_data() Fail(%d)", ret);
-
-       return PHONE_NUMBER_ERROR_NONE;
-}
 
 API int phone_number_get_location_from_number(const char *number,
                phone_number_region_e region, phone_number_lang_e lang, char **location)
index 0dfce4264e8168b2b9f16747e717479002b1ca82..bdac93eb43130ef17e07554ab32c32d04c708c95 100644 (file)
@@ -59,187 +59,6 @@ struct phn_location_header {
        int mobile_prefix_len;
 };
 
-static bool _phn_location_file_is_symlink(const char *full_path)
-{
-       struct stat file_info;
-       lstat(full_path, &file_info);
-       if (file_info.st_mode & S_IFLNK)
-               return true;
-       return false;
-}
-
-int phn_location_validate_extra_data(phone_number_region_e region, const char *file_name)
-{
-       int ret;
-
-       char full_path[PHN_PATH_MAX_LEN] = {0};
-       snprintf(full_path, sizeof(full_path), PHN_LOCATION_DOWNLOAD_DIR"/%s", file_name);
-
-       if (_phn_location_file_is_symlink(full_path))
-               return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
-
-       int fd = open(full_path, O_RDONLY);
-       RETVM_IF(fd < 0, PHONE_NUMBER_ERROR_INVALID_PARAMETER, "open() Fail(%d)", errno);
-
-       int start_mark = 0;
-       ret = read(fd, &start_mark, sizeof(int));
-       if (ret <= 0) {
-               ERR("read() Fail(%d)", errno);
-               close(fd);
-               return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
-       }
-
-       if (PHN_LOCATION_FILE_MARK != start_mark) {
-               ERR("Invalid start_mark(%x)", start_mark);
-               close(fd);
-               return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
-       }
-
-       struct phn_location_header header;
-       ret = read(fd, &header, sizeof(struct phn_location_header));
-       if (ret <= 0) {
-               ERR("read() Fail(%d)", errno);
-               close(fd);
-               return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
-       }
-
-       int i,j;
-       int expected_len = 0;
-
-       // province
-       for (i=0;i<header.province_count;i++) {
-               for (j=0;j<PHN_LOCATION_LANG_INDEX_MAX;j++) {
-                       expected_len += header.province_name_len[j];
-               }
-       }
-
-       // telephone city
-       for (i=0;i<header.telephone_city_count;i++) {
-               expected_len += sizeof(gint8); // province index
-               for (j=0;j<PHN_LOCATION_LANG_INDEX_MAX;j++) {
-                       expected_len += header.telephone_city_len[j];
-               }
-               expected_len += sizeof(gint16); // number
-       }
-
-       if (region == PHONE_NUMBER_REGION_CHINA) {
-               // mobile city
-               for (i=0;i<header.mobile_city_count;i++) {
-                       expected_len += sizeof(gint8); // province index
-                       for (j=0;j<PHN_LOCATION_LANG_INDEX_MAX;j++) {
-                               expected_len += header.mobile_city_len[j];
-                       }
-               }
-
-               // mobile prefix index
-               expected_len += header.mobile_prefix_index_count * sizeof(gint16);
-
-               // mobile prefix
-               expected_len += header.mobile_prefix_index_count * sizeof(gint16) * PHN_LOCATION_CHINA_MOBILE_SUFFIX_OFFSET;
-       }
-
-       ret = lseek(fd, expected_len, SEEK_CUR);
-       if (ret <= 0) {
-               ERR("lseek() Fail(%d)", errno);
-               close(fd);
-               return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
-       }
-
-       // crc
-       ret = lseek(fd, sizeof(int), SEEK_CUR);
-       if (ret <= 0) {
-               ERR("read() Fail(%d)", errno);
-               close(fd);
-               return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
-       }
-
-       int end_mark = 0;
-       // check end mark
-       ret = read(fd, &end_mark, sizeof(int));
-       if (ret <= 0) {
-               ERR("read() Fail(%d)", errno);
-               close(fd);
-               return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
-       }
-
-       if (PHN_LOCATION_FILE_MARK != end_mark) {
-               ERR("Invalid end_mark(%x)", end_mark);
-               close(fd);
-               return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
-       }
-
-       // check eof
-       gint8 temp;
-       ret = read(fd, &temp, sizeof(gint8));
-       if (0 != ret) {
-               ERR("file size over (ret=%d)", ret);
-               close(fd);
-               return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
-       }
-
-       close(fd);
-       return PHONE_NUMBER_ERROR_NONE;
-}
-
-int phn_location_replace_extra_data(phone_number_region_e region, const char *file_name)
-{
-       const char *region_str = NULL;
-       region_str = phn_region_data_get_region_str(region);
-       RETVM_IF(NULL == region_str, PHONE_NUMBER_ERROR_NOT_SUPPORTED, "phn_region_info not found(%d)", region);
-
-       char dest_temp[PHN_STR_SHORT_LEN] = {0};
-       snprintf(dest_temp, sizeof(dest_temp), "%s/location-%s.bin.new", PHN_LOCATION_DIR, region_str);
-
-       char full_path[PHN_PATH_MAX_LEN] = {0};
-       snprintf(full_path, sizeof(full_path), PHN_LOCATION_DOWNLOAD_DIR"/%s", file_name);
-
-       int src_fd = open(full_path, O_RDONLY);
-       RETVM_IF(src_fd < 0, PHONE_NUMBER_ERROR_INVALID_PARAMETER, "System : Open(src:%s) Fail(%d)", full_path, errno);
-
-       int dest_fd = open(dest_temp, O_WRONLY|O_CREAT|O_TRUNC, 0660);
-       if (dest_fd < 0) {
-               ERR("Open Fail(%d)", errno);
-               close(src_fd);
-               return PHONE_NUMBER_ERROR_IO_ERROR;
-       }
-
-       int ret;
-       int size;
-       char buf[PHN_COPY_SIZE_MAX] = {0};
-       while ((size = read(src_fd, buf, PHN_COPY_SIZE_MAX)) > 0) {
-               ret = write(dest_fd, buf, size);
-               if (ret <= 0) {
-                       if (EINTR == errno)
-                               continue;
-                       else {
-                               ERR("write() Fail(%d)", errno);
-                               if (ENOSPC == errno)
-                                       ret = PHONE_NUMBER_ERROR_FILE_NO_SPACE_ON_DEVICE;       // No space
-                               else
-                                       ret = PHONE_NUMBER_ERROR_IO_ERROR;                      // IO error
-                               close(src_fd);
-                               close(dest_fd);
-                               unlink(dest_temp);
-                               return ret;
-                       }
-               }
-       }
-       close(src_fd);
-       close(dest_fd);
-
-       char dest[PHN_STR_SHORT_LEN] = {0};
-       snprintf(dest, sizeof(dest), "%s/location-%s.bin", PHN_LOCATION_DIR, region_str);
-
-       ret = rename(dest_temp, dest);
-       if (ret < 0) {
-               ERR("reanme() Fail(%d)", errno);
-               unlink(dest_temp);
-               return PHONE_NUMBER_ERROR_IO_ERROR;
-       }
-
-       return PHONE_NUMBER_ERROR_NONE;
-}
-
 int phn_location_find_extra_data(const char *region_str, char **p_location_file)
 {
        char *location_file = NULL;
index 3350de0d8617ddc9aa4d6a85292bb147354b4336..6c97bba85e1fd795cbadf6d19fc6d28ba097bca1 100644 (file)
@@ -22,8 +22,6 @@
 
 #include "phone_number_types.h"
 
-int phn_location_validate_extra_data(phone_number_region_e region, const char *file_name);
-int phn_location_replace_extra_data(phone_number_region_e region, const char *file_name);
 int phn_location_find_extra_data(const char *region_str, char **p_location_file);
 int phn_location_get_location_from_extra_data(const char *file, const char *number,
                phone_number_region_e region, phone_number_lang_e lang, char **p_location);