upload tizen1.0 source
authorKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 08:01:30 +0000 (17:01 +0900)
committerKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 08:01:30 +0000 (17:01 +0900)
71 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
LICENSE [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/copyright [new file with mode: 0644]
debian/dirs [new file with mode: 0644]
debian/docs [new file with mode: 0644]
debian/libtcore-dev.install.in [new file with mode: 0644]
debian/libtcore.install.in [new file with mode: 0644]
debian/rules [new file with mode: 0755]
include/co_call.h [new file with mode: 0644]
include/co_context.h [new file with mode: 0644]
include/co_modem.h [new file with mode: 0644]
include/co_network.h [new file with mode: 0644]
include/co_phonebook.h [new file with mode: 0644]
include/co_ps.h [new file with mode: 0644]
include/co_sap.h [new file with mode: 0644]
include/co_sat.h [new file with mode: 0644]
include/co_sim.h [new file with mode: 0644]
include/co_sms.h [new file with mode: 0644]
include/co_ss.h [new file with mode: 0644]
include/communicator.h [new file with mode: 0644]
include/core_object.h [new file with mode: 0644]
include/hal.h [new file with mode: 0644]
include/log.h [new file with mode: 0644]
include/plugin.h [new file with mode: 0644]
include/queue.h [new file with mode: 0644]
include/server.h [new file with mode: 0644]
include/storage.h [new file with mode: 0644]
include/tcore.h [new file with mode: 0644]
include/type/call.h [new file with mode: 0644]
include/type/common.h [new file with mode: 0644]
include/type/modem.h [new file with mode: 0644]
include/type/network.h [new file with mode: 0644]
include/type/notification.h [new file with mode: 0644]
include/type/phonebook.h [new file with mode: 0644]
include/type/ps.h [new file with mode: 0644]
include/type/request.h [new file with mode: 0644]
include/type/response.h [new file with mode: 0644]
include/type/sap.h [new file with mode: 0644]
include/type/sat.h [new file with mode: 0644]
include/type/sim.h [new file with mode: 0644]
include/type/sms.h [new file with mode: 0644]
include/type/sound.h [new file with mode: 0644]
include/type/ss.h [new file with mode: 0644]
include/user_request.h [new file with mode: 0644]
include/util.h [new file with mode: 0644]
packaging/libtcore.spec [new file with mode: 0644]
src/co_call.c [new file with mode: 0644]
src/co_context.c [new file with mode: 0644]
src/co_modem.c [new file with mode: 0644]
src/co_network.c [new file with mode: 0644]
src/co_phonebook.c [new file with mode: 0644]
src/co_ps.c [new file with mode: 0644]
src/co_sap.c [new file with mode: 0644]
src/co_sat.c [new file with mode: 0644]
src/co_sim.c [new file with mode: 0644]
src/co_sms.c [new file with mode: 0644]
src/co_ss.c [new file with mode: 0644]
src/communicator.c [new file with mode: 0644]
src/core_object.c [new file with mode: 0644]
src/hal.c [new file with mode: 0644]
src/plugin.c [new file with mode: 0644]
src/queue.c [new file with mode: 0644]
src/server.c [new file with mode: 0644]
src/storage.c [new file with mode: 0644]
src/user_request.c [new file with mode: 0644]
src/util.c [new file with mode: 0644]
tcore.pc.in [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..0e9faa9
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,6 @@
+Jongman Park <jman.park@samsung.com>
+Ja-young Gu <jygu@samsung.com>
+Kyeongchul Kim <kyeongchul.kim@samsung.com>
+DongHoo Park <donghoo.park@samsung.>
+Youngman Park <youngman.park@samsung.com>
+Inho Oh <inho48.oh@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6c2ec3d
--- /dev/null
@@ -0,0 +1,66 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(libtcore C)
+
+#INCLUDE(FindPkgConfig)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED glib-2.0 dlog)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_SOURCE_DIR}/include ${EXTRA_CFLAGS} -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align")
+
+ADD_DEFINITIONS("-DFEATURE_DLOG_DEBUG")
+ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"TCORE\"")
+
+MESSAGE(${CMAKE_C_FLAGS})
+MESSAGE(${CMAKE_EXE_LINKER_FLAGS})
+
+SET(SRCS
+               src/server.c
+               src/plugin.c
+               src/hal.c
+               src/communicator.c
+               src/storage.c
+               src/queue.c
+               src/user_request.c
+               src/util.c
+               src/core_object.c
+               src/co_modem.c
+               src/co_network.c
+               src/co_ps.c
+               src/co_context.c
+               src/co_sim.c
+               src/co_sat.c
+               src/co_sap.c
+               src/co_call.c
+               src/co_ss.c
+               src/co_sms.c
+               src/co_phonebook.c
+)
+
+
+
+# library build
+ADD_LIBRARY(tcore SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(tcore ${pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(tcore PROPERTIES VERSION 0.0.0 SOVERSION 0 OUTPUT_NAME tcore)
+
+# pkgconfig file
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+CONFIGURE_FILE(tcore.pc.in tcore.pc @ONLY)
+
+
+# install
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include/tcore)
+INSTALL(TARGETS tcore
+               LIBRARY DESTINATION lib)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tcore.pc DESTINATION lib/pkgconfig)
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..bae7f54
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2012 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/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..72d3b83
--- /dev/null
@@ -0,0 +1,127 @@
+libtcore (0.1.14) unstable; urgency=low
+
+  * Fix ip string bug
+  * Git: pkgs/l/libtcore
+  * Tag: libtcore_0.1.14
+
+ -- Inho Oh <inho48.oh@samsung.com>  Thu, 05 Apr 2012 13:40:08 +0900
+
+libtcore (0.1.13) unstable; urgency=low
+
+  * fixed SAT TR operation - RESULT_BACKWARD_MOVE_BY_USER case and so on
+  * Git: pkgs/l/libtcore
+  * Tag: libtcore_0.1.13
+
+ -- Kyeongchul Kim <kyeongchul.kim@samsung.com>  Mon, 02 Apr 2012 20:33:33 +0900
+
+libtcore (0.1.12) unstable; urgency=low
+
+  * version up for code sync with public binary 
+  * Git: pkgs/l/libtcore
+  * Tag: libtcore_0.1.12
+
+ -- Kyeongchul Kim <kyeongchul.kim@samsung.com>  Mon, 02 Apr 2012 12:18:03 +0900
+
+libtcore (0.1.11) unstable; urgency=low
+
+  * Apply coding guide line, Fix obs build break
+  * Git: pkgs/l/libtcore
+  * Tag: libtcore_0.1.11
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Fri, 30 Mar 2012 10:53:48 +0900
+
+libtcore (0.1.10) unstable; urgency=low
+
+  * Fix SAT TR
+  * Git: pkgs/l/libtcore
+  * Tag: libtcore_0.1.10
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Thu, 29 Mar 2012 16:35:42 +0900
+
+libtcore (0.1.9) unstable; urgency=low
+
+   * Fix prefix (TAPI_ to TCORE_) 
+   * Git: pkgs/l/libtcore
+   * Tag: libtcore_0.1.9
+
+ -- Inho Oh <inho48.oh@samsung.com>  Tue, 27 Mar 2012 22:04:25 +0900
+
+libtcore (0.1.8) unstable; urgency=low
+
+   * Apply SAT encoding functions
+   * Git: pkgs/l/libtcore
+   * Tag: libtcore_0.1.8
+
+ -- Kyeongchul Kim <kyeongchul.kim@samsung.com>  Tue, 27 Mar 2012 20:46:13 +0900
+
+libtcore (0.1.7) unstable; urgency=low
+
+   * Fix sat
+   * Git: pkgs/l/libtcore
+   * Tag: libtcore_0.1.7
+
+ -- Inho Oh <inho48.oh@samsung.com>  Thu, 22 Mar 2012 14:33:47 +0900
+
+libtcore (0.1.6) unstable; urgency=low
+
+   * version up
+   * Git: pkgs/l/libtcore
+   * Tag: libtcore_0.1.6
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Wed, 21 Mar 2012 14:08:51 +0900
+
+libtcore (0.1.5) unstable; urgency=low
+
+  * add tcore_network_get/set_network_name_priority
+  * Git: pkgs/l/libtcore
+  * Tag: libtcore_0.1.5
+
+ -- Inho Oh <inho48.oh@samsung.com>  Tue, 20 Mar 2012 17:04:56 +0900
+
+libtcore (0.1.4) unstable; urgency=low
+
+  * change member name of enum telephony_ps_pdp_err 
+  * Git: pkgs/l/libtcore
+  * Tag: libtcore_0.1.4
+
+ -- Kyeongchul Kim <kyeongchul.kim@samsung.com>  Mon, 19 Mar 2012 22:56:49 +0900
+
+libtcore (0.1.3) unstable; urgency=low
+
+  * Add HSDPA noti and so on 
+  * Git: pkgs/l/libtcore
+  * Tag: libtcore_0.1.3
+
+ -- Kyeongchul Kim <kyeongchul.kim@samsung.com>  Tue, 20 Mar 2012 15:51:46 +0900
+
+libtcore (0.1.2) unstable; urgency=low
+
+  * Add Code for Video Call 
+  * Git: pkgs/l/libtcore
+  * Tag: libtcore_0.1.2
+
+ -- Youngman Park <youngman.park@samsung.com>  Sat, 17 Mar 2012 18:15:30 +0900
+
+libtcore (0.1.1) unstable; urgency=low
+
+  * Version info change & Fix OBS Build break
+  * Git: pkgs/l/libtcore
+  * Tag: libtcore_0.1.1
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Fri, 16 Mar 2012 13:40:30 +0900
+
+libtcore (0.1.0-1) unstable; urgency=low
+
+  * Fix arm/i386 version mismatch
+  * Git: pkgs/l/libtcore
+  * Tag: libtcore_0.1.0-1
+
+ -- Inho Oh <inho48.oh@samsung.com>  Thu, 15 Mar 2012 23:40:55 +0900
+
+libtcore (0.1.0) unstable; urgency=low
+
+  * Initial
+  * Git: pkgs/l/libtcore
+  * Tag: libtcore_0.1.0
+
+ -- Inho Oh <inho48.oh@samsung.com>  Thu, 15 Mar 2012 22:37:29 +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..50ccc37
--- /dev/null
@@ -0,0 +1,27 @@
+Source: libtcore
+Section: libs
+Priority: extra
+Maintainer: Jongman Park <jman.park@samsung.com>
+Uploaders: Jayoung Gu <jygu@samsung.com>, Kyeongchul Kim <kyeongchul.kim@samsung.com>, Youngman Park <youngman.park@samsung.com>, Inho Oh <inho48.oh@samsung.com>,  DongHoo Park <donghoo.park@samsung.com>
+Build-Depends: debhelper (>= 5), libglib2.0-dev, dlog-dev
+Standards-Version: 0.0.0
+
+Package: libtcore-dev
+Section: libs
+Architecture: any
+Depends: libtcore (= ${Source-Version}),
+         libglib2.0-dev
+Description: telephony client API library (Development)
+
+Package: libtcore
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends},
+Description: telephony client API library (Shared Object)
+
+Package: libtcore-dbg
+Section: debug
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libtcore (= ${Source-Version})
+Description: telephony client API library (dbg package)
+
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..d5a0cca
--- /dev/null
@@ -0,0 +1,7 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License version 2.1.
+
+The full text of the LGPL 2.1 can be found in
+/usr/share/common-licenses.
diff --git a/debian/dirs b/debian/dirs
new file mode 100644 (file)
index 0000000..ca882bb
--- /dev/null
@@ -0,0 +1,2 @@
+usr/bin
+usr/sbin
diff --git a/debian/docs b/debian/docs
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/debian/libtcore-dev.install.in b/debian/libtcore-dev.install.in
new file mode 100644 (file)
index 0000000..77573d0
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/include/*
+@PREFIX@/lib/pkgconfig/tcore.pc
diff --git a/debian/libtcore.install.in b/debian/libtcore.install.in
new file mode 100644 (file)
index 0000000..143a4e8
--- /dev/null
@@ -0,0 +1 @@
+@PREFIX@/lib/libtcore*
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..afa2a34
--- /dev/null
@@ -0,0 +1,118 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS ?= -Wall -g
+CXXFLAGS ?=  -Wall -g
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+       CXXFLAGS += -O0
+else
+       CFLAGS += -O2
+       CXXFLAGS += -O2
+endif
+
+#CFLAGS += -fvisibility=hidden -fPIC
+CFLAGS += -fvisibility=default -fPIC
+LDFLAGS += -rdynamic -fPIC -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+#LDFLAGS += -Wl,--unresolved-symbols=ignore-in-shared-libs,--as-needed
+
+CMAKE_TMP_DIR = $(CURDIR)/cmake_tmp
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       # Add here commands to configure the package.
+       mkdir -p $(CMAKE_TMP_DIR);
+       cd $(CMAKE_TMP_DIR); CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+
+       touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+       dh_testdir
+
+       # Add here commands to compile the package.
+       cd $(CMAKE_TMP_DIR) && $(MAKE) all
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               cat $$f > $${f%.in}; \
+               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+               sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+       done
+
+       touch $@
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       rm -rf $(CMAKE_TMP_DIR)
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               rm -f $${f%.in}; \
+       done
+
+       dh_clean
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k
+       dh_installdirs
+
+       # Add here commands to install the package into debian/wavplayer.
+       cd $(CMAKE_TMP_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs
+       dh_installdocs
+       dh_installexamples
+       dh_install --sourcedir=debian/tmp
+#      dh_installmenu
+#      dh_installdebconf
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_python
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+       dh_installman
+       dh_link
+       dh_strip --dbg-package=libtcore-dbg
+       dh_compress
+       dh_fixperms
+#      dh_perl
+       dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps --dpkg-shlibdeps-params="-v"
+       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/co_call.h b/include/co_call.h
new file mode 100644 (file)
index 0000000..72ff86d
--- /dev/null
@@ -0,0 +1,242 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_CO_CALL_H__
+#define __TCORE_CO_CALL_H__
+
+#include <core_object.h>
+
+__BEGIN_DECLS
+
+#define MAX_CALL_NUMBER_LEN                    83
+#define MAX_CALL_NAME_LEN                      83
+
+enum tcore_call_type {
+       TCORE_CALL_TYPE_VOICE,
+       TCORE_CALL_TYPE_VIDEO,
+       TCORE_CALL_TYPE_E911,
+};
+
+enum tcore_call_direction {
+       TCORE_CALL_DIRECTION_NONE,
+       TCORE_CALL_DIRECTION_OUTGOING,
+       TCORE_CALL_DIRECTION_INCOMING,
+};
+
+enum tcore_call_status {
+       TCORE_CALL_STATUS_IDLE,
+       TCORE_CALL_STATUS_ACTIVE,
+       TCORE_CALL_STATUS_HELD,
+       TCORE_CALL_STATUS_DIALING,
+       TCORE_CALL_STATUS_ALERT,
+       TCORE_CALL_STATUS_INCOMING,
+       TCORE_CALL_STATUS_WAITING,
+};
+
+enum tcore_call_cli_mode {
+       TCORE_CALL_CLI_MODE_DEFAULT,
+       TCORE_CALL_CLI_MODE_PRESENT,
+       TCORE_CALL_CLI_MODE_RESTRICT,
+};
+
+enum tcore_call_cna_mode {
+       TCORE_CALL_CNA_MODE_DEFAULT,
+       TCORE_CALL_CNA_MODE_PRESENT,
+       TCORE_CALL_CNA_MODE_RESTRICT,
+};
+
+enum tcore_call_answer_type {
+       TCORE_CALL_ANSWER_ACCEPT,
+       TCORE_CALL_ANSWER_REJECT,
+       TCORE_CALL_ANSWER_REPLACE,
+       TCORE_CALL_ANSWER_HOLD_AND_ACCEPT,
+};
+
+enum tcore_call_end_type {
+       TCORE_CALL_END_DEFAULT,
+       TCORE_CALL_END_ALL,
+       TCORE_CALL_END_ALL_ACTIVE,
+       TCORE_CALL_END_ALL_HELD,
+};
+
+typedef struct call_object CallObject;
+
+struct tcore_call_operations {
+       TReturn (*dial)(CoreObject *o, UserRequest *ur);
+       TReturn (*answer)(CoreObject *o, UserRequest *ur);
+       TReturn (*end)(CoreObject *o, UserRequest *ur);
+       TReturn (*hold)(CoreObject *o, UserRequest *ur);
+       TReturn (*active)(CoreObject *o, UserRequest *ur);
+       TReturn (*swap)(CoreObject *o, UserRequest *ur);
+       TReturn (*join)(CoreObject *o, UserRequest *ur);
+       TReturn (*split)(CoreObject *o, UserRequest *ur);
+       TReturn (*deflect)(CoreObject* o, UserRequest *ur);
+       TReturn (*transfer)(CoreObject* o, UserRequest *ur);
+       TReturn (*send_dtmf)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_sound_path)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_sound_volume_level)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_sound_volume_level)(CoreObject *o, UserRequest *ur);
+       TReturn (*mute)(CoreObject *o, UserRequest *ur);
+       TReturn (*unmute)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_mute_status)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_active_line)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_active_line)(CoreObject *o, UserRequest *ur);
+       TReturn (*activate_ccbs)(CoreObject *o, UserRequest *ur);
+};
+
+struct tcore_call_information_operations {
+       void (*mo_call_col)(CoreObject *o, char* number);
+       void (*mo_call_waiting)(CoreObject *o);
+       void (*mo_call_cug)(CoreObject *o, int cug_index);
+       void (*mo_call_forwarded)(CoreObject *o);
+       void (*mo_call_barred_incoming)(CoreObject *o);
+       void (*mo_call_barred_outgoing)(CoreObject *o);
+       void (*mo_call_deflected)(CoreObject *o);
+       void (*mo_call_clir_suppression_reject)(CoreObject *o);
+       void (*mo_call_cfu)(CoreObject *o);
+       void (*mo_call_cfc)(CoreObject *o);
+       void (*mt_call_cli)(CoreObject *o, enum tcore_call_cli_mode mode, char *number);
+       void (*mt_call_cna)(CoreObject *o, enum tcore_call_cna_mode mode, char *name, int dcs);
+       void (*mt_call_forwarded_call)(CoreObject *o, char* number);
+       void (*mt_call_cug_call)(CoreObject *o, int cug_index, char* number);
+       void (*mt_call_deflected_call)(CoreObject *o, char* number);
+       void (*mt_call_transfered)(CoreObject *o, char* number);
+       void (*call_held)(CoreObject *o, char* number);
+       void (*call_active)(CoreObject *o, char* number);
+       void (*call_joined)(CoreObject *o, char* number);
+       void (*call_released_on_hold)(CoreObject *o, char* number);
+       void (*call_transfer_alert)(CoreObject *o, char* number);
+       void (*call_transfered)(CoreObject *o, char* number);
+       void (*call_cf_check_message)(CoreObject *o, char* number);
+};
+
+typedef void(*ConfirmCallback)(TcorePending *p, int data_len, const void *data, void *user_data);
+
+struct tcore_call_control_operations {
+       TReturn (*answer_hold_and_accept)( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+       TReturn (*answer_replace)( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+       TReturn (*answer_reject)( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+       TReturn (*end_specific)( CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data );
+       TReturn (*end_all_active)( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+       TReturn (*end_all_held)( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+       TReturn (*active)( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+       TReturn (*hold)( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+       TReturn (*swap)( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+       TReturn (*join)( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+       TReturn (*split)( CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data );
+       TReturn (*transfer)( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+       TReturn (*deflect)( CoreObject* o, UserRequest* ur, const char* number, ConfirmCallback cb, void* user_data );
+};
+
+// Call Core API
+CoreObject*                            tcore_call_new(TcorePlugin *p, const char *name, struct tcore_call_operations *ops);
+void                                   tcore_call_free( CoreObject *o);
+
+
+// Call Object API
+CallObject*                            tcore_call_object_new( CoreObject *o, int id );
+gboolean                               tcore_call_object_free( CoreObject *o, CallObject *co );
+
+CallObject*                            tcore_call_object_current_on_mt_processing( CoreObject *o );
+CallObject*                            tcore_call_object_current_on_mo_processing( CoreObject *o );
+CallObject*                            tcore_call_object_find_by_id( CoreObject *o, int id );
+CallObject*                            tcore_call_object_find_by_number( CoreObject *o, char *num );
+GSList*                                        tcore_call_object_find_by_status( CoreObject *o, enum tcore_call_status cs );
+
+int                                            tcore_call_object_get_id( CallObject *co );
+
+gboolean                               tcore_call_object_set_type( CallObject *co, enum tcore_call_type ct );
+enum tcore_call_type   tcore_call_object_get_type( CallObject *co );
+
+gboolean                               tcore_call_object_set_direction( CallObject *co, enum tcore_call_direction cd );
+enum tcore_call_direction tcore_call_object_get_direction( CallObject *co );
+
+gboolean                               tcore_call_object_set_status( CallObject *co, enum tcore_call_status cs );
+enum tcore_call_status  tcore_call_object_get_status( CallObject *co );
+
+gboolean                               tcore_call_object_set_cli_info( CallObject *co, enum tcore_call_cli_mode mode, char *num );
+enum tcore_call_cli_mode tcore_call_object_get_cli_mode( CallObject *co );
+int                                            tcore_call_object_get_number( CallObject *co, char *num );
+
+gboolean                               tcore_call_object_set_cna_info( CallObject *co, enum tcore_call_cna_mode mode, char *name, int dcs );
+enum tcore_call_cna_mode tcore_call_object_get_cna_mode( CallObject *co );
+int                                            tcore_call_object_get_name( CallObject *co, char *name );
+
+gboolean                               tcore_call_object_set_multiparty_state ( CallObject *co,  gboolean is );
+gboolean                               tcore_call_object_get_multiparty_state ( CallObject *co );
+
+gboolean                               tcore_call_object_set_active_line( CallObject *co, unsigned int line );
+int                                            tcore_call_object_get_active_line( CallObject *co );
+
+
+// Call Control API
+gboolean                               tcore_call_control_new( CoreObject *o, struct tcore_call_control_operations *ops );
+void                                   tcore_call_control_free( CoreObject *o );
+
+TReturn                                        tcore_call_control_answer_hold_and_accept( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+TReturn                                        tcore_call_control_answer_replace( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+TReturn                                        tcore_call_control_answer_reject( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+
+TReturn                                        tcore_call_control_end_specific( CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data );
+TReturn                                        tcore_call_control_end_all_active( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+TReturn                                        tcore_call_control_end_all_held( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+
+TReturn                                        tcore_call_control_active( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+TReturn                                        tcore_call_control_hold( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+TReturn                                        tcore_call_control_swap( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+TReturn                                        tcore_call_control_join( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+TReturn                                        tcore_call_control_split( CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data );
+TReturn                                        tcore_call_control_transfer( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
+TReturn                                        tcore_call_control_deflect( CoreObject* o, UserRequest* ur, const char* number, ConfirmCallback cb, void* user_data );
+
+void                                   tcore_call_control_set_operations( CoreObject* o, struct tcore_call_control_operations *ops );
+
+
+void                                   tcore_call_information_mo_col( CoreObject *o, char* number );
+void                                   tcore_call_information_mo_waiting( CoreObject *o );
+void                                   tcore_call_information_mo_cug( CoreObject *o, int cug_index );
+void                                   tcore_call_information_mo_forwarded( CoreObject *o );
+void                                   tcore_call_information_mo_barred_incoming( CoreObject *o );
+void                                   tcore_call_information_mo_barred_outgoing( CoreObject *o );
+void                                   tcore_call_information_mo_deflected( CoreObject *o );
+void                                   tcore_call_information_mo_clir_suppression_reject( CoreObject *o );
+void                                   tcore_call_information_mo_cfu( CoreObject *o );
+void                                   tcore_call_information_mo_cfc( CoreObject *o );
+
+void                                   tcore_call_information_mt_cli( CoreObject *o, enum tcore_call_cli_mode mode, char* number );
+void                                   tcore_call_information_mt_cna( CoreObject *o, enum tcore_call_cna_mode mode, char* name, int dcs );
+void                                   tcore_call_information_mt_forwarded_call( CoreObject *o, char* number );
+void                                   tcore_call_information_mt_cug_call( CoreObject *o, int cug_index, char* number );
+void                                   tcore_call_information_mt_deflected_call( CoreObject *o, char* number );
+void                                   tcore_call_information_mt_transfered( CoreObject *o, char* number );
+
+void                                   tcore_call_information_held( CoreObject *o, char* number );
+void                                   tcore_call_information_active( CoreObject *o, char* number );
+void                                   tcore_call_information_joined( CoreObject *o, char* number );
+void                                   tcore_call_information_released_on_hold( CoreObject *o, char* number );
+void                                   tcore_call_information_transfer_alert( CoreObject *o, char* number );
+void                                   tcore_call_information_transfered( CoreObject *o, char* number );
+void                                   tcore_call_information_cf_check_ss_message( CoreObject *o, char* number );
+
+void                                   tcore_call_information_set_operations( CoreObject *o, struct tcore_call_information_operations *ops );
+
+__END_DECLS
+
+#endif
diff --git a/include/co_context.h b/include/co_context.h
new file mode 100644 (file)
index 0000000..732f058
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_CO_CONTEXT_H__
+#define __TCORE_CO_CONTEXT_H__
+
+#include <core_object.h>
+
+__BEGIN_DECLS
+
+enum co_context_state {
+       CONTEXT_STATE_DEACTIVATED,
+       CONTEXT_STATE_ACTIVATING,
+       CONTEXT_STATE_ACTIVATED,
+       CONTEXT_STATE_DEACTIVATING,
+};
+
+enum co_context_type {
+       CONTEXT_TYPE_UNKNOWN,
+       CONTEXT_TYPE_X25,
+       CONTEXT_TYPE_IP,
+       CONTEXT_TYPE_IHOST,
+       CONTEXT_TYPE_PPP,
+       CONTEXT_TYPE_IPV6,
+};
+
+enum co_context_role {
+       CONTEXT_ROLE_UNKNOWN,
+       CONTEXT_ROLE_INTERNET,
+       CONTEXT_ROLE_MMS,
+};
+
+enum co_context_d_comp {
+       CONTEXT_D_COMP_OFF,
+       CONTEXT_D_COMP_ON,
+       CONTEXT_D_COMP_V42BIS,
+       CONTEXT_D_COMP_V44,
+};
+
+enum co_context_h_comp {
+       CONTEXT_H_COMP_OFF,
+       CONTEXT_H_COMP_ON,
+       CONTEXT_H_COMP_RFC1144,
+       CONTEXT_H_COMP_RFC2507,
+       CONTEXT_H_COMP_RFC3095
+};
+
+enum co_context_auth {
+       CONTEXT_AUTH_NONE,
+       CONTEXT_AUTH_PAP,
+       CONTEXT_AUTH_CHAP
+};
+
+CoreObject*              tcore_context_new(TcorePlugin *p, const char *name);
+void                     tcore_context_free(CoreObject *o);
+
+TReturn                  tcore_context_set_state(CoreObject *o, enum co_context_state state);
+enum co_context_state    tcore_context_get_state(CoreObject *o);
+TReturn                  tcore_context_set_id(CoreObject *o, unsigned int id);
+unsigned int             tcore_context_get_id(CoreObject *o);
+TReturn                  tcore_context_set_role(CoreObject *o, enum co_context_role type);
+enum co_context_role     tcore_context_get_role(CoreObject *o);
+
+TReturn                  tcore_context_set_apn(CoreObject *o, const char *apn);
+char*                    tcore_context_get_apn(CoreObject *o);
+TReturn                  tcore_context_set_address(CoreObject *o, const char *addr);
+char*                    tcore_context_get_address(CoreObject *o);
+TReturn                  tcore_context_set_type(CoreObject *o, enum co_context_type type);
+enum co_context_type     tcore_context_get_type(CoreObject *o);
+TReturn                  tcore_context_set_data_compression(CoreObject *o, enum co_context_d_comp comp);
+enum co_context_d_comp   tcore_context_get_data_compression(CoreObject *o);
+TReturn                  tcore_context_set_header_compression(CoreObject *o, enum co_context_h_comp comp);
+enum co_context_h_comp   tcore_context_get_header_compression(CoreObject *o);
+
+TReturn                  tcore_context_set_username(CoreObject *o, const char *username);
+char*                    tcore_context_get_username(CoreObject *o);
+TReturn                  tcore_context_set_password(CoreObject *o, const char *password);
+char*                    tcore_context_get_password(CoreObject *o);
+TReturn                  tcore_context_set_dns1(CoreObject *o, const char *dns);
+char*                    tcore_context_get_dns1(CoreObject *o);
+TReturn                  tcore_context_set_dns2(CoreObject *o, const char *dns);
+char*                    tcore_context_get_dns2(CoreObject *o);
+TReturn                  tcore_context_set_auth(CoreObject *o, enum co_context_auth auth);
+enum co_context_auth     tcore_context_get_auth(CoreObject *o);
+TReturn                  tcore_context_set_proxy(CoreObject *o, const char *proxy);
+char*                    tcore_context_get_proxy(CoreObject *o);
+TReturn                  tcore_context_set_mmsurl(CoreObject *o, const char *mmsurl);
+char*                    tcore_context_get_mmsurl(CoreObject *o);
+
+TReturn                  tcore_context_set_devinfo(CoreObject *o, struct tnoti_ps_pdp_ipconfiguration *devinfo);
+TReturn                  tcore_context_reset_devinfo(CoreObject *o);
+void                     tcore_context_cp_service_info(CoreObject *dest, CoreObject *src);
+
+char*                    tcore_context_get_ipv4_addr(CoreObject *o);
+char*                    tcore_context_get_ipv4_dns1(CoreObject *o);
+char*                    tcore_context_get_ipv4_dns2(CoreObject *o);
+char*                    tcore_context_get_ipv4_gw(CoreObject *o);
+char*                    tcore_context_get_ipv4_devname(CoreObject *o);
+
+__END_DECLS
+
+#endif
diff --git a/include/co_modem.h b/include/co_modem.h
new file mode 100644 (file)
index 0000000..dbc2a64
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_CO_MODEM_H__
+#define __TCORE_CO_MODEM_H__
+
+#include <core_object.h>
+
+__BEGIN_DECLS
+
+
+struct tcore_modem_operations {
+       TReturn (*power_on)(CoreObject *o, UserRequest *ur);
+       TReturn (*power_off)(CoreObject *o, UserRequest *ur);
+       TReturn (*power_reset)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_flight_mode)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_imei)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_version)(CoreObject *o, UserRequest *ur);
+};
+
+
+CoreObject*      tcore_modem_new(TcorePlugin *p, const char *name, struct tcore_modem_operations *ops);
+void             tcore_modem_free(CoreObject *o);
+
+TReturn          tcore_modem_set_flight_mode_state(CoreObject *o, gboolean flag);
+gboolean         tcore_modem_get_flight_mode_state(CoreObject *o);
+TReturn          tcore_modem_set_powered(CoreObject *o, gboolean pwr);
+gboolean         tcore_modem_get_powered(CoreObject *o);
+
+__END_DECLS
+
+#endif
diff --git a/include/co_network.h b/include/co_network.h
new file mode 100644 (file)
index 0000000..5e88f85
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_CO_NETWORK_H__
+#define __TCORE_CO_NETWORK_H__
+
+#include <core_object.h>
+
+__BEGIN_DECLS
+
+
+enum tcore_network_service_domain_type {
+       TCORE_NETWORK_SERVICE_DOMAIN_TYPE_CIRCUIT,
+       TCORE_NETWORK_SERVICE_DOMAIN_TYPE_PACKET
+};
+
+enum tcore_network_name_type {
+       TCORE_NETWORK_NAME_TYPE_SHORT,
+       TCORE_NETWORK_NAME_TYPE_FULL,
+       TCORE_NETWORK_NAME_TYPE_SPN,
+};
+
+enum tcore_network_name_priority {
+       TCORE_NETWORK_NAME_PRIORITY_NETWORK,
+       TCORE_NETWORK_NAME_PRIORITY_SPN,
+       TCORE_NETWORK_NAME_PRIORITY_ANY,
+};
+
+struct tcore_network_operator_info {
+       char mcc[4];
+       char mnc[4];
+       char name[41];
+       char country[4];
+};
+
+struct tcore_network_operations {
+       TReturn (*search)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_plmn_selection_mode)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_plmn_selection_mode)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_service_domain)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_service_domain)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_band)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_band)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_preferred_plmn)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_preferred_plmn)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_order)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_order)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_power_on_attach)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_power_on_attach)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_cancel_manual_search)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_serving_network)(CoreObject *o, UserRequest *ur);
+};
+
+
+CoreObject* tcore_network_new(TcorePlugin *plugin, const char *name,
+                struct tcore_network_operations *ops);
+void        tcore_network_free(CoreObject *co);
+
+TReturn     tcore_network_set_plmn(CoreObject *co, const char *plmn);
+char*       tcore_network_get_plmn(CoreObject *co);
+
+TReturn     tcore_network_set_network_name(CoreObject *co,
+                enum tcore_network_name_type type, const char *network_name);
+char*       tcore_network_get_network_name(CoreObject *co,
+                enum tcore_network_name_type type);
+
+TReturn     tcore_network_set_network_name_priority(CoreObject *co,
+                enum tcore_network_name_priority priority);
+TReturn     tcore_network_get_network_name_priority(CoreObject *co,
+                enum tcore_network_name_priority *priority);
+
+TReturn     tcore_network_set_roaming_state(CoreObject *co, gboolean state);
+gboolean    tcore_network_get_roaming_state(CoreObject *co);
+
+TReturn     tcore_network_set_service_status(CoreObject *co,
+                enum tcore_network_service_domain_type type,
+                enum telephony_network_service_domain_status status);
+TReturn     tcore_network_get_service_status(CoreObject *co,
+                enum tcore_network_service_domain_type type,
+                enum telephony_network_service_domain_status *result);
+
+TReturn     tcore_network_set_access_technology(CoreObject *co,
+                enum telephony_network_access_technology act);
+TReturn     tcore_network_get_access_technology(CoreObject *co,
+                enum telephony_network_access_technology *result);
+
+TReturn     tcore_network_set_lac(CoreObject *co, unsigned int lac);
+TReturn     tcore_network_get_lac(CoreObject *co, unsigned int *result);
+
+TReturn     tcore_network_set_rac(CoreObject *co, unsigned int rac);
+TReturn     tcore_network_get_rac(CoreObject *co, unsigned int *result);
+
+TReturn     tcore_network_set_cell_id(CoreObject *co, unsigned int cell_id);
+TReturn     tcore_network_get_cell_id(CoreObject *co, unsigned int *result);
+
+TReturn     tcore_network_set_service_type(CoreObject *co,
+                enum telephony_network_service_type service_type);
+TReturn     tcore_network_get_service_type(CoreObject *co,
+                enum telephony_network_service_type *result);
+
+TReturn     tcore_network_operator_info_add(CoreObject *co,
+                struct tcore_network_operator_info *noi);
+
+struct tcore_network_operator_info*
+            tcore_network_operator_info_find(CoreObject *co,
+                const char *mcc, const char *mnc);
+
+__END_DECLS
+
+#endif
diff --git a/include/co_phonebook.h b/include/co_phonebook.h
new file mode 100644 (file)
index 0000000..f7f7ab4
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_CO_PHONEBOOK_H__
+#define __TCORE_CO_PHONEBOOK_H__
+
+#include <core_object.h>
+
+__BEGIN_DECLS
+
+struct tcore_phonebook_operations {
+       TReturn (*get_count)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_info)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_usim_info)(CoreObject *o, UserRequest *ur);
+       TReturn (*read_record)(CoreObject *o, UserRequest *ur);
+       TReturn (*update_record)(CoreObject *o, UserRequest *ur);
+       TReturn (*delete_record)(CoreObject *o, UserRequest *ur);
+};
+
+CoreObject* tcore_phonebook_new(TcorePlugin *p, const char *name, struct tcore_phonebook_operations *ops);
+void        tcore_phonebook_free(CoreObject *n);
+
+gboolean    tcore_phonebook_get_status(CoreObject *o);
+gboolean    tcore_phonebook_set_status(CoreObject *o, gboolean b_init);
+
+struct tel_phonebook_support_list* tcore_phonebook_get_support_list(CoreObject *o);
+gboolean    tcore_phonebook_set_support_list(CoreObject *o, struct tel_phonebook_support_list *list);
+
+
+__END_DECLS
+
+#endif
diff --git a/include/co_ps.h b/include/co_ps.h
new file mode 100644 (file)
index 0000000..dd53655
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_CO_PS_H__
+#define __TCORE_CO_PS_H__
+
+#include <core_object.h>
+#include <co_context.h>
+
+__BEGIN_DECLS
+
+
+#define PS_MAX_CID  4
+
+struct tcore_ps_operations {
+       TReturn (*pin_ctrl)(CoreObject *o, UserRequest *ur);
+       TReturn (*activate_context)(CoreObject *co_ps, CoreObject *context, void *user_data);
+       TReturn (*deactivate_context)(CoreObject *co_ps, CoreObject *context, void *user_data);
+};
+
+CoreObject*  tcore_ps_new(TcorePlugin *p, const char *name, struct tcore_ps_operations *ops);
+void         tcore_ps_free(CoreObject *o);
+
+TReturn      tcore_ps_add_context(CoreObject *o, CoreObject *ctx_o);
+TReturn      tcore_ps_remove_context(CoreObject *o, CoreObject *ctx_o);
+CoreObject*  tcore_ps_ref_context_by_role(CoreObject *o, enum co_context_role role);
+GSList*      tcore_ps_ref_context_by_id(CoreObject *o, unsigned int id);
+
+TReturn      tcore_ps_set_online(CoreObject *o, gboolean state);
+
+TReturn      tcore_ps_assign_context_id(CoreObject *o, CoreObject *context, unsigned int cid);
+TReturn      tcore_ps_clear_context_id(CoreObject *o, CoreObject *context);
+
+TReturn      tcore_ps_activate_context(CoreObject *o, CoreObject *context, void *user_data);
+TReturn      tcore_ps_deactivate_context(CoreObject *o, CoreObject *context, void *user_data);
+TReturn      tcore_ps_deactivate_contexts(CoreObject *o);
+
+__END_DECLS
+
+#endif
diff --git a/include/co_sap.h b/include/co_sap.h
new file mode 100644 (file)
index 0000000..c2274c5
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_CO_SAP_H__
+#define __TCORE_CO_SAP_H__
+
+#include <core_object.h>
+
+__BEGIN_DECLS
+
+struct tcore_sap_operations {
+       TReturn (*connect)(CoreObject *o, UserRequest *ur);
+       TReturn (*disconnect)(CoreObject *o, UserRequest *ur);
+       TReturn (*req_status)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_transport_protocol)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_power)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_atr)(CoreObject *o, UserRequest *ur);
+       TReturn (*transfer_apdu)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_cardreader_status)(CoreObject *o, UserRequest *ur);
+};
+
+CoreObject* tcore_sap_new(TcorePlugin *p, const char *name, struct tcore_sap_operations *ops);
+void        tcore_sap_free(CoreObject *o);
+
+__END_DECLS
+
+#endif
diff --git a/include/co_sat.h b/include/co_sat.h
new file mode 100644 (file)
index 0000000..e2f8b72
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_CO_SAT_H__
+#define __TCORE_CO_SAT_H__
+
+#include <core_object.h>
+
+enum tcore_sat_result{
+       TCORE_SAT_SUCCESS,
+       TCORE_SAT_SUCCESS_PARTIAL_COMPREHENSION,
+       TCORE_SAT_UNABLE_TO_PERFORM_CMD,
+       TCORE_SAT_REQUIRED_VALUE_MISSING,
+       TCORE_SAT_COMMAND_NOT_UNDERSTOOD,
+       TCORE_SAT_BEYOND_ME_CAPABILITY,
+       TCORE_SAT_COMMAND_TYPE_NOT_UNDERSTOOD,
+       TCORE_SAT_ERROR_FATAL
+};
+
+struct tcore_sat_proactive_command {
+       int cmd_num;
+       enum tel_sat_proactive_cmd_type cmd_type;
+       union {
+               struct tel_sat_setup_event_list_tlv setup_event_list;
+               struct tel_sat_display_text_tlv display_text;
+               struct tel_sat_get_inkey_tlv get_inkey;
+               struct tel_sat_get_input_tlv get_input;
+               struct tel_sat_select_item_tlv select_item;
+               struct tel_sat_setup_menu_tlv setup_menu;
+/*             TelSatMoreTimeIndInfo_t moreTime;
+               TelSatPlayToneIndInfo_t playTone;
+
+               TelSatSendSmsIndInfo_t sendSms;
+               TelSatSendSsIndInfo_t sendSs;
+               TelSatSendUssdIndInfo_t sendUssd;
+               TelSatSetupCallIndInfo_t setupCall;
+               TelSatRefreshIndInfo_t refresh;
+               TelSatProvideLocalInfoIndInfo_t provideLocInfo;
+               TelSatLaunchBrowserIndInfo_t launchBrowser;
+               TelSatSetupIdleModeTextIndInfo_t idleText;
+               TelSatSendDtmfIndInfo_t sendDtmf;
+               TelSatLanguageNotificationIndInfo_t languageNotification;
+               TelSatSetupEventListIndInfo_t setupEventList;
+               TelSatOpenChannelIndInfo_t openChannel;
+               TelSatCloseChannelIndInfo_t closeChannel;
+               TelSatReceiveDataIndInfo_t receiveData;
+               TelSatSendDataIndInfo_t sendData;
+               TelSatGetChannelStatusIndInfo_t getChannelStatus;*/
+       } data;
+};
+
+struct tcore_sat_operations {
+       TReturn (*envelope)(CoreObject *o, UserRequest *ur);
+       TReturn (*terminal_response)(CoreObject *o, UserRequest *ur);
+};
+
+int tcore_sat_decode_proactive_command(unsigned char* tlv_origin, unsigned int tlv_length, struct tcore_sat_proactive_command* decoded_tlv);
+int tcore_sat_encode_envelop_cmd(const struct treq_sat_envelop_cmd_data *src_envelop, char *dst_envelop);
+int tcore_sat_encode_terminal_response(const struct treq_sat_terminal_rsp_data *src_tr, char *dst_tr);
+
+CoreObject* tcore_sat_new(TcorePlugin *p, const char *name, struct tcore_sat_operations *ops);
+void        tcore_sat_free(CoreObject *n);
+
+#endif
diff --git a/include/co_sim.h b/include/co_sim.h
new file mode 100644 (file)
index 0000000..5ab7a87
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_CO_SIM_H__
+#define __TCORE_CO_SIM_H__
+
+#include <core_object.h>
+
+__BEGIN_DECLS
+
+struct tcore_sim_operations {
+       TReturn (*verify_pins)(CoreObject *o, UserRequest *ur);
+       TReturn (*verify_puks)(CoreObject *o, UserRequest *ur);
+       TReturn (*change_pins)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_facility_status)(CoreObject *o, UserRequest *ur);
+       TReturn (*enable_facility)(CoreObject *o, UserRequest *ur);
+       TReturn (*disable_facility)(CoreObject *o, UserRequest *ur);
+       TReturn (*read_file)(CoreObject *o, UserRequest *ur);
+       TReturn (*update_file)(CoreObject *o, UserRequest *ur);
+       TReturn (*transmit_apdu)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_atr)(CoreObject *o, UserRequest *ur);
+       TReturn (*req_authentication)(CoreObject *o, UserRequest *ur);
+};
+
+CoreObject*          tcore_sim_new(TcorePlugin *p, const char *name, struct tcore_sim_operations *ops);
+void                 tcore_sim_free(CoreObject *n);
+
+enum tel_sim_type    tcore_sim_get_type(CoreObject *o);
+gboolean             tcore_sim_set_type(CoreObject *o, enum tel_sim_type type);
+
+struct tel_sim_imsi* tcore_sim_get_imsi(CoreObject *o);
+gboolean             tcore_sim_set_imsi(CoreObject *o, struct tel_sim_imsi *imsi);
+
+enum tel_sim_status  tcore_sim_get_status(CoreObject *o);
+gboolean             tcore_sim_set_status(CoreObject *o, enum tel_sim_status status);
+
+gboolean             tcore_sim_get_identification(CoreObject *o);
+gboolean             tcore_sim_set_identification(CoreObject *o, gboolean b_changed);
+
+gboolean             tcore_sim_get_cphs_status(CoreObject *o);
+gboolean             tcore_sim_set_cphs_status(CoreObject *o, gboolean b_support);
+
+gboolean             tcore_sim_link_userdata(CoreObject *o, void *userdata);
+void*                tcore_sim_ref_userdata(CoreObject *o);
+
+gboolean             tcore_sim_decode_iccid(struct tel_sim_iccid *p_out, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_lp(struct tel_sim_language *p_out, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_encode_lp(char *p_out, int out_length, struct tel_sim_language *p_in);
+gboolean             tcore_sim_decode_li(enum tel_sim_file_id file_id, struct tel_sim_language *p_out, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_encode_li(char *p_out, int out_length, struct tel_sim_language *p_in);
+gboolean             tcore_sim_decode_imsi(struct tel_sim_imsi *p_out, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_sst(struct tel_sim_sst *p_sst, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_spn(struct tel_sim_spn *p_spn, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_spdi(struct tel_sim_spdi *p_spdi, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_msisdn(struct tel_sim_msisdn *p_msisdn, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_xdn(struct tel_sim_dialing_number *p_xdn, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_encode_xdn(char *p_out, int out_length, struct tel_sim_dialing_number *p_xdn);
+gboolean             tcore_sim_decode_ecc(struct tel_sim_ecc_list *p_ecc, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_ust(struct tel_sim_ust *p_ust, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_est(struct tel_sim_est *p_est, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_uecc(struct tel_sim_ecc *p_ecc, unsigned char* p_in, int in_length);
+gboolean             tcore_sim_decode_gid( struct tel_sim_gid *p_gid, unsigned char* p_in, int in_length);
+gboolean             tcore_sim_decode_mbi(struct tel_sim_mbi *p_mbi, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_encode_mbi(char *p_out, int out_length, struct tel_sim_mbi *p_mbi);
+gboolean             tcore_sim_decode_cff(struct tel_sim_callforwarding *cfis, unsigned char *p_in, int in_length);
+char*                tcore_sim_encode_cff(const struct tel_sim_callforwarding *cff);
+gboolean             tcore_sim_decode_csp(struct tel_sim_cphs_csp *p_csp, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_encode_csp(unsigned char *p_out, int out_length, struct tel_sim_cphs_csp *p_csp);
+gboolean             tcore_sim_decode_vmwf(struct tel_sim_cphs_mw *p_vmwf,     unsigned char* p_in, unsigned long in_length);
+gboolean             tcore_sim_decode_mwis(struct tel_sim_mw *pMwis, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_encode_mwis( char *p_out, int out_length, struct tel_sim_mw *pMwis);
+gboolean             tcore_sim_encode_vmwf(char *p_out, int out_length, struct tel_sim_cphs_mw *p_vmwf);
+gboolean             tcore_sim_decode_ons(struct tel_sim_cphs_full_netname *p_on, unsigned char* p_in, int in_length);
+gboolean             tcore_sim_decode_cfis(struct tel_sim_callforwarding *cfis, unsigned char *p_in, int in_length);
+char*                tcore_sim_encode_cfis(const struct tel_sim_callforwarding *cfis);
+gboolean             tcore_sim_decode_dynamic_flag(struct tel_sim_cphs_dflag *p_df, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_dynamic2_flag(struct tel_sim_cphs_dflag2 *p_d2f, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_encode_dynamic_flag(char *p_out, int out_length, struct tel_sim_cphs_dflag *p_df);
+gboolean             tcore_sim_encode_dynamic2_flag(char *p_out, int out_length, struct tel_sim_cphs_dflag2 *p_d2f);
+gboolean             tcore_sim_decode_cphs_info(struct tel_sim_cphs_info *pCphsInfo, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_short_ons(struct tel_sim_cphs_short_netname *p_short_name, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_information_number(struct tel_sim_cphs_info_number *p_info, unsigned char* p_in, int in_length);
+gboolean             tcore_sim_decode_opl(struct tel_sim_opl *p_opl, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_pnn(struct tel_sim_pnn *p_pnn, unsigned char* p_in, int in_length);
+gboolean             tcore_sim_decode_oplmnwact(struct tel_sim_oplmnwact_list *p_list, unsigned char *p_in, int in_length);
+
+__END_DECLS
+
+#endif
diff --git a/include/co_sms.h b/include/co_sms.h
new file mode 100644 (file)
index 0000000..9c5dd39
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_CO_SMS_H__
+#define __TCORE_CO_SMS_H__
+
+#include <core_object.h>
+
+__BEGIN_DECLS
+
+
+#define nDefaultSMSPWithoutAlphaId     28
+
+#define SMSPValidDestAddr                      0x01
+#define SMSPValidSvcAddr                       0x02
+#define SMSPValidPID                           0x04
+#define SMSPValidDCS                           0x08
+#define SMSPValidVP                                    0x10
+
+#define nDestAddrOffset                                1
+#define nSCAAddrOffset                         13
+#define nPIDOffset                                     25
+#define nDCSOffset                                     26
+#define nVPOffset                                      27
+
+struct property_sms_info {
+       int     g_trans_id;
+       int     bDevice_Ready;
+       int     SMSPRecordLen;
+};
+
+struct tcore_sms_operations {
+       TReturn (*send_umts_msg)(CoreObject *o, UserRequest *ur);
+       TReturn (*read_msg)(CoreObject *o, UserRequest *ur);
+       TReturn (*save_msg)(CoreObject *o, UserRequest *ur);
+       TReturn (*delete_msg)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_storedMsgCnt)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_sca)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_sca)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_cb_config)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_cb_config)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_mem_status)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_pref_brearer)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_pref_brearer)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_delivery_report)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_msg_status)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_sms_params)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_sms_params)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_paramcnt)(CoreObject *o, UserRequest *ur);
+       TReturn (*send_cdma_msg)(CoreObject *o, UserRequest *ur);
+};
+
+
+CoreObject* tcore_sms_new(TcorePlugin *p, const char *name, struct tcore_sms_operations *ops);
+void        tcore_sms_free(CoreObject * n);
+int         _tcore_util_sms_encode_smsParameters(const struct telephony_sms_Params *incoming, unsigned char *data, int SMSPRecordLen);
+
+__END_DECLS
+
+#endif
+
diff --git a/include/co_ss.h b/include/co_ss.h
new file mode 100644 (file)
index 0000000..1f5d6a7
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_CO_SS_H__
+#define __TCORE_CO_SS_H__
+
+#include <core_object.h>
+
+__BEGIN_DECLS
+
+#define MAX_TCORE_SS_NUMBER_LEN 83
+
+enum tcore_ss_class {
+       TCORE_SS_CLATCORE_SS_NONE = 0x00,              /* 0x00 */
+
+       /* TELESERVICE */
+       TCORE_SS_CLATCORE_SS_ALL_TELE = 0x10,          /* 0x10 : All Teleservices */
+       TCORE_SS_CLATCORE_SS_VOICE = 0x11,             /* 0x11 : All Voice (telephony) */
+       TCORE_SS_CLATCORE_SS_ALL_DATA_TELE = 0x12,     /* 0x12 : All Data Teleservices */
+       TCORE_SS_CLATCORE_SS_FAX = 0x13,               /* 0x13 : All Fax Service */
+       TCORE_SS_CLATCORE_SS_SMS = 0x16,               /* 0x16 : SMS service */
+       TCORE_SS_CLATCORE_SS_VGCS = 0x17,              /* 0x17 : Voice Group Call Service */
+       TCORE_SS_CLATCORE_SS_VBS = 0x18,               /* 0x18 : Voice Broadcast */
+       TCORE_SS_CLATCORE_SS_ALL_TELE_EXPT_SMS = 0x19, /* 0x19 : All teleservice except SMS */
+
+       /* BEARER SERVICE */
+       TCORE_SS_CLATCORE_SS_ALL_BEARER = 0x20,        /* 0X20 : all bearer services */
+       TCORE_SS_CLATCORE_SS_ALL_ASYNC = 0x21,         /* 0x21 : All Async services */
+       TCORE_SS_CLATCORE_SS_ALL_SYNC = 0x22,          /* 0x22 : All sync services */
+       TCORE_SS_CLATCORE_SS_ALL_CS_SYNC = 0x24,       /* 0x24 : All Circuit switched sync */
+       TCORE_SS_CLATCORE_SS_ALL_CS_ASYNC = 0x25,      /* 0x25 : All Circuit switched async */
+       TCORE_SS_CLATCORE_SS_ALL_DEDI_PS = 0x26,       /* 0x26 : All Dedicated packet Access */
+       TCORE_SS_CLATCORE_SS_ALL_DEDI_PAD = 0x27,      /* 0x27 : All Dedicated PAD Access */
+       TCORE_SS_CLATCORE_SS_ALL_DATA_CDA = 0x28,      /* 0x28 : All Data CDA */
+
+       /* PLMN SPECIFIC TELESERVICE */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_ALL = 0x50,     /* 0x50 : PLMN specific teleservices */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_1 = 0x51,       /* 0x51 : PLMN specific teleservice 1 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_2 = 0x52,       /* 0x52 : PLMN specific teleservice 2 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_3 = 0x53,       /* 0x53 : PLMN specific teleservice 3 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_4 = 0x54,       /* 0x54 : PLMN specific teleservice 4 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_5 = 0x55,       /* 0x55 : PLMN specific teleservice 5 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_6 = 0x56,       /* 0x56 : PLMN specific teleservice 6 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_7 = 0x57,       /* 0x57 : PLMN specific teleservice 7 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_8 = 0x58,       /* 0x58 : PLMN specific teleservice 8 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_9 = 0x59,       /* 0x59 : PLMN specific teleservice 9 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_A = 0x60,       /* 0x60 : PLMN specific teleservice 10 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_B = 0x61,       /* 0x61 : PLMN specific teleservice 11 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_C = 0x62,       /* 0x62 : PLMN specific teleservice 12 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_D = 0x63,       /* 0x63 : PLMN specific teleservice 13 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_E = 0x64,       /* 0x64 : PLMN specific teleservice 14 */
+       TCORE_SS_CLATCORE_SS_PLMN_TELE_F = 0x65,       /* 0x65 : PLMN specific teleservice 15 */
+
+       /* PLMN SPECIFIC BEARER SERVICE */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_ALL = 0x70,     /* 0x70 : All PLMN specific bearer services */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_1 = 0x71,       /* 0x71 : PLMN specific bearer service 1 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_2 = 0x72,       /* 0x72 : PLMN specific bearer service 2 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_3 = 0x73,       /* 0x73 : PLMN specific bearer service 3 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_4 = 0x74,       /* 0x74 : PLMN specific bearer service 4 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_5 = 0x75,       /* 0x75 : PLMN specific bearer service 5 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_6 = 0x76,       /* 0x76 : PLMN specific bearer service 6 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_7 = 0x77,       /* 0x77 : PLMN specific bearer service 7 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_8 = 0x78,       /* 0x78 : PLMN specific bearer service 8 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_9 = 0x79,       /* 0x79 : PLMN specific bearer service 9 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_A = 0x80,       /* 0x80 : PLMN specific bearer service 10 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_B = 0x81,       /* 0x81 : PLMN specific bearer service 11 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_C = 0x82,       /* 0x82 : PLMN specific bearer service 12 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_D = 0x83,       /* 0x83 : PLMN specific bearer service 13 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_E = 0x84,       /* 0x84 : PLMN specific bearer service 14 */
+       TCORE_SS_CLATCORE_SS_PLMN_BEAR_F = 0x85,       /* 0x85 : PLMN specific bearer service 15 */
+
+       /* CPHS - AUXILIARY SERVICE */
+       TCORE_SS_CLATCORE_SS_AUX_VOICE = 0x89,         /* 0x89 : All Auxiliary Voice (Auxiliary telephony) */
+
+       TCORE_SS_CLATCORE_SS_ALL_GPRS_BEARER = 0x99,   /* 0x99 : All GPRS bearer services */
+       TCORE_SS_CLATCORE_SS_ALL_TELE_BEARER = 0xFF,   /* 0xFF : all tele and bearer services */
+};
+
+enum tcore_ss_status {
+       TCORE_SS_STATUS_REG = 0x01, /* 0x01 : Registration */
+       TCORE_SS_STATUS_DEREG,      /* 0x02 : De-registration( erase ) */
+       TCORE_SS_STATUS_ACTIVATE,   /* 0x03 : Activation */
+       TCORE_SS_STATUS_DEACTIVATE, /* 0x04 : De-activation */
+       TCORE_SS_STATUS_MAX
+};
+
+enum tcore_ss_barring_mode {
+       TCORE_SS_BARR_MODE_NONE,
+       TCORE_SS_BARR_MODE_BAOC,        /* 0x01 : Barring All Outgoing Calls */
+       TCORE_SS_BARR_MODE_BOIC,        /* 0x02 : Barring Outgoing International Calls */
+       TCORE_SS_BARR_MODE_BOIC_NOT_HC, /* 0x03 : Barring Outgoing International Calls  except to Home Country */
+       TCORE_SS_BARR_MODE_BAIC,        /* 0x04 : Barring All Incoming Calls */
+       TCORE_SS_BARR_MODE_BIC_ROAM,    /* 0x05 : Barring Incoming Calls when roam,     outside of the Home Country */
+       TCORE_SS_BARR_MODE_AB,          /* 0x06 : All Barring Services */
+       TCORE_SS_BARR_MODE_AOB,         /* 0x07 : All Outgoing Barring Services */
+       TCORE_SS_BARR_MODE_AIB,         /* 0x08 : All Incoming Barring Services */
+       TCORE_SS_BARR_MODE_BIC_NOT_SIM, /* 0x09 : Barring Incoming Calls which is not stored in the SIM memory */
+       TCORE_SS_BARR_MODE_MAX
+};
+
+enum tcore_ss_forwarding_mode {
+       TCORE_SS_CF_MODE_CFU = 0x01, /* 0x01 : Call Forwarding Unconditional */
+       TCORE_SS_CF_MODE_CFB,        /* 0x02 : Call Forwarding Mobile Busy */
+       TCORE_SS_CF_MODE_CFNRy,      /* 0x03 : Call Forwarding No Reply */
+       TCORE_SS_CF_MODE_CFNRc,      /* 0x04 : Call Forwarding Not Reachable */
+       TCORE_SS_CF_MODE_CF_ALL,     /* 0x05 : All Call Forwarding */
+       TCORE_SS_CF_MODE_CFC,        /* 0x06 : All Conditional Call Forwarding */
+       TCORE_SS_CF_MODE_MAX         /* 0x07 : Max */
+};
+
+enum tcore_ss_ussd_type {
+       TCORE_SS_USSD_TYPE_USER_INITIATED = 0x01, /* User Initiated USSD Message */
+       TCORE_SS_USSD_TYPE_USER_RES,              /* User Response to Network Initiated Message */
+       TCORE_SS_USSD_TYPE_USER_RELEASE,          /* SS Termination by user */
+       TCORE_SS_USSD_TYPE_NETWORK_INITIATED,     /* Network Initiated USSD Message */
+       TCORE_SS_USSD_TYPE_MAX,
+};
+
+enum tcore_ss_ussd_status {
+       TCORE_SS_USSD_NO_ACTION_REQUIRE = 0x01, /* 0x01 : no further user action required  information needed after mobile initiated operation) */
+       TCORE_SS_USSD_ACTION_REQUIRE,           /* 0x02 : further user action required(network initiated USSD Request, or further information needed after mobile initiated operation) */
+       TCORE_SS_USSD_TERMINATED_BY_NET,        /* 0x03 : USSD terminated by network */
+       TCORE_SS_USSD_OTHER_CLIENT,             /* 0x04 : other local client has responded */
+       TCORE_SS_USSD_NOT_SUPPORT,              /* 0x05 : operation not supported */
+       TCORE_SS_USSD_TIME_OUT,                 /* 0x06 : network time out */
+       TCORE_SS_USSD_MAX
+};
+
+enum tcore_ss_aoc_type {
+       TCORE_SS_AOC_TYPE_RESET  = 0x00, /* AoC Reset Message */
+       TCORE_SS_AOC_TYPE_ACM    = 0x01, /* Accumulated call meter Message */
+       TCORE_SS_AOC_TYPE_CCM    = 0x02, /* Current call meter Message */
+       TCORE_SS_AOC_TYPE_MAXACM = 0x04, /* Max Accumulated call meter Message */
+       TCORE_SS_AOC_TYPE_PUC    = 0x08, /* Price per unit and currency Message */
+       TCORE_SS_AOC_TYPE_MAX    = 0x10
+};
+
+typedef struct ussd_session UssdSession;
+
+struct tcore_ss_operations {
+       TReturn (*barring_activate)(CoreObject *o, UserRequest *ur);
+       TReturn (*barring_deactivate)(CoreObject *o, UserRequest *ur);
+       TReturn (*barring_change_password)(CoreObject *o, UserRequest *ur);
+       TReturn (*barring_get_status)(CoreObject *o, UserRequest *ur);
+       TReturn (*forwarding_activate)(CoreObject *o, UserRequest *ur);
+       TReturn (*forwarding_deactivate)(CoreObject *o, UserRequest *ur);
+       TReturn (*forwarding_register)(CoreObject *o, UserRequest *ur);
+       TReturn (*forwarding_deregister)(CoreObject *o, UserRequest *ur);
+       TReturn (*forwarding_get_status)(CoreObject *o, UserRequest *ur);
+       TReturn (*waiting_activate)(CoreObject *o, UserRequest *ur);
+       TReturn (*waiting_deactivate)(CoreObject *o, UserRequest *ur);
+       TReturn (*waiting_get_status)(CoreObject *o, UserRequest *ur);
+       TReturn (*cli_activate)(CoreObject *o, UserRequest *ur);
+       TReturn (*cli_deactivate)(CoreObject *o, UserRequest *ur);
+       TReturn (*cli_get_status)(CoreObject *o, UserRequest *ur);
+       TReturn (*send_ussd)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_aoc)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_aoc)(CoreObject *o, UserRequest *ur);
+};
+
+
+CoreObject* tcore_ss_new(TcorePlugin *p, const char *name, struct tcore_ss_operations *ops);
+void        tcore_ss_free(CoreObject *o);
+
+struct ussd_session*   tcore_ss_ussd_create_session( CoreObject *o, enum tcore_ss_ussd_type type, void *data, int data_len );
+void                                   tcore_ss_ussd_destroy_session( struct ussd_session *ussd_s );
+struct ussd_session*   tcore_ss_ussd_get_session( CoreObject *o );
+enum tcore_ss_ussd_type tcore_ss_ussd_get_session_type( struct ussd_session* ussd_s );
+void                                   tcore_ss_ussd_set_session_type( struct ussd_session* ussd_s, enum tcore_ss_ussd_type type );
+int                                            tcore_ss_ussd_get_session_data( struct ussd_session* ussd_s, void** data );
+
+__END_DECLS
+
+#endif
diff --git a/include/communicator.h b/include/communicator.h
new file mode 100644 (file)
index 0000000..867cb66
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_COMMUNICATOR_H__
+#define __TCORE_COMMUNICATOR_H__
+
+__BEGIN_DECLS
+
+struct tcore_communitor_operations {
+       TReturn (*send_response)(Communicator *comm, UserRequest *ur,
+        enum tcore_response_command command,
+        unsigned int data_len, const void *data);
+
+       TReturn (*send_notification)(Communicator *comm, CoreObject *source,
+        enum tcore_notification_command command,
+        unsigned int data_len, const void *data);
+};
+
+Communicator* tcore_communicator_new(TcorePlugin *plugin, const char *name,
+                  struct tcore_communitor_operations *ops);
+void          tcore_communicator_free();
+
+TcorePlugin*  tcore_communicator_ref_plugin(Communicator *comm);
+const char*   tcore_communicator_ref_name(Communicator *comm);
+
+TReturn       tcore_communicator_link_user_data(Communicator *comm, void *data);
+void*         tcore_communicator_ref_user_data(Communicator *comm);
+
+TReturn       tcore_communicator_send_response(Communicator *comm,
+                  UserRequest *ur,  enum tcore_response_command command,
+                  unsigned int data_len, const void *data);
+
+TReturn       tcore_communicator_send_notification(Communicator *comm,
+                  CoreObject *source, enum tcore_notification_command command,
+                  unsigned int data_len, const void *data);
+
+TReturn       tcore_communicator_dispatch_request(Communicator *comm, UserRequest *ur);
+
+__END_DECLS
+
+#endif
diff --git a/include/core_object.h b/include/core_object.h
new file mode 100644 (file)
index 0000000..d415fa4
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_CORE_OBJECT_H__
+#define __TCORE_CORE_OBJECT_H__
+
+__BEGIN_DECLS
+
+#define CORE_OBJECT_TYPE_DEFAULT       0xB0000000
+#define CORE_OBJECT_TYPE_MODEM         (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_MODEM)
+#define CORE_OBJECT_TYPE_CALL          (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_CALL)
+#define CORE_OBJECT_TYPE_SS            (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SS)
+#define CORE_OBJECT_TYPE_NETWORK       (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_NETWORK)
+#define CORE_OBJECT_TYPE_PS            (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_PS)
+#define CORE_OBJECT_TYPE_PS_CONTEXT    (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_PDP)
+#define CORE_OBJECT_TYPE_SIM           (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SIM)
+#define CORE_OBJECT_TYPE_SAT           (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SAT)
+#define CORE_OBJECT_TYPE_SAP           (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SAP)
+#define CORE_OBJECT_TYPE_SMS           (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SMS)
+#define CORE_OBJECT_TYPE_PHONEBOOK     (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_PHONEBOOK)
+#define CORE_OBJECT_TYPE_SOUND         (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_SOUND)
+#define CORE_OBJECT_TYPE_CUSTOM        (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_CUSTOM)
+
+#define CORE_OBJECT_CHECK(o,t) \
+       if (!o) { warn("core_object is NULL"); return; } \
+       if (tcore_object_get_type(o) != t) { warn("type(0x%x != 0x%x) mismatch", tcore_object_get_type(o), t); return; }
+#define CORE_OBJECT_CHECK_RETURN(o,t,r) \
+       if (!o) { warn("core_object is NULL"); return r; } \
+       if (tcore_object_get_type(o) != t) { warn("type(0x%x != 0x%x) mismatch", tcore_object_get_type(o), t); return r; }
+
+typedef void (*CoreObjectFreeHook)(CoreObject *co);
+typedef void (*CoreObjectCallback)(CoreObject *co, const void *event_info, void *user_data);
+typedef TReturn (*CoreObjectDispatcher)(CoreObject *co, UserRequest *ur);
+
+CoreObject*      tcore_object_new(TcorePlugin *plugin, const char *name);
+void             tcore_object_free(CoreObject *co);
+
+TReturn          tcore_object_set_free_hook(CoreObject *co, CoreObjectFreeHook free_hook);
+
+TReturn          tcore_object_set_name(CoreObject *co, const char *name);
+const char*      tcore_object_ref_name(CoreObject *co);
+
+TReturn          tcore_object_set_plugin(CoreObject *co, TcorePlugin *plugin);
+TcorePlugin*     tcore_object_ref_plugin(CoreObject *co);
+
+TReturn          tcore_object_link_object(CoreObject *co, void *object);
+void*            tcore_object_ref_object(CoreObject *co);
+
+TReturn          tcore_object_set_type(CoreObject *co, unsigned int type);
+unsigned int     tcore_object_get_type(CoreObject *co);
+
+TReturn          tcore_object_link_user_data(CoreObject *co, void *user_data);
+void*            tcore_object_ref_user_data(CoreObject *co);
+
+TReturn          tcore_object_set_dispatcher(CoreObject *co, CoreObjectDispatcher func);
+TReturn          tcore_object_dispatch_request(CoreObject *co, UserRequest *ur);
+
+TReturn          tcore_object_add_callback(CoreObject *co, const char *event, CoreObjectCallback callback, void *user_data);
+TReturn          tcore_object_del_callback(CoreObject *co, const char *event, CoreObjectCallback callback);
+TReturn          tcore_object_emit_callback(CoreObject *co, const char *event, const void *event_info);
+
+__END_DECLS
+
+#endif
diff --git a/include/hal.h b/include/hal.h
new file mode 100644 (file)
index 0000000..8775802
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_HAL_H__
+#define __TCORE_HAL_H__
+
+__BEGIN_DECLS
+
+typedef void (*TcoreHalReceiveCallback)(TcoreHal *hal, unsigned int data_len, const void *data, void *user_data);
+typedef enum tcore_hook_return (*TcoreHalSendHook)(TcoreHal *hal, unsigned int data_len, void *data, void *user_data);
+
+enum tcore_hal_recv_data_type {
+       TCORE_HAL_RECV_INDICATION,
+       TCORE_HAL_RECV_RESPONSE,
+       TCORE_HAL_RECV_NOTIFICATION,
+       TCORE_HAL_RECV_UNKNOWN
+};
+
+struct tcore_hal_operations {
+       TReturn (*power)(TcoreHal *hal, gboolean flag);
+       TReturn (*send)(TcoreHal *hal, unsigned int data_len, void *data);
+};
+
+TcoreHal*    tcore_hal_new(TcorePlugin *plugin, const char *name,
+                 struct tcore_hal_operations *hops);
+void         tcore_hal_free(TcoreHal *hal);
+
+TReturn      tcore_hal_set_name(TcoreHal *hal, const char *name);
+char*        tcore_hal_get_name(TcoreHal *hal);
+
+TReturn      tcore_hal_set_power(TcoreHal *hal, gboolean flag);
+
+TReturn      tcore_hal_link_user_data(TcoreHal *hal, void *user_data);
+void*        tcore_hal_ref_user_data(TcoreHal *hal);
+
+TReturn      tcore_hal_send_data(TcoreHal *hal, unsigned int data_len, void *data);
+TReturn      tcore_hal_send_request(TcoreHal *hal, TcorePending *plugin);
+
+TReturn      tcore_hal_dispatch_notification_data(TcoreHal *hal,
+                 const char *event, const void *data);
+TReturn      tcore_hal_dispatch_response_data(TcoreHal *hal, int id,
+                 unsigned int data_len, const void *data);
+
+TReturn      tcore_hal_add_recv_callback(TcoreHal *hal,
+                 TcoreHalReceiveCallback func, void *user_data);
+TReturn      tcore_hal_remove_recv_callback(TcoreHal *hal,
+                 TcoreHalReceiveCallback func);
+TReturn      tcore_hal_emit_recv_callback(TcoreHal *hal,
+                 unsigned int data_len, const void *data);
+
+TReturn      tcore_hal_add_send_hook(TcoreHal *hal, TcoreHalSendHook func,
+                 void *user_data);
+TReturn      tcore_hal_remove_send_hook(TcoreHal *hal, TcoreHalSendHook func);
+
+TReturn      tcore_hal_set_power_state(TcoreHal *hal, gboolean flag);
+gboolean     tcore_hal_get_power_state(TcoreHal *hal);
+
+TcoreQueue*  tcore_hal_ref_queue(TcoreHal *hal);
+TcorePlugin* tcore_hal_ref_plugin(TcoreHal *hal);
+
+__END_DECLS
+
+#endif
diff --git a/include/log.h b/include/log.h
new file mode 100644 (file)
index 0000000..b80d822
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_LOG_H__
+#define __TCORE_LOG_H__
+
+__BEGIN_DECLS
+
+#ifdef FEATURE_DLOG_DEBUG
+
+#include <dlog.h>
+
+#ifndef TCORE_LOG_TAG
+#define TCORE_LOG_TAG "UNKNOWN"
+#endif
+
+#define msg(fmt,args...)  { RLOG(LOG_INFO, TCORE_LOG_TAG, fmt "\n", ##args); }
+#define dbg(fmt,args...)  { RLOG(LOG_DEBUG, TCORE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); }
+#define warn(fmt,args...)  { RLOG(LOG_WARN, TCORE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); }
+#define err(fmt,args...)  { RLOG(LOG_FATAL, TCORE_LOG_TAG, "<%s:%D> " fmt "\n", __func__, __LINE__, ##args); }
+
+#else
+
+#define ANSI_COLOR_NORMAL "\e[0m"
+
+#define ANSI_COLOR_BLACK "\e[0;30m"
+#define ANSI_COLOR_RED "\e[0;31m"
+#define ANSI_COLOR_GREEN "\e[0;32m"
+#define ANSI_COLOR_BROWN "\e[0;33m"
+#define ANSI_COLOR_BLUE "\e[0;34m"
+#define ANSI_COLOR_MAGENTA "\e[0;35m"
+#define ANSI_COLOR_CYAN "\e[0;36m"
+#define ANSI_COLOR_LIGHTGRAY "\e[0;37m"
+
+#define ANSI_COLOR_DARKGRAY "\e[1;30m"
+#define ANSI_COLOR_LIGHTRED "\e[1;31m"
+#define ANSI_COLOR_LIGHTGREEN "\e[1;32m"
+#define ANSI_COLOR_YELLOW "\e[1;33m"
+#define ANSI_COLOR_LIGHTBLUE "\e[1;34m"
+#define ANSI_COLOR_LIGHTMAGENTA "\e[1;35m"
+#define ANSI_COLOR_LIGHTCYAN "\e[1;36m"
+#define ANSI_COLOR_WHITE "\e[1;37m"
+
+#ifndef TCORE_LOG_FILE
+#define TCORE_LOG_FILE stdout
+#endif
+
+#define msg(fmt,args...)  fprintf(TCORE_LOG_FILE, fmt "\n", ##args); fflush(TCORE_LOG_FILE);
+#define dbg(fmt,args...)  fprintf(TCORE_LOG_FILE, ANSI_COLOR_LIGHTGRAY "<%s:%s> " ANSI_COLOR_NORMAL fmt "\n", __FILE__, __FUNCTION__, ##args); fflush(TCORE_LOG_FILE);
+#define warn(fmt,args...) fprintf(TCORE_LOG_FILE, ANSI_COLOR_YELLOW "<%s:%s> " ANSI_COLOR_NORMAL fmt "\n", __FILE__, __FUNCTION__, ##args); fflush(TCORE_LOG_FILE);
+#define err(fmt,args...)  fprintf(TCORE_LOG_FILE, ANSI_COLOR_LIGHTRED "<%s:%s> " ANSI_COLOR_NORMAL fmt "\n", __FILE__, __FUNCTION__, ##args); fflush(TCORE_LOG_FILE);
+
+#endif
+
+__END_DECLS
+
+#endif
diff --git a/include/plugin.h b/include/plugin.h
new file mode 100644 (file)
index 0000000..a6920e4
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_PLUGIN_H__
+#define __TCORE_PLUGIN_H__
+
+__BEGIN_DECLS
+
+enum tcore_plugin_priority {
+       TCORE_PLUGIN_PRIORITY_HIGH = -100,
+       TCORE_PLUGIN_PRIORITY_MID = 0,
+       TCORE_PLUGIN_PRIORITY_LOW = +100
+};
+
+struct tcore_plugin_define_desc {
+       gchar *name;
+       enum tcore_plugin_priority priority;
+       int version;
+       gboolean (*load)();
+       gboolean (*init)(TcorePlugin *);
+       void (*unload)(TcorePlugin *);
+};
+
+
+TcorePlugin* tcore_plugin_new(Server *server,
+                 const struct tcore_plugin_define_desc *desc,
+                 const char *filename, void *handle);
+void         tcore_plugin_free(TcorePlugin *plugin);
+
+const struct tcore_plugin_define_desc*
+             tcore_plugin_get_description(TcorePlugin *plugin);
+
+char*        tcore_plugin_get_filename(TcorePlugin *plugin);
+char*        tcore_plugin_ref_plugin_name(TcorePlugin *plugin);
+Server*      tcore_plugin_ref_server(TcorePlugin *plugin);
+
+TReturn      tcore_plugin_set_hal(TcorePlugin *plugin, TcoreHal *hal);
+TcoreHal*    tcore_plugin_ref_hal(TcorePlugin *plugin);
+
+TReturn      tcore_plugin_link_user_data(TcorePlugin *plugin, void *user_data);
+void*        tcore_plugin_ref_user_data(TcorePlugin *plugin);
+
+TReturn      tcore_plugin_add_core_object(TcorePlugin *plugin, CoreObject *co);
+CoreObject*  tcore_plugin_ref_core_object(TcorePlugin *plugin, const char *name);
+GSList*      tcore_plugin_get_core_objects_bytype(TcorePlugin *plugin,
+                 unsigned int type);
+
+TReturn      tcore_plugin_core_object_event_emit(TcorePlugin *plugin,
+                 const char *event, const void *event_info);
+
+TReturn      tcore_plugin_link_property(TcorePlugin *plugin, const char *key,
+                 void *data);
+void*        tcore_plugin_ref_property(TcorePlugin *plugin, const char *key);
+
+__END_DECLS
+
+#endif
diff --git a/include/queue.h b/include/queue.h
new file mode 100644 (file)
index 0000000..66ce722
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_QUEUE_H__
+#define __TCORE_QUEUE_H__
+
+__BEGIN_DECLS
+
+typedef void(*TcorePendingSendCallback)(TcorePending *p, gboolean result,
+    void *user_data);
+typedef void(*TcorePendingTimeoutCallback)(TcorePending *p, void *user_data);
+typedef void(*TcorePendingResponseCallback)(TcorePending *p, int data_len,
+    const void *data, void *user_data);
+
+enum tcore_pending_priority {
+       TCORE_PENDING_PRIORITY_IMMEDIATELY = 0,
+       TCORE_PENDING_PRIORITY_HIGH = 100,
+       TCORE_PENDING_PRIORITY_DEFAULT = 200,
+       TCORE_PENDING_PRIORITY_LOW = 300,
+};
+
+TcorePending* tcore_pending_new(CoreObject *co, unsigned int id);
+void          tcore_pending_free(TcorePending *pending);
+
+unsigned int  tcore_pending_get_id(TcorePending *pending);
+TReturn       tcore_pending_set_auto_free_status_after_sent(TcorePending *pending,
+                  gboolean flag);
+gboolean      tcore_pending_get_auto_free_status_after_sent(TcorePending *pending);
+TReturn       tcore_pending_set_request_data(TcorePending *pending,
+                  unsigned int data_len, void *data);
+void*         tcore_pending_ref_request_data(TcorePending *pending,
+                  unsigned int *data_len);
+TReturn       tcore_pending_set_timeout(TcorePending *pending,
+                  unsigned int timeout);
+TcorePlugin*  tcore_pending_ref_plugin(TcorePending *pending);
+CoreObject*   tcore_pending_ref_core_object(TcorePending *pending);
+TReturn       tcore_pending_set_priority(TcorePending *pending,
+                  enum tcore_pending_priority priority);
+TReturn       tcore_pending_get_priority(TcorePending *pending,
+                  enum tcore_pending_priority *result_priority);
+TReturn       tcore_pending_get_send_status(TcorePending *pending,
+                  gboolean *result_status);
+TReturn       tcore_pending_link_user_request(TcorePending *pending,
+                  UserRequest *ur);
+UserRequest*  tcore_pending_ref_user_request(TcorePending *pending);
+
+TReturn       tcore_pending_set_send_callback(TcorePending *pending,
+                  TcorePendingSendCallback func, void *user_data);
+TReturn       tcore_pending_emit_send_callback(TcorePending *pending, int bytes);
+
+TReturn       tcore_pending_set_timeout_callback(TcorePending *pending,
+                  TcorePendingTimeoutCallback func, void *user_data);
+TReturn       tcore_pending_emit_timeout_callback(TcorePending *pending);
+
+TReturn       tcore_pending_set_response_callback(TcorePending *pending,
+                  TcorePendingResponseCallback func, void *user_data);
+TReturn       tcore_pending_emit_response_callback(TcorePending *pending,
+                  int data_len, const void *data);
+
+
+TcoreQueue*   tcore_queue_new(TcorePlugin *plugin);
+void          tcore_queue_free(TcoreQueue *qeueu);
+
+TReturn       tcore_queue_push(TcoreQueue *queue, TcorePending *pending);
+TcorePending* tcore_queue_pop(TcoreQueue *queue);
+TcorePending* tcore_queue_pop_timeout_pending(TcoreQueue *queue);
+TcorePending* tcore_queue_ref_head(TcoreQueue *queue);
+TcorePending* tcore_queue_ref_tail(TcoreQueue *queue);
+TcorePending* tcore_queue_pop_by_id(TcoreQueue *queue, unsigned int id);
+TcorePending* tcore_queue_ref_pending_by_id(TcoreQueue *queue, unsigned int id);
+TcorePending* tcore_queue_ref_next_pending(TcoreQueue *queue);
+unsigned int  tcore_queue_get_length(TcoreQueue *queue);
+TcorePlugin*  tcore_queue_ref_plugin(TcoreQueue *queue);
+
+__END_DECLS
+
+#endif
diff --git a/include/server.h b/include/server.h
new file mode 100644 (file)
index 0000000..5017f73
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_SERVER_H__
+#define __TCORE_SERVER_H__
+
+__BEGIN_DECLS
+
+typedef enum tcore_hook_return (*TcoreServerRequestHook)(Server *s,
+    UserRequest *ur, void *user_data);
+typedef enum tcore_hook_return (*TcoreServerNotificationHook)(Server *s,
+    CoreObject *source, enum tcore_notification_command command,
+    unsigned int data_len, void *data, void *user_data);
+
+Server*       tcore_server_new();
+void          tcore_server_free(Server *s);
+
+TReturn       tcore_server_run(Server *s);
+TReturn       tcore_server_exit(Server *s);
+
+TReturn       tcore_server_add_plugin(Server *s, TcorePlugin *plugin);
+GSList*       tcore_server_ref_plugins(Server *s);
+TcorePlugin*  tcore_server_find_plugin(Server *s, const char *name);
+
+TReturn       tcore_server_add_communicator(Server *s, Communicator *comm);
+GSList*       tcore_server_ref_communicators(Server *s);
+Communicator* tcore_server_find_communicator(Server *s, const char *name);
+
+TReturn       tcore_server_add_storage(Server *s, Storage *strg);
+GSList*       tcore_server_ref_storages(Server *s);
+Storage*      tcore_server_find_storage(Server *s, const char *name);
+
+TReturn       tcore_server_add_hal(Server *s, TcoreHal *hal);
+GSList*       tcore_server_ref_hals(Server *s);
+TcoreHal*     tcore_server_find_hal(Server *s, const char *name);
+
+TReturn       tcore_server_dispatch_request(Server *s, UserRequest *ur);
+TReturn       tcore_server_send_notification(Server *s, CoreObject *source,
+                  enum tcore_notification_command command,
+                  unsigned int data_len, void *data);
+
+TReturn       tcore_server_add_request_hook(Server *s,
+                  enum tcore_request_command command,
+                  TcoreServerRequestHook func, void *user_data);
+TReturn       tcore_server_remove_request_hook(Server *s,
+                  TcoreServerRequestHook func);
+TReturn       tcore_server_add_notification_hook(Server *s,
+                  enum tcore_notification_command command,
+                  TcoreServerNotificationHook func, void *user_data);
+TReturn       tcore_server_remove_notification_hook(Server *s,
+                  TcoreServerNotificationHook func);
+
+__END_DECLS
+
+#endif
diff --git a/include/storage.h b/include/storage.h
new file mode 100644 (file)
index 0000000..3f422f2
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_STORAGE_H__
+#define __TCORE_STORAGE_H__
+
+__BEGIN_DECLS
+
+#define STORAGE_KEY_INT                0x01000000
+#define STORAGE_KEY_BOOL       0x02000000
+#define STORAGE_KEY_STRING     0x03000000
+#define STORAGE_KEY_DOUBLE     0x04000000
+
+enum tcore_storage_key {
+       STORAGE_KEY_TELEPHONY_INT = STORAGE_KEY_INT,
+       STORAGE_KEY_TELEPHONY_PLMN,
+       STORAGE_KEY_TELEPHONY_LAC,
+       STORAGE_KEY_TELEPHONY_CELLID,
+       STORAGE_KEY_TELEPHONY_SVCTYPE,
+       STORAGE_KEY_TELEPHONY_SVC_CS,//5
+
+       STORAGE_KEY_TELEPHONY_SVC_PS,
+       STORAGE_KEY_TELEPHONY_SVC_ROAM,
+       STORAGE_KEY_TELEPHONY_ZONE_TYPE,
+       STORAGE_KEY_TELEPHONY_SIM_INIT,
+       STORAGE_KEY_TELEPHONY_SIM_CHV,//10
+
+       STORAGE_KEY_TELEPHONY_SIM_PB_INIT,
+       STORAGE_KEY_TELEPHONY_CALL_STATE,
+       STORAGE_KEY_TELEPHONY_CALL_FORWARD_STATE,
+       STORAGE_KEY_TELEPHONY_TAPI_STATE,
+       STORAGE_KEY_TELEPHONY_SPN_DISP_CONDITION,//15
+
+       STORAGE_KEY_TELEPHONY_SAT_STATE,
+       STORAGE_KEY_TELEPHONY_ZONE_ZUHAUSE,
+       STORAGE_KEY_TELEPHONY_RSSI,
+       STORAGE_KEY_TELEPHONY_LOW_BATTERY,
+       STORAGE_KEY_TELEPHONY_EVENT_SYSTEM_READY,//20
+
+       STORAGE_KEY_TELEPHONY_SIM_SLOT,
+       STORAGE_KEY_PM_STATE,
+       STORAGE_KEY_PACKET_SERVICE_STATE,
+       STORAGE_KEY_MESSAGE_NETWORK_MODE,
+       STORAGE_KEY_CELLULAR_STATE,//25
+
+       STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV,
+       STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT,
+       STORAGE_KEY_CELLULAR_PKT_LAST_RCV,
+       STORAGE_KEY_CELLULAR_PKT_LAST_SNT,
+
+       STORAGE_KEY_TELEPHONY_BOOL = STORAGE_KEY_BOOL,
+       STORAGE_KEY_3G_ENABLE,
+       STORAGE_KEY_SETAPPL_STATE_DATA_ROAMING_BOOL,
+       STORAGE_KEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL,
+       STORAGE_KEY_SETAPPL_FLIGHT_MODE_BOOL,
+
+       STORAGE_KEY_TELEPHONY_STRING = STORAGE_KEY_STRING,
+       STORAGE_KEY_TELEPHONY_NWNAME,
+       STORAGE_KEY_TELEPHONY_SPN_NAME,
+       STORAGE_KEY_TELEPHONY_SAT_SETUP_IDLE_TEXT,
+       STORAGE_KEY_TELEPHONY_IMEI,
+       STORAGE_KEY_TELEPHONY_SUBSCRIBER_NUMBER,
+       STORAGE_KEY_TELEPHONY_SUBSCRIBER_NAME,
+       STORAGE_KEY_TELEPHONY_SWVERSION,
+       STORAGE_KEY_TELEPHONY_HWVERSION,
+       STORAGE_KEY_TELEPHONY_CALDATE,
+       STORAGE_KEY_TELEPHONY_IMEI_FACTORY_REBOOT,
+       STORAGE_KEY_TELEPHONY_SIM_FACTORY_MODE,
+       STORAGE_KEY_TELEPHONY_PRODUCTCODE,
+       STORAGE_KEY_TELEPHONY_FACTORY_KSTRINGB,
+       STORAGE_KEY_TELEPHONY_IMSI,
+};
+
+enum storage_value {
+       STORAGE_VALUE_UNKNOWN = 0,
+       STORAGE_VALUE_OFF = 0,
+       STORAGE_VALUE_ON  = 1,
+       STORAGE_VALUE_STATE_0 = 0,
+       STORAGE_VALUE_STATE_1 = 1,
+       STORAGE_VALUE_STATE_2 = 2,
+       STORAGE_VALUE_STATE_3 = 3,
+       STORAGE_VALUE_STATE_4 = 4,
+       STORAGE_VALUE_STATE_5 = 5,
+       STORAGE_VALUE_STATE_6 = 6,
+       STORAGE_VALUE_STATE_7 = 7,
+       STORAGE_VALUE_STATE_8 = 8,
+       STORAGE_VALUE_STATE_9 = 9,
+};
+
+typedef void (*TcoreStorageKeyCallback) (enum tcore_storage_key key,
+    void *value, void *user_data);
+typedef void (*TcoreStorageDispatchCallback) (Storage *strg,
+    enum tcore_storage_key key, void *value);
+
+struct storage_operations {
+       void* (*create_handle)(Storage *strg, const char *path);
+       gboolean (*remove_handle)(Storage *strg, void *handle);
+
+       gboolean (*set_int)(Storage *strg, enum tcore_storage_key key, int value);
+       gboolean (*set_string)(Storage *strg, enum tcore_storage_key key, const char *value);
+       gboolean (*set_bool)(Storage *strg, enum tcore_storage_key key, gboolean value);
+       int (*get_int)(Storage *strg, enum tcore_storage_key key);
+       char* (*get_string)(Storage *strg, enum tcore_storage_key key);
+       gboolean (*get_bool)(Storage *strg, enum tcore_storage_key key);
+       gboolean (*set_key_callback)(Storage *strg, enum tcore_storage_key key,
+                       TcoreStorageDispatchCallback cb);
+       gboolean (*remove_key_callback)(Storage *strg, enum tcore_storage_key key);
+
+       gboolean (*update_query_database)(Storage *strg, void *handle,
+                       const char *query, GHashTable *in_param);
+       gboolean (*read_query_database)(Storage *strg, void *handle,
+                       const char *query, GHashTable *in_param,
+                       GHashTable *out_param, int out_param_cnt);
+       gboolean (*insert_query_database)(Storage *strg, void *handle,
+                       const char *query, GHashTable *in_param);
+       gboolean (*remove_query_database)(Storage *strg, void *handle,
+                       const char *query, GHashTable *in_param);
+};
+
+Storage*     tcore_storage_new(TcorePlugin *plugin, const char *name,
+                 struct storage_operations *ops);
+void         tcore_storage_free(Storage *strg);
+const char*  tcore_storage_ref_name(Storage *strg);
+
+void*        tcore_storage_create_handle(Storage *strg, const char *path);
+gboolean     tcore_storage_remove_handle(Storage *strg, void *handle);
+
+//storage vconf
+gboolean     tcore_storage_set_int(Storage *strg, enum tcore_storage_key key,
+                 int value);
+int          tcore_storage_get_int(Storage *strg, enum tcore_storage_key key);
+
+gboolean     tcore_storage_set_string(Storage *strg, enum tcore_storage_key key,
+                 const char *value);
+char*        tcore_storage_get_string(Storage *strg, enum tcore_storage_key key);
+
+gboolean     tcore_storage_set_bool(Storage *strg, enum tcore_storage_key key,
+                 gboolean value);
+gboolean     tcore_storage_get_bool(Storage *strg, enum tcore_storage_key key);
+
+gboolean     tcore_storage_set_key_callback(Storage *strg,
+                 enum tcore_storage_key key, TcoreStorageKeyCallback cb,
+                 void *user_data);
+gboolean     tcore_storage_remove_key_callback(Storage *strg,
+                 enum tcore_storage_key key, TcoreStorageKeyCallback cb);
+
+//storage database
+gboolean     tcore_storage_update_query_database(Storage *strg, void *handle,
+                 const char *query, GHashTable *in_param);
+gboolean     tcore_storage_read_query_database(Storage *strg, void *handle,
+                 const char *query, GHashTable *in_param, GHashTable *out_param,
+                 int out_param_cnt);
+gboolean     tcore_storage_insert_query_database(Storage *strg, void *handle,
+                 const char *query, GHashTable *in_param);
+gboolean     tcore_storage_remove_query_database(Storage *strg, void *handle,
+                 const char *query, GHashTable *in_param);
+
+__END_DECLS
+
+#endif
diff --git a/include/tcore.h b/include/tcore.h
new file mode 100644 (file)
index 0000000..32a5e5b
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_H__
+#define __TCORE_H__
+
+#include <sys/types.h>
+#include <stdint.h>
+
+#include <log.h>
+
+#include <type/common.h>
+
+#include <type/request.h>
+#include <type/response.h>
+#include <type/notification.h>
+
+#include <type/ps.h>
+#include <type/network.h>
+#include <type/modem.h>
+#include <type/sim.h>
+#include <type/sat.h>
+#include <type/sms.h>
+#include <type/call.h>
+#include <type/ss.h>
+#include <type/sap.h>
+#include <type/phonebook.h>
+
+typedef struct tcore_object_type CoreObject;
+typedef struct tcore_hal_type TcoreHal;
+typedef struct tcore_plugin_type TcorePlugin;
+typedef struct tcore_queue_type TcoreQueue;
+typedef struct tcore_pending_type TcorePending;
+typedef struct tcore_communicator_type Communicator;
+typedef struct tcore_user_request_type UserRequest;
+typedef struct tcore_server_type Server;
+typedef struct tcore_storage_type Storage;
+
+enum tcore_hook_return {
+       TCORE_HOOK_RETURN_STOP_PROPAGATION = FALSE,
+       TCORE_HOOK_RETURN_CONTINUE = TRUE
+};
+
+#endif
diff --git a/include/type/call.h b/include/type/call.h
new file mode 100644 (file)
index 0000000..c14d178
--- /dev/null
@@ -0,0 +1,475 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_CALL_H__
+#define __TYPE_CALL_H__
+
+__BEGIN_DECLS
+
+#include <glib.h>
+
+enum telephony_call_error_cause {
+       CALL_CAUSE_NONE,                                        /**< Success  */
+       CALL_CAUSE_ACCESSDISCARD,                       /**< Access discarded  */
+       CALL_CAUSE_BARR_BYOPERATOR,                     /**< Barred by operator */
+       CALL_CAUSE_BEARERMODE_NOTIMPL,          /**< Bearer mode not implemented */
+       CALL_CAUSE_BEARERMODE_RESTRICTED,       /**< Bearer mode restricted */
+       CALL_CAUSE_BEARERMODE_UNAUTH,           /**< Bearer mode un authorized */
+       CALL_CAUSE_BEARERMODE_UNAVAIL,          /**< Bearer mode not available */
+       CALL_CAUSE_BUSY,                                        /**< (Network/Server) busy */
+       CALL_CAUSE_CALLMETER_EXPIRED,           /**< Call meter expired */
+       CALL_CAUSE_CALLNO_ERROR,                        /**< Call number error */
+       CALL_CAUSE_CKTUNAVAIL,                          /**< Circuit channel unavailable */                     //10
+       CALL_CAUSE_CONGESTION,                          /**< Congestion happened */
+       CALL_CAUSE_NO_CIRCUIT_AVAIL,            /**< Circuit  not available */
+       CALL_CAUSE_DESTIN_INCOMPAT,                     /**< Destination incompatibility */
+       CALL_CAUSE_DTMF_NOSPEECH,                       /**< No speech in DTMF */
+       CALL_CAUSE_DTMF_REJECTED,                       /**< DTMF rejected */
+       CALL_CAUSE_FACILITY_NOTIMPL,            /**< Facility not implemented */
+       CALL_CAUSE_FACILITY_NOTSUBSCRIBED,      /**< Facility not subscribed */
+       CALL_CAUSE_INCOMINGCUGCALLS_BARRED, /**< Incoming CUG Calls barred */
+       CALL_CAUSE_INVALNUM,                            /**< Invalid number */
+       CALL_CAUSE_MPTY_ERROR,                          /**< Multiparty error */                                                //20
+       CALL_CAUSE_NOANSWER,                            /**< No answer  */
+       CALL_CAUSE_NONCUGMEMBER,                        /**< Non CUG member */
+       CALL_CAUSE_NUMBERCHANGED,                       /**< Number changed */
+       CALL_CAUSE_NUMBER_ERROR,                        /**< Number error */
+       CALL_CAUSE_NWFAILURE,                           /**< Network failure */
+       CALL_CAUSE_OPERATIONUNAVAIL,            /**< Operation not available */
+       CALL_CAUSE_OUTOFORDER,                          /**< Out of order */
+       CALL_CAUSE_PROTOCOL_ERROR,                      /**< Protocol error */
+       CALL_CAUSE_QOSUNAVAIL,                          /**< QOS unavailable */
+       CALL_CAUSE_REJECT,                                      /**< Rejected */                                                                //30
+       CALL_CAUSE_REJ_FAIL,                            /**< Rejection failed */
+       CALL_CAUSE_REJ_SRVC_NOT_AVL,            /**< Rejection service not available  */
+       CALL_CAUSE_REMOTE_CKTUNAVAIL,           /**< Remote Circuit channel unavailable */
+       CALL_CAUSE_RESOURCEUNAVAIL,                     /**< Resource not available */
+       CALL_CAUSE_SERVICEID_ERROR,                     /**< Service id error */
+       CALL_CAUSE_SERVICE_NOTIMPL,                     /**< Service not implemented */
+       CALL_CAUSE_SERVICE_UNAVAIL,                     /**< Service not available */
+       CALL_CAUSE_MODIFY_SAME_BEARER,          /**< Modify same bearer */
+       CALL_CAUSE_MODIFY_NOT_PERMITTED,        /**< Modification not permitted */
+       CALL_CAUSE_HOLD_FAIL,                           /**< Call hold fail */                                                  //40
+       CALL_CAUSE_TEMPFAILURE,                         /**< Temporary failure */
+       CALL_CAUSE_WRONGNUM,                            /**< Wrong number */
+       CALL_CAUSE_NORMAL_UNSPECIFIED,          /**< Normal but unspecified */
+       CALL_CAUSE_SSERRINVALIDTIVALUE,         /**< SS invalid Transaction ID Value */
+       CALL_CAUSE_SSERRINVALIDTI,                      /**< SS Invalid transaction ID */
+       CALL_CAUSE_SSINCOMPATIBLESTATE,         /**< SS incompatible state */
+       CALL_CAUSE_SSERRSYNTAXERROR,            /**< SS syntax error */
+       CALL_CAUSE_SSPROTOCOLERROR,                     /**< Protocol error */
+       CALL_CAUSE_SSNEGATIVEPASSWORDCHECK, /**< Negative password check */
+       CALL_CAUSE_SSSENTASPHASE1,                      /**< SS sent as phase1 message */                               //50
+       CALL_CAUSE_SSERROR,                                     /**< Supplementary service error */
+       CALL_CAUSE_SS_USSD_BUSY,                        /**< Second USSD request will be rejected when already USSD transaction is ongoing. */
+       CALL_CAUSE_IDLE,                                        /**< Idle */
+       CALL_CAUSE_NETWORK_SPECIFIC,            /**< Network specific error */
+       CALL_CAUSE_FADE,                                        /**< voice call was dropped e.g. because of a loss of signal */
+       CALL_CAUSE_UNKNOWN,                                     /**< unknown no details available */
+       CALL_CAUSE_INCOM_CALL,                          /**< terminated by incoming call */
+       CALL_CAUSE_ALERT_STOP,                          /**< terminated by alert stop */
+       CALL_CAUSE_INTERCEPT,                           /**< voice call was dropped by interception */
+       CALL_CAUSE_REORDER,                                     /**< voice call was dropped by reordering */    //60
+       CALL_CAUSE_CLIENT_END,                          /**< client ended the call */
+       CALL_CAUSE_ACCESS_CLASS_BLOCKED,        /**< access class blocked */
+       CALL_CAUSE_MEMCAPEXCEEDED,                      /**< Memory capacity exceeded */
+       CALL_CAUSE_TYPENOTSUPPORTED,            /**< Type not supported */
+       CALL_CAUSE_REPLACENOTSUPPORTED,         /**< Replace not supported */
+       CALL_CAUSE_PROTOCOLID_ERROR,            /**< Protocol id error */
+       CALL_CAUSE_CLASSNOTSUPPORTED,           /**< Class not supported */
+       CALL_CAUSE_DATACODING_ERROR,            /**< Data coding error */
+       CALL_CAUSE_INVAL_MSG,                           /**< Invalid message */
+       CALL_CAUSE_CALL_BARRED,                 /**< Call barred */                                                     //70
+       CALL_CAUSE_SIM_CALL_CONTROL_CHANGED_TO_SS,              /**< Sim call control changed to SS */
+       CALL_CAUSE_SIM_CALL_CONTROL_CHANGED_TO_CALL,    /**< SIM Call control changed to call */
+       CALL_CAUSE_SIM_ERROR,                           /**< SIM error */
+       CALL_CAUSE_SIM_CALL_CONTROL_MODIFIED,                   /**< SIM call control modified */
+       CALL_CAUSE_RANDOM_ACCESS_FAILURE,       /**< Random access error */
+       CALL_CAUSE_LOWER_LAYER_FAILURE,         /**< Lower layer error */
+       CALL_CAUSE_ACCESS_REJECTED,                     /**< Access rejected */
+       CALL_CAUSE_RESET_NOT_ALLOWED,           /**< Reset not allowed */
+       CALL_CAUSE_EMERGENCY_CALL_NOT_ALLOWED,                  /**< Emergency call not allowed */
+       CALL_CAUSE_ACCESS_NOT_ALLOWED,          /**< Access not allowed */                                              //80
+       CALL_CAUSE_RADIO_LINK_FAILURE,          /**< Radio link failure */
+       CALL_CAUSE_INVALID_IDENTITY,            /**< Invalid identity */
+       CALL_CAUSE_UNKNOWN_IDENTITY,            /**< Unknown identity */
+       CALL_CAUSE_UNACCEPTABLE_IDENTITY,       /**< Un acceptable identity */
+       CALL_CAUSE_NO_SERVICE_HERE,                     /**< No service here */
+       CALL_CAUSE_SERVICE_NOT_ALLOWED,         /**< Service not allowed */
+       CALL_CAUSE_SERVICE_NOT_AVAIL,           /**< Service not available */
+       CALL_CAUSE_SERVICE_NOT_WORKING,         /**< Service not working */
+       CALL_CAUSE_CANNOT_IDENTIFY_CALL,        /**< Cannot identify the call */
+       CALL_CAUSE_DEACTIVATION,                        /**< Deactivation */                                                    //90
+       CALL_CAUSE_FATAL_ERROR,                         /**< Fatal error */
+       CALL_CAUSE_SEND_DTMF_SUCCESS,           /**< Sending DTMF Success */
+       CALL_CAUSE_SEND_DTMF_FAIL,                      /**< Sending DTMF Failed */
+       CALL_CAUSE_TIMER_EXPIRED,                       /**< Call Timer Expired */
+};
+
+enum telephony_call_answer_type {
+       CALL_ANSWER_TYPE_ACCEPT,
+       CALL_ANSWER_TYPE_REJECT,
+       CALL_ANSWER_TYPE_REPLACE,
+       CALL_ANSWER_TYPE_HOLD_ACCEPT,
+};
+
+enum telephony_call_type {
+       CALL_TYPE_VOICE,
+       CALL_TYPE_VIDEO,
+       CALL_TYPE_E911
+};
+
+enum telephony_call_status {
+       CALL_STATUS_IDLE,
+       CALL_STATUS_ACTIVE,
+       CALL_STATUS_HELD,
+       CALL_STATUS_DIALING,
+       CALL_STATUS_ALERT,
+       CALL_STATUS_INCOMING,
+       CALL_STATUS_WAITING,
+};
+
+enum telephony_call_end_type {
+       CALL_END_TYPE_DEFAULT,
+       CALL_END_TYPE_ALL,
+       CALL_END_TYPE_ACTIVE_ALL,
+       CALL_END_TYPE_HOLD_ALL,
+};
+
+enum telephony_call_end_cause {
+       CALL_END_CAUSE_NONE = 0x00,                             /**< No Cause */
+
+       CALL_END_CAUSE_UNASSIGNED_NUMBER,                       /**< Unassigned Number */
+       CALL_END_CAUSE_NO_ROUTE_TO_DEST,                        /**< No Route to Destination */
+       CALL_END_CAUSE_CHANNEL_UNACCEPTABLE,            /**< Channel Unacceptable */
+       CALL_END_CAUSE_OPERATOR_DETERMINED_BARRING,     /**< Operator Determined Barring */
+       CALL_END_CAUSE_NORMAL_CALL_CLEARING,    /**< Normal Call Clearing */
+
+       CALL_END_CAUSE_USER_BUSY,                                       /**< User Busy */
+       CALL_END_CAUSE_NO_USER_RESPONDING,                      /**< No user Responding */
+       CALL_END_CAUSE_USER_ALERTING_NO_ANSWER,         /**< User Alerting no Answer */
+       CALL_END_CAUSE_CALL_REJECTED,                   /**< Call Rejected */
+       CALL_END_CAUSE_NUMBER_CHANGED,                          /**< Number Changed */
+
+       CALL_END_CAUSE_NON_SELECTED_USER_CLEARING,      /**< Non Selected User Clearing */
+       CALL_END_CAUSE_DESTINATION_OUT_OF_ORDER,        /**< Destination out of Order */
+       CALL_END_CAUSE_INVALID_NUMBER_FORMAT,           /**< Invalid Number Format */
+       CALL_END_CAUSE_FACILITY_REJECTED,                       /**< Facility Rejected */
+       CALL_END_CAUSE_RESPONSE_TO_STATUS_ENQUIRY,      /**< Response to Status Enquiry */
+
+       CALL_END_CAUSE_NORMAL_UNSPECIFIED,                              /**< Normal Unspecified */
+       CALL_END_CAUSE_NO_CIRCUIT_CHANNEL_AVAILABLE,    /**< No Circuit Channel Available */
+       CALL_END_CAUSE_NETWORK_OUT_OF_ORDER,                    /**< Network out of Order */
+       CALL_END_CAUSE_TEMPORARY_FAILURE,                               /**< Temporary Failure */
+       CALL_END_CAUSE_SWITCHING_EQUIPMENT_CONGESTION,  /**< Switching Equipment Congestion */
+
+       CALL_END_CAUSE_ACCESS_INFORMATION_DISCARDED,                    /**< Access Information Discarded */
+       CALL_END_CAUSE_REQUESTED_CIRCUIT_CHANNEL_NOT_AVAILABLE, /**< Requested Circuit channel not available */
+       CALL_END_CAUSE_RESOURCES_UNAVAILABLE_UNSPECIFIED,               /**< Resources unavailable unspecified */
+       CALL_END_CAUSE_QUALITY_OF_SERVICE_UNAVAILABLE,                  /**< Quality of service unavailable */
+       CALL_END_CAUSE_REQUESTED_FACILITY_NOT_SUBSCRIBED,               /**< Requested facility not subscribed */
+
+       CALL_END_CAUSE_INCOMING_CALL_BARRED_WITHIN_CUG,         /**< incomming call barred within CUG */
+       CALL_END_CAUSE_BEARER_CAPABILITY_NOT_AUTHORISED,                /**< Bearer Capability not Authorised */
+       CALL_END_CAUSE_BEARER_CAPABILITY_NOT_PRESENTLY_AVAILABLE,/**< Bearer capability not presently Available */
+       CALL_END_CAUSE_SERVICE_OR_OPTION_NOT_AVAILABLE,                 /**< Service or Option not available */
+       CALL_END_CAUSE_BEARER_SERVICE_NOT_IMPLEMENTED,                  /**< Service not implemented */
+
+       CALL_END_CAUSE_ACM_GEQ_ACMMAX,                                                  /**< ACM GEQ ACMAX */
+       CALL_END_CAUSE_REQUESTED_FACILITY_NOT_IMPLEMENTED,              /**< Requested facility not implemented */
+       CALL_END_CAUSE_ONLY_RESTRICTED_DIGITAL_INFO_BC_AVAILABLE,/**< Resticted digital info BC not available */
+       CALL_END_CAUSE_SERVICE_OR_OPTION_NOT_IMPLEMENTED,               /**< Service or Option not Implemented  */
+       CALL_END_CAUSE_INVALID_TRANSACTION_ID_VALUE,                    /**< Transaction ID value */
+
+       CALL_END_CAUSE_USER_NOT_MEMBER_OF_CUG,                          /**< Not member of CUG */
+       CALL_END_CAUSE_INCOMPATIBLE_DESTINATION,                        /**< Incompatible Destination */
+       CALL_END_CAUSE_INVALID_TRANSIT_NETWORK_SELECTION,       /**< Transit Network selection */
+       CALL_END_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE,          /**< Semantically Incorrect message */
+       CALL_END_CAUSE_INVALID_MANDATORY_INFORMATION,           /**< Invalid Mandatory Message */
+
+       CALL_END_CAUSE_MESSAGE_TYPE_NON_EXISTENT,                                       /**< Message Type Non Existent */
+       CALL_END_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROT_STATE,     /**< Message type not compatible with Prot state */
+       CALL_END_CAUSE_IE_NON_EXISTENT_OR_NOT_IMPLEMENTED,                      /**< IE non exitent or not implemented */
+       CALL_END_CAUSE_CONDITIONAL_IE_ERROR,                                            /**< Conditional IE error */
+       CALL_END_CAUSE_MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE,      /**< Not Compatible with protocol state */
+
+       CALL_END_CAUSE_RECOVERY_ON_TIMER_EXPIRY,        /**< Recovery on timer expiry */
+       CALL_END_CAUSE_PROTOCOL_ERROR_UNSPECIFIED,      /**< Protocol error unspecified */
+       CALL_END_CAUSE_INTERWORKING_UNSPECIFIED,        /**< Interworking unspecified */
+
+       CALL_END_CAUSE_END = 128,
+
+       /* Reject causes*/
+       CALL_END_CAUSE_IMSI_UNKNOWN_IN_HLR,     /**< IMSI unknown in HLR */
+       CALL_END_CAUSE_ILLEGAL_MS,                      /**< Illegal MS */
+       CALL_END_CAUSE_IMSI_UNKNOWN_IN_VLR,     /**< IMSI unknown in VLR */
+       CALL_END_CAUSE_IMEI_NOT_ACCEPTED,       /**< IMEI not accepted */
+       CALL_END_CAUSE_ILLEGAL_ME,                      /**< Illegal ME */
+
+       CALL_END_CAUSE_GPRS_SERVICES_NOT_ALLOWED,                                               /**< GPRS service not allowed */
+       CALL_END_CAUSE_GPRS_SERVICES_AND_NON_GPRS_SERVICES_NOT_ALLOWED, /**< GPRS services and Non-GPRS services not allowed */
+       CALL_END_CAUSE_MS_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK,    /**< MS device cannot be derived by the network */
+       CALL_END_CAUSE_IMPLICITLY_DETACHED,                                                             /**< Implicitly detached */
+       CALL_END_CAUSE_PLMN_NOT_ALLOWED,                                                                /**< PLMN not allowed */
+
+       CALL_END_CAUSE_LA_NOT_ALLOWED,                                                  /**< LA not allowed */
+       CALL_END_CAUSE_NATIONAL_ROAMING_NOT_ALLOWED,                    /**< National roaming not allowed */
+       CALL_END_CAUSE_GPRS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN,  /**< GPRS services not allowed in this PLMN */
+       CALL_END_CAUSE_NO_SUITABLE_CELLS_IN_LA,                                 /**< No suitable cells in the LA */
+       CALL_END_CAUSE_MSC_TEMPORARILY_NOT_REACHABLE,                   /**< MSC temporarily not reachable */
+
+       CALL_END_CAUSE_NETWORK_FAILURE,         /**< Network unavailable */
+       CALL_END_CAUSE_MAC_FAILURE,                     /**< MAC failure */
+       CALL_END_CAUSE_SYNCH_FAILURE,           /**< SYNCh failure */
+       CALL_END_CAUSE_CONGESTTION,                     /**< Congestion */
+       CALL_END_CAUSE_GSM_AUTH_UNACCEPTED,     /**< GSM Auth unaccepted */
+
+       CALL_END_CAUSE_SERVICE_OPTION_NOT_SUPPORTED, /**< Service option not supported */
+       CALL_END_CAUSE_REQ_SERV_OPT_NOT_SUBSCRIBED,     /**< REQ_SERV option not suscribed */
+       CALL_END_CAUSE_SERVICE_OPT__OUT_OF_ORDER,       /**< Service OPT out of order */
+       CALL_END_CAUSE_CALL_CANNOT_BE_IDENTIFIED,       /**< Call cannot be identified */
+       CALL_END_CAUSE_NO_PDP_CONTEXT_ACTIVATED,        /**< No PDP context Activated */
+
+       CALL_END_CAUSE_RETRY_UPON_ENTRY_INTO_A_NEW_CELL_MIN_VALUE,      /**< Retry upon entry into a new call min value */
+       CALL_END_CAUSE_RETRY_UPON_ENTRY_INTO_A_NEW_CELL_MAX_VALUE,      /**< Retry upon entry into a new call max value */
+       CALL_END_CAUSE_SEMANTICALLY_INCORRECT_MSG,                                      /**< Semantically incorret message */
+       CALL_END_CAUSE_INVALID_MANDATORY_INFO,                                          /**< Invalid mandatory information */
+       CALL_END_CAUSE_MESSAGE_TYPE_NON_EXISTANT,                                       /**< Message type non-existant */
+
+       CALL_END_CAUSE_MESSAGE_TYPE_NOT_COMP_PRT_ST,            /**< Message type not COMP PRT ST */
+       CALL_END_CAUSE_IE_NON_EXISTANT,                                         /**< IE not existant */
+       CALL_END_CAUSE_MSG_NOT_COMPATIBLE_PROTOCOL_STATE,       /**< MSG not compatible protocol state */
+
+       /* Connection Management establishment rejection cause */
+       CALL_END_CAUSE_REJ_UNSPECIFIED, /**< rej unspecified */
+
+       /* AS reject causes */
+       CALL_END_CAUSE_AS_REJ_RR_REL_IND,                                               /**< RR release indication */
+       CALL_END_CAUSE_AS_REJ_RR_RANDOM_ACCESS_FAILURE,                 /**< Random Access Failure */
+       CALL_END_CAUSE_AS_REJ_RRC_REL_IND,                                              /**< RRC release indication */
+       CALL_END_CAUSE_AS_REJ_RRC_CLOSE_SESSION_IND,                    /**< RRC close session indication */
+       CALL_END_CAUSE_AS_REJ_RRC_OPEN_SESSION_FAILURE,                 /**< RRC open session failure */
+       CALL_END_CAUSE_AS_REJ_LOW_LEVEL_FAIL,                                   /**< Low level failure */
+       CALL_END_CAUSE_AS_REJ_LOW_LEVEL_FAIL_REDIAL_NOT_ALLOWED, /**< Low level failure redial not alowed */
+       CALL_END_CAUSE_AS_REJ_LOW_LEVEL_IMMED_RETRY,                    /**< low level immediate retry */
+
+       /* MM reject causes */
+       CALL_END_CAUSE_MM_REJ_INVALID_SIM,                      /**< invalid Sim */
+       CALL_END_CAUSE_MM_REJ_NO_SERVICE,                       /**< No service */
+       CALL_END_CAUSE_MM_REJ_TIMER_T3230_EXP,          /**< Timer T3230 expire */
+       CALL_END_CAUSE_MM_REJ_NO_CELL_AVAILABLE,        /**< No call available  */
+       CALL_END_CAUSE_MM_REJ_WRONG_STATE,                      /**< wrong state */
+       CALL_END_CAUSE_MM_REJ_ACCESS_CLASS_BLOCKED,     /**< Access class blocked */
+
+       /* Definitions for release ind causes between MM  and CNM*/
+       CALL_END_CAUSE_ABORT_MSG_RECEIVED,      /**< Abort Message received */
+       CALL_END_CAUSE_OTHER_CAUSE,                     /**< Other cause  */
+
+       /* CNM reject causes */
+       CALL_END_CAUSE_CNM_REJ_TIMER_T303_EXP,  /**< Timer T303 expiry */
+       CALL_END_CAUSE_CNM_REJ_NO_RESOURCES,    /**< Rejected due to unavailibilty of resources */
+       CALL_END_CAUSE_CNM_MM_REL_PENDING,              /**< MM release pending */
+       CALL_END_CAUSE_CNM_INVALID_USER_DATA,   /**< Invalid user data */
+};
+
+enum telephony_call_cli_mode {
+       CALL_CLI_MODE_DEFAULT,
+       CALL_CLI_MODE_PRESENT,
+       CALL_CLI_MODE_RESTRICT,
+};
+
+enum telephony_call_cna_mode {
+       CALL_CNA_MODE_DEFAULT,
+       CALL_CNA_MODE_PRESENT,
+       CALL_CNA_MODE_RESTRICT,
+};
+
+enum telephony_call_sound_path {
+       CALL_SOUND_PATH_HANDSET         = 0x01,
+       CALL_SOUND_PATH_HEADSET,
+       CALL_SOUND_PATH_HANDFREE,
+       CALL_SOUND_PATH_BLUETOOTH,
+       CALL_SOUND_PATH_STEREO_BLUETOOTH,
+       CALL_SOUND_PATH_SPEAKER,
+       CALL_SOUND_PATH_HEADSET_3_5PI,
+       CALL_SOUND_PATH_BT_NSEC_OFF,
+       CALL_SOUND_PATH_MIC1,
+       CALL_SOUND_PATH_MIC2,
+       CALL_SOUND_PATH_HEADSET_HAC,
+};
+
+enum telephony_call_sound_device {
+       CALL_SOUND_DEVICE_RECEIVER      = 0x10,
+       CALL_SOUND_DEVICE_SPEAKER       = 0x20,
+       CALL_SOUND_DEVICE_HFK           = 0x30,
+       CALL_SOUND_DEVICE_BLUETOOTH     = 0x40,
+       CALL_SOUND_DEVICE_ECHO_CANCELLER        = 0xA0,
+};
+
+enum telephony_call_sound_type {
+       CALL_SOUND_TYPE_VOICE   = 0x1,
+       CALL_SOUND_TYPE_KEYTONE,
+       CALL_SOUND_TYPE_BELL,
+       CALL_SOUND_TYPE_MESSAGE,
+       CALL_SOUND_TYPE_ALARM,
+       CALL_SOUND_TYPE_MISCELLANEOUS,
+};
+
+enum telephony_call_sound_volume_level {
+       CALL_SOUND_MUTE,
+       CALL_SOUND_VOLUME_LEVEL_1,
+       CALL_SOUND_VOLUME_LEVEL_2,
+       CALL_SOUND_VOLUME_LEVEL_3,
+       CALL_SOUND_VOLUME_LEVEL_4,
+       CALL_SOUND_VOLUME_LEVEL_5,
+       CALL_SOUND_VOLUME_LEVEL_6,
+       CALL_SOUND_VOLUME_LEVEL_7,
+       CALL_SOUND_VOLUME_LEVEL_8,
+       CALL_SOUND_VOLUME_LEVEL_9,
+};
+
+enum telephony_call_sound_error_cause {
+       CALL_SOUND_OK,
+};
+
+
+
+
+/**********
+  Struct
+  **********/
+
+// Request
+
+#define MAX_CALL_NUMBER_LEN 83
+#define MAX_CALL_DIAL_NUM_LEN MAX_CALL_NUMBER_LEN
+#define MAX_CALL_DTMF_DIGITS_LEN 32
+
+
+#define MAX_CALL_CLI_NUM_LEN MAX_CALL_NUMBER_LEN
+#define MAX_CALL_CNA_NAME_LEN 83
+
+struct telephony_call_cli_info {
+       enum telephony_call_cli_mode mode;
+       char number[ MAX_CALL_CLI_NUM_LEN ];
+};
+
+struct telephony_call_cna_info {
+       enum telephony_call_cna_mode mode;
+       char name[ MAX_CALL_CNA_NAME_LEN ];
+};
+
+
+
+struct treq_call_dial {
+       enum telephony_call_type type;
+       char number[ MAX_CALL_DIAL_NUM_LEN ];
+};
+
+struct treq_call_answer {
+       unsigned int id;
+       enum telephony_call_answer_type type;
+};
+
+struct treq_call_end {
+       unsigned int id;
+       enum telephony_call_end_type type;
+};
+
+struct treq_call_dtmf {
+       char digits[ MAX_CALL_DTMF_DIGITS_LEN ]; 
+};
+
+struct treq_call_sound_set_path {
+       enum telephony_call_sound_path path;
+};
+
+struct treq_call_sound_set_volume_level {
+       enum telephony_call_sound_type                  sound;
+       enum telephony_call_sound_device                        device;
+       enum telephony_call_sound_volume_level  volume;
+};
+
+struct treq_call_sound_get_volume_level {
+       enum telephony_call_sound_type          sound;
+       enum telephony_call_sound_device        device;
+};
+
+
+// Response
+
+struct tresp_call_general {
+       enum telephony_call_type type;
+       unsigned int    id;
+       gboolean                err;
+       enum telephony_call_error_cause cause;
+};
+
+struct tresp_call_sound_general {
+       gboolean                err;
+       enum telephony_call_sound_error_cause cause;
+};
+
+// Notification
+
+struct tnoti_call_status_idle {
+       enum telephony_call_type type;
+       unsigned int    id;
+       enum telephony_call_end_cause cause;
+};
+
+struct tnoti_call_status_active {
+       enum telephony_call_type type;
+       unsigned int    id;
+};
+
+struct tnoti_call_status_held {
+       enum telephony_call_type type;
+       unsigned int    id;
+};
+
+struct tnoti_call_status_dialing {
+       enum telephony_call_type type;
+       unsigned int    id;
+};
+
+struct tnoti_call_status_alert {
+       enum telephony_call_type type;
+       unsigned int    id;
+};
+
+struct tnoti_call_status_incoming {
+       enum telephony_call_type type;
+       unsigned int    id;
+       struct telephony_call_cli_info cli;
+       struct telephony_call_cna_info cna;
+       gboolean                forward;
+       unsigned int    active_line;
+};
+
+struct tnoti_call_status_waiting {
+       enum telephony_call_type type;
+       unsigned int    id;
+};
+
+
+__END_DECLS
+
+#endif
diff --git a/include/type/common.h b/include/type/common.h
new file mode 100644 (file)
index 0000000..b217762
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_COMMON_H__
+#define __TYPE_COMMON_H__
+
+#include <errno.h>
+
+#define TCORE_REQUEST        0x10000000
+#define TCORE_RESPONSE       0x20000000
+#define TCORE_NOTIFICATION   0x30000000
+#define TCORE_RETURN         0x40000000
+#define TCORE_3GPP_RETURN    0x50000000
+
+#define TCORE_TYPE_DEFAULT   0x00100000
+#define TCORE_TYPE_SERVER    0x00200000
+#define TCORE_TYPE_MODEM     0x00300000
+#define TCORE_TYPE_PENDING   0x00400000
+#define TCORE_TYPE_HOOK      0x00500000
+#define TCORE_TYPE_CALL      0x01000000
+#define TCORE_TYPE_NETWORK   0x01100000
+#define TCORE_TYPE_PS        0x01200000
+#define TCORE_TYPE_PDP       0x01300000
+#define TCORE_TYPE_SIM       0x01400000
+#define TCORE_TYPE_SAT       0x01500000
+#define TCORE_TYPE_SAP       0x01600000
+#define TCORE_TYPE_SMS       0x01700000
+#define TCORE_TYPE_PHONEBOOK 0x01800000
+#define TCORE_TYPE_SS        0x01900000
+#define TCORE_TYPE_SOUND     0x01A00000
+#define TCORE_TYPE_GPS       0x01B00000
+#define TCORE_TYPE_CUSTOM    0x0F000000
+
+#define TCORE_PLUGIN_DEFAULT "default"
+
+
+__BEGIN_DECLS
+
+enum tcore_return {
+       TCORE_RETURN_SUCCESS = 0,
+       TCORE_RETURN_FAILURE = -1,
+
+       TCORE_RETURN_ENOENT = ENOENT, /* No such file or directory */
+       TCORE_RETURN_EPERM = EPERM, /* Operation not permitted */
+       TCORE_RETURN_ENOMEM = ENOMEM, /* Out of memory */
+       TCORE_RETURN_EAGAIN = EAGAIN, /* Try again */
+       TCORE_RETURN_EINVAL = EINVAL, /* Invalid argument */
+       TCORE_RETURN_ENOSYS = ENOSYS, /* Function not implemented */
+       TCORE_RETURN_EALREADY = EALREADY, /* Operation already in progress */
+       TCORE_RETURN_ETIMEDOUT = ETIMEDOUT, /* Connection timed out */
+       TCORE_RETURN_EMSGSIZE = EMSGSIZE, /* Message too long */
+
+
+       TCORE_RETURN_SERVER_WRONG_PLUGIN = TCORE_RETURN | TCORE_TYPE_SERVER,
+
+       TCORE_RETURN_PENDING_WRONG_ID = TCORE_RETURN | TCORE_TYPE_PENDING,
+
+       TCORE_RETURN_PS_NETWORK_NOT_READY = TCORE_RETURN | TCORE_TYPE_PS,
+       TCORE_RETURN_PS_CID_ERROR,
+       TCORE_RETURN_PS_ACTIVATING,
+       TCORE_RETURN_PS_ALREADY_ACTIVATED,
+       TCORE_RETURN_PS_DEACTIVATING,
+
+       TCORE_RETURN_HOOK_STOP = TCORE_RETURN | TCORE_TYPE_HOOK,
+
+       /* NETTEXT */
+       TCORE_RETURN_SMS = TCORE_RETURN | TCORE_TYPE_SMS,
+       TCORE_RETURN_SMS_DEVICE_NOT_READY, /**<Nettext device not ready */
+       TCORE_RETURN_SMS_SCADDR_NOT_SET, /**<Nettext SCA address not set */
+       TCORE_RETURN_SMS_INVALID_DATA_LEN, /**<Nettext Invalid data length */
+       TCORE_RETURN_SMS_SCADDRESS_NOT_SET, /**<Nettext SCA address not set*/
+
+       TCORE_RETURN_3GPP_ERROR = TCORE_3GPP_RETURN, /**< TCORE_3GPP_RETURN + (0x0000 ~ 0x7FFF) */
+
+       TCORE_RETURN_UNKNOWN = TCORE_RETURN | 0x0FFFFFFF
+};
+
+typedef enum tcore_return TReturn;
+
+__END_DECLS
+
+#endif
diff --git a/include/type/modem.h b/include/type/modem.h
new file mode 100644 (file)
index 0000000..084fd5a
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_MODEM_H__
+#define __TYPE_MODEM_H__
+
+__BEGIN_DECLS
+
+enum modem_state {
+       MODEM_STATE_ONLINE,
+       MODEM_STATE_OFFLINE,
+       MODEM_STATE_ERROR,
+};
+
+struct treq_modem_set_flightmode {
+       int enable;
+};
+
+struct treq_modem_get_flightmode {
+};
+
+struct treq_modem_get_imei {
+};
+
+struct treq_modem_get_version {
+};
+
+
+struct tresp_modem_set_flightmode {
+       TReturn result;
+};
+
+struct tresp_modem_get_flightmode {
+       TReturn result;
+       int enable;
+};
+
+struct tresp_modem_get_imei {
+       TReturn result;
+       char imei[17];
+};
+
+struct tresp_modem_get_version {
+       TReturn result;
+       char software[20];
+       char hardware[20];
+};
+
+struct tnoti_modem_power {
+       enum modem_state state;
+};
+
+struct tnoti_modem_flight_mode {
+       int enable;
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/type/network.h b/include/type/network.h
new file mode 100644 (file)
index 0000000..8066287
--- /dev/null
@@ -0,0 +1,314 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_NETWORK_H__
+#define __TYPE_NETWORK_H__
+
+__BEGIN_DECLS
+
+
+enum telephony_network_select_mode {
+       NETWORK_SELECT_MODE_GLOBAL_AUTOMATIC = 0x01,
+       NETWORK_SELECT_MODE_GSM_AUTOMATIC = 0x02,
+       NETWORK_SELECT_MODE_GSM_MANUAL = 0x03,
+       NETWORK_SELECT_MODE_CDMA = 0x04,
+};
+
+enum telephony_network_plmn_status {
+       NETWORK_PLMN_UNKNOWN,
+       NETWORK_PLMN_AVAILABLE,
+       NETWORK_PLMN_CURRENT,
+       NETWORK_PLMN_FORBIDDEN,
+};
+
+enum telephony_network_service_domain {
+       NETWORK_SERVICE_DOMAIN_COMBINED = 0x01,
+       NETWORK_SERVICE_DOMAIN_CS,
+       NETWORK_SERVICE_DOMAIN_PS,
+       NETWORK_SERVICE_DOMAIN_AUTOMATIC,
+};
+
+enum telephony_network_service_domain_status {
+       NETWORK_SERVICE_DOMAIN_STATUS_NO = 0x0,
+       NETWORK_SERVICE_DOMAIN_STATUS_EMERGENCY,
+       NETWORK_SERVICE_DOMAIN_STATUS_FULL,
+       NETWORK_SERVICE_DOMAIN_STATUS_SEARCH,
+};
+
+enum telephony_network_service_type {
+       NETWORK_SERVICE_TYPE_UNKNOWN = 0x0,
+       NETWORK_SERVICE_TYPE_NO_SERVICE,
+       NETWORK_SERVICE_TYPE_EMERGENCY,
+       NETWORK_SERVICE_TYPE_SEARCH,
+       NETWORK_SERVICE_TYPE_2G,
+       NETWORK_SERVICE_TYPE_2_5G,
+       NETWORK_SERVICE_TYPE_2_5G_EDGE,
+       NETWORK_SERVICE_TYPE_3G,
+       NETWORK_SERVICE_TYPE_HSDPA
+};
+
+enum telephony_network_access_technology {
+       NETWORK_ACT_UNKNOWN = 0x0,
+       NETWORK_ACT_GSM = 0x1,
+       NETWORK_ACT_GPRS,
+       NETWORK_ACT_EGPRS,
+       NETWORK_ACT_UMTS = 0x4,
+       NETWORK_ACT_UTRAN = 0x4,
+       NETWORK_ACT_GSM_UTRAN,
+       NETWORK_ACT_IS95A = 0x11,
+       NETWORK_ACT_IS95B,
+       NETWORK_ACT_CDMA_1X,
+       NETWORK_ACT_EVDO_REV0,
+       NETWORK_ACT_CDMA_1X_EVDO_REV0,
+       NETWORK_ACT_EVDO_REVA,
+       NETWORK_ACT_CDMA_1X_EVDO_REVA,
+       NETWORK_ACT_EVDV,
+       NETWORK_ACT_LTE = 0x21,
+       NETWORK_ACT_NOT_SPECIFIED = 0xFF
+};
+
+enum telephony_network_band_mode {
+       NETWORK_BAND_MODE_PREFERRED = 0x01,
+       NETWORK_BAND_MODE_ONLY = 0x02,
+};
+
+enum telephony_network_band {
+       NETWORK_BAND_TYPE_ANY = 0x00,
+       NETWORK_BAND_TYPE_GSM850,
+       NETWORK_BAND_TYPE_GSM_900_1800,
+       NETWORK_BAND_TYPE_GSM1900,
+       NETWORK_BAND_TYPE_GSM,
+       NETWORK_BAND_TYPE_WCDMA,
+       NETWORK_BAND_TYPE_WCDMA850,
+       NETWORK_BAND_TYPE_WCDMA1900,
+       NETWORK_BAND_TYPE_WCDMA2100,
+       NETWORK_BAND_TYPE_GSM900,
+       NETWORK_BAND_TYPE_GSM1800,
+       NETWORK_BAND_TYPE_GSM_850_1900
+};
+
+enum telephony_network_preferred_plmn_operation {
+       NETWORK_PREF_PLMN_ADD = 0x01,
+       NETWORK_PREF_PLMN_EDIT,
+       NETWORK_PREF_PLMN_DELETE
+};
+
+enum telephony_network_acquisition_order {
+       NETWORK_ORDER_AUTO = 0x01,
+       NETWORK_ORDER_GSM_FIRST = 0x02,
+       NETWORK_ORDER_WCDMA_FIRST = 0x03,
+       NETWORK_ORDER_NO_CHANGE = 0x04
+};
+
+struct treq_network_search { /* no data */
+};
+struct treq_network_set_plmn_selection_mode {
+       enum telephony_network_select_mode mode;
+       char plmn[7];
+       enum telephony_network_access_technology act;
+};
+struct treq_network_get_plmn_selection_mode { /* no data */
+};
+struct treq_network_set_service_domain {
+       enum telephony_network_service_domain domain;
+};
+struct treq_network_get_service_domain { /* no data */
+};
+struct treq_network_set_band {
+       enum telephony_network_band_mode mode;
+       enum telephony_network_band band;
+};
+struct treq_network_get_band { /* no data */
+};
+struct treq_network_set_preferred_plmn {
+       enum telephony_network_preferred_plmn_operation operation;
+       char plmn[7];
+       enum telephony_network_access_technology act;
+       int ef_index;
+};
+struct treq_network_get_preferred_plmn { /* no data */
+};
+struct treq_network_set_order {
+       enum telephony_network_acquisition_order order;
+};
+struct treq_network_get_order { /* no data */
+};
+struct treq_network_set_power_on_attach {
+       int enable;
+};
+struct treq_network_get_power_on_attach { /* no data */
+};
+struct treq_network_set_cancel_manual_search { /* no data */
+};
+struct treq_network_get_serving_network { /* no data */
+};
+
+
+struct tresp_network_search {
+       int list_count;
+       struct {
+               enum telephony_network_plmn_status  status;
+               char plmn[7];
+               enum telephony_network_access_technology act;
+               unsigned int lac;
+               unsigned int rac;
+               unsigned int cell_id;
+               unsigned int tac;
+       } list[20];
+};
+
+struct tresp_network_set_plmn_selection_mode {
+       TReturn result;
+};
+
+struct tresp_network_get_plmn_selection_mode {
+       enum telephony_network_select_mode mode;
+};
+
+struct tresp_network_set_service_domain {
+       TReturn result;
+};
+
+struct tresp_network_get_service_domain {
+       enum telephony_network_service_domain domain;
+};
+
+struct tresp_network_set_band {
+       TReturn result;
+};
+
+struct tresp_network_get_band {
+       enum telephony_network_band_mode mode;
+       enum telephony_network_band band;
+};
+
+struct tresp_network_set_preferred_plmn {
+       TReturn result;
+};
+
+struct tresp_network_get_preferred_plmn {
+       int list_count;
+       struct {
+               int ef_index;
+               char plmn[7];
+               enum telephony_network_access_technology act;
+               unsigned int lac;
+       } list[150];
+};
+
+struct tresp_network_set_order {
+       TReturn result;
+};
+
+struct tresp_network_get_order {
+       enum telephony_network_acquisition_order order;
+};
+
+struct tresp_network_set_power_on_attach {
+       TReturn result;
+};
+
+struct tresp_network_get_power_on_attach {
+       int enabled;
+};
+
+struct tresp_network_set_cancel_manual_search {
+       TReturn result;
+};
+
+struct tresp_network_get_serving_network {
+       char plmn[7];
+       enum telephony_network_access_technology act;
+       struct {
+               unsigned int lac;
+       } gsm;
+       struct {
+               int carrier;
+               int sid;
+               int nid;
+               int bs_id;
+               int bs_lat;
+               int bs_long;
+               int reg_sonze;
+               int pilot_pn;
+       } cdma;
+};
+
+
+struct tnoti_network_registration_status {
+       enum telephony_network_service_domain_status cs_domain_status;
+       enum telephony_network_service_domain_status ps_domain_status;
+       enum telephony_network_service_type service_type;
+       int roaming_status;
+};
+
+struct tnoti_network_location_cellinfo {
+       unsigned int lac;
+       unsigned int cell_id;
+};
+
+struct tnoti_network_icon_info {
+       int type;
+       int rssi;
+       int battery;
+       int hdr_rssi;
+};
+
+struct tnoti_network_change {
+       char plmn[7];
+       enum telephony_network_access_technology act;
+       struct {
+               unsigned int lac;
+       } gsm;
+       struct {
+               int carrier;
+               int sid;
+               int nid;
+               int bs_id;
+               int bs_lat;
+               int bs_long;
+               int reg_sonze;
+               int pilot_pn;
+       } cdma;
+};
+
+struct tnoti_network_timeinfo {
+       unsigned int year;
+       unsigned int month;
+       unsigned int day;
+       unsigned int hour;
+       unsigned int minute;
+       unsigned int second;
+       unsigned int wday;
+       int gmtoff;
+       int dstoff;
+       unsigned int isdst;
+       char plmn[7];
+};
+
+struct tnoti_network_identity {
+       char short_name[17];
+       char full_name[33];
+       char plmn[7];
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/type/notification.h b/include/type/notification.h
new file mode 100644 (file)
index 0000000..9c1a543
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_NOTIFICATION_H__
+#define __TYPE_NOTIFICATION_H__
+
+#include <type/common.h>
+
+__BEGIN_DECLS
+
+enum tcore_notification_command {
+       TNOTI_UNKNOWN = 0,
+
+       TNOTI_SERVER = TCORE_NOTIFICATION | TCORE_TYPE_SERVER,
+       TNOTI_SERVER_RUN,
+       TNOTI_SERVER_ADDED_PLUGIN,
+       TNOTI_SERVER_REMOVED_PLUGIN,
+       TNOTI_SERVER_ADDED_COMMUNICATOR,
+       TNOTI_SERVER_REMOVED_COMMUNICATOR,
+       TNOTI_SERVER_ADDED_HAL,
+       TNOTI_SERVER_REMOVED_HAL,
+       TNOTI_SERVER_ADDED_STORAGE,
+       TNOTI_SERVER_REMOVED_STORAGE,
+       TNOTI_SERVER_EXIT,
+
+       TNOTI_CALL = TCORE_NOTIFICATION | TCORE_TYPE_CALL,
+       TNOTI_CALL_STATUS_IDLE,
+       TNOTI_CALL_STATUS_ACTIVE,
+       TNOTI_CALL_STATUS_HELD,
+       TNOTI_CALL_STATUS_DIALING,
+       TNOTI_CALL_STATUS_ALERT,
+       TNOTI_CALL_STATUS_INCOMING,
+       TNOTI_CALL_STATUS_WAITING,
+       TNOTI_CALL_INFO_CALL_CONNECTED_LINE,
+       TNOTI_CALL_INFO_WAITING,
+       TNOTI_CALL_INFO_CUG,
+       TNOTI_CALL_INFO_FORWARDED,
+       TNOTI_CALL_INFO_BARRED_INCOMING,
+       TNOTI_CALL_INFO_BARRED_OUTGOING,
+       TNOTI_CALL_INFO_DEFLECTED,
+       TNOTI_CALL_INFO_CLIR_SUPPRESSION_REJECT,
+       TNOTI_CALL_INFO_FORWARD_UNCONDITIONAL,
+       TNOTI_CALL_INFO_FORWARD_CONDITIONAL,
+       TNOTI_CALL_INFO_CALL_LINE_IDENTITY,
+       TNOTI_CALL_INFO_CALL_NAME_INFORMATION,
+       TNOTI_CALL_INFO_FORWARDED_CALL,
+       TNOTI_CALL_INFO_CUG_CALL,
+       TNOTI_CALL_INFO_DEFLECTED_CALL,
+       TNOTI_CALL_INFO_TRANSFERED_CALL,
+       TNOTI_CALL_INFO_HELD,
+       TNOTI_CALL_INFO_ACTIVE,
+       TNOTI_CALL_INFO_JOINED,
+       TNOTI_CALL_INFO_RELEASED_ON_HOLD,
+       TNOTI_CALL_INFO_TRANSFER_ALERT,
+       TNOTI_CALL_INFO_TRANSFERED,
+       TNOTI_CALL_INFO_CF_CHECK_MESSAGE,
+
+       TNOTI_SS = TCORE_NOTIFICATION | TCORE_TYPE_SS,
+       TNOTI_SS_INFO,
+       TNOTI_SS_USSD,
+
+       TNOTI_MODEM = TCORE_NOTIFICATION | TCORE_TYPE_MODEM,
+       TNOTI_MODEM_POWER,
+       TNOTI_MODEM_FLIGHT_MODE,
+
+       TNOTI_SIM = TCORE_NOTIFICATION | TCORE_TYPE_SIM,
+       TNOTI_SIM_STATUS,
+
+       TNOTI_SAT = TCORE_NOTIFICATION | TCORE_TYPE_SAT,
+       TNOTI_SAT_PROACTIVE_CMD,
+       TNOTI_SAT_SESSION_END,
+
+       TNOTI_SAP = TCORE_NOTIFICATION | TCORE_TYPE_SAP,
+       TNOTI_SAP_STATUS,
+       TNOTI_SAP_DISCONNECT,
+
+       TNOTI_NETWORK = TCORE_NOTIFICATION | TCORE_TYPE_NETWORK,
+       TNOTI_NETWORK_REGISTRATION_STATUS,
+       TNOTI_NETWORK_LOCATION_CELLINFO,
+       TNOTI_NETWORK_ICON_INFO,
+       TNOTI_NETWORK_CHANGE,
+       TNOTI_NETWORK_TIMEINFO,
+       TNOTI_NETWORK_IDENTITY,
+
+       TNOTI_PS = TCORE_NOTIFICATION | TCORE_TYPE_PS,
+       TNOTI_PS_CALL_STATUS,
+       TNOTI_PS_CURRENT_SESSION_DATA_COUNTER,
+       TNOTI_PS_PDP_IPCONFIGURATION,
+       TNOTI_PS_DUN_PIN_CONTROL,
+       TNOTI_PS_EXTERNAL_CALL,
+       TNOTI_PS_PROTOCOL_STATUS,
+
+       TNOTI_SMS = TCORE_NOTIFICATION | TCORE_TYPE_SMS,
+       TNOTI_SMS_INCOM_MSG,                    /* This is an unsolicited Incoming SMS Event*/
+       TNOTI_SMS_CB_INCOM_MSG,         /* This is an unsolicited Incoming cell broadcast message*/
+       TNOTI_SMS_INCOM_EX_MSG,         /* This is an extended unsolicited Incoming SMS Event*/
+       TNOTI_SMS_CB_INCOM_EX_MSG,      /* This is an extended unsolicited Incoming cell broadcast message*/
+       TNOTI_SMS_MEMORY_STATUS,                /* This event is an unsolicited event indicating SIM memory status */
+       TNOTI_SMS_DEVICE_READY,         /* Device Ready indication */
+       TNOTI_SMS_IND_MAX,
+
+       TNOTI_PHONEBOOK = TCORE_NOTIFICATION | TCORE_TYPE_PHONEBOOK,
+       TNOTI_PHONEBOOK_STATUS,
+
+       TNOTI_GPS = TCORE_NOTIFICATION | TCORE_TYPE_GPS,
+
+       TNOTI_CUSTOM = TCORE_NOTIFICATION | TCORE_TYPE_CUSTOM,
+};
+
+struct tnoti_server_run {
+};
+
+struct tnoti_server_added_plugin {
+};
+
+struct tnoti_server_removed_plugin {
+};
+
+struct tnoti_server_added_communicator {
+};
+
+struct tnoti_server_removed_communicator {
+};
+
+struct tnoti_server_added_hal {
+};
+
+struct tnoti_server_removed_hal {
+};
+
+struct tnoti_server_added_storage {
+};
+
+struct tnoti_server_removed_storage {
+};
+
+struct tnoti_server_exit {
+};
+
+struct tnoti_custom {
+       unsigned int length;
+       void *data;
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/type/phonebook.h b/include/type/phonebook.h
new file mode 100644 (file)
index 0000000..b60d4c9
--- /dev/null
@@ -0,0 +1,242 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_PHONEBOOK_H__
+#define __TYPE_PHONEBOOK_H__
+
+__BEGIN_DECLS
+
+#include <glib.h>
+
+enum tel_phonebook_type {
+       PB_TYPE_FDN, /**< Fixed Dialing Number */
+       PB_TYPE_ADN, /**< SIM - ADN      */
+       PB_TYPE_SDN, /**< Service Dialing Number  */
+       PB_TYPE_USIM, /**< USIM - 3G phone book */
+       PB_TYPE_AAS, /**< Additional number Alpha String */
+       PB_TYPE_GAS, /**< Grouping identifier Alpha String */
+       PB_TYPE_UNKNOWNN = 0xFF, /**< Unknown file type */
+};
+
+enum tel_phonebook_field_type {
+       PB_FIELD_NAME = 0x01, /**< Name */
+       PB_FIELD_NUMBER, /**< Number */
+       PB_FIELD_ANR1, /**< First Another number*/
+       PB_FIELD_ANR2, /**< Second Another number */
+       PB_FIELD_ANR3, /**< Third Another number */
+       PB_FIELD_EMAIL1, /**< First Email */
+       PB_FIELD_EMAIL2, /**< Second Email */
+       PB_FIELD_EMAIL3, /**< Third Email */
+       PB_FIELD_EMAIL4, /**< Fourth Email */
+       PB_FIELD_SNE, /**< Second name entry of main name*/
+       PB_FIELD_GRP, /**< Group  */
+       PB_FIELD_PBC, /** <1 byte control info and 1 byte hidden info*/
+};
+
+enum tel_phonebook_result {
+       PB_SUCCESS, /**< SIM phonebook operation successful. */
+       PB_FAIL, /**< SIM phonebook operation failure. */
+       PB_INVALID_INDEX, /**< The index passed was not a valid index. */
+       PB_INVALID_NUMBER_LENGTH, /**< The number length is exceeds the max length allowed (or 0). */
+       PB_INVALID_NAME_LENGTH, /**< The name length is exceeds the max length allowed (or 0). */
+       PB_ACCESS_CONDITION_NOT_SATISFIED, /**< Access condition for PB file is not satisfied. */
+};
+
+enum tel_phonebook_ton {
+       PB_TON_UNKNOWN = 0, /**< unknown */
+       PB_TON_INTERNATIONAL = 1, /**< international number */
+       PB_TON_NATIONAL = 2, /**< national number */
+       PB_TON_NETWORK_SPECIFIC = 3, /**< network specific number */
+       PB_TON_DEDICATED_ACCESS = 4, /**< subscriber number */
+       PB_TON_ALPHA_NUMERIC = 5, /**< alphanumeric, GSM 7-bit default alphabet) */
+       PB_TON_ABBREVIATED_NUMBER = 6, /**< abbreviated number */
+       PB_TON_RESERVED_FOR_EXT = 7 /**< reserved for extension */
+};
+
+enum tel_phonebook_dcs {
+       PB_TEXT_ASCII, /**< ASCII Encoding */
+       PB_TEXT_GSM7BIT, /**< GSM 7 Bit Encoding */
+       PB_TEXT_UCS2, /**< UCS2 Encoding */
+       PB_TEXT_HEX, /**< HEX Encoding */
+};
+
+struct tel_phonebook_support_list {
+       gboolean b_fdn; /**< Fixed Dialing Number */
+       gboolean b_adn; /**< SIM - ADN(2G phonebook      */
+       gboolean b_sdn; /**< Service Dialing Number  */
+       gboolean b_usim; /**< USIM - 3G phonebook */
+       gboolean b_aas; /**< Additional number Alpha String phonebook */
+       gboolean b_gas; /**< Grouping information Alpha String phonebook */
+};
+
+struct treq_phonebook_get_count {
+       enum tel_phonebook_type phonebook_type;
+};
+
+struct treq_phonebook_get_info {
+       enum tel_phonebook_type phonebook_type;
+};
+
+struct treq_phonebook_get_usim_info {
+
+};
+
+struct treq_phonebook_read_record {
+       enum tel_phonebook_type phonebook_type;
+       unsigned short index;
+};
+
+struct treq_phonebook_update_record {
+       enum tel_phonebook_type phonebook_type;
+       unsigned short index;
+
+       unsigned char name[60];
+       enum tel_phonebook_dcs dcs;
+
+       unsigned char number[40];
+       enum tel_phonebook_ton ton;
+
+       /* following field is valid in only USIM*/
+       unsigned char anr1[40];
+       enum tel_phonebook_ton anr1_ton;
+       unsigned char anr2[40];
+       enum tel_phonebook_ton anr2_ton;
+       unsigned char anr3[40];
+       enum tel_phonebook_ton anr3_ton;
+
+       unsigned char email1[60];
+       unsigned char email2[60];
+       unsigned char email3[60];
+       unsigned char email4[60];
+
+       unsigned short group_index; //GRP
+       unsigned short pb_control; //PBC
+};
+
+struct treq_phonebook_delete_record {
+       enum tel_phonebook_type phonebook_type;
+       unsigned short index;
+};
+
+struct tresp_phonebook_get_count {
+       enum tel_phonebook_result result;
+       enum tel_phonebook_type type;
+       unsigned short used_count;
+       unsigned short total_count;
+};
+
+struct tresp_phonebook_get_info {
+       enum tel_phonebook_result result;
+       enum tel_phonebook_type type;
+       unsigned short index_min;
+       unsigned short index_max;
+       unsigned short number_length_max;
+       unsigned short text_length_max;
+};
+
+struct tresp_phonebook_get_usim_info {
+       enum tel_phonebook_result result;
+       unsigned short name_index_max;
+       unsigned short name_length_max;
+       unsigned short name_used_count;
+
+       unsigned short number_index_max;
+       unsigned short number_length_max;
+       unsigned short number_used_count;
+
+       unsigned short anr1_index_max;
+       unsigned short anr1_length_max;
+       unsigned short anr1_used_count;
+
+       unsigned short anr2_index_max;
+       unsigned short anr2_length_max;
+       unsigned short anr2_used_count;
+
+       unsigned short anr3_index_max;
+       unsigned short anr3_length_max;
+       unsigned short anr3_used_count;
+
+       unsigned short email1_index_max;
+       unsigned short email1_length_max;
+       unsigned short email1_used_count;
+
+       unsigned short email2_index_max;
+       unsigned short email2_length_max;
+       unsigned short email2_used_count;
+
+       unsigned short email3_index_max;
+       unsigned short email3_length_max;
+       unsigned short email3_used_count;
+
+       unsigned short email4_index_max;
+       unsigned short email4_length_max;
+       unsigned short email4_used_count;
+
+       unsigned short grp_index_max;
+       unsigned short grp_length_max;
+       unsigned short grp_used_count;
+};
+
+struct tresp_phonebook_read_record {
+       enum tel_phonebook_result result;
+       enum tel_phonebook_type phonebook_type;
+       unsigned short index;
+       unsigned short next_index;
+
+       unsigned char name[60];
+       enum tel_phonebook_dcs dcs;
+
+       unsigned char number[40];
+       enum tel_phonebook_ton ton;
+
+       /* following field is valid in only USIM*/
+       unsigned char anr1[40];
+       enum tel_phonebook_ton anr1_ton;
+       unsigned char anr2[40];
+       enum tel_phonebook_ton anr2_ton;
+       unsigned char anr3[40];
+       enum tel_phonebook_ton anr3_ton;
+
+       unsigned char email1[60];
+       unsigned char email2[60];
+       unsigned char email3[60];
+       unsigned char email4[60];
+
+       unsigned short group_index; //GRP
+       unsigned short pb_control; //PBC
+};
+
+struct tresp_phonebook_update_record {
+       enum tel_phonebook_result result;
+};
+
+struct tresp_phonebook_delete_record {
+       enum tel_phonebook_result result;
+};
+
+struct tnoti_phonebook_status {
+       gboolean b_init;
+       struct tel_phonebook_support_list support_list;
+};
+
+__END_DECLS
+
+
+#endif
diff --git a/include/type/ps.h b/include/type/ps.h
new file mode 100644 (file)
index 0000000..8fe5036
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_PS_H__
+#define __TYPE_PS_H__
+
+__BEGIN_DECLS
+
+enum telephony_ps_pdp_err {
+       PDP_FAILURE_CAUSE_NORMAL                                                = 0x00,                   // 0x00 : Normal Process ( no problem )
+       PDP_FAILURE_CAUSE_REL_BY_USER                                   = 0x01,                   // Call Released by User
+       PDP_FAILURE_CAUSE_REGULAR_DEACTIVATION                  = 0x02,                   // Regular deactivation
+       PDP_FAILURE_CAUSE_LLC_SNDCP                                     = 0x03,                   // LLC SNDCP failure
+       PDP_FAILURE_CAUSE_INSUFFICIENT_RESOURCE         = 0x04,                   // Insufficient resources
+       PDP_FAILURE_CAUSE_UNKNOWN_APN                                   = 0x05,                   // Missing or unkown apn
+       PDP_FAILURE_CAUSE_UNKNOWN_PDP_ADDRESS                   = 0x06,                   // Unknown pdp address or type
+       PDP_FAILURE_CAUSE_USER_AUTH_FAILED                              = 0x07,                   // Unknown pdp address or type
+       PDP_FAILURE_CAUSE_ACT_REJ_GGSN                                  = 0x08,                   // Unknown pdp address or type
+       PDP_FAILURE_CAUSE_ACT_REJ_UNSPECIFIED                   = 0x09,                   // Unknown pdp address or type
+       PDP_FAILURE_CAUSE_SVC_OPTION_NOT_SUPPORTED              = 0x0A,                   // Service option not supported
+       PDP_FAILURE_CAUSE_SVC_NOT_SUBSCRIBED                    = 0x0B,                   // Requested service option not subscribed
+       PDP_FAILURE_CAUSE_SVC_OPT_OUT_ORDER                     = 0x0C,                   // Service out of order
+    PDP_FAILURE_CAUSE_NSAPI_USED                                       = 0x0D,                   // NSAPI already used
+       PDP_FAILURE_CAUSE_QOS_NOT_ACCEPTED                              = 0x0E,                   // QoS not accepted
+       PDP_FAILURE_CAUSE_NETWORK_FAILURE                               = 0x0F,                   // Network Failure
+    PDP_FAILURE_CAUSE_REACT_REQUIRED                           = 0x10,                   // Reactivation Required
+       PDP_FAILURE_CAUSE_FEATURE_NOT_SUPPORTED         = 0x11,                   // Feature not supported
+       PDP_FAILURE_CAUSE_TFT_FILTER_ERROR                              = 0x12,                   // TFT or filter error
+       PDP_FAILURE_CAUSE_UNKOWN_PDP_CONTEXT                    = 0x13,                   // Unkown PDP context
+       PDP_FAILURE_CAUSE_INVALID_MSG                                   = 0x14,                   // Invalied MSG
+       PDP_FAILURE_CAUSE_PROTOCOL_ERROR                                = 0x15,                   // Protocol error
+       PDP_FAILURE_CAUSE_MOBILE_FAILURE_ERROR                  = 0x16,                   // Mobile failure error
+       PDP_FAILURE_CAUSE_TIMEOUT_ERROR                         = 0x17,                   // Timeout error
+       PDP_FAILURE_CAUSE_UNKNOWN_ERROR                         = 0x18,                   // Unknown error
+       PDP_FAILURE_CAUSE_MAX,
+};
+
+enum telephony_ps_dun_pincontrol_signal {
+       DUN_PINCONTROL_SIGNAL_DCD = 0x01,
+       DUN_PINCONTROL_SIGNAL_DTR = 0x04,
+       DUN_PINCONTROL_SIGNAL_DSR = 0x06,
+       DUN_PINCONTROL_SIGNAL_RTS = 0x07,
+       DUN_PINCONTROL_SIGNAL_CTS = 0x08,
+       DUN_PINCONTROL_SIGNAL_RI = 0x09
+};
+
+enum telephony_ps_dun_pincontrol_status {
+       DUN_PINCONTROL_STATUS_OFF = 0x00,
+       DUN_PINCONTROL_STATUS_ON = 0x01,
+};
+
+enum telephony_ps_protocol_status {
+       TELEPHONY_HSDPA_OFF = 0x00,
+       TELEPHONY_HSDPA_ON = 0x01,
+};
+
+enum telephony_ps_state {
+       TELEPHONY_PS_ON,
+       TELEPHONY_PS_3G_OFF,
+       TELEPHONY_PS_ROAMING_OFF,
+       TELEPHONY_PS_FLIGHT_MODE,
+       TELEPHONY_PS_NO_SERVICE
+};
+
+struct treq_ps_pdp_activate {
+       int context_id;
+       int secondary_context_id;
+       char apn[102];
+       char pdp_address[20];
+       int pdp_type;
+
+       char username[32];
+       char password[32];
+       char dns1[16];
+       char dns2[16];
+       int auth_type;
+};
+
+struct tresp_ps_set_pdp_activate {
+       int context_id;
+       int secondary_context_id;
+       int result;
+};
+
+
+struct treq_ps_pdp_deactivate {
+       int context_id;
+       int secondary_context_id;
+
+       char username[32];
+       char password[32];
+       char dns1[16];
+       char dns2[16];
+       int auth_type;
+};
+
+struct tresp_ps_set_pdp_deactivate {
+       int context_id;
+       int secondary_context_id;
+       int result;
+};
+
+
+struct treq_ps_set_dun_pin_control {
+       enum telephony_ps_dun_pincontrol_signal signal;
+       enum telephony_ps_dun_pincontrol_status status;
+};
+
+struct tresp_ps_set_dun_pin_control {
+       int result;
+};
+
+
+struct tnoti_ps_call_status {
+       int context_id;
+       int state;
+       int result;
+};
+
+struct tnoti_ps_pdp_ipconfiguration {
+       int context_id;
+       int secondary_context_id;
+
+       enum telephony_ps_pdp_err err;
+       unsigned short field_flag;
+       unsigned char ip_address[4];
+       unsigned char primary_dns[4];
+       unsigned char secondary_dns[4];
+       unsigned char gateway[4];
+       unsigned char subnet_mask[4];
+       char devname[16];
+};
+
+struct tnoti_ps_dun_pin_control {
+       enum telephony_ps_dun_pincontrol_signal signal;
+       enum telephony_ps_dun_pincontrol_status status;
+};
+
+struct tnoti_ps_external_call {
+};
+
+struct tnoti_ps_protocol_status {
+       enum telephony_ps_protocol_status status;
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/type/request.h b/include/type/request.h
new file mode 100644 (file)
index 0000000..27a6583
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_REQUEST_H__
+#define __TYPE_REQUEST_H__
+
+#include <type/common.h>
+
+__BEGIN_DECLS
+
+/*
+ * SET/REQ: async
+ * GET: sync
+ */
+enum tcore_request_command {
+       TREQ_UNKNOWN = 0,
+
+       TREQ_SERVER = TCORE_REQUEST | TCORE_TYPE_SERVER,
+       TREQ_SERVER_GET_PLUGINS,
+
+       TREQ_MODEM = TCORE_REQUEST | TCORE_TYPE_MODEM,
+       TREQ_MODEM_POWER_ON,
+       TREQ_MODEM_POWER_OFF,
+       TREQ_MODEM_POWER_RESET,
+       TREQ_MODEM_SET_FLIGHTMODE,
+       TREQ_MODEM_GET_FLIGHTMODE,
+       TREQ_MODEM_GET_IMEI,
+       TREQ_MODEM_GET_VERSION,
+
+       TREQ_CALL = TCORE_REQUEST | TCORE_TYPE_CALL,
+       TREQ_CALL_DIAL,
+       TREQ_CALL_ANSWER,
+       TREQ_CALL_END,
+       TREQ_CALL_HOLD,
+       TREQ_CALL_ACTIVE,
+       TREQ_CALL_SWAP,
+       TREQ_CALL_JOIN,
+       TREQ_CALL_SPLIT,
+       TREQ_CALL_DEFLECT,
+       TREQ_CALL_TRANSFER,
+       TREQ_CALL_SEND_DTMF,
+       TREQ_CALL_SET_SOUND_PATH,
+       TREQ_CALL_GET_SOUND_VOLUME_LEVEL,
+       TREQ_CALL_SET_SOUND_VOLUME_LEVEL,
+       TREQ_CALL_MUTE,
+       TREQ_CALL_UNMUTE,
+       TREQ_CALL_GET_MUTE_STATUS,
+       TREQ_CALL_SET_ACTIVE_LINE,
+       TREQ_CALL_GET_ACTIVE_LINE,
+       TREQ_CALL_ACTIVATE_CCBS,
+
+       TREQ_SS = TCORE_REQUEST | TCORE_TYPE_SS,
+       TREQ_SS_BARRING_ACTIVATE,
+       TREQ_SS_BARRING_DEACTIVATE,
+       TREQ_SS_BARRING_CHANGE_PASSWORD,
+       TREQ_SS_BARRING_GET_STATUS,
+       TREQ_SS_FORWARDING_ACTIVATE,
+       TREQ_SS_FORWARDING_DEACTIVATE,
+       TREQ_SS_FORWARDING_REGISTER,
+       TREQ_SS_FORWARDING_DEREGISTER,
+       TREQ_SS_FORWARDING_GET_STATUS,
+       TREQ_SS_WAITING_ACTIVATE,
+       TREQ_SS_WAITING_DEACTIVATE,
+       TREQ_SS_WAITING_GET_STATUS,
+       TREQ_SS_CLI_ACTIVATE,
+       TREQ_SS_CLI_DEACTIVATE,
+       TREQ_SS_CLI_GET_STATUS,
+       TREQ_SS_SEND_USSD,
+       TREQ_SS_SET_AOC,
+       TREQ_SS_GET_AOC,
+
+       TREQ_SIM = TCORE_REQUEST | TCORE_TYPE_SIM,
+       TREQ_SIM_VERIFY_PINS,
+       TREQ_SIM_VERIFY_PUKS,
+       TREQ_SIM_CHANGE_PINS,
+       TREQ_SIM_GET_FACILITY_STATUS,
+       TREQ_SIM_DISABLE_FACILITY,
+       TREQ_SIM_ENABLE_FACILITY,
+       TREQ_SIM_TRANSMIT_APDU,
+       TREQ_SIM_GET_ATR,
+       TREQ_SIM_GET_ECC,
+       TREQ_SIM_GET_LANGUAGE,
+       TREQ_SIM_SET_LANGUAGE,
+       TREQ_SIM_GET_ICCID,
+       TREQ_SIM_GET_MAILBOX,
+       TREQ_SIM_GET_CALLFORWARDING,
+       TREQ_SIM_SET_CALLFORWARDING,
+       TREQ_SIM_GET_MESSAGEWAITING,
+       TREQ_SIM_GET_CPHS_INFO,
+       TREQ_SIM_GET_MSISDN,
+       TREQ_SIM_GET_SPN,
+       TREQ_SIM_GET_SPDI,
+       TREQ_SIM_GET_OPL,
+       TREQ_SIM_GET_PNN,
+       TREQ_SIM_GET_CPHS_SHORTNETNAME,
+       TREQ_SIM_GET_CPHS_FULLNETNAME,
+       TREQ_SIM_GET_OPLMNWACT,
+       TREQ_SIM_REQ_AUTHENTICATION,
+
+       TREQ_SAT = TCORE_REQUEST | TCORE_TYPE_SAT,
+       TREQ_SAT_REQ_ENVELOPE,
+       TREQ_SAT_REQ_TERMINALRESPONSE,
+
+       TREQ_SAP = TCORE_REQUEST | TCORE_TYPE_SAP,
+       TREQ_SAP_REQ_CONNECT,
+       TREQ_SAP_REQ_DISCONNECT,
+       TREQ_SAP_REQ_STATUS,
+       TREQ_SAP_REQ_ATR,
+       TREQ_SAP_TRANSFER_APDU,
+       TREQ_SAP_SET_PROTOCOL,
+       TREQ_SAP_SET_POWER,
+       TREQ_SAP_REQ_CARDREADERSTATUS,
+
+       TREQ_NETWORK = TCORE_REQUEST | TCORE_TYPE_NETWORK,
+       TREQ_NETWORK_SEARCH,
+       TREQ_NETWORK_SET_PLMN_SELECTION_MODE,
+       TREQ_NETWORK_GET_PLMN_SELECTION_MODE,
+       TREQ_NETWORK_SET_SERVICE_DOMAIN,
+       TREQ_NETWORK_GET_SERVICE_DOMAIN,
+       TREQ_NETWORK_SET_BAND,
+       TREQ_NETWORK_GET_BAND,
+       TREQ_NETWORK_SET_PREFERRED_PLMN,
+       TREQ_NETWORK_GET_PREFERRED_PLMN,
+       TREQ_NETWORK_SET_ORDER,
+       TREQ_NETWORK_GET_ORDER,
+       TREQ_NETWORK_SET_POWER_ON_ATTACH,
+       TREQ_NETWORK_GET_POWER_ON_ATTACH,
+       TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH,
+       TREQ_NETWORK_GET_SERVING_NETWORK,
+
+       TREQ_PS = TCORE_REQUEST | TCORE_TYPE_PS,
+       TREQ_PS_SET_PDP_ACTIVATE,
+       TREQ_PS_SET_PDP_DEACTIVATE,
+       TREQ_PS_SET_DUN_PIN_CONTROL,
+
+       TREQ_SMS = TCORE_REQUEST | TCORE_TYPE_SMS,
+       TREQ_SMS_SEND_UMTS_MSG, /* Send the SMS-SUBMIT, SMS-COMMAND or SMS-SUBMIT-REPORT message */
+       TREQ_SMS_READ_MSG, /* Read the message from the phone flash or SIM */
+       TREQ_SMS_SAVE_MSG, /* Stores a message to memory storage */
+       TREQ_SMS_DELETE_MSG, /* Deletes message from preferred message storage */
+       TREQ_SMS_GET_COUNT, /* Get SMS Count Stored in Memory */
+       TREQ_SMS_GET_SCA, /* Get SMS Service Center Address */
+       TREQ_SMS_SET_SCA, /* Set SMS Service Center Address */
+       TREQ_SMS_GET_CB_CONFIG, /* Get Cell Broadcast Configuration */
+       TREQ_SMS_SET_CB_CONFIG, /* Set Cell Broadcast Configuration */
+       TREQ_SMS_SET_MEM_STATUS, /* Memory Storage Status message*/
+       TREQ_SMS_GET_PREF_BEARER, /* Get SMS Service Option like CS/PS bearer */
+       TREQ_SMS_SET_PREF_BEARER, /* Set SMS Service Option like CS/PS bearer */
+       TREQ_SMS_SET_DELIVERY_REPORT, /* Send the SMS-DELIVER-REPORT message to the network for the SMS-DELIVER message. */
+       TREQ_SMS_SET_MSG_STATUS, /* SMS Status Stored in Memory message */
+       TREQ_SMS_GET_PARAMS,
+       TREQ_SMS_SET_PARAMS,
+       TREQ_SMS_GET_PARAMCNT,
+       TREQ_SMS_SEND_CDMA_MSG,
+
+       TREQ_PHONEBOOK = TCORE_REQUEST | TCORE_TYPE_PHONEBOOK,
+       TREQ_PHONEBOOK_GETCOUNT,
+       TREQ_PHONEBOOK_GETMETAINFO,
+       TREQ_PHONEBOOK_GETUSIMINFO,
+       TREQ_PHONEBOOK_READRECORD,
+       TREQ_PHONEBOOK_UPDATERECORD,
+       TREQ_PHONEBOOK_DELETERECORD,
+
+       TREQ_SOUND = TCORE_REQUEST | TCORE_TYPE_SOUND,
+
+       TREQ_GPS = TCORE_REQUEST | TCORE_TYPE_GPS,
+
+       TREQ_CUSTOM = TCORE_REQUEST | TCORE_TYPE_CUSTOM,
+};
+
+struct treq_server_get_plugins {
+};
+
+struct treq_custom {
+       unsigned int custom_command;
+       GHashTable *data;
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/type/response.h b/include/type/response.h
new file mode 100644 (file)
index 0000000..d6c8b6c
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_RESPONSE_H__
+#define __TYPE_RESPONSE_H__
+
+#include <type/common.h>
+
+__BEGIN_DECLS
+
+enum tcore_response_command {
+       TRESP_UNKNOWN = 0,
+
+       TRESP_SERVER = TCORE_RESPONSE | TCORE_TYPE_SERVER,
+
+       TRESP_MODEM = TCORE_RESPONSE | TCORE_TYPE_MODEM,
+       TRESP_MODEM_POWER_ON,
+       TRESP_MODEM_POWER_OFF,
+       TRESP_MODEM_POWER_RESET,
+       TRESP_MODEM_SET_FLIGHTMODE,
+       TRESP_MODEM_GET_FLIGHTMODE,
+       TRESP_MODEM_GET_IMEI,
+       TRESP_MODEM_GET_VERSION,
+
+       TRESP_CALL = TCORE_RESPONSE | TCORE_TYPE_CALL,
+       TRESP_CALL_DIAL,
+       TRESP_CALL_ANSWER,
+       TRESP_CALL_END,
+       TRESP_CALL_END_ALL,
+       TRESP_CALL_END_ALL_ACTIVE,
+       TRESP_CALL_END_ALL_HELD,
+       TRESP_CALL_HOLD,
+       TRESP_CALL_ACTIVE,
+       TRESP_CALL_SWAP,
+       TRESP_CALL_JOIN,
+       TRESP_CALL_SPLIT,
+       TRESP_CALL_DEFLECT,
+       TRESP_CALL_TRANSFER,
+       TRESP_CALL_SEND_DTMF,
+       TRESP_CALL_SET_SOUND_PATH,
+       TRESP_CALL_GET_SOUND_VOLUME_LEVEL,
+       TRESP_CALL_SET_SOUND_VOLUME_LEVEL,
+       TRESP_CALL_MUTE,
+       TRESP_CALL_UNMUTE,
+       TRESP_CALL_GET_MUTE_STATUS,
+       TRESP_CALL_SET_ACTIVE_LINE,
+       TRESP_CALL_GET_ACTIVE_LINE,
+       TRESP_CALL_ACTIVATE_CCBS,
+
+       TRESP_SS = TCORE_RESPONSE | TCORE_TYPE_SS,
+       TRESP_SS_BARRING_ACTIVATE,
+       TRESP_SS_BARRING_DEACTIVATE,
+       TRESP_SS_BARRING_CHANGE_PASSWORD,
+       TRESP_SS_BARRING_GET_STATUS,
+       TRESP_SS_FORWARDING_ACTIVATE,
+       TRESP_SS_FORWARDING_DEACTIVATE,
+       TRESP_SS_FORWARDING_REGISTER,
+       TRESP_SS_FORWARDING_DEREGISTER,
+       TRESP_SS_FORWARDING_GET_STATUS,
+       TRESP_SS_WAITING_ACTIVATE,
+       TRESP_SS_WAITING_DEACTIVATE,
+       TRESP_SS_WAITING_GET_STATUS,
+       TRESP_SS_CLI_ACTIVATE,
+       TRESP_SS_CLI_DEACTIVATE,
+       TRESP_SS_CLI_GET_STATUS,
+       TRESP_SS_SEND_USSD,
+       TRESP_SS_SET_AOC,
+       TRESP_SS_GET_AOC,
+
+       TRESP_SIM = TCORE_RESPONSE | TCORE_TYPE_SIM,
+       TRESP_SIM_VERIFY_PINS,
+       TRESP_SIM_VERIFY_PUKS,
+       TRESP_SIM_CHANGE_PINS,
+       TRESP_SIM_GET_FACILITY_STATUS,
+       TRESP_SIM_DISABLE_FACILITY,
+       TRESP_SIM_ENABLE_FACILITY,
+       TRESP_SIM_TRANSMIT_APDU,
+       TRESP_SIM_GET_ATR,
+       TRESP_SIM_GET_ECC,
+       TRESP_SIM_GET_LANGUAGE,
+       TRESP_SIM_SET_LANGUAGE,
+       TRESP_SIM_GET_ICCID,
+       TRESP_SIM_GET_MAILBOX,
+       TRESP_SIM_GET_CALLFORWARDING,
+       TRESP_SIM_SET_CALLFORWARDING,
+       TRESP_SIM_GET_MESSAGEWAITING,
+       TRESP_SIM_GET_CPHS_INFO,
+       TRESP_SIM_GET_MSISDN,
+       TRESP_SIM_GET_SPN,
+       TRESP_SIM_GET_SPDI,
+       TRESP_SIM_GET_OPL,
+       TRESP_SIM_GET_PNN,
+       TRESP_SIM_GET_CPHS_SHORTNETNAME,
+       TRESP_SIM_GET_CPHS_FULLNETNAME,
+       TRESP_SIM_GET_OPLMNWACT,
+       TRESP_SIM_REQ_AUTHENTICATION,
+
+       TRESP_SAT = TCORE_RESPONSE | TCORE_TYPE_SAT,
+       TRESP_SAT_REQ_ENVELOPE,
+       TRESP_SAT_REQ_TERMINALRESPONSE,
+
+       TRESP_SAP = TCORE_RESPONSE | TCORE_TYPE_SAP,
+       TRESP_SAP_REQ_CONNECT,
+       TRESP_SAP_REQ_DISCONNECT,
+       TRESP_SAP_REQ_STATUS,
+       TRESP_SAP_REQ_ATR,
+       TRESP_SAP_TRANSFER_APDU,
+       TRESP_SAP_SET_PROTOCOL,
+       TRESP_SAP_SET_POWER,
+       TRESP_SAP_REQ_CARDREADERSTATUS,
+
+       TRESP_NETWORK = TCORE_RESPONSE | TCORE_TYPE_NETWORK,
+       TRESP_NETWORK_SEARCH,
+       TRESP_NETWORK_SET_PLMN_SELECTION_MODE,
+       TRESP_NETWORK_GET_PLMN_SELECTION_MODE,
+       TRESP_NETWORK_SET_SERVICE_DOMAIN,
+       TRESP_NETWORK_GET_SERVICE_DOMAIN,
+       TRESP_NETWORK_SET_BAND,
+       TRESP_NETWORK_GET_BAND,
+       TRESP_NETWORK_SET_PREFERRED_PLMN,
+       TRESP_NETWORK_GET_PREFERRED_PLMN,
+       TRESP_NETWORK_SET_ORDER,
+       TRESP_NETWORK_GET_ORDER,
+       TRESP_NETWORK_SET_POWER_ON_ATTACH,
+       TRESP_NETWORK_GET_POWER_ON_ATTACH,
+       TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH,
+       TRESP_NETWORK_GET_SERVING_NETWORK,
+
+       TRESP_PS = TCORE_RESPONSE | TCORE_TYPE_PS,
+       TRESP_PS_SET_PDP_ACTIVATE,
+       TRESP_PS_SET_PDP_DEACTIVATE,
+       TRESP_PS_SET_DUN_PIN_CONTROL,
+
+       TRESP_SMS = TCORE_RESPONSE | TCORE_TYPE_SMS,
+       TRESP_SMS_SEND_UMTS_MSG, /* This event is returned in response to SMS  message sent */
+       TRESP_SMS_READ_MSG, /* This event is returned in response to SMS Read message*/
+       TRESP_SMS_SAVE_MSG, /* This confirmation event is a returned indicating the Save SMS into SIM status*/
+       TRESP_SMS_DELETE_MSG, /* This confirmation event is a returned indicating the delete message status*/
+       TRESP_SMS_GET_STORED_MSG_COUNT, /* This event is returned in response to Get Number of messages stored in SIM*/
+       TRESP_SMS_GET_SCA, /* This event is returned with Get SCA */
+       TRESP_SMS_SET_SCA,
+       TRESP_SMS_GET_CB_CONFIG, /* This event is returned with Get CB configuration details*/
+       TRESP_SMS_SET_CB_CONFIG, /* This event is returned as a confirmation for SET CB configuration */
+       TRESP_SMS_SET_MEM_STATUS,
+       TRESP_SMS_GET_PREF_BEARER, /* This event is returned as a response to get preferred bearer used for SMS Transport*/
+       TRESP_SMS_SET_PREF_BEARER,
+       TRESP_SMS_SET_DELIVERY_REPORT, /* This event is returned in response to send delivery report */
+       TRESP_SMS_SET_MSG_STATUS,
+       TRESP_SMS_GET_PARAMS, /* This event is returned in response to SMS Get parameters*/
+       TRESP_SMS_SET_PARAMS,
+       TRESP_SMS_GET_PARAMCNT, /* Parameter count response */
+       TRESP_SMS_SEND_CDMA_MSG, /* This event is returned in response to SMS  message extended sent*/
+
+       TRESP_PHONEBOOK = TCORE_RESPONSE | TCORE_TYPE_PHONEBOOK,
+       TRESP_PHONEBOOK_GETCOUNT,
+       TRESP_PHONEBOOK_GETMETAINFO,
+       TRESP_PHONEBOOK_GETUSIMINFO,
+       TRESP_PHONEBOOK_READRECORD,
+       TRESP_PHONEBOOK_UPDATERECORD,
+       TRESP_PHONEBOOK_DELETERECORD,
+
+       TRESP_SOUND = TCORE_RESPONSE | TCORE_TYPE_SOUND,
+
+       TRESP_GPS = TCORE_RESPONSE | TCORE_TYPE_GPS,
+
+       TRESP_CUSTOM = TCORE_RESPONSE | TCORE_TYPE_CUSTOM,
+};
+
+struct tresp_custom {
+       unsigned int custom_command;
+       GHashTable *data;
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/type/sap.h b/include/type/sap.h
new file mode 100644 (file)
index 0000000..ffd525a
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_SAP_H__
+#define __TYPE_SAP_H__
+
+__BEGIN_DECLS
+
+#include <glib.h>
+
+enum tel_sap_power_mode {
+       SAP_POWER_ON,
+       SAP_POWER_OFF,
+       SAP_POWER_RESET
+};
+
+enum tel_sap_protocol_type {
+       SAP_PROTOCOL_T0, /**< T = 0, character */
+       SAP_PROTOCOL_T1 /**< T = 1, block */
+};
+
+enum tel_sap_connection_status {
+       SAP_CONNECTION_STATUS_OK = 0x00, /**< connect successfully */
+       SAP_CONNECTION_STATUS_UNABLE_TO_ESTABLISH, /**< unable to establish connection */
+       SAP_CONNECTION_STATUS_NOT_SUPPORT_MAX_SIZE, /**< when server does not support message length that client want send */
+       SAP_CONNECTION_STATUS_TOO_SMALL_MAX_SIZE /**< when client want to connect with very small message length which is not supported by Server */
+};
+
+enum tel_sap_disconnect_type {
+       SAP_DISCONNECT_TYPE_GRACEFUL = 0x00, /**< disconnection procedure ends after finishing current work */
+       SAP_DISCONNECT_TYPE_IMMEDIATE /**<  disconnection procedure ends immediately*/
+};
+
+enum tel_sap_status { //CARD READER STATUS
+       SAP_STATUS_UNKNOWN = 0x00, /**<  SAP server connection status - unknown*/
+       SAP_STATUS_NO_SIM, /**<  SAP server connection status - no SIM*/
+       SAP_STATUS_NOT_READY, /**<  SAP server connection status - not ready*/
+       SAP_STATUS_READY, /**<  SAP server connection status - ready*/
+       SAP_STATUS_CONNECTED /**<  SAP server connection status - connected*/
+};
+
+enum tel_sap_status_change {
+       SAP_CARD_STATUS_UNKNOWN = 0x00, /**<  SAP server status(card reader status) - unknown*/
+       SAP_CARD_STATUS_RESET, /**<  SAP server status(card reader status) - reset*/
+       SAP_CARD_STATUS_NOT_ACCESSIBLE, /**<  SAP server status(card reader status) - not accessible*/
+       SAP_CARD_STATUS_REMOVED, /**<  SAP server status(card reader status) - removed*/
+       SAP_CARD_STATUS_INSERTED, /**<  SAP server status(card reader status) - inserted*/
+       SAP_CARD_STATUS_RECOVERED /**<  SAP server status(card reader status) - recovered*/
+};
+
+enum tel_sap_result_code {
+       SAP_RESULT_CODE_OK = 0x00, /**<  SAP operation result - OK*/
+       SAP_RESULT_CODE_NO_REASON, /**<  SAP operation result - no reason*/
+       SAP_RESULT_CODE_CARD_NOT_ACCESSIBLE, /**<  SAP operation result - not accessible*/
+       SAP_RESULT_CODE_CARD_ALREADY_POWER_OFF, /**<  SAP operation result - card already power off*/
+       SAP_RESULT_CODE_CARD_REMOVED, /**<  SAP operation result - card removed*/
+       SAP_RESULT_CODE_CARD_ALREADY_POWER_ON, /**<  SAP operation result - card already power on*/
+       SAP_RESULT_CODE_DATA_NOT_AVAILABLE, /**<  SAP operation result - data not available*/
+       SAP_RESULT_CODE_NOT_SUPPORT /**<  SAP operation result - not support*/
+};
+
+struct treq_sap_req_connect {
+       unsigned short max_msg_size;
+};
+
+struct treq_sap_req_disconnect {
+       /*NO Parameter*/
+};
+
+struct treq_sap_req_status {
+       /*NO Parameter*/
+};
+
+struct treq_sap_req_atr {
+       /*NO Parameter*/
+};
+
+struct treq_sap_transfer_apdu {
+       unsigned int apdu_length;
+       unsigned char apdu_data[256+2];
+};
+
+struct treq_sap_set_protocol {
+       enum tel_sap_protocol_type protocol;
+};
+
+struct treq_sap_set_power {
+       enum tel_sap_power_mode mode;
+};
+
+struct treq_sap_req_cardreaderstatus {
+       /*NO Parameter*/
+};
+
+struct tresp_sap_req_connect {
+       enum tel_sap_connection_status status;
+       unsigned short max_msg_size;
+};
+
+struct tresp_sap_req_disconnect {
+       enum tel_sap_result_code result;
+};
+
+struct tresp_sap_req_status {
+       enum tel_sap_status status;
+};
+
+struct tresp_sap_req_atr {
+       enum tel_sap_result_code result;
+       unsigned int atr_length;
+       unsigned char atr[256];
+};
+
+struct tresp_sap_transfer_apdu {
+       enum tel_sap_result_code result;
+       unsigned int resp_apdu_length;
+       unsigned char resp_adpdu[256+2];
+};
+
+struct tresp_sap_set_protocol {
+       enum tel_sap_result_code result;
+};
+
+struct tresp_sap_set_power {
+       enum tel_sap_result_code result;
+};
+
+struct tresp_sap_req_cardreaderstatus {
+       enum tel_sap_result_code result;
+       char reader_status;
+};
+
+struct tnoti_sap_status_changed {
+       enum tel_sap_status_change status;
+};
+
+struct tnoti_sap_disconnect {
+       enum tel_sap_disconnect_type type;
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/type/sat.h b/include/type/sat.h
new file mode 100644 (file)
index 0000000..297d4b3
--- /dev/null
@@ -0,0 +1,591 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_SAT_H__
+#define __TYPE_SAT_H__
+
+__BEGIN_DECLS
+
+#include <glib.h>
+
+#define SAT_TEXT_STRING_LEN_MAX 500
+#define SAT_MENU_ITEM_COUNT_MAX 40
+#define SAT_ALPHA_ID_LEN_MAX   255      /**<   max length of  alpha identifier         */
+#define SAT_ITEM_TEXT_LEN_MAX 45        /**<   max length of item text                 */
+#define SAT_ITEMS_NEXT_ACTION_INDI_LIST_MAX_COUNT      50       /**<   max count of items next action indication list  */
+#define SAT_IMG_DATA_FILE_PATH_LEN_MAX 50       /**<   max length of image data file name (Icon, CLUT)         */
+#define SAT_ICON_LIST_MAX_COUNT        50       /**<   max count of icon list          */
+#define SAT_ITEM_TEXT_ATTRIBUTES_LIST_MAX_COUNT        50       /**<   max count of item text attributes list          */
+#define SAT_ENVELOPE_CMD_LEN_MAX       256
+
+enum tel_sat_proactive_cmd_type {
+       SAT_PROATV_CMD_NONE = 0x00, /**<        command type - None             */
+       SAT_PROATV_CMD_REFRESH = 0x01, /**<     command type - refresh          */
+       SAT_PROATV_CMD_MORE_TIME = 0x02, /**<   command type - more time                */
+       SAT_PROATV_CMD_SETUP_EVENT_LIST = 0x05, /**<    command type - setup event list                 */
+       SAT_PROATV_CMD_SETUP_CALL = 0x10, /**<  command type - setup call               */
+       SAT_PROATV_CMD_SEND_SS = 0x11, /**<     command type - send ss          */
+       SAT_PROATV_CMD_SEND_USSD = 0x12, /**<   command type - send ussd                */
+       SAT_PROATV_CMD_SEND_SMS = 0x13, /**<    command type - send sms                 */
+       SAT_PROATV_CMD_SEND_DTMF = 0x14, /**<   command type - send dtmf                */
+       SAT_PROATV_CMD_LAUNCH_BROWSER = 0x15, /**<      command type - launch browser           */
+       SAT_PROATV_CMD_PLAY_TONE = 0x20, /**<   command type - play tone                */
+       SAT_PROATV_CMD_DISPLAY_TEXT = 0x21, /**<        command type - display text             */
+       SAT_PROATV_CMD_GET_INKEY = 0x22, /**<   command type - get inkey                */
+       SAT_PROATV_CMD_GET_INPUT = 0x23, /**<   command type - get input                */
+       SAT_PROATV_CMD_SELECT_ITEM = 0x24, /**< command type - select item              */
+       SAT_PROATV_CMD_SETUP_MENU = 0x25, /**<  command type - setup menu               */
+       SAT_PROATV_CMD_PROVIDE_LOCAL_INFO = 0x26, /**<  command type - provide local info               */
+       SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT = 0x28, /**<        command type - setup idle mode text             */
+       SAT_PROATV_CMD_LANGUAGE_NOTIFICATION = 0x35, /**<       command type - language notification            */
+       SAT_PROATV_CMD_OPEN_CHANNEL = 0x40, /**<        command type - open channel -class e            */
+       SAT_PROATV_CMD_CLOSE_CHANNEL = 0x41, /**<       command type - close channel - class e          */
+       SAT_PROATV_CMD_RECEIVE_DATA = 0x42, /**<        command type - receive data -class e            */
+       SAT_PROATV_CMD_SEND_DATA = 0x43, /**<   command type - send data                */
+       SAT_PROATV_CMD_GET_CHANNEL_STATUS = 0x44, /**<  command type - get channel status -class e              */
+       SAT_PROATV_CMD_RESERVED = 0xFF /**<     command type - reserved         */
+};
+
+/*
+ * TS 102.223 V6.12.0
+ * SAT DATA OBJECT DEFINE
+ */
+
+/*
+ * Data Coding Scheme Object
+ */
+enum alphabet_format{
+       ALPHABET_FROMAT_SMS_DEFAULT = 0x00,
+       ALPHABET_FROMAT_8BIT_DATA = 0x01,
+       ALPHABET_FROMAT_UCS2 = 0x02,
+       ALPHABET_FROMAT_RESERVED = 0x03
+};
+
+enum msg_class{
+       MSG_CLASS_NONE =0x00,
+       MSG_CLASS_0 =0x01, //class 0
+       MSG_CLASS_1, // class 1 Default meaning:ME-specific
+       MSG_CLASS_2, // class 2 SIM specific message
+       MSG_CLASS_3, // class 3 Default meaning: TE sepcific
+       MSG_CLASS_RESERVED =0xFF
+};
+
+struct data_coding_scheme{
+       int is_compressed_format;               // if FALSE, unpacked format
+       enum alphabet_format a_format;
+       enum msg_class m_class;
+       unsigned char raw_dcs;
+};
+
+/*
+ * 8.1 Address
+ */
+
+/*
+ * 8.2 Alpha identifier
+ */
+struct tel_sat_alpha_identifier{
+       gboolean is_exist;
+       struct data_coding_scheme dcs;
+       unsigned char alpha_data_len; /**<      alpha identifier length                 */
+       char alpha_data[SAT_ALPHA_ID_LEN_MAX]; /**<     alpha identifier info   */
+};
+
+/*
+ * 8.6 Command details
+ */
+enum display_text_priority{
+       TEXT_PRIORITY_NORMAL = 0,
+       TEXT_PRIORITY_HIGH = 1
+};
+
+enum display_text_clear_type{
+       TEXT_AUTO_CLEAR_MSG_AFTER_A_DELAY = 0,
+       TEXT_WAIT_FOR_USER_TO_CLEAR_MSG = 1
+};
+
+struct tel_sat_cmd_qualifier_display_text{
+       enum display_text_priority text_priority;
+       enum display_text_clear_type text_clear_type;
+};
+
+enum inkey_type{
+       INKEY_TYPE_CHARACTER_SET_ENABLED = 0,
+       INKEY_TYPE_YES_NO_REQUESTED = 1
+
+};
+
+enum input_alphabet_type{
+       INPUT_ALPHABET_TYPE_SMS_DEFAULT = 1,
+       INPUT_ALPHABET_TYPE_UCS2 = 2
+};
+
+struct tel_sat_cmd_qualifier_get_inkey{
+       enum inkey_type inkey_type;
+       enum input_alphabet_type alphabet_type;
+       gboolean alphabet_set;
+       gboolean immediate_rsp_required;
+       gboolean help_info;
+};
+
+struct tel_sat_cmd_qualifier_get_input{
+       enum input_alphabet_type alphabet_type;
+       gboolean alphabet_set;
+       gboolean me_echo_user_input;
+       gboolean user_input_unpacked_format;
+       gboolean help_info;
+};
+
+enum presentation_type{
+       PRESENTATION_TYPE_NOT_SPECIFIED = 0x00,
+       PRESENTATION_TYPE_DATA_VALUE                    = 0x01,
+       PRESENTATION_TYPE_NAVIGATION_OPTION     = 0x02
+
+};
+
+enum selection_preference_type {
+       SELECTION_PREFERENCE_NONE_REQUESTED = 0,
+       SELECTION_PREFERENCE_USING_SOFT_KEY = 1
+};
+
+struct tel_sat_cmd_qualifier_select_item{
+       enum presentation_type presentation_type;
+       enum selection_preference_type select_preference;
+       gboolean help_info;
+};
+
+struct tel_sat_cmd_qualifier_setup_menu{
+       enum selection_preference_type select_preference;
+       gboolean help_info;
+};
+
+struct tel_sat_cmd_detail_info{
+       int cmd_num; /**< specific command number       */
+       enum tel_sat_proactive_cmd_type cmd_type; /**<  proactive command type          */
+       union {
+               struct tel_sat_cmd_qualifier_display_text display_text;
+               struct tel_sat_cmd_qualifier_get_inkey get_inkey;
+               struct tel_sat_cmd_qualifier_get_input get_input;
+               struct tel_sat_cmd_qualifier_select_item select_item;
+               struct tel_sat_cmd_qualifier_setup_menu setup_menu; /**<        setup menu command qualifier info       */
+
+       }cmd_qualifier; /**<    Union   */
+};
+
+/*
+ * 8.7 Device identities
+ */
+enum device_identity{
+       DEVICE_ID_KEYPAD = 0x01,
+       DEVICE_ID_DISPLAY = 0x02,
+       DEVICE_ID_EARPIECE = 0x03,
+       DEVICE_ID_SIM = 0x81,
+       DEVICE_ID_ME = 0x82,
+       DEVICE_ID_NETWORK = 0x83,
+       DEVICE_ID_RESERVED = 0XFF
+};
+
+struct tel_sat_device_identities{
+       enum device_identity src;
+       enum device_identity dest;
+};
+
+/*
+ * 8.8 Duration
+ */
+enum time_unit_type{
+       TIME_UNIT_MINUTES                                               = 0x0,
+       TIME_UNIT_SECONDS                                               = 0x01,
+       TIME_UNIT_TENTHS_OF_SECONDS                     = 0x02,
+       TIME_UNIT_RESERVED                                              = 0xFF
+};
+
+struct tel_sat_duration{
+       enum time_unit_type time_unit;
+       unsigned char time_interval;
+};
+
+/*
+ * 8.9 Item
+ */
+struct tel_sat_item_info{
+       unsigned char item_id;
+       unsigned char text_len;
+       unsigned char text[SAT_ITEM_TEXT_LEN_MAX + 1];
+};
+
+/*
+ * 8.10 Item identifier
+ */
+struct tel_sat_item_identifier{
+       unsigned char item_identifier;
+};
+
+/*
+ * 8.11 Response length
+ */
+struct tel_sat_response_length{
+       unsigned char min;
+       unsigned char max;
+};
+
+/*
+ * 8.15 Text string
+ */
+struct tel_sat_text_string_object{
+       int is_digit_only;
+       struct data_coding_scheme dcs;
+       int string_length;
+       char string[SAT_TEXT_STRING_LEN_MAX+1];
+};
+
+/*
+ * 8.24 Items next action indicator
+ */
+struct tel_sat_item_next_action_indicatior_list{
+       unsigned char cnt;
+       unsigned char indicator_list[SAT_ITEMS_NEXT_ACTION_INDI_LIST_MAX_COUNT];
+};
+
+/*
+ * 8.23 Default text
+ * It is the same as Text string(8.15)
+ */
+
+/*
+ * 8.31 Icon identifier
+ */
+enum img_coding_scheme{
+       IMAGE_CODING_SCHEME_BASIC = 0x11,
+       IMAGE_CODING_SCHEME_COLOUR = 0x21,
+       IMAGE_CODING_SCHEME_RESERVED = 0xFF
+};
+
+enum icon_qualifier{
+       ICON_QUALI_SELF_EXPLANATORY = 0,
+       ICON_QUALI_NOT_SELF_EXPLANATORY = 1,
+       ICON_QUALI_RESERVED = 0xFF
+};
+
+struct tel_sat_icon{
+       unsigned char width;
+       unsigned char height;
+       enum img_coding_scheme ics;
+       unsigned short icon_data_len;
+       unsigned short clut_data_len;
+       char icon_file[SAT_IMG_DATA_FILE_PATH_LEN_MAX];
+       char clut_file[SAT_IMG_DATA_FILE_PATH_LEN_MAX];
+};
+
+struct tel_sat_icon_identifier{
+       gboolean is_exist;
+       enum icon_qualifier icon_qualifer;
+       unsigned char icon_identifier;
+       struct tel_sat_icon icon_info;
+};
+
+/*
+ * 8.32 Item icon identifier next_action_indicator_list
+ */
+struct tel_sat_icon_identifier_list{
+       gboolean is_exist;
+       enum icon_qualifier icon_qualifer;
+       unsigned char icon_cnt;
+       unsigned char icon_id_list[SAT_ICON_LIST_MAX_COUNT];
+       struct tel_sat_icon icon_info[SAT_ICON_LIST_MAX_COUNT];
+};
+
+/*
+ * 8.72 Text attribute
+ */
+struct tel_sat_text_attribute{
+       unsigned char text_formatting[4];
+};
+
+/*
+ * 8.73 Item text attribute list
+ */
+struct tel_sat_text_attribute_list{
+       unsigned int list_cnt;
+       struct tel_sat_text_attribute text_attribute_list[SAT_ITEM_TEXT_ATTRIBUTES_LIST_MAX_COUNT];
+};
+
+/*
+ * 6.6 Structure of proactive UICC commands
+ */
+
+/*
+ * 6.6.1 DISPLAY TEXT
+ */
+struct tel_sat_display_text_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_text_string_object text;
+       struct tel_sat_icon_identifier icon_id;
+       gboolean immediate_response_requested;
+       struct tel_sat_duration duration;
+       struct tel_sat_text_attribute text_attribute;
+};
+
+/*
+ * 6.6.2 GET INKEY
+ */
+struct tel_sat_get_inkey_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_text_string_object text;
+       struct tel_sat_icon_identifier icon_id;
+       struct tel_sat_duration duration;
+       struct tel_sat_text_attribute text_attribute;
+};
+
+/*
+ * 6.6.3 GET INPUT
+ */
+struct tel_sat_get_input_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_text_string_object text;
+       struct tel_sat_response_length rsp_len;
+       struct tel_sat_text_string_object default_text;
+       struct tel_sat_icon_identifier icon_id;
+       struct tel_sat_text_attribute text_attribute;
+};
+
+/*
+ * 6.6.7 SET-UP MENU
+ */
+struct tel_sat_setup_menu_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_alpha_identifier alpha_id;
+       unsigned char menu_item_cnt;
+       struct tel_sat_item_info menu_item[SAT_MENU_ITEM_COUNT_MAX];
+       struct tel_sat_item_next_action_indicatior_list next_act_ind_list;
+       struct tel_sat_icon_identifier icon_id;
+       struct tel_sat_icon_identifier_list icon_list;
+       struct tel_sat_text_attribute text_attribute;
+       struct tel_sat_text_attribute_list text_attribute_list;
+};
+
+/*
+ * 6.6.8 SELECT ITEM
+ */
+struct tel_sat_select_item_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_alpha_identifier alpha_id;
+       unsigned char menu_item_cnt;
+       struct tel_sat_item_info menu_item[SAT_MENU_ITEM_COUNT_MAX];
+       struct tel_sat_item_next_action_indicatior_list item_next_act_ind_list;
+       struct tel_sat_item_identifier item_identifier;
+       struct tel_sat_icon_identifier icon_id;
+       struct tel_sat_icon_identifier_list icon_list;
+       struct tel_sat_text_attribute text_attribute;
+       struct tel_sat_text_attribute_list text_attribute_list;
+       //frame identifier 8.80
+};
+
+/*
+ * 6.6.16 SETUP EVENT LIST
+ */
+struct tel_sat_setup_event_list_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+//TODO
+       //Event LIST
+};
+
+/*
+ * CoreObject
+ * Structure of Req. Rsp. Noti.
+ */
+
+/*
+ * Define SAT Request structure
+ */
+enum sat_envelop_sub_cmd{
+       ENVELOP_MENU_SELECTION,
+       ENVELOP_CALL_CONTROL,
+       ENVELOP_TIMER_EXPIRATION,
+       ENVELOP_EVENT_DOWNLOAD,
+};
+
+struct tel_sat_envelop_menu_selection_tlv{
+       struct tel_sat_device_identities device_identitie;
+       struct tel_sat_item_identifier item_identifier;
+       gboolean help_request;
+};
+
+struct tel_sat_envelop_event_download_tlv{
+       struct tel_sat_device_identities device_identitie;
+       struct tel_sat_item_identifier item_identifier;
+       gboolean help_request;
+//TODO
+};
+
+struct treq_sat_envelop_cmd_data{
+       enum sat_envelop_sub_cmd sub_cmd;
+       union{
+               struct tel_sat_envelop_menu_selection_tlv menu_select;
+               struct tel_sat_envelop_event_download_tlv event_download;
+       }envelop_data;
+};
+
+enum tel_sat_result_type{
+       RESULT_SUCCESS = 0x0, /**<      command performed successfully */
+       RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION = 0x01, /**<  command performed with partial comprehension    */
+       RESULT_SUCCESS_WITH_MISSING_INFO = 0x02, /**<   command performed, with missing information     */
+
+       RESULT_REFRESH_PERFORMED_WITH_ADDITIONAL_EFS_READ = 0x03, /**<  REFRESH PERFORMED WITH ADDITIONAL EFS READ              */
+       RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED = 0x04, /**<    command performed but REQUESTED ICON NOT DISPLAYED                      */
+       RESULT_SUCCESS_BUT_MODIFIED_BY_CALL_CONTROL_BY_SIM = 0x05, /**< command performed but MODIFIED BY CALL CONTROL BY SIM           */
+       RESULT_SUCCESS_LIMITED_SERVICE = 0x06, /**<     command performed with LIMITED SERVICE          */
+       RESULT_SUCCESS_WITH_MODIFICATION = 0x07, /**<   command performed with MODIFICATION             */
+       RESULT_REFRESH_PRFRMD_BUT_INDICATED_USIM_NOT_ACTIVE = 0x08, /**<        REFRESH PERFORMED BUT INDICATED USIM NOT ACTIVE                 */
+
+       RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER = 0x10, /**<        proactive sim application session terminated by user            */
+       RESULT_BACKWARD_MOVE_BY_USER = 0x11, /**<       backward move in the proactive sim application session request by the user              */
+       RESULT_NO_RESPONSE_FROM_USER = 0x12, /**<       no response from user           */
+
+       RESULT_HELP_INFO_REQUIRED_BY_USER = 0x13, /**<  HELP INFO REQUIRED BY USER              */
+       RESULT_USSD_OR_SS_TRANSACTION_TERMINATED_BY_USER = 0x14, /**<   USSD OR SS TRANSACTION TERMINATED BY USER       */
+
+       RESULT_ME_UNABLE_TO_PROCESS_COMMAND = 0x20, /**<        ME currently unable to process command          */
+       RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND = 0x21, /**<   Network currently unable to process command             */
+       RESULT_USER_DID_NOT_ACCEPT_CALL_SETUP_REQ = 0x22, /**<  User did not accept call setup request          */
+       RESULT_USER_CLEAR_DOWN_CALL_BEFORE_CONN = 0x23, /**<    User cleared down call before connection or network released            */
+
+       RESULT_INTERACTION_WITH_CC_BY_SIM_IN_TMP_PRBLM = 0x25, /**<     INTERACTION WITH CALL CONTROL BY SIM IN TEMPORARY PROBLEM               */
+       RESULT_LAUNCH_BROWSER_GENERIC_ERROR_CODE = 0x26, /**<   LAUNCH BROWSER GENERIC ERROR CODE               */
+
+       RESULT_BEYOND_ME_CAPABILITIES = 0x30, /**<      command beyond ME's capabilities                */
+       RESULT_COMMAND_TYPE_NOT_UNDERSTOOD_BY_ME = 0x31, /**<   command type not understood by ME               */
+       RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME = 0x32, /**<   command data not understood by ME               */
+       RESULT_COMMAND_NUMBER_NOT_KNOWN_BY_ME = 0x33, /**<      command number not known by ME          */
+       RESULT_SS_RETURN_ERROR = 0x34, /**<     SS return error         */
+       RESULT_SMS_RP_ERROR = 0x35, /**<        SMS rp-error            */
+       RESULT_ERROR_REQUIRED_VALUES_ARE_MISSING = 0x36, /**<   Error, required values are missing              */
+
+       RESULT_USSD_RETURN_ERROR = 0x37, /**<   USSD_RETURN_ERROR               */
+       RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM = 0x39, /**<     INTERACTION WITH CALL CONTROL OR SMS CONTROL PERMANENT PROBLEM          */
+       RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR = 0x3A, /**<   BEARER INDEPENDENT PROTOCOL ERROR               */
+       RESULT_FRAMES_ERROR = 0x3C /**< FRAMES ERROR            */
+};
+
+enum tel_sat_me_problem_type{
+       ME_PROBLEM_NO_SPECIFIC_CAUSE = 0x0, /**<        ME problem with NO SPECIFIC CAUSE               */
+       ME_PROBLEM_SCREEN_BUSY = 0x01, /**<     ME problem with SCREEN BUSY             */
+       ME_PROBLEM_ME_BUSY_ON_CALL = 0x02, /**< ME problem with ME BUSY ON CALL         */
+       ME_PROBLEM_ME_BUSY_ON_SS = 0x03, /**<   ME problem with ME_BUSY ON SS           */
+       ME_PROBLEM_NO_SERVICE = 0x04, /**<      ME problem with NO SERVICE              */
+       ME_PROBLEM_ACCESS_CONTROL_CLASS_BAR = 0x05, /**<        ME problem with ACCESS CONTROL CLASS BAR                */
+       ME_PROBLEM_RADIO_RES_NOT_GRANTED = 0x06, /**<   ME problem with RADIO RES NOT GRANTED           */
+       ME_PROBLEM_NOT_IN_SPEECH_CALL = 0x07, /**<      ME problem with NOT IN SPEECH CALL      */
+       ME_PROBLEM_ME_BUSY_ON_USSD = 0x08, /**< ME problem with ME BUSY ON USSD         */
+       ME_PROBLEM_ME_BUSY_ON_SEND_DTMF_CMD = 0x09, /**<        ME problem with ME BUSY ON SEND DTMF CMD        */
+       ME_PROBLEM_NO_USIM_ACTIVE = 0x0A, /**<  ME problem with NO USIM ACTIVE          */
+       ME_PROBLEM_INVALID = 0xFF /**<  ME problem with INVALID                 */
+};
+
+struct tel_sat_tr_setup_event_list_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       enum tel_sat_result_type result_type;
+       enum tel_sat_me_problem_type me_problem_type;
+};
+
+struct tel_sat_tr_display_text_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       enum tel_sat_result_type result_type;
+       enum tel_sat_me_problem_type me_problem_type;
+};
+
+struct tel_sat_tr_get_inkey_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       enum tel_sat_result_type result_type;
+       enum tel_sat_me_problem_type me_problem_type;
+       struct tel_sat_text_string_object text;
+       struct tel_sat_duration duration;
+};
+
+struct tel_sat_tr_get_input_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       enum tel_sat_result_type result_type;
+       enum tel_sat_me_problem_type me_problem_type;
+       struct tel_sat_text_string_object text;
+};
+
+struct tel_sat_tr_setup_menu_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       enum tel_sat_result_type result_type;
+       enum tel_sat_me_problem_type me_problem_type;
+};
+
+struct tel_sat_tr_select_item_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       enum tel_sat_result_type result_type;
+       enum tel_sat_me_problem_type me_problem_type;
+       gboolean other_info;
+       struct tel_sat_item_identifier item_identifier;
+};
+
+struct treq_sat_terminal_rsp_data{
+       int cmd_number;
+       enum tel_sat_proactive_cmd_type cmd_type;
+       union{
+               struct tel_sat_tr_setup_event_list_tlv setup_event_list;
+               struct tel_sat_tr_display_text_tlv display_text;
+               struct tel_sat_tr_get_inkey_tlv get_inkey;
+               struct tel_sat_tr_get_input_tlv get_input;
+               struct tel_sat_tr_setup_menu_tlv setup_menu;
+               struct tel_sat_tr_select_item_tlv select_item;
+       }terminal_rsp_data;
+};
+
+
+/*
+ * Define SAT Response structure
+ */
+
+
+/*
+ * Define SAT Notification structure
+ */
+struct tnoti_sat_proactive_ind{
+       int cmd_number;
+       enum tel_sat_proactive_cmd_type cmd_type;
+       union{
+               struct tel_sat_setup_event_list_tlv setup_event_list;
+               struct tel_sat_setup_menu_tlv setup_menu;
+               struct tel_sat_display_text_tlv display_text;
+               struct tel_sat_get_inkey_tlv get_inkey;
+               struct tel_sat_get_input_tlv get_input;
+               struct tel_sat_select_item_tlv select_item;
+       }proactive_ind_data;
+};
+__END_DECLS
+
+#endif
diff --git a/include/type/sim.h b/include/type/sim.h
new file mode 100644 (file)
index 0000000..10b486a
--- /dev/null
@@ -0,0 +1,1009 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_SIM_H__
+#define __TYPE_SIM_H__
+
+__BEGIN_DECLS
+
+#include <glib.h>
+
+#define SIM_ICCID_LEN_MAX 20 // 3gpp
+#define SIM_LANG_CNT_MAX 30 //telephony defined
+#define SIM_SST_LEN_MAX 20 //telephony defined
+#define SIM_SST_SERVICE_CNT_MAX 50 //3gpp
+#define SIM_UST_BYTE_LEN_MAX 8 //telephony defined
+#define SIM_SPN_LEN_MAX 16 //3gpp
+#define SIM_SPDI_PLMN_MAX 41 //telephony defined
+#define SIM_XDN_ALPHA_ID_LEN_MAX 30 //telephony defined
+#define SIM_XDN_NUMBER_LEN_MAX 20 //telephony defined
+#define SIM_ECC_BYTE_LEN_MAX 3 //3gpp
+#define SIM_ECC_STRING_LEN_MAX 50 //telephony defined
+#define SIM_ECC_RECORD_CNT_MAX 15 //telephony defined
+#define SIM_CF_RECORD_CNT_MAX 2 //telephony defined
+#define SIM_MSISDN_RECORD_CNT_MAX 3 //telephony defined
+#define SIM_GROUP_IDENTIFIER_LEN_MAX 10 //telephony defined
+#define SIM_MAIL_BOX_IDENTIFIER_LEN_MAX 5 //3gpp
+#define SIM_OPL_PNN_RECORD_CNT_MAX 5//85 //telephony defined
+#define SIM_NW_FULL_NAME_LEN_MAX 40 //telephony defined TODO should be defined one value in all.
+#define SIM_OPLMNWACT_LEN_MAX 100 //telephony defined
+#define SIM_AUTH_REQ_DATA_LEN_MAX 256 //telephony defined
+#define SIM_AUTH_RESP_DATA_LEN_MAX 128 //telephony defined
+#define SIM_CPHS_CALL_FORWARDING_LEN_MAX 2 //telephony defined
+#define SIM_CPHS_CSP_ENTRY_CNT_MAX 11 //telephony defined
+#define SIM_CPHS_CSP_LEN_MAX 22 //telephony defined
+#define SIM_CPHS_VMWF_LEN_MAX 2 //telephony defined
+#define SIM_CPHS_OPERATOR_NAME_LEN_MAX 25 //telephony defined
+#define SIM_CPHS_OPERATOR_NAME_SHORT_FORM_LEN_MAX 10 //CPHS spec
+#define SIM_CPHS_INFO_LEN_MAX 3 //telephony defined
+
+enum tel_sim_file_id {
+       SIM_EF_DIR = 0x2F00, /**< Root Directory for the USIM */
+       SIM_EF_ICCID = 0x2FE2, /**< the ICC Identification file */
+       SIM_EF_IMSI = 0x6F07, /**< the IMSI file                */
+       SIM_EF_SST = 0x6F38, /**< the SIM Service Table file   */
+       SIM_EF_EST = 0x6F56, /**< the Enabled Service Table file   */
+       SIM_EF_OPLMN_ACT = 0x6F61, /**< the OPLMN List file*/
+       SIM_EF_GID1 = 0x6F3E, /**< the Group Identifier Level 1 */
+       SIM_EF_GID2 = 0x6F3F, /**< the Group Identifier Level 2 */
+
+       SIM_EF_ELP = 0x2F05, /**< the Extended Language Preference file */
+       SIM_EF_LP = 0x6F05, /**< SIM: Language preference */
+       SIM_EF_ECC = 0x6FB7, /**< the Emergency Call Codes     */
+       SIM_EF_SPN = 0x6F46, /**< the Service Provider Name    */
+       SIM_EF_SPDI = 0x6FCD, /**< the Service provider display information*/
+       SIM_EF_PNN = 0x6FC5, /**< the PLMN Network Name File*/
+       SIM_EF_OPL = 0x6FC6, /**< the Operator PLMN List File*/
+       SIM_EF_MBDN = 0x6FC7, /** < SIM Mail Box Dialing Number file */
+       SIM_EF_MSISDN = 0x6F40, /**< MSISDN */
+
+       SIM_EF_USIM_LI = 0x6A05, /**< USIM: Language Indication */
+       SIM_EF_USIM_PL = 0x2A05, /**< the Language Preference file of USIM */
+       SIM_EF_USIM_MBI = 0x6FC9, /** < Mailbox Identifier -linear fixed*/
+       SIM_EF_USIM_MWIS = 0x6FCA, /** < Message Waiting Indication Status -linear fixed*/
+       SIM_EF_USIM_CFIS = 0x6FCB, /** < Call forward indication status -linear fixed*/
+
+       /* CPHS FILE ID */
+       SIM_EF_CPHS_VOICE_MSG_WAITING = 0x6F11, /** < CPHS voice MSG waiting indication  */
+       SIM_EF_CPHS_SERVICE_STRING_TABLE = 0x6F12, /** < CPHS service string table  */
+       SIM_EF_CPHS_CALL_FORWARD_FLAGS = 0x6F13, /** < CPHS call forward flags  */
+       SIM_EF_CPHS_OPERATOR_NAME_STRING = 0x6F14, /** < CPHS operator name string  */
+       SIM_EF_CPHS_CUSTOMER_SERVICE_PROFILE = 0x6F15, /** < CPHS customer service profile  */
+       SIM_EF_CPHS_CPHS_INFO = 0x6F16, /** < CPHS information  */
+       SIM_EF_CPHS_MAILBOX_NUMBERS = 0x6F17, /** < CPHS mail box numbers  */
+       SIM_EF_CPHS_OPERATOR_NAME_SHORT_FORM_STRING = 0x6F18, /** < CPHS operator name short form string  */
+       SIM_EF_CPHS_INFORMATION_NUMBERS = 0x6F19, /** < CPHS information numbers  */
+       /*  CPHS ALS FILE ID */
+       SIM_EF_CPHS_DYNAMICFLAGS = 0x6F9F, /** < CPHS Dynamics flags  */
+       SIM_EF_CPHS_DYNAMIC2FLAG = 0x6F92, /** < CPHS Dynamics2 flags  */
+       SIM_EF_CPHS_CUSTOMER_SERVICE_PROFILE_LINE2 = 0x6F98, /** < CPHS CSP2  */
+
+       /* Invalid File ID, All the file ID are less than this Value*/
+       SIM_EF_INVALID = 0xFFFF, /**< Invalid file.*/
+       SIM_EF_OTHERS, /**< Element to indicate an unknown file.*/
+};
+
+enum tel_sim_type {
+       SIM_TYPE_UNKNOWN, /**< Unknown card */
+       SIM_TYPE_GSM, /**< 2G GSM card*/
+       SIM_TYPE_USIM, /**< 3G USIM card */
+       SIM_TYPE_RUIM, /** CDMA based card*/
+       SIM_TYPE_ISIM /** IMS based card */
+};
+
+enum tel_sim_status {
+       SIM_STATUS_CARD_ERROR = 0x00, /**< Bad card / On the fly SIM gone bad **/
+       SIM_STATUS_CARD_NOT_PRESENT = 0x01, /**<  Card not present **/
+       SIM_STATUS_INITIALIZING = 0x02, /**<  SIM is Initializing state **/
+       SIM_STATUS_INIT_COMPLETED = 0x03, /**<  SIM Initialization OK **/
+       SIM_STATUS_PIN_REQUIRED = 0x04, /**<  PIN  required state **/
+       SIM_STATUS_PUK_REQUIRED = 0x05, /**<  PUK required state **/
+       SIM_STATUS_CARD_BLOCKED = 0x06, /**<  PIN/PUK blocked(permanently blocked- All the attempts for PIN/PUK failed) **/
+       SIM_STATUS_NCK_REQUIRED = 0x07, /**<  Network Control Key required state **/
+       SIM_STATUS_NSCK_REQUIRED = 0x08, /**<  Network Subset Control Key required state **/
+       SIM_STATUS_SPCK_REQUIRED = 0x09, /**<  Service Provider Control Key required state **/
+       SIM_STATUS_CCK_REQUIRED = 0x0a, /**<  Corporate Control Key required state **/
+       SIM_STATUS_CARD_REMOVED = 0x0b, /**<  Card removed **/
+       SIM_STATUS_LOCK_REQUIRED = 0x0c, /**<  PH-SIM (phone-SIM) locked state **/
+       SIM_STATUS_UNKNOWN = 0xff /**<  unknown state. not checked yet. **/
+};
+
+enum tel_sim_facility_status {
+       SIM_FACILITY_STATUS_DISABLED = 0x00, /**< PIN1 or PIN2 Disabled */
+       SIM_FACILITY_STATUS_ENABLED = 0x01, /**< PIN1 or PIN2 Enabled */
+       SIM_FACILITY_STATUS_BLOCKED = 0x02, /**< SIM is present, but PIN1 or PIN2  is blocked. need unblocking by PUK or PUK2 */
+       SIM_FACILITY_STATUS_PUK_BLOCKED = 0x03, /**< SIM is present, but PUK is blocked. */
+       SIM_FACILITY_STATUS_UNKNOWN = 0xFF /**< SIM is in unknown state */
+};
+
+enum tel_sim_access_result {
+       SIM_ACCESS_SUCCESS, /**< Access to file successful.  */
+       SIM_ACCESS_CARD_ERROR, /**< SIM card error    */
+       SIM_ACCESS_FILE_NOT_FOUND, /**< File not found  */
+       SIM_ACCESS_CONDITION_NOT_SATISFIED, /**< Access condition is not fulfilled  */
+       SIM_ACCESS_FAILED, /**< Access failed.  */
+};
+
+enum tel_sim_pin_operation_result {
+       SIM_PIN_OPERATION_SUCCESS, /**< Operation involving PIN (verification/change/enable/disable, etc) is successful.  */
+       SIM_BUSY, /**< SIM is busy  */
+       SIM_CARD_ERROR, /**< SIM card error - Permanently blocked and general errors   */
+       SIM_INCOMPATIBLE_PIN_OPERATION, /**< SIM Incompatible pin operation that is in case when invalid SIM command is given or incorrect parameters are supplied to the SIM. */
+       SIM_INCORRECT_PASSWORD, /**< SIM PIN  Incorrect password */
+       SIM_PIN_REQUIRED, /**< PIN Required */
+       SIM_PUK_REQUIRED, /**< PUK Required */
+       SIM_NCK_REQUIRED, /**< Network Control Key Required */
+       SIM_NSCK_REQUIRED, /**< Network Subset Control Key Required */
+       SIM_SPCK_REQUIRED, /**< Service Provider Control Key Required */
+       SIM_CCK_REQUIRED, /**< Corporate Control Key Required */
+       SIM_LOCK_REQUIRED, /**<  PH-SIM (phone-SIM) locked state **/
+       SIM_ADM_REQUIRED /**<  Admin key locked state **/
+};
+
+enum tel_sim_language_type {
+       SIM_LANG_GERMAN = 0x00, /**< German */
+       SIM_LANG_ENGLISH = 0x01, /**< English */
+       SIM_LANG_ITALIAN = 0x02, /**< Italian */
+       SIM_LANG_FRENCH = 0x03, /**< French */
+       SIM_LANG_SPANISH = 0x04, /**< Spanish */
+       SIM_LANG_DUTCH = 0x05, /**< Dutch */
+       SIM_LANG_SWEDISH = 0x06, /**< Swedish */
+       SIM_LANG_DANISH = 0x07, /**< Danish */
+       SIM_LANG_PORTUGUESE = 0x08, /**< Portuguese */
+       SIM_LANG_FINNISH = 0x09, /**< Finnish */
+       SIM_LANG_NORWEGIAN = 0x0A, /**< Norwegian */
+       SIM_LANG_GREEK = 0x0B, /**< Greek */
+       SIM_LANG_TURKISH = 0x0C, /**< Turkish */
+       SIM_LANG_HUNGARIAN = 0x0D, /**< Hungarian */
+       SIM_LANG_POLISH = 0x0E, /**< Polish */
+       SIM_LANG_KOREAN = 0x0F, /**< Korean */
+       SIM_LANG_CHINESE = 0x10, /**< Chinese */
+       SIM_LANG_RUSSIAN = 0x11, /**< Russian */
+       SIM_LANG_JAPANESE = 0x12, /**< Japanese */
+       SIM_LANG_UNSPECIFIED = 0xFF /**< Unspecified */
+};
+
+enum tel_sim_msgwaiting_idication_mask {
+       SIM_MWIS_NONE = 0x00, /**< MWIS none*/
+       SIM_MWIS_VOICE = 0x01, /**< MWIS voice*/
+       SIM_MWIS_FAX = 0x02, /**< MWIS FAX*/
+       SIM_MWIS_EMAIL = 0x04, /**< MWIS email*/
+       SIM_MWIS_OTHER = 0x08, /**< MWIS other*/
+       SIM_MWIS_VIDEO = 0x10, /**< MWIS video*/
+       SIM_MWIS_RFU = 0xff /**< MWIS RFU*/
+};
+
+enum tel_sim_pin_type {
+       SIM_PTYPE_PIN1 = 0x00, /**< PIN 1 code */
+       SIM_PTYPE_PIN2 = 0x01, /**< PIN 2 code */
+       SIM_PTYPE_PUK1 = 0x02, /**< PUK 1 code */
+       SIM_PTYPE_PUK2 = 0x03, /**< PUK 2 code */
+       SIM_PTYPE_UPIN = 0x04, /**< Universal PIN - Unused now */
+       SIM_PTYPE_ADM = 0x05, /**< Administrator - Unused now */
+       SIM_PTYPE_SIM = 0x06 /**< SIM Lock code */
+};
+
+enum tel_sim_facility_type {
+       SIM_FACILITY_PS, /**< PH-SIM, Lock PHone to SIM/UICC card*/
+       SIM_FACILITY_SC, /**< Lock SIM/UICC card, simply PIN1 */
+       SIM_FACILITY_FD, /**< Fixed Dialing Number feature, need PIN2 */
+       SIM_FACILITY_PN, /**< Network Personalization */
+       SIM_FACILITY_PU, /**< network sUbset Personalization */
+       SIM_FACILITY_PP, /**< service Provider Personalization */
+       SIM_FACILITY_PC, /**< Corporate Personalization */
+};
+
+enum tel_sim_cphs_dynamic_flag_selected_line {
+       SIM_DYNAMIC_FLAGS_LINE1 = 0x01, /**< line 1 */
+       SIM_DYNAMIC_FLAGS_LINE2 = 0x00, /**< line 2*/
+       SIM_DYNAMIC_FLAGS_RFU = 0xff /**< rfu*/
+};
+
+enum tel_sim_cphs_dynamic2_flag_als_status {
+       SIM_PIN2_ACCESSIBLE_FLAGS_LOCKED = 0x01, /**< Dynamic flags locked */
+       SIM_PIN2_ACCESSIBLE_FLAGS_UNLOCKED = 0x00, /**< Dynamic flags unlocked */
+       SIM_PIN2_ACCESSIBLE_FLAGS_RFU = 0xff /**< rfu */
+};
+
+enum tel_sim_cphs_phase {
+       SIM_CPHS_PHASE1 = 0x01, /**< phase1  */
+       SIM_CPHS_PHASE2 = 0x02, /**< phase2  */
+       SIM_CPHS_PHASE_RFU = 0xff /**< RFU  */
+};
+
+enum tel_sim_ton {
+       SIM_TON_UNKNOWN = 0, /**< unknown */
+       SIM_TON_INTERNATIONAL = 1, /**< international number */
+       SIM_TON_NATIONAL = 2, /**< national number */
+       SIM_TON_NETWORK_SPECIFIC = 3, /**< network specific number */
+       SIM_TON_DEDICATED_ACCESS = 4, /**< subscriber number */
+       SIM_TON_ALPHA_NUMERIC = 5, /**< alphanumeric, GSM 7-bit default alphabet) */
+       SIM_TON_ABBREVIATED_NUMBER = 6, /**< abbreviated number */
+       SIM_TON_RESERVED_FOR_EXT = 7 /**< reserved for extension */
+};
+
+enum tel_sim_npi {
+       SIM_NPI_UNKNOWN = 0, /**< Unknown */
+       SIM_NPI_ISDN_TEL = 1, /**< ISDN/Telephone numbering plan */
+       SIM_NPI_DATA_NUMBERING_PLAN = 3, /**< Data numbering plan */
+       SIM_NPI_TELEX = 4, /**< Telex numbering plan */
+       SIM_NPI_SVC_CNTR_SPECIFIC_PLAN = 5, /**< Service Center Specific plan */
+       SIM_NPI_SVC_CNTR_SPECIFIC_PLAN2 = 6, /**< Service Center Specific plan */
+       SIM_NPI_NATIONAL = 8, /**< National numbering plan */
+       SIM_NPI_PRIVATE = 9, /**< Private numbering plan */
+       SIM_NPI_ERMES_NUMBERING_PLAN = 10, /**< ERMES numbering plan */
+       SIM_NPI_RESERVED_FOR_EXT = 0xF /**< Reserved for extension */
+};
+
+enum tel_sim_emergency_service_type {
+       SIM_ECC_POLICE = 0x01, /**< Police */
+       SIM_ECC_AMBULANCE = 0x02, /**< Ambulance */
+       SIM_ECC_FIREBRIGADE = 0x04, /**< Fire brigade */
+       SIM_ECC_MARAINEGUARD = 0x08, /**< Marine guard */
+       SIM_ECC_MOUTAINRESCUE = 0x10, /**< Mountain rescue */
+       SIM_ECC_SPARE = 0x00 /**< Spare */
+};
+
+enum tel_sim_cphs_csp_group {
+       SIM_CPHS_CSP_GROUP_CALL_OFFERING = 0x01, /**< Group CSP offering*/
+       SIM_CPHS_CSP_GROUP_CALL_RESTRICTION = 0x02, /**< Group CSP restriction*/
+       SIM_CPHS_CSP_GROUP_OTHER_SUPP_SERVICES = 0x03, /**< Group CSP supplementary services*/
+       SIM_CPHS_CSP_GROUP_CALL_COMPLETION = 0x04, /**< Group CSP completion*/
+       SIM_CPHS_CSP_GROUP_TELESERVICES = 0x05, /**< Group CSP teleservices*/
+       SIM_CPHS_CSP_GROUP_CPHS_TELESERVICES = 0x06, /**< Group CSP CPHS teleservies*/
+       SIM_CPHS_CSP_GROUP_CPHS_FEATURES = 0x07, /**< Group CSP CPHS features*/
+       SIM_CPHS_CSP_GROUP_NUMBER_IDENTIFIERS = 0x08, /**< Group CSP number identifiers*/
+       SIM_CPHS_CSP_GROUP_PHASE_SERVICES = 0x09, /**< Group CSP phase services*/
+       SIM_CPHS_CSP_GROUP_VALUE_ADDED_SERVICES = 0xC0, /**< Group CSP value added services*/
+       SIM_CPHS_CSP_GROUP_INFORMATION_NUMBERS = 0xD5 /**< Group CSP information numbers*/
+};
+
+enum tel_sim_cphs_index_level {
+       SIM_CPHS_INDEX_LEVEL_ONE = 0x01, /**< SIM CPHS index level one */
+       SIM_CPHS_INDEX_LEVEL_TWO = 0x02, /**< SIM CPHS index level two */
+       SIM_CPHS_INDEX_LEVEL_THREE = 0x03, /**< SIM CPHS index level three */
+       SIM_CPHS_INDEX_LEVEL_RFU = 0xff /**< SIM CPHS index level RFU */
+};
+
+enum tel_sim_auth_type {
+       SIM_AUTH_TYPE_IMS = 0x00, /**< IMS Authentication */
+       SIM_AUTH_TYPE_GSM, /**< GSM Authentication */
+       SIM_AUTH_TYPE_3G, /**< 3G Authentication */
+       SIM_AUTH_TYPE_MAX /**< TBD */
+};
+
+enum tel_sim_auth_result {
+       SIM_AUTH_NO_ERROR = 0x00, /**< ISIM no error */
+       SIM_AUTH_CANNOT_PERFORM, /**< status - can't perform authentication */
+       SIM_AUTH_SKIP_RESPONSE, /**< status - skip authentication response */
+       SIM_AUTH_MAK_CODE_FAILURE, /**< status - MAK(Multiple Activation Key) code failure */
+       SIM_AUTH_SQN_FAILURE, /**< status - SQN(SeQuenceNumber) failure */
+       SIM_AUTH_SYNCH_FAILURE, /**< status - synch failure */
+       SIM_AUTH_UNSUPPORTED_CONTEXT, /**< status - unsupported context */
+       SIM_AUTH_MAX /**< TBD */
+};
+
+struct tel_sim_sst {
+       // service 1
+       char bPIN1DisableFunction; /**< PIN1 disable function */
+       char bAdn; /**< abbreviated Dialing number */
+       char bFdn; /**< fixed Dialing number */
+       char bSms; /**< short message storage */
+       char bAoc; /**< advice of charge */
+       char bCcp; /**< capability configuration parameters */
+       char bPlmnSelector; /**< plmn selector */
+       char bRfu1; /**< rfu */
+
+       // service 9
+       char bMsisdn; /**< msisdn */
+       char bExtension1; /**< extension1       */
+       char bExtension2; /**< extension2 */
+       char bSmsParams; /**< sms parameteres */
+       char blnd; /**< last number dialed */
+       char bCellBroadCastMsgId; /**< cell broadcast message identifier */
+       char bGroupIdLevel1; /**< group identifier level 1 */
+       char bGroupIdLevel2; /**< group identifier level 2 */
+
+       // service 17
+       char bSpn; /**< service provider name */
+       char bSdn; /**< service Dialing number */
+       char bExtension3; /**< extension3 */
+       char bRfu2; /**< rfu */
+       char bVgcsGroupIdList; /**< vgcs group identifier (EF-VGCS, EF-VGCSS) */
+       char bVbsGroupIDList; /**< vbs group identifier (EF-VBS, EF-VBSS) */
+       char bEnhancedMultilevelPrecedencePreemptionService; /**< enhanced multi-level precedence and pre-emption service */
+       char bAutoAnswerForeMLPP; /**< automatic answer fro eMLPP */
+
+       // service 25
+       char bSmsCbdDataDownload; /**< data download via sms-cb */
+       char bSmsPpDataDownload; /**< data download via sms-pp */
+       char bMenuSelection; /**< menu selection */
+       char bCallControl; /**< call control */
+       char bProactiveSimCommand; /**< proactive sim command */
+       char bCellBroadcastMsgIdRanges; /**< cell broadcast message identifier ranges */
+       char bBdn; /**< barred Dialing numbers */
+       char bExtension4; /**< extension 4 */
+
+       // service 33
+       char bDePersonalizedControlKeys; /**< de-personalization control keys */
+       char bCoOperativeNetworkList; /**< co-operative network list */
+       char bSmsr; /**< short message status reports */
+       char bNetworkAlertIndInMS; /**< network's indication of alerting in the MS */
+       char bMoSMSControl; /**< mobile-originated short message control by sim */
+       char bGPRS; /**< gprs */
+       char bImage; /**< image */
+       char bSolsa; /**< support of local service area */
+
+       //      service 41
+       char bUSSDSupportedInCallControl; /**< ussd string data object supported in call control */
+       char bRunAtCommand; /**< RUN AT COMMAND command */
+       char bUserControlledPLMNSelectorAccessTech; /**< user controlled PLMN selector with Access technology */
+       char bOperatorControlledPlmnSelectorAccessTech; /**< operator controlled PLMN selector with Access technology */
+       char bHplmnSelectorAccessTech; /**< HPLMN selector with access technology */
+       char bCPBCCHInfo; /**< CPBCCH information */
+       char bInvestigationScan; /**< investigation scan */
+       char bExtenedCapaConfigParams; /**< extended capability configuration parameters */
+
+       //      service 49
+       char bMexe; /**< MExE */
+       char bRplmnLastUsedAccessTech; /**< RPLMN last used access technology */
+};
+
+struct tel_sim_ust {
+       // service 1
+       char bLocalPhoneBook; /**< local phone book */
+       char bFdn; /**< fixed Dialing number */
+       char bExtension2; /**< extension 2 */
+       char bSdn; /**< service Dialing number */
+       char bExtension3; /**< extension 3 */
+       char bBdn; /**< barred Dialing numbers */
+       char bExtension4; /**< extension 4 */
+       char bOCIOCT; /**< outgoing call information */
+
+       //      service 9
+       char bIciIct; /**< incoming call information */
+       char bSms; /**< short message storage */
+       char bSmsr; /**< short message status reports */
+       char bSMSP; /**< short message service parameters */
+       char bAoc; /**< advice of charge */
+       char bCcp; /**< capability config parameters */
+       char bCellBroadcastMsgId; /**< cell broadcast message identifier */
+       char bCellBroadcastMsgIdRanges; /**< cell broadcast message identifier charge */
+
+       //      sevice 17
+       char bGroupIdLevel1; /**< group identifier level 1 */
+       char bGroupIdLevel2; /**< group identifier level 2 */
+       char bSpn; /**< service provide name */
+       char bUserControlledPLMNSelectorAccessTech; /**< user controlled plmn selector with access technology */
+       char bMsisdn; /**< msisdn */
+       char bImage; /**< image */
+       char bSolsa;
+       char bEnhancedMultilevelPrecedencePreemptionService; /**< enhanced multi-level precedence and pre-emption service */
+
+       //      service 25
+       char bAutoAnswerForeMLPP; /**< automatic answer fro eMLPP */
+       char bRfu1;
+       char bGsmAccess; /**< gsm access */
+       char bSmsPpDataDownload; /**< data download via sms-pp */
+       char bSmsCbdDataDownload; /**< data download via sms-cb */
+       char bUsimCallControl; /**< usim call control */
+       char bUsimMoSmsControl; /**< mo-sms control by usim */
+       char bRunAtCommand; /**< RUN AT COMMAND command */
+
+       //      service 33
+       char bShallBeSetToOne; /**< shall be set to 1 */
+       char bEnabledServiceTable; /**< enabled service table */
+       char bAcl; /**< APN control list */
+       char bDePersonalizedControlKeys; /**< de-personalization control keys */
+       char bCoOperativeNetworkList; /**< co-operative network list */
+       char bGsmSecurityContext; /**< gsm security context */
+       char bCpbcchiInformation; /**< cpbcch information */
+       char bInvestigationScan; /**< investigation scan */
+
+       //      service 41
+       char bMexe; /**< mexe */
+       char bOperatorControlledPlmnSelectorAccessTech; /**< Operator controlled PLMN selector with Access Technology */
+       char bHplmnSelectorAccessTech; /**< HPLMN selector with access technology */
+       char bExtension5; /**< extension 5 */
+       char bPlmnNetworkName; /**< plmn network name */
+       char bOperatorPlmnList; /**< operator plmn list */
+       char bMailBoxDiallingNumbers; /**< mailbox Dialing numbers */
+       char bMsgWaitingIndStatus; /**< message waiting indication status */
+
+       //      service 49
+       char bCallForwardingIndicationStatus; /**< call forwarding indication status */
+       char bRplmnLastUsedAccessTech; /**< RPLMN last used access technology */
+       char bServiceProviderDisplayInfo; /**< service provider display information */
+       char bMms; /**< multimedia messaging service */
+       char bExtension8; /**< extension 8 */
+       char bUsimGpsCallControl; /**< call control on gprs by usim */
+       char bMmsUserConnectivityParameters; /**< mms user connectivity parameters */
+       char bNia; /**< Network's indication of alerting in the MS (NIA) */
+
+       //service 57
+       char bVgcsIdList; /**< VGCS Group Identifier List (EFVGCS and EFVGCSS) */
+       char bVbsGroupId; /**< VBS Group Identifier List (EFVBS and EFVBSS)*/
+       char bPseudonym;
+       char bUserCtrlPlmnSelectorForWlan;
+       char bOperatorCtrlPlmnSelectorForWlan;
+       char bUserCtrlWsidList;
+       char bOperatorCtrlWsidList;
+       char bVgcsSecurity;
+};
+
+struct tel_sim_est {
+       gboolean bFdnEnabled;
+       gboolean bBdnEnabled;
+       gboolean bAclEnabled;
+};
+
+struct tel_sim_imsi {
+       char plmn[6 + 1]; /**< SIM MCC, MNC code. MNC is 2 digit or 3digit */
+       char msin[10 + 1]; /**< Mobile Station Identification Number */
+};
+
+struct tel_sim_dialing_number {
+       int AlphaIDMaxLength; /**< alpha max length in SIM - READ ONLY*/
+       int AlphaIdLength; /**< length of alpha identifier */
+       char AlphaId[SIM_XDN_ALPHA_ID_LEN_MAX + 1]; /**< Alpha Identifier */
+       int DiallingNumMaxLength; /**< max length of dialing number filed in SIM - READ ONLY */
+       int DiallingnumLength; /**< Length of BCD number/SSC contents */
+       enum tel_sim_ton TypeOfNumber; /**< TON */
+       enum tel_sim_npi NumberingPlanIdent; /**< NPI */
+       char DiallingNum[SIM_XDN_NUMBER_LEN_MAX + 1]; /**< Dialing Number/SSC String */
+       unsigned char CapaConfigId; /**< Capability/Configuration Identifier */
+       unsigned char Ext1RecordId; /**< Extensiion1 Record Identifier */
+};
+
+struct tel_sim_gid {
+       int GroupIdentifierLen; /**< Group identifier length */
+       char szGroupIdentifier[SIM_GROUP_IDENTIFIER_LEN_MAX]; /**< Group identifier */
+};
+
+struct tel_sim_mbi {
+       /*      '00' - no mailbox dialing number associated with message waiting indication group type.
+        'xx' - record number in EFMBDN associated with message waiting indication group type.
+        */
+       unsigned char VoiceMailBoxIdentifier; /**< voice mailbox identifier*/
+       unsigned char FaxMailBoxIdentifier; /**< FAX mailbox identifier*/
+       unsigned char EmailMailBoxIdentifier; /**< email mailbox identifier*/
+       unsigned char VideoMailBoxIdentifier; /**< video mailbox identifier*/
+       unsigned char OtherMailBoxIdentifier; /**< other mailbox identifier*/
+};
+
+struct tel_sim_cphs_mailbox {
+       struct tel_sim_dialing_number voice_line1; /**< the array of mailbox number */
+       struct tel_sim_dialing_number voice_line2; /**< the array of mailbox number */
+       struct tel_sim_dialing_number video; /**< the array of mailbox number */
+       struct tel_sim_dialing_number fax; /**< the array of mailbox number */
+};
+
+struct tel_sim_cfis {
+       unsigned char MspNumber; /**< MSP number*/
+       unsigned char Status; /**< call forwarding indication status*/
+       int DiallingnumLen; /**< Length of BCD number/SSC contents*/
+       enum tel_sim_ton TypeOfNumber; /**< TON*/
+       enum tel_sim_npi NumberingPlanIdent; /**< NPI*/
+       char DiallingNum[SIM_XDN_NUMBER_LEN_MAX + 1];/**< Dialing Number/SSC String*/
+};
+
+struct tel_sim_cphs_cf {
+       int bCallForwardUnconditionalLine1; /**< CallForwardUnconditionalLine 1 */
+       int bCallForwardUnconditionalLine2; /**< CallForwardUnconditionalLine 2 */
+       int bCallForwardUnconditionalFax; /**< CallForwardUnconditional FAX */
+       int bCallForwardUnconditionalData; /**<CallForwardUnconditional data*/
+       int bCallForwardUnconditionalSms; /**< CallForwardUnconditional SMS */
+       int bCallForwardUnconditionalBearer; /**< CallForwardUnconditional bearer*/
+};
+
+struct tel_sim_mw {
+       unsigned char IndicatorType; /**< Indicator Type*/
+       int voice_count; /**< VoiceMail Count*/
+       int fax_count; /**< FAX Count*/
+       int email_count; /**< Email Count*/
+       int other_count; /**< Other Count*/
+       int video_count; /**< VideoMail Count*/
+};
+
+struct tel_sim_cphs_mw {
+       gboolean b_voice1; /**< VoiceMsgLine1 message waiting flag */
+       gboolean b_voice2; /**< VoiceMsgLine2 message waiting flag */
+       gboolean b_fax; /**< FAX message waiting flag */
+       gboolean b_data; /**< Data message waiting flag */
+};
+
+struct tel_sim_cphs_svc_call_offering_s {
+       int bCallForwardingUnconditional; /**< CallForwarding Unconditional */
+       int bCallForwardingOnUserBusy; /**< CallForwarding On UserBusy */
+       int bCallForwardingOnNoReply; /**< CallForwarding On NoReply */
+       int bCallForwardingOnUserNotReachable; /**< CallForwarding On User Not Reachable */
+       int bCallTransfer; /**< Call Transfer */
+};
+
+struct tel_sim_cphs_svc_call_restriction_s {
+       int bBarringOfAllOutgoingCalls; /**< Barring Of All Outgoing Calls*/
+       int bBarringOfOutgoingInternationalCalls; /**< Barring Of Outgoing International Calls */
+       int bBarringOfOutgoingInternationalCallsExceptHplmn; /**< Barring Of Outgoing International Calls Except HPLMN */
+       int bBarringOfAllIncomingCallsRoamingOutsideHplmn; /**< Barring Of All Incoming Calls Roaming Outside HPLMN */
+       int bBarringOfIncomingCallsWhenRoaming; /**< Barring Of IncomingCalls When Roaming */
+};
+
+struct tel_sim_cphs_svc_other_ss_s {
+       int bMultiPartyService; /**< MultiPartyService*/
+       int bClosedUserGroup; /**< ClosedUserGroup*/
+       int bAdviceOfCharge; /**< AdviceOfCharge*/
+       int bPreferentialClosedUserGroup; /**< PreferentialClosedUserGroup*/
+       int bClosedUserGroupOutgoingAccess; /**< ClosedUserGroupOutgoingAccess*/
+};
+
+struct tel_sim_cphs_svc_call_complete_s {
+       int bCallHold; /**< Call Hold*/
+       int bCallWaiting; /**< Call Waiting*/
+       int bCompletionOfCallToBusySubscriber; /**< Completion Of Call To Busy Subscriber*/
+       int bUserUserSignalling; /**< User User Signaling*/
+};
+
+struct tel_sim_cphs_svc_teleservices_s {
+       int bShortMessageMobileOriginated; /**< Short Message Mobile Originated*/
+       int bShortMessageMobileTerminated; /**< Short Message Mobile Terminated*/
+       int bShortMessageCellBroadcast; /**< Short Message Cell Broadcast*/
+       int bShortMessageReplyPath; /**< Short  Message Reply Path*/
+       int bShortMessageDeliveryConf; /**< Short Message Delivery Conf*/
+       int bShortMessageProtocolIdentifier; /**< Short Message Protocol Identifier*/
+       int bShortMessageValidityPeriod; /**< Short Message Validity Period*/
+};
+
+struct tel_sim_cphs_svc_cphs_teleservices_s {
+       int bAlternativeLineService; /**< Alternative Line Service*/
+};
+
+struct tel_sim_cphs_svc_cphs_features_s {
+       int bStringServiceTable; /**< String Service Table*/
+};
+
+struct tel_sim_cphs_svc_number_identifier_s {
+       int bCallingLineIdentificationPresent; /**< Calling Line Identification Present*/
+       int bConnectedLineIdentificationRestrict; /**< Connected Line Identification Restrict*/
+       int bConnectedLineIdentificationPresent; /**< Connected Line Identification Present*/
+       int bMaliciousCallIdentifier; /**< Malicious Call Identifier*/
+       int bCallingLineIdentificationSend; /**< Calling Line Identification Send*/
+       int bCallingLineIdentificationBlock; /**< Calling Line Identification Block*/
+};
+
+struct tel_sim_cphs_svc_phase_services_s {
+       int bMenuForGprs; /**< Menu For group*/
+       int bMenuForHighSpeedCsd; /**< Menu For HighSpeedCsd*/
+       int bMenuForVoiceGroupCall; /**< Menu For VoiceGroupCall*/
+       int bMenuForVoiceBroadcastService; /**< Menu For VoiceBroadcastService*/
+       int bMenuForMultipleSubscriberProfile; /**< Menu For MultipleSubscriberProfile*/
+       int bMenuForMultipleBand; /**< Menu For MultipleBand*/
+};
+
+struct tel_sim_cphs_svc_value_added_services_s {
+       int bRestrictMenuForManualSelection; /**< RestrictMenu For ManualSelection*/
+       int bRestrictMenuForVoiceMail; /**< RestrictMenu For VoiceMail*/
+       int bRestrictMenuForMoSmsAndPaging; /**< RestrictMenu For MoSmsAndPaging*/
+       int bRestrictMenuForMoSmsWithEmialType; /**< RestrictMenu For MoSmsWithEmialType*/
+       int bRestrictMenuForFaxCalls; /**< RestrictMenu For FaxCalls*/
+       int bRestrictMenuForDataCalls; /**< RestrictMenu For DataCalls*/
+       int bRestrictMenuForChangeLanguage; /**< RestrictMenu For ChangeLanguage*/
+};
+
+struct tel_sim_cphs_svc_information_numbers_s {
+       int bInformationNumbers; /**< Information Numbers*/
+};
+
+struct tel_sim_cphs_csp_entry_s {
+       enum tel_sim_cphs_csp_group CustomerServiceGroup; /**< customer service group*/
+       union {
+               struct tel_sim_cphs_svc_call_offering_s CallOffering; /**< call offering*/
+               struct tel_sim_cphs_svc_call_restriction_s CallRestriction; /**< call restriction*/
+               struct tel_sim_cphs_svc_other_ss_s OtherSuppServices; /**< other SS services*/
+               struct tel_sim_cphs_svc_call_complete_s CallComplete; /**< call complete*/
+               struct tel_sim_cphs_svc_teleservices_s Teleservices; /**< teleservices*/
+               struct tel_sim_cphs_svc_cphs_teleservices_s CphsTeleservices; /**< CPHS teleservices*/
+               struct tel_sim_cphs_svc_cphs_features_s CphsFeatures; /**< CPHS features*/
+               struct tel_sim_cphs_svc_number_identifier_s NumberIdentifiers; /**< number identifiers*/
+               struct tel_sim_cphs_svc_phase_services_s PhaseServices; /**< phase services*/
+               struct tel_sim_cphs_svc_value_added_services_s ValueAddedServices; /**< value added services*/
+               struct tel_sim_cphs_svc_information_numbers_s InformationNumbers; /**< information numbers*/
+       } u;
+};
+
+struct tel_sim_cphs_csp {
+       struct tel_sim_cphs_csp_entry_s ServiceProfileEntry[SIM_CPHS_CSP_ENTRY_CNT_MAX]; /**< service profile entry*/
+};
+
+struct tel_sim_cphs_dflag {
+       enum tel_sim_cphs_dynamic_flag_selected_line DynamicFlags; /**< Dynamic flags information */
+};
+
+struct tel_sim_cphs_dflag2 {
+       enum tel_sim_cphs_dynamic2_flag_als_status Dynamic2Flag; /**< Dynamic flags status */
+};
+
+struct tel_sim_cphs_service_tablie_s {
+       /* Byte 2 - bit1 & 2*/
+       int bCustomerServiceProfile; /**< Customer Service Profile (CSP)  */
+       /* Byte 2 - bit3 & 4*/
+       int bServiceStringTable; /**< Service String Table (SST) */
+       /* Byte 2 - bit5 & 6*/
+       int bMailBoxNumbers; /**< MailBoxNumbers */
+       /* Byte 2 - bit7 & 8*/
+       int bOperatorNameShortForm; /**< Short form of operator name */
+       /* Byte 3 - bit1 & 2*/
+       int bInformationNumbers; /**< Information numbers */
+};
+
+struct tel_sim_cphs_info {
+       enum tel_sim_cphs_phase CphsPhase; /**< CPHS phase type */
+       struct tel_sim_cphs_service_tablie_s CphsServiceTable; /**< CPHS service table */
+};
+
+struct tel_sim_cphs_info_number {
+       int AlphaIdLength; /**< length of alpha identifier */
+       enum tel_sim_cphs_index_level IndexLevelIndicator; /**< SIM CPHS index level one */
+       int PremiumServiceIndicator; /**< SIM CPHS index level one */
+       int NetworkSpecificIndicator; /**< SIM CPHS index level one */
+       unsigned char Alpha_id[SIM_XDN_ALPHA_ID_LEN_MAX + 1]; /**<  Alpha Identifier */
+       unsigned long DiallingnumLength; /**< Length of BCD number/SSC contents */
+       enum tel_sim_ton TypeOfNumber; /**< TON */
+       enum tel_sim_npi NumberingPlanIdentity; /**< NPI */
+       char DiallingNum[SIM_XDN_NUMBER_LEN_MAX + 1]; /**< Dialing Number/SSC String */
+       unsigned char Ext1RecordId; /**< Extensiion1 Record Identifier */
+};
+
+
+struct treq_sim_verify_pins {
+       enum tel_sim_pin_type pin_type;
+       unsigned int pin_length;
+       char pin[9];
+};
+
+struct treq_sim_verify_puks {
+       enum tel_sim_pin_type puk_type;
+       unsigned int puk_length;
+       char puk[9];
+       unsigned int pin_length;
+       char pin[9];
+};
+
+struct treq_sim_change_pins {
+       enum tel_sim_pin_type type;
+       unsigned int old_pin_length;
+       char old_pin[9];
+       unsigned int new_pin_length;
+       char new_pin[9];
+};
+
+struct treq_sim_get_facility_status {
+       enum tel_sim_facility_type type;
+};
+
+struct treq_sim_disable_facility {
+       enum tel_sim_facility_type type;
+       unsigned int password_length;
+       char password[39];
+};
+
+struct treq_sim_enable_facility {
+       enum tel_sim_facility_type type;
+       unsigned int password_length;
+       char password[39];
+};
+
+struct treq_sim_transmit_apdu {
+       unsigned int apdu_length;
+       unsigned char apdu[256];
+};
+
+struct treq_sim_get_atr {
+
+};
+
+struct treq_sim_get_ecc {
+
+};
+
+struct treq_sim_get_language {
+
+};
+
+struct treq_sim_set_language {
+       enum tel_sim_language_type language;
+};
+
+struct treq_sim_set_callforwarding {
+       gboolean voice1;
+       gboolean voice2;
+       gboolean fax;
+       gboolean data;
+       gboolean sms;
+       gboolean allbearer;
+};
+
+struct treq_ssim_get_imsi {
+
+};
+
+struct treq_sim_get_iccid {
+
+};
+
+struct treq_sim_get_mailbox {
+
+};
+
+struct treq_sim_get_callforwarding {
+
+};
+
+struct treq_sim_get_messagewaiting {
+
+};
+
+struct treq_sim_get_cphs_info {
+
+};
+
+struct treq_sim_get_msisdn {
+
+};
+
+struct treq_sim_get_spn {
+
+};
+
+struct treq_sim_get_spdi {
+
+};
+
+struct treq_sim_get_opl {
+
+};
+
+struct treq_sim_get_pnn {
+
+};
+
+struct treq_sim_get_cphs_short_netname {
+
+};
+
+struct treq_sim_get_cphs_full_netname {
+
+};
+
+struct treq_sim_req_authentication {
+       enum tel_sim_auth_type auth_type; /**< Authentication type */
+       unsigned int rand_length; /**< the length of RAND */
+       unsigned int autn_length; /**< the length of AUTN. it is not used in case of GSM AUTH */
+       char rand_data[SIM_AUTH_REQ_DATA_LEN_MAX + 1]; /**< RAND data */
+       char autn_data[SIM_AUTH_REQ_DATA_LEN_MAX + 1]; /**< AUTN data. it is not used in case of GSM AUTH */
+};
+
+struct tresp_sim_verify_pins {
+       enum tel_sim_pin_operation_result result;
+       enum tel_sim_pin_type pin_type;
+       int retry_count;
+};
+
+struct tresp_sim_verify_puks {
+       enum tel_sim_pin_operation_result result;
+       enum tel_sim_pin_type pin_type;
+       int retry_count;
+};
+
+struct tresp_sim_change_pins {
+       enum tel_sim_pin_operation_result result;
+       enum tel_sim_pin_type pin_type;
+       int retry_count;
+};
+
+struct tresp_sim_get_facility_status {
+       enum tel_sim_pin_operation_result result;
+       enum tel_sim_facility_type type;
+       gboolean b_enable;
+};
+
+struct tresp_sim_disable_facility {
+       enum tel_sim_pin_operation_result result;
+       enum tel_sim_facility_type type;
+       int retry_count;
+};
+
+struct tresp_sim_enable_facility {
+       enum tel_sim_pin_operation_result result;
+       enum tel_sim_facility_type type;
+       int retry_count;
+};
+
+struct tresp_sim_transmit_apdu {
+       enum tel_sim_access_result result;
+       unsigned int apdu_resp_length;
+       unsigned char apdu_resp[256 + 2];
+};
+
+struct tresp_sim_get_atr {
+       enum tel_sim_access_result result;
+       unsigned int atr_length;
+       unsigned char atr[256 + 2];
+};
+
+struct tel_sim_ecc {
+       char ecc_num[SIM_ECC_BYTE_LEN_MAX * 2 + 1]; /**< Emergency Call Code info-ECC is coded in BCD format. null termination used*/
+       char ecc_string[SIM_ECC_STRING_LEN_MAX + 1]; /**< Alphabet identifier. null termination used*/
+       enum tel_sim_emergency_service_type ecc_category; /**< ECC emergency service information */
+};
+
+struct tel_sim_ecc_list {
+       int ecc_count;
+       struct tel_sim_ecc ecc[SIM_ECC_RECORD_CNT_MAX];
+};
+
+struct tel_sim_language {
+       int language_count;
+       enum tel_sim_language_type language[SIM_LANG_CNT_MAX];
+};
+
+struct tresp_sim_set_language {
+       enum tel_sim_access_result result;
+};
+
+struct tresp_sim_set_callforwarding {
+       enum tel_sim_access_result result;
+};
+
+struct tel_sim_iccid {
+       char iccid[SIM_ICCID_LEN_MAX + 1];
+};
+
+struct tel_sim_mailbox {
+       gboolean b_cphs;
+       struct tel_sim_dialing_number voice1; /**< voice1 mailbox */
+       struct tel_sim_dialing_number voice2; /**< voice2 mailbox */
+       struct tel_sim_dialing_number fax; /**< FAX mailbox */
+       struct tel_sim_dialing_number video; /**< video mailbox */
+};
+
+struct tel_sim_callforwarding {
+       gboolean voice1; /**< voice1 cf status */
+       gboolean voice2; /**< voice2 cf status */
+       gboolean fax; /**< fax cf status */
+       gboolean data; /**< data cf status */
+       gboolean sms; /**< sms cf status */
+       gboolean allbearer; /**< allbearer cf status */
+};
+
+struct tel_sim_messagewaiting {
+       gboolean b_cphs;
+       union {
+               struct tel_sim_mw mw;
+               struct tel_sim_cphs_mw cphs_mw;
+       } mw_data_u;
+};
+
+struct tel_sim_msisdn {
+       unsigned char num[SIM_XDN_NUMBER_LEN_MAX + 1];
+       enum tel_sim_ton ton;
+       unsigned char name[SIM_XDN_ALPHA_ID_LEN_MAX + 1];
+};
+
+struct tel_sim_msisdn_list {
+       int count;
+       struct tel_sim_msisdn msisdn[SIM_MSISDN_RECORD_CNT_MAX];
+};
+
+struct tel_sim_spn {
+       unsigned char display_condition; /**< display condition (1 byte) */
+       unsigned char spn[SIM_SPN_LEN_MAX + 1]; /**< SPN */
+};
+
+struct tel_sim_spdi {
+       int plmn_count;
+       struct {
+               unsigned char plmn[6+1];
+       }list[SIM_SPDI_PLMN_MAX];
+};
+
+struct tel_sim_opl {
+       unsigned char plmn[6+1];
+       unsigned short lac_from;
+       unsigned short lac_to;
+       unsigned char rec_identifier;
+};
+
+struct tel_sim_opl_list {
+       int opl_count;
+       struct tel_sim_opl opl[SIM_OPL_PNN_RECORD_CNT_MAX];
+};
+
+struct tel_sim_pnn{
+       unsigned char full_name[SIM_NW_FULL_NAME_LEN_MAX + 1];
+       unsigned char short_name[SIM_NW_FULL_NAME_LEN_MAX + 1];
+};
+
+struct tel_sim_pnn_list {
+       int pnn_count;
+       struct tel_sim_pnn pnn[SIM_OPL_PNN_RECORD_CNT_MAX];
+};
+
+struct tel_sim_cphs_short_netname {
+       unsigned char short_name[SIM_CPHS_OPERATOR_NAME_SHORT_FORM_LEN_MAX+1];
+};
+
+struct tel_sim_cphs_full_netname {
+       unsigned char full_name[SIM_CPHS_OPERATOR_NAME_LEN_MAX+1];
+};
+
+struct tel_sim_oplmnwact {
+       unsigned char plmn[6+1];
+       gboolean b_umts;
+       gboolean b_gsm;
+};
+
+struct tel_sim_oplmnwact_list {
+       int opwa_count;
+       struct tel_sim_oplmnwact opwa[SIM_OPLMNWACT_LEN_MAX];
+};
+
+struct tresp_sim_read {
+       enum tel_sim_access_result result;
+       union {
+               struct tel_sim_ecc_list ecc;
+               struct tel_sim_language language;
+               struct tel_sim_iccid iccid;
+               struct tel_sim_mailbox mailbox;
+               struct tel_sim_callforwarding cf;
+               struct tel_sim_messagewaiting mw;
+               struct tel_sim_cphs_info cphs;
+               struct tel_sim_msisdn_list msisdn_list;
+               struct tel_sim_spn spn;
+               struct tel_sim_spdi spdi;
+               struct tel_sim_opl_list opl;
+               struct tel_sim_pnn_list pnn;
+               struct tel_sim_cphs_short_netname cphs_s_name;
+               struct tel_sim_cphs_full_netname cphs_f_name;
+               struct tel_sim_oplmnwact_list opwa;
+       } data;
+};
+
+struct tresp_sim_req_authentication {
+       enum tel_sim_access_result result;
+       enum tel_sim_auth_type auth_type; /**< authentication type */
+       enum tel_sim_auth_result auth_result; /**< authentication result */
+       unsigned int resp_length; /**< response length. IMS and 3G case, it stands for RES_AUTS. GSM case, it stands for SRES. */
+       char resp_data[SIM_AUTH_RESP_DATA_LEN_MAX + 1]; /**< response data. IMS and 3G case, it stands for RES_AUTS. GSM case, it stands for SRES. */
+       unsigned int authentication_key_length; /**< the length of authentication key, Kc*/
+       char authentication_key[SIM_AUTH_RESP_DATA_LEN_MAX + 1]; /**< the data of of authentication key, Kc*/
+       unsigned int cipher_length; /**< the length of cipher key length */
+       char cipher_data[SIM_AUTH_RESP_DATA_LEN_MAX + 1]; /**< cipher key */
+       unsigned int integrity_length; /**< the length of integrity key length */
+       char integrity_data[SIM_AUTH_RESP_DATA_LEN_MAX + 1]; /**< integrity key */
+};
+
+struct tnoti_sim_status {
+       enum tel_sim_status sim_status;
+       gboolean b_changed;
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/type/sms.h b/include/type/sms.h
new file mode 100644 (file)
index 0000000..457e7dc
--- /dev/null
@@ -0,0 +1,959 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_SMS_H__
+#define __TYPE_SMS_H__
+
+__BEGIN_DECLS
+
+/*
+       TREQ_SMS_SEND_UMTS_MSG,
+       TREQ_SMS_READ_MSG,
+       TREQ_SMS_SAVE_MSG,
+       TREQ_SMS_DELETE_MSG,
+       TREQ_SMS_GET_COUNT,
+       TREQ_SMS_GET_SCA,
+       TREQ_SMS_SET_SCA,
+       TREQ_SMS_GET_CB_CONFIG,
+       TREQ_SMS_SET_CB_CONFIG,
+       TREQ_SMS_SET_MEM_STATUS,
+       TREQ_SMS_GET_PREF_BEARER,
+       TREQ_SMS_SET_PREF_BEARER,
+       TREQ_SMS_SET_DELIVERY_REPORT,
+       TREQ_SMS_SET_MSG_STATUS,
+       TREQ_SMS_GET_PARAMS,
+       TREQ_SMS_SET_PARAMS,
+       TREQ_SMS_GET_PARAMCNT,
+       TREQ_SMS_SEND_CDMA_MSG,
+
+       TREQ_PS_ACTIVATE_CONTEXT,
+       TREQ_PS_DEACTIVATE_CONTEXT,
+       TREQ_PS_PDP_ACTIVATE,
+       TREQ_PS_PDP_DEACTIVATE,
+       TREQ_PS_SET_DORMANT,
+       TREQ_PS_SET_PORT_LIST,
+       TREQ_PS_GET_PORT_LIST,
+       TREQ_PS_DUN_PIN_CONTROL,
+*/
+
+#define SMS_SMSP_ADDRESS_LEN                                   20              /* EF-SMSP digit length */
+#define SMS_SMDATA_SIZE_MAX                                    165             /* Maximum SMS data size that can be stored*/
+#define SMS_GSM_SMS_CBMI_LIST_SIZE_MAX         50              /* Maximum GSM SMS CBMI list size*/
+#define SMS_SMSP_ALPHA_ID_LEN_MAX                      128             /* EF-SMSP alpha id length */
+#define SMS_MAXLENGTH_SMS_ADDRESS                      32              /* MAX sms destination(or origination ) address /call back number */
+#define SMS_MAXLENGTH_SMS_MO_USER_DATA         160             /* Maximum MO user data  size*/
+#define SMS_MAXLENGTH_SMS_MT_USER_DATA         160             /* Maximum MT user data  size*/
+#define SMS_MAX_EFSMSP_RECORD_LENGTH           156             /* Maximum number of bytes SMSP Record size (Y + 28), y : 0 ~ 128 */
+
+/*==================================================================================================
+                                            MACROS
+==================================================================================================*/
+/* NetText */
+#define SMS_MSG_SIZE_MAX                                               918             /**< Maximum Message Size */
+#define SMS_CB_SIZE_MAX                                                93              /** Maximum CB Message Size */
+#define SMS_ADDRESS_LEN_MAX                                    20              /* Nettext Address Length */
+#define SMS_SCADDRESS_LEN_MAX                          18              /* SC Address Length */
+
+#define SMS_CB_PAGE_SIZE_MAX                                   9               /**< CB maximum page size*/
+#define SMS_GSM_SMS_MSG_NUM_MAX                                90              /**< Maximum GSM SMS message number*/
+#define SMS_GSM_SMS_CBMI_LIST_SIZE_MAX         50              /**< Maximum GSM SMS CBMI list size*/
+#define SMS_SMDATA_SIZE_MAX                                    165             /**< Maximum SMS data size that can be stored*/
+#define SMS_MAX_SMS_SERVICE_CENTER_ADDR                12              /**<Maximum SMS service center address*/
+#define SMS_MAX_INDEX                                                  25              /**< Maximum index value for SMS */
+
+#define SMS_SMSP_PARAMS_MAX_LEN                                28
+
+// ************************  CDMA Features  **************************//
+#define SMS_PARAM_TELESERVICE_MASK                                     1 << 0  /**< Teleservice parameter bit position */
+#define SMS_PARAM_SERVICE_CATEGORY_MASK                                1 << 1  /**< Service Category parameter bit position */
+#define SMS_PARAM_ADDRESS_MASK                                         1 << 2  /**< Address parameter bit position */
+#define SMS_PARAM_SUBADDRESS_MASK                                      1 << 3  /**< Subaddress parameter bit position */
+#define SMS_PARAM_BEARER_REPLY_MASK                                    1 << 4  /**< Bearer reply parameter bit position */
+#define SMS_PARAM_CAUSE_CODES_MASK                                     1 << 5  /**< Cause Code parameter bit position */
+#define SMS_PARAM_MESSAGE_ID_MASK                                      1 << 6  /**< Message ID parameter bit position */
+#define SMS_PARAM_USER_DATA_MASK                                       1 << 7  /**< User Data parameter bit position */
+#define SMS_PARAM_USER_RESPONSE_CODE_MASK                      1 << 8  /**< User Response Code parameter bit position */
+#define SMS_PARAM_MC_TIME_STAMP_MASK                           1 << 9  /**< Message Center Timestamp parameter bit position */
+#define SMS_PARAM_VALIDITY_PERIOD_ABS_MASK                     1 << 10 /**< Valid period Absolute parameter bit position */
+#define SMS_PARAM_VALIDITY_PERIOD_REL_MASK                     1 << 11 /**< Valid period Relative parameter bit position */
+#define SMS_PARAM_DEFERRED_DELIVERY_ABS_MASK           1 << 12 /**< Deferred delivery absolute parameter bit position */
+#define SMS_PARAM_DEFERRED_DELIVERY_REL_MASK           1 << 13 /**< Deferred delivery relative parameter bit position */
+#define SMS_PARAM_PRIORITY_MASK                                                1 << 14 /**< Priority parameter bit position */
+#define SMS_PARAM_PRIVACY_MASK                                         1 << 15 /**< Privacy parameter bit position */
+#define SMS_PARAM_REPLY_OPTION_MASK                                    1 << 16 /**< Reply Option parameter bit position */
+#define SMS_PARAM_NUMBER_OF_MESSAGE_MASK                       1 << 17 /**< Number of message parameter bit position */
+#define SMS_PARAM_ALERT_ON_DELIVERY_MASK                       1 << 18 /**< Alert on delivery parameter bit position */
+#define SMS_PARAM_LANGUAGE_MASK                                                1 << 19 /**< Language parameter bit position */
+#define SMS_PARAM_CALLBACK_MASK                                                1 << 20 /**< Callback Number parameter bit position */
+#define SMS_PARAM_DISPLAY_MODE_MASK                                    1 << 21 /**< Display mode parameter bit position */
+#define SMS_PARAM_MULTI_ENCODING_USER_DATA_MASK        1 << 22 /**< Multi Encoding user data parameter bit position */
+
+#define SMS_MAXLENGTH_SMS_MT_USER_DATA                         160             /**< Maximum MT user data  size*/
+#define SMS_MAXLENGTH_SMS_MO_USER_DATA                         160             /**< Maximum MO user data  size*/
+
+#define SMS_MAXLENGTH_SMS_ADDRESS                                      32              /**< MAX sms destination(or origination ) address /call back number */
+
+#define SMS_ERR_CLASS0_STATUS_SEND_OK                                                          0       /**< send success */
+#define SMS_ERR_CLASS23_ADDRESS_VACANT                                                         0       /**< address vacant */
+#define SMS_ERR_CLASS23_ADDRESS_TRANSLATION_FAILURE                            1       /**< address translation failure */
+#define SMS_ERR_CLASS23_NETWORK_RESOURCE_SHORTAGE                                      2       /**< network resource shortage */
+#define SMS_ERR_CLASS23_NETWORK_FAILURE                                                                3       /**< network failure */
+#define SMS_ERR_CLASS23_INVALID_TELESERVICE_ID                                         4       /**< invalid teleservice id */
+#define SMS_ERR_CLASS23_OTHER_NETWORK_PROBLEM                                          5       /**< other network problem */
+#define SMS_ERR_CLASS23_OTHER_NETWORK_PROBLEM_MORE_FIRST                       6       /**< other network problem more first */
+#define SMS_ERR_CLASS23_OTHER_NETWORK_PROBLEM_MORE_LAST                        31      /**< other network problem more last */
+#define SMS_ERR_CLASS23_NO_PAGE_RESPONSE                                                       32      /**< no page response */
+#define SMS_ERR_CLASS23_DESTINATION_BUSY                                                       33      /**< destination busy */
+#define SMS_ERR_CLASS23_NO_ACK                                                                         34      /**< no ack */
+#define SMS_ERR_CLASS23_DESTINATION_RESOURCE_SHORTAGE                          35      /**< destination resource shortage */
+#define SMS_ERR_CLASS23_SMS_DELIVERY_POSTPONED                                         36      /**< sms delivery postponed */
+#define SMS_ERR_CLASS23_DESTINATION_OUT_OF_SERVICE                                     37      /**< destination out of service */
+#define SMS_ERR_CLASS23_DESTINATION_NO_LONGER_AT_THIS_ADDRESS  38      /**< destination no longer at this address */
+#define SMS_ERR_CLASS23_OTHER_TERMINAL_PROBLEM                                         39      /**< other terminal problem */
+#define SMS_ERR_CLASS23_OTHER_TERMINAL_PROBLEM_MORE_FIRST              40      /**< other terminal problem more first */
+#define SMS_ERR_CLASS23_OTHER_TERMINAL_PROBLEM_MORE_LAST                       47      /**< other terminal problem more last */
+#define SMS_ERR_CLASS23_SMS_DELIVERY_POSTPONED_MORE_FIRST                      48      /**< sms delivery postpone more first */
+#define SMS_ERR_CLASS23_SMS_DELIVERY_POSTPONED_MORE_LAST                       63      /**< sms delivery postpone more last */
+#define SMS_ERR_CLASS23_RADIO_IF_RESOURCE_SHORTAGE                                     64      /**< radio interface resource shortage */
+#define SMS_ERR_CLASS23_RADIO_IF_INCOMPATIBLE                                          65      /**< radio interface incompatible */
+#define SMS_ERR_CLASS23_OTHER_RADIO_IF_PROBLEM                                         66      /**< other radio interface problem */
+#define SMS_ERR_CLASS23_OTHER_RADIO_IF_PROBLEM_MORE_FIRST                      67      /**< other radio interface problem more first */
+#define SMS_ERR_CLASS23_OTHER_RADIO_IF_PROBLEM_MORE_LAST                       95      /**< other radio interface problem more last */
+#define SMS_ERR_CLASS23_UNEXPECTED_PARM_SIZE                                           96      /**< unexpected parameter size */
+#define SMS_ERR_CLASS23_SMS_ORIGINATION_DENIED                                         97      /**< sms origination denied */
+#define SMS_ERR_CLASS23_SMS_TERMINATION_DENIED                                         98      /**< sms termination denied */
+#define SMS_ERR_CLASS23_SUPPL_SERVICE_NOT_SUPPORTED                            99      /**< supplementary service not supported */
+#define SMS_ERR_CLASS23_SMS_NOT_SUPPORTED                                                      100     /**< sms not supported */
+#define SMS_ERR_CLASS23_RESERVED_101                                                                   101     /**< reserved 101 */
+#define SMS_ERR_CLASS23_MISSING_EXPECTED_PARM                                          102     /**< missing expected parameter */
+#define SMS_ERR_CLASS23_MISSING_MANDATORY_PARM                                 103     /**< missing mandatory parameter value */
+#define SMS_ERR_CLASS23_UNRECOGNIZED_PARM_VALUE                                        104     /**< unrecognized parameter value */
+#define SMS_ERR_CLASS23_UNEXPECTED_PARM_VALUE                                          105     /**< unexpected parameter value */
+#define SMS_ERR_CLASS23_USER_DATA_SIZE_ERROR                                           106     /**< user data size error */
+#define SMS_ERR_CLASS23_OTHER_GENERAL_PROBLEMS                                         107     /**< other general problem */
+#define SMS_ERR_CLASS23_OTHER_GENERAL_PROBLEMS_MORE_FIRST              108     /**< other general problem first */
+#define SMS_ERR_CLASS23_OTHER_GENERAL_PROBLEMS_MORE_LAST                       255     /**< other general problem last */
+
+#define SMS_ERR_CLASS4_WAITING_FOR_TL_ACK                                                      1       /**< waiting for transport ack */
+#define SMS_ERR_CLASS4_OUT_OF_RESOURCES                                                                2       /**< out of resource */
+#define SMS_ERR_CLASS4_ACCESS_TOO_LARGE                                                                3       /**< access to large */
+#define SMS_ERR_CLASS4_DTC_TOO_LARGE                                                                   4       /**< DTC too large */
+#define SMS_ERR_CLASS4_DTC_CONNECTED                                                                   5       /**< DTC connected */
+#define SMS_ERR_CLASS4_NETWORK_NOT_READY                                                       6       /**< network not ready */
+#define SMS_ERR_CLASS4_NO_SVC                                                                                  7       /**< no service */
+#define SMS_ERR_CLASS4_PHONE_NOT_READY                                                         8       /**< phone not ready */
+#define SMS_ERR_CLASS4_NOT_ALLOWED_IN_AMPS                                                     9       /**< fail to allowed in amps */
+#define SMS_ERR_CLASS4_CANNOT_SEND_BROADCAST                                           10      /**< fail to send broadcast */
+#define SMS_ERR_CLASS4_INVALID_TRANSACTION_ID
+// ********************************************************************//
+
+/*==================================================================================================
+                                             ENUMS
+==================================================================================================*/
+/**
+ * @enum telephony_sms_MsgStatus_t
+ * This enumeration defines the network text status type.
+ */
+enum telephony_sms_MsgStatus {
+       SMS_STATUS_READ,                                                /**< MT message, stored and read */
+       SMS_STATUS_UNREAD,                                      /**< MT message, stored and unread */
+       SMS_STATUS_SENT,                                                /**< MO message, stored and  sent */
+       SMS_STATUS_UNSENT,                                      /**< MO message, stored but not sent */
+       SMS_STATUS_DELIVERED,                                   /**< delivered destination */
+       SMS_STATUS_DELIVERY_UNCONFIRMED,        /**< Service centre forwarded message but is unable to confirm delivery*/
+       SMS_STATUS_MESSAGE_REPLACED,            /**< Message has been replaced*/
+       SMS_STATUS_RESERVED                                     /**< Reserved for future use*/
+};
+
+/**
+ * @enum telephony_sms_MemStatusType
+ * This enumeration defines the memory status type.
+ */
+enum telephony_sms_MemStatusType {
+       SMS_PDA_MEMORY_STATUS_AVAILABLE = 0x01, /**< PDA Memory Available */
+       SMS_PDA_MEMORY_STATUS_FULL                      = 0x02,  /**< PDAMemory is Full */
+       SMS_PHONE_MEMORY_STATUS_AVAILABLE       = 0x03, /**< Phone memory Available */
+       SMS_PHONE_MEMORY_STATUS_FULL            = 0x04, /**< phone memory is full */
+};
+
+/**
+ * @enum telephony_sms_BearerType_t
+ * This enum defines the different bearer types
+ */
+enum telephony_sms_BearerType {
+       SMS_BEARER_PS_ONLY = 0x01,       /**< Send SMS only on PS Bearer */
+       SMS_BEARER_CS_ONLY,                  /**< Send SMS only on CS Bearer */
+       SMS_BEARER_PS_PREFERRED,        /**<Send SMS preferably on PS Bearer*/
+       SMS_BEARER_CS_PREFERRED ,       /**<Send SMS preferably on CS Bearer*/
+       SMS_NO_PREFERRED_BEARER         /**<SMS is sent based on default preferred bearer set at OEM based on vendor/operator preference*/
+};
+
+
+/**
+* @enum telephony_sms_CbMsgType_t
+* This enumeration defines the different CB message types.
+*/
+enum telephony_sms_CbMsgType {
+          SMS_CB_MSG_CBS = 1,          /**< Cell broadcast message */
+          SMS_CB_MSG_SCHEDULE, /**< CB Schedule message  */
+          SMS_CB_MSG_CBS41,            /**< CBS41 type message  */
+          SMS_CB_MSG_INVALID           /**< Invalid  CB message */
+};
+
+
+/**
+ * @enum telephony_sms_Response_t
+ * This enum defines the different response types that come in the
+ * sent status acknowledgement/notification after sending a message to the network
+ */
+enum telephony_sms_Response {
+       SMS_SENDSMS_SUCCESS = 0x00,                                     /**<Message send success*/
+       SMS_ROUTING_NOT_AVAILABLE,                                      /**< Message routing not available*/
+       SMS_INVALID_PARAMETER,                                          /**< Invalid parameter present in TPDU*/
+       SMS_DEVICE_FAILURE,                                                     /**< Device failure*/
+       SMS_SERVICE_RESERVED,                                                   /**< Reserved Service*/
+       SMS_INVALID_LOCATION,                                                   /**< Invalid location*/
+       SMS_NO_SIM,                                                             /**< No SIM error*/
+       SMS_SIM_NOT_READY,                                                      /**< SIM not ready error*/
+       SMS_NO_NETWORK_RESP,                                                    /**< No response from network*/
+       SMS_DEST_ADDRESS_FDN_RESTRICTED,                        /**< Destination address restricted*/
+       SMS_SCADDRESS_FDN_RESTRICTED,                           /**< Service center address restricted*/
+       SMS_RESEND_ALREADY_DONE,                                        /**< Resend a operation already done*/
+       SMS_SCADDRESS_NOT_AVAILABLE,                            /**< SCA address not available*/
+       SMS_UNASSIGNED_NUMBER = 0x8001,                         /**< Unassigned number*/
+       SMS_OPERATOR_DETERMINED_BARRING = 0x8008,       /**< Operator determined barring*/
+       SMS_CALL_BARRED = 0x800A,                                               /**< Call barred*/
+       SMS_MESSAGE_TRANSFER_REJECTED = 0x8015,         /**< Message transfer rejected*/
+       SMS_MEMORY_CAPACITY_EXCEEDED = 0x8016,          /**< Memory capacity exceeded/memory full*/
+       SMS_DESTINAITION_OUTOFSERVICE = 0x801B,         /**< Destination number/address out of service*/
+       SMS_UNSPECIFIED_SUBSCRIBER = 0x801C,                    /**< Unspecified subscriber*/
+       SMS_FACILITY_REJECTED = 0x801D,                         /**< Facility rejected*/
+       SMS_UNKNOWN_SUBSCRIBER = 0x801E,                                /**< Unknown subscriber*/
+       SMS_NETWORK_OUTOFORDER = 0x8026,                        /**< Network out of order*/
+       SMS_TEMPORARY_FAILURE = 0x8029,                         /**< Temporary failure*/
+       SMS_CONGESTION = 0x802A,                                                /**< Congestion happened*/
+       SMS_RESOURCES_UNAVAILABLE = 0x802F,                     /**< Resource unavailable*/
+       SMS_FACILITY_NOT_SUBSCRIBED = 0x8032,                   /**< Facility not subscribed by the user*/
+       SMS_FACILITY_NOT_IMPLEMENTED = 0x8045,          /**< Facility not implemented*/
+       SMS_INVALID_REF_VALUE = 0x8051,                         /**< Invalid reference value*/
+       SMS_INVALID_MSG = 0x805F,                                               /**< Invalid message*/
+       SMS_INVALID_MANDATORY_INFO = 0x8060,                    /**< Invalid Mandatory information*/
+       SMS_MESSAGE_TYPE_NOT_IMPLEMENTED = 0x8061,      /**< Message type not implemented*/
+       SMS_MESSAGE_NOT_COMPAT_PROTOCOL = 0x8062,       /**< Message not compact protocol*/
+       SMS_IE_NOT_IMPLEMENTED = 0x8063,                         /**< Information element not implemented*/
+       SMS_PROTOCOL_ERROR = 0x806F,                                    /**< Protocol error*/
+       SMS_INTERWORKING = 0x807F,                                      /**< Networking error*/
+       SMS_ME_FULL = 0x8080,                                                   /**< SMS ME FULL */
+       SMS_SIM_FULL = 0x8081,                                                  /**< SMS SIM FULL */
+       SMS_TIMEOUT                                                                     /**< Timeout error */
+};
+
+ /** @enum  telephony_sms_Cause_t
+ * This enum defines the different cause types that come in the
+ * sent status acknowledgement/notification after sending a message to the network
+ */
+
+enum telephony_sms_Cause {
+
+       SMS_SUCCESS,                                            /**< SMS Operation successful*/
+       SMS_INVALID_PARAMETER_FORMAT,    /**< Invalid format for some parameters passed in Data package information(TPDU)*/
+       SMS_PHONE_FAILURE,                              /**<SMS operation failed due to Modem failure*/
+       SMS_SIM_BUSY,                                           /**< SMS SIM operation cannot be performed as SIM is busy with some other operation*/
+       SMS_SIM_FAILURE,                                        /**< SMS SIM operation cannot be performed due to SIM failure */
+       SMS_UNKNOWN,                                            /**< unknown error*/
+       SMS_MEMORY_FAILURE,                             /**< Error while accessing memory or allocation of memory for SMS operation.*/
+       SMS_OPERATION_NOT_SUPPORTED     /**< operation not allowed/supported*/
+} ;
+
+/**
+ * @enum telephony_sms_SetResponse
+ * This defines the response values
+ */
+enum telephony_sms_SetResponse {
+       SMS_CBSETCONFIG_RSP,                    /**<  cellbroadcast config response */
+       SMS_SETPREFERREDBEARER_RSP,     /**<  set preferred bearer response */
+       SMS_SETPARAMETERS_RSP,          /**<  set parameter response */
+       SMS_SETMEMORYSTATUS_RSP,        /**<   set memory status response*/
+       SMS_SETMESSAGESTATUS_RSP,       /**<   set message status response*/
+       SMS_SETDEVICESTATUS_RSP,                /**<   set device status response*/
+       SMS_SETSCADDR_RSP,                      /**<   set SCA address response */
+       SMS_SET_RSP_MAX                         /**<   maximum limit*/
+};
+
+
+
+/**
+ * This structure defines the fields related to an Sms like SIM index, TPDU  and length
+ */
+struct telephony_sms_DataPackageInfo {
+       unsigned char   sca[SMS_SMSP_ADDRESS_LEN];                      /* Service Centre address - an optional parameter. If this parameter is not present, then this field will be Null.If present, the valid service centre address information is filled as per 3GPP TS23.040 9.1.2.5 Address fields */
+       int                     msgLength;                                                      /* Size of array szData (which is actual TPDU message) */
+       unsigned char tpduData[SMS_SMDATA_SIZE_MAX + 1];        /* SMS TPDU message */
+};
+
+/**
+ *This structure defines the data Related to SimIndex,MessageStatus and SMS Data Stored.
+ */
+struct telephony_sms_Data {
+       int                                                                     simIndex;       /**< Index where SMS is stored. */
+       enum telephony_sms_MsgStatus                    msgStatus;      /**< Message status.*/
+       struct telephony_sms_DataPackageInfo    smsData;        /**<SMS message */
+};
+
+struct telephony_sms_AddressInfo {
+       unsigned int    dialNumLen;                                                             /* length of address. If Service center address is not set, then this will be zero */
+       int                     typeOfNum;                                                              /* Type of number*/
+       int                     numPlanId;                                                              /* Numbering plan identification*/
+       unsigned char diallingNum[SMS_SMSP_ADDRESS_LEN + 1];    /* destination address. If Address not set, then set to 0xFF */
+};
+
+/**
+ * This structure defines different fields involved in setting the parameters of
+ * a particular sms in EFsmsp.
+ */
+struct telephony_sms_Params {
+
+       unsigned char                                   recordIndex;                                            /**< Index*/
+       unsigned char                                   recordLen;                                                      /**< SMS Parameter Record length*/
+       unsigned long                                           alphaIdLen;                                                     /**< Alpha id length */
+       char                                                    szAlphaId[SMS_SMSP_ALPHA_ID_LEN_MAX + 1];       /**< Alpha id .It is a unique identifier for each row/record in EFsmsp */ //JYGU: TAPI_SIM_SMSP_ALPHA_ID_LEN_MAX 128
+       unsigned char                                   paramIndicator;                                         /**< SMS parameter indicator is a 1 byte value. Each bit in this value indicates the presence/absence of the sms header parameters.If the parameter is present the corresponding bit value is set to 0.If the parameter is absent then it is set as 1.Refer 3GPP TS 31.02 :4.4.23 */
+       struct telephony_sms_AddressInfo        tpDestAddr;                                                     /**< TP-destination address (TP-DA) */
+       struct telephony_sms_AddressInfo        tpSvcCntrAddr;                                          /**< TP-service center address */
+       unsigned short                                  tpProtocolId;                                           /**< TP-protocol Id */
+       unsigned short                                  tpDataCodingScheme;                             /**< TP-data coding scheme */
+       unsigned short                                  tpValidityPeriod;                                               /**< TP-validity period */
+};
+
+/**
+ * This structure defines the different parameters that are related to the message count
+ *in a particular memory(Phone/SIM)
+ */
+struct telephony_sms_StoredMsgCountInfo {
+       unsigned int    totalCount;                                                             /**< Total count of messages stored in SIM*/
+       int                     usedCount;                                                              /**< Stored message count in SIM in SIM*/
+       int                     indexList[SMS_GSM_SMS_MSG_NUM_MAX];     /**< Message index list stored in SIM. And the maximum size of this array can be of totalCount.This array contains the list of index values in which the messages are stored.i.e. index_list[totalcount] = [2,3] denotes that indexs 2 and 3 are stored(valid) and others not(empty).*/
+};
+
+/**
+ * This structure defines a cell broadcast message.
+ */
+struct telephony_sms_CbMsg {
+
+       enum telephony_sms_CbMsgType    cbMsgType;                                                      /**< Cell Broadcast  message type */
+       unsigned short                                  length;                                                                 /**<Size of array szMsgData (which is actual TPDU message) */
+       char                                                    msgData[SMS_CB_PAGE_SIZE_MAX + 1]; /**<Cell broadcast message data[Refer 3GPP TS 23.041 9.4.1]*/
+};
+
+/**
+ * This structure defines the different parameters of  CB configuration
+ */
+struct telephony_sms_CbConfig {
+       int                             bCBEnabled;             /**< CB service state. If cb_enabled is true then cell broadcast service will be enabled and underlying modem will enable CB Channel to receiving CB messages. Otherwise CB service will be disabled, underlying modem will deactivate the CB channel. (enabled/disabled) */
+       unsigned char   selectedId;             /**< CBMI Identifier selected (all or some)  */
+       unsigned char   msgIdMaxCount;  /**< CB Channel List Max Count */
+       int                             msgIdCount;             /**< CB message ID count */
+       unsigned short  msgIDs[SMS_GSM_SMS_CBMI_LIST_SIZE_MAX]; /**< CB message ID information */
+};
+
+
+// ************************  CDMA Features  **************************//
+ /** @enum  telephony_sms_Is637AlertPriority_t
+ * This enum defines the type of alerts used to distinguish different priorities
+ * of the message
+ */
+enum telephony_sms_Is637AlertPriority {
+       SMS_ALERT_PRIORITY_DEFAULT = 0, /* Mobile default alert */
+       SMS_ALERT_PRIORITY_LOW,                 /* Low priority alert */
+       SMS_ALERT_PRIORITY_MEDIUM,              /* Medium priority alert */
+       SMS_ALERT_PRIORITY_HIGH,                        /* High priority alert */
+};
+
+ /** @enum  telephony_sms_Is637Privacy_t
+ * This enum defines the desired privacy level of the message
+ */
+enum telephony_sms_Is637Privacy {
+       SMS_PRIVACY_NOT_RESTRICTED = 0, /* Not restricted */
+       SMS_PRIVACY_RESTRICTED,                 /* Restricted */
+       SMS_PRIVACY_CONFIDENTIAL,               /* Confidential */
+       SMS_PRIVACY_SECRET,                             /* Secret */
+};
+
+ /** @enum  telephony_sms_Is637Priority_t
+ * This enum defines the priority level of the message
+ */
+enum telephony_sms_Is637Priority {
+       SMS_PRIORITY_NORMAL = 0,                /* Normal */
+       SMS_PRIORITY_INTERACTIVE,               /* Interactive */
+       SMS_PRIORITY_URGENT,                    /* Urgent */
+       SMS_PRIORITY_EMERGENCY,         /* Emergency */
+};
+
+ /** @enum  telephony_sms_Is637LangIndicator_t
+ * This enum defines the language of the message so that the receiving mobile station can
+ * discard those messages that are not in the user's preferred language
+ */
+enum telephony_sms_Is637LangIndicator {
+       SMS_LANG_UNKNOWN = 0x0,                 /* Unknown or unspecified */
+       SMS_LANG_ENGLISH,                               /* English */
+       SMS_LANG_FRENCH,                                /* French */
+       SMS_LANG_SPANISH,                               /* Spanish */
+       SMS_LANG_JAPANESE,                      /* Japanese */
+       SMS_LANG_KOREAN,                                /* Korean */
+       SMS_LANG_CHINESE,                               /* Chinese */
+       SMS_LANG_HEBREW,                                /* Hebrew */
+};
+
+ /** @enum  telephony_sms_Is637MsgDisplayMode_t
+ * This enum defines the display mode to the mobile station when to display the received message
+ */
+enum telephony_sms_Is637MsgDisplayMode {
+       SMS_MSG_DISPLAY_IMMEDIATE = 0x0,                /* The mobile station is to display the received message as soon as possible */
+       SMS_MSG_DISPLAY_DEFAULT,                                /* he mobile station is to display the received message based on a pre-defined mode in the mobile station. */
+       SMS_MSG_DISPLAY_USER_INVOKE = 0x3,      /* The mobile station is to display the received message based on the mode selected by the user. */
+       SMS_MSG_DISPLAY_RESERVED,                       /* Reserved */
+};
+
+ /** @enum  telephony_sms_Is637ErrorClass_t
+ * This enum defines the error report class
+ */
+enum telephony_sms_Is637ErrorClass {
+       SMS_MSG_ERROR_CLASS_NONE = 0x0,                                         /* None error(for SMS ack) */
+       SMS_MSG_ERROR_CLASS_TEMPORARY_ERROR = 0x2,                      /* Temporary error(for SMS ack) */
+       SMS_MSG_ERROR_CLASS_PERMANENT_ERROR = 0x3,                      /* Permanent error(for SMS ack) */
+       SMS_MSG_ERROR_CLASS_PHONE_INTERNAL_ERROR = 0x4, /* Phone Internal Status (for Send status) */
+};
+
+ /** @enum  telephony_sms_BroadCastCategory_t
+ * This enum defines the Broadcast Service Category
+ */
+enum telephony_sms_BroadCastCategory {
+       SMS_CATEGORY_UNKNOWN            = 0x00,                 /* Unknown category */
+       SMS_CATEGORY_EMERGENCY          = 0x01,                 /* Emergency category */
+       SMS_CATEGORY_ADMIN                      = 0x02,                 /* Admin category */
+       SMS_CATEGORY_MAINTENANCE        = 0x03,                 /* Maintenance category */
+       SMS_CATEGORY_GEN_NEWS_LOC       = 0x04,                 /* General News(Local) category */
+       SMS_CATEGORY_GEN_NEWS_REG       = 0x05,                 /* General News(Regional) category */
+       SMS_CATEGORY_GEN_NEWS_NAT       = 0x06,                 /* General News(National) category */
+       SMS_CATEGORY_GEN_NEWS_INT       = 0x07,                 /* General News(International) category */
+       SMS_CATEGORY_FIN_NEWS_LOC       = 0x08,                 /* Business/Financial News(Local) category */
+       SMS_CATEGORY_FIN_NEWS_REG       = 0x09,                 /* Business/Financial News(Regional) category */
+       SMS_CATEGORY_FIN_NEWS_NAT       = 0x0A,                 /* Business/Financial News(National) category */
+       SMS_CATEGORY_FIN_NEWS_INT       = 0x0B,                 /* Business/Financial News(International) category */
+       SMS_CATEGORY_SPT_NEWS_LOC       = 0x0C,                 /* Sports News(Local) category */
+       SMS_CATEGORY_SPT_NEWS_REG       = 0x0D,                 /* Sports News(Regional) category */
+       SMS_CATEGORY_SPT_NEWS_NAT       = 0x0E,                 /* Sports News(National) category */
+       SMS_CATEGORY_SPT_NEWS_INT       = 0x0F,                 /* Sports News(International) category */
+       SMS_CATEGORY_ENT_NEWS_LOC       = 0x10,                 /* Entertainment News(Local) category */
+       SMS_CATEGORY_ENT_NEWS_REG       = 0x11,                 /* Entertainment News(Regional) category */
+       SMS_CATEGORY_ENT_NEWS_NAT       = 0x12,                 /* Entertainment News(National) category */
+       SMS_CATEGORY_ENT_NEWS_INT       = 0x13,                 /* Entertainment News(International) category */
+       SMS_CATEGORY_LOC_WEATHER        = 0x14,                 /* Local Weather category */
+       SMS_CATEGORY_AREA_TRAFFIC       = 0x15,                 /* Area Traffic Reports category */
+       SMS_CATEGORY_AIRPORT_SCHED      = 0x16,                 /* Local Airport Flight Schedules category */
+       SMS_CATEGORY_RESTAURANTS        = 0x17,                 /* Restaurants category */
+       SMS_CATEGORY_LODGINGS           = 0x18,                 /* Lodgings category */
+       SMS_CATEGORY_RETAILS                    = 0x19,                 /* Retail Directory category */
+       SMS_CATEGORY_ADS                                = 0x1A,                 /* Advertisements category */
+       SMS_CATEGORY_STOCK_QUOTES       = 0x1B,                 /* Stock Quotes category */
+       SMS_CATEGORY_JOBS                       = 0x1C,                 /* Employment Opportunities category */
+       SMS_CATEGORY_MEDICAL                    = 0x1D,                 /* Medical/Health/Hospitals category */
+       SMS_CATEGORY_TECH_NEWS          = 0x1E,                 /* Technology News category */
+       SMS_CATEGORY_MULTI                      =  0x1F,                        /* Multi-category */
+};
+
+/** @enum  telephony_sms_MsgType_t
+ * This enum defines the type of IS637 message
+ */
+enum telephony_sms_CdmaMsgType {
+       SMS_MESSAGETYPE_DELIVER = 0x01,                         /* sms deliver message  */
+       SMS_MESSAGETYPE_SUBMIT = 0x02,                          /* sms submit message  */
+       SMS_MESSAGETYPE_CANCEL = 0x03,                          /* sms cancellation message  */
+       SMS_MESSAGETYPE_DELIVERY_ACK = 0x04,                    /* sms delivery acknowledgment message  */
+       SMS_MESSAGETYPE_USER_ACK = 0x05,                                /* sms user acknowledgment message  */
+} telephony_sms_CdmaMsgType_e;
+
+/** @enum  telephony_sms_Is637DigitMode_t
+ * This enum defines the type of address whether it is 4-bit mode or 8-bit mode
+ */
+enum telephony_sms_Is637DigitMode {
+       SMS_DIGITMODE_4BITDTMF  = 0x00,         /* 4-bit mode  */
+       SMS_DIGITMODE_8BITCODE  = 0x01,         /* 8-bit mode  */
+};
+
+/** @enum  telephony_sms_Is637NumberMode_t
+ * This enum defines the mode of address number to indicate whether the address type is as defined in ANSI TI.607 or is a data network address
+ */
+enum telephony_sms_Is637NumberMode {
+       SMS_NUMMODE_NONE_DATANETWORK =  0x00,   /* in ANSI TI.607 */
+       SMS_NUMMODE_DATANETWORK = 0x01,                 /* in Data Network */
+};
+
+/** @enum  telephony_sms_Is637NumberType_t
+ * This enum defines the type of address
+ */
+enum telephony_sms_Is637NumberType {
+       SMS_NUMBER_TYPE_UNKNOWN         = 0x00,         /*  Unknown */
+       SMS_NUMBER_TYPE_INTERNATIONAL   = 0x01,         /*  International number*/
+       SMS_NUMBER_TYPE_NATIONAL                = 0x02,         /*  National number */
+       SMS_NUMBER_TYPE_NETWORK         = 0x03,         /*  Abbreviated number */
+       SMS_NUMBER_TYPE_SUBSCRIBER              = 0x04,         /* Abbreviated number */
+       SMS_NUMBER_TYPE_RESERVED_5              = 0x05,         /*  Reserved */
+       SMS_NUMBER_TYPE_ABBREVIATED             = 0x06,         /*  Abbreviated number */
+       SMS_NUMBER_TYPE_RESERVED_7              = 0x07,         /*  Reserved */
+       SMS_NUMBER_TYPE_IP                              = 0x11,         /*  Internet Protocol(RFC 791) */
+       SMS_NUMBER_TYPE_EMAILADDR               = 0x12,         /*  Internet Email Address(RFC 822) */
+} telephony_sms_Is637NumberType_e;
+
+/** @enum  telephony_sms_Is637NumberPlan_t
+ * This enum defines the plan of address
+ */
+enum telephony_sms_Is637NumberPlan {
+       SMS_NUMBER_PLAN_UNKNOWN         = 0x00, /*  Unknown */
+       SMS_NUMBER_PLAN_TELEPHONY               = 0x01, /* ISDN/Telephony numbering plan */
+       SMS_NUMBER_PLAN_RESERVED_2              = 0x02, /*  Reserved */
+       SMS_NUMBER_PLAN_DATA                    = 0x03, /* Data numbering plan */
+       SMS_NUMBER_PLAN_TELEX                   = 0x04, /* CTelex numbering plan */
+       SMS_NUMBER_PLAN_RESERVED_5              = 0x05, /*  Reserved */
+       SMS_NUMBER_PLAN_RESERVED_6              = 0x06, /*  Reserved */
+       SMS_NUMBER_PLAN_RESERVED_7              = 0x07, /*  Reserved */
+       SMS_NUMBER_PLAN_RESERVED_8              = 0x08, /*  Reserved */
+       SMS_NUMBER_PLAN_PRIVATE                 = 0x09, /*  Private numbering plan */
+       SMS_NUMBER_PLAN_RESERVED_10     = 0x0A, /*  Reserved */
+       SMS_NUMBER_PLAN_RESERVED_11     = 0x0B, /*  Reserved */
+       SMS_NUMBER_PLAN_RESERVED_12     = 0x0C, /*  Reserved */
+       SMS_NUMBER_PLAN_RESERVED_13     = 0x0D, /*  Reserved */
+       SMS_NUMBER_PLAN_RESERVED_14     = 0x0E, /*  Reserved */
+       SMS_NUMBER_PLAN_RESERVED_15     = 0x0F, /*  Reserved */
+};
+
+/** @enum  telephony_sms_Is637SubAddressType_t
+ * This enum defines the plan of address
+ */
+enum telephony_sms_Is637SubAddressType {
+
+       SMS_SUBADDR_NSAP                                = 0x00, /**< NSAP ( CCITT Recommendation X.213 or ISO 8348 AD2 ) */
+       SMS_SUBADDR_USER_SPECIFIED      = 0x01, /**<  User-specified */
+};
+
+/**
+ *  This structure defines cause code as an indication whether an SMS error has occurred and
+ *  if so, whether the condition is considered temporary or permanent
+ **/
+struct telephony_sms_Is637CauseCode {
+       unsigned char                                           ReplySeqNumber; /* Reply sequence number */
+       enum telephony_sms_Is637ErrorClass      ErrClass;                       /* Error report class */
+       unsigned char                                                   Cause;                          /* Error cause identifier */
+};
+
+/**
+ * This structure defines the parameters of address and its type
+ */
+struct telephony_sms_Is637Address {
+       enum telephony_sms_Is637DigitMode               Digit;                  /* Digit mode indicator (0x00:4bit_dtmf, 0x01:8bit_code) */
+       enum telephony_sms_Is637NumberMode      NumberMode;     /* Number mode indicator (0x00:ANSI TI607, 0x01:Data network) */
+       enum telephony_sms_Is637NumberType      NumberType;     /* Type of number */
+       enum telephony_sms_Is637NumberPlan      NumberPlan;     /* Numbering plan */
+       unsigned char                                           szAddrLength;   /* The number of CHARi */
+       unsigned char                                           szAddress[SMS_MAXLENGTH_SMS_ADDRESS]; /* The address digit or character */
+};
+
+/**
+ * This structure defines the parameters of subaddress of originator and destination
+ */
+struct telephony_sms_Is637SubAddress {
+       enum telephony_sms_Is637SubAddressType  SubType;                /* Subaddress type */
+       unsigned char                                                   Odd;                    /* Odd/even indicator */
+       unsigned char                                                   szAddrLength;   /* The number of CHARi */
+       unsigned char                                                   szAddress[SMS_MAXLENGTH_SMS_ADDRESS]; /* A subaddress octet */
+};
+
+/**
+ * This structure defines the message center time stamp may be include
+ * with SMS message sent from a message center
+ */
+struct telephony_sms_TimeStamp {
+       unsigned int    year;           /* Year - if the year is 2002, the year field contains 0x02 */
+       unsigned int    month;          /* Month (1 ~ 12) */
+       unsigned int    day;            /* Day (1 ~ 31) */
+       unsigned int    hours;          /* Hours (0 ~ 23) */
+       unsigned int    minutes;        /* Minute (0 ~ 59) */
+       unsigned int    seconds;        /* Seconds (0 ~ 59) */
+};
+
+/**
+ * The structure defines the parameter of SMS submit message
+ */
+struct telephony_sms_Is637OutSubmit {
+       struct telephony_sms_Is637Address               DstAddr; /* Destination address */
+       struct telephony_sms_Is637SubAddress    DstSubAddr; /* Destination subaddress */
+       unsigned short                                          TeleService; /* Teleservice Identifier */
+       int                                                                     bBearerReplySeqRequest; /* Bearer reply sequence request */
+       unsigned char                                                   ReplySeqNumber; /* Reply sequence number */
+       unsigned short                                          MsgId; /* Message identifier */
+       unsigned short                                          MsgEncoding; /* Message encoding (defined in TSB-58A) */
+       unsigned short                                          MsgLength; /* Message length */
+       unsigned char                                                   szData[SMS_MAXLENGTH_SMS_MO_USER_DATA]; /* SMS user data */
+       struct telephony_sms_TimeStamp          ValidityPeriodAbs; /* Validity period - Absolute (not supported) */
+       unsigned char                                                   ValidityPeriodRel; /* Validity period - Relative (not supported) */
+       struct telephony_sms_TimeStamp          DeferredDelTimeAbs; /* Deferred delivery time - Absolute */
+       unsigned char                                                   DeferredDelTimeRel; /* Deferred delivery time - Relative */
+       enum telephony_sms_Is637Priority                Priority; /* Priority indicator */
+       enum telephony_sms_Is637Privacy         Privacy; /* Privacy indicator */
+       int                                                                     bUserAckRequest; /* User acknowledge request */
+       int                                                                     bDeliveryAckRequest; /* Delivery acknowledge request */
+       enum telephony_sms_Is637AlertPriority   AlertPriority; /* Alert priority of message */
+       enum telephony_sms_Is637LangIndicator   MsgLang; /* Language indicator */
+       struct telephony_sms_Is637Address               CallBackNumber; /* Callback number address */
+};
+
+/**
+ * The structure defines the parameter of SMS acknowledgement message for submit
+ */
+struct telephony_sms_Is637OutAck {
+       struct telephony_sms_Is637Address               DstAddr; /* Destination address */
+       struct telephony_sms_Is637SubAddress    DstSubAddr; /* Destination subaddress */
+       unsigned short                                          TeleService; /* Teleservice Identifier */
+       int                                                                     bBearerReplySeqRequest; /* Bearer reply sequence request */
+       unsigned char                                           ReplySeqNumber; /* Reply sequence number */
+       unsigned short                                          MsgId; /* Message identifier */
+       unsigned short                                          MsgEncoding; /* Message encoding (defined in TSB-58A) */
+       unsigned short                                          MsgLength; /* Message length */
+       unsigned char                                                   szData[SMS_MAXLENGTH_SMS_MO_USER_DATA]; /* SMS user data */
+       unsigned char                                                   UserResponseCode; /* User response code */
+};
+
+/**
+ * The structure defines the parameter of SMS cancellation message
+ */
+struct telephony_sms_Is637OutCancel {
+       struct telephony_sms_Is637Address               DstAddr; /* Destination address */
+       struct telephony_sms_Is637SubAddress    DstSubAddr; /* Destination subaddress */
+       unsigned short                                          TeleService; /* Teleservice Identifier */
+       int                                                                     bBearerReplySeqRequest; /* Bearer reply sequence request */
+       unsigned char                                                   ReplySeqNumber; /* Reply sequence number */
+       unsigned short                                          MsgId; /* Message identifier */
+};
+
+/**
+ * The structure defines the parameter of SMS devivery message
+ */
+struct telephony_sms_Is637InDeliver {
+       struct telephony_sms_Is637Address                       OrigAddr; /* Origination address */
+       struct telephony_sms_Is637SubAddress            OrigSubAddr; /* Origination subaddress */
+       unsigned short                                                  TeleService; /* Teleservice Identifier */
+       int                                                                             bBearerReplySeqRequest; /* Bearer reply sequence request */
+       unsigned char                                                           ReplySeqNumber; /* Reply sequence number */
+       unsigned short                                                  MsgId; /* Message identifier */
+       unsigned short                                                  MsgEncoding; /* Message encoding (defined in TSB-58A) */
+       unsigned short                                                  MsgLength; /* Message length */
+       unsigned char                                                           szData[SMS_MAXLENGTH_SMS_MT_USER_DATA]; /* SMS user data */
+       struct telephony_sms_TimeStamp                  MessageCenterTimeStamp; /* Message center time stamp */
+       struct telephony_sms_TimeStamp                  ValidityPeriodAbs; /* Validity period - Absolute */
+       unsigned char                                                           ValidityPeriodRel; /* Validity period - Relative */
+       struct telephony_sms_TimeStamp                  DeferredDelTimeAbs; /* Deferred delivery time - Absolute (not supported) */
+       unsigned char                                                           DeferredDelTimeRel; /* Deferred delivery time - Relative (not supported) */
+       enum telephony_sms_Is637Priority                        Priority; /* Priority indicator */
+       enum telephony_sms_Is637Privacy                 Privacy; /* Privacy indicator */
+       unsigned char                                                           NumMsg; /* Number of voice mail (0-99) */
+       int                                                                             bUserAckRequest; /* User acknowledge request */
+       int                                                                             bDeliveryAckRequest; /* Delivery acknowledge request */
+       enum telephony_sms_Is637AlertPriority           AlertPriority; /* Alert priority of message */
+       enum telephony_sms_Is637LangIndicator           MsgLang; /* Language indicator */
+       struct telephony_sms_Is637Address                       CallBackNumer; /* Callback number address */
+       enum telephony_sms_Is637MsgDisplayMode  Display; /* Message display mode */
+};
+
+/**
+ * The structure defines the parameter of SMS acknowledge message for deliver
+ */
+struct telephony_sms_Is637InAck {
+       struct telephony_sms_Is637Address               OrigAddr; /* Origination address */
+       struct telephony_sms_Is637SubAddress    OrigSubAddr; /* Origination subaddress */
+       unsigned short                                          TeleService; /* Teleservice Identifier */
+       int                                                                     bBearerReplySeqRequest; /* Bearer reply sequence request */
+       unsigned char                                                   ReplySeqNumber; /* Reply sequence number */
+       unsigned short                                          MsgId; /* Message identifier */
+       unsigned short                                          MsgEncoding; /* Message encoding (defined in TSB-58A) */
+       unsigned short                                          MsgLength; /* Message length */
+       unsigned char                                                   szData[SMS_MAXLENGTH_SMS_MT_USER_DATA]; /* SMS user data */
+       unsigned char                                                   UserResponseCode; /* User response code */
+       struct telephony_sms_TimeStamp          MessageCenterTimeStamp; /* Message center time stamp */
+};
+
+/**
+ * The structure defines the parameter of SMS acknowledge message from message center
+ */
+struct telephony_sms_Is637InDeliverAck {
+       struct telephony_sms_Is637Address               OrigAddr; /* Origination address */
+       struct telephony_sms_Is637SubAddress    OrigSubAddr; /* Origination subaddress */
+       unsigned short                                          TeleService; /* Teleservice Identifier */
+       int                                                                     bBearerReplySeqRequest; /* Bearer reply sequence request */
+       unsigned char                                                   ReplySeqNumber; /* Reply sequence number */
+       unsigned short                                          MsgId; /* Message identifier */
+       unsigned short                                          MsgEncoding; /* Message encoding (defined in TSB-58A) */
+       unsigned short                                          MsgLength; /* Message length */
+       unsigned char                                                   szData[SMS_MAXLENGTH_SMS_MT_USER_DATA]; /* SMS user data */
+       struct telephony_sms_TimeStamp          MessageCenterTimeStamp; /* Message center time stamp */
+};
+
+/**
+ * The structure defines the parameter of SMS broadcast message
+ */
+struct telephony_sms_Is637InBroadCast {
+       enum telephony_sms_BroadCastCategory            ServiceCategory; /* Broadcast service category */
+       unsigned short                                                  MsgId; /* Message identifier */
+       int                                                                             bBearerReplySeqRequest; /* Bearer reply sequence request */
+       unsigned char                                                           ReplySeqNumber; /* Reply sequence number */
+       unsigned short                                                  MsgEncoding; /* Message encoding (defined in TSB-58A) */
+       unsigned short                                                  MsgLength; /* Message length */
+       unsigned char                                                           szData[SMS_MAXLENGTH_SMS_MT_USER_DATA]; /* SMS user data */
+       struct telephony_sms_TimeStamp                  MessageCenterTimeStamp; /* Message center time stamp */
+       struct telephony_sms_TimeStamp                  ValidityPeriodAbs; /* Validity period - Absolute */
+       unsigned char                                                           ValidityPeriodRel; /* Validity period - Relative */
+       enum telephony_sms_Is637Priority                        Priority; /* Priority indicator */
+       enum telephony_sms_Is637AlertPriority           AlertPriority; /* Alert priority of message */
+       enum telephony_sms_Is637LangIndicator           MsgLang; /* Language indicator */
+       enum telephony_sms_Is637MsgDisplayMode  Display; /* Message display mode */
+} telephony_sms_Is637InBroadCast_t;
+
+
+/**
+ * The structure defines the type of SMS message as union
+ */
+union telephony_sms_CdmaMessage_u {
+       struct telephony_sms_Is637OutSubmit     outSubmit;              /* Outgoing Submit message */
+       struct telephony_sms_Is637OutAck                outAck;                 /* Outgoing Acknowledge message */
+       struct telephony_sms_Is637OutCancel     outCancel;              /* Outgoing Cancel message */
+       struct telephony_sms_Is637InDeliver             inDeliver;              /* Incoming Delivery message */
+       struct telephony_sms_Is637InAck         inAck;                  /* Incoming Acknowledge message */
+       struct telephony_sms_Is637InDeliverAck  inDeliverAck;   /* Incoming Delivery Acknowledge message */
+       struct telephony_sms_Is637InBroadCast   inBc;                   /* Incoming Broadcast message */
+};
+
+/**
+ * The structure defines the parameter of entire SMS message of each type
+ */
+struct telephony_sms_CdmaMsgInfo {
+       int                                                                     ParamMask; /**< Parameter ID mask */
+       enum telephony_sms_CdmaMsgType          MsgType; /**< Message type */
+       union telephony_sms_CdmaMessage_u       MsgData; /**< Message data */
+};
+
+/*-----------------------------------------------------------------------------------------------------------------*/
+/*-----------------------------------------------------------------------------------------------------------------*/
+/*-----------------------------------------------------------------------------------------------------------------*/
+/*-----------------------------------------------------------------------------------------------------------------*/
+/*-----------------------------------------------------------------------------------------------------------------*/
+
+
+/*---------------------------------*/
+/*                Structs of Requests              */
+/*---------------------------------*/
+struct treq_sms_send_umts_msg {
+       struct telephony_sms_DataPackageInfo    msgDataPackage;
+       int                                                                     more;
+};
+
+struct treq_sms_send_cdma_msg {
+       struct telephony_sms_CdmaMsgInfo        cdmaMsgInfo;
+       unsigned int                                            more;
+};
+
+struct treq_sms_read_msg {
+       int     index;
+};
+
+struct treq_sms_save_msg {
+       int                                                                     simIndex;                       /* Index where SMS is stored. */
+       enum telephony_sms_MsgStatus                    msgStatus;
+       struct telephony_sms_DataPackageInfo    msgDataPackage;
+};
+
+struct treq_sms_delete_msg {
+       int     index;
+};
+
+struct treq_sms_get_msg_count {
+};
+
+struct treq_sms_get_sca {
+       int     index;
+};
+
+struct treq_sms_set_sca {
+       struct telephony_sms_AddressInfo        scaInfo;
+       int                                                             index;
+};
+
+struct treq_sms_get_cb_config {
+};
+
+struct treq_sms_set_cb_config {
+       int                             bCBEnabled;                                                                     /* CB service state. If cb_enabled is true then cell broadcast service will be enabled and underlying modem will enable CB Channel to receiving CB messages. Otherwise CB service will be disabled, underlying modem will deactivate the CB channel. (enabled/disabled) */
+       unsigned char           selectedId;                                                                     /* CBMI Identifier selected (all or some)  */
+       unsigned char           msgIdMaxCount;                                                          /* CB Channel List Max Count */
+       int                             msgIdCount;                                                                     /* CB message ID count */
+       unsigned short  msgIDs[SMS_GSM_SMS_CBMI_LIST_SIZE_MAX]; /* CB message ID information */
+};
+
+struct treq_sms_set_mem_status {
+       int     memory_status;
+};
+
+struct treq_sms_get_pref_brearer {
+};
+
+struct treq_sms_set_pref_brearer {
+       int     svc;
+};
+
+struct treq_sms_set_delivery_report {
+       struct telephony_sms_DataPackageInfo    dataInfo;
+       int                                                                     rspType;
+};
+
+struct treq_sms_set_msg_status {
+       int                                                     index;
+       enum telephony_sms_MsgStatus    msgStatus;
+};
+
+struct treq_sms_get_params {
+       int     index;
+};
+
+struct treq_sms_set_params {
+       struct telephony_sms_Params     params;
+};
+
+struct treq_sms_get_paramcnt {
+};
+
+/*----------------------------------*/
+/*                Structs of Responses              */
+/*----------------------------------*/
+struct tresp_sms_send_umts_msg {
+       struct telephony_sms_DataPackageInfo    dataInfo;
+       int                                                                     result;
+};
+
+struct tresp_sms_read_msg {
+       struct telephony_sms_Data       dataInfo;
+       int                                             result;
+};
+
+struct tresp_sms_save_msg {
+       int     index;
+       int     result;
+};
+
+struct tresp_sms_delete_msg {
+       int     index;
+       int     result;
+};
+
+struct tresp_sms_get_storedMsgCnt {
+       struct telephony_sms_StoredMsgCountInfo storedMsgCnt;
+       int                                                                             result;
+};
+
+struct tresp_sms_get_sca {
+       struct telephony_sms_AddressInfo        scaAddress;
+       int                                                             result;
+};
+
+struct tresp_sms_set_sca {
+       int     result;
+};
+
+struct tresp_sms_get_cb_config {
+       struct telephony_sms_CbConfig   cbConfig;
+       int                                                     result;
+};
+
+struct tresp_sms_set_cb_config {
+       int     result;
+};
+
+struct tresp_sms_set_mem_status {
+       int     result;
+};
+
+struct tresp_sms_get_pref_brearer {
+};
+
+struct tresp_sms_set_pref_brearer {
+       int     svc;
+};
+
+struct tresp_sms_set_delivery_report {
+       int     result;
+};
+
+struct tresp_sms_set_msg_status {
+       int     result;
+};
+
+struct tresp_sms_get_params {
+       struct telephony_sms_Params     paramsInfo;
+       int                                                     result;
+};
+
+struct tresp_sms_set_params {
+       int     result;
+};
+
+struct tresp_sms_get_paramcnt {
+       int     recordCount;
+       int     result;
+};
+
+struct tresp_sms_send_cdma_msg {
+       struct telephony_sms_Is637CauseCode     causeCode;
+       int                                                                     result;
+};
+
+/*-----------------------------------*/
+/*                Structs of Notifications              */
+/*-----------------------------------*/
+struct tnoti_sms_umts_msg {
+       struct telephony_sms_DataPackageInfo    msgInfo;
+};
+
+struct tnoti_sms_cdma_msg {
+       struct telephony_sms_CdmaMsgInfo        cdmaMsg;
+};
+
+struct tnoti_sms_cellBroadcast_msg {
+       struct telephony_sms_CbMsg      cbMsg;
+};
+
+struct tnoti_sms_memory_status {
+       int     status;
+};
+
+struct tnoti_sms_device_ready_status {
+       int     status;
+};
+
+__END_DECLS
+
+#endif
+
diff --git a/include/type/sound.h b/include/type/sound.h
new file mode 100644 (file)
index 0000000..b9a66d6
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_SOUND_H__
+#define __TYPE_SOUND_H__
+
+__BEGIN_DECLS
+
+#include <glib.h>
+
+enum telephony_sound_path {
+       XXX_SOUND_PATH_HANDSET          = 0x01,
+       XXX_SOUND_PATH_HEADSET,
+       XXX_SOUND_PATH_HANDFREE,
+       XXX_SOUND_PATH_BLUETOOTH,
+       XXX_SOUND_PATH_STEREO_BLUETOOTH,
+       XXX_SOUND_PATH_SPEAKER,
+       XXX_SOUND_PATH_HEADSET_3_5PI,
+       XXX_SOUND_PATH_BT_NSEC_OFF,
+       XXX_SOUND_PATH_MIC1,
+       XXX_SOUND_PATH_MIC2,
+       XXX_SOUND_PATH_HEADSET_HAC,
+};
+
+enum telephony_sound_device {
+       XXX_SOUND_DEVICE_RECEIVER       = 0x10,
+       XXX_SOUND_DEVICE_SPEAKER        = 0x20,
+       XXX_SOUND_DEVICE_HFK            = 0x30,
+       XXX_SOUND_DEVICE_BLUETOOTH      = 0x40,
+       XXX_SOUND_DEVICE_ECHO_CANCELLER = 0xA0,
+};
+
+enum telephony_sound_type {
+       XXX_SOUND_TYPE_VOICE    = 0x1,
+       XXX_SOUND_TYPE_KEYTONE,
+       XXX_SOUND_TYPE_BELL,
+       XXX_SOUND_TYPE_MESSAGE,
+       XXX_SOUND_TYPE_ALARM,
+       XXX_SOUND_TYPE_MISCELLANEOUS,
+};
+
+enum telephony_sound_volume_level {
+       XXX_SOUND_MUTE,
+       XXX_SOUND_VOLUME_LEVEL_1,
+       XXX_SOUND_VOLUME_LEVEL_2,
+       XXX_SOUND_VOLUME_LEVEL_3,
+       XXX_SOUND_VOLUME_LEVEL_4,
+       XXX_SOUND_VOLUME_LEVEL_5,
+       XXX_SOUND_VOLUME_LEVEL_6,
+       XXX_SOUND_VOLUME_LEVEL_7,
+       XXX_SOUND_VOLUME_LEVEL_8,
+       XXX_SOUND_VOLUME_LEVEL_9,
+};
+
+
+struct treq_sound_set_path {
+       enum telephony_sound_path path;
+};
+
+struct treq_sound_set_volume_level {
+       enum telephony_sound_type                       sound;
+       enum telephony_sound_device             device;
+       enum telephony_sound_volume_level       volume;
+};
+
+struct treq_sound_get_volume_level {
+       enum telephony_sound_type                       sound;
+       enum telephony_sound_device             device;
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/type/ss.h b/include/type/ss.h
new file mode 100644 (file)
index 0000000..d242a6e
--- /dev/null
@@ -0,0 +1,278 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TYPE_SS_H__
+#define __TYPE_SS_H__
+
+__BEGIN_DECLS
+
+#include <glib.h>
+
+enum telephony_ss_class {
+
+       SS_CLASS_NONE=0x00,                               /* 0x00 */
+
+       /* TELESERVICE */
+       SS_CLASS_ALL_TELE=0x10,                        /* 0x10 : All Teleservices */
+       SS_CLASS_VOICE=0x11,                              /* 0x11 : All Voice ( telephony ) */
+       SS_CLASS_ALL_DATA_TELE=0x12,             /* 0x12 : All Data Teleservices */
+       SS_CLASS_FAX=0x13,                                /* 0x13 : All Fax Service */
+       SS_CLASS_SMS=0x16,                                /* 0x16 : SMS service  */
+       SS_CLASS_VGCS=0x17,                              /* 0x17 : Voice Group Call Service */
+       SS_CLASS_VBS=0x18,                                /* 0x18 : Voice Broadcast */
+       SS_CLASS_ALL_TELE_EXPT_SMS=0x19,    /* 0x19 : All teleservice except SMS */
+
+       /* BEARER SERVICE */
+       SS_CLASS_ALL_BEARER=0x20,                  /* 0X20 : all bearer services */
+       SS_CLASS_ALL_ASYNC=0x21,                    /* 0x21 : All Async services */
+       SS_CLASS_ALL_SYNC=0x22,                      /* 0x22 : All sync services*/
+       SS_CLASS_ALL_CS_SYNC=0x24,                /* 0x24 : All Circuit switched sync */
+       SS_CLASS_ALL_CS_ASYNC=0x25,              /* 0x25 : All Circuit switched async */
+       SS_CLASS_ALL_DEDI_PS=0x26,                /* 0x26 : All Dedicated packet Access */
+       SS_CLASS_ALL_DEDI_PAD=0x27,              /* 0x27 : All Dedicated PAD Access */
+       SS_CLASS_ALL_DATA_CDA=0x28,             /*0x28 : All Data CDA*/  
+
+       /* PLMN SPECIFIC TELESERVICE */
+       SS_CLASS_PLMN_TELE_ALL = 0x50,         /*0x50 : PLMN specific teleservices*/
+       SS_CLASS_PLMN_TELE_1 = 0x51,              /*0x51 :PLMN specific teleservice 1*/
+       SS_CLASS_PLMN_TELE_2 = 0x52,             /*0x52 : PLMN specific teleservice 2*/
+       SS_CLASS_PLMN_TELE_3 = 0x53,             /*0x53 : PLMN specific teleservice 3*/
+       SS_CLASS_PLMN_TELE_4 = 0x54,             /*0x54 : PLMN specific teleservice 4*/
+       SS_CLASS_PLMN_TELE_5 = 0x55,             /*0x55 : PLMN specific teleservice 5*/
+       SS_CLASS_PLMN_TELE_6 = 0x56,             /*0x56 : PLMN specific teleservice 6*/
+       SS_CLASS_PLMN_TELE_7 = 0x57,             /*0x57 : PLMN specific teleservice 7*/
+       SS_CLASS_PLMN_TELE_8 = 0x58,             /*0x58 : PLMN specific teleservice 8*/
+       SS_CLASS_PLMN_TELE_9 = 0x59,             /*0x59 : PLMN specific teleservice 9*/
+       SS_CLASS_PLMN_TELE_A = 0x60,           /*0x60 :PLMN specific teleservice 10*/
+       SS_CLASS_PLMN_TELE_B = 0x61,           /*0x61 :PLMN specific teleservice 11*/
+       SS_CLASS_PLMN_TELE_C = 0x62,             /*0x62 : PLMN specific teleservice 12*/
+       SS_CLASS_PLMN_TELE_D = 0x63,             /*0x63 : PLMN specific teleservice 13*/
+       SS_CLASS_PLMN_TELE_E = 0x64,             /*0x64 : PLMN specific teleservice 14*/
+       SS_CLASS_PLMN_TELE_F = 0x65,             /*0x65 : PLMN specific teleservice 15*/
+
+       /* PLMN SPECIFIC BEARER SERVICE */
+       SS_CLASS_PLMN_BEAR_ALL = 0x70,         /*0x70 : All PLMN specific bearer services*/
+       SS_CLASS_PLMN_BEAR_1 = 0x71,              /*0x71 :PLMN specific bearer service 1*/
+       SS_CLASS_PLMN_BEAR_2 = 0x72,             /*0x72 : PLMN specific bearer service  2*/
+       SS_CLASS_PLMN_BEAR_3 = 0x73,             /*0x73 : PLMN specific bearer service  3*/
+       SS_CLASS_PLMN_BEAR_4 = 0x74,             /*0x74 : PLMN specific bearer service  4*/
+       SS_CLASS_PLMN_BEAR_5 = 0x75,             /*0x75 : PLMN specific bearer service  5*/
+       SS_CLASS_PLMN_BEAR_6 = 0x76,             /*0x76 : PLMN specific bearer service  6*/
+       SS_CLASS_PLMN_BEAR_7 = 0x77,             /*0x77 : PLMN specific bearer service  7*/
+       SS_CLASS_PLMN_BEAR_8 = 0x78,             /*0x78 : PLMN specific bearer service  8*/
+       SS_CLASS_PLMN_BEAR_9 = 0x79,             /*0x79 : PLMN specific bearer service  9*/
+       SS_CLASS_PLMN_BEAR_A = 0x80,            /*0x80 : PLMN specific bearer service  10*/
+       SS_CLASS_PLMN_BEAR_B = 0x81,             /*0x81 : PLMN specific bearer service  11*/
+       SS_CLASS_PLMN_BEAR_C = 0x82,            /*0x82 : PLMN specific bearer service  12*/
+       SS_CLASS_PLMN_BEAR_D = 0x83,            /*0x83 : PLMN specific bearer service  13*/
+       SS_CLASS_PLMN_BEAR_E = 0x84,             /*0x84 : PLMN specific bearer service  14*/
+       SS_CLASS_PLMN_BEAR_F = 0x85,             /*0x85 : PLMN specific bearer service  15*/
+
+       /* CPHS - AUXILIARY SERVICE */
+       SS_CLASS_AUX_VOICE = 0x89,                      /* 0x89 : All Auxiliary Voice ( Auxiliary telephony ) */
+
+       SS_CLASS_ALL_GPRS_BEARER=0x99,       /* 0x99 : All GPRS bearer services */
+       SS_CLASS_ALL_TELE_BEARER=0xFF,        /* 0xFF : all tele and bearer services */
+};
+
+enum telephony_ss_status {
+       SS_STATUS_REG=0x01,         /* 0x01 : Registration */
+       SS_STATUS_DEREG,              /* 0x02 : De-registration( erase ) */
+       SS_STATUS_ACTIVATE,        /* 0x03 : Activation */
+       SS_STATUS_DEACTIVATE,    /* 0x04 : De-activation */
+       SS_STATUS_MAX
+};
+
+enum telephony_ss_barring_mode {
+       SS_BARR_MODE_NONE,
+       SS_BARR_MODE_BAOC,                /* 0x01 : Barring All Outgoing Calls */
+       SS_BARR_MODE_BOIC,                /* 0x02 : Barring Outgoing International Calls */
+       SS_BARR_MODE_BOIC_NOT_HC, /* 0x03 : Barring Outgoing International Calls
+                                                                except to Home Country */
+       SS_BARR_MODE_BAIC,                /* 0x04 : Barring All Incoming Calls */
+       SS_BARR_MODE_BIC_ROAM,       /* 0x05 : Barring Incoming Calls when roam, 
+                                                                       outside of the Home Country */
+       SS_BARR_MODE_AB,                   /* 0x06 : All Barring Services */
+       SS_BARR_MODE_AOB,                 /* 0x07 : All Outgoing Barring Services */
+       SS_BARR_MODE_AIB,                  /* 0x08 : All Incoming Barring Services */
+       SS_BARR_MODE_BIC_NOT_SIM, /* 0x09 : Barring Incoming Calls which is
+                                                                not stored in the SIM memory */
+       SS_BARR_MODE_MAX
+};
+
+enum telephony_ss_forwarding_mode {
+       SS_CF_MODE_CFU = 0x01, /* 0x01 : Call Forwarding Unconditional */
+       SS_CF_MODE_CFB,        /* 0x02 : Call Forwarding Mobile Busy */
+       SS_CF_MODE_CFNRy,      /* 0x03 : Call Forwarding No Reply */
+       SS_CF_MODE_CFNRc,      /* 0x04 : Call Forwarding Not Reachable */
+       SS_CF_MODE_CF_ALL,     /* 0x05 : All Call Forwarding */
+       SS_CF_MODE_CFC,        /* 0x06 : All Conditional Call Forwarding */
+       SS_CF_MODE_MAX         /* 0x07 : Max */
+};
+
+enum telephony_ss_forwarding_no_reply_time {
+       SS_CF_NO_REPLY_5_SEC    = 5,
+       SS_CF_NO_REPLY_10_SEC   = 10,
+       SS_CF_NO_REPLY_15_SEC   = 15,
+       SS_CF_NO_REPLY_20_SEC   = 20,
+       SS_CF_NO_REPLY_25_SEC   = 25,
+       SS_CF_NO_REPLY_30_SEC   = 30,
+};
+
+enum telephony_ss_cli_type {
+       SS_CLI_TYPE_NONE,
+       SS_CLI_TYPE_CLIP,       /* 0x01 : Calling Line Identification Presentation */
+       SS_CLI_TYPE_CLIR,       /* 0x02 : Calling Line Identification Restriction */
+       SS_CLI_TYPE_COLP,      /* 0x03 : Connected Line Identification Presentation */
+       SS_CLI_TYPE_COLR,      /* 0x04 : Connected Line Identification Restriction */
+       SS_CLI_TYPE_CDIP,       /* 0x05 : Called Line Identification Presentation */
+       SS_CLI_TYPE_CNAP,      /* 0x06 : Calling Name Presentation */
+       SS_CLI_TYPE_MAX
+};
+
+enum telephony_ss_ussd_type {
+       SS_USSD_TYPE_USER_INITIATED=0x01,   /* User Initiated USSD Message */
+       SS_USSD_TYPE_USER_RES,                       /* User Response to Network Initiated Message */
+       SS_USSD_TYPE_USER_RELEASE,               /* SS Termination by user */
+       SS_USSD_TYPE_MAX,
+};
+
+enum telephony_ss_ussd_status {
+       SS_USSD_NO_ACTION_REQUIRE = 0x01,  /* 0x01 : no further user action required
+                                                                                         information needed after mobile initiated operation) */
+       SS_USSD_ACTION_REQUIRE,                     /* 0x02 : further user action required
+                                                                                                          (network initiated USSD Request, or further
+                                                                                                          information needed after mobile initiated operation) */
+       SS_USSD_TERMINATED_BY_NET,              /* 0x03 : USSD terminated by network */
+       SS_USSD_OTHER_CLIENT,                         /* 0x04 : other local client has responded */
+       SS_USSD_NOT_SUPPORT,                          /* 0x05 : operation not supported */
+       SS_USSD_TIME_OUT,                                 /* 0x06 : network time out */
+       SS_USSD_MAX
+};
+
+enum telephony_ss_aoc_type {
+       SS_AOC_TYPE_RESET               =0x00,          /* AoC Reset Message */
+       SS_AOC_TYPE_ACM                 =0x01,          /* Accumulated call meter Message */
+       SS_AOC_TYPE_CCM                 =0x02,          /* Current call meter Message */
+       SS_AOC_TYPE_MAXACM      =0x04,          /* Max Accumulated call meter Message */
+       SS_AOC_TYPE_PUC                 =0x08,          /* Price per unit and currency Message */
+       SS_AOC_TYPE_MAX         =0x10
+};
+
+#define MAX_SS_BARRING_PASSWORD_LEN 4
+struct treq_ss_barring {
+       enum telephony_ss_class class;
+       enum telephony_ss_barring_mode mode;
+       char password[ MAX_SS_BARRING_PASSWORD_LEN ];
+};
+
+struct treq_ss_barring_change_password {
+       char password_old[ MAX_SS_BARRING_PASSWORD_LEN ];
+       char password_new[ MAX_SS_BARRING_PASSWORD_LEN ];
+       char password_confirm[ MAX_SS_BARRING_PASSWORD_LEN ];
+};
+
+#define MAX_SS_FORWARDING_NUMBER_LEN 32
+struct treq_ss_forwarding {
+       enum telephony_ss_class class;
+       enum telephony_ss_forwarding_mode mode;
+       enum telephony_ss_forwarding_no_reply_time time;
+       char number[ MAX_SS_FORWARDING_NUMBER_LEN ];
+};
+
+struct treq_ss_waiting {
+       enum telephony_ss_class class;
+
+};
+
+struct treq_ss_cli {
+       enum telephony_ss_cli_type type;
+};
+
+#define MAX_SS_USSD_LEN 208
+struct treq_ss_ussd {
+       enum telephony_ss_ussd_type type;
+       char str[ MAX_SS_USSD_LEN ];
+};
+
+// response
+
+struct tresp_ss_general {
+       gboolean err;
+};
+
+struct tresp_ss_barring {
+       int record_num;
+       struct barring_info {
+               enum telephony_ss_class class;
+               enum telephony_ss_status status;
+               enum telephony_ss_barring_mode mode;
+       } *record;
+       gboolean err;
+};
+
+struct tresp_ss_forwarding {
+       int record_num;
+       struct forwarding_info {
+               enum telephony_ss_class class;
+               enum telephony_ss_status status;
+               enum telephony_ss_forwarding_mode mode;
+               enum telephony_ss_forwarding_no_reply_time time;
+               gboolean number_present;
+               int              number_type;
+               char     number[ MAX_SS_FORWARDING_NUMBER_LEN ];
+       } *record;
+       gboolean err;
+};
+
+struct tresp_ss_waiting {
+       int record_num;
+       struct waiting_info {
+               enum telephony_ss_class class;
+               enum telephony_ss_status status;
+       } *record;
+       gboolean err;
+};
+
+struct tresp_ss_cli {
+       enum telephony_ss_cli_type type;
+       gboolean status;
+       gboolean err;
+};
+
+struct tresp_ss_ussd {
+       enum telephony_ss_ussd_type type;
+       enum telephony_ss_ussd_status status;
+       char str[ MAX_SS_USSD_LEN ];
+       gboolean err;
+};
+
+
+
+// notification
+
+struct tnoti_ss_ussd {
+       enum telephony_ss_ussd_status status;
+       char str[ MAX_SS_USSD_LEN ];
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/user_request.h b/include/user_request.h
new file mode 100644 (file)
index 0000000..3572074
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_USER_REQUEST_H__
+#define __TCORE_USER_REQUEST_H__
+
+__BEGIN_DECLS
+
+struct tcore_user_info {
+       uid_t uid;
+       gid_t gid;
+       pid_t pid;
+
+       char *appname;
+       unsigned int channel_id;
+       unsigned int client_cmd;
+
+       void *user_data;
+};
+
+typedef void (*UserRequestFreeHook)(UserRequest *ur);
+typedef void (*UserRequestResponseHook)(UserRequest *ur,
+               enum tcore_response_command command,
+               unsigned int data_len, const void *data, void *user_data);
+
+UserRequest*  tcore_user_request_new(Communicator *comm, const char *modem_name);
+void          tcore_user_request_free(UserRequest *ur);
+UserRequest*  tcore_user_request_dup(UserRequest *ur);
+
+TReturn       tcore_user_request_set_free_hook(UserRequest *ur,
+                  UserRequestFreeHook free_hook);
+TReturn       tcore_user_request_set_response_hook(UserRequest *ur,
+                  UserRequestResponseHook resp_hook, void *user_data);
+
+Communicator* tcore_user_request_ref_communicator(UserRequest *ur);
+char*         tcore_user_request_get_modem_name(UserRequest *ur);
+
+TReturn       tcore_user_request_set_user_info(UserRequest *ur,
+                  const struct tcore_user_info *ui);
+const struct tcore_user_info*
+              tcore_user_request_ref_user_info(UserRequest *ur);
+
+TReturn       tcore_user_request_send_response(UserRequest *ur,
+                  enum tcore_response_command command,
+                  unsigned int data_len, const void *data);
+
+TReturn       tcore_user_request_set_command(UserRequest *ur,
+                  enum tcore_request_command command);
+
+enum tcore_request_command
+              tcore_user_request_get_command(UserRequest *ur);
+
+TReturn       tcore_user_request_set_data(UserRequest *ur,
+                  unsigned int data_len, const void *data);
+const void*   tcore_user_request_ref_data(UserRequest *ur,
+                  unsigned int *data_len);
+
+TReturn       tcore_user_request_set_metainfo(UserRequest *ur,
+                  unsigned int metainfo_len, const void *metainfo);
+const void*   tcore_user_request_ref_metainfo(UserRequest *ur,
+                  unsigned int *metainfo_len);
+
+__END_DECLS
+
+#endif
diff --git a/include/util.h b/include/util.h
new file mode 100644 (file)
index 0000000..85fa5fa
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __TCORE_UTIL_H__
+#define __TCORE_UTIL_H__
+
+#include <glib-object.h>
+
+__BEGIN_DECLS
+
+
+enum tcore_util_marshal_data_type {
+       TCORE_UTIL_MARSHAL_DATA_CHAR_TYPE = G_TYPE_CHAR,
+       TCORE_UTIL_MARSHAL_DATA_BOOLEAN_TYPE = G_TYPE_BOOLEAN,
+       TCORE_UTIL_MARSHAL_DATA_INT_TYPE = G_TYPE_INT,
+       TCORE_UTIL_MARSHAL_DATA_DOUBLE_TYPE = G_TYPE_DOUBLE,
+       TCORE_UTIL_MARSHAL_DATA_STRING_TYPE = G_TYPE_STRING,
+       TCORE_UTIL_MARSHAL_DATA_OBJECT_TYPE = G_TYPE_BOXED,
+       TCORE_UTIL_MARSHAL_DATA_STRING_MAX = 0xFF,
+};
+
+
+union tcore_ip4_type {
+       uint32_t i;
+       unsigned char s[4];
+};
+
+enum tcore_dcs_type {
+       TCORE_DCS_TYPE_NONE = 0xff,
+       TCORE_DCS_TYPE_7_BIT = 0x00,
+       TCORE_DCS_TYPE_8_BIT = 0x04,
+       TCORE_DCS_TYPE_UCS2 = 0x08,
+       TCORE_DCS_TYPE_UNSPECIFIED = 0x0F,
+};
+
+TReturn     tcore_util_netif_up(const char *name);
+TReturn     tcore_util_netif_down(const char *name);
+TReturn     tcore_util_netif_set(const char *name, const char *ipaddr,
+                const char *gateway, const char *netmask);
+
+char*       tcore_util_get_string_by_ip4type(union tcore_ip4_type ip);
+
+GHashTable* tcore_util_marshal_create();
+void        tcore_util_marshal_destory(GHashTable *ht);
+
+GHashTable* tcore_util_marshal_deserialize_string(const gchar *serialized_string);
+gchar*      tcore_util_marshal_serialize(GHashTable *ht);
+
+gboolean    tcore_util_marshal_add_data(GHashTable *ht, const gchar *key,
+                const void *data, enum tcore_util_marshal_data_type type);
+gboolean    tcore_util_marshal_get_data(GHashTable *ht, const gchar *key,
+                void **data, enum tcore_util_marshal_data_type type);
+
+gint        tcore_util_marshal_get_int(GHashTable *ht, const gchar *key);
+gchar*      tcore_util_marshal_get_string(GHashTable *ht, const gchar *key);
+GHashTable* tcore_util_marshal_get_object(GHashTable *ht, const gchar *key);
+
+enum tcore_dcs_type
+            tcore_util_get_cbs_coding_scheme(unsigned char encode);
+
+char*       tcore_util_unpack_gsm7bit(const char *src, unsigned int src_len);
+char*       tcore_util_pack_gsm7bit(const char* src, unsigned int src_len);
+
+__END_DECLS
+
+#endif
diff --git a/packaging/libtcore.spec b/packaging/libtcore.spec
new file mode 100644 (file)
index 0000000..02148a7
--- /dev/null
@@ -0,0 +1,50 @@
+#sbs-git:slp/pkgs/l/libtcore
+Name:       libtcore
+Summary:    Telephony-core library
+Version: 0.1.14
+Release:    1
+Group:      System/Libraries
+License:    Apache
+Source0:    libtcore-%{version}.tar.gz
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(dlog)
+
+%description
+Telephony-core library
+
+%package devel
+Summary:        Telephony-core library (Development)
+Requires:       %{name} = %{version}
+Group:          Development/Libraries
+
+%description devel
+Telephony-core library (Development)
+
+%prep
+%setup -q
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+make %{?jobs:-j%jobs}
+
+%post
+/sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%files
+%defattr(-,root,root,-)
+#%doc COPYING
+%{_libdir}/libtcore*
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/*
+%{_libdir}/pkgconfig/tcore.pc
diff --git a/src/co_call.c b/src/co_call.c
new file mode 100644 (file)
index 0000000..7eb1a7a
--- /dev/null
@@ -0,0 +1,1113 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "plugin.h"
+#include "queue.h"
+#include "user_request.h"
+#include "co_call.h"
+
+
+#define _check_null( name, value, err ) { \
+       if ( !value ) { \
+               dbg("[error] %s : NULL", name ); \
+               return err; \
+       } \
+}
+
+struct call_cli_info {
+       enum tcore_call_cli_mode mode;
+       char number[MAX_CALL_NUMBER_LEN];
+       int number_len;
+};
+
+struct call_cna_info {
+       enum tcore_call_cna_mode mode;
+       int dcs;
+       char name[MAX_CALL_NAME_LEN];
+       int name_len;
+};
+
+struct call_object {
+       enum tcore_call_type type;
+       unsigned int id;
+       enum tcore_call_direction direction;
+       enum tcore_call_status status;
+       gboolean mpty;
+       struct call_cli_info cli;
+       struct call_cna_info cna;
+       unsigned int cug_id;
+       unsigned int active_line;
+       struct call_time { // second
+               long start;
+               long end;
+       } time;
+};
+
+struct private_object_data {
+       GSList* cobjs;
+       struct tcore_call_operations *ops;
+       struct tcore_call_control_operations *cops;
+       struct tcore_call_information_operations *iops;
+};
+
+static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
+{
+       enum tcore_request_command command;
+
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->ops", po->ops, TCORE_RETURN_FAILURE);
+       _check_null( "ur", ur, TCORE_RETURN_FAILURE);
+
+       command = tcore_user_request_get_command(ur);
+       switch (command) {
+               case TREQ_CALL_DIAL:
+                       _check_null( "po->ops->dial", po->ops->dial, TCORE_RETURN_FAILURE);
+                       return po->ops->dial(o, ur);
+
+               case TREQ_CALL_ANSWER:
+                       _check_null( "po->ops->answer", po->ops->answer, TCORE_RETURN_FAILURE);
+                       return po->ops->answer(o, ur);
+
+               case TREQ_CALL_END:
+                       _check_null( "po->ops->end", po->ops->end, TCORE_RETURN_FAILURE);
+                       return po->ops->end(o, ur);
+
+               case TREQ_CALL_HOLD:
+                       return po->ops->hold(o, ur);
+
+               case TREQ_CALL_ACTIVE:
+                       return po->ops->active(o, ur);
+
+               case TREQ_CALL_SWAP:
+                       return po->ops->swap(o, ur);
+
+               case TREQ_CALL_JOIN:
+                       return po->ops->join(o, ur);
+
+               case TREQ_CALL_SPLIT:
+                       return po->ops->split(o, ur);
+
+               case TREQ_CALL_DEFLECT:
+                       return po->ops->deflect(o, ur);
+
+               case TREQ_CALL_TRANSFER:
+                       return po->ops->transfer(o, ur);
+
+               case TREQ_CALL_SEND_DTMF:
+                       return po->ops->send_dtmf(o, ur);
+
+               case TREQ_CALL_SET_SOUND_PATH:
+                       return po->ops->set_sound_path(o, ur);
+
+               case TREQ_CALL_GET_SOUND_VOLUME_LEVEL:
+                       return po->ops->get_sound_volume_level(o, ur);
+
+               case TREQ_CALL_SET_SOUND_VOLUME_LEVEL:
+                       return po->ops->set_sound_volume_level(o, ur);
+
+               case TREQ_CALL_MUTE:
+                       return po->ops->mute(o, ur);
+
+               case TREQ_CALL_UNMUTE:
+                       return po->ops->unmute(o, ur);
+
+               case TREQ_CALL_GET_MUTE_STATUS:
+                       return po->ops->get_mute_status(o, ur);
+
+               default:
+                       break;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+static void _free_hook(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+       GSList *list;
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       if (po->cobjs) {
+               for (list = po->cobjs; list; list = list->next) {
+                       if (!list)
+                               continue;
+
+                       if (list->data)
+                               free(list->data);
+
+                       list->data = NULL;
+               }
+
+               g_slist_free(po->cobjs);
+               po->cobjs = NULL;
+       }
+
+       free(po);
+       tcore_object_link_object(o, NULL);
+}
+
+typedef gboolean(*func)(struct call_object* co, void *data);
+static struct call_object *_find_object(GSList *objs, void* data, func compare)
+{
+       struct call_object *co = 0;
+       GSList *l = 0;
+
+       _check_null( "objs", objs, 0);
+       _check_null( "compare", compare, 0);
+
+       l = objs;
+       while (l) {
+               co = (struct call_object*) l->data;
+
+               if (compare(co, data))
+                       return co;
+
+               l = g_slist_next( l );
+       }
+
+       return NULL;
+}
+
+static GSList* _find_object_all(GSList *objs, void* data, func compare)
+{
+       struct call_object *co = 0;
+       GSList *l = 0;
+       GSList *ret = 0;
+
+       _check_null( "objs", objs, 0);
+       _check_null( "compare", compare, 0);
+
+       l = objs;
+       while (l) {
+               co = (struct call_object*) l->data;
+
+               if (compare(co, data))
+                       ret = g_slist_append(ret, co);
+
+               l = g_slist_next( l );
+       }
+
+       return ret;
+}
+
+static gboolean _compare_by_id(struct call_object* co, void *data)
+{
+       unsigned int *id = (unsigned int*) data;
+
+       _check_null( "co", co, FALSE);
+       _check_null( "data", data, FALSE);
+
+       if (co->id == *id)
+               return TRUE;
+
+       return FALSE;
+}
+
+static gboolean _compare_by_status(struct call_object* co, void *data)
+{
+       enum tcore_call_status *ct = (enum tcore_call_status*) data;
+
+       _check_null( "co", co, FALSE);
+       _check_null( "data", data, FALSE);
+
+       if (co->status == *ct)
+               return TRUE;
+
+       return FALSE;
+}
+
+static gboolean _compare_by_number(struct call_object* co, void *data)
+{
+       char *number = (char*) data;
+
+       _check_null( "co", co, FALSE);
+       _check_null( "data", data, FALSE);
+
+       if (!strcmp(co->cli.number, number))
+               return TRUE;
+
+       return FALSE;
+}
+
+static enum tcore_call_cli_mode _check_cli_mode_by_number(char *num)
+{
+       _check_null( "num", num, TCORE_CALL_CLI_MODE_DEFAULT);
+
+       if (!strncmp(num, "*31#", 4))
+               return TCORE_CALL_CLI_MODE_PRESENT;
+
+       if (!strncmp(num, "#31#", 4))
+               return TCORE_CALL_CLI_MODE_RESTRICT;
+
+       return TCORE_CALL_CLI_MODE_DEFAULT;
+}
+
+
+// Call Object API
+
+struct call_object *tcore_call_object_new(CoreObject *o, int id)
+{
+       struct private_object_data *po = 0;
+       struct call_object *co = 0;
+
+       po = tcore_object_ref_object(o);
+
+       _check_null( "po", po, 0);
+
+       co = g_new0( struct call_object, 1 );
+
+       if (id > 0) {
+               if (!_find_object(po->cobjs, (void*) &id, (void*) _compare_by_id))
+                       co->id = id;
+               else {
+                       dbg("[ error ] call object exist already. [ %d ]", id);
+                       g_free(co);
+                       return 0;
+               }
+       }
+       else {
+               int i = 0;
+
+               for (i = 1; i < 6; i++) {
+                       // 6 is MAX call count
+                       if (!_find_object(po->cobjs, (void*) &i, (void*) _compare_by_id)) {
+                               co->id = i;
+                               break;
+                       }
+               }
+       }
+
+       po->cobjs = g_slist_append(po->cobjs, co);
+
+       dbg("new call object id : [%d]", co->id);
+
+       return co;
+}
+
+gboolean tcore_call_object_free(CoreObject *o, struct call_object *co)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       _check_null( "po", po, FALSE);
+       _check_null( "po->cobjs", po->cobjs, FALSE);
+       _check_null( "co", co, FALSE);
+
+       po->cobjs = g_slist_remove(po->cobjs, co);
+
+       if (!co) {
+               dbg("co is not free");
+               g_free(co);
+       }
+       else
+               dbg("co is also free");
+
+       return TRUE;
+}
+
+struct call_object *tcore_call_object_current_on_mt_processing(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+       GSList *l = 0;
+
+       enum tcore_call_status cs = CALL_STATUS_INCOMING;
+
+       po = tcore_object_ref_object(o);
+
+       _check_null( "po", po, 0);
+       _check_null( "po->cobjs", po->cobjs, 0);
+
+       l = _find_object_all(po->cobjs, (void*) &cs, (void*) _compare_by_status);
+       if (!l) {
+               cs = CALL_STATUS_WAITING;
+               l = _find_object_all(po->cobjs, (void*) &cs, (void*) _compare_by_status);
+               if (!l)
+                       return 0;
+       }
+
+       return (struct call_object*) l->data;
+}
+
+struct call_object *tcore_call_object_current_on_mo_processing(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+       GSList *l = 0;
+
+       enum tcore_call_status cs = CALL_STATUS_DIALING;
+
+       po = tcore_object_ref_object(o);
+
+       _check_null( "po", po, 0);
+       _check_null( "po->cobjs", po->cobjs, 0);
+
+       l = _find_object_all(po->cobjs, (void*) &cs, (void*) _compare_by_status);
+       if (!l) {
+               cs = CALL_STATUS_ALERT;
+               l = _find_object_all(po->cobjs, (void*) &cs, (void*) _compare_by_status);
+               if (!l)
+                       return 0;
+       }
+
+       return (struct call_object*) l->data;
+}
+
+struct call_object *tcore_call_object_find_by_id(CoreObject *o, int id)
+{
+       struct private_object_data *po = NULL;
+
+       po = tcore_object_ref_object(o);
+
+       _check_null( "po", po, 0);
+       _check_null( "po->cobjs", po->cobjs, 0);
+
+       return _find_object(po->cobjs, (void*) &id, (void*) _compare_by_id);
+}
+
+struct call_object *tcore_call_object_find_by_number(CoreObject *o, char *num)
+{
+       struct private_object_data *po = NULL;
+
+       po = tcore_object_ref_object(o);
+
+       _check_null( "po", po, 0);
+       _check_null( "po->cobjs", po->cobjs, 0);
+       _check_null( "num", num, 0);
+
+       return _find_object(po->cobjs, (void*) num, (void*) _compare_by_number);
+}
+
+GSList* tcore_call_object_find_by_status(CoreObject *o, enum tcore_call_status cs)
+{
+       struct private_object_data *po = NULL;
+
+       po = tcore_object_ref_object(o);
+
+       _check_null( "po", po, 0);
+       _check_null( "po->cobjs", po->cobjs, 0);
+
+       return _find_object_all(po->cobjs, (void*) &cs, (void*) _compare_by_status);
+}
+
+int tcore_call_object_get_id(struct call_object *co)
+{
+       _check_null( "co", co, -1);
+
+       return co->id;
+}
+
+gboolean tcore_call_object_set_type(struct call_object *co, enum tcore_call_type ct)
+{
+       _check_null( "co", co, FALSE);
+
+       co->type = ct;
+       return TRUE;
+}
+
+enum tcore_call_type tcore_call_object_get_type(struct call_object *co)
+{
+       _check_null( "co", co, -1);
+
+       return co->type;
+}
+
+gboolean tcore_call_object_set_direction(struct call_object *co, enum tcore_call_direction cd)
+{
+       _check_null( "co", co, FALSE);
+
+       co->direction = cd;
+       return TRUE;
+}
+
+enum tcore_call_direction tcore_call_object_get_direction(struct call_object *co)
+{
+       _check_null( "co", co, -1);
+
+       return co->direction;
+}
+
+gboolean tcore_call_object_set_status(struct call_object *co, enum tcore_call_status cs)
+{
+       _check_null( "co", co, FALSE);
+
+       co->status = cs;
+       return TRUE;
+}
+
+enum tcore_call_status tcore_call_object_get_status(struct call_object *co)
+{
+       _check_null( "co", co, -1);
+
+       return co->status;
+}
+
+gboolean tcore_call_object_set_cli_info(struct call_object *co, enum tcore_call_cli_mode mode, char *num)
+{
+       char *pos = 0;
+
+       _check_null( "co", co, FALSE);
+
+       if (!num) {
+               co->cli.mode = mode;
+               return TRUE;
+       }
+
+       dbg("num  : %s", num);
+       dbg("mode : 0x%x", mode);
+
+       pos = num;
+
+       if (!mode) {
+               co->cli.mode = _check_cli_mode_by_number(num);
+
+               if (co->cli.mode)
+                       pos = (num + 4);
+       }
+       else {
+               co->cli.mode = mode;
+       }
+
+       strncpy(co->cli.number, pos, (strlen(pos) + 1));
+       co->cli.number_len = strlen(co->cli.number);
+
+       dbg("co->cli.mode   : 0x%x", co->cli.mode);
+       dbg("co->cli.number : %s", co->cli.number);
+       dbg("co->cli.number_len : %d", co->cli.number_len);
+
+       return TRUE;
+}
+
+int tcore_call_object_get_number(struct call_object *co, char *num)
+{
+       _check_null( "co", co, -1);
+       _check_null( "num", num, -1);
+
+       strncpy(num, co->cli.number, MAX_CALL_NUMBER_LEN);
+       return co->cli.number_len;
+}
+
+enum tcore_call_cli_mode tcore_call_object_get_cli_mode(struct call_object *co)
+{
+       _check_null( "co", co, -1);
+       return co->cli.mode;
+}
+
+gboolean tcore_call_object_set_cna_info(struct call_object *co, enum tcore_call_cna_mode mode, char *name, int dcs)
+{
+       _check_null( "co", co, FALSE);
+       _check_null( "name", name, FALSE);
+
+       co->cna.mode = mode;
+       strncpy(co->cna.name, name, MAX_CALL_NAME_LEN);
+       return TRUE;
+}
+
+int tcore_call_object_get_name(struct call_object *co, char *name)
+{
+       _check_null( "co", co, -1);
+       _check_null( "name", name, -1);
+
+       strncpy(name, co->cna.name, MAX_CALL_NAME_LEN);
+       return co->cna.name_len;
+}
+
+enum tcore_call_cna_mode tcore_call_object_get_cna_mode(struct call_object *co)
+{
+       _check_null( "co", co, -1);
+
+       return co->cna.mode;
+}
+
+gboolean tcore_call_object_set_multiparty_state(struct call_object *co, gboolean is)
+{
+       _check_null( "co", co, FALSE);
+
+       co->mpty = is;
+       return TRUE;
+}
+
+gboolean tcore_call_object_get_multiparty_state(struct call_object *co)
+{
+       _check_null( "co", co, FALSE);
+
+       return co->mpty;
+}
+
+gboolean tcore_call_object_set_active_line(struct call_object *co, unsigned int line)
+{
+       _check_null( "co", co, FALSE);
+
+       co->active_line = line;
+       return TRUE;
+}
+
+int tcore_call_object_get_active_line(struct call_object *co)
+{
+       _check_null( "co", co, -1);
+
+       return co->active_line;
+}
+
+TReturn tcore_call_control_answer_hold_and_accept(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->answer_hold_and_accept(o, ur, cb, user_data);
+}
+
+TReturn tcore_call_control_answer_replace(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->answer_replace(o, ur, cb, user_data);
+}
+
+TReturn tcore_call_control_answer_reject(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->answer_reject(o, ur, cb, user_data);
+}
+
+TReturn tcore_call_control_end_specific(CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb,
+               void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->end_specific(o, ur, id, cb, user_data);
+}
+
+TReturn tcore_call_control_end_all_active(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->end_all_active(o, ur, cb, user_data);
+}
+
+TReturn tcore_call_control_end_all_held(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->end_all_held(o, ur, cb, user_data);
+}
+
+TReturn tcore_call_control_active(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->active(o, ur, cb, user_data);
+}
+
+TReturn tcore_call_control_hold(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->hold(o, ur, cb, user_data);
+}
+
+TReturn tcore_call_control_swap(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->swap(o, ur, cb, user_data);
+}
+
+TReturn tcore_call_control_join(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->join(o, ur, cb, user_data);
+}
+
+TReturn tcore_call_control_split(CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->split(o, ur, id, cb, user_data);
+}
+
+TReturn tcore_call_control_transfer(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->transfer(o, ur, cb, user_data);
+}
+
+TReturn tcore_call_control_deflect(CoreObject* o, UserRequest* ur, const char* number, ConfirmCallback cb,
+               void* user_data)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->cops)
+               return TCORE_RETURN_FAILURE;
+
+       return po->cops->deflect(o, ur, number, cb, user_data);
+}
+
+void tcore_call_control_set_operations(CoreObject *o, struct tcore_call_control_operations *ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       po->cops = ops;
+}
+
+void tcore_call_information_mo_col(CoreObject *o, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mo_call_col(o, number);
+}
+
+void tcore_call_information_mo_waiting(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mo_call_waiting(o);
+}
+
+void tcore_call_information_mo_cug(CoreObject *o, int cug_index)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mo_call_cug(o, cug_index);
+}
+
+void tcore_call_information_mo_forwarded(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mo_call_forwarded(o);
+}
+
+void tcore_call_information_mo_barred_incoming(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mo_call_barred_incoming(o);
+}
+
+void tcore_call_information_mo_barred_outgoing(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mo_call_barred_outgoing(o);
+}
+
+void tcore_call_information_mo_deflected(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mo_call_deflected(o);
+}
+
+void tcore_call_information_mo_clir_suppression_reject(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mo_call_clir_suppression_reject(o);
+}
+
+void tcore_call_information_mo_cfu(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mo_call_cfu(o);
+}
+
+void tcore_call_information_mo_cfc(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mo_call_cfc(o);
+}
+
+void tcore_call_information_mt_cli(CoreObject *o, enum tcore_call_cli_mode mode, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mt_call_cli(o, mode, number);
+}
+
+void tcore_call_information_mt_cna(CoreObject *o, enum tcore_call_cna_mode mode, char* name, int dcs)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mt_call_cna(o, mode, name, dcs);
+}
+
+void tcore_call_information_mt_forwarded_call(CoreObject *o, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mt_call_forwarded_call(o, number);
+}
+
+void tcore_call_information_mt_cug_call(CoreObject *o, int cug_index, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mt_call_cug_call(o, cug_index, number);
+}
+
+void tcore_call_information_mt_deflected_call(CoreObject *o, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mt_call_deflected_call(o, number);
+}
+
+void tcore_call_information_mt_transfered(CoreObject *o, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->mt_call_transfered(o, number);
+}
+
+void tcore_call_information_held(CoreObject *o, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->call_held(o, number);
+}
+
+void tcore_call_information_active(CoreObject *o, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->call_active(o, number);
+}
+
+void tcore_call_information_joined(CoreObject *o, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->call_joined(o, number);
+}
+
+void tcore_call_information_released_on_hold(CoreObject *o, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->call_released_on_hold(o, number);
+}
+
+void tcore_call_information_transfer_alert(CoreObject *o, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->call_transfer_alert(o, number);
+}
+
+void tcore_call_information_transfered(CoreObject *o, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->call_transfered(o, number);
+}
+
+void tcore_call_information_cf_check_ss_message(CoreObject *o, char* number)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+
+       if (!po && !po->iops)
+               return;
+
+       po->iops->call_cf_check_message(o, number);
+}
+
+void tcore_call_information_set_operations(CoreObject *o, struct tcore_call_information_operations *ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       po->iops = ops;
+}
+
+CoreObject *tcore_call_new(TcorePlugin *p, const char *name, struct tcore_call_operations *ops)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name);
+       if (!o)
+               return NULL;
+
+       po = calloc(sizeof(struct private_object_data), 1);
+       if (!po) {
+               tcore_object_free(o);
+               return NULL;
+       }
+
+       po->ops = ops;
+
+       tcore_object_set_type(o, CORE_OBJECT_TYPE_CALL);
+       tcore_object_link_object(o, po);
+       tcore_object_set_free_hook(o, _free_hook);
+       tcore_object_set_dispatcher(o, _dispatcher);
+
+       return o;
+}
+
+void tcore_call_free(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       free(po);
+       tcore_object_free(o);
+}
diff --git a/src/co_context.c b/src/co_context.c
new file mode 100644 (file)
index 0000000..0f69e79
--- /dev/null
@@ -0,0 +1,746 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "util.h"
+#include "plugin.h"
+#include "user_request.h"
+#include "co_context.h"
+
+struct private_object_data {
+       enum co_context_state state;
+       unsigned int id;
+       enum co_context_role role;
+
+       char *apn;
+       char *addr;
+       enum co_context_type type;
+       enum co_context_d_comp d_comp;
+       enum co_context_h_comp h_comp;
+
+       char *username;
+       char *password;
+       char *dns1;
+       char *dns2;
+       enum co_context_auth auth;
+
+       union tcore_ip4_type ip_v4;
+       union tcore_ip4_type gateway_v4;
+       union tcore_ip4_type dns_primary_v4;
+       union tcore_ip4_type dns_secondary_v4;
+
+       /*IPv6 will be supported*/
+
+       char *proxy;
+       char *mmsurl;
+       char devname[16];
+};
+
+static void _free_hook(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       po = tcore_object_ref_object(o);
+       if (po) {
+               g_free(po);
+               tcore_object_link_object(o, NULL);
+       }
+}
+
+CoreObject *tcore_context_new(TcorePlugin *p, const char *name)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name);
+       if (!o)
+               return NULL;
+
+       po = calloc(sizeof(struct private_object_data), 1);
+       if (!po) {
+               tcore_object_free(o);
+               return NULL;
+       }
+
+       po->type = CONTEXT_TYPE_IP;
+       po->d_comp = CONTEXT_D_COMP_OFF;
+       po->h_comp = CONTEXT_H_COMP_OFF;
+       po->role = CONTEXT_ROLE_UNKNOWN;
+       po->auth = CONTEXT_AUTH_NONE;
+
+       tcore_object_set_type(o, CORE_OBJECT_TYPE_PS_CONTEXT);
+       tcore_object_link_object(o, po);
+       tcore_object_set_free_hook(o, _free_hook);
+
+       return o;
+}
+
+void tcore_context_free(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_PS_CONTEXT);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       g_free(po);
+       tcore_object_link_object(o, NULL);
+       tcore_object_free(o);
+}
+
+TReturn tcore_context_set_state(CoreObject *o, enum co_context_state state)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->state = state;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+enum co_context_state    tcore_context_get_state(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, 0);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return 0;
+
+       return po->state;
+}
+
+TReturn tcore_context_set_id(CoreObject *o, unsigned int id)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->id = id;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+unsigned int tcore_context_get_id(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, 0);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return 0;
+
+       return po->id;
+}
+
+TReturn tcore_context_set_apn(CoreObject *o, const char *apn)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return FALSE;
+
+       if (po->apn) {
+               free(po->apn);
+               po->apn = NULL;
+       }
+
+       if (apn) {
+               po->apn = g_strdup(apn);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+char *tcore_context_get_apn(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       if (!po->apn)
+               return NULL;
+
+       return g_strdup(po->apn);
+}
+
+TReturn tcore_context_set_address(CoreObject *o, const char *addr)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       if (po->addr) {
+               free(po->addr);
+               po->addr = NULL;
+       }
+
+       if (addr) {
+               po->addr = g_strdup(addr);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+char *tcore_context_get_address(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       if (!po->addr)
+               return NULL;
+
+       return g_strdup(po->addr);
+}
+
+TReturn tcore_context_set_role(CoreObject *o, enum co_context_role role)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->role = role;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+enum co_context_role tcore_context_get_role(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, 0);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return 0;
+
+       return po->role;
+}
+
+TReturn tcore_context_set_type(CoreObject *o, enum co_context_type type)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->type = type;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+enum co_context_type tcore_context_get_type(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, 0);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return 0;
+
+       return po->type;
+}
+
+TReturn tcore_context_set_data_compression(CoreObject *o, enum co_context_d_comp comp)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->d_comp = comp;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+enum co_context_d_comp tcore_context_get_data_compression(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, 0);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return 0;
+
+       return po->d_comp;
+}
+
+TReturn tcore_context_set_header_compression(CoreObject *o, enum co_context_h_comp comp)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->h_comp = comp;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+enum co_context_h_comp tcore_context_get_header_compression(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, 0);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return 0;
+
+       return po->h_comp;
+}
+
+TReturn tcore_context_set_username(CoreObject *o, const char *username)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       if (po->username) {
+               free(po->username);
+               po->username = NULL;
+       }
+
+       if (username) {
+               po->username = g_strdup(username);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+char *tcore_context_get_username(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       if (!po->username)
+               return NULL;
+
+       return g_strdup(po->username);
+}
+
+TReturn tcore_context_set_password(CoreObject *o, const char *password)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       if (po->password) {
+               free(po->password);
+               po->password = NULL;
+       }
+
+       if (password) {
+               po->password = g_strdup(password);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+char *tcore_context_get_password(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       if (!po->password)
+               return NULL;
+
+       return g_strdup(po->password);
+}
+
+TReturn tcore_context_set_dns1(CoreObject *o, const char *dns)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       if (po->dns1) {
+               free(po->dns1);
+               po->dns1 = NULL;
+       }
+
+       if (dns) {
+               po->dns1 = g_strdup(dns);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+char *tcore_context_get_dns1(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       if (!po->dns1)
+               return NULL;
+
+       return g_strdup(po->dns1);
+}
+
+TReturn tcore_context_set_dns2(CoreObject *o, const char *dns)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       if (po->dns2) {
+               free(po->dns2);
+               po->dns2 = NULL;
+       }
+
+       if (dns) {
+               po->dns2 = g_strdup(dns);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+char *tcore_context_get_dns2(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       if (!po->dns2)
+               return NULL;
+
+       return g_strdup(po->dns2);
+}
+
+TReturn tcore_context_set_auth(CoreObject *o, enum co_context_auth auth)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->auth = auth;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+enum co_context_auth tcore_context_get_auth(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, 0);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return 0;
+
+       return po->auth;
+}
+
+TReturn tcore_context_set_proxy(CoreObject *o, const char *proxy)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return FALSE;
+
+       if (po->proxy) {
+               free(po->proxy);
+               po->apn = NULL;
+       }
+
+       if (proxy) {
+               po->proxy = g_strdup(proxy);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+char *tcore_context_get_proxy(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       if (!po->proxy)
+               return NULL;
+
+       return g_strdup(po->proxy);
+}
+
+TReturn tcore_context_set_mmsurl(CoreObject *o, const char *mmsurl)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return FALSE;
+
+       if (po->mmsurl) {
+               free(po->mmsurl);
+               po->mmsurl = NULL;
+       }
+
+       if (mmsurl) {
+               po->mmsurl = g_strdup(mmsurl);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+char *tcore_context_get_mmsurl(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       if (!po->mmsurl)
+               return NULL;
+
+       return g_strdup(po->mmsurl);
+}
+
+TReturn tcore_context_set_devinfo(CoreObject *o, struct tnoti_ps_pdp_ipconfiguration *devinfo)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return FALSE;
+       if (!devinfo)
+               return FALSE;
+
+       memcpy(&(po->ip_v4), devinfo->ip_address, sizeof(union tcore_ip4_type));
+       memcpy(&(po->dns_primary_v4), devinfo->primary_dns, sizeof(union tcore_ip4_type));
+       memcpy(&(po->dns_secondary_v4), devinfo->secondary_dns, sizeof(union tcore_ip4_type));
+       memcpy(&(po->gateway_v4), devinfo->gateway, sizeof(union tcore_ip4_type));
+       memcpy(po->devname, devinfo->devname, sizeof(char) * 16);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_context_reset_devinfo(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return FALSE;
+
+       memset(&(po->ip_v4), 0, sizeof(union tcore_ip4_type));
+       memset(&(po->dns_primary_v4), 0, sizeof(union tcore_ip4_type));
+       memset(&(po->dns_secondary_v4), 0, sizeof(union tcore_ip4_type));
+       memset(&(po->gateway_v4), 0, sizeof(union tcore_ip4_type));
+       memset(po->devname, 0, sizeof(char) * 16);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+void tcore_context_cp_service_info(CoreObject *dest, CoreObject *src)
+{
+       struct private_object_data *d_po = NULL;
+       struct private_object_data *s_po = NULL;
+
+       CORE_OBJECT_CHECK(dest, CORE_OBJECT_TYPE_PS_CONTEXT);
+       CORE_OBJECT_CHECK(src, CORE_OBJECT_TYPE_PS_CONTEXT);
+
+       d_po = tcore_object_ref_object(dest);
+       s_po = tcore_object_ref_object(src);
+
+       d_po->state = s_po->state;
+       d_po->id = s_po->id;
+       memcpy(&(d_po->ip_v4), &(s_po->ip_v4), sizeof(union tcore_ip4_type));
+       memcpy(&(d_po->dns_primary_v4), &(s_po->dns_primary_v4), sizeof(union tcore_ip4_type));
+       memcpy(&(d_po->dns_secondary_v4), &(s_po->dns_secondary_v4), sizeof(union tcore_ip4_type));
+       memcpy(&(d_po->gateway_v4), &(s_po->gateway_v4), sizeof(union tcore_ip4_type));
+
+       return;
+}
+
+char* tcore_context_get_ipv4_addr(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       return tcore_util_get_string_by_ip4type(po->ip_v4);
+}
+
+char* tcore_context_get_ipv4_dns1(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       return tcore_util_get_string_by_ip4type(po->dns_primary_v4);
+}
+
+char* tcore_context_get_ipv4_dns2(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       return tcore_util_get_string_by_ip4type(po->dns_secondary_v4);
+}
+
+char* tcore_context_get_ipv4_gw(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       return tcore_util_get_string_by_ip4type(po->gateway_v4);
+}
+
+char* tcore_context_get_ipv4_devname(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS_CONTEXT, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       if (!po->devname)
+               return NULL;
+
+       return g_strdup(po->devname);
+}
diff --git a/src/co_modem.c b/src/co_modem.c
new file mode 100644 (file)
index 0000000..7e3323b
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "plugin.h"
+#include "user_request.h"
+#include "co_modem.h"
+
+struct private_object_data {
+       struct tcore_modem_operations *ops;
+
+       gboolean flight_mode;
+       gboolean powered;
+};
+
+static void _free_hook(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       po = tcore_object_ref_object(o);
+       if (po) {
+               free(po);
+               tcore_object_link_object(o, NULL);
+       }
+}
+
+static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
+{
+       enum tcore_request_command command;
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_MODEM, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po || !po->ops)
+               return TCORE_RETURN_ENOSYS;
+
+       command = tcore_user_request_get_command(ur);
+       switch (command) {
+               case TREQ_MODEM_POWER_ON:
+                       if (!po->ops->power_on)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->power_on(o, ur);
+                       break;
+
+               case TREQ_MODEM_POWER_OFF:
+                       if (!po->ops->power_off)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->power_off(o, ur);
+                       break;
+
+               case TREQ_MODEM_POWER_RESET:
+                       if (!po->ops->power_reset)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->power_reset(o, ur);
+                       break;
+
+               case TREQ_MODEM_SET_FLIGHTMODE:
+                       if (!po->ops->set_flight_mode)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_flight_mode(o, ur);
+                       break;
+
+               case TREQ_MODEM_GET_IMEI:
+                       if (!po->ops->get_imei)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_imei(o, ur);
+                       break;
+
+               case TREQ_MODEM_GET_VERSION:
+                       if (!po->ops->get_version)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_version(o, ur);
+                       break;
+
+               default:
+                       return TCORE_RETURN_EINVAL;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+CoreObject *tcore_modem_new(TcorePlugin *p, const char *name, struct tcore_modem_operations *ops)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name);
+       if (!o)
+               return NULL;
+
+       po = calloc(sizeof(struct private_object_data), 1);
+       if (!po) {
+               tcore_object_free(o);
+               return NULL;
+       }
+
+       po->ops = ops;
+
+       tcore_object_set_type(o, CORE_OBJECT_TYPE_MODEM);
+       tcore_object_link_object(o, po);
+       tcore_object_set_free_hook(o, _free_hook);
+       tcore_object_set_dispatcher(o, _dispatcher);
+
+       return o;
+}
+
+void tcore_modem_free(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_MODEM);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       free(po);
+       tcore_object_free(o);
+}
+
+TReturn tcore_modem_set_flight_mode_state(CoreObject *o, gboolean flag)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_MODEM, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->flight_mode = flag;
+
+       return TRUE;
+}
+
+gboolean tcore_modem_get_flight_mode_state(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_MODEM, FALSE);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return FALSE;
+
+       return po->flight_mode;
+}
+
+TReturn tcore_modem_set_powered(CoreObject *o, gboolean pwr)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_MODEM, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->powered = pwr;
+
+       return TRUE;
+}
+
+gboolean tcore_modem_get_powered(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_MODEM, FALSE);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return FALSE;
+
+       return po->powered;
+}
diff --git a/src/co_network.c b/src/co_network.c
new file mode 100644 (file)
index 0000000..cde75e2
--- /dev/null
@@ -0,0 +1,704 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "plugin.h"
+#include "queue.h"
+#include "user_request.h"
+#include "co_network.h"
+
+struct private_object_data {
+       struct tcore_network_operations *ops;
+
+       enum telephony_network_service_type service_type;
+       enum telephony_network_access_technology act;
+       enum telephony_network_service_domain_status cs_domain_status;
+       enum telephony_network_service_domain_status ps_domain_status;
+       char *plmn;
+       gboolean roaming_state;
+       unsigned int lac;
+       unsigned int rac;
+       unsigned int cell_id;
+
+       char *network_name_short;
+       char *network_name_full;
+       char *network_name_spn;
+       enum tcore_network_name_priority network_name_priority;
+
+       GSList *network_operator_info_table[999];
+};
+
+static TReturn _dispatcher(CoreObject *co, UserRequest *ur)
+{
+       enum tcore_request_command command;
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(co);
+       if (!po || !po->ops)
+               return TCORE_RETURN_ENOSYS;
+
+       command = tcore_user_request_get_command(ur);
+       switch (command) {
+               case TREQ_NETWORK_SEARCH:
+                       if (!po->ops->search)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->search(co, ur);
+                       break;
+
+               case TREQ_NETWORK_SET_PLMN_SELECTION_MODE:
+                       if (!po->ops->set_plmn_selection_mode)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_plmn_selection_mode(co, ur);
+                       break;
+
+               case TREQ_NETWORK_GET_PLMN_SELECTION_MODE:
+                       if (!po->ops->get_plmn_selection_mode)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_plmn_selection_mode(co, ur);
+                       break;
+
+               case TREQ_NETWORK_SET_SERVICE_DOMAIN:
+                       if (!po->ops->set_service_domain)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_service_domain(co, ur);
+                       break;
+
+               case TREQ_NETWORK_GET_SERVICE_DOMAIN:
+                       if (!po->ops->get_service_domain)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_service_domain(co, ur);
+                       break;
+
+               case TREQ_NETWORK_SET_BAND:
+                       if (!po->ops->set_band)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_band(co, ur);
+                       break;
+
+               case TREQ_NETWORK_GET_BAND:
+                       if (!po->ops->get_band)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_band(co, ur);
+                       break;
+
+               case TREQ_NETWORK_SET_PREFERRED_PLMN:
+                       if (!po->ops->set_preferred_plmn)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_preferred_plmn(co, ur);
+                       break;
+
+               case TREQ_NETWORK_GET_PREFERRED_PLMN:
+                       if (!po->ops->get_preferred_plmn)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_preferred_plmn(co, ur);
+                       break;
+
+               case TREQ_NETWORK_SET_ORDER:
+                       if (!po->ops->set_order)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_order(co, ur);
+                       break;
+
+               case TREQ_NETWORK_GET_ORDER:
+                       if (!po->ops->get_order)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_order(co, ur);
+                       break;
+
+               case TREQ_NETWORK_SET_POWER_ON_ATTACH:
+                       if (!po->ops->set_power_on_attach)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_power_on_attach(co, ur);
+                       break;
+
+               case TREQ_NETWORK_GET_POWER_ON_ATTACH:
+                       if (!po->ops->get_power_on_attach)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_power_on_attach(co, ur);
+                       break;
+
+               case TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH:
+                       if (!po->ops->set_cancel_manual_search)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_cancel_manual_search(co, ur);
+                       break;
+
+               case TREQ_NETWORK_GET_SERVING_NETWORK:
+                       if (!po->ops->get_serving_network)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_serving_network(co, ur);
+                       break;
+
+               default:
+                       break;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+static void _free_hook(CoreObject *co)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(co, CORE_OBJECT_TYPE_NETWORK);
+
+       po = tcore_object_ref_object(co);
+       if (po) {
+               free(po);
+               tcore_object_link_object(co, NULL);
+       }
+}
+
+CoreObject *tcore_network_new(TcorePlugin *plugin, const char *name,
+               struct tcore_network_operations *ops)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!plugin)
+               return NULL;
+
+       o = tcore_object_new(plugin, name);
+       if (!o)
+               return NULL;
+
+       po = calloc(sizeof(struct private_object_data), 1);
+       if (!po) {
+               tcore_object_free(o);
+               return NULL;
+       }
+
+       po->ops = ops;
+
+       tcore_object_set_type(o, CORE_OBJECT_TYPE_NETWORK);
+       tcore_object_link_object(o, po);
+       tcore_object_set_free_hook(o, _free_hook);
+       tcore_object_set_dispatcher(o, _dispatcher);
+
+       return o;
+}
+
+void tcore_network_free(CoreObject *co)
+{
+       struct private_object_data *po = NULL;
+       GSList *list;
+       int i;
+
+       CORE_OBJECT_CHECK(co, CORE_OBJECT_TYPE_NETWORK);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return;
+
+       for (i=0; i<999; i++) {
+               list = po->network_operator_info_table[i];
+               if (!list)
+                       continue;
+
+               for (; list; list = list->next) {
+                       if (!list)
+                               continue;
+
+                       if (list->data)
+                               free(list->data);
+               }
+
+               g_slist_free(po->network_operator_info_table[i]);
+       }
+
+       if (po->network_name_short)
+               free(po->network_name_short);
+       if (po->network_name_full)
+               free(po->network_name_full);
+       if (po->network_name_spn)
+               free(po->network_name_spn);
+       if (po->plmn)
+               free(po->plmn);
+
+       free(po);
+       tcore_object_free(co);
+}
+
+char* tcore_network_get_plmn(CoreObject *co)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, NULL);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return NULL;
+
+       return g_strdup(po->plmn);
+}
+
+TReturn tcore_network_set_plmn(CoreObject *co, const char *plmn)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       if (po->plmn)
+               free(po->plmn);
+
+       po->plmn = g_strdup(plmn);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+
+char* tcore_network_get_network_name(CoreObject *co,
+               enum tcore_network_name_type type)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, NULL);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return NULL;
+
+       if (type == TCORE_NETWORK_NAME_TYPE_SHORT)
+               return g_strdup(po->network_name_short);
+       else if (type == TCORE_NETWORK_NAME_TYPE_FULL)
+               return g_strdup(po->network_name_full);
+       else if (type == TCORE_NETWORK_NAME_TYPE_SPN)
+               return g_strdup(po->network_name_spn);
+       else
+               return NULL;
+}
+
+TReturn tcore_network_set_network_name(CoreObject *co,
+               enum tcore_network_name_type type, const char *network_name)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       if (type == TCORE_NETWORK_NAME_TYPE_SHORT) {
+               if (po->network_name_short)
+                       free(po->network_name_short);
+
+               dbg("short network_name = [%s]", network_name);
+               po->network_name_short = g_strdup(network_name);
+       }
+       else if (type == TCORE_NETWORK_NAME_TYPE_FULL) {
+               if (po->network_name_full)
+                       free(po->network_name_full);
+
+               dbg("full network_name = [%s]", network_name);
+               po->network_name_full = g_strdup(network_name);
+       }
+       else if (type == TCORE_NETWORK_NAME_TYPE_SPN) {
+               if (po->network_name_spn)
+                       free(po->network_name_spn);
+
+               dbg("spn network_name = [%s]", network_name);
+               po->network_name_spn = g_strdup(network_name);
+       }
+       else {
+               return TCORE_RETURN_EINVAL;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+
+TReturn tcore_network_get_network_name_priority(CoreObject *co,
+               enum tcore_network_name_priority *priority)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       if (!priority)
+               return TCORE_RETURN_EINVAL;
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return FALSE;
+
+       *priority = po->network_name_priority;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_set_network_name_priority(CoreObject *co,
+               enum tcore_network_name_priority priority)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->network_name_priority  = priority;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+gboolean tcore_network_get_roaming_state(CoreObject *co)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, FALSE);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return FALSE;
+
+       return po->roaming_state;
+}
+
+TReturn tcore_network_set_roaming_state(CoreObject *co, gboolean state)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->roaming_state = state;
+       dbg("roaming_state = 0x%x", state);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_get_service_status(CoreObject *co,
+               enum tcore_network_service_domain_type type,
+               enum telephony_network_service_domain_status *result)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       if (!result)
+               return TCORE_RETURN_EINVAL;
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       switch (type) {
+               case TCORE_NETWORK_SERVICE_DOMAIN_TYPE_CIRCUIT:
+                       *result = po->cs_domain_status;
+                       break;
+
+               case TCORE_NETWORK_SERVICE_DOMAIN_TYPE_PACKET:
+                       *result = po->ps_domain_status;
+                       break;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_set_service_status(CoreObject *co,
+               enum tcore_network_service_domain_type type,
+               enum telephony_network_service_domain_status status)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       switch (type) {
+               case TCORE_NETWORK_SERVICE_DOMAIN_TYPE_CIRCUIT:
+                       po->cs_domain_status = status;
+                       dbg("cs.status = 0x%x", status);
+                       break;
+
+               case TCORE_NETWORK_SERVICE_DOMAIN_TYPE_PACKET:
+                       po->ps_domain_status = status;
+                       dbg("cs.status = 0x%x", status);
+                       break;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_set_access_technology(CoreObject *co,
+               enum telephony_network_access_technology act)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->act = act;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_get_access_technology(CoreObject *co,
+               enum telephony_network_access_technology *result)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       if (!result)
+               return TCORE_RETURN_EINVAL;
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       *result = po->act;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_set_lac(CoreObject *co, unsigned int lac)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->lac = lac;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_get_lac(CoreObject *co, unsigned int *result)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       if (!result)
+               return TCORE_RETURN_EINVAL;
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       *result = po->lac;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_set_rac(CoreObject *co, unsigned int rac)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->rac = rac;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_get_rac(CoreObject *co, unsigned int *result)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       if (!result)
+               return TCORE_RETURN_EINVAL;
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       *result = po->rac;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_set_cell_id(CoreObject *co, unsigned int cell_id)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->cell_id = cell_id;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_get_cell_id(CoreObject *co, unsigned int *result)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       if (!result)
+               return TCORE_RETURN_EINVAL;
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       *result = po->cell_id;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_set_service_type(CoreObject *co,
+               enum telephony_network_service_type service_type)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->service_type = service_type;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_get_service_type(CoreObject *co,
+               enum telephony_network_service_type *result)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       if (!result)
+               return TCORE_RETURN_EINVAL;
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       *result = po->service_type;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_network_operator_info_add(CoreObject *co,
+               struct tcore_network_operator_info *noi)
+{
+       struct private_object_data *po = NULL;
+       int mcc_index = 0;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, TCORE_RETURN_EINVAL);
+
+       if (!noi)
+               return TCORE_RETURN_EINVAL;
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       mcc_index = atoi(noi->mcc);
+       po->network_operator_info_table[mcc_index] = g_slist_append(po->network_operator_info_table[mcc_index], noi);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+struct tcore_network_operator_info *
+tcore_network_operator_info_find(CoreObject *co, const char *mcc, const char *mnc)
+{
+       struct private_object_data *po = NULL;
+       GSList *list;
+       int mcc_index = 0;
+       struct tcore_network_operator_info *data;
+
+       CORE_OBJECT_CHECK_RETURN(co, CORE_OBJECT_TYPE_NETWORK, NULL);
+
+       if (!mcc || !mnc)
+               return NULL;
+
+       po = tcore_object_ref_object(co);
+       if (!po)
+               return NULL;
+
+       mcc_index = atoi(mcc);
+       list = po->network_operator_info_table[mcc_index];
+       if (list == NULL) {
+               dbg("mcc[%d] is not in table", mcc_index);
+               return NULL;
+       }
+
+       for (; list; list = list->next) {
+               if (!list)
+                       continue;
+
+               if (!list->data)
+                       continue;
+
+               data = list->data;
+
+               dbg(" +- mnc[%s]", data->mnc);
+               if (g_strcmp0(data->mnc, mnc) == 0)
+                       return data;
+       }
+
+       dbg("mnc[%s] is not in list", mnc);
+       return NULL;
+}
diff --git a/src/co_phonebook.c b/src/co_phonebook.c
new file mode 100644 (file)
index 0000000..a1cf2c7
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "plugin.h"
+#include "queue.h"
+#include "user_request.h"
+#include "core_object.h"
+#include "co_phonebook.h"
+
+struct private_object_data {
+       struct tcore_phonebook_operations *ops;
+       gboolean b_init;
+       struct tel_phonebook_support_list support_list;
+};
+
+static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
+{
+       enum tcore_request_command command;
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PHONEBOOK, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po || !po->ops)
+               return TCORE_RETURN_ENOSYS;
+
+       command = tcore_user_request_get_command(ur);
+       switch (command) {
+               case TREQ_PHONEBOOK_GETCOUNT:
+                       if (!po->ops->get_count)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_count(o, ur);
+                       break;
+
+               case TREQ_PHONEBOOK_GETMETAINFO:
+                       if (!po->ops->get_info)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_info(o, ur);
+                       break;
+
+               case TREQ_PHONEBOOK_GETUSIMINFO:
+                       if (!po->ops->get_usim_info)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_usim_info(o, ur);
+                       break;
+
+               case TREQ_PHONEBOOK_READRECORD:
+                       if (!po->ops->read_record)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->read_record(o, ur);
+                       break;
+
+               case TREQ_PHONEBOOK_UPDATERECORD:
+                       if (!po->ops->update_record)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->update_record(o, ur);
+                       break;
+
+               case TREQ_PHONEBOOK_DELETERECORD:
+                       if (!po->ops->delete_record)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->delete_record(o, ur);
+                       break;
+
+               default:
+                       break;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+static void _free_hook(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_PHONEBOOK);
+
+       po = tcore_object_ref_object(o);
+       if (po) {
+               free(po);
+               tcore_object_link_object(o, NULL);
+       }
+}
+
+gboolean tcore_phonebook_get_status(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PHONEBOOK, TCORE_RETURN_EINVAL);
+       po = tcore_object_ref_object(o);
+       return po->b_init;
+}
+
+gboolean tcore_phonebook_set_status(CoreObject *o, gboolean b_init)
+{
+       struct private_object_data *po = NULL;
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PHONEBOOK, TCORE_RETURN_EINVAL);
+       po = tcore_object_ref_object(o);
+       po->b_init = b_init;
+       return TRUE;
+}
+
+struct tel_phonebook_support_list* tcore_phonebook_get_support_list(CoreObject *o)
+{
+       struct tel_phonebook_support_list *tmp;
+       struct private_object_data *po = NULL;
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PHONEBOOK, NULL);
+       po = tcore_object_ref_object(o);
+       tmp = calloc(sizeof(struct tel_phonebook_support_list), 1);
+       memcpy(tmp, &po->support_list, sizeof(struct tel_phonebook_support_list));
+       return tmp;
+}
+
+gboolean tcore_phonebook_set_support_list(CoreObject *o, struct tel_phonebook_support_list *list)
+{
+       struct private_object_data *po = NULL;
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PHONEBOOK, TCORE_RETURN_EINVAL);
+       po = tcore_object_ref_object(o);
+       memcpy(&po->support_list, list, sizeof(struct tel_phonebook_support_list));
+       return TRUE;
+}
+
+CoreObject *tcore_phonebook_new(TcorePlugin *p, const char *name, struct tcore_phonebook_operations *ops)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name);
+       if (!o)
+               return NULL;
+
+       po = calloc(sizeof(struct private_object_data), 1);
+       if (!po) {
+               tcore_object_free(o);
+               return NULL;
+       }
+
+       po->ops = ops;
+
+       tcore_object_set_type(o, CORE_OBJECT_TYPE_PHONEBOOK);
+       tcore_object_link_object(o, po);
+       tcore_object_set_free_hook(o, _free_hook);
+       tcore_object_set_dispatcher(o, _dispatcher);
+
+       return o;
+}
+
+void tcore_phonebook_free(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_PHONEBOOK);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       free(po);
+       tcore_object_free(o);
+}
diff --git a/src/co_ps.c b/src/co_ps.c
new file mode 100644 (file)
index 0000000..7479ba4
--- /dev/null
@@ -0,0 +1,536 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "plugin.h"
+#include "user_request.h"
+#include "co_ps.h"
+
+struct p_callid_type{
+       unsigned int cid;
+       GSList *contexts;
+};
+
+struct private_object_data {
+       struct tcore_ps_operations *ops;
+
+       gboolean online;
+
+       /* 1 ~ UMTS_PS_MAX_CID */
+       struct p_callid_type cid[PS_MAX_CID + 1];
+       //CoreObject *cid[PS_MAX_CID + 1];
+
+       GSList *context_list;
+};
+
+static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
+{
+       enum tcore_request_command command;
+       struct private_object_data *po = NULL;
+
+       if (!o || !ur)
+               return TCORE_RETURN_EINVAL;
+
+       po = tcore_object_ref_object(o);
+       if (!po || !po->ops)
+               return TCORE_RETURN_ENOSYS;
+
+       command = tcore_user_request_get_command(ur);
+       switch (command) {
+               case TREQ_PS_SET_DUN_PIN_CONTROL:
+                       if (!po->ops->pin_ctrl)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->pin_ctrl(o, ur);
+                       break;
+
+               default:
+                       break;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+static void _free_hook(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+       GSList *list;
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       if (po->context_list) {
+               for (list = po->context_list; list; list = list->next) {
+                       if (!list)
+                               continue;
+
+                       if (list->data)
+                               free(list->data);
+
+                       list->data = NULL;
+               }
+
+               g_slist_free(po->context_list);
+               po->context_list = NULL;
+       }
+
+       free(po);
+       tcore_object_link_object(o, NULL);
+}
+
+static gboolean _ps_is_active_context(CoreObject *o, CoreObject *ps_context)
+{
+       GSList *contexts = NULL;
+       CoreObject *s_context = NULL;
+
+       int idx_cid = 0;
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+
+       for (idx_cid = 0; idx_cid < PS_MAX_CID; idx_cid++) {
+
+               if (po->cid[idx_cid].cid != 0) {
+                       contexts = po->cid[idx_cid].contexts;
+
+                       do {
+                               s_context = contexts->data;
+                               if (!s_context)
+                                       continue;
+
+                               if (ps_context == s_context) {
+                                       dbg("find contexts(%p) in cid(%d)", ps_context, idx_cid);
+                                       return TRUE;
+                               }
+
+                       } while ((contexts = g_slist_next(contexts)));
+
+               }
+       }
+
+       return FALSE;
+}
+
+static gboolean _ps_is_duplicated_apn(CoreObject *o, CoreObject *ps_context)
+{
+       GSList *contexts = NULL;
+       CoreObject *s_context = NULL;
+       gchar *t_apn = NULL, *s_apn = NULL;
+
+       int idx_cid = 0;
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       t_apn = tcore_context_get_apn(ps_context);
+
+       for (idx_cid = 0; idx_cid < PS_MAX_CID; idx_cid++) {
+
+               if (po->cid[idx_cid].cid != 0) {
+                       contexts = po->cid[idx_cid].contexts;
+
+                       do {
+                               s_context = contexts->data;
+
+                               if (!s_context)
+                                       continue;
+                               if (ps_context == s_context)
+                                       continue;
+
+                               s_apn = tcore_context_get_apn(s_context);
+                               if (g_strcmp0(t_apn, s_apn) == 0) {
+                                       dbg("target and source context have same APN");
+                                       tcore_context_cp_service_info(ps_context, s_context);
+                                       g_free(t_apn);
+                                       g_free(s_apn);
+                                       return TRUE;
+                               }
+                               g_free(s_apn);
+                       } while ((contexts = g_slist_next(contexts)));
+
+               }
+       }
+
+       g_free(t_apn);
+       return FALSE;
+}
+
+CoreObject *tcore_ps_new(TcorePlugin *p, const char *name, struct tcore_ps_operations *ops)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name);
+       if (!o)
+               return NULL;
+
+       po = calloc(sizeof(struct private_object_data), 1);
+       if (!po) {
+               tcore_object_free(o);
+               return NULL;
+       }
+
+       po->ops = ops;
+
+       tcore_object_set_type(o, CORE_OBJECT_TYPE_PS);
+       tcore_object_link_object(o, po);
+       tcore_object_set_free_hook(o, _free_hook);
+       tcore_object_set_dispatcher(o, _dispatcher);
+
+       return o;
+}
+
+void tcore_ps_free(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_PS);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       g_free(po);
+       tcore_object_link_object(o, po);
+       tcore_object_free(o);
+}
+
+TReturn tcore_ps_add_context(CoreObject *o, CoreObject *ctx_o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS, TCORE_RETURN_EINVAL);
+       CORE_OBJECT_CHECK_RETURN(ctx_o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->context_list = g_slist_insert(po->context_list, ctx_o, 0);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_ps_remove_context(CoreObject *o, CoreObject *ctx_o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS, TCORE_RETURN_EINVAL);
+       CORE_OBJECT_CHECK_RETURN(ctx_o, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->context_list = g_slist_remove(po->context_list, ctx_o);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_ps_set_online(CoreObject *o, gboolean state)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       po->online = state;
+       dbg("ps status = %d", po->online);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+CoreObject *tcore_ps_ref_context_by_role(CoreObject *o, enum co_context_role role)
+{
+       struct private_object_data *po = NULL;
+       GSList *list;
+       CoreObject *pdp_o;
+       TcorePlugin *p;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       p = tcore_object_ref_plugin(o);
+       if (!p)
+               return NULL;
+
+       if (po->context_list) {
+               for (list = po->context_list; list; list = list->next) {
+                       if (!list)
+                               continue;
+
+                       if (!list->data)
+                               continue;
+
+                       pdp_o = list->data;
+                       if (!pdp_o)
+                               continue;
+
+                       if (tcore_object_get_type(pdp_o) != CORE_OBJECT_TYPE_PS_CONTEXT)
+                               continue;
+
+                       if (tcore_context_get_role(pdp_o) == role)
+                               return pdp_o;
+               }
+       }
+
+       return NULL;
+}
+
+GSList *tcore_ps_ref_context_by_id(CoreObject *o, unsigned int id)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS, NULL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return NULL;
+
+       if (id == 0 || id > PS_MAX_CID)
+               return NULL;
+
+       if (po->cid[id].cid != id)
+               return NULL;
+
+       return po->cid[id].contexts;
+}
+
+TReturn tcore_ps_assign_context_id(CoreObject *o, CoreObject *context, unsigned int cid)
+{
+       struct private_object_data *po = NULL;
+       int idx;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS, TCORE_RETURN_EINVAL);
+       CORE_OBJECT_CHECK_RETURN(context, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       if (cid == 0) {
+               /* Automatic assign */
+               for (idx = 1; idx <= PS_MAX_CID; idx++) {
+                       if (po->cid[idx].cid == 0) {
+                               po->cid[idx].cid = idx;
+                               po->cid[idx].contexts = g_slist_append(po->cid[idx].contexts, context);
+                               return tcore_context_set_id(context, idx);
+                       }
+                       else {
+                               dbg("cid[%d] is not null", idx);
+                       }
+               }
+
+               dbg("can't find empty cid");
+       }
+       else {
+               /* Manual assign */
+               if (po->cid[cid].cid == cid) {
+                       po->cid[cid].contexts = g_slist_append(po->cid[cid].contexts, context);
+                       return tcore_context_set_id(context, cid);
+               }
+               else {
+                       dbg("cid[%d] is not null", cid);
+               }
+       }
+
+       return TCORE_RETURN_PS_CID_ERROR;
+}
+
+TReturn tcore_ps_clear_context_id(CoreObject *o, CoreObject *context)
+{
+       struct private_object_data *po = NULL;
+       int i = 0, cnt = 0;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS, TCORE_RETURN_EINVAL);
+       CORE_OBJECT_CHECK_RETURN(context, CORE_OBJECT_TYPE_PS_CONTEXT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       i = tcore_context_get_id(context);
+       if (i == 0) {
+               return TCORE_RETURN_PS_CID_ERROR;
+       }
+
+       if (i > PS_MAX_CID)
+               return TCORE_RETURN_PS_CID_ERROR;
+
+       po->cid[i].contexts = g_slist_remove(po->cid[i].contexts, context);
+       cnt = g_slist_length(po->cid[i].contexts);
+       if (cnt <= 0)
+               po->cid[i].cid = 0;
+
+       return tcore_context_set_id(context, 0);
+}
+
+TReturn tcore_ps_activate_context(CoreObject *o, CoreObject *ps_context, void *user_data)
+{
+       int rv;
+       struct private_object_data *po = NULL;
+       enum co_context_state context_state = CONTEXT_STATE_DEACTIVATED;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       if (!po->online) {
+               dbg("ps network is not online !");
+               return TCORE_RETURN_PS_NETWORK_NOT_READY;
+       }
+
+       if (!ps_context)
+               return TCORE_RETURN_EINVAL;
+
+       rv = _ps_is_active_context(o, ps_context);
+       if (rv)
+               return TCORE_RETURN_SUCCESS;
+
+       rv = _ps_is_duplicated_apn(o, ps_context);
+       if (rv) {
+               int cid = 0;
+               cid = tcore_context_get_id(ps_context);
+               po->cid[cid].contexts = g_slist_append(po->cid[cid].contexts, ps_context);
+               return TCORE_RETURN_SUCCESS;
+       }
+
+       context_state = tcore_context_get_state(ps_context);
+       if (context_state == CONTEXT_STATE_ACTIVATED)
+               return TCORE_RETURN_SUCCESS;
+       else if (context_state == CONTEXT_STATE_ACTIVATING)
+               return TCORE_RETURN_SUCCESS;
+       else if (context_state == CONTEXT_STATE_DEACTIVATING)
+               return TCORE_RETURN_PS_DEACTIVATING;
+
+       if (tcore_context_get_id(ps_context) == 0) {
+               if (tcore_ps_assign_context_id(o, ps_context, 0) != TCORE_RETURN_SUCCESS)
+                       return TCORE_RETURN_PS_CID_ERROR;
+       }
+       else {
+               dbg("cid = %d", tcore_context_get_id(ps_context));
+       }
+
+       tcore_context_set_state(ps_context, CONTEXT_STATE_ACTIVATING);
+       return po->ops->activate_context(o, ps_context, user_data);
+}
+
+TReturn tcore_ps_deactivate_context(CoreObject *o, CoreObject *ps_context, void *user_data)
+{
+       int rv;
+       struct private_object_data *po = NULL;
+       enum co_context_state context_state = CONTEXT_STATE_DEACTIVATED;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       if (!po->online) {
+               dbg("ps network is not online !");
+               return TCORE_RETURN_PS_NETWORK_NOT_READY;
+       }
+
+       if (!ps_context)
+               return TCORE_RETURN_EINVAL;
+
+       rv = _ps_is_active_context(o, ps_context);
+       if (!rv)
+               return TCORE_RETURN_EINVAL;
+
+       rv = _ps_is_duplicated_apn(o, ps_context);
+       if (rv) {
+               int cid = 0;
+               cid = tcore_context_get_id(ps_context);
+               po->cid[cid].contexts = g_slist_remove(po->cid[cid].contexts, ps_context);
+               tcore_context_set_state(ps_context, CONTEXT_STATE_DEACTIVATED);
+               return TCORE_RETURN_SUCCESS;
+       }
+
+       context_state = tcore_context_get_state(ps_context);
+       if (context_state == CONTEXT_STATE_DEACTIVATED)
+               return TCORE_RETURN_SUCCESS;
+       else if (context_state == CONTEXT_STATE_DEACTIVATING)
+               return TCORE_RETURN_SUCCESS;
+       else if (context_state == CONTEXT_STATE_ACTIVATING)
+               return TCORE_RETURN_PS_ACTIVATING;
+
+       tcore_context_set_state(ps_context, CONTEXT_STATE_DEACTIVATING);
+       return po->ops->deactivate_context(o, ps_context, user_data);
+}
+
+TReturn tcore_ps_deactivate_contexts(CoreObject *o)
+{
+       int index = 0;
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PS, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return TCORE_RETURN_EINVAL;
+
+       if (!po->online) {
+               dbg("ps network is not online !");
+               return TCORE_RETURN_PS_NETWORK_NOT_READY;
+       }
+
+       for (index = 0; index < PS_MAX_CID; index++) {
+               if (po->cid[index].cid != 0) {
+                       GSList *contexts = NULL;
+                       contexts = po->cid[index].contexts;
+
+                       do {
+                               CoreObject *context = NULL;
+                               context = contexts->data;
+
+                               if (!context)
+                                       continue;
+                               tcore_ps_deactivate_context(o, context, NULL);
+
+                       } while ((contexts = g_slist_next(contexts)));
+
+               }
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
diff --git a/src/co_sap.c b/src/co_sap.c
new file mode 100644 (file)
index 0000000..c58117e
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "plugin.h"
+#include "queue.h"
+#include "user_request.h"
+#include "co_sap.h"
+
+struct private_object_data {
+       struct tcore_sap_operations *ops;
+};
+
+static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
+{
+       enum tcore_request_command command;
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_SAP, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po || !po->ops)
+               return TCORE_RETURN_ENOSYS;
+
+       command = tcore_user_request_get_command(ur);
+       switch (command) {
+               case TREQ_SAP_REQ_CONNECT:
+                       po = tcore_object_ref_object(o);
+                       if (!po->ops->connect)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->connect(o, ur);
+                       break;
+
+               case TREQ_SAP_REQ_DISCONNECT:
+                       if (!po->ops->disconnect)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->disconnect(o, ur);
+                       break;
+
+               case TREQ_SAP_REQ_STATUS:
+                       if (!po->ops->req_status)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->req_status(o, ur);
+                       break;
+
+               case TREQ_SAP_REQ_ATR:
+                       if (!po->ops->get_atr)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_atr(o, ur);
+                       break;
+
+               case TREQ_SAP_TRANSFER_APDU:
+                       if (!po->ops->transfer_apdu)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->transfer_apdu(o, ur);
+                       break;
+
+               case TREQ_SAP_SET_PROTOCOL:
+                       if (!po->ops->set_transport_protocol)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_transport_protocol(o, ur);
+                       break;
+
+               case TREQ_SAP_SET_POWER:
+                       if (!po->ops->set_power)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_power(o, ur);
+                       break;
+
+               case TREQ_SAP_REQ_CARDREADERSTATUS:
+                       if (!po->ops->get_cardreader_status)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_cardreader_status(o, ur);
+                       break;
+
+               default:
+                       break;
+       }
+       return TCORE_RETURN_SUCCESS;
+}
+
+static void _free_hook(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SAP);
+
+       po = tcore_object_ref_object(o);
+       if (po) {
+               free(po);
+               tcore_object_link_object(o, NULL);
+       }
+}
+
+CoreObject *tcore_sap_new(TcorePlugin *p, const char *name, struct tcore_sap_operations *ops)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name);
+       if (!o)
+               return NULL;
+
+       po = calloc(sizeof(struct private_object_data), 1);
+       if (!po) {
+               tcore_object_free(o);
+               return NULL;
+       }
+
+       po->ops = ops;
+
+       tcore_object_set_type(o, CORE_OBJECT_TYPE_SAP);
+       tcore_object_link_object(o, po);
+       tcore_object_set_free_hook(o, _free_hook);
+       tcore_object_set_dispatcher(o, _dispatcher);
+
+       return o;
+}
+
+void tcore_sap_free(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SAP);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       free(po);
+       tcore_object_free(o);
+}
diff --git a/src/co_sat.c b/src/co_sat.c
new file mode 100644 (file)
index 0000000..db91715
--- /dev/null
@@ -0,0 +1,2310 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "plugin.h"
+#include "queue.h"
+#include "user_request.h"
+#include "core_object.h"
+#include "util.h"
+#include "co_sat.h"
+
+#define SATK_PROACTIVE_CMD_TAG 0xD0  /*Proactive Command Tag*/
+#define SATK_MENU_SELECTION_TAG        0xD3  /*Menu Selection Tag*/
+#define SATK_EVENT_DOWNLOAD_TAG        0xD6  /*Event Download Tag*/
+
+/*Tag Values (without Comprehension bit)*/
+#define SATK_COMMAND_DETAILS_TAG       0x01 /* COMMAND DETAILS TAG */
+#define SATK_DEVICE_IDENTITY_TAG       0x02 /* DEVICE IDENTITY TAG */
+#define SATK_RESULT_TAG        0x03 /* RESULT TAG */
+#define SATK_DURATION_TAG      0x04 /* DURATION TAG */
+#define SATK_ALPHA_IDENTIFIER_TAG      0x05 /* ALPHA IDENTIFIER TAG */
+#define SATK_ADDRESS_TAG       0x06 /* ADDRESS TAG */
+#define SATK_CAPABILITY_CONFIGURATION_PARAMETERS_TAG   0x07 /* CAPABILITY CONFIGURATION PARAMETERS TAG */
+#define SATK_SUB_ADDRESS_TAG   0x08 /* SUB ADDRESS TAG */
+#define SATK_SS_STRING_TAG     0x09 /* SS STRING TAG */
+#define SATK_USSD_STRING_TAG   0x0A /* USSD STRING TAG */
+#define SATK_SMS_TPDU_TAG      0x0B /* SMS TPDU TAG */
+#define SATK_CELL_BROADCAST_PAGE_TAG   0x0C /* CELL BROADCAST PAGE TAG */
+#define SATK_TEXT_STRING_TAG   0x0D /* TEXT STRING TAG */
+#define SATK_TONE_TAG  0x0E /* TONE TAG */
+#define SATK_ITEM_TAG  0x0F /* ITEM TAG */
+#define SATK_ITEM_IDENTIFIER_TAG       0x10 /* ITEM IDENTIFIER TAG */
+#define SATK_RESPONSE_LENGTH_TAG       0x11 /* RESPONSE LENGTH TAG */
+#define SATK_FILE_LIST_TAG     0x12 /* FILE LIST TAG */
+#define SATK_LOCATION_INFORMATION_TAG  0x13 /* LOCATION INFORMATION TAG */
+#define SATK_IMEI_TAG  0x14 /* IMEI TAG */
+#define SATK_HELP_REQUEST_TAG  0x15 /* HELP REQUEST TAG */
+#define SATK_NETWORK_MEASUREMENT_RESULTS_TAG   0x16 /* NETWORK MEASUREMENT RESULTS TAG */
+#define SATK_DEFAULT_TEXT_TAG  0x17 /* DEFAULT TEXT TAG */
+#define SATK_ITEMS_NEXT_ACTION_INDICATOR_TAG   0x18 /* ITEMS NEXT ACTION INDICATOR TAG */
+#define SATK_EVENT_LIST_TAG    0x19 /* EVENT LIST TAG */
+#define SATK_CAUSE_TAG 0x1A /* CAUSE TAG */
+#define SATK_LOCATION_STATUS_TAG       0x1B /* LOCATION STATUS TAG */
+#define SATK_BCCH_CHANNEL_LIST_TAG     0x1D /* BCCH CHANNEL LIST TAG */
+#define SATK_ICON_IDENTIFIER_TAG       0x1E /* ICON IDENTIFIER TAG */
+#define SATK_ITEM_ICON_IDENTIFIER_LIST_TAG     0x1F /* ITEM ICON IDENTIFIER LIST TAG */
+#define SATK_DATE_TIME_AND_TIME_ZONE_TAG       0x26 /* DATE TIME AND TIME ZONE TAG */
+#define SATK_CALL_CONTROL_REQUESTED_ACTION_TAG 0x27 /* CALL CONTROL REQUESTED ACTION TAG */
+#define SATK_AT_COMMAND_TAG    0x28 /* AT COMMAND TAG */
+#define SATK_AT_RESPONSE_TAG   0x29 /* AT RESPONSE TAG */
+#define SATK_BC_REPEAT_INDICATOR_TAG   0x2A /* BC REPEAT INDICATOR TAG */
+#define SATK_IMMEDIATE_RESPONSE_TAG    0x2B /* IMMEDIATE RESPONSE TAG */
+#define SATK_DTMF_STRING_TAG   0x2C /* DTMF STRING TAG */
+#define SATK_LANGUAGE_TAG      0x2D /* LANGUAGE TAG */
+#define SATK_BROWSER_IDENTITY_TAG      0x30 /* BROWSER IDENTITY TAG */
+#define SATK_URL_TAG   0x31 /* URL TAG */
+#define SATK_BEARER_TAG        0x32 /* BEARER TAG */
+#define SATK_PROVISIONING_REF_FILE_TAG 0x33 /* PROVISIONING REFERENCE FILE TAG */
+#define SATK_BROWSER_TERMINATION_CAUSE_TAG     0x34 /* BROWSER TERMINATION CAUSE TAG */
+#define SATK_BEARER_DISCRIPTION_TAG    0x35 /* BEARER DISCRIPTION TAG */
+#define SATK_CHANNEL_DATA_TAG  0x36 /* CHANNEL DATA TAG */
+#define SATK_CHANNEL_DATA_LEN_TAG      0x37 /* CHANNEL DATA LEN TAG */
+#define SATK_CHANNEL_STATUS_TAG        0x38 /* CHANNEL STATUS TAG */
+#define SATK_BUFFER_SIZE_TAG   0x39 /* BUFFER SIZE TAG */
+#define SATK_CARD_READER_IDENTIFIER_TAG        0x3A /* CARD READER IDENTIFIER TAG */
+#define SATK_USIM_ME_INTERFACE_TRANSPORT_LEVEL_TAG     0x3C /* USIM ME INTERFACE TRANSPORT LEVEL  */
+#define SATK_OTHER_ADDRESS_TAG 0x3E /* OTHER ADDRESS        */
+#define SATK_CDMA_SMS_TPDU_TAG 0x48 /* CDMA SMS TPDU TAG */
+#define SATK_NETWORK_ACCESS_TAG        0x48 /* NETWORK ACCESS NAME TAG */
+#define SATK_REMOTE_ENTITY_ADDRESS_TAG 0x48 /* REMOTE ENTITY ADDRESS TAG */
+
+/* general data object lengths */
+#define SATK_DCS_LENGTH 0x01
+#define SATK_COMMAND_DETAILS_LENGTH    0x03  /*  COMMAND DETAILS LENGTH */
+#define SATK_DEVICE_IDENTITY_LENGTH    0x02  /*  DEVICE IDENTITY LENGTH */
+#define SATK_ICON_IDENTITY_LENGTH      0x02  /*  ICON IDENTITY LENGTH */
+#define SATK_DURATION_LENGTH   0x02  /*  DURATION LENGTH */
+#define SATK_ITEM_IDENTIFIER_LENGTH    0x01  /*  ITEM IDENTIFIER LENGTH */
+#define SATK_LOCATION_INFORMATION_LENGTH       0x07  /*  LOCATION INFORMATION LENGTH */
+#define SATK_HELP_REQUEST_LENGTH       0x00  /*  HELP REQUEST LENGTH */
+#define SATK_LOCATION_STATUS_LENGTH    0x01  /*  LOCATION STATUS LENGTH */
+#define SATK_DATE_TIME_AND_TIME_ZONE_LENGTH    0x07  /*  DATE TIME AND TIME ZONE LENGTH */
+#define SATK_LANGUAGE_LENGTH   0x02  /*  LANGUAGE LENGTH */
+#define SATK_BC_REPEAT_IND_LENGTH      0x01  /*  BC REPEAT INDICATION LENGTH */
+#define SATK_RESPONSE_LENGTH_LENGTH    0x02  /*  RESPONSE LENGTH LENGTH */
+#define SATK_TONE_LENGTH       0x01  /*  TONE LENGTH */
+#define SATK_BROWSER_ID_LENGTH 0x01  /*  BROWSER ID LENGTH */
+#define SATK_BROWSER_TERMINATION_CAUSE_LENGTH  0x01  /*  BROWSER TERMINATION CAUSE LENGTH */
+#define SATK_BUFFER_SIZE_LENGTH        0x02 /*  BUFFER SIZE LENGTH */
+#define SATK_UICC_ME_TRANS_INTERFACE_LEVEL_LENGTH      0x03 /*  UICC TERMINAL TRANSPORT INTERFACE LEVEL LENGTH */
+#define SATK_CHANNEL_DATA_LENGTH_VALUE_LENGTH  0x01 /*  CHANNEL DATA LENGTH VALUE LENGTH */
+#define SATK_CHANNEL_STATUS_LENGTH     0x01 /*  CHANNEL STATUS LENGTH */
+
+struct private_object_data {
+       struct tcore_sat_operations *ops;
+};
+
+static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
+{
+       enum tcore_request_command command;
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_SAT, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po || !po->ops)
+               return TCORE_RETURN_ENOSYS;
+
+       command = tcore_user_request_get_command(ur);
+       switch (command) {
+               case TREQ_SAT_REQ_ENVELOPE:
+                       if (!po->ops->envelope)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->envelope(o, ur);
+                       break;
+
+               case TREQ_SAT_REQ_TERMINALRESPONSE:
+                       if (!po->ops->terminal_response)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->terminal_response(o, ur);
+                       break;
+
+               default:
+                       break;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+static void _free_hook(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SAT);
+
+       po = tcore_object_ref_object(o);
+       if (po) {
+               free(po);
+               tcore_object_link_object(o, NULL);
+       }
+}
+
+static int _get_length_filed_size(unsigned char firstLenByte)
+{
+       if (firstLenByte <= 0x7F) return 1;
+       else if (firstLenByte == 0x81) return 2;
+       else return 0; //return zero, as the length field can only be 1 or 2.
+}
+
+static void _get_string_data(unsigned char* src, int len,
+               struct tel_sat_text_string_object *text_obj)
+{
+       if (!src || !text_obj) return;
+
+       switch (text_obj->dcs.a_format) {
+               case ALPHABET_FROMAT_SMS_DEFAULT: {
+                       char* unpacked_str;
+
+                       text_obj->string_length = 0;
+                       unpacked_str = tcore_util_unpack_gsm7bit((const char*)src, (unsigned int)len);
+                       if (!unpacked_str) return;
+
+                       text_obj->dcs.a_format = ALPHABET_FROMAT_8BIT_DATA;
+                       text_obj->string_length = strlen(unpacked_str);
+
+                       if (text_obj->string_length >= SAT_TEXT_STRING_LEN_MAX) {
+                               text_obj->string_length = SAT_TEXT_STRING_LEN_MAX;
+                               memcpy(text_obj->string, unpacked_str, SAT_TEXT_STRING_LEN_MAX);
+                               text_obj->string[SAT_TEXT_STRING_LEN_MAX] = 0x00;
+                       }
+                       else {
+                               memcpy(text_obj->string, unpacked_str, text_obj->string_length);
+                               text_obj->string[text_obj->string_length] = 0x00;
+                       }
+
+                       g_free(unpacked_str);
+               }break;
+               case ALPHABET_FROMAT_UCS2:
+               case ALPHABET_FROMAT_8BIT_DATA: {
+
+                       if (text_obj->string_length >= SAT_TEXT_STRING_LEN_MAX) {
+                               text_obj->string_length = SAT_TEXT_STRING_LEN_MAX;
+                               memcpy(text_obj->string, src, SAT_TEXT_STRING_LEN_MAX);
+                               text_obj->string[SAT_TEXT_STRING_LEN_MAX] = 0x00;
+                       }
+                       else {
+                               memcpy(text_obj->string, src, text_obj->string_length);
+                               text_obj->string[text_obj->string_length] = 0x00;
+                       }
+               }break;
+               default: {
+                       dbg("[SAT] SAT PARSER -  Unknown alphabet format(%d)", text_obj->dcs.a_format);
+               }break;
+       }
+
+       return;
+}
+
+static void _sat_decode_dcs(unsigned char dcs, struct data_coding_scheme* dsc_obj)
+{
+       dbg("[SAT] SAT PARSER - dcs=[0x%x]", dcs);
+       dsc_obj->raw_dcs = dcs;
+       //bit 5 of DCS byte will tell us if the text is compressed or not.
+
+       if (dcs & 0x20)
+               dsc_obj->is_compressed_format = TRUE;
+       else
+               dsc_obj->is_compressed_format = FALSE;
+
+       //bit 4 when set, indicates that bits 0 & 1 have message class meaning.
+       dsc_obj->m_class = MSG_CLASS_NONE;
+       if (dcs & 0x10) {
+               switch (dcs & 0x03) {
+                       case 0x00:
+                               dsc_obj->m_class = MSG_CLASS_0;
+                               break;
+                       case 0x01:
+                               dsc_obj->m_class = MSG_CLASS_1;
+                               break;
+                       case 0x02:
+                               dsc_obj->m_class = MSG_CLASS_2;
+                               break;
+                       case 0x03:
+                               dsc_obj->m_class = MSG_CLASS_3;
+                               break;
+                       default:
+                               dsc_obj->m_class = MSG_CLASS_RESERVED;
+                               break;
+               }
+       }
+
+       /*bits 2 & 3 indicate the character set being used*/
+       switch (dcs & 0x0C) {
+               case 0x00:
+               case 0x0C:
+                       dsc_obj->a_format = ALPHABET_FROMAT_SMS_DEFAULT;
+                       break;
+
+               case 0x04:
+                       dsc_obj->a_format = ALPHABET_FROMAT_8BIT_DATA;
+                       break;
+
+               case 0X08:
+                       dsc_obj->a_format = ALPHABET_FROMAT_UCS2;
+                       break;
+
+               default:
+                       dsc_obj->a_format = ALPHABET_FROMAT_RESERVED;
+                       break;
+       }
+
+       dbg("[SAT] SAT PARSER - is_compressed_format(%d), msgClass(0x%x), alpha_format(0x%x)",
+                       dsc_obj->is_compressed_format, dsc_obj->m_class, dsc_obj->a_format);
+
+       return;
+}
+
+/*
+ * Decode TLV data object
+ */
+static enum tcore_sat_result _sat_decode_alpha_identifier_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_alpha_identifier* alpha_id_obj, int* consumed_data_len)
+{
+       unsigned char* src_data;
+       int index, len_of_len = 0;
+       int alpha_len = 0;
+
+       if (tlv_str == NULL || consumed_data_len == NULL || alpha_id_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || alpha_id_obj == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if (tlv_len <= (curr_offset + 1)) {
+               dbg("[SAT] SAT PARSER -  incorrect length original_command_len=%d", tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //tag
+       index = curr_offset;
+       src_data = &tlv_str[0];
+       if ((src_data[index++] & 0x7F) != SATK_ALPHA_IDENTIFIER_TAG) {
+               dbg("[SAT] SAT PARSER -  alphaID TAG missing");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //length
+       alpha_id_obj->is_exist = TRUE;
+       len_of_len = _get_length_filed_size(src_data[index]);
+       if (!len_of_len) {
+               dbg("[SAT] SAT PARSER -  incorrect length");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+       alpha_len = alpha_id_obj->alpha_data_len = src_data[index + len_of_len - 1];
+
+       //alpha identifier
+       index += len_of_len;
+       if ((index + alpha_len) > tlv_len) {
+               dbg("[SAT] SAT PARSER  -  incorrect length");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if (alpha_id_obj->alpha_data_len > 0) {
+
+               unsigned char dcs;
+
+               if (alpha_id_obj->alpha_data_len >= SAT_ALPHA_ID_LEN_MAX)
+                       alpha_id_obj->alpha_data_len = SAT_ALPHA_ID_LEN_MAX - 1;
+
+               memcpy(alpha_id_obj->alpha_data, &src_data[index], alpha_id_obj->alpha_data_len);
+               alpha_id_obj->alpha_data[alpha_id_obj->alpha_data_len] = 0x00;
+
+               if (src_data[index] == 0x80 || src_data[index] == 0x81 || src_data[index] == 0x82)
+                       dcs = 0X08;
+               else
+                       dcs = 0x04;
+
+               _sat_decode_dcs(dcs, &alpha_id_obj->dcs);
+       }
+
+       *consumed_data_len = 1 + len_of_len + alpha_len;
+       dbg("[SAT] SAT PARSER alphaId= %s", alpha_id_obj->alpha_data);
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_device_identities_tlv(unsigned char* tlv_str,
+               struct tel_sat_device_identities* dev_id_obj)
+{
+       int index = 0, i;
+
+       if (tlv_str == NULL || dev_id_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str ==NULL || dev_id_obj == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if ((tlv_str[index++] & 0x7F) != SATK_DEVICE_IDENTITY_TAG) {
+               dbg("[SAT] SAT PARSER -  device identity tag missing.");
+               return TCORE_SAT_REQUIRED_VALUE_MISSING; //send TR
+       }
+
+       if (tlv_str[index++] != SATK_DEVICE_IDENTITY_LENGTH) {
+               dbg("[SAT] SAT PARSER -  device identity length incorrect.");
+               return TCORE_SAT_REQUIRED_VALUE_MISSING; //send TR
+       }
+
+       for (i = 0; i < 2; i++) {
+               switch (tlv_str[index]) {
+                       case DEVICE_ID_KEYPAD:
+                       case DEVICE_ID_DISPLAY:
+                       case DEVICE_ID_EARPIECE:
+                       case DEVICE_ID_SIM:
+                       case DEVICE_ID_ME:
+                       case DEVICE_ID_NETWORK:
+                               if (i == 0) dev_id_obj->src = tlv_str[index];
+                               if (i == 1) dev_id_obj->dest = tlv_str[index];
+                               break;
+
+                       default:
+                               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+                               //send TR
+                               break;
+               }
+               index++;
+       }
+
+       dbg("[SAT] SAT PARSER -  source=%d, dest=%d", dev_id_obj->src, dev_id_obj->dest);
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_duration_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_duration *duration_obj, int* consumed_data_len)
+{
+       int index = 0;
+       unsigned char* src_data = NULL;
+
+       if (!tlv_str || !duration_obj || !consumed_data_len) {
+               err("[SAT] SAT PARSER data is null");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if (tlv_len < curr_offset + 3) {
+               err("[SAT] SAT PARSER -  incorrect length original_command_len=%d", tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       index = curr_offset;
+       src_data = &tlv_str[0];
+       if ((src_data[index++] & 0x7F) != SATK_DURATION_TAG) {
+               err("[SAT] SAT PARSER -  duration tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       if (src_data[index++] != SATK_DURATION_LENGTH) {
+               err("[SAT] SAT PARSER -  incorrect length value.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       //time unit
+       switch (src_data[index]) {
+               case TIME_UNIT_MINUTES:
+               case TIME_UNIT_SECONDS:
+               case TIME_UNIT_TENTHS_OF_SECONDS:
+                       duration_obj->time_unit = src_data[index];
+                       break;
+               default:
+                       duration_obj->time_unit = TIME_UNIT_RESERVED;
+                       break;
+       }
+
+       //interval
+       index++;
+       duration_obj->time_interval = src_data[index];
+       *consumed_data_len = 4;
+
+       dbg("[SAT] SAT PARSER -  timeUnit=%d, interval=%d", duration_obj->time_unit, duration_obj->time_interval);
+
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_item_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_item_info* item_obj, int* consumed_data_len)
+{
+       int index, len_of_len=0, i=0;
+       int item_len =0;
+       unsigned char* src_data = NULL;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || item_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || item_obj == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if(tlv_len <= (curr_offset+1)) {
+               dbg("[SAT] SAT PARSER -  incorrect length original_command_len=%d", tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //tag
+       index = curr_offset;
+       src_data = &tlv_str[0];
+       if((src_data[index++]&0x7F) != SATK_ITEM_TAG){
+               dbg("[SAT] SAT PARSER -  tag not found.=%d",src_data[index-1]);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //length
+       len_of_len = _get_length_filed_size(src_data[index]);
+       if(!len_of_len){
+               dbg("[SAT] SAT PARSER -  incorrect length");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+       item_len = src_data[index+len_of_len-1];
+
+       index+=len_of_len; //index pointing to item.
+       if((index+item_len) > tlv_len){
+               dbg("[SAT] SAT PARSER -  incorrect length");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       memset(item_obj->text, 0x00,(SAT_ITEM_TEXT_LEN_MAX+1));
+       if(item_len <= 0){
+               dbg("[SAT] SAT PARSER -  menu_text is NULL, remove the menu");
+               *consumed_data_len = 1+len_of_len+item_len;
+               return TCORE_SAT_SUCCESS;
+       }
+
+       //item
+       item_obj->item_id = src_data[index++];
+       // fix for orange SIM issue
+       // H0100078487 Strange Character display on SIM SAT
+       // The string length was less than its real length
+       // So garbage characters was displayed. To fix it, we would recalculate the real length.
+       for(i=0; i<item_len-1;i++){
+               dbg("[SAT] %d: %c", i, src_data[index+i]);
+               if(src_data[index+i] == 0xFF) break;
+       }
+       item_obj->text_len = i;
+
+       if(item_obj->text_len <= 0){
+               dbg("[SAT] SAT PARSER -  text len = 0");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if(item_obj->text_len > SAT_ITEM_TEXT_LEN_MAX)
+               item_obj->text_len = SAT_ITEM_TEXT_LEN_MAX;
+
+       memcpy(item_obj->text, &src_data[index], item_obj->text_len);
+
+       dbg("[SAT] SAT PARSER -  item_text=%s", item_obj->text);
+       *consumed_data_len = 1+len_of_len+item_len;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_response_length_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_response_length *response_obj, int* consumed_data_len)
+{
+       int index = 0;
+       unsigned char* src_data = NULL;
+
+       if (!tlv_str || !response_obj || !consumed_data_len) {
+               err("[SAT] SAT PARSER data is null");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if (tlv_len <= curr_offset + 1) {
+               err("[SAT] SAT PARSER -  incorrect length original_command_len=%d", tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       index = curr_offset;
+       src_data = &tlv_str[0];
+       if ((src_data[index++] & 0x7F) != SATK_RESPONSE_LENGTH_TAG) {
+               err("[SAT] SAT PARSER -  response length tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       if (src_data[index++] != SATK_RESPONSE_LENGTH_LENGTH) {
+               err("[SAT] SAT PARSER -  incorrect length value.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       response_obj->min = src_data[index++];
+       response_obj->max = src_data[index++];
+       dbg("[SAT] SAT PARSER  min length(%d), max length(%d)", response_obj->min, response_obj->max);
+
+       *consumed_data_len = 4;
+       if(response_obj->min > response_obj->max){
+               err("[SAT] SAT PARSER - : min length is larger than max length");
+               return TCORE_SAT_BEYOND_ME_CAPABILITY;
+       }
+
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_item_identifier_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_item_identifier *item_identifier_obj, int* consumed_data_len)
+{
+       int index = 0;
+       unsigned char* src_data = NULL;
+
+       if (!tlv_str || !item_identifier_obj || !consumed_data_len) {
+               err("[SAT] SAT PARSER data is null");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if (tlv_len <= curr_offset + 1) {
+               err("[SAT] SAT PARSER -  incorrect length original_command_len=%d", tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       index = curr_offset;
+       src_data = &tlv_str[0];
+       if ((src_data[index++] & 0x7F) != SATK_ITEM_IDENTIFIER_TAG) {
+               err("[SAT] SAT PARSER -  Item identifier tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       if (src_data[index++] != SATK_ITEM_IDENTIFIER_LENGTH) {
+               err("[SAT] SAT PARSER -  incorrect length value.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       item_identifier_obj->item_identifier = src_data[index++];
+       *consumed_data_len = 3;
+       dbg("[SAT] SAT PARSER item identifier(0x%02x)", item_identifier_obj->item_identifier);
+
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_text_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_text_string_object *text_obj, int* consumed_data_len)
+{
+       int index, len_of_len=0;
+       int text_len =0;
+       unsigned char* src_data;
+       gboolean comprehension_req = FALSE;
+
+       if (!tlv_str || !consumed_data_len ) {
+               err("[SAT] parser: data is null");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if(tlv_len <= (curr_offset+1)){
+               err("[SAT] parser: incorrect length");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //tag
+       index = curr_offset;
+       src_data = &tlv_str[0];
+       if((src_data[index]&0x7F) != SATK_TEXT_STRING_TAG){
+               err("[SAT] parser: text string tag missing, tag=0x%x",src_data[index]);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if(src_data[index++]&0x80)
+               comprehension_req = TRUE;
+
+       //length
+       len_of_len = _get_length_filed_size(src_data[index]);
+       if(!len_of_len){
+               err("[SAT] parser: invalid length.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       text_len = src_data[index+len_of_len-1];
+       dbg("[SAT] parser: text_tlv_len=%d",text_len);
+
+       index += len_of_len;
+       memset(text_obj->string, 0x00, SAT_TEXT_STRING_LEN_MAX);
+
+       //text
+       if(text_len <=1){
+               text_obj->string_length = 0;
+       }else{
+               text_obj->string_length = text_len-1;
+               _sat_decode_dcs(src_data[index++], &text_obj->dcs);
+               _get_string_data(&src_data[index], text_obj->string_length, text_obj);
+       }
+
+        // 1 is the length of Tag.
+       *consumed_data_len = 1 + len_of_len + text_len;
+
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_item_next_action_indicator_tlv(unsigned char* tlv_str,
+               int tlv_len, int curr_offset,
+               struct tel_sat_item_next_action_indicatior_list* item_next_act_indi_obj,
+               int* consumed_data_len)
+{
+       int index;
+       int item_nai_len;
+       unsigned char* src_data;
+       gboolean comprehension_req = FALSE;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || item_next_act_indi_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || item_next_act_indi_obj == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if(tlv_len <= (curr_offset+1)) {
+               dbg("[SAT] SAT PARSER - incorrect length original_command_len=%d", tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //tag
+       index = curr_offset;
+       src_data = &tlv_str[0];
+       if((src_data[index]&0x7F) != SATK_ITEMS_NEXT_ACTION_INDICATOR_TAG){
+               dbg("[SAT] SAT PARSER - tag not found.=%d",src_data[index]);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if((src_data[index++]&0x7F))
+               comprehension_req = TRUE;
+
+       //item cnt
+       item_nai_len = item_next_act_indi_obj->cnt = src_data[index++];
+       if((index+item_nai_len) > tlv_len) {
+               dbg("[SAT] SAT PARSER - incorrect cmd len, expected len = %d, orig_len=%d", (index+item_nai_len),tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if(item_next_act_indi_obj->cnt > SAT_ITEMS_NEXT_ACTION_INDI_LIST_MAX_COUNT) {
+               if(comprehension_req == TRUE) {
+                       dbg("[SAT] SAT PARSER - list count exceeds maximum allowed count=%d",item_next_act_indi_obj->cnt);
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+               }
+               item_next_act_indi_obj->cnt = 0;
+       }
+
+       memset(item_next_act_indi_obj->indicator_list, 0xFF, SAT_ITEMS_NEXT_ACTION_INDI_LIST_MAX_COUNT);
+       if(item_next_act_indi_obj->cnt > 0)
+               memcpy(item_next_act_indi_obj->indicator_list, &src_data[index], item_next_act_indi_obj->cnt);
+
+       *consumed_data_len = 1+1+item_nai_len;
+       dbg("[SAT] SAT PARSER - listCount=%d, consumed_data_len = %d",item_next_act_indi_obj->cnt, *consumed_data_len);
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_icon_identifier_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_icon_identifier* icon_id_obj, int* consumed_data_len)
+{
+       unsigned char* src_data;
+       int index = 0;
+
+       if(tlv_str == NULL || icon_id_obj == NULL ||consumed_data_len == NULL)  {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || icon_id_obj == NULL ||consumed_data_len == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if(tlv_len <= (curr_offset+1)) {//length of icon id tlv is 4
+               dbg("[SAT] SAT PARSER -  incorrect length original_command_len=%d", tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //tag
+       index = curr_offset;
+       src_data = &tlv_str[0];
+       if((src_data[index++]&0x7F) != SATK_ICON_IDENTIFIER_TAG) {
+               dbg("[SAT] SAT PARSER -  icon identity tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       if(src_data[index++] != SATK_ICON_IDENTITY_LENGTH) {
+               dbg("[SAT] SAT PARSER -  incorrect length value.");
+               return FALSE; //send TR
+       }
+
+       if((index+SATK_ICON_IDENTITY_LENGTH) > tlv_len) {
+               dbg("[SAT] SAT PARSER -  incorrect cmd len, expected len = %d, orig_len=%d", (index+SATK_ICON_IDENTITY_LENGTH),tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+       icon_id_obj->is_exist = TRUE;
+
+       if((src_data[index++]&0x01))
+               icon_id_obj->icon_qualifer = ICON_QUALI_NOT_SELF_EXPLANATORY;
+       else
+               icon_id_obj->icon_qualifer = ICON_QUALI_SELF_EXPLANATORY;
+
+       if(src_data[index] > 0x00) {
+               icon_id_obj->icon_identifier = src_data[index];
+       }
+       else {
+               dbg("[SAT] SAT PARSER -  incorrect icon identifier");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       dbg("[SAT] SAT PARSER -  icon_qual=%d, iconId=%d",icon_id_obj->icon_qualifer, icon_id_obj->icon_identifier);
+       *consumed_data_len = 4;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_icon_identifier_list_tlv(unsigned char* tlv_str,
+               int tlv_len, int curr_offset, struct tel_sat_icon_identifier_list* icon_list_obj,
+               int* consumed_data_len)
+{
+       int index, i;
+       int len_value =0;
+       unsigned char* src_data;
+       gboolean comprehension_req = FALSE;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || icon_list_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || icon_list_obj == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if(tlv_len <= (curr_offset+1)+1) {
+               dbg("[SAT] SAT PARSER -  incorrect length original_command_len=%d", tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //tag
+       index = curr_offset;
+       src_data = &tlv_str[0];
+       if((src_data[index]&0x7F) != SATK_ITEM_ICON_IDENTIFIER_LIST_TAG) {
+               dbg("[SAT] SAT PARSER -  icon identity tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       icon_list_obj->is_exist = TRUE;
+       if(src_data[index++]&0x80)
+               comprehension_req = TRUE;
+
+       len_value = src_data[index++];
+       if(src_data[index++]&0x01)
+               icon_list_obj->icon_qualifer = ICON_QUALI_NOT_SELF_EXPLANATORY;
+       else
+               icon_list_obj->icon_qualifer = ICON_QUALI_SELF_EXPLANATORY;
+
+       icon_list_obj->icon_cnt = len_value-1;
+       if(icon_list_obj->icon_cnt > SAT_ICON_LIST_MAX_COUNT){
+               if(comprehension_req == TRUE) {
+                       dbg("[SAT] SAT PARSER -  list count exceeds maximum allowed count=%d",icon_list_obj->icon_cnt);
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+               }
+               icon_list_obj->icon_cnt = 0;
+       }
+       else{
+
+               for(i=0;i<icon_list_obj->icon_cnt;i++) {
+                       if(src_data[index] > 0x00) {
+                               icon_list_obj->icon_id_list[i]= src_data[index++];
+                       } else  {
+                               dbg("[SAT] SAT PARSER -  incorrect icon identifier");
+                               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+                       }
+               }
+       }
+
+
+
+       *consumed_data_len = 1+1+len_value;
+       dbg("[SAT] SAT PARSER -  icon_qual=%d, iconCount=%d",icon_list_obj->icon_qualifer, icon_list_obj->icon_cnt);
+       return TCORE_SAT_SUCCESS;
+}
+
+//decode proactive cmd
+static enum tcore_sat_result _sat_decode_setup_event_list(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0;
+       unsigned char dev_id[4];
+       unsigned char* cmd_data = NULL;
+       enum tcore_sat_result rv = TCORE_SAT_SUCCESS;
+
+       if(o_cmd_data == NULL){
+               dbg("[SAT] SAT PARSER -  orig_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.setup_event_list.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.setup_event_list.command_detail.cmd_type = cmd_data[index++];
+
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.setup_event_list.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       index+=4;
+
+       //TOdo Eventlist parsing
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_display_text(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0;
+       int data_len_consumed=0;
+       unsigned char dev_id[4];
+       unsigned char* cmd_data = NULL;
+       enum tcore_sat_result rv = TCORE_SAT_SUCCESS;
+
+       if(o_cmd_data == NULL){
+               dbg("[SAT] SAT PARSER -  orig_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.display_text.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.display_text.command_detail.cmd_type = cmd_data[index++];
+
+       /* ******decode command qualifier****** */
+       if (cmd_data[index] & 0x01) {
+               sat_cmd_ind_data->data.display_text.command_detail.cmd_qualifier.display_text.text_priority =
+                               TEXT_PRIORITY_HIGH;
+               dbg("[SAT] SAT PARSER -  msg_prio=TAPI_SAT_MSG_PRIORITY_HIGH.");
+       }
+       else {
+               sat_cmd_ind_data->data.display_text.command_detail.cmd_qualifier.display_text.text_priority =
+                               TEXT_PRIORITY_NORMAL;
+               dbg("[SAT] SAT PARSER - : msg_prio=TAPI_SAT_MSG_PRIORITY_NORMAL.");
+       }
+
+       if (cmd_data[index] & 0x80) {
+               sat_cmd_ind_data->data.display_text.command_detail.cmd_qualifier.display_text.text_clear_type =
+                               TEXT_WAIT_FOR_USER_TO_CLEAR_MSG;
+               dbg("[SAT] SAT PARSER - : msgClear=TAPI_SAT_WAIT_FOR_USER_TO_CLEAR_MSG.");
+       }
+       else {
+               sat_cmd_ind_data->data.display_text.command_detail.cmd_qualifier.display_text.text_clear_type =
+                               TEXT_AUTO_CLEAR_MSG_AFTER_A_DELAY;
+               dbg("[SAT] SAT PARSER -  msgClear=TAPI_SAT_AUTO_CLEAR_MSG_AFTER_A_DELAY.");
+       }
+
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.display_text.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       index+=4;
+       rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.display_text.text, &data_len_consumed);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       if(sat_cmd_ind_data->data.display_text.text.string_length <= 0){
+               err("[SAT] SAT PARSER - :string length is 0");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       dbg("[SAT] SAT PARSER  text(%s)",sat_cmd_ind_data->data.display_text.text.string);
+       dbg("[SAT] SAT PARSER o_len(%d) index(%d) data_len_consumed(%d)",o_length , index, data_len_consumed);
+
+       if(index+data_len_consumed > o_length){
+               err("[SAT] SAT PARSER - Wrong String TLV");
+               return TCORE_SAT_BEYOND_ME_CAPABILITY;
+       }
+       else if(index+data_len_consumed == o_length){
+               dbg("[SAT] SAT PARSER - :no more TLVs to decode.");
+               return TCORE_SAT_SUCCESS;
+       }
+
+       //icon identifier
+       index+=data_len_consumed;
+       if((cmd_data[index]&0x7F) == SATK_ICON_IDENTIFIER_TAG){
+               data_len_consumed = 0;
+               rv = _sat_decode_icon_identifier_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.display_text.icon_id, &data_len_consumed);
+
+               if(rv != TCORE_SAT_SUCCESS){
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //SEND TR
+               }
+
+               if(index+data_len_consumed >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+       }
+
+       //immediate response
+       sat_cmd_ind_data->data.display_text.immediate_response_requested = FALSE;
+       if((cmd_data[index]&0x7F) == SATK_IMMEDIATE_RESPONSE_TAG){
+               dbg("[SAT] SAT PARSER - :immediate response required.");
+               sat_cmd_ind_data->data.display_text.immediate_response_requested = TRUE;
+               index+=2;
+       }
+
+       if(index >= o_length){
+               dbg("[SAT] SAT PARSER - :no more TLVs to decode.");
+               return TCORE_SAT_SUCCESS;
+       }
+
+       //time duration
+       if((cmd_data[index]&0x7F)==SATK_DURATION_TAG){
+               rv =_sat_decode_duration_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.display_text.duration, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS){
+                       return rv; //SEND TR
+               }
+       }
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_get_inkey(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0;
+       int data_len_consumed=0;
+       unsigned char dev_id[4];
+       unsigned char* cmd_data = NULL;
+       enum tcore_sat_result rv = TCORE_SAT_SUCCESS;
+
+       if(o_cmd_data == NULL){
+               dbg("[SAT] SAT PARSER -  orig_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.get_inkey.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.get_inkey.command_detail.cmd_type = cmd_data[index++];
+
+       /* ******decode command qualifier****** */
+       if (cmd_data[index] & 0x01) {
+               sat_cmd_ind_data->data.get_inkey.command_detail.cmd_qualifier.get_inkey.alphabet_set = TRUE;
+               dbg("[SAT] SAT PARSER - Alphabet set");
+       }
+
+       if(cmd_data[index]&0x02){
+               sat_cmd_ind_data->data.get_inkey.command_detail.cmd_qualifier.get_inkey.alphabet_type = INPUT_ALPHABET_TYPE_UCS2;
+               dbg("[SAT] SAT PARSER -  INPUT_ALPHABET_TYPE_UCS2");
+       }
+       else{
+               sat_cmd_ind_data->data.get_inkey.command_detail.cmd_qualifier.get_inkey.alphabet_type = INPUT_ALPHABET_TYPE_SMS_DEFAULT;
+               dbg("[SAT] SAT PARSER -  INPUT_ALPHABET_TYPE_SMS_DEFAULT");
+       }
+
+       if(cmd_data[index]&0x04){
+               sat_cmd_ind_data->data.get_inkey.command_detail.cmd_qualifier.get_inkey.inkey_type = INKEY_TYPE_YES_NO_REQUESTED;
+               dbg("[SAT] SAT PARSER -  INKEY_TYPE_YES_NO_REQUESTED");
+       }
+       else{
+               sat_cmd_ind_data->data.get_inkey.command_detail.cmd_qualifier.get_inkey.inkey_type = INKEY_TYPE_CHARACTER_SET_ENABLED;
+               dbg("[SAT] SAT PARSER -  INKEY_TYPE_YES_NO_REQUESTED");
+       }
+
+       if(cmd_data[index]&0x08){
+               sat_cmd_ind_data->data.get_inkey.command_detail.cmd_qualifier.get_inkey.immediate_rsp_required = TRUE;
+               dbg("[SAT] SAT PARSER -  immediate response requested");
+       }
+
+       if (cmd_data[index] & 0x80) {
+               sat_cmd_ind_data->data.get_inkey.command_detail.cmd_qualifier.get_inkey.help_info = TRUE;
+               dbg("[SAT] SAT PARSER - Help info");
+       }
+
+       //device identities
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.get_inkey.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //text
+       index+=4;
+       rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.get_inkey.text, &data_len_consumed);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       if(sat_cmd_ind_data->data.get_inkey.text.string_length <= 0){
+               err("[SAT] SAT PARSER - :string length is 0");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       dbg("[SAT] SAT PARSER  text(%s)",sat_cmd_ind_data->data.get_inkey.text.string);
+       dbg("[SAT] SAT PARSER o_len(%d) index(%d) data_len_consumed(%d)",o_length , index, data_len_consumed);
+
+       if(index+data_len_consumed > o_length){
+               err("[SAT] SAT PARSER - Wrong String TLV");
+               return TCORE_SAT_BEYOND_ME_CAPABILITY;
+       }
+       else if(index+data_len_consumed == o_length){
+               dbg("[SAT] SAT PARSER - :no more TLVs to decode.");
+               return TCORE_SAT_SUCCESS;
+       }
+
+       //icon identifier
+       index+=data_len_consumed;
+       if((cmd_data[index]&0x7F) == SATK_ICON_IDENTIFIER_TAG){
+               data_len_consumed = 0;
+               rv = _sat_decode_icon_identifier_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.get_inkey.icon_id, &data_len_consumed);
+
+               if(rv != TCORE_SAT_SUCCESS){
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //SEND TR
+               }
+
+               if(index+data_len_consumed >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+       }
+
+       //time duration
+       if((cmd_data[index]&0x7F)==SATK_DURATION_TAG){
+               rv =_sat_decode_duration_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.get_inkey.duration, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS){
+                       return rv; //SEND TR
+               }
+       }
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_get_input(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0;
+       int data_len_consumed=0;
+       unsigned char dev_id[4];
+       unsigned char* cmd_data = NULL;
+       enum tcore_sat_result rv = TCORE_SAT_SUCCESS;
+
+       if(o_cmd_data == NULL){
+               dbg("[SAT] SAT PARSER -  orig_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.get_input.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.get_input.command_detail.cmd_type = cmd_data[index++];
+
+       /* ******decode command qualifier****** */
+       if (cmd_data[index] & 0x01) {
+               sat_cmd_ind_data->data.get_input.command_detail.cmd_qualifier.get_inkey.alphabet_set = TRUE;
+               dbg("[SAT] SAT PARSER - Alphabet set");
+       }
+
+       if(cmd_data[index]&0x02){
+               sat_cmd_ind_data->data.get_input.command_detail.cmd_qualifier.get_input.alphabet_type = INPUT_ALPHABET_TYPE_UCS2;
+               dbg("[SAT] SAT PARSER -  INPUT_ALPHABET_TYPE_UCS2");
+       }
+       else{
+               sat_cmd_ind_data->data.get_input.command_detail.cmd_qualifier.get_input.alphabet_type = INPUT_ALPHABET_TYPE_SMS_DEFAULT;
+               dbg("[SAT] SAT PARSER -  INPUT_ALPHABET_TYPE_SMS_DEFAULT");
+       }
+
+       if(cmd_data[index]&0x04){
+               sat_cmd_ind_data->data.get_input.command_detail.cmd_qualifier.get_input.me_echo_user_input = TRUE;
+               dbg("[SAT] SAT PARSER -  Me Echo user input");
+       }
+
+       if(cmd_data[index]&0x08){
+               sat_cmd_ind_data->data.get_input.command_detail.cmd_qualifier.get_input.user_input_unpacked_format = FALSE;
+               dbg("[SAT] SAT PARSER - User input unpacked format - FALSE");
+       }
+       else{
+               sat_cmd_ind_data->data.get_input.command_detail.cmd_qualifier.get_input.user_input_unpacked_format = TRUE;
+               dbg("[SAT] SAT PARSER - User input unpacked format - TRUE");
+       }
+
+       if (cmd_data[index] & 0x80) {
+               sat_cmd_ind_data->data.get_input.command_detail.cmd_qualifier.get_input.help_info = TRUE;
+               dbg("[SAT] SAT PARSER - Help info");
+       }
+
+       //device identities
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.get_input.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //text
+       index+=4;
+       rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.get_input.text, &data_len_consumed);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       if(sat_cmd_ind_data->data.get_input.text.string_length <= 0){
+               err("[SAT] SAT PARSER - :string length is 0");
+       }
+       dbg("[SAT] SAT PARSER  text(%s)",sat_cmd_ind_data->data.get_input.text.string);
+
+       //response length
+       index+=data_len_consumed;
+       rv = _sat_decode_response_length_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.get_input.rsp_len, &data_len_consumed);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       if(index+data_len_consumed >= o_length){
+               err("[SAT] SAT PARSER - no more TLVs");
+               return TCORE_SAT_SUCCESS;
+       }
+
+       //default text
+       index+=data_len_consumed;
+       if((o_cmd_data[index]&0x7F) == SATK_DEFAULT_TEXT_TAG){
+               rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.get_input.default_text, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS)
+                       return rv;
+
+               if(sat_cmd_ind_data->data.get_input.default_text.string_length <= 0){
+                       err("[SAT] SAT PARSER - :string length is 0");
+               }
+               dbg("[SAT] SAT PARSER default text(%s)",sat_cmd_ind_data->data.get_input.default_text.string);
+               index+=data_len_consumed;
+       }
+
+       //icon identifier
+       if((cmd_data[index]&0x7F) == SATK_ICON_IDENTIFIER_TAG){
+               data_len_consumed = 0;
+               rv = _sat_decode_icon_identifier_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.display_text.icon_id, &data_len_consumed);
+
+               if(rv != TCORE_SAT_SUCCESS){
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //SEND TR
+               }
+
+               if(index+data_len_consumed >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+       }
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_select_item(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0;
+       int data_len_consumed=0;
+       unsigned char dev_id[4];
+       unsigned char* cmd_data = NULL;
+       enum tcore_sat_result rv = TCORE_SAT_SUCCESS;
+
+       if(o_cmd_data == NULL){
+               dbg("[SAT] SAT PARSER -  orig_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.select_item.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.select_item.command_detail.cmd_type = cmd_data[index++];
+
+       /* ******decode command qualifier****** */
+       if (cmd_data[index] & 0x01) {
+               if (cmd_data[index] & 0x02) {
+                       sat_cmd_ind_data->data.select_item.command_detail.cmd_qualifier.select_item.presentation_type = PRESENTATION_TYPE_NAVIGATION_OPTION;
+                       dbg("[SAT] SAT PARSER - PRESENTATION_TYPE_NAVIGATION_OPTION");
+               }
+               else{
+                       sat_cmd_ind_data->data.select_item.command_detail.cmd_qualifier.select_item.presentation_type = PRESENTATION_TYPE_DATA_VALUE;
+                       dbg("[SAT] SAT PARSER - PRESENTATION_TYPE_DATA_VALUE");
+               }
+       }
+       else {
+               sat_cmd_ind_data->data.select_item.command_detail.cmd_qualifier.select_item.presentation_type = PRESENTATION_TYPE_NOT_SPECIFIED;
+               dbg("[SAT] SAT PARSER - PRESENTATION_TYPE_NOT_SPECIFIED");
+       }
+
+       if (cmd_data[index] & 0x04) {
+               sat_cmd_ind_data->data.select_item.command_detail.cmd_qualifier.select_item.select_preference = SELECTION_PREFERENCE_USING_SOFT_KEY;
+               dbg("[SAT] SAT PARSER - SELECTION_PREFERENCE_USING_SOFT_KEY");
+       }
+       else {
+               sat_cmd_ind_data->data.select_item.command_detail.cmd_qualifier.select_item.select_preference = SELECTION_PREFERENCE_NONE_REQUESTED;
+               dbg("[SAT] SAT PARSER - SELECTION_PREFERENCE_NONE_REQUESTED");
+       }
+
+       if (cmd_data[index] & 0x80) {
+               sat_cmd_ind_data->data.select_item.command_detail.cmd_qualifier.select_item.help_info = TRUE;
+               dbg("[SAT] SAT PARSER - Help info");
+       }
+
+       //device identities
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.select_item.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //alpha identifier
+       index+=4;
+       if((cmd_data[index]&0x7F) == SATK_ALPHA_IDENTIFIER_TAG){
+               rv = _sat_decode_alpha_identifier_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.select_item.alpha_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+               index+=data_len_consumed;
+       }
+
+       //item objects
+       sat_cmd_ind_data->data.select_item.menu_item_cnt = 0;
+       do{
+               data_len_consumed=0;
+
+               if((cmd_data[index]&0x7F) == SATK_ITEM_TAG) {
+                       rv = _sat_decode_item_tlv(o_cmd_data, o_length, index,
+                               &sat_cmd_ind_data->data.select_item.menu_item[sat_cmd_ind_data->data.select_item.menu_item_cnt],
+                               &data_len_consumed);
+
+                       if(rv != TCORE_SAT_SUCCESS)
+                               return rv;
+               }
+               else {
+                       if(sat_cmd_ind_data->data.select_item.menu_item_cnt == 0) {
+                               dbg("menu item is not exist.");
+                               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+                       }
+                       //else
+                       break;  //???
+               }
+               sat_cmd_ind_data->data.select_item.menu_item_cnt++;
+               index += data_len_consumed;
+
+               if(index >= o_length)
+                       break;
+
+       }while(sat_cmd_ind_data->data.select_item.menu_item_cnt < SAT_MENU_ITEM_COUNT_MAX);
+
+       dbg("[SAT] SAT PARSER - select menu item_count=%d",sat_cmd_ind_data->data.select_item.menu_item_cnt);
+       if(index >= o_length){
+               dbg("[SAT] SAT PARSER - :no more TLVs to decode.");
+               return TCORE_SAT_SUCCESS;
+       }
+
+       //item next action indicator
+       if((cmd_data[index]&0x7F) == SATK_ITEMS_NEXT_ACTION_INDICATOR_TAG) {
+               data_len_consumed = 0;
+               rv = _sat_decode_item_next_action_indicator_tlv(o_cmd_data, o_length, index,
+                               &sat_cmd_ind_data->data.select_item.item_next_act_ind_list, &data_len_consumed);
+               if(rv!=TCORE_SAT_SUCCESS)
+                       return rv;
+
+               if(index+data_len_consumed >= o_length) {
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+
+               index+=data_len_consumed;
+       }
+
+       //item identifier
+       if((cmd_data[index]&0x7F) == SATK_ITEM_IDENTIFIER_TAG) {
+               data_len_consumed = 0;
+               rv = _sat_decode_item_identifier_tlv(o_cmd_data, o_length, index,
+                               &sat_cmd_ind_data->data.select_item.item_identifier, &data_len_consumed);
+               if(rv !=TCORE_SAT_SUCCESS)
+                       return rv;
+
+               if(index+data_len_consumed >= o_length) {
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+       }
+
+       //icon identifier
+       if((cmd_data[index]&0x7F) == SATK_ICON_IDENTIFIER_TAG){
+               data_len_consumed = 0;
+               rv = _sat_decode_icon_identifier_tlv(o_cmd_data, o_length, index,
+                               &sat_cmd_ind_data->data.select_item.icon_id, &data_len_consumed);
+
+               if(rv != TCORE_SAT_SUCCESS){
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //SEND TR
+               }
+
+               if(index+data_len_consumed >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+       }
+
+       if((cmd_data[index]&0x7F) == SATK_ITEM_ICON_IDENTIFIER_LIST_TAG) {
+               data_len_consumed = 0;
+               rv = _sat_decode_icon_identifier_list_tlv(o_cmd_data, o_length, index,
+                               &sat_cmd_ind_data->data.select_item.icon_list, &data_len_consumed);
+               if(rv !=TCORE_SAT_SUCCESS)
+                       return rv; //SEND TR
+
+               if(index+data_len_consumed >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+       }
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_setup_menu(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tcore_sat_proactive_command *pactive_cmd_ind_obj)
+{
+       int index = 0;
+       int data_len_consumed=0;
+       unsigned char dev_id[4];
+       unsigned char* src_data;
+       enum tcore_sat_result rv = TCORE_SAT_SUCCESS;
+
+       //access command detail
+       index = curr_offset+2; //move the index to command detail info +2(tag and length)
+       src_data = &tlv_str[0];
+
+// In this time, the point of index is COMMAND NUMBER
+// [1] insert command detail information into each proactive command data structure.
+       pactive_cmd_ind_obj->data.setup_menu.command_detail.cmd_num = src_data[index++];
+       pactive_cmd_ind_obj->data.setup_menu.command_detail.cmd_type = src_data[index++];
+
+// [2] decode COMMAND QUALIFIER
+/*
+-bit 1:        0 = no selection preference;
+               1 = selection using soft key preferred.
+-bits 2 to 7:  = RFU.
+-bit 8:        0 = no help information available;
+               1 = help information available.
+*/
+
+//[2-1] selection preference
+       if (src_data[index] & 0x01) {
+               pactive_cmd_ind_obj->data.setup_menu.command_detail.cmd_qualifier.setup_menu.select_preference =
+                               SELECTION_PREFERENCE_USING_SOFT_KEY;
+               dbg("[SAT] SAT PARSER -  sel_pref=SAT_SELECTION_PREFERENCE_USING_SOFT_KEY.");
+       }
+       else {
+               pactive_cmd_ind_obj->data.setup_menu.command_detail.cmd_qualifier.setup_menu.select_preference =
+                               SELECTION_PREFERENCE_NONE_REQUESTED;
+               dbg("[SAT] SAT PARSER - : sel_pref=SAT_SELECTION_PREFERENCE_NONE_REQUESTED.");
+       }
+
+//[2-2] help available
+       if (src_data[index] & 0x80) {
+               pactive_cmd_ind_obj->data.setup_menu.command_detail.cmd_qualifier.setup_menu.help_info =
+                               TRUE;
+               ;dbg("[SAT] SAT PARSER - : is help Available=TRUE.");
+       }
+       else {
+               pactive_cmd_ind_obj->data.setup_menu.command_detail.cmd_qualifier.setup_menu.help_info =
+                               FALSE;
+               dbg("[SAT] SAT PARSER -  is help Available=FALSE.");
+       }
+
+// In this time, the point of index is DEVICE IDENTITIES.
+//[3] decode DEVICE IDENTITIES TLV
+       index++;
+       memcpy(dev_id, &src_data[index], 4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &pactive_cmd_ind_obj->data.setup_menu.device_id);
+       if (rv != TCORE_SAT_SUCCESS) {
+               //send TR in SatkProcessProactiveCmdInd()
+               return rv;
+       }
+
+
+// In this time, the point of index is ALPHA IDENTIFIER. 11 or 12.
+//[4] decode ALPHA IDENTIFIER TLV
+       index+=4;
+       dbg("[SAT] SAT PARSER - :index=%d",index);
+       rv = _sat_decode_alpha_identifier_tlv(src_data, tlv_len, index,
+                       &pactive_cmd_ind_obj->data.setup_menu.alpha_id, &data_len_consumed);
+       if(rv != TCORE_SAT_SUCCESS) {
+               return rv;
+       }
+
+// In this time, the point of index is ITEM  TLV
+//[5] decode ITEM LIST (at least one is mandatory)
+       index+= data_len_consumed;
+       pactive_cmd_ind_obj->data.setup_menu.menu_item_cnt = 0;
+       do{
+               data_len_consumed=0;
+               if((src_data[index]&0x7F) == SATK_ITEM_TAG) {
+                       rv = _sat_decode_item_tlv(src_data, tlv_len, index,
+                                               &pactive_cmd_ind_obj->data.setup_menu.menu_item[pactive_cmd_ind_obj->data.setup_menu.menu_item_cnt],
+                                               &data_len_consumed);
+
+                       if(rv != TCORE_SAT_SUCCESS)
+                               return rv;
+               }
+               else {
+                       if(pactive_cmd_ind_obj->data.setup_menu.menu_item_cnt == 0) {
+                               dbg("menu item is not exist.");
+                               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+                       }
+                       //else
+                       break;  //???
+               }
+               pactive_cmd_ind_obj->data.setup_menu.menu_item_cnt++;
+               index += data_len_consumed;
+
+               if(index >= tlv_len)
+                       break;
+       }while(pactive_cmd_ind_obj->data.setup_menu.menu_item_cnt < SAT_MENU_ITEM_COUNT_MAX);
+
+       dbg("[SAT] SAT PARSER - :setup menu item_count=%d",pactive_cmd_ind_obj->data.setup_menu.menu_item_cnt);
+       if(index >= tlv_len){
+               dbg("[SAT] SAT PARSER - :no more TLVs to decode.");
+               //send TR in SatkProcessProactiveCmdInd()
+               return TCORE_SAT_SUCCESS;
+       }
+
+//[6] (optional TLV) decode ITEMS NEXT ACTION INDICATOR TLV
+       if((src_data[index]&0x7F) == SATK_ITEMS_NEXT_ACTION_INDICATOR_TAG) {
+               data_len_consumed = 0;
+               rv = _sat_decode_item_next_action_indicator_tlv(tlv_str, tlv_len, index,
+                               &pactive_cmd_ind_obj->data.setup_menu.next_act_ind_list, &data_len_consumed);
+               if(rv!=TCORE_SAT_SUCCESS) return rv;
+
+               if(index+data_len_consumed >= tlv_len) {
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       //send the data to Noti manager.
+                       return TCORE_SAT_SUCCESS;
+               }
+
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+       }
+       else {
+               dbg("[SAT] SAT PARSER -  ITEMS NEXT ACTION INDICATOR TLV Not present");
+       }
+
+//[7] (optional TLV) decode ICON IDENTIFIER TLV
+       if((src_data[index]&0x7F) == SATK_ICON_IDENTIFIER_TAG) {
+               data_len_consumed = 0;
+               rv = _sat_decode_icon_identifier_tlv(tlv_str, tlv_len, index,
+                               &pactive_cmd_ind_obj->data.setup_menu.icon_id, &data_len_consumed);
+               if(rv !=TCORE_SAT_SUCCESS) return rv;
+
+               if(index+data_len_consumed >= tlv_len) {
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       //send the data to Noti manager.
+                       return TCORE_SAT_SUCCESS;
+               }
+
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+       }
+       else{
+               dbg("[SAT] SAT PARSER - ICON IDENTIFIER TLV Not present");
+       }
+
+//[8] (optional TLV) decode ICON IDENTIFIER LIST TLV
+       if((src_data[index]&0x7F) == SATK_ITEM_ICON_IDENTIFIER_LIST_TAG) {
+               data_len_consumed = 0;
+               rv = _sat_decode_icon_identifier_list_tlv(tlv_str, tlv_len, index,
+                               &pactive_cmd_ind_obj->data.setup_menu.icon_list, &data_len_consumed);
+               if(rv !=TCORE_SAT_SUCCESS) return rv; //SEND TR
+
+               if(index+data_len_consumed >= tlv_len){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       //send the data to Noti manager.
+                       return TCORE_SAT_SUCCESS;
+               }
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+
+       }
+       else {
+               dbg("[SAT] SAT PARSER - ICON IDENTIFIER LIST TLV not present");
+       }
+
+       //decoding done, send data to client
+       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+       return TCORE_SAT_SUCCESS;
+//ToDo:  Text Attribute, Text Attribute list. refer ETSI 102.223.
+}
+
+int tcore_sat_decode_proactive_command(unsigned char* tlv_origin, unsigned int tlv_length,
+               struct tcore_sat_proactive_command* decoded_tlv)
+{
+       unsigned int index = 0;
+       int length_field_len = 0;
+       enum tcore_sat_result rv = TCORE_SAT_SUCCESS;
+
+       if(tlv_origin == NULL || tlv_length <=2) {
+               dbg("[SAT] SAT PARSER - pointer pData passed is NULL or invalid length.");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //tag
+       if(tlv_origin[index++]!= SATK_PROACTIVE_CMD_TAG) {
+               dbg("[SAT] SAT PARSER - Did not find Proactive command tag.tag=%d", tlv_origin[index-1]);
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //length
+       length_field_len = _get_length_filed_size(tlv_origin[index]);
+       if(length_field_len == 0) {
+               dbg("[SAT] SAT PARSER - Invalid length.");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       index+=length_field_len;
+
+       //check command validation
+       if(tlv_length < index+5+4)//command detail(5) and device identities(4)
+               return TCORE_SAT_ERROR_FATAL;
+
+       if( (tlv_origin[index] & 0x7F) != SATK_COMMAND_DETAILS_TAG){
+               err("[SAT] no command detail info");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if( tlv_origin[index+1] != SATK_COMMAND_DETAILS_LENGTH){
+               err("[SAT] invalid command detail length");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       decoded_tlv->cmd_num= tlv_origin[index+2];
+       decoded_tlv->cmd_type = tlv_origin[index+3];
+
+       switch(decoded_tlv->cmd_type) {
+               case SAT_PROATV_CMD_SETUP_EVENT_LIST:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SETUP_EVENT_LIST");
+                       //TOdo
+                       rv = _sat_decode_setup_event_list(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_DISPLAY_TEXT:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_DISPLAY_TEXT");
+                       rv = _sat_decode_display_text(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_GET_INKEY:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_GET_INKEY");
+                       rv = _sat_decode_get_inkey(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_GET_INPUT:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_GET_INPUT");
+                       rv = _sat_decode_get_input(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_SELECT_ITEM:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SELECT_ITEM");
+                       rv = _sat_decode_select_item(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_SETUP_MENU:
+                       dbg("[SAT] SAT PARSER - SAT_PROATV_CMD_SETUP_MENU");
+                       rv = _sat_decode_setup_menu(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+#if 0
+               case SAT_CMD_TYPE_MORE_TIME:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_MORE_TIME");
+                       rv = SatkProcessMoreTimeInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_REFRESH:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_REFRESH");
+                       rv = SatkProcessRefreshInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_SEND_SMS:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SEND_SMS");
+                       rv = SatkProcessSendSmsInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_SEND_SS:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SEND_SS");
+                       rv = SatkProcessSendSsInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_SEND_USSD:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SEND_USSD");
+                       rv = SatkProcessSendUssdInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_SETUP_CALL:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SETUP_CALL");
+                       rv = SatkProcessSetupCallInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_PLAY_TONE:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_PLAY_TONE");
+                       rv = SatkProcessPlayToneInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+                       //others to be added later
+
+               case SAT_CMD_TYPE_SETUP_IDLE_MODE_TEXT:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SETUP_IDLE_MODE_TEXT");
+                       rv = SatkProcessSetupIdleModeTextInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_PROVIDE_LOCAL_INFO:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_PROVIDE_LOCAL_INFO");
+                       rv = SatkProcessProvideLocalInfoInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_LANGUAGE_NOTIFICATION:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_LANGUAGE_NOTIFICATION");
+                       rv = SatkProcessLanguageNotificationInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_SEND_DTMF:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SEND_DTMF");
+                       rv = SatkProcessSendDtmfInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_LAUNCH_BROWSER:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_LAUNCH_BROWSER");
+                       rv = SatkProcessLaunchBrowserInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+#endif
+       #ifdef SAT_BIP
+               case SAT_CMD_TYPE_OPEN_CHANNEL:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_OPEN_CHANNEL");
+                       rv = SatkProcessOpenChannelInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_CLOSE_CHANNEL:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_CLOSE_CHANNEL");
+                       rv = SatkProcessCloseChannelInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_RECEIVE_DATA:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_RECEIVE_DATA");
+                       rv = SatkProcessReceiveDataInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_SEND_DATA:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SEND_DATA");
+                       rv = SatkProcessSendDataInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+
+               case SAT_CMD_TYPE_GET_CHANNEL_STATUS:
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_GET_CHANNEL_STATUS");
+                       rv = SatkProcessGetChannelStatusInd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+       #endif
+               default:
+                       dbg("[SAT] SAT PARSER - ME cannot perform this command =0x[%02x]", decoded_tlv->cmd_type);
+                       //SEND TR with command not understood by ME, those command that are defined but not implemented by ME should be sent as beyond me's capability.
+                       rv = TCORE_SAT_BEYOND_ME_CAPABILITY;
+                       break;
+       }
+
+       //return value will be success if the proactive command has been successfuly decoded, then send it to clients.
+       dbg("[SAT] SAT PARSER - each command parsing done.");
+       return rv;
+}
+
+static unsigned char _sat_encode_dcs_tlv(const struct data_coding_scheme* src)
+{
+       unsigned char rv = 0x00;
+
+       if(src == NULL)
+               return 0;
+
+       if(src->is_compressed_format)
+               rv |= 0x20;
+
+       //msg class
+       switch(src->m_class){
+               case MSG_CLASS_0:
+               case MSG_CLASS_1:
+               case MSG_CLASS_2:
+               case MSG_CLASS_3:
+                       rv |= 0x10;
+                       rv |= src->m_class;
+               break;
+
+               case MSG_CLASS_RESERVED:
+               case MSG_CLASS_NONE:
+               default:
+                       rv &= 0xEF;
+                       break;
+       }
+
+       //alphabet format
+       switch(src->a_format)
+       {
+               case ALPHABET_FROMAT_SMS_DEFAULT:
+                       rv &= 0xF3;
+                       break;
+
+               case ALPHABET_FROMAT_8BIT_DATA:
+                       rv |= 0x04;
+                       break;
+
+               case ALPHABET_FROMAT_UCS2:
+                       rv |= 0x08;
+                       break;
+
+               default:
+                       rv |= 0x0C;
+                       break;
+       }
+
+       return rv;
+}
+
+static int _sat_encode_command_detail_tlv(const struct tel_sat_cmd_detail_info* src, char *dst, int current_index)
+{
+       dst[current_index++] = SATK_COMMAND_DETAILS_TAG;
+       dst[current_index++] = SATK_COMMAND_DETAILS_LENGTH;
+       dst[current_index++] = src->cmd_num;
+       dst[current_index++] = src->cmd_type;
+
+       switch(src->cmd_type){
+               case SAT_PROATV_CMD_SETUP_EVENT_LIST:{
+                       dbg("setup evnet list : 1bit RFU")
+               }break;
+               case SAT_PROATV_CMD_DISPLAY_TEXT:{
+                       dst[current_index++] = 0x00;
+
+                       //command detail text priority
+                       if (src->cmd_qualifier.display_text.text_priority == TEXT_PRIORITY_HIGH)
+                               dst[current_index] += 0x01;
+
+                       //command detail text clear type
+                       if (src->cmd_qualifier.display_text.text_clear_type == TEXT_WAIT_FOR_USER_TO_CLEAR_MSG)
+                               dst[current_index] += 0x80;
+               }break;
+               case SAT_PROATV_CMD_GET_INKEY:{
+                       dst[current_index++] = 0x00;
+
+                       //command detail alphabet set
+                       if(src->cmd_qualifier.get_inkey.alphabet_set)
+                               dst[current_index] += 0x01;
+
+                       //command detail alphabet type
+                       if(src->cmd_qualifier.get_inkey.alphabet_type == INPUT_ALPHABET_TYPE_UCS2)
+                               dst[current_index] += 0x02;
+
+                       //command detail get inkey type
+                       if(src->cmd_qualifier.get_inkey.inkey_type == INKEY_TYPE_YES_NO_REQUESTED)
+                               dst[current_index] += 0x04;
+
+
+                       //command detail immediate response required
+                       if(src->cmd_qualifier.get_inkey.immediate_rsp_required)
+                               dst[current_index] += 0x08;
+
+                       //command detail help available
+                       if (src->cmd_qualifier.get_inkey.help_info)
+                               dst[current_index] += 0x80;
+               }break;
+               case SAT_PROATV_CMD_GET_INPUT:{
+                       dst[current_index++] = 0x00;
+
+                       //command detail alphabet set
+                       if(src->cmd_qualifier.get_input.alphabet_set)
+                               dst[current_index] += 0x01;
+
+                       //command detail alphabet type
+                       if(src->cmd_qualifier.get_input.alphabet_type == INPUT_ALPHABET_TYPE_UCS2)
+                               dst[current_index] += 0x02;
+
+                       //command detail echo user input
+                       if(src->cmd_qualifier.get_input.me_echo_user_input)
+                               dst[current_index] += 0x04;
+
+                       //command detail user input unpacked format
+                       if(src->cmd_qualifier.get_input.user_input_unpacked_format)
+                               dst[current_index] += 0x08;
+
+                       //command detail help available
+                       if (src->cmd_qualifier.get_input.help_info)
+                               dst[current_index] += 0x80;
+               }break;
+               case SAT_PROATV_CMD_SELECT_ITEM:{
+                       dst[current_index++] = 0x00;
+
+                       //command detail presentation
+                       dst[current_index] += src->cmd_qualifier.select_item.presentation_type;
+
+                       //command detail selection preference
+                       if(src->cmd_qualifier.select_item.select_preference == SELECTION_PREFERENCE_USING_SOFT_KEY)
+                               dst[current_index] += 0x04;
+
+                       //command detail help available
+                       if (src->cmd_qualifier.select_item.help_info)
+                               dst[current_index] += 0x80;
+               }break;
+               case SAT_PROATV_CMD_SETUP_MENU:{
+                       dst[current_index++] = 0x00;
+
+                       //command detail preferences
+                       if (src->cmd_qualifier.setup_menu.select_preference == SELECTION_PREFERENCE_USING_SOFT_KEY)
+                               dst[current_index] += 0x01;
+
+                       //command detail help available
+                       if (src->cmd_qualifier.setup_menu.help_info)
+                               dst[current_index] += 0x80;
+               }break;
+               default:
+                       err("no matched cmd type(%d)", src->cmd_type);
+                       break;
+       }
+
+       return 5;
+}
+
+static int _sat_encode_device_identities_tlv(const struct tel_sat_device_identities* src, char *dst, int current_index)
+{
+       dst[current_index++] =SATK_DEVICE_IDENTITY_TAG;
+       dst[current_index++] =SATK_DEVICE_IDENTITY_LENGTH;
+       dst[current_index++] = src->src;
+       dst[current_index++] = src->dest;
+
+       //device identities total len 4
+       return 4;
+}
+
+static int _sat_encode_item_identifier_tlv(const struct tel_sat_item_identifier* src, char *dst, int current_index)
+{
+       dst[current_index++] =SATK_ITEM_IDENTIFIER_TAG;
+       dst[current_index++] =SATK_ITEM_IDENTIFIER_LENGTH;
+       dst[current_index++] = src->item_identifier;
+
+       //item identifier total len 3
+       return 3;
+}
+
+static int _sat_encode_duration_tlv(const struct tel_sat_duration* src, char *dst, int current_index)
+{
+       dst[current_index++] =SATK_DURATION_TAG;
+       dst[current_index++] =SATK_DURATION_LENGTH;
+       dst[current_index++] = src->time_unit;
+       dst[current_index++] = src->time_interval;
+
+       //duration total len 4
+       return 4;
+}
+
+static int _sat_encode_text_tlv(const struct tel_sat_text_string_object* src, char *dst, int current_index, gboolean raw_dcs)
+{
+       int index = 0;
+
+       if(src == NULL)
+               return 0;
+
+       //tag
+       index++;
+       dst[current_index++] =SATK_TEXT_STRING_TAG;
+       if(src->string_length > 0x7F){
+               index++;
+               dst[current_index++] =0x81;
+       }
+
+       //length
+       index++;
+       dst[current_index++] =SATK_DCS_LENGTH+src->string_length;
+
+       //dcs
+       index++;
+       if(raw_dcs)
+               dst[current_index++] = src->dcs.raw_dcs;
+       else
+               dst[current_index++] =_sat_encode_dcs_tlv(&(src->dcs));
+
+       //value
+       if(src->string_length > 0){
+               index += src->string_length;
+               memcpy(&(dst[current_index]), src->string, src->string_length);
+       }
+
+       return index;
+}
+
+int tcore_sat_encode_envelop_cmd(const struct treq_sat_envelop_cmd_data *src_envelop, char *dst_envelop)
+{
+       int index = 0, encoded_len= 0;
+
+       if(!dst_envelop)
+               return 0;
+
+       if(src_envelop->sub_cmd == ENVELOP_MENU_SELECTION){
+               index = 2; //set the cursor to device identity
+               dbg("item id(%d)", src_envelop->envelop_data.menu_select.item_identifier.item_identifier);
+               encoded_len =_sat_encode_device_identities_tlv(&(src_envelop->envelop_data.menu_select.device_identitie), dst_envelop, index);
+               index += encoded_len;
+
+               //item identifier
+               encoded_len = _sat_encode_item_identifier_tlv(&(src_envelop->envelop_data.menu_select.item_identifier), dst_envelop, index);
+               index += encoded_len;
+
+               if(src_envelop->envelop_data.menu_select.help_request){
+                       encoded_len = 2;//help request
+                       dst_envelop[index++] = SATK_HELP_REQUEST_TAG;
+                       dst_envelop[index++] = SATK_HELP_REQUEST_LENGTH;
+               }
+
+               dbg("menu selection cmd len(%d)", index);
+
+               //main cmd
+               dst_envelop[0] = SATK_MENU_SELECTION_TAG;
+               dst_envelop[1] = index-2;
+       }
+
+       return index;
+}
+
+static int _sat_encode_setup_event_list(const struct tel_sat_tr_setup_event_list_tlv *src_tr, char *dst_tr)
+{
+       int index = 0, encoded_len = 0;
+
+       //set command detail info
+       encoded_len = _sat_encode_command_detail_tlv(&(src_tr->command_detail), dst_tr, index);
+       index += encoded_len;
+
+       //set device identities info
+       encoded_len = _sat_encode_device_identities_tlv(&(src_tr->device_id), dst_tr, index);
+       index += encoded_len;
+
+       //set result info
+       dst_tr[index++] = SATK_RESULT_TAG;
+       switch(src_tr->result_type){
+               case RESULT_SUCCESS:
+               case RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION:
+               case RESULT_SUCCESS_WITH_MISSING_INFO:
+               case RESULT_BEYOND_ME_CAPABILITIES:
+               case RESULT_COMMAND_TYPE_NOT_UNDERSTOOD_BY_ME:
+               case RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME:
+               case RESULT_COMMAND_NUMBER_NOT_KNOWN_BY_ME:
+               case RESULT_ERROR_REQUIRED_VALUES_ARE_MISSING:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+                       dst_tr[index++] = 2;
+                       dst_tr[index] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->me_problem_type;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_display_text(const struct tel_sat_tr_display_text_tlv *src_tr, char *dst_tr)
+{
+       int index = 0, encoded_len = 0;
+
+       //set command detail info
+       encoded_len = _sat_encode_command_detail_tlv(&(src_tr->command_detail), dst_tr, index);
+       index += encoded_len;
+
+       //set device identities info
+       encoded_len = _sat_encode_device_identities_tlv(&(src_tr->device_id), dst_tr, index);
+       index += encoded_len;
+
+       //set result info
+       dst_tr[index++] = SATK_RESULT_TAG;
+       switch(src_tr->result_type){
+               case RESULT_SUCCESS:
+               case RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION:
+               case RESULT_SUCCESS_WITH_MISSING_INFO:
+               case RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED:
+               case RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER:
+               case RESULT_BACKWARD_MOVE_BY_USER:
+               case RESULT_NO_RESPONSE_FROM_USER:
+               case RESULT_BEYOND_ME_CAPABILITIES:
+               case RESULT_COMMAND_TYPE_NOT_UNDERSTOOD_BY_ME:
+               case RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME:
+               case RESULT_COMMAND_NUMBER_NOT_KNOWN_BY_ME:
+               case RESULT_ERROR_REQUIRED_VALUES_ARE_MISSING:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+               case RESULT_FRAMES_ERROR:
+                       dst_tr[index++] = 2;
+                       dst_tr[index] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->me_problem_type;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_get_inkey(const struct tel_sat_tr_get_inkey_tlv *src_tr, char *dst_tr)
+{
+       int index = 0, encoded_len = 0;
+
+       //set command detail info
+       encoded_len = _sat_encode_command_detail_tlv(&(src_tr->command_detail), dst_tr, index);
+       index += encoded_len;
+
+       //set device identities info
+       encoded_len = _sat_encode_device_identities_tlv(&(src_tr->device_id), dst_tr, index);
+       index += encoded_len;
+
+       //set result info
+       dst_tr[index++] = SATK_RESULT_TAG;
+
+       switch(src_tr->result_type){
+               case RESULT_SUCCESS:
+               case RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION:
+               case RESULT_SUCCESS_WITH_MISSING_INFO:
+               case RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+
+                       encoded_len = _sat_encode_text_tlv(&(src_tr->text), dst_tr, index, FALSE);
+                       index += encoded_len;
+                       break;
+               case RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER:
+               case RESULT_BACKWARD_MOVE_BY_USER:
+               case RESULT_HELP_INFO_REQUIRED_BY_USER:
+               case RESULT_BEYOND_ME_CAPABILITIES:
+               case RESULT_COMMAND_TYPE_NOT_UNDERSTOOD_BY_ME:
+               case RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME:
+               case RESULT_COMMAND_NUMBER_NOT_KNOWN_BY_ME:
+               case RESULT_ERROR_REQUIRED_VALUES_ARE_MISSING:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+                       break;
+               case RESULT_NO_RESPONSE_FROM_USER:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+
+                       encoded_len = _sat_encode_duration_tlv(&(src_tr->duration), dst_tr, index);
+                       index += encoded_len;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+               case RESULT_FRAMES_ERROR:
+                       dst_tr[index++] = 2;
+                       dst_tr[index] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->me_problem_type;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_get_input(const struct tel_sat_tr_get_input_tlv *src_tr, char *dst_tr)
+{
+       int index = 0, encoded_len = 0;
+
+       //set command detail info
+       encoded_len = _sat_encode_command_detail_tlv(&(src_tr->command_detail), dst_tr, index);
+       index += encoded_len;
+
+       //set device identities info
+       encoded_len = _sat_encode_device_identities_tlv(&(src_tr->device_id), dst_tr, index);
+       index += encoded_len;
+
+       //set result info
+       dst_tr[index++] = SATK_RESULT_TAG;
+
+       switch(src_tr->result_type){
+               case RESULT_SUCCESS:
+               case RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION:
+               case RESULT_SUCCESS_WITH_MISSING_INFO:
+               case RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+
+                       encoded_len = _sat_encode_text_tlv(&(src_tr->text), dst_tr, index, FALSE);
+                       index += encoded_len;
+                       break;
+               case RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER:
+               case RESULT_BACKWARD_MOVE_BY_USER:
+               case RESULT_NO_RESPONSE_FROM_USER:
+               case RESULT_HELP_INFO_REQUIRED_BY_USER:
+               case RESULT_BEYOND_ME_CAPABILITIES:
+               case RESULT_COMMAND_TYPE_NOT_UNDERSTOOD_BY_ME:
+               case RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME:
+               case RESULT_COMMAND_NUMBER_NOT_KNOWN_BY_ME:
+               case RESULT_ERROR_REQUIRED_VALUES_ARE_MISSING:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+               case RESULT_FRAMES_ERROR:
+                       dst_tr[index++] = 2;
+                       dst_tr[index] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->me_problem_type;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_select_item(const struct tel_sat_tr_select_item_tlv *src_tr, char *dst_tr)
+{
+       int index = 0, encoded_len = 0;
+
+       //set command detail info
+       encoded_len = _sat_encode_command_detail_tlv(&(src_tr->command_detail), dst_tr, index);
+       index += encoded_len;
+
+       //set device identities info
+       encoded_len = _sat_encode_device_identities_tlv(&(src_tr->device_id), dst_tr, index);
+       index += encoded_len;
+
+       //set result info
+       dst_tr[index++] = SATK_RESULT_TAG;
+
+       switch(src_tr->result_type){
+               case RESULT_SUCCESS:
+               case RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION:
+               case RESULT_SUCCESS_WITH_MISSING_INFO:
+               case RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+                       encoded_len = _sat_encode_item_identifier_tlv(&(src_tr->item_identifier), dst_tr, index);
+                       index += encoded_len;
+                       break;
+               case RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER:
+               case RESULT_BACKWARD_MOVE_BY_USER:
+               case RESULT_NO_RESPONSE_FROM_USER:
+               case RESULT_HELP_INFO_REQUIRED_BY_USER:
+               case RESULT_BEYOND_ME_CAPABILITIES:
+               case RESULT_COMMAND_TYPE_NOT_UNDERSTOOD_BY_ME:
+               case RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME:
+               case RESULT_COMMAND_NUMBER_NOT_KNOWN_BY_ME:
+               case RESULT_ERROR_REQUIRED_VALUES_ARE_MISSING:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+               case RESULT_FRAMES_ERROR:
+                       dst_tr[index++] = 2;
+                       dst_tr[index] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->me_problem_type;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_setup_menu(const struct tel_sat_tr_setup_menu_tlv *src_tr, char *dst_tr)
+{
+       int index = 0, encoded_len = 0;
+
+       //set command detail info
+       encoded_len = _sat_encode_command_detail_tlv(&(src_tr->command_detail), dst_tr, index);
+       index += encoded_len;
+
+       //set device identities info
+       encoded_len = _sat_encode_device_identities_tlv(&(src_tr->device_id), dst_tr, index);
+       index += encoded_len;
+
+       //set result info
+       dst_tr[index++] = SATK_RESULT_TAG;
+       switch(src_tr->result_type){
+               case RESULT_SUCCESS:
+               case RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+                       dst_tr[index++] = 2;
+                       dst_tr[index] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->me_problem_type;
+                       break;
+               default:
+                       break;
+       }
+
+       return index;
+}
+
+int tcore_sat_encode_terminal_response(const struct treq_sat_terminal_rsp_data *src_tr, char *dst_tr){
+       int tr_len = 0;
+
+       if(!dst_tr)
+               return 0;
+
+       switch(src_tr->cmd_type){
+               case SAT_PROATV_CMD_SETUP_EVENT_LIST:{
+                       tr_len = _sat_encode_setup_event_list(&(src_tr->terminal_rsp_data.setup_event_list), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_DISPLAY_TEXT:{
+                       tr_len = _sat_encode_display_text(&(src_tr->terminal_rsp_data.display_text), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_GET_INKEY:{
+                       tr_len = _sat_encode_get_inkey(&(src_tr->terminal_rsp_data.get_inkey), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_GET_INPUT:{
+                       tr_len = _sat_encode_get_input(&(src_tr->terminal_rsp_data.get_input), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_SELECT_ITEM:{
+                       tr_len = _sat_encode_select_item(&(src_tr->terminal_rsp_data.select_item), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_SETUP_MENU:{
+                       tr_len = _sat_encode_setup_menu(&(src_tr->terminal_rsp_data.setup_menu), dst_tr);
+               }break;
+
+               default:
+                       err("no matched cmd type(%d)", src_tr->cmd_type);
+                       break;
+       }
+
+       return tr_len;
+}
+
+CoreObject *tcore_sat_new(TcorePlugin *p, const char *name, struct tcore_sat_operations *ops)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name);
+       if (!o)
+               return NULL;
+
+       po = calloc(sizeof(struct private_object_data), 1);
+       if (!po) {
+               tcore_object_free(o);
+               return NULL;
+       }
+
+       po->ops = ops;
+
+       tcore_object_set_type(o, CORE_OBJECT_TYPE_SAT);
+       tcore_object_link_object(o, po);
+       tcore_object_set_free_hook(o, _free_hook);
+       tcore_object_set_dispatcher(o, _dispatcher);
+
+       return o;
+}
+
+void tcore_sat_free(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SAT);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       free(po);
+       tcore_object_free(o);
+}
diff --git a/src/co_sim.c b/src/co_sim.c
new file mode 100644 (file)
index 0000000..4576c8c
--- /dev/null
@@ -0,0 +1,2482 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 <ctype.h>
+#include <glib.h>
+
+#include "tcore.h"
+#include "plugin.h"
+#include "queue.h"
+#include "user_request.h"
+#include "core_object.h"
+#include "co_sim.h"
+
+struct private_object_data {
+       struct tcore_sim_operations *ops;
+
+       enum tel_sim_type type; /**< Provides the SIM card type*/
+       enum tel_sim_status sim_status; /**< Provides the card status*/
+       struct tel_sim_imsi imsi; /**< Provides IMSI information*/
+       gboolean b_sim_changed; /**< Provides SIM card Identification- 0:no changed, 1:changed*/
+       gboolean b_cphs; /**< Whether current SIM is for CPHS or not*/
+
+       enum tel_sim_file_id language_file; /**<Provides Current cached language EF address */
+       enum tel_sim_file_id cf_file; /**<Provides Current cached call forwarding EF address */
+       enum tel_sim_file_id mw_file; /**<Provides Current cached message waiting EF address */
+       enum tel_sim_file_id mb_file; /**<Provides Current cached mailbox number EF address */
+
+       void *userdata; /**< free use data*/
+};
+
+
+static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
+{
+       enum tcore_request_command command;
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_SIM, TCORE_RETURN_EINVAL);
+
+       po = tcore_object_ref_object(o);
+       if (!po || !po->ops)
+               return TCORE_RETURN_ENOSYS;
+
+       command = tcore_user_request_get_command(ur);
+
+       switch (command) {
+               case TREQ_SIM_VERIFY_PINS:
+                       if (!po->ops->verify_pins)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->verify_pins(o, ur);
+                       break;
+
+               case TREQ_SIM_VERIFY_PUKS:
+                       if (!po->ops->verify_puks)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->verify_puks(o, ur);
+                       break;
+
+               case TREQ_SIM_CHANGE_PINS:
+                       if (!po->ops->change_pins)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->change_pins(o, ur);
+                       break;
+
+               case TREQ_SIM_GET_FACILITY_STATUS:
+                       if (!po->ops->get_facility_status)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_facility_status(o, ur);
+                       break;
+
+               case TREQ_SIM_DISABLE_FACILITY:
+                       if (!po->ops->disable_facility)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->disable_facility(o, ur);
+                       break;
+
+               case TREQ_SIM_ENABLE_FACILITY:
+                       if (!po->ops->enable_facility)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->enable_facility(o, ur);
+                       break;
+
+               case TREQ_SIM_TRANSMIT_APDU:
+                       if (!po->ops->transmit_apdu)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->transmit_apdu(o, ur);
+                       break;
+
+               case TREQ_SIM_GET_ATR:
+                       if (!po->ops->get_atr)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_atr(o, ur);
+                       break;
+
+               case TREQ_SIM_SET_LANGUAGE:
+               case TREQ_SIM_SET_CALLFORWARDING:
+                       if (!po->ops->update_file)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->update_file(o, ur);
+                       break;
+
+               case TREQ_SIM_GET_ECC:
+               case TREQ_SIM_GET_LANGUAGE:
+               case TREQ_SIM_GET_ICCID:
+               case TREQ_SIM_GET_MAILBOX:
+               case TREQ_SIM_GET_CALLFORWARDING:
+               case TREQ_SIM_GET_MESSAGEWAITING:
+               case TREQ_SIM_GET_CPHS_INFO:
+               case TREQ_SIM_GET_MSISDN:
+               case TREQ_SIM_GET_SPN:
+               case TREQ_SIM_GET_SPDI:
+               case TREQ_SIM_GET_OPL:
+               case TREQ_SIM_GET_PNN:
+               case TREQ_SIM_GET_CPHS_SHORTNETNAME:
+               case TREQ_SIM_GET_CPHS_FULLNETNAME:
+               case TREQ_SIM_GET_OPLMNWACT:
+                       if (!po->ops->read_file)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->read_file(o, ur);
+                       break;
+
+               case TREQ_SIM_REQ_AUTHENTICATION:
+                       if (!po->ops->req_authentication)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->req_authentication(o, ur);
+                       break;
+
+               default:
+                       break;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+static void _free_hook(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SIM);
+
+       po = tcore_object_ref_object(o);
+       if (po) {
+               free(po);
+               tcore_object_link_object(o, NULL);
+       }
+}
+
+static void _reverse(char* p_in, int length)
+{
+       int i, j = length - 1;
+       for (i = 0; i < j; i++) {
+               int t = p_in[i];
+               p_in[i] = p_in[j];
+               p_in[j--] = t;
+       }
+}
+
+static char* _acitoa(int n, char* str, int b)
+{
+       int i = 0;
+
+       do {
+               str[i++] = "0123456789ABCDEF"[n % b];
+       } while ((n /= b) > 0);
+
+       _reverse(str, i);
+
+       str[i] = '\0';
+
+       return str;
+}
+
+/*******************************************************************************
+ Convert Digit to BCD (BCD to Digit)
+
+ bcd           <--->   digit
+ 0xa                           0x2a '*'
+ 0xb                           0x23 '#'
+ 0xc                           0x70 'P'
+ 0xd                           '?'
+ 0xf                           0
+ 1032547698            0123456789
+
+ ********************************************************************************/
+/**
+ * This function is used to Convert Digit to BCD (Digit to BCD)
+ *
+ * @return             None
+ * @param[out] bcdCode - BCD output
+ * @param[in]          digits - Digit input
+ * @param[in]          digitLen - digit length
+ * @Interface          Synchronous.
+ * @remark
+ * @Refer
+ */
+static void _digit_to_bcd(char* bcdCode, char* digits, int digitLen)
+{
+       int i, j, digit;
+       unsigned char higher, lower;
+
+       // 0123456789 -> 1032547698
+       for (i = 0, j = 0; i < digitLen; i = i + 2, j++) {
+               if (digits[i] == '*')
+                       digit = 0x0A;
+               else if (digits[i] == '#')
+                       digit = 0x0B;
+               else if (toupper((int) digits[i]) == 'P')
+                       digit = 0x0C;
+               else if ((digits[i]) == '?')
+                       digit = 0x0D;
+               else
+                       digit = (int) digits[i];
+
+               lower = digit & 0x0F;
+
+               if (digitLen != i + 1) {
+                       if (digits[i + 1] == '*')
+                               digit = 0x0A;
+                       else if (digits[i + 1] == '#')
+                               digit = 0x0B;
+                       else if (toupper((int) digits[i + 1]) == 'P')
+                               digit = 0x0C;
+                       else if (digits[i + 1] == '?')
+                               digit = 0x0D;
+                       else
+                               digit = (int) digits[i + 1];
+                       higher = digit & 0x0F;
+               } else {
+                       higher = 0xFF;
+               }
+               bcdCode[j] = (higher << 4) | lower;
+       }
+}
+
+/**
+ * This function is used to Convert BCD to Digit (BCD to Digit)
+ *
+ * @return             None
+ * @param[out] digit - Digit output output
+ * @param[in]          bcdCode - BCD Input
+ * @param[in]          bcdLen - BCD length
+ * @Interface          Synchronous.
+ * @remark
+ * @Refer
+ */
+static unsigned long _bcd_to_digit(char* digit, char* bcdCode, int bcdLen)
+{
+       int i, h, l;
+       char c[2];
+       unsigned char higher, lower;
+       unsigned long digitLen = 0;
+
+       // 0123456789 <- 1032547698
+       memset((void*) digit, 0, bcdLen * 2);
+
+       for (i = 0; i < bcdLen; i++) {
+               higher = (bcdCode[i] >> 4) & 0x0F; // get high nibble
+
+               if (higher == 0x0A)
+                       higher = '*'; // =0x2A
+               else if (higher == 0x0B)
+                       higher = '#'; // =0x23
+               else if (higher == 0x0C)
+                       higher = 'P'; // =0x70, DTMF Control digit
+               else if (higher == 0x0D)
+                       higher = '?';
+               else if (higher == 0x0F)
+                       higher = 0;
+               else {
+                       h = (int) higher;
+                       _acitoa(h, c, 16);
+                       higher = (char) toupper(*c);
+               }
+
+               lower = bcdCode[i] & 0x0F; // get low nibble
+
+               if (lower == 0x0A)
+                       lower = '*';
+               else if (lower == 0x0B)
+                       lower = '#';
+               else if (lower == 0x0C)
+                       lower = 'P'; //DTMF Control digit
+               else if (lower == 0x0D)
+                       lower = '?';
+               else if (lower == 0x0F)
+                       lower = 0;
+               else {
+                       l = (int) lower;
+                       _acitoa(l, c, 16);
+                       lower = (char) toupper(*c);
+               }
+               digit[i * 2] = lower;
+               digit[i * 2 + 1] = higher;
+       }
+
+       digitLen = (unsigned long) strlen(digit);
+       return digitLen;
+}
+
+/**
+ * This function is used to get(decode) string name
+ *
+ * @return             length of string
+ * @param[out] palpha_id - Alpha string
+ * @param[in]          pRecord - Input raw data
+ * @param[in]          alphaIDMaxLen - Max size of alpha id array
+ * @Interface          Synchronous.
+ * @remark
+ * @Refer
+ */
+static unsigned long _get_string(unsigned char* palpha_id, unsigned char* pRecord,     unsigned long alphaIDMaxLen)
+{
+       unsigned long i, alphaIDLen = 0;
+       unsigned char *pAlphaID = (unsigned char*) palpha_id;
+
+       memset((void*) pAlphaID, 0, alphaIDMaxLen);
+
+       if (pRecord[0] == 0xFF)
+               return alphaIDLen;
+
+       for (i = 0; i < alphaIDMaxLen; i++) {
+               if (pRecord[0] <= 0x7F && pRecord[i] == 0xFF)
+                       break;
+
+               pAlphaID[i] = pRecord[i];
+               alphaIDLen++;
+       }
+       return alphaIDLen;
+}
+
+/**
+ * This function is used to set(encode) string name
+ *
+ * @return             length of string
+ * @param[in]          palpha_id - Alpha string input
+ * @param[out] pRecord - output raw data
+ * @param[in]          alphaIDMaxLen - Max size of alpha id array
+ * @Interface          Synchronous.
+ * @remark
+ * @Refer
+ */
+static void _set_string(unsigned char* pRecord, unsigned char* palpha_id, unsigned long alphaIDMaxLen)
+{
+       unsigned long i;
+       unsigned char* pAlphaID = (unsigned char*) palpha_id;
+
+       memset((void*) pRecord, 0xFF, alphaIDMaxLen);
+
+       for (i = 0; i < alphaIDMaxLen; i++)
+               pRecord[i] = pAlphaID[i];
+}
+
+static gboolean _is_empty(unsigned char* p_in, int in_length)
+{
+       int i;
+       for (i = 0; i < in_length; i++) {
+               if (p_in[i] != 0xFF)
+                       return FALSE;
+       }
+       return TRUE;            // this is empty record.
+}
+
+/**
+ * This function is used to get BCD length
+ *
+ * @return             length of string
+ * @param[in]          pBcdData - BCD Input data
+ * @param[in]          bcdMaxLen - BCD Max data Length
+ * @Interface          Synchronous.
+ * @remark
+ * @Refer
+ */
+static int _get_valid_bcd_byte(unsigned char* pBcdData, int bcdMaxLen)
+{
+       int i, bcd_length = 0;
+
+       for (i = 0; i < bcdMaxLen; i++) {
+               if (pBcdData[i] == 0xFF)
+                       break;
+
+               bcd_length++;
+       }
+       return bcd_length;
+}
+
+/**
+ * This function is used to get unpacked 8bit Format from GSM 7bit packed string.
+ *
+ * @return          the length of unpacked characters  .
+ * @param[out] out_string      Specifies the unpacked output string
+ * @param[in]          in_string       Contains the input string to be unpacked
+ * @param[in]          in_string_len   Contains the input string length
+ * @remark
+ */
+static int _unpack_7bit28bit(unsigned char* pInString, unsigned int inStringLen, unsigned char * pOutString)
+{
+       int i = 0;
+       unsigned int pos = 0;
+       unsigned short shift = 0;
+       int outlen = 0;
+       outlen = (short int) ((inStringLen * 8) / 7);
+
+       for (i = 0; pos < inStringLen; i++, pos++) {
+               pOutString[i] = (pInString[pos] << shift) & 0x7F;
+
+               if (pos != 0) {
+                       /* except the first byte, a character contains some bits from the previous byte.*/
+                       pOutString[i] |= pInString[pos - 1] >> (8 - shift);
+               }
+
+               shift++;
+
+               if (shift == 7) {
+                       shift = 0;
+
+                       /* a possible extra complete character is available */
+                       i++;
+                       pOutString[i] = pInString[pos] >> 1;
+               }
+       }
+
+       /*If a character is '\r'(13), change it to space(32) */
+       for (i = 0; i < outlen; i++)
+               if (pOutString[i] == 13) pOutString[i] = 32;
+
+       pOutString[outlen] = '\0';
+
+       dbg( "unpack is done with outlen[%d] and array index[%d], out string[%s]", outlen, i, pOutString);
+       return (unsigned int) (i);
+}
+
+static int _ucs2_to_utf8(int in_length, unsigned char *in_data, int *out_length,       unsigned char *out_data)
+{
+       int i, j;
+       i = j = 0;
+       if (in_length == 0 || in_data == NULL || out_data == NULL) {
+               dbg( "Unicode Decode Failed as text length is 0");
+               return FALSE;
+       }
+
+       if (0 != (in_length % 2)) {
+               dbg( " ##### Unicode decoding failed due to invalid text length [%d]",  in_length);
+               return FALSE;
+       }
+
+       for (i = 0; i < in_length; i++) {
+               out_data[i] = in_data[j];
+               j = j + 2;
+       }
+       *out_length = (in_length / 2);
+       out_data[i] = '\0';
+       return TRUE;
+}
+
+/**
+ * According to ETSI 102.221 ( 3GPP specification refers it ), EF-ICCID is coded by BCD, left justified and padded with 'F'.
+ * This EF is mandatory and byte length is fixed with 10 bytes. So actual maximum length of ICCID is 20 digits.
+ */
+gboolean tcore_sim_decode_iccid(struct tel_sim_iccid *p_out, unsigned char *p_in, int in_length)
+{
+       int bcd_byte = 0;
+       int char_length = 0;
+
+       if (p_in == NULL || p_out == NULL)
+               return FALSE;
+
+       if (in_length == 0 || in_length > 10)
+               return FALSE;
+
+       memset((void*) p_out->iccid, 0, SIM_ICCID_LEN_MAX+1);
+
+       bcd_byte = _get_valid_bcd_byte(p_in, in_length);
+       dbg( "ICCID valid bcd byte is[%d]", bcd_byte);
+
+       char_length = _bcd_to_digit(p_out->iccid, (char*) p_in, bcd_byte);
+       dbg( "ICCID string length is[%d]", char_length);
+
+       *(p_out->iccid+char_length) = '\0';
+
+       return TRUE;
+}
+
+/**
+ * This function is used to decode EFLP (2G)
+ */
+gboolean tcore_sim_decode_lp(struct tel_sim_language *p_out, unsigned char *p_in, int in_length)
+{
+       int i = 0;
+
+       memset((void*) p_out, 0xFF, sizeof(struct tel_sim_language));
+       p_out->language_count = 0;
+
+       if (in_length == 0)
+               return FALSE;
+       /*
+        * Description of problem: language decoding was not correctly done if we used 7layers's test SIM
+        * Patch Description : The tested SIM  at 7layers has 3 language codes like [ff][ff][01].
+        In this case we could not decode 3rd language code.
+        So, the below 2 lines checking the UNSPECIFIED language are commented.
+        */
+
+       if (in_length > SIM_LANG_CNT_MAX)
+               in_length = SIM_LANG_CNT_MAX;
+
+       for (i = 0; i < in_length; i++) {
+               /*
+                * Description of problem: Language decoding was not correctly done if we used some test SIM
+                * Patch Description : Test SIM at some place has 3 language codes like  [ff][ff][01].
+                * In this case we could not decode 3rd language code.
+                * So, the below 2 lines checking the UNSPECIFIED language are commented.
+                */
+               if (p_in[i] == 0xFF)
+                       continue;
+
+               p_out->language[p_out->language_count] = (enum tel_sim_language_type) p_in[i];
+               dbg( "p_out->language[%d]=[%d] ", i, p_out->language[p_out->language_count]);
+               p_out->language_count++;
+       }
+       dbg( "in_length %d, lang_cnt %d ", in_length, p_out->language_count);
+       return TRUE;
+}
+
+/**
+ * This function is used to encode EFLP (2G)
+ */
+gboolean tcore_sim_encode_lp(char *p_out, int out_length, struct tel_sim_language *p_in)
+{
+       int i;
+
+       if (p_in->language_count > out_length)
+               return FALSE;
+
+       memset((void*) p_out, 0xff, out_length);
+
+       for (i = 0; i < p_in->language_count; i++)
+               p_out[i] = p_in->language[i];
+
+       return TRUE;
+}
+
+/**
+ * This function is used to decode LI (3G)
+ */
+gboolean tcore_sim_decode_li(enum tel_sim_file_id file_id, struct tel_sim_language *p_out, unsigned char *p_in, int in_length)
+{
+       int i;
+       unsigned short defaultLi;
+       unsigned char tempLi[3] = { 0, 0, 0 };
+
+       memset((void*) p_out, 0xFF, sizeof(struct tel_sim_language));
+       p_out->language_count  = 0;
+
+       if (in_length == 0)
+               return FALSE;
+
+       /*
+        * Description of problem: language decoding was not correctly done if we used 7layers's test SIM
+        * Patch Description : TS31.102 If the EFLI has the value 'FFFF' in its highest priority position,
+        then the preferred language selection shall be the language preference in the EFPL
+        */
+       if (/*TODO g_sim.CardType == SIM_TYPE_USIM && */(file_id == SIM_EF_USIM_LI || file_id == SIM_EF_LP)) {
+               defaultLi = p_in[0];
+               defaultLi = ((defaultLi << 8) & 0xFF00) + p_in[1];
+
+               if (defaultLi == 0xFFFF)        // 1st language is default.
+                       return FALSE;
+       }
+
+       if (in_length > SIM_LANG_CNT_MAX)
+               in_length = SIM_LANG_CNT_MAX;
+
+       for (i = 0; i < in_length; i++) {
+               tempLi[0] = p_in[i++];
+               tempLi[1] = p_in[i];
+/*
+                Description of problem: language decoding was not correctly done if we used 7layers's test SIM
+                Patch Description : The tested SIM at specific test lab has 3 language codes like [ff][ff][ff][ff][64][65].
+                In this case we could not decode 3rd language code.
+                So, the below 2 lines checking the UNSPECIFIED language are commented.
+*/
+               if (tempLi[0] == 0xFF || tempLi[1] == 0xFF)  //this is always 2 bytes
+                       continue;
+
+               p_out->language[p_out->language_count] = SIM_LANG_UNSPECIFIED;
+
+               if (tempLi[0] == 'e') {
+                       switch (tempLi[1]) {
+                               case 'n':
+                                       p_out->language[p_out->language_count] = SIM_LANG_ENGLISH;
+                                       break;
+                               case 's':
+                                       p_out->language[p_out->language_count] = SIM_LANG_SPANISH;
+                                       break;
+                               case 'l':
+                                       p_out->language[p_out->language_count] = SIM_LANG_GREEK;
+                                       break;
+                       }
+               } else if (tempLi[0] == 'd') {
+                       switch (tempLi[1]) {
+                               case 'e':
+                                       p_out->language[p_out->language_count] = SIM_LANG_GERMAN;
+                                       break;
+
+                               case 'a':
+                                       p_out->language[p_out->language_count] = SIM_LANG_DANISH;
+                                       break;
+                       }
+               } else if (tempLi[0] == 'i' && tempLi[1] == 't') {
+                       p_out->language[p_out->language_count] = SIM_LANG_ITALIAN;
+               } else if (tempLi[0] == 'f' && tempLi[1] == 'r') {
+                       p_out->language[p_out->language_count] = SIM_LANG_FRENCH;
+               } else if (tempLi[0] == 'n' && tempLi[1] == 'l') {
+                       p_out->language[p_out->language_count] = SIM_LANG_DUTCH;
+               } else if (tempLi[0] == 's' && tempLi[1] == 'v') {
+                       p_out->language[p_out->language_count] = SIM_LANG_SWEDISH;
+               } else if (tempLi[0] == 'f' && tempLi[1] == 'i') {
+                       p_out->language[p_out->language_count] = SIM_LANG_FINNISH;
+               } else if (tempLi[0] == 'n' && tempLi[1] == 'o') {
+                       p_out->language[p_out->language_count] = SIM_LANG_NORWEGIAN;
+               } else if (tempLi[0] == 't' && tempLi[1] == 'r') {
+                       p_out->language[p_out->language_count] = SIM_LANG_TURKISH;
+               } else if (tempLi[0] == 'h' && tempLi[1] == 'u') {
+                       p_out->language[p_out->language_count] = SIM_LANG_HUNGARIAN;
+               } else if (tempLi[0] == 'p') {
+                       switch (tempLi[1]) {
+                               case 'l':
+                                       p_out->language[p_out->language_count] = SIM_LANG_POLISH;
+                                       break;
+                               case 't':
+                                       p_out->language[p_out->language_count] = SIM_LANG_PORTUGUESE;
+                                       break;
+                       }
+               } else if (tempLi[0] == 'k' && tempLi[1] == 'o') {
+                       p_out->language[p_out->language_count] = SIM_LANG_KOREAN;
+               } else if (tempLi[0] == 'z' && tempLi[1] == 'h') {
+                       p_out->language[p_out->language_count] = SIM_LANG_CHINESE;
+               } else if (tempLi[0] == 'r' && tempLi[1] == 'u') {
+                       p_out->language[p_out->language_count] = SIM_LANG_RUSSIAN;
+               } else if (tempLi[0] == 'j' && tempLi[1] == 'a') {
+                       p_out->language[p_out->language_count] = SIM_LANG_JAPANESE;
+               }
+
+               dbg( "count %d & Codes %d ", p_out->language_count, p_out->language[p_out->language_count]);
+               p_out->language_count++;
+       }
+
+       if (p_out->language_count == 0) {
+               dbg( "p_out->language_count = %d ", p_out->language_count);
+               return FALSE;
+       }
+       else {
+               return TRUE;
+       }
+}
+
+/**
+ * This function is used to encode EFLI (3G)
+ */
+gboolean tcore_sim_encode_li(char *p_out, int out_length, struct tel_sim_language *p_in)
+{
+       int i = 0;
+       char *LanguageCode[] = { "de", "en", "it", "fr", "es", "nl", "sv", "da", "pt", "fi", "no", "el",
+                                                                                                       "tr", "hu", "pl", "ko", "zh", "ru", "ja" };
+
+       if (p_in->language_count > out_length)
+               return FALSE;
+
+       memset((void*) p_out, 0xFF, out_length);
+
+       for (i = 0; i < p_in->language_count; i++) {
+               if (p_in->language[i] < SIM_LANG_UNSPECIFIED) {
+                       strncpy((char *) &p_out[i * 2], LanguageCode[p_in->language[i]], 2);
+                       dbg( "sim_encode_li: p_out[%s]:[%x][%x]", p_out, p_out[i*2], p_out[(i*2)+1]);
+               }
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_imsi(struct tel_sim_imsi *p_out, unsigned char *p_in, int in_length)
+{
+       int i,j=0;
+       char imsi_raw[16];
+
+       dbg( "Func Entrance");
+
+       if ((NULL == p_out) || (NULL == p_in))
+               return FALSE;
+
+       /*
+               According to 3GPP specification, the length of raw IMSI data is 9 bytes.
+               first byte is length of IMSI
+               second byte byte has parity nibble, so second byte has one digit of IMSI. other byte has two digit of IMSI
+       */
+       if ((in_length == 0) || (in_length == 0xff) || (4 > in_length) || (9 <in_length)) {
+               dbg("No valid IMSI present to convert - length:[%x]",   in_length);
+               return FALSE;
+       }
+       dbg("imsi length[%d], input data length[%d]", p_in[0], in_length);
+
+       /* Decode IMSI value from nibbles */
+       for (i = 1; i < in_length; i++) {
+               if (i == 1) { /* first byte, ignore lower nibble */
+                       imsi_raw[j++] = ((p_in[i] & 0xF0) >> 4) + '0';
+               } else if (i == p_in[0]+1) { /* last byte */
+                       imsi_raw[j++] = (p_in[i] & 0x0F)+ '0';
+                       if (p_in[0]%2) /* count the last one if odd digits */
+                               imsi_raw[j++] = ((p_in[i] & 0xF0) >> 4) + '0';
+               } else {
+                       imsi_raw[j++] = (p_in[i]  & 0x0F) + '0';
+                       imsi_raw[j++] = ((p_in[i] & 0xF0) >> 4) + '0';
+               }
+       }
+       /* Terminate string */
+       imsi_raw[j] = '\0';
+       dbg("imsi_raw[%s], size[%d]", imsi_raw, strlen(imsi_raw));
+
+       memcpy(p_out->plmn, imsi_raw, 5);
+       p_out->plmn[5] = '\0';
+       memcpy(p_out->msin, imsi_raw+5, strlen(imsi_raw)-5);
+       p_out->msin[strlen(imsi_raw)-5] = '\0';
+
+       dbg("p_out->plmn[%s], p_out->msin[%s]", p_out->plmn, p_out->msin);
+
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_sst(struct tel_sim_sst *p_sst, unsigned char *p_in, int in_length)
+{
+       unsigned char sstByte, rast, mask = 0;
+       char simServiceID = 1;  // set "CHV1 disable function"
+       int i, svc_count;
+       char *p_index;
+
+       memset((void*)p_sst, 0, sizeof(struct tel_sim_sst));
+
+       if (in_length == 0 || in_length > SIM_SST_LEN_MAX)
+               return FALSE;
+
+       // get count of SIM service id. one byte has four service status.
+       svc_count = in_length * 4;
+
+       /*3GPP 11.11 SST shows 50 kinds of service types. current sim_ss_s has also 50 elements*/
+       if (svc_count > SIM_SST_SERVICE_CNT_MAX)
+               svc_count = SIM_SST_SERVICE_CNT_MAX;
+
+       p_index = (char*)p_sst;
+
+       for (i = 0; i < svc_count; i++) {
+               sstByte = p_in[(simServiceID - 1) / 4];
+               rast = simServiceID - 4 * (simServiceID / 4);
+
+               switch (rast) {
+                       case 1:
+                               mask = 0x02;
+                               break;
+                       case 2:
+                               mask = 0x08;
+                               break;
+                       case 3:
+                               mask = 0x20;
+                               break;
+                       case 0:
+                               mask = 0x80;
+                               break;
+               }
+
+               if (sstByte & mask)
+                       *p_index = 1;
+               else
+                       *p_index = 0;
+
+               p_index += sizeof(char);
+               simServiceID++; // next service id
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_spn(struct tel_sim_spn *p_spn, unsigned char *p_in, int in_length)
+{
+       int i;
+
+       if (in_length == 0)
+               return FALSE;
+
+       p_spn->display_condition = p_in[0];
+       dbg( "The display condition is [%d]", p_spn->display_condition);
+
+       for (i = 1; i < SIM_SPN_LEN_MAX + 1; i++) {
+               if (p_in[i] == 0xFF)
+                       break; /* loop break*/
+
+               p_spn->spn[i - 1] = p_in[i];
+               dbg( "EF-SPN name[%d][%c]", i, p_in[i]);
+       }
+       p_spn->spn[i-1] = '\0';
+
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_spdi(struct tel_sim_spdi *p_spdi, unsigned char *p_in, int in_length)
+{
+       int i, Src_plmn_start_len, total_data_len;
+
+       if (in_length == 0)
+               return FALSE;
+
+       if(p_in[0] == 0xff){
+               dbg("file is exist but there is no valid records");
+               p_spdi->plmn_count = 0;
+               memset(p_spdi->list, 0x00, sizeof(unsigned char)*7*SIM_SPDI_PLMN_MAX);
+               return TRUE;
+       }
+
+       //Display info tag('A3')
+       if (p_in[0] == 0xA3) {
+               total_data_len = p_in[1];
+                //PLMN list tag('80')
+               if (p_in[2] == 0x80) {
+                       p_spdi->plmn_count = p_in[3] / 3;
+
+                       /*
+                        *  plmn tag 1byte
+                        *  length 1byte
+                        *  each plmn entry 3byte
+                        */
+                       if (p_spdi->plmn_count > SIM_SPDI_PLMN_MAX)
+                               p_spdi->plmn_count =    SIM_SPDI_PLMN_MAX;
+
+                       Src_plmn_start_len = 4;
+
+                       dbg( "p_spdi->num_of_plmn_entries[%d]", p_spdi->plmn_count);
+
+                       for (i = 0; i < p_spdi->plmn_count; i++) {
+                               unsigned char packetInDigit[3 * 2 + 1];
+                               _bcd_to_digit((char*) packetInDigit, (char*) &p_in[Src_plmn_start_len], 3);
+                               // get MCC (mobile country code)
+                               memcpy(p_spdi->list[i].plmn, &(packetInDigit[0]), 6);
+                               p_spdi->list[i].plmn[6] = '\0';
+                               dbg( "SPDI PLMN[%d][%s]", i, p_spdi->list[i].plmn);
+
+                               Src_plmn_start_len = Src_plmn_start_len + 3;
+                       }
+                       return TRUE;
+               }
+               dbg("Current EF-SPDI has invalid data");
+               return FALSE;
+       }
+       dbg("Current EF-SPDI has invalid data");
+       return FALSE;
+}
+
+gboolean tcore_sim_decode_msisdn(struct tel_sim_msisdn *p_msisdn, unsigned char *p_in, int in_length)
+{
+       int X;  // alpha id max length
+       int value_length;
+       int bcd_byte;   // dialing number max length
+
+       memset((void*) p_msisdn, 0, sizeof(struct tel_sim_msisdn));
+
+       if (in_length == 0)
+               return FALSE;
+
+       if (_is_empty(p_in, in_length) == TRUE)
+               return TRUE;    // this is empty record
+
+       X = in_length - 14;     // get alpha id max length
+
+       if (X != 0) {
+               value_length =  _get_string((unsigned char *)p_msisdn->name, p_in, X);
+               p_msisdn->name[value_length] = '\0';
+       }
+
+       // get dialing number length
+       // p_in[X] is BCD length of dialing number length plus TON/NPI 1 bytes.
+       // Convert to digit length and subtract TON/NPI length.
+       if (p_in[X] != 0xFF) {
+               dbg( "Dialing number Length %d, BCD length 0x%x ",  (p_in[X] - 1) * 2, p_in[X]);
+
+               // get TON and NPI
+               p_msisdn->ton = (p_in[X + 1] >> 4) & 0x07;
+
+               // get actual dialing number length
+               bcd_byte = _get_valid_bcd_byte(&p_in[X + 2], SIM_XDN_NUMBER_LEN_MAX / 2);
+               dbg( "bcd_byte[%x]", bcd_byte);
+
+               // get dialing number/SSC string
+               value_length = _bcd_to_digit((char*) p_msisdn->num, (char*) &p_in[X + 2], bcd_byte); // actual dialing number length in BCD.
+               p_msisdn->num[value_length] = '\0';
+               dbg( "p_msisdn->num[%s]", p_msisdn->num);
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_xdn(struct tel_sim_dialing_number *p_xdn, unsigned char *p_in, int in_length)
+{
+       int X;  // alpha id max length
+       int bcd_byte;   // dialing number max length
+
+       memset((void*) p_xdn, 0, sizeof(struct tel_sim_dialing_number));
+
+       if (in_length == 0)
+               return FALSE;
+
+       if (_is_empty(p_in, in_length) == TRUE)
+               return TRUE;    // this is empty record
+
+       X = in_length - 14;     // get alpha id max length
+
+       if (X != 0) {
+               p_xdn->AlphaIdLength = _get_string((unsigned char *)p_xdn->AlphaId, p_in, X);
+               p_xdn->AlphaIDMaxLength = X;
+       }
+
+       // get dialing number length
+       // p_in[X] is BCD length of dialing number length plus TON/NPI 1 bytes.
+       // Convert to digit length and subtract TON/NPI length.
+       if (p_in[X] != 0xFF) {
+               p_xdn->DiallingNumMaxLength = (p_in[X] - 1) * 2;
+               dbg( "Dialing number Length %d, BCD length 0x%x ",      p_xdn->DiallingNumMaxLength, p_in[X]);
+
+               if (p_xdn->DiallingNumMaxLength > SIM_XDN_NUMBER_LEN_MAX)       {
+                       /*
+                        this may be broken record.
+                        p_xdn->b_used = FALSE;
+                        memset((void*)p_xdn, 0, sizeof(tapi_sim_dialing_number_info_t));
+                        return FALSE;
+
+                        ADN record cannot have more than 20 digits. Anyway we can restrict this as per 31.102
+                        X+1    Length of BCD number/SSC contents       M       1 byte
+                        X+2    TON and NPI     M       1 byte
+                        X+3 to X+12    Dialing Number/SSC String       M       10 bytes
+                        X+13   Capability/Configuration1 Identifier    M       1 byte
+                        X+14   Extension1 Record Identifier    M       1 byte
+
+                        Anyway we are doing this check @
+                        bcd_byte = _get_valid_bcd_byte (&p_in[X+2], TAPI_SIM_XDN_DIALING_NUMBER_LEN/2);
+                        by using the 20/2; so don`t return false.
+                        */
+                       if (p_in[X] == 0x00)
+                               p_xdn->DiallingNumMaxLength = 0;
+                       else
+                               p_xdn->DiallingNumMaxLength = SIM_XDN_NUMBER_LEN_MAX;
+               }
+
+               // get TON and NPI
+               p_xdn->TypeOfNumber = (p_in[X + 1] >> 4) & 0x07;
+               p_xdn->NumberingPlanIdent = p_in[X + 1] & 0x0F;
+
+               // get actual dialing number length
+               bcd_byte = _get_valid_bcd_byte(&p_in[X + 2], SIM_XDN_NUMBER_LEN_MAX / 2);
+               dbg( "bcd_byte[%x]", bcd_byte);
+
+               // get dialing number/SSC string
+               p_xdn->DiallingnumLength = _bcd_to_digit((char*) p_xdn->DiallingNum, (char*) &p_in[X + 2], bcd_byte); // actual dialing number length in BCD.
+               dbg( "p_xdn->DiallingnumLength[%x]", p_xdn->DiallingnumLength);
+               dbg( "p_xdn->DiallingNum[%s]", p_xdn->DiallingNum);
+               // get Capability/Configuration id
+               p_xdn->CapaConfigId = p_in[X + 12];
+               // get Extension1 id
+               p_xdn->Ext1RecordId = p_in[X + 13];
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_encode_xdn(char *p_out, int out_length, struct tel_sim_dialing_number *p_xdn)
+{
+       int X;
+       char bcdCode[SIM_XDN_NUMBER_LEN_MAX / 2];
+
+       memset((void*) p_out, 0xFF, out_length);
+
+       X = out_length - 14;            // get alpha id max length
+
+       if (X < p_xdn->AlphaIdLength)
+               return FALSE;           // alpha id is too big
+
+       if (p_xdn->DiallingnumLength > SIM_XDN_NUMBER_LEN_MAX)  // this is digit length
+               return FALSE;   // dialing number is too big
+
+       _set_string((unsigned char *)p_out, (unsigned char *)p_xdn->AlphaId, p_xdn->AlphaIdLength);
+
+       // set length of BCD number/SSC contents
+       // p_xdn->diallingnumLen is maximum digit length. = 20 bytes.
+       // convert to BCD length and add 1 byte.
+       p_out[X] = ((p_xdn->DiallingnumLength + 1) / 2) + 1;
+
+       // set TON and NPI
+       p_out[X + 1] = 0x80;
+       p_out[X + 1] |= (p_xdn->TypeOfNumber & 0x07) << 4;
+       p_out[X + 1] |= p_xdn->NumberingPlanIdent & 0x0F;
+
+       // set dialing number/SSC string
+       memset((void*) bcdCode, 0xFF, SIM_XDN_NUMBER_LEN_MAX / 2);
+
+       _digit_to_bcd((char*) bcdCode, (char*) p_xdn->DiallingNum, p_xdn->DiallingnumLength);
+
+       memcpy((void*) &p_out[X + 2], bcdCode, SIM_XDN_NUMBER_LEN_MAX / 2);
+
+       // set Capability/Configuration Identifier
+       p_out[X + 12] = (unsigned char) p_xdn->CapaConfigId;
+       // set extension1 record Identifier
+       p_out[X + 13] = (unsigned char) p_xdn->Ext1RecordId;
+
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_ecc(struct tel_sim_ecc_list *p_ecc, unsigned char *p_in, int in_length)
+{
+       int bcd_byte;   // dialing number max length
+       int i;
+       int valid_ecc_length;
+       memset((void*)p_ecc, 0x00, sizeof(struct tel_sim_ecc_list));
+
+       if(in_length%3 != 0) {
+               dbg("error - invalid data length");
+               return FALSE;
+       }
+
+       for(i=0; i < in_length/3; i++){
+               //get the BCD length of the ECC
+               bcd_byte = _get_valid_bcd_byte((unsigned char*) p_in+(i*3), 3);
+               if(bcd_byte != 0) {
+                       valid_ecc_length = _bcd_to_digit(p_ecc->ecc[p_ecc->ecc_count].ecc_num, (char *)p_in+(i*3), bcd_byte);
+                       p_ecc->ecc[p_ecc->ecc_count].ecc_num[valid_ecc_length] = '\0';
+                       p_ecc->ecc_count++;
+               }
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_ust(struct tel_sim_ust *p_ust, unsigned char *p_in, int in_length)
+{
+       int i, j;
+       char mask;
+       char *p_index;
+       memset((void*) p_ust, 0, sizeof(struct tel_sim_ust));
+       p_index = (char*)p_ust;
+
+/*     UST service is described to 74(1 byte includes 8 service status) in 31.102 r7.
+       current sim_ust_s has 64 services. so in_length should be under 8 byte. */
+       if (in_length > SIM_UST_BYTE_LEN_MAX)
+               in_length = SIM_UST_BYTE_LEN_MAX;
+
+       for (i = 0; i < in_length; i++) {
+               mask = 0x01;    // reset mast to check first bit
+
+               for (j = 0; j < 8; j++) {
+                       if (p_in[i] & mask) {
+                               *p_index = 1;
+                       }
+                       p_index += sizeof(char);
+                       mask = mask << 1;
+               }
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_est(struct tel_sim_est *p_est, unsigned char *p_in, int in_length)
+{
+       memset((void*) p_est, 0, sizeof(struct tel_sim_est));
+
+       if (*p_in & 0x01)
+               p_est->bFdnEnabled = TRUE;
+       if (*p_in & 0x02)
+               p_est->bBdnEnabled = TRUE;
+       if (*p_in & 0x04)
+               p_est->bAclEnabled = TRUE;
+
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_uecc(struct tel_sim_ecc *p_ecc, unsigned char* p_in, int in_length)
+{
+       int bcd_byte;   // dialing number max length
+       unsigned char eccServiceCategory;
+
+       if (_is_empty(p_in, in_length) == TRUE) {
+               memset(p_ecc, 0, sizeof(struct tel_sim_ecc));
+               return TRUE;
+       }
+
+       //get the BCD length of the ECC
+       bcd_byte = _get_valid_bcd_byte(&p_in[0], SIM_ECC_BYTE_LEN_MAX);
+
+       //get the ECC codes in digits and the length as well
+       _bcd_to_digit((char*) p_ecc->ecc_num, (char*) &p_in[0], bcd_byte);
+
+       //get the alpha identifier of ECC (
+       _get_string((unsigned char*) p_ecc->ecc_string, (unsigned char*) &p_in[3], in_length - 3);
+
+       eccServiceCategory = p_in[in_length - 1] & 0x1F;         // Check for the first 5 bits
+
+       /*
+        Assign the service category
+        3GPP TS24.008 Emergency Service Category Value.
+        Bit 8,7,6 are spare, 5~1 bit is used.
+        The meaning of the Emergency Category Value is derived from the following settings
+        (see 3GPP TS 22.101 clause 10):
+        Bit 1  Police 0x01
+        Bit 2  Ambulance 0x02
+        Bit 3  Fire Brigade 0x04
+        Bit 4  Marine Guard 0x08
+        Bit 5  Mountain Rescue 0x10
+        Bit 6  manually initiated eCall
+        Bit 7  automatically initiated eCall
+        Bit 8  is spare and set to "0"
+        */
+       switch (eccServiceCategory) {
+               case 0x01:
+                       p_ecc->ecc_category = SIM_ECC_POLICE;
+                       break;
+               case 0x02:
+                       p_ecc->ecc_category = SIM_ECC_AMBULANCE;
+                       break;
+               case 0x04:
+                       p_ecc->ecc_category = SIM_ECC_FIREBRIGADE;
+                       break;
+               case 0x08:
+                       p_ecc->ecc_category = SIM_ECC_MARAINEGUARD;
+                       break;
+               case 0x10:
+                       p_ecc->ecc_category = SIM_ECC_MOUTAINRESCUE;
+                       break;
+               default:
+                       p_ecc->ecc_category = SIM_ECC_SPARE;
+                       break;
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_gid( struct tel_sim_gid *p_gid, unsigned char* p_in, int in_length)
+{
+       int i;
+
+       memset((void*) p_gid, 0, sizeof(struct tel_sim_gid ));
+
+       if (in_length == 0)
+               return FALSE;
+
+/*regarding 31.102, EF-GID data byte is not defined. currently 10.*/
+       if (in_length >= SIM_GROUP_IDENTIFIER_LEN_MAX)
+               in_length = SIM_GROUP_IDENTIFIER_LEN_MAX;
+
+       for (i = 0; i < in_length; i++) {
+               if (p_in[i] == 0xFF)
+                       break;
+
+               p_gid->szGroupIdentifier[i] = p_in[i];
+               p_gid->GroupIdentifierLen++;
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_mbi(struct tel_sim_mbi *p_mbi, unsigned char *p_in, int in_length)
+{
+       int i;
+       for (i = 0; i < in_length; i++) {
+               dbg( " \t0x%04X.", p_in[i]);
+       }
+
+       /* EF-MBI is defined 4 mandatory, 1 optional byte in 31.102 */
+       if (in_length == 0 || in_length > SIM_MAIL_BOX_IDENTIFIER_LEN_MAX)
+               return FALSE;
+
+       if ( _is_empty(p_in, in_length) == TRUE)
+               return TRUE; // this is empty record
+
+       p_mbi->VoiceMailBoxIdentifier = p_in[0];
+       p_mbi->FaxMailBoxIdentifier = p_in[1];
+       p_mbi->EmailMailBoxIdentifier = p_in[2];
+       p_mbi->OtherMailBoxIdentifier = p_in[3];
+
+       // 5th byte is optional
+       if (in_length == 5)
+               p_mbi->VideoMailBoxIdentifier = p_in[4];
+
+       return TRUE;
+}
+
+gboolean tcore_sim_encode_mbi(char *p_out, int out_length, struct tel_sim_mbi *p_mbi)
+{
+       p_out[0] = p_mbi->VoiceMailBoxIdentifier;
+       p_out[1] = p_mbi->FaxMailBoxIdentifier;
+       p_out[2] = p_mbi->EmailMailBoxIdentifier;
+       p_out[3] = p_mbi->OtherMailBoxIdentifier;
+
+       if (out_length == 5)
+               p_out[4] = p_mbi->VideoMailBoxIdentifier;
+
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_cff(struct tel_sim_callforwarding *cfis, unsigned char *p_in, int in_length)
+{
+       struct tel_sim_cphs_cf  p_cff = {0,};
+
+       if (in_length == 0)
+               return FALSE;
+
+       dbg( "flag(0)=%x, packetlen=%lu ", p_in[0], in_length);
+       dbg( "flag(1)=%x", p_in[1]);
+
+       if ((p_in[0] & 0x0F) == 0x0A) {
+               p_cff.bCallForwardUnconditionalLine1 = TRUE;
+               cfis->voice1 = TRUE;
+       }
+       if ((p_in[0] & 0xF0) == 0xA0) {
+               p_cff.bCallForwardUnconditionalLine2 = TRUE;
+               cfis->voice2 = TRUE;
+       }
+
+       if (in_length > 1) {
+               if ((p_in[1] & 0x0F) == 0x0A) {
+                       p_cff.bCallForwardUnconditionalFax = TRUE;
+                       cfis->fax = TRUE;
+               }
+               if ((p_in[1] & 0xF0) == 0xA0) {
+                       p_cff.bCallForwardUnconditionalData = TRUE;
+                       cfis->data = TRUE;
+               }
+       }
+
+       dbg("Line1 = %d, line2 = %d, Fax = %d, Data = %d ",
+                       p_cff.bCallForwardUnconditionalLine1,
+                       p_cff.bCallForwardUnconditionalLine2,
+                       p_cff.bCallForwardUnconditionalFax,
+                       p_cff.bCallForwardUnconditionalData);
+       return TRUE;
+}
+
+char* tcore_sim_encode_cff(const struct tel_sim_callforwarding *cff)
+{
+       int i, j = 0;
+       char *p_out = NULL;
+       unsigned char* pTemp = (unsigned char*) cff;
+       unsigned char present = 0x0A;
+       unsigned char absent = 0x05;
+
+       p_out =  calloc(SIM_CPHS_CALL_FORWARDING_LEN_MAX+1, 1);
+
+       for (i = 0; i < SIM_CPHS_CALL_FORWARDING_LEN_MAX; i++) {
+               present = 0x0A;
+               absent = 0x05;
+
+               for (j = 0; j < 2; j++) {
+                       if (*pTemp) {
+                               p_out[i] = p_out[i] | present;
+                       } else {
+                               p_out[i] = p_out[i] | absent;
+                       }
+                       pTemp += sizeof(gboolean);
+                       present = present << 4;
+                       absent = absent << 4;
+               }
+       }
+       p_out[SIM_CPHS_CALL_FORWARDING_LEN_MAX] = '\0';
+       return p_out;
+}
+
+gboolean tcore_sim_decode_csp(struct tel_sim_cphs_csp *p_csp, unsigned char *p_in, int in_length)
+{
+       int i, j, k = 0;
+       unsigned char byteSignificance = 0x00;
+       unsigned char mask = 0x80;
+
+       if (in_length == 0)
+               return FALSE;
+
+       memset((void*) p_csp, 0, sizeof(struct tel_sim_cphs_csp));
+
+/* current telephony supports 22 byte cphs-csp data. 18 byte is mandatory, the other is optional. */
+       for (i = 0, j = 0; i < SIM_CPHS_CSP_LEN_MAX || j < SIM_CPHS_CSP_LEN_MAX; i++, j++) {
+               p_csp->ServiceProfileEntry[j].CustomerServiceGroup = (enum tel_sim_cphs_csp_group) p_in[i];
+               byteSignificance = p_in[++i];
+               mask = 0x80;
+
+               switch (p_csp->ServiceProfileEntry[j].CustomerServiceGroup) {
+                       case 0x01:
+                               for (k = 0; k < 5; k++) {
+                                       switch (byteSignificance & mask) {
+                                               case 0x80:
+                                                       p_csp->ServiceProfileEntry[j].u.CallOffering.bCallForwardingUnconditional = TRUE;
+                                                       break;
+                                               case 0x40:
+                                                       p_csp->ServiceProfileEntry[j].u.CallOffering.bCallForwardingOnUserBusy = TRUE;
+                                                       break;
+                                               case 0x20:
+                                                       p_csp->ServiceProfileEntry[j].u.CallOffering.bCallForwardingOnNoReply = TRUE;
+                                                       break;
+                                               case 0x10:
+                                                       p_csp->ServiceProfileEntry[j].u.CallOffering.bCallForwardingOnUserNotReachable = TRUE;
+                                                       break;
+                                               case 0x08:
+                                                       p_csp->ServiceProfileEntry[j].u.CallOffering.bCallTransfer = TRUE;
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       mask = mask >> 1;
+                               }
+                               break;
+
+                       case 0x02:
+                               for (k = 0; k < 5; k++) {
+                                       switch (byteSignificance & mask) {
+                                               case 0x80:
+                                                       p_csp->ServiceProfileEntry[j].u.CallRestriction.bBarringOfAllOutgoingCalls = TRUE;
+                                                       break;
+                                               case 0x40:
+                                                       p_csp->ServiceProfileEntry[j].u.CallRestriction.bBarringOfOutgoingInternationalCalls = TRUE;
+                                                       break;
+                                               case 0x20:
+                                                       p_csp->ServiceProfileEntry[j].u.CallRestriction.bBarringOfOutgoingInternationalCallsExceptHplmn = TRUE;
+                                                       break;
+                                               case 0x10:
+                                                       p_csp->ServiceProfileEntry[j].u.CallRestriction.bBarringOfAllIncomingCallsRoamingOutsideHplmn = TRUE;
+                                                       break;
+                                               case 0x08:
+                                                       p_csp->ServiceProfileEntry[j].u.CallRestriction.bBarringOfIncomingCallsWhenRoaming = TRUE;
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       mask = mask >> 1;
+                               }
+                               break;
+
+                       case 0x03:
+                               for (k = 0; k < 5; k++) {
+                                       switch (byteSignificance & mask) {
+                                               case 0x80:
+                                                       p_csp->ServiceProfileEntry[j].u.OtherSuppServices.bMultiPartyService = TRUE;
+                                                       break;
+                                               case 0x40:
+                                                       p_csp->ServiceProfileEntry[j].u.OtherSuppServices.bClosedUserGroup = TRUE;
+                                                       break;
+                                               case 0x20:
+                                                       p_csp->ServiceProfileEntry[j].u.OtherSuppServices.bAdviceOfCharge = TRUE;
+                                                       break;
+                                               case 0x10:
+                                                       p_csp->ServiceProfileEntry[j].u.OtherSuppServices.bPreferentialClosedUserGroup = TRUE;
+                                                       break;
+                                               case 0x08:
+                                                       p_csp->ServiceProfileEntry[j].u.OtherSuppServices.bClosedUserGroupOutgoingAccess = TRUE;
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       mask = mask >> 1;
+                               }
+                               break;
+
+                       case 0x04:
+                               for (k = 0; k < 4; k++) {
+                                       switch (byteSignificance & mask) {
+                                               case 0x80:
+                                                       p_csp->ServiceProfileEntry[j].u.CallComplete.bCallHold = TRUE;
+                                                       break;
+                                               case 0x40:
+                                                       p_csp->ServiceProfileEntry[j].u.CallComplete.bCallWaiting = TRUE;
+                                                       break;
+                                               case 0x20:
+                                                       p_csp->ServiceProfileEntry[j].u.CallComplete.bCompletionOfCallToBusySubscriber = TRUE;
+                                                       break;
+                                               case 0x10:
+                                                       p_csp->ServiceProfileEntry[j].u.CallComplete.bUserUserSignalling = TRUE;
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       mask = mask >> 1;
+                               }
+                               break;
+
+                       case 0x05:
+                               for (k = 0; k < 7; k++) {
+                                       switch (byteSignificance & mask) {
+                                               case 0x80:
+                                                       p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageMobileTerminated = TRUE;
+                                                       break;
+                                               case 0x40:
+                                                       p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageMobileOriginated = TRUE;
+                                                       break;
+                                               case 0x20:
+                                                       p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageCellBroadcast = TRUE;
+                                                       break;
+                                               case 0x10:
+                                                       p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageReplyPath = TRUE;
+                                                       break;
+                                               case 0x08:
+                                                       p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageDeliveryConf = TRUE;
+                                                       break;
+                                               case 0x04:
+                                                       p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageProtocolIdentifier = TRUE;
+                                                       break;
+                                               case 0x02:
+                                                       p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageValidityPeriod = TRUE;
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       mask = mask >> 1;
+                               }
+                               break;
+
+                       case 0x06:
+                               for (k = 0; k < 1; k++) {
+                                       switch (byteSignificance & mask) {
+                                               case 0x80:
+                                                       p_csp->ServiceProfileEntry[j].u.CphsTeleservices.bAlternativeLineService =  TRUE;
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       mask = mask >> 1;
+                               }
+                               break;
+
+                       case 0x07:
+                               for (k = 0; k < 1; k++) {
+                                       switch (byteSignificance & mask) {
+                                               case 0x80:
+                                                       p_csp->ServiceProfileEntry[j].u.CphsFeatures.bStringServiceTable = TRUE;
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       mask = mask >> 1;
+                               }
+                               break;
+
+                       case 0x08:
+                               for (k = 0; k < 8; k++) {
+                                       switch (byteSignificance & mask) {
+                                               case 0x80:
+                                                       p_csp->ServiceProfileEntry[j].u.NumberIdentifiers.bCallingLineIdentificationPresent = TRUE;
+                                                       break;
+                                               case 0x20:
+                                                       p_csp->ServiceProfileEntry[j].u.NumberIdentifiers.bConnectedLineIdentificationRestrict = TRUE;
+                                                       break;
+                                               case 0x10:
+                                                       p_csp->ServiceProfileEntry[j].u.NumberIdentifiers.bConnectedLineIdentificationPresent = TRUE;
+                                                       break;
+                                               case 0x08:
+                                                       p_csp->ServiceProfileEntry[j].u.NumberIdentifiers.bMaliciousCallIdentifier = TRUE;
+                                                       break;
+                                               case 0x02:
+                                                       p_csp->ServiceProfileEntry[j].u.NumberIdentifiers.bCallingLineIdentificationSend = TRUE;
+                                                       break;
+                                               case 0x01:
+                                                       p_csp->ServiceProfileEntry[j].u.NumberIdentifiers.bCallingLineIdentificationBlock = TRUE;
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       mask = mask >> 1;
+                               }
+                               break;
+
+                       case 0x09:
+                               for (k = 0; k < 6; k++) {
+                                       switch (byteSignificance & mask) {
+                                               case 0x80:
+                                                       p_csp->ServiceProfileEntry[j].u.PhaseServices.bMenuForGprs = TRUE;
+                                                       break;
+                                               case 0x40:
+                                                       p_csp->ServiceProfileEntry[j].u.PhaseServices.bMenuForHighSpeedCsd = TRUE;
+                                                       break;
+                                               case 0x20:
+                                                       p_csp->ServiceProfileEntry[j].u.PhaseServices.bMenuForVoiceGroupCall = TRUE;
+                                                       break;
+                                               case 0x10:
+                                                       p_csp->ServiceProfileEntry[j].u.PhaseServices.bMenuForVoiceBroadcastService = TRUE;
+                                                       break;
+                                               case 0x08:
+                                                       p_csp->ServiceProfileEntry[j].u.PhaseServices.bMenuForMultipleSubscriberProfile = TRUE;
+                                                       break;
+                                               case 0x04:
+                                                       p_csp->ServiceProfileEntry[j].u.PhaseServices.bMenuForMultipleBand = TRUE;
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       mask = mask >> 1;
+                               }
+                               break;
+
+                       case 0xC0:
+                               for (k = 0; k < 8; k++) {
+                                       switch (byteSignificance & mask) {
+                                               case 0x80:
+                                                       p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForManualSelection = TRUE;
+                                                       break;
+                                               case 0x40:
+                                                       p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForVoiceMail = TRUE;
+                                                       break;
+                                               case 0x20:
+                                                       p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForMoSmsAndPaging = TRUE;
+                                                       break;
+                                               case 0x10:
+                                                       p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForMoSmsWithEmialType = TRUE;
+                                                       break;
+                                               case 0x08:
+                                                       p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForFaxCalls = TRUE;
+                                                       break;
+                                               case 0x04:
+                                                       p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForDataCalls = TRUE;
+                                                       break;
+                                               case 0x01:
+                                                       p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForChangeLanguage = TRUE;
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       mask = mask >> 1;
+                               }
+                               break;
+
+                       case 0xD5:
+                               for (k = 0; k < 8; k++) {
+                                       switch (byteSignificance & mask) {
+                                               case 0x80:
+                                               case 0x40:
+                                               case 0x20:
+                                               case 0x10:
+                                               case 0x08:
+                                               case 0x04:
+                                               case 0x02:
+                                               case 0x01:
+                                                       p_csp->ServiceProfileEntry[j].u.InformationNumbers.bInformationNumbers = TRUE;
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       mask = mask >> 1;
+                               }
+                               break;
+
+                       default:
+                               break;
+               }
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_encode_csp(unsigned char *p_out, int out_length, struct tel_sim_cphs_csp *p_csp)
+{
+       unsigned char i, j = 0;
+
+       if (out_length == 0)
+               return FALSE;
+
+       memset((void*) p_out, 0xFF, out_length);
+
+/* current telephony supports 22 byte cphs-csp data. 18 byte is mandatory, the other is optional.*/
+       for (i = 0, j = 0; i < 22 || j < 22; i++, j++) {
+               p_out[i] = (unsigned char) p_csp->ServiceProfileEntry[j].CustomerServiceGroup;
+               switch (p_out[i]) {
+                       case 0x01:
+                               p_out[++i] =    (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallOffering.bCallForwardingUnconditional) << 7)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallOffering.bCallForwardingOnUserBusy) << 6)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallOffering.bCallForwardingOnNoReply) << 5)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallOffering.bCallForwardingOnUserNotReachable) << 4)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallOffering.bCallTransfer) << 3);
+                               break;
+
+                       case 0x02:
+                               p_out[++i] =    (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallRestriction.bBarringOfAllOutgoingCalls) << 7)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallRestriction.bBarringOfOutgoingInternationalCalls) << 6)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallRestriction.bBarringOfOutgoingInternationalCallsExceptHplmn) << 5)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallRestriction.bBarringOfAllIncomingCallsRoamingOutsideHplmn) << 4)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallRestriction.bBarringOfIncomingCallsWhenRoaming) << 3);
+                               break;
+
+                       case 0x03:
+                               p_out[++i] =    (((unsigned char) p_csp->ServiceProfileEntry[j].u.OtherSuppServices.bMultiPartyService) << 7)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.OtherSuppServices.bClosedUserGroup) << 6)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.OtherSuppServices.bAdviceOfCharge) << 5)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.OtherSuppServices.bPreferentialClosedUserGroup) << 4)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.OtherSuppServices.bClosedUserGroupOutgoingAccess) << 3);
+                               break;
+
+                       case 0x04:
+                               p_out[++i] = (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallComplete.bCallHold) << 7)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallComplete.bCallWaiting) << 6)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallComplete.bCompletionOfCallToBusySubscriber) << 5)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.CallComplete.bUserUserSignalling) << 4);
+                               break;
+
+                       case 0x05:
+                               p_out[++i] = (((unsigned char) p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageMobileTerminated) << 7)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageMobileOriginated) << 6)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageCellBroadcast) << 5)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageReplyPath) << 4)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageDeliveryConf) << 3)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageProtocolIdentifier) << 2)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.Teleservices.bShortMessageValidityPeriod) << 1);
+                               break;
+
+                       case 0x06:
+                               p_out[++i] = (((unsigned char) p_csp->ServiceProfileEntry[j].u.CphsTeleservices.bAlternativeLineService) << 7);
+                               break;
+
+                       case 0x07:
+                               p_out[++i] = (((unsigned char) p_csp->ServiceProfileEntry[j].u.CphsFeatures.bStringServiceTable) << 7);
+                               break;
+
+                       case 0x08:
+                               p_out[++i] = (((unsigned char) p_csp->ServiceProfileEntry[j].u.NumberIdentifiers.bCallingLineIdentificationPresent) << 7)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.NumberIdentifiers.bConnectedLineIdentificationRestrict) << 5)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.NumberIdentifiers.bConnectedLineIdentificationPresent) << 4)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.NumberIdentifiers.bMaliciousCallIdentifier) << 3)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.NumberIdentifiers.bCallingLineIdentificationSend) << 1)
+                                                               + ((unsigned char) p_csp->ServiceProfileEntry[j].u.NumberIdentifiers.bCallingLineIdentificationBlock);
+                               break;
+
+                       case 0x09:
+                               p_out[++i] =    (((unsigned char) p_csp->ServiceProfileEntry[j].u.PhaseServices.bMenuForGprs) << 7)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.PhaseServices.bMenuForHighSpeedCsd) << 6)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.PhaseServices.bMenuForVoiceGroupCall) << 5)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.PhaseServices.bMenuForVoiceBroadcastService) << 4)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.PhaseServices.bMenuForMultipleSubscriberProfile) << 3)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.PhaseServices.bMenuForMultipleBand) << 2);
+                               break;
+
+                       case 0xC0:
+                               p_out[++i] =    (((unsigned char) p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForManualSelection) << 7)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForVoiceMail) << 6)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForMoSmsAndPaging) << 5)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForMoSmsWithEmialType) << 4)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForFaxCalls) << 3)
+                                                               + (((unsigned char) p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForDataCalls) << 2)
+                                                               + ((unsigned char) p_csp->ServiceProfileEntry[j].u.ValueAddedServices.bRestrictMenuForChangeLanguage);
+                               break;
+
+                       case 0xD5:
+                               if (p_csp->ServiceProfileEntry[j].u.InformationNumbers.bInformationNumbers)
+                                       p_out[++i] = 0xFF;
+                               else
+                                       p_out[++i] = 0x00;
+                               break;
+
+                       default:
+                               break;
+               }
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_vmwf(struct tel_sim_cphs_mw *p_vmwf, unsigned char* p_in, unsigned long in_length)
+{
+       int i, j = 0;
+       unsigned char* pTemp = (unsigned char*) p_vmwf;
+       unsigned char mask = 0x0F;
+       unsigned char voiceMsgFlg = 0;
+
+       if (in_length == 0)
+               return FALSE;
+
+/*     current telephony supports 2 byte cphs-vmwf data*/
+       for (i = 0; i < SIM_CPHS_VMWF_LEN_MAX; i++) {
+               voiceMsgFlg = p_in[i];
+               for (j = 0; j < 2; j++) {
+                       if ((voiceMsgFlg & mask) == 0x0A) {
+                               *pTemp = 1;  //TRUE
+                       } else if ((voiceMsgFlg & mask) == 0x05) {
+                               *pTemp = 0;  // FALSE
+                       }
+                       pTemp += sizeof(gboolean);
+                       voiceMsgFlg = voiceMsgFlg >> 4;
+               }
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_mwis(struct tel_sim_mw *pMwis, unsigned char *p_in, int in_length)
+{
+       int i;
+       unsigned char type = 0;
+       unsigned char mask = 0x01;
+
+       if (in_length == 0)
+               return FALSE;
+
+       memset((void*) pMwis, 0, sizeof(struct tel_sim_mw));
+
+       type = p_in[0];  //0x07
+
+       if (type) {
+               for (i = 0; i < 5; i++) {
+                       switch (type & mask) {
+                               case 0x01:
+                                       pMwis->IndicatorType = pMwis->IndicatorType | SIM_MWIS_VOICE;
+                                       break;
+                               case 0x02:
+                                       pMwis->IndicatorType = pMwis->IndicatorType | SIM_MWIS_FAX;
+                                       break;
+                               case 0x04:
+                                       pMwis->IndicatorType = pMwis->IndicatorType | SIM_MWIS_EMAIL;
+                                       break;
+                               case 0x08:
+                                       pMwis->IndicatorType = pMwis->IndicatorType | SIM_MWIS_OTHER;
+                                       break;
+                               case 0x10:
+                                       pMwis->IndicatorType = pMwis->IndicatorType | SIM_MWIS_VIDEO;
+                                       break;
+                               default:
+                                       pMwis->IndicatorType = pMwis->IndicatorType | SIM_MWIS_NONE;
+                                       break;
+                       }
+                       mask = mask << 1;
+               }
+
+               pMwis->voice_count = p_in[1];
+               pMwis->fax_count = p_in[2];
+               pMwis->email_count = p_in[3];
+               pMwis->other_count = p_in[4];
+
+               if (in_length == 6)
+                       pMwis->video_count = p_in[5];
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_encode_mwis( char *p_out, int out_length, struct tel_sim_mw *pMwis)
+{
+       if (out_length == 0)
+               return FALSE;
+
+       memset((void*) p_out, 0xFF, out_length);
+       p_out[0] = 0x00;
+
+       p_out[0] = (unsigned char) pMwis->IndicatorType;
+       p_out[1] = pMwis->voice_count;
+       p_out[2] = pMwis->fax_count;
+       p_out[3] = pMwis->email_count;
+       p_out[4] = pMwis->other_count;
+
+       if (out_length == 6)
+               p_out[5] = pMwis->video_count;
+
+       return TRUE;
+}
+
+gboolean tcore_sim_encode_vmwf(char *p_out, int out_length, struct tel_sim_cphs_mw *p_vmwf)
+{
+       int i, j = 0;
+       unsigned char* pTemp = (unsigned char*) p_vmwf;
+       unsigned char present = 0x0A;
+       unsigned char absent = 0x05;
+
+       if (out_length == 0)
+               return FALSE;
+
+       for (i = 0; i < 2; i++) {
+               present = 0x0A;
+               absent = 0x05;
+
+               p_out[i] = 0x00;
+
+               for (j = 0; j < 2; j++) {
+                       if (*pTemp)
+                               p_out[i] = p_out[i] | present;  //TRUE
+                       else
+                               p_out[i] = p_out[i] | absent;  //TRUE
+
+                       pTemp += sizeof(gboolean);
+                       present = present << 4;
+                       absent = absent << 4;
+               }
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_ons(struct tel_sim_cphs_full_netname *p_on,unsigned  char* p_in, int in_length)
+{
+       int length;
+       memset((void*) p_on, 0, sizeof(struct tel_sim_cphs_full_netname));
+
+       if (in_length == 0)
+               return FALSE;
+
+       if (_is_empty(p_in, in_length) == TRUE)
+               return TRUE;
+
+       /* current telephony supports 25 byte cphs-operator name string.*/
+       if (in_length >= SIM_CPHS_OPERATOR_NAME_LEN_MAX)
+               in_length = SIM_CPHS_OPERATOR_NAME_LEN_MAX;
+
+       length = _get_string(p_on->full_name, p_in, in_length);
+       p_on->full_name[length] = '\0';
+       dbg( "Operator Name is (%s) & Length (%d) ",    p_on->full_name, length);
+
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_cfis(struct tel_sim_callforwarding *cfis, unsigned char *p_in, int in_length)
+{
+       int bcd_byte;   // dialing number max length
+       int i = 0, j = 0;
+       struct tel_sim_cfis p_cfis = {0,};
+
+       if (in_length == 0)
+               return FALSE;
+
+       if (_is_empty(p_in, in_length) == TRUE)
+               return TRUE;    // this is empty record
+
+       p_cfis.MspNumber = p_in[i++];
+       p_cfis.Status = p_in[i++];
+
+       // get TON and NPI
+       p_cfis.TypeOfNumber = (p_in[++i] >> 4) & 0x07;
+       p_cfis.NumberingPlanIdent = p_in[i++] & 0x0F;
+
+       // get actual dialing number length
+       /* current telephony supports 20 byte dialing number format. */
+       bcd_byte = _get_valid_bcd_byte(&p_in[i], SIM_XDN_NUMBER_LEN_MAX / 2);
+
+       // get dialing number/SSC string
+       p_cfis.DiallingnumLen = _bcd_to_digit((char*) p_cfis.DiallingNum, (char*) &p_in[i], bcd_byte); // actual dialing number length in BCD.
+       dbg( "Dialing number Length %d \n", p_cfis.DiallingnumLen);
+
+       i = i + SIM_XDN_NUMBER_LEN_MAX / 2;
+
+       // get Capability/Configuration id
+       //      p_cfis.CapaConfig2Id = p_in[i++];
+
+       // get Extension1 id
+       //      p_cfis.Ext7RecordId = p_in[i];
+
+       dbg( "MspNumber 0x%x", p_cfis.MspNumber);
+       dbg( "Status 0x%x", p_cfis.Status);
+       dbg( "DiallingnumLen %d", p_cfis.DiallingnumLen);
+       dbg( "TypeOfNumber %d", p_cfis.TypeOfNumber);
+       dbg( "NumberingPlanIdent %d", p_cfis.NumberingPlanIdent);
+
+       for (j = 0; j < p_cfis.DiallingnumLen; j++) {
+               dbg( "Dialing number[j][%c]", j, p_cfis.DiallingNum[j]);
+       }
+
+       if(p_cfis.Status & 0x01)
+               cfis->voice1 = TRUE;
+       if(p_cfis.Status & 0x02)
+               cfis->fax = TRUE;
+       if(p_cfis.Status & 0x04)
+               cfis->data = TRUE;
+       if(p_cfis.Status & 0x08)
+               cfis->sms = TRUE;
+       if(p_cfis.Status & 0x0a)
+               cfis->allbearer = TRUE;
+       return TRUE;
+}
+
+char* tcore_sim_encode_cfis(const struct tel_sim_callforwarding *p_cfis)
+{
+       char *p_out = NULL;
+       p_out = calloc(16+1, 1);
+
+       memset(p_out, 0x00, 16+1);
+
+       if(p_cfis->voice1 )
+               p_out[1] = p_out[1] | 0x01;
+       if(p_cfis->fax )
+               p_out[1] = p_out[1] | 0x02;
+       if(p_cfis->data )
+               p_out[1] = p_out[1] | 0x04;
+       if(p_cfis->sms )
+               p_out[1] = p_out[1] | 0x08;
+       if(p_cfis->voice1 )
+               p_out[1] = p_out[1] | 0x0a;
+
+       p_out[16] = '\0';
+
+       return p_out;
+
+#if 0
+       /*
+        Bytes  Description                                                     M/O             Length
+        1              MSP number                                                      M               1 byte
+        2              CFU indicator status                                    M               1 byte
+        3              Length of BCD number                                    M               1 byte
+        4              TON and NPI                                                     M               1 byte
+        5 to 14        Dialing Number                                          M               10 bytes
+        15             Capability/Configuration2 Record Identifier     M               1 byte
+        16             Extension 7 Record Identifier                           M               1 byte
+        */
+       p_out[0] = p_cfis.MspNumber;
+       p_out[1] = p_cfis->Status;
+       dbg("p_out[%d]=[%x] , p_cfis->Status[%d]",1, p_out[1], p_cfis->Status);
+
+       // set length of BCD number/SSC contents
+       // p_xdn->diallingnumLen is maximum digit length. = 20 bytes.
+       // convert to BCD length and add 1 byte.
+       p_out[ 2] = ((p_cfis->DiallingnumLen + 1) / 2) + 1;
+
+       // set TON and NPI
+       p_out[3] = 0x80;
+       p_out[3] |= (p_cfis->TypeOfNumber & 0x07) << 4;
+       p_out[3] |= p_cfis->NumberingPlanIdent & 0x0F;
+
+       // set dialing number/SSC string
+       memset((void*) bcdCode, 0xFF, SIM_XDN_NUMBER_LEN_MAX / 2);
+
+       _digit_to_bcd((char*) bcdCode, (char*) p_cfis->DiallingNum, p_cfis->DiallingnumLen);
+
+       memcpy((void*) &p_out[4], bcdCode, SIM_XDN_NUMBER_LEN_MAX / 2);
+
+       // set Capability/Configuration Identifier
+       p_out[14] = 0xff;
+
+       // set extension1 record Identifier
+       p_out[15] = 0xff;
+
+       return TRUE;
+#endif
+}
+
+gboolean tcore_sim_decode_dynamic_flag(struct tel_sim_cphs_dflag *p_df, unsigned char *p_in, int in_length)
+{
+       if (in_length == 0)
+               return FALSE;
+
+       memset((void*) p_df, 0, sizeof(struct tel_sim_cphs_dflag));
+
+       switch (p_in[0] & 0x01) {
+               case 0x00:
+                       p_df->DynamicFlags = SIM_DYNAMIC_FLAGS_LINE2;
+                       break;
+
+               case 0x01:
+                       p_df->DynamicFlags = SIM_DYNAMIC_FLAGS_LINE1;
+                       break;
+
+               default:
+                       break;
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_dynamic2_flag(struct tel_sim_cphs_dflag2 *p_d2f, unsigned char *p_in, int in_length)
+{
+       if (in_length == 0)
+               return FALSE;
+
+       memset((void*) p_d2f, 0, sizeof(struct tel_sim_cphs_dflag2));
+
+       switch (p_in[0] & 0x01) {
+               case 0x00:
+                       p_d2f->Dynamic2Flag = SIM_PIN2_ACCESSIBLE_FLAGS_UNLOCKED;
+                       break;
+               case 0x01:
+                       p_d2f->Dynamic2Flag = SIM_PIN2_ACCESSIBLE_FLAGS_LOCKED;
+                       break;
+               default:
+                       break;
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_encode_dynamic_flag(char *p_out, int out_length, struct tel_sim_cphs_dflag *p_df)
+{
+       if (out_length == 0 || out_length > 1)
+               return FALSE;
+
+       memset((void*) p_out, 0xFF, out_length);
+       p_out[0] = p_df->DynamicFlags;
+       return TRUE;
+}
+
+gboolean tcore_sim_encode_dynamic2_flag(char *p_out, int out_length, struct tel_sim_cphs_dflag2 *p_d2f)
+{
+       if (out_length == 0 || out_length > 1)
+               return FALSE;
+
+       memset((void*) p_out, 0xFF, out_length);
+       p_out[0] = p_d2f->Dynamic2Flag;
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_cphs_info(struct tel_sim_cphs_info *pCphsInfo, unsigned char *p_in, int in_length)
+{
+       int i, j = 0;
+       unsigned char mask = 0x03;
+       unsigned char* pTemp = (unsigned char*) &pCphsInfo->CphsServiceTable;
+
+       memset((void*) pCphsInfo, 0, sizeof(struct tel_sim_cphs_info));
+
+       if (in_length == 0)
+               return FALSE;
+
+        /*CPHS info EF has 3 bytes data.*/
+       if (in_length >= SIM_CPHS_INFO_LEN_MAX)
+               in_length = SIM_CPHS_INFO_LEN_MAX;
+
+       switch (p_in[0]) {
+               case 0x01:
+                       pCphsInfo->CphsPhase = SIM_CPHS_PHASE1;
+                       break;
+               case 0x02:
+                       pCphsInfo->CphsPhase = SIM_CPHS_PHASE2;
+                       break;
+               default:
+                       pCphsInfo->CphsPhase = SIM_CPHS_PHASE_RFU;
+                       break;
+       }
+
+       dbg( "Cphs Phase %d \n", pCphsInfo->CphsPhase);
+
+       for (i = 1; i < in_length; i++) { //CPHS SST is only 2 bytes
+               mask = 0x03;    // reset mast to check first bit
+               for (j = 0; j < 4; j++) {
+                       if (p_in[i] & mask) {
+                               *pTemp = 1;
+                       }
+                       dbg( "Byte (%d), service (%d) ", i+1, *pTemp);
+                       pTemp += sizeof(gboolean);
+                       mask = mask << 2;
+               }
+       }
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_short_ons(struct tel_sim_cphs_short_netname *p_short_name, unsigned char *p_in, int in_length)
+{
+       int length;
+
+       memset(p_short_name, 0x00, sizeof(struct tel_sim_cphs_short_netname));
+
+       if (_is_empty(p_in, in_length) == TRUE){
+               return TRUE;    // this is empty record
+       }
+
+       /*CPHS specification shows current EF include 10 bytes */
+       if (in_length == 0)
+               return FALSE;
+
+       if(in_length > SIM_CPHS_OPERATOR_NAME_SHORT_FORM_LEN_MAX)
+               in_length = SIM_CPHS_OPERATOR_NAME_SHORT_FORM_LEN_MAX;
+
+       length = _get_string( p_short_name->short_name, p_in, in_length );
+       p_short_name->short_name[length] = '\0';
+       dbg( "Operator short Name is (%s) &  length (%d)", p_short_name->short_name, length);
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_information_number(struct tel_sim_cphs_info_number *p_info, unsigned char* p_in, int in_length)
+{
+       int i;
+
+       if (in_length == 0)
+               return FALSE;
+
+       for (i = 0; i < in_length; i++) {
+               dbg( " \t0x%04X.", p_in[i]);
+       }
+
+       if (_is_empty(p_in, in_length) == TRUE)
+               return TRUE;    // this is empty record
+
+       p_info->AlphaIdLength = p_in[0];
+
+       if (p_in[1] & 0x0F)
+               p_info->IndexLevelIndicator =   (enum tel_sim_cphs_index_level) (p_in[1] & 0x0F);
+
+       if (p_in[1] & 0x10)
+               p_info->PremiumServiceIndicator = TRUE;
+
+       if (p_in[1] & 0x20)
+               p_info->PremiumServiceIndicator = TRUE;
+
+       _get_string(p_info->Alpha_id, &p_in[2], p_info->AlphaIdLength);
+
+       p_info->DiallingnumLength = p_in[2 + p_info->AlphaIdLength] * 2;
+       p_info->TypeOfNumber = (p_in[3 + p_info->AlphaIdLength] >> 4) & 0x07;
+       p_info->NumberingPlanIdentity = p_in[3 + p_info->AlphaIdLength] & 0x0F;
+
+       // get dialing number/SSC string
+       _bcd_to_digit((char*) p_info->DiallingnumLength, (char*) &p_in[4 + p_info->AlphaIdLength],      p_info->DiallingnumLength / 2); // actual dialing number length in BCD.
+       // get Extension1 id
+       p_info->Ext1RecordId = p_in[4 + p_info->AlphaIdLength + p_info->DiallingnumLength / 2];
+
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_opl(struct tel_sim_opl *p_opl, unsigned char *p_in, int in_length)
+{
+       unsigned char packetInDigit[3 * 2 + 1];
+
+       if (_is_empty(p_in, in_length) == TRUE) {
+               memset(p_opl, 0x00, sizeof(struct tel_sim_opl));
+               return TRUE;    // this is empty record
+       }
+       _bcd_to_digit((char*) packetInDigit, (char*) &p_in[0], 3);
+       dbg( "AFTER _bcd_to_digit 4th[0x%x]", packetInDigit[3]);
+
+       // get MCC
+       memcpy(&p_opl->plmn, &(packetInDigit[0]), 3);
+       // get MNC
+       if (packetInDigit[3] == 0x00){
+               memcpy(&(p_opl->plmn[3]), &(packetInDigit[3 + 1]), 2);
+               p_opl->plmn[5] = '\0';
+       } else{
+               memcpy(&(p_opl->plmn[3]), &(packetInDigit[3]), 3);
+               p_opl->plmn[6] = '\0';
+       }
+
+       dbg( " PLMN Code[%s]", p_opl->plmn);
+       p_opl->lac_from = (*(p_in+3) << 8) | (*(p_in+4) & 0x00ff);
+       dbg( " Start value of the LAC range[%x]",       p_opl->lac_from);
+       p_opl->lac_to = (*(p_in+5) << 8) | (*(p_in+6) & 0x00ff);
+       dbg( " End value of the LAC range[%x]", p_opl->lac_to);
+       p_opl->rec_identifier = p_in[7];
+       dbg( " PNN Record identifier[%x]", p_opl->rec_identifier);
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_pnn(struct tel_sim_pnn *p_pnn, unsigned char* p_in, int in_length)
+{
+       int f_name_length = 0, s_name_length = 0;
+       int i, cvt_leng = 0;
+
+       if (_is_empty(p_in, in_length) == TRUE) {
+               memset(p_pnn, 0x00, sizeof(struct tel_sim_pnn));
+               return TRUE;    // this is empty record
+       }
+
+       /*Full name for network IEI(Information Element Identifier),0x43*/
+       if (p_in[0] == 0x43) {
+               dbg( " Full name of network IEI exist");
+               /*Assigning the variable 'f_name_length' with the Full name network length*/
+               f_name_length = p_in[1];
+
+               /* current telephony supports 40 bytes network name string */
+               if (f_name_length > SIM_NW_FULL_NAME_LEN_MAX)
+                       f_name_length = SIM_NW_FULL_NAME_LEN_MAX;
+
+               /* 3rd byte information element(according to TS 24.008 for Network Name)
+                8 :ext1
+                7 6 5 : coding scheme
+                4 : Add CI
+                3 2 1 : number of spare bits in last octet
+
+                Coding Scheme (octet 3, bits 5-7)
+                0      0       0               Cell Broadcast data coding scheme, GSM default alphabet, language unspecified, defined in 3GPP TS 23.038 [8b]
+                0      0       1               UCS2 (16 bit) [72]
+                0      1       0               to      reserved
+                1      1       1               to      reserved
+                */
+               if ((p_in[2] & 0x01110000) >> 4 == 0) {
+                       dbg( "DCS:GSM7");
+                       //f_name_length includes information byte.
+                       _unpack_7bit28bit(p_in + 3, f_name_length - 1,
+                                       (unsigned char *) (p_pnn->full_name));
+               }
+               else if ((p_in[2] & 0x01110000) >> 4 == 1) {
+                       dbg( "DCS:UCS2");
+                       _ucs2_to_utf8(f_name_length, p_in + 3, (int*) &cvt_leng,
+                                       (unsigned char *) (p_pnn->full_name));
+               }
+               else {
+                       dbg( "DCS:unknown");
+                       return FALSE;
+               }
+               dbg( " Full name of network contents[%s]", p_pnn->full_name);
+
+               /*Short Name for network IEI(Information Element Identifier), 0x45*/
+               if (p_in[f_name_length + 2] == 0x45) {
+                       dbg( " Short name of network IEI exist");
+                       /*Assigning the variable 's_name_length' with the short name network length*/
+                       s_name_length = p_in[f_name_length + 3];
+
+                       if (s_name_length > SIM_NW_FULL_NAME_LEN_MAX)
+                               s_name_length = SIM_NW_FULL_NAME_LEN_MAX;
+
+                       for (i = 0; i < s_name_length; i++)
+                               p_pnn->short_name[i] =  p_in[f_name_length + 4 + i];
+
+                       dbg( " Short name of network contents[%s]", p_pnn->short_name);
+               }
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
+gboolean tcore_sim_decode_oplmnwact(struct tel_sim_oplmnwact_list *p_list, unsigned char *p_in, int in_length)
+{
+       unsigned long m = 0;
+//unsigned long k, j, m = 0;
+//     unsigned char mask = 0x00;
+
+       //current raw data can include invalid OPLMN data(ex: ff ff ff 00 00). so we can`t decide the number of OPLMN records directly.
+       int rawOplmnWactCount = 0;
+       int i = 0;
+
+       memset((void*) p_list, 0, sizeof(struct tel_sim_oplmnwact_list));
+
+       rawOplmnWactCount = in_length / 5;
+
+       dbg( "rawOplmnWactCount[%d]", rawOplmnWactCount);
+
+       for (i = 0; i < rawOplmnWactCount; i++) {
+               unsigned char packetInDigit[3 * 2 + 1];
+
+               //Regarding current IPC data, even if there`s no OPLMN value, IPC data is sending with 'ff ff ff 00 00'. so we should check for validation.
+               if (p_in[m] == 0xff) {
+                       p_list->opwa_count = m / 5;
+                       dbg("OPLMN(MCC+MNC) value is not found at p_in[m]=[%lu].So OPLMN count is [%d]", m, p_list->opwa_count);
+                       return TRUE;
+               }
+
+               _bcd_to_digit((char*) packetInDigit, (char*) &p_in[m], 3);
+               dbg( "AFTER _bcd_to_digit 4th[0x%x]", packetInDigit[3]);
+
+               // get MCC
+               memcpy(&p_list->opwa[i].plmn, &(packetInDigit[0]), 3);
+               // get MNC
+               if (packetInDigit[3] == 0x00){
+                       memcpy(&(p_list->opwa[i].plmn[3]), &(packetInDigit[3 + 1]), 2);
+                       p_list->opwa[i].plmn[5] = '\0';
+               } else{
+                       memcpy(&(p_list->opwa[i].plmn[3]), &(packetInDigit[3]), 3);
+                       p_list->opwa[i].plmn[6] = '\0';
+               }
+               dbg( "[%d] OPLMN PLMN Code[%s]", i, p_list->opwa[i].plmn);
+
+               if(p_in[m+3] & 0x80)
+                       p_list->opwa[i].b_umts = 1;
+
+               if(p_in[m+4] & 0x80)
+                       p_list->opwa[i].b_gsm = 1;
+
+               m = m + 5;
+       }
+
+       p_list->opwa_count = rawOplmnWactCount;
+       dbg( "OPLMN count is p_list->opwa_count[%d]", p_list->opwa_count);
+
+       return TRUE;
+}
+
+enum tel_sim_status tcore_sim_get_status(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return -1;
+       }
+       return po->sim_status;
+}
+
+gboolean tcore_sim_set_status(CoreObject *o, enum tel_sim_status status)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return FALSE;
+       }
+       po->sim_status = status;
+
+       return TRUE;
+}
+
+gboolean tcore_sim_get_identification(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return -1;
+       }
+       return po->b_sim_changed;
+}
+
+gboolean tcore_sim_set_identification(CoreObject *o, gboolean b_changed)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return FALSE;
+       }
+       po->b_sim_changed = b_changed;
+
+       return TRUE;
+}
+
+enum tel_sim_type tcore_sim_get_type(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return -1;
+       }
+       return po->type;
+}
+
+gboolean tcore_sim_set_type(CoreObject *o, enum tel_sim_type type)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return FALSE;
+       }
+       po->type = type;
+       return TRUE;
+}
+
+struct tel_sim_imsi* tcore_sim_get_imsi(CoreObject *o)
+{
+       struct tel_sim_imsi *tmp_imsi;
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return NULL;
+       }
+       tmp_imsi =  calloc(sizeof(struct tel_sim_imsi), 1);
+       memcpy(tmp_imsi, &po->imsi, sizeof(struct tel_sim_imsi));
+       return tmp_imsi;
+}
+
+gboolean tcore_sim_set_imsi(CoreObject *o, struct tel_sim_imsi *imsi)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return FALSE;
+       }
+       memcpy(&po->imsi, imsi, sizeof(struct tel_sim_imsi));
+       return TRUE;
+}
+
+gboolean tcore_sim_get_cphs_status(CoreObject *o){
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return FALSE;
+       }
+       return po->b_cphs;
+}
+
+gboolean tcore_sim_set_cphs_status(CoreObject *o, gboolean b_support){
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return FALSE;
+       }
+       po->b_cphs = b_support;
+       return TRUE;
+}
+
+gboolean tcore_sim_link_userdata(CoreObject *o, void *userdata)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return FALSE;
+       }
+       po->userdata = userdata;
+       return TRUE;
+}
+
+void* tcore_sim_ref_userdata(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po || !po->userdata) {
+               dbg("po access fail");
+               return NULL;
+       }
+       return po->userdata;
+}
+
+static void tcore_sim_initialize_context(CoreObject *o)
+{
+       struct tcore_sim_operations *tmp_ops = NULL;
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return;
+       }
+
+       tmp_ops = po->ops;
+
+/*     if(!po->p_cache)
+               free(po->p_cache);*/
+
+       memset(po, 0x00, sizeof(struct private_object_data));
+
+       po->ops = tmp_ops;
+
+       po->sim_status = SIM_STATUS_UNKNOWN;
+       po->language_file = SIM_EF_INVALID;
+       po->cf_file = SIM_EF_INVALID;
+       po->mw_file = SIM_EF_INVALID;
+       po->mb_file = SIM_EF_INVALID;
+}
+
+CoreObject *tcore_sim_new(TcorePlugin *p, const char *name, struct tcore_sim_operations *ops)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name);
+       if (!o)
+               return NULL;
+
+       po = calloc(sizeof(struct private_object_data), 1);
+       if (!po) {
+               tcore_object_free(o);
+               return NULL;
+       }
+
+       po->ops = ops;
+
+       tcore_object_set_type(o, CORE_OBJECT_TYPE_SIM);
+       tcore_object_link_object(o, po);
+       tcore_object_set_free_hook(o, _free_hook);
+       tcore_object_set_dispatcher(o, _dispatcher);
+
+       tcore_sim_initialize_context(o);
+
+       return o;
+}
+
+void tcore_sim_free(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SIM);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       free(po);
+       tcore_object_free(o);
+}
diff --git a/src/co_sms.c b/src/co_sms.c
new file mode 100644 (file)
index 0000000..cce7b53
--- /dev/null
@@ -0,0 +1,403 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "plugin.h"
+#include "user_request.h"
+#include "co_sms.h"
+
+struct private_object_data {
+       struct tcore_sms_operations *ops;
+};
+
+//static int           _tcore_util_sms_encode_smsParameters(const telephony_sms_Params_t *incoming, unsigned char *data, int SMSPRecordLen);
+
+static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
+{
+       TcorePlugin *p = NULL;
+       struct property_sms_info *property = NULL;
+       enum tcore_request_command command;
+       struct private_object_data *po = NULL;
+       TReturn rtn = TCORE_RETURN_SUCCESS;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_SMS, TCORE_RETURN_EINVAL);
+
+       p = tcore_object_ref_plugin(o);
+       property = tcore_plugin_ref_property(p, "SMS");
+       if (property->bDevice_Ready == FALSE) {
+               dbg("[tcore_SMS] DEVICE_NOT_READY");
+               return TCORE_RETURN_ENOSYS; /* TAPI_API_NETTEXT_DEVICE_NOT_READY */
+       }
+
+       po = tcore_object_ref_object(o);
+       if (!po || !po->ops) {
+               dbg("[tcore_SMS] ERR: private_object is NULL or ops is NULL");
+               return TCORE_RETURN_ENOSYS;
+       }
+
+       command = tcore_user_request_get_command(ur);
+       switch (command) {
+               case TREQ_SMS_SEND_UMTS_MSG:
+                       if (!po->ops->send_umts_msg)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->send_umts_msg is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->send_umts_msg(o, ur);
+
+                       break;
+               case TREQ_SMS_READ_MSG:
+                       if (!po->ops->read_msg)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->read_msg is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->read_msg(o, ur);
+
+                       break;
+               case TREQ_SMS_SAVE_MSG:
+                       if (!po->ops->save_msg)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->save_msg is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->save_msg(o, ur);
+
+                       break;
+               case TREQ_SMS_DELETE_MSG:
+                       if (!po->ops->delete_msg)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->delete_msg is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->delete_msg(o, ur);
+
+                       break;
+               case TREQ_SMS_GET_COUNT:
+                       if (!po->ops->get_storedMsgCnt)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->get_storedMsgCnt is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->get_storedMsgCnt(o, ur);
+
+                       break;
+               case TREQ_SMS_GET_SCA:
+                       if (!po->ops->get_sca)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->get_sca is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->get_sca(o, ur);
+
+                       break;
+               case TREQ_SMS_SET_SCA:
+                       if (!po->ops->set_sca)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->set_sca is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->set_sca(o, ur);
+
+                       break;
+               case TREQ_SMS_GET_CB_CONFIG:
+                       if (!po->ops->get_cb_config)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->get_cb_config is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->get_cb_config(o, ur);
+
+                       break;
+               case TREQ_SMS_SET_CB_CONFIG:
+                       if (!po->ops->set_cb_config)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->set_cb_config is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->set_cb_config(o, ur);
+
+                       break;
+               case TREQ_SMS_SET_MEM_STATUS:
+                       if (!po->ops->set_mem_status)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->set_mem_status is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->set_mem_status(o, ur);
+
+                       break;
+               case TREQ_SMS_GET_PREF_BEARER:
+                       if (!po->ops->get_pref_brearer)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->get_pref_brearer is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->get_pref_brearer(o, ur);
+
+                       break;
+               case TREQ_SMS_SET_PREF_BEARER:
+                       if (!po->ops->set_pref_brearer)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->get_pref_brearer is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->set_pref_brearer(o, ur);
+
+                       break;
+               case TREQ_SMS_SET_DELIVERY_REPORT:
+                       if (!po->ops->set_delivery_report)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->set_delivery_report is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->set_delivery_report(o, ur);
+
+                       break;
+               case TREQ_SMS_SET_MSG_STATUS:
+                       if (!po->ops->set_msg_status)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->set_msg_status is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->set_msg_status(o, ur);
+
+                       break;
+               case TREQ_SMS_GET_PARAMS:
+                       if (!po->ops->get_sms_params)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->get_sms_params is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->get_sms_params(o, ur);
+
+                       break;
+               case TREQ_SMS_SET_PARAMS:
+                       if (!po->ops->set_sms_params)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->set_sms_params is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->set_sms_params(o, ur);
+
+                       break;
+               case TREQ_SMS_GET_PARAMCNT:
+                       if (!po->ops->get_paramcnt)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->get_paramcnt is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->get_paramcnt(o, ur);
+
+                       break;
+               case TREQ_SMS_SEND_CDMA_MSG:
+                       if (!po->ops->send_cdma_msg)
+                       {
+                               dbg("[tcore_SMS] ERR: po->ops->send_cdma_msg is NULL");
+                               return TCORE_RETURN_ENOSYS;
+                       }
+
+                       rtn = po->ops->send_cdma_msg(o, ur);
+
+                       break;
+               default:
+                       break;
+       }
+
+       dbg("[tcore_SMS] result = [0x%x], command = [0x%x]", rtn, command);
+
+       return rtn;
+}
+
+
+static void _free_hook(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SMS);
+
+       po = tcore_object_ref_object(o);
+       if (po) {
+               free(po);
+               tcore_object_link_object(o, NULL);
+       }
+}
+
+CoreObject *tcore_sms_new(TcorePlugin *p, const char *name, struct tcore_sms_operations *ops)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name);
+       if (!o)
+               return NULL;
+
+       po = calloc(sizeof(struct private_object_data), 1);
+       if (!po) {
+               tcore_object_free(o);
+               return NULL;
+       }
+
+       po->ops = ops;
+
+       tcore_object_set_type(o, CORE_OBJECT_TYPE_SMS);
+       tcore_object_link_object(o, po);
+       tcore_object_set_free_hook(o, _free_hook);
+       tcore_object_set_dispatcher(o, _dispatcher);
+
+       return o;
+}
+
+void tcore_sms_free(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SMS);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       free(po);
+       tcore_object_free(o);
+}
+
+/**
+ * This function is used to encode SMS Parameters to TPDU on EFsmsp
+ *
+ * @return             length of string
+ * @param[in]          incoming - telephony_sms_Params_t
+ * @param[in]          data - TPDU data
+ * @Interface          Synchronous.
+ * @remark
+ * @Refer
+ */
+int _tcore_util_sms_encode_smsParameters(const struct telephony_sms_Params *incoming, unsigned char *data, int SMSPRecordLen)
+{
+       struct telephony_sms_Params *smsParams =  (struct telephony_sms_Params *)incoming;
+       unsigned int nPIDIndex = 0;
+       unsigned char nOffset = 0;
+
+       if(incoming == NULL || data == NULL)
+               return FALSE;
+
+       memset(data, 0xff, SMSPRecordLen);//pSmsParam->RecordLen);
+
+       dbg(" Record index = %d", (int) smsParams->recordIndex);
+       dbg(" Alpha ID Len = %d", (int) smsParams->alphaIdLen);
+       dbg(" Record Length : %d", SMSPRecordLen);//pSmsParam->RecordLen);
+
+       if (SMSPRecordLen/*pSmsParam->RecordLen*/>= nDefaultSMSPWithoutAlphaId) {
+               nPIDIndex = SMSPRecordLen
+                               /*pSmsParam->RecordLen*/- nDefaultSMSPWithoutAlphaId;
+       }
+
+       //dongil01.park(2008/12/27) - Check Point
+       memcpy(data, smsParams->szAlphaId, (int) nPIDIndex/*pSmsParam->AlphaIdLen*/);
+
+       dbg(" Alpha ID : %s", smsParams->szAlphaId);
+       dbg(" nPIDIndex = %d", nPIDIndex);
+
+       data[nPIDIndex] = smsParams->paramIndicator;
+
+       dbg(" Param Indicator = %02x",  smsParams->paramIndicator);
+
+       if ((smsParams->paramIndicator & SMSPValidDestAddr) == 0x00) {
+               nOffset = nDestAddrOffset;
+
+               data[nPIDIndex + (nOffset)] = smsParams->tpDestAddr.dialNumLen + 1;
+               data[nPIDIndex + (++nOffset)] = ((smsParams->tpDestAddr.typeOfNum << 4) | smsParams->tpDestAddr.numPlanId) | 0x80;
+
+               memcpy(&data[nPIDIndex + (++nOffset)], &smsParams->tpDestAddr.diallingNum, smsParams->tpDestAddr.dialNumLen);
+
+               dbg(" nextIndex = %d", nPIDIndex);
+       }
+
+       if( (smsParams->paramIndicator & SMSPValidSvcAddr) == 0x00 )
+       {
+               dbg("TON [%d] / NPI [%d]", smsParams->tpSvcCntrAddr.typeOfNum, smsParams->tpSvcCntrAddr.numPlanId);
+
+               nOffset = nSCAAddrOffset;
+
+               dbg("SCA Length : %d", smsParams->tpSvcCntrAddr.dialNumLen);
+
+               data[nPIDIndex + (nOffset)] = smsParams->tpSvcCntrAddr.dialNumLen + 1;
+               data[nPIDIndex + (++nOffset)] = ((smsParams->tpSvcCntrAddr.typeOfNum << 4) | smsParams->tpSvcCntrAddr.numPlanId) | 0x80;
+
+               memcpy(&data[nPIDIndex + (++nOffset)], &smsParams->tpSvcCntrAddr.diallingNum, smsParams->tpSvcCntrAddr.dialNumLen);
+
+               dbg(" nextIndex = %d", nPIDIndex);
+       }
+
+       if ((smsParams->paramIndicator & SMSPValidPID) == 0x00) {
+               nOffset = nPIDOffset;
+
+               data[nPIDIndex + nOffset] = smsParams->tpProtocolId;
+               dbg(" PID = %02x", smsParams->tpProtocolId);
+               dbg(" nextIndex = %d", nPIDIndex);
+       }
+
+       if ((smsParams->paramIndicator & SMSPValidDCS) == 0x00) {
+               nOffset = nDCSOffset;
+
+               data[nPIDIndex + nOffset] = smsParams->tpDataCodingScheme;
+               dbg(" DCS = %02x", smsParams->tpDataCodingScheme);
+               dbg(" nextIndex = %d", nPIDIndex);
+       }
+
+       if ((smsParams->paramIndicator & SMSPValidVP) == 0x00) {
+               nOffset = nVPOffset;
+
+               data[nPIDIndex + nOffset] = smsParams->tpValidityPeriod;
+               dbg(" VP = %02x", smsParams->tpValidityPeriod);
+               dbg(" nextIndex = %d", nPIDIndex);
+       }
+
+       return TRUE;
+
+}
+
+
diff --git a/src/co_ss.c b/src/co_ss.c
new file mode 100644 (file)
index 0000000..acce35e
--- /dev/null
@@ -0,0 +1,299 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "plugin.h"
+#include "queue.h"
+#include "user_request.h"
+#include "co_ss.h"
+
+#define _check_null( name, value, err ) { \
+       if ( !value ) { \
+               dbg("[error] %s : NULL", name ); \
+               return err; \
+       } \
+}
+
+struct ussd_session {
+       gboolean session;
+       enum tcore_ss_ussd_type type;
+       void* data;
+       int data_len;
+};
+
+struct private_object_data {
+       struct ussd_session ussd_s;
+       struct tcore_ss_operations *ops;
+};
+
+static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
+{
+       enum tcore_request_command command;
+       TReturn ret = 0;
+
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->ops", po->ops, TCORE_RETURN_FAILURE);
+       _check_null( "ur", ur, TCORE_RETURN_FAILURE);
+
+       command = tcore_user_request_get_command(ur);
+       switch (command) {
+               case TREQ_SS_BARRING_ACTIVATE:
+                       ret = po->ops->barring_activate(o, ur);
+                       break;
+
+               case TREQ_SS_BARRING_DEACTIVATE:
+                       ret = po->ops->barring_deactivate(o, ur);
+                       break;
+
+               case TREQ_SS_BARRING_CHANGE_PASSWORD:
+                       ret = po->ops->barring_change_password(o, ur);
+                       break;
+
+               case TREQ_SS_BARRING_GET_STATUS:
+                       ret = po->ops->barring_get_status(o, ur);
+                       break;
+
+               case TREQ_SS_FORWARDING_ACTIVATE:
+                       ret = po->ops->forwarding_activate(o, ur);
+                       break;
+
+               case TREQ_SS_FORWARDING_DEACTIVATE:
+                       ret = po->ops->forwarding_deactivate(o, ur);
+                       break;
+
+               case TREQ_SS_FORWARDING_REGISTER:
+                       ret = po->ops->forwarding_register(o, ur);
+                       break;
+
+               case TREQ_SS_FORWARDING_DEREGISTER:
+                       ret = po->ops->forwarding_deregister(o, ur);
+                       break;
+
+               case TREQ_SS_FORWARDING_GET_STATUS:
+                       ret = po->ops->forwarding_get_status(o, ur);
+                       break;
+
+               case TREQ_SS_WAITING_ACTIVATE:
+                       ret = po->ops->waiting_activate(o, ur);
+                       break;
+
+               case TREQ_SS_WAITING_DEACTIVATE:
+                       ret = po->ops->waiting_deactivate(o, ur);
+                       break;
+
+               case TREQ_SS_WAITING_GET_STATUS:
+                       ret = po->ops->waiting_get_status(o, ur);
+                       break;
+
+               case TREQ_SS_CLI_ACTIVATE:
+                       ret = po->ops->cli_activate(o, ur);
+                       break;
+
+               case TREQ_SS_CLI_DEACTIVATE:
+                       ret = po->ops->cli_deactivate(o, ur);
+                       break;
+
+               case TREQ_SS_CLI_GET_STATUS:
+                       ret = po->ops->cli_get_status(o, ur);
+                       break;
+
+               case TREQ_SS_SEND_USSD:
+                       ret = po->ops->send_ussd(o, ur);
+                       break;
+
+               case TREQ_SS_SET_AOC:
+                       ret = po->ops->set_aoc(o, ur);
+                       break;
+
+               case TREQ_SS_GET_AOC:
+                       ret = po->ops->get_aoc(o, ur);
+                       break;
+
+               default:
+                       break;
+       }
+
+       return ret;
+}
+
+static void _free_hook(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       free(po);
+       tcore_object_link_object(o, NULL);
+}
+
+static void _ussd_session_init(struct ussd_session *ussd_s)
+{
+       ussd_s->session = FALSE;
+       ussd_s->type = 0;
+       ussd_s->data = 0;
+       ussd_s->data_len = 0;
+}
+
+struct ussd_session* tcore_ss_ussd_create_session(CoreObject *o,
+               enum tcore_ss_ussd_type type, void *data, int data_len)
+{
+       struct private_object_data *po = NULL;
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return 0;
+
+       if (type < TCORE_SS_USSD_TYPE_USER_INITIATED
+                       || type > TCORE_SS_USSD_TYPE_NETWORK_INITIATED) {
+               dbg("[ error ] wrong ussd type : (0x%x)", type);
+               return 0;
+       }
+
+       if (!po->ussd_s.session) {
+               po->ussd_s.session = TRUE;
+               po->ussd_s.type = type;
+               po->ussd_s.data = data;
+
+               if (data_len < 0)
+                       po->ussd_s.data_len = 0;
+               else
+                       po->ussd_s.data_len = data_len;
+
+               return &po->ussd_s;
+
+       }
+       else {
+               dbg("[ error ] already exist ussd session, type : (0x%x)", po->ussd_s.type);
+               return 0;
+       }
+}
+
+void tcore_ss_ussd_destroy_session(struct ussd_session *ussd_s)
+{
+       if (!ussd_s || !ussd_s->session) {
+               return;
+       }
+       else {
+
+               _ussd_session_init(ussd_s);
+       }
+}
+
+struct ussd_session* tcore_ss_ussd_get_session(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return 0;
+
+       if (!po->ussd_s.session)
+               return 0;
+       else
+               return &po->ussd_s;
+}
+
+enum tcore_ss_ussd_type tcore_ss_ussd_get_session_type(struct ussd_session *ussd_s)
+{
+       if (!ussd_s || !ussd_s->session) {
+               dbg("[ error ] there is no session");
+               return 0;
+
+       }
+       else {
+               return ussd_s->type;
+       }
+}
+
+void tcore_ss_ussd_set_session_type(struct ussd_session *ussd_s,
+               enum tcore_ss_ussd_type type)
+{
+       if (!ussd_s || !ussd_s->session) {
+               dbg("[ error ] there is no session");
+               return;
+
+       }
+       else {
+               ussd_s->type = type;
+       }
+}
+
+int tcore_ss_ussd_get_session_data(struct ussd_session* ussd_s, void **data)
+{
+       if (!ussd_s || !ussd_s->session) {
+               dbg("[ error ] there is no session");
+               return -1;
+
+       }
+       else {
+
+               *data = ussd_s->data;
+               return ussd_s->data_len;
+       }
+}
+
+CoreObject *tcore_ss_new(TcorePlugin *p, const char *name,
+               struct tcore_ss_operations *ops)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name);
+       if (!o)
+               return NULL;
+
+       po = calloc(sizeof(struct private_object_data), 1);
+       if (!po) {
+               tcore_object_free(o);
+               return NULL;
+       }
+
+       po->ops = ops;
+
+       _ussd_session_init(&po->ussd_s);
+
+       tcore_object_set_type(o, CORE_OBJECT_TYPE_SS);
+       tcore_object_link_object(o, po);
+       tcore_object_set_free_hook(o, _free_hook);
+       tcore_object_set_dispatcher(o, _dispatcher);
+
+       return o;
+}
+
+void tcore_ss_free(CoreObject *o)
+{
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SS);
+
+       tcore_object_free(o);
+}
diff --git a/src/communicator.c b/src/communicator.c
new file mode 100644 (file)
index 0000000..fe72f62
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "plugin.h"
+#include "server.h"
+#include "communicator.h"
+
+struct tcore_communicator_type {
+       const char *name;
+       struct tcore_communitor_operations *ops;
+
+       void *user_data;
+
+       TcorePlugin *parent_plugin;
+};
+
+
+Communicator* tcore_communicator_new(TcorePlugin *plugin, const char *name,
+               struct tcore_communitor_operations *ops)
+{
+       Communicator *comm;
+
+       comm = calloc(sizeof(struct tcore_communicator_type), 1);
+       if (!comm)
+               return NULL;
+
+       if (name)
+               comm->name = strdup(name);
+
+       comm->parent_plugin = plugin;
+       comm->ops = ops;
+
+       tcore_server_add_communicator(tcore_plugin_ref_server(plugin), comm);
+
+       return comm;
+}
+
+void tcore_communicator_free(Communicator *comm)
+{
+       if (!comm)
+               return;
+
+       if (comm->name)
+               free((void *)comm->name);
+
+       free(comm);
+}
+
+TcorePlugin *tcore_communicator_ref_plugin(Communicator *comm)
+{
+       if (!comm)
+               return NULL;
+
+       return comm->parent_plugin;
+}
+
+const char *tcore_communicator_ref_name(Communicator *comm)
+{
+       if (!comm)
+               return NULL;
+
+       return comm->name;
+}
+
+TReturn tcore_communicator_link_user_data(Communicator *comm, void *data)
+{
+       if (!comm)
+               return TCORE_RETURN_EINVAL;
+
+       comm->user_data = data;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+void *tcore_communicator_ref_user_data(Communicator *comm)
+{
+       if (!comm)
+               return NULL;
+
+       return comm->user_data;
+}
+
+TReturn tcore_communicator_dispatch_request(Communicator *comm, UserRequest *ur)
+{
+       Server *s;
+
+       if (!comm || !ur)
+               return TCORE_RETURN_EINVAL;
+
+       s = tcore_plugin_ref_server(comm->parent_plugin);
+
+       return tcore_server_dispatch_request(s, ur);
+}
+
+TReturn tcore_communicator_send_response(Communicator *comm, UserRequest *ur,
+               enum tcore_response_command command,
+               unsigned int data_len, const void *data)
+{
+       if (!comm || !comm->ops || !comm->ops->send_response)
+               return TCORE_RETURN_EINVAL;
+
+       dbg("ur = 0x%x", ur);
+
+       return comm->ops->send_response(comm, ur, command, data_len, data);
+}
+
+TReturn tcore_communicator_send_notification(Communicator *comm,
+               CoreObject *source, enum tcore_notification_command command,
+               unsigned int data_len, const void *data)
+{
+       if (!comm || !comm->ops || !comm->ops->send_notification)
+               return TCORE_RETURN_EINVAL;
+
+       return comm->ops->send_notification(comm, source, command, data_len, data);
+}
diff --git a/src/core_object.c b/src/core_object.c
new file mode 100644 (file)
index 0000000..1ac41f4
--- /dev/null
@@ -0,0 +1,310 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "plugin.h"
+#include "core_object.h"
+
+struct callback_type {
+       char *event;
+       CoreObjectCallback callback;
+       void *user_data;
+};
+
+struct tcore_object_type {
+       unsigned int type;
+       char *name;
+
+       TcorePlugin *parent_plugin;
+
+       void *object;
+       void *user_data;
+
+       CoreObjectFreeHook free_hook;
+       CoreObjectDispatcher dispatcher;
+       GSList *callbacks;
+};
+
+CoreObject *tcore_object_new(TcorePlugin *plugin, const char *name)
+{
+       CoreObject *co;
+
+       if (!plugin)
+               return NULL;
+
+       co = calloc(sizeof(struct tcore_object_type), 1);
+       if (!co)
+               return NULL;
+
+       co->parent_plugin = plugin;
+       co->name = strdup(name);
+       co->type = CORE_OBJECT_TYPE_DEFAULT;
+       co->object = NULL;
+       co->user_data = NULL;
+       co->free_hook = NULL;
+       co->callbacks = NULL;
+
+       tcore_plugin_add_core_object(plugin, co);
+
+       return co;
+}
+
+void tcore_object_free(CoreObject *co)
+{
+       GSList *l = NULL;
+       struct callback_type *cb = NULL;
+
+       if (!co)
+               return;
+
+       dbg("co_name=%s", co->name);
+
+       if (co->free_hook)
+               co->free_hook(co);
+
+       if (co->callbacks) {
+               for (l = co->callbacks; l; l = l->next) {
+                       if (!l)
+                               continue;
+
+                       cb = l->data;
+                       if (!cb)
+                               continue;
+
+                       if (cb->event)
+                               g_free(cb->event);
+
+                       g_free(cb);
+               }
+
+               g_slist_free(co->callbacks);
+               co->callbacks = NULL;
+       }
+
+       if (co->name)
+               g_free(co->name);
+
+       g_free(co);
+}
+
+const char *tcore_object_ref_name(CoreObject *co)
+{
+       if (!co)
+               return NULL;
+
+       return co->name;
+}
+
+TReturn tcore_object_set_free_hook(CoreObject *co, CoreObjectFreeHook free_hook)
+{
+       if (!co)
+               return TCORE_RETURN_EINVAL;
+
+       co->free_hook = free_hook;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_object_set_name(CoreObject *co, const char *name)
+{
+       if (!co)
+               return TCORE_RETURN_EINVAL;
+
+       if (co->name) {
+               free(co->name);
+               co->name = NULL;
+       }
+
+       if (name)
+               co->name = strdup(name);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TcorePlugin *tcore_object_ref_plugin(CoreObject *co)
+{
+       if (!co)
+               return NULL;
+
+       return co->parent_plugin;
+}
+
+TReturn tcore_object_link_object(CoreObject *co, void *object)
+{
+       if (!co)
+               return TCORE_RETURN_EINVAL;
+
+       co->object = object;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+void *tcore_object_ref_object(CoreObject *co)
+{
+       if (!co)
+               return NULL;
+
+       return co->object;
+}
+
+TReturn tcore_object_set_type(CoreObject *co, unsigned int type)
+{
+       if (!co)
+               return TCORE_RETURN_EINVAL;
+
+       co->type = type;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+unsigned int tcore_object_get_type(CoreObject *co)
+{
+       if (!co)
+               return 0;
+
+       return co->type;
+}
+
+TReturn tcore_object_link_user_data(CoreObject *co, void *user_data)
+{
+       if (!co)
+               return TCORE_RETURN_EINVAL;
+
+       co->user_data = user_data;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+void *tcore_object_ref_user_data(CoreObject *co)
+{
+       if (!co)
+               return NULL;
+
+       return co->user_data;
+}
+
+TReturn tcore_object_dispatch_request(CoreObject *co, UserRequest *ur)
+{
+       if (!co || !ur)
+               return TCORE_RETURN_EINVAL;
+
+       if (!co->dispatcher)
+               return TCORE_RETURN_ENOSYS;
+
+       return co->dispatcher(co, ur);
+}
+
+TReturn tcore_object_set_dispatcher(CoreObject *co, CoreObjectDispatcher func)
+{
+       if (!co || !func)
+               return TCORE_RETURN_EINVAL;
+
+       co->dispatcher = func;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_object_add_callback(CoreObject *co, const char *event, CoreObjectCallback callback, void *user_data)
+{
+       struct callback_type *cb = NULL;
+
+       if (!co || !event || !callback)
+               return TCORE_RETURN_EINVAL;
+
+       if (strlen(event) < 1)
+               return TCORE_RETURN_EINVAL;
+
+       cb = calloc(sizeof(struct callback_type), 1);
+       if (!cb)
+               return TCORE_RETURN_ENOMEM;
+
+       cb->event = strdup(event);
+       cb->callback = callback;
+       cb->user_data = user_data;
+
+       co->callbacks = g_slist_append(co->callbacks, cb);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_object_del_callback(CoreObject *co, const char *event, CoreObjectCallback callback)
+{
+       struct callback_type *cb = NULL;
+       GSList *l = NULL;
+
+       if (!co || !event || !callback || !co->callbacks)
+               return TCORE_RETURN_EINVAL;
+
+       if (strlen(event) < 1)
+               return TCORE_RETURN_EINVAL;
+
+       for (l = co->callbacks; l; l = l->next) {
+               if (!l)
+                       continue;
+
+               cb = l->data;
+               if (!cb)
+                       continue;
+
+               if (cb->callback != callback)
+                       continue;
+
+               if (g_strcmp0(cb->event, event) != 0)
+                       continue;
+
+               free(cb->event);
+               co->callbacks = g_slist_remove(co->callbacks, cb);
+               free(cb);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_object_emit_callback(CoreObject *co, const char *event, const void *event_info)
+{
+       struct callback_type *cb = NULL;
+       GSList *l = NULL;
+
+       if (!co || !event)
+               return TCORE_RETURN_EINVAL;
+
+       for (l = co->callbacks; l; l = l->next) {
+               if (!l)
+                       continue;
+
+               cb = l->data;
+               if (!cb)
+                       continue;
+
+               if (g_strcmp0(cb->event, event) != 0)
+                       continue;
+
+               if (cb->callback)
+                       cb->callback(co, event_info, cb->user_data);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
diff --git a/src/hal.c b/src/hal.c
new file mode 100644 (file)
index 0000000..1579cdf
--- /dev/null
+++ b/src/hal.c
@@ -0,0 +1,440 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 <pthread.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include <glib.h>
+
+#include "tcore.h"
+#include "hal.h"
+#include "queue.h"
+#include "plugin.h"
+#include "user_request.h"
+
+//#define IDLE_SEND_PRIORITY G_PRIORITY_DEFAULT
+#define IDLE_SEND_PRIORITY G_PRIORITY_HIGH
+
+struct hook_send_type {
+       TcoreHalSendHook func;
+       void *user_data;
+};
+
+struct recv_callback_item_type {
+       TcoreHalReceiveCallback func;
+       void *user_data;
+};
+
+struct tcore_hal_type {
+       TcorePlugin *parent_plugin;
+       TcoreQueue *queue;
+       char *name;
+       struct tcore_hal_operations *ops;
+       void *user_data;
+       GSList *callbacks;
+       gboolean power_state;
+       GSList *hook_list_send;
+};
+
+static gboolean _hal_idle_send(void *user_data)
+{
+       TcoreHal *h = user_data;
+       TcorePending *p = NULL;
+       TcoreQueue *q;
+       int ret = 0;
+       void *data = NULL;
+       unsigned int data_len = 0;
+       gboolean renew = FALSE;
+
+       if (!h)
+               return FALSE;
+
+       msg("--[Queue SEND]-------------------");
+
+       p = tcore_queue_ref_next_pending(h->queue);
+       if (!p) {
+               dbg("next pending is NULL. no send, queue len=%d", tcore_queue_get_length(h->queue));
+               goto out;
+       }
+
+       data = tcore_pending_ref_request_data(p, &data_len);
+       dbg("queue len=%d, pending=0x%x, id=0x%x, data_len=%d",
+                       tcore_queue_get_length(h->queue), p, tcore_pending_get_id(p), data_len);
+
+       ret = tcore_hal_send_data(h, data_len, data);
+       if (ret != TCORE_RETURN_HOOK_STOP) {
+               tcore_pending_emit_send_callback(p, ret);
+
+               if (tcore_pending_get_auto_free_status_after_sent(p)) {
+                       q = tcore_hal_ref_queue(h);
+                       p = tcore_queue_pop(q);
+                       tcore_pending_free(p);
+
+                       /* renew idler */
+                       renew = TRUE;
+               }
+               else {
+                       /* Send fail */
+                       if (ret != TCORE_RETURN_SUCCESS) {
+                               dbg("send fail.");
+                               q = tcore_hal_ref_queue(h);
+                               p = tcore_queue_pop(q);
+                               tcore_pending_free(p);
+                       }
+               }
+       }
+
+out:
+       msg("--[Queue SEND FINISH]------------\n");
+       return renew;
+}
+
+TcoreHal *tcore_hal_new(TcorePlugin *plugin, const char *name,
+               struct tcore_hal_operations *hops)
+{
+       TcoreHal *h;
+
+       if (!plugin || !name)
+               return NULL;
+
+       h = calloc(sizeof(struct tcore_hal_type), 1);
+       if (!h)
+               return NULL;
+
+       h->parent_plugin = plugin;
+       h->ops = hops;
+       h->name = strdup(name);
+       h->queue = tcore_queue_new(plugin);
+
+       tcore_plugin_set_hal(plugin, h);
+
+       return h;
+}
+
+void tcore_hal_free(TcoreHal *hal)
+{
+       if (!hal)
+               return;
+
+       dbg("hal=%s", hal->name);
+
+       if (hal->name)
+               free(hal->name);
+
+       if (hal->callbacks)
+               g_slist_free(hal->callbacks);
+
+       if (hal->queue)
+               tcore_queue_free(hal->queue);
+
+       free(hal);
+}
+
+TReturn tcore_hal_set_name(TcoreHal *hal, const char *name)
+{
+       if (!hal)
+               return TCORE_RETURN_EINVAL;
+
+       if (hal->name) {
+               free(hal->name);
+               hal->name = NULL;
+       }
+
+       if (name)
+               hal->name = strdup(name);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+char *tcore_hal_get_name(TcoreHal *hal)
+{
+       if (!hal)
+               return NULL;
+
+       if (hal->name)
+               return strdup(hal->name);
+
+       return NULL;
+}
+
+TReturn tcore_hal_link_user_data(TcoreHal *hal, void *user_data)
+{
+       if (!hal)
+               return TCORE_RETURN_EINVAL;
+
+       hal->user_data = user_data;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+void *tcore_hal_ref_user_data(TcoreHal *hal)
+{
+       if (!hal)
+               return NULL;
+
+       return hal->user_data;
+}
+
+/* Send data without Queue */
+TReturn tcore_hal_send_data(TcoreHal *hal, unsigned int data_len, void *data)
+{
+       struct hook_send_type *hook;
+       GSList *list;
+
+       if (!hal || !hal->ops || !hal->ops->send)
+               return TCORE_RETURN_EINVAL;
+
+       for (list = hal->hook_list_send; list; list = list->next) {
+               hook = list->data;
+               if (!hook) {
+                       continue;
+               }
+
+               if (hook->func(hal, data_len, data, hook->user_data) == TCORE_HOOK_RETURN_STOP_PROPAGATION) {
+                       return TCORE_RETURN_HOOK_STOP;
+               }
+       }
+
+       return hal->ops->send(hal, data_len, data);
+}
+
+/* Send data by Queue */
+TReturn tcore_hal_send_request(TcoreHal *hal, TcorePending *plugin)
+{
+       int qlen = 0;
+       enum tcore_pending_priority priority;
+
+       if (!hal || !plugin)
+               return TCORE_RETURN_EINVAL;
+
+       qlen = tcore_queue_get_length(hal->queue);
+       tcore_queue_push(hal->queue, plugin);
+
+       tcore_pending_get_priority(plugin, &priority);
+       if (priority == TCORE_PENDING_PRIORITY_IMMEDIATELY) {
+               dbg("IMMEDIATELY pending !!");
+               _hal_idle_send(hal);
+       }
+       else {
+               if (tcore_queue_get_length(hal->queue) == 1) {
+                       g_idle_add_full(IDLE_SEND_PRIORITY, _hal_idle_send, hal, NULL);
+               }
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_hal_dispatch_notification_data(TcoreHal *hal, const char *event,
+               const void *data)
+{
+       TcorePlugin *p = NULL;
+
+       if (!hal || !event)
+               return TCORE_RETURN_EINVAL;
+
+       p = tcore_hal_ref_plugin(hal);
+       if (!p)
+               return TCORE_RETURN_SERVER_WRONG_PLUGIN;
+
+       tcore_plugin_core_object_event_emit(p, event, data);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_hal_dispatch_response_data(TcoreHal *hal, int id,
+               unsigned int data_len, const void *data)
+{
+       TcorePending *p = NULL;
+
+       if (!hal)
+               return TCORE_RETURN_EINVAL;
+
+       if (data_len > 0 && data == NULL)
+               return TCORE_RETURN_EINVAL;
+
+       p = tcore_queue_pop_by_id(hal->queue, id);
+       if (!p) {
+               dbg("unknown pending (id=0x%x)", id);
+               return TCORE_RETURN_PENDING_WRONG_ID;
+       }
+
+       tcore_pending_emit_response_callback(p, data_len, data);
+       tcore_user_request_free(tcore_pending_ref_user_request(p));
+       tcore_pending_free(p);
+
+       /* Send next request in queue */
+       g_idle_add_full(IDLE_SEND_PRIORITY, _hal_idle_send, hal, NULL);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_hal_add_recv_callback(TcoreHal *hal, TcoreHalReceiveCallback func,
+               void *user_data)
+{
+       struct recv_callback_item_type *item;
+
+       if (!hal)
+               return TCORE_RETURN_EINVAL;
+
+       item = calloc(sizeof(struct recv_callback_item_type), 1);
+       if (!item)
+               return TCORE_RETURN_ENOMEM;
+
+       item->func = func;
+       item->user_data = user_data;
+
+       hal->callbacks = g_slist_append(hal->callbacks, item);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_hal_remove_recv_callback(TcoreHal *hal, TcoreHalReceiveCallback func)
+{
+       struct recv_callback_item_type *item;
+       GSList *list;
+
+       if (!hal)
+               return TCORE_RETURN_EINVAL;
+
+       for (list = hal->callbacks; list; list = list->next) {
+               item = list->data;
+               if (!item) {
+                       continue;
+               }
+
+               if (item->func == func) {
+                       hal->callbacks = g_slist_remove(hal->callbacks, item);
+                       free(item);
+                       list = hal->callbacks;
+               }
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_hal_emit_recv_callback(TcoreHal *hal, unsigned int data_len,
+               const void *data)
+{
+       GSList *list;
+       struct recv_callback_item_type *item;
+
+       if (!hal)
+               return TCORE_RETURN_EINVAL;
+
+       for (list = hal->callbacks; list; list = list->next) {
+               item = list->data;
+
+               if (item) {
+                       item->func(hal, data_len, data, item->user_data);
+               }
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+
+TReturn tcore_hal_add_send_hook(TcoreHal *hal, TcoreHalSendHook func, void *user_data)
+{
+       struct hook_send_type *hook;
+
+       if (!hal || !func)
+               return TCORE_RETURN_EINVAL;
+
+       hook = calloc(sizeof(struct hook_send_type), 1);
+       if (!hook)
+               return TCORE_RETURN_ENOMEM;
+
+       hook->func = func;
+       hook->user_data = user_data;
+
+       hal->hook_list_send = g_slist_append(hal->hook_list_send, hook);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_hal_remove_send_hook(TcoreHal *hal, TcoreHalSendHook func)
+{
+       struct hook_send_type *hook;
+       GSList *list;
+
+       if (!hal)
+               return TCORE_RETURN_EINVAL;
+
+       for (list = hal->hook_list_send; list; list = list->next) {
+               hook = list->data;
+               if (!hook) {
+                       continue;
+               }
+
+               if (hook->func == func) {
+                       hal->hook_list_send = g_slist_remove(hal->hook_list_send, hook);
+                       free(hook);
+                       list = hal->hook_list_send;
+               }
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TcoreQueue *tcore_hal_ref_queue(TcoreHal *hal)
+{
+       if (!hal)
+               return NULL;
+
+       return hal->queue;
+}
+
+TcorePlugin *tcore_hal_ref_plugin(TcoreHal *hal)
+{
+       if (!hal)
+               return NULL;
+
+       return hal->parent_plugin;
+}
+
+TReturn tcore_hal_set_power_state(TcoreHal *hal, gboolean flag)
+{
+       if (!hal)
+               return TCORE_RETURN_EINVAL;
+
+       hal->power_state = flag;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+gboolean tcore_hal_get_power_state(TcoreHal *hal)
+{
+       if (!hal)
+               return FALSE;
+
+       return hal->power_state;
+}
+
+TReturn tcore_hal_set_power(TcoreHal *hal, gboolean flag)
+{
+       if (!hal || !hal->ops || !hal->ops->power)
+               return TCORE_RETURN_EINVAL;
+
+       return hal->ops->power(hal, flag);
+}
diff --git a/src/plugin.c b/src/plugin.c
new file mode 100644 (file)
index 0000000..fe740e0
--- /dev/null
@@ -0,0 +1,312 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 <pthread.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <time.h>
+#include <dlfcn.h>
+
+#include <glib.h>
+
+#include "tcore.h"
+#include "hal.h"
+#include "core_object.h"
+#include "plugin.h"
+#include "server.h"
+
+struct tcore_plugin_type {
+       char *filename;
+       const struct tcore_plugin_define_desc *desc;
+       void *handle;
+
+       void *user_data;
+       TcoreHal *hal;
+       Communicator *comm;
+       GSList *list_co;
+       GHashTable *property;
+
+       Server *parent_server;
+};
+
+TcorePlugin *tcore_plugin_new(Server *server,
+               const struct tcore_plugin_define_desc *desc,
+               const char *filename, void *handle)
+{
+       TcorePlugin *p;
+
+       p = calloc(sizeof(struct tcore_plugin_type), 1);
+       if (!p)
+               return NULL;
+
+       p->desc = desc;
+       p->filename = strdup(filename);
+       p->property = g_hash_table_new(g_str_hash, g_str_equal);
+       p->handle = handle;
+       p->parent_server = server;
+
+       return p;
+}
+
+void tcore_plugin_free(TcorePlugin *plugin)
+{
+       GSList *list;
+       CoreObject *o;
+
+       if (!plugin)
+               return;
+
+       dbg("");
+
+       if (plugin->hal) {
+               tcore_hal_free(plugin->hal);
+               plugin->hal = NULL;
+       }
+
+       if (plugin->list_co) {
+               for (list = plugin->list_co; list; list = list->next) {
+                       if (!list)
+                               continue;
+
+                       o = list->data;
+                       if (!o)
+                               continue;
+
+                       tcore_object_free(o);
+                       list->data = NULL;
+               }
+
+               g_slist_free(plugin->list_co);
+               plugin->list_co = NULL;
+       }
+
+       if (plugin->filename) {
+               free(plugin->filename);
+               plugin->filename = NULL;
+       }
+
+       if (plugin->property) {
+               g_hash_table_destroy(plugin->property);
+               plugin->property = NULL;
+       }
+
+       plugin->desc = NULL;
+
+       if (plugin->handle) {
+               dlclose(plugin->handle);
+               plugin->handle = NULL;
+       }
+
+       free(plugin);
+}
+
+const struct tcore_plugin_define_desc *tcore_plugin_get_description(TcorePlugin *plugin)
+{
+       if (!plugin)
+               return NULL;
+
+       return plugin->desc;
+}
+
+char *tcore_plugin_get_filename(TcorePlugin *plugin)
+{
+       if (!plugin)
+               return NULL;
+
+       if (!plugin->filename)
+               return NULL;
+
+       return strdup(plugin->filename);
+}
+
+char* tcore_plugin_ref_plugin_name(TcorePlugin *plugin)
+{
+       if (!plugin)
+               return NULL;
+
+       if (!plugin->desc->name)
+               return NULL;
+
+       return plugin->desc->name;
+}
+
+Server *tcore_plugin_ref_server(TcorePlugin *plugin)
+{
+       if (!plugin)
+               return NULL;
+
+       return plugin->parent_server;
+}
+
+TReturn tcore_plugin_set_hal(TcorePlugin *plugin, TcoreHal *hal)
+{
+       if (!plugin)
+               return TCORE_RETURN_EINVAL;
+
+       plugin->hal = hal;
+
+       return tcore_server_add_hal(plugin->parent_server, hal);
+}
+
+TcoreHal *tcore_plugin_ref_hal(TcorePlugin *plugin)
+{
+       if (!plugin)
+               return NULL;
+
+       return plugin->hal;
+}
+
+TReturn tcore_plugin_link_user_data(TcorePlugin *plugin, void *user_data)
+{
+       if (!plugin)
+               return TCORE_RETURN_EINVAL;
+
+       plugin->user_data = user_data;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+void *tcore_plugin_ref_user_data(TcorePlugin *plugin)
+{
+       if (!plugin)
+               return FALSE;
+
+       return plugin->user_data;
+}
+
+TReturn tcore_plugin_add_core_object(TcorePlugin *plugin, CoreObject *co)
+{
+       if (!plugin || !co)
+               return TCORE_RETURN_EINVAL;
+
+       dbg("add core_object! (name=%s)", tcore_object_ref_name(co));
+
+       plugin->list_co = g_slist_insert(plugin->list_co, co, 0);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+CoreObject *tcore_plugin_ref_core_object(TcorePlugin *plugin, const char *name)
+{
+       GSList *list;
+       CoreObject *co;
+
+       if (!plugin)
+               return NULL;
+
+       for (list = plugin->list_co; list; list = list->next) {
+               if (!list)
+                       continue;
+
+               co = list->data;
+               if (!co)
+                       continue;
+
+               if (strcmp(tcore_object_ref_name(co), name) == 0) {
+                       return co;
+               }
+       }
+
+       return NULL;
+}
+
+
+GSList *tcore_plugin_get_core_objects_bytype(TcorePlugin *plugin, unsigned int type)
+{
+       GSList *list, *rlist = NULL;
+       CoreObject *co;
+
+       if (!plugin)
+               return NULL;
+
+       for (list = plugin->list_co; list; list = list->next) {
+               if (!list)
+                       continue;
+
+               co = list->data;
+               if (!co)
+                       continue;
+
+               if (tcore_object_get_type(co) == type) {
+                       rlist = g_slist_append(rlist, co);
+               }
+       }
+
+       return rlist;
+}
+
+TReturn tcore_plugin_core_object_event_emit(TcorePlugin *plugin, const char *event, const void *event_info)
+{
+       GSList *list;
+       CoreObject *co;
+
+       if (!plugin)
+               return TCORE_RETURN_EINVAL;
+
+       dbg("event(%s) emit", event);
+
+       for (list = plugin->list_co; list; list = list->next) {
+               if (!list)
+                       continue;
+
+               co = list->data;
+               if (!co)
+                       continue;
+
+               tcore_object_emit_callback(co, event, event_info);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_plugin_link_property(TcorePlugin *plugin, const char *key, void *data)
+{
+       void *prev;
+
+       if (!plugin)
+               return TCORE_RETURN_EINVAL;
+
+       if (!plugin->property)
+               return TCORE_RETURN_EINVAL;
+
+       prev = g_hash_table_lookup(plugin->property, key);
+       if (prev != NULL) {
+               free(prev);
+               g_hash_table_replace(plugin->property, (gpointer)key, data);
+       }
+       else {
+               g_hash_table_insert(plugin->property, strdup(key), data);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+void *tcore_plugin_ref_property(TcorePlugin *plugin, const char *key)
+{
+       if (!plugin)
+               return NULL;
+
+       if (!plugin->property)
+               return NULL;
+
+       return g_hash_table_lookup(plugin->property, key);
+}
diff --git a/src/queue.c b/src/queue.c
new file mode 100644 (file)
index 0000000..ce2bcf1
--- /dev/null
@@ -0,0 +1,526 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 <pthread.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include <glib.h>
+
+#include "tcore.h"
+#include "plugin.h"
+#include "queue.h"
+#include "user_request.h"
+#include "core_object.h"
+
+
+struct tcore_queue_type {
+       TcorePlugin *plugin;
+       GQueue *gq;
+};
+
+struct tcore_pending_type {
+       unsigned int id;
+
+       TcorePendingSendCallback on_send;
+       void *on_send_user_data;
+       TcorePendingTimeoutCallback on_timeout;
+       void *on_timeout_user_data;
+       TcorePendingResponseCallback on_response;
+       void *on_response_user_data;
+
+       enum tcore_pending_priority priority;
+       void *data;
+       unsigned int data_len;
+
+       gboolean enable;
+       unsigned int timeout;
+       time_t timestamp;
+       gboolean flag_sent;
+       gboolean flag_received_response;
+       gboolean flag_auto_free_after_sent;
+
+       UserRequest *ur;
+       TcorePlugin *plugin;
+       CoreObject *co;
+};
+
+TcorePending *tcore_pending_new(CoreObject *co, unsigned int id)
+{
+       TcorePending *p;
+
+       p = calloc(sizeof(struct tcore_pending_type), 1);
+       if (!p)
+               return NULL;
+
+       p->id = id;
+       time(&p->timestamp);
+
+       p->on_send = NULL;
+       p->on_send_user_data = NULL;
+       p->on_response = NULL;
+       p->on_response_user_data = NULL;
+       p->on_timeout = NULL;
+       p->on_timeout_user_data = NULL;
+       p->data = NULL;
+       p->data_len = 0;
+       p->timeout = 0;
+       p->priority = TCORE_PENDING_PRIORITY_DEFAULT;
+       p->flag_sent = FALSE;
+       p->co = co;
+       p->plugin = tcore_object_ref_plugin(co);
+
+       return p;
+}
+
+void tcore_pending_free(TcorePending *pending)
+{
+       if (!pending)
+               return;
+
+       dbg("pending(0x%x) free, id=0x%x", pending, pending->id);
+
+       if (pending->data)
+               free(pending->data);
+
+       free(pending);
+}
+
+unsigned int tcore_pending_get_id(TcorePending *pending)
+{
+       if (!pending)
+               return 0;
+
+       return pending->id;
+}
+
+TReturn tcore_pending_set_auto_free_status_after_sent(TcorePending *pending,
+               gboolean flag)
+{
+       if (!pending)
+               return TCORE_RETURN_EINVAL;
+
+       pending->flag_auto_free_after_sent = flag;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+gboolean tcore_pending_get_auto_free_status_after_sent(TcorePending *pending)
+{
+       if (!pending)
+               return FALSE;
+
+       return pending->flag_auto_free_after_sent;
+}
+
+TReturn tcore_pending_set_request_data(TcorePending *pending,
+               unsigned int data_len, void *data)
+{
+       if (!pending)
+               return TCORE_RETURN_EINVAL;
+
+       if (pending->data) {
+               free(pending->data);
+               pending->data = NULL;
+       }
+
+       pending->data_len = data_len;
+       if (pending->data_len > 0) {
+               pending->data = calloc(data_len, 1);
+               if (!pending->data)
+                       return TCORE_RETURN_ENOMEM;
+
+               memcpy(pending->data, data, data_len);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+void *tcore_pending_ref_request_data(TcorePending *pending, unsigned int *data_len)
+{
+       if (!pending)
+               return NULL;
+
+       if (data_len)
+               *data_len = pending->data_len;
+
+       return pending->data;
+}
+
+TReturn tcore_pending_set_priority(TcorePending *pending,
+               enum tcore_pending_priority priority)
+{
+       if (!pending)
+               return TCORE_RETURN_EINVAL;
+
+       pending->priority = priority;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_pending_get_priority(TcorePending *pending,
+               enum tcore_pending_priority *result_priority)
+{
+       if (!pending || !result_priority)
+               return TCORE_RETURN_EINVAL;
+
+       *result_priority = pending->priority;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_pending_set_timeout(TcorePending *pending, unsigned int timeout)
+{
+       if (!pending)
+               return TCORE_RETURN_EINVAL;
+
+       pending->timeout = timeout;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_pending_get_send_status(TcorePending *pending,
+               gboolean *result_status)
+{
+       if (!pending || !result_status)
+               return TCORE_RETURN_EINVAL;
+
+       *result_status = pending->flag_sent;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_pending_set_send_callback(TcorePending *pending,
+               TcorePendingSendCallback func, void *user_data)
+{
+       if (!pending)
+               return TCORE_RETURN_EINVAL;
+
+       pending->on_send = func;
+       pending->on_send_user_data = user_data;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_pending_set_timeout_callback(TcorePending *pending,
+               TcorePendingTimeoutCallback func, void *user_data)
+{
+       if (!pending)
+               return TCORE_RETURN_EINVAL;
+
+       pending->on_timeout = func;
+       pending->on_timeout_user_data = user_data;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_pending_set_response_callback(TcorePending *pending,
+               TcorePendingResponseCallback func, void *user_data)
+{
+       if (!pending)
+               return TCORE_RETURN_EINVAL;
+
+       pending->on_response = func;
+       pending->on_response_user_data = user_data;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_pending_emit_send_callback(TcorePending *pending, gboolean result)
+{
+       if (!pending)
+               return TCORE_RETURN_EINVAL;
+
+       pending->flag_sent = TRUE;
+
+       if (pending->on_send)
+               pending->on_send(pending, result, pending->on_send_user_data);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_pending_emit_timeout_callback(TcorePending *pending)
+{
+       if (!pending)
+               return TCORE_RETURN_EINVAL;
+
+       if (pending->on_timeout)
+               pending->on_timeout(pending, pending->on_timeout_user_data);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_pending_emit_response_callback(TcorePending *pending,
+               int data_len, const void *data)
+{
+       if (!pending)
+               return TCORE_RETURN_EINVAL;
+
+       if (pending->on_response)
+               pending->on_response(pending, data_len, data,
+                               pending->on_response_user_data);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+CoreObject *tcore_pending_ref_core_object(TcorePending *pending)
+{
+       if (!pending)
+               return NULL;
+
+       return pending->co;
+}
+
+TcorePlugin *tcore_pending_ref_plugin(TcorePending *pending)
+{
+       if (!pending)
+               return NULL;
+
+       return pending->plugin;
+}
+
+TReturn tcore_pending_link_user_request(TcorePending *pending, UserRequest *ur)
+{
+       if (!pending)
+               return TCORE_RETURN_EINVAL;
+
+       pending->ur = ur;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+UserRequest *tcore_pending_ref_user_request(TcorePending *pending)
+{
+       if (!pending)
+               return NULL;
+
+       return pending->ur;
+}
+
+TcoreQueue *tcore_queue_new(TcorePlugin *plugin)
+{
+       TcoreQueue *queue;
+
+       queue = calloc(sizeof(struct tcore_queue_type), 1);
+       if (!queue)
+               return FALSE;
+
+       queue->plugin = plugin;
+
+       queue->gq = g_queue_new();
+       if (!queue->gq) {
+               free(queue);
+               return FALSE;
+       }
+
+       g_queue_init(queue->gq);
+
+       return queue;
+}
+
+void tcore_queue_free(TcoreQueue *queue)
+{
+       if (!queue)
+               return;
+
+       if (queue->gq)
+               g_queue_free(queue->gq);
+
+       free(queue);
+}
+
+TReturn tcore_queue_push(TcoreQueue *queue, TcorePending *pending)
+{
+       enum tcore_pending_priority priority;
+
+       if (!queue || !pending)
+               return TCORE_RETURN_EINVAL;
+
+       tcore_pending_get_priority(pending, &priority);
+       switch (priority) {
+               case TCORE_PENDING_PRIORITY_IMMEDIATELY:
+               case TCORE_PENDING_PRIORITY_HIGH:
+                       g_queue_push_head(queue->gq, pending);
+                       break;
+
+               case TCORE_PENDING_PRIORITY_DEFAULT:
+               case TCORE_PENDING_PRIORITY_LOW:
+                       g_queue_push_tail(queue->gq, pending);
+                       break;
+
+               default:
+                       return TCORE_RETURN_EINVAL;
+                       break;
+       }
+
+       dbg("pending(0x%x) push to queue. queue len=%d",
+                       pending, g_queue_get_length(queue->gq));
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TcorePending *tcore_queue_pop(TcoreQueue *queue)
+{
+       if (!queue)
+               return NULL;
+
+       return g_queue_pop_head(queue->gq);
+}
+
+TcorePending *tcore_queue_pop_timeout_pending(TcoreQueue *queue)
+{
+       int i = 0;
+       TcorePending *pending = NULL;
+       time_t cur_time = 0;
+
+       time(&cur_time);
+
+       do {
+               pending = g_queue_peek_nth(queue->gq, i);
+               if (!pending)
+                       return NULL;
+
+               if (cur_time - pending->timestamp >= (int)pending->timeout) {
+                       pending = g_queue_pop_nth(queue->gq, i);
+                       break;
+               }
+
+               i++;
+       } while (pending != NULL);
+
+       return pending;
+}
+
+TcorePending *tcore_queue_ref_head(TcoreQueue *queue)
+{
+       if (!queue)
+               return NULL;
+
+       return g_queue_peek_head(queue->gq);
+}
+
+TcorePending *tcore_queue_ref_tail(TcoreQueue *queue)
+{
+       if (!queue)
+               return NULL;
+
+       return g_queue_peek_tail(queue->gq);
+}
+
+
+static TcorePending *_tcore_queue_search(TcoreQueue *queue, unsigned int id,
+               gboolean flag_pop)
+{
+       TcorePending *pending = NULL;
+       int i = 0;
+
+       if (!queue)
+               return NULL;
+
+       do {
+               pending = g_queue_peek_nth(queue->gq, i);
+               if (!pending)
+                       return NULL;
+
+               if (pending->id == id) {
+                       if (flag_pop == TRUE) {
+                               pending = g_queue_pop_nth(queue->gq, i);
+                       }
+                       break;
+               }
+
+               i++;
+       } while (pending != NULL);
+
+       return pending;
+}
+
+TcorePending *tcore_queue_pop_by_id(TcoreQueue *queue, unsigned int id)
+{
+       if (!queue)
+               return NULL;
+
+       return _tcore_queue_search(queue, id, TRUE);
+}
+
+TcorePending *tcore_queue_ref_pending_by_id(TcoreQueue *queue, unsigned int id)
+{
+       if (!queue)
+               return NULL;
+
+       return _tcore_queue_search(queue, id, FALSE);
+}
+
+TcorePending *tcore_queue_ref_next_pending(TcoreQueue *queue)
+{
+       TcorePending *pending = NULL;
+       int i = 0;
+
+       if (!queue)
+               return NULL;
+
+       do {
+               pending = g_queue_peek_nth(queue->gq, i);
+               if (!pending) {
+                       return NULL;
+               }
+
+               /* skip already sent immediately pending */
+               if (pending->priority == TCORE_PENDING_PRIORITY_IMMEDIATELY) {
+                       if (pending->flag_sent == FALSE) {
+                               break;
+                       }
+
+                       i++;
+                       continue;
+               }
+               else {
+                       break;
+               }
+
+               i++;
+       } while (pending != NULL);
+
+       if (pending->flag_sent == TRUE) {
+               dbg("pending(0x%x) is waiting state.", pending);
+               return NULL;
+       }
+
+       return pending;
+}
+
+unsigned int tcore_queue_get_length(TcoreQueue *queue)
+{
+       if (!queue)
+               return 0;
+
+       return g_queue_get_length(queue->gq);
+}
+
+TcorePlugin *tcore_queue_ref_plugin(TcoreQueue *queue)
+{
+       if (!queue)
+               return NULL;
+
+       return queue->plugin;
+}
diff --git a/src/server.c b/src/server.c
new file mode 100644 (file)
index 0000000..661f8e3
--- /dev/null
@@ -0,0 +1,556 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 <pthread.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <time.h>
+#include <dlfcn.h>
+
+#include <glib.h>
+
+#include "tcore.h"
+#include "plugin.h"
+#include "hal.h"
+#include "server.h"
+#include "user_request.h"
+#include "core_object.h"
+#include "co_ps.h"
+#include "communicator.h"
+#include "storage.h"
+
+struct tcore_server_type {
+       GMainLoop *mainloop;
+       GSList *plugins;
+       GSList *communicators;
+       GSList *storages;
+       GSList *hals;
+       GSList *hook_list_request;
+       GSList *hook_list_notification;
+       TcorePlugin *default_plugin;
+};
+
+struct hook_request_type {
+       enum tcore_request_command command;
+       TcoreServerRequestHook func;
+       void *user_data;
+};
+
+struct hook_notification_type {
+       enum tcore_notification_command command;
+       TcoreServerNotificationHook func;
+       void *user_data;
+};
+
+static gint _compare_priority(gconstpointer a, gconstpointer b)
+{
+       TcorePlugin *plugin1 = (TcorePlugin *)a;
+       TcorePlugin *plugin2 = (TcorePlugin *)b;
+
+       if (!plugin2)
+               return 1;
+
+       return tcore_plugin_get_description(plugin1)->priority -
+                       tcore_plugin_get_description(plugin2)->priority;
+}
+
+static TcorePlugin *_find_default_plugin(Server *s)
+{
+       GSList *list;
+       TcorePlugin *p;
+       GSList *co_list;
+
+       if (s->default_plugin != NULL) {
+               return s->default_plugin;
+       }
+
+       for (list = s->plugins; list; list = list->next) {
+               p = list->data;
+               if (!p)
+                       continue;
+
+               co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_MODEM);
+               if (!co_list)
+                       continue;
+
+               g_slist_free(co_list);
+               s->default_plugin = p;
+               return p;
+       }
+
+       return NULL;
+}
+
+Server *tcore_server_new()
+{
+       Server *s;
+
+       s = calloc(sizeof(struct tcore_server_type), 1);
+       if (!s)
+               return NULL;
+
+       s->mainloop = g_main_loop_new (NULL, FALSE);
+       if (!s->mainloop) {
+               free(s);
+               return NULL;
+       }
+
+       s->plugins = NULL;
+       s->communicators = NULL;
+       s->storages = NULL;
+       s->hals = NULL;
+       s->hook_list_request = NULL;
+       s->hook_list_notification = NULL;
+       s->default_plugin = NULL;
+
+       return s;
+}
+
+void tcore_server_free(Server *s)
+{
+       GSList *list = NULL;
+       TcorePlugin *p = NULL;
+       struct tcore_plugin_define_desc *desc = NULL;
+
+       if (!s)
+               return;
+
+       if (s->mainloop)
+               g_main_loop_unref(s->mainloop);
+
+    for (list = s->plugins; list; list = list->next) {
+        p = list->data;
+        if (!p)
+            continue;
+
+        desc = (struct tcore_plugin_define_desc *)tcore_plugin_get_description(p);
+               if (!desc || !desc->unload)
+                       continue;
+
+        desc->unload(p);
+
+        tcore_plugin_free(p);
+
+        list->data = NULL;
+    }
+
+    if (s->plugins) {
+        g_slist_free(s->plugins);
+        s->plugins = NULL;
+    }
+}
+
+TReturn tcore_server_run(Server *s)
+{
+       if (!s || !s->mainloop)
+               return TCORE_RETURN_EINVAL;
+
+       tcore_server_send_notification(s, NULL, TNOTI_SERVER_RUN, 0, NULL);
+
+       g_main_loop_run(s->mainloop);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_server_exit(Server *s)
+{
+       if (!s || !s->mainloop)
+               return TCORE_RETURN_EINVAL;
+
+       g_main_loop_quit(s->mainloop);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_server_add_plugin(Server *s, TcorePlugin *plugin)
+{
+       if (!s || !plugin)
+               return TCORE_RETURN_EINVAL;
+
+       s->plugins = g_slist_insert_sorted(s->plugins, plugin, _compare_priority);
+
+       tcore_server_send_notification(s, NULL, TNOTI_SERVER_ADDED_PLUGIN, 0, NULL);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TcorePlugin *tcore_server_find_plugin(Server *s, const char *name)
+{
+       GSList *list;
+       TcorePlugin *p;
+
+       if (strncmp(name, TCORE_PLUGIN_DEFAULT, strlen(name)) == 0) {
+               return _find_default_plugin(s);
+       }
+
+       for (list = s->plugins; list; list = list->next) {
+               p = list->data;
+               if (!p) {
+                       continue;
+               }
+
+               if (strncmp(tcore_plugin_get_description(p)->name, name, strlen(name)) == 0) {
+                       return p;
+               }
+       }
+
+       return NULL;
+}
+
+GSList *tcore_server_ref_plugins(Server *s)
+{
+       if (!s)
+               return NULL;
+
+       return s->plugins;
+}
+
+TReturn tcore_server_add_communicator(Server *s, Communicator *comm)
+{
+       if (!s || !comm)
+               return TCORE_RETURN_EINVAL;
+
+       s->communicators = g_slist_insert(s->communicators, comm, 0);
+
+       tcore_server_send_notification(s, NULL, TNOTI_SERVER_ADDED_COMMUNICATOR, 0, NULL);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+GSList *tcore_server_ref_communicators(Server *s)
+{
+       if (!s)
+               return NULL;
+
+       return s->communicators;
+}
+
+Communicator *tcore_server_find_communicator(Server *s, const char *name)
+{
+       GSList *list;
+       Communicator *comm;
+
+       for (list = s->communicators; list; list = list->next) {
+               comm = list->data;
+               if (!comm) {
+                       continue;
+               }
+
+               if (strncmp(tcore_communicator_ref_name(comm), name, strlen(name)) == 0) {
+                       return comm;
+               }
+       }
+
+       return NULL;
+}
+
+TReturn tcore_server_add_storage(Server *s, Storage *strg)
+{
+       if (!s || !strg)
+               return TCORE_RETURN_EINVAL;
+
+       s->storages = g_slist_insert(s->storages, strg, 0);
+
+       tcore_server_send_notification(s, NULL, TNOTI_SERVER_ADDED_STORAGE, 0, NULL);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+GSList *tcore_server_ref_storages(Server *s)
+{
+       if (!s)
+               return NULL;
+
+       return s->storages;
+}
+
+Storage *tcore_server_find_storage(Server *s, const char *name)
+{
+       GSList *list;
+       Storage *strg;
+
+       for (list = s->storages; list; list = list->next) {
+               strg = list->data;
+               if (!strg) {
+                       continue;
+               }
+
+               if (strncmp(tcore_storage_ref_name(strg), name, strlen(name)) == 0) {
+                       return strg;
+               }
+       }
+
+       return NULL;
+}
+
+TReturn tcore_server_add_hal(Server *s, TcoreHal *hal)
+{
+       GSList *list;
+       TcoreHal *temp;
+
+       if (!s || !hal)
+               return TCORE_RETURN_EINVAL;
+
+       for (list = s->hals; list; list = list->next) {
+               temp = list->data;
+               if (!temp) {
+                       continue;
+               }
+
+               if (temp == hal)
+                       return TCORE_RETURN_EALREADY;
+       }
+
+       s->hals = g_slist_insert(s->hals, hal, 0);
+
+       tcore_server_send_notification(s, NULL, TNOTI_SERVER_ADDED_HAL, 0, NULL);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+GSList *tcore_server_ref_hals(Server *s)
+{
+       if (!s)
+               return NULL;
+
+       return s->hals;
+}
+
+TcoreHal *tcore_server_find_hal(Server *s, const char *name)
+{
+       GSList *list;
+       TcoreHal *hal;
+       char *buf;
+
+       for (list = s->hals; list; list = list->next) {
+               hal = list->data;
+               if (!hal) {
+                       continue;
+               }
+
+               buf = tcore_hal_get_name(hal);
+               if (!buf)
+                       continue;
+
+               if (strncmp(buf, name, strlen(name)) == 0) {
+                       free(buf);
+                       return hal;
+               }
+
+               free(buf);
+       }
+
+       return NULL;
+}
+
+TReturn tcore_server_dispatch_request(Server *s, UserRequest *ur)
+{
+       char *modem = NULL;
+       TcorePlugin *p;
+       enum tcore_request_command command = 0;
+       GSList *list, *co_list=NULL;
+       struct hook_request_type *hook;
+       int category;
+       CoreObject *o;
+       TReturn ret = TCORE_RETURN_ENOSYS;
+
+       if (!s || !ur)
+               return TCORE_RETURN_EINVAL;
+
+       for (list = s->hook_list_request; list; list = list->next) {
+               hook = list->data;
+               if (!hook) {
+                       continue;
+               }
+
+               if (hook->command == tcore_user_request_get_command(ur)) {
+                       if (hook->func(s, ur, hook->user_data) == TCORE_HOOK_RETURN_STOP_PROPAGATION) {
+                               return TCORE_RETURN_SUCCESS;
+                       }
+               }
+       }
+
+       modem = tcore_user_request_get_modem_name(ur);
+       if (!modem)
+               return TCORE_RETURN_EINVAL;
+
+       p = tcore_server_find_plugin(s, modem);
+       if (!p) {
+               free(modem);
+               return TCORE_RETURN_SERVER_WRONG_PLUGIN;
+       }
+       free(modem);
+
+       command = tcore_user_request_get_command(ur);
+
+       category = CORE_OBJECT_TYPE_DEFAULT | (command & 0x0FF00000);
+       dbg("Category = 0x%x, command = 0x%x", category, command);
+
+       co_list = tcore_plugin_get_core_objects_bytype(p, category);
+       if (!co_list) {
+               warn("can't find 0x%x core_object", category);
+               return TCORE_RETURN_ENOSYS;
+       }
+
+       for (list = co_list; list; list = list->next) {
+               o = (CoreObject *) list->data;
+               if (!o) {
+                       warn("can't find 0x%x core_object", category);
+                       continue;
+               }
+
+               if (tcore_object_dispatch_request(o, ur) == TCORE_RETURN_SUCCESS)
+                       ret = TCORE_RETURN_SUCCESS;
+       }
+
+       g_slist_free(co_list);
+       return ret;
+}
+
+TReturn tcore_server_send_notification(Server *s, CoreObject *source,
+               enum tcore_notification_command command,
+               unsigned int data_len, void *data)
+{
+       GSList *list;
+       Communicator *comm;
+       struct hook_notification_type *hook;
+
+       if (!s)
+               return TCORE_RETURN_EINVAL;
+
+       for (list = s->hook_list_notification; list; list = list->next) {
+               hook = list->data;
+               if (!hook) {
+                       continue;
+               }
+
+               if (hook->command == command) {
+                       if (hook->func(s, source, command, data_len, data, hook->user_data) == TCORE_HOOK_RETURN_STOP_PROPAGATION) {
+                               return TCORE_RETURN_SUCCESS;
+                       }
+               }
+       }
+
+       for (list = s->communicators; list; list = list->next) {
+               comm = list->data;
+               if (!comm) {
+                       continue;
+               }
+
+               tcore_communicator_send_notification(comm, source, command, data_len, data);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_server_add_request_hook(Server *s,
+               enum tcore_request_command command,
+               TcoreServerRequestHook func, void *user_data)
+{
+       struct hook_request_type *hook;
+
+       if (!s || !func)
+               return TCORE_RETURN_EINVAL;
+
+       hook = calloc(sizeof(struct hook_request_type), 1);
+       if (!hook)
+               return TCORE_RETURN_ENOMEM;
+
+       hook->command = command;
+       hook->func = func;
+       hook->user_data = user_data;
+
+       s->hook_list_request = g_slist_append(s->hook_list_request, hook);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_server_remove_request_hook(Server *s, TcoreServerRequestHook func)
+{
+       struct hook_request_type *hook;
+       GSList *list;
+
+       if (!s)
+               return TCORE_RETURN_EINVAL;
+
+       for (list = s->hook_list_request; list; list = list->next) {
+               hook = list->data;
+               if (!hook) {
+                       continue;
+               }
+
+               if (hook->func == func) {
+                       s->hook_list_request = g_slist_remove(s->hook_list_request, hook);
+                       free(hook);
+                       list = s->hook_list_request;
+               }
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_server_add_notification_hook(Server *s,
+               enum tcore_notification_command command,
+               TcoreServerNotificationHook func, void *user_data)
+{
+       struct hook_notification_type *hook;
+
+       if (!s || !func)
+               return TCORE_RETURN_EINVAL;
+
+       hook = calloc(sizeof(struct hook_notification_type), 1);
+       if (!hook)
+               return TCORE_RETURN_ENOMEM;
+
+       hook->command = command;
+       hook->func = func;
+       hook->user_data = user_data;
+
+       s->hook_list_notification = g_slist_append(s->hook_list_notification, hook);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_server_remove_notification_hook(Server *s,
+               TcoreServerNotificationHook func)
+{
+       struct hook_notification_type *hook;
+       GSList *list;
+
+       if (!s)
+               return TCORE_RETURN_EINVAL;
+
+       for (list = s->hook_list_notification; list; list = list->next) {
+               hook = list->data;
+               if (!hook) {
+                       continue;
+               }
+
+               if (hook->func == func) {
+                       s->hook_list_notification = g_slist_remove(s->hook_list_notification, hook);
+                       free(hook);
+                       list = s->hook_list_notification;
+               }
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
diff --git a/src/storage.c b/src/storage.c
new file mode 100644 (file)
index 0000000..e35c61d
--- /dev/null
@@ -0,0 +1,332 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "plugin.h"
+#include "server.h"
+#include "storage.h"
+
+struct tcore_storage_type {
+       const char *name;
+       struct storage_operations *ops;
+       GHashTable *callback;
+
+       TcorePlugin *parent_plugin;
+};
+
+struct storage_callback_type{
+       TcoreStorageKeyCallback cb_fn;
+       void *user_data;
+};
+
+Storage *tcore_storage_new(TcorePlugin *plugin, const char *name,
+               struct storage_operations *ops)
+{
+       Storage *strg;
+
+       strg = calloc(sizeof(struct tcore_storage_type), 1);
+       if (!strg)
+               return NULL;
+
+       if (name)
+               strg->name = strdup(name);
+
+       strg->parent_plugin = plugin;
+       strg->ops = ops;
+       strg->callback = g_hash_table_new_full(g_str_hash,g_str_equal, g_free, NULL);
+
+       tcore_server_add_storage(tcore_plugin_ref_server(plugin), strg);
+
+       return strg;
+}
+
+void tcore_storage_free(Storage *strg)
+{
+       if (!strg)
+               return;
+
+       if (strg->name)
+               free((void *)strg->name);
+
+       free(strg);
+}
+
+const char *tcore_storage_ref_name(Storage *strg)
+{
+       if (!strg)
+               return NULL;
+
+       return strg->name;
+}
+
+void *tcore_storage_create_handle(Storage *strg, const char *path)
+{
+       if (!path)
+               return NULL;
+
+       if (!strg || !strg->ops || !strg->ops->create_handle) {
+               return NULL;
+       }
+
+       return strg->ops->create_handle(strg, path);
+}
+
+gboolean tcore_storage_remove_handle(Storage *strg, void *handle)
+{
+       if (!handle)
+               return FALSE;
+
+       if (!strg || !strg->ops || !strg->ops->remove_handle) {
+               return FALSE;
+       }
+
+       return strg->ops->remove_handle(strg, handle);
+}
+
+gboolean tcore_storage_set_int(Storage *strg, enum tcore_storage_key key,
+               int value)
+{
+       if (!strg || !strg->ops || !strg->ops->set_int) {
+               return FALSE;
+       }
+
+       return strg->ops->set_int(strg, key, value);
+}
+
+gboolean tcore_storage_set_string(Storage *strg, enum tcore_storage_key key,
+               const char *value)
+{
+       if (!strg || !strg->ops || !strg->ops->set_string) {
+               return FALSE;
+       }
+
+       return strg->ops->set_string(strg, key, value);
+}
+
+gboolean tcore_storage_set_bool(Storage *strg, enum tcore_storage_key key,
+               gboolean value)
+{
+       if (!strg || !strg->ops || !strg->ops->set_bool) {
+               return FALSE;
+       }
+
+       return strg->ops->set_bool(strg, key, value);
+}
+
+int tcore_storage_get_int(Storage *strg, enum tcore_storage_key key)
+{
+       if (!strg || !strg->ops || !strg->ops->get_int) {
+               return FALSE;
+       }
+
+       return strg->ops->get_int(strg, key);
+}
+
+char *tcore_storage_get_string(Storage *strg, enum tcore_storage_key key)
+{
+       if (!strg || !strg->ops || !strg->ops->get_string) {
+               return FALSE;
+       }
+
+       return strg->ops->get_string(strg, key);
+}
+
+gboolean tcore_storage_get_bool(Storage *strg, enum tcore_storage_key key)
+{
+       if (!strg || !strg->ops || !strg->ops->get_bool) {
+               return FALSE;
+       }
+
+       return strg->ops->get_bool(strg, key);
+}
+
+static void tcore_storage_vkey_callback_dispatcher(Storage *strg,
+               enum tcore_storage_key key, void *value)
+{
+       gpointer tmp = NULL;
+       gchar *key_gen = NULL;
+       struct storage_callback_type *tmp_cb = NULL;
+
+       key_gen = g_strdup_printf("%d", key);
+       tmp = g_hash_table_lookup(strg->callback, key_gen);
+
+       if (tmp != NULL) {
+
+               GSList *cb_data = (GSList *) tmp;
+
+               do {
+                       tmp_cb = cb_data->data;
+                       tmp_cb->cb_fn(key, value, tmp_cb->user_data);
+               } while ((cb_data = g_slist_next(cb_data)));
+       }
+
+       g_free(key_gen);
+       return;
+}
+
+gboolean tcore_storage_set_key_callback(Storage *strg,
+               enum tcore_storage_key key, TcoreStorageKeyCallback cb, void *user_data)
+{
+       gpointer tmp = NULL;
+       gchar *key_gen = NULL;
+       struct storage_callback_type *strg_cb_data = NULL;
+       struct storage_callback_type *tmp_cb = NULL;
+
+       if (!strg || !strg->ops || !strg->ops->set_key_callback)
+       {
+               return FALSE;
+       }
+
+       strg_cb_data = g_new0(struct storage_callback_type, 1);
+       strg_cb_data->cb_fn = cb;
+       strg_cb_data->user_data = user_data;
+
+       key_gen = g_strdup_printf("%d", key);
+       tmp = g_hash_table_lookup(strg->callback, key_gen);
+       if (tmp != NULL) {
+               GSList *cb_data = (GSList *) tmp;
+
+               do {
+                       tmp_cb = cb_data->data;
+                       if (tmp_cb->cb_fn == cb) {
+                               g_free(key_gen);
+                               g_free(strg_cb_data);
+                               return FALSE;
+                       }
+
+               } while ((cb_data = g_slist_next(cb_data)));
+
+               tmp = g_slist_append( (GSList *)tmp, strg_cb_data);
+       }
+       else {
+               GSList *data = NULL;
+               data = g_slist_append(data, strg_cb_data);
+               g_hash_table_insert(strg->callback, g_strdup(key_gen), data);
+               strg->ops->set_key_callback(strg, key, tcore_storage_vkey_callback_dispatcher);
+       }
+
+       g_free(key_gen);
+       return TRUE;
+}
+
+gboolean tcore_storage_remove_key_callback(Storage *strg,
+               enum tcore_storage_key key, TcoreStorageKeyCallback cb)
+{
+       gpointer tmp = NULL;
+       gchar *key_gen = NULL;
+       GSList *cb_data = NULL;
+       int cb_cnt = 0;
+       struct storage_callback_type *tmp_cb = NULL;
+
+       if (!strg || !strg->ops || !strg->ops->remove_key_callback) {
+               return FALSE;
+       }
+
+       key_gen = g_strdup_printf("%d", key);
+       tmp = g_hash_table_lookup(strg->callback, key_gen);
+
+       if (tmp == NULL){
+               g_free(key_gen);
+               return FALSE;
+       }
+
+       cb_data = (GSList *) tmp;
+
+       do {
+               tmp_cb = cb_data->data;
+               if (tmp_cb->cb_fn == cb) {
+                       tmp = g_slist_remove((GSList *) tmp, cb_data->data);
+                       g_free(cb_data->data);
+                       break;
+               }
+
+       } while ((cb_data = g_slist_next(cb_data)));
+
+       cb_cnt = g_slist_length( (GSList *) tmp );
+       dbg("glist cnt (%d)", cb_cnt);
+
+       if(cb_cnt == 0){
+               g_hash_table_remove(strg->callback, key_gen);
+               strg->ops->remove_key_callback(strg, key);
+       }
+
+       g_free(key_gen);
+       return TRUE;
+}
+
+gboolean tcore_storage_update_query_database(Storage *strg, void *handle,
+               const char *query, GHashTable *in_param)
+{
+       if (!strg || !handle || !query)
+               return FALSE;
+
+       if (!strg->ops || !strg->ops->update_query_database) {
+               return FALSE;
+       }
+
+       return strg->ops->update_query_database(strg, handle, query, in_param);
+}
+
+gboolean tcore_storage_read_query_database(Storage *strg, void *handle,
+               const char *query, GHashTable *in_param,
+               GHashTable *out_param, int out_param_cnt)
+{
+       if (!strg || !handle || !query)
+               return FALSE;
+
+       if (!strg->ops || !strg->ops->read_query_database) {
+               return FALSE;
+       }
+
+       return strg->ops->read_query_database(strg, handle, query,
+                       in_param, out_param, out_param_cnt);
+}
+
+gboolean tcore_storage_insert_query_database(Storage *strg, void *handle,
+               const char *query, GHashTable *in_param)
+{
+       if (!strg || !handle || !query)
+               return FALSE;
+
+       if (!strg->ops || !strg->ops->insert_query_database) {
+               return FALSE;
+       }
+
+       return strg->ops->insert_query_database(strg, handle, query, in_param);
+}
+
+gboolean tcore_storage_remove_query_database(Storage *strg, void *handle,
+               const char *query, GHashTable *in_param)
+{
+       if (!strg || !handle || !query)
+               return FALSE;
+
+       if (!strg->ops || !strg->ops->remove_query_database) {
+               return FALSE;
+       }
+
+       return strg->ops->remove_query_database(strg, handle, query, in_param);
+}
diff --git a/src/user_request.c b/src/user_request.c
new file mode 100644 (file)
index 0000000..39a6d15
--- /dev/null
@@ -0,0 +1,311 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 "tcore.h"
+#include "user_request.h"
+#include "communicator.h"
+
+struct tcore_user_request_type {
+       struct tcore_user_info ui;
+
+       Communicator *comm;
+
+       char *modem_name;
+
+       enum tcore_request_command command;
+
+       void *data;
+       unsigned int data_len;
+
+       void *metainfo;
+       unsigned int metainfo_len;
+
+       UserRequestFreeHook free_hook;
+       UserRequestResponseHook response_hook;
+       void *response_hook_user_data;
+};
+
+UserRequest *tcore_user_request_new(Communicator *comm, const char *modem_name)
+{
+       UserRequest *ur;
+
+       ur = calloc(sizeof(struct tcore_user_request_type), 1);
+       if (!ur)
+               return NULL;
+
+       ur->comm = comm;
+
+       if (modem_name)
+               ur->modem_name = strdup(modem_name);
+       else
+               ur->modem_name = NULL;
+
+       return ur;
+}
+
+void tcore_user_request_free(UserRequest *ur)
+{
+       if (!ur)
+               return;
+
+       if (ur->free_hook)
+               ur->free_hook(ur);
+
+       if (ur->modem_name)
+               free(ur->modem_name);
+
+       if (ur->data)
+               free(ur->data);
+
+       if(ur->metainfo)
+               free(ur->metainfo);
+
+       dbg("user_request(0x%x) free.", ur);
+
+       free(ur);
+}
+
+UserRequest *tcore_user_request_dup(UserRequest *ur)
+{
+       UserRequest *dest;
+
+       if (!ur)
+               return NULL;
+
+       dest = tcore_user_request_new(ur->comm, ur->modem_name);
+       if (!dest)
+               return NULL;
+
+       tcore_user_request_set_user_info(dest, &(ur->ui));
+       dest->command = ur->command;
+
+       if (ur->data_len > 0) {
+               dest->data = calloc(ur->data_len, 1);
+               dest->data_len = ur->data_len;
+               memcpy(dest->data, ur->data, ur->data_len);
+       }
+
+       if (ur->metainfo_len > 0) {
+               dest->metainfo = calloc(ur->metainfo_len,1);
+               dest->metainfo_len = ur->metainfo_len;
+               memcpy(dest->metainfo, ur->metainfo, ur->metainfo_len);
+       }
+
+       if (ur->free_hook)
+               dest->free_hook = ur->free_hook;
+
+       if (ur->response_hook)
+               dest->response_hook = ur->response_hook;
+
+       if (ur->response_hook_user_data)
+               dest->response_hook_user_data = ur->response_hook_user_data;
+
+       return dest;
+}
+
+TReturn tcore_user_request_set_free_hook(UserRequest *ur,
+               UserRequestFreeHook free_hook)
+{
+       if (!ur)
+               return TCORE_RETURN_EINVAL;
+
+       ur->free_hook = free_hook;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_user_request_set_response_hook(UserRequest *ur,
+               UserRequestResponseHook resp_hook, void *user_data)
+{
+       if (!ur)
+               return TCORE_RETURN_EINVAL;
+
+       ur->response_hook = resp_hook;
+       ur->response_hook_user_data = user_data;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+Communicator *tcore_user_request_ref_communicator(UserRequest *ur)
+{
+       if (!ur)
+               return NULL;
+
+       return ur->comm;
+}
+
+char *tcore_user_request_get_modem_name(UserRequest *ur)
+{
+       if (!ur)
+               return NULL;
+
+       if (!ur->modem_name)
+               return NULL;
+
+       return strdup(ur->modem_name);
+}
+
+TReturn tcore_user_request_set_user_info(UserRequest *ur,
+               const struct tcore_user_info *ui)
+{
+       if (!ur || !ui)
+               return TCORE_RETURN_EINVAL;
+
+       ur->ui.uid = ui->uid;
+       ur->ui.gid = ui->gid;
+       ur->ui.pid = ui->pid;
+       ur->ui.channel_id = ui->channel_id;
+       ur->ui.client_cmd = ui->client_cmd;
+
+       if (ur->ui.appname) {
+               dbg("free old appname (%s)", ur->ui.appname);
+               free(ur->ui.appname);
+       }
+
+       if (ui->appname) {
+               ur->ui.appname = strdup(ui->appname);
+               dbg("alloc appname(%s, %s)", ur->ui.appname, ui->appname);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+const struct tcore_user_info *tcore_user_request_ref_user_info(UserRequest *ur)
+{
+       if (!ur)
+               return NULL;
+
+       return &(ur->ui);
+}
+
+TReturn tcore_user_request_send_response(UserRequest *ur,
+               enum tcore_response_command command,
+               unsigned int data_len, const void *data)
+{
+       if (!ur) {
+               dbg("ur is NULL");
+               return TCORE_RETURN_EINVAL;
+       }
+
+       if (ur->response_hook) {
+               ur->response_hook(ur, command, data_len, data,
+                               ur->response_hook_user_data);
+       }
+
+       if (ur->comm) {
+               return tcore_communicator_send_response(ur->comm, ur,
+                               command, data_len, data);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_user_request_set_command(UserRequest *ur,
+               enum tcore_request_command command)
+{
+       if (!ur)
+               return TCORE_RETURN_EINVAL;
+
+       ur->command = command;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+enum tcore_request_command tcore_user_request_get_command(UserRequest *ur)
+{
+       if (!ur)
+               return 0;
+
+       return ur->command;
+}
+
+TReturn tcore_user_request_set_data(UserRequest *ur,
+               unsigned int data_len, const void *data)
+{
+       if (!ur)
+               return TCORE_RETURN_EINVAL;
+
+       ur->data_len = data_len;
+
+       if (data_len > 0 && data != NULL) {
+               ur->data = calloc(data_len, 1);
+               if (!ur->data)
+                       return TCORE_RETURN_ENOMEM;
+
+               memcpy(ur->data, data, data_len);
+       }
+       else {
+               ur->data = NULL;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_user_request_set_metainfo(UserRequest *ur,
+               unsigned int metainfo_len, const void *metainfo)
+{
+       if (!ur)
+               return TCORE_RETURN_EINVAL;
+
+       ur->metainfo_len = metainfo_len;
+
+       if (metainfo_len > 0 && metainfo != NULL) {
+               ur->metainfo = calloc(metainfo_len, 1);
+               if (!ur->metainfo)
+                       return TCORE_RETURN_ENOMEM;
+
+               memcpy(ur->metainfo, metainfo, metainfo_len);
+       }
+       else {
+               ur->metainfo = NULL;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+const void *tcore_user_request_ref_data(UserRequest *ur,
+               unsigned int *data_len)
+{
+       if (!ur)
+               return NULL;
+
+       if (data_len)
+               *data_len = ur->data_len;
+
+       return ur->data;
+}
+
+const void *tcore_user_request_ref_metainfo(UserRequest *ur,
+               unsigned int *metainfo_len)
+{
+       if (!ur)
+               return NULL;
+
+       if (metainfo_len)
+               *metainfo_len = ur->metainfo_len;
+
+       return ur->metainfo;
+}
diff --git a/src/util.c b/src/util.c
new file mode 100644 (file)
index 0000000..67e0e12
--- /dev/null
@@ -0,0 +1,709 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 <unistd.h>
+
+#include <net/if.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "tcore.h"
+#include "util.h"
+
+
+static gboolean _tcore_util_marshal_create_gvalue(GValue *value,
+               const void *data, enum tcore_util_marshal_data_type type)
+{
+       switch (type) {
+               case TCORE_UTIL_MARSHAL_DATA_CHAR_TYPE:
+                       g_value_init(value, type);
+                       g_value_set_char(value, *((gchar *) data));
+                       break;
+
+               case TCORE_UTIL_MARSHAL_DATA_BOOLEAN_TYPE:
+                       g_value_init(value, type);
+                       g_value_set_boolean(value, *((gboolean *) data));
+                       break;
+
+               case TCORE_UTIL_MARSHAL_DATA_INT_TYPE:
+                       g_value_init(value, type);
+                       g_value_set_int(value, *((gint *) data));
+                       break;
+
+               case TCORE_UTIL_MARSHAL_DATA_DOUBLE_TYPE:
+                       g_value_init(value, type);
+                       g_value_set_double(value, *((gdouble *) data));
+                       break;
+
+               case TCORE_UTIL_MARSHAL_DATA_STRING_TYPE:
+                       g_value_init(value, type);
+                       g_value_set_string(value, (gchar *) data);
+                       break;
+
+               case TCORE_UTIL_MARSHAL_DATA_OBJECT_TYPE:
+                       g_value_init(value, G_TYPE_HASH_TABLE);
+                       g_value_set_boxed(value, (gpointer) data);
+                       break;
+
+               default:
+                       return FALSE;
+                       break;
+       }
+
+       return TRUE;
+}
+
+
+static gboolean _tcore_util_return_value(GValue *src, void **dest,
+               enum tcore_util_marshal_data_type type)
+{
+       switch (type) {
+               case TCORE_UTIL_MARSHAL_DATA_CHAR_TYPE:
+                       *dest = g_new0(gchar, 1);
+                       *((gchar *) *dest) = g_value_get_char(src);
+                       break;
+
+               case TCORE_UTIL_MARSHAL_DATA_BOOLEAN_TYPE:
+                       *dest = g_new0(gboolean, 1);
+                       *((gboolean *) *dest) = g_value_get_boolean(src);
+                       break;
+
+               case TCORE_UTIL_MARSHAL_DATA_INT_TYPE:
+                       *dest = g_new0(gint, 1);
+                       *((gint *) *dest) = g_value_get_int(src);
+                       break;
+
+               case TCORE_UTIL_MARSHAL_DATA_DOUBLE_TYPE:
+                       *dest = g_new0(gdouble, 1);
+                       *((gdouble *) *dest) = g_value_get_double(src);
+                       break;
+
+               case TCORE_UTIL_MARSHAL_DATA_STRING_TYPE:
+                       *dest = g_value_dup_string(src);
+                       break;
+
+               case TCORE_UTIL_MARSHAL_DATA_OBJECT_TYPE:
+                       *dest = g_value_dup_boxed(src);
+                       break;
+
+               default:
+                       return FALSE;
+                       break;
+       }
+
+       return TRUE;
+}
+
+
+static void _tcore_util_marshal_remove_value(gpointer value)
+{
+       unsigned int gtype = 0;
+       GHashTable *ht = NULL;
+
+       gtype = ((GValue *) value)->g_type;
+       if (gtype == G_TYPE_HASH_TABLE) {
+               ht = g_value_get_boxed(value);
+               g_hash_table_destroy(ht);
+       }
+
+       g_value_unset((GValue *) value);
+       return;
+}
+
+static gboolean _tcore_util_marshal_convert_str_to_type(GValue *src,
+               GValue *dest, unsigned int dest_type)
+{
+       if (dest_type == G_TYPE_HASH_TABLE)
+               dest_type = G_TYPE_BOXED;
+
+       switch (dest_type) {
+               case G_TYPE_INT: {
+                       gint64 tmp = 0;
+                       tmp = g_ascii_strtoll(g_value_get_string(src), NULL, 10);
+                       g_value_set_int(dest, tmp);
+               }
+                       break;
+               case G_TYPE_BOOLEAN: {
+                       gboolean tmp = FALSE;
+                       tmp = g_ascii_strncasecmp(g_value_get_string(src), "TRUE", 4) == 0
+                                       ? TRUE : FALSE;
+                       g_value_set_boolean(dest, tmp);
+               }
+                       break;
+               case G_TYPE_STRING: {
+                       const gchar* tmp = NULL;
+                       tmp = g_value_get_string(src);
+                       g_value_set_string(dest, tmp);
+               }
+                       break;
+               case G_TYPE_DOUBLE: {
+                       gdouble tmp = 0;
+                       tmp = g_ascii_strtod(g_value_get_string(src), NULL);
+                       g_value_set_double(dest, tmp);
+               }
+                       break;
+               case G_TYPE_BOXED: {
+                       GHashTable* tmp;
+                       tmp = tcore_util_marshal_deserialize_string(g_value_get_string(src));
+                       g_value_set_boxed(dest, tmp);
+               }
+                       break;
+               default: {
+                       return FALSE;
+               }
+                       break;
+       }
+
+       return TRUE;
+}
+
+TReturn tcore_util_netif_up(const char *name)
+{
+       int ret;
+       int fd;
+       struct ifreq ifr;
+
+       if (!name)
+               return TCORE_RETURN_EINVAL;
+
+       if (strlen(name) > IFNAMSIZ)
+               return TCORE_RETURN_EINVAL;
+
+       fd = socket(AF_INET, SOCK_DGRAM, 0);
+       if (fd < 0) {
+               return TCORE_RETURN_FAILURE;
+       }
+
+       memset(&ifr, 0, sizeof(struct ifreq));
+       strncpy(ifr.ifr_name, name, IFNAMSIZ);
+       ifr.ifr_name[IFNAMSIZ - 1] = '\0';
+
+       ret = ioctl(fd, SIOCGIFFLAGS, &ifr);
+       if (ret < 0) {
+               close(fd);
+               return TCORE_RETURN_FAILURE;
+       }
+
+       ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
+
+       ret = ioctl(fd, SIOCSIFFLAGS, &ifr);
+       if (ret < 0) {
+               close(fd);
+               return TCORE_RETURN_FAILURE;
+       }
+
+       close(fd);
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_util_netif_down(const char *name)
+{
+       int ret;
+       int fd;
+       struct ifreq ifr;
+
+       if (!name)
+               return TCORE_RETURN_EINVAL;
+
+       if (strlen(name) > IFNAMSIZ)
+               return TCORE_RETURN_EINVAL;
+
+       fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
+       if (fd < 0) {
+               return TCORE_RETURN_FAILURE;
+       }
+
+       memset(&ifr, 0, sizeof(struct ifreq));
+       strncpy(ifr.ifr_name, name, IFNAMSIZ);
+       ifr.ifr_name[IFNAMSIZ - 1] = '\0';
+
+
+       ret = ioctl(fd, SIOCGIFFLAGS, &ifr);
+       if (ret < 0) {
+               close(fd);
+               return TCORE_RETURN_FAILURE;
+       }
+
+       ifr.ifr_flags &= ~(IFF_UP | IFF_RUNNING);
+
+       ret = ioctl(fd, SIOCSIFFLAGS, &ifr);
+       if (ret < 0) {
+               close(fd);
+               return TCORE_RETURN_FAILURE;
+       }
+
+       close(fd);
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_util_netif_set(const char *name, const char *ipaddr,
+               const char *gateway, const char *netmask)
+{
+       int ret;
+       int fd;
+       struct ifreq ifr;
+       struct sockaddr_in sai;
+
+       if (!name)
+               return TCORE_RETURN_EINVAL;
+
+       if (strlen(name) > IFNAMSIZ)
+               return TCORE_RETURN_EINVAL;
+
+       fd = socket(AF_INET, SOCK_DGRAM, 0);
+       if (fd < 0) {
+               return TCORE_RETURN_FAILURE;
+       }
+
+       sai.sin_family = AF_INET;
+       sai.sin_port = 0;
+       memset(&ifr, 0, sizeof(struct ifreq));
+
+       if (ipaddr) {
+               dbg("ip = [%s]", ipaddr);
+               if (!inet_aton(ipaddr, &sai.sin_addr)) {
+                       close(fd);
+                       return TCORE_RETURN_FAILURE;
+               }
+
+               strncpy(ifr.ifr_name, name, IFNAMSIZ);
+               ifr.ifr_name[IFNAMSIZ - 1] = '\0';
+               memcpy(&ifr.ifr_addr, &sai, sizeof(sai));
+
+               ret = ioctl(fd, SIOCSIFADDR, &ifr);
+               if (ret < 0) {
+                       close(fd);
+                       return TCORE_RETURN_FAILURE;
+               }
+       }
+
+       if (gateway) {
+               dbg("gateway = [%s]", gateway);
+               if (!inet_aton(gateway, &sai.sin_addr)) {
+                       close(fd);
+                       return TCORE_RETURN_FAILURE;
+               }
+
+               strncpy(ifr.ifr_name, name, IFNAMSIZ);
+               ifr.ifr_name[IFNAMSIZ - 1] = '\0';
+               memcpy(&ifr.ifr_dstaddr, &sai, sizeof(sai));
+
+               ret = ioctl(fd, SIOCSIFDSTADDR, &ifr);
+               if (ret < 0) {
+                       close(fd);
+                       return TCORE_RETURN_FAILURE;
+               }
+       }
+
+       if (netmask) {
+               dbg("netmask = [%s]", netmask);
+               if (!inet_aton(netmask, &sai.sin_addr)) {
+                       close(fd);
+                       return TCORE_RETURN_FAILURE;
+               }
+
+               strncpy(ifr.ifr_name, name, IFNAMSIZ);
+               ifr.ifr_name[IFNAMSIZ - 1] = '\0';
+               memcpy(&ifr.ifr_netmask, &sai, sizeof(sai));
+
+               ret = ioctl(fd, SIOCSIFNETMASK, &ifr);
+               if (ret < 0) {
+                       close(fd);
+                       return TCORE_RETURN_FAILURE;
+               }
+       }
+
+       close(fd);
+       return TCORE_RETURN_SUCCESS;
+}
+
+char *tcore_util_get_string_by_ip4type(union tcore_ip4_type ip)
+{
+       char buf[16]; /* 'nnn'*4 + '.'*3 + '\0' */
+
+       snprintf(buf, 16, "%d.%d.%d.%d", ip.s[0], ip.s[1], ip.s[2], ip.s[3]);
+
+       return strdup(buf);
+}
+
+enum tcore_dcs_type tcore_util_get_cbs_coding_scheme(unsigned char encode)
+{
+       enum tcore_dcs_type dcs = TCORE_DCS_TYPE_NONE;
+
+       switch (encode & 0xf0)
+       {
+               case 0x00:
+               case 0x20:
+               case 0x30:
+                       dcs = TCORE_DCS_TYPE_7_BIT;
+                       break;
+
+               case 0x10:
+                       if ((encode & 0x0f) == 0x00)
+                               dcs = TCORE_DCS_TYPE_7_BIT;
+                       else if ((encode & 0x0f) == 0x01)
+                               dcs = TCORE_DCS_TYPE_8_BIT; //should be re-defined
+                       else
+                               dcs = TCORE_DCS_TYPE_UNSPECIFIED;
+                       break;
+
+               case 0x40:
+               case 0x50:
+               case 0x60:
+               case 0x70: // 01xx
+                       if ((encode & 0x0c) == 0x00)
+                               dcs = TCORE_DCS_TYPE_7_BIT;
+                       else if ((encode & 0x0c) == 0x04)
+                               dcs = TCORE_DCS_TYPE_8_BIT;
+                       else if ((encode & 0x0c) == 0x08)
+                               dcs = TCORE_DCS_TYPE_UCS2;
+                       else if ((encode & 0x0c) == 0x0c)
+                               dcs = TCORE_DCS_TYPE_UNSPECIFIED;
+                       break;
+
+               case 0x90: // 1001
+                       if ((encode & 0x0c) == 0x00)
+                               dcs = TCORE_DCS_TYPE_7_BIT;
+                       else if ((encode & 0x0c) == 0x04)
+                               dcs = TCORE_DCS_TYPE_8_BIT;
+                       else if ((encode & 0x0c) == 0x08)
+                               dcs = TCORE_DCS_TYPE_UCS2;
+                       else if ((encode & 0x0c) == 0x0c)
+                               dcs = TCORE_DCS_TYPE_UNSPECIFIED;
+                       break;
+
+               case 0x80: // 1000
+               case 0xA0:
+               case 0xB0:
+               case 0xC0:
+               case 0xD0: // 1010 .. 1101
+               case 0xE0: // 0x1110
+                       break;
+
+               case 0xF0:
+                       if ((encode & 0x04) == 0x00)
+                               dcs = TCORE_DCS_TYPE_7_BIT;
+                       else if ((encode & 0x04) == 0x01)
+                               dcs = TCORE_DCS_TYPE_8_BIT;
+                       break;
+       }
+
+       return dcs;
+}
+
+char *tcore_util_unpack_gsm7bit(const char *src, unsigned int src_len)
+{
+       char *dest;
+       int i = 0;
+       unsigned int pos = 0;
+       unsigned char shift = 0;
+       int outlen = 0;
+
+       if (!src || src_len == 0) {
+               return NULL;
+       }
+
+       outlen = (src_len * 8) / 7;
+
+       dest = calloc(outlen + 1, 1);
+       if (!dest)
+               return NULL;
+
+       for (i = 0; pos < src_len; i++, pos++) {
+               dest[i] = (src[pos] << shift) & 0x7F;
+
+               if (pos != 0) {
+                       /* except the first byte, a character contains some bits from the previous byte.*/
+                       dest[i] |= src[pos - 1] >> (8 - shift);
+               }
+
+               shift++;
+
+               if (shift == 7) {
+                       shift = 0;
+
+                       /* a possible extra complete character is available */
+                       i++;
+                       dest[i] = src[pos] >> 1;
+               }
+       }
+
+       /*If a character is '\r'(13), change it to space(32) */
+       for (i = 0; i < outlen; i++)
+               if (dest[i] == '\r')
+                       dest[i] = ' ';
+
+       dest[outlen] = '\0';
+
+       return dest;
+}
+
+char *tcore_util_pack_gsm7bit(const char* src, unsigned int src_len)
+{
+       char *dest;
+       unsigned int i = 0;
+       unsigned int pos = 0, shift = 0;
+       unsigned int outlen = 0;
+
+       if (!src || src_len == 0) {
+               return NULL;
+       }
+
+       outlen = ((src_len * 7) / 8) + 1;
+
+       dest = calloc(outlen + 1, 1);
+       if (!dest)
+               return NULL;
+
+       for (pos = 0, i = 0; i < src_len; pos++, i++) {
+               if ( pos >= outlen ) {
+                       return NULL;
+               }
+
+               /* pack the low bits */
+               dest[pos] = src[i] >> shift;
+
+               if (i + 1 < src_len) {
+                       /* pack the high bits using the low bits of the next character */
+                       dest[pos] |= src[i + 1] << (7 - shift);
+
+                       shift++;
+
+                       if (shift == 7) {
+                               shift = 0;
+                               i++;
+                       }
+               }
+               else {
+                       if (shift == 6)
+                               dest[pos] |= 0x1a;
+               }
+       }
+
+       return dest;
+}
+
+GHashTable *tcore_util_marshal_create()
+{
+       GHashTable *ht = NULL;
+
+       ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+                       _tcore_util_marshal_remove_value);
+
+       return ht;
+}
+
+void tcore_util_marshal_destory(GHashTable *ht)
+{
+       if (!ht)
+               return;
+
+       g_hash_table_destroy(ht);
+}
+
+
+GHashTable *tcore_util_marshal_deserialize_string(const gchar *serialized_string)
+{
+       int index = 0;
+       gchar **tuple = NULL;
+       GHashTable *ht = NULL;
+
+       ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+                       _tcore_util_marshal_remove_value);
+
+       if (strlen(serialized_string) == 0) {
+               return ht;
+       }
+
+       tuple = g_strsplit((gchar *) serialized_string, "/", 0);
+
+       while (strlen(tuple[index]) > 3) {
+               int tmp = 0;
+               guchar *content = NULL;
+               gchar **inner_tuple = NULL;
+               GValue *src = g_new0(GValue, 1);
+               GValue *dest = g_new0(GValue, 1);
+               unsigned int type = 0;
+
+               inner_tuple = g_strsplit(tuple[index], ":", 0);
+               type = atoi(inner_tuple[1]);
+               content = g_base64_decode(inner_tuple[2], (gsize *)&tmp);
+
+               g_value_init(src, G_TYPE_STRING);
+               g_value_init(dest, type);
+
+               g_value_set_string(src, (const gchar *)content);
+               _tcore_util_marshal_convert_str_to_type(src, dest, type);
+               g_hash_table_insert(ht, g_strdup(inner_tuple[0]), dest);
+
+               g_free(content);
+               g_strfreev(inner_tuple);
+               index++;
+       }
+
+       g_strfreev(tuple);
+       return ht;
+}
+
+gchar *tcore_util_marshal_serialize(GHashTable *ht)
+{
+       gchar *rv_str = NULL;
+       GHashTableIter iter;
+       gpointer key, value;
+       GString *gstring_tmp = NULL;
+
+       gstring_tmp = g_string_new(NULL);
+       g_hash_table_iter_init(&iter, ht);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               unsigned int gtype = 0;
+               gchar *tmp = NULL, *encoded_d = NULL;
+               GValue gval = { 0,{ { 0 } } };
+
+               g_value_init(&gval, G_TYPE_STRING);
+
+               gtype = ((GValue *) value)->g_type;
+               if (gtype != G_TYPE_HASH_TABLE) {
+                       g_value_transform((GValue *) value, &gval);
+                       tmp = g_value_dup_string(&gval);
+               }
+               else {
+                       GHashTable *sub_ht;
+                       sub_ht = g_value_get_boxed((GValue *) value);
+                       tmp = tcore_util_marshal_serialize(sub_ht);
+               }
+
+               encoded_d = g_base64_encode((guchar *)tmp, (gsize)strlen(tmp));
+               g_free(tmp);
+
+               g_string_append_printf(gstring_tmp, "%s:%d:%s/", (gchar *)key,
+                               gtype, encoded_d);
+               g_free((gpointer)encoded_d);
+               g_value_unset(&gval);
+       }
+
+       rv_str = g_strdup(gstring_tmp->str);
+       g_string_free(gstring_tmp, TRUE);
+
+       return rv_str;
+}
+
+gboolean tcore_util_marshal_add_data(GHashTable *ht, const gchar *key,
+               const void *data, enum tcore_util_marshal_data_type type)
+{
+       gboolean rv = FALSE;
+       GValue *value;
+
+       if (!ht || !key || !data)
+               return FALSE;
+
+       if (type >= 0xff)
+               return FALSE;
+
+       value = g_new0(GValue, 1);
+
+       rv = _tcore_util_marshal_create_gvalue(value, data, type);
+
+       if (!rv)
+               return FALSE;
+
+       g_hash_table_insert(ht, g_strdup(key), value);
+
+       return TRUE;
+}
+
+gboolean tcore_util_marshal_get_data(GHashTable *ht, const gchar *key,
+               void **data, enum tcore_util_marshal_data_type type)
+{
+       gboolean rv = FALSE;
+       gpointer value;
+
+       if (!ht || !key || !data)
+               return FALSE;
+
+       value = g_hash_table_lookup(ht, key);
+
+       rv = _tcore_util_return_value((GValue *) value, data, type);
+       if (!rv)
+               return FALSE;
+
+       return TRUE;
+}
+
+gint tcore_util_marshal_get_int(GHashTable *ht, const gchar *key)
+{
+       gboolean rv = FALSE;
+       gint rvalue, *tmp = NULL;
+
+       if (!ht || !key)
+               return 0;
+
+       rv = tcore_util_marshal_get_data(ht, key, (void **) &tmp,
+                       TCORE_UTIL_MARSHAL_DATA_INT_TYPE);
+       if (!rv)
+               return 0;
+
+       if (!tmp)
+               return 0;
+
+       rvalue = *tmp;
+       g_free(tmp);
+
+       return rvalue;
+}
+
+gchar *tcore_util_marshal_get_string(GHashTable *ht, const gchar *key)
+{
+       gboolean rv = FALSE;
+       gchar *rvalue = NULL;
+
+       if (!ht || !key)
+               return 0;
+
+       rv = tcore_util_marshal_get_data(ht, key, (void **) &rvalue,
+                       TCORE_UTIL_MARSHAL_DATA_STRING_TYPE);
+       if (!rv)
+               return NULL;
+
+       return rvalue;
+}
+
+GHashTable *tcore_util_marshal_get_object(GHashTable *ht, const gchar *key)
+{
+       gboolean rv = FALSE;
+       GHashTable *rvalue = NULL;
+
+       if (!ht || !key)
+               return 0;
+
+       rv = tcore_util_marshal_get_data(ht, key, (void **) &rvalue,
+                       TCORE_UTIL_MARSHAL_DATA_OBJECT_TYPE);
+       if (!rv)
+               return NULL;
+
+       return rvalue;
+}
diff --git a/tcore.pc.in b/tcore.pc.in
new file mode 100644 (file)
index 0000000..243c454
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@PREFIX@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: tcore
+Description: SLP Telephony core API
+Version: 1.0
+Libs: -L${libdir} -ltcore -ldl
+Cflags: -I${includedir}/tcore
+