tizen 2.3 release tizen_2.3 submit/tizen_2.3/20150202.061121 tizen_2.3_release
authorjk7744.park <jk7744.park@samsung.com>
Sat, 31 Jan 2015 07:27:59 +0000 (16:27 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sat, 31 Jan 2015 07:27:59 +0000 (16:27 +0900)
20 files changed:
CMakeLists.txt [new file with mode: 0644]
LICENSE [new file with mode: 0644]
capi-telephony.manifest [new file with mode: 0644]
capi-telephony.pc.in [new file with mode: 0644]
doc/telephony_doc.h [new file with mode: 0644]
include/telephony.h [new file with mode: 0644]
include/telephony_call.h [new file with mode: 0644]
include/telephony_common.h [new file with mode: 0644]
include/telephony_modem.h [new file with mode: 0644]
include/telephony_network.h [new file with mode: 0644]
include/telephony_private.h [new file with mode: 0644]
include/telephony_sim.h [new file with mode: 0644]
packaging/capi-telephony.spec [new file with mode: 0644]
src/telephony_call.c [new file with mode: 0644]
src/telephony_common.c [new file with mode: 0644]
src/telephony_modem.c [new file with mode: 0644]
src/telephony_network.c [new file with mode: 0644]
src/telephony_sim.c [new file with mode: 0644]
test/CMakeLists.txt [new file with mode: 0644]
test/test_all_api.c [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c3bbf1e
--- /dev/null
@@ -0,0 +1,139 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(project_prefix "capi")
+SET(prefix "/usr")
+SET(version "0.0.1")
+SET(maintainer "Wootak Jung<wootak.jung@samsung.com>")
+SET(description "Telephony Core API")
+SET(service "telephony")
+SET(dependents "dlog tapi glib-2.0 capi-base-common capi-system-info")
+SET(pc_dependents "capi-base-common tapi")
+
+SET(Services
+        "application"
+        "base"
+        "content"
+        "location"
+        "media"
+        "messaging"
+        "network"
+        "social"
+        "telephony"
+        "system"
+   )
+
+#FILE(STRINGS config.cfg configs REGEX "^ *[^#]")
+FOREACH(lines ${configs})
+#    MESSAGE(${lines})
+    IF(${lines} MATCHES "([^=]*)=['\"](.*)['\"]")
+        SET(key ${CMAKE_MATCH_1})
+        SET(value ${CMAKE_MATCH_2})
+#        MESSAGE("${key} -> ${value}")
+        SET(${key} "${value}")
+    ENDIF()
+ENDFOREACH(lines ${configs})
+
+LIST(FIND Services ${service} sfind)
+
+IF( ${sfind} EQUAL -1 )
+    MESSAGE(FATAL_ERROR "Service must be one of ")
+    FOREACH( s IN ${Services} )
+        MESSAGE(FATAL_ERROR "[${s}]")
+    ENDFOREACH( s IN ${Services} )
+ENDIF( ${sfind} EQUAL -1 )
+
+SET(fw_name "${project_prefix}-${service}")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX ${prefix})
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(VERSION ${version})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${dependents})
+FOREACH(flag ${${fw_name}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(ADDITIONAL_CFLAGS "-Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wcast-qual")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ADDITIONAL_CFLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+    ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+aux_source_directory(src SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+SET_TARGET_PROPERTIES(${fw_name}
+     PROPERTIES
+     VERSION ${FULLVER}
+     SOVERSION ${MAJORVER}
+     CLEAN_DIRECT_OUTPUT 1
+)
+
+INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(
+        DIRECTORY ${INC_DIR}/ DESTINATION include/${service}
+        FILES_MATCHING
+        PATTERN "*_private.h" EXCLUDE
+        PATTERN "${INC_DIR}/*.h"
+        )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${pc_dependents})
+SET(PC_LDFLAGS -l${fw_name})
+
+CONFIGURE_FILE(
+    capi-telephony.pc.in
+    ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+    @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME capi-telephony)
+
+ADD_SUBDIRECTORY(test)
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+        DEPENDS clean
+        COMMENT "distribution clean"
+        COMMAND find
+        ARGS    .
+        -not -name config.cmake -and \(
+        -name tester.c -or
+        -name Testing -or
+        -name CMakeFiles -or
+        -name cmake.depends -or
+        -name cmake.check_depends -or
+        -name CMakeCache.txt -or
+        -name cmake.check_cache -or
+        -name *.cmake -or
+        -name Makefile -or
+        -name core -or
+        -name core.* -or
+        -name gmon.out -or
+        -name install_manifest.txt -or
+        -name *.pc -or
+        -name *~ \)
+        | grep -v TC | xargs rm -rf
+        TARGET  distclean
+        VERBATIM
+)
+
+ENDIF(UNIX)
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..a06208b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2011 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.
+
diff --git a/capi-telephony.manifest b/capi-telephony.manifest
new file mode 100644 (file)
index 0000000..dfdc35c
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+  <domain name="_"/>
+ </request>
+</manifest>
diff --git a/capi-telephony.pc.in b/capi-telephony.pc.in
new file mode 100644 (file)
index 0000000..397716c
--- /dev/null
@@ -0,0 +1,14 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/telephony
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
diff --git a/doc/telephony_doc.h b/doc/telephony_doc.h
new file mode 100644 (file)
index 0000000..769aa96
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2011 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_INFORMATION_DOC_H__
+#define __TIZEN_TELEPHONY_INFORMATION_DOC_H__
+
+/**
+ * @ingroup CAPI_TELEPHONY_FRAMEWORK
+ * @defgroup CAPI_TELEPHONY_INFORMATION Telephony Information
+ * @brief The Telephony provides call, modem, network, and SIM information.
+ *
+ * @section CAPI_TELEPHONY_INFORMATION_HEADER Required Header
+ *   \#include <telephony.h>
+ *
+ * @section CAPI_TELEPHONY_INFORMATION_OVERVIEW Overview
+ * The Telephony provides call, modem, network, and SIM information.
+ * @section CAPI_TELEPHONY_INFORMATION_FEATURE Related Features
+ * This API is related with the following feature:\n
+ * - http://tizen.org/feature/network.telephony
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ */
+
+/**
+ * @ingroup CAPI_TELEPHONY_INFORMATION
+ * @defgroup CAPI_TELEPHONY_INFORMATION_CALL Call
+ * @brief The Call API provides functions to check the state of voice and video calls.
+ *
+ * @section CAPI_TELEPHONY_INFORMATION_CALL_HEADER Required Header
+ *   \#include <telephony.h>
+ *
+ * @section CAPI_TELEPHONY_INFORMATION_CALL_OVERVIEW Overview
+ * The Telephony Call API allows you to get the voice and videos call states.
+ * You can use this information about call related actions.
+ * @section CAPI_TELEPHONY_INFORMATION_CALL_FEATURE Related Features
+ * This API is related with the following feature:\n
+ * - http://tizen.org/feature/network.telephony
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ */
+
+/**
+ * @ingroup CAPI_TELEPHONY_INFORMATION
+ * @defgroup CAPI_TELEPHONY_INFORMATION_NETWORK Network
+ * @brief The Network Information API provides functions to obtain information about the current telephony service network.
+ *
+ * @section CAPI_TELEPHONY_INFORMATION_NETWORK_HEADER Required Header
+ *   \#include <telephony.h>
+ *
+ * @section CAPI_TELEPHONY_INFORMATION_NETWORK_OVERVIEW Overview
+ * The Telephony Network Information API allows you to access, but not change the
+ * information about the current cellular network and telephony service.
+ * @section CAPI_TELEPHONY_INFORMATION_NETWORK_FEATURE Related Features
+ * This API is related with the following feature:\n
+ * - http://tizen.org/feature/network.telephony
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ */
+
+/**
+ * @ingroup CAPI_TELEPHONY_INFORMATION
+ * @defgroup CAPI_TELEPHONY_INFORMATION_SIM SIM
+ * @brief The SIM API provides functions to obtain information from the SIM card, as well as SIM status.
+ *
+ * @section CAPI_TELEPHONY_INFORMATION_SIM_HEADER Required Header
+ *   \#include <telephony.h>
+ *
+ * @section CAPI_TELEPHONY_INFORMATION_SIM_OVERVIEW Overview
+ * The Telephony SIM API allows you to extract information stored on a SIM card, but not change the information.
+ * @section CAPI_TELEPHONY_INFORMATION_SIM_FEATURE Related Features
+ * This API is related with the following feature:\n
+ * - http://tizen.org/feature/network.telephony
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ */
+
+/**
+ * @ingroup CAPI_TELEPHONY_INFORMATION
+ * @defgroup CAPI_TELEPHONY_INFORMATION_MODEM Modem
+ * @brief The Modem Information API provides functions to obtain information from the modem.
+ *
+ * @section CAPI_TELEPHONY_INFORMATION_MODEM_HEADER Required Header
+ *   \#include <telephony.h>
+ *
+ * @section CAPI_TELEPHONY_INFORMATION_MODEM_OVERVIEW Overview
+ * The Telephony Modem Information API allows you to access, but not change the information about IMEI.
+ * @section CAPI_TELEPHONY_INFORMATION_MODEM_FEATURE Related Features
+ * This API is related with the following feature:\n
+ * - http://tizen.org/feature/network.telephony
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ */
+
+#endif /* __TIZEN_TELEPHONY_INFORMATION_DOC_H__ */
diff --git a/include/telephony.h b/include/telephony.h
new file mode 100644 (file)
index 0000000..69a54e7
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011 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 __CAPI_TELEPHONY_H__
+#define __CAPI_TELEPHONY_H__
+
+#include "telephony_common.h"
+#include "telephony_call.h"
+#include "telephony_sim.h"
+#include "telephony_network.h"
+#include "telephony_modem.h"
+
+/**
+ * @file telephony.h
+ * @brief This file contains telephony related headers.
+ */
+
+#endif /* __CAPI_TELEPHONY_H__ */
diff --git a/include/telephony_call.h b/include/telephony_call.h
new file mode 100644 (file)
index 0000000..390b3b5
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2011 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 __CAPI_TELEPHONY_CALL_H__
+#define __CAPI_TELEPHONY_CALL_H__
+
+/**
+ * @file telephony_call.h
+ * @brief This file contains call APIs and related enumeration.
+ */
+
+#include "telephony_common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup CAPI_TELEPHONY_INFORMATION_CALL
+ * @{
+ */
+
+/**
+ * @brief Enumeration for the call state.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+    TELEPHONY_CALL_STATE_IDLE,       /**< There exists no calls. */
+    TELEPHONY_CALL_STATE_CONNECTING, /**< There exists at least one call that is dialing, alerting or incoming */
+    TELEPHONY_CALL_STATE_CONNECTED,  /**< There exist active or held calls, and no calls are dialing, alerting or incoming*/
+} telephony_call_state_e;
+
+/**
+ * @brief Gets the voice call state of the telephony service.
+ * @details Determines if the voice call is connecting, connected, or idle.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks When you are dialing a number or a new voice call is ringing,
+ *          the state of the voice call is #TELEPHONY_CALL_STATE_CONNECTING.
+ *          When a new voice call is connecting while another voice call is already connected,
+ *          the state of the voice call is #TELEPHONY_CALL_STATE_CONNECTING as well.
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] call_state The current state of the voice call
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ */
+int telephony_call_get_voice_call_state(telephony_h handle, telephony_call_state_e *call_state);
+
+/**
+ * @brief Gets the video call state of the telephony service.
+ * @details Determines if the video call is connecting, connected, or idle.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks When you are dialing a number or a new video call is ringing,
+ *          the state of the video call is #TELEPHONY_CALL_STATE_CONNECTING.
+ *          If a video call is connected, then the state of any other call cannot be
+ *          #TELEPHONY_CALL_STATE_CONNECTING and #TELEPHONY_CALL_STATE_CONNECTED.
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] call_state The current state of the video call
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ */
+int telephony_call_get_video_call_state(telephony_h handle, telephony_call_state_e *call_state);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __CAPI_TELEPHONY_CALL_H__
diff --git a/include/telephony_common.h b/include/telephony_common.h
new file mode 100644 (file)
index 0000000..b2db970
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2011 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 __CAPI_TELEPHONY_COMMON_H__
+#define __CAPI_TELEPHONY_COMMON_H__
+
+/**
+ * @file telephony_common.h
+ * @brief This file contains telephony common APIs and related enumerations.
+ */
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file telephony_common.h
+ * @brief This file contains the common information APIs.
+ */
+
+/**
+ * @addtogroup CAPI_TELEPHONY_INFORMATION
+ * @{
+ */
+
+/**
+ * @brief The Telephony API handle.
+ * @since_tizen 2.3
+ */
+typedef struct telephony_data *telephony_h;
+
+/**
+ * @brief The structure type for the list of handles to use the Telephony API.
+ * @remarks There are two handles in case of dual SIM device. \n
+ *          In this case, handle[0] is mean Primary SIM and handle[1] is mean Secondary SIM.
+ * @since_tizen 2.3
+ */
+typedef struct {
+    unsigned int count; /**< Number of available handle */
+    telephony_h *handle; /**< Handle to use Telephony API */
+} telephony_handle_list_s;
+
+/**
+ * @brief Enumeration for Telephony error.
+ * @since_tizen 2.3
+ */
+typedef enum {
+    TELEPHONY_ERROR_NONE = TIZEN_ERROR_NONE,                            /**< Successful */
+    TELEPHONY_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,          /**< Out of memory */
+    TELEPHONY_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,  /**< Invalid parameter */
+    TELEPHONY_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED,  /**< Permission denied */
+    TELEPHONY_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED,          /**< Not supported */
+    TELEPHONY_ERROR_OPERATION_FAILED = TIZEN_ERROR_TELEPHONY | 0x0001,  /**< Operation failed */
+    TELEPHONY_ERROR_SIM_NOT_AVAILABLE = TIZEN_ERROR_TELEPHONY | 0x1001, /**< SIM is not available */
+} telephony_error_e;
+
+/**
+ * @brief Enumeration for Telephony notification.
+ * @since_tizen 2.3
+ */
+typedef enum  {
+    TELEPHONY_NOTI_SIM_STATUS = 0x10,            /**< Notification to be invoked when the SIM card state changes */
+
+    TELEPHONY_NOTI_NETWORK_SERVICE_STATE = 0x20, /**< Notification to be invoked when the network service state changes */
+    TELEPHONY_NOTI_NETWORK_CELLID,               /**< Notification to be invoked when the cell ID changes */
+    TELEPHONY_NOTI_NETWORK_ROAMING_STATUS,       /**< Notification to be invoked when the roaming status changes */
+    TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL, /**< Notification to be invoked when the signal strength changes */
+
+    TELEPHONY_NOTI_VOICE_CALL_STATE = 0x30,      /**< Notification to be invoked when the voice call state changes */
+    TELEPHONY_NOTI_VIDEO_CALL_STATE              /**< Notification to be invoked when the video call state changes */
+} telephony_noti_e;
+
+/**
+ * @brief Called when the telephony state changes.
+ * @since_tizen 2.3
+ */
+typedef void (*telephony_noti_cb)(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data);
+
+/**
+ * @brief Sets a callback function to be invoked when the telephony state changes.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @param[in] handle  The handle to use the telephony API
+ * @param[in] noti_id The notification ID to set the callback
+ * @param[in] cb The callback to be invoked when the telephony state changes
+ * @param[in] user_data The user data passed to the callback function
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ *
+ * @post telephony_noti_cb() will be invoked.
+ *
+ * @see telephony_unset_noti_cb()
+ */
+int telephony_set_noti_cb(telephony_h handle,
+    telephony_noti_e noti_id, telephony_noti_cb cb, void *user_data);
+
+/**
+ * @brief Unsets a callback function.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @param[in] handle  The handle to use the telephony API
+ * @param[in] noti_id The notification ID to unset a callback
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ *
+ * @see telephony_set_noti_cb()
+ */
+int telephony_unset_noti_cb(telephony_h handle, telephony_noti_e noti_id);
+
+/**
+ * @brief Acquires the list of available handles to use the telephony API.
+ *
+ * @since_tizen 2.3
+ *
+ * @remarks You will get two handles in case of dual SIM device. \n
+ *          In this case, handle[0] is mean Primary SIM and handle[1] is mean Secondary SIM.
+ *
+ * @param[out] list The list contains the number of
+ *                  available handles and array of handles
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ *
+ * @see telephony_deinit()
+ */
+int telephony_init(telephony_handle_list_s *list);
+
+/**
+ * @brief Deinitializes the telephony handle list.
+ *
+ * @since_tizen 2.3
+ *
+ * @param[in] list The handle list to be deinitialized
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ *
+ * @see telephony_init()
+ */
+int telephony_deinit(telephony_handle_list_s *list);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CAPI_TELEPHONY_COMMON_H__ */
diff --git a/include/telephony_modem.h b/include/telephony_modem.h
new file mode 100644 (file)
index 0000000..2058cf8
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011 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 __CAPI_TELEPHONY_MODEM_H__
+#define __CAPI_TELEPHONY_MODEM_H__
+
+/**
+ * @file telephony_modem.h
+ * @brief This file contains modem APIs.
+ */
+
+#include "telephony_common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup CAPI_TELEPHONY_INFORMATION_MODEM
+ * @{
+ */
+
+/**
+ * @brief Gets the IMEI (International Mobile Station Equipment Identity) of a mobile phone.
+ * @details The IMEI number is used by a GSM network to identify valid devices
+ *          and therefore can be used for stopping a stolen phone from accessing that network.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks You must release @c imei using free().
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] imei The International Mobile Station Equipment Identity
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ */
+int telephony_modem_get_imei(telephony_h handle, char **imei);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __CAPI_TELEPHONY_MODEM_H__
diff --git a/include/telephony_network.h b/include/telephony_network.h
new file mode 100644 (file)
index 0000000..039ad7f
--- /dev/null
@@ -0,0 +1,324 @@
+/*
+ * Copyright (c) 2011 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 __CAPI_TELEPHONY_NETWORK_INFO_H__
+#define __CAPI_TELEPHONY_NETWORK_INFO_H__
+
+#include "telephony_common.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @file telephony_network.h
+ * @brief This file contains the network APIs and related enumerations.
+ */
+
+/**
+ * @addtogroup CAPI_TELEPHONY_INFORMATION_NETWORK
+ * @{
+ */
+
+/**
+ * @brief Enumeration for RSSI (Receive Signal Strength Indicator).
+ * @details #TELEPHONY_NETWORK_RSSI_6 indicates the highest strength.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+    TELEPHONY_NETWORK_RSSI_0, /**< Strength 0 */
+    TELEPHONY_NETWORK_RSSI_1, /**< Strength 1 */
+    TELEPHONY_NETWORK_RSSI_2, /**< Strength 2 */
+    TELEPHONY_NETWORK_RSSI_3, /**< Strength 3 */
+    TELEPHONY_NETWORK_RSSI_4, /**< Strength 4 */
+    TELEPHONY_NETWORK_RSSI_5, /**< Strength 5 */
+    TELEPHONY_NETWORK_RSSI_6, /**< Strength 6 */
+} telephony_network_rssi_e;
+
+
+/**
+ * @brief Enumeration for Network Type.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+    TELEPHONY_NETWORK_TYPE_UNKNOWN, /**< Unknown */
+    TELEPHONY_NETWORK_TYPE_GSM,     /**< 2G GSM network type */
+    TELEPHONY_NETWORK_TYPE_GPRS,    /**< 2.5G GPRS network type */
+    TELEPHONY_NETWORK_TYPE_EDGE,    /**< 2.5G EDGE network type */
+    TELEPHONY_NETWORK_TYPE_UMTS,    /**< 3G UMTS network type */
+    TELEPHONY_NETWORK_TYPE_HSDPA,   /**< HSDPA network type */
+    TELEPHONY_NETWORK_TYPE_LTE,     /**< LTE network type */
+} telephony_network_type_e;
+
+
+/**
+ * @brief Enumeration for Network Service State.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+    TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE,     /**< In service */
+    TELEPHONY_NETWORK_SERVICE_STATE_OUT_OF_SERVICE, /**< Out of service */
+    TELEPHONY_NETWORK_SERVICE_STATE_EMERGENCY_ONLY, /**< Only emergency call is allowed */
+} telephony_network_service_state_e;
+
+/**
+ * @brief Gets the LAC (Location Area Code) of the current network.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] lac The Location Area Code
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ *
+ * @pre The Network service state must be #TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE.
+ *
+ * @see telephony_network_get_service_state()
+ */
+int telephony_network_get_lac(telephony_h handle, int *lac);
+
+/**
+ * @brief Gets the cell ID.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] cell_id The cell identification number
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ *
+ * @pre The Network service state must be #TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE.
+ *
+ * @see telephony_network_get_service_state()
+ */
+int telephony_network_get_cell_id(telephony_h handle, int *cell_id);
+
+/**
+ * @brief Gets the RSSI (Received Signal Strength Indicator).
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %%%%%http://tizen.org/privilege/telephony
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] rssi The Received Signal Strength Indicator \n
+ *                  Higher the received number, the stronger the signal strength.
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ *
+ * @pre The Network service state must be #TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE.
+ *
+ * @see telephony_network_get_service_state()
+ */
+int telephony_network_get_rssi(telephony_h handle, telephony_network_rssi_e *rssi);
+
+/**
+ * @brief Gets the roaming state.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] status @c true if roaming,
+ *                    otherwise @c false if not roaming
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ *
+ * @pre The Network service state must be #TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE.
+ *
+ * @see telephony_network_get_service_state()
+ */
+int telephony_network_get_roaming_status(telephony_h handle, bool *status);
+
+/**
+ * @brief Gets the MCC (Mobile Country Code) of the current registered network.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks You must release @c mcc using free().
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] mcc The Mobile Country Code (three digits)
+ *                 Mobile Country Code (MCC) identifies the country where the cell is being used.
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ *
+ * @pre The Network service state must be #TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE.
+ *
+ * @see telephony_network_get_service_state()
+ */
+int telephony_network_get_mcc(telephony_h handle, char **mcc);
+
+/**
+ * @brief Gets the MNC (Mobile Network Code) of the current registered network.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks You must release @c mnc using free().
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] mnc The Mobile Network Code (three digits)
+ *                 The Mobile Network Code (MNC) identifies the mobile phone operator and network provider.
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ *
+ * @pre The Network service state must be #TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE.
+ *
+ * @see telephony_network_get_service_state()
+ */
+int telephony_network_get_mnc(telephony_h handle, char **mnc);
+
+/**
+ * @brief Gets the name of the current registered network.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks You must release @c network_name using free().
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] network_name The name of the current registered network
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ *
+ * @pre The Network service state must be #TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE.
+ *
+ * @see telephony_network_get_service_state()
+ */
+int telephony_network_get_network_name(telephony_h handle, char **network_name);
+
+/**
+ * @brief Gets the network service type of the current registered network.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] network_type The network service type
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ *
+ * @pre The Network service state must be #TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE.
+ *
+ * @see telephony_network_get_service_state()
+ */
+int telephony_network_get_type(telephony_h handle,
+    telephony_network_type_e *network_type);
+
+/**
+ * @brief Gets the current network state of the telephony service.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks To know the state of data network, refer connection API.
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] network_service_state The current network state
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Operation failed
+ */
+int telephony_network_get_service_state(telephony_h handle,
+    telephony_network_service_state_e *network_service_state);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __CAPI_TELEPHONY_NETWORK_INFO_H__
diff --git a/include/telephony_private.h b/include/telephony_private.h
new file mode 100644 (file)
index 0000000..9ff0c7c
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011 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 __CAPI_TELEPHONY_PRIVATE_H__
+#define __CAPI_TELEPHONY_PRIVATE_H__
+
+#include <gio/gio.h>
+#include <glib.h>
+#include <system_info.h>
+#include "telephony_common.h"
+
+#define TELEPHONY_FEATURE      "http://tizen.org/feature/network.telephony"
+
+#define CHECK_TELEPHONY_SUPPORTED(feature_name) { \
+       bool telephony_supported = FALSE; \
+       if (!system_info_get_platform_bool(feature_name, &telephony_supported)) { \
+               if (telephony_supported == FALSE) { \
+                       LOGE("telephony feature is disabled"); \
+                       return TELEPHONY_ERROR_NOT_SUPPORTED; \
+               } \
+       } else { \
+               LOGE("Error - Feature getting from System Info"); \
+               return TELEPHONY_ERROR_OPERATION_FAILED; \
+       } \
+}
+
+typedef struct {
+       GSList *evt_list;
+       struct tapi_handle *tapi_h;
+} telephony_data;
+
+/*
+ * Need to define the struct same as tapi_handle of libslp-tapi
+ * because we are request dbus directly using dbus_connection, path
+ */
+struct tapi_handle {
+       gpointer dbus_connection;
+       char *path;
+       char *cp_name;
+       GHashTable *evt_list;
+       char cookie[20];
+       GCancellable *ca;
+
+       GHashTable *cache_property;
+       guint prop_callback_evt_id;
+};
+
+#endif /* __CAPI_TELEPHONY_PRIVATE_H__ */
diff --git a/include/telephony_sim.h b/include/telephony_sim.h
new file mode 100644 (file)
index 0000000..b7fdf7a
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2011 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 __CAPI_TELEPHONY_SIM_H__
+#define __CAPI_TELEPHONY_SIM_H__
+
+#include "telephony_common.h"
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/**
+ * @file telephony_sim.h
+ * @brief This file contains the SIM APIs and related enumerations.
+ */
+
+/**
+ * @addtogroup CAPI_TELEPHONY_INFORMATION_SIM
+ * @{
+ */
+
+/**
+ * @brief Enumeration for the state of SIM card.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+    TELEPHONY_SIM_STATE_UNAVAILABLE, /**< SIM is not available on this device */
+    TELEPHONY_SIM_STATE_LOCKED,      /**< SIM is locked */
+    TELEPHONY_SIM_STATE_AVAILABLE,   /**< SIM is available on this device */
+    TELEPHONY_SIM_STATE_UNKNOWN,     /**< SIM is in transition between states */
+} telephony_sim_state_e;
+
+/**
+ * @brief Gets the Integrated Circuit Card IDentification (ICC-ID).
+ * @details The Integrated Circuit Card Identification number internationally identifies SIM cards.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks You must release @c icc_id using free().
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] icc_id The Integrated Circuit Card Identification
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Out of memory
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Invalid parameter
+ * @retval #TELEPHONY_ERROR_SIM_NOT_AVAILABLE SIM is not available
+ *
+ * @pre The SIM state must be #TELEPHONY_SIM_STATE_AVAILABLE.
+ *
+ * @see telephony_sim_get_state()
+ */
+int telephony_sim_get_icc_id(telephony_h handle, char **icc_id);
+
+/**
+ * @brief Gets the SIM Operator (MCC [3 digits] + MNC [2~3 digits]).
+ * @details The Operator is embedded in the SIM card.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks You must release @c sim_operator using free().
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] sim_operator The SIM Operator
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Out of memory
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Invalid parameter
+ * @retval #TELEPHONY_ERROR_SIM_NOT_AVAILABLE SIM is not available
+ *
+ * @pre The SIM state must be #TELEPHONY_SIM_STATE_AVAILABLE.
+ *
+ * @see telephony_sim_get_state()
+ */
+int telephony_sim_get_operator(telephony_h handle, char **sim_operator);
+
+/**
+ * @brief Gets the Mobile Subscription Identification Number (MSIN [9~10 digits]) of the SIM provider.
+ * @details This function gets Mobile Subscription Identification Number embedded in the SIM card.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks You must release @c msin using free().
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] msin The Mobile Subscription Identification Number
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Out of memory
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Invalid parameter
+ * @retval #TELEPHONY_ERROR_SIM_NOT_AVAILABLE SIM is not available
+ *
+ * @pre The SIM state must be #TELEPHONY_SIM_STATE_AVAILABLE.
+ *
+ * @see telephony_sim_get_state()
+ */
+int telephony_sim_get_msin(telephony_h handle, char **msin);
+
+/**
+ * @brief Gets the Service Provider Name (SPN) of the SIM card.
+ * @details This function gets Service Provider Name embedded in the SIM card.
+ *          If this value is not stored in SIM card, @c NULL will be returned.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks You must release @c spn using free().
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] spn The Service Provider Name
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Out of memory
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Invalid parameter
+ * @retval #TELEPHONY_ERROR_SIM_NOT_AVAILABLE SIM is not available
+ *
+ * @pre The SIM state must be #TELEPHONY_SIM_STATE_AVAILABLE.
+ *
+ * @see telephony_sim_get_state()
+ */
+int telephony_sim_get_spn(telephony_h handle, char **spn);
+
+/**
+ * @brief Checks whether the current SIM card is different from the previous SIM card.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] is_changed @c true if the current SIM card is different from the previous SIM card,
+ *                        otherwise @c false if the SIM card is not changed
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Out of memory
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Invalid parameter
+ * @retval #TELEPHONY_ERROR_SIM_NOT_AVAILABLE SIM is not available
+ *
+ * @pre The SIM state must be #TELEPHONY_SIM_STATE_AVAILABLE.
+ *
+ * @see telephony_sim_get_state()
+ */
+int telephony_sim_is_changed(telephony_h handle, bool *is_changed);
+
+/**
+ * @brief Gets the state of the SIM.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] sim_state The current state of the SIM
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Out of memory
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Invalid parameter
+ */
+int telephony_sim_get_state(telephony_h handle, telephony_sim_state_e *sim_state);
+
+/**
+ * @brief Gets the SIM card subscriber number.
+ * @details This function gets subscriber number embedded in the SIM card.
+ *          This value contains MSISDN related to the subscriber.
+ *          If this value is not stored in SIM card, @c NULL will be returned.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/telephony
+ *
+ * @remarks You must release @c subscriber_number using free().
+ *
+ * @param[in] handle The handle from telephony_init()
+ * @param[out] subscriber_number The subscriber number in the SIM
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #TELEPHONY_ERROR_NONE              Successful
+ * @retval #TELEPHONY_ERROR_INVALID_PARAMETER Out of memory
+ * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TELEPHONY_ERROR_NOT_SUPPORTED     Not supported
+ * @retval #TELEPHONY_ERROR_OPERATION_FAILED  Invalid parameter
+ * @retval #TELEPHONY_ERROR_SIM_NOT_AVAILABLE SIM is not available
+ *
+ * @pre The SIM state must be #TELEPHONY_SIM_STATE_AVAILABLE.
+ *
+ * @see telephony_sim_get_state()
+ */
+int telephony_sim_get_subscriber_number(telephony_h handle, char **subscriber_number);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif // __CAPI_TELEPHONY_SIM_H__
diff --git a/packaging/capi-telephony.spec b/packaging/capi-telephony.spec
new file mode 100644 (file)
index 0000000..112e4aa
--- /dev/null
@@ -0,0 +1,59 @@
+Name:       capi-telephony
+Summary:    Telephony Core API
+Version: 0.1.27
+Release:    2
+Group:      TO_BE/FILLED_IN
+License:    TO BE FILLED IN
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(tapi)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(capi-system-info)
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+
+%package devel
+Summary:  Telephony Core API
+Group:    TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+
+%prep
+%setup -q
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+mkdir -p %{buildroot}/usr/share/license
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest capi-telephony.manifest
+%{_libdir}/libcapi-telephony.so.*
+/usr/share/license/capi-telephony
+
+%files devel
+%{_includedir}/telephony/telephony.h
+%{_includedir}/telephony/telephony_common.h
+%{_includedir}/telephony/telephony_call.h
+%{_includedir}/telephony/telephony_sim.h
+%{_includedir}/telephony/telephony_network.h
+%{_includedir}/telephony/telephony_modem.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/libcapi-telephony.so
+
+
diff --git a/src/telephony_call.c b/src/telephony_call.c
new file mode 100644 (file)
index 0000000..7e6ca6e
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2014 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 <string.h>
+#include <glib.h>
+#include <dlog.h>
+
+#include <tapi_common.h>
+#include <TapiUtility.h>
+#include <ITapiCall.h>
+#include "telephony_common.h"
+#include "telephony_call.h"
+#include "telephony_private.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CAPI_TELEPHONY"
+
+#define CHECK_INPUT_PARAMETER(arg) \
+       if (arg == NULL) { \
+               LOGE("INVALID_PARAMETER"); \
+               return TELEPHONY_ERROR_INVALID_PARAMETER; \
+       }
+
+static void _mapping_call_state(TelCallStates_t tapi_call_state, telephony_call_state_e *call_state)
+{
+       switch (tapi_call_state) {
+       case TAPI_CALL_STATE_ACTIVE:
+       case TAPI_CALL_STATE_HELD:
+               if (*call_state != TELEPHONY_CALL_STATE_CONNECTING)
+                       *call_state = TELEPHONY_CALL_STATE_CONNECTED;
+               break;
+       case TAPI_CALL_STATE_DIALING:
+       case TAPI_CALL_STATE_ALERT:
+       case TAPI_CALL_STATE_INCOMING:
+       case TAPI_CALL_STATE_WAITING:
+               *call_state = TELEPHONY_CALL_STATE_CONNECTING;
+               break;
+       /* Do not check IDLE state to prevent overriding in case of multi-party call */
+       default:
+               LOGE("Not handled call state: [%d]", tapi_call_state);
+               break;
+       }
+}
+
+static void _voice_call_get_state_cb(TelCallStatus_t *tapi_status, void *user_data)
+{
+       telephony_call_state_e *call_state = user_data;
+
+       if (tapi_status->CallType != TAPI_CALL_TYPE_VOICE
+                       && tapi_status->CallType != TAPI_CALL_TYPE_E911)
+               return;
+
+       _mapping_call_state(tapi_status->CallState, call_state);
+}
+
+static void _video_call_get_state_cb(TelCallStatus_t *tapi_status, void *user_data)
+{
+       telephony_call_state_e *call_state = user_data;
+
+       if (tapi_status->CallType != TAPI_CALL_TYPE_DATA)
+               return;
+
+       _mapping_call_state(tapi_status->CallState, call_state);
+}
+
+int telephony_call_get_voice_call_state(telephony_h handle, telephony_call_state_e *call_state)
+{
+       int ret;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(call_state);
+
+       *call_state = TELEPHONY_CALL_STATE_IDLE;
+
+       ret = tel_get_call_status_all(tapi_h, _voice_call_get_state_cb, call_state);
+       if (ret == TAPI_API_ACCESS_DENIED) {
+               LOGE("PERMISSION_DENIED");
+               return TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else if (ret != TAPI_API_SUCCESS) {
+               LOGE("OPERATION_FAILED");
+               return TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       LOGI("call_state: [%d]", *call_state);
+
+       return TELEPHONY_ERROR_NONE;
+}
+
+int telephony_call_get_video_call_state(telephony_h handle, telephony_call_state_e *call_state)
+{
+       int ret;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(call_state);
+
+       *call_state = TELEPHONY_CALL_STATE_IDLE;
+
+       ret = tel_get_call_status_all(tapi_h, _video_call_get_state_cb, call_state);
+       if (ret == TAPI_API_ACCESS_DENIED) {
+               LOGE("PERMISSION_DENIED");
+               return TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else if (ret != TAPI_API_SUCCESS) {
+               LOGE("OPERATION_FAILED");
+               return TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       LOGI("call_state: [%d]", *call_state);
+
+       return TELEPHONY_ERROR_NONE;
+}
diff --git a/src/telephony_common.c b/src/telephony_common.c
new file mode 100644 (file)
index 0000000..7208473
--- /dev/null
@@ -0,0 +1,430 @@
+/*
+ * Copyright (c) 2014 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 "telephony_common.h"
+#include "telephony_sim.h"
+#include "telephony_call.h"
+#include "telephony_network.h"
+#include "telephony_private.h"
+#include <gio/gio.h>
+#include <dlog.h>
+
+#include <tapi_common.h>
+#include <TelSim.h>
+#include <TelNetwork.h>
+#include <TapiUtility.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CAPI_TELEPHONY"
+
+#define CALLBACK_CALL(data) \
+       if (evt_cb_data->cb) { \
+               evt_cb_data->cb(evt_cb_data->handle, \
+                        evt_cb_data->noti_id, data, evt_cb_data->user_data); \
+       }
+
+#define CHECK_INPUT_PARAMETER(arg) \
+       if (arg == NULL) { \
+               LOGE("INVALID_PARAMETER"); \
+               return TELEPHONY_ERROR_INVALID_PARAMETER; \
+       }
+
+typedef struct {
+       telephony_h handle;
+       telephony_noti_e noti_id;
+       telephony_noti_cb cb;
+       void *user_data;
+} telephony_evt_cb_data;
+
+static const char *voice_call_state_tbl[] = {
+       TAPI_NOTI_VOICE_CALL_STATUS_IDLE,
+       TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE,
+       TAPI_NOTI_VOICE_CALL_STATUS_HELD,
+       TAPI_NOTI_VOICE_CALL_STATUS_DIALING,
+       TAPI_NOTI_VOICE_CALL_STATUS_ALERT,
+       TAPI_NOTI_VOICE_CALL_STATUS_INCOMING
+};
+
+static const char *video_call_state_tbl[] = {
+       TAPI_NOTI_VIDEO_CALL_STATUS_IDLE,
+       TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE,
+       TAPI_NOTI_VIDEO_CALL_STATUS_DIALING,
+       TAPI_NOTI_VIDEO_CALL_STATUS_ALERT,
+       TAPI_NOTI_VIDEO_CALL_STATUS_INCOMING
+};
+
+static const char *_mapping_noti_id(telephony_noti_e noti_id)
+{
+       switch (noti_id) {
+       case TELEPHONY_NOTI_SIM_STATUS:
+               return TAPI_NOTI_SIM_STATUS;
+       case TELEPHONY_NOTI_NETWORK_SERVICE_STATE:
+               return TAPI_PROP_NETWORK_SERVICE_TYPE;
+       case TELEPHONY_NOTI_NETWORK_CELLID:
+               return TAPI_PROP_NETWORK_CELLID;
+       case TELEPHONY_NOTI_NETWORK_ROAMING_STATUS:
+               return TAPI_PROP_NETWORK_ROAMING_STATUS;
+       case TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL:
+               return TAPI_PROP_NETWORK_SIGNALSTRENGTH_LEVEL;
+       default:
+               return NULL;
+       }
+}
+
+static int _mapping_sim_status(TelSimCardStatus_t tapi_sim_status)
+{
+       int sim_status;
+
+       switch (tapi_sim_status) {
+       case TAPI_SIM_STATUS_CARD_ERROR:
+       case TAPI_SIM_STATUS_CARD_NOT_PRESENT:
+       case TAPI_SIM_STATUS_CARD_BLOCKED:
+       case TAPI_SIM_STATUS_CARD_REMOVED:
+       case TAPI_SIM_STATUS_CARD_CRASHED:
+               sim_status = TELEPHONY_SIM_STATE_UNAVAILABLE;
+               break;
+       case TAPI_SIM_STATUS_SIM_PIN_REQUIRED:
+       case TAPI_SIM_STATUS_SIM_PUK_REQUIRED:
+       case TAPI_SIM_STATUS_SIM_NCK_REQUIRED:
+       case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED:
+       case TAPI_SIM_STATUS_SIM_SPCK_REQUIRED:
+       case TAPI_SIM_STATUS_SIM_CCK_REQUIRED:
+       case TAPI_SIM_STATUS_SIM_LOCK_REQUIRED:
+               sim_status = TELEPHONY_SIM_STATE_LOCKED;
+               break;
+       case TAPI_SIM_STATUS_SIM_INIT_COMPLETED:
+               sim_status = TELEPHONY_SIM_STATE_AVAILABLE;
+               break;
+       case TAPI_SIM_STATUS_UNKNOWN:
+       case TAPI_SIM_STATUS_SIM_INITIALIZING:
+       default:
+               sim_status = TELEPHONY_SIM_STATE_UNKNOWN;
+               break;
+       }
+
+       return sim_status;
+}
+
+static int _mapping_service_state(int tapi_service_type)
+{
+       int service_state;
+
+       switch (tapi_service_type) {
+       case TAPI_NETWORK_SERVICE_TYPE_UNKNOWN:
+       case TAPI_NETWORK_SERVICE_TYPE_NO_SERVICE:
+       case TAPI_NETWORK_SERVICE_TYPE_SEARCH:
+               service_state = TELEPHONY_NETWORK_SERVICE_STATE_OUT_OF_SERVICE;
+               break;
+       case TAPI_NETWORK_SERVICE_TYPE_EMERGENCY:
+               service_state = TELEPHONY_NETWORK_SERVICE_STATE_EMERGENCY_ONLY;
+               break;
+       default:
+               service_state = TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE;
+               break;
+       }
+
+       return service_state;
+}
+
+static telephony_error_e __deregister_all_noti(telephony_h handle, telephony_noti_e noti_id)
+{
+       const char *tapi_noti;
+       int ret, i;
+       TapiHandle *tapi_h;
+
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+
+       tapi_noti = _mapping_noti_id(noti_id);
+       if (tapi_noti == NULL && noti_id != TELEPHONY_NOTI_VOICE_CALL_STATE
+                       && noti_id != TELEPHONY_NOTI_VIDEO_CALL_STATE) {
+               LOGE("Not supported noti_id");
+               return TELEPHONY_ERROR_INVALID_PARAMETER;
+       }
+
+       /* Deregister all TAPI_NOTI_VOICE/VIDEO_CALL_STATUS_xxx notification */
+       if (noti_id == TELEPHONY_NOTI_VOICE_CALL_STATE) {
+               int count = sizeof(voice_call_state_tbl) / sizeof(char *);
+               for (i = 0; i < count; i++) {
+                       ret = tel_deregister_noti_event(tapi_h, voice_call_state_tbl[i]);
+                       if (ret != TAPI_API_SUCCESS) {
+                               LOGE("Noti [%s] deregistration failed", voice_call_state_tbl[i]);
+                       }
+               }
+       } else if (noti_id == TELEPHONY_NOTI_VIDEO_CALL_STATE) {
+               int count = sizeof(video_call_state_tbl) / sizeof(char *);
+               for (i = 0; i < count; i++) {
+                       ret = tel_deregister_noti_event(tapi_h, video_call_state_tbl[i]);
+                       if (ret != TAPI_API_SUCCESS) {
+                               LOGE("Noti [%s] deregistration failed", video_call_state_tbl[i]);
+                       }
+               }
+       } else {
+               /* Deregister other notifications */
+               ret = tel_deregister_noti_event(tapi_h, tapi_noti);
+               if (ret != TAPI_API_SUCCESS) {
+                       LOGE("Noti [%s] deregistration failed", tapi_noti);
+               }
+       }
+
+       return TELEPHONY_ERROR_NONE;
+}
+
+static void _deregister_noti(gpointer data)
+{
+       telephony_evt_cb_data *evt_cb_data = data;
+
+       if (evt_cb_data != NULL) {
+               /* Deregister all TAPI_NOTI_VOICE/VIDEO_CALL_STATUS_xxx notification */
+               if (__deregister_all_noti(evt_cb_data->handle, evt_cb_data->noti_id)
+                               == TELEPHONY_ERROR_NONE) {
+                       LOGI("De-registered noti_id: [%d]", evt_cb_data->noti_id);
+               }
+
+               /* Free evt_cb_data */
+               g_free(evt_cb_data);
+       }
+}
+
+static void on_signal_callback(TapiHandle *tapi_h, const char *evt_id,
+       void *data, void *user_data)
+{
+       telephony_evt_cb_data *evt_cb_data = user_data;
+
+       if (evt_cb_data == NULL) {
+               LOGE("evt_cb_data is NULL");
+               return;
+       }
+
+       if (!g_strcmp0(evt_id, TAPI_NOTI_SIM_STATUS)) {
+               int sim_status = _mapping_sim_status(*(TelSimCardStatus_t *)data);
+               CALLBACK_CALL(&sim_status);
+       } else if (!g_strcmp0(evt_id, TAPI_PROP_NETWORK_SERVICE_TYPE)) {
+               int service_state = _mapping_service_state(*(int *)data);
+               CALLBACK_CALL(&service_state);
+       } else if (!g_strcmp0(evt_id, TAPI_PROP_NETWORK_CELLID)) {
+               int cell_id = *(int *)data;
+               CALLBACK_CALL(&cell_id);
+       } else if (!g_strcmp0(evt_id, TAPI_PROP_NETWORK_ROAMING_STATUS)) {
+               int roaming_status = *(int *)data;
+               CALLBACK_CALL(&roaming_status);
+       } else if (!g_strcmp0(evt_id, TAPI_PROP_NETWORK_SIGNALSTRENGTH_LEVEL)) {
+               int rssi = *(int *)data;
+               CALLBACK_CALL(&rssi);
+       } else if (!g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_IDLE)
+                       || !g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE)
+                       || !g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_HELD)
+                       || !g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_DIALING)
+                       || !g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_ALERT)
+                       || !g_strcmp0(evt_id, TAPI_NOTI_VOICE_CALL_STATUS_INCOMING)) {
+               telephony_call_state_e call_state;
+               telephony_call_get_voice_call_state(evt_cb_data->handle, &call_state);
+               CALLBACK_CALL(&call_state);
+       } else if (!g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_IDLE)
+                       || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE)
+                       || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_DIALING)
+                       || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_ALERT)
+                       || !g_strcmp0(evt_id, TAPI_NOTI_VIDEO_CALL_STATUS_INCOMING)) {
+               telephony_call_state_e call_state;
+               telephony_call_get_video_call_state(evt_cb_data->handle, &call_state);
+               CALLBACK_CALL(&call_state);
+       } else {
+               LOGE("Unhandled noti: [%s]", evt_id);
+       }
+}
+
+int telephony_set_noti_cb(telephony_h handle,
+       telephony_noti_e noti_id, telephony_noti_cb cb, void *user_data)
+{
+       telephony_evt_cb_data *evt_cb_data = NULL;
+       const char *tapi_noti;
+       int ret, i;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+
+       LOGI("Entry");
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+
+       /* Mapping TAPI notification */
+       tapi_noti = _mapping_noti_id(noti_id);
+       if (tapi_noti == NULL && noti_id != TELEPHONY_NOTI_VOICE_CALL_STATE
+                       && noti_id != TELEPHONY_NOTI_VIDEO_CALL_STATE) {
+               LOGE("Not supported noti_id");
+               return TELEPHONY_ERROR_INVALID_PARAMETER;
+       }
+
+       /* Make evt_cb_data */
+       evt_cb_data = g_new0(telephony_evt_cb_data, 1);
+       evt_cb_data->handle = handle;
+       evt_cb_data->noti_id = noti_id;
+       evt_cb_data->cb = cb;
+       evt_cb_data->user_data = user_data;
+
+       /*
+        * In case of register Call State notification,
+        * we should take care of all TAPI_NOTI_VOICE/VIDEO_CALL_STATUS_xxx notification
+        */
+       if (noti_id == TELEPHONY_NOTI_VOICE_CALL_STATE) {
+               int count = sizeof(voice_call_state_tbl) / sizeof(char *);
+               for (i = 0; i < count; i++) {
+                       ret = tel_register_noti_event(tapi_h, voice_call_state_tbl[i], on_signal_callback, evt_cb_data);
+                       if (ret != TAPI_API_SUCCESS) {
+                               LOGE("Noti registration failed");
+                               g_free(evt_cb_data);
+                               return TELEPHONY_ERROR_OPERATION_FAILED;
+                       }
+               }
+       } else if (noti_id == TELEPHONY_NOTI_VIDEO_CALL_STATE) {
+               int count = sizeof(video_call_state_tbl) / sizeof(char *);
+               for (i = 0; i < count; i++) {
+                       ret = tel_register_noti_event(tapi_h, video_call_state_tbl[i], on_signal_callback, evt_cb_data);
+                       if (ret != TAPI_API_SUCCESS) {
+                               LOGE("Noti registration failed");
+                               g_free(evt_cb_data);
+                               return TELEPHONY_ERROR_OPERATION_FAILED;
+                       }
+               }
+       } else { /* Register other notifications */
+               ret = tel_register_noti_event(tapi_h, tapi_noti, on_signal_callback, evt_cb_data);
+               if (ret != TAPI_API_SUCCESS) {
+                       LOGE("Noti registration failed");
+                       g_free(evt_cb_data);
+                       return TELEPHONY_ERROR_OPERATION_FAILED;
+               }
+       }
+
+       /* Append evt_cb_data to free */
+       ((telephony_data *)handle)->evt_list = g_slist_append(((telephony_data *)handle)->evt_list, evt_cb_data);
+
+       return TELEPHONY_ERROR_NONE;
+}
+
+int telephony_unset_noti_cb(telephony_h handle, telephony_noti_e noti_id)
+{
+       telephony_evt_cb_data *evt_cb_data = NULL;
+       GSList *list = NULL;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+
+       LOGI("Entry");
+
+       /* Deregister all TAPI_NOTI_VOICE/VIDEO_CALL_STATUS_xxx notification */
+       if (__deregister_all_noti(handle, noti_id) != TELEPHONY_ERROR_NONE) {
+               LOGE("De-registration failed");
+               return TELEPHONY_ERROR_INVALID_PARAMETER;
+       }
+       LOGI("De-registered noti_id: [%d]", noti_id);
+
+       /* Free evt_cb_data */
+       list = g_slist_nth(((telephony_data *)handle)->evt_list, 0);
+       while (list) {
+               evt_cb_data = list->data;
+               if (evt_cb_data->noti_id == noti_id) {
+                       ((telephony_data *)handle)->evt_list = g_slist_remove(((telephony_data *)handle)->evt_list, evt_cb_data);
+                       g_free(evt_cb_data);
+                       break;
+               }
+
+               list = g_slist_next(list);
+       }
+
+       return TELEPHONY_ERROR_NONE;
+}
+
+int telephony_init(telephony_handle_list_s *list)
+{
+       char **cp_list;
+       int cp_count = 0;
+       int i;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(list);
+
+       /* Need g_type_init() to use tel_get_cp_name_list() */
+       g_type_init();
+
+       cp_list = tel_get_cp_name_list();
+       if (cp_list == NULL) {
+               LOGE("cp_list is NULL");
+               return TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       while (cp_list[cp_count]) {
+               cp_count++;
+       }
+
+       list->count = cp_count;
+       list->handle = g_malloc(cp_count * sizeof(telephony_h));
+       for (i = 0; i < cp_count; i++) {
+               telephony_data *tmp = g_malloc(sizeof(telephony_data));
+               tmp->evt_list = NULL;
+               tmp->tapi_h = tel_init(cp_list[i]);
+               if (tmp->tapi_h == NULL) {
+                       int j = 0;
+                       LOGE("handle is NULL");
+                       for (; j < i; j++) {
+                               /* Need to free already allocated data */
+                               if (list->handle[j]) {
+                                       tel_deinit(((telephony_data *)list->handle[j])->tapi_h);
+                                       g_free(list->handle[j]);
+                               }
+                       }
+                       g_free(tmp);
+                       g_free(list->handle);
+                       list->handle = NULL;
+                       list->count = 0;
+                       g_strfreev(cp_list);
+                       return TELEPHONY_ERROR_OPERATION_FAILED;
+               }
+               list->handle[i] = (telephony_h)tmp;
+       }
+       g_strfreev(cp_list);
+
+       return TELEPHONY_ERROR_NONE;
+}
+
+int telephony_deinit(telephony_handle_list_s *list)
+{
+       unsigned int i;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(list);
+
+       for (i = 0; i < list->count; i++) {
+               telephony_data *tmp = (telephony_data *)list->handle[i];
+
+               /* De-init all TapiHandle */
+               tel_deinit(tmp->tapi_h);
+               tmp->tapi_h = NULL;
+
+               /* De-register all registered events */
+               g_slist_free_full(tmp->evt_list, _deregister_noti);
+               tmp->evt_list = NULL;
+
+               /* Free handle[i] */
+               g_free(list->handle[i]);
+       }
+       g_free(list->handle);
+       list->handle = NULL;
+       list->count = 0;
+
+       return TELEPHONY_ERROR_NONE;
+}
diff --git a/src/telephony_modem.c b/src/telephony_modem.c
new file mode 100644 (file)
index 0000000..07ab0e8
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2014 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 <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <dlog.h>
+
+#include <tapi_common.h>
+#include <ITapiModem.h>
+#include "telephony_common.h"
+#include "telephony_modem.h"
+#include "telephony_private.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CAPI_TELEPHONY"
+
+#define CHECK_INPUT_PARAMETER(arg) \
+       if (arg == NULL) { \
+               LOGE("INVALID_PARAMETER"); \
+               return TELEPHONY_ERROR_INVALID_PARAMETER; \
+       }
+
+int telephony_modem_get_imei(telephony_h handle, char **imei)
+{
+       GVariant *gv = NULL;
+       GError *gerr = NULL;
+       int tapi_result;
+       char *tapi_imei;
+       int error = TELEPHONY_ERROR_OPERATION_FAILED;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(imei);
+
+       gv = g_dbus_connection_call_sync(tapi_h->dbus_connection,
+               DBUS_TELEPHONY_SERVICE, tapi_h->path, DBUS_TELEPHONY_MODEM_INTERFACE,
+               "GetIMEI", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &gerr);
+
+       if (gv) {
+               g_variant_get(gv, "(is)", &tapi_result, &tapi_imei);
+               if (tapi_result == 0) {
+                       if (tapi_imei != NULL && strlen(tapi_imei) != 0) {
+                               *imei = g_strdup_printf("%s", tapi_imei);
+                               error = TELEPHONY_ERROR_NONE;
+                       }
+               }
+       } else {
+               LOGE("g_dbus_conn failed. error (%s)", gerr->message);
+               if (strstr(gerr->message, "No access rights")) {
+                       LOGE("PERMISSION_DENIED");
+                       error = TELEPHONY_ERROR_PERMISSION_DENIED;
+               }
+       }
+
+       return error;
+}
diff --git a/src/telephony_network.c b/src/telephony_network.c
new file mode 100644 (file)
index 0000000..728dd73
--- /dev/null
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2011 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 <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <glib.h>
+#include <dlog.h>
+#include <tapi_common.h>
+#include <TapiUtility.h>
+#include <TelNetwork.h>
+#include "telephony_network.h"
+#include "telephony_common.h"
+#include "telephony_private.h"
+
+#include <sys/types.h>
+#include <unistd.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CAPI_TELEPHONY"
+
+#define CHECK_INPUT_PARAMETER(arg) \
+       if (arg == NULL) { \
+               LOGE("INVALID_PARAMETER"); \
+               return TELEPHONY_ERROR_INVALID_PARAMETER; \
+       }
+
+int telephony_network_get_lac(telephony_h handle, int *lac)
+{
+       int ret;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(lac);
+
+       ret = tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_LAC, lac);
+       if (ret == TAPI_API_SUCCESS) {
+               LOGI("lac:[%d]", *lac);
+               ret = TELEPHONY_ERROR_NONE;
+       } else if (ret == TAPI_API_ACCESS_DENIED) {
+               LOGE("PERMISSION_DENIED");
+               ret = TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else {
+               LOGE("OPERATION_FAILED");
+               ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       return ret;
+}
+
+int telephony_network_get_cell_id(telephony_h handle, int *cell_id)
+{
+       int ret;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(cell_id);
+
+       ret = tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_CELLID, cell_id);
+       if (ret == TAPI_API_SUCCESS) {
+               LOGI("cell_id:[%d]", *cell_id);
+               ret = TELEPHONY_ERROR_NONE;
+       } else if (ret == TAPI_API_ACCESS_DENIED) {
+               LOGE("PERMISSION_DENIED");
+               ret = TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else {
+               LOGE("OPERATION_FAILED");
+               ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       return ret;
+}
+
+int telephony_network_get_rssi(telephony_h handle, telephony_network_rssi_e *rssi)
+{
+       int ret;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(rssi);
+
+       ret = tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_SIGNALSTRENGTH_LEVEL, (int *)rssi);
+       if (ret == TAPI_API_SUCCESS) {
+               LOGI("rssi:[%d]", *rssi);
+               ret = TELEPHONY_ERROR_NONE;
+       } else if (ret == TAPI_API_ACCESS_DENIED) {
+               LOGE("PERMISSION_DENIED");
+               ret = TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else {
+               LOGE("OPERATION_FAILED");
+               ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       return ret;
+}
+
+int telephony_network_get_roaming_status(telephony_h handle, bool *status)
+{
+       int ret;
+       int temp = 0;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(status);
+
+       ret = tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_ROAMING_STATUS, &temp);
+       if (ret == TAPI_API_SUCCESS) {
+               if (temp == 1)
+                       *status = true;
+               else
+                       *status = false;
+               LOGI("status:[%d]", *status);
+               ret = TELEPHONY_ERROR_NONE;
+       } else if (ret == TAPI_API_ACCESS_DENIED) {
+               LOGE("PERMISSION_DENIED");
+               ret = TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else {
+               LOGE("OPERATION_FAILED");
+               ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       return ret;
+}
+
+int telephony_network_get_mcc(telephony_h handle, char **mcc)
+{
+       int ret;
+       char *plmn_str = NULL;
+       int mcc_length = 3;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(mcc);
+
+       ret = tel_get_property_string(tapi_h, TAPI_PROP_NETWORK_PLMN, &plmn_str);
+       if (ret == TAPI_API_SUCCESS) {
+               *mcc = malloc (sizeof(char) * (mcc_length + 1));
+               if (*mcc == NULL) {
+                       LOGE("OUT_OF_MEMORY");
+                       ret = TELEPHONY_ERROR_OUT_OF_MEMORY;
+               } else {
+                       memset (*mcc, 0x00, mcc_length + 1);
+                       strncpy (*mcc, plmn_str, mcc_length);
+                       free (plmn_str);
+
+                       LOGI("mcc:[%s]", *mcc);
+                       ret = TELEPHONY_ERROR_NONE;
+               }
+       } else if (ret == TAPI_API_ACCESS_DENIED) {
+               LOGE("PERMISSION_DENIED");
+               ret = TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else {
+               LOGE("OPERATION_FAILED");
+               ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       return ret;
+}
+
+int telephony_network_get_mnc(telephony_h handle, char **mnc)
+{
+       int ret;
+       char *plmn_str = NULL;
+       int plmn_length;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(mnc);
+
+       ret = tel_get_property_string(tapi_h, TAPI_PROP_NETWORK_PLMN, &plmn_str);
+       if (ret == TAPI_API_SUCCESS) {
+               plmn_length = strlen(plmn_str);
+               LOGI("plmn:[%s], length:[%d]", plmn_str, plmn_length);
+
+               *mnc = malloc (sizeof(char) * (plmn_length -3 + 1));
+               if (*mnc == NULL) {
+                       LOGE("OUT_OF_MEMORY");
+                       ret = TELEPHONY_ERROR_OUT_OF_MEMORY;
+               } else {
+                       memset (*mnc, 0x00, (plmn_length -3 + 1));
+                       strncpy (*mnc, plmn_str + 3, (plmn_length -3 + 1));
+                       free (plmn_str);
+
+                       LOGI("mnc:[%s]", *mnc);
+                       ret = TELEPHONY_ERROR_NONE;
+               }
+       } else if (ret == TAPI_API_ACCESS_DENIED) {
+               LOGE("PERMISSION_DENIED");
+               ret = TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else {
+               LOGE("OPERATION_FAILED");
+               ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       return ret;
+}
+
+int telephony_network_get_network_name(telephony_h handle, char **network_name)
+{
+       int ret;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(network_name);
+
+       ret = tel_get_property_string(tapi_h, TAPI_PROP_NETWORK_NETWORK_NAME, network_name);
+       if (ret == TAPI_API_SUCCESS) {
+               LOGI("network_name:[%s]", *network_name);
+               ret = TELEPHONY_ERROR_NONE;
+       } else if (ret == TAPI_API_ACCESS_DENIED) {
+               LOGE("PERMISSION_DENIED");
+               ret = TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else {
+               LOGE("OPERATION_FAILED");
+               ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       return ret;
+}
+
+int telephony_network_get_type(telephony_h handle, telephony_network_type_e *network_type)
+{
+       int ret;
+       int service_type = 0;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(network_type);
+
+       ret = tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_SERVICE_TYPE, &service_type);
+       if (ret == TAPI_API_SUCCESS) {
+               switch (service_type) {
+               case TAPI_NETWORK_SERVICE_TYPE_2G:
+                       *network_type = TELEPHONY_NETWORK_TYPE_GSM;
+                       break;
+               case TAPI_NETWORK_SERVICE_TYPE_2_5G:
+                       *network_type = TELEPHONY_NETWORK_TYPE_GPRS;
+                       break;
+               case TAPI_NETWORK_SERVICE_TYPE_2_5G_EDGE:
+                       *network_type = TELEPHONY_NETWORK_TYPE_EDGE;
+                       break;
+               case TAPI_NETWORK_SERVICE_TYPE_3G:
+                       *network_type = TELEPHONY_NETWORK_TYPE_UMTS;
+                       break;
+               case TAPI_NETWORK_SERVICE_TYPE_HSDPA:
+                       *network_type = TELEPHONY_NETWORK_TYPE_HSDPA;
+                       break;
+               case TAPI_NETWORK_SERVICE_TYPE_LTE:
+                       *network_type = TELEPHONY_NETWORK_TYPE_LTE;
+                       break;
+               default:
+                       *network_type = TELEPHONY_NETWORK_TYPE_UNKNOWN;
+                       break;
+               }
+
+               LOGI("network_type:[%d]", *network_type);
+               ret = TELEPHONY_ERROR_NONE;
+       } else if (ret == TAPI_API_ACCESS_DENIED) {
+               LOGE("PERMISSION_DENIED");
+               ret = TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else {
+               LOGE("OPERATION_FAILED");
+               ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       return ret;
+}
+
+int telephony_network_get_service_state(telephony_h handle, telephony_network_service_state_e *network_service_state)
+{
+       int ret;
+       int service_type = 0;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(network_service_state);
+
+       ret = tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_SERVICE_TYPE, &service_type);
+       if (ret == TAPI_API_SUCCESS) {
+               switch (service_type) {
+               case TAPI_NETWORK_SERVICE_TYPE_UNKNOWN:
+               case TAPI_NETWORK_SERVICE_TYPE_NO_SERVICE:
+               case TAPI_NETWORK_SERVICE_TYPE_SEARCH:
+                       *network_service_state = TELEPHONY_NETWORK_SERVICE_STATE_OUT_OF_SERVICE;
+                       break;
+               case TAPI_NETWORK_SERVICE_TYPE_EMERGENCY:
+                       *network_service_state = TELEPHONY_NETWORK_SERVICE_STATE_EMERGENCY_ONLY;
+                       break;
+               default:
+                       *network_service_state = TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE;
+                       break;
+               }
+               LOGI("network_service_state:[%d]", *network_service_state);
+               ret = TELEPHONY_ERROR_NONE;
+       } else if (ret == TAPI_API_ACCESS_DENIED) {
+               LOGE("PERMISSION_DENIED");
+               ret = TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else {
+               LOGE("OPERATION_FAILED");
+               ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       return ret;
+}
diff --git a/src/telephony_sim.c b/src/telephony_sim.c
new file mode 100644 (file)
index 0000000..4ff0518
--- /dev/null
@@ -0,0 +1,403 @@
+/*
+ * Copyright (c) 2011 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 <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <dlog.h>
+
+#include <tapi_common.h>
+#include <TapiUtility.h>
+#include <ITapiSim.h>
+#include "telephony_sim.h"
+#include "telephony_private.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CAPI_TELEPHONY"
+
+#define DBUS_SIM_STATUS_ERROR "SIM STATUS ERROR"
+#define DBUS_SIM_NOT_FOUND "SIM NOT FOUND"
+#define DBUS_SIM_PERM_BLOCKED "SIM PERM BLOCKED"
+#define DBUS_SIM_CARD_ERROR "SIM CARD ERROR"
+#define DBUS_SIM_NOT_INITIALIZED "SIM NOT INITIALIZED"
+#define DBUS_SIM_INIT_COMPLETED "SIM INIT COMPLETED"
+#define DBUS_SIM_LOCKED "SIM LOCKED"
+#define DBUS_SIM_NOT_READY "SIM NOT READY"
+#define DBUS_SIM_RESPONSE_DATA_ERROR "SIM RESPONSE DATA ERROR"
+#define DBUS_SIM_ACCESS_DENIED "No access rights"
+
+#define CHECK_INPUT_PARAMETER(arg) \
+       if (arg == NULL) { \
+               LOGE("INVALID_PARAMETER"); \
+               return TELEPHONY_ERROR_INVALID_PARAMETER; \
+       }
+
+#define GET_SIM_STATUS(tapi_h, sim_card_state) { \
+       int card_changed = 0; \
+       int ret = tel_get_sim_init_info(tapi_h, &sim_card_state, &card_changed); \
+       if (ret == TAPI_API_ACCESS_DENIED) { \
+               LOGE("PERMISSION_DENIED"); \
+               return TELEPHONY_ERROR_PERMISSION_DENIED; \
+       } else if (ret != TAPI_API_SUCCESS) { \
+               LOGE("OPERATION_FAILED"); \
+               return TELEPHONY_ERROR_OPERATION_FAILED; \
+       } \
+}
+
+static telephony_error_e _convert_dbus_errmsg_to_sim_error(gchar *err_msg)
+{
+       telephony_error_e ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       if (err_msg == NULL)
+               return ret;
+
+       if (strstr(err_msg, DBUS_SIM_NOT_FOUND)) {
+               ret = TELEPHONY_ERROR_SIM_NOT_AVAILABLE;
+       } else if (strstr(err_msg, DBUS_SIM_PERM_BLOCKED)) {
+               ret = TELEPHONY_ERROR_SIM_NOT_AVAILABLE;
+       } else if (strstr(err_msg, DBUS_SIM_CARD_ERROR)) {
+               ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       } else if (strstr(err_msg, DBUS_SIM_NOT_INITIALIZED)) {
+               ret = TELEPHONY_ERROR_SIM_NOT_AVAILABLE;
+       } else if (strstr(err_msg, DBUS_SIM_INIT_COMPLETED)) {
+               ret = TELEPHONY_ERROR_NONE;
+       } else if (strstr(err_msg, DBUS_SIM_LOCKED)) {
+               ret = TELEPHONY_ERROR_SIM_NOT_AVAILABLE;
+       } else if (strstr(err_msg, DBUS_SIM_NOT_READY)) {
+               ret = TELEPHONY_ERROR_SIM_NOT_AVAILABLE;
+       } else if (strstr(err_msg, DBUS_SIM_RESPONSE_DATA_ERROR)) {
+               ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       } else if (strstr(err_msg, DBUS_SIM_ACCESS_DENIED)) {
+               LOGE("PERMISSION_DENIED");
+               ret = TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else {
+               ret = TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       return ret;
+}
+
+int telephony_sim_get_icc_id(telephony_h handle, char **icc_id)
+{
+       int error_code = TELEPHONY_ERROR_NONE;
+       TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(icc_id);
+       GET_SIM_STATUS(tapi_h, sim_card_state);
+
+       if (sim_card_state == TAPI_SIM_STATUS_CARD_ERROR
+                       || sim_card_state == TAPI_SIM_STATUS_CARD_BLOCKED
+                       || sim_card_state == TAPI_SIM_STATUS_CARD_NOT_PRESENT
+                       || sim_card_state == TAPI_SIM_STATUS_CARD_REMOVED
+                       || sim_card_state == TAPI_SIM_STATUS_UNKNOWN) {
+               *icc_id = NULL;
+               error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE;
+       } else {
+               GError *gerr = NULL;
+               GVariant *sync_gv = NULL;
+               gchar *iccid = NULL;
+               TelSimAccessResult_t result = TAPI_SIM_ACCESS_SUCCESS;
+
+               sync_gv = g_dbus_connection_call_sync(tapi_h->dbus_connection,
+                       DBUS_TELEPHONY_SERVICE, tapi_h->path, DBUS_TELEPHONY_SIM_INTERFACE,
+                       "GetICCID", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &gerr);
+
+               if (sync_gv) {
+                       g_variant_get(sync_gv, "(is)", &result, &iccid);
+                       if (result == TAPI_SIM_ACCESS_SUCCESS) {
+                               if (iccid != NULL && strlen(iccid) != 0) {
+                                       *icc_id = g_strdup_printf("%s", iccid);
+                               }
+                       } else {
+                               error_code = TELEPHONY_ERROR_OPERATION_FAILED;
+                               *icc_id = NULL;
+                       }
+               } else {
+                       LOGE("g_dbus_conn failed. error (%s)", gerr->message);
+                       error_code = _convert_dbus_errmsg_to_sim_error(gerr->message);
+                       g_error_free(gerr);
+                       *icc_id = NULL;
+               }
+       }
+
+       return error_code;
+}
+
+int telephony_sim_get_operator(telephony_h handle, char **sim_operator)
+{
+       int error_code = TELEPHONY_ERROR_NONE;
+       TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(sim_operator);
+       GET_SIM_STATUS(tapi_h, sim_card_state);
+
+       if (sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
+               *sim_operator = NULL;
+               error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE;
+       } else {
+               TelSimImsiInfo_t sim_imsi_info;
+               int ret = tel_get_sim_imsi(tapi_h, &sim_imsi_info);
+               if (ret == TAPI_API_SUCCESS) {
+                       *sim_operator = g_strdup_printf("%s%s", sim_imsi_info.szMcc, sim_imsi_info.szMnc);
+                       LOGI("SIM operator: [%s]", *sim_operator);
+               } else if (ret == TAPI_API_ACCESS_DENIED) {
+                       LOGE("PERMISSION_DENIED");
+                       *sim_operator = NULL;
+                       error_code = TELEPHONY_ERROR_PERMISSION_DENIED;
+               } else {
+                       LOGE("OPERATION_FAILED");
+                       *sim_operator = NULL;
+                       error_code = TELEPHONY_ERROR_OPERATION_FAILED;
+               }
+       }
+
+       return error_code;
+}
+
+int telephony_sim_get_msin(telephony_h handle, char **msin)
+{
+       int error_code = TELEPHONY_ERROR_NONE;
+       TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(msin);
+       GET_SIM_STATUS(tapi_h, sim_card_state);
+
+       if( sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
+               *msin = NULL;
+               error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE;
+       } else {
+               TelSimImsiInfo_t sim_imsi_info;
+               int ret = tel_get_sim_imsi(tapi_h, &sim_imsi_info);
+               if (ret == TAPI_API_SUCCESS) {
+                       *msin = g_strdup_printf("%s", sim_imsi_info.szMsin);
+               } else if (ret == TAPI_API_ACCESS_DENIED) {
+                       LOGE("PERMISSION_DENIED");
+                       *msin = NULL;
+                       error_code = TELEPHONY_ERROR_PERMISSION_DENIED;
+               } else {
+                       LOGE("OPERATION_FAILED");
+                       *msin = NULL;
+                       error_code = TELEPHONY_ERROR_OPERATION_FAILED;
+               }
+       }
+
+       return error_code;
+}
+
+int telephony_sim_get_spn(telephony_h handle, char **spn)
+{
+       int error_code = TELEPHONY_ERROR_NONE;
+       TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(spn);
+       GET_SIM_STATUS(tapi_h, sim_card_state);
+
+       if (sim_card_state == TAPI_SIM_STATUS_CARD_ERROR
+                       || sim_card_state == TAPI_SIM_STATUS_CARD_BLOCKED
+                       || sim_card_state == TAPI_SIM_STATUS_CARD_NOT_PRESENT
+                       || sim_card_state == TAPI_SIM_STATUS_CARD_REMOVED
+                       || sim_card_state == TAPI_SIM_STATUS_UNKNOWN) {
+               *spn = NULL;
+               error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE;
+       } else {
+               GError *gerr = NULL;
+               GVariant *sync_gv = NULL;
+               TelSimAccessResult_t result = TAPI_SIM_ACCESS_SUCCESS;
+               gchar *spn_str = NULL;
+               guchar dc = 0;
+
+               sync_gv = g_dbus_connection_call_sync(tapi_h->dbus_connection,
+                       DBUS_TELEPHONY_SERVICE, tapi_h->path, DBUS_TELEPHONY_SIM_INTERFACE,
+                       "GetSpn", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &gerr);
+
+               if (sync_gv) {
+                       g_variant_get(sync_gv, "(iys)", &result, &dc, &spn_str);
+                       if (result == TAPI_SIM_ACCESS_SUCCESS) {
+                               if (spn_str != NULL && strlen(spn_str) != 0) {
+                                       *spn = g_strdup_printf("%s", spn_str);
+                                       LOGI("SPN: [%s]", *spn);
+                               } else {
+                                       *spn = NULL;
+                               }
+                       } else {
+                               error_code = TELEPHONY_ERROR_OPERATION_FAILED;
+                               *spn = NULL;
+                       }
+               } else {
+                       LOGE("g_dbus_conn failed. error (%s)", gerr->message);
+                       error_code = _convert_dbus_errmsg_to_sim_error(gerr->message);
+                       g_error_free(gerr);
+                       *spn = NULL;
+               }
+       }
+
+       return error_code;
+}
+
+int telephony_sim_is_changed(telephony_h handle, bool *is_changed)
+{
+       int card_changed = 0;
+       TelSimCardStatus_t sim_card_state = 0x00;
+       int error_code = TELEPHONY_ERROR_NONE;
+       int ret;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(is_changed);
+
+       ret = tel_get_sim_init_info(tapi_h, &sim_card_state, &card_changed);
+       if (ret == TAPI_API_SUCCESS) {
+               if (sim_card_state == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
+                       *is_changed = card_changed;
+               } else {
+                       LOGE("NOT_AVAILABLE");
+                       error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE;
+               }
+       } else if (ret == TAPI_API_ACCESS_DENIED) {
+               LOGE("PERMISSION_DENIED");
+               error_code = TELEPHONY_ERROR_PERMISSION_DENIED;
+       } else {
+               LOGE("OPERATION_FAILED");
+               error_code = TELEPHONY_ERROR_OPERATION_FAILED;
+       }
+
+       return error_code;
+}
+
+int telephony_sim_get_state(telephony_h handle, telephony_sim_state_e *sim_state)
+{
+       TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
+       int error_code = TELEPHONY_ERROR_NONE;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(sim_state);
+       GET_SIM_STATUS(tapi_h, sim_card_state);
+
+       switch (sim_card_state) {
+       case TAPI_SIM_STATUS_CARD_ERROR:
+       case TAPI_SIM_STATUS_CARD_NOT_PRESENT:
+       case TAPI_SIM_STATUS_CARD_BLOCKED:
+       case TAPI_SIM_STATUS_CARD_REMOVED:
+       case TAPI_SIM_STATUS_CARD_CRASHED:
+               *sim_state = TELEPHONY_SIM_STATE_UNAVAILABLE;
+               break;
+       case TAPI_SIM_STATUS_SIM_PIN_REQUIRED:
+       case TAPI_SIM_STATUS_SIM_PUK_REQUIRED:
+       case TAPI_SIM_STATUS_SIM_NCK_REQUIRED:
+       case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED:
+       case TAPI_SIM_STATUS_SIM_SPCK_REQUIRED:
+       case TAPI_SIM_STATUS_SIM_CCK_REQUIRED:
+       case TAPI_SIM_STATUS_SIM_LOCK_REQUIRED:
+               *sim_state = TELEPHONY_SIM_STATE_LOCKED;
+               break;
+       case TAPI_SIM_STATUS_SIM_INIT_COMPLETED:
+               *sim_state = TELEPHONY_SIM_STATE_AVAILABLE;
+               break;
+       case TAPI_SIM_STATUS_UNKNOWN:
+       case TAPI_SIM_STATUS_SIM_INITIALIZING:
+       default:
+               *sim_state = TELEPHONY_SIM_STATE_UNKNOWN;
+               break;
+       }
+
+       return error_code;
+}
+
+int telephony_sim_get_subscriber_number(telephony_h handle, char **subscriber_number)
+{
+       int error_code = TELEPHONY_ERROR_NONE;
+       GError *gerr = NULL;
+       GVariant *sync_gv = NULL;
+       TelSimAccessResult_t result = TAPI_SIM_ACCESS_SUCCESS;
+       TapiHandle *tapi_h;
+
+       CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
+       CHECK_INPUT_PARAMETER(handle);
+       tapi_h = ((telephony_data *)handle)->tapi_h;
+       CHECK_INPUT_PARAMETER(tapi_h);
+       CHECK_INPUT_PARAMETER(subscriber_number);
+
+       sync_gv = g_dbus_connection_call_sync(tapi_h->dbus_connection,
+               DBUS_TELEPHONY_SERVICE, tapi_h->path, DBUS_TELEPHONY_SIM_INTERFACE,
+               "GetMSISDN", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &gerr);
+
+       if (sync_gv) {
+               GVariantIter *iter = NULL;
+               g_variant_get(sync_gv, "(iaa{sv})", &result, &iter);
+               if (result == TAPI_SIM_ACCESS_SUCCESS) {
+                       gchar *key = NULL;
+                       GVariant *value = NULL;
+                       const gchar *str_value = NULL;
+                       GVariantIter *iter_row = NULL;
+                       while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
+                               while (g_variant_iter_loop(iter_row, "{sv}", &key, &value)) {
+                                       if (!g_strcmp0(key, "number")) {
+                                               str_value = g_variant_get_string(value, NULL);
+                                               if (strlen(str_value) != 0) {
+                                                       *subscriber_number = g_strdup_printf("%s", str_value);
+                                               } else {
+                                                       *subscriber_number = NULL;
+                                               }
+                                       }
+                               }
+                               g_variant_iter_free(iter_row);
+                               /* Acquire only 1 subscriber number */
+                               break;
+                       }
+                       g_variant_iter_free(iter);
+               } else {
+                       error_code = TELEPHONY_ERROR_OPERATION_FAILED;
+                       *subscriber_number = NULL;
+               }
+       } else {
+               LOGE("g_dbus_conn failed. error (%s)", gerr->message);
+               error_code = _convert_dbus_errmsg_to_sim_error(gerr->message);
+               g_error_free(gerr);
+               *subscriber_number = NULL;
+       }
+
+       return error_code;
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..97657b6
--- /dev/null
@@ -0,0 +1,20 @@
+SET(fw_test "${fw_name}-test")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED glib-2.0)
+FOREACH(flag ${${fw_test}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+
+#ADD_EXECUTABLE("system-sensor" system-sensor.c)
+#TARGET_LINK_LIBRARIES("system-sensor" ${fw_name} ${${fw_test}_LDFLAGS})
+
+aux_source_directory(. sources)
+FOREACH(src ${sources})
+    GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+    MESSAGE("${src_name}")
+    ADD_EXECUTABLE(${src_name} ${src})
+    TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
+ENDFOREACH()
diff --git a/test/test_all_api.c b/test/test_all_api.c
new file mode 100644 (file)
index 0000000..cb07e2a
--- /dev/null
@@ -0,0 +1,374 @@
+/*
+ * Copyright (c) 2011 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 <glib.h>
+#include <dlog.h>
+
+#include <telephony.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CAPI_TELEPHONY_TEST"
+
+static GMainLoop *event_loop;
+
+static int network_noti_tbl[] = {
+       TELEPHONY_NOTI_NETWORK_SERVICE_STATE,
+       TELEPHONY_NOTI_NETWORK_CELLID,
+       TELEPHONY_NOTI_NETWORK_ROAMING_STATUS,
+       TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL
+};
+
+static int call_noti_tbl[] = {
+       TELEPHONY_NOTI_VOICE_CALL_STATE,
+       TELEPHONY_NOTI_VIDEO_CALL_STATE
+};
+
+static const char *_mapping_sim_state(telephony_sim_state_e sim_state)
+{
+       switch (sim_state) {
+       case TELEPHONY_SIM_STATE_AVAILABLE:
+               return "Available";
+       case TELEPHONY_SIM_STATE_LOCKED:
+               return "Locked";
+       case TELEPHONY_SIM_STATE_UNKNOWN:
+               return "Unknown";
+       default:
+               return "Unavailable";
+       }
+}
+
+static void sim_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data)
+{
+       LOGI("Noti!! SIM status: [%d]", *(int *)data);
+
+//     g_main_loop_quit(event_loop);
+}
+
+
+static const char *_mapping_service_state(telephony_network_service_state_e service_state)
+{
+       switch (service_state) {
+       case TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE:
+               return "In service";
+       case TELEPHONY_NETWORK_SERVICE_STATE_OUT_OF_SERVICE:
+               return "Out of service";
+       case TELEPHONY_NETWORK_SERVICE_STATE_EMERGENCY_ONLY:
+               return "Emergency only";
+       default:
+               return "Unknown state";
+       }
+}
+
+static const char *_mapping_network_type(telephony_network_type_e network_type)
+{
+       switch (network_type) {
+       case TELEPHONY_NETWORK_TYPE_GSM:
+               return "GSM";
+       case TELEPHONY_NETWORK_TYPE_GPRS:
+               return "GPRS";
+       case TELEPHONY_NETWORK_TYPE_EDGE:
+               return "EDGE";
+       case TELEPHONY_NETWORK_TYPE_UMTS:
+               return "UMTS";
+       case TELEPHONY_NETWORK_TYPE_HSDPA:
+               return "HSDPA";
+       case TELEPHONY_NETWORK_TYPE_LTE:
+               return "LTE";
+       default:
+               return "Unknown";
+       }
+}
+
+static void network_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data)
+{
+       switch (noti_id) {
+       case TELEPHONY_NOTI_NETWORK_SERVICE_STATE:
+               LOGI("Noti!!! Service state: [%s]", _mapping_service_state(*(int *)data));
+               break;
+       case TELEPHONY_NOTI_NETWORK_CELLID:
+               LOGI("Noti!!! Cell ID: [%d]", *(int *)data);
+               break;
+       case TELEPHONY_NOTI_NETWORK_ROAMING_STATUS:
+               LOGI("Noti!!! Roaming status: [%s]", *(int *)data ? "ON" : "OFF");
+               break;
+       case TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL:
+               LOGI("Noti!!! Signal strength: [%d]", *(int *)data);
+               break;
+       default:
+               LOGE("Unknown noti");
+               break;
+       }
+
+//     g_main_loop_quit(event_loop);
+}
+
+static const char *_mapping_call_state(telephony_call_state_e call_state)
+{
+       switch (call_state) {
+       case TELEPHONY_CALL_STATE_IDLE:
+               return "Idle";
+       case TELEPHONY_CALL_STATE_CONNECTING:
+               return "Connecting";
+       case TELEPHONY_CALL_STATE_CONNECTED:
+               return "Active";
+       default:
+               return "Unknown";
+       }
+}
+
+static void call_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data)
+{
+       switch (noti_id) {
+       case TELEPHONY_NOTI_VOICE_CALL_STATE:
+               LOGI("Noti!!! Voice Call state: [%s]", _mapping_call_state(*(int *)data));
+               break;
+       case TELEPHONY_NOTI_VIDEO_CALL_STATE:
+               LOGI("Noti!!! Video Call state: [%s]", _mapping_call_state(*(int *)data));
+               break;
+       default:
+               LOGE("Unknown noti");
+               break;
+       }
+
+//     g_main_loop_quit(event_loop);
+}
+
+int main()
+{
+       telephony_handle_list_s handle_list;
+       int ret_value, i;
+
+       /* SIM value */
+       char *operator = NULL;
+       char *icc_id = NULL;
+       char *msin = NULL;
+       char *spn = NULL;
+       telephony_sim_state_e sim_state = 0;
+       char *subscriber_number = NULL;
+
+       /* Network value */
+       int cell_id = 0;
+       int lac = 0;
+       char *mcc = NULL;
+       char *mnc = NULL;
+       char *network_name = NULL;
+       bool roaming_status;
+       telephony_network_rssi_e rssi = 0;
+       telephony_network_service_state_e service_state = 0;
+       telephony_network_type_e network_type = 0;
+
+       /* Call value */
+       telephony_call_state_e call_state = 0;
+
+       /* Modem value */
+       char *imei = NULL;
+
+       /* Initialize handle */
+       ret_value = telephony_init(&handle_list);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("Initialize failed!!!");
+               return 0;
+       }
+
+       LOGI("handle count: [%d]", handle_list.count);
+
+       /* SIM API */
+       ret_value = telephony_sim_get_operator(handle_list.handle[0], &operator);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_sim_get_operator() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Operator is [%s]", operator);
+               free(operator);
+       }
+
+       ret_value = telephony_sim_get_icc_id(handle_list.handle[0], &icc_id);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_sim_get_icc_id() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("ICC-ID is [%s]", icc_id);
+               free(icc_id);
+       }
+
+       ret_value = telephony_sim_get_msin(handle_list.handle[0], &msin);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_sim_get_msin() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("MSIN is [%s]", msin);
+               free(msin);
+       }
+
+       ret_value = telephony_sim_get_spn(handle_list.handle[0], &spn);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_sim_get_spn() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("SPN is [%s]", spn);
+               free(spn);
+       }
+
+       ret_value = telephony_sim_get_state(handle_list.handle[0], &sim_state);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_sim_get_state() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("SIM state is [%s]", _mapping_sim_state(sim_state));
+       }
+
+       ret_value = telephony_sim_get_subscriber_number(handle_list.handle[0], &subscriber_number);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_sim_get_subscriber_number() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Subscriber number is [%s]", subscriber_number);
+               free(subscriber_number);
+       }
+
+       /* Network API */
+       ret_value = telephony_network_get_cell_id(handle_list.handle[0], &cell_id);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_network_get_cell_id() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Cell ID is [%d]", cell_id);
+       }
+
+       ret_value = telephony_network_get_lac(handle_list.handle[0], &lac);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_network_get_lac() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Location Area Code is [%d]", lac);
+       }
+
+       ret_value = telephony_network_get_mcc(handle_list.handle[0], &mcc);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_network_get_mcc() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Mobile Country Code is [%s]", mcc);
+               free(mcc);
+       }
+
+       ret_value = telephony_network_get_mnc(handle_list.handle[0], &mnc);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_network_get_mnc() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Mobile Network Code is [%s]", mnc);
+               free(mnc);
+       }
+
+       ret_value = telephony_network_get_network_name(handle_list.handle[0], &network_name);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_network_get_network_name() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Network name is [%s]", network_name);
+               free(network_name);
+       }
+
+       ret_value = telephony_network_get_roaming_status(handle_list.handle[0], &roaming_status);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_network_get_roaming_status() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Network Roaming: [%s]", roaming_status ? "ON" : "OFF");
+       }
+
+       ret_value = telephony_network_get_rssi(handle_list.handle[0], &rssi);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_network_get_rssi() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Received Signal Strength Indicator is [%d]", rssi);
+       }
+
+       ret_value = telephony_network_get_service_state(handle_list.handle[0], &service_state);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_network_get_service_state() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Network service state is [%s]", _mapping_service_state(service_state));
+       }
+
+       ret_value = telephony_network_get_type(handle_list.handle[0], &network_type);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_network_get_type() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Network type is [%s]", _mapping_network_type(network_type));
+       }
+
+       /* Call API */
+       ret_value = telephony_call_get_voice_call_state(handle_list.handle[0], &call_state);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_call_get_voice_call_state() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Voice Call state is [%s]", _mapping_call_state(call_state));
+       }
+
+       ret_value = telephony_call_get_video_call_state(handle_list.handle[0], &call_state);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_call_get_video_call_state() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("Video Call state is [%s]", _mapping_call_state(call_state));
+       }
+
+       /* Modem API */
+       ret_value = telephony_modem_get_imei(handle_list.handle[0], &imei);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("telephony_modem_get_imei() failed!!! [%d]", ret_value);
+       } else {
+               LOGI("IMEI is [%s]", imei);
+               free(imei);
+       }
+
+       /* set_noti_cb */
+       ret_value = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_SIM_STATUS, sim_noti_cb, NULL);
+       if (ret_value != TELEPHONY_ERROR_NONE)
+               LOGE("Set noti failed!!!");
+
+       for (i = 0; i < 4; i++) {
+               ret_value = telephony_set_noti_cb(handle_list.handle[0], network_noti_tbl[i], network_noti_cb, NULL);
+               if (ret_value != TELEPHONY_ERROR_NONE)
+                       LOGE("Set noti failed!!!");
+       }
+
+       for (i = 0; i < 2; i++) {
+               ret_value = telephony_set_noti_cb(handle_list.handle[0], call_noti_tbl[i], call_noti_cb, NULL);
+               if (ret_value != TELEPHONY_ERROR_NONE)
+                       LOGE("Set noti failed!!!");
+       }
+
+       LOGI("If telephony status is changed, then callback function will be called");
+       event_loop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(event_loop);
+
+       ret_value = telephony_unset_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_SIM_STATUS);
+       if (ret_value != TELEPHONY_ERROR_NONE)
+               LOGE("Unset noti failed!!!");
+
+       for (i = 0; i < 4; i++) {
+               ret_value = telephony_unset_noti_cb(handle_list.handle[0], network_noti_tbl[i]);
+               if (ret_value != TELEPHONY_ERROR_NONE)
+                       LOGE("Unset noti failed!!!");
+       }
+
+       for (i = 0; i < 2; i++) {
+               ret_value = telephony_unset_noti_cb(handle_list.handle[0], call_noti_tbl[i]);
+               if (ret_value != TELEPHONY_ERROR_NONE)
+                       LOGE("Unset noti failed!!!");
+       }
+
+       ret_value = telephony_deinit(&handle_list);
+       if (ret_value != TELEPHONY_ERROR_NONE) {
+               LOGE("Deinitialize failed!!!");
+       }
+
+       return 0;
+}