Git init
authorKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:42:59 +0000 (00:42 +0900)
committerKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:42:59 +0000 (00:42 +0900)
24 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0755]
LICENSE [new file with mode: 0644]
capi-telephony-sim.pc.in [new file with mode: 0644]
debian/README [new file with mode: 0644]
debian/capi-telephony-sim-dev.install [new file with mode: 0644]
debian/capi-telephony-sim-dev.postinst [new file with mode: 0644]
debian/capi-telephony-sim.install [new file with mode: 0644]
debian/capi-telephony-sim.postinst [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/rules [new file with mode: 0755]
include/sim.h [new file with mode: 0755]
packaging/capi-telephony-sim.spec [new file with mode: 0644]
src/sim.c [new file with mode: 0644]
test/CMakeLists.txt [new file with mode: 0755]
test/sim_get_icc_id_test.c [new file with mode: 0644]
test/sim_get_mcc_test.c [new file with mode: 0644]
test/sim_get_mnc_test.c [new file with mode: 0644]
test/sim_get_spn_test.c [new file with mode: 0644]
test/sim_get_state_test.c [new file with mode: 0644]
test/sim_get_subscriber_number_test.c [new file with mode: 0644]
test/sim_state_changed_test.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..5ecc5e2
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+ByungWoo Lee <bw1212.lee@samsung.com>
+Kangho Hur <kanho.hur@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..f3274c8
--- /dev/null
@@ -0,0 +1,131 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(project_prefix "capi")
+SET(prefix "/usr")
+SET(version "0.0.1")
+SET(maintainer "ByungWoo Lee <bw1212.lee@samsung.com>")
+SET(description "Telephony SIM Framework")
+SET(service "telephony")
+SET(submodule "sim")
+SET(dependents "dlog tapi glib-2.0 vconf capi-base-common")
+SET(deb_dependents "dlog-dev libslp-tapi-dev libglib2.0-dev libvconf-dev capi-base-common-dev")
+
+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}-${submodule}")
+
+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(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+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})
+
+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 ${dependents})
+SET(PC_LDFLAGS -l${fw_name})
+SET(PC_CFLAGS -I\${includedir}/${service})
+
+CONFIGURE_FILE(
+    capi-telephony-sim.pc.in
+    ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+    @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+
+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..9c13a9b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
diff --git a/capi-telephony-sim.pc.in b/capi-telephony-sim.pc.in
new file mode 100644 (file)
index 0000000..9b898b7
--- /dev/null
@@ -0,0 +1,15 @@
+
+# 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} @PC_CFLAGS@
+
diff --git a/debian/README b/debian/README
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/debian/capi-telephony-sim-dev.install b/debian/capi-telephony-sim-dev.install
new file mode 100644 (file)
index 0000000..761a28b
--- /dev/null
@@ -0,0 +1,4 @@
+/usr/include/*
+/usr/include/*/*
+/usr/lib/pkgconfig/*.pc
+
diff --git a/debian/capi-telephony-sim-dev.postinst b/debian/capi-telephony-sim-dev.postinst
new file mode 100644 (file)
index 0000000..1a24852
--- /dev/null
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/debian/capi-telephony-sim.install b/debian/capi-telephony-sim.install
new file mode 100644 (file)
index 0000000..4a755a4
--- /dev/null
@@ -0,0 +1 @@
+/usr/lib/lib*.so*
diff --git a/debian/capi-telephony-sim.postinst b/debian/capi-telephony-sim.postinst
new file mode 100644 (file)
index 0000000..1a24852
--- /dev/null
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..3abd1b2
--- /dev/null
@@ -0,0 +1,15 @@
+capi-telephony-sim (0.1.0-8) unstable; urgency=low
+
+  * Update version
+  * Git: api/sim
+  * Tag: capi-telephony-sim_0.1.0-8
+
+ -- ByungWoo Lee <bw1212.lee@samsung.com>  Thu, 15 Dec 2011 13:17:30 +0900
+
+capi-telephony-sim (0.0.1-1) unstable; urgency=low
+
+  * Initial release. 
+  * Git: api/sim
+  * Tag: capi-telephony-sim_0.0.1-1
+
+ -- ByungWoo Lee <bw1212.lee@samsung.com>  Wed, 07 Dec 2011 12:47:03 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..044074a
--- /dev/null
@@ -0,0 +1,22 @@
+
+Source: capi-telephony-sim
+Section: libs
+Priority: extra
+Maintainer: Kangho Hur <kangho.hur@samsung.com>, ByungWoo Lee <bw1212.lee@samsung.com>
+Build-Depends: debhelper (>= 5), dlog-dev, libslp-tapi-dev, libglib2.0-dev, libvconf-dev, capi-base-common-dev
+
+Package: capi-telephony-sim
+Architecture: any
+Depends: ${shilbs:Depends}, ${misc:Depends}
+Description: A Telephony SIM library in Tizen Natvie API
+
+Package: capi-telephony-sim-dev
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, capi-telephony-sim (= ${Source-Version}), dlog-dev, libslp-tapi-dev, libglib2.0-dev, libvconf-dev, capi-base-common-dev
+Description: A Telephony SIM library in Tizen Natvie API (DEV)
+
+Package: capi-telephony-sim-dbg
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, capi-telephony-sim (= ${Source-Version})
+Description: A Telephony SIM library in Tizen Natvie API (DBG)
+
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..561d7e5
--- /dev/null
@@ -0,0 +1,66 @@
+#!/usr/bin/make -f
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+else
+       CFLAGS += -O2
+endif
+CMAKE_ROOT_DIR ?= $(CURDIR)
+CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake ..
+       touch configure-stamp
+
+
+build: build-stamp
+build-stamp: configure-stamp 
+       dh_testdir
+       cd $(CMAKE_BUILD_DIR) && $(MAKE)
+       touch $@
+
+clean:
+       cd $(CMAKE_ROOT_DIR)
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+       rm -f 
+       rm -rf $(CMAKE_BUILD_DIR)
+       rm -f *.pc
+       dh_clean
+       
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+binary-indep: build install
+
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs 
+       dh_installdocs
+       dh_installexamples
+       dh_install --sourcedir=debian/tmp
+       dh_installman
+       dh_link
+       dh_strip --dbg-package=capi-telephony-sim-dbg
+       dh_fixperms
+       dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
+
diff --git a/include/sim.h b/include/sim.h
new file mode 100755 (executable)
index 0000000..7bce0d2
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ * 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_SIM_H__
+#define __TIZEN_TELEPHONY_SIM_H__
+
+
+#include <tizen.h>
+
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+        
+/**
+ * @file sim.h
+ * @brief This file contains the SIM APIs and related enumeration.
+ */
+
+/**
+ * @addtogroup CAPI_TELEPHONY_SIM_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration of error code for sim card.
+ */
+typedef enum
+{
+       SIM_ERROR_NONE                  = TIZEN_ERROR_NONE,     /**< Successful */
+       SIM_ERROR_OUT_OF_MEMORY         = TIZEN_ERROR_OUT_OF_MEMORY,            /**< Out of memory */                           
+       SIM_ERROR_INVALID_PARAMETER     = TIZEN_ERROR_INVALID_PARAMETER,                /**< Invalid parameter */
+       SIM_ERROR_OPERATION_FAILED      = TIZEN_ERROR_TELEPHONY_CLASS | 0x3000, /**< Operation failed */
+       SIM_ERROR_NOT_AVAILABLE         = TIZEN_ERROR_TELEPHONY_CLASS | 0x3001, /**< SIM is not available */ 
+} sim_error_e;
+
+/**
+ * @brief Enumeration of the state of SIM card.
+ * 
+ */
+typedef enum
+{
+       SIM_STATE_UNAVAILABLE, /**< SIM is not available on this device */
+       SIM_STATE_LOCKED,      /**< SIM is locked */
+       SIM_STATE_AVAILABLE,    /**< SIM is available on this device */
+       SIM_STATE_UNKNOWN,      /**< SIM is in transition between states */
+} sim_state_e; 
+
+
+/**
+ * @brief Gets the Integrated Circuit Card IDentification (ICC-ID).
+ * @details The Integrated Circuit Card Identification number internationally identifies SIM cards. 
+ * @remarks @c icc_id must be released with free() by you.
+ *
+ * @param[out] icc_id The Integrated Circuit Card IDentification
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #SIM_ERROR_NONE Successful
+ * @retval #SIM_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #SIM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SIM_ERROR_OPERATION_FAILED Operation failed
+ * @retval #SIM_ERROR_NOT_AVAILABLE SIM is not available
+ * @pre The SIM state must be #SIM_STATE_AVAILABLE.
+ * @see        sim_get_state()
+ *
+ */
+int sim_get_icc_id(char **icc_id);
+
+/**
+ * @brief Gets the Mobile Country Code (MCC) of SIM provider.
+ * @details The Mobile Country Code is embedded in the SIM card.
+ *
+ * @remarks @c mcc must be released with free() by you.
+ *
+ * @param[out] mcc The Mobile Country Code
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #SIM_ERROR_NONE Successful
+ * @retval #SIM_ERROR_OUT_OF_MEMORY Out of memory 
+ * @retval #SIM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SIM_ERROR_OPERATION_FAILED Operation failed
+ * @retval #SIM_ERROR_NOT_AVAILABLE SIM is not available
+ * @pre The SIM state must be #SIM_STATE_AVAILABLE.
+ * @see        sim_get_state()
+ *
+ */
+int sim_get_mcc(char **mcc);
+
+/**
+ * @brief Gets the Mobile Network Code (MNC) of SIM provider.
+ * @details This function gets Mobile Network Code embedded in SIM card.
+ *
+ * @remarks @c mnc must be released with free() by you.
+ * @param[out] mnc The Mobile Network Code
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #SIM_ERROR_NONE Successful
+ * @retval #SIM_ERROR_OUT_OF_MEMORY Out of memory 
+ * @retval #SIM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SIM_ERROR_OPERATION_FAILED Operation failed
+ * @retval #SIM_ERROR_NOT_AVAILABLE SIM is not available
+ * @pre The SIM state must be #SIM_STATE_AVAILABLE.
+ * @see        sim_get_state()
+ *
+ */
+int sim_get_mnc(char **mnc);
+
+/**
+ * @brief Gets the Service Provider Name (SPN) of SIM card.
+ * @details This function gets Service Provider Name embedded in SIM card.
+ * If this value is not stored in SIM card, NULL will be returned.
+ * @remarks @c spn must be released with free() by you.
+ * @param[out] spn The Service Provider Name
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #SIM_ERROR_NONE Successful
+ * @retval #SIM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SIM_ERROR_OPERATION_FAILED Operation failed
+ * @retval #SIM_ERROR_NOT_AVAILABLE SIM is not available
+ * @pre The SIM state must be #SIM_STATE_AVAILABLE.
+ * @see        sim_get_state()
+ *
+ */
+int sim_get_spn(char **spn);
+
+/**
+ * @brief Gets the state of SIM.
+ *
+ * @param[out] sim_state The current state of SIM
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #SIM_ERROR_NONE Successful
+ * @retval #SIM_ERROR_OPERATION_FAILED Operation failed
+ * @retval #SIM_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int sim_get_state(sim_state_e *sim_state);
+
+/**
+ * @brief Gets the SIM card subscriber number.
+ * @details This function gets subscriber number embedded in SIM card. This value contains MSISDN related to the subscriber. \n
+ * If this value is not stored in SIM card, NULL will be returned.
+ *
+ * @remarks @c subscriber_number must be released with free() by you.
+ *
+ * @param[out] subscriber_number The subscriber number in SIM
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #SIM_ERROR_NONE Successful
+ * @retval #SIM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SIM_ERROR_OPERATION_FAILED Operation failed
+ * @retval #SIM_ERROR_NOT_AVAILABLE SIM is not available
+ * @pre The SIM state must be #SIM_STATE_AVAILABLE.
+ * @see        sim_get_state()
+ *
+ */
+int sim_get_subscriber_number(char **subscriber_number);
+
+/**
+ * @brief Called when sim card state changes.
+ * @param [in] state The status of sim
+ * @param [in] user_data The user data passed from the callback registration function
+ * @pre This callback function is invoked if you register this function using sim_set_state_changed_cb(). 
+ * 
+ * @see sim_set_state_changed_cb()
+ * @see sim_unset_state_changed_cb()
+ */
+typedef void(* sim_state_changed_cb)(sim_state_e state, void *user_data);
+
+/**
+ * @brief Registers a callback function to be invoked when sim card state changes. 
+ *
+ * @remarks You can register several callback functions.   
+ *
+ * @param [in] callback        The callback function to register
+ * @param [in] user_data The user data to be passed to the callback function
+ * @param [out] id A callback ID
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #SIM_ERROR_NONE Successful
+ * @retval #SIM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SIM_ERROR_OPERATION_FAILED Operation failed
+ * @post sim_state_changed_cb() will be invoked. 
+ * @see sim_state_changed_cb()
+ * @see        sim_unset_state_changed_cb()
+ */
+int sim_set_state_changed_cb(sim_state_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * 
+ * @param [in] id The callback ID
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #SIM_ERROR_NONE Successful
+ * @retval #SIM_ERROR_OPERATION_FAILED Operation failed.  
+ * @see        sim_set_state_changed_cb()
+ *
+ */
+int sim_unset_state_changed_cb();
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+
+#endif // __TIZEN_TELEPHONY_SIM_H__
+
diff --git a/packaging/capi-telephony-sim.spec b/packaging/capi-telephony-sim.spec
new file mode 100644 (file)
index 0000000..58039ea
--- /dev/null
@@ -0,0 +1,55 @@
+Name:       capi-telephony-sim
+Summary:    Telephony SIM Framework
+Version:    0.0.1
+Release:    1
+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(vconf)
+BuildRequires:  pkgconfig(capi-base-common)
+Requires(post): /sbin/ldconfig  
+Requires(postun): /sbin/ldconfig
+
+%description
+
+
+%package devel
+Summary:  Telephony SIM Framework (Development)
+Group:    TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+
+
+
+%prep
+%setup -q
+
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=/usr
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%{_libdir}/libcapi-telephony-sim.so
+
+%files devel
+%{_includedir}/telephony/sim.h
+%{_libdir}/pkgconfig/*.pc
+
+
diff --git a/src/sim.c b/src/sim.c
new file mode 100644 (file)
index 0000000..e7fd4a0
--- /dev/null
+++ b/src/sim.c
@@ -0,0 +1,459 @@
+/*
+ * 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 <sim.h>
+#include <TapiCommon.h>
+#include <ITapiSim.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dlog.h>
+#include <glib.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_SIM"
+
+typedef struct sim_cb_data
+{
+       sim_state_e previous_state;
+       const void* cb;
+       void* user_data;
+} sim_cb_data;
+
+// Whether vconf_notifiy_key_chnaged is registered or not
+static bool init_is_registered = false;
+static bool chv_is_registered = false;
+static bool slot_is_registered = false;
+
+// Callback function data
+static sim_cb_data sim_state_cb = {SIM_STATE_UNKNOWN, NULL, NULL};
+
+// Callback function adapter
+void _sim_state_changed_cb_adapter(keynode_t *node, void* user_data);
+
+// Internal Macros
+#define SIM_CHECK_INPUT_PARAMETER(arg) \
+       if( arg == NULL ) \
+       { \
+               LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, SIM_ERROR_INVALID_PARAMETER); \
+               return SIM_ERROR_INVALID_PARAMETER; \
+       }
+
+#define SIM_INIT() \
+       if( tel_init() != TAPI_API_SUCCESS ) \
+       { \
+               LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, SIM_ERROR_OPERATION_FAILED); \
+               return SIM_ERROR_OPERATION_FAILED; \
+       }
+
+
+int sim_get_icc_id(char** icc_id)
+{
+       TelSimIccIdInfo_t icc_data;
+       int error_code = SIM_ERROR_NONE;
+       int card_changed = 0;
+       TelSimCardStatus_t sim_card_state = 0x00;
+
+       SIM_CHECK_INPUT_PARAMETER(icc_id);
+       SIM_INIT();
+       
+       if( tel_get_sim_init_info(&sim_card_state, &card_changed) != 0 
+               || sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED )
+       {
+               LOGE("[%s] NOT_AVAILABLE(0x%08x)", __FUNCTION__, SIM_ERROR_NOT_AVAILABLE);              
+               error_code = SIM_ERROR_NOT_AVAILABLE;   
+       }
+       
+       else
+       {
+               if( tel_get_sim_iccid(&icc_data) != 0 )
+               {
+                       LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, SIM_ERROR_OPERATION_FAILED);                
+                       error_code = SIM_ERROR_OPERATION_FAILED;        
+               }
+               else
+               {
+                       *icc_id = strndup(icc_data.icc_num, icc_data.icc_length);
+                       if( *icc_id == NULL )
+                       {
+                               LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, SIM_ERROR_OUT_OF_MEMORY);
+                               error_code = SIM_ERROR_OUT_OF_MEMORY; 
+                       }                       
+               }
+       }
+
+       tel_deinit();
+       return error_code;
+}
+
+
+int sim_get_mcc(char** mcc)
+{
+       TelSimImsiInfo_t sim_imsi_info;
+       int error_code = SIM_ERROR_NONE;
+       int card_changed = 0;
+       TelSimCardStatus_t sim_card_state = 0x00;
+
+       SIM_CHECK_INPUT_PARAMETER(mcc);
+       SIM_INIT();
+       
+       if( tel_get_sim_init_info(&sim_card_state, &card_changed) != 0 
+               || sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED )
+       {
+               LOGE("[%s] NOT_AVAILABLE(0x%08x)", __FUNCTION__, SIM_ERROR_NOT_AVAILABLE);              
+               error_code = SIM_ERROR_NOT_AVAILABLE;   
+       }
+       else
+       {
+               if( tel_get_sim_imsi(&sim_imsi_info) != 0 )
+               {
+                       LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, SIM_ERROR_OPERATION_FAILED);                
+                       error_code = SIM_ERROR_OPERATION_FAILED;        
+               }
+               else
+               {
+                       *mcc = (char*)malloc(sizeof(char) * (TAPI_SIM_MCC_CODE_LEN+1));
+                       if( *mcc == NULL )
+                       {
+                               LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, SIM_ERROR_OUT_OF_MEMORY);
+                               error_code = SIM_ERROR_OUT_OF_MEMORY;                                                        
+                       }
+                       else
+                       {
+                               strncpy(*mcc, sim_imsi_info.szMcc, TAPI_SIM_MCC_CODE_LEN+1);                            
+                       }
+               }
+       }
+
+       tel_deinit();
+       return error_code;
+}
+
+
+int sim_get_mnc(char** mnc)
+{
+       TelSimImsiInfo_t sim_imsi_info;
+       int error_code = SIM_ERROR_NONE;
+       int card_changed = 0;
+       TelSimCardStatus_t sim_card_state = 0x00;       
+
+       SIM_CHECK_INPUT_PARAMETER(mnc);
+       SIM_INIT();
+
+       if( tel_get_sim_init_info(&sim_card_state, &card_changed) != 0 
+               || sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED )
+       {
+               LOGE("[%s] NOT_AVAILABLE(0x%08x)", __FUNCTION__, SIM_ERROR_NOT_AVAILABLE);              
+               error_code = SIM_ERROR_NOT_AVAILABLE;   
+       }
+       else
+       {
+               if( tel_get_sim_imsi(&sim_imsi_info) != 0 )
+               {
+                       LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, SIM_ERROR_OPERATION_FAILED);                
+                       error_code = SIM_ERROR_OPERATION_FAILED;        
+               }
+               else
+               {
+                       *mnc = (char*)malloc(sizeof(char) * (TAPI_SIM_MNC_CODE_LEN+1));
+                       if( *mnc == NULL )
+                       {
+                               LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, SIM_ERROR_OUT_OF_MEMORY);
+                               error_code = SIM_ERROR_OUT_OF_MEMORY;
+                       }
+                       else
+                       {
+                               strncpy(*mnc, sim_imsi_info.szMnc, TAPI_SIM_MNC_CODE_LEN+1);
+                       }
+               }
+       }
+
+       tel_deinit();
+       return SIM_ERROR_NONE;
+}
+
+
+int sim_get_spn(char** spn)
+{
+       int error_code = SIM_ERROR_NONE;
+       int card_changed = 0;
+       TelSimCardStatus_t sim_card_state = 0x00;       
+       char* service_provider_name = NULL;
+
+       SIM_CHECK_INPUT_PARAMETER(spn);
+       SIM_INIT();
+
+       error_code = tel_get_sim_init_info(&sim_card_state, &card_changed);
+       if( error_code != 0 || sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED )
+       {
+               LOGE("[%s] NOT_AVAILABLE(0x%08x)", __FUNCTION__, SIM_ERROR_NOT_AVAILABLE);              
+               error_code = SIM_ERROR_NOT_AVAILABLE;   
+       }
+       else
+       {
+               service_provider_name = vconf_get_str(VCONFKEY_TELEPHONY_SPN_NAME);
+               if( service_provider_name == NULL )
+               {
+                       LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, SIM_ERROR_OPERATION_FAILED);
+                       error_code = SIM_ERROR_OPERATION_FAILED;
+               }
+               else if( strlen(service_provider_name) == 0 )
+               {
+                       LOGI("[%s] spn has no value", __FUNCTION__);
+                       free(service_provider_name);
+                       *spn = NULL;
+               }
+               else
+               {
+                       *spn = service_provider_name;
+               }
+       }
+
+       tel_deinit();
+       return error_code;
+}
+
+
+int sim_get_state(sim_state_e* sim_state)
+{
+       int card_changed = 0;
+       TelSimCardStatus_t sim_card_state = 0x00;
+       int error_code = SIM_ERROR_NONE;
+
+       SIM_CHECK_INPUT_PARAMETER(sim_state);
+       SIM_INIT();
+
+       if( tel_get_sim_init_info(&sim_card_state, &card_changed) != 0 )
+       {
+               LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, SIM_ERROR_OPERATION_FAILED);                
+               error_code = SIM_ERROR_OPERATION_FAILED;
+       }
+       else
+       {
+               switch(sim_card_state)
+               {
+                       case TAPI_SIM_STATUS_CARD_ERROR:
+                               *sim_state = SIM_STATE_UNAVAILABLE;
+                               break;
+                       case TAPI_SIM_STATUS_CARD_NOT_PRESENT:
+                               *sim_state = SIM_STATE_UNAVAILABLE;
+                               break;
+                       case TAPI_SIM_STATUS_SIM_INITIALIZING:
+                               *sim_state = SIM_STATE_UNKNOWN;
+                               break;
+                       case TAPI_SIM_STATUS_SIM_INIT_COMPLETED:
+                               *sim_state = SIM_STATE_AVAILABLE;
+                               break;
+                       case TAPI_SIM_STATUS_SIM_PIN_REQUIRED:
+                               *sim_state = SIM_STATE_LOCKED;
+                               break;
+                       case TAPI_SIM_STATUS_SIM_PUK_REQUIRED:
+                               *sim_state = SIM_STATE_LOCKED;
+                               break;                          
+                       case TAPI_SIM_STATUS_CARD_BLOCKED:
+                               *sim_state = SIM_STATE_UNAVAILABLE;
+                               break;                          
+                       case TAPI_SIM_STATUS_SIM_NCK_REQUIRED:
+                               *sim_state = SIM_STATE_LOCKED;
+                               break;                          
+                       case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED:
+                               *sim_state = SIM_STATE_LOCKED;
+                               break;                          
+                       case TAPI_SIM_STATUS_SIM_SPCK_REQUIRED:
+                               *sim_state = SIM_STATE_LOCKED;
+                               break;                          
+                       case TAPI_SIM_STATUS_SIM_CCK_REQUIRED:
+                               *sim_state = SIM_STATE_LOCKED;
+                               break;                          
+                       case TAPI_SIM_STATUS_CARD_REMOVED:
+                               *sim_state = SIM_STATE_UNAVAILABLE;
+                               break;                  
+                       case TAPI_SIM_STATUS_SIM_LOCK_REQUIRED:
+                               *sim_state = SIM_STATE_LOCKED;
+                               break;
+                       default:
+                               *sim_state = SIM_STATE_UNAVAILABLE;
+                               break;                  
+               }
+       }
+
+       tel_deinit();
+       return error_code;
+}
+
+
+int sim_get_subscriber_number(char** subscriber_number)
+{
+       int error_code = SIM_ERROR_NONE;
+       int card_changed = 0;
+       TelSimCardStatus_t sim_card_state = 0x00;       
+       char* subscriber_number_p = NULL;
+
+       SIM_CHECK_INPUT_PARAMETER(subscriber_number);
+       SIM_INIT();
+
+       error_code = tel_get_sim_init_info(&sim_card_state, &card_changed);
+       if( error_code != 0 || sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED )
+       {
+               LOGE("[%s] NOT_AVAILABLE(0x%08x)", __FUNCTION__, SIM_ERROR_NOT_AVAILABLE);              
+               error_code = SIM_ERROR_NOT_AVAILABLE;   
+       }
+       else
+       {
+               subscriber_number_p = vconf_get_str(VCONFKEY_TELEPHONY_SUBSCRIBER_NUMBER);
+               if( subscriber_number_p == NULL )
+               {
+                       LOGE("[%s] OPERATION_FAILED(0x%08x)", __FUNCTION__, SIM_ERROR_OPERATION_FAILED);
+                       error_code = SIM_ERROR_OPERATION_FAILED;
+               }
+               else if( strlen(subscriber_number_p) == 0 )     
+               {
+                       LOGI("[%s] subscriber number has no value", __FUNCTION__);
+                       free(subscriber_number_p);
+                       *subscriber_number = NULL;
+               }
+               else
+               {
+                       *subscriber_number = subscriber_number_p;
+               }
+       }
+
+       tel_deinit();
+       return error_code;
+}
+
+int sim_set_state_changed_cb(sim_state_changed_cb sim_cb, void* user_data)
+{
+       sim_state_e state = SIM_STATE_UNKNOWN;
+
+       SIM_CHECK_INPUT_PARAMETER(sim_cb);
+
+       if( sim_get_state(&state) != SIM_ERROR_NONE )
+       {
+               LOGE("[%s] OPERATION_FAILED(0x%08x) : fail to get current state of SIM", __FUNCTION__, SIM_ERROR_OPERATION_FAILED);
+               return SIM_ERROR_OPERATION_FAILED;
+       }
+
+       if( init_is_registered == false) 
+       {               
+               if( vconf_notify_key_changed(VCONFKEY_TELEPHONY_SIM_INIT, (vconf_callback_fn)_sim_state_changed_cb_adapter, NULL) != 0 )
+               {
+                       LOGE("[%s] OPERATION_FAILED(0x%08x) : fail to register callback of sim initialization", 
+                                       __FUNCTION__, SIM_ERROR_OPERATION_FAILED);
+                       return SIM_ERROR_OPERATION_FAILED;
+               }
+               init_is_registered = true;
+       }
+
+       if( chv_is_registered == false )
+       {
+               if( vconf_notify_key_changed(VCONFKEY_TELEPHONY_SIM_CHV, (vconf_callback_fn)_sim_state_changed_cb_adapter, NULL) != 0)
+               {
+                       LOGE("[%s] OPERATION_FAILED(0x%08x) : fail to register callback of several lock verification", 
+                                       __FUNCTION__, SIM_ERROR_OPERATION_FAILED);
+                       return SIM_ERROR_OPERATION_FAILED;
+               }
+               chv_is_registered = true;               
+       }
+
+       if( slot_is_registered == false )
+       {
+               if(vconf_notify_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT, (vconf_callback_fn)_sim_state_changed_cb_adapter, NULL) != 0)
+               {
+                       LOGE("[%s] OPERATION_FAILED(0x%08x) : fail to register callback of sim slot", 
+                                       __FUNCTION__, SIM_ERROR_OPERATION_FAILED);
+                       return SIM_ERROR_OPERATION_FAILED;
+               }
+               slot_is_registered = true;
+       }
+
+       sim_state_cb.previous_state = state;
+       sim_state_cb.cb = sim_cb;
+       sim_state_cb.user_data = user_data;
+
+       return SIM_ERROR_NONE;
+}
+
+int sim_unset_state_changed_cb()
+{
+       if( init_is_registered == true) 
+       {               
+               if( vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SIM_INIT, (vconf_callback_fn)_sim_state_changed_cb_adapter) != 0 )
+               {
+                       LOGE("[%s] OPERATION_FAILED(0x%08x) : fail to unregister callback of sim initialization", 
+                                       __FUNCTION__, SIM_ERROR_OPERATION_FAILED);
+                       return SIM_ERROR_OPERATION_FAILED;
+               }
+               init_is_registered = false;
+       }
+
+       if( chv_is_registered == true )
+       {
+               if( vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SIM_CHV, (vconf_callback_fn)_sim_state_changed_cb_adapter) != 0)
+               {
+                       LOGE("[%s] OPERATION_FAILED(0x%08x) : fail to unregister callback of several lock verification", 
+                                       __FUNCTION__, SIM_ERROR_OPERATION_FAILED);
+                       return SIM_ERROR_OPERATION_FAILED;
+               }
+               chv_is_registered = false;              
+       }
+
+       if( slot_is_registered == true )
+       {
+               if( vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT, (vconf_callback_fn)_sim_state_changed_cb_adapter) != 0)
+               {
+                       LOGE("[%s] OPERATION_FAILED(0x%08x) : fail to unregister callback of sim slot", 
+                                       __FUNCTION__, SIM_ERROR_OPERATION_FAILED);
+                       return SIM_ERROR_OPERATION_FAILED;
+               }
+               slot_is_registered = false;
+       }
+
+       sim_state_cb.previous_state = SIM_STATE_UNKNOWN;
+       sim_state_cb.cb = NULL;
+       sim_state_cb.user_data = NULL;
+
+       return SIM_ERROR_NONE;
+}
+
+void _sim_state_changed_cb_adapter(keynode_t *node, void* user_data) 
+{
+       sim_state_e sim_state = SIM_STATE_UNKNOWN;
+
+       if( sim_state_cb.cb == NULL )
+       {
+               return;
+       }
+
+       if( sim_get_state(&sim_state) == SIM_ERROR_NONE )
+       {
+               if( sim_state != sim_state_cb.previous_state )
+               {
+                       ((sim_state_changed_cb)(sim_state_cb.cb))(sim_state, sim_state_cb.user_data);
+                       sim_state_cb.previous_state = sim_state;
+               }
+       }
+}
+
+
+
+
+
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755 (executable)
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/sim_get_icc_id_test.c b/test/sim_get_icc_id_test.c
new file mode 100644 (file)
index 0000000..3550d61
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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 <sim.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_SIM_TEST"
+
+
+int main()
+{
+       int ret = 0;
+       char* icc_id = NULL;
+       int ret_value = sim_get_icc_id(&icc_id);
+
+       switch(ret_value)
+       {
+               case SIM_ERROR_NONE:
+                       LOGI("ICC-ID is %s", icc_id);
+                       ret = 0;
+                       if(icc_id != NULL)
+                               free(icc_id);
+                       break;
+               case SIM_ERROR_OUT_OF_MEMORY:
+                       LOGI("Out of memory\n");
+                       ret = -1;
+                       break;                                    
+               case SIM_ERROR_INVALID_PARAMETER:
+                       LOGI("Invalid parameter\n");
+                       ret = -1;
+                       break;                                                
+               case SIM_ERROR_OPERATION_FAILED:
+                       LOGI("Can not get ICC-ID value\n");
+                       ret = -1;
+                       break;
+               case SIM_ERROR_NOT_AVAILABLE:
+                       LOGI("SIM is not available\n");
+                       ret = -1;
+                       break;                                          
+               default:
+                       LOGI("Unexpected return value\n");
+                       ret = -1;
+                       break;
+       }
+
+       return ret;
+}
diff --git a/test/sim_get_mcc_test.c b/test/sim_get_mcc_test.c
new file mode 100644 (file)
index 0000000..47cd11c
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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 <sim.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_SIM_TEST"
+
+int main()
+{
+       int ret = 0;
+       char* mcc = NULL;
+       int ret_value = sim_get_mcc(&mcc);
+
+       switch(ret_value)
+       {
+               case SIM_ERROR_NONE:
+                       LOGI("MCC is %s", mcc);
+                       ret = 0;
+                       free(mcc);
+                       break;
+               case SIM_ERROR_OUT_OF_MEMORY:
+                       LOGE("Out of memory");
+                       ret = -1;
+                       break;                                                
+               case SIM_ERROR_INVALID_PARAMETER:
+                       LOGE("Invalid parameter");
+                       ret = -1;
+                       break;                                                                        
+               case SIM_ERROR_OPERATION_FAILED:
+                       LOGE("Can not get MCC value");
+                       ret = -1;
+                       break;
+               case SIM_ERROR_NOT_AVAILABLE:
+                       LOGE("SIM is not available");
+                       ret = -1;
+                       break;                                          
+               default:
+                       LOGE("Unexpected return value");
+                       ret = -1;
+                       break;
+       }
+
+       return ret;
+}
diff --git a/test/sim_get_mnc_test.c b/test/sim_get_mnc_test.c
new file mode 100644 (file)
index 0000000..a3c04d9
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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 <sim.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_SIM_TEST"
+
+int main()
+{
+       int ret = 0;
+       char* mnc = NULL;
+       int ret_value = sim_get_mnc(&mnc);
+
+       switch(ret_value)
+       {
+               case SIM_ERROR_NONE:
+                       LOGI("MNC is %s", mnc);
+                       ret = 0;
+                       free(mnc);
+                       break;
+               case SIM_ERROR_OUT_OF_MEMORY:
+                       LOGE("Out of memory");
+                       ret = -1;
+                       break;        
+               case SIM_ERROR_INVALID_PARAMETER:
+                       LOGE("Invalid parameter");
+                       ret = -1;
+                       break;                                                                                                
+               case SIM_ERROR_OPERATION_FAILED:
+                       LOGE("Can not get MNC value");
+                       ret = -1;
+                       break;
+               case SIM_ERROR_NOT_AVAILABLE:
+                       LOGE("SIM is not available");
+                       ret = -1;
+                       break;                                          
+               default:
+                       LOGE("Unexpected return value");
+                       ret = -1;
+                       break;
+       }
+
+       return ret;
+}
diff --git a/test/sim_get_spn_test.c b/test/sim_get_spn_test.c
new file mode 100644 (file)
index 0000000..dd868cc
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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 <sim.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_SIM_TEST"
+
+int main()
+{
+       int ret = 0;
+       char* spn = NULL;
+       int ret_value = sim_get_spn(&spn);
+
+       switch(ret_value)
+       {
+               case SIM_ERROR_NONE:
+                       ret = 0;
+                       if( spn != NULL )
+                       {
+                               LOGI("SPN is %s", spn);
+                               free(spn);
+                       }
+                       else
+                       {
+                               LOGI("SPN is NULL");
+                       }
+                       break;
+               case SIM_ERROR_INVALID_PARAMETER:
+                       LOGE("Invalid parameter");
+                       ret = -1;
+                       break;                                                                                                                        
+               case SIM_ERROR_OPERATION_FAILED:
+                       LOGE("Cannot find SPN value");
+                       ret = -1;
+                       break;
+               case SIM_ERROR_NOT_AVAILABLE:
+                       LOGE("SIM is not available");
+                       ret = -1;
+                       break;                  
+               default:
+                       LOGE("Unexpected return value");
+                       ret = -1;
+                       break;
+       }
+
+
+       return ret;
+}
diff --git a/test/sim_get_state_test.c b/test/sim_get_state_test.c
new file mode 100644 (file)
index 0000000..c4218ca
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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 <string.h>
+#include <sim.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_SIM_TEST"
+
+
+void convert_state_into_string(sim_state_e sim_state, char* sim_state_string)
+{
+       switch(sim_state)
+       {
+               case SIM_STATE_AVAILABLE:
+                       snprintf(sim_state_string, 256, "available");
+                       break;
+               case SIM_STATE_LOCKED:
+                       snprintf(sim_state_string, 256, "locked");
+                       break;
+               case SIM_STATE_UNKNOWN:
+                       snprintf(sim_state_string, 256, "unknown");
+                       break;
+               default:
+                       snprintf(sim_state_string, 256, "unavailable");
+                       break;          
+       }
+
+}
+
+int main()
+{
+       int ret = 0;
+       sim_state_e sim_state = SIM_STATE_UNAVAILABLE;
+       char sim_state_string[256] = "";
+       int ret_value = sim_get_state(&sim_state);
+
+
+       switch(ret_value)
+       {
+               case SIM_ERROR_NONE:
+                       convert_state_into_string(sim_state, sim_state_string);
+                       LOGI("SIM is %s", sim_state_string);
+                       ret = 0;
+                       break;
+               case SIM_ERROR_OPERATION_FAILED:
+                       LOGE("Can not get sim state");
+                       ret = -1;
+                       break;
+               case SIM_ERROR_INVALID_PARAMETER:
+                       LOGE("Invalid parameter");
+                       ret = -1;
+                       break;                                                                                                                                                
+               default:
+                       LOGE("Unexpected return value");
+                       ret = -1;
+                       break;
+       }
+
+       return ret;
+}
diff --git a/test/sim_get_subscriber_number_test.c b/test/sim_get_subscriber_number_test.c
new file mode 100644 (file)
index 0000000..32456a4
--- /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.
+ */
+
+
+#include <stdio.h>
+#include <sim.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_SIM_TEST"
+
+int main()
+{
+       int ret = 0;
+       char* subscriber_number = NULL;
+       int ret_value = sim_get_subscriber_number(&subscriber_number);
+
+       switch(ret_value)
+       {
+               case SIM_ERROR_NONE:
+                       LOGI("Subscriber number is \"%s\"", subscriber_number);
+                       ret = 0;
+                       free(subscriber_number);
+                       break;
+               case SIM_ERROR_INVALID_PARAMETER:
+                       LOGE("Invalid parameter");
+                       ret = -1;
+                       break;                                                                                                                        
+               case SIM_ERROR_OPERATION_FAILED:
+                       LOGE("Cannot find subscriber number value");
+                       ret = -1;
+                       break;
+               case SIM_ERROR_NOT_AVAILABLE:
+                       LOGE("SIM is not available");
+                       ret = -1;
+                       break;                  
+               default:
+                       LOGE("Unexpected return value");
+                       ret = -1;
+                       break;
+       }
+
+
+       return ret;
+}
diff --git a/test/sim_state_changed_test.c b/test/sim_state_changed_test.c
new file mode 100644 (file)
index 0000000..d1c75ef
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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 <string.h>
+#include <sim.h>
+#include <dlog.h>
+#include <glib.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_SIM_TEST"
+
+static GMainLoop *event_loop;
+
+char* convert_state_to_string(sim_state_e sim_state)
+{
+       switch(sim_state)
+       {
+               case SIM_STATE_AVAILABLE:
+                       return "available";
+               case SIM_STATE_LOCKED:
+                       return "locked";
+               case SIM_STATE_UNKNOWN:
+                       return "unknown";
+               case SIM_STATE_UNAVAILABLE:
+                       return "unavailable";
+               default:
+                       return "unexpected";
+       }       
+}
+
+void sim_state_changed(sim_state_e state, void* user_data)
+{
+       LOGI("[%s] Start sim_state_changed_cb", __FUNCTION__);
+
+       LOGI("[%s] Status of sim: %s", __FUNCTION__, convert_state_to_string(state));
+       LOGI("[%s] user data: %s", __FUNCTION__, user_data);
+
+       LOGI("[%s] End sim_state_changed_cb", __FUNCTION__);    
+       g_main_loop_quit(event_loop);
+}
+
+int main()
+{
+       if( sim_set_state_changed_cb(sim_state_changed, "sim_state_changed_test") == SIM_ERROR_NONE )
+       {
+               LOGI("[%s] Succeeded to add callback function", __FUNCTION__);
+       }
+       else
+       {
+               LOGE("[%s] Failed to add callback function", __FUNCTION__);
+               return -1;
+       }
+
+       LOGI("[%s] If you change the state of SIM card, then callback function will be called", __FUNCTION__);
+       event_loop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(event_loop);
+
+       if( sim_unset_state_changed_cb() == SIM_ERROR_NONE )
+       {
+               LOGI("[%s] Succeeded to remove callback function", __FUNCTION__);
+       }
+       else
+       {
+               LOGE("[%s] Failed to remove callback function", __FUNCTION__);
+               return -1;
+       }
+
+       return 0;
+}