delete unused files(for extra location data) 40/77140/1 accepted/tizen/common/20160706.142016 accepted/tizen/ivi/20160706.081842 accepted/tizen/mobile/20160706.081805 accepted/tizen/wearable/20160706.081820 submit/tizen/20160706.013325
authorJongkyu Koo <jk.koo@samsung.com>
Tue, 28 Jun 2016 23:56:27 +0000 (08:56 +0900)
committerJongkyu Koo <jk.koo@samsung.com>
Tue, 28 Jun 2016 23:56:27 +0000 (08:56 +0900)
Change-Id: I264e197953e06b3a139dd0730f794844f2ec74eb
Signed-off-by: Jongkyu Koo <jk.koo@samsung.com>
daemon/CMakeLists.txt
daemon/phnd-dbus.c
daemon/phnd-location.c [deleted file]
daemon/phnd-location.h [deleted file]
packaging/phonenumber-utils.spec

index ef28cf21ebb5edc41c50dcf02018deadc6655111..41ea3f988b37c969c84873ef374f4f9511817f1c 100644 (file)
@@ -1,10 +1,6 @@
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 
-IF(ENABLE_LOG_FEATURE)
-       ADD_DEFINITIONS("-DENABLE_EXTRA_LOCATION_DATA")
-ENDIF(ENABLE_LOG_FEATURE)
-
 SET(DAEMON_SRCS
        phnd.c
        phnd-dbus.c
@@ -13,12 +9,6 @@ SET(DAEMON_SRCS
        phnd-libphonenumber.cpp
 )
 
-IF(ENABLE_EXTRA_LOCATION_DATA)
-SET(DAEMON_SRCS ${DAEMON_SRCS}
-       phnd-location.c
-)
-ENDIF(ENABLE_EXTRA_LOCATION_DATA)
-
 SET(DAEMON_SRCS ${DAEMON_SRCS} ${CMAKE_SOURCE_DIR}/common/phn-dbus.c)
 
 SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/common/phn-dbus.c
index 177e67744a6f1209ab99fb60511809f844a750dd..f625ac623b1c2a764527b3207551a6035fba687c 100644 (file)
@@ -22,9 +22,6 @@
 #include "phnd.h"
 #include "phnd-utils.h"
 #include "phnd-libphonenumber.h"
-#ifdef ENABLE_EXTRA_LOCATION_DATA
-#include "phnd-location.h"
-#endif
 #include "phnd-region-data.h"
 
 static inline int _dbus_get_location_handler(const char *number,
@@ -33,9 +30,6 @@ static inline int _dbus_get_location_handler(const char *number,
        int ret;
        char *lang_str = NULL;
        char *region_str = NULL;
-#ifdef ENABLE_EXTRA_LOCATION_DATA
-       char *location_file = NULL;
-#endif
 
        ret = phn_region_data_get_region_str(region, &region_str);
        if (PHONE_NUMBER_ERROR_NONE != ret) {
@@ -50,21 +44,6 @@ static inline int _dbus_get_location_handler(const char *number,
                return ret;
        }
 
-#ifdef ENABLE_EXTRA_LOCATION_DATA
-       ret = phn_location_find_extra_data(region_str, &location_file);
-       if (PHONE_NUMBER_ERROR_NONE == ret) {
-               ret = phn_location_get_location_from_extra_data(location_file, number, region_str,
-                               lang_str, location);
-               free(location_file);
-               if (PHONE_NUMBER_ERROR_NONE == ret && *location) {
-                       /* Found location from Extra data */
-                       free(region_str);
-                       free(lang_str);
-                       return PHONE_NUMBER_ERROR_NONE;
-               }
-       }
-#endif
-
        bool exist = phn_region_data_find_match_info(region, lang);
        if (false == exist) {
                INFO("Language not matched with Region. Set to defualt language.");
diff --git a/daemon/phnd-location.c b/daemon/phnd-location.c
deleted file mode 100644 (file)
index 6951fc2..0000000
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * Phonenumber Utils
- *
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES 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 <fcntl.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <glib.h>
-#include <tzplatform_config.h>
-
-#include "phnd.h"
-#include "phnd-region-data.h"
-#include "phnd-location.h"
-
-#define PHN_LOCATION_DIR tzplatform_mkpath(TZ_SYS_DATA, "phonenumber-utils")
-#define PHN_LOCATION_FILE_PREFIX "location"
-
-#define PHN_LOCATION_CHINA_MOBILE_SUFFIX_OFFSET 10000
-#define PHN_LOCATION_CHINA_MOBILE_PREFIX_LEN 3
-#define PHN_LOCATION_CHINA_MOBILE_SUFFIX_LEN 4
-#define PHN_LOCATION_CHINA_MOBILE_NUMBER_MIN_LEN 7
-
-struct phn_location_header {
-       gunichar2 version[16];
-       gunichar2 version_date[16];
-       int province_count;
-       int telephone_city_count;
-       int mobile_city_count;
-       int mobile_prefix_index_count;
-       int province_name_len[3];
-       int province_id_len;
-       int telephone_number_len;
-       int telephone_city_len[3];
-       int mobile_city_len[3];
-       int mobile_prefix_len;
-};
-
-int phn_location_find_extra_data(char *region_str, char **p_location_file)
-{
-       DIR *dirp = NULL;
-       struct dirent **dir_list;
-       char *location_file = NULL;
-
-       dirp = opendir(PHN_LOCATION_DIR);
-       if (NULL == dirp) {
-               ERR("opendir() return NULL");
-               return PHONE_NUMBER_ERROR_NO_DATA;
-       }
-
-       int count = scandir(PHN_LOCATION_DIR, &dir_list, 0, alphasort);
-       if (count) {
-               int idx = 0;
-               char location_prefix[PHN_STR_SHORT_LEN] = {0};
-
-               snprintf(location_prefix, sizeof(location_prefix), "%s-%s",
-                               PHN_LOCATION_FILE_PREFIX, region_str);
-               while (idx != count) {
-                       const char *file_name = dir_list[idx]->d_name;
-                       if (0 == strncmp(file_name, location_prefix, strlen(location_prefix))) {
-                               location_file = g_strdup(file_name);
-                               break;
-                       }
-                       idx++;
-               }
-       }
-       closedir(dirp);
-
-       if (location_file) {
-               *p_location_file = location_file;
-               return PHONE_NUMBER_ERROR_NONE;
-       }
-
-       return PHONE_NUMBER_ERROR_NO_DATA;
-}
-
-int phn_location_get_location_from_extra_data(const char *file, const char *number,
-               char *region_str, char *lang_str, char **p_location)
-{
-       int ret = 0;
-       int city_str_len = 0;
-       int province_str_len = 0;
-       gchar *city_temp = NULL;
-       gchar *province_temp = NULL;
-       const char *real_number = number;
-       const gunichar2 *city_str = NULL;
-       const gunichar2 *province_str = NULL;
-       char file_path[PHN_STR_SHORT_LEN] = {0};
-
-       /* support region - CN, support lang - zh,en,ko */
-
-       RETV_IF(NULL == number, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == lang_str, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == region_str, PHONE_NUMBER_ERROR_INVALID_PARAMETER);
-
-       while (real_number && real_number[0] == '0')
-               real_number++;
-
-       char lang_region[PHN_STR_SHORT_LEN] = {0};
-       snprintf(lang_region, sizeof(lang_region), "%s_%s", lang_str, region_str);
-
-       int lang_index = 0;
-       if (STRING_EQUAL == strcmp(lang_region, PHN_LOCATION_SUPPORT_ZH_CN)) {
-               lang_index = 0;
-       } else if (STRING_EQUAL == strcmp(lang_region, PHN_LOCATION_SUPPORT_EN_CN)) {
-               lang_index = 1;
-       } else if (STRING_EQUAL == strcmp(lang_region, PHN_LOCATION_SUPPORT_KO_CN)) {
-               lang_index = 2;
-       } else {
-               ERR("Not supported(%s)", lang_region);
-               return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
-       }
-
-       snprintf(file_path, sizeof(file_path), "%s/%s", PHN_LOCATION_DIR, file);
-
-       int fd = open(file_path, O_RDONLY);
-       RETVM_IF(fd < 0, PHONE_NUMBER_ERROR_NOT_SUPPORTED, "open() Fail(%d)", errno);
-
-       ret = lseek(fd, sizeof(int), SEEK_CUR); /* start_mark */
-       if (ret <= 0) {
-               ERR("lseek() Fail(%d)", errno);
-               close(fd);
-               return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
-       }
-
-       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_NOT_SUPPORTED;
-       }
-
-       struct phn_province_info {
-               gunichar2 name1[header.province_name_len[0]/2];
-               gunichar2 name2[header.province_name_len[1]/2];
-               gunichar2 name3[header.province_name_len[2]/2];
-       };
-
-#pragma pack(1)
-       struct phn_telephone_city_info {
-               gint8 province_index;
-               gunichar2 city1[header.telephone_city_len[0]/2];
-               gunichar2 city2[header.telephone_city_len[1]/2];
-               gunichar2 city3[header.telephone_city_len[2]/2];
-               gint16 prefix;
-       };
-
-#pragma pack(1)
-       struct phn_mobile_city_info {
-               gint8 province_index;
-               gunichar2 city1[header.mobile_city_len[0]/2];
-               gunichar2 city2[header.mobile_city_len[1]/2];
-               gunichar2 city3[header.mobile_city_len[2]/2];
-       };
-
-       if (header.province_count <= 0) {
-               ERR("Invalid provice_count(%d)", header.province_count);
-               close(fd);
-               return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
-       }
-       struct phn_province_info province_info[header.province_count];
-       ret = read(fd, &province_info, sizeof(province_info));
-       if (ret <= 0) {
-               ERR("read() Fail(%d)", errno);
-               close(fd);
-               return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
-       }
-
-       if (header.telephone_city_count <= 0) {
-               ERR("Invalid telephone_city_count(%d)", header.telephone_city_count);
-               close(fd);
-               return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
-       }
-       struct phn_telephone_city_info telephone_city_info[header.telephone_city_count];
-       ret = read(fd, &telephone_city_info, sizeof(telephone_city_info));
-       if (ret <= 0) {
-               ERR("read() Fail(%d)", errno);
-               close(fd);
-               return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
-       }
-
-       int i;
-       int telephone_city_count =
-               sizeof(telephone_city_info) / sizeof(struct phn_telephone_city_info);
-       for (i = 0; i < telephone_city_count; i++) {
-               gint8 provice_idx;
-               gint16 prefix = telephone_city_info[i].prefix;
-               char prefix_str[PHN_STR_SHORT_LEN] = {0};
-
-               snprintf(prefix_str, sizeof(prefix_str), "%u", prefix);
-               if (0 == strncmp(real_number, prefix_str, strlen(prefix_str))) {
-                       switch (lang_index) {
-                       case 0:
-                               city_str = telephone_city_info[i].city1;
-                               city_str_len = header.telephone_city_len[0] / 2;
-                               break;
-                       case 1:
-                               city_str = telephone_city_info[i].city2;
-                               city_str_len = header.telephone_city_len[1] / 2;
-                               break;
-                       case 2:
-                               city_str = telephone_city_info[i].city3;
-                               city_str_len = header.telephone_city_len[2] / 2;
-                               break;
-                       default:
-                               ERR("Invalid lang_index(%d)", lang_index);
-                               break;
-                       }
-
-                       provice_idx = telephone_city_info[i].province_index;
-                       if (0 < provice_idx && provice_idx <= header.province_count) {
-                               switch (lang_index) {
-                               case 0:
-                                       province_str = province_info[provice_idx-1].name1;
-                                       province_str_len = header.province_name_len[0] / 2;
-                                       break;
-                               case 1:
-                                       province_str = province_info[provice_idx-1].name2;
-                                       province_str_len = header.province_name_len[1] / 2;
-                                       break;
-                               case 2:
-                                       province_str = province_info[provice_idx-1].name3;
-                                       province_str_len = header.province_name_len[2] / 2;
-                                       break;
-                               default:
-                                       ERR("Invalid lang_index(%d)", lang_index);
-                                       break;
-                               }
-                       }
-
-                       province_temp = g_utf16_to_utf8(province_str, province_str_len, NULL, NULL,
-                                       NULL);
-                       city_temp = g_utf16_to_utf8(city_str, city_str_len, NULL, NULL, NULL);
-
-                       if (city_temp && province_temp) {
-                               int size = strlen(city_temp) + strlen(province_temp);
-                               char *location = NULL;
-                               location = calloc(size + 3, sizeof(char));
-                               if (location)
-                                       snprintf(location, size + 3, "%s, %s", city_temp, province_temp);
-                               *p_location = location;
-                       } else if (city_temp) {
-                               int size = strlen(city_temp);
-                               char *location = NULL;
-                               location = calloc(size + 1, sizeof(char));
-                               if (location)
-                                       snprintf(location, size + 1, "%s", city_temp);
-                               *p_location = location;
-                       }
-
-                       close(fd);
-                       free(city_temp);
-                       free(province_temp);
-                       if (NULL == p_location)
-                               return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
-                       return PHONE_NUMBER_ERROR_NONE;
-               }
-       }
-
-       if (strlen(number) < PHN_LOCATION_CHINA_MOBILE_NUMBER_MIN_LEN) {
-               ERR("Invalid number(%s)", number);
-               close(fd);
-               return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
-       }
-
-       if (header.mobile_city_count <= 0) {
-               ERR("Invalid mobile_city_count(%d)", header.mobile_city_count);
-               close(fd);
-               return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
-       }
-
-       struct phn_mobile_city_info mobile_city_info[header.mobile_city_count];
-       ret = read(fd, &mobile_city_info, sizeof(mobile_city_info));
-       if (ret <= 0) {
-               ERR("read() Fail(%d)", errno);
-               close(fd);
-               return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
-       }
-
-       if (header.mobile_prefix_index_count <= 0) {
-               ERR("Invalid mobile_prefix_index_count(%d)", header.mobile_prefix_index_count);
-               close(fd);
-               return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
-       }
-
-       gint16 mobile_prefix_info[header.mobile_prefix_index_count];
-       ret = read(fd, &mobile_prefix_info, sizeof(mobile_prefix_info));
-       if (ret <= 0) {
-               ERR("read() Fail(%d)", errno);
-               close(fd);
-               return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
-       }
-
-       char num_prefix_str[PHN_LOCATION_CHINA_MOBILE_PREFIX_LEN + 1] = {0};
-       char num_suffix_str[PHN_LOCATION_CHINA_MOBILE_SUFFIX_LEN + 1] = {0};
-       snprintf(num_prefix_str, sizeof(num_prefix_str), "%s", number);
-       snprintf(num_suffix_str, sizeof(num_suffix_str), "%s", number + 3);
-       int num_prefix = atoi(num_prefix_str);
-       int num_suffix = atoi(num_suffix_str);
-
-       int mobile_prefix_index_count = sizeof(mobile_prefix_info) / sizeof(gint16);
-       for (i = 0; i < mobile_prefix_index_count; i++) {
-               if (num_prefix == mobile_prefix_info[i]) {
-                       gint16 mobile_prefix = 0;
-                       ret = lseek(fd, (PHN_LOCATION_CHINA_MOBILE_SUFFIX_OFFSET * sizeof(gint16) * i)
-                                       + (num_suffix * sizeof(gint16)), SEEK_CUR);
-                       ret = read(fd, &mobile_prefix, sizeof(gint16));
-                       WARN_IF(ret < 0, "read() Fail(%d)", errno);
-                       if (0 == mobile_prefix) {
-                               ERR("Invalid value:mobile_prefix is 0");
-                               continue;
-                       }
-
-                       switch (lang_index) {
-                       case 0:
-                               city_str = mobile_city_info[mobile_prefix - 1].city1;
-                               city_str_len = header.mobile_city_len[0] / 2;
-                               break;
-                       case 1:
-                               city_str = mobile_city_info[mobile_prefix - 1].city2;
-                               city_str_len = header.mobile_city_len[1] / 2;
-                               break;
-                       case 2:
-                               city_str = mobile_city_info[mobile_prefix - 1].city3;
-                               city_str_len = header.mobile_city_len[2] / 2;
-                               break;
-                       default:
-                               ERR("Invalid lang_index(%d)", lang_index);
-                               break;
-                       }
-
-                       int province_index = mobile_city_info[mobile_prefix - 1].province_index;
-
-                       if (0 < province_index && province_index <= header.province_count) {
-                               switch (lang_index) {
-                               case 0:
-                                       province_str = province_info[province_index - 1].name1;
-                                       province_str_len = header.province_name_len[0] / 2;
-                                       break;
-                               case 1:
-                                       province_str = province_info[province_index - 1].name2;
-                                       province_str_len = header.province_name_len[1] / 2;
-                                       break;
-                               case 2:
-                                       province_str = province_info[province_index - 1].name3;
-                                       province_str_len = header.province_name_len[2] / 2;
-                                       break;
-                               default:
-                                       ERR("Invalid lang_index(%d)", lang_index);
-                                       break;
-                               }
-                       }
-
-                       province_temp = g_utf16_to_utf8(province_str, province_str_len, NULL, NULL,
-                                       NULL);
-                       city_temp = g_utf16_to_utf8(city_str, city_str_len, NULL, NULL, NULL);
-
-                       if (city_temp && province_temp) {
-                               int size = strlen(city_temp) + strlen(province_temp);
-                               char *location = NULL;
-                               location = calloc(size + 3, sizeof(char));
-                               if (location)
-                                       snprintf(location, size + 3, "%s, %s", city_temp, province_temp);
-                               *p_location = location;
-                       } else if (city_temp) {
-                               int size = strlen(city_temp);
-                               char *location = NULL;
-                               location = calloc(size + 1, sizeof(char));
-                               if (location)
-                                       snprintf(location, size + 1, "%s", city_temp);
-                               *p_location = location;
-                       }
-                       close(fd);
-                       free(city_temp);
-                       free(province_temp);
-                       if (NULL == p_location)
-                               return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
-                       return PHONE_NUMBER_ERROR_NONE;
-               }
-       }
-
-       close(fd);
-       return PHONE_NUMBER_ERROR_NONE;
-}
-
diff --git a/daemon/phnd-location.h b/daemon/phnd-location.h
deleted file mode 100644 (file)
index acf9848..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Phonenumber Utils
- *
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 __PHN_LOCATION_H__
-#define __PHN_LOCATION_H__
-
-#define PHN_LOCATION_SUPPORT_ZH_CN "zh_CN"
-#define PHN_LOCATION_SUPPORT_EN_CN "en_CN"
-#define PHN_LOCATION_SUPPORT_KO_CN "ko_CN"
-
-int phn_location_find_extra_data(char *region_str, char **p_location_file);
-int phn_location_get_location_from_extra_data(const char *file, const char *number,
-               char *region_str, char *lang_str, char **p_location);
-
-#endif /* __PHN_LOCATION_H__ */
index 8dd082ffe1221b610eefb6648a3fb16fe72f6149..7d88e889edbdff43d18b39f52dcb834886f339ba 100644 (file)
@@ -1,6 +1,6 @@
 Name:       phonenumber-utils
 Summary:    Phone Number Utilities
-Version:    0.2.2
+Version:    0.2.3
 Release:    0
 Group:      Telephony/Utilities
 License:    Apache-2.0