--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT(phonenumber-utils C CXX)
+
+SET(COMMON_CFLAGS "-fvisibility=hidden -fdata-sections -ffunction-sections -Wl,--gc-sections -fPIC")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_CFLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} -Wall -fPIC -std=c++0x -fvisibility=hidden")
+
+SET(SRC_FILE
+ src/phn.c
+ src/phn_location.c
+ src/phn_region_data.c
+ src/phn_phonenumber_wrapper.cpp
+)
+INCLUDE(FindPkgConfig)
+pkg_check_modules(PN_pkgs REQUIRED dlog icu-i18n glib-2.0 capi-base-common)
+INCLUDE_DIRECTORIES(${PN_pkgs_INCLUDE_DIRS})
+LINK_DIRECTORIES(${PN_pkgs_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(include)
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRC_FILE})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PN_pkgs_LIBRARIES} m phonenumber geocoding)
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${FULLVER} SOVERSION ${MAJORVER})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+INSTALL(FILES ${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
+FILE(GLOB HEADER_FILES include/*.h)
+INSTALL(FILES ${HEADER_FILES} DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME})
+INSTALL(DIRECTORY DESTINATION /opt/usr/data/${PROJECT_NAME})
+INSTALL(DIRECTORY DESTINATION /opt/usr/data/${PROJECT_NAME}/downloads)
--- /dev/null
+Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ 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.
+
+ 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,
+ 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 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 in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) 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
+
+ (d) 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 Apache License to your work.
+
+ To apply the Apache 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 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.
+
--- /dev/null
+Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache license, version 2 terms and conditions.
--- /dev/null
+/*
+ * 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 __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_DOC_H__
+#define __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_DOC_H__
+
+/**
+ * @ingroup CAPI_TELEPHONY_FRAMEWORK
+ * @defgroup CAPI_TELEPHONY_PHONE_NUMBER_UTILS_MODULE Phonenumber utils
+ *
+ *
+ * @section CAPI_TELEPHONY_PHONE_NUMBER_UTILS_MODULE_HEADER Required Header
+ * \#include <phone_number.h>
+ *
+ *
+ * @section CAPI_TELEPHONY_PHONE_NUMBER_UTILS_MODULE_OVERVIEW Overview
+ * The phonenumber utils API provides methods for parsing and formatting phone numbers.
+ */
+
+#endif /* __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_DOC_H__ */
--- /dev/null
+/*
+ * 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 __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_H__
+#define __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <phone_number_types.h>
+#include <phone_number_errors.h>
+
+/**
+ * @file phone_number.h
+ */
+
+/**
+ * @addtogroup CAPI_TELEPHONY_PHONE_NUMBER_UTILS_MODULE
+ *
+ * @{
+ */
+
+/**
+ * @brief This function gets the location string from number, region and language.
+ *
+ * @since_tizen 2.4
+ *
+ * @remarks You must release @a location using free().
+ *
+ * @param[in] number The number
+ * @param[in] region The region of number
+ * @param[in] language The language of location
+ * @param[out] location The location string to be returned
+ *
+ * @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_NO_DATA Requested data does not exist
+ *
+ */
+int phone_number_get_location_from_number(const char *number,
+ phone_number_region_e region, phone_number_lang_e language, char **location);
+
+/**
+ * @brief This function gets the formatted number.
+ * Formatted number includes the separators (such as dash or space) in input number
+ * according to national rules.
+ *
+ * @since_tizen 2.4
+ *
+ * @remarks You must release @a formatted_number using free().
+ *
+ * @param[in] number The number
+ * @param[in] region The region of number
+ * @param[out] formatted_number The formatted number string to be returned
+ *
+ * @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_NO_DATA Requested data does not exist
+ *
+ */
+int phone_number_get_formatted_number(const char *number, phone_number_region_e region,
+ char **formatted_number);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_H__ */
--- /dev/null
+/*
+ * 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 __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_ERRORS_H__
+#define __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_ERRORS_H__
+
+#include <tizen.h>
+
+/**
+ * @file phone_number_errors.h
+ */
+
+/**
+ * @addtogroup CAPI_TELEPHONY_PHONE_NUMBER_UTILS_MODULE
+ *
+ * @{
+ */
+
+/**
+ * @brief Enumeration for phone number errors.
+ *
+ * @since_tizen 2.4
+ *
+ */
+typedef enum {
+ /* GENERAL */
+ PHONE_NUMBER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ PHONE_NUMBER_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O Error */
+ PHONE_NUMBER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ PHONE_NUMBER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ PHONE_NUMBER_ERROR_FILE_NO_SPACE_ON_DEVICE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< FS Full */
+ PHONE_NUMBER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+ /* LOGIC & DATA */
+ PHONE_NUMBER_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< Requested data does not exist */
+} phone_number_error_e;
+
+/**
+ * @}
+ */
+
+#endif /* __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_ERRORS_H__ */
--- /dev/null
+/*
+ * 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 __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_TYPES_H__
+#define __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_TYPES_H__
+
+
+/**
+ * @file phone_number_types.h
+ */
+
+/**
+ * @addtogroup CAPI_TELEPHONY_PHONE_NUMBER_UTILS_MODULE
+ *
+ * @{
+ */
+
+/**
+ * @brief Enumeration for language type.
+ *
+ * @since_tizen 2.4
+ *
+ */
+typedef enum {
+ PHONE_NUMBER_LANG_AMHARIC, /**< Amharic */
+ PHONE_NUMBER_LANG_ARABIC, /**< Arabic */
+ PHONE_NUMBER_LANG_BELARUSIAN, /**< Belarusian */
+ PHONE_NUMBER_LANG_BULGARIAN, /**< Bulgarian */
+ PHONE_NUMBER_LANG_CHINESE, /**< Chinese */
+ PHONE_NUMBER_LANG_CHINESE_TRADITIONAL, /**< Chinese(Traditional) */
+ PHONE_NUMBER_LANG_CZECH, /**< Czech */
+ PHONE_NUMBER_LANG_DUTCH, /**< Dutch */
+ PHONE_NUMBER_LANG_ENGLISH, /**< English */
+ PHONE_NUMBER_LANG_FINNISH, /**< Finnish */
+ PHONE_NUMBER_LANG_FRENCH, /**< French */
+ PHONE_NUMBER_LANG_GERMAN, /**< German */
+ PHONE_NUMBER_LANG_GREEK, /**< Greek */
+ PHONE_NUMBER_LANG_HUNGARIAN, /**< Hungarian */
+ PHONE_NUMBER_LANG_INDONESIAN, /**< Indonesian */
+ PHONE_NUMBER_LANG_ITALIAN, /**< Italian */
+ PHONE_NUMBER_LANG_JAPANESE, /**< Japanese */
+ PHONE_NUMBER_LANG_KOREAN, /**< Korean */
+ PHONE_NUMBER_LANG_NORTHERN_SAMI, /**< Northern Sami */
+ PHONE_NUMBER_LANG_PERSIAN, /**< Persian */
+ PHONE_NUMBER_LANG_POLISH, /**< Polish */
+ PHONE_NUMBER_LANG_PORTUGUESE, /**< Portuguese */
+ PHONE_NUMBER_LANG_ROMANIAN, /**< Romanian */
+ PHONE_NUMBER_LANG_RUSSIAN, /**< Russian */
+ PHONE_NUMBER_LANG_SERBIAN, /**< Serbian */
+ PHONE_NUMBER_LANG_SPANISH, /**< Spanish */
+ PHONE_NUMBER_LANG_SWEDISH, /**< Swedish */
+ PHONE_NUMBER_LANG_THAI, /**< Thai */
+ PHONE_NUMBER_LANG_TURKISH, /**< Turkish */
+ PHONE_NUMBER_LANG_VIETNAMESE, /**< Vietnamese */
+ PHONE_NUMBER_LANG_MAX,
+} phone_number_lang_e;
+
+/**
+ * @brief Enumeration for region type.
+ *
+ * @since_tizen 2.4
+ *
+ */
+typedef enum {
+ PHONE_NUMBER_REGION_ALAND_ISLANDS, /**< Aland Islands */
+ PHONE_NUMBER_REGION_ALBANIA, /**< Albania */
+ PHONE_NUMBER_REGION_ALGERIA, /**< Algeria */
+ PHONE_NUMBER_REGION_AMERICAN_SAMOA, /**< American Samoa */
+ PHONE_NUMBER_REGION_ANGOLA, /**< Angola */
+ PHONE_NUMBER_REGION_ANGUILLA, /**< Anguilla */
+ PHONE_NUMBER_REGION_ARGENTINA, /**< Argentina */
+ PHONE_NUMBER_REGION_ARMENIA, /**< Armenia */
+ PHONE_NUMBER_REGION_ASCENSION_ISLAND, /**< Ascension Island */
+ PHONE_NUMBER_REGION_ATIGUA_AND_BARBUDA, /**< Atigua and Barbuda */
+ PHONE_NUMBER_REGION_AUSTRIA, /**< Austria */
+ PHONE_NUMBER_REGION_BAHAMAS, /**< Bahamas */
+ PHONE_NUMBER_REGION_BARBADOS, /**< Barbados */
+ PHONE_NUMBER_REGION_BELARUS, /**< Belarus */
+ PHONE_NUMBER_REGION_BELGIUM, /**< Belgium */
+ PHONE_NUMBER_REGION_BENIN, /**< Benin */
+ PHONE_NUMBER_REGION_BERMUDA, /**< Bermuda */
+ PHONE_NUMBER_REGION_BONAIRE_SINT_EUSTATIUS_AND_SABA, /**< Bonaire Sint Eustatius and Saba */
+ PHONE_NUMBER_REGION_BOTSWANA, /**< Botswana */
+ PHONE_NUMBER_REGION_BRAZIL, /**< Brazil */
+ PHONE_NUMBER_REGION_BULGARIA, /**< Bulgaria */
+ PHONE_NUMBER_REGION_BURKINA_FASO, /**< Burkina Faso */
+ PHONE_NUMBER_REGION_BURUNDI, /**< Burundi */
+ PHONE_NUMBER_REGION_CABO_VERDE, /**< Cabo Verde */
+ PHONE_NUMBER_REGION_CAMEROON, /**< Cameroon */
+ PHONE_NUMBER_REGION_CANADA, /**< Canada */
+ PHONE_NUMBER_REGION_CAYMAN_ISLAND, /**< Cayman Island */
+ PHONE_NUMBER_REGION_CHILE, /**< Chile */
+ PHONE_NUMBER_REGION_CHINA, /**< China */
+ PHONE_NUMBER_REGION_COLOMBIA, /**< Colombia */
+ PHONE_NUMBER_REGION_COMOROS, /**< Comoros */
+ PHONE_NUMBER_REGION_CONGO, /**< Congo */
+ PHONE_NUMBER_REGION_COTE_D_IVOIRE, /**< Cote d'Ivoire */
+ PHONE_NUMBER_REGION_CUBA, /**< Cuba */
+ PHONE_NUMBER_REGION_CURACAO, /**< Curacao */
+ PHONE_NUMBER_REGION_CZECH_REPUBLIC, /**< Czech Republic */
+ PHONE_NUMBER_REGION_DEMOCRATIC_REPUBLIC_OF_THE_CONGO, /**< Congo (Democratic Republic of the) */
+ PHONE_NUMBER_REGION_DOMINICA, /**< Dominica */
+ PHONE_NUMBER_REGION_DOMINICAN_REPUBLIC, /**< Domoinican Republic */
+ PHONE_NUMBER_REGION_EGYPT, /**< Egypt */
+ PHONE_NUMBER_REGION_ESTONIA, /**< Estonia */
+ PHONE_NUMBER_REGION_ETHIOPIA, /**< Ethiopia */
+ PHONE_NUMBER_REGION_FINLAND, /**< Finland */
+ PHONE_NUMBER_REGION_FRANCE, /**< France */
+ PHONE_NUMBER_REGION_GABON, /**< Gabon */
+ PHONE_NUMBER_REGION_GAMBIA, /**< Gambia */
+ PHONE_NUMBER_REGION_GERMANY, /**< Germany */
+ PHONE_NUMBER_REGION_GHANA, /**< Ghana */
+ PHONE_NUMBER_REGION_GREECE, /**< Greece */
+ PHONE_NUMBER_REGION_GREENLAND, /**< Greenland */
+ PHONE_NUMBER_REGION_GRENADA, /**< Grenada */
+ PHONE_NUMBER_REGION_GUAM, /**< Guam */
+ PHONE_NUMBER_REGION_GUERNSEY, /**< Guernsey */
+ PHONE_NUMBER_REGION_GUINEA, /**< Guinea */
+ PHONE_NUMBER_REGION_GUINEA_BISSAU, /**< Guinea-Bissau */
+ PHONE_NUMBER_REGION_HUNGARY, /**< Hungary */
+ PHONE_NUMBER_REGION_ICELAND, /**< Iceland */
+ PHONE_NUMBER_REGION_INDIA, /**< India */
+ PHONE_NUMBER_REGION_INDONESIA, /**< Indonesia */
+ PHONE_NUMBER_REGION_IRELAND, /**< Ireland */
+ PHONE_NUMBER_REGION_ISLAMIC_REPUBLIC_OF_IRAN, /**< Iran (Islamic Republic of) */
+ PHONE_NUMBER_REGION_ISLE_OF_MAN, /**< Isle of Man */
+ PHONE_NUMBER_REGION_ITALY, /**< Italy */
+ PHONE_NUMBER_REGION_JAMAICA, /**< Jamaica */
+ PHONE_NUMBER_REGION_JAPAN, /**< Japan */
+ PHONE_NUMBER_REGION_JERSEY, /**< Jersey */
+ PHONE_NUMBER_REGION_JORDAN, /**< Jordan */
+ PHONE_NUMBER_REGION_KAZAKHSTAN, /**< Kazakhstan */
+ PHONE_NUMBER_REGION_KENYA, /**< Kenya */
+ PHONE_NUMBER_REGION_KIRIBATI, /**< Kiribati */
+ PHONE_NUMBER_REGION_LATVIA, /**< Latvia */
+ PHONE_NUMBER_REGION_LESOTHO, /**< Lesotho */
+ PHONE_NUMBER_REGION_LITHUANIA, /**< Lithuania */
+ PHONE_NUMBER_REGION_LUXEMBOURG, /**< Luxembourg */
+ PHONE_NUMBER_REGION_MADAGASCAR, /**< Madagascar */
+ PHONE_NUMBER_REGION_MAURITANIA, /**< Mauritania */
+ PHONE_NUMBER_REGION_MAURITIUS, /**< Maritius */
+ PHONE_NUMBER_REGION_MONTSERRAT, /**< Montserrat */
+ PHONE_NUMBER_REGION_MOROCCO, /**< Morocco */
+ PHONE_NUMBER_REGION_MOZAMBIQUE, /**< Mazambique */
+ PHONE_NUMBER_REGION_NAMIBIA, /**< Namibia */
+ PHONE_NUMBER_REGION_NETHERLANDS, /**< Netherlands */
+ PHONE_NUMBER_REGION_NIGERIA, /**< Nigeria */
+ PHONE_NUMBER_REGION_NORTHERN_MARIANA_ISLANDS, /**< Northern Mariana Island */
+ PHONE_NUMBER_REGION_NORWAY, /**< Norway */
+ PHONE_NUMBER_REGION_PERU, /**< Peru */
+ PHONE_NUMBER_REGION_POLAND, /**< Poland */
+ PHONE_NUMBER_REGION_PORTUGAL, /**< Portugal */
+ PHONE_NUMBER_REGION_PUERTO_RICO, /**< Puerto Rico */
+ PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, /**< Korea (Republic of) */
+ PHONE_NUMBER_REGION_REPUBLIC_OF_MOLDOVA, /**< Moldova (Republic of) */
+ PHONE_NUMBER_REGION_ROMANIA, /**< Romania */
+ PHONE_NUMBER_REGION_RUSSIAN_FEDERATION, /**< Russian Federation */
+ PHONE_NUMBER_REGION_SAINT_HELENA, /**< Saint Helena, Ascension and Tristan da Cunha */
+ PHONE_NUMBER_REGION_SAINT_KITTS_AND_NEVIS, /**< Saint Kitts and Nevis */
+ PHONE_NUMBER_REGION_SAINT_LUCIA, /**< Saint Lucia */
+ PHONE_NUMBER_REGION_SAINT_VINCENT_AND_THE_GRENADINES, /**< Saint Vincent and the Grenadines */
+ PHONE_NUMBER_REGION_SAO_TOME_AND_PRINCIPE, /**< Sao Tome and Principe */
+ PHONE_NUMBER_REGION_SAUDI_ARABIA, /**< Saudi Arabia */
+ PHONE_NUMBER_REGION_SENEGAL, /**< Senegal */
+ PHONE_NUMBER_REGION_SERBIA, /**< Serbia */
+ PHONE_NUMBER_REGION_SIERRA_LEONE, /**< Sierra Leone */
+ PHONE_NUMBER_REGION_SINT_MAARTEN, /**< Sint maarten (Dutch part) */
+ PHONE_NUMBER_REGION_SLOVAKIA, /**< Slovakia */
+ PHONE_NUMBER_REGION_SOMALIA, /**< Somalia */
+ PHONE_NUMBER_REGION_SOUTH_AFRICA, /**< South Africa */
+ PHONE_NUMBER_REGION_SPAIN, /**< Spain */
+ PHONE_NUMBER_REGION_SRI_LANKA, /**< Sri Lanka */
+ PHONE_NUMBER_REGION_SUDAN, /**< Sudan */
+ PHONE_NUMBER_REGION_SVALBARD_AND_JAN_MAYEN, /**< Svalbard and Jan Mayen */
+ PHONE_NUMBER_REGION_SWAZILAND, /**< Swaziland */
+ PHONE_NUMBER_REGION_SWEDEN, /**< Sweden */
+ PHONE_NUMBER_REGION_SWITZERLAND, /**< Switzerland */
+ PHONE_NUMBER_REGION_TAIWAN_PROVINCE_OF_CHINA, /**< Taiwan Province of China */
+ PHONE_NUMBER_REGION_THAILAND, /**< Thailand */
+ PHONE_NUMBER_REGION_THE_FORMER_YUGOSLAV_REPUBLIC_OF_MACEDONIA, /**< Macedonia (the Former Yugoslav Republic of) */
+ PHONE_NUMBER_REGION_TOGO, /**< Togo */
+ PHONE_NUMBER_REGION_TRINIDAD_AND_TOBAGO, /**< Trinidad and Tobago */
+ PHONE_NUMBER_REGION_TRISTAN_DA_CUNHA, /**< Tristan da Cunha */
+ PHONE_NUMBER_REGION_TUNISIA, /**< Tunisia */
+ PHONE_NUMBER_REGION_TURKEY, /**< Turkey */
+ PHONE_NUMBER_REGION_TURKS_AND_CAICOS_ISLANDS, /**< Turks and Caicos Islands */
+ PHONE_NUMBER_REGION_UGANDA, /**< Uganda */
+ PHONE_NUMBER_REGION_UNITED_KINGDOM, /**< United Kingdom */
+ PHONE_NUMBER_REGION_UNITED_STATES_OF_AMERICA, /**< United States of America */
+ PHONE_NUMBER_REGION_VENEZUELA, /**< Venezuela */
+ PHONE_NUMBER_REGION_VIET_NAM, /**< Viet Nam */
+ PHONE_NUMBER_REGION_VIRGIN_ISLAND_BRITISH, /**< Virgin Island (British) */
+ PHONE_NUMBER_REGION_VIRGIN_ISLAND_US, /**< Virgin Island (U.S.) */
+ PHONE_NUMBER_REGION_WESTERN_SAHARA, /**< Western Sahara */
+ PHONE_NUMBER_REGION_ZAMBIA, /**< Zambia */
+ PHONE_NUMBER_REGION_ZIMBABWE, /**< Zimbabwe */
+ PHONE_NUMBER_REGION_MAX,
+} phone_number_region_e;
+
+
+/**
+ * @}
+ */
+
+#endif /* __TIZEN_TELEPHONY_PHONE_NUMBER_UTILS_TYPES_H__ */
--- /dev/null
+<manifest>
+ <define>
+ <domain name="phonenumber-utils" />
+ <provide>
+ <label name="phonenumber-utils::db" />
+ </provide>
+ </define>
+ <assign>
+ <filesystem path="/usr/lib/libphonenumber-utils.so*" label="_" exec_label="_" />
+ <filesystem path="/opt/usr/data/phonenumber-utils" label="phonenumber-utils::db" type="transmutable" />
+ <filesystem path="/opt/usr/data/phonenumber-utils/downloads" label="phonenumber-utils::db" type="transmutable" />
+ </assign>
+ <request>
+ <domain name="phonenumber-utils" />
+ </request>
+</manifest>
--- /dev/null
+Name: phonenumber-utils
+Summary: Phone Number Utilities
+Version: 0.1.8
+Release: 0
+Group: Telephony/Utilities
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+Source1001: %{name}.manifest
+BuildRequires: cmake
+BuildRequires: gettext-devel
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(icu-i18n)
+BuildRequires: pkgconfig(protobuf)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: libphonenumber-devel
+
+%if "%{?tizen_profile_name}" == "tv" && 0%{?tizen_version_major} < 3
+ExcludeArch: %{arm} %ix86 x86_64
+%endif
+
+%description
+Phone Number Utilities
+
+%package devel
+Summary: Phone Number Utilities (devel)
+Group: Telephony/Development
+Requires: %{name} = %{version}-%{release}
+
+%description -n phonenumber-utils-devel
+Phone Number Utilities development kit
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+
+%build
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%cmake . -DMAJORVER=${MAJORVER} -DFULLVER=%{version}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
+cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}-devel
+
+%post -n %{name}
+/sbin/ldconfig
+
+chown :5000 -R /opt/usr/data/%{name}
+chmod 775 -R /opt/usr/data/%{name}
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%{_libdir}/lib%{name}.so.*
+/opt/usr/data/%{name}
+/opt/usr/data/%{name}/downloads
+/usr/share/license/%{name}
+
+%files devel
+%defattr(-,root,root,-)
+%{_libdir}/lib%{name}.so
+%{_libdir}/pkgconfig/%{name}.pc
+%{_includedir}/%{name}/*.h
+/usr/share/license/%{name}-devel
--- /dev/null
+prefix=@PREFIX@
+exec_prefix=${prefix}/bin
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@/@PROJECT_NAME@
+
+Name: @PROJECT_NAME@
+Description: @PROJECT_NAME@ library
+Version: @FULLVER@
+Requires:
+Libs: -L${libdir} -l@PROJECT_NAME@
+Cflags: -I${includedir}
--- /dev/null
+/*
+ * 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 <stdlib.h>
+
+#include "phone_number.h"
+#include "phn_common.h"
+#include "phn_phonenumber_wrapper.h"
+#include "phn_location.h"
+#include "phn_region_data.h"
+
+
+API int phone_number_get_location_from_number(const char *number,
+ phone_number_region_e region, phone_number_lang_e lang, char **location)
+{
+ int ret;
+ const char *region_str = NULL;
+ const char *lang_str = NULL;
+
+ RETVM_IF(NULL == number || '\0' == *number, PHONE_NUMBER_ERROR_INVALID_PARAMETER,
+ "Invalid parameter (number is NULL)");
+ RETVM_IF(region < 0 || PHONE_NUMBER_REGION_MAX <= region, PHONE_NUMBER_ERROR_INVALID_PARAMETER,
+ "Invalid parameter (region:%d)", region);
+ RETVM_IF(lang < 0 || PHONE_NUMBER_LANG_MAX <= lang, PHONE_NUMBER_ERROR_INVALID_PARAMETER,
+ "Invalid parameter (lang:%d)", lang);
+ RETVM_IF(NULL == location, PHONE_NUMBER_ERROR_INVALID_PARAMETER,
+ "Invalid parameter (location is NULL)");
+
+ region_str = phn_region_data_get_region_str(region);
+ RETVM_IF(NULL == region_str, PHONE_NUMBER_ERROR_NO_DATA, "phn_region_info not found(%d)", region);
+
+ lang_str = phn_region_data_get_lang_str(lang);
+ RETVM_IF(NULL == lang_str, PHONE_NUMBER_ERROR_NO_DATA, "phn_lang_info not found(%d)", lang);
+
+ char *location_file = NULL;
+ ret = phn_location_find_extra_data(region_str, &location_file);
+ if (PHONE_NUMBER_ERROR_NONE == ret && location_file) {
+ ret = phn_location_get_location_from_extra_data(location_file, number, region, lang, location);
+ free(location_file);
+ if (PHONE_NUMBER_ERROR_NONE == ret && *location)
+ return PHONE_NUMBER_ERROR_NONE;
+ else
+ ERR("phn_location_get_location_from_extra_data() Fail(%d)", ret);
+ }
+
+ bool exist = phn_region_data_find_match_info(region, lang);
+ if (!exist)
+ lang_str = PHN_REGION_DEFAULT_LANG;
+
+ ret = phn_get_location_from_number(number, region_str, lang_str, location);
+ RETVM_IF(PHONE_NUMBER_ERROR_NONE != ret, ret, "phn_get_location_from_number() Fail(%d)", ret);
+
+ return PHONE_NUMBER_ERROR_NONE;
+}
+
+API int phone_number_get_formatted_number(const char *number, phone_number_region_e region, char **formatted_number)
+{
+ int ret;
+ const char *region_str = NULL;
+
+ RETVM_IF(NULL == number || '\0' == *number, PHONE_NUMBER_ERROR_INVALID_PARAMETER,
+ "Invalid parameter (number is NULL)");
+ RETVM_IF((int)region < 0 || PHONE_NUMBER_REGION_MAX <= region, PHONE_NUMBER_ERROR_INVALID_PARAMETER,
+ "Invalid parameter (region:%d)", region);
+ RETVM_IF(NULL == formatted_number, PHONE_NUMBER_ERROR_INVALID_PARAMETER, "Invalid parameter (formatted_number is NULL)");
+
+ region_str = phn_region_data_get_region_str(region);
+ RETVM_IF(NULL == region_str, PHONE_NUMBER_ERROR_NO_DATA, "phn_region_info not found(%d)", region);
+
+ ret = phn_get_formatted_number(number, region_str, formatted_number);
+ RETVM_IF(PHONE_NUMBER_ERROR_NONE != ret, ret, "phn_get_formatted_number() Fail(%d)", ret);
+
+ return PHONE_NUMBER_ERROR_NONE;
+}
+
+
--- /dev/null
+/*
+ * 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_COMMON_H__
+#define __PHN_COMMON_H__
+
+#include "phone_number_errors.h"
+
+#define PHN_STR_SHORT_LEN 1024
+
+#define LOG_TAG "PHONE_NUMBER_UTILS"
+#include <dlog.h>
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#define DLOG(prio, fmt, arg...) \
+ do { SLOG(prio, LOG_TAG, fmt, ##arg); } while (0);
+#define INFO(fmt, arg...) SLOGI(fmt, ##arg)
+#define WARN(fmt, arg...) SLOGW("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg)
+#define ERR(fmt, arg...) SLOGE("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg)
+#define DBG(fmt, arg...) SLOGD("%s:" fmt, __FUNCTION__, ##arg)
+#define WARN_IF(expr, fmt, arg...) do { \
+ if (expr) { \
+ WARN(fmt, ##arg); \
+ } \
+} while (0)
+
+#define RET_IF(expr) do { \
+ if (expr) { \
+ ERR("(%s)", #expr); \
+ return; \
+ } \
+} while (0)
+#define RETV_IF(expr, val) do { \
+ if (expr) { \
+ ERR("(%s)", #expr); \
+ return (val); \
+ } \
+} while (0)
+#define RETM_IF(expr, fmt, arg...) do { \
+ if (expr) { \
+ ERR(fmt, ##arg); \
+ return; \
+ } \
+} while (0)
+#define RETVM_IF(expr, val, fmt, arg...) do { \
+ if (expr) { \
+ ERR(fmt, ##arg); \
+ return (val); \
+ } \
+} while (0)
+
+#endif /* __PHN_COMMON_H__ */
--- /dev/null
+/*
+ * 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 "phn_common.h"
+#include "phn_region_data.h"
+#include "phn_location.h"
+
+#define PHN_PATH_MAX_LEN 1024
+#define PHN_COPY_SIZE_MAX 4096
+
+#define PHN_LOCATION_DIR "/opt/usr/data/phonenumber-utils"
+#define PHN_LOCATION_DOWNLOAD_DIR "/opt/usr/data/phonenumber-utils/downloads"
+#define PHN_LOCATION_FILE_PREFIX "location"
+#define PHN_LOCATION_LANG_INDEX_MAX 3
+#define PHN_LOCATION_FILE_MARK 0xfefe0000
+
+#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(const 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 = 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,
+ phone_number_region_e region, phone_number_lang_e lang, char **p_location)
+{
+ int ret = 0;
+ int city_str_len = 0;
+ int province_str_len = 0;
+ size_t read_size;
+ 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 */
+ RETVM_IF(region != PHONE_NUMBER_REGION_CHINA, PHONE_NUMBER_ERROR_NOT_SUPPORTED,
+ "Not supported region(%d)", region);
+
+ int lang_index = 0;
+ switch (lang) {
+ case PHONE_NUMBER_LANG_CHINESE:
+ lang_index = 0;
+ break;
+ case PHONE_NUMBER_LANG_ENGLISH:
+ lang_index = 1;
+ break;
+ case PHONE_NUMBER_LANG_KOREAN:
+ lang_index = 2;
+ break;
+ default:
+ ERR("Not supported lang(%d)", lang);
+ return PHONE_NUMBER_ERROR_NOT_SUPPORTED;
+ }
+
+ while (real_number && real_number[0] == '0')
+ real_number++;
+ RETVM_IF(NULL == real_number, PHONE_NUMBER_ERROR_INVALID_PARAMETER, "number=%s",
+ number);
+
+ 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 (region != PHONE_NUMBER_REGION_CHINA) {
+ ERR("Invalid region(%d)", region);
+ close(fd);
+ return PHONE_NUMBER_ERROR_NO_DATA;
+ } else 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;
+}
+
--- /dev/null
+/*
+ * 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__
+
+#include "phone_number_types.h"
+
+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);
+
+#endif /* __PHN_LOCATION_H__ */
--- /dev/null
+/*
+ * 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 <string.h>
+#include <glib.h>
+#include <phonenumbers/phonenumberutil.h>
+#include <phonenumbers/asyoutypeformatter.h>
+#include <phonenumbers/geocoding/phonenumber_offline_geocoder.h>
+#include "phn_common.h"
+#include "phn_phonenumber_wrapper.h"
+
+using namespace i18n::phonenumbers;
+
+int phn_get_location_from_number(const char *number, const char *region, const char *language, char **location)
+{
+ PhoneNumber phNumber;
+ const PhoneNumberUtil& pn_instance = *PhoneNumberUtil::GetInstance();
+ const PhoneNumberUtil::ErrorType status = pn_instance.Parse(
+ number, region, &phNumber);
+ RETVM_IF(status != PhoneNumberUtil::NO_PARSING_ERROR, PHONE_NUMBER_ERROR_NO_DATA, "parse() failed(%d)", status);
+
+ const std::string description =
+ PhoneNumberOfflineGeocoder().GetDescriptionForNumber(
+ phNumber, icu::Locale(language));
+ *location = g_strdup((gchar *)description.c_str());
+
+ return PHONE_NUMBER_ERROR_NONE;
+}
+
+int phn_get_formatted_number(const char *number, const char *region, char **formatted_number)
+{
+ const PhoneNumberUtil& pn_instance = *PhoneNumberUtil::GetInstance();
+ AsYouTypeFormatter *formatter = pn_instance.GetAsYouTypeFormatter(region);
+
+ int i=0;
+ string result;
+ while (number[i] && '\0' != number[i]) {
+ formatter->InputDigit(number[i++], &result);
+ }
+ delete formatter;
+ *formatted_number = g_strdup((gchar *)result.c_str());
+
+ return PHONE_NUMBER_ERROR_NONE;
+}
+
--- /dev/null
+/*
+ * 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_PHONENUMBER_WRAPPER_H__
+#define __PHN_PHONENUMBER_WRAPPER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int phn_get_formatted_number(const char *number, const char *region,
+ char **formatted_number);
+int phn_get_location_from_number(const char *number, const char *region,
+ const char *language, char **location);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PHN_PHONENUMBER_WRAPPER_H__ */
--- /dev/null
+/*
+ * 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 "phn_common.h"
+#include "phn_region_data.h"
+
+struct phn_lang_info {
+ const char *lang_str;
+ phone_number_lang_e lang;
+};
+
+struct phn_match_info {
+ phone_number_region_e region;
+ phone_number_lang_e lang;
+};
+
+struct phn_region_info {
+ const char *region_str;
+ phone_number_region_e region;
+};
+
+const struct phn_match_info phn_match_info_table[] = {
+ {PHONE_NUMBER_REGION_WESTERN_SAHARA, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_MOROCCO, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_MAURITANIA, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_COTE_D_IVOIRE, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_TOGO, PHONE_NUMBER_LANG_SPANISH},
+ {PHONE_NUMBER_REGION_TOGO, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_BENIN, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_MAURITIUS, PHONE_NUMBER_LANG_SPANISH},
+ {PHONE_NUMBER_REGION_MAURITIUS, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_CABO_VERDE, PHONE_NUMBER_LANG_PORTUGUESE},
+ {PHONE_NUMBER_REGION_SAO_TOME_AND_PRINCIPE, PHONE_NUMBER_LANG_PORTUGUESE},
+ {PHONE_NUMBER_REGION_CONGO, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_DEMOCRATIC_REPUBLIC_OF_THE_CONGO, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_ANGOLA, PHONE_NUMBER_LANG_PORTUGUESE},
+ {PHONE_NUMBER_REGION_GUINEA_BISSAU, PHONE_NUMBER_LANG_PORTUGUESE},
+ {PHONE_NUMBER_REGION_MOZAMBIQUE, PHONE_NUMBER_LANG_PORTUGUESE},
+ {PHONE_NUMBER_REGION_COMOROS, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_SAINT_HELENA, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_TRISTAN_DA_CUNHA, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_GREECE, PHONE_NUMBER_LANG_GREEK},
+ {PHONE_NUMBER_REGION_NETHERLANDS, PHONE_NUMBER_LANG_DUTCH},
+ {PHONE_NUMBER_REGION_BELGIUM, PHONE_NUMBER_LANG_GERMAN},
+ {PHONE_NUMBER_REGION_BELGIUM, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_BELGIUM, PHONE_NUMBER_LANG_DUTCH},
+ {PHONE_NUMBER_REGION_FRANCE, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_SPAIN, PHONE_NUMBER_LANG_SPANISH},
+ {PHONE_NUMBER_REGION_PORTUGAL, PHONE_NUMBER_LANG_PORTUGUESE},
+ {PHONE_NUMBER_REGION_LUXEMBOURG, PHONE_NUMBER_LANG_GERMAN},
+ {PHONE_NUMBER_REGION_LUXEMBOURG, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_ALAND_ISLANDS, PHONE_NUMBER_LANG_FINNISH},
+ {PHONE_NUMBER_REGION_ALAND_ISLANDS, PHONE_NUMBER_LANG_NORTHERN_SAMI},
+ {PHONE_NUMBER_REGION_FINLAND, PHONE_NUMBER_LANG_FINNISH},
+ {PHONE_NUMBER_REGION_BULGARIA, PHONE_NUMBER_LANG_BULGARIAN},
+ {PHONE_NUMBER_REGION_HUNGARY, PHONE_NUMBER_LANG_HUNGARIAN},
+ {PHONE_NUMBER_REGION_REPUBLIC_OF_MOLDOVA, PHONE_NUMBER_LANG_ROMANIAN},
+ {PHONE_NUMBER_REGION_REPUBLIC_OF_MOLDOVA, PHONE_NUMBER_LANG_RUSSIAN},
+ {PHONE_NUMBER_REGION_ARMENIA, PHONE_NUMBER_LANG_AMHARIC},
+ {PHONE_NUMBER_REGION_ARMENIA, PHONE_NUMBER_LANG_RUSSIAN},
+ {PHONE_NUMBER_REGION_BELARUS, PHONE_NUMBER_LANG_BELARUSIAN},
+ {PHONE_NUMBER_REGION_BELARUS, PHONE_NUMBER_LANG_RUSSIAN},
+ {PHONE_NUMBER_REGION_SERBIA, PHONE_NUMBER_LANG_SERBIAN},
+ {PHONE_NUMBER_REGION_ITALY, PHONE_NUMBER_LANG_ITALIAN},
+ {PHONE_NUMBER_REGION_ROMANIA, PHONE_NUMBER_LANG_ROMANIAN},
+ {PHONE_NUMBER_REGION_SWITZERLAND, PHONE_NUMBER_LANG_GERMAN},
+ {PHONE_NUMBER_REGION_SWITZERLAND, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_SWITZERLAND, PHONE_NUMBER_LANG_ITALIAN},
+ {PHONE_NUMBER_REGION_AUSTRIA, PHONE_NUMBER_LANG_GERMAN},
+ {PHONE_NUMBER_REGION_SWEDEN, PHONE_NUMBER_LANG_SWEDISH},
+ {PHONE_NUMBER_REGION_POLAND, PHONE_NUMBER_LANG_POLISH},
+ {PHONE_NUMBER_REGION_GERMANY, PHONE_NUMBER_LANG_GERMAN},
+ {PHONE_NUMBER_REGION_BRAZIL, PHONE_NUMBER_LANG_PORTUGUESE},
+ {PHONE_NUMBER_REGION_CHILE, PHONE_NUMBER_LANG_SPANISH},
+ {PHONE_NUMBER_REGION_COLOMBIA, PHONE_NUMBER_LANG_SPANISH},
+ {PHONE_NUMBER_REGION_VENEZUELA, PHONE_NUMBER_LANG_SPANISH},
+ {PHONE_NUMBER_REGION_INDONESIA, PHONE_NUMBER_LANG_INDONESIAN},
+ {PHONE_NUMBER_REGION_THAILAND, PHONE_NUMBER_LANG_THAI},
+ {PHONE_NUMBER_REGION_KAZAKHSTAN, PHONE_NUMBER_LANG_RUSSIAN},
+ {PHONE_NUMBER_REGION_RUSSIAN_FEDERATION, PHONE_NUMBER_LANG_RUSSIAN},
+ {PHONE_NUMBER_REGION_JAPAN, PHONE_NUMBER_LANG_JAPANESE},
+ {PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, PHONE_NUMBER_LANG_ARABIC},
+ {PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, PHONE_NUMBER_LANG_CZECH},
+ {PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, PHONE_NUMBER_LANG_FRENCH},
+ {PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, PHONE_NUMBER_LANG_KOREAN},
+ {PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, PHONE_NUMBER_LANG_CHINESE},
+ {PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA, PHONE_NUMBER_LANG_CHINESE_TRADITIONAL},
+ {PHONE_NUMBER_REGION_VIET_NAM, PHONE_NUMBER_LANG_VIETNAMESE},
+ {PHONE_NUMBER_REGION_CHINA, PHONE_NUMBER_LANG_CHINESE},
+ {PHONE_NUMBER_REGION_CHINA, PHONE_NUMBER_LANG_CHINESE_TRADITIONAL},
+ {PHONE_NUMBER_REGION_TAIWAN_PROVINCE_OF_CHINA, PHONE_NUMBER_LANG_CHINESE},
+ {PHONE_NUMBER_REGION_TAIWAN_PROVINCE_OF_CHINA, PHONE_NUMBER_LANG_CHINESE_TRADITIONAL},
+ {PHONE_NUMBER_REGION_TURKEY, PHONE_NUMBER_LANG_TURKISH},
+ {PHONE_NUMBER_REGION_SAUDI_ARABIA, PHONE_NUMBER_LANG_ARABIC},
+ {PHONE_NUMBER_REGION_ISLAMIC_REPUBLIC_OF_IRAN, PHONE_NUMBER_LANG_PERSIAN},
+};
+
+const struct phn_lang_info phn_lang_info_table[] = {
+ {"am", PHONE_NUMBER_LANG_AMHARIC},
+ {"ar", PHONE_NUMBER_LANG_ARABIC},
+ {"be", PHONE_NUMBER_LANG_BELARUSIAN},
+ {"bg", PHONE_NUMBER_LANG_BULGARIAN},
+ {"zh", PHONE_NUMBER_LANG_CHINESE},
+ {"zh_Hant", PHONE_NUMBER_LANG_CHINESE_TRADITIONAL},
+ {"cs", PHONE_NUMBER_LANG_CZECH},
+ {"nl", PHONE_NUMBER_LANG_DUTCH},
+ {"en", PHONE_NUMBER_LANG_ENGLISH},
+ {"fi", PHONE_NUMBER_LANG_FINNISH},
+ {"fr", PHONE_NUMBER_LANG_FRENCH},
+ {"de", PHONE_NUMBER_LANG_GERMAN},
+ {"el", PHONE_NUMBER_LANG_GREEK},
+ {"hu", PHONE_NUMBER_LANG_HUNGARIAN},
+ {"id", PHONE_NUMBER_LANG_INDONESIAN},
+ {"it", PHONE_NUMBER_LANG_ITALIAN},
+ {"ja", PHONE_NUMBER_LANG_JAPANESE},
+ {"ko", PHONE_NUMBER_LANG_KOREAN},
+ {"se", PHONE_NUMBER_LANG_NORTHERN_SAMI},
+ {"fa", PHONE_NUMBER_LANG_PERSIAN},
+ {"pl", PHONE_NUMBER_LANG_POLISH},
+ {"pt", PHONE_NUMBER_LANG_PORTUGUESE},
+ {"ro", PHONE_NUMBER_LANG_ROMANIAN},
+ {"ru", PHONE_NUMBER_LANG_RUSSIAN},
+ {"sr", PHONE_NUMBER_LANG_SERBIAN},
+ {"se", PHONE_NUMBER_LANG_SPANISH},
+ {"sv", PHONE_NUMBER_LANG_SWEDISH},
+ {"th", PHONE_NUMBER_LANG_THAI},
+ {"tr", PHONE_NUMBER_LANG_TURKISH},
+ {"vi", PHONE_NUMBER_LANG_VIETNAMESE},
+};
+
+const struct phn_region_info phn_region_info_table[] = {
+ {"AX", PHONE_NUMBER_REGION_ALAND_ISLANDS},
+ {"AL", PHONE_NUMBER_REGION_ALBANIA},
+ {"DZ", PHONE_NUMBER_REGION_ALGERIA},
+ {"AS", PHONE_NUMBER_REGION_AMERICAN_SAMOA},
+ {"AO", PHONE_NUMBER_REGION_ANGOLA},
+ {"AI", PHONE_NUMBER_REGION_ANGUILLA},
+ {"AR", PHONE_NUMBER_REGION_ARGENTINA},
+ {"AM", PHONE_NUMBER_REGION_ARMENIA},
+ {"AC", PHONE_NUMBER_REGION_ASCENSION_ISLAND},
+ {"AG", PHONE_NUMBER_REGION_ATIGUA_AND_BARBUDA},
+ {"AT", PHONE_NUMBER_REGION_AUSTRIA},
+ {"BS", PHONE_NUMBER_REGION_BAHAMAS},
+ {"BB", PHONE_NUMBER_REGION_BARBADOS},
+ {"BY", PHONE_NUMBER_REGION_BELARUS},
+ {"BE", PHONE_NUMBER_REGION_BELGIUM},
+ {"BJ", PHONE_NUMBER_REGION_BENIN},
+ {"BM", PHONE_NUMBER_REGION_BERMUDA},
+ {"BQ", PHONE_NUMBER_REGION_BONAIRE_SINT_EUSTATIUS_AND_SABA},
+ {"BW", PHONE_NUMBER_REGION_BOTSWANA},
+ {"BR", PHONE_NUMBER_REGION_BRAZIL},
+ {"BG", PHONE_NUMBER_REGION_BULGARIA},
+ {"BF", PHONE_NUMBER_REGION_BURKINA_FASO},
+ {"BI", PHONE_NUMBER_REGION_BURUNDI},
+ {"CV", PHONE_NUMBER_REGION_CABO_VERDE},
+ {"CM", PHONE_NUMBER_REGION_CAMEROON},
+ {"CA", PHONE_NUMBER_REGION_CANADA},
+ {"KY", PHONE_NUMBER_REGION_CAYMAN_ISLAND},
+ {"CL", PHONE_NUMBER_REGION_CHILE},
+ {"CN", PHONE_NUMBER_REGION_CHINA},
+ {"CO", PHONE_NUMBER_REGION_COLOMBIA},
+ {"KM", PHONE_NUMBER_REGION_COMOROS},
+ {"CG", PHONE_NUMBER_REGION_CONGO},
+ {"CI", PHONE_NUMBER_REGION_COTE_D_IVOIRE},
+ {"CU", PHONE_NUMBER_REGION_CUBA},
+ {"CW", PHONE_NUMBER_REGION_CURACAO},
+ {"CZ", PHONE_NUMBER_REGION_CZECH_REPUBLIC},
+ {"CD", PHONE_NUMBER_REGION_DEMOCRATIC_REPUBLIC_OF_THE_CONGO},
+ {"DM", PHONE_NUMBER_REGION_DOMINICA},
+ {"EG", PHONE_NUMBER_REGION_EGYPT},
+ {"EE", PHONE_NUMBER_REGION_ESTONIA},
+ {"ET", PHONE_NUMBER_REGION_ETHIOPIA},
+ {"FI", PHONE_NUMBER_REGION_FINLAND},
+ {"FR", PHONE_NUMBER_REGION_FRANCE},
+ {"GA", PHONE_NUMBER_REGION_GABON},
+ {"GM", PHONE_NUMBER_REGION_GAMBIA},
+ {"DE", PHONE_NUMBER_REGION_GERMANY},
+ {"GH", PHONE_NUMBER_REGION_GHANA},
+ {"GR", PHONE_NUMBER_REGION_GREECE},
+ {"GL", PHONE_NUMBER_REGION_GREENLAND},
+ {"GD", PHONE_NUMBER_REGION_GRENADA},
+ {"GU", PHONE_NUMBER_REGION_GUAM},
+ {"GG", PHONE_NUMBER_REGION_GUERNSEY},
+ {"GN", PHONE_NUMBER_REGION_GUINEA},
+ {"GW", PHONE_NUMBER_REGION_GUINEA_BISSAU},
+ {"HU", PHONE_NUMBER_REGION_HUNGARY},
+ {"IS", PHONE_NUMBER_REGION_ICELAND},
+ {"IN", PHONE_NUMBER_REGION_INDIA},
+ {"ID", PHONE_NUMBER_REGION_INDONESIA},
+ {"IE", PHONE_NUMBER_REGION_IRELAND},
+ {"IR", PHONE_NUMBER_REGION_ISLAMIC_REPUBLIC_OF_IRAN},
+ {"IM", PHONE_NUMBER_REGION_ISLE_OF_MAN},
+ {"IT", PHONE_NUMBER_REGION_ITALY},
+ {"JM", PHONE_NUMBER_REGION_JAMAICA},
+ {"JP", PHONE_NUMBER_REGION_JAPAN},
+ {"JE", PHONE_NUMBER_REGION_JERSEY},
+ {"JO", PHONE_NUMBER_REGION_JORDAN},
+ {"KZ", PHONE_NUMBER_REGION_KAZAKHSTAN},
+ {"KE", PHONE_NUMBER_REGION_KENYA},
+ {"KI", PHONE_NUMBER_REGION_KIRIBATI},
+ {"LV", PHONE_NUMBER_REGION_LATVIA},
+ {"LS", PHONE_NUMBER_REGION_LESOTHO},
+ {"LT", PHONE_NUMBER_REGION_LITHUANIA },
+ {"LU", PHONE_NUMBER_REGION_LUXEMBOURG},
+ {"MG", PHONE_NUMBER_REGION_MADAGASCAR},
+ {"MR", PHONE_NUMBER_REGION_MAURITANIA},
+ {"MU", PHONE_NUMBER_REGION_MAURITIUS },
+ {"DO", PHONE_NUMBER_REGION_DOMINICAN_REPUBLIC },
+ {"MS", PHONE_NUMBER_REGION_MONTSERRAT},
+ {"MA", PHONE_NUMBER_REGION_MOROCCO},
+ {"MZ", PHONE_NUMBER_REGION_MOZAMBIQUE},
+ {"NA", PHONE_NUMBER_REGION_NAMIBIA},
+ {"NL", PHONE_NUMBER_REGION_NETHERLANDS},
+ {"NG", PHONE_NUMBER_REGION_NIGERIA},
+ {"MP", PHONE_NUMBER_REGION_NORTHERN_MARIANA_ISLANDS},
+ {"NO", PHONE_NUMBER_REGION_NORWAY},
+ {"PE", PHONE_NUMBER_REGION_PERU},
+ {"PL", PHONE_NUMBER_REGION_POLAND},
+ {"PT", PHONE_NUMBER_REGION_PORTUGAL},
+ {"PR", PHONE_NUMBER_REGION_PUERTO_RICO},
+ {"KR", PHONE_NUMBER_REGION_REPUBLIC_OF_KOREA},
+ {"MD", PHONE_NUMBER_REGION_REPUBLIC_OF_MOLDOVA},
+ {"RO", PHONE_NUMBER_REGION_ROMANIA},
+ {"RU", PHONE_NUMBER_REGION_RUSSIAN_FEDERATION},
+ {"SH", PHONE_NUMBER_REGION_SAINT_HELENA},
+ {"KN", PHONE_NUMBER_REGION_SAINT_KITTS_AND_NEVIS},
+ {"LC", PHONE_NUMBER_REGION_SAINT_LUCIA},
+ {"VC", PHONE_NUMBER_REGION_SAINT_VINCENT_AND_THE_GRENADINES},
+ {"ST", PHONE_NUMBER_REGION_SAO_TOME_AND_PRINCIPE},
+ {"SA", PHONE_NUMBER_REGION_SAUDI_ARABIA},
+ {"SN", PHONE_NUMBER_REGION_SENEGAL},
+ {"RS", PHONE_NUMBER_REGION_SERBIA},
+ {"SL", PHONE_NUMBER_REGION_SIERRA_LEONE},
+ {"SX", PHONE_NUMBER_REGION_SINT_MAARTEN},
+ {"SK", PHONE_NUMBER_REGION_SLOVAKIA},
+ {"SO", PHONE_NUMBER_REGION_SOMALIA},
+ {"ZA", PHONE_NUMBER_REGION_SOUTH_AFRICA},
+ {"ES", PHONE_NUMBER_REGION_SPAIN},
+ {"LK", PHONE_NUMBER_REGION_SRI_LANKA},
+ {"SD", PHONE_NUMBER_REGION_SUDAN},
+ {"SJ", PHONE_NUMBER_REGION_SVALBARD_AND_JAN_MAYEN},
+ {"SZ", PHONE_NUMBER_REGION_SWAZILAND},
+ {"SE", PHONE_NUMBER_REGION_SWEDEN},
+ {"CH", PHONE_NUMBER_REGION_SWITZERLAND},
+ {"TW", PHONE_NUMBER_REGION_TAIWAN_PROVINCE_OF_CHINA},
+ {"TH", PHONE_NUMBER_REGION_THAILAND},
+ {"MK", PHONE_NUMBER_REGION_THE_FORMER_YUGOSLAV_REPUBLIC_OF_MACEDONIA},
+ {"TG", PHONE_NUMBER_REGION_TOGO},
+ {"TT", PHONE_NUMBER_REGION_TRINIDAD_AND_TOBAGO},
+ {"TA", PHONE_NUMBER_REGION_TRISTAN_DA_CUNHA},
+ {"TN", PHONE_NUMBER_REGION_TUNISIA},
+ {"TR", PHONE_NUMBER_REGION_TURKEY},
+ {"TC", PHONE_NUMBER_REGION_TURKS_AND_CAICOS_ISLANDS},
+ {"UG", PHONE_NUMBER_REGION_UGANDA},
+ {"GB", PHONE_NUMBER_REGION_UNITED_KINGDOM},
+ {"US", PHONE_NUMBER_REGION_UNITED_STATES_OF_AMERICA},
+ {"VE", PHONE_NUMBER_REGION_VENEZUELA},
+ {"VN", PHONE_NUMBER_REGION_VIET_NAM},
+ {"VG", PHONE_NUMBER_REGION_VIRGIN_ISLAND_BRITISH},
+ {"VI", PHONE_NUMBER_REGION_VIRGIN_ISLAND_US},
+ {"EH", PHONE_NUMBER_REGION_WESTERN_SAHARA},
+ {"ZM", PHONE_NUMBER_REGION_ZAMBIA},
+ {"ZW", PHONE_NUMBER_REGION_ZIMBABWE},
+};
+
+const char* phn_region_data_get_region_str(phone_number_region_e region)
+{
+ int i;
+
+ for (i = 0; i < sizeof(phn_region_info_table)/sizeof(struct phn_region_info); i++) {
+ if (phn_region_info_table[i].region == region)
+ return phn_region_info_table[i].region_str;
+ }
+ return NULL;
+}
+
+const char* phn_region_data_get_lang_str(phone_number_lang_e lang)
+{
+ int i;
+ for (i = 0; i < sizeof(phn_lang_info_table)/sizeof(struct phn_lang_info); i++) {
+ if (phn_lang_info_table[i].lang == lang)
+ return phn_lang_info_table[i].lang_str;
+ }
+ return NULL;
+}
+
+bool phn_region_data_find_match_info(phone_number_region_e region,
+ phone_number_lang_e lang)
+{
+ int i;
+ for (i = 0; i < sizeof(phn_match_info_table)/sizeof(struct phn_match_info); i++) {
+ if (phn_match_info_table[i].region == region
+ && phn_match_info_table[i].lang == lang) {
+ return true;
+ }
+ }
+ return false;
+}
--- /dev/null
+/*
+ * 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_REGION_DATA_H__
+#define __PHN_REGION_DATA_H__
+
+#include "phone_number_types.h"
+
+#define PHN_REGION_DEFAULT_LANG "en"
+
+const char* phn_region_data_get_region_str(phone_number_region_e region);
+const char* phn_region_data_get_lang_str(phone_number_lang_e lang);
+bool phn_region_data_find_match_info(phone_number_region_e region,
+ phone_number_lang_e lang);
+
+#endif /* __PHN_REGION_DATA_H__ */