Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:52:07 +0000 (01:52 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:52:07 +0000 (01:52 +0900)
91 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/at.h [new file with mode: 0644]
include/co_call.h [new file with mode: 0644]
include/co_context.h [new file with mode: 0644]
include/co_gps.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/mux.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/gps.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/udev.h [new file with mode: 0644]
include/user_request.h [new file with mode: 0644]
include/util.h [new file with mode: 0644]
libtcore.manifest [new file with mode: 0644]
packaging/0001-hal-Add-set_sound_path-function.patch [new file with mode: 0644]
packaging/0002-hal-Add-new-entry-points-and-method-declarations.patch [new file with mode: 0644]
packaging/0003-hal-Add-new-method-definitions.patch [new file with mode: 0644]
packaging/0004-mux-Declare-new-public-API-for-HAL-plugin-manipulati.patch [new file with mode: 0644]
packaging/0005-mux-Remove-plateform-dependencies-from-core-multiple.patch [new file with mode: 0644]
packaging/0006-notification-Add-new-notifcation-type.patch [new file with mode: 0644]
packaging/0007-at-Add-Connect-to-success-responses.patch [new file with mode: 0644]
packaging/0008-hal-Add-new-setup_pdp-entry-point-declaration-and-DA.patch [new file with mode: 0644]
packaging/0009-hal-Add-tcore_hal_setup_pdp-definition-and-mana-DATA.patch [new file with mode: 0644]
packaging/0010-mux-Initialize-setup_pdp-entry-point.patch [new file with mode: 0644]
packaging/libtcore.spec [new file with mode: 0644]
src/at.c [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_gps.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/mux.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/udev.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..4359bc9
--- /dev/null
@@ -0,0 +1,72 @@
+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 gudev-1.0)
+
+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_TLOG_DEBUG")
+ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"TCORE\"")
+ADD_DEFINITIONS("-DTCORE_VERSION=\"${VERSION}\"")
+
+MESSAGE(${CMAKE_C_FLAGS})
+MESSAGE(${CMAKE_EXE_LINKER_FLAGS})
+
+SET(SRCS
+               src/server.c
+               src/plugin.c
+               src/hal.c
+               src/at.c
+               src/udev.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
+               src/co_gps.c
+               src/mux.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)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME libtcore)
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..4a3c5d8
--- /dev/null
@@ -0,0 +1,201 @@
+libtcore (0.1.23) unstable; urgency=low
+
+  * Replace dun_pin_ctrl from ps to modem
+  * Git: slp/pkgs/l/libtcore
+  * Tag: libtcore_0.1.23
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Mon, 11 Jun 2012 14:32:10 +0900
+
+libtcore (0.1.22) unstable; urgency=low
+
+  * Add phonebook selection feature
+  * Git: slp/pkgs/l/libtcore
+  * Tag: libtcore_0.1.22
+
+ -- Youngman Park <youngman.park@samsung.com>  Tue, 22 May 2012 11:57:45 +0900
+
+libtcore (0.1.21) unstable; urgency=low
+
+  * Add sat proactive command
+  * Fix user_request_dup
+  * Git: slp/pkgs/l/libtcore
+  * Tag: libtcore_0.1.21
+
+ -- Inho Oh <inho48.oh@samsung.com>  Tue, 22 May 2012 10:47:29 +0900
+
+libtcore (0.1.20) unstable; urgency=low
+
+  * add req,resp type for getting sim lock info
+  * Git: slp/pkgs/l/libtcore
+  * Tag: libtcore_0.1.20
+
+ -- Kyeongchul Kim <kyeongchul.kim@samsung.com>  Thu, 17 May 2012 17:35:34 +0900
+
+libtcore (0.1.19) unstable; urgency=low
+
+  * Fix SPN in NO-SIM state
+  * Add HSUPA, HSPA
+  * Git: slp/pkgs/l/libtcore
+  * Tag: libtcore_0.1.19
+
+ -- Inho Oh <inho48.oh@samsung.com>  Thu, 10 May 2012 11:00:05 +0900
+
+libtcore (0.1.18) unstable; urgency=low
+
+  * Fix OBS build error
+  * Git: slp/pkgs/l/libtcore
+  * Tag: libtcore_0.1.18
+
+ -- Youngman Park <youngman.park@samsung.com>  Tue, 08 May 2012 16:17:01 +0900
+
+libtcore (0.1.17) unstable; urgency=low
+
+  * Add Call New API ( call custom service )
+  * Git: slp/pkgs/l/libtcore
+  * Tag: libtcore_0.1.17
+
+ -- Youngman Park <youngman.park@samsung.com>  Mon, 07 May 2012 17:40:01 +0900
+
+libtcore (0.1.16) unstable; urgency=low
+
+  * Add pending timeout
+  * Git: slp/pkgs/l/libtcore
+  * Tag: libtcore_0.1.16
+
+ -- Inho Oh <inho48.oh@samsung.com>  Thu, 03 May 2012 15:12:01 +0900
+
+libtcore (0.1.15) unstable; urgency=low
+
+  * Fix typo bug & network icon info type
+  * Git: slp/pkgs/l/libtcore
+  * Tag: libtcore_0.1.15
+
+ -- Inho Oh <inho48.oh@samsung.com>  Tue, 24 Apr 2012 14:24:50 +0900
+
+libtcore (0.1.14) unstable; urgency=low
+
+  * Fix ip string bug
+  * Git: slp/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: slp/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: slp/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: slp/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: slp/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: slp/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: slp/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: slp/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: slp/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: slp/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: slp/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 the HSDPA Noti
+  * Git: slp/pkgs/l/libtcore
+  * Tag: libtcore_0.1.3
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Mon, 19 Mar 2012 14:44:45 +0900
+
+libtcore (0.1.2) unstable; urgency=low
+
+  * Add Code for Video Call 
+  * Git: slp/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: slp/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: slp/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: slp/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..dd6dabe
--- /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 the Apache License, Version 2.0 (the "License");
+
+You may obtain a copy of the License at
+http://www.apache.org/licenses/LICENSE-2.0.
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/at.h b/include/at.h
new file mode 100644 (file)
index 0000000..e4f8abf
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * 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_AT_H__
+#define __TCORE_AT_H__
+
+__BEGIN_DECLS
+
+#include <tcore.h>
+#include <queue.h>
+
+enum tcore_at_command_type {
+    TCORE_AT_NO_RESULT,   /* no intermediate response expected */
+    TCORE_AT_NUMERIC,     /* a single intermediate response starting with a 0-9 */
+    TCORE_AT_SINGLELINE,  /* a single intermediate response starting with a prefix */
+    TCORE_AT_MULTILINE,   /* multiple line intermediate response starting with a prefix */
+    TCORE_AT_PDU
+};
+
+enum ATCMEError{
+       AT_ERROR_MOBILE_FAILRURE                                        =0,
+       AT_ERROR_NOT_CONNECTED_TO_PHONE         =1,
+       AT_ERROR_LINK_RESERVED                                  =2,
+       AT_ERROR_OPER_NOT_ALLOWED                               =3,
+       AT_ERROR_OPER_NOT_SUPPORTED                     =4,
+       AT_ERROR_PH_SIM_PIN_REQUIRED                    =5,
+       AT_ERROR_PH_FSIM_PIN_REQUIRED                   =6,
+       AT_ERROR_PH_FSIM_PUK_REQUIRED                   =7,
+
+       AT_ERROR_SIM_NOT_INSERTED                               =10,
+       AT_ERROR_SIM_PIN_REQUIRED                               =11,
+       AT_ERROR_SIM_PUK_REQUIRED                               =12,
+       AT_ERROR_SIM_FAILURE                                            =13,
+       AT_ERROR_SIM_BUSY                                                       =14,
+       AT_ERROR_SIM_WRONG                                              =15,
+       AT_ERROR_INCORRECT_PWD                                  =16,
+       AT_ERROR_SIM_PIN2_REQUIRED                              =17,
+       AT_ERROR_SIM_PUK2_REQUIRED                              =18,
+
+       AT_ERROR_MEMORY_FULL                                            =20,
+       AT_ERROR_INVALID_INDEX                                  =21,
+       AT_ERROR_NOT_FOUND                                              =22,
+       AT_ERROR_MEMORY_FAILURE                                 =23,
+       AT_ERROR_TEXT_TOO_LONG                                  =24,
+       AT_ERROR_INVALID_CHAR_IN_STR                    =25,
+       AT_ERROR_DIAL_TOO_LONG                                  =26,
+       AT_ERROR_INVALID_CHAR_IN_DIAL                   =27,
+
+       AT_ERROR_NO_NETWORK_SVC                                 =30,
+       AT_ERROR_NETWORK_TIMEOUT                                =31,
+       AT_ERROR_EMERGENCY_CALL_ONLY                    =32,
+
+       AT_ERROR_NET_PERSONAL_PIN_REQ                   =40,
+       AT_ERROR_NET_PERSONAL_PUN_REQ                   =41,
+       AT_ERROR_NET_SUB_PERSONAL_PIN_REQ               =42,
+       AT_ERROR_NET_SUB_PERSONAL_PUK_REQ               =43,
+       AT_ERROR_PROVIDER_PERSONAL_PIN_REQ              =44,
+       AT_ERROR_PROVIDER_PERSONAL_PUK_REQ              =45,
+       AT_ERROR_CORP_PERSONAL_PIN_REQ                  =46,
+       AT_ERROR_CORP_PERSONAL_PUK_REQ                  =47,
+       AT_ERROR_HIDDEN_KEY_REQUIRED                    =48,
+       AT_ERROR_EAP_METHOD_NOT_SUPPORTED               =49,
+       AT_ERROR_INCORRECT_PARAM                                =50,
+
+       AT_ERROR_UNKNOWN                                                        =100
+};
+
+
+struct tcore_at_request {
+       char *cmd;
+       char *next_send_pos;
+       char *prefix;
+       enum tcore_at_command_type type;
+};
+
+struct tcore_at_response {
+       int success; /* true if final response indicates success (eg "OK") */
+       char *final_response; /* eg OK, ERROR */
+       GSList *lines; /* any intermediate responses */
+};
+
+typedef gboolean (*TcoreATNotificationCallback)(TcoreAT *at, const GSList *lines,
+               void *user_data);
+
+typedef struct tcore_at_response TcoreATResponse;
+typedef struct tcore_at_request TcoreATRequest;
+
+TcoreAT*         tcore_at_new(TcoreHal *hal);
+void             tcore_at_free(TcoreAT *at);
+
+TReturn          tcore_at_buf_write(TcoreAT *at, unsigned int data_len,
+                     const char *data);
+
+TReturn          tcore_at_set_request(TcoreAT *at, TcoreATRequest *req, gboolean send);
+TcoreATRequest*  tcore_at_get_request(TcoreAT *at);
+TcoreATResponse* tcore_at_get_response(TcoreAT *at);
+
+TReturn          tcore_at_add_notification(TcoreAT *at, const char *prefix,
+                     gboolean pdu, TcoreATNotificationCallback callback,
+                     void *user_data);
+TReturn          tcore_at_remove_notification(TcoreAT *at, const char *prefix,
+                     TcoreATNotificationCallback callback);
+TReturn          tcore_at_remove_notification_full(TcoreAT *at,
+                     const char *prefix,
+                     TcoreATNotificationCallback callback, void *user_data);
+
+TcoreATRequest*  tcore_at_request_new(const char *cmd, const char *prefix,
+                     enum tcore_at_command_type type);
+void             tcore_at_request_free(TcoreATRequest *req);
+
+gboolean         tcore_at_process(TcoreAT *at, unsigned int data_len,
+                     const char *data);
+
+TcorePending*    tcore_at_pending_new(CoreObject *co, const char *cmd,
+                     const char *prefix, enum tcore_at_command_type type,
+                     TcorePendingResponseCallback func, void *user_data);
+
+GSList*          tcore_at_tok_new(const char *line);
+void             tcore_at_tok_free(GSList *tokens);
+char*            tcore_at_tok_extract(const char *src);
+char*            tcore_at_tok_nth(GSList *tokens, unsigned int token_index);
+
+
+__END_DECLS
+
+#endif
diff --git a/include/co_call.h b/include/co_call.h
new file mode 100644 (file)
index 0000000..f0459f6
--- /dev/null
@@ -0,0 +1,246 @@
+/*
+ * 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_sound_recording)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_sound_equalization)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_sound_noise_reduction)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_sound_clock_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, TcoreHal *hal);
+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..64aeca2
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * 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,
+       CONTEXT_ROLE_PREPAID_INTERNET,
+       CONTEXT_ROLE_PREPAID_MMS,
+       CONTEXT_ROLE_TETHERING,
+       CONTEXT_ROLE_USER_DEFINED,
+};
+
+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, TcoreHal *hal);
+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_profile_name(CoreObject *o, const char *profile_name);
+char*                    tcore_context_get_profile_name(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_gps.h b/include/co_gps.h
new file mode 100644 (file)
index 0000000..9cc5b10
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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_GPS_H__
+#define __TCORE_CO_GPS_H__
+
+#include <core_object.h>
+
+__BEGIN_DECLS
+
+
+struct tcore_gps_operations {
+       TReturn (*confirm_measure_pos)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_frequency_aiding)(CoreObject *o, UserRequest *ur);
+};
+
+CoreObject*  tcore_gps_new(TcorePlugin *p, const char *name, struct tcore_gps_operations *ops, TcoreHal *hal);
+void         tcore_gps_free(CoreObject *o);
+
+__END_DECLS
+
+#endif
diff --git a/include/co_modem.h b/include/co_modem.h
new file mode 100644 (file)
index 0000000..c9ce420
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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);
+       TReturn (*get_sn)(CoreObject *o, UserRequest *ur);
+       TReturn (*dun_pin_ctrl)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_flight_mode)(CoreObject *o, UserRequest *ur);
+};
+
+
+CoreObject*      tcore_modem_new(TcorePlugin *p, const char *name, struct tcore_modem_operations *ops, TcoreHal *hal);
+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..d866f04
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * 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_UNKNOWN,
+       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);
+       TReturn (*set_mode)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_mode)(CoreObject *o, UserRequest *ur);
+       TReturn (*set_neighboring_cell_info)(CoreObject *o, UserRequest *ur);
+       TReturn (*get_neighboring_cell_info)(CoreObject *o, UserRequest *ur);
+};
+
+
+CoreObject* tcore_network_new(TcorePlugin *plugin, const char *name,
+                struct tcore_network_operations *ops, TcoreHal *hal);
+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..8cefb1b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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, TcoreHal *hal);
+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);
+
+enum tel_phonebook_type tcore_phonebook_get_selected_type(CoreObject *o);
+gboolean tcore_phonebook_set_selected_type(CoreObject *o, enum tel_phonebook_type t);
+
+__END_DECLS
+
+#endif
diff --git a/include/co_ps.h b/include/co_ps.h
new file mode 100644 (file)
index 0000000..8cf2fe5
--- /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_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 (*define_context)(CoreObject *co_ps, CoreObject *context, void *user_data);
+       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, TcoreHal *hal);
+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_define_context(CoreObject *o, CoreObject *context, void *user_data);
+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..a8a3fab
--- /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, TcoreHal *hal);
+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..ad9f35a
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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_display_text_tlv display_text;
+               struct tel_sat_get_inkey_tlv get_inkey;
+               struct tel_sat_get_input_tlv get_input;
+               struct tel_sat_more_time_tlv more_time;
+               struct tel_sat_play_tone_tlv play_tone;
+               struct tel_sat_setup_menu_tlv setup_menu;
+               struct tel_sat_select_item_tlv select_item;
+               struct tel_sat_send_sms_tlv send_sms;
+               struct tel_sat_send_ss_tlv send_ss;
+               struct tel_sat_send_ussd_tlv send_ussd;
+               struct tel_sat_setup_call_tlv setup_call;
+               struct tel_sat_refresh_tlv refresh;
+               struct tel_sat_provide_local_info_tlv provide_local_info;
+               struct tel_sat_setup_event_list_tlv setup_event_list;
+               struct tel_sat_setup_idle_mode_text_tlv setup_idle_mode_text;
+               struct tel_sat_send_dtmf_tlv send_dtmf;
+               struct tel_sat_language_notification_tlv language_notification;
+               struct tel_sat_launch_browser_tlv launch_browser;
+               struct tel_sat_open_channel_tlv open_channel;
+               struct tel_sat_close_channel_tlv close_channel;
+               struct tel_sat_receive_channel_tlv receive_data;
+               struct tel_sat_send_channel_tlv send_data;
+               struct tel_sat_get_channel_status_tlv get_channel_status;
+/*
+               TelSatRefreshIndInfo_t refresh;
+               TelSatProvideLocalInfoIndInfo_t provideLocInfo;
+               TelSatLaunchBrowserIndInfo_t launchBrowser;
+               TelSatSetupIdleModeTextIndInfo_t idleText;
+               TelSatSendDtmfIndInfo_t sendDtmf;
+               TelSatLanguageNotificationIndInfo_t languageNotification;
+               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, TcoreHal *hal);
+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..611f8de
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * 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 (*get_lock_info)(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, TcoreHal *hal);
+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);
+
+struct tel_sim_service_table* tcore_sim_get_service_table(CoreObject *o);
+gboolean tcore_sim_set_service_table(CoreObject *o, struct tel_sim_service_table *svct);
+
+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);
+char*             tcore_sim_encode_lp(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);
+char*             tcore_sim_encode_li(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);
+char*             tcore_sim_encode_xdn(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_mwis(struct tel_sim_mw *pMwis, unsigned char *p_in, int in_length);
+char*             tcore_sim_encode_mwis(int *out_length, const struct tel_sim_mw *pMwis);
+gboolean             tcore_sim_decode_vmwf(struct tel_sim_cphs_mw *p_vmwf,     unsigned char* p_in, unsigned long in_length);
+char*             tcore_sim_encode_vmwf(int *out_length, const struct tel_sim_cphs_mw *p_vmwf);
+gboolean             tcore_sim_decode_cfis(struct tel_sim_cfis *cfis, unsigned char *p_in, int in_length);
+char*             tcore_sim_encode_cfis(int *out_length, const struct tel_sim_cfis *p_cfis);
+gboolean             tcore_sim_decode_cff(struct tel_sim_cphs_cf *cfis, unsigned char *p_in, int in_length);
+char*                tcore_sim_encode_cff(const struct tel_sim_cphs_cf *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_dynamic_flag(struct tel_sim_cphs_dflag *p_df, 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_decode_dynamic2_flag(struct tel_sim_cphs_dflag2 *p_d2f, unsigned char *p_in, int in_length);
+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(unsigned char *p_out, unsigned char *p_in, int in_length);
+gboolean             tcore_sim_decode_ons(unsigned char *p_out, 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..576ef76
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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     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);
+};
+
+
+int         _tcore_util_sms_encode_smsParameters(const struct telephony_sms_Params *incoming, unsigned char *data, int SMSPRecordLen);
+gboolean    tcore_sms_get_ready_status(CoreObject *o);
+gboolean    tcore_sms_set_ready_status(CoreObject *o, int status);
+CoreObject* tcore_sms_new(TcorePlugin *p, const char *name, struct tcore_sms_operations *ops, TcoreHal *hal);
+void        tcore_sms_free(CoreObject * n);
+
+__END_DECLS
+
+#endif
+
diff --git a/include/co_ss.h b/include/co_ss.h
new file mode 100644 (file)
index 0000000..ca809ac
--- /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.
+ */
+
+#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, TcoreHal *hal);
+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 );
+void                                   tcore_ss_ussd_set_session_data( struct ussd_session* ussd_s, void* data, int data_len );
+
+__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..0f07e55
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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_TYPE_GPS           (CORE_OBJECT_TYPE_DEFAULT | TCORE_TYPE_GPS)
+
+#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 (*CoreObjectCloneHook)(CoreObject *src, CoreObject *dest);
+typedef gboolean (*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, TcoreHal *hal);
+void             tcore_object_free(CoreObject *co);
+
+TReturn          tcore_object_set_free_hook(CoreObject *co, CoreObjectFreeHook free_hook);
+TReturn          tcore_object_set_clone_hook(CoreObject *co, CoreObjectCloneHook clone_hook);
+
+CoreObject*      tcore_object_clone(CoreObject *src, TcorePlugin *new_parent, const char *new_name);
+
+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_set_hal(CoreObject *co, TcoreHal *hal);
+TcoreHal*        tcore_object_get_hal(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..d93795a
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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
+};
+
+enum tcore_hal_mode {
+       TCORE_HAL_MODE_UNKNOWN,
+       TCORE_HAL_MODE_AT,
+       TCORE_HAL_MODE_CUSTOM,
+    TCORE_HAL_MODE_TRANSPARENT
+};
+
+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,
+                 enum tcore_hal_mode mode);
+void         tcore_hal_free(TcoreHal *hal);
+
+TReturn      tcore_hal_set_name(TcoreHal *hal, const char *name);
+char*        tcore_hal_get_name(TcoreHal *hal);
+
+TcoreAT*     tcore_hal_get_at(TcoreHal *hal);
+enum tcore_hal_mode tcore_hal_get_mode(TcoreHal *hal);
+TReturn      tcore_hal_set_mode(TcoreHal *hal, enum tcore_hal_mode mode);
+
+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 *pending);
+TReturn      tcore_hal_send_force(TcoreHal *hal);
+
+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..3be554b
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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 info(fmt,args...)  { RLOG(LOG_INFO, TCORE_LOG_TAG, fmt "\n", ##args); }
+#define msg(fmt,args...)  { RLOG(LOG_DEBUG, 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); }
+
+#elif defined(FEATURE_TLOG_DEBUG)
+
+#ifndef TCORE_LOG_TAG
+#define TCORE_LOG_TAG "UNKNOWN"
+#endif
+
+enum tcore_log_type {
+       TCORE_LOG_TYPE_MAIN = 0,
+       TCORE_LOG_TYPE_RADIO,
+       TCORE_LOG_TYPE_SYSTEM
+};
+
+enum tcore_log_priority {
+       TCORE_LOG_UNKNOWN = 0,
+       TCORE_LOG_DEFAULT,
+       TCORE_LOG_VERBOSE,
+       TCORE_LOG_DEBUG,
+       TCORE_LOG_INFO,
+       TCORE_LOG_WARN,
+       TCORE_LOG_ERROR,
+       TCORE_LOG_FATAL,
+       TCORE_LOG_SILENT
+};
+
+/*
+ * Virtual log function.
+ * Daemon should implement the actual content. (printrf/file writing/...)
+ */
+void tcore_log(enum tcore_log_type type, enum tcore_log_priority priority, const char *tag, const char *fmt, ...);
+
+#define info(fmt,args...)  { tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_INFO, TCORE_LOG_TAG, fmt "\n", ##args); }
+#define msg(fmt,args...)  { tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_DEBUG, TCORE_LOG_TAG, fmt "\n", ##args); }
+#define dbg(fmt,args...)  { tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_DEBUG, TCORE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); }
+#define warn(fmt,args...)  { tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_WARN, TCORE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); }
+#define err(fmt,args...)  { tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_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
+
+#ifndef TCORE_LOG_FUNC
+#define TCORE_LOG_FUNC fprintf
+#endif
+
+#define info(fmt,args...)  TCORE_LOG_FUNC(TCORE_LOG_FILE, fmt "\n", ##args); fflush(TCORE_LOG_FILE);
+#define msg(fmt,args...)  TCORE_LOG_FUNC(TCORE_LOG_FILE, fmt "\n", ##args); fflush(TCORE_LOG_FILE);
+#define dbg(fmt,args...)  TCORE_LOG_FUNC(TCORE_LOG_FILE, ANSI_COLOR_LIGHTGRAY "<%s:%s> " ANSI_COLOR_NORMAL fmt "\n", __FILE__, __FUNCTION__, ##args); fflush(TCORE_LOG_FILE);
+#define warn(fmt,args...) TCORE_LOG_FUNC(TCORE_LOG_FILE, ANSI_COLOR_YELLOW "<%s:%s> " ANSI_COLOR_NORMAL fmt "\n", __FILE__, __FUNCTION__, ##args); fflush(TCORE_LOG_FILE);
+#define err(fmt,args...)  TCORE_LOG_FUNC(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/mux.h b/include/mux.h
new file mode 100644 (file)
index 0000000..1b11776
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Arijit Sen <arijit.sen@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 __MUX_H__
+#define __MUX_H__
+
+TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal);
+void    tcore_cmux_close(void);
+int     tcore_cmux_rcv_from_hal(unsigned char *data, size_t length);
+
+#endif  /* __MUX_H__ */
diff --git a/include/plugin.h b/include/plugin.h
new file mode 100644 (file)
index 0000000..f4eded2
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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_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..796da23
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * 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(TcoreHal *hal);
+void          tcore_queue_free(TcoreQueue *qeueu);
+
+TReturn       tcore_queue_push(TcoreQueue *queue, TcorePending *pending);
+TcorePending* tcore_queue_pop(TcoreQueue *queue);
+TcorePending* tcore_queue_pop_by_pending(TcoreQueue *queue, TcorePending *pending);
+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);
+TcoreHal*     tcore_queue_ref_hal(TcoreQueue *queue);
+TReturn       tcore_queue_cancel_pending_by_command(TcoreQueue *queue, enum tcore_request_command command);
+TcorePending* tcore_queue_search_by_command(TcoreQueue *queue, enum tcore_request_command command, gboolean flag_sent);
+
+__END_DECLS
+
+#endif
diff --git a/include/server.h b/include/server.h
new file mode 100644 (file)
index 0000000..1f9a305
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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_link_udev(Server *s, TcoreUdev *udev);
+TcoreUdev*    tcore_server_ref_udev(Server *s);
+
+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..d3974c9
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * 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_TELEPHONY_READY,
+       STORAGE_KEY_SETAPPL_STATE_DATA_ROAMING_BOOL,
+       STORAGE_KEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_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,
+       STORAGE_KEY_LANGUAGE_SET,
+       STORAGE_KEY_FLIGHT_MODE_BOOL,
+       STORAGE_KEY_IDLE_SCREEN_LAUNCHED_BOOL,
+};
+
+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..82867d2
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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>
+#include <type/gps.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;
+typedef struct tcore_at_type TcoreAT;
+typedef struct tcore_udev_type TcoreUdev;
+
+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..129abca
--- /dev/null
@@ -0,0 +1,642 @@
+/*
+ * 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 {
+       CALL_ERROR_NONE,                                        /**< Success  */
+       CALL_ERROR_ACCESSDISCARD,                       /**< Access discarded  */
+       CALL_ERROR_BARR_BYOPERATOR,                     /**< Barred by operator */
+       CALL_ERROR_BEARERMODE_NOTIMPL,          /**< Bearer mode not implemented */
+       CALL_ERROR_BEARERMODE_RESTRICTED,       /**< Bearer mode restricted */
+       CALL_ERROR_BEARERMODE_UNAUTH,           /**< Bearer mode un authorized */
+       CALL_ERROR_BEARERMODE_UNAVAIL,          /**< Bearer mode not available */
+       CALL_ERROR_BUSY,                                        /**< (Network/Server) busy */
+       CALL_ERROR_CALLMETER_EXPIRED,           /**< Call meter expired */
+       CALL_ERROR_CALLNO_ERROR,                        /**< Call number error */
+       CALL_ERROR_CKTUNAVAIL,                          /**< Circuit channel unavailable */                     //10
+       CALL_ERROR_CONGESTION,                          /**< Congestion happened */
+       CALL_ERROR_NO_CIRCUIT_AVAIL,            /**< Circuit  not available */
+       CALL_ERROR_DESTIN_INCOMPAT,                     /**< Destination incompatibility */
+       CALL_ERROR_DTMF_NOSPEECH,                       /**< No speech in DTMF */
+       CALL_ERROR_DTMF_REJECTED,                       /**< DTMF rejected */
+       CALL_ERROR_FACILITY_NOTIMPL,            /**< Facility not implemented */
+       CALL_ERROR_FACILITY_NOTSUBSCRIBED,      /**< Facility not subscribed */
+       CALL_ERROR_INCOMINGCUGCALLS_BARRED, /**< Incoming CUG Calls barred */
+       CALL_ERROR_INVALNUM,                            /**< Invalid number */
+       CALL_ERROR_MPTY_ERROR,                          /**< Multiparty error */                                                //20
+       CALL_ERROR_NOANSWER,                            /**< No answer  */
+       CALL_ERROR_NONCUGMEMBER,                        /**< Non CUG member */
+       CALL_ERROR_NUMBERCHANGED,                       /**< Number changed */
+       CALL_ERROR_NUMBER_ERROR,                        /**< Number error */
+       CALL_ERROR_NWFAILURE,                           /**< Network failure */
+       CALL_ERROR_OPERATIONUNAVAIL,            /**< Operation not available */
+       CALL_ERROR_OUTOFORDER,                          /**< Out of order */
+       CALL_ERROR_PROTOCOL_ERROR,                      /**< Protocol error */
+       CALL_ERROR_QOSUNAVAIL,                          /**< QOS unavailable */
+       CALL_ERROR_REJECT,                                      /**< Rejected */                                                                //30
+       CALL_ERROR_REJ_FAIL,                            /**< Rejection failed */
+       CALL_ERROR_REJ_SRVC_NOT_AVL,            /**< Rejection service not available  */
+       CALL_ERROR_REMOTE_CKTUNAVAIL,           /**< Remote Circuit channel unavailable */
+       CALL_ERROR_RESOURCEUNAVAIL,                     /**< Resource not available */
+       CALL_ERROR_SERVICEID_ERROR,                     /**< Service id error */
+       CALL_ERROR_SERVICE_NOTIMPL,                     /**< Service not implemented */
+       CALL_ERROR_SERVICE_UNAVAIL,                     /**< Service not available */
+       CALL_ERROR_MODIFY_SAME_BEARER,          /**< Modify same bearer */
+       CALL_ERROR_MODIFY_NOT_PERMITTED,        /**< Modification not permitted */
+       CALL_ERROR_HOLD_FAIL,                           /**< Call hold fail */                                                  //40
+       CALL_ERROR_TEMPFAILURE,                         /**< Temporary failure */
+       CALL_ERROR_WRONGNUM,                            /**< Wrong number */
+       CALL_ERROR_NORMAL_UNSPECIFIED,          /**< Normal but unspecified */
+       CALL_ERROR_SSERRINVALIDTIVALUE,         /**< SS invalid Transaction ID Value */
+       CALL_ERROR_SSERRINVALIDTI,                      /**< SS Invalid transaction ID */
+       CALL_ERROR_SSINCOMPATIBLESTATE,         /**< SS incompatible state */
+       CALL_ERROR_SSERRSYNTAXERROR,            /**< SS syntax error */
+       CALL_ERROR_SSPROTOCOLERROR,                     /**< Protocol error */
+       CALL_ERROR_SSNEGATIVEPASSWORDCHECK, /**< Negative password check */
+       CALL_ERROR_SSSENTASPHASE1,                      /**< SS sent as phase1 message */                               //50
+       CALL_ERROR_SSERROR,                                     /**< Supplementary service error */
+       CALL_ERROR_SS_USSD_BUSY,                        /**< Second USSD request will be rejected when already USSD transaction is ongoing. */
+       CALL_ERROR_IDLE,                                        /**< Idle */
+       CALL_ERROR_NETWORK_SPECIFIC,            /**< Network specific error */
+       CALL_ERROR_FADE,                                        /**< voice call was dropped e.g. because of a loss of signal */
+       CALL_ERROR_UNKNOWN,                                     /**< unknown no details available */
+       CALL_ERROR_INCOM_CALL,                          /**< terminated by incoming call */
+       CALL_ERROR_ALERT_STOP,                          /**< terminated by alert stop */
+       CALL_ERROR_INTERCEPT,                           /**< voice call was dropped by interception */
+       CALL_ERROR_REORDER,                                     /**< voice call was dropped by reordering */    //60
+       CALL_ERROR_CLIENT_END,                          /**< client ended the call */
+       CALL_ERROR_ACCESS_CLASS_BLOCKED,        /**< access class blocked */
+       CALL_ERROR_MEMCAPEXCEEDED,                      /**< Memory capacity exceeded */
+       CALL_ERROR_TYPENOTSUPPORTED,            /**< Type not supported */
+       CALL_ERROR_REPLACENOTSUPPORTED,         /**< Replace not supported */
+       CALL_ERROR_PROTOCOLID_ERROR,            /**< Protocol id error */
+       CALL_ERROR_CLASSNOTSUPPORTED,           /**< Class not supported */
+       CALL_ERROR_DATACODING_ERROR,            /**< Data coding error */
+       CALL_ERROR_INVAL_MSG,                           /**< Invalid message */
+       CALL_ERROR_CALL_BARRED,                 /**< Call barred */                                                     //70
+       CALL_ERROR_SIM_CALL_CONTROL_CHANGED_TO_SS,              /**< Sim call control changed to SS */
+       CALL_ERROR_SIM_CALL_CONTROL_CHANGED_TO_CALL,    /**< SIM Call control changed to call */
+       CALL_ERROR_SIM_ERROR,                           /**< SIM error */
+       CALL_ERROR_SIM_CALL_CONTROL_MODIFIED,                   /**< SIM call control modified */
+       CALL_ERROR_RANDOM_ACCESS_FAILURE,       /**< Random access error */
+       CALL_ERROR_LOWER_LAYER_FAILURE,         /**< Lower layer error */
+       CALL_ERROR_ACCESS_REJECTED,                     /**< Access rejected */
+       CALL_ERROR_RESET_NOT_ALLOWED,           /**< Reset not allowed */
+       CALL_ERROR_EMERGENCY_CALL_NOT_ALLOWED,                  /**< Emergency call not allowed */
+       CALL_ERROR_ACCESS_NOT_ALLOWED,          /**< Access not allowed */                                              //80
+       CALL_ERROR_RADIO_LINK_FAILURE,          /**< Radio link failure */
+       CALL_ERROR_INVALID_IDENTITY,            /**< Invalid identity */
+       CALL_ERROR_UNKNOWN_IDENTITY,            /**< Unknown identity */
+       CALL_ERROR_UNACCEPTABLE_IDENTITY,       /**< Un acceptable identity */
+       CALL_ERROR_NO_SERVICE_HERE,                     /**< No service here */
+       CALL_ERROR_SERVICE_NOT_ALLOWED,         /**< Service not allowed */
+       CALL_ERROR_SERVICE_NOT_AVAIL,           /**< Service not available */
+       CALL_ERROR_SERVICE_NOT_WORKING,         /**< Service not working */
+       CALL_ERROR_CANNOT_IDENTIFY_CALL,        /**< Cannot identify the call */
+       CALL_ERROR_DEACTIVATION,                        /**< Deactivation */                                                    //90
+       CALL_ERROR_FATAL_ERROR,                         /**< Fatal error */
+       CALL_ERROR_SEND_DTMF_SUCCESS,           /**< Sending DTMF Success */
+       CALL_ERROR_SEND_DTMF_FAIL,                      /**< Sending DTMF Failed */
+       CALL_ERROR_FIXED_DIALING_NUMBER_ONLY,/**< Fixed Dialing Number Only */
+       CALL_ERROR_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_ringback_tone_status {
+       CALL_SOUND_RINGBACK_TONE_START,
+       CALL_SOUND_RINGBACK_TONE_END,
+};
+
+enum telephony_call_sound_direction {
+       CALL_SOUND_DIRECTION_LEFT,
+       CALL_SOUND_DIRECTION_RIGHT,
+};
+
+/**********
+  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_active {
+       unsigned int id;
+};
+
+struct treq_call_hold {
+       unsigned int id;
+};
+
+struct treq_call_swap {
+       unsigned int id;
+};
+
+struct treq_call_join {
+       unsigned int id;
+};
+
+struct treq_call_split {
+       unsigned int id;
+};
+
+struct treq_call_transfer {
+       unsigned int id;
+};
+
+struct treq_call_deflect {
+       unsigned int id;
+       char number[MAX_CALL_NUMBER_LEN];
+};
+
+struct treq_call_sound_set_path {
+       enum telephony_call_sound_path path;
+       gboolean extra_volume_on;
+};
+
+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;
+};
+
+struct treq_call_sound_set_recording {
+       gboolean state;
+};
+
+#define MAX_CALL_EQ_PARAMETER_SIZE 6
+struct treq_call_sound_set_equalization {
+       gboolean mode;
+       enum telephony_call_sound_direction direction;
+       unsigned short parameter[ MAX_CALL_EQ_PARAMETER_SIZE ];
+};
+
+struct treq_call_sound_set_noise_reduction {
+       gboolean status;
+};
+
+struct treq_call_sound_set_clock_status {
+       gboolean status;
+};
+
+
+// Response
+
+struct tresp_call_dial {
+       enum telephony_call_error err;
+};
+
+struct tresp_call_answer {
+       unsigned int id;
+       enum telephony_call_error err;
+};
+
+struct tresp_call_end {
+       enum telephony_call_end_type type;
+       unsigned int id;
+       enum telephony_call_error err;
+};
+
+struct tresp_call_hold {
+       unsigned int id;
+       enum telephony_call_error err;
+};
+
+struct tresp_call_active {
+       unsigned int id;
+       enum telephony_call_error err;
+};
+
+struct tresp_call_swap {
+       unsigned int id;
+       enum telephony_call_error err;
+};
+
+struct tresp_call_join {
+       unsigned int id;
+       enum telephony_call_error err;
+};
+
+struct tresp_call_split {
+       unsigned int id;
+       enum telephony_call_error err;
+};
+
+struct tresp_call_deflect {
+       unsigned int id;
+       enum telephony_call_error err;
+};
+
+struct tresp_call_transfer {
+       unsigned int id;
+       enum telephony_call_error err;
+};
+
+struct tresp_call_dtmf {
+       enum telephony_call_error err;
+};
+
+struct tresp_call_sound_set_path {
+       gboolean err;
+};
+
+struct tresp_call_sound_set_volume_level {
+       gboolean err;
+};
+
+struct tresp_call_sound_get_volume_level {
+       int record_num;
+       struct volume_info {
+               enum telephony_call_sound_type sound;
+               enum telephony_call_sound_volume_level volume;
+       } *record;
+       gboolean err;
+};
+
+struct tresp_call_mute {
+       gboolean err;
+};
+
+struct tresp_call_unmute {
+       gboolean err;
+};
+
+struct tresp_call_get_mute_status {
+       int status;
+       gboolean err;
+};
+
+struct tresp_call_sound_set_recording {
+       gboolean err;
+};
+
+struct tresp_call_sound_set_equalization {
+       gboolean err;
+};
+
+struct tresp_call_sound_set_noise_reduction {
+       gboolean err;
+};
+
+struct tresp_call_sound_set_clock_status {
+       gboolean err;
+};
+
+
+// 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;
+};
+
+struct tnoti_call_sound_path {
+       enum telephony_call_sound_path path;
+};
+
+struct tnoti_call_sound_ringback_tone {
+       enum telephony_call_sound_ringback_tone_status status;
+};
+
+struct tnoti_call_sound_wbamr {
+       gboolean status;
+};
+
+struct tnoti_call_sound_equalization {
+       gboolean mode;
+       enum telephony_call_sound_direction direction;
+};
+
+struct tnoti_call_sound_noise_reduction {
+       gboolean status;
+};
+
+struct tnoti_call_sound_clock_status {
+       gboolean status;
+};
+
+
+__END_DECLS
+
+#endif
diff --git a/include/type/common.h b/include/type/common.h
new file mode 100644 (file)
index 0000000..0da05b2
--- /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_ENODATA = ENODATA, /* No data available */
+
+       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/gps.h b/include/type/gps.h
new file mode 100644 (file)
index 0000000..f20e487
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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_GPS_H__
+#define __TYPE_GPS_H__
+
+__BEGIN_DECLS
+
+struct treq_gps_set_frequency_aiding {
+       unsigned char enable;
+};
+
+struct tresp_gps_set_frequency_aiding {
+       TReturn result;
+};
+
+struct tnoti_gps_frequency_aiding {
+       unsigned char lock_status;
+       unsigned char afc_update;
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/type/modem.h b/include/type/modem.h
new file mode 100644 (file)
index 0000000..b60532b
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * 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,
+};
+
+enum modem_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 modem_dun_pincontrol_status {
+       DUN_PINCONTROL_STATUS_OFF = 0x00,
+       DUN_PINCONTROL_STATUS_ON = 0x01,
+};
+
+struct treq_modem_power_on {
+};
+
+struct treq_modem_power_off {
+};
+
+struct treq_modem_power_reset {
+};
+
+struct treq_modem_set_flightmode {
+       int enable;
+};
+
+struct treq_modem_get_flightmode {
+};
+
+struct treq_modem_get_imei {
+};
+
+struct treq_modem_get_version {
+};
+
+struct treq_modem_get_sn {
+};
+
+struct treq_modem_set_dun_pin_control {
+       enum modem_dun_pincontrol_signal signal;
+       enum modem_dun_pincontrol_status status;
+};
+
+
+struct tresp_modem_power_on {
+       TReturn result;
+};
+
+struct tresp_modem_power_off {
+       TReturn result;
+};
+
+struct tresp_modem_power_reset {
+       TReturn result;
+};
+
+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[33];
+       char hardware[33];
+       char calibration[33];
+       char product_code[33];
+};
+
+struct tresp_modem_get_sn {
+       TReturn result;
+       char sn[13];
+};
+
+struct tresp_modem_set_dun_pin_control {
+       int result;
+};
+
+struct tnoti_modem_power {
+       enum modem_state state;
+};
+
+struct tnoti_modem_flight_mode {
+       int enable;
+};
+
+struct tnoti_modem_dun_pin_control {
+       enum modem_dun_pincontrol_signal signal;
+       enum modem_dun_pincontrol_status status;
+};
+
+struct tnoti_modem_dun_external_call {
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/type/network.h b/include/type/network.h
new file mode 100644 (file)
index 0000000..6111cc4
--- /dev/null
@@ -0,0 +1,406 @@
+/*
+ * 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
+
+#define NETWORK_GERAN_NEIGHBORING_CELL_LIST_MAX 6              /**<    max count of GERAN neighboring cell list        */
+#define NETWORK_UMTS_NEIGHBORING_CELL_LIST_MAX 24              /**<    max count of UMTS neighboring cell list         */
+
+#define NETWORK_MODE_AUTO  0x00
+#define NETWORK_MODE_GSM   0x01
+#define NETWORK_MODE_WCDMA 0x02
+#define NETWORK_MODE_CDMA  0x04
+#define NETWORK_MODE_LTE   0x08
+
+#define NETWORK_RESTRICTED_STATE_NONE           0x00 /* No restriction at all including voice/SMS/USSD/SS/AV64 and packet data. */
+#define NETWORK_RESTRICTED_STATE_CS_EMERGENCY   0x01 /* Block emergency call due to restriction. But allow all normal voice/SMS/USSD/SS/AV64. */
+#define NETWORK_RESTRICTED_STATE_CS_NORMAL      0x02 /* Block all normal voice/SMS/USSD/SS/AV64 due to restriction. Only Emergency call allowed. */
+#define NETWORK_RESTRICTED_STATE_CS_ALL         0x04 /* Block all voice/SMS/USSD/SS/AV64 including emergency call due to restriction.*/
+#define NETWORK_RESTRICTED_STATE_PS_ALL         0x10 /* Block packet data access due to restriction. */
+
+enum telephony_network_select_mode {
+       NETWORK_SELECT_MODE_AUTOMATIC = 0x01,
+       NETWORK_SELECT_MODE_MANUAL = 0x02
+};
+
+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,
+       NETWORK_SERVICE_TYPE_LTE
+};
+
+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,
+       NETWORK_BAND_TYPE_LTE_BAND_4,
+       NETWORK_BAND_TYPE_LTE_BAND_17
+};
+
+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,
+       NETWORK_ORDER_LTE_FIRST = 0x05
+};
+
+enum telephony_network_icon_info_type {
+       NETWORK_ICON_INFO_RSSI = 0x01,
+       NETWORK_ICON_INFO_BATTERY = 0x02,
+       NETWORK_ICON_INFO_HDR_RSSI = 0x04,
+       NETWORK_ICON_INFO_ALL = 0xFF
+};
+
+struct tel_network_geran_neighboring_cell_info{
+       int cell_id;
+       int lac;
+       int bcch;
+       int bsic;
+       int rxlev;
+};
+
+struct tel_network_umts_neighboring_cell_info{
+       int cell_id;
+       int lac;
+       int arfcn;
+       int psc;
+       int rscp;
+};
+
+struct tel_network_neighboring_cell_info{
+       int geran_list_count;
+       struct tel_network_geran_neighboring_cell_info geran_list[NETWORK_GERAN_NEIGHBORING_CELL_LIST_MAX];
+       int umts_list_count;
+       struct tel_network_umts_neighboring_cell_info umts_list[NETWORK_UMTS_NEIGHBORING_CELL_LIST_MAX];
+};
+
+
+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 treq_network_set_mode {
+       int mode;
+};
+struct treq_network_get_mode { /* no data */
+};
+struct treq_network_set_neighboring_cell_info {
+       int enable;
+};
+struct treq_network_get_neighboring_cell_info { /* no data */
+};
+
+
+struct tresp_network_search {
+       TReturn result;
+       int list_count;
+       struct {
+               enum telephony_network_plmn_status  status;
+               char name[17];
+               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 {
+       TReturn result;
+       enum telephony_network_select_mode mode;
+};
+
+struct tresp_network_set_service_domain {
+       TReturn result;
+};
+
+struct tresp_network_get_service_domain {
+       TReturn result;
+       enum telephony_network_service_domain domain;
+};
+
+struct tresp_network_set_band {
+       TReturn result;
+};
+
+struct tresp_network_get_band {
+       TReturn result;
+       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 {
+       TReturn result;
+       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 {
+       TReturn result;
+       enum telephony_network_acquisition_order order;
+};
+
+struct tresp_network_set_power_on_attach {
+       TReturn result;
+};
+
+struct tresp_network_get_power_on_attach {
+       TReturn result;
+       int enabled;
+};
+
+struct tresp_network_set_cancel_manual_search {
+       TReturn result;
+};
+
+struct tresp_network_get_serving_network {
+       TReturn result;
+       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_zone;
+               int pilot_pn;
+       } cdma;
+};
+
+struct tresp_network_set_mode {
+       TReturn result;
+};
+
+struct tresp_network_get_mode {
+       TReturn result;
+       int mode;
+};
+
+struct tresp_network_set_neighboring_cell_info {
+       TReturn result;
+};
+
+struct tresp_network_get_neighboring_cell_info {
+       TReturn result;
+       struct tel_network_neighboring_cell_info info;
+};
+
+
+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 {
+       enum telephony_network_icon_info_type 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_zone;
+               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];
+};
+
+struct tnoti_network_neighboring_cell_info {
+       struct tel_network_neighboring_cell_info info;
+};
+
+struct tnoti_network_restricted_state {
+       int restricted_state;
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/type/notification.h b/include/type/notification.h
new file mode 100644 (file)
index 0000000..3fa9520
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * 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_CALL_SOUND_PATH,
+       TNOTI_CALL_SOUND_RINGBACK_TONE,
+       TNOTI_CALL_SOUND_WBAMR,
+       TNOTI_CALL_SOUND_EQUALIZATION,
+       TNOTI_CALL_SOUND_NOISE_REDUCTION,
+       TNOTI_CALL_SOUND_CLOCK_STATUS,
+
+       TNOTI_SS = TCORE_NOTIFICATION | TCORE_TYPE_SS,
+       TNOTI_SS_INFO,
+       TNOTI_SS_USSD,
+       TNOTI_SS_RELEASE_COMPLETE,
+
+       TNOTI_MODEM = TCORE_NOTIFICATION | TCORE_TYPE_MODEM,
+       TNOTI_MODEM_POWER,
+       TNOTI_MODEM_FLIGHT_MODE,
+       TNOTI_MODEM_DUN_PIN_CONTROL,
+       TNOTI_MODEM_DUN_EXTERNAL_CALL,
+
+       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_NETWORK_NEIGHBORING_CELL_INFO,
+       TNOTI_NETWORK_RESTRICTED_STATE,
+
+       TNOTI_PS = TCORE_NOTIFICATION | TCORE_TYPE_PS,
+       TNOTI_PS_CALL_STATUS,
+       TNOTI_PS_CURRENT_SESSION_DATA_COUNTER,
+       TNOTI_PS_PDP_IPCONFIGURATION,
+       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_SMS_ETWS_INCOM_MSG,               /* This is an unsolicited Incoming ETWS message*/
+
+       TNOTI_PHONEBOOK = TCORE_NOTIFICATION | TCORE_TYPE_PHONEBOOK,
+       TNOTI_PHONEBOOK_STATUS,
+
+       TNOTI_GPS = TCORE_NOTIFICATION | TCORE_TYPE_GPS,
+       TNOTI_GPS_ASSIST_DATA,
+       TNOTI_GPS_MEASURE_POSITION,
+       TNOTI_GPS_RESET_ASSIST_DATA,
+       TNOTI_GPS_FREQUENCY_AIDING_DATA,
+
+       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..f7dd90c
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * 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>
+#define PHONEBOOK_NAME_BYTE_MAX                256
+#define PHONEBOOK_NUMBER_BYTE_MAX      256
+#define PHONEBOOK_EMAIL_BYTE_MAX       256
+
+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 with bit 8 set to 0 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, Under DF 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[PHONEBOOK_NAME_BYTE_MAX+1];          // +1 is for Null termination
+       unsigned short name_len;
+       enum tel_phonebook_dcs dcs;
+
+       unsigned char number[PHONEBOOK_NUMBER_BYTE_MAX+1];      // +1 is for Null termination
+       enum tel_phonebook_ton ton;
+
+       /* following fields are valid in only USIM*/
+       unsigned char sne[PHONEBOOK_NAME_BYTE_MAX+1];           // +1 is for Null termination
+       unsigned short sne_len;
+       enum tel_phonebook_dcs sne_dcs;
+
+       unsigned char anr1[PHONEBOOK_NUMBER_BYTE_MAX+1];        // +1 is for Null termination
+       enum tel_phonebook_ton anr1_ton;
+       unsigned char anr2[PHONEBOOK_NUMBER_BYTE_MAX+1];        // +1 is for Null termination
+       enum tel_phonebook_ton anr2_ton;
+       unsigned char anr3[PHONEBOOK_NUMBER_BYTE_MAX+1];        // +1 is for Null termination
+       enum tel_phonebook_ton anr3_ton;
+
+       unsigned char email1[PHONEBOOK_EMAIL_BYTE_MAX+1];       // +1 is for Null termination
+       unsigned short email1_len;
+       unsigned char email2[PHONEBOOK_EMAIL_BYTE_MAX+1];       // +1 is for Null termination
+       unsigned short email2_len;
+       unsigned char email3[PHONEBOOK_EMAIL_BYTE_MAX+1];       // +1 is for Null termination
+       unsigned short email3_len;
+       unsigned char email4[PHONEBOOK_EMAIL_BYTE_MAX+1];       // +1 is for Null termination
+       unsigned short email4_len;
+
+       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 tel_phonebook_usim_meta {
+       enum tel_phonebook_field_type field;
+       unsigned short index_max;
+       unsigned short text_max;
+       unsigned short used_count;
+};
+
+struct tresp_phonebook_get_usim_info {
+       enum tel_phonebook_result result;
+       int field_count;
+       struct tel_phonebook_usim_meta field_list[13]; //supported fields are 13 currently.
+};
+
+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[PHONEBOOK_NAME_BYTE_MAX+1];          // +1 is for Null termination
+       unsigned short name_len;
+       enum tel_phonebook_dcs dcs;
+
+       unsigned char number[PHONEBOOK_NUMBER_BYTE_MAX+1];      // +1 is for Null termination
+       enum tel_phonebook_ton ton;
+
+       /* following fields are valid in only USIM*/
+       unsigned char sne[PHONEBOOK_NAME_BYTE_MAX+1];           // +1 is for Null termination
+       unsigned short sne_len;
+       enum tel_phonebook_dcs sne_dcs;
+
+       unsigned char anr1[PHONEBOOK_NUMBER_BYTE_MAX+1];        // +1 is for Null termination
+       enum tel_phonebook_ton anr1_ton;
+       unsigned char anr2[PHONEBOOK_NUMBER_BYTE_MAX+1];        // +1 is for Null termination
+       enum tel_phonebook_ton anr2_ton;
+       unsigned char anr3[PHONEBOOK_NUMBER_BYTE_MAX+1];        // +1 is for Null termination
+       enum tel_phonebook_ton anr3_ton;
+
+       unsigned char email1[PHONEBOOK_EMAIL_BYTE_MAX+1];       // +1 is for Null termination
+       unsigned short email1_len;
+       unsigned char email2[PHONEBOOK_EMAIL_BYTE_MAX+1];       // +1 is for Null termination
+       unsigned short email2_len;
+       unsigned char email3[PHONEBOOK_EMAIL_BYTE_MAX+1];       // +1 is for Null termination
+       unsigned short email3_len;
+       unsigned char email4[PHONEBOOK_EMAIL_BYTE_MAX+1];       // +1 is for Null termination
+       unsigned short email4_len;
+
+       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..e816f9b
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * 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_protocol_status {
+       TELEPHONY_HSDPA_OFF = 0x00,
+       TELEPHONY_HSDPA_ON = 0x01,
+       TELEPHONY_HSUPA_ON = 0x02,
+       TELEPHONY_HSPA_ON = 0x03,
+};
+
+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 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_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..fda44d2
--- /dev/null
@@ -0,0 +1,213 @@
+/*
+ * 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_MODEM_GET_SN,
+       TREQ_MODEM_SET_DUN_PIN_CONTROL,
+
+       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_SOUND_RECORDING,
+       TREQ_CALL_SET_SOUND_EQUALIZATION,
+       TREQ_CALL_SET_SOUND_NOISE_REDUCTION,
+       TREQ_CALL_SET_SOUND_CLOCK_STATUS,
+
+       TREQ_CALL_SET_ACTIVE_LINE,
+       TREQ_CALL_GET_ACTIVE_LINE,
+       TREQ_CALL_ACTIVATE_CCBS,
+       TREQ_CALL_CUSTOM_SERVICE,
+
+       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_SET_MAILBOX,
+       TREQ_SIM_GET_CALLFORWARDING,
+       TREQ_SIM_SET_CALLFORWARDING,
+       TREQ_SIM_GET_MESSAGEWAITING,
+       TREQ_SIM_SET_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_NETNAME,
+       TREQ_SIM_GET_OPLMNWACT,
+       TREQ_SIM_REQ_AUTHENTICATION,
+       TREQ_SIM_GET_LOCK_INFO,
+
+       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_NETWORK_SET_MODE,
+       TREQ_NETWORK_GET_MODE,
+       TREQ_NETWORK_SET_NEIGHBORING_CELL_INFO,
+       TREQ_NETWORK_GET_NEIGHBORING_CELL_INFO,
+
+       TREQ_PS = TCORE_REQUEST | TCORE_TYPE_PS,
+       TREQ_PS_SET_PDP_ACTIVATE,
+       TREQ_PS_SET_PDP_DEACTIVATE,
+
+       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_GPS_CONFIRM_MEASURE_POS,
+       TREQ_GPS_SET_FREQUENCY_AIDING,
+
+       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..44f8676
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * 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_MODEM_GET_SN,
+       TRESP_MODEM_SET_DUN_PIN_CONTROL,
+
+       TRESP_CALL = TCORE_RESPONSE | TCORE_TYPE_CALL,
+       TRESP_CALL_DIAL,
+       TRESP_CALL_ANSWER,
+       TRESP_CALL_END,
+       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_SOUND_RECORDING,
+       TRESP_CALL_SET_SOUND_EQUALIZATION,
+       TRESP_CALL_SET_SOUND_NOISE_REDUCTION,
+       TRESP_CALL_SET_SOUND_CLOCK_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_SET_MAILBOX,
+       TRESP_SIM_GET_CALLFORWARDING,
+       TRESP_SIM_SET_CALLFORWARDING,
+       TRESP_SIM_GET_MESSAGEWAITING,
+       TRESP_SIM_SET_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_NETNAME,
+       TRESP_SIM_GET_OPLMNWACT,
+       TRESP_SIM_REQ_AUTHENTICATION,
+       TRESP_SIM_GET_LOCK_INFO,
+
+       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_NETWORK_SET_MODE,
+       TRESP_NETWORK_GET_MODE,
+       TRESP_NETWORK_SET_NEIGHBORING_CELL_INFO,
+       TRESP_NETWORK_GET_NEIGHBORING_CELL_INFO,
+
+       TRESP_PS = TCORE_RESPONSE | TCORE_TYPE_PS,
+       TRESP_PS_SET_PDP_ACTIVATE,
+       TRESP_PS_SET_PDP_DEACTIVATE,
+
+       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_GPS_SET_FREQUENCY_AIDING,
+
+       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..bdbec09
--- /dev/null
@@ -0,0 +1,1789 @@
+/*
+ * 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>
+#include <type/sim.h>
+
+#define SAT_DEF_TITLE_LEN_MAX 50 /**< max length for Menu Title */
+#define SAT_DEF_ITEM_STR_LEN_MAX 50
+
+#define SAT_TEXT_STRING_LEN_MAX 500
+#define SAT_MENU_ITEM_COUNT_MAX 40
+#define SAT_DIALING_NUMBER_LEN_MAX 200
+#define SAT_SS_STRING_LEN_MAX 160
+#define SAT_USSD_STRING_LEN_MAX 255
+#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_SMS_TPDU_SMS_DATA_LEN_MAX 175
+#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_DTMF_STRING_LEN_MAX 30      /**<   max length of dtmf string               */
+#define SAT_URL_LEN_MAX 129     /**<   max length of URL               */
+#define SAT_ITEM_TEXT_ATTRIBUTES_LIST_MAX_COUNT        50       /**<   max count of item text attributes list          */
+#define SAT_EVENT_LIST_MAX     17      /**< max count of event list */
+#define SAT_FILE_ID_LIST_MAX_COUNT 255
+#define SAT_ENVELOPE_CMD_LEN_MAX 256
+#define SAT_AID_LEN_MAX 128
+#define SAT_SUB_ADDR_LEN_MAX 30
+#define SAT_CCP_DATA_LEN_MAX 30         /**<   max length of ccp data          */
+#define SAT_URL_LEN_MAX 129     /**<   max length of url               */
+#define SAT_BEARER_LIST_MAX_COUNT 5     /**<   max count of bearer list                */
+#define SAT_PROVISIONING_REF_MAX_COUNT 10      /**<    max count of sat provisioning reference */
+#define SAT_PROVISIONING_FILE_PATH_LEN_MAX 50   /**<   max length of provisioning file path    */
+#define SAT_BEARER_PARAMS_LEN_MAX 10    /**<   max length of bearer parameters         */
+#define SAT_OTHER_ADDR_LEN_MAX 30       /**<   max length of other address             */
+#define SAT_NET_ACC_NAM_LEN_MAX 30      /**<   max length of net acc name              */
+#define SAT_REMOTE_ENTITY_ADDR_LEN_MAX 50       /**<   max length of remote entity address     */
+#define SAT_CHANNEL_DATA_STRING_LEN_MAX 255
+
+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_TYPE_END_PROACTIVE_SESSION = 0xFE,
+       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_FORMAT_SMS_DEFAULT = 0x00,
+       ALPHABET_FORMAT_8BIT_DATA = 0x01,
+       ALPHABET_FORMAT_UCS2 = 0x02,
+       ALPHABET_FORMAT_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 specific
+       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
+ */
+enum type_of_number{
+       TON_UNKNOWN = 0,                        /*< unknown */
+       TON_INTERNATIONAL = 1,          /*< international number */
+       TON_NATIONAL = 2,                       /*< national number */
+       TON_NETWORK_SPECIFIC = 3,       /*< network specific number */
+       TON_DEDICATED_ACCESS = 4,       /*< subscriber number */
+       TON_ALPHA_NUMERIC = 5,          /*< alphanumeric, GSM 7-bit default alphabet) */
+       TON_ABBREVIATED_NUMBER = 6,     /*< abbreviated number */
+       TON_RESERVED_FOR_EXT = 7        /*< reserved for extension */
+};
+
+enum numbering_plan_identifier{
+       NPI_UNKNOWN = 0,                                /*< Unknown */
+       NPI_ISDN_TEL = 1,                               /*< ISDN/Telephone numbering plan */
+       NPI_DATA_NUMBERING_PLAN = 3,    /*< Data numbering plan */
+       NPI_TELEX = 4,                                  /*< Telex numbering plan */
+       NPI_SVC_CNTR_SPECIFIC_PLAN = 5, /*< Service Center Specific plan */
+       NPI_SVC_CNTR_SPECIFIC_PLAN2 = 6,/*< Service Center Specific plan */
+       NPI_NATIONAL = 8,                               /*< National numbering plan */
+       NPI_PRIVATE = 9,                                /*< Private numbering plan */
+       NPI_ERMES_NUMBERING_PLAN = 10,  /*< ERMES numbering plan */
+       NPI_RESERVED_FOR_EXT = 0xF              /*< Reserved for extension */
+};
+
+struct tel_sat_address{
+       enum type_of_number ton;
+       enum numbering_plan_identifier npi;
+       int dialing_number_len;                                 /**< Dialing Number length */
+       char dialing_number[SAT_DIALING_NUMBER_LEN_MAX];        /**< Dialing Number*/
+};
+
+/*
+ * 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.3 Subaddress
+ */
+struct tel_sat_subaddress{
+       int subaddress_len;
+       char subaddress[SAT_SUB_ADDR_LEN_MAX];
+};
+
+/*
+ * 8.4 Capability configuration parameters
+ */
+struct tel_sat_ccp{
+       int data_len;
+       char data[SAT_CCP_DATA_LEN_MAX];
+};
+
+/*
+ * 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 vibration_alert{
+       VIBRATE_ALERT_OPTIONAL = 0, /**<        VIBRATE ALERT UPTO THE TERMINAL         */
+       VIBRATE_ALERT_REQUIRED = 1 /**< VIBRATE, IF AVAILABLE, WITH TONE.               */
+};
+
+struct tel_sat_cmd_qualifier_play_tone{
+       enum vibration_alert vibration_alert;
+};
+
+enum refresh_command{
+       REFRESH_SIM_INIT_AND_FULL_FCN = 0, /**< command qualifier for REFRESH SIM INIT AND FULL FILE CHANGE_NOTIFICATION                */
+       REFRESH_FCN = 1, /**<   command qualifier for REFRESH FILE CHANGE NOTIFICATION          */
+       REFRESH_SIM_INIT_AND_FCN = 2, /**<      command qualifier for REFRESH SIM INIT AND FILE CHANGE NOTIFICATION             */
+       REFRESH_SIM_INIT = 3, /**<      command qualifier for REFRESH SIM INIT          */
+       REFRESH_SIM_RESET = 4, /**<     command qualifier for REFRESH SIM RESET         */
+       REFRESH_3G_APPLICATION_RESET = 5, /**<  command qualifier for REFRESH 3G APPLICATION RESET              */
+       REFRESH_3G_SESSION_RESET = 6, /**<      command qualifier for REFRESH 3G SESSION RESET          */
+       REFRESH_RESERVED = 0xFF /**<    command qualifier for REFRESH RESERVED          */
+};
+
+struct tel_sat_cmd_qualifier_refresh{
+       enum refresh_command refresh;
+};
+
+enum provide_local_info_command{
+       LOCAL_INFO_LOCATION = 0,
+       LOCAL_INFO_IMEI = 1,
+       LOCAL_INFO_NMR = 2,
+       LOCAL_INFO_DATE_TIME_AND_TIMEZONE = 3,
+       LOCAL_INFO_LANGUAGE = 4,
+       LOCAL_INFO_TIMING_ADVANCE = 5,
+       LOCAL_INFO_ACT = 6,
+       LOCAL_INFO_ESN = 7,
+       LOCAL_INFO_IMEISV = 8,
+       LOCAL_INFO_MEID = 0x0B,
+       LOCAL_INFO_RESERVED = 0xFF
+};
+
+struct tel_sat_cmd_qualifier_provide_local_info{
+       enum provide_local_info_command provide_local_info;
+};
+
+enum setup_call_command{
+       SETUP_CALL_IF_ANOTHER_CALL_NOT_BUSY = 0x00, /**<        command qualifier for SETUP CALL IF ANOTHER CALL NOT BUSY               */
+       SETUP_CALL_IF_ANOTHER_CALL_NOT_BUSY_WITH_REDIAL = 0x01, /**<    command qualifier for SETUP CALL IF ANOTHER CALL NOT BUSY WITH REDIAL           */
+       SETUP_CALL_PUT_ALL_OTHER_CALLS_ON_HOLD = 0x02, /**<     command qualifier for SETUP CALL PUTTING ALL OTHER CALLS ON HOLD                */
+       SETUP_CALL_PUT_ALL_OTHER_CALLS_ON_HOLD_WITH_REDIAL = 0x03, /**< command qualifier for SETUP CALL PUTTING ALL OTHER CALLS ON HOLD WITH REDIAL            */
+       SETUP_CALL_DISCONN_ALL_OTHER_CALLS = 0x04, /**< command qualifier for SETUP CALL DISCONNECTING ALL OTHER CALLS          */
+       SETUP_CALL_DISCONN_ALL_OTHER_CALLS_WITH_REDIAL = 0x05, /**<     command qualifier for SETUP CALL DISCONNECTING ALL OTHER CALLS WITH REDIAL              */
+       SETUP_CALL_RESERVED = 0xFF /**< command qualifier for SETUP CALL RESERVED               */
+};
+
+struct tel_sat_cmd_qualifier_setup_call{
+       enum setup_call_command setup_call;
+};
+
+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_send_sms{
+       gboolean packing_by_me_required;
+};
+
+struct tel_sat_cmd_qualifier_language_notification{
+       gboolean specific_language;
+};
+
+enum launch_browser_command{
+       LAUNCH_BROWSER_IF_NOT_ALREADY_LAUNCHED = 0, /**<        command qualifier for  LAUNCH BROWSER           */
+       LAUNCH_BROWSER_NOT_USED = 1, /**<       command qualifier for  NOT USED         */
+       LAUNCH_BROWSER_USE_EXISTING_BROWSER = 2, /**<   command qualifier for  USE EXISTING BROWSER if secure session, do not use it.           */
+       LAUNCH_BROWSER_CLOSE_AND_LAUNCH_NEW_BROWSER = 3, /**<   command qualifier for CLOSE AND LAUNCH NEW BROWSER              */
+       LAUNCH_BROWSER_NOT_USED2 = 4, /**<      command qualifier for  NOT USED2                */
+       LAUNCH_BROWSER_RESERVED = 0xFF /**<     reserved        */
+};
+
+struct tel_sat_cmd_qualifier_launch_browser{
+       enum launch_browser_command launch_browser;
+};
+
+struct tel_sat_cmd_qualifier_setup_menu{
+       enum selection_preference_type select_preference;
+       gboolean help_info;
+};
+
+struct tel_sat_cmd_qualifier_open_channel{
+       gboolean immediate_link;
+       gboolean automatic_reconnection;
+       gboolean background_mode;
+};
+
+struct tel_sat_cmd_qualifier_send_data{
+       gboolean send_data_immediately;
+};
+
+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_play_tone play_tone;
+               struct tel_sat_cmd_qualifier_setup_menu setup_menu; /**<        setup menu command qualifier info       */
+               struct tel_sat_cmd_qualifier_select_item select_item;
+               struct tel_sat_cmd_qualifier_send_sms send_sms;
+               struct tel_sat_cmd_qualifier_setup_call setup_call;
+               struct tel_sat_cmd_qualifier_refresh refresh;
+               struct tel_sat_cmd_qualifier_provide_local_info provide_local_info;
+               struct tel_sat_cmd_qualifier_language_notification language_notification;
+               struct tel_sat_cmd_qualifier_launch_browser launch_browser;
+               struct tel_sat_cmd_qualifier_open_channel open_channel;
+               struct tel_sat_cmd_qualifier_send_data send_data;
+       }cmd_qualifier; /**<    Union   */
+};
+
+/*
+ * 8.7 Device identities
+ */
+enum device_identity{
+       DEVICE_ID_KEYPAD = 0x01,
+       DEVICE_ID_DISPLAY = 0x02,
+       DEVICE_ID_EARPIECE = 0x03,
+       //21-27 for channel
+       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.12 Result
+ */
+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_SUCCESS_BUT_TONE_NOT_PLAYED = 0x09, /**< command performed successfully, tone not played*/
+
+       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         */
+};
+
+enum tel_sat_user_confirm_type{
+       USER_CONFIRM_YES,                                               /**<This Enum Informs That user confirms yes */
+       USER_CONFIRM_NO_OR_CANCEL,                              /**<This enum informs that user confirms no/cancel */
+       USER_CONFIRM_HELP_INFO,                         /**<This enum informs that user wants help information */
+       USER_CONFIRM_END,                                               /**<This enum informs that user confirms end */
+       USER_CONFIRM_TIMEOUT,                                   /**<This enum informs that user did not respond */
+};
+
+enum tel_sat_call_ctrl_problem_type{
+       CC_PROBLEM_NO_SPECIFIC_CAUSE = 0, /**<  Call Control problem with no specific cause             */
+       CC_PROBLEM_ACTION_NOT_ALLOWED = 1, /**< Call Control problem with action not allowed    */
+       CC_PROBLEM_REQUEST_TYPE_HAS_CHANGED = 2 /**<    Call Control problem with request type has changed      */
+};
+
+enum ss_problem_type{
+       SATK_SS_PROBLEM_NO_SPECIFIC_CAUSE                       = 0,
+       SATK_SS_PROBLEM_FACILITY_NOT_SUPPORTED          = 0x15
+};
+
+enum ussd_problem_type{
+       SATK_USSD_PROBLEM_NO_SPECIFIC_CAUSE                     = 0,
+       SATK_USSD_PROBLEM_UNKNOWN_ALPHABET                      = 0x47
+};
+
+enum network_problem_type{
+       NETWORK_PROBLEM_NO_SPECIFIC_CAUSE = 0x0, /**<   Network problem with no specific cause          */
+       NETWORK_PROBLEM_USER_BUSY = 0x91 /**<   Network problem with USER BUSY          */
+};
+
+enum browser_problem_type{
+       BROWSER_PROBLEM_NO_SPECIFIC_CAUSE = 0, /**<     Browser problem with no specific cause          */
+       BROWSER_PROBLEM_BEARER_UNAVAILABLE = 1, /**<    Browser problem with bearer unavailable         */
+       BROWSER_PROBLEM_BROWSER_UNAVAILABLE = 2, /**<   Browser problem with browser unavailable                */
+       BROWSER_PRBLM_ME_UNABLE_TO_READ_PROV_DATA = 3 /**<      Browser problem with ME unable to read provisioning data                */
+};
+
+enum bip_problem_type{
+       BIP_PROBLEM_NO_SPECIFIC_CAUSE = 0x00, /**<      BIP problem with no specific cause      */
+       BIP_PROBLEM_NO_CHANNEL_AVAILABLE = 0x01, /**<   BIP problem with no channel available           */
+       BIP_PROBLEM_CHANNEL_CLOSED = 0x02, /**< BIP problem with channel closed         */
+       BIP_PROBLEM_CHANNEL_ID_NOT_VALID = 0x03, /**<   BIP problem with channel id not valid           */
+       BIP_PROBLEM_BUF_SIZE_NOT_AVAILABLE = 0x04, /**< BIP problem with buffer size not available              */
+       BIP_PROBLEM_SECURITY_ERROR = 0x05, /**< BIP problem with security error         */
+       BIP_PRBLM_SIM_ME_IF_TRNSPRT_LEVEL_NOT_AVL = 0x06, /**<  BIP problem with SIM ME interface transport level not available         */
+       BIP_REMOTE_DEV_NOT_REACHABLE = 0x07, /**<       BIP problem with remote device not reachable            */
+       BIP_SERVICE_ERROR = 0x08, /**<  BIP service error               */
+       BIP_SERVICE_IDENTIFIER_UNKNOWN = 0x09 /**<      BIP service identifier unknown          */
+};
+
+/*
+ * 8.13 3GPP SMS TPDU
+ */
+enum sms_tpdu_type{
+       SMS_TPDU_TYPE_DELIVER_TPDU      = 0,
+       SMS_TPDU_TYPE_DELIVER_RPT       = 1,
+       SMS_TPDU_TYPE_SUBMIT_TPDU       = 2,
+       SMS_TPDU_TYPE_SUBMIT_RPT        = 3,
+       SMS_TPDU_TYPE_STATUS_RPT        = 4,
+       SMS_TPDU_TYPE_TPDU_CMD          = 5
+};
+
+struct tel_sat_sms_tpdu{
+       enum sms_tpdu_type tpdu_type;
+       int data_len;
+       char data[SAT_SMS_TPDU_SMS_DATA_LEN_MAX];
+};
+
+/*
+ * 8.14 SS string
+ */
+struct tel_sat_ss_string{
+       enum type_of_number ton;
+       enum numbering_plan_identifier npi;
+       unsigned char string_len;                                       /**< SS string length */
+       char ss_string[SAT_SS_STRING_LEN_MAX];  /**< SS stringr*/
+};
+
+/*
+ * 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.16 TONE
+ */
+enum tone_type{
+       // standard supervisory tones
+       DIAL_TONE = 0x01, /**<  TONE TYPE DIAL TONE             */
+       CALLED_SUBSCRIBER_BUSY = 0x02, /**<     TONE TYPE CALLED SUBSCRIBER BUSY                */
+       CONGESTION = 0x03, /**< TONE TYPE CONGESTION    */
+       RADIO_PATH_ACK = 0x04, /**<     TONE TYPE RADIO PATH ACK        */
+       RADIO_PATH_NOT_AVAILABLE_CALL_DROPPED = 0x05, /**<      TONE TYPE RADIO PATH NOT AVAILABLE CALL DROPPED */
+       ERR_SPECIAL_INFO = 0x06, /**<   TONE TYPE ERR SPECIAL INFO      */
+       CALL_WAITING_TONE = 0x07, /**<  TONE TYPE CALL WAITING TONE             */
+       RINGING_TONE = 0x08, /**<       TONE TYPE RINGING TONE  */
+
+       // ME proprietary tones
+       GENERAL_BEEP = 0x10, /**<       TONE TYPE GENERAL BEEP          */
+       POSITIVE_ACK_TONE = 0x11, /**<  TONE TYPE POSITIVE ACK TONE             */
+       NEGATIVE_ACK_OR_ERROR_TONE = 0x12, /**< TONE TYPE NEGATIVE ACK OR ERROR TONE            */
+       RINGING_TONE_SLCTD_BY_USR_FOR_INCOM_SPEECH_CALL = 0x13, /**<    TONE TYPE RINGING TONE SELECTED BY USER FOR INCOMING SPEECH CALL        */
+       ALERT_TONE_SELECTED_BY_USER_FOR_INCOMING_SMS = 0x14, /**<       TONE TYPE ALERT TONE SELECTED BY USER FOR INCOMING SMS          */
+       CRITICAL_ALERT = 0x15, /**<     TONE TYPE CRITICAL ALERT                */
+
+       //Themed tones
+       HAPPY_TONE = 0x30, /**< TONE TYPE HAPPY TONE            */
+       SAD_TONE = 0x31, /**<   TONE TYPE SAD TONE                      */
+       URGENT_ACTION_TONE = 0x32, /**< TONE TYPE URGENT ACTION TONE            */
+       QUESTION_TONE = 0x33, /**<      TONE TYPE QUESTION TONE         */
+       MESSAGE_RECEIVED_TONE = 0x34, /**<      TONE TYPE MESSAGE RECEIVED TONE         */
+
+       //Melody tones
+       MELODY_1 = 0x40, /**<   TONE TYPE MELODY 1              */
+       MELODY_2 = 0x41, /**<   TONE TYPE MELODY 2              */
+       MELODY_3 = 0x42, /**<   TONE TYPE MELODY 3              */
+       MELODY_4 = 0x43, /**<   TONE TYPE MELODY 4              */
+       MELODY_5 = 0x44, /**<   TONE TYPE MELODY 5              */
+       MELODY_6 = 0x45, /**<   TONE TYPE MELODY 6              */
+       MELODY_7 = 0x46, /**<   TONE TYPE MELODY 7              */
+       MELODY_8 = 0x47, /**<   TONE TYPE MELODY 8              */
+
+       TONE_TYPE_RESERVED = 0xFF /**<  TONE TYPE RESERVED              */
+};
+
+struct tel_sat_tone{
+       enum tone_type tone_type;
+};
+
+/*
+ * 8.17 USSD string
+ */
+struct tel_sat_ussd_string{
+       struct data_coding_scheme dsc;
+       unsigned char string_len;                                       /**< USSD string length */
+       char ussd_string[SAT_USSD_STRING_LEN_MAX];      /**< USSD stringr*/
+};
+
+/*
+ * 8.18 File List
+ */
+/* use enum tel_sim_file_id in sim.h*/
+
+struct tel_sat_file_list{
+       int file_count;
+       enum tel_sim_file_id file_id[SAT_FILE_ID_LIST_MAX_COUNT];
+};
+
+/*
+ * 8.19 Location information
+ */
+struct tel_sat_location_information{
+       char mcc[3+1];
+       char mnc[3+1];
+       char lac [4+1];
+       char cell_id[4+1];
+       char extended_cell_id[4+1];
+};
+
+/*
+ * 8.20 IMEI
+ */
+struct tel_sat_imei{
+       char imei[8+1]; // length is defined by 8 in TS 102 223
+};
+
+/*
+ * 8.22 Network measurement results
+ */
+struct tel_sat_network_measurement_results{
+       char nmr[10+1]; // length is defined by 10 in TS 102 223
+};
+
+/*
+ * 8.23 Default text
+ * It is the same as Text string(8.15)
+ */
+
+/*
+ * 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.25 Event list
+ */
+enum event_list{
+       EVENT_MT_CALL = 0,
+       EVENT_CALL_CONNECTED = 1,
+       EVENT_CALL_DISCONNECTED = 2,
+       EVENT_LOCATION_STATUS = 3,
+       EVENT_USER_ACTIVITY = 4, /**<   data download type - USER_ACTIVITY              */
+       EVENT_IDLE_SCREEN_AVAILABLE = 5, /**<   data download type - IDLE SCREEN AVAILABLE              */
+       EVENT_CARD_READER_STATUS = 6,
+       EVENT_LANGUAGE_SELECTION = 7, /**<      data download type - LANGUAGE SELECTION         */
+       EVENT_BROWSER_TERMINATION = 8, /**<     data download type - BROWSER TERMINATION                */
+       EVENT_DATA_AVAILABLE = 9, /**<  data download type -DATA AVAILABLE              */
+       EVENT_CHANNEL_STATUS = 0x0A, /**<       data download type - CHANNEL STATUS             */
+       EVENT_ACCESS_TECHNOLOGY_CHANGED = 0x0B,
+       EVENT_DISPLAY_PARAMETERS_CHANGED = 0x0C,
+       EVENT_LOCAL_CONNECTION = 0x0D,
+       EVENT_NW_SEARCH_MODE_CHANGED = 0X0E,
+       EVENT_BROWSING_STATUS = 0X0F,
+       EVENT_FRAMES_INFORMATION_CHANGED = 0X10,
+       EVENT_RESERVED_FOR_3GPP = 0X11,
+       EVENT_UNKNOWN = 0xFF /**<       data download type - unknown            */
+};
+
+struct tel_sat_event_list{
+       int event_list_cnt;
+       enum event_list evt_list[SAT_EVENT_LIST_MAX];
+};
+
+/*
+ * 8.42 BC repeat indicator
+ */
+enum bc_repeat_indi_type{
+       BC_REPEAT_INDI_ALTERNATE_MODE = 0x01, /**<      BC REPEAT ALTERNATE MODE                */
+       BC_REPEAT_INDI_SEQUENTIAL_MODE = 0x03, /**<     BC REPEAT SEQUENTIAL MODE               */
+       BC_REPEAT_INDI_RESERVED = 0xFF /**<     RESERVED        */
+};
+
+struct tel_sat_repeat_indicator_type{
+       enum bc_repeat_indi_type bc_indi_repeat_type;
+};
+
+/*
+ * 8.30 Call control requested action
+ */
+struct tel_sat_call_ctrl_req_action{
+       struct tel_sat_address address;
+       struct tel_sat_ccp ccp1;
+       struct tel_sat_subaddress sub_address;
+       struct tel_sat_alpha_identifier alpha_id;
+       struct tel_sat_repeat_indicator_type bc_repeat_type;
+       struct tel_sat_ccp ccp2;
+};
+
+/*
+ * 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.39 date, time and timezone
+ */
+struct tel_sat_date_time_and_timezone{
+       unsigned char year; /**<        year    */
+       unsigned char month; /**<       month   */
+       unsigned char day; /**< day     */
+       unsigned char hour; /**<        hour    */
+       unsigned char minute; /**<      minute  */
+       unsigned char second; /**<      second  */
+       unsigned char timeZone; /**<    timeZone        */
+};
+
+/*
+ * 8.44 DTMF string
+ */
+struct tel_sat_dtmf_string{
+       int dtmf_length;
+       char dtmf_string[SAT_DTMF_STRING_LEN_MAX];
+};
+
+/*
+ * 8.45 Language
+ */
+/*
+ * Refer enum tel_sim_language_type in sim.h
+ */
+
+/*
+ * 8.47 Browser Identity
+ */
+enum browser_identity{
+       BROWSER_ID_DEFAULT = 0, /**<    DEFAULT BROWSER         */
+       BROWSER_ID_WML, /**<    BROWSER WML     */
+       BROWSER_ID_HTML, /**<   BROWSER HTML    */
+       BROWSER_ID_XHTML, /**<  BROWSER XHTML   */
+       BROWSER_ID_CHTML, /**<  BROWSER CHTML   */
+       BROWSER_ID_RESERVED = 0xFF /**< RESERVED        */
+};
+
+/*
+ * 8.48 URL
+ * URL shall be coded as defined in RFC 1738 on using the "SMS 7bit default alphabet" with bit 8 set to 0.
+ */
+struct tel_sat_url{
+       int url_length;
+       char url[SAT_URL_LEN_MAX];
+};
+
+/*
+ * 8.49 Bear
+ */
+enum bearer_list_type{
+       BEARER_LIST_SMS = 0, /**<       BEARER SMS              */
+       BEARER_LIST_CSD = 1, /**<       BEARER CSD              */
+       BEARER_LIST_USSD = 2, /**<      BEARER USSD             */
+       BEARER_LIST_GPRS = 3, /**<      BEARER GPRS             */
+       BEARER_LIST_RESERVED = 0xFF /**<        BEARER RESERVED         */
+};
+
+struct tel_sat_bearer_list{
+       int count;
+       enum bearer_list_type bear[6];
+};
+
+/*
+ * 8.50 Provisioning file reference
+ */
+struct tel_sat_provisioning_file_ref{
+       int file_path_length;
+       char file_path[SAT_PROVISIONING_FILE_PATH_LEN_MAX];
+};
+
+
+/*
+ * 8.51 Browser termination cause
+ */
+enum browser_termination_cause{
+       BROWSER_TERMINATED_BY_USER = 0, /**<    BROWSER TERMINATED BY USER              */
+       BROWSER_TERMINATED_BY_ERROR = 1, /**<   BROWSER TERMINATED BY ERROR             */
+};
+
+/*
+ * 8.52 Bearer description
+ */
+enum bearer_type{
+       BEARER_CSD = 0x1, /**<  BEARER DESC CSD         */
+       BEARER_GPRS = 0x2, /**< BEARER DESC GPRS                */
+       BEARER_DEFAULT_BEARER_FROM_TRANSPORT_LAYER = 0x3, /**<  BEARER DESC DEFAULT BEARER FROM TRANSPORT LAYER         */
+       BEARER_LOCAL_LINK_TECHNOLOGY_INDEPENDENT = 0x4, /**<    BEARER DESC LOCAL LINK TECHNOLOGY INDEPENDENT           */
+       BEARER_BLUETOOTH = 0x5, /**<    BEARER DESC BLUETOOTH   */
+       BEARER_IrDA = 0x6, /**< BEARER DESC IrDA        */
+       BEARER_RS232 = 0x7, /**<        BEARER DESC RS232       */
+       BEARER_USB = 0x10, /**< BEARER DESC USB */
+       BEARER_RESERVED = 0xFF /**<     RESERVED        */
+};
+
+enum bearer_param_cs_data_rate{
+       BIP_DR_AUTOBAUDING = 0, /**<    CSD data rate - AUTOBAUDING             */
+       BIP_DR_300BPS_V21 = 1, /**<     CSD data rate -300BPS V21               */
+       BIP_DR_1200BPS_V22 = 2, /**<    CSD data rate - 1200BPS V22             */
+       BIP_DR_1200_75BPS_V23 = 3, /**< CSD data rate -1200 75BPS V23                   */
+       BIP_DR_2400BPS_V22 = 4, /**<    CSD data rate -2400BPS V22              */
+       BIP_DR_2400BPS_V26 = 5, /**<    CSD data rate - 2400BPS V26                     */
+       BIP_DR_4800BPS_V32 = 6, /**<    CSD data rate - 4800BPS V32             */
+       BIP_DR_9600BPS_V32 = 7, /**<    CSD data rate - 9600BPS V32             */
+       BIP_DR_9600BPS_V34 = 12, /**<   CSD data rate - 9600BPS_V34             */
+       BIP_DR_14400BPS_V34 = 14, /**<  CSD data rate -14400BPS V34             */
+       BIP_DR_19200BPS_V34 = 15, /**<  CSD data rate -19200BPS V34             */
+       BIP_DR_28800BPS_V34 = 16, /**<  CSD data rate -28800BPS V34             */
+       BIP_DR_33600BPS_V34 = 17, /**<  CSD data rate -33600BPS V34             */
+       BIP_DR_1200BPS_V120 = 34, /**<  CSD data rate -1200BPS V120             */
+       BIP_DR_2400BPS_V120 = 36, /**<  CSD data rate -2400BPS V120             */
+       BIP_DR_4800BPS_V120 = 38, /**<  CSD data rate -4800BPS V120             */
+       BIP_DR_9600BPS_V120 = 39, /**<  CSD data rate -9600BPS V120             */
+       BIP_DR_14400BPS_V120 = 43, /**< CSD data rate -14400BPS V120            */
+       BIP_DR_19200BPS_V120 = 47, /**< CSD data rate -19200BPS V120            */
+       BIP_DR_28800BPS_V120 = 48, /**< CSD data rate -28800BPS V120            */
+       BIP_DR_38400BPS_V120 = 49, /**< CSD data rate -38400BPS V120            */
+       BIP_DR_48000BPS_V120 = 50, /**< CSD data rate -48000BPS V120            */
+       BIP_DR_56000BPS_V120 = 51, /**< CSD data rate -56000BPS V120            */
+       BIP_DR_300BPS_V110 = 65, /**<   CSD data rate - 300BPS V110             */
+       BIP_DR_1200BPS_V110 = 66, /**<  CSD data rate -1200BPS V110             */
+       BIP_DR_2400BPS_V110_OR_X31_FALG_STUFFING = 68, /**<     CSD data rate - 2400BPS V110 OR X31 FALG STUFFING               */
+       BIP_DR_4800BPS_V110_OR_X31_FALG_STUFFING = 70, /**<     CSD data rate - 4800BPS V110 OR X31 FALG STUFFING               */
+       BIP_DR_9600BPS_V110_OR_X31_FALG_STUFFING = 71, /**<     CSD data rate - 9600BPS V110 OR X31 FALG STUFFING               */
+       BIP_DR_14400BPS_V110_OR_X31_FALG_STUFFING = 75, /**<    CSD data rate - 14400BPS V110 OR X31 FALG STUFFING              */
+       BIP_DR_19200BPS_V110_OR_X31_FALG_STUFFING = 79, /**<    CSD data rate -19200BPS V110 OR X31 FALG STUFFING               */
+       BIP_DR_28800BPS_V110_OR_X31_FALG_STUFFING = 80, /**<    CSD data rate -28800BPS V110 OR X31 FALG STUFFING               */
+       BIP_DR_38400BPS_V110_OR_X31_FALG_STUFFING = 81, /**<    CSD data rate -38400BPS V110 OR X31 FALG STUFFING               */
+       BIP_DR_48000BPS_V110_OR_X31_FALG_STUFFING = 82, /**<    CSD data rate -48000BPS V110 OR X31 FALG STUFFING               */
+       BIP_DR_56000BPS_V110_OR_X31_FALG_STUFFING = 83, /**<    CSD data rate -56000BPS V110 OR X31 FALG STUFFING               */
+       BIP_DR_64000BPS = 84, /**<      CSD data rate -64000BPS         */
+       BIP_DR_56000BPS_BIT_TRANSPERENT = 115, /**<     CSD data rate -56000BPS BIT TRANSPERENT         */
+       BIP_DR_64000BPS_BIT_TRANSPERENT = 116, /**<     CSD data rate -64000BPS BIT TRANSPERENT         */
+       BIP_DR_32000BPS_PIAFS32K = 120, /**<    CSD data rate -32000BPS PIAFS32K                */
+       BIP_DR_64000BPS_PIAFS64K = 121, /**<    CSD data rate - 64000BPS PIAFS64K               */
+       BIP_DR_28800BPS_MULTIMEDIA = 130, /**<  CSD data rate -28800BPS MULTIMEDIA              */
+       BIP_DR_32000BPS_MULTIMEDIA = 131, /**<  CSD data rate -32000BPS MULTIMEDIA              */
+       BIP_DR_33600BPS_MULTIMEDIA = 132, /**<  CSD data rate - 33600BPS MULTIMEDIA             */
+       BIP_DR_56000BPS_MULTIMEDIA = 133, /**<  CSD data rate -56000BPS MULTIMEDIA              */
+       BIP_DR_64000BPS_MULTIMEDIA = 134 /**<   CSD data rate -64000BPS MULTIMEDIA              */
+};
+
+enum bearer_param_cs_service_type{
+       BIP_CSD_BS_DATA_CIRCUIT_ASYNC_UDI = 0, /**<     CSD Bearer service - DATA CIRCUIT ASYNCHRONOUS UDI              */
+       BIP_CSD_BS_DATA_CIRCUIT_SYNC = 1, /**<  CSD Bearer service - DATA CIRCUIT SYNCHRONOUS UDI               */
+       BIP_CSD_BS_PAD_ACCESS_ASYNC_UDI = 2, /**<       CSD Bearer service - PAD ACCESS ASYNCHRONOUS UDI                        */
+       BIP_CSD_BS_PACKET_ACCESS_SYNC = 3, /**< CSD Bearer service - PACKET ACCESS SYNCHRONOUS UDI              */
+       BIP_CSD_BS_DATA_CIRCUIT_ASYNC_RDI = 4, /**<     CSD Bearer service - DATA CIRCUIT ASYNCHRONOUS RDI              */
+       BIP_CSD_BS_DATA_CIRCUIT_SYNC_RDI = 5, /**<      CSD Bearer service - DATA CIRCUIT SYNCHRONOUS RDI               */
+       BIP_CSD_BS_PAD_ACCESS_ASYNC_RDI = 6, /**<       CSD Bearer service - PAD ACCESS ASYNCHRONOUS RDI                */
+       BIP_CSD_BS_PACKET_ACCESS_SYNC_RDI = 7 /**<      CSD Bearer service - PACKET ACCESS SYNCHRONOUS RDI              */
+};
+
+enum bearer_param_cs_connection_element_type{
+       BIP_CSD_CONN_ELEM_TRANSPARENT = 0, /**< CSD connection element - TRANSPARENT            */
+       BIP_CSD_CONN_ELEM_NON_TRANSPARENT = 1, /**<     CSD connection element - NON TRANSPARENT                */
+       BIP_CSD_CONN_ELEM_BOTH_TRANSPARENT_PREF = 2, /**<       CSD connection element -BOTH TRANSPARENT PREFFERED              */
+       BIP_CSD_CONN_ELEM_BOTH_NON_TRANSPARENT_PREF = 3 /**<    CSD connection element -  NON TRANSPARENT PREFFERED             */
+};
+
+struct tel_sat_bearer_param_cs_bearer{
+       enum bearer_param_cs_data_rate data_rate;
+       enum bearer_param_cs_service_type service_type;
+       enum bearer_param_cs_connection_element_type connection_element_type;
+};
+
+enum bearer_param_ps_precedence_class{
+       BIP_GPRS_PRECED_CLASS_HIGH_PRIORITY = 0x01, /**<        GPRS precedence class -HIGH PRIORITY            */
+       BIP_GPRS_PRECED_CLASS_NORM_PRIORITY = 0x02, /**<        GPRS precedence class -NORM PRIORITY            */
+       BIP_GPRS_PRECED_CLASS_LOW_PRIORITY = 0x03 /**<  GPRS precedence class - LOW PRIORITY            */
+};
+
+enum bearer_param_ps_delay_class{
+       BIP_GPRS_DELAY_CLASS_1 = 0x01, /**<     GPRS delay class - 1            */
+       BIP_GPRS_DELAY_CLASS_2 = 0x02, /**<     GPRS delay class -      2       */
+       BIP_GPRS_DELAY_CLASS_3 = 0x03, /**<     GPRS delay class -      3       */
+       BIP_GPRS_DELAY_CLASS_4 = 0x04 /**<      GPRS delay class - 4            */
+};
+
+enum bearer_param_ps_reliability_class{
+       BIP_GPRS_RELIABILITY_CLASS_1 = 0x01, /**<       GPRS Reliability class -1               */
+       BIP_GPRS_RELIABILITY_CLASS_2 = 0x02, /**<       GPRS Reliability class -2               */
+       BIP_GPRS_RELIABILITY_CLASS_3 = 0x03, /**<       GPRS Reliability class -3               */
+       BIP_GPRS_RELIABILITY_CLASS_4 = 0x04, /**<       GPRS Reliability class -4               */
+       BIP_GPRS_RELIABILITY_CLASS_5 = 0x05 /**<        GPRS Reliability class -5               */
+};
+
+enum bearer_param_ps_peak_throughput_class{
+       BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_8KBPS = 0x01, /**<  GPRS peak throughput class- UPTO 8KBPS          */
+       BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_16KBPS = 0x02, /**< GPRS peak throughput class- UPTO 16KBPS         */
+       BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_32KBPS = 0x03, /**< GPRS peak throughput class-UPTO 32KBPS          */
+       BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_64KBPS = 0x04, /**< GPRS peak throughput class-UPTO 64KBPS          */
+       BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_128KBPS = 0x05, /**<        GPRS peak throughput class- UPTO 128KBPS                        */
+       BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_256KBPS = 0x06, /**<        GPRS peak throughput class- UPTO 256KBPS                        */
+       BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_512KBPS = 0x07, /**<        GPRS peak throughput class- UPTO 512KBPS                */
+       BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_1024KBPS = 0x08, /**<       GPRS peak throughput class-UPTO 1024KBPS                */
+       BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_2048KBPS = 0x09 /**<        GPRS peak throughput class- UPTO 2048KBPS               */
+};
+
+enum bearer_param_ps_mean_throughput_class{
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_DOT_22_BPS = 0x01, /**<  GPRS mean throughput class - DOT 22 BPS         */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_DOT_44_BPS = 0x02, /**<  GPRS mean throughput class - DOT 44 BPS         */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_1_DOT_11_BPS = 0x03, /**<        GPRS mean throughput class -1 DOT 11 BPS                */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_2_DOT_2_BPS = 0x04, /**< GPRS mean throughput class -2 DOT 2 BPS         */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_2_DOT_4_BPS = 0x05, /**< GPRS mean throughput class -2 DOT 4 BPS         */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_11_DOT_1_BPS = 0x06, /**<        GPRS mean throughput class - 11 DOT 1 BPS               */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_22BPS = 0x07, /**<       GPRS mean throughput class -22BPS               */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_44BPS = 0x08, /**<       GPRS mean throughput class - 44BPS              */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_111BPS = 0x09, /**<      GPRS mean throughput class - 111BPS             */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_DOT_22_KBPS = 0x0A, /**< GPRS mean throughput class - DOT 22 KBPS                */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_DOT_44_KBPS = 0x0B, /**< GPRS mean throughput class -DOT 44 KBPS         */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_1_DOT_11_KBPS = 0x0C, /**<       GPRS mean throughput class -1 DOT 11 KBPS               */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_2_DOT_2_KBPS = 0x0D, /**<        GPRS mean throughput class -2 DOT 2 KBPS                */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_4_DOT_4_KBPS = 0x0E, /**<        GPRS mean throughput class - 4 DOT 4 KBPS               */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_11_DOT_1_KBPS = 0x0F, /**<       GPRS mean throughput class -11 DOT 1 KBPS               */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_22KBPS = 0x10, /**<      GPRS mean throughput class - 22KBPS             */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_44KBPS = 0x11, /**<      GPRS mean throughput class - 44KBPS             */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_111KBPS = 0x12, /**<     GPRS mean throughput class -111KBPS             */
+       BIP_GPRS_MEAN_THROUGHPUT_CLASS_BEST_EFFORT = 0x13 /**<  GPRS mean throughput class - BEST EFFORT                */
+};
+
+enum bearer_param_ps_pdp_type{
+       BIP_GPRS_PDP_TYPE_IP = 0x02, /**<       bearer parameter GPRS pdp type - IP             */
+       BIP_GPRS_PDP_TYPE_RESERVED = 0xff /**<  reserved                */
+};
+
+struct tel_sat_bearer_param_ps_bearer{
+       enum bearer_param_ps_precedence_class precedence_class;
+       enum bearer_param_ps_delay_class delay_class;
+       enum bearer_param_ps_reliability_class reliability_class;
+       enum bearer_param_ps_peak_throughput_class peak_throughput_class;
+       enum bearer_param_ps_mean_throughput_class mean_throughput_class;
+       enum bearer_param_ps_pdp_type pdp_type;
+};
+
+enum bearer_param_local_link_service_type{
+       BIP_LL_SERVICE_IDENT_VALUE_ASSIGNED_BY_USIM = 0x00, /**<        local links service identity - value assigned by USIM           */
+       BIP_LL_SERVICE_IDENT_VALUE_ASSIGNED_BY_REMOTED_DEVICE = 0xFF /**<       local links service identity - value assigned by remote service */
+};
+
+struct tel_sat_bearer_param_local_link_bearer{
+       enum bearer_param_local_link_service_type service_type;
+       char service_record[SAT_BEARER_PARAMS_LEN_MAX];
+};
+
+struct tel_sat_bearer_description{
+       enum bearer_type bearer_type;
+       union{
+               struct tel_sat_bearer_param_cs_bearer cs_bearer_param;
+               struct tel_sat_bearer_param_ps_bearer ps_bearer_param;
+               struct tel_sat_bearer_param_local_link_bearer local_link_bearer_param;
+       }bearer_parameter;
+};
+
+/*
+ * 8.53 Channel data
+ */
+struct tel_sat_channel_data{
+       unsigned char data_string_len; /**<     channel data string length      */
+       char    data_string[SAT_CHANNEL_DATA_STRING_LEN_MAX];
+};
+
+/*
+ * 8.54 Channel data length
+ */
+struct tel_sat_channel_data_len{
+       unsigned char data_len; /**<    channel data length     */
+};
+
+
+/*
+ * 8.55 Buffer size
+ */
+struct tel_sat_buffer_size{
+       unsigned char size[2]; /**<     channel data buffer size        */
+};
+
+/*
+ * 8.56 Channel status
+ */
+enum channel_status{
+       link_or_packet_service_not_activated,
+       link_or_packet_service_activated
+};
+
+enum channel_status_info{
+       no_futher_info = 0x00,
+       link_dropped = 0x05
+};
+
+struct tel_sat_channel_status{
+       unsigned char channel_id;
+       enum channel_status status;
+       enum channel_status_info status_info;
+};
+
+/*
+ * 8.58 Other Address
+ */
+enum address_type{
+       ADDR_TYPE_IPv4 = 0x21, /**<     address type - IPv4     */
+       ADDR_TYPE_IPv6 = 0x57, /**<     address type - IPv6     */
+       ADDR_RESERVED = 0xFF /**<       reserved                */
+};
+
+struct tel_sat_other_address{
+       enum address_type address_type; /**<    channel address type    */
+       unsigned char address_len; /**< channel address length  */
+       char address[SAT_OTHER_ADDR_LEN_MAX]; /**<      channel address */
+};
+
+/*
+ * 8.59 UICC/terminal interface transport level
+ */
+enum transport_protocol_type{
+       TP_TYPE_UDP_UICC_CLIENT = 0x01, /**<    transport protocol type- UDP UICC CLIENT        */
+       TP_TYPE_TCP_UICC_CLIENT = 0x02, /**<    transport protocol type-TCP UICC CLIENT */
+       TP_TYPE_TCP_UICC_SERVER = 0x03 /**<     transport protocol type- TCP UICC SERVER        */
+};
+
+struct tel_sat_uicc_terminal_interface_transport_level{
+       enum transport_protocol_type protocol_type;
+       unsigned short port_number;
+};
+
+/*
+ * 8.68 Remote entity address
+ */
+enum remote_entity_coding_type{
+       REMOTE_ENTITY_ADDR_CODING_TYPE_IEEE802_48BIT = 0, /**<  remote entity address coding type- IEEE802 48BIT                */
+       REMOTE_ENTITY_ADDR_CODING_TYPE_IRDA_32BIT = 1, /**<     remote entity address coding type- IRDA 32BIT           */
+       REMOTE_ENTITY_ADDR_CODING_TYPE_RESERVED = 0xFF /**<     reserved                */
+};
+
+struct tel_sat_remote_entity_address{
+       enum remote_entity_coding_type coding_type;
+       unsigned short length;
+       unsigned char remote_entity_address[SAT_REMOTE_ENTITY_ADDR_LEN_MAX];
+};
+
+/*
+ * 8.70 Network access name
+ */
+struct tel_sat_network_access_name{
+       unsigned short length;
+       unsigned char network_access_name[SAT_NET_ACC_NAM_LEN_MAX];
+};
+
+/*
+ * 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.4 MORE TIME
+ */
+struct tel_sat_more_time_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+};
+
+/*
+ * 6.6.5 PLAY TONE
+ */
+struct tel_sat_play_tone_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_alpha_identifier alpha_id;
+       struct tel_sat_tone tone;
+       struct tel_sat_duration duration;
+       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.9 SEND SMS
+ */
+struct tel_sat_send_sms_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_alpha_identifier alpha_id;
+       struct tel_sat_address address;
+       struct tel_sat_sms_tpdu sms_tpdu;
+       //CDMA-SMS TPDU 8.71
+       struct tel_sat_icon_identifier icon_id;
+       struct tel_sat_text_attribute text_attribute;
+       //frame identifier 8.80
+};
+
+/*
+ * 6.6.10 SEND SS
+ */
+struct tel_sat_send_ss_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_alpha_identifier alpha_id;
+       struct tel_sat_ss_string ss_string;
+       struct tel_sat_icon_identifier icon_id;
+       struct tel_sat_text_attribute text_attribute;
+       //frame identifier 8.80
+};
+
+/*
+ * 6.6.11 SEND USSD
+ */
+struct tel_sat_send_ussd_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_alpha_identifier alpha_id;
+       struct tel_sat_ussd_string ussd_string;
+       struct tel_sat_icon_identifier icon_id;
+       struct tel_sat_text_attribute text_attribute;
+       //frame identifier 8.80
+};
+
+/*
+ * 6.6.12 SETUP CALL
+ */
+struct tel_sat_setup_call_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_address address;
+       struct tel_sat_ccp ccp;
+       struct tel_sat_subaddress subaddress;
+       struct tel_sat_duration duration;
+       struct tel_sat_alpha_identifier user_confirm_alpha_id;
+       struct tel_sat_icon_identifier user_confirm_icon_id;
+       struct tel_sat_alpha_identifier call_setup_alpha_id;
+       struct tel_sat_icon_identifier call_setup_icon_id;
+       struct tel_sat_text_attribute user_confirm_text_attribute;
+       struct tel_sat_text_attribute call_setup_text_attribute;
+       //frame identifier 8.80
+};
+
+/*
+ * 6.6.13 REFRESH
+ */
+struct tel_sat_refresh_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_file_list file_list;
+       char aid[16]; // 8.60 AID - length is 16 byte, Refer TS 101.220
+};
+
+/*
+ * 6.6.15 PROVIDE LOCAL INFORMATION
+ */
+struct tel_sat_provide_local_info_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+};
+
+/*
+ * 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;
+       struct tel_sat_event_list event_list;
+       struct tel_sat_event_list modem_event_list;
+};
+
+/*
+ * 6.6.22 SETUP IDLE MODE TEXT
+ */
+struct tel_sat_setup_idle_mode_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;
+       struct tel_sat_text_attribute text_attribute;
+};
+
+/*
+ * 6.6.24 SEND DTMF
+ */
+struct tel_sat_send_dtmf_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_alpha_identifier alpha_id;
+       struct tel_sat_dtmf_string dtmf_string;
+       struct tel_sat_icon_identifier icon_id;
+       struct tel_sat_text_attribute text_attribute;
+};
+
+/*
+ * 6.6.25 LANGUAGE NOTIFICATION
+ */
+struct tel_sat_language_notification_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       enum tel_sim_language_type language;
+};
+
+/*
+ * 6.6.26 LAUNCH BROWSER
+ */
+struct tel_sat_launch_browser_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       enum browser_identity browser_id;
+       struct tel_sat_url url;
+       struct tel_sat_bearer_list bearer;
+       int file_ref_count;
+       struct tel_sat_provisioning_file_ref file_list[SAT_PROVISIONING_REF_MAX_COUNT];
+       struct tel_sat_text_string_object gateway_proxy_text;
+       struct tel_sat_alpha_identifier user_confirm_alpha_id;
+       struct tel_sat_icon_identifier user_confirm_icon_id;
+       struct tel_sat_text_attribute user_confirm_text_attribute;
+       //frame identifier 8.80
+};
+
+/*
+ * 6.6.27 OPEN CHANNEL
+ */
+struct tel_sat_open_channel_cs_bearer{
+       struct tel_sat_address address;
+       struct tel_sat_subaddress subaddress;
+       struct tel_sat_duration duration1;
+       struct tel_sat_duration duration2;
+       struct tel_sat_other_address other_address;
+       struct tel_sat_text_string_object text_user_login;
+       struct tel_sat_text_string_object text_user_pwd;
+};
+
+struct tel_sat_open_channel_packet_data_service_bearer{
+       struct tel_sat_network_access_name network_access_name;
+       struct tel_sat_other_address other_address;
+       struct tel_sat_text_string_object text_user_login;
+       struct tel_sat_text_string_object text_user_pwd;
+};
+
+struct tel_sat_open_channel_local_bearer{
+       struct tel_sat_duration duration1;
+       struct tel_sat_duration duration2;
+       struct tel_sat_text_string_object text_user_pwd;
+       struct tel_sat_remote_entity_address remote_entity_address;
+};
+
+struct tel_sat_open_channel_default_bearer{
+       struct tel_sat_other_address other_address;
+       struct tel_sat_text_string_object text_user_login;
+       struct tel_sat_text_string_object text_user_pwd;
+};
+
+struct tel_sat_open_channel_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_alpha_identifier alpha_id;
+       struct tel_sat_icon_identifier icon_id;
+       struct tel_sat_bearer_description bearer_desc;
+       struct tel_sat_buffer_size buffer_size;
+       struct tel_sat_uicc_terminal_interface_transport_level interface_transport_level;
+       struct tel_sat_other_address data_destination_address;
+       struct tel_sat_text_attribute text_attribute;
+       //frame identifier 8.80
+       union{
+               struct tel_sat_open_channel_cs_bearer cs_bearer;
+               struct tel_sat_open_channel_packet_data_service_bearer ps_bearer;
+               struct tel_sat_open_channel_local_bearer local_bearer;
+               struct tel_sat_open_channel_default_bearer default_bearer;
+       }bearer_detail;
+};
+
+/*
+ * 6.6.28 CLOSE CHANNEL
+ */
+struct tel_sat_close_channel_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_alpha_identifier alpha_id;
+       struct tel_sat_icon_identifier icon_id;
+       struct tel_sat_text_attribute text_attribute;
+};
+
+/*
+ * 6.6.29 RECEIVE DATA
+ */
+struct tel_sat_receive_channel_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_alpha_identifier alpha_id;
+       struct tel_sat_icon_identifier icon_id;
+       struct tel_sat_channel_data_len channel_data_len;
+       struct tel_sat_text_attribute text_attribute;
+};
+
+/*
+ * 6.6.30 SEND DATA
+ */
+struct tel_sat_send_channel_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+       struct tel_sat_alpha_identifier alpha_id;
+       struct tel_sat_icon_identifier icon_id;
+       struct tel_sat_channel_data channel_data;
+       struct tel_sat_text_attribute text_attribute;
+};
+
+/*
+ * 6.6.31 GET CHANNEL STATUS
+ */
+struct tel_sat_get_channel_status_tlv{
+       struct tel_sat_cmd_detail_info command_detail;
+       struct tel_sat_device_identities device_id;
+};
+
+/*
+ * 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;
+       enum event_list event;
+       gboolean idle_screen;
+       enum tel_sim_language_type language;
+       enum browser_termination_cause browser_termination;
+       struct tel_sat_channel_status channel_status;
+       struct tel_sat_channel_data_len channel_data_len;
+};
+
+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;
+};
+
+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_more_time_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_play_tone_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_refresh_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_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 tel_sat_tr_send_sms_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;
+       enum tel_sat_call_ctrl_problem_type cc_problem_type;
+};
+
+struct tel_sat_tr_send_ss_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;
+       enum ss_problem_type ss_problem;
+       gboolean other_info;
+       enum tel_sat_call_ctrl_problem_type cc_problem_type;
+       struct tel_sat_call_ctrl_req_action call_ctrl_req_act;
+       enum tel_sat_result_type result_type2;
+       struct tel_sat_text_string_object text;
+};
+
+struct tel_sat_tr_send_ussd_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;
+       enum ussd_problem_type ussd_problem;
+       gboolean other_info;
+       gboolean call_ctrl_has_modification;
+       enum tel_sat_call_ctrl_problem_type cc_problem_type;
+       struct tel_sat_call_ctrl_req_action call_ctrl_req_act;
+       enum tel_sat_result_type result_type2;
+       struct tel_sat_text_string_object text;
+       struct tel_sat_text_string_object text2;
+};
+
+struct tel_sat_tr_setup_call_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;
+       enum network_problem_type network_problem_type;
+       enum tel_sat_call_ctrl_problem_type cc_problem_type;
+       struct tel_sat_call_ctrl_req_action call_ctrl_req_act;
+       enum tel_sat_result_type result_type2;
+       struct tel_sat_text_string_object text;
+       gboolean tapi_cause;
+       int tapi_call_level_cause;
+       int tapi_ss_level_cause;
+};
+
+struct tel_sat_tr_provide_local_info_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;
+       union {
+               struct tel_sat_location_information location_info;
+               struct tel_sat_imei imei;
+               struct tel_sat_network_measurement_results nmr;
+               struct tel_sat_date_time_and_timezone date_time_and_timezone;
+               enum tel_sim_language_type language;
+       }other;
+};
+
+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_setup_idle_mode_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_send_dtmf_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_language_notification_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_launch_browser_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;
+       enum browser_problem_type browser_problem_type;
+};
+
+struct tel_sat_tr_open_channel_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;
+       enum bip_problem_type bip_problem_type;
+       struct tel_sat_channel_status channel_status;
+       struct tel_sat_bearer_description bearer_desc;
+       struct tel_sat_buffer_size buffer_size;
+       //struct tel_sat_other_address other_address; (uicc server mode)
+};
+
+struct tel_sat_tr_close_channel_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;
+       enum bip_problem_type bip_problem_type;
+};
+
+struct tel_sat_tr_send_data_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;
+       enum bip_problem_type bip_problem_type;
+       struct tel_sat_channel_data_len channel_data_len;
+};
+
+struct tel_sat_tr_receive_data_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;
+       enum bip_problem_type bip_problem_type;
+       struct tel_sat_channel_data channel_data;
+       struct tel_sat_channel_data_len channel_data_len;
+};
+
+struct tel_sat_tr_get_channel_status_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;
+       enum bip_problem_type bip_problem_type;
+       struct tel_sat_channel_status channel_status;
+};
+
+struct treq_sat_terminal_rsp_data{
+       int cmd_number;
+       enum tel_sat_proactive_cmd_type cmd_type;
+       union{
+               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_more_time_tlv more_time;
+               struct tel_sat_tr_play_tone_tlv play_tone;
+               struct tel_sat_tr_refresh_tlv refresh;
+               struct tel_sat_tr_setup_menu_tlv setup_menu;
+               struct tel_sat_tr_select_item_tlv select_item;
+               struct tel_sat_tr_send_sms_tlv send_sms;
+               struct tel_sat_tr_send_ss_tlv send_ss;
+               struct tel_sat_tr_send_ussd_tlv send_ussd;
+               struct tel_sat_tr_setup_call_tlv setup_call;
+               struct tel_sat_tr_provide_local_info_tlv provide_local_info;
+               struct tel_sat_tr_setup_event_list_tlv setup_event_list;
+               struct tel_sat_tr_setup_idle_mode_text_tlv setup_idle_mode_text;
+               struct tel_sat_tr_send_dtmf_tlv send_dtmf;
+               struct tel_sat_tr_language_notification_tlv language_notification;
+               struct tel_sat_tr_launch_browser_tlv launch_browser;
+               struct tel_sat_tr_open_channel_tlv open_channel;
+               struct tel_sat_tr_close_channel_tlv close_channel;
+               struct tel_sat_tr_send_data_tlv send_data;
+               struct tel_sat_tr_receive_data_tlv receive_data;
+               struct tel_sat_tr_get_channel_status_tlv get_channel_status;
+       }terminal_rsp_data;
+};
+
+/*
+ * Define SAT Response structure
+ */
+enum envelop_rsp{
+       ENVELOPE_SUCCESS,       /**<    envelope result - success       */
+       ENVELOPE_SIM_BUSY,      /**<    envelope result - USIM busy     */
+       ENVELOPE_FAILED /**<    envelope result - failed        */
+};
+
+struct tresp_sat_envelop_data{
+       int result;
+       enum sat_envelop_sub_cmd sub_cmd;
+       enum envelop_rsp envelop_resp;
+};
+
+/*
+ * Define SAT Notification structure
+ */
+struct tnoti_sat_proactive_ind{
+       int cmd_number;
+       enum tel_sat_proactive_cmd_type cmd_type;
+       union{
+               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_more_time_tlv more_time;
+               struct tel_sat_play_tone_tlv play_tone;
+               struct tel_sat_setup_menu_tlv setup_menu;
+               struct tel_sat_select_item_tlv select_item;
+               struct tel_sat_send_sms_tlv send_sms;
+               struct tel_sat_send_ss_tlv send_ss;
+               struct tel_sat_send_ussd_tlv send_ussd;
+               struct tel_sat_setup_call_tlv setup_call;
+               struct tel_sat_refresh_tlv refresh;
+               struct tel_sat_provide_local_info_tlv provide_local_info;
+               struct tel_sat_setup_event_list_tlv setup_event_list;
+               struct tel_sat_setup_idle_mode_text_tlv setup_idle_mode_text;
+               struct tel_sat_send_dtmf_tlv send_dtmf;
+               struct tel_sat_language_notification_tlv language_notification;
+               struct tel_sat_launch_browser_tlv launch_browser;
+               struct tel_sat_open_channel_tlv open_channel;
+               struct tel_sat_close_channel_tlv close_channel;
+               struct tel_sat_receive_channel_tlv receive_data;
+               struct tel_sat_send_channel_tlv send_data;
+               struct tel_sat_get_channel_status_tlv get_channel_status;
+       }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..ed5af2e
--- /dev/null
@@ -0,0 +1,990 @@
+/*
+ * 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 56 //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 10 //telephony defined
+#define SIM_GROUP_IDENTIFIER_LEN_MAX 10 //telephony defined
+#define SIM_MAIL_BOX_IDENTIFIER_LEN_MAX 5 //3gpp
+#define SIM_MSP_CNT_MAX 2 //telephony defined
+#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. EF UST has same address */
+       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_lock_status {
+       SIM_LOCK_STATUS_UNLOCKED,
+       SIM_LOCK_STATUS_PIN,
+       SIM_LOCK_STATUS_PUK,
+       SIM_LOCK_STATUS_PIN2,
+       SIM_LOCK_STATUS_PUK2,
+       SIM_LOCK_STATUS_PERM_BLOCKED,
+};
+
+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_mailbox_type {
+       SIM_MAILBOX_VOICE = 0x01, /**< voice */
+       SIM_MAILBOX_FAX = 0x02, /**< fax*/
+       SIM_MAILBOX_DATA = 0x03, /**< data*/
+       SIM_MAILBOX_EMAIL = 0x04, /**< email*/
+       SIM_MAILBOX_OTHER = 0x05, /**< other*/
+};
+
+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 */
+       char bPlmnNetworkName; /*PLMN Network Name*/
+       char bOperatorPlmnList; /*Operator PLMN List*/
+       char bMailboxDiallingNumber; /*Mailbox Dialling Numbers*/
+       char bMessageWaitingIndicationStatus; /*Message Waiting Indication Status*/
+       char bCallForwardingIndicationStatus; /*Call Forwarding Indication Status*/
+       char bServiceProviderDisplayInformation; /*Service Provider Display Information*/
+};
+
+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; /**< multi media 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_service_table {
+       struct tel_sim_sst sst;
+       struct tel_sim_ust ust;
+};
+
+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 alpha_id_max_len; /**< alpha max length in SIM - READ ONLY*/
+       char alpha_id[SIM_XDN_ALPHA_ID_LEN_MAX + 1]; /**< Alpha Identifier */
+       enum tel_sim_ton ton; /**< Type Of Number */
+       enum tel_sim_npi npi; /**< Number Plan Identity */
+       char num[SIM_XDN_NUMBER_LEN_MAX + 1]; /**< Dialing Number/SSC String */
+       unsigned char cc_id; /**< Capability/Configuration Identifier */
+       unsigned char ext1_id; /**< Extensiion1 Record Identifier */
+};
+
+struct tel_sim_gid {
+       int GroupIdentifierLen; /**< Group identifier length */
+       char szGroupIdentifier[SIM_GROUP_IDENTIFIER_LEN_MAX]; /**< Group identifier */
+};
+
+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_get_lock_info {
+       enum tel_sim_facility_type type;
+};
+
+struct treq_sim_transmit_apdu {
+       unsigned int apdu_length;
+       unsigned char apdu[256];
+};
+
+struct treq_sim_set_language {
+       enum tel_sim_language_type language;
+};
+
+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_get_lock_info {
+       enum tel_sim_pin_operation_result result;
+       enum tel_sim_facility_type type;
+       enum tel_sim_lock_status lock_status;
+       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_data {
+       enum tel_sim_access_result result;
+};
+
+struct tel_sim_iccid {
+       char iccid[SIM_ICCID_LEN_MAX + 1];
+};
+
+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.
+        */
+       int voice_index;        /**< voice mailbox identifier*/
+       int fax_index;  /**< FAX mailbox identifier*/
+       int email_index;        /**< email mailbox identifier*/
+       int other_index;        /**< other mailbox identifier*/
+       int video_index;        /**< video mailbox identifier*/
+};
+
+struct tel_sim_mbi_list {
+       int profile_count;
+       struct tel_sim_mbi mbi[SIM_MSP_CNT_MAX];
+};
+
+struct tel_sim_mb_number{
+       int rec_index; // SIM record index;
+       int profile_number; // Subscriber profile number(ex: line1, line2, lineX)
+       enum tel_sim_mailbox_type mb_type;
+       struct tel_sim_dialing_number number_info;
+};
+
+struct tel_sim_mailbox {
+       gboolean b_cphs;
+       int count;
+       struct tel_sim_mb_number mb[SIM_MSP_CNT_MAX*5]; //each profile mailbox number can exist 5 numbers
+};
+
+struct treq_sim_set_mailbox {
+       gboolean b_cphs;
+       struct tel_sim_mb_number mb_info;
+};
+
+struct tel_sim_cfis {
+       int rec_index;
+       unsigned char msp_num; /**< MSP number*/
+       unsigned char cfu_status; /**< call forwarding unconditional indication status*/
+       enum tel_sim_ton ton; /**< TON*/
+       enum tel_sim_npi npi; /**< NPI*/
+       char cfu_num[SIM_XDN_NUMBER_LEN_MAX + 1];/**< Dialing Number/SSC String*/
+       unsigned char cc2_id; /**< Capability/Configuration2 Record Identifier */
+       unsigned char ext7_id; /**< Extension 7 Record Identifier */
+};
+
+struct tel_sim_cf_list {
+       int profile_count;
+       struct tel_sim_cfis cf[SIM_MSP_CNT_MAX];
+};
+
+struct tel_sim_cphs_cf {
+       gboolean b_line1; /**< CallForwardUnconditionalLine 1 */
+       gboolean b_line2; /**< CallForwardUnconditionalLine 2 */
+       gboolean b_fax; /**< CallForwardUnconditional FAX */
+       gboolean b_data; /**<CallForwardUnconditional data*/
+};
+
+struct tel_sim_callforwarding {
+       gboolean b_cphs;
+       struct tel_sim_cf_list cf_list;
+       struct tel_sim_cphs_cf cphs_cf;
+};
+
+struct treq_sim_set_callforwarding {
+       gboolean b_cphs;
+       struct tel_sim_cfis cf;
+       struct tel_sim_cphs_cf cphs_cf;
+};
+
+struct tel_sim_mw {
+       int rec_index;
+       unsigned char indicator_status; /**< Indicator status*/
+       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_mw_list {
+       int profile_count;
+       struct tel_sim_mw mw[SIM_MSP_CNT_MAX];
+};
+
+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_messagewaiting {
+       gboolean b_cphs;
+       struct tel_sim_mw_list mw_list;
+       struct tel_sim_cphs_mw cphs_mw;
+};
+
+struct treq_sim_set_messagewaiting {
+       gboolean b_cphs;
+       struct tel_sim_mw mw;
+       struct tel_sim_cphs_mw cphs_mw;
+};
+
+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_netname {
+       unsigned char full_name[SIM_CPHS_OPERATOR_NAME_LEN_MAX+1];
+       unsigned char short_name[SIM_CPHS_OPERATOR_NAME_SHORT_FORM_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 mb;
+               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_netname cphs_net;
+               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..eead21d
--- /dev/null
@@ -0,0 +1,1008 @@
+/*
+ * 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,
+*/
+
+/*==================================================================================================
+                                            MACROS
+==================================================================================================*/
+/* NetText */
+
+#define SMS_SMSP_ADDRESS_LEN                           20              /* EF-SMSP digit length */
+#define SMS_SMSP_ALPHA_ID_LEN_MAX                      128             /* EF-SMSP alpha id length */
+#define SMS_MAX_EFSMSP_RECORD_LENGTH           156             /* Maximum number of bytes SMSP Record size (Y + 28), y : 0 ~ 128 */
+
+#define SMS_MSG_SIZE_MAX                                       918             /**< Maximum Message Size */
+#define SMS_CB_SIZE_MAX                                                93              /** Maximum CB Message Size */
+#define SMS_ETWS_SIZE_MAX                                      56              /** Maximum ETWS 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                                255             /**< 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                                          255             /**< 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_GSM = 1,      /**< GSM Cell broadcast message */
+               SMS_CB_MSG_UMTS      /**< UMTS Cell broadcast message */
+};
+
+/**
+* @enum telephony_sms_etws_type
+* This enumeration defines the different ETWS message types.
+*/
+enum telephony_sms_etws_type {
+               SMS_ETWS_MSG_PRIMARY = 0,                               /**< PRIMARY ETWS Message */
+               SMS_ETWS_MSG_SECONDARY_GSM,                             /**< SECONDARY GSM ETWS Message */
+               SMS_ETWS_MSG_SECONDARY_UMTS                             /**< SECONDARY UMTS ETWS 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*/
+};
+
+/**
+ * @enum telephony_sms_3gpp_type
+ * This defines the type of 3gpp
+ */
+enum telephony_sms_3gpp_type {
+       SMS_NETTYPE_3GPP = 0x01,                                                /**< 3gpp type */
+       SMS_NETTYPE_3GPP2,    /**< 3gpp2 type (CDMA) */
+};
+
+
+/**
+ * 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_SIZE_MAX + 1]; /**<Cell broadcast message data[Refer 3GPP TS 23.041 9.4.1]*/
+};
+
+struct telephony_sms_etws_msg {
+
+       enum telephony_sms_etws_type    etwsMsgType;                                                    /**< ETWS  message type */
+       unsigned short                                  length;                                                         /**<Size of array msgData (which is actual TPDU message) */
+       char                                                    msgData[SMS_ETWS_SIZE_MAX + 1]; /**< ETWS message data[Refer 3GPP TS 23.041 9.4.1.3]*/
+};
+
+struct telephony_sms_cb_msg_info_3gpp {
+ unsigned short fromMsgId; /**< Starting point of the range of CBS message ID */
+ unsigned short toMsgId; /**< Ending point of the range of CBS message ID */
+ unsigned char selected; /**< 0x00 . Not selected. 0x01 . Selected */
+};
+
+struct telephony_sms_cb_msg_info_3gpp2 {
+ unsigned short cbCategory; /**< CB Service category */
+ unsigned short cbLanguage; /**< Language indicator value
+                                                               . 0x00 . LANGUAGE_UNKNOWN .
+                                                                       Unknown or Unspecified
+                                                               . 0x01 . LANGUAGE_ENGLISH . English
+                                                               . 0x02 . LANGUAGE_FRENCH . French
+                                                               . 0x03 . LANGUAGE_SPANISH . Spanish
+                                                               . 0x04 . LANGUAGE_JAPANESE . Japanese
+                                                               . 0x05 . LANGUAGE_KOREAN . Korean
+                                                               . 0x06 . LANGUAGE_CHINESE . Chinese
+                                                               . 0x07 . LANGUAGE_HEBREW . Hebrew*/
+ unsigned char selected; /**< 0x00 . Not selected. 0x01 . Selected */
+};
+
+union telephony_sms_cb_msg_info_u {
+       struct telephony_sms_cb_msg_info_3gpp net3gpp; /**< 3GPP Broadcast Configuration Information */
+       struct telephony_sms_cb_msg_info_3gpp2 net3gpp2; /**< 3GPP2 Broadcast Configuration Information, CDMA*/
+};
+
+struct telephony_sms_CbConfig {
+       int net3gppType;  /**< Type of 3gpp, 0x01 . 3gpp. 0x02 . 3gpp2(CDMA) */
+       int cbEnabled; /**< 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 msgIdMaxCount; /**< CB Channel List Max Count For Response */
+       int msgIdRangeCount; /**< Range of CB message ID count */
+       union telephony_sms_cb_msg_info_u msgIDs[SMS_GSM_SMS_CBMI_LIST_SIZE_MAX]; /**< Range of 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 net3gppType;  /**< Type of 3gpp, 0x01 . 3gpp. 0x02 . 3gpp2(CDMA) */
+       int cbEnabled; /**< 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 msgIdMaxCount; /**< CB Channel List Max Count For Response */
+       int msgIdRangeCount; /**< Range of CB message ID count */
+       union telephony_sms_cb_msg_info_u msgIDs[SMS_GSM_SMS_CBMI_LIST_SIZE_MAX]; /**< Range of CB message ID information */
+};
+
+struct treq_sms_set_mem_status {
+       int     memory_status;
+};
+
+struct treq_sms_get_pref_bearer {
+};
+
+struct treq_sms_set_pref_bearer {
+       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_bearer {
+       int     result;
+};
+
+struct tresp_sms_set_pref_bearer {
+       int     svc;
+       int     result;
+};
+
+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_etws_msg {
+       struct telephony_sms_etws_msg   etwsMsg;
+};
+
+struct tnoti_sms_memory_status {
+       int     status;
+};
+
+struct tnoti_sms_ready_status {
+       gboolean        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..2e96a46
--- /dev/null
@@ -0,0 +1,330 @@
+/*
+ * 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
+};
+
+enum telephony_ss_error {
+       SS_ERROR_NONE, /**<  SS operation was successful */
+       SS_ERROR_TIMEREXPIRE, /**< SS operation timer expired on network. */
+       SS_ERROR_UNKNOWNSUBSCRIBER, /**< SS error indicating unknown/illegal subscriber.  */
+       SS_ERROR_BEARERSERVICENOTPROVISIONED, /**<The network returns this error when it is requested to  @n
+        perform an operation on a supplementary service  */
+       SS_ERROR_TELESERVICENOTPROVISIONED, /**<The network returns this error when it is requested to perform  @n
+        an operation on a supplementary service  */
+       SS_ERROR_ILLEGALSSOPERATION, /**<This error is returned by the network when it is requested to perform an illegal operation @n
+        which is defined as not applicable for the relevant supplementary service */
+       SS_ERROR_ERRORSTATUS, /**<This error is returned by the network when it is requested to perform an operation @n
+        which is not compatible with the current status of the relevant supplementary service. */
+       SS_ERROR_NOTAVAILABLE, /**< SS not available in network */
+       SS_ERROR_SUBSCRIPTIONVIOLATION, /**< SS service subscription violation. */
+       SS_ERROR_INCOMPATIBILITY, /**< This error is returned by the network when it is requested for a supplementary service operation incompatible with the @n
+        status of another supplementary service or with the teleservice or bearer service for which the operation is requested */
+       SS_ERROR_SYSTEMFAILURE, /**< This error is returned by the network, when it cannot perform an operation because of a failure in the network */
+       SS_ERROR_DATAMISSING, /**< This error is returned by the network when an optional parameter is missing in an invoke component @n
+        or an inner data structure, while it is required by the context of the request. */
+       SS_ERROR_UNEXPECTEDDATAVALUE, /**< SS error indicating unexpected data value on network side *//**< SS operation barred.  */
+       SS_ERROR_PWREGISTRATIONFAILURE, /**< SS error indicating change password failure. */
+       SS_ERROR_NEGATIVEPWCHECK, /**< SS error indicating negative password check.  */
+       SS_ERROR_FACILITYNOTSUPPORTED, /**< SS service facility not supported  */
+       SS_ERROR_RESOURCESNOTAVAILABLE, /**< SS error indicating resources not available in network.  */
+       SS_ERROR_MAXNOMPTYEXCEEDED, /**< SS error indicating Maximum MPTY is reached.  */
+       SS_ERROR_CALLBARRED, /**< This error is returned by the network to the MS when call independent subscriber control procedures are barred by the operator */
+       SS_ERROR_NUMBEROFPWATTEMPTSVIOLATION, /**< SS error indicating barring password attempts violated.  */
+       SS_ERROR_ABSENTSUBSCRIBER, /**< This error is returned when the subscriber has activated the detach service or the system detects the absence condition */
+       SS_ERROR_ILLEGALSUBSCRIBER, /**<This error is returned when illegality of the access has been @n
+        established by use of authentication procedure. */
+       SS_ERROR_ILLEGALEQUIPMENT, /**<This error is returned when the IMEI check procedure has shown that  @n
+        the IMEI is blacklisted or not whitelisted  */
+       SS_ERROR_USSDBUSY, /**< SS error indicating USSD Busy(Already SS / USSD is ongoing).  */
+       SS_ERROR_UNKNOWNALPHABET, /**< SS error indicating unknown SS data coding of alphabet */
+       SS_ERROR_INVALIDDEFLECTEDTONUMBER, /**< SS error indicating the invalid deflected to number.  */
+       SS_ERROR_DEFLECTIONTOSERVEDSUBSCRIBER, /**< This error is returned if a diversion to the served  @n
+        subscriber's number was requested.  */
+       SS_ERROR_SPECIALSERVICECODE, /**< This error is returned if diversion to a special service code was requested.  */
+       SS_ERROR_REJECTEDBYUSER, /**< SS operation rejected by user.  */
+       SS_ERROR_REJECTEDBYNETWORK, /**< SS operation rejected by network.  */
+       SS_ERROR_NET_NOT_ALLOWED_EMERGENCY_CALLS_ONLY, /**< SS operation is not allowed by network.  */
+       SS_ERROR_UNKNOWNERROR, /**< SS error indicating unknown error  */
+       SS_ERROR_OEM_NOT_SUPPORTED /**< If oem do not support any of SS requests, then this error will be returned back */
+};
+
+
+#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 {
+       enum telephony_ss_error 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;
+       enum telephony_ss_error 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;
+       enum telephony_ss_error err;
+};
+
+struct tresp_ss_waiting {
+       int record_num;
+       struct waiting_info {
+               enum telephony_ss_class class;
+               enum telephony_ss_status status;
+       } *record;
+       enum telephony_ss_error err;
+};
+
+struct tresp_ss_cli {
+       enum telephony_ss_cli_type type;
+       gboolean status;
+       enum telephony_ss_error err;
+};
+
+struct tresp_ss_ussd {
+       enum telephony_ss_ussd_type type;
+       enum telephony_ss_ussd_status status;
+       char str[ MAX_SS_USSD_LEN ];
+       enum telephony_ss_error err;
+};
+
+
+
+// notification
+
+struct tnoti_ss_ussd {
+       enum telephony_ss_ussd_status status;
+       char str[ MAX_SS_USSD_LEN ];
+};
+
+#define MAX_SS_RELEASE_COMPLETE_DATA_SIZE 260
+struct tnoti_ss_release_complete {
+       int data_len;
+       unsigned char data[ MAX_SS_RELEASE_COMPLETE_DATA_SIZE ];
+};
+
+__END_DECLS
+
+#endif
diff --git a/include/udev.h b/include/udev.h
new file mode 100644 (file)
index 0000000..70a2c4b
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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_UDEV_H__
+#define __TCORE_UDEV_H__
+
+#include <gudev/gudev.h>
+
+__BEGIN_DECLS
+
+typedef gboolean (*TcoreUdevEnumerCallback)(TcoreUdev *udev, GList *list, void *user_data);
+typedef gboolean (*TcoreUdevCallback)(TcoreUdev *udev, GUdevDevice *device, void *user_data);
+
+TcoreUdev*       tcore_udev_new(Server *s, const gchar **subsystems);
+void             tcore_udev_free(TcoreUdev *udev);
+
+Server*          tcore_udev_ref_server(TcoreUdev *udev);
+GUdevClient*     tcore_udev_ref_client(TcoreUdev *udev);
+GUdevEnumerator* tcore_udev_ref_enumerator(TcoreUdev *udev);
+
+TReturn          tcore_udev_add_enumerator_callback(TcoreUdev *udev, TcoreUdevEnumerCallback func, void *user_data);
+GList*           tcore_udev_exec_enumerator(TcoreUdev *udev, gboolean event_emit_flag);
+
+TReturn          tcore_udev_add_callback(TcoreUdev *udev, const char *subsystem, const char *action, TcoreUdevCallback func, void *user_data);
+
+__END_DECLS
+
+#endif
diff --git a/include/user_request.h b/include/user_request.h
new file mode 100644 (file)
index 0000000..d47e125
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * 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_ref(UserRequest *ur);
+void          tcore_user_request_unref(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..5915e9e
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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);
+
+unsigned char* tcore_util_decode_hex(const char *src, int len);
+
+unsigned char*         tcore_util_unpack_gsm7bit(const unsigned char *src, unsigned int src_len);
+unsigned char*         tcore_util_pack_gsm7bit(const unsigned char *src, unsigned int src_len);
+char*                          tcore_util_convert_bcd2ascii(const char *src, int src_len, int max_len);
+gboolean                       tcore_util_convert_utf8_to_gsm(unsigned char *dest, int *dest_len, unsigned char* src, int src_len);
+gboolean                       tcore_util_convert_utf8_to_ucs2(unsigned char* dest, int* dest_len,     unsigned char* src, int src_len);
+gboolean                       tcore_util_convert_string_to_utf8(unsigned char *dest, unsigned short *dest_len,
+                                               enum alphabet_format dcs, const unsigned char *src, unsigned short src_len);
+void                           tcore_util_swap_byte_order(unsigned short* dest, const unsigned short* src, int src_len);
+
+char*          tcore_util_get_version(void);
+
+__END_DECLS
+
+#endif
diff --git a/libtcore.manifest b/libtcore.manifest
new file mode 100644 (file)
index 0000000..dfdc35c
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+  <domain name="_"/>
+ </request>
+</manifest>
diff --git a/packaging/0001-hal-Add-set_sound_path-function.patch b/packaging/0001-hal-Add-set_sound_path-function.patch
new file mode 100644 (file)
index 0000000..50b950b
--- /dev/null
@@ -0,0 +1,77 @@
+From c524695eda823d025f5d2f64b8a84e1b478caa9a Mon Sep 17 00:00:00 2001
+From: Nicolas Bertrand <nicolas.bertrand@linux.intel.com>
+Date: Thu, 4 Oct 2012 10:23:16 +0200
+Subject: [PATCH 01/10] hal: Add set_sound_path function
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+---
+ include/hal.h |    2 ++
+ src/hal.c     |   10 ++++++++++
+ src/mux.c     |    8 ++++++++
+ 3 files changed, 20 insertions(+)
+
+diff --git a/include/hal.h b/include/hal.h
+index d93795a..55b4762 100644
+--- a/include/hal.h
++++ b/include/hal.h
+@@ -43,6 +43,7 @@ enum tcore_hal_mode {
+ struct tcore_hal_operations {
+       TReturn (*power)(TcoreHal *hal, gboolean flag);
+       TReturn (*send)(TcoreHal *hal, unsigned int data_len, void *data);
++      TReturn (*set_sound_path)(TcoreHal *hal, int device);
+ };
+ TcoreHal*    tcore_hal_new(TcorePlugin *plugin, const char *name,
+@@ -58,6 +59,7 @@ enum tcore_hal_mode tcore_hal_get_mode(TcoreHal *hal);
+ TReturn      tcore_hal_set_mode(TcoreHal *hal, enum tcore_hal_mode mode);
+ TReturn      tcore_hal_set_power(TcoreHal *hal, gboolean flag);
++TReturn             tcore_hal_set_sound_path(TcoreHal *hal, int device);
+ TReturn      tcore_hal_link_user_data(TcoreHal *hal, void *user_data);
+ void*        tcore_hal_ref_user_data(TcoreHal *hal);
+diff --git a/src/hal.c b/src/hal.c
+index 178cecd..59ba41f 100644
+--- a/src/hal.c
++++ b/src/hal.c
+@@ -508,3 +508,13 @@ TReturn tcore_hal_set_power(TcoreHal *hal, gboolean flag)
+       return hal->ops->power(hal, flag);
+ }
++
++TReturn tcore_hal_set_sound_path(TcoreHal *hal, int device)
++{
++      dbg("start");
++
++      if (!hal || !hal->ops || !hal->ops->set_sound_path)
++              return TCORE_RETURN_EINVAL;
++
++      return hal->ops->set_sound_path(hal, device);
++}
+diff --git a/src/mux.c b/src/mux.c
+index 46cafce..7456762 100644
+--- a/src/mux.c
++++ b/src/mux.c
+@@ -283,10 +283,18 @@ static TReturn tcore_cmux_hal_send(TcoreHal *h, unsigned int data_len, void *dat
+       return TCORE_RETURN_SUCCESS;
+ }
++static TReturn tcore_cmux_hal_set_sound_path(TcoreHal *hal, int device)
++{
++      dbg("Entry");
++
++      return tcore_hal_set_sound_path(g_mux_obj_ptr->phy_hal, device);
++}
++
+ /* CMUX supported HAL (Logical HAL) operations */
+ static struct tcore_hal_operations mux_hops = {
+       .power = tcore_cmux_hal_power,
+       .send = tcore_cmux_hal_send,
++      .set_sound_path = tcore_cmux_hal_set_sound_path,
+ };
+ static TReturn tcore_cmux_send_data(int data_len, unsigned char *data)
+-- 
+1.7.10.4
+
diff --git a/packaging/0002-hal-Add-new-entry-points-and-method-declarations.patch b/packaging/0002-hal-Add-new-entry-points-and-method-declarations.patch
new file mode 100644 (file)
index 0000000..7ff172d
--- /dev/null
@@ -0,0 +1,59 @@
+From 69ef003199bc6848d39d75b12bd6ccb84383abad Mon Sep 17 00:00:00 2001
+From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
+Date: Wed, 3 Oct 2012 10:14:40 +0200
+Subject: [PATCH 02/10] hal: Add new entry points and method declarations
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+Create callback for HAL power operation.
+
+mux_init-->initialize multiplexer through HAL
+lin_object_channel--> link core object to HAL channel
+---
+ include/hal.h |   10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/include/hal.h b/include/hal.h
+index 55b4762..bed6684 100644
+--- a/include/hal.h
++++ b/include/hal.h
+@@ -25,6 +25,7 @@ __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);
++typedef void (*TcoreHalPowerCallBack)(TcoreHal *hal, void *user_data);
+ enum tcore_hal_recv_data_type {
+       TCORE_HAL_RECV_INDICATION,
+@@ -41,9 +42,11 @@ enum tcore_hal_mode {
+ };
+ struct tcore_hal_operations {
+-      TReturn (*power)(TcoreHal *hal, gboolean flag);
++      TReturn (*power)(TcoreHal *hal, gboolean flag,
++                              TcoreHalPowerCallBack func, void *user_data);
+       TReturn (*send)(TcoreHal *hal, unsigned int data_len, void *data);
+       TReturn (*set_sound_path)(TcoreHal *hal, int device);
++      TReturn (*link_object_channel)(CoreObject *object);
+ };
+ TcoreHal*    tcore_hal_new(TcorePlugin *plugin, const char *name,
+@@ -58,11 +61,14 @@ TcoreAT*     tcore_hal_get_at(TcoreHal *hal);
+ enum tcore_hal_mode tcore_hal_get_mode(TcoreHal *hal);
+ TReturn      tcore_hal_set_mode(TcoreHal *hal, enum tcore_hal_mode mode);
+-TReturn      tcore_hal_set_power(TcoreHal *hal, gboolean flag);
++TReturn      tcore_hal_set_power(TcoreHal *hal, gboolean flag,
++                                      TcoreHalPowerCallBack func,
++                                      void *user_data);
+ TReturn             tcore_hal_set_sound_path(TcoreHal *hal, int device);
+ TReturn      tcore_hal_link_user_data(TcoreHal *hal, void *user_data);
+ void*        tcore_hal_ref_user_data(TcoreHal *hal);
++TReturn            tcore_hal_link_object(TcoreHal *hal, CoreObject *co);
+ TReturn      tcore_hal_send_data(TcoreHal *hal, unsigned int data_len, void *data);
+ TReturn      tcore_hal_send_request(TcoreHal *hal, TcorePending *pending);
+-- 
+1.7.10.4
+
diff --git a/packaging/0003-hal-Add-new-method-definitions.patch b/packaging/0003-hal-Add-new-method-definitions.patch
new file mode 100644 (file)
index 0000000..b040ae0
--- /dev/null
@@ -0,0 +1,50 @@
+From a7806ad9a86716bcdc9acba58575015e6224af91 Mon Sep 17 00:00:00 2001
+From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
+Date: Wed, 3 Oct 2012 10:16:53 +0200
+Subject: [PATCH 03/10] hal: Add new method definitions
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+---
+ src/hal.c |   14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/src/hal.c b/src/hal.c
+index 59ba41f..9ade963 100644
+--- a/src/hal.c
++++ b/src/hal.c
+@@ -241,6 +241,14 @@ TReturn tcore_hal_link_user_data(TcoreHal *hal, void *user_data)
+       return TCORE_RETURN_SUCCESS;
+ }
++TReturn tcore_hal_link_object(TcoreHal *hal, CoreObject *co)
++{
++      if (!hal)
++              return TCORE_RETURN_EINVAL;
++
++      return hal->ops->link_object_channel(co);
++}
++
+ void *tcore_hal_ref_user_data(TcoreHal *hal)
+ {
+       if (!hal)
+@@ -501,12 +509,14 @@ gboolean tcore_hal_get_power_state(TcoreHal *hal)
+       return hal->power_state;
+ }
+-TReturn tcore_hal_set_power(TcoreHal *hal, gboolean flag)
++TReturn tcore_hal_set_power(TcoreHal *hal, gboolean flag,
++                              TcoreHalPowerCallBack func,
++                              void *user_data)
+ {
+       if (!hal || !hal->ops || !hal->ops->power)
+               return TCORE_RETURN_EINVAL;
+-      return hal->ops->power(hal, flag);
++      return hal->ops->power(hal, flag, func, user_data);
+ }
+ TReturn tcore_hal_set_sound_path(TcoreHal *hal, int device)
+-- 
+1.7.10.4
+
diff --git a/packaging/0004-mux-Declare-new-public-API-for-HAL-plugin-manipulati.patch b/packaging/0004-mux-Declare-new-public-API-for-HAL-plugin-manipulati.patch
new file mode 100644 (file)
index 0000000..09ba1d8
--- /dev/null
@@ -0,0 +1,39 @@
+From 77346145fe1c5e9332b509ab489f087d29321c25 Mon Sep 17 00:00:00 2001
+From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
+Date: Wed, 3 Oct 2012 10:18:00 +0200
+Subject: [PATCH 04/10] mux: Declare new public API for HAL plugin
+ manipulations
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+Add new callback to notify when MUX is ready.
+---
+ include/mux.h |   13 ++++++++++---
+ 1 file changed, 10 insertions(+), 3 deletions(-)
+
+diff --git a/include/mux.h b/include/mux.h
+index 1b11776..342244f 100644
+--- a/include/mux.h
++++ b/include/mux.h
+@@ -21,8 +21,15 @@
+ #ifndef __MUX_H__
+ #define __MUX_H__
+-TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal);
+-void    tcore_cmux_close(void);
+-int     tcore_cmux_rcv_from_hal(unsigned char *data, size_t length);
++#include "hal.h"
++
++typedef void (*CMuxInitCallBack)(void *user_data);
++
++TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal,
++                              CMuxInitCallBack cb, void *user_data,
++                              int channel_num);
++TcoreHal *tcore_cmux_get_hal_channel(int channel_idx);
++void tcore_cmux_close(void);
++int tcore_cmux_rcv_from_hal(unsigned char *data, size_t length);
+ #endif  /* __MUX_H__ */
+-- 
+1.7.10.4
+
diff --git a/packaging/0005-mux-Remove-plateform-dependencies-from-core-multiple.patch b/packaging/0005-mux-Remove-plateform-dependencies-from-core-multiple.patch
new file mode 100644 (file)
index 0000000..9f2f83e
--- /dev/null
@@ -0,0 +1,618 @@
+From a8facc64fbebfe779218931b22f7062d75f9820a Mon Sep 17 00:00:00 2001
+From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
+Date: Wed, 3 Oct 2012 10:26:41 +0200
+Subject: [PATCH 05/10] mux: Remove plateform dependencies from core
+ multiplexer
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+Remove struct cmux_channel_object.
+Remove hardcoded channel indexes and channel limitations.
+Remove core object list from mux object.
+Only allocate multiplexer channel during cmux_init and
+open channels on HAL plugin demand.
+Let telephony plugin set physical HAL back to each of its
+core object.
+---
+ src/mux.c |  321 +++++++++++++++++--------------------------------------------
+ 1 file changed, 88 insertions(+), 233 deletions(-)
+
+diff --git a/src/mux.c b/src/mux.c
+index 7456762..3794685 100644
+--- a/src/mux.c
++++ b/src/mux.c
+@@ -27,16 +27,12 @@
+ #include "tcore.h"
+-#include "hal.h"
+ #include "plugin.h"
+ #include "user_request.h"
+ #include "server.h"
+ #include "mux.h"
+ #include "core_object.h"
+-/* Maximum Core objects per Logical HAL (indirectly per Channel) */
+-#define MAX_CMUX_CORE_OBJECTS         3
+-
+ /* Max CMUX Buffer size */
+ #define MAX_CMUX_BUFFER_SIZE          4096
+@@ -57,16 +53,6 @@
+ #define  CMUX_COMMAND_MSC                     0xE3    // Modem Status Command
+ #define  CMUX_COMMAND_CLD                     0xC3    // Multiplexer close down
+-/* CMUX Channels [0-7] -
+-  * Channel 0 - Control Channel for CMUX
+-  * Channel 1 - CALL
+-  * Channel 2 - SIM
+-  * Channel 3 - SAT
+-  * Channel 4 - SMS
+-  * Channel 5 - SS
+-  * Channel 6 - NETWORK
+-  * Channel 7 - MODEM & PS
+-  */
+ typedef enum CMUX_Channels {
+       CMUX_CHANNEL_0,
+       CMUX_CHANNEL_1,
+@@ -135,30 +121,28 @@ const unsigned char crc_table[256] = { // reversed, 8-bit, poly=0x07
+ /* CMUX Channel */
+ typedef struct cmux_channel {
+-      GSList *co;
+       TcoreHal *hal;
+       MuxChannelState state;
+       CMUX_Channels channel_id;
++      char *channel_id_name;
+       int frame_type;
+       unsigned char ext_bit;
+       unsigned char cr_bit;
+       unsigned char poll_final_bit;
+ } CHANNEL;
+-/* CMUX callback prototype */
+-typedef gboolean (*mux_cb_func)(CHANNEL *channel_ptr);
+-
+ /* CMUX structure */
+ typedef struct cmux {
+       MuxState state;
+       CHANNEL *channel_info[MAX_CMUX_CHANNELS_SUPPORTED];
++      int channel_num;
+       int is_waiting;
+       int msg_len;
+       int cur_main_buf_len;
+       TcorePlugin *plugin;
+       TcoreHal *phy_hal;
+-      CoreObject *modem_co;
+-      mux_cb_func cb_func;
++      CMuxInitCallBack cb_init;
++      void *cb_data;
+       int info_field_len;
+       unsigned char *info_field;
+ } MUX;
+@@ -169,69 +153,26 @@ MUX *g_mux_obj_ptr = NULL;
+ /* CMUX mode of operation */
+ int g_mux_mode = 0; /* BASIC mode */
+-struct cmux_channel_object {
+-      char *channel_id_name;
+-      char *core_object_name[MAX_CMUX_CORE_OBJECTS];
+-};
+-
+-/* Core Object names need to be verified, define a MACRO globally */
+-struct cmux_channel_object cmux_channel_core_object[] = {
+-      {"channel_0", {"control", NULL, NULL}},
+-      {"channel_1", {"call", NULL, NULL}},
+-      {"channel_2", {"sim", NULL, NULL}},
+-      {"channel_3", {"sat", NULL, NULL}},
+-      {"channel_4", {"umts_sms", NULL, NULL}},
+-      {"channel_5", {"ss", NULL, NULL}},
+-      {"channel_6", {"umts_network", NULL, NULL}},
+-      {"channel_7", {"modem", "umts_ps", NULL}},
+-};
+-
+ /* All the local functions declared below */
+ static unsigned char calc_crc(unsigned char *header, int length);
+ static int rcv_crc_check(unsigned char *data, unsigned char len, unsigned char rcv_FCS);
+-MUX* tcore_cmux_new(void);
++static MUX* tcore_cmux_new(int channel_num);
+ static void tcore_cmux_free(void);
+-void tcore_cmux_link_core_object_hal(CMUX_Channels channel_id, TcorePlugin *plugin);
+ static gboolean tcore_cmux_recv_mux_data(CHANNEL *channel_ptr);
+ static void tcore_cmux_process_rcv_frame(unsigned char *data, int len);
+ static void tcore_cmux_process_channel_data(CHANNEL *channel_info_ptr);
+ static void tcore_cmux_control_channel_handle(void);
+ static void tcore_cmux_flush_channel_data(void);
+ static void tcore_cmux_channel_init(CMUX_Channels channel_id);
+-static void tcore_cmux_close_channel(int channel_id);
+ static unsigned char* tcore_encode_cmux_frame(unsigned char *data, int length, int channel_id, int frame_type, unsigned char EA_bit, unsigned char CR_bit, unsigned char PF_bit, int *out_data_len);
++static void tcore_cmux_close_channel(int channel_idx);
+ static TReturn tcore_cmux_send_data(int data_len, unsigned char *data);
+-static TReturn tcore_cmux_hal_power(TcoreHal *h, gboolean flag)
+-{
+-      TcorePlugin *p = NULL;
+-      struct custom_data *user_data = NULL;
+-
+-      dbg("Entry");
+-
+-      p = tcore_hal_ref_plugin(h);
+-      if (!p) {
+-              err("Plugin is undefined");
+-              return TCORE_RETURN_FAILURE;
+-      }
+-
+-      user_data = tcore_hal_ref_user_data(h);
+-      if (!user_data) {
+-              err("User data is undefined");
+-              return TCORE_RETURN_FAILURE;
+-      }
+-
+-      tcore_hal_set_power_state(h, TRUE);
+-
+-      dbg("Exit");
+-      return TCORE_RETURN_SUCCESS;
+-}
+-
+ static TReturn tcore_cmux_hal_send(TcoreHal *h, unsigned int data_len, void *data)
+ {
+       unsigned char *send_data = NULL;
+-      char *channel_name = NULL;
+-      int channel_id = MAX_CMUX_CHANNELS_SUPPORTED;
++      char *channel_id_name = NULL;
++      int channel_id = g_mux_obj_ptr->channel_num;
+       int len = 0;
+       int i = 0;
+       int ret;
+@@ -244,16 +185,15 @@ static TReturn tcore_cmux_hal_send(TcoreHal *h, unsigned int data_len, void *dat
+               return TCORE_RETURN_FAILURE;
+       }
+-      channel_name = tcore_hal_get_name(h);
+-      dbg("HAL name: %s", channel_name)
+-      if (channel_name) {
+-              while (i < MAX_CMUX_CHANNELS_SUPPORTED) {
+-                      if (0 == strcmp((char *) cmux_channel_core_object[i].channel_id_name, (char *) channel_name)) {
++      channel_id_name = tcore_hal_get_name(h);
++      if (channel_id_name) {
++              while (i < g_mux_obj_ptr->channel_num) {
++                      if (strcmp((char *) g_mux_obj_ptr->channel_info[i]->channel_id_name, (char *) channel_id_name) == 0) {
+                               channel_id = i;
+                               dbg("Found Channel ID: %d", channel_id);
+                               /* Free memory */
+-                              free(channel_name);
++                              free(channel_id_name);
+                               break;
+                       }
+                       i++;
+@@ -263,7 +203,7 @@ static TReturn tcore_cmux_hal_send(TcoreHal *h, unsigned int data_len, void *dat
+               return TCORE_RETURN_FAILURE;
+       }
+-      if (channel_id > MAX_CMUX_CHANNELS_SUPPORTED) {
++      if (channel_id > g_mux_obj_ptr->channel_num) {
+               err("Failed to find Channel ID");
+               return TCORE_RETURN_FAILURE;
+       }
+@@ -292,9 +232,10 @@ static TReturn tcore_cmux_hal_set_sound_path(TcoreHal *hal, int device)
+ /* CMUX supported HAL (Logical HAL) operations */
+ static struct tcore_hal_operations mux_hops = {
+-      .power = tcore_cmux_hal_power,
++      .power = NULL,
+       .send = tcore_cmux_hal_send,
+       .set_sound_path = tcore_cmux_hal_set_sound_path,
++      .link_object_channel = NULL,
+ };
+ static TReturn tcore_cmux_send_data(int data_len, unsigned char *data)
+@@ -323,76 +264,41 @@ static gboolean tcore_cmux_recv_mux_data(CHANNEL *channel_ptr)
+       /* Dereferencing HAL from Channel Pointer */
+       hal = channel_ptr->hal;
+-      dbg("Dispatching to logical HAL - hal: %x", (unsigned int)hal);
++      dbg("Dispatching to logical HAL - hal: %x", hal);
+       tcore_hal_dispatch_response_data(hal, 0, g_mux_obj_ptr->info_field_len, g_mux_obj_ptr->info_field);
+       dbg("Exit");
+       return TRUE;
+ }
+-void tcore_cmux_link_core_object_hal(CMUX_Channels channel_id, TcorePlugin *plugin)
++TcoreHal *tcore_cmux_get_hal_channel(int channel_idx)
+ {
+-      TcoreHal *hal = NULL;
+-      CoreObject *co = NULL;
+-      int index;
+-
+       dbg("Entry");
+-      if (CMUX_CHANNEL_0 != channel_id) {
+-              dbg("Normal channel [%d]", channel_id);
+-
+-              /* Creating Logical HAL for Core Object - Mode - 'AT mode' */
+-              hal = tcore_hal_new(plugin, cmux_channel_core_object[channel_id].channel_id_name, &mux_hops, TCORE_HAL_MODE_AT);
+-              dbg("hal: %p", hal);
+-
+-              /* Update Logical HAL of CMUX Channel */
+-              g_mux_obj_ptr->channel_info[channel_id]->hal = hal;
+-
+-              index = 0;
+-              while (NULL != cmux_channel_core_object[channel_id].core_object_name[index]) {
+-                      /* Retrieving Core Object */
+-                      dbg("Core Object: '%s'", cmux_channel_core_object[channel_id].core_object_name[index]);
+-                      co = tcore_plugin_ref_core_object(plugin, cmux_channel_core_object[channel_id].core_object_name[index]);
+-                      dbg("co: %p", co);
+-
+-                      if (0 == strcmp((const char *) cmux_channel_core_object[channel_id].core_object_name[index], "modem")) {
+-                              g_mux_obj_ptr->modem_co = co;
+-                              dbg("'modem' Core object reference is stored");
+-                      }
+-
+-                      /* Set Logical HAL to Core objects */
+-                      tcore_object_set_hal(co, hal);
+-
+-                      /* Update Core Object list of CMUX Channel */
+-                      g_mux_obj_ptr->channel_info[channel_id]->co = g_slist_append(g_mux_obj_ptr->channel_info[channel_id]->co, co);
+-
+-                      /* Next Core Object of the channel */
+-                      index++;
+-              }
+-      } else {
+-              /* Control Channel */
+-              dbg("Control channel");
+-
+-              /* Creating Logical HAL for Core Object - Mode - 'AT mode' */
+-              hal = tcore_hal_new(plugin, cmux_channel_core_object[channel_id].channel_id_name, &mux_hops, TCORE_HAL_MODE_AT);
+-              dbg("hal: %p", hal);
+-
+-              /* Update Logical HAL of CMUX Channel */
+-              g_mux_obj_ptr->channel_info[channel_id]->hal = hal;
++      if (g_mux_obj_ptr == NULL) {
++              err("No multiplexer available");
++              return NULL;
+       }
+-      /* Set Logical HAL Power State to TRUE */
+-      tcore_hal_set_power_state(hal, TRUE);
+-      dbg("HAL Power is SET");
++      if (channel_idx >= g_mux_obj_ptr->channel_num) {
++              err("Channel ID out of range");
++              return NULL;
++      }
+       dbg("Exit");
+-      return;
++
++      return g_mux_obj_ptr->channel_info[channel_idx]->hal;
+ }
+-MUX* tcore_cmux_new(void)
++static MUX* tcore_cmux_new(int channel_num)
+ {
+       MUX *mux = NULL;
+-      int i = 0;
++      int i;
++
++      if (channel_num > MAX_CMUX_CHANNELS_SUPPORTED) {
++              err("Exceed number of supported channels");
++              return NULL;
++      }
+       /* Allocating memory for mux */
+       mux = (MUX *) calloc(sizeof(MUX), 1);
+@@ -401,6 +307,8 @@ MUX* tcore_cmux_new(void)
+               return NULL;
+       }
++      mux->channel_num = channel_num;
++
+       /* Allocating memory for info_field */
+       mux->info_field = (unsigned char *) calloc(MAX_CMUX_BUFFER_SIZE, 1);
+       if (!mux->info_field) {
+@@ -411,10 +319,8 @@ MUX* tcore_cmux_new(void)
+       /* MUX State initialize to MUX_NOT_INITIALIZED */
+       mux->state = MUX_NOT_INITIALIZED;
+-      /* Allocating memory for channel_info */
+-      for (i = 0; i < MAX_CMUX_CHANNELS_SUPPORTED; i++) {
++      for (i = 0; i < channel_num; i ++) {
+               mux->channel_info[i] = (CHANNEL *) calloc(sizeof(CHANNEL), 1);
+-              /* Check for Memory allocation failure */
+               if (!mux->channel_info[i]) {
+                       err("Failed to allocate memory for channel_info of channel: %d", i);
+                       goto ERROR;
+@@ -430,7 +336,7 @@ ERROR:
+                       free(mux->info_field);
+               }
+-              for (i = 0; i < MAX_CMUX_CHANNELS_SUPPORTED; i++) {
++              for (i = 0; i < channel_num; i++) {
+                       if (mux->channel_info[i]) {
+                               free(mux->channel_info[i]);
+                       }
+@@ -495,11 +401,11 @@ static unsigned char* tcore_encode_cmux_frame(unsigned char *data,
+               /* DLCI: Data Link Connection Identifier */
+               /* Check if the channel is within range */
+-              if (channel_id < MAX_CMUX_CHANNELS_SUPPORTED && channel_id >= 0) {
++              if (channel_id < g_mux_obj_ptr->channel_num && channel_id >= 0) {
+                       dbg("Channel ID: %d", channel_id);
+                       g_mux_obj_ptr->info_field[frame_length] = g_mux_obj_ptr->info_field[frame_length] | ((unsigned char) channel_id << 2);
+               } else {
+-                      err("Channel is out of range[0-8]");
++                      err("Channel is out of range[0-%d]", g_mux_obj_ptr->channel_num);
+                       return NULL;
+               }
+               frame_length++;
+@@ -694,21 +600,10 @@ static void tcore_cmux_process_channel_data(CHANNEL *channel_info_ptr)
+                       count++;
+                       dbg("Count: %d", count);
+-                      if (MAX_CMUX_CHANNELS_SUPPORTED == count) {
+-                              /* Indicate to CoreObject */
+-                              CoreObject *co = NULL;
+-
+-                              /* 'modem' Core Object */
+-                              co = g_mux_obj_ptr->modem_co;
+-                              if (NULL == co) {
+-                                      err("'modem' Core object is not present");
+-                                      return;
+-                              }
+-
+-                              /* Emit callback */
+-                              dbg("Emit Core object callback");
+-                              tcore_object_emit_callback(co, "CMUX-UP", NULL);
+-                              dbg("Emitted Core object callback");
++                      if (g_mux_obj_ptr->channel_num == count) {
++
++                              /* Call init callback to notify mux is ready */
++                              g_mux_obj_ptr->cb_init(g_mux_obj_ptr->cb_data);
+                               /* Reset 'count' */
+                               count = 0;
+@@ -840,7 +735,7 @@ static void tcore_cmux_process_rcv_frame(unsigned char *data, int len)
+       /* Get the Channel ID : 1st byte will be flag (F9)..Flag checking is already done.*/
+       channel_id = (*++frame_process_ptr >> 2) & 0x3F;
+-      if (channel_id < MAX_CMUX_CHANNELS_SUPPORTED) {          // max channel is 8
++      if (channel_id < g_mux_obj_ptr->channel_num) {          // max channel is 8
+               ch = g_mux_obj_ptr->channel_info[channel_id];
+               ch->channel_id = channel_id;
+@@ -1029,9 +924,9 @@ static void tcore_cmux_channel_init(CMUX_Channels channel_id)
+       memset(ch, 0x0, sizeof(CHANNEL));
+       ch->channel_id = channel_id;
++      ch->channel_id_name = g_strdup_printf("channel_%d", channel_id);
+       ch->state = MUX_CHANNEL_SABM_SEND_WAITING_FOR_UA;
+-      ch->co = NULL;
+       ch->hal = NULL;
+       /* TODO - Check if required */
+@@ -1045,7 +940,7 @@ static void tcore_cmux_channel_init(CMUX_Channels channel_id)
+       return;
+ }
+-static void tcore_cmux_close_channel(int channel_id)
++static void tcore_cmux_close_channel(int channel_idx)
+ {
+       CHANNEL *ch = NULL;
+       unsigned char *send_data = NULL;
+@@ -1053,7 +948,13 @@ static void tcore_cmux_close_channel(int channel_id)
+       dbg("Entry");
+-      ch = g_mux_obj_ptr->channel_info[channel_id];
++      ch = g_mux_obj_ptr->channel_info[channel_idx];
++
++      if (ch == NULL)
++              return;
++
++      g_free(ch->channel_id_name);
++      ch->channel_id_name = NULL;
+       if (ch->state != MUX_CHANNEL_CLOSED) {
+               ch->frame_type = CMUX_COMMAND_DISC;
+@@ -1063,26 +964,24 @@ static void tcore_cmux_close_channel(int channel_id)
+               /* Send DSC command */
+               /* Encoding frame */
+-              send_data = tcore_encode_cmux_frame(NULL, 0, channel_id, CMUX_COMMAND_DISC, 0x01, 0x01, 0x01, &len);
+-              if (0 != len) {
++              send_data = tcore_encode_cmux_frame(NULL, 0, channel_idx, CMUX_COMMAND_DISC, 0x01, 0x01, 0x01, &len);
++              if (0 > len)
+                       /* Send CMUX data */
+                       ret = tcore_cmux_send_data(len, send_data);
+-              } else {
++              else
+                       err("Failed to encode");
+-              }
+-      } else {
++      } else
+               /* Channel is already closed */
+               err("Channel is already closed");
+-      }
++
++      free(g_mux_obj_ptr->channel_info[channel_idx]);
++      g_mux_obj_ptr->channel_info[channel_idx] = NULL;
+       dbg("Exit");
+-      return;
+ }
+ static void tcore_cmux_free(void)
+ {
+-      int channel;
+-
+       dbg("Entry");
+       if (g_mux_obj_ptr) {
+@@ -1092,14 +991,6 @@ static void tcore_cmux_free(void)
+                       g_mux_obj_ptr->info_field = NULL;
+               }
+-              for (channel = 0; channel < MAX_CMUX_CHANNELS_SUPPORTED; channel++) {
+-                      /* Free Channel Information */
+-                      if (g_mux_obj_ptr->channel_info[channel]) {
+-                              free(g_mux_obj_ptr->channel_info[channel]);
+-                              g_mux_obj_ptr->channel_info[channel] = NULL;
+-                      }
+-              }
+-
+               /* Free MUX Object */
+               free(g_mux_obj_ptr);
+               g_mux_obj_ptr = NULL;
+@@ -1111,21 +1002,21 @@ static void tcore_cmux_free(void)
+       return;
+ }
+-TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal)
++TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal,
++                              CMuxInitCallBack cb, void *user_data,
++                              int channel_num)
+ {
++      TReturn ret = TCORE_RETURN_SUCCESS;
+       unsigned char *data = NULL;
+       int data_len = 0;
+-
+       int index;
+-      TReturn ret = TCORE_RETURN_SUCCESS;
+-
+       dbg("Entry");
+-      dbg("Physical HAL: %x", (unsigned int)hal);
++      dbg("Physical HAL: %x", hal);
+       /* Creat new CMUX Object */
+-      g_mux_obj_ptr = tcore_cmux_new();
++      g_mux_obj_ptr = tcore_cmux_new(channel_num);
+       if (NULL == g_mux_obj_ptr) {
+               err("Failed to create MUX object");
+@@ -1139,18 +1030,11 @@ TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal)
+       /* Save Physical HAL */
+       g_mux_obj_ptr->phy_hal = hal;
+-      /* Setting Receive callback function for data received from Physical HAL */
+-      g_mux_obj_ptr->cb_func = tcore_cmux_recv_mux_data;
++      /* Set init callback function and data */
++      g_mux_obj_ptr->cb_init = cb;
++      g_mux_obj_ptr->cb_data = user_data;
+-      /* After MUX setup, AT parse functionality of PHY HAL should be disabled,
+-        * here we change the mode of PHYSICAL HAL to Transparent.
+-        */
+-      tcore_hal_set_mode(g_mux_obj_ptr->phy_hal, TCORE_HAL_MODE_TRANSPARENT);
+-      dbg("Physical HAL mode changed to Transparent");
+-
+-      /* Initialize all the Channels */
+-      /* Open all Channels */
+-      for (index = 0; index < MAX_CMUX_CHANNELS_SUPPORTED; index++) {
++      for (index = 0; index < channel_num; index ++) {
+               dbg("Initialize the Channel %d", index);
+               tcore_cmux_channel_init((CMUX_Channels) index);
+@@ -1169,10 +1053,22 @@ TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal)
+               tcore_cmux_send_data(data_len, data);
+               dbg("CMUX Control Request sent to CP");
+-              /* Set Core object and HAL */
+-              tcore_cmux_link_core_object_hal((CMUX_Channels) index, plugin);
++              hal = tcore_hal_new(plugin, g_mux_obj_ptr->channel_info[index]->channel_id_name, &mux_hops, TCORE_HAL_MODE_AT);
++
++              /* Update Logical HAL of CMUX Channel */
++              g_mux_obj_ptr->channel_info[index]->hal = hal;
++
++              /* Set Logical HAL Power State to TRUE */
++              tcore_hal_set_power_state(hal, TRUE);
+       }
++      /*
++       * After MUX setup, AT parse functionality of PHY HAL should be disabled,
++       * here we change the mode of PHYSICAL HAL to Transparent.
++       */
++      tcore_hal_set_mode(g_mux_obj_ptr->phy_hal, TCORE_HAL_MODE_TRANSPARENT);
++      dbg("Physical HAL mode changed to Transparent");
++
+       dbg("Exit");
+       return ret;
+@@ -1187,68 +1083,27 @@ ERROR:
+ void tcore_cmux_close(void)
+ {
+       int channel = 0;
+-      int index = 0;
+-      CoreObject *co = NULL;
+-      GSList *co_list = NULL;
+       dbg("Entry");
+-      for (channel = 0; channel < MAX_CMUX_CHANNELS_SUPPORTED; channel++) {
++      for (channel = 0; channel < g_mux_obj_ptr->channel_num; channel++) {
+               dbg("Channel ID: %d", channel);
+-              index = 0;
+               /* Close Channel - Send DSC command */
+               tcore_cmux_close_channel(channel);
+-              /* Revert Physical HAL as HAL of each Core Object associated to this Channel */
+-              while (NULL != cmux_channel_core_object[channel].core_object_name[index]) {
+-                      co = NULL;
+-
+-                      /* Core Objects list */
+-                      co_list = g_mux_obj_ptr->channel_info[channel]->co;
+-                      dbg("Core Objects list : %p", co_list);
+-
+-                      /* Core Object list may contain multiple Core Objects.
+-                        * Revert to Physical HAL for each of the Core Objects associated
+-                        * with this Channel
+-                        */
+-                      while (NULL != co_list) {
+-                              if (NULL != co_list->data) {
+-                                      if (!strcmp((const char *) cmux_channel_core_object[channel].core_object_name[index], (const char *) tcore_object_ref_name((CoreObject *) co_list->data))) {
+-                                              co = (CoreObject *) co_list->data;
+-                                              dbg("Core Object found ");
+-                                              break;
+-                                      }
+-                              }
+-
+-                              /* To next Core Object in the list */
+-                              co_list = co_list->next;
+-                      }
+-
+-                      /* Set the previous Physical HAL as HAL for Core Object */
+-                      if (NULL != co) {
+-                              tcore_object_set_hal(co, g_mux_obj_ptr->phy_hal);
+-                      } else {
+-                              /* Proceed to next Channel */
+-                              err("No more Core Objects present in this Channel");
+-                              break;
+-                      }
+-
+-                      /* To next Core Object */
+-                      index++;
+-              }
+-
+               /* Free Logical HAL for Channel */
+               tcore_hal_free(g_mux_obj_ptr->channel_info[channel]->hal);
+               g_mux_obj_ptr->channel_info[channel]->hal = NULL;
+       }
+-      /* Change the mode of PHYSICAL HAL to Custom */
++      /* Change the mode of PHYSICAL HAL to AT */
+       tcore_hal_set_mode(g_mux_obj_ptr->phy_hal, TCORE_HAL_MODE_AT);
+       /* Free all the allocated memory */
+       tcore_cmux_free();
+       dbg("Exit");
++
+       return;
+ }
+-- 
+1.7.10.4
+
diff --git a/packaging/0006-notification-Add-new-notifcation-type.patch b/packaging/0006-notification-Add-new-notifcation-type.patch
new file mode 100644 (file)
index 0000000..646ef4c
--- /dev/null
@@ -0,0 +1,26 @@
+From 00565c321fc84175fbc3aa599b074d30f798e4ec Mon Sep 17 00:00:00 2001
+From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
+Date: Mon, 8 Oct 2012 11:32:11 +0200
+Subject: [PATCH 06/10] notification: Add new notifcation type
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+---
+ include/type/notification.h |    1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/include/type/notification.h b/include/type/notification.h
+index 3fa9520..a196226 100644
+--- a/include/type/notification.h
++++ b/include/type/notification.h
+@@ -84,6 +84,7 @@ enum tcore_notification_command {
+       TNOTI_SS_RELEASE_COMPLETE,
+       TNOTI_MODEM = TCORE_NOTIFICATION | TCORE_TYPE_MODEM,
++      TNOTI_MODEM_ADDED,
+       TNOTI_MODEM_POWER,
+       TNOTI_MODEM_FLIGHT_MODE,
+       TNOTI_MODEM_DUN_PIN_CONTROL,
+-- 
+1.7.10.4
+
diff --git a/packaging/0007-at-Add-Connect-to-success-responses.patch b/packaging/0007-at-Add-Connect-to-success-responses.patch
new file mode 100644 (file)
index 0000000..b526cc2
--- /dev/null
@@ -0,0 +1,26 @@
+From 5f313b36343eae686e0f630d1dc037513b4aac1e Mon Sep 17 00:00:00 2001
+From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
+Date: Thu, 4 Oct 2012 14:59:15 +0200
+Subject: [PATCH 07/10] at: Add Connect to success responses
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+---
+ src/at.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/at.c b/src/at.c
+index 00e40f9..c13d830 100644
+--- a/src/at.c
++++ b/src/at.c
+@@ -75,6 +75,7 @@ struct _notification {
+  */
+ static const char *list_final_responses_success[] = {
+     "OK",
++    "CONNECT",
+ };
+ /**
+-- 
+1.7.10.4
+
diff --git a/packaging/0008-hal-Add-new-setup_pdp-entry-point-declaration-and-DA.patch b/packaging/0008-hal-Add-new-setup_pdp-entry-point-declaration-and-DA.patch
new file mode 100644 (file)
index 0000000..ec7fd7c
--- /dev/null
@@ -0,0 +1,61 @@
+From aef0af1166e2f7b6b3d53992774135891e379deb Mon Sep 17 00:00:00 2001
+From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
+Date: Thu, 4 Oct 2012 15:00:41 +0200
+Subject: [PATCH 08/10] hal: Add new setup_pdp entry point declaration and
+ DATA mode
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+---
+ include/hal.h |   13 ++++++++++++-
+ 1 file changed, 12 insertions(+), 1 deletion(-)
+
+diff --git a/include/hal.h b/include/hal.h
+index bed6684..1e8a072 100644
+--- a/include/hal.h
++++ b/include/hal.h
+@@ -26,6 +26,7 @@ __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);
+ typedef void (*TcoreHalPowerCallBack)(TcoreHal *hal, void *user_data);
++typedef void (*TcoreHalSetupPDPCallBack)(CoreObject *co, const char *iname, void *user_data);
+ enum tcore_hal_recv_data_type {
+       TCORE_HAL_RECV_INDICATION,
+@@ -38,7 +39,8 @@ enum tcore_hal_mode {
+       TCORE_HAL_MODE_UNKNOWN,
+       TCORE_HAL_MODE_AT,
+       TCORE_HAL_MODE_CUSTOM,
+-    TCORE_HAL_MODE_TRANSPARENT
++      TCORE_HAL_MODE_TRANSPARENT,
++      TCORE_HAL_MODE_DATA,
+ };
+ struct tcore_hal_operations {
+@@ -47,6 +49,10 @@ struct tcore_hal_operations {
+       TReturn (*send)(TcoreHal *hal, unsigned int data_len, void *data);
+       TReturn (*set_sound_path)(TcoreHal *hal, int device);
+       TReturn (*link_object_channel)(CoreObject *object);
++      TReturn (*setup_pdp)(CoreObject *object,
++                              TcoreHalSetupPDPCallBack func,
++                              void *user_data,
++                              unsigned int cid);
+ };
+ TcoreHal*    tcore_hal_new(TcorePlugin *plugin, const char *name,
+@@ -68,7 +74,12 @@ TReturn           tcore_hal_set_sound_path(TcoreHal *hal, int device);
+ TReturn      tcore_hal_link_user_data(TcoreHal *hal, void *user_data);
+ void*        tcore_hal_ref_user_data(TcoreHal *hal);
++
+ TReturn            tcore_hal_link_object(TcoreHal *hal, CoreObject *co);
++TReturn      tcore_hal_setup_pdp(TcoreHal *hal, CoreObject *co,
++                                      TcoreHalSetupPDPCallBack func,
++                                      void *user_data,
++                                      unsigned int cid);
+ TReturn      tcore_hal_send_data(TcoreHal *hal, unsigned int data_len, void *data);
+ TReturn      tcore_hal_send_request(TcoreHal *hal, TcorePending *pending);
+-- 
+1.7.10.4
+
diff --git a/packaging/0009-hal-Add-tcore_hal_setup_pdp-definition-and-mana-DATA.patch b/packaging/0009-hal-Add-tcore_hal_setup_pdp-definition-and-mana-DATA.patch
new file mode 100644 (file)
index 0000000..a23a748
--- /dev/null
@@ -0,0 +1,49 @@
+From ef579dee232a6fdddaf08c537c548cfa2e9d0240 Mon Sep 17 00:00:00 2001
+From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
+Date: Thu, 4 Oct 2012 15:01:27 +0200
+Subject: [PATCH 09/10] hal: Add tcore_hal_setup_pdp definition and mana DATA
+ mode
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+---
+ src/hal.c |   16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/src/hal.c b/src/hal.c
+index 9ade963..579d765 100644
+--- a/src/hal.c
++++ b/src/hal.c
+@@ -249,6 +249,16 @@ TReturn tcore_hal_link_object(TcoreHal *hal, CoreObject *co)
+       return hal->ops->link_object_channel(co);
+ }
++TReturn tcore_hal_setup_pdp(TcoreHal *hal, CoreObject *co,
++                              TcoreHalSetupPDPCallBack func,
++                              void *user_data,
++                              unsigned int cid)
++{
++      if (!hal)
++              return TCORE_RETURN_EINVAL;
++
++      return hal->ops->setup_pdp(co, func, user_data, cid);
++}
+ void *tcore_hal_ref_user_data(TcoreHal *hal)
+ {
+       if (!hal)
+@@ -356,6 +366,12 @@ TReturn tcore_hal_dispatch_response_data(TcoreHal *hal, int id,
+                       /* Invoke CMUX receive API for decoding */
+                       tcore_cmux_rcv_from_hal((unsigned char *)data, data_len);
++              } else if (hal->mode == TCORE_HAL_MODE_DATA) {
++                      dbg("TCORE_HAL_MODE_DATA");
++
++                      tcore_hal_emit_recv_callback(hal, data_len, data);
++
++                      return TCORE_RETURN_SUCCESS;
+               }
+               /* Send next request in queue */
+               g_idle_add_full(IDLE_SEND_PRIORITY, _hal_idle_send, hal, NULL );
+-- 
+1.7.10.4
+
diff --git a/packaging/0010-mux-Initialize-setup_pdp-entry-point.patch b/packaging/0010-mux-Initialize-setup_pdp-entry-point.patch
new file mode 100644 (file)
index 0000000..69ca6b2
--- /dev/null
@@ -0,0 +1,40 @@
+From 9c702353c5a38d8c0b45dfc6fe579644d5016479 Mon Sep 17 00:00:00 2001
+From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
+Date: Thu, 4 Oct 2012 15:01:59 +0200
+Subject: [PATCH 10/10] mux: Initialize setup_pdp entry point
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+---
+ src/mux.c |    9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/src/mux.c b/src/mux.c
+index 3794685..4cdaa67 100644
+--- a/src/mux.c
++++ b/src/mux.c
+@@ -230,12 +230,21 @@ static TReturn tcore_cmux_hal_set_sound_path(TcoreHal *hal, int device)
+       return tcore_hal_set_sound_path(g_mux_obj_ptr->phy_hal, device);
+ }
++static TReturn hal_setup_pdp(CoreObject *co, TcoreHalSetupPDPCallBack func,
++                              void *user_data, unsigned int cid)
++{
++      /* Redirect request to physical HAL */
++      return tcore_hal_setup_pdp(g_mux_obj_ptr->phy_hal, co, func,
++                                      user_data, cid);
++}
++
+ /* CMUX supported HAL (Logical HAL) operations */
+ static struct tcore_hal_operations mux_hops = {
+       .power = NULL,
+       .send = tcore_cmux_hal_send,
+       .set_sound_path = tcore_cmux_hal_set_sound_path,
+       .link_object_channel = NULL,
++      .setup_pdp = hal_setup_pdp,
+ };
+ static TReturn tcore_cmux_send_data(int data_len, unsigned char *data)
+-- 
+1.7.10.4
+
diff --git a/packaging/libtcore.spec b/packaging/libtcore.spec
new file mode 100644 (file)
index 0000000..00af71e
--- /dev/null
@@ -0,0 +1,82 @@
+#sbs-git:slp/pkgs/l/libtcore
+Name: libtcore
+Summary: Telephony-core library
+Version: 0.1.114
+Release:    1
+Group:      System/Libraries
+License:    Apache
+Source0:    libtcore-%{version}.tar.gz
+%ifarch %ix86
+%if "%{simulator}" != "1"
+patch0: 0001-hal-Add-set_sound_path-function.patch
+patch1: 0002-hal-Add-new-entry-points-and-method-declarations.patch
+patch2: 0003-hal-Add-new-method-definitions.patch
+patch3: 0004-mux-Declare-new-public-API-for-HAL-plugin-manipulati.patch
+patch4: 0005-mux-Remove-plateform-dependencies-from-core-multiple.patch
+patch5: 0006-notification-Add-new-notifcation-type.patch
+patch6: 0007-at-Add-Connect-to-success-responses.patch
+patch7: 0008-hal-Add-new-setup_pdp-entry-point-declaration-and-DA.patch
+patch8: 0009-hal-Add-tcore_hal_setup_pdp-definition-and-mana-DATA.patch
+patch9: 0010-mux-Initialize-setup_pdp-entry-point.patch
+%endif
+%endif
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(gudev-1.0)
+
+%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
+%ifarch %ix86
+%if "%{simulator}" != "1"
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
+%patch8 -p1
+%patch9 -p1
+%endif
+%endif
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DVERSION=%{version}
+make %{?jobs:-j%jobs}
+
+%post
+/sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%install
+rm -rf %{buildroot}
+%make_install
+mkdir -p %{buildroot}/usr/share/license
+
+%files
+%manifest libtcore.manifest
+%defattr(-,root,root,-)
+#%doc COPYING
+%{_libdir}/libtcore*
+#%{_bindir}/*
+/usr/share/license/libtcore
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/*
+%{_libdir}/pkgconfig/tcore.pc
diff --git a/src/at.c b/src/at.c
new file mode 100644 (file)
index 0000000..00e40f9
--- /dev/null
+++ b/src/at.c
@@ -0,0 +1,909 @@
+/*
+ * 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 <stdlib.h>
+#include <ctype.h>
+
+#include <glib.h>
+
+#include "tcore.h"
+#include "hal.h"
+#include "queue.h"
+#include "user_request.h"
+#include "at.h"
+
+#define NUM_ELEMS(x) (sizeof(x)/sizeof(x[0]))
+
+#define CR '\r'
+#define LF '\n'
+
+#define MAX_AT_RESPONSE    255  // for testing
+//#define MAX_AT_RESPONSE    8191
+
+struct tcore_at_type {
+       TcoreHal *hal;
+
+       enum tcore_at_command_type cmd_type;
+
+       GHashTable *unsolicited_table;
+
+       struct tcore_at_request *req;
+       struct tcore_at_response *resp;
+
+       unsigned int buf_size;
+       char *buf;
+       char *buf_read_pos;
+       char *buf_write_pos;
+
+       gboolean pdu_status;
+       struct _notification *pdu_noti;
+       GSList *pdu_lines;
+};
+
+struct _notification_callback {
+       TcoreATNotificationCallback callback;
+       void *user_data;
+};
+
+struct _notification {
+       gboolean type_pdu;
+       GSList *callbacks;
+};
+
+/**
+ * returns 1 if line is a final response indicating success
+ * See 27.007 annex B
+ */
+static const char *list_final_responses_success[] = {
+    "OK",
+};
+
+/**
+ * returns 1 if line is a final response indicating error
+ * See 27.007 annex B
+ */
+static const char *list_final_responses_error[] = {
+    "ERROR",
+    "+CMS ERROR:",
+    "+CME ERROR:",
+    "NO ANSWER",
+    "NO DIALTONE",
+};
+
+static int _check_final_response(const char *line)
+{
+       unsigned int i;
+
+       for (i = 0; i < NUM_ELEMS(list_final_responses_success); i++) {
+               if (g_str_has_prefix(line, list_final_responses_success[i])) {
+                       return 1;
+               }
+       }
+
+       for (i = 0; i < NUM_ELEMS(list_final_responses_error); i++) {
+               if (g_str_has_prefix(line, list_final_responses_error[i])) {
+                       return 2;
+               }
+       }
+
+       return 0;
+}
+
+
+static char *_find_next_EOL(char *cur)
+{
+       if (cur[0] == '>' && cur[1] == ' ' && cur[2] == '\0') {
+               /* SMS prompt character...not \r terminated */
+               return cur + 2;
+       }
+
+       // Find next newline
+       while (*cur != '\0' && *cur != CR)
+               cur++;
+
+       return *cur == '\0' ? NULL : cur;
+}
+
+static struct tcore_at_response* _response_new()
+{
+       struct tcore_at_response *resp;
+
+       resp = calloc(sizeof(struct tcore_at_response), 1);
+       if (!resp)
+               return NULL;
+
+       return resp;
+}
+
+static void _response_free(struct tcore_at_response *resp)
+{
+       if (!resp)
+               return;
+
+       if (resp->lines) {
+               g_slist_free_full(resp->lines, g_free);
+       }
+
+       if (resp->final_response)
+               free(resp->final_response);
+
+       free(resp);
+}
+
+
+static void _response_add(struct tcore_at_response *resp,
+               const char *line)
+{
+       if (!resp || !line)
+               return;
+
+       dbg("current lines = %d", g_slist_length(resp->lines));
+
+       resp->lines = g_slist_append(resp->lines, strdup(line));
+}
+
+static void _emit_pending_response(TcoreAT *at)
+{
+       TcorePending *p;
+
+       if (!at)
+               return;
+
+       tcore_at_request_free(at->req);
+       at->req = NULL;
+
+       p = tcore_queue_pop(tcore_hal_ref_queue(at->hal));
+       if (!p) {
+               dbg("no pending");
+       }
+
+       tcore_pending_emit_response_callback(p, sizeof(TcoreATResponse *), at->resp);
+       tcore_user_request_unref(tcore_pending_ref_user_request(p));
+       tcore_pending_free(p);
+
+       _response_free(at->resp);
+       at->resp = NULL;
+}
+
+static void _emit_unsolicited_message(TcoreAT *at, const char *line)
+{
+       struct _notification *noti = NULL;
+       struct _notification_callback *item = NULL;
+       GSList *p;
+       GHashTableIter iter;
+       gpointer key = NULL, value;
+       gboolean ret;
+       GSList *data = NULL;
+
+       if (!at || !line)
+               return;
+
+       if (at->pdu_status == FALSE) {
+               g_hash_table_iter_init(&iter, at->unsolicited_table);
+
+               while (g_hash_table_iter_next(&iter, &key, &value)) {
+                       if (!g_str_has_prefix(line, key))
+                               continue;
+
+                       noti = value;
+                       break;
+               }
+
+               if (!noti)
+                       return;
+
+               if (noti->type_pdu == TRUE) {
+                       at->pdu_status = TRUE;
+                       at->pdu_noti = noti;
+                       at->pdu_lines = g_slist_append(NULL, g_strdup(line));
+                       dbg("PDU mode");
+                       return;
+               }
+
+               data = g_slist_append(NULL, g_strdup(line));
+       }
+       else {
+               noti = at->pdu_noti;
+               at->pdu_status = FALSE;
+               at->pdu_noti = NULL;
+               at->pdu_lines = g_slist_append(at->pdu_lines, g_strdup(line));
+
+               data = at->pdu_lines;
+       }
+
+       p = noti->callbacks;
+       while (p) {
+               item = p->data;
+               if (!item) {
+                       p = p->next;
+                       continue;
+               }
+
+               ret = item->callback(at, data, item->user_data);
+               if (ret == FALSE) {
+                       p = p->next;
+                       noti->callbacks = g_slist_remove(noti->callbacks, item);
+                       continue;
+               }
+
+               p = p->next;
+       }
+
+
+       g_slist_free_full(data, g_free);
+       at->pdu_lines = NULL;
+
+       if (g_slist_length(noti->callbacks) == 0) {
+               g_hash_table_remove(at->unsolicited_table, key);
+       }
+
+}
+
+static void _free_noti_list(void *data)
+{
+       struct _notification *noti = data;
+
+       if (!data)
+               return;
+
+       g_slist_free_full(noti->callbacks, g_free);
+}
+
+#if 0
+static void _msgat(const char *prefix, const char *str)
+{
+       unsigned int i;
+       char buf[8192] = {0,};
+       char *pos;
+
+       if (!str) {
+               msg("str is NULL");
+               return;
+       }
+
+       if (strlen(str) > 4096) {
+               msg("%s[%s]", prefix, str);
+               return;
+       }
+
+       pos = buf;
+       for (i = 0; i < strlen(str); i++) {
+               if (str[i] == '\r') {
+                       strncpy(pos, "<CR>", 4);
+                       pos += 4;
+               }
+               else if (str[i] == '\n') {
+                       strncpy(pos, "<LF>", 4);
+                       pos += 4;
+               }
+               else {
+                       *pos = str[i];
+                       pos++;
+               }
+
+       }
+
+       msg("%s[%s]", prefix, buf);
+}
+#endif
+
+TcoreAT *tcore_at_new(TcoreHal *hal)
+{
+       TcoreAT *at;
+
+       at = calloc(sizeof(struct tcore_at_type), 1);
+       if (!at)
+               return NULL;
+
+       at->hal = hal;
+       at->buf_size = MAX_AT_RESPONSE;
+       at->buf = calloc(at->buf_size + 1, 1);
+       at->buf_read_pos = at->buf;
+       at->buf_write_pos = at->buf;
+
+       at->unsolicited_table = g_hash_table_new_full(g_str_hash, g_str_equal,
+                       g_free, _free_noti_list );
+
+       return at;
+}
+
+void tcore_at_free(TcoreAT *at)
+{
+       if (!at)
+               return;
+
+       if (at->buf)
+               free(at->buf);
+
+       if (at->unsolicited_table)
+               g_hash_table_destroy(at->unsolicited_table);
+
+       free(at);
+}
+
+TReturn tcore_at_remove_notification_full(TcoreAT *at, const char *prefix,
+               TcoreATNotificationCallback callback, void *user_data)
+{
+       struct _notification *noti;
+       struct _notification_callback *item;
+       GSList *p;
+
+       if (!at || !prefix)
+               return TCORE_RETURN_EINVAL;
+
+       if (!callback) {
+               /* remove all callbacks for prefix */
+               g_hash_table_remove(at->unsolicited_table, prefix);
+               return TCORE_RETURN_SUCCESS;
+       }
+
+       noti = g_hash_table_lookup(at->unsolicited_table, prefix);
+       if (!noti)
+               return TCORE_RETURN_SUCCESS;
+
+       p = noti->callbacks;
+       for(; p; p = p->next) {
+               item = p->data;
+               if (!item)
+                       continue;
+
+               if (callback == item->callback) {
+                       if (!user_data) {
+                               noti->callbacks = g_slist_remove(noti->callbacks, item);
+                               continue;
+                       }
+
+                       if (user_data == item->user_data) {
+                               noti->callbacks = g_slist_remove(noti->callbacks, item);
+                               continue;
+                       }
+               }
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+
+TReturn tcore_at_remove_notification(TcoreAT *at, const char *prefix,
+               TcoreATNotificationCallback callback)
+{
+       return tcore_at_remove_notification_full(at, prefix, callback, NULL);
+}
+
+TReturn tcore_at_add_notification(TcoreAT *at, const char *prefix,
+               gboolean pdu, TcoreATNotificationCallback callback,
+               void *user_data)
+{
+       struct _notification *noti;
+       struct _notification_callback *item;
+
+       if (!at || !prefix || !callback)
+               return TCORE_RETURN_EINVAL;
+
+       noti = g_hash_table_lookup(at->unsolicited_table, prefix);
+       if (!noti) {
+               noti = calloc(sizeof(struct _notification), 1);
+               if (!noti)
+                       return TCORE_RETURN_ENOMEM;
+
+               noti->type_pdu = pdu;
+               noti->callbacks = NULL;
+
+               g_hash_table_insert(at->unsolicited_table, g_strdup(prefix), noti);
+       }
+
+       if (noti->type_pdu != pdu)
+               return TCORE_RETURN_EINVAL;
+
+       item = calloc(sizeof(struct _notification_callback), 1);
+       if (!item)
+               return TCORE_RETURN_ENOMEM;
+
+       item->callback = callback;
+       item->user_data = user_data;
+
+       noti->callbacks = g_slist_append(noti->callbacks, item);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TReturn tcore_at_set_request(TcoreAT *at, TcoreATRequest *req, gboolean send)
+{
+       TReturn ret;
+       char *end;
+       char next;
+
+       if (!at)
+               return TCORE_RETURN_EINVAL;
+
+       at->req = req;
+
+       if (req) {
+               dbg("req->cmd = [%s]", at->req->cmd);
+               dbg("req->prefix = [%s]", at->req->prefix);
+               dbg("req->type = %d", at->req->type);
+       }
+
+       if (send == FALSE)
+               return TCORE_RETURN_SUCCESS;
+
+       end = strchr(at->req->cmd, CR);
+       next = *(end + 1);
+       if (next == '\0') {
+               return tcore_hal_send_data(at->hal, strlen(req->cmd), req->cmd);
+       }
+
+       dbg("backup data = [%c]", next);
+       at->req->next_send_pos = end + 1;
+       dbg("next data = [%s]", at->req->next_send_pos);
+
+       *(end+1) = '\0';
+       ret = tcore_hal_send_data(at->hal, strlen(req->cmd), req->cmd);
+       *(end+1) = next;
+
+       return ret;
+}
+
+TcoreATRequest *tcore_at_get_request(TcoreAT *at)
+{
+       if (!at)
+               return NULL;
+
+       return at->req;
+}
+
+
+TcoreATResponse *tcore_at_get_response(TcoreAT *at)
+{
+       if (!at)
+               return NULL;
+
+       return at->resp;
+}
+
+TReturn tcore_at_buf_write(TcoreAT *at, unsigned int data_len, const char *data)
+{
+       unsigned int read_pos;
+       unsigned int write_pos;
+
+       if (!at)
+               return TCORE_RETURN_EINVAL;
+
+       read_pos = at->buf_read_pos - at->buf;
+       write_pos = at->buf_write_pos - at->buf;
+
+       if (write_pos + data_len >= at->buf_size) {
+               /* shift left (trim completed data) */
+               dbg("shift left buffer (request data_len = %d)", data_len);
+               dbg("before read_pos=buf+%d, write_pos=buf+%d", read_pos, write_pos);
+               memmove(at->buf, at->buf_read_pos, at->buf_size - read_pos);
+               at->buf_read_pos = at->buf;
+               at->buf_write_pos = at->buf + write_pos - read_pos;
+               dbg("after  read_pos=buf+%d, write_pos=buf+%d",
+                               at->buf_read_pos - at->buf,
+                               at->buf_write_pos - at->buf);
+               memset(at->buf_write_pos, 0, at->buf_size - (at->buf_write_pos - at->buf));
+       }
+
+       write_pos = at->buf_write_pos - at->buf;
+       if (write_pos + data_len >= at->buf_size) {
+               while (1) {
+                       at->buf_size = at->buf_size << 1;
+                       if (at->buf_size > write_pos + data_len)
+                               break;
+               }
+               at->buf = realloc(at->buf, at->buf_size);
+               at->buf_read_pos = at->buf;
+               at->buf_write_pos = at->buf + write_pos;
+               memset(at->buf_write_pos, 0, at->buf_size - (at->buf_write_pos - at->buf));
+
+               dbg("resize buffer to %d", at->buf_size);
+       }
+
+       memcpy(at->buf_write_pos, data, data_len);
+
+       at->buf_write_pos += data_len;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TcoreATRequest* tcore_at_request_new(const char *cmd, const char *prefix, enum tcore_at_command_type type)
+{
+       TcoreATRequest *req;
+
+       if (!cmd)
+               return NULL;
+
+       if (strlen(cmd) < 1)
+               return NULL;
+
+       req = calloc(sizeof(struct tcore_at_request), 1);
+       if (!req)
+               return NULL;
+
+       if (!strchr(cmd, CR))
+               req->cmd = g_strdup_printf("%s%c", cmd, CR);
+       else
+               req->cmd = g_strdup_printf("%s%c", cmd, 26);
+
+       if (prefix)
+               req->prefix = strdup(prefix);
+
+       req->type = type;
+
+       return req;
+}
+
+void tcore_at_request_free(TcoreATRequest *req)
+{
+       if (!req)
+               return;
+
+       if (req->cmd)
+               free(req->cmd);
+
+       if (req->prefix)
+               free(req->prefix);
+
+       free(req);
+}
+
+gboolean tcore_at_process(TcoreAT *at, unsigned int data_len, const char *data)
+{
+       char *pos;
+       char *next_pos;
+       int ret;
+
+       if (!at || !data)
+               return FALSE;
+
+       tcore_at_buf_write(at, data_len, data);
+
+       pos = at->buf_read_pos;
+
+       while (1) {
+
+               while (*pos == CR || *pos == LF)
+                       pos++;
+
+               next_pos = _find_next_EOL(pos);
+               if (!next_pos)
+                       break;
+
+               if (pos != next_pos)
+                       *next_pos = '\0';
+
+               //dbg("complete line found.");
+               dbg("line = [%s]", pos);
+
+               // check request
+               if (!at->req) {
+                       _emit_unsolicited_message(at, pos);
+               }
+               else {
+
+                       if (g_strcmp0(pos, "> ") == 0) {
+                               if (at->req->next_send_pos) {
+                                       dbg("send next: [%s]", at->req->next_send_pos);
+                                       tcore_hal_send_data(at->hal, strlen(at->req->next_send_pos), at->req->next_send_pos);
+                                       pos += 2;
+                                       at->buf_read_pos = pos;
+                                       break;
+                               }
+                       }
+
+                       if (!at->resp) {
+                               at->resp = _response_new();
+                       }
+
+                       ret = _check_final_response(pos);
+                       if (ret) {
+                               if (ret == 1)
+                                       at->resp->success = TRUE;
+                               else
+                                       at->resp->success = FALSE;
+
+                               at->resp->final_response = strdup(pos);
+
+                               _emit_pending_response(at);
+                               at->buf_read_pos = next_pos + 1;
+                               return TRUE;
+                       }
+                       else {
+                               switch (at->req->type) {
+                                       case TCORE_AT_NO_RESULT:
+                                               _emit_unsolicited_message(at, pos);
+                                               break;
+
+                                       case TCORE_AT_NUMERIC:
+                                               if (at->resp->lines == NULL && isdigit(pos[0])) {
+                                                       _response_add(at->resp, pos);
+                                               }
+                                               else {
+                                                       _emit_unsolicited_message(at, pos);
+                                               }
+
+                                               break;
+
+                                       case TCORE_AT_SINGLELINE:
+                                               if (at->resp->lines == NULL) {
+                                                       if (at->req->prefix) {
+                                                               if (g_str_has_prefix(pos, at->req->prefix)) {
+                                                                       _response_add(at->resp, pos);
+                                                               }
+                                                               else {
+                                                                       _emit_unsolicited_message(at, pos);
+                                                               }
+                                                       }
+                                                       else {
+                                                               _response_add(at->resp, pos);
+                                                       }
+                                               }
+                                               else {
+                                                       _emit_unsolicited_message(at, pos);
+                                               }
+                                               break;
+
+                                       case TCORE_AT_MULTILINE:
+                                               if (at->req->prefix) {
+                                                       if (g_str_has_prefix(pos, at->req->prefix)) {
+                                                               _response_add(at->resp, pos);
+                                                       }
+                                                       else {
+                                                               _emit_unsolicited_message(at, pos);
+                                                       }
+                                               }
+                                               else {
+                                                       _response_add(at->resp, pos);
+                                               }
+                                               break;
+
+                                       case TCORE_AT_PDU:
+                                               if (at->req->prefix) {
+                                                       if (g_str_has_prefix(pos, at->req->prefix)) {
+                                                               _response_add(at->resp, pos);
+                                                       }
+                                                       else {
+                                                               if (at->resp->lines != NULL) {
+                                                                       _response_add(at->resp, pos);
+                                                               }
+                                                               else {
+                                                                       _emit_unsolicited_message(at, pos);
+                                                               }
+                                                       }
+                                               }
+                                               else {
+                                                       _response_add(at->resp, pos);
+                                               }
+                                               break;
+
+                                       default:
+                                               dbg("unknown");
+                                               _emit_unsolicited_message(at, pos);
+                                               break;
+                               }
+                       }
+               }
+
+               //
+               pos = next_pos + 1;
+               at->buf_read_pos = pos;
+       }
+
+       return FALSE;
+}
+
+TcorePending *tcore_at_pending_new(CoreObject *co, const char *cmd, const char *prefix, enum tcore_at_command_type type, TcorePendingResponseCallback func, void *user_data)
+{
+       TcorePending *p;
+       TcoreATRequest *req;
+
+       if (!cmd)
+               return NULL;
+
+       req = tcore_at_request_new(cmd, prefix, type);
+       if (!req)
+               return NULL;
+
+       p = tcore_pending_new(co, 0);
+       if (!p) {
+               tcore_at_request_free(req);
+               return NULL;
+       }
+
+       tcore_pending_set_request_data(p, 0, req);
+       tcore_pending_set_response_callback(p, func, user_data);
+
+       return p;
+}
+
+#define TYPE_NONE              0
+#define TYPE_RAW               1
+#define TYPE_STR               2
+#define TYPE_STR_FIN   3
+#define TYPE_PAREN             4
+#define TYPE_PAREN_FIN 5
+
+GSList *tcore_at_tok_new(const char *line)
+{
+       char *begin;
+       char *pos;
+       char *buf = NULL;
+       char *mark_end = NULL;
+       int type = TYPE_NONE;
+       GSList *tokens = NULL;
+
+       if (!line)
+               return NULL;
+
+       if (strlen(line) == 0)
+               return NULL;
+
+       if (line[0] == '(') {
+               /* list token container */
+               pos = (char *)line;
+               if (line[strlen(line)-1] == ')')
+                       mark_end = (char *)line + strlen(line) - 1;
+       }
+       else {
+               /* normal at message */
+               pos = strchr(line, ':');
+               if (!pos) {
+                       tokens = g_slist_append(tokens, strdup(line));
+                       return tokens;
+               }
+       }
+
+       pos++;
+
+       /* skip whitespace */
+       while (*pos != '\0' && isspace(*pos)) {
+               pos++;
+       }
+
+       begin = pos;
+
+       do {
+               switch (type) {
+               case TYPE_NONE:
+                       if (*pos == '"') {
+                               type = TYPE_STR;
+                       }
+                       else if (*pos == ',') {
+                               tokens = g_slist_append(tokens, strdup(""));
+                       }
+                       else if (*pos == ' ') {
+                               // skip
+                       }
+                       else if (*pos == '(') {
+                               type = TYPE_PAREN;
+                       }
+                       else {
+                               type = TYPE_RAW;
+                       }
+                       begin = pos;
+                       break;
+
+               case TYPE_STR:
+                       if (*pos == '"') {
+                               type = TYPE_STR_FIN;
+                               buf = calloc(pos - begin + 2, 1);
+                               memcpy(buf, begin, pos - begin + 1);
+                               tokens = g_slist_append(tokens, buf);
+                       }
+                       break;
+
+               case TYPE_PAREN:
+                       if (*pos == ')') {
+                               type = TYPE_PAREN_FIN;
+                               buf = calloc(pos - begin + 2, 1);
+                               memcpy(buf, begin, pos - begin + 1);
+                               tokens = g_slist_append(tokens, buf);
+                       }
+                       break;
+
+               case TYPE_RAW:
+                       if (*pos == ',' || *pos == '\0') {
+                               type = TYPE_NONE;
+                               buf = calloc(pos - begin + 1, 1);
+                               memcpy(buf, begin, pos - begin);
+                               tokens = g_slist_append(tokens, buf);
+                       }
+                       break;
+
+               case TYPE_STR_FIN:
+               case TYPE_PAREN_FIN:
+                       if (*pos == ',') {
+                               type = TYPE_NONE;
+                       }
+                       break;
+               }
+
+               if (*pos == '\0' || pos == mark_end)
+                       break;
+
+               pos++;
+       } while (1);
+
+       if (type == TYPE_RAW) {
+               buf = calloc(pos - begin + 1, 1);
+               memcpy(buf, begin, pos - begin);
+               tokens = g_slist_append(tokens, buf);
+       }
+
+       return tokens;
+}
+
+void tcore_at_tok_free(GSList *tokens)
+{
+       if (!tokens)
+               return;
+
+       g_slist_free_full(tokens, g_free);
+}
+
+char *tcore_at_tok_extract(const char *src)
+{
+       char *dest = NULL;
+       char *last = NULL;
+
+       if (!src)
+               return NULL;
+
+       if (strlen(src) < 2)
+               return g_strdup(src);
+
+       last = (char *)src + strlen(src) - 1;
+
+       switch (*src) {
+               case '(':
+                       if (*last == ')') {
+                               dest = g_strdup(src + 1);
+                               dest[strlen(dest) - 1] = '\0';
+                       }
+                       break;
+
+               case '"':
+                       if (*last == '"') {
+                               dest = g_strdup(src + 1);
+                               dest[strlen(dest) - 1] = '\0';
+                       }
+                       break;
+
+               default:
+                       return g_strdup(src);
+                       break;
+       }
+
+       return dest;
+}
+
+char *tcore_at_tok_nth(GSList *tokens, unsigned int token_index)
+{
+       if (!tokens)
+               return NULL;
+
+       if (token_index > g_slist_length(tokens))
+               return NULL;
+
+       return (char *)g_slist_nth_data(tokens, token_index);
+}
diff --git a/src/co_call.c b/src/co_call.c
new file mode 100644 (file)
index 0000000..c22943e
--- /dev/null
@@ -0,0 +1,1143 @@
+/*
+ * 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; \
+       } \
+}
+
+#define CALL_OPS(ops, name, co, ur) \
+       ((NULL == ops->name) ? TCORE_RETURN_ENOSYS : ops->name(co, ur))
+
+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 void _clone_hook(CoreObject *src, CoreObject *dest)
+{
+       struct private_object_data *src_po = NULL;
+       struct private_object_data *dest_po = NULL;
+
+       if (!src || !dest)
+               return;
+
+       dest_po = calloc(sizeof(struct private_object_data), 1);
+       if (!dest_po) {
+               tcore_object_link_object(dest, NULL);
+               return;
+       }
+
+       src_po = tcore_object_ref_object(src);
+       dest_po->ops = src_po->ops;
+
+       tcore_object_link_object(dest, dest_po);
+}
+
+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:
+               return CALL_OPS(po->ops, dial, o, ur);
+
+       case TREQ_CALL_ANSWER:
+               return CALL_OPS(po->ops, answer, o, ur);
+
+       case TREQ_CALL_END:
+               return CALL_OPS(po->ops, end, o, ur);
+
+       case TREQ_CALL_HOLD:
+               return CALL_OPS(po->ops, hold, o, ur);
+
+       case TREQ_CALL_ACTIVE:
+               return CALL_OPS(po->ops, active, o, ur);
+
+       case TREQ_CALL_SWAP:
+               return CALL_OPS(po->ops, swap, o, ur);
+
+       case TREQ_CALL_JOIN:
+               return CALL_OPS(po->ops, join, o, ur);
+
+       case TREQ_CALL_SPLIT:
+               return CALL_OPS(po->ops, split, o, ur);
+
+       case TREQ_CALL_DEFLECT:
+               return CALL_OPS(po->ops, deflect, o, ur);
+
+       case TREQ_CALL_TRANSFER:
+               return CALL_OPS(po->ops, transfer, o, ur);
+
+       case TREQ_CALL_SEND_DTMF:
+               return CALL_OPS(po->ops, send_dtmf, o, ur);
+
+       case TREQ_CALL_SET_SOUND_PATH:
+               return CALL_OPS(po->ops, set_sound_path, o, ur);
+
+       case TREQ_CALL_GET_SOUND_VOLUME_LEVEL:
+               return CALL_OPS(po->ops, get_sound_volume_level, o, ur);
+
+       case TREQ_CALL_SET_SOUND_VOLUME_LEVEL:
+               return CALL_OPS(po->ops, set_sound_volume_level, o, ur);
+
+       case TREQ_CALL_MUTE:
+               return CALL_OPS(po->ops, mute, o, ur);
+
+       case TREQ_CALL_UNMUTE:
+               return CALL_OPS(po->ops, unmute, o, ur);
+
+       case TREQ_CALL_GET_MUTE_STATUS:
+               return CALL_OPS(po->ops, get_mute_status, o, ur);
+
+       case TREQ_CALL_SET_SOUND_RECORDING:
+               return CALL_OPS(po->ops, set_sound_recording, o, ur);
+
+       case TREQ_CALL_SET_SOUND_EQUALIZATION:
+               return CALL_OPS(po->ops, set_sound_equalization, o, ur);
+
+       case TREQ_CALL_SET_SOUND_NOISE_REDUCTION:
+               return CALL_OPS(po->ops, set_sound_noise_reduction, o, ur);
+
+       case TREQ_CALL_SET_SOUND_CLOCK_STATUS:
+               return CALL_OPS(po->ops, set_sound_clock_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 != NULL; list = list->next) {
+                       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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, TCORE_RETURN_FAILURE);
+       _check_null( "po->cops", po->cops, 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);
+
+       _check_null( "po", po, );
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po, );
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po, );
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po, );
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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);
+
+       _check_null( "po", po,);
+       _check_null( "po->iops", po->iops,);
+
+       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, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name, hal);
+       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_clone_hook(o, _clone_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..c04bb7b
--- /dev/null
@@ -0,0 +1,786 @@
+/*
+ * 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 *profile_name;
+       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, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name, hal);
+       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_profile_name(CoreObject *o, const char *profile_name)
+{
+       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->profile_name) {
+               free(po->profile_name);
+               po->profile_name = NULL;
+       }
+
+       if (profile_name) {
+               po->profile_name = g_strdup(profile_name);
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+char *tcore_context_get_profile_name(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->profile_name)
+               return NULL;
+
+       return g_strdup(po->profile_name);
+}
+
+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));
+       memcpy(d_po->devname, s_po->devname, sizeof(char) * 16);
+
+       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[0] == 0)
+               return NULL;
+
+       return g_strdup(po->devname);
+}
diff --git a/src/co_gps.c b/src/co_gps.c
new file mode 100644 (file)
index 0000000..144e59f
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * 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_gps.h"
+
+struct private_object_data {
+       struct tcore_gps_operations *ops;
+};
+
+static void _clone_hook(CoreObject *src, CoreObject *dest)
+{
+       struct private_object_data *src_po = NULL;
+       struct private_object_data *dest_po = NULL;
+
+       if (!src || !dest)
+               return;
+
+       dest_po = calloc(sizeof(struct private_object_data), 1);
+       if (!dest_po) {
+               tcore_object_link_object(dest, NULL);
+               return;
+       }
+
+       src_po = tcore_object_ref_object(src);
+       dest_po->ops = src_po->ops;
+
+       tcore_object_link_object(dest, dest_po);
+}
+
+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_GPS_CONFIRM_MEASURE_POS:
+                       dbg("TREQ_GPS_CONFIRM_MEASURE_POS");
+                       if (!po->ops->confirm_measure_pos)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->confirm_measure_pos(o, ur);
+                       break;
+
+               case TREQ_GPS_SET_FREQUENCY_AIDING:
+                       dbg("TREQ_GPS_SET_FREQUENCY_AIDING");
+                       if (!po->ops->set_frequency_aiding)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_frequency_aiding(o, ur);
+                       break;
+
+               default:
+                       dbg("not supported cmd");
+                       break;
+       }
+       return TCORE_RETURN_SUCCESS;
+}
+
+CoreObject *tcore_gps_new(TcorePlugin *p, const char *name,
+               struct tcore_gps_operations *ops, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name, hal);
+       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_GPS);
+       tcore_object_link_object(o, po);
+       tcore_object_set_dispatcher(o, _dispatcher);
+       tcore_object_set_clone_hook(o, _clone_hook);
+
+       return o;
+}
+
+void tcore_gps_free(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_GPS);
+
+       po = tcore_object_ref_object(o);
+       if (!po)
+               return;
+
+       g_free(po);
+       tcore_object_link_object(o, po);
+       tcore_object_free(o);
+}
+
diff --git a/src/co_modem.c b/src/co_modem.c
new file mode 100644 (file)
index 0000000..82b6488
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * 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"
+#include "hal.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 void _clone_hook(CoreObject *src, CoreObject *dest)
+{
+       struct private_object_data *src_po = NULL;
+       struct private_object_data *dest_po = NULL;
+
+       if (!src || !dest)
+               return;
+
+       dest_po = calloc(sizeof(struct private_object_data), 1);
+       if (!dest_po) {
+               tcore_object_link_object(dest, NULL);
+               return;
+       }
+
+       src_po = tcore_object_ref_object(src);
+       dest_po->ops = src_po->ops;
+
+       tcore_object_link_object(dest, dest_po);
+}
+
+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;
+
+               case TREQ_MODEM_GET_SN:
+                       if (!po->ops->get_sn)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_sn(o, ur);
+                       break;
+
+               case TREQ_MODEM_SET_DUN_PIN_CONTROL:
+                       if (!po->ops->dun_pin_ctrl)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->dun_pin_ctrl(o, ur);
+                       break;
+
+               case TREQ_MODEM_GET_FLIGHTMODE:
+                       if (!po->ops->get_flight_mode)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_flight_mode(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, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name, hal);
+       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_clone_hook(o, _clone_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)
+{
+       TcoreHal *h;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_MODEM, TCORE_RETURN_EINVAL);
+
+       h = tcore_object_get_hal(o);
+       if (!h)
+               return TCORE_RETURN_FAILURE;
+
+       tcore_hal_set_power_state(h, pwr);
+
+       return TRUE;
+}
+
+gboolean tcore_modem_get_powered(CoreObject *o)
+{
+       TcoreHal *h;
+
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_MODEM, FALSE);
+
+       h = tcore_object_get_hal(o);
+       if (!h)
+               return FALSE;
+
+       return tcore_hal_get_power_state(h);
+}
diff --git a/src/co_network.c b/src/co_network.c
new file mode 100644 (file)
index 0000000..3b5f097
--- /dev/null
@@ -0,0 +1,756 @@
+/*
+ * 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[1000];
+};
+
+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;
+
+               case TREQ_NETWORK_SET_MODE:
+                       if (!po->ops->set_mode)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_mode(co, ur);
+                       break;
+
+               case TREQ_NETWORK_GET_MODE:
+                       if (!po->ops->get_mode)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_mode(co, ur);
+                       break;
+
+               case TREQ_NETWORK_SET_NEIGHBORING_CELL_INFO:
+                       if (!po->ops->set_neighboring_cell_info)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->set_neighboring_cell_info(co, ur);
+                       break;
+
+               case TREQ_NETWORK_GET_NEIGHBORING_CELL_INFO:
+                       if (!po->ops->get_neighboring_cell_info)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_neighboring_cell_info(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);
+       }
+}
+
+static void _clone_hook(CoreObject *src, CoreObject *dest)
+{
+       struct private_object_data *src_po = NULL;
+       struct private_object_data *dest_po = NULL;
+
+       if (!src || !dest)
+               return;
+
+       dest_po = calloc(sizeof(struct private_object_data), 1);
+       if (!dest_po) {
+               tcore_object_link_object(dest, NULL);
+               return;
+       }
+
+       src_po = tcore_object_ref_object(src);
+       dest_po->ops = src_po->ops;
+
+       tcore_object_link_object(dest, dest_po);
+}
+
+CoreObject *tcore_network_new(TcorePlugin *plugin, const char *name,
+               struct tcore_network_operations *ops, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!plugin)
+               return NULL;
+
+       o = tcore_object_new(plugin, name, hal);
+       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_clone_hook(o, _clone_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->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);
+       if (mcc_index > 999)
+               return TCORE_RETURN_EINVAL;
+
+       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);
+       if (mcc_index > 999)
+               return NULL;
+
+       list = po->network_operator_info_table[mcc_index];
+       if (list == NULL) {
+               dbg("mcc[%d] is not in operator table", mcc_index);
+               return NULL;
+       }
+
+       for (; list; list = list->next) {
+               if (!list->data)
+                       continue;
+
+               data = list->data;
+
+               dbg(" +- mnc[%s]", data->mnc);
+               if (g_strcmp0(data->mnc, mnc) == 0)
+                       return data;
+       }
+
+       dbg("mcc[%s] mnc[%s] is not in operator table", mcc, mnc);
+
+       return NULL;
+}
diff --git a/src/co_phonebook.c b/src/co_phonebook.c
new file mode 100644 (file)
index 0000000..c77f2eb
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * 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;
+       enum tel_phonebook_type selected;
+};
+
+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 _clone_hook(CoreObject *src, CoreObject *dest)
+{
+       struct private_object_data *src_po = NULL;
+       struct private_object_data *dest_po = NULL;
+
+       if (!src || !dest)
+               return;
+
+       dest_po = calloc(sizeof(struct private_object_data), 1);
+       if (!dest_po) {
+               tcore_object_link_object(dest, NULL);
+               return;
+       }
+
+       src_po = tcore_object_ref_object(src);
+       dest_po->ops = src_po->ops;
+
+       tcore_object_link_object(dest, dest_po);
+}
+
+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, FALSE);
+       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, FALSE);
+       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, FALSE);
+       po = tcore_object_ref_object(o);
+       memcpy(&po->support_list, list, sizeof(struct tel_phonebook_support_list));
+       return TRUE;
+}
+
+enum tel_phonebook_type tcore_phonebook_get_selected_type(CoreObject *o)
+{
+       struct private_object_data *po = NULL;
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PHONEBOOK, PB_TYPE_UNKNOWNN);
+       po = tcore_object_ref_object(o);
+       return po->selected;
+}
+
+gboolean tcore_phonebook_set_selected_type(CoreObject *o, enum tel_phonebook_type t)
+{
+       struct private_object_data *po = NULL;
+       CORE_OBJECT_CHECK_RETURN(o, CORE_OBJECT_TYPE_PHONEBOOK, FALSE);
+       po = tcore_object_ref_object(o);
+       po->selected = t;
+       return TRUE;
+}
+
+CoreObject *tcore_phonebook_new(TcorePlugin *p, const char *name,
+               struct tcore_phonebook_operations *ops, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name, hal);
+       if (!o)
+               return NULL;
+
+       po = calloc(sizeof(struct private_object_data), 1);
+       if (!po) {
+               tcore_object_free(o);
+               return NULL;
+       }
+
+       po->ops = ops;
+       po->selected = PB_TYPE_UNKNOWNN;
+
+       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_clone_hook(o, _clone_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..a8afab7
--- /dev/null
@@ -0,0 +1,584 @@
+/*
+ * 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) {
+               default:
+                       break;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+static void _clone_hook(CoreObject *src, CoreObject *dest)
+{
+       struct private_object_data *src_po = NULL;
+       struct private_object_data *dest_po = NULL;
+
+       if (!src || !dest)
+               return;
+
+       dest_po = calloc(sizeof(struct private_object_data), 1);
+       if (!dest_po) {
+               tcore_object_link_object(dest, NULL);
+               return;
+       }
+
+       src_po = tcore_object_ref_object(src);
+       dest_po->ops = src_po->ops;
+
+       tcore_object_link_object(dest, dest_po);
+}
+
+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->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;
+                       if (contexts == NULL)
+                               continue;
+
+                       for (; contexts != NULL; contexts = g_slist_next(contexts)) {
+                               s_context = contexts->data;
+                               if (s_context == NULL)
+                                       continue;
+
+                               if (ps_context == s_context) {
+                                       dbg("find contexts(%p) in cid(%d)",
+                                               ps_context, idx_cid);
+                                       return TRUE;
+                               }
+                       }
+               }
+       }
+
+       dbg("cannot find contexts(%p) ", ps_context);
+       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;
+                       if (contexts == NULL)
+                               continue;
+
+                       for (; contexts != NULL; contexts = g_slist_next(contexts)) {
+                               s_context = contexts->data;
+                               if (s_context == NULL)
+                                       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 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);
+                       }
+               }
+       }
+
+       g_free(t_apn);
+       return FALSE;
+}
+
+CoreObject *tcore_ps_new(TcorePlugin *p, const char *name,
+               struct tcore_ps_operations *ops, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name, hal);
+       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_clone_hook(o, _clone_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;
+
+       tcore_ps_clear_context_id(o, ctx_o);
+       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->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);
+                               dbg("assign contexts(%p) in cid(%d)", context, idx);
+                               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_define_context(CoreObject *o, CoreObject *ps_context, void *user_data)
+{
+       int rv;
+       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 (!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;
+       }
+
+       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;
+       }
+
+       dbg("contexts(%p), cid = %d", ps_context, tcore_context_get_id(ps_context));
+
+       return po->ops->define_context(o, ps_context, user_data);
+}
+
+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)
+       {
+               dbg("it is not defined context");
+               return TCORE_RETURN_EINVAL;
+       }
+
+       rv = _ps_is_duplicated_apn(o, ps_context);
+       if (rv) {
+               dbg("context activation is already requested for the same apn(%s)",
+                       tcore_context_get_apn(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;
+
+
+       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;
+                       if (contexts == NULL)
+                               continue;
+
+                       for (; contexts != NULL; contexts = g_slist_next(contexts)) {
+                               CoreObject *context = NULL;
+                               context = contexts->data;
+                               if (context == NULL)
+                                       continue;
+
+                               tcore_ps_deactivate_context(o, context, NULL);
+                       }
+               }
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
diff --git a/src/co_sap.c b/src/co_sap.c
new file mode 100644 (file)
index 0000000..def550e
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * 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 _clone_hook(CoreObject *src, CoreObject *dest)
+{
+       struct private_object_data *src_po = NULL;
+       struct private_object_data *dest_po = NULL;
+
+       if (!src || !dest)
+               return;
+
+       dest_po = calloc(sizeof(struct private_object_data), 1);
+       if (!dest_po) {
+               tcore_object_link_object(dest, NULL);
+               return;
+       }
+
+       src_po = tcore_object_ref_object(src);
+       dest_po->ops = src_po->ops;
+
+       tcore_object_link_object(dest, dest_po);
+}
+
+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, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name, hal);
+       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_clone_hook(o, _clone_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..fbdcfa0
--- /dev/null
@@ -0,0 +1,6899 @@
+/*
+ * 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_NETWORK_ACCESS_TAG        0x47 /* NETWORK ACCESS NAME TAG */
+#define SATK_CDMA_SMS_TPDU_TAG 0x48 /* CDMA SMS TPDU 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     0x02 /*  CHANNEL STATUS LENGTH */
+
+struct private_object_data {
+       struct tcore_sat_operations *ops;
+};
+
+gboolean b_comprehensive = FALSE;
+
+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 _clone_hook(CoreObject *src, CoreObject *dest)
+{
+       struct private_object_data *src_po = NULL;
+       struct private_object_data *dest_po = NULL;
+
+       if (!src || !dest)
+               return;
+
+       dest_po = calloc(sizeof(struct private_object_data), 1);
+       if (!dest_po) {
+               tcore_object_link_object(dest, NULL);
+               return;
+       }
+
+       src_po = tcore_object_ref_object(src);
+       dest_po->ops = src_po->ops;
+
+       tcore_object_link_object(dest, dest_po);
+}
+
+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 gboolean _check_file_for_refresh(enum tel_sim_file_id file_id)
+{
+       int i;
+       enum tel_sim_file_id ef_under_mf[3] = { SIM_EF_DIR, SIM_EF_ELP, SIM_EF_ICCID };
+       enum tel_sim_file_id ef_under_df[29] = {
+               SIM_EF_IMSI,    SIM_EF_SST,
+               SIM_EF_EST,     SIM_EF_OPLMN_ACT,
+               SIM_EF_GID1, SIM_EF_GID2,
+               SIM_EF_LP, SIM_EF_ECC,
+               SIM_EF_SPN,     SIM_EF_SPDI,
+               SIM_EF_PNN,     SIM_EF_OPL,
+               SIM_EF_MBDN,    SIM_EF_MSISDN,
+               SIM_EF_USIM_MBI, SIM_EF_USIM_MWIS,
+               SIM_EF_USIM_CFIS,       SIM_EF_CPHS_VOICE_MSG_WAITING,
+               SIM_EF_CPHS_SERVICE_STRING_TABLE, SIM_EF_CPHS_CALL_FORWARD_FLAGS,
+               SIM_EF_CPHS_OPERATOR_NAME_STRING,       SIM_EF_CPHS_CUSTOMER_SERVICE_PROFILE,
+               SIM_EF_CPHS_CPHS_INFO,  SIM_EF_CPHS_MAILBOX_NUMBERS,
+               SIM_EF_CPHS_OPERATOR_NAME_SHORT_FORM_STRING, SIM_EF_CPHS_INFORMATION_NUMBERS,
+               SIM_EF_CPHS_DYNAMICFLAGS, SIM_EF_CPHS_DYNAMIC2FLAG,
+               SIM_EF_CPHS_CUSTOMER_SERVICE_PROFILE_LINE2 };
+
+       dbg("[SAT] SAT PARSER - FILE ID=0x%04x", (unsigned int)file_id);
+
+       if( (file_id & 0x2F00) == 0x2F00 )
+       {
+               dbg("[SAT] SAT PARSER - MF, EF=0x%04x",file_id);
+               for(i=0;i<3;i++){
+                       if(file_id == ef_under_mf[i]){
+                               dbg("[SAT] SAT PARSER - MATCH!");
+                               return TRUE;
+                       }
+               }
+       }
+       else if( (file_id & 0x6F00) == 0x6F00)
+       {
+               dbg("[SAT] SAT PARSER - ADF_USIM EF=0x%04x",file_id);
+               for(i=0;i<29;i++){
+                       if(file_id == ef_under_df[i]){
+                               dbg("[SAT] SAT PARSER - MATCH!");
+                               return TRUE;
+                       }
+               }
+       }
+       return FALSE;
+}
+
+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_FORMAT_SMS_DEFAULT: {
+                       char* unpacked_str;
+
+                       text_obj->string_length = 0;
+                       unpacked_str = (char *)tcore_util_unpack_gsm7bit(src, (unsigned int)len);
+                       if (!unpacked_str) return;
+
+                       text_obj->dcs.a_format = ALPHABET_FORMAT_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_FORMAT_UCS2:
+               case ALPHABET_FORMAT_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_FORMAT_SMS_DEFAULT;
+                       break;
+
+               case 0x04:
+                       dsc_obj->a_format = ALPHABET_FORMAT_8BIT_DATA;
+                       break;
+
+               case 0X08:
+                       dsc_obj->a_format = ALPHABET_FORMAT_UCS2;
+                       break;
+
+               default:
+                       dsc_obj->a_format = ALPHABET_FORMAT_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;
+}
+
+static void _sat_decode_ton_npi(unsigned char ton_npi, enum type_of_number *ton, enum numbering_plan_identifier *npi)
+{
+       int ton_value = 0;
+       int npi_value = 0;
+
+       if(!ton || !npi)
+               return;
+
+       ton_value = (ton_npi & 0x70) >> 4;
+       *ton = ton_value;
+       if(*ton > TON_NETWORK_SPECIFIC)
+               *ton = TON_UNKNOWN;
+
+       npi_value = (ton_npi & 0x0F);
+       switch(npi_value){
+               case NPI_ISDN_TEL:
+               case NPI_DATA_NUMBERING_PLAN:
+               case NPI_TELEX:
+               case NPI_PRIVATE:
+               case NPI_RESERVED_FOR_EXT:
+                       *npi = npi_value;
+                       break;
+               default:
+                       *npi = NPI_UNKNOWN;
+                       break;
+       }
+
+       dbg("[SAT] SAT PATSER - ton(0x%x) npi(0x%x)", *ton, *npi);
+       return;
+}
+
+static enum tel_sim_language_type _sat_decode_language(unsigned char byte1, unsigned char byte2)
+{
+       if((byte1 == 'e')&&(byte2 == 'n')){
+               return SIM_LANG_ENGLISH;
+       } else if((byte1 == 'd')&&(byte2 == 'e')){
+               return SIM_LANG_GERMAN;
+       } else if((byte1 == 'i')&&(byte2 == 't')){
+               return SIM_LANG_ITALIAN;
+       } else if((byte1 == 'f')&&(byte2 == 'r')){
+               return SIM_LANG_FRENCH;
+       } else if((byte1 == 'e')&&(byte2 == 's')){
+               return SIM_LANG_SPANISH;
+       } else if((byte1 == 'n')&&(byte2 == 'l')){
+               return SIM_LANG_DUTCH;
+       } else if((byte1 == 's')&&(byte2 == 'v')){
+               return SIM_LANG_SWEDISH;
+       } else if((byte1 == 'd')&&(byte2 == 'a')){
+               return SIM_LANG_DANISH;
+       } else if((byte1 == 'p')&&(byte2 == 't')){
+               return SIM_LANG_PORTUGUESE;
+       } else if((byte1 == 'f')&&(byte2 == 'i')){
+               return SIM_LANG_FINNISH;
+       } else if((byte1 == 'n')&&(byte2 == 'o')){
+               return SIM_LANG_NORWEGIAN;
+       } else if((byte1 == 'e')&&(byte2 == 'l')){
+               return SIM_LANG_GREEK;
+       } else if((byte1 == 't')&&(byte2 == 'r')){
+               return SIM_LANG_TURKISH;
+       } else if((byte1 == 'h')&&(byte2 == 'u')){
+               return SIM_LANG_HUNGARIAN;
+       } else if((byte1 == 'p')&&(byte2 == 'i')){
+               return SIM_LANG_POLISH;
+       } else  {
+               dbg("[SAT] SAT PARSER -  unknown language, default to english.");
+               return SIM_LANG_ENGLISH;
+       }
+}
+
+/*
+ * Decode TLV data object
+ */
+static enum tcore_sat_result _sat_decode_address_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_address* address_obj, int* consumed_data_len)
+{
+       unsigned char* src_data;
+       int index, len_of_len = 0;
+       int address_len = 0;
+       gboolean comprehensive_req = FALSE;
+
+       if (tlv_str == NULL || consumed_data_len == NULL || address_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || address_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_ADDRESS_TAG) {
+               dbg("[SAT] SAT PARSER -  address TAG missing");
+               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+       }
+
+       //comprehensive required
+       if((src_data[index++] & 0x80))
+               comprehensive_req = TRUE;
+
+       //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;
+       }
+       address_len = src_data[index + len_of_len - 1];
+
+       //check the address length
+       index += len_of_len;
+       if ((index + address_len) > tlv_len) {
+               dbg("[SAT] SAT PARSER  -  incorrect length");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       address_obj->dialing_number_len = 0;
+       if(address_len > 1){
+               char* str_ascii = NULL;
+               _sat_decode_ton_npi(src_data[index++], &address_obj->ton, &address_obj->npi);
+               str_ascii = tcore_util_convert_bcd2ascii((const char*)&src_data[index], address_len-1, SAT_DIALING_NUMBER_LEN_MAX);
+               if(str_ascii){
+                       memcpy(address_obj->dialing_number, str_ascii, strlen(str_ascii));
+                       address_obj->dialing_number_len = strlen(str_ascii);
+                       g_free(str_ascii);
+               }
+       }
+
+       if(address_obj->dialing_number_len == 0){
+               if(comprehensive_req){
+                       err("[SAT] SAT PARSER -  incorrect address");
+                       return TCORE_SAT_REQUIRED_VALUE_MISSING;
+               }
+               dbg("comprehensive partial proactive command");
+               //global variable (comprehensive_partial= TRUE)
+       }
+
+       *consumed_data_len = 1 + len_of_len + address_len;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_subaddress_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_subaddress* sub_address_obj, int* consumed_data_len)
+{
+       unsigned char* src_data;
+       int index, len_of_len = 0;
+       int sub_address_len = 0;
+       gboolean comprehensive_req = FALSE;
+
+       if (tlv_str == NULL || consumed_data_len == NULL || sub_address_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || sub_address_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_SUB_ADDRESS_TAG) {
+               dbg("[SAT] SAT PARSER -  sub address TAG missing");
+               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+       }
+
+       //comprehensive required
+       if((src_data[index++] & 0x80))
+               comprehensive_req = TRUE;
+
+       //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;
+       }
+       sub_address_len = src_data[index + len_of_len - 1];
+
+       //check the address length
+       index += len_of_len;
+       if ((index + sub_address_len) > tlv_len) {
+               dbg("[SAT] SAT PARSER  -  incorrect length");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //sub address
+       if(sub_address_len <= 0){
+               dbg("[SAT] SAT PARSER - no sub address data");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       sub_address_obj->subaddress_len = sub_address_len;
+       if( sub_address_obj->subaddress_len > SAT_CCP_DATA_LEN_MAX){
+               if(comprehensive_req){
+                       dbg("[SAT] SAT PARSER - sub address is too big");
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+               }
+               else{
+                       //bIsComprehensionPartial = TRUE;
+                       sub_address_obj->subaddress_len = 0;
+               }
+       }
+       else{
+               memcpy(sub_address_obj->subaddress, &src_data[index], sub_address_obj->subaddress_len);
+       }
+
+       *consumed_data_len = 1 + len_of_len + sub_address_len;
+       return TCORE_SAT_SUCCESS;
+}
+
+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_sub_address_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_subaddress* sub_address_obj, int* consumed_data_len)
+{
+       int i = 0;
+       int index, len_of_len = 0;
+       int sub_address_len = 0;
+       unsigned char* src_data;
+       gboolean comprehension_req = FALSE;
+
+       if (tlv_str == NULL || consumed_data_len == NULL || sub_address_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || sub_address_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_SUB_ADDRESS_TAG) {
+               dbg("[SAT] SAT PARSER -  address TAG missing");
+               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+       }
+
+       //comprehensive required
+       if((src_data[index++] & 0x80))
+               comprehension_req = TRUE;
+
+       //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;
+       }
+       sub_address_len = src_data[index + len_of_len - 1];
+
+       //check the address length
+       index += len_of_len;
+       if ((index + sub_address_len) > tlv_len) {
+               dbg("[SAT] SAT PARSER  -  incorrect length");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if(sub_address_len <= 0){
+               dbg("[SAT] SAT PARSER  -  no sub address");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       sub_address_obj->subaddress_len = sub_address_len;
+       if(sub_address_obj->subaddress_len > SAT_SUB_ADDR_LEN_MAX){
+               if(comprehension_req)
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+               else
+                       sub_address_obj->subaddress_len = 0;
+       }
+       else{
+               memcpy(sub_address_obj->subaddress, &src_data[index],sub_address_obj->subaddress_len);
+       }
+
+       dbg("[SAT] SAT PARSER -  subAddressLen=%d",sub_address_obj->subaddress_len);
+       for(i=0;i<sub_address_obj->subaddress_len;i++)
+               dbg("[SAT] SAT PARSER - 0x%02x\t",sub_address_obj->subaddress[i]);
+
+       *consumed_data_len = 1+len_of_len+sub_address_len;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_ccp_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_ccp* ccp_obj, int* consumed_data_len)
+{
+       int i = 0;
+       int index, len_of_len = 0;
+       int ccp_len = 0;
+       unsigned char* src_data;
+       gboolean comprehension_req = FALSE;
+
+       if (tlv_str == NULL || consumed_data_len == NULL || ccp_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || ccp_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_CAPABILITY_CONFIGURATION_PARAMETERS_TAG) {
+               dbg("[SAT] SAT PARSER -  CCP TAG missing");
+               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+       }
+
+       //comprehensive required
+       if((src_data[index++] & 0x80))
+               comprehension_req = TRUE;
+
+       //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;
+       }
+       ccp_len = src_data[index + len_of_len - 1];
+
+       //check the address length
+       index += len_of_len;
+       if ((index + ccp_len) > tlv_len) {
+               dbg("[SAT] SAT PARSER  -  incorrect length");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if(ccp_len <= 0){
+               dbg("[SAT] SAT PARSER  -  no ccp data");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       ccp_obj->data_len = ccp_len;
+       if(ccp_obj->data_len > SAT_CCP_DATA_LEN_MAX){
+               if(comprehension_req)
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+               else
+                       ccp_obj->data_len = 0;
+       }
+       else{
+               memcpy(ccp_obj->data, &src_data[index],ccp_obj->data_len);
+       }
+
+       dbg("[SAT] SAT PARSER -  ccp len=%d",ccp_obj->data_len);
+       for(i=0;i<ccp_obj->data_len;i++)
+               dbg("[SAT] SAT PARSER - 0x%02x\t",ccp_obj->data[i]);
+
+       *consumed_data_len = 1+len_of_len+ccp_len;
+       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:{
+                               if(tlv_str[index] >= 0x21 && tlv_str[index] <= 0x27){
+                                       dbg("BIP channel id(0x%x)", tlv_str[index])
+                                       if (i == 0) dev_id_obj->src = tlv_str[index];
+                                       if (i == 1) dev_id_obj->dest = tlv_str[index];
+                               }
+                               else{
+                                       dbg("unmatched device id");
+                                       return TCORE_SAT_REQUIRED_VALUE_MISSING;
+                               }
+                       }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_sms_tpdu_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_sms_tpdu *sms_tpdu_obj, int* consumed_data_len)
+{
+       int index = 0, len_of_len = 0;
+       int tpdu_len = 0;
+       unsigned char* src_data = NULL;
+
+       if (!tlv_str || !sms_tpdu_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_SMS_TPDU_TAG) {
+               err("[SAT] SAT PARSER -  sat tpdu tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //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;
+       }
+       tpdu_len = src_data[index+len_of_len-1];
+       index += len_of_len;
+
+       if(tpdu_len <= 0)
+               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+
+       //data len
+       sms_tpdu_obj->data_len = tpdu_len;
+       if(sms_tpdu_obj->data_len > SAT_SMS_TPDU_SMS_DATA_LEN_MAX){
+               sms_tpdu_obj->data_len = SAT_SMS_TPDU_SMS_DATA_LEN_MAX;
+       }
+
+       //data
+       memcpy(sms_tpdu_obj->data, &src_data[index], sms_tpdu_obj->data_len);
+       dbg("[SAT] SAT PARSER tpdu_len (%d)", sms_tpdu_obj->data_len);
+
+       *consumed_data_len = 1+len_of_len+tpdu_len;
+       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_ss_string_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_ss_string *ss_str_obj, int* consumed_data_len)
+{
+       char* str_ascii = NULL;
+       int index, len_of_len=0;
+       int ss_len =0;
+       unsigned char* src_data;
+       gboolean comprehension_req = FALSE;
+
+       if (!tlv_str || !ss_str_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_SS_STRING_TAG) {
+               err("[SAT] SAT PARSER -  SS string tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       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;
+       }
+
+       ss_len = src_data[index+len_of_len-1];
+       dbg("[SAT] parser: ss_tlv len=%d",ss_len);
+
+       index += len_of_len;
+       ss_str_obj->string_len = 0;
+
+       //ss data
+       if(ss_len <= 1)
+               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+
+       _sat_decode_ton_npi(src_data[index++], &ss_str_obj->ton, &ss_str_obj->npi);
+       str_ascii = tcore_util_convert_bcd2ascii((const char*)&src_data[index], ss_len-1, SAT_SS_STRING_LEN_MAX);
+       if(str_ascii){
+               memcpy(ss_str_obj->ss_string, str_ascii, strlen(str_ascii));
+               ss_str_obj->string_len = strlen(str_ascii);
+               g_free(str_ascii);
+       }
+
+        // 1 is the length of Tag.
+       *consumed_data_len = 1 + len_of_len + ss_len;
+       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 && (src_data[index]&0x7F) != SATK_DEFAULT_TEXT_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_tone_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_tone *tone_obj, int* consumed_data_len)
+{
+       int index;
+       unsigned char* src_data;
+       gboolean comprehension_req = FALSE;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || tone_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || tone_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_TONE_TAG){
+               err("[SAT] parser: tone tag missing");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if(src_data[index++]&0x80)
+               comprehension_req = TRUE;
+
+       //length
+       if (src_data[index++] != SATK_TONE_LENGTH) {
+               err("[SAT] SAT PARSER -  incorrect length value.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       if((index+SATK_TONE_LENGTH) > tlv_len)
+       {
+               err("[SAT] SAT PARSER -  incorrect cmd len, expected len = %d, orig_len=%d", (index+SATK_TONE_LENGTH),tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //tone
+       switch(src_data[index])
+       {
+               // standard supervisory tones
+               case DIAL_TONE:
+               case CALLED_SUBSCRIBER_BUSY     :
+               case CONGESTION :
+               case RADIO_PATH_ACK:
+               case RADIO_PATH_NOT_AVAILABLE_CALL_DROPPED:
+               case ERR_SPECIAL_INFO:
+               case CALL_WAITING_TONE:
+               case RINGING_TONE:
+               // ME proprietary tones
+               case GENERAL_BEEP:
+               case POSITIVE_ACK_TONE:
+               case NEGATIVE_ACK_OR_ERROR_TONE:
+               case RINGING_TONE_SLCTD_BY_USR_FOR_INCOM_SPEECH_CALL:
+               case ALERT_TONE_SELECTED_BY_USER_FOR_INCOMING_SMS:
+               case CRITICAL_ALERT:
+               //Themed tones
+               case HAPPY_TONE:
+               case SAD_TONE:
+               case URGENT_ACTION_TONE :
+               case QUESTION_TONE:
+               case MESSAGE_RECEIVED_TONE      :
+               //Melody tones
+               case MELODY_1:
+               case MELODY_2:
+               case MELODY_3:
+               case MELODY_4:
+               case MELODY_5:
+               case MELODY_6:
+               case MELODY_7:
+               case MELODY_8:
+                       dbg("[SAT] SAT PARSER -  Tone =0x%x", src_data[index]);
+                       tone_obj->tone_type = src_data[index];
+                       break;
+
+               case TONE_TYPE_RESERVED:
+               default:
+                       dbg("[SAT] SAT PARSER -  Reserved value of Tone =0x%x", src_data[index]);
+                       if(comprehension_req)
+                               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+                       break;
+       }
+
+       *consumed_data_len = 3;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_ussd_string_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_ussd_string *ussd_str_obj, int* consumed_data_len)
+{
+       int index, len_of_len=0;
+       int ussd_len =0;
+       unsigned char* src_data;
+       gboolean comprehension_req = FALSE;
+
+       if (!tlv_str || !ussd_str_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_USSD_STRING_TAG) {
+               err("[SAT] SAT PARSER -  SS string tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       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;
+       }
+
+       ussd_len = src_data[index+len_of_len-1];
+       dbg("[SAT] parser: ussd_tlv len=%d",ussd_len);
+
+       index += len_of_len;
+       ussd_str_obj->string_len = 0;
+
+       //ussd data
+       if(ussd_len <= 1)
+               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+
+       _sat_decode_dcs(src_data[index++], &ussd_str_obj->dsc);
+       ussd_str_obj->string_len = ussd_len - 1;
+       memcpy(ussd_str_obj->ussd_string, &src_data[index], ussd_str_obj->string_len);
+
+        // 1 is the length of Tag.
+       *consumed_data_len = 1 + len_of_len + ussd_len;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_file_list_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_file_list *file_list_obj, int* consumed_data_len)
+{
+       //tmp
+       int tmp_cnt, tmp_path_len;
+       int f_count;
+       unsigned int ef = 0x0000;
+
+       int index, len_of_len=0;
+       int file_list_len = 0;
+       unsigned char* src_data;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || file_list_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || file_list_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_FILE_LIST_TAG){
+               err("[SAT] parser: tag missing, tag=0x%x",src_data[index]);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //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;
+       }
+       file_list_len = src_data[index+len_of_len-1];
+       index += len_of_len;
+
+       if((index+file_list_len) > tlv_len) {
+               dbg("[SAT] SAT PARSER - incorrect cmd len, expected len = %d, orig_len=%d", (index+file_list_len),tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       tmp_cnt = src_data[index++];
+       tmp_path_len = file_list_len - 1;
+       file_list_obj->file_count = 0;
+       memset(file_list_obj->file_id, 0, SAT_FILE_ID_LIST_MAX_COUNT);
+
+       if(!tmp_cnt){
+               dbg("file cnt = 0");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       f_count = 0;
+       do{
+               ef = 0x0000;
+               if( src_data[index] != 0x3F || src_data[index+1] != 0x00){
+                       index++;
+                       if(index > tlv_len) break;
+                       else continue;
+               }
+               index+=2; //MASTER FILE (DIR) 0x3F00
+
+               if(src_data[index] == 0x2F){
+               //ELEMENTRY FILE (VALUE)
+                       ef = src_data[index] << 8;
+                       index++;
+                       ef = ef | src_data[index];
+
+                       if( _check_file_for_refresh((enum tel_sim_file_id)ef) ){//check file registered for refresh?
+                               file_list_obj->file_id[file_list_obj->file_count] = ef;
+                               file_list_obj->file_count++;
+                       }
+               }
+               else if(src_data[index] == 0x7F && src_data[index+1] == 0xFF){
+               //USIM DIRECTORY FILE (DIR) 0x7FFF
+                       index+=2;
+                       if(src_data[index] == 0x6F){
+                               ef = 0x6A << 8;
+                               index++;
+                               ef = ef | src_data[index];
+
+                               if( _check_file_for_refresh((enum tel_sim_file_id)ef) ){//check file registered for refresh?
+                                       file_list_obj->file_id[file_list_obj->file_count] = ef;
+                                       file_list_obj->file_count++;
+                               }
+                       }
+                       else{
+                               index++;
+                       }
+               }
+               else if(src_data[index] == 0x7F && (src_data[index+1] == 0x10 || src_data[index+1] == 0x20) ){
+               //TELECOM DIRECTORY FILE 0x7F10 or GSM DIRECTORY FILE 0x7F20
+                       index+=2;
+                       if(src_data[index] == 0x6F){
+                               ef = src_data[index] << 8;
+                               index++;
+                               ef = ef | src_data[index];
+
+                               if( _check_file_for_refresh((enum tel_sim_file_id)ef) ){//check file registered for refresh?
+                                       file_list_obj->file_id[file_list_obj->file_count] = ef;
+                                       file_list_obj->file_count++;
+                               }
+                       }
+                       else{
+                               index++;
+                       }
+               }
+
+               f_count++;
+               index++;
+       }while( f_count < tmp_cnt);
+
+       dbg("[SAT] SAT PARSER -  total file count=%d, PDA file count = %d", tmp_cnt, file_list_obj->file_count);
+       *consumed_data_len = 1 + len_of_len + file_list_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_event_list_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_event_list* event_list_obj,  struct tel_sat_event_list* modem_event_list_obj, int* consumed_data_len)
+{
+       int i = 0;
+       int index, len_of_len=0;
+       int evt_list_len;
+       unsigned char* src_data;
+       gboolean comprehension_req = FALSE;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || event_list_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || event_list_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_EVENT_LIST_TAG){
+               dbg("[SAT] SAT PARSER - tag not found.=%d",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;
+       }
+
+       evt_list_len = src_data[index+len_of_len-1];
+       dbg("[SAT] parser: evt_list_len=%d",evt_list_len);
+       index += len_of_len;
+
+       if((index+evt_list_len) > tlv_len) {
+               dbg("[SAT] SAT PARSER - incorrect cmd len, expected len = %d, orig_len=%d", (index+evt_list_len),tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if(evt_list_len > SAT_EVENT_LIST_MAX){
+               dbg("[SAT] SAT PARSER - event list contains more items than it is supposed to have! len=%d", evt_list_len);
+               if(comprehension_req)
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+               else
+                       evt_list_len = SAT_EVENT_LIST_MAX;
+       }
+
+       event_list_obj->event_list_cnt = 0;
+       memset(event_list_obj->evt_list, 0xFF, SAT_EVENT_LIST_MAX);
+
+       modem_event_list_obj->event_list_cnt = 0;
+       memset(modem_event_list_obj->evt_list, 0xFF, SAT_EVENT_LIST_MAX);
+
+       //event list
+       for(i = 0; i < evt_list_len; i++){
+               dbg("[SAT] SAT PARSER - event[%d]=0x%x", i, src_data[index]);
+               switch(src_data[index]){
+                       /*PDA events*/
+                       case EVENT_USER_ACTIVITY:
+                       case EVENT_IDLE_SCREEN_AVAILABLE:
+                       case EVENT_LANGUAGE_SELECTION:
+                       case EVENT_BROWSER_TERMINATION:
+                       case EVENT_DATA_AVAILABLE:
+                       case EVENT_CHANNEL_STATUS:
+                               event_list_obj->evt_list[i] = src_data[index];
+                               event_list_obj->event_list_cnt++;
+                               break;
+                       /*MODEM events*/
+                       case EVENT_MT_CALL      :
+                       case EVENT_CALL_CONNECTED:
+                       case EVENT_CALL_DISCONNECTED:
+                       case EVENT_LOCATION_STATUS:
+                       case EVENT_ACCESS_TECHNOLOGY_CHANGED:
+                               modem_event_list_obj->evt_list[i] = src_data[index];
+                               modem_event_list_obj->event_list_cnt++;
+                               break;
+                       case EVENT_UNKNOWN:
+                       default:
+                               if(comprehension_req)
+                                       return TCORE_SAT_BEYOND_ME_CAPABILITY;
+                               break;
+               }
+               index++;
+       }
+
+        // 1 is the length of Tag.
+       *consumed_data_len = 1 + len_of_len + evt_list_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;
+}
+
+static enum tcore_sat_result _sat_decode_dtmf_string_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, struct tel_sat_dtmf_string* dtmf_string_obj, int* consumed_data_len)
+{
+       unsigned char* src_data;
+       int index, len_of_len = 0;
+       int dtmf_len = 0;
+       gboolean comprehension_req = FALSE;
+       char* str_ascii = NULL;
+
+       if (tlv_str == NULL || consumed_data_len == NULL || dtmf_string_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || dtmf_string_obj == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       src_data = &tlv_str[0];
+
+       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;
+       if ((src_data[index] & 0x7F) != SATK_DTMF_STRING_TAG) {
+               dbg("[SAT] SAT PARSER - address tag missing");
+               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+       }
+
+       //comprehensive required
+       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;
+       }
+
+       dtmf_len = src_data[index + len_of_len - 1];
+       index += len_of_len; //index pointing to TON/NPI
+
+       if ((index + dtmf_len) > tlv_len) {
+               dbg("[SAT] SAT PARSER - incorrect cmd len, expected len = %d, orig_len=%d", (index+dtmf_len), tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       dtmf_string_obj->dtmf_length = 0;
+
+       if(dtmf_len > 0){
+               str_ascii = tcore_util_convert_bcd2ascii((const char*)&src_data[index], dtmf_len, SAT_DTMF_STRING_LEN_MAX);
+               if(str_ascii){
+                       memcpy(dtmf_string_obj->dtmf_string, str_ascii, strlen(str_ascii));
+                       dtmf_string_obj->dtmf_length = strlen(str_ascii);
+                       g_free(str_ascii);
+               }
+       }
+
+       if (dtmf_string_obj->dtmf_length == 0) {
+               dbg("[SAT] SAT PARSER - DTMF string length is either 0 or it is too long for the ME to handle.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       *consumed_data_len = 1 + len_of_len + dtmf_len;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_language_tlv(unsigned char* tlv_str, int tlv_len,
+               int curr_offset, enum tel_sim_language_type* language_obj)
+{
+       unsigned char* src_data;
+       int index = 0;
+
+       if(tlv_len <= (curr_offset+1)) {
+               dbg("[SAT] SAT PARSER -  incorrect length original_command_len=%d", tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       src_data = &tlv_str[0];
+       index = curr_offset;
+
+       if((src_data[index++]&0x7F) != SATK_LANGUAGE_TAG)       {
+               dbg("[SAT] SAT PARSER -  Language tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+       if(src_data[index++] != SATK_LANGUAGE_LENGTH) {
+               dbg("[SAT] SAT PARSER -  incorrect length value.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if((index+SATK_LANGUAGE_LENGTH) > tlv_len) {
+               dbg("[SAT] SAT PARSER -  incorrect cmd len, expected len = %d, orig_len=%d", (index+SATK_LANGUAGE_LENGTH),tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+       *language_obj = _sat_decode_language(src_data[index], src_data[index+1]);
+       dbg("[SAT] SAT PARSER -  <in> %c %c, <out> %d", src_data[index], src_data[index+1], *language_obj);
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_browser_identity_tlv(unsigned char* tlv_str, int tlv_len, int curr_offset,
+               enum browser_identity* browser_id, int* consumed_data_len)
+{
+       unsigned char* src_data;
+       int index = 0;
+
+       if (tlv_str == NULL || browser_id == NULL || consumed_data_len == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || browser_id == NULL ||consumed_data_len == 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;
+       }
+
+       index = curr_offset;
+       src_data = &tlv_str[0];
+
+       if ((src_data[index++] & 0x7F) != SATK_BROWSER_IDENTITY_TAG) {
+               dbg("[SAT] SAT PARSER -  Browser ID tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+       if (src_data[index++] != SATK_BROWSER_ID_LENGTH) {
+               dbg("[SAT] SAT PARSER -  incorrect length value.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       dbg("[SAT] SAT PARSER - : browser ID value:ox%x", src_data[index]);
+
+       switch (src_data[index]) {
+               case 0x00:
+                       *browser_id = BROWSER_ID_DEFAULT;
+                       break;
+               case 0x01:
+                       *browser_id = BROWSER_ID_WML;
+                       break;
+               case 0x02:
+                       *browser_id = BROWSER_ID_HTML;
+                       break;
+               case 0x03:
+                       *browser_id = BROWSER_ID_XHTML;
+                       break;
+               case 0x04:
+                       *browser_id = BROWSER_ID_CHTML;
+                       break;
+               default:
+                       *browser_id = BROWSER_ID_RESERVED;
+                       break;
+       }
+
+       *consumed_data_len = 3;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_url_tlv(unsigned char* tlv_str, int tlv_len, int curr_offset,
+               struct tel_sat_url* url, int* consumed_data_len)
+{
+       unsigned char* src_data;
+       int index= curr_offset;
+       int len_of_len=0, url_len=0;
+
+       if (tlv_str == NULL || url == NULL || consumed_data_len == NULL)        {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || url == NULL ||consumed_data_len == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       src_data = &tlv_str[0];
+       if(tlv_len <= (curr_offset+1)) {
+               dbg("[SAT] SAT PARSER -  incorrect length original_command_len=%d", tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if((src_data[index++]&0x7F) != SATK_URL_TAG) {
+               dbg("[SAT] SAT PARSER -  Browser URL tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       //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;
+       }
+
+       url_len =  src_data[index+len_of_len-1];
+       index+=len_of_len; //index pointing to url.
+
+       if(url_len > 0) {
+               if(url_len > SAT_URL_LEN_MAX)
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+               else
+                       memcpy(url->url, &src_data[index], url_len);
+       } else  {
+               dbg("[SAT] SAT PARSER -  NULL string for URL");
+       }
+
+       *consumed_data_len = 1+len_of_len+url_len;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_bearer_tlv(unsigned char* tlv_str, int tlv_len, int curr_offset,
+               struct tel_sat_bearer_list* satk_bearer, int* consumed_data_len)
+{
+       unsigned char* src_data;
+       int index, len_of_len = 0;
+       int list_len = 0, list_idx = 0;
+
+       if (tlv_str == NULL || consumed_data_len == NULL || satk_bearer == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || satk_bearer == 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;
+       }
+
+       src_data = &tlv_str[0];
+       index = curr_offset;
+
+       if ((src_data[index++] & 0x7F) != SATK_BEARER_TAG) {
+               dbg("[SAT] SAT PARSER - _sat_decode_bearer_tlv: alphaID TAG missing");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //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;
+       }
+
+       satk_bearer->count = src_data[index + len_of_len - 1];
+       list_len = satk_bearer->count;
+       index += len_of_len;
+
+       if ((index + list_len) > tlv_len) {
+               dbg("[SAT] SAT PARSER -  incorrect cmd len, expected len = %d, orig_len=%d",    (index + list_len), tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if (satk_bearer->count > 0) {
+               if (list_len > SAT_BEARER_LIST_MAX_COUNT)
+                       list_len = SAT_BEARER_LIST_MAX_COUNT;
+
+               for (list_idx = 0; list_idx < list_len; list_idx++) {
+                       switch (src_data[index]) {
+                               case 0x00:
+                                       satk_bearer->bear[list_idx] = BEARER_LIST_SMS;
+                                       break;
+                               case 0x01:
+                                       satk_bearer->bear[list_idx] = BEARER_LIST_CSD;
+                                       break;
+                               case 0x02:
+                                       satk_bearer->bear[list_idx] = BEARER_LIST_USSD;
+                                       break;
+                               case 0x03:
+                                       satk_bearer->bear[list_idx] = BEARER_LIST_GPRS;
+                                       break;
+                               default:
+                                       satk_bearer->bear[list_idx] = BEARER_LIST_RESERVED;
+                                       break;
+                       }
+                       dbg("[SAT] SAT PARSER -  bearer[%d]=0x%x", list_idx, satk_bearer->bear[list_idx]);
+                       index++;
+               }
+       } else {
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       *consumed_data_len = 1 + len_of_len + list_len;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_provisioning_file_ref_tlv(unsigned char* tlv_str,
+               int tlv_len, int curr_offset, struct tel_sat_provisioning_file_ref* prf, int* data_len_consumed)
+{
+       unsigned char* src_data;
+       int index = curr_offset;
+       int len_of_len = 0, prf_len = 0;
+
+       if (tlv_str == NULL || prf == NULL || data_len_consumed == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || prf == NULL ||data_len_consumed == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       src_data = &tlv_str[0];
+       if (tlv_len <= (curr_offset + 1)) {
+               dbg("[SAT] SAT PARSER -  incorrect length original_command_len=%d",tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if ((src_data[index++] & 0x7F) != SATK_PROVISIONING_REF_FILE_TAG) {
+               dbg("[SAT] SAT PARSER -  PRF tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       //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;
+       }
+
+       prf_len = src_data[index + len_of_len - 1];
+       prf->file_path_length = prf_len;
+       index += len_of_len; //index pointing to prf.
+
+       if (prf_len > 0) {
+               if (prf_len > SAT_PROVISIONING_FILE_PATH_LEN_MAX)
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+               else
+                       memcpy(prf->file_path, &src_data[index], prf_len);
+       } else {
+               dbg("[SAT] SAT PARSER -  NULL string for PRF");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       *data_len_consumed = 1 + len_of_len + prf_len;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_bearer_description_tlv(unsigned char* tlv_str,
+               int tlv_len, int curr_offset, struct tel_sat_bearer_description *bearer_desc_obj,
+               int* consumed_data_len)
+{
+       int index, length=0;
+       unsigned char* src_data;
+
+       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;
+       }
+
+       index = curr_offset;
+       src_data = &tlv_str[0];
+       while(1){
+               if(index >= tlv_len){
+                       dbg("bearer desc cannot find. UICC Server mode");
+                       *consumed_data_len = 0;
+                       return TCORE_SAT_SUCCESS;
+               }
+
+               if( (src_data[index]&0x7F) == SATK_BEARER_DISCRIPTION_TAG ){
+                       dbg("find bearer description tag index(%d)", index);
+                       index++;
+                       break;
+               }
+               index++;
+       }
+
+       //length
+       length = src_data[index++];
+       dbg("bearer description length (%d)", length);
+
+       //bearer parameter
+       switch(src_data[index++]){
+               case BEARER_CSD:
+                       bearer_desc_obj->bearer_type = BEARER_CSD;
+                       bearer_desc_obj->bearer_parameter.cs_bearer_param.data_rate = src_data[index++];
+                       bearer_desc_obj->bearer_parameter.cs_bearer_param.service_type = src_data[index++];
+                       bearer_desc_obj->bearer_parameter.cs_bearer_param.connection_element_type = src_data[index++];
+                       break;
+               case BEARER_GPRS:
+                       bearer_desc_obj->bearer_type = BEARER_GPRS;
+                       bearer_desc_obj->bearer_parameter.ps_bearer_param.precedence_class = src_data[index++];
+                       bearer_desc_obj->bearer_parameter.ps_bearer_param.delay_class = src_data[index++];
+                       bearer_desc_obj->bearer_parameter.ps_bearer_param.reliability_class = src_data[index++];
+                       bearer_desc_obj->bearer_parameter.ps_bearer_param.peak_throughput_class = src_data[index++];
+                       bearer_desc_obj->bearer_parameter.ps_bearer_param.mean_throughput_class = src_data[index++];
+                       bearer_desc_obj->bearer_parameter.ps_bearer_param.pdp_type = BIP_GPRS_PDP_TYPE_RESERVED;
+                       if(src_data[index] == BIP_GPRS_PDP_TYPE_IP)
+                               bearer_desc_obj->bearer_parameter.ps_bearer_param.pdp_type = BIP_GPRS_PDP_TYPE_IP;
+                       break;
+               case BEARER_DEFAULT_BEARER_FROM_TRANSPORT_LAYER:
+                       bearer_desc_obj->bearer_type = BEARER_DEFAULT_BEARER_FROM_TRANSPORT_LAYER;
+                       break;
+               case BEARER_LOCAL_LINK_TECHNOLOGY_INDEPENDENT:
+                       bearer_desc_obj->bearer_type = BEARER_DEFAULT_BEARER_FROM_TRANSPORT_LAYER;
+                       break;
+               default:
+                       bearer_desc_obj->bearer_type = BEARER_RESERVED;
+                       dbg("bearer type not supported");
+                       return TCORE_SAT_BEYOND_ME_CAPABILITY;
+       }
+
+       *consumed_data_len = 1+1+length;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_channel_data_tlv(unsigned char* tlv_str,
+               int tlv_len, int curr_offset, struct tel_sat_channel_data *channel_data_obj,
+               int* consumed_data_len)
+{
+       int index = 0;
+       int len_of_len = 0, channel_data_len = 0;
+       unsigned char* src_data;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || channel_data_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || channel_data_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_CHANNEL_DATA_TAG){
+               dbg("[SAT] SAT PARSER - tag not found.=%d",src_data[index]);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //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;
+       }
+
+       channel_data_len = src_data[index+len_of_len-1];
+       dbg("[SAT] parser: channel_data_len=%d",channel_data_len);
+       index += len_of_len;
+
+       if((index+channel_data_len) > tlv_len) {
+               dbg("[SAT] SAT PARSER - incorrect cmd len, expected len = %d, orig_len=%d", (index+channel_data_len),tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //data
+       channel_data_obj->data_string_len = channel_data_len;
+       memcpy(channel_data_obj->data_string, &src_data[index], channel_data_len);
+
+       *consumed_data_len = 1+len_of_len+channel_data_len;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_channel_data_length_tlv(unsigned char* tlv_str,
+               int tlv_len, int curr_offset, struct tel_sat_channel_data_len *data_len_obj,
+               int* consumed_data_len)
+{
+       int index;
+       unsigned char* src_data;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || data_len_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || data_len_obj == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //tag
+       index = curr_offset;
+       src_data = &tlv_str[0];
+       if((src_data[index++]&0x7F) != SATK_CHANNEL_DATA_LEN_TAG) {
+               dbg("[SAT] SAT PARSER -  channel data tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       //length
+       if(src_data[index++] != SATK_CHANNEL_DATA_LENGTH_VALUE_LENGTH) {
+               dbg("[SAT] SAT PARSER -  incorrect length");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       //data
+       data_len_obj->data_len = src_data[index];
+
+       *consumed_data_len = 3;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_buffer_size_tlv(unsigned char* tlv_str,
+               int tlv_len, int curr_offset, struct tel_sat_buffer_size *buffer_size_obj,
+               int* consumed_data_len)
+{
+       int index;
+       unsigned char* src_data;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || buffer_size_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || buffer_size_obj == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if(tlv_len <= (curr_offset+1)+SATK_BUFFER_SIZE_LENGTH) {
+               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_BUFFER_SIZE_TAG) {
+               dbg("[SAT] SAT PARSER -  buffer size tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       //length
+       if(src_data[index++] != SATK_BUFFER_SIZE_LENGTH) {
+               dbg("[SAT] SAT PARSER -  incorrect length");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       buffer_size_obj->size[0] = src_data[index++];
+       buffer_size_obj->size[1] = src_data[index];
+
+       *consumed_data_len = 4;
+       dbg("[SAT] SAT PARSER -  buffer size = 0x%x%x", buffer_size_obj->size[0], buffer_size_obj->size[1]);
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_other_address_tlv(unsigned char* tlv_str,
+               int tlv_len, int curr_offset, struct tel_sat_other_address *other_address_obj,
+               int* consumed_data_len)
+{
+       gchar* address = NULL;
+       int index, address_len;
+       unsigned char* src_data;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || other_address_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || other_address_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_OTHER_ADDRESS_TAG) {
+               dbg("[SAT] SAT PARSER -  other address tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       //length
+       address_len = src_data[index++];
+       if((index+address_len) > tlv_len) {
+               dbg("[SAT] SAT PARSER -  incorrect cmd len, expected len = %d, orig_len=%d", (index+address_len),tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       if(address_len-1 > SAT_OTHER_ADDR_LEN_MAX){
+               dbg("[SAT] SAT PARSER - address is longer than capability");
+               return TCORE_SAT_BEYOND_ME_CAPABILITY;
+       }
+
+       //other address type
+       switch(src_data[index++]){
+               case ADDR_TYPE_IPv4:{
+                       other_address_obj->address_type = ADDR_TYPE_IPv4;
+                       address = g_strdup_printf("%d.%d.%d.%d", src_data[index], src_data[index+1], src_data[index+2], src_data[index+3]);
+               }break;
+               case ADDR_TYPE_IPv6:{
+                       other_address_obj->address_type = ADDR_TYPE_IPv6;
+                       address = g_strdup_printf("%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:",
+                                       src_data[index], src_data[index+1], src_data[index+2], src_data[index+3],
+                                       src_data[index+4], src_data[index+5], src_data[index+6], src_data[index+7],
+                                       src_data[index+8], src_data[index+9], src_data[index+10], src_data[index+11],
+                                       src_data[index+12], src_data[index+13], src_data[index+14], src_data[index+15]);
+               }break;
+               default:{
+                       other_address_obj->address_type = ADDR_RESERVED;
+                       address = g_strdup("");
+               }break;
+       }//end of switch
+
+       //address
+       memcpy(other_address_obj->address, address, strlen(address));
+       other_address_obj->address_len = strlen(address);
+
+       if(address)
+               g_free(address);
+
+       dbg("destination address(%s)", other_address_obj->address);
+       *consumed_data_len = 2+address_len;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_uicc_terminal_interface_tlv(unsigned char* tlv_str,
+               int tlv_len, int curr_offset, struct tel_sat_uicc_terminal_interface_transport_level *level_obj,
+               int* consumed_data_len)
+{
+       int index;
+       unsigned char* src_data;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || level_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || level_obj == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       if(tlv_len <= (curr_offset+1)+SATK_UICC_ME_TRANS_INTERFACE_LEVEL_LENGTH) {
+               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_USIM_ME_INTERFACE_TRANSPORT_LEVEL_TAG) {
+               dbg("[SAT] SAT PARSER - UICC/TERMINAL Interface transport level tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       //length
+       if(src_data[index++] != SATK_UICC_ME_TRANS_INTERFACE_LEVEL_LENGTH) {
+               dbg("[SAT] SAT PARSER -  incorrect length");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       level_obj->protocol_type = src_data[index++];
+       level_obj->port_number = src_data[index++] << 8;
+       level_obj->port_number |= src_data[index];
+
+       *consumed_data_len = 2+SATK_UICC_ME_TRANS_INTERFACE_LEVEL_LENGTH;
+       dbg("[SAT] SAT PARSER -  protocol type(%d) , port number(%d)", level_obj->protocol_type, level_obj->port_number);
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_remote_entity_address_tlv(unsigned char* tlv_str,
+               int tlv_len, int curr_offset, struct tel_sat_remote_entity_address *remote_address_obj,
+               int* consumed_data_len)
+{
+       int index = 0;
+       int len_of_len = 0, remote_data_len = 0;
+       unsigned char* src_data;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || remote_address_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || remote_address_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_REMOTE_ENTITY_ADDRESS_TAG){
+               dbg("[SAT] SAT PARSER - tag not found.=%d",src_data[index]);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       //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;
+       }
+
+       remote_data_len = src_data[index+len_of_len-1];
+       dbg("[SAT] parser: remote_data_len=%d",remote_data_len);
+       index += len_of_len;
+
+       //data
+       switch(src_data[index++]){
+               case REMOTE_ENTITY_ADDR_CODING_TYPE_IEEE802_48BIT:
+                       remote_address_obj->coding_type = REMOTE_ENTITY_ADDR_CODING_TYPE_IEEE802_48BIT;
+                       break;
+               case REMOTE_ENTITY_ADDR_CODING_TYPE_IRDA_32BIT:
+                       remote_address_obj->coding_type = REMOTE_ENTITY_ADDR_CODING_TYPE_IRDA_32BIT;
+                       break;
+               default:
+                       remote_address_obj->coding_type =REMOTE_ENTITY_ADDR_CODING_TYPE_RESERVED;
+                       break;
+       }
+
+       remote_address_obj->length = remote_data_len - 1;
+       memcpy(remote_address_obj->remote_entity_address, &src_data[index], remote_address_obj->length);
+
+       *consumed_data_len = 1+len_of_len+remote_data_len;
+       return TCORE_SAT_SUCCESS;
+}
+
+static enum tcore_sat_result _sat_decode_network_access_name_tlv(unsigned char* tlv_str,
+               int tlv_len, int curr_offset, struct tel_sat_network_access_name *access_name_obj,
+               int* consumed_data_len)
+{
+       int index, idx, name_idx, name_length;
+       unsigned char* src_data;
+
+       if(tlv_str == NULL || consumed_data_len == NULL || access_name_obj == NULL) {
+               dbg("[SAT] SAT PARSER -  tlv_str == NULL || consumed_data_len == NULL || access_name_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_NETWORK_ACCESS_TAG) {
+               dbg("[SAT] SAT PARSER -  network access name tag missing.");
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //send TR
+       }
+
+       //length
+       name_length = src_data[index++];
+       if((index+name_length) > tlv_len) {
+               dbg("[SAT] SAT PARSER -  incorrect cmd len, expected len = %d, orig_len=%d", (index+name_length),tlv_len);
+               return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+       }
+
+       access_name_obj->length = name_length;
+       if(access_name_obj->length > SAT_NET_ACC_NAM_LEN_MAX){
+               dbg("[SAT] SAT PARSER - network access name is longer than capability");
+               return TCORE_SAT_BEYOND_ME_CAPABILITY;
+       }
+
+       name_idx = 0;
+       for(idx = 0; idx < access_name_obj->length; idx++){
+               dbg("data (%c) Bool(%d)",src_data[index], g_ascii_isalpha(src_data[index]) );
+
+               if( g_ascii_isalpha(src_data[index]) ){
+                       access_name_obj->network_access_name[name_idx] = src_data[index];
+                       name_idx++;
+               }
+               else{
+
+                       if(src_data[index] == 0x02){//02 convert to "."
+                               access_name_obj->network_access_name[name_idx] = '.';
+                               name_idx++;
+                       }
+               }
+               index++;
+       }
+
+       //network access name
+       dbg("network access name(%s)", access_name_obj->network_access_name);
+
+       *consumed_data_len = 2+name_length;
+       return TCORE_SAT_SUCCESS;
+}
+
+//decode proactive cmd
+//6.4.1 DISPLAY TEXT
+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 -  o_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;
+}
+
+//6.4.2 GET INKEY
+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 -  o_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;
+}
+
+//6.4.3 GET INPUT
+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 -  o_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_input.alphabet_set = TRUE;
+               dbg("[SAT] SAT PARSER - Alphabet set");
+       }
+       else{
+               sat_cmd_ind_data->data.get_input.command_detail.cmd_qualifier.get_input.alphabet_set = FALSE;
+               dbg("[SAT] SAT PARSER - Numeric info");
+       }
+
+       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 = FALSE;
+               dbg("[SAT] SAT PARSER -  user input not be revealed");
+       }
+       else{
+               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 - packing required");
+       }
+       else{
+               sat_cmd_ind_data->data.get_input.command_detail.cmd_qualifier.get_input.user_input_unpacked_format = TRUE;
+               dbg("[SAT] SAT PARSER - unpacked format");
+       }
+
+       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;
+}
+
+//6.4.4 MORE TIME
+static enum tcore_sat_result _sat_decode_more_time(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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //command detail
+       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++];
+
+       //device identifier
+       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;
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.5 PLAY TONE
+static enum tcore_sat_result _sat_decode_play_tone(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0, 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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //command detail
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.play_tone.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.play_tone.command_detail.cmd_type = cmd_data[index++];
+
+       /* ******decode command qualifier****** */
+       if (cmd_data[index] & 0x01)
+               sat_cmd_ind_data->data.play_tone.command_detail.cmd_qualifier.play_tone.vibration_alert = VIBRATE_ALERT_REQUIRED;
+       else
+               sat_cmd_ind_data->data.play_tone.command_detail.cmd_qualifier.play_tone.vibration_alert = VIBRATE_ALERT_OPTIONAL;
+
+       //device identifier
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.play_tone.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //alpha id - optional
+       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.play_tone.alpha_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+
+               index+=data_len_consumed;
+               if(index >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       dbg("[SAT] SAT PARSER - default value is set - tone type, duration");
+                       sat_cmd_ind_data->data.play_tone.tone.tone_type = GENERAL_BEEP;
+                       sat_cmd_ind_data->data.play_tone.duration.time_unit = TIME_UNIT_SECONDS;
+                       sat_cmd_ind_data->data.play_tone.duration.time_interval = 2;
+                       return TCORE_SAT_SUCCESS;
+               }
+       }
+
+       //tone - optional
+       if((cmd_data[index]&0x7F) == SATK_TONE_TAG){
+               rv = _sat_decode_tone_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.play_tone.tone, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+               index+=data_len_consumed;
+       }
+       else{
+               sat_cmd_ind_data->data.play_tone.tone.tone_type = GENERAL_BEEP;
+       }
+
+       //time duration - optional
+       if((cmd_data[index]&0x7F)==SATK_DURATION_TAG){
+               rv =_sat_decode_duration_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.play_tone.duration, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS){
+                       return rv; //SEND TR
+               }
+
+               index+=data_len_consumed;
+               if(index >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+       }
+       else{
+               dbg("[SAT] SAT PARSER -  Duration TLV not present, ME should use a default value.");
+               sat_cmd_ind_data->data.play_tone.duration.time_unit = TIME_UNIT_SECONDS;
+               sat_cmd_ind_data->data.play_tone.duration.time_interval = 2;
+       }
+
+       //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.play_tone.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
+       }
+
+//ToDo:  Text Attribute and frames
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.7 REFRESH
+static enum tcore_sat_result _sat_decode_refresh(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0, 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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //command detail
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.refresh.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.refresh.command_detail.cmd_type = cmd_data[index++];
+
+       /* ******decode command qualifier****** */
+       switch(cmd_data[index]){
+               case REFRESH_SIM_INIT_AND_FULL_FCN:
+               case REFRESH_FCN:
+               case REFRESH_SIM_INIT_AND_FCN:
+               case REFRESH_SIM_INIT   :
+               case REFRESH_SIM_RESET:
+                       sat_cmd_ind_data->data.refresh.command_detail.cmd_qualifier.refresh.refresh = cmd_data[index];
+                       dbg("[SAT] SAT PARSER - : refresh mode=[0x%02x]:0-init&FFCN, 1-FCN, 2-init&FCN, 3-init, 4-reset", cmd_data[index]);
+                       break;
+
+               case REFRESH_3G_APPLICATION_RESET:
+               case REFRESH_3G_SESSION_RESET:
+               case REFRESH_RESERVED:
+               default:
+                       dbg("[SAT] SAT PARSER - : refresh mode=0x%02x Not Supported", cmd_data[index]);
+                       return TCORE_SAT_BEYOND_ME_CAPABILITY;
+                       break;
+       }
+
+       //device identifier
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.refresh.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //check file list
+       index+=4;
+       if( (sat_cmd_ind_data->data.refresh.command_detail.cmd_qualifier.refresh.refresh == REFRESH_FCN)
+               || (sat_cmd_ind_data->data.refresh.command_detail.cmd_qualifier.refresh.refresh == REFRESH_SIM_INIT_AND_FCN) ){
+
+               rv = _sat_decode_file_list_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.refresh.file_list, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS)
+                       return rv;
+       }
+       else
+               sat_cmd_ind_data->data.refresh.file_list.file_count = 0;
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.8 SETUP MENU
+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");
+       }
+
+//ToDo:  Text Attribute, Text Attribute list. refer ETSI 102.223.
+       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.9 SELECT ITEM
+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 -  o_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;
+}
+
+//6.4.10 SEND SMS
+static enum tcore_sat_result _sat_decode_send_sms(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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.send_sms.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.send_sms.command_detail.cmd_type = cmd_data[index++];
+
+       /* ******decode command qualifier****** */
+       if (cmd_data[index] & 0x01) {
+               sat_cmd_ind_data->data.send_sms.command_detail.cmd_qualifier.send_sms.packing_by_me_required = TRUE;
+       }
+       else {
+               sat_cmd_ind_data->data.send_sms.command_detail.cmd_qualifier.send_sms.packing_by_me_required = FALSE;
+               dbg("[SAT] SAT PARSER - packing by me required is false");
+       }
+
+       //device identities
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.send_sms.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //alpha identifier
+       index+=4;
+       if((cmd_data[index]&0x7F) == SATK_ALPHA_IDENTIFIER_TAG){
+               data_len_consumed = 0;
+               rv = _sat_decode_alpha_identifier_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.send_sms.alpha_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+               index+=data_len_consumed;
+       }
+
+       //address
+       if((cmd_data[index]&0x7F) == SATK_ADDRESS_TAG){
+               data_len_consumed = 0;
+               rv = _sat_decode_address_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.send_sms.address, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+               index+=data_len_consumed;
+       }
+
+       //SMS-TPDU
+       data_len_consumed = 0;
+       rv = _sat_decode_sms_tpdu_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.send_sms.sms_tpdu, &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;
+       }
+
+       //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.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
+       }
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.11 SEND SS
+static enum tcore_sat_result _sat_decode_send_ss(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0, 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 || sat_cmd_ind_data == NULL){
+               dbg("[SAT] SAT PARSER -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.send_ss.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.send_ss.command_detail.cmd_type = cmd_data[index++];
+
+       /** command detail **/
+       index++; //RFU
+
+       //device identities
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.send_ss.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //alpha identifier - optional
+       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.send_ss.alpha_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+               index+=data_len_consumed;
+       }
+
+       //ss string
+       rv = _sat_decode_ss_string_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.send_ss.ss_string, &data_len_consumed);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //icon identifier- optional
+       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.send_ss.icon_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS){
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //SEND TR
+               }
+
+       }
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.12 SEND USSD
+static enum tcore_sat_result _sat_decode_send_ussd(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0, 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 || sat_cmd_ind_data == NULL){
+               dbg("[SAT] SAT PARSER -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.send_ussd.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.send_ussd.command_detail.cmd_type = cmd_data[index++];
+
+       /** command detail **/
+       index++; //RFU
+
+       //device identities
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.send_ussd.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //alpha identifier - optional
+       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.send_ussd.alpha_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+               index+=data_len_consumed;
+       }
+
+       //ussd string
+       rv = _sat_decode_ussd_string_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.send_ussd.ussd_string, &data_len_consumed);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //icon identifier- optional
+       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.send_ussd.icon_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS){
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //SEND TR
+               }
+
+       }
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.13 SETUP CALL
+static enum tcore_sat_result _sat_decode_setup_call(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0, 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 || sat_cmd_ind_data == NULL){
+               dbg("[SAT] SAT PARSER -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //command detail
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.setup_call.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.setup_call.command_detail.cmd_type = cmd_data[index++];
+
+       /* ******decode command qualifier****** */
+       switch(cmd_data[index]){
+               case SETUP_CALL_IF_ANOTHER_CALL_NOT_BUSY:
+               case SETUP_CALL_IF_ANOTHER_CALL_NOT_BUSY_WITH_REDIAL:
+               case SETUP_CALL_PUT_ALL_OTHER_CALLS_ON_HOLD:
+               case SETUP_CALL_PUT_ALL_OTHER_CALLS_ON_HOLD_WITH_REDIAL:
+               case SETUP_CALL_DISCONN_ALL_OTHER_CALLS:
+               case SETUP_CALL_DISCONN_ALL_OTHER_CALLS_WITH_REDIAL:
+                       sat_cmd_ind_data->data.setup_call.command_detail.cmd_qualifier.setup_call.setup_call = cmd_data[index];
+                       dbg("[SAT] SAT PARSER -  setup_call.cmd_qualifier= 0x%02x", sat_cmd_ind_data->data.setup_call.command_detail.cmd_qualifier.setup_call.setup_call);
+                       break;
+               case SETUP_CALL_RESERVED:
+               default:
+                       dbg("[SAT] SAT PARSER -  setup_call.cmd_qualifier= 0x%02x", cmd_data[index]);
+                       return TCORE_SAT_BEYOND_ME_CAPABILITY;
+                       break;
+       }
+
+       //device identifier
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.setup_call.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //alpha identifier (user confirmation) - optional
+       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.setup_call.user_confirm_alpha_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+               index+=data_len_consumed;
+       }
+
+       //address
+       rv = _sat_decode_address_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.setup_call.address, &data_len_consumed);
+       if(rv != TCORE_SAT_SUCCESS) {
+               return rv;
+       }
+
+       index+=data_len_consumed;
+       if(index >= o_length){
+               dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+               return TCORE_SAT_SUCCESS;
+       }
+
+       //capability configuration parameter - optional
+       if((cmd_data[index]&0x7F)==SATK_CAPABILITY_CONFIGURATION_PARAMETERS_TAG){
+               rv =_sat_decode_ccp_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.setup_call.ccp, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS){
+                       return rv; //SEND TR
+               }
+
+               index+=data_len_consumed;
+               if(index >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+       }
+
+       //sub address - optional
+       if((cmd_data[index]&0x7F)==SATK_SUB_ADDRESS_TAG){
+               rv =_sat_decode_sub_address_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.setup_call.subaddress, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS){
+                       return rv; //SEND TR
+               }
+
+               index+=data_len_consumed;
+               if(index >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+       }
+
+       //time duration - optional
+       if((cmd_data[index]&0x7F)==SATK_DURATION_TAG){
+               rv =_sat_decode_duration_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.setup_call.duration, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS){
+                       return rv; //SEND TR
+               }
+
+               index+=data_len_consumed;
+               if(index >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+       }
+
+       //icon identifier (user confirmation) - optional
+       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.setup_call.user_confirm_icon_id, &data_len_consumed);
+
+               if(rv != TCORE_SAT_SUCCESS){
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //SEND TR
+               }
+
+               index+=data_len_consumed;
+               if(index >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+       }
+
+       //alpha identifier (call setup) - optional
+       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.setup_call.call_setup_alpha_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+
+               index+=data_len_consumed;
+               if(index >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+       }
+
+       //icon identifier (call setup) - optional
+       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.setup_call.call_setup_icon_id, &data_len_consumed);
+
+               if(rv != TCORE_SAT_SUCCESS){
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD; //SEND TR
+               }
+
+               index+=data_len_consumed;
+               if(index >= o_length){
+                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                       return TCORE_SAT_SUCCESS;
+               }
+       }
+
+       //ToDo:  Text Attribute (user_confirmation , call_setup)
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.15 PROVIDE LOCAL INFO
+static enum tcore_sat_result _sat_decode_provide_local_info(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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //command detail
+       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++];
+
+       /* ******decode command qualifier****** */
+       switch(cmd_data[index]){
+               case LOCAL_INFO_DATE_TIME_AND_TIMEZONE:
+               case LOCAL_INFO_LANGUAGE:
+                       sat_cmd_ind_data->data.setup_event_list.command_detail.cmd_qualifier.provide_local_info.provide_local_info = cmd_data[index];
+                       break;
+               //TODO - Other cases
+               default:
+                       sat_cmd_ind_data->data.setup_event_list.command_detail.cmd_qualifier.provide_local_info.provide_local_info = LOCAL_INFO_RESERVED;
+                       break;
+       }
+
+       //device identifier
+       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;
+
+       //TODO - UTRAN Measurement Qualifier
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.16 SETUP EVENT LIST
+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, 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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //command detail
+       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++];
+
+       //device identifier
+       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;
+
+       //event list
+       index+=4;
+       rv = _sat_decode_event_list_tlv(o_cmd_data, o_length, index,
+                       &sat_cmd_ind_data->data.setup_event_list.event_list,
+                       &sat_cmd_ind_data->data.setup_event_list.event_list, &data_len_consumed);
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.22 SETUP IDLE MODE TEXT
+static enum tcore_sat_result _sat_decode_setup_idle_mode_text(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0, 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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //command detail
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.setup_idle_mode_text.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.setup_idle_mode_text.command_detail.cmd_type = cmd_data[index++];
+
+       //device identifier
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.setup_idle_mode_text.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //text string
+       index+=4;
+       rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.setup_idle_mode_text.text, &data_len_consumed);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       if(sat_cmd_ind_data->data.setup_idle_mode_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.setup_idle_mode_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.setup_idle_mode_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
+       }
+
+       //ToDo:  Text Attribute
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.24 SEND DTMF
+static enum tcore_sat_result _sat_decode_send_dtmf(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0, 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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //command detail
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.send_dtmf.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.send_dtmf.command_detail.cmd_type = cmd_data[index++];
+
+       //device identifier
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.send_dtmf.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //alpha identifier - optional
+       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.send_dtmf.alpha_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+               index+=data_len_consumed;
+       }
+
+       // DTMF string - mandatory
+       if ((cmd_data[index] & 0x7F) == SATK_DTMF_STRING_TAG) {
+               rv = _sat_decode_dtmf_string_tlv(o_cmd_data, o_length, index,
+                               &sat_cmd_ind_data->data.send_dtmf.dtmf_string, &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;
+       } else {
+               dbg("[SAT] SAT PARSER - DTMF tlv is missed.");
+               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+       }
+
+       //icon identifier - optional
+       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.setup_idle_mode_text.icon_id, &data_len_consumed);
+
+               if (rv != TCORE_SAT_SUCCESS) {
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+               }
+
+               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
+       }
+
+       //ToDo:  Text Attribute, Frame Identifier
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.25 LANGUAGE NOTIFICATION
+static enum tcore_sat_result _sat_decode_language_notification(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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //command detail
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.language_notification.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.language_notification.command_detail.cmd_type = cmd_data[index++];
+
+       /* ******decode command qualifier****** */
+       if(cmd_data[index]&0x01)
+               sat_cmd_ind_data->data.language_notification.command_detail.cmd_qualifier.language_notification.specific_language = TRUE;
+       else
+               sat_cmd_ind_data->data.language_notification.command_detail.cmd_qualifier.language_notification.specific_language = FALSE;
+
+       //device identifier
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.language_notification.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //language - conditional
+       index+=4;
+       if (sat_cmd_ind_data->data.language_notification.command_detail.cmd_qualifier.language_notification.specific_language == TRUE) {
+               if((cmd_data[index]&0x7F) == SATK_LANGUAGE_TAG) {
+                       rv = _sat_decode_language_tlv(cmd_data, o_length, index, &sat_cmd_ind_data->data.language_notification.language);
+                       if(rv != TCORE_SAT_SUCCESS)
+                               return rv;
+               } else  {
+                       dbg("[SAT] SAT PARSER -  Language TLV is required but missing.");
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+               }
+       } else {
+               sat_cmd_ind_data->data.language_notification.language = SIM_LANG_UNSPECIFIED;
+               dbg("[SAT] SAT PARSER -  non-specific language");
+       }
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.26 LAUNCH BROWSER
+static enum tcore_sat_result _sat_decode_launch_browser(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0, 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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       //command detail
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.launch_browser.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.launch_browser.command_detail.cmd_type = cmd_data[index++];
+
+       // decode command qualifier
+       switch (cmd_data[index]) {
+               case 0x00:
+                       sat_cmd_ind_data->data.launch_browser.command_detail.cmd_qualifier.launch_browser.launch_browser =
+                                       LAUNCH_BROWSER_IF_NOT_ALREADY_LAUNCHED;
+                       break;
+               case 0x01:
+                       sat_cmd_ind_data->data.launch_browser.command_detail.cmd_qualifier.launch_browser.launch_browser =
+                                       LAUNCH_BROWSER_NOT_USED;
+                       break;
+               case 0x02:
+                       sat_cmd_ind_data->data.launch_browser.command_detail.cmd_qualifier.launch_browser.launch_browser =
+                                       LAUNCH_BROWSER_USE_EXISTING_BROWSER;
+                       break;
+               case 0x03:
+                       sat_cmd_ind_data->data.launch_browser.command_detail.cmd_qualifier.launch_browser.launch_browser =
+                                       LAUNCH_BROWSER_CLOSE_AND_LAUNCH_NEW_BROWSER;
+                       break;
+               case 0x04:
+                       sat_cmd_ind_data->data.launch_browser.command_detail.cmd_qualifier.launch_browser.launch_browser =
+                                       LAUNCH_BROWSER_NOT_USED2;
+                       break;
+               default:
+                       sat_cmd_ind_data->data.launch_browser.command_detail.cmd_qualifier.launch_browser.launch_browser =
+                                       LAUNCH_BROWSER_RESERVED;
+                       break;
+       }
+
+       //device identifier
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.language_notification.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       index += 4;
+
+       //Browser Identity TLV - Optional
+       if ((cmd_data[index] & 0x7F) == SATK_BROWSER_IDENTITY_TAG) {
+               rv = _sat_decode_browser_identity_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.launch_browser.browser_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS)
+                       return rv;
+               index += data_len_consumed;
+       } else {
+               dbg("[SAT] SAT PARSER - Browser ID NOT present");
+       }
+
+       //URL TLV - Mandatory
+       if ((cmd_data[index] & 0x7F) == SATK_URL_TAG) {
+               rv = _sat_decode_url_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.launch_browser.url, &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, decoding done.");
+                       return TCORE_SAT_SUCCESS;
+               } else {
+                       dbg("[SAT] SAT PARSER -  more TLVs to decode, decoding continue.");
+                       index += data_len_consumed;
+               }
+       } else {
+               dbg("[SAT] SAT PARSER - Browser URL NOT present! BUG! this value is mandatory!!!");
+               return TCORE_SAT_REQUIRED_VALUE_MISSING;
+       }
+
+       //bearer - optional
+       if ((cmd_data[index] & 0x7F) == SATK_BEARER_TAG) {
+               rv = _sat_decode_bearer_tlv(o_cmd_data, o_length, index,        &sat_cmd_ind_data->data.launch_browser.bearer, &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, decoding done.");
+                       return TCORE_SAT_SUCCESS;
+               } else {
+                       index += data_len_consumed;
+               }
+       } else {
+               dbg("[SAT] SAT PARSER -  Bearer TLV Not present.");
+       }
+
+       //Provisioning reference file - optional
+       sat_cmd_ind_data->data.launch_browser.file_ref_count = 0;
+       while ((cmd_data[index] & 0x7F) == SATK_PROVISIONING_REF_FILE_TAG) {
+               if (sat_cmd_ind_data->data.launch_browser.file_ref_count >= SAT_PROVISIONING_REF_MAX_COUNT) {
+                       dbg("[SAT] SAT PARSER -  More number of PRF entries than can be handled");
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+               }
+
+               rv = _sat_decode_provisioning_file_ref_tlv(
+                                                               o_cmd_data,
+                                                               o_length,
+                                                               index,
+                                                               &sat_cmd_ind_data->data.launch_browser.file_list[sat_cmd_ind_data->data.launch_browser.file_ref_count],
+                                                               &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               } else {
+                       sat_cmd_ind_data->data.launch_browser.file_ref_count++;
+               }
+
+               if (index + data_len_consumed >= o_length) {
+                       dbg("[SAT] SAT PARSER -  No more TLVs to decode, decoding done.");
+                       return TCORE_SAT_SUCCESS;
+               } else {
+                       index += data_len_consumed;
+               }
+       }
+
+       //text string(gateway/proxy identity) - optional
+       if ((cmd_data[index] & 0x7F) == SATK_TEXT_STRING_TAG) {
+               rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.launch_browser.gateway_proxy_text, &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, decoding done.");
+                       return TCORE_SAT_SUCCESS;
+               } else {
+                       index += data_len_consumed;
+               }
+       }
+
+       //alpha identifier - optional
+       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.launch_browser.user_confirm_alpha_id, &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, decoding done.");
+                       return TCORE_SAT_SUCCESS;
+               }
+               index+=data_len_consumed;
+       } else {
+               dbg("[SAT] SAT PARSER -  No Alpha ID TLV.");
+       }
+
+       //icon identifier - optional
+       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.launch_browser.user_confirm_icon_id, &data_len_consumed);
+
+               if (rv != TCORE_SAT_SUCCESS) {
+                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+               }
+
+               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
+       }
+
+       //ToDo:  Text Attribute, Frame Identifier
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.27 OPEN CHANNEL
+static enum tcore_sat_result _sat_decode_open_channel(unsigned char* o_cmd_data, int o_length,
+               int curr_offset, struct tcore_sat_proactive_command *sat_cmd_ind_data)
+{
+       int index = 0;
+       gboolean b_1st_duration = FALSE;
+       int bearer_desc_len =0, 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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.open_channel.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.open_channel.command_detail.cmd_type = cmd_data[index++];
+
+       /** command detail **/
+       sat_cmd_ind_data->data.open_channel.command_detail.cmd_qualifier.open_channel.immediate_link = FALSE;
+       sat_cmd_ind_data->data.open_channel.command_detail.cmd_qualifier.open_channel.automatic_reconnection = FALSE;
+       sat_cmd_ind_data->data.open_channel.command_detail.cmd_qualifier.open_channel.background_mode = FALSE;
+
+       if(cmd_data[index]&0x01){
+               sat_cmd_ind_data->data.open_channel.command_detail.cmd_qualifier.open_channel.immediate_link = TRUE;
+               dbg("[SAT] SAT PARSER - Immediate Link Establishment");
+       }
+
+       if(cmd_data[index]&0x02){
+               sat_cmd_ind_data->data.open_channel.command_detail.cmd_qualifier.open_channel.automatic_reconnection = TRUE;
+               dbg("[SAT] SAT PARSER - Auto Reconnection");
+       }
+
+       if(cmd_data[index]&0x04){
+               sat_cmd_ind_data->data.open_channel.command_detail.cmd_qualifier.open_channel.background_mode = TRUE;
+               dbg("[SAT] SAT PARSER - Background mode");
+       }
+
+       //device identities
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.open_channel.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //alpha identifier - optional
+       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.open_channel.alpha_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+               index+=data_len_consumed;
+       }
+
+       //icon id - optional
+       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.open_channel.icon_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS){
+                       return rv; //SEND TR
+               }
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+       }
+
+       //bearer description
+       rv =_sat_decode_bearer_description_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_desc, &data_len_consumed);
+       bearer_desc_len = data_len_consumed;
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+       //TODO UICC SERVER MODE
+
+       switch(sat_cmd_ind_data->data.open_channel.bearer_desc.bearer_type){
+               case BEARER_CSD:
+
+                       //address
+                       rv = _sat_decode_address_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.cs_bearer.address, &data_len_consumed);
+                       if(rv != TCORE_SAT_SUCCESS) {
+                               return rv;
+                       }
+                       index+=data_len_consumed;
+
+                       //sub address - optional
+                       if((cmd_data[index]&0x7F) == SATK_SUB_ADDRESS_TAG){
+                               data_len_consumed = 0;
+                               rv = _sat_decode_subaddress_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.cs_bearer.subaddress, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS) {
+                                       return rv;
+                               }
+                               index+=data_len_consumed;
+                       }
+
+                       //time duration 1- optional
+                       if((cmd_data[index]&0x7F)==SATK_DURATION_TAG){
+                               data_len_consumed = 0;
+                               rv =_sat_decode_duration_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.cs_bearer.duration1, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+                               index+=data_len_consumed;
+                               b_1st_duration = TRUE;
+                       }
+
+                       //time duration 2- optional
+                       if((cmd_data[index]&0x7F)==SATK_DURATION_TAG){
+
+                               if(!b_1st_duration){
+                                       dbg("duration 1 does not present!");
+                                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+                               }
+
+                               data_len_consumed = 0;
+                               rv =_sat_decode_duration_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.cs_bearer.duration2, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+                               index+=data_len_consumed;
+                       }
+
+                       //bearer description - already did it
+                       index+=bearer_desc_len;
+
+                       //buffer size
+                       rv =_sat_decode_buffer_size_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.buffer_size, &data_len_consumed);
+                       if(rv != TCORE_SAT_SUCCESS){
+                               return rv; //SEND TR
+                       }
+
+                       index+=data_len_consumed;
+                       if(index >= o_length){
+                               dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                               return TCORE_SAT_SUCCESS;
+                       }
+
+                       //other address - optional
+                       if((cmd_data[index]&0x7F)==SATK_OTHER_ADDRESS_TAG){
+                               data_len_consumed = 0;
+                               rv =_sat_decode_other_address_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.cs_bearer.other_address, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //text string - user login - optional
+                       if((cmd_data[index]&0x7F)==SATK_TEXT_STRING_TAG){
+                               data_len_consumed = 0;
+                               rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.cs_bearer.text_user_login, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS)
+                                       return rv;
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //text string - user password - optional
+                       if((cmd_data[index]&0x7F)==SATK_TEXT_STRING_TAG){
+                               data_len_consumed = 0;
+                               rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.cs_bearer.text_user_pwd, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS)
+                                       return rv;
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //UICC/TERMINAL interface transport level - optional
+                       if((cmd_data[index]&0x7F)==SATK_USIM_ME_INTERFACE_TRANSPORT_LEVEL_TAG){
+                               data_len_consumed = 0;
+                               rv = _sat_decode_uicc_terminal_interface_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.interface_transport_level, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS)
+                                       return rv;
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //destination address - optional
+                       if((cmd_data[index]&0x7F)==SATK_OTHER_ADDRESS_TAG){
+                               data_len_consumed = 0;
+                               rv =_sat_decode_other_address_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.data_destination_address, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       break;
+               case BEARER_GPRS:
+                       //bearer description - already did it
+                       index+=bearer_desc_len;
+
+                       //buffer size
+                       rv =_sat_decode_buffer_size_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.buffer_size, &data_len_consumed);
+                       if(rv != TCORE_SAT_SUCCESS){
+                               return rv; //SEND TR
+                       }
+
+                       index+=data_len_consumed;
+                       if(index >= o_length){
+                               dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                               return TCORE_SAT_SUCCESS;
+                       }
+
+                       //Network Access Name - optional
+                       if((cmd_data[index]&0x7F)==SATK_NETWORK_ACCESS_TAG){
+                               data_len_consumed = 0;
+                               rv =_sat_decode_network_access_name_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.ps_bearer.network_access_name, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //other address - optional
+                       if((cmd_data[index]&0x7F)==SATK_OTHER_ADDRESS_TAG){
+                               data_len_consumed = 0;
+                               rv =_sat_decode_other_address_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.ps_bearer.other_address, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //text string - user login - optional
+                       if((cmd_data[index]&0x7F)==SATK_TEXT_STRING_TAG){
+                               data_len_consumed = 0;
+                               rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.ps_bearer.text_user_login, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS)
+                                       return rv;
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //text string - user password - optional
+                       if((cmd_data[index]&0x7F)==SATK_TEXT_STRING_TAG){
+                               data_len_consumed = 0;
+                               rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.ps_bearer.text_user_pwd, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS)
+                                       return rv;
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //UICC/TERMINAL interface transport level - optional
+                       if((cmd_data[index]&0x7F)==SATK_USIM_ME_INTERFACE_TRANSPORT_LEVEL_TAG){
+                               data_len_consumed = 0;
+                               rv = _sat_decode_uicc_terminal_interface_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.interface_transport_level, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS)
+                                       return rv;
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       dbg("the value (0x%x) after interface transport level", cmd_data[index]&0x7F);
+
+                       //destination address - optional
+                       if((cmd_data[index]&0x7F)==SATK_OTHER_ADDRESS_TAG){
+                               data_len_consumed = 0;
+                               rv =_sat_decode_other_address_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.data_destination_address, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       break;
+               case BEARER_DEFAULT_BEARER_FROM_TRANSPORT_LAYER:
+                       //bearer description - already did it
+                       index+=bearer_desc_len;
+
+                       //buffer size
+                       rv =_sat_decode_buffer_size_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.buffer_size, &data_len_consumed);
+                       if(rv != TCORE_SAT_SUCCESS){
+                               return rv; //SEND TR
+                       }
+
+                       index+=data_len_consumed;
+                       if(index >= o_length){
+                               dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                               return TCORE_SAT_SUCCESS;
+                       }
+
+                       //other address - optional
+                       if((cmd_data[index]&0x7F)==SATK_OTHER_ADDRESS_TAG){
+                               data_len_consumed = 0;
+                               rv =_sat_decode_other_address_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.default_bearer.other_address, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //text string - user login - optional
+                       if((cmd_data[index]&0x7F)==SATK_TEXT_STRING_TAG){
+                               data_len_consumed = 0;
+                               rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.default_bearer.text_user_login, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS)
+                                       return rv;
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //text string - user password - optional
+                       if((cmd_data[index]&0x7F)==SATK_TEXT_STRING_TAG){
+                               data_len_consumed = 0;
+                               rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.default_bearer.text_user_pwd, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS)
+                                       return rv;
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //UICC/TERMINAL interface transport level - optional
+                       if((cmd_data[index]&0x7F)==SATK_USIM_ME_INTERFACE_TRANSPORT_LEVEL_TAG){
+                               data_len_consumed = 0;
+                               rv = _sat_decode_uicc_terminal_interface_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.interface_transport_level, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS)
+                                       return rv;
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //destination address - optional
+                       if((cmd_data[index]&0x7F)==SATK_OTHER_ADDRESS_TAG){
+                               data_len_consumed = 0;
+                               rv =_sat_decode_other_address_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.data_destination_address, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       break;
+               case BEARER_LOCAL_LINK_TECHNOLOGY_INDEPENDENT:
+
+                       //time duration 1- optional
+                       if((cmd_data[index]&0x7F)==SATK_DURATION_TAG){
+                               data_len_consumed = 0;
+                               rv =_sat_decode_duration_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.local_bearer.duration1, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+                               index+=data_len_consumed;
+                               b_1st_duration = TRUE;
+                       }
+
+                       //time duration 2- optional
+                       if((cmd_data[index]&0x7F)==SATK_DURATION_TAG){
+
+                               if(!b_1st_duration){
+                                       dbg("duration 1 does not present!");
+                                       return TCORE_SAT_COMMAND_NOT_UNDERSTOOD;
+                               }
+
+                               data_len_consumed = 0;
+                               rv =_sat_decode_duration_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.local_bearer.duration2, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+                               index+=data_len_consumed;
+                       }
+
+                       //bearer description - already did it
+                       index+=bearer_desc_len;
+
+                       //buffer size
+                       rv =_sat_decode_buffer_size_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.buffer_size, &data_len_consumed);
+                       if(rv != TCORE_SAT_SUCCESS){
+                               return rv; //SEND TR
+                       }
+
+                       index+=data_len_consumed;
+                       if(index >= o_length){
+                               dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                               return TCORE_SAT_SUCCESS;
+                       }
+
+                       //text string - user password - optional
+                       if((cmd_data[index]&0x7F)==SATK_TEXT_STRING_TAG){
+                               data_len_consumed = 0;
+                               rv = _sat_decode_text_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.local_bearer.text_user_pwd, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS)
+                                       return rv;
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //UICC/TERMINAL interface transport level - optional
+                       if((cmd_data[index]&0x7F)==SATK_USIM_ME_INTERFACE_TRANSPORT_LEVEL_TAG){
+                               data_len_consumed = 0;
+                               rv = _sat_decode_uicc_terminal_interface_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.interface_transport_level, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS)
+                                       return rv;
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //destination address - optional
+                       if((cmd_data[index]&0x7F)==SATK_OTHER_ADDRESS_TAG){
+                               data_len_consumed = 0;
+                               rv =_sat_decode_other_address_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.data_destination_address, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       //remote entity address - optional
+                       if((cmd_data[index]&0x7F)==SATK_REMOTE_ENTITY_ADDRESS_TAG){
+                               data_len_consumed = 0;
+                               rv =_sat_decode_remote_entity_address_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.open_channel.bearer_detail.local_bearer.remote_entity_address, &data_len_consumed);
+                               if(rv != TCORE_SAT_SUCCESS){
+                                       return rv; //SEND TR
+                               }
+
+                               index+=data_len_consumed;
+                               if(index >= o_length){
+                                       dbg("[SAT] SAT PARSER - no more TLVs to decode.");
+                                       return TCORE_SAT_SUCCESS;
+                               }
+                       }
+
+                       break;
+               default:
+                       break;
+       }//end of switch
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.28 CLOSE CHANNEL
+static enum tcore_sat_result _sat_decode_close_channel(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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.close_channel.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.close_channel.command_detail.cmd_type = cmd_data[index++];
+
+       /** command detail **/
+       index++; //RFU
+
+       //device identities
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.close_channel.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //alpha identifier - optional
+       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.close_channel.alpha_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+               index+=data_len_consumed;
+       }
+
+       //icon id - optional
+       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.close_channel.icon_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS){
+                       return rv; //SEND TR
+               }
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+       }
+
+       //ToDo:  Text Attribute and frames
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.29 RECEIVE DATA
+static enum tcore_sat_result _sat_decode_receive_data(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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.receive_data.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.receive_data.command_detail.cmd_type = cmd_data[index++];
+
+       /** command detail **/
+       index++; //RFU
+
+       //device identities
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.receive_data.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //alpha identifier - optional
+       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.receive_data.alpha_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+               index+=data_len_consumed;
+       }
+
+       //icon id - optional
+       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.receive_data.icon_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS){
+                       return rv; //SEND TR
+               }
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+       }
+
+       //channel data length
+       rv =_sat_decode_channel_data_length_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.receive_data.channel_data_len, &data_len_consumed);
+       if(rv != TCORE_SAT_SUCCESS){
+               return rv; //SEND TR
+       }
+
+       //ToDo:  Text Attribute and frames
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.30 SEND DATA
+static enum tcore_sat_result _sat_decode_send_data(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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.send_data.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.send_data.command_detail.cmd_type = cmd_data[index++];
+
+       /** command detail **/
+       sat_cmd_ind_data->data.send_data.command_detail.cmd_qualifier.send_data.send_data_immediately = FALSE;
+       if(cmd_data[index]&0x01){
+               sat_cmd_ind_data->data.send_data.command_detail.cmd_qualifier.send_data.send_data_immediately = TRUE;
+               dbg("[SAT] SAT PARSER - Send data immediately");
+       }
+
+       //device identities
+       index++;
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.send_data.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       //alpha identifier - optional
+       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.send_data.alpha_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS) {
+                       return rv;
+               }
+               index+=data_len_consumed;
+       }
+
+       //icon id - optional
+       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.send_data.icon_id, &data_len_consumed);
+               if(rv != TCORE_SAT_SUCCESS){
+                       return rv; //SEND TR
+               }
+               index+=data_len_consumed; //index pointing to the Tag of next TLV
+       }
+
+       //channel data
+       rv =_sat_decode_channel_data_tlv(o_cmd_data, o_length, index, &sat_cmd_ind_data->data.send_data.channel_data, &data_len_consumed);
+       if(rv != TCORE_SAT_SUCCESS){
+               return rv; //SEND TR
+       }
+
+       //ToDo:  Text Attribute and frames
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+//6.4.31 GET CHANNEL STATUS
+static enum tcore_sat_result _sat_decode_get_channel_status(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 -  o_cmd_data == NULL");
+               return TCORE_SAT_ERROR_FATAL;
+       }
+
+       cmd_data = &o_cmd_data[0];
+       index = curr_offset+2;
+       sat_cmd_ind_data->data.get_channel_status.command_detail.cmd_num = cmd_data[index++];
+       sat_cmd_ind_data->data.get_channel_status.command_detail.cmd_type = cmd_data[index++];
+
+       /** command detail **/
+       index++; //RFU
+
+       //device identities
+       memcpy(dev_id,&cmd_data[index],4);
+       rv = _sat_decode_device_identities_tlv(dev_id, &sat_cmd_ind_data->data.get_channel_status.device_id);
+       if(rv != TCORE_SAT_SUCCESS)
+               return rv;
+
+       dbg("[SAT] SAT PARSER - :decoding done!.");
+       return TCORE_SAT_SUCCESS;
+}
+
+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;
+
+       //check comprehensive value
+       if((tlv_origin[index] | 0x7F) != 0x7F){
+               dbg("comprehensive value 0x%x", tlv_origin[index] | 0x7F);
+               b_comprehensive = TRUE;
+       }
+
+       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_DISPLAY_TEXT: //6.4.1
+                       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: //6.4.2
+                       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: //6.4.3
+                       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_MORE_TIME: //6.4.4
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_MORE_TIME");
+                       rv = _sat_decode_more_time(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_PLAY_TONE: //6.4.5
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_PLAY TONE");
+                       rv = _sat_decode_play_tone(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               //case POLL INTERVAL //6.4.6 processing by cp
+               case SAT_PROATV_CMD_REFRESH: //6.4.7
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_REFRESH");
+                       rv = _sat_decode_refresh(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_SETUP_MENU: //6.4.8
+                       dbg("[SAT] SAT PARSER - SAT_PROATV_CMD_SETUP_MENU");
+                       rv = _sat_decode_setup_menu(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_SELECT_ITEM: //6.4.9
+                       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_SEND_SMS: //6.4.10
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SEND_SMS");
+                       rv = _sat_decode_send_sms(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_SEND_SS: //6.4.11
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SEND_SS");
+                       rv = _sat_decode_send_ss(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_SEND_USSD: //6.4.12
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SEND_USSD");
+                       rv = _sat_decode_send_ussd(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_SETUP_CALL: //6.4.13
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SETUP_CALL");
+                       rv = _sat_decode_setup_call(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_PROVIDE_LOCAL_INFO: //6.4.15
+                       dbg("[SAT] SAT PARSER - SAT_PROATV_CMD_PROVIDE_LOCAL_INFO");
+                       rv = _sat_decode_provide_local_info(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_SETUP_EVENT_LIST: //6.4.16
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SETUP_EVENT_LIST");
+                       rv = _sat_decode_setup_event_list(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT: //6.4.22
+                       dbg("[SAT] SAT PARSER - SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT");
+                       rv = _sat_decode_setup_idle_mode_text(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_SEND_DTMF: //6.4.24
+                       dbg("[SAT] SAT PARSER - SAT_PROATV_CMD_SEND_DTMF");
+                       rv = _sat_decode_send_dtmf(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_LANGUAGE_NOTIFICATION: //6.4.25
+                       dbg("[SAT] SAT PARSER - SAT_PROATV_CMD_LANGUAGE_NOTIFICATION");
+                       rv = _sat_decode_language_notification(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_LAUNCH_BROWSER: //6.4.26
+                       dbg("[SAT] SAT PARSER - SAT_PROATV_CMD_LAUNCH_BROWSER");
+                       rv = _sat_decode_launch_browser(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_OPEN_CHANNEL://6.4.27
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_OPEN_CHANNEL");
+                       rv = _sat_decode_open_channel(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_CLOSE_CHANNEL://6.4.28
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_CLOSE_CHANNEL");
+                       rv = _sat_decode_close_channel(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_RECEIVE_DATA://6.4.29
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_RECEIVE_DATA");
+                       rv = _sat_decode_receive_data(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_SEND_DATA://6.4.30
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_SEND_DATA");
+                       rv = _sat_decode_send_data(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               case SAT_PROATV_CMD_GET_CHANNEL_STATUS://6.4.31
+                       dbg("[SAT] SAT PARSER - SAT_CMD_TYPE_GET_CHANNEL_STATUS");
+                       rv = _sat_decode_get_channel_status(tlv_origin, tlv_length, index, decoded_tlv);
+                       break;
+               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_FORMAT_SMS_DEFAULT:
+                       rv &= 0xF3;
+                       break;
+
+               case ALPHABET_FORMAT_8BIT_DATA:
+                       rv |= 0x04;
+                       break;
+
+               case ALPHABET_FORMAT_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++] = (b_comprehensive ? (SATK_COMMAND_DETAILS_TAG | 0x80) : SATK_COMMAND_DETAILS_TAG);
+       dst[current_index++] = SATK_COMMAND_DETAILS_LENGTH;
+       dst[current_index++] = src->cmd_num;
+       dst[current_index++] = src->cmd_type;
+       dst[current_index] = 0x00;
+
+       switch(src->cmd_type){
+               case SAT_PROATV_CMD_DISPLAY_TEXT:{
+                       //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:{
+                       //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:{
+                       //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_MORE_TIME:{
+                       dbg("more time : 1bit RFU")
+               }break;
+               case SAT_PROATV_CMD_PLAY_TONE:{
+                       //command detail vibration alert
+                       if(src->cmd_qualifier.play_tone.vibration_alert == VIBRATE_ALERT_REQUIRED)
+                               dst[current_index] += 0x01;
+               }break;
+               case SAT_PROATV_CMD_REFRESH:{
+                       //command detail refresh command
+                       dst[current_index] += src->cmd_qualifier.refresh.refresh;
+               }break;
+               case SAT_PROATV_CMD_SETUP_MENU:{
+                       //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;
+               case SAT_PROATV_CMD_SELECT_ITEM:{
+                       //command detail presentation
+                       if(src->cmd_qualifier.select_item.presentation_type != PRESENTATION_TYPE_NOT_SPECIFIED){
+                               dst[current_index] += 0x01;
+                               if(src->cmd_qualifier.select_item.presentation_type == PRESENTATION_TYPE_NAVIGATION_OPTION){
+                                       dst[current_index] += PRESENTATION_TYPE_NAVIGATION_OPTION;
+                               }
+                       }
+
+                       //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_SEND_SMS:{
+                       //command detail sms packing by me required
+                       if(src->cmd_qualifier.send_sms.packing_by_me_required)
+                               dst[current_index] += 0x01;
+               }break;
+               case SAT_PROATV_CMD_SETUP_CALL:{
+                       //command detail setup call command;
+                       dst[current_index] += src->cmd_qualifier.setup_call.setup_call;
+               }break;
+               case SAT_PROATV_CMD_SETUP_EVENT_LIST:{
+                       dbg("setup evnet list : 1bit RFU")
+               }break;
+               case SAT_PROATV_CMD_OPEN_CHANNEL:{
+                       if(src->cmd_qualifier.open_channel.immediate_link)
+                               dst[current_index] += 0x01;
+                       if(src->cmd_qualifier.open_channel.automatic_reconnection)
+                               dst[current_index] += 0x02;
+                       if(src->cmd_qualifier.open_channel.background_mode)
+                               dst[current_index] += 0x04;
+               }break;
+               case SAT_PROATV_CMD_SEND_DATA:{
+                       if(src->cmd_qualifier.send_data.send_data_immediately)
+                               dst[current_index] += 0x01;
+               }break;
+               case SAT_PROATV_CMD_PROVIDE_LOCAL_INFO:{
+                       dst[current_index] += src->cmd_qualifier.provide_local_info.provide_local_info;
+               }break;
+               case SAT_PROATV_CMD_LANGUAGE_NOTIFICATION:{
+                       if(src->cmd_qualifier.language_notification.specific_language)
+                               dst[current_index] += 0x01;
+               }break;
+               case SAT_PROATV_CMD_LAUNCH_BROWSER:{
+                               dst[current_index] += src->cmd_qualifier.launch_browser.launch_browser;
+               }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++] = (b_comprehensive ? (SATK_DEVICE_IDENTITY_TAG | 0x80) : 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 total_len = 0;
+       int length_index = 0;
+
+       //tag
+       dst[current_index++] =SATK_TEXT_STRING_TAG;
+
+       //length
+       if(src->string_length <= 0x7F){
+               dst[current_index++] =SATK_DCS_LENGTH+src->string_length;
+               length_index = 1;
+       }
+       else{
+               dst[current_index++] = 0x81;
+               dst[current_index++] =SATK_DCS_LENGTH+src->string_length;
+               length_index = 2;
+       }
+
+       //dcs
+       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){
+               memcpy(&(dst[current_index]), src->string, src->string_length);
+       }
+
+       //tag+index+dcs+data
+       total_len = 1+length_index+1+src->string_length;
+
+       return total_len;
+}
+
+static int _sat_encode_eventlist_tlv(const enum event_list src, char *dst, int current_index)
+{
+       dst[current_index++] =SATK_EVENT_LIST_TAG;
+       dst[current_index++] =0x01;
+       dst[current_index++] =src;
+
+       return 3;
+}
+
+static int _sat_encode_date_time_and_timezone_tlv(const struct tel_sat_date_time_and_timezone *src, char *dst, int current_index)
+{
+       dst[current_index++] = SATK_DATE_TIME_AND_TIME_ZONE_TAG;
+       dst[current_index++] = SATK_DATE_TIME_AND_TIME_ZONE_LENGTH;
+       dst[current_index++] = src->year;
+       dst[current_index++] = src->month;
+       dst[current_index++] = src->day;
+       dst[current_index++] = src->hour;
+       dst[current_index++] = src->minute;
+       dst[current_index++] = src->second;
+       dst[current_index++] = src->timeZone;
+
+       return 1+1+SATK_DATE_TIME_AND_TIME_ZONE_LENGTH; //tag length+len field length+value length;
+}
+
+static int _sat_encode_language_tlv(const enum tel_sim_language_type src, char *dst, int current_index)
+{
+       dst[current_index++] =SATK_LANGUAGE_TAG;
+       dst[current_index++] =SATK_LANGUAGE_LENGTH;
+
+       dbg("language (%d)", src);
+
+       switch(src){
+
+               case SIM_LANG_GERMAN :
+                       dst[current_index++] = 'd';
+                       dst[current_index++] = 'e';
+                       break;
+
+               case SIM_LANG_ENGLISH :
+                       dst[current_index++] = 'e';
+                       dst[current_index++] = 'n';
+                       break;
+
+               case SIM_LANG_ITALIAN :
+                       dst[current_index++] = 'i';
+                       dst[current_index++] = 't';
+                       break;
+
+               case SIM_LANG_FRENCH :
+                       dst[current_index++] = 'f';
+                       dst[current_index++] = 'r';
+                       break;
+
+               case SIM_LANG_SPANISH :
+                       dst[current_index++] = 'e';
+                       dst[current_index++] = 's';
+                       break;
+
+               case SIM_LANG_DUTCH :
+                       dst[current_index++] = 'n';
+                       dst[current_index++] = 'l';
+                       break;
+
+               case SIM_LANG_SWEDISH :
+                       dst[current_index++] = 's';
+                       dst[current_index++] = 'v';
+                       break;
+
+               case SIM_LANG_DANISH :
+                       dst[current_index++] = 'd';
+                       dst[current_index++] = 'a';
+                       break;
+
+               case SIM_LANG_PORTUGUESE :
+                       dst[current_index++] = 'p';
+                       dst[current_index++] = 't';
+                       break;
+
+               case SIM_LANG_FINNISH :
+                       dst[current_index++] = 'f';
+                       dst[current_index++] = 'i';
+                       break;
+
+               case SIM_LANG_NORWEGIAN :
+                       dst[current_index++] = 'n';
+                       dst[current_index++] = 'b';
+                       break;
+
+               case SIM_LANG_GREEK :
+                       dst[current_index++] = 'e';
+                       dst[current_index++] = 'l';
+                       break;
+
+               case SIM_LANG_TURKISH :
+                       dst[current_index++] = 't';
+                       dst[current_index++] = 'k';
+                       break;
+
+               case SIM_LANG_HUNGARIAN :
+                       dst[current_index++] = 'h';
+                       dst[current_index++] = 'u';
+                       break;
+
+               case SIM_LANG_POLISH :
+                       dst[current_index++] = 'p';
+                       dst[current_index++] = 'l';
+                       break;
+
+               default:{
+                       dst[current_index++] = 'e';
+                       dst[current_index++] = 'n';
+                       dbg("[SAT] SAT PARSER - Unknown Language: 0x%x",src);
+                       break;
+               }
+       }
+       return 4;
+}
+
+static int _sat_encode_browser_termination_tlv(const enum browser_termination_cause src, char *dst, int current_index)
+{
+       dst[current_index++] =SATK_BROWSER_TERMINATION_CAUSE_TAG;
+       dst[current_index++] =SATK_BROWSER_TERMINATION_CAUSE_LENGTH;
+       dst[current_index++] =src;
+
+       return 3;
+}
+
+static int _sat_encode_bearer_desc_tlv(const struct tel_sat_bearer_description* src, char *dst, int current_index)
+{
+       int total_len = 0;
+       int length_index = 0;
+
+       dst[current_index++] =SATK_BEARER_DISCRIPTION_TAG;
+
+       //length index
+       length_index = current_index++;
+
+       //bearer type
+       dst[current_index++] = src->bearer_type;
+
+       switch(src->bearer_type){
+               case BEARER_CSD:{
+                       dst[current_index++] = src->bearer_parameter.cs_bearer_param.data_rate;
+                       dst[current_index++] = src->bearer_parameter.cs_bearer_param.service_type;
+                       dst[current_index++] = src->bearer_parameter.cs_bearer_param.connection_element_type;
+               }break;
+               case BEARER_GPRS:{
+                       dst[current_index++] = src->bearer_parameter.ps_bearer_param.precedence_class;
+                       dst[current_index++] = src->bearer_parameter.ps_bearer_param.delay_class;
+                       dst[current_index++] = src->bearer_parameter.ps_bearer_param.reliability_class;
+                       dst[current_index++] = src->bearer_parameter.ps_bearer_param.peak_throughput_class;
+                       dst[current_index++] = src->bearer_parameter.ps_bearer_param.mean_throughput_class;
+                       dst[current_index++] = src->bearer_parameter.ps_bearer_param.pdp_type;
+               }break;
+               case BEARER_DEFAULT_BEARER_FROM_TRANSPORT_LAYER:
+               case BEARER_LOCAL_LINK_TECHNOLOGY_INDEPENDENT:
+               default:
+               break;
+       }
+
+       dst[length_index] = (current_index-1) - length_index;
+       total_len = (current_index-1) - length_index + 2; //tag and length
+
+       return total_len;
+}
+
+static int _sat_encode_buffer_size_tlv(const struct tel_sat_buffer_size* src, char *dst, int current_index)
+{
+       dst[current_index++] = SATK_BUFFER_SIZE_TAG;
+       dst[current_index++] = SATK_BUFFER_SIZE_LENGTH;
+       dst[current_index++] = src->size[0];
+       dst[current_index++] = src->size[1];
+
+       return 4;
+}
+
+static int _sat_encode_channel_data_tlv(const struct tel_sat_channel_data* src, char *dst, int current_index)
+{
+       int total_len = 0;
+       int length_index = 0;
+
+       dst[current_index++] = SATK_CHANNEL_DATA_TAG;
+
+       if(src->data_string_len <= 0x7F){
+               dst[current_index++] = src->data_string_len;
+               length_index = 1;
+       }
+       else{
+               dst[current_index++] = 0x81;
+               dst[current_index++] = src->data_string_len;
+               length_index = 2;
+       }
+
+       memcpy(&(dst[current_index]), src->data_string, src->data_string_len);
+
+       total_len = 1+length_index+src->data_string_len;
+
+       return total_len;
+}
+
+static int _sat_encode_channel_data_length_tlv(const struct tel_sat_channel_data_len* src, char *dst, int current_index)
+{
+       dst[current_index++] = SATK_CHANNEL_DATA_LEN_TAG;
+       dst[current_index++] = SATK_CHANNEL_DATA_LENGTH_VALUE_LENGTH;
+       dst[current_index++] = src->data_len;
+
+       return 3;
+}
+
+static int _sat_encode_channel_status_tlv(const struct tel_sat_channel_status* src, char *dst, int current_index)
+{
+       dst[current_index++] = SATK_CHANNEL_STATUS_TAG;
+       dst[current_index++] = SATK_CHANNEL_STATUS_LENGTH;
+
+       if(src->status == link_or_packet_service_activated) //(bit 8)
+               dst[current_index] += 0x80;
+
+       dst[current_index++] += src->channel_id; //(bit 1~3)
+       dst[current_index++] = src->status_info;
+
+       return 4;
+}
+
+static int _sat_encode_download_event(const struct tel_sat_envelop_event_download_tlv *evt_dl, char *dst_envelop)
+{
+       int index = 2;
+       int encoded_len = 0;
+
+       dbg("event type(%d)", evt_dl->event);
+
+       //event list
+       encoded_len = _sat_encode_eventlist_tlv(evt_dl->event, dst_envelop, index);
+       index += encoded_len;
+
+       //device id - len 4
+       encoded_len =_sat_encode_device_identities_tlv(&(evt_dl->device_identitie), dst_envelop, index);
+       index += encoded_len;
+
+       switch(evt_dl->event){
+               case EVENT_LANGUAGE_SELECTION:
+                       encoded_len = _sat_encode_language_tlv(evt_dl->language, dst_envelop, index);
+                       index += encoded_len;
+                       break;
+               case EVENT_BROWSER_TERMINATION:
+                       encoded_len = _sat_encode_browser_termination_tlv(evt_dl->browser_termination, dst_envelop, index);
+                       index += encoded_len;
+                       break;
+               case EVENT_DATA_AVAILABLE:
+                       encoded_len = _sat_encode_channel_status_tlv(&(evt_dl->channel_status), dst_envelop, index);
+                       index += encoded_len;
+
+                       encoded_len = _sat_encode_channel_data_length_tlv(&(evt_dl->channel_data_len), dst_envelop, index);
+                       index += encoded_len;
+                       break;
+               case EVENT_CHANNEL_STATUS:
+                       encoded_len = _sat_encode_channel_status_tlv(&(evt_dl->channel_status), dst_envelop, index);
+                       index += encoded_len;
+                       break;
+               default:
+                       break;
+       }
+
+       dst_envelop[0] = SATK_EVENT_DOWNLOAD_TAG;
+       dst_envelop[1] = index-2;
+
+       dbg("download envelop cmd len(%d)", index);
+
+       if(index-2 > 0x7F){
+               int idx = 0;
+               for(idx = index; idx > 0; idx--){
+                       dst_envelop[idx] = dst_envelop[idx+1];
+               }
+               dst_envelop[1] = 0x81;
+               index += 1;
+               dbg("download envelop added cmd len(%d)", index);
+       }
+
+       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;
+       }
+       else if(src_envelop->sub_cmd == ENVELOP_EVENT_DOWNLOAD){
+               index = _sat_encode_download_event(&(src_envelop->envelop_data.event_download),dst_envelop);
+       }
+
+       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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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);
+                       index = 0;
+                       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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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:
+               case RESULT_NO_RESPONSE_FROM_USER:
+                       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);
+                       index = 0;
+                       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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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);
+                       index =0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_more_time(const struct tel_sat_tr_more_time_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_play_tone(const struct tel_sat_tr_play_tone_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_SUCCESS_BUT_TONE_NOT_PLAYED:
+               case RESULT_PROACTIVE_SESSION_TERMINATED_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);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_refresh(const struct tel_sat_tr_refresh_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_REFRESH_PERFORMED_WITH_ADDITIONAL_EFS_READ:
+               case RESULT_REFRESH_PRFRMD_BUT_INDICATED_USIM_NOT_ACTIVE:
+               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);
+                       index = 0;
+                       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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_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);
+                       index = 0;
+                       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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_HELP_INFO_REQUIRED_BY_USER:
+                       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_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);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_send_sms(const struct tel_sat_tr_send_sms_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+               case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND:
+               case RESULT_BEYOND_ME_CAPABILITIES:
+               case RESULT_COMMAND_TYPE_NOT_UNDERSTOOD_BY_ME:
+               case RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME:
+               case RESULT_SMS_RP_ERROR:
+               case RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM:
+                       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);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_send_ss(const struct tel_sat_tr_send_ss_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_SUCCESS_BUT_MODIFIED_BY_CALL_CONTROL_BY_SIM:
+               case RESULT_USSD_OR_SS_TRANSACTION_TERMINATED_BY_USER:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+
+                       memcpy(&(dst_tr[index]), src_tr->text.string, src_tr->text.string_length);
+                       encoded_len = src_tr->text.string_length;
+                       index += encoded_len;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+               case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->me_problem_type;
+                       break;
+               case RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->cc_problem_type;
+                       break;
+               case RESULT_SS_RETURN_ERROR:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->ss_problem;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_send_ussd(const struct tel_sat_tr_send_ussd_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_SUCCESS_BUT_MODIFIED_BY_CALL_CONTROL_BY_SIM:
+               case RESULT_USSD_OR_SS_TRANSACTION_TERMINATED_BY_USER:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+
+                       encoded_len = _sat_encode_text_tlv(&(src_tr->text), dst_tr, index, TRUE);
+                       index += encoded_len;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+               case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->me_problem_type;
+                       break;
+               case RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->cc_problem_type;
+                       break;
+               case RESULT_USSD_RETURN_ERROR:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->ussd_problem;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_setup_call(const struct tel_sat_tr_setup_call_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_SUCCESS_BUT_MODIFIED_BY_CALL_CONTROL_BY_SIM:
+               case RESULT_PROACTIVE_SESSION_TERMINATED_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:
+               case RESULT_SS_RETURN_ERROR:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+               case RESULT_USER_DID_NOT_ACCEPT_CALL_SETUP_REQ:
+               case RESULT_USER_CLEAR_DOWN_CALL_BEFORE_CONN:
+               case RESULT_FRAMES_ERROR:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->me_problem_type;
+                       break;
+               case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->network_problem_type;
+                       break;
+               case RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->cc_problem_type;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_provide_local_info(const struct tel_sat_tr_provide_local_info_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_LIMITED_SERVICE:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+                       switch(src_tr->command_detail.cmd_qualifier.provide_local_info.provide_local_info){
+                               case LOCAL_INFO_DATE_TIME_AND_TIMEZONE:
+                                       encoded_len = _sat_encode_date_time_and_timezone_tlv(&(src_tr->other.date_time_and_timezone), dst_tr, index);
+                                       break;
+                               case LOCAL_INFO_LANGUAGE:
+                                       encoded_len = _sat_encode_language_tlv(src_tr->other.language, dst_tr, index);
+                                       break;
+                               default:
+                                       dbg("local info type[%d] is not handled", src_tr->command_detail.cmd_qualifier.provide_local_info.provide_local_info);
+                                       break;
+                       }
+                       index += encoded_len;
+                       break;
+               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);
+                       index = 0;
+                       break;
+       }
+
+       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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_setup_idle_mode_text(const struct tel_sat_tr_setup_idle_mode_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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:
+               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);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_send_dtmf(const struct tel_sat_tr_send_dtmf_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_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);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_language_notification(const struct tel_sat_tr_language_notification_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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:
+               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);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_launch_browser(const struct tel_sat_tr_launch_browser_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+               case RESULT_NETWORK_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;
+               case RESULT_LAUNCH_BROWSER_GENERIC_ERROR_CODE:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->browser_problem_type;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_open_channel(const struct tel_sat_tr_open_channel_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_SUCCESS_WITH_MODIFICATION:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+
+                       //set channel status
+                       encoded_len = _sat_encode_channel_status_tlv(&(src_tr->channel_status), dst_tr, index);
+                       index += encoded_len;
+                       break;
+               case RESULT_REFRESH_PRFRMD_BUT_INDICATED_USIM_NOT_ACTIVE:
+               case RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER:
+               case RESULT_INTERACTION_WITH_CC_BY_SIM_IN_TMP_PRBLM:
+               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:
+               case RESULT_USER_DID_NOT_ACCEPT_CALL_SETUP_REQ:
+                       dst_tr[index++] = 1;
+                       dst_tr[index++] = src_tr->result_type;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+               case RESULT_NETWORK_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;
+               case RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->bip_problem_type;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       return 0;
+                       break;
+       }
+
+       //set buffer desc
+       encoded_len = _sat_encode_bearer_desc_tlv(&(src_tr->bearer_desc), dst_tr, index);
+       index += encoded_len;
+
+       //set buffer size
+       encoded_len = _sat_encode_buffer_size_tlv(&(src_tr->buffer_size), dst_tr, index);
+       index += encoded_len;
+
+       return index;
+}
+
+static int _sat_encode_close_channel(const struct tel_sat_tr_close_channel_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_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;
+               case RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->bip_problem_type;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_send_data(const struct tel_sat_tr_send_data_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_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;
+                       encoded_len = _sat_encode_channel_data_length_tlv(&(src_tr->channel_data_len), dst_tr, index);
+                       index += encoded_len;
+                       break;
+               case RESULT_ME_UNABLE_TO_PROCESS_COMMAND:
+               case RESULT_NETWORK_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;
+
+               case RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->bip_problem_type;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_receive_data(const struct tel_sat_tr_receive_data_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_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;
+                       encoded_len = _sat_encode_channel_data_tlv(&(src_tr->channel_data), dst_tr, index);
+                       index += encoded_len;
+                       encoded_len = _sat_encode_channel_data_length_tlv(&(src_tr->channel_data_len), 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;
+
+               case RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->bip_problem_type;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       index = 0;
+                       break;
+       }
+
+       return index;
+}
+
+static int _sat_encode_get_channel_status(const struct tel_sat_tr_get_channel_status_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++] = (b_comprehensive ? (SATK_RESULT_TAG | 0x80) : 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_channel_status_tlv(&(src_tr->channel_status), dst_tr, index);
+                       index += encoded_len;
+                       break;
+               case RESULT_PROACTIVE_SESSION_TERMINATED_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_NETWORK_UNABLE_TO_PROCESS_COMMAND:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->me_problem_type;
+                       break;
+               case RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR:
+                       dst_tr[index++] = 2;
+                       dst_tr[index++] = src_tr->result_type;
+                       dst_tr[index++] = src_tr->bip_problem_type;
+                       break;
+               default:
+                       dbg("invalid response value[0x%x] in current TR",src_tr->result_type);
+                       index = 0;
+                       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_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_MORE_TIME:{
+                       tr_len = _sat_encode_more_time(&(src_tr->terminal_rsp_data.more_time), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_PLAY_TONE:{
+                       tr_len = _sat_encode_play_tone(&(src_tr->terminal_rsp_data.play_tone), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_REFRESH:{
+                       tr_len = _sat_encode_refresh(&(src_tr->terminal_rsp_data.refresh), 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;
+               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_SEND_SMS:{
+                       tr_len = _sat_encode_send_sms(&(src_tr->terminal_rsp_data.send_sms), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_SEND_SS:{
+                       tr_len = _sat_encode_send_ss(&(src_tr->terminal_rsp_data.send_ss), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_SEND_USSD:{
+                       tr_len = _sat_encode_send_ussd(&(src_tr->terminal_rsp_data.send_ussd), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_SETUP_CALL:{
+                       tr_len = _sat_encode_setup_call(&(src_tr->terminal_rsp_data.setup_call), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_PROVIDE_LOCAL_INFO:{
+                       tr_len = _sat_encode_provide_local_info(&(src_tr->terminal_rsp_data.provide_local_info), dst_tr);
+               }break;
+               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_SETUP_IDLE_MODE_TEXT:{
+                       tr_len = _sat_encode_setup_idle_mode_text(&(src_tr->terminal_rsp_data.setup_idle_mode_text), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_SEND_DTMF:{
+                       tr_len = _sat_encode_send_dtmf(&(src_tr->terminal_rsp_data.send_dtmf), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_LANGUAGE_NOTIFICATION:{
+                       tr_len = _sat_encode_language_notification(&(src_tr->terminal_rsp_data.language_notification), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_LAUNCH_BROWSER:{
+                       tr_len = _sat_encode_launch_browser(&(src_tr->terminal_rsp_data.launch_browser), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_OPEN_CHANNEL:{
+                       tr_len = _sat_encode_open_channel(&(src_tr->terminal_rsp_data.open_channel), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_CLOSE_CHANNEL:{
+                       tr_len = _sat_encode_close_channel(&(src_tr->terminal_rsp_data.close_channel), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_SEND_DATA:{
+                       tr_len = _sat_encode_send_data(&(src_tr->terminal_rsp_data.send_data), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_RECEIVE_DATA:{
+                       tr_len = _sat_encode_receive_data(&(src_tr->terminal_rsp_data.receive_data), dst_tr);
+               }break;
+               case SAT_PROATV_CMD_GET_CHANNEL_STATUS:{
+                       tr_len = _sat_encode_get_channel_status(&(src_tr->terminal_rsp_data.get_channel_status), 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, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name, hal);
+       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_clone_hook(o, _clone_hook);
+       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..4c9d465
--- /dev/null
@@ -0,0 +1,2524 @@
+/*
+ * 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*/
+       struct tel_sim_service_table svct; /**< (U)SIM Service Table information*/
+       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_GET_LOCK_INFO:
+                       if (!po->ops->get_lock_info)
+                               return TCORE_RETURN_ENOSYS;
+
+                       return po->ops->get_lock_info(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:
+               case TREQ_SIM_SET_MESSAGEWAITING:
+               case TREQ_SIM_SET_MAILBOX:
+                       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_NETNAME:
+               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 _clone_hook(CoreObject *src, CoreObject *dest)
+{
+       struct private_object_data *src_po = NULL;
+       struct private_object_data *dest_po = NULL;
+
+       if (!src || !dest)
+               return;
+
+       dest_po = calloc(sizeof(struct private_object_data), 1);
+       if (!dest_po) {
+               tcore_object_link_object(dest, NULL);
+               return;
+       }
+
+       src_po = tcore_object_ref_object(src);
+       dest_po->ops = src_po->ops;
+
+       tcore_object_link_object(dest, dest_po);
+}
+
+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;
+       }
+       dbg("current index has empty data");
+       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)
+ */
+char* tcore_sim_encode_lp( int *out_length, struct tel_sim_language *p_in)
+{
+    int i = 0;
+    char *tmp_out = NULL;
+
+    if ( out_length == NULL || p_in == NULL ){
+        dbg("out_length or p_in is null");
+        return NULL;
+    }
+
+    tmp_out = (char*)malloc(p_in->language_count);
+    memset((void*) tmp_out, 0xff, p_in->language_count);
+
+    for (i = 0; i < p_in->language_count; i++)
+        tmp_out[i] = p_in->language[i];
+
+    *out_length = i;
+    return tmp_out;
+}
+
+/**
+ * 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)
+ */
+char* tcore_sim_encode_li( int *out_length, struct tel_sim_language *p_in)
+{
+       int i = 0;
+    char *tmp_out = NULL;
+       char *LanguageCode[] = { "de", "en", "it", "fr", "es", "nl", "sv", "da", "pt", "fi", "no", "el",
+                                                                                                       "tr", "hu", "pl", "ko", "zh", "ru", "ja" };
+
+    if ( out_length == NULL || p_in == NULL ){
+        dbg("out_length or p_in is null");
+        return NULL;
+    }
+
+    tmp_out = (char*)malloc((p_in->language_count) *2);
+    memset((void*) tmp_out, 0xff, (p_in->language_count)*2);
+
+       for (i = 0; i < p_in->language_count; i++) {
+               if (p_in->language[i] < SIM_LANG_UNSPECIFIED) {
+                       strncpy((char *) &tmp_out[i * 2], LanguageCode[p_in->language[i]], 2);
+                       dbg( "sim_encode_li: p_out[%s]:[%x][%x]", tmp_out, tmp_out[i*2], tmp_out[(i*2)+1]);
+               }
+       }
+       *out_length = i*2;
+       return tmp_out;
+}
+
+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 51.011 SST shows 56 kinds of service types. current tel_sim_sst has also 56 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 = 0;      // alpha id max length
+       int alpha_id_length = 0;
+       int value_length = 0;
+       int bcd_byte = 0;       // 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) {
+               memset(p_msisdn, 0, sizeof(struct tel_sim_msisdn));
+               return FALSE;
+       }
+
+       X = in_length - 14;     // get alpha id max length
+
+       if (X != 0) {
+               alpha_id_length = X;
+               dbg("alpha_id_length[%d]", alpha_id_length);
+               if(alpha_id_length > SIM_XDN_ALPHA_ID_LEN_MAX)
+                       alpha_id_length = SIM_XDN_ALPHA_ID_LEN_MAX;
+
+               value_length =  _get_string((unsigned char *)p_msisdn->name, p_in, alpha_id_length);
+               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 FALSE;   // this is empty record
+       }
+
+       X = in_length - 14;     // get alpha id max length
+
+       if (X != 0) {
+               _get_string((unsigned char *)p_xdn->alpha_id, p_in, X);
+               p_xdn->alpha_id_max_len = 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) {
+               dbg( "Dialing number Length %d, BCD length 0x%x ",      (p_in[X] - 1) * 2, p_in[X]);
+
+/*             if (p_xdn->num_max_len > 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->num_max_len = 0;
+                       else
+                               p_xdn->num_max_len = SIM_XDN_NUMBER_LEN_MAX;
+               }*/
+
+               // get TON and NPI
+               p_xdn->ton = (p_in[X + 1] >> 4) & 0x07;
+               p_xdn->npi = 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
+               _bcd_to_digit((char*) p_xdn->num, (char*) &p_in[X + 2], bcd_byte); // actual dialing number length in BCD.
+               dbg( "p_xdn->DiallingNum[%s]", p_xdn->num);
+               // get Capability/Configuration id
+               p_xdn->cc_id = p_in[X + 12];
+               // get Extension1 id
+               p_xdn->ext1_id = p_in[X + 13];
+       }
+       return TRUE;
+}
+
+char* tcore_sim_encode_xdn(int out_length, struct tel_sim_dialing_number *p_xdn)
+{
+       int alpha_id_space =0, digit_len =0, str_len = 0;
+       char bcdCode[SIM_XDN_NUMBER_LEN_MAX / 2];
+       char * p_out = NULL;
+       p_out = calloc(out_length,1);
+       memset((void*) p_out, 0xFF, out_length);
+
+       // get alpha id max length
+       alpha_id_space = out_length - 14;
+
+       // alpha id is too big
+       str_len = strlen(p_xdn->alpha_id);
+       if (alpha_id_space < str_len) {
+               dbg("SIM space for alpha_id is [%d] but input alpha_id length is [%d]. so we will use [%d] byte",
+                               alpha_id_space, str_len, alpha_id_space);
+               str_len = alpha_id_space;
+       }
+
+       digit_len = strlen(p_xdn->num);
+       // this is digit length
+       if ( digit_len > SIM_XDN_NUMBER_LEN_MAX) {
+               dbg("SIM space for number is [%d] but input number length is [%d]. so we will use [%d] byte",
+                               SIM_XDN_NUMBER_LEN_MAX, digit_len, SIM_XDN_NUMBER_LEN_MAX);
+               digit_len = SIM_XDN_NUMBER_LEN_MAX;
+       }
+
+       _set_string((unsigned char *)p_out, (unsigned char *)p_xdn->alpha_id, str_len);
+
+       // 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[alpha_id_space] = ( (digit_len + 1) / 2 ) + 1;
+
+       // set TON and NPI
+       p_out[alpha_id_space + 1] = 0x80;
+       p_out[alpha_id_space + 1] |= (p_xdn->ton & 0x07) << 4;
+       p_out[alpha_id_space + 1] |= p_xdn->npi & 0x0F;
+
+       // set dialing number/SSC string
+       memset((void*) bcdCode, 0xFF, SIM_XDN_NUMBER_LEN_MAX / 2);
+
+       _digit_to_bcd((char*) bcdCode, (char*) p_xdn->num, digit_len);
+
+       memcpy((void*) &p_out[alpha_id_space + 2], bcdCode, SIM_XDN_NUMBER_LEN_MAX / 2);
+
+       // set Capability/Configuration Identifier
+       p_out[alpha_id_space + 12] = (unsigned char) p_xdn->cc_id;
+       // set extension1 record Identifier
+       p_out[alpha_id_space + 13] = (unsigned char) p_xdn->ext1_id;
+
+       return p_out;
+}
+
+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 FALSE;
+       }
+
+       //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)
+{
+       /* 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 FALSE; // this is empty record
+       }
+
+       p_mbi->voice_index = p_in[0];
+       p_mbi->fax_index = p_in[1];
+       p_mbi->email_index = p_in[2];
+       p_mbi->other_index = p_in[3];
+
+       // 5th byte is optional
+       if (in_length == 5)
+               p_mbi->video_index = 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->voice_index;
+       p_out[1] = p_mbi->fax_index;
+       p_out[2] = p_mbi->email_index;
+       p_out[3] = p_mbi->other_index;
+
+       if (out_length == 5)
+               p_out[4] = p_mbi->video_index;
+
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_cff(struct tel_sim_cphs_cf *p_cff, unsigned char *p_in, int in_length)
+{
+       if (in_length == 0)
+               return FALSE;
+
+       dbg( "flag(0)=%x, packetlen=%d ", (unsigned int)p_in[0], in_length);
+       dbg( "flag(1)=%x", p_in[1]);
+
+       if ((p_in[0] & 0x0F) == 0x0A) {
+               p_cff->b_line1 = TRUE;
+       }
+       if ((p_in[0] & 0xF0) == 0xA0) {
+               p_cff->b_line2 = TRUE;
+       }
+
+       if (in_length > 1) {
+               if ((p_in[1] & 0x0F) == 0x0A) {
+                       p_cff->b_fax = TRUE;
+               }
+               if ((p_in[1] & 0xF0) == 0xA0) {
+                       p_cff->b_data = TRUE;
+               }
+       }
+
+       dbg("Line1 = %d, line2 = %d, Fax = %d, Data = %d ",
+                       p_cff->b_line1,
+                       p_cff->b_line2,
+                       p_cff->b_fax,
+                       p_cff->b_data);
+       return TRUE;
+}
+
+char* tcore_sim_encode_cff(const struct tel_sim_cphs_cf *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; j < SIM_CPHS_CSP_ENTRY_CNT_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; j < SIM_CPHS_CSP_ENTRY_CNT_MAX; 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_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->indicator_status = pMwis->indicator_status | SIM_MWIS_VOICE;
+                                       break;
+                               case 0x02:
+                                       pMwis->indicator_status = pMwis->indicator_status | SIM_MWIS_FAX;
+                                       break;
+                               case 0x04:
+                                       pMwis->indicator_status = pMwis->indicator_status | SIM_MWIS_EMAIL;
+                                       break;
+                               case 0x08:
+                                       pMwis->indicator_status = pMwis->indicator_status | SIM_MWIS_OTHER;
+                                       break;
+                               case 0x10:
+                                       pMwis->indicator_status = pMwis->indicator_status | SIM_MWIS_VIDEO;
+                                       break;
+                               default:
+                                       pMwis->indicator_status = pMwis->indicator_status | 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;
+}
+
+char* tcore_sim_encode_mwis( int *out_length, const struct tel_sim_mw *pMwis)
+{
+       char *p_out = NULL;
+
+       if (out_length == 0)
+               return FALSE;
+
+       p_out = calloc(6,1);
+
+       p_out[0] = (unsigned char) pMwis->indicator_status;
+       p_out[1] = pMwis->voice_count;
+       p_out[2] = pMwis->fax_count;
+       p_out[3] = pMwis->email_count;
+       p_out[4] = pMwis->other_count;
+       p_out[5] = pMwis->video_count;
+
+       *out_length = 6;
+       return p_out;
+}
+
+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){
+               dbg("fail - input length is zero");
+               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;
+}
+
+char* tcore_sim_encode_vmwf(int *out_length, const struct tel_sim_cphs_mw *p_vmwf)
+{
+       int i, j = 0;
+       char *p_out = NULL;
+       unsigned char* pTemp = (unsigned char*) p_vmwf;
+       unsigned char present = 0x0A;
+       unsigned char absent = 0x05;
+
+       if (out_length == 0)
+               return NULL;
+
+       p_out = calloc(2,1);
+
+       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;
+               }
+       }
+       *out_length = 2;
+       return p_out;
+}
+
+gboolean tcore_sim_decode_ons(unsigned char* p_out,unsigned  char* p_in, int in_length)
+{
+       int length;
+       memset((void*) p_out, 0, SIM_CPHS_OPERATOR_NAME_LEN_MAX+1);
+
+       if (in_length == 0)
+               return FALSE;
+
+       if (_is_empty(p_in, in_length) == TRUE) {
+               return FALSE;
+       }
+
+       /* 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_out, p_in, in_length);
+       p_out[length] = '\0';
+       dbg( "Operator Name is (%s) & Length (%d) ",    p_out, length);
+
+       return TRUE;
+}
+
+gboolean tcore_sim_decode_cfis(struct tel_sim_cfis *p_cfis, unsigned char *p_in, int in_length)
+{
+       int bcd_byte;   // dialing number max length
+       int digit_len;
+       int i = 0;
+       if (in_length == 0)
+               return FALSE;
+
+       if (_is_empty(p_in, in_length) == TRUE) {
+               dbg("empty record. all data is set 0xff");
+               return TRUE;    // this is empty record
+       }
+
+       p_cfis->msp_num = p_in[i++];
+       p_cfis->cfu_status = p_in[i++];
+
+       // get TON and NPI
+       p_cfis->ton = (p_in[++i] >> 4) & 0x07;
+       p_cfis->npi = 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
+       digit_len = _bcd_to_digit((char*) p_cfis->cfu_num, (char*) &p_in[i], bcd_byte); // actual dialing number length in BCD.
+       dbg( "Dialing number Length[%d]", digit_len);
+
+       i = i + SIM_XDN_NUMBER_LEN_MAX / 2;
+
+       // get Capability/Configuration id
+       p_cfis->cc2_id = p_in[i++];
+
+       // get Extension1 id
+       p_cfis->ext7_id = p_in[i];
+
+       dbg( "MspNumber 0x%x", p_cfis->msp_num);
+       dbg( "Status 0x%x", p_cfis->cfu_status);
+       dbg( "TypeOfNumber %d", p_cfis->ton);
+       dbg( "NumberingPlanIdent %d", p_cfis->npi);
+       dbg( "Dialing number[%s]", p_cfis->cfu_num);
+
+       return TRUE;
+}
+
+char* tcore_sim_encode_cfis(int *out_length, const struct tel_sim_cfis *p_cfis)
+{
+       char *encoded_o = NULL;
+       char bcd[10];
+
+       encoded_o = calloc(16, 1); // EF-CFIS record length is 16
+       memset(bcd, 0xff, 10);
+
+       /*
+        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. unused byte should be set with 'F'
+        15             Capability/Configuration2 Record Identifier     M               1 byte
+        16             Extension 7 Record Identifier                           M               1 byte
+        */
+       encoded_o[0] = p_cfis->msp_num;
+       encoded_o[1] = p_cfis->cfu_status;
+
+       encoded_o[2] = (strlen(p_cfis->cfu_num) +1) /2;
+
+       // set TON and NPI
+       encoded_o[3] = 0x80;
+       encoded_o[3] |= (p_cfis->ton & 0x07) << 4;
+       encoded_o[3] |= p_cfis->npi & 0x0F;
+
+       _digit_to_bcd(bcd, (char*)&p_cfis->cfu_num, strlen(p_cfis->cfu_num));
+       memcpy(&encoded_o[4], bcd, 10);
+
+       encoded_o[14] = p_cfis->cc2_id;
+       encoded_o[15] = p_cfis->ext7_id;
+
+       *out_length = 16;
+       return encoded_o;
+}
+
+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(unsigned char *p_out, unsigned char *p_in, int in_length)
+{
+       int length;
+
+       memset(p_out, 0x00, SIM_CPHS_OPERATOR_NAME_SHORT_FORM_LEN_MAX+1);
+
+       if (_is_empty(p_in, in_length) == TRUE){
+               return FALSE;   // 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_out, p_in, in_length );
+       p_out[length] = '\0';
+       dbg( "Operator short Name is (%s) &  length (%d)", p_out, 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 FALSE;   // 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 FALSE;   // 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_len = 0, s_name_len = 0;
+       int cvt_leng = 0, s_name_base = 0;
+
+       if (_is_empty(p_in, in_length) == TRUE) {
+               memset(p_pnn, 0x00, sizeof(struct tel_sim_pnn));
+               return FALSE;   // 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");
+               //f_name_part includes information byte.
+               f_name_len =  (int)p_in[1] - 1;
+
+               /* 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] & 0x70) >> 4 == 0) {
+                       dbg( "DCS:GSM7");
+                       // In case of GSM7, 35byte packing data will be converted 40 bytes unpacking string.
+                       if (f_name_len > (SIM_NW_FULL_NAME_LEN_MAX * 7) / 8)
+                               f_name_len = (SIM_NW_FULL_NAME_LEN_MAX * 7) / 8;
+
+                       _unpack_7bit28bit(p_in + 3, f_name_len, (unsigned char *) (p_pnn->full_name));
+               } else if ((p_in[2] & 0x70) >> 4 == 1) {
+                       dbg( "DCS:UCS2");
+                       /* current telephony supports 40 bytes network name string */
+                       if (f_name_len > SIM_NW_FULL_NAME_LEN_MAX)
+                               f_name_len = SIM_NW_FULL_NAME_LEN_MAX;
+
+                       _ucs2_to_utf8(f_name_len, 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);
+
+               s_name_base = (int)p_in[1] +2;
+               dbg( " short name base byte [0x%02x]", s_name_base);
+
+               /*Short Name for network IEI(Information Element Identifier), 0x45*/
+               if (p_in[s_name_base] == 0x45) {
+                       dbg( " Short name of network IEI exist");
+                       //s_name_part includes information byte.
+                       s_name_len = p_in[s_name_base +1] -1;
+
+                       if ((p_in[s_name_base + 2] & 0x70) >> 4 == 0) {
+                               dbg( "DCS:GSM7");
+                               // In case of GSM7, 35byte packing data will be converted 40 bytes unpacking string.
+                               if (s_name_len > (SIM_NW_FULL_NAME_LEN_MAX * 7) / 8)
+                                       s_name_len = (SIM_NW_FULL_NAME_LEN_MAX * 7) / 8;
+
+                               _unpack_7bit28bit(p_in + s_name_base + 3, s_name_len, (unsigned char *) (p_pnn->short_name));
+                       } else if ((p_in[s_name_base +2] & 0x70) >> 4 == 1) {
+                               dbg( "DCS:UCS2");
+                               if (s_name_len > SIM_NW_FULL_NAME_LEN_MAX)
+                                       s_name_len = SIM_NW_FULL_NAME_LEN_MAX;
+
+                               _ucs2_to_utf8(s_name_len, p_in + s_name_base+ 3, (int*) &cvt_leng, (unsigned char *) (p_pnn->short_name));
+                       } else {
+                               dbg( "DCS:unknown");
+                               return FALSE;
+                       }
+                       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;
+}
+
+struct tel_sim_service_table* tcore_sim_get_service_table(CoreObject *o)
+{
+       struct tel_sim_service_table *tmp_svct;
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return NULL;
+       }
+       tmp_svct =  calloc(sizeof(struct tel_sim_service_table), 1);
+       memcpy(tmp_svct, &po->svct, sizeof(struct tel_sim_service_table));
+       return tmp_svct;
+}
+
+gboolean tcore_sim_set_service_table(CoreObject *o, struct tel_sim_service_table *svct)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return FALSE;
+       }
+       memcpy(&po->svct, svct, sizeof(struct tel_sim_service_table));
+       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;
+       memset(po, 0x00, sizeof(struct private_object_data));
+       po->ops = tmp_ops;
+       po->sim_status = SIM_STATUS_UNKNOWN;
+}
+
+CoreObject *tcore_sim_new(TcorePlugin *p, const char *name,
+               struct tcore_sim_operations *ops, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name, hal);
+       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_clone_hook(o, _clone_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..2fd96dc
--- /dev/null
@@ -0,0 +1,445 @@
+/*
+ * 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;
+       gboolean b_readyStatus;
+};
+
+/**
+ * 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;
+
+}
+
+static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
+{
+       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);
+
+       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;
+       }
+
+       if(po->b_readyStatus == FALSE) {
+               dbg("[tcore_SMS] DEVICE_NOT_READY");
+               return TCORE_RETURN_ENOSYS; /* TAPI_API_NETTEXT_DEVICE_NOT_READY */
+       }
+
+       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);
+       }
+}
+
+static void _clone_hook(CoreObject *src, CoreObject *dest)
+{
+       struct private_object_data *src_po = NULL;
+       struct private_object_data *dest_po = NULL;
+
+       if (!src || !dest)
+               return;
+
+       dest_po = calloc(sizeof(struct private_object_data), 1);
+       if (!dest_po) {
+               tcore_object_link_object(dest, NULL);
+               return;
+       }
+
+       src_po = tcore_object_ref_object(src);
+       dest_po->ops = src_po->ops;
+
+       tcore_object_link_object(dest, dest_po);
+}
+
+gboolean tcore_sms_get_ready_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_readyStatus;
+}
+
+gboolean tcore_sms_set_ready_status(CoreObject *o, int status)
+{
+       struct private_object_data *po = NULL;
+       po = tcore_object_ref_object(o);
+       if (!po) {
+               dbg("po access fail");
+               return FALSE;
+       }
+
+       po->b_readyStatus = status;
+
+       return TRUE;
+}
+
+CoreObject *tcore_sms_new(TcorePlugin *p, const char *name,
+               struct tcore_sms_operations *ops, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name, hal);
+       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_clone_hook(o, _clone_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);
+}
+
+
diff --git a/src/co_ss.c b/src/co_ss.c
new file mode 100644 (file)
index 0000000..1629815
--- /dev/null
@@ -0,0 +1,335 @@
+/*
+ * 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 _clone_hook(CoreObject *src, CoreObject *dest)
+{
+       struct private_object_data *src_po = NULL;
+       struct private_object_data *dest_po = NULL;
+
+       if (!src || !dest)
+               return;
+
+       dest_po = calloc(sizeof(struct private_object_data), 1);
+       if (!dest_po) {
+               tcore_object_link_object(dest, NULL);
+               return;
+       }
+
+       src_po = tcore_object_ref_object(src);
+       dest_po->ops = src_po->ops;
+
+       tcore_object_link_object(dest, dest_po);
+}
+
+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;
+       }
+}
+
+void tcore_ss_ussd_set_session_data(struct ussd_session* ussd_s, void *data, int data_len)
+{
+       if (!ussd_s || !ussd_s->session) {
+               dbg("[ error ] there is no session");
+               return ;
+
+       }
+       else {
+
+               ussd_s->data = data;
+               ussd_s->data_len = data_len;
+       }
+}
+
+
+CoreObject *tcore_ss_new(TcorePlugin *p, const char *name,
+               struct tcore_ss_operations *ops, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+       struct private_object_data *po = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_new(p, name, hal);
+       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_clone_hook(o, _clone_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..d0f1fbd
--- /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", (unsigned int)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..e48589d
--- /dev/null
@@ -0,0 +1,497 @@
+/*
+ * 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"
+#include "hal.h"
+#include "at.h"
+
+struct callback_type {
+       CoreObject *co;
+       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;
+       CoreObjectCloneHook clone_hook;
+       CoreObjectDispatcher dispatcher;
+       GSList *callbacks;
+
+       TcoreHal *hal;
+};
+
+static CoreObject *_object_new(TcorePlugin *plugin, const char *name, unsigned int type)
+{
+       CoreObject *co;
+
+       co = calloc(sizeof(struct tcore_object_type), 1);
+       if (!co)
+               return NULL;
+
+       co->parent_plugin = plugin;
+
+       if (name)
+               co->name = strdup(name);
+
+       co->type = type;
+
+       return co;
+}
+
+static gboolean _on_at_event(TcoreAT *at, const GSList *lines, void *user_data)
+{
+       gboolean ret;
+
+       struct callback_type *cb = user_data;
+
+       ret = cb->callback(cb->co, lines, cb->user_data);
+       if (ret == FALSE) {
+
+       }
+
+       return ret;
+}
+
+static void _remove_at_callback(TcoreAT *at, struct callback_type *cb)
+{
+       tcore_at_remove_notification_full(at, cb->event, _on_at_event, cb);
+}
+
+CoreObject *tcore_object_new(TcorePlugin *plugin,
+               const char *name, TcoreHal *hal)
+{
+       CoreObject *co;
+
+       co = _object_new(plugin, name, CORE_OBJECT_TYPE_DEFAULT);
+       if (!co)
+               return NULL;
+
+       tcore_object_set_hal(co, hal);
+
+       if (plugin)
+               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) {
+                       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);
+}
+
+CoreObject *tcore_object_clone(CoreObject *src, TcorePlugin *new_parent, const char *new_name)
+{
+       CoreObject *dest;
+       TcorePlugin *p;
+       const char *name;
+       GSList *l = NULL;
+       struct callback_type *cb = NULL;
+
+       if (!src)
+               return NULL;
+
+       if (new_parent)
+               p = new_parent;
+       else
+               p = src->parent_plugin;
+
+       if (new_name)
+               name = new_name;
+       else
+               name = src->name;
+
+       dest = _object_new(p, name, src->type);
+       if (!dest)
+               return NULL;
+
+       dest->object = src->object;
+       dest->user_data = src->user_data;
+       dest->free_hook = src->free_hook;
+       dest->clone_hook = src->clone_hook;
+       dest->dispatcher = src->dispatcher;
+       dest->hal = src->hal;
+
+       for (l = src->callbacks; l; l = l->next) {
+               cb = l->data;
+               if (!cb)
+                       continue;
+
+               tcore_object_add_callback(dest, cb->event, cb->callback, cb->user_data);
+       }
+
+       tcore_plugin_add_core_object(p, dest);
+
+       if (src->clone_hook)
+               src->clone_hook(src, dest);
+
+       return dest;
+}
+
+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_clone_hook(CoreObject *co,
+               CoreObjectCloneHook clone_hook)
+{
+       if (!co)
+               return TCORE_RETURN_EINVAL;
+
+       co->clone_hook = clone_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_set_hal(CoreObject *co, TcoreHal *hal)
+{
+       TcoreAT *at;
+       struct callback_type *cb = NULL;
+       GSList *l = NULL;
+
+       if (!co)
+               return TCORE_RETURN_EINVAL;
+
+       if (co->hal) {
+               // remove unsolicited callbacks
+               if (tcore_hal_get_mode(co->hal) == TCORE_HAL_MODE_AT) {
+                       at = tcore_hal_get_at(co->hal);
+                       for (l = co->callbacks; l != NULL; l = l->next) {
+                               cb = l->data;
+                               if (cb == NULL)
+                                       continue;
+
+                               tcore_at_remove_notification_full(
+                                       at, cb->event, _on_at_event, cb);
+                       }
+               }
+       }
+
+       co->hal = hal;
+       if (!hal)
+               return TCORE_RETURN_SUCCESS;
+
+       // register unsolicited callbacks
+       if (tcore_hal_get_mode(hal) == TCORE_HAL_MODE_AT) {
+               at = tcore_hal_get_at(hal);
+               for (l = co->callbacks; l != NULL; l = l->next) {
+                       cb = l->data;
+                       if (cb == NULL)
+                               continue;
+
+                       if (cb->event[0] == 27)
+                               tcore_at_add_notification(at, cb->event + 1,
+                                               TRUE, _on_at_event, cb);
+                       else
+                               tcore_at_add_notification(at, cb->event,
+                                               FALSE, _on_at_event, cb);
+               }
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TcoreHal *tcore_object_get_hal(CoreObject *co)
+{
+       if (!co)
+               return NULL;
+
+       return co->hal;
+}
+
+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;
+       TcoreAT *at = 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->co = co;
+       cb->event = strdup(event);
+       cb->callback = callback;
+       cb->user_data = user_data;
+
+       co->callbacks = g_slist_append(co->callbacks, cb);
+
+       if (co->hal) {
+               if (tcore_hal_get_mode(co->hal) == TCORE_HAL_MODE_AT) {
+                       at = tcore_hal_get_at(co->hal);
+                       if (event[0] == 27)
+                               tcore_at_add_notification(at, cb->event + 1, TRUE, _on_at_event, cb);
+                       else
+                               tcore_at_add_notification(at, cb->event, FALSE, _on_at_event, 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;
+       TcoreAT *at = NULL;
+
+       if (!co || !event || !callback || !co->callbacks)
+               return TCORE_RETURN_EINVAL;
+
+       if (strlen(event) < 1)
+               return TCORE_RETURN_EINVAL;
+
+       if (co->hal) {
+               if (tcore_hal_get_mode(co->hal) == TCORE_HAL_MODE_AT)
+                       at = tcore_hal_get_at(co->hal);
+       }
+
+       for (l = co->callbacks; l; l = l->next) {
+               cb = l->data;
+               if (!cb)
+                       continue;
+
+               if (cb->callback != callback)
+                       continue;
+
+               if (g_strcmp0(cb->event, event) != 0)
+                       continue;
+
+               if (at)
+                       _remove_at_callback(at, cb);
+
+               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;
+       TReturn ret;
+
+       if (!co || !event)
+               return TCORE_RETURN_EINVAL;
+
+       l = co->callbacks;
+       while (l) {
+               cb = l->data;
+               if (!cb) {
+                       l = l->next;
+                       continue;
+               }
+
+               if (g_strcmp0(cb->event, event) != 0) {
+                       l = l->next;
+                       continue;
+               }
+
+               if (cb->callback) {
+                       ret = cb->callback(co, event_info, cb->user_data);
+                       if (ret == FALSE) {
+                               l = l->next;
+                               co->callbacks = g_slist_remove(co->callbacks, cb);
+                               continue;
+                       }
+               }
+
+               l = l->next;
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
diff --git a/src/hal.c b/src/hal.c
new file mode 100644 (file)
index 0000000..178cecd
--- /dev/null
+++ b/src/hal.c
@@ -0,0 +1,510 @@
+/*
+ * 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 "at.h"
+#include "queue.h"
+#include "plugin.h"
+#include "user_request.h"
+#include "server.h"
+#include "mux.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;
+
+       enum tcore_hal_mode mode;
+       TcoreAT *at;
+};
+
+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), (unsigned int)p, tcore_pending_get_id(p), data_len);
+
+       if (h->mode == TCORE_HAL_MODE_AT) {
+               ret = tcore_at_set_request(h->at, data, TRUE);
+       }
+       else {
+               ret = tcore_hal_send_data(h, data_len, data);
+       }
+
+       if (ret == TCORE_RETURN_SUCCESS) {
+               tcore_pending_emit_send_callback(p, TRUE);
+       }
+       else {
+               tcore_pending_emit_send_callback(p, FALSE);
+       }
+
+       if (ret != TCORE_RETURN_HOOK_STOP) {
+               if (tcore_pending_get_auto_free_status_after_sent(p)) {
+                       q = tcore_hal_ref_queue(h);
+                       tcore_queue_pop_by_pending(q, p);
+                       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,
+               enum tcore_hal_mode mode)
+{
+       TcoreHal *h;
+
+       if (!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(h);
+       h->mode = mode;
+
+       if (mode == TCORE_HAL_MODE_AT)
+               h->at = tcore_at_new(h);
+
+       if (plugin)
+               tcore_server_add_hal(tcore_plugin_ref_server(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);
+
+       if (hal->at)
+               tcore_at_free(hal->at);
+
+       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;
+}
+
+TcoreAT *tcore_hal_get_at(TcoreHal *hal)
+{
+       if (!hal)
+               return NULL;
+
+       return hal->at;
+}
+
+enum tcore_hal_mode tcore_hal_get_mode(TcoreHal *hal)
+{
+       if (!hal)
+               return TCORE_HAL_MODE_UNKNOWN;
+
+       return hal->mode;
+}
+
+TReturn tcore_hal_set_mode(TcoreHal *hal, enum tcore_hal_mode mode)
+{
+       if (!hal)
+               return TCORE_RETURN_EINVAL;
+
+       hal->mode = mode;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+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 *pending)
+{
+       int qlen = 0;
+       enum tcore_pending_priority priority;
+
+       if (!hal || !pending)
+               return TCORE_RETURN_EINVAL;
+
+       if (hal->power_state == FALSE)
+               return TCORE_RETURN_FAILURE;
+
+       qlen = tcore_queue_get_length(hal->queue);
+       tcore_queue_push(hal->queue, pending);
+
+       tcore_pending_get_priority(pending, &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_send_force(TcoreHal *hal)
+{
+       if (!hal)
+               return TCORE_RETURN_EINVAL;
+
+       _hal_idle_send(hal);
+
+       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;
+
+       if (hal->mode == TCORE_HAL_MODE_AT) {
+               gboolean ret;
+               ret = tcore_at_process(hal->at, data_len, data);
+               if (ret) {
+                       /* Send next request in queue */
+                       g_idle_add_full(IDLE_SEND_PRIORITY, _hal_idle_send, hal, NULL );
+               }
+       }
+       else {
+               if(hal->mode == TCORE_HAL_MODE_CUSTOM) {
+                       dbg("TCORE_HAL_MODE_CUSTOM");
+                       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);
+               }
+               else if(hal->mode == TCORE_HAL_MODE_TRANSPARENT) {
+                       dbg("TCORE_HAL_MODE_TRANSPARENT");
+
+                       /* Invoke CMUX receive API for decoding */
+                       tcore_cmux_rcv_from_hal((unsigned char *)data, data_len);
+               }
+               /* 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);
+                       if (!hal->callbacks)
+                               break;
+
+                       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/mux.c b/src/mux.c
new file mode 100644 (file)
index 0000000..46cafce
--- /dev/null
+++ b/src/mux.c
@@ -0,0 +1,1246 @@
+/*
+ * libtcore
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Arijit Sen <arijit.sen@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 <unistd.h>
+#include <stdlib.h>
+
+#include <glib.h>
+
+#include "tcore.h"
+
+#include "hal.h"
+#include "plugin.h"
+#include "user_request.h"
+#include "server.h"
+#include "mux.h"
+#include "core_object.h"
+
+/* Maximum Core objects per Logical HAL (indirectly per Channel) */
+#define MAX_CMUX_CORE_OBJECTS          3
+
+/* Max CMUX Buffer size */
+#define MAX_CMUX_BUFFER_SIZE           4096
+
+/* Max muber of CMUX Channels */
+#define MAX_CMUX_CHANNELS_SUPPORTED    8
+
+/* CMUX Commands */
+#define CMUX_COMMAND_SABM                      0x2F
+#define CMUX_COMMAND_UA                                0x63
+#define CMUX_COMMAND_DM                                0x0F
+#define CMUX_COMMAND_DISC                      0x43
+#define CMUX_COMMAND_UIH                       0xEF
+#define CMUX_COMMAND_UI                                0x03
+
+/* MUX CONTROL COMMANDS
+  * We are supporting only MSC command for phase 1
+  */
+#define  CMUX_COMMAND_MSC                      0xE3    // Modem Status Command
+#define  CMUX_COMMAND_CLD                      0xC3    // Multiplexer close down
+
+/* CMUX Channels [0-7] -
+  * Channel 0 - Control Channel for CMUX
+  * Channel 1 - CALL
+  * Channel 2 - SIM
+  * Channel 3 - SAT
+  * Channel 4 - SMS
+  * Channel 5 - SS
+  * Channel 6 - NETWORK
+  * Channel 7 - MODEM & PS
+  */
+typedef enum CMUX_Channels {
+       CMUX_CHANNEL_0,
+       CMUX_CHANNEL_1,
+       CMUX_CHANNEL_2,
+       CMUX_CHANNEL_3,
+       CMUX_CHANNEL_4,
+       CMUX_CHANNEL_5,
+       CMUX_CHANNEL_6,
+       CMUX_CHANNEL_7
+} CMUX_Channels;
+
+/* MUX Channel States */
+typedef enum MuxChannelState {
+       MUX_CHANNEL_CLOSED,
+       MUX_CHANNEL_SABM_SEND_WAITING_FOR_UA,
+       MUX_CHANNEL_ESTABLISHED,
+       MUX_CHANNEL_UA_NOT_RECEIVED_RETRY,
+       MUX_CHANNEL_DM_RECEIVED_CLOSING,
+       MUX_CHANNEL_DM_SEND,
+       MUX_CHANNEL_DISC_RECEIVED_CLOSING,
+       MUX_CHANNEL_DISC_SEND_WAITING_FOR_UA,
+       MUX_CHANNEL_UA_SEND_CLOSING,
+       MUX_CHANNEL_UA_RECEIVED,
+       MUX_CHANNEL_UA_SENDING,
+} MuxChannelState;
+
+/* MUX State */
+typedef enum MuxState {
+       MUX_NOT_INITIALIZED,
+       MUX_INITIALIZED,
+       MUX_CLOSED
+} MuxState;
+
+#define FIND_LENGTH(buf, header_length, total_length)  do {    \
+               if (*buf & 0x01) { \
+                       total_length = *buf++ >> 1;     \
+                       header_length = 6; \
+               } \
+               else { \
+                       total_length = *(buf + 0x01) << 7; \
+                       total_length = total_length | (*buf & 0xFE) >> 1; \
+                       header_length = 7; \
+               } \
+} while (0)
+
+/*================= CRC TABLE=========================*/
+const unsigned char crc_table[256] = { // reversed, 8-bit, poly=0x07
+       0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B,
+       0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67,
+       0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43,
+       0x24, 0xB5, 0xC7, 0x56, 0x23, 0xB2, 0xC0, 0x51, 0x2A, 0xBB, 0xC9, 0x58, 0x2D, 0xBC, 0xCE, 0x5F,
+       0x70, 0xE1, 0x93, 0x02, 0x77, 0xE6, 0x94, 0x05, 0x7E, 0xEF, 0x9D, 0x0C, 0x79, 0xE8, 0x9A, 0x0B,
+       0x6C, 0xFD, 0x8F, 0x1E, 0x6B, 0xFA, 0x88, 0x19, 0x62, 0xF3, 0x81, 0x10, 0x65, 0xF4, 0x86, 0x17,
+       0x48, 0xD9, 0xAB, 0x3A, 0x4F, 0xDE, 0xAC, 0x3D, 0x46, 0xD7, 0xA5, 0x34, 0x41, 0xD0, 0xA2, 0x33,
+       0x54, 0xC5, 0xB7, 0x26, 0x53, 0xC2, 0xB0, 0x21, 0x5A, 0xCB, 0xB9, 0x28, 0x5D, 0xCC, 0xBE, 0x2F,
+       0xE0, 0x71, 0x03, 0x92, 0xE7, 0x76, 0x04, 0x95, 0xEE, 0x7F, 0x0D, 0x9C, 0xE9, 0x78, 0x0A, 0x9B,
+       0xFC, 0x6D, 0x1F, 0x8E, 0xFB, 0x6A, 0x18, 0x89, 0xF2, 0x63, 0x11, 0x80, 0xF5, 0x64, 0x16, 0x87,
+       0xD8, 0x49, 0x3B, 0xAA, 0xDF, 0x4E, 0x3C, 0xAD, 0xD6, 0x47, 0x35, 0xA4, 0xD1, 0x40, 0x32, 0xA3,
+       0xC4, 0x55, 0x27, 0xB6, 0xC3, 0x52, 0x20, 0xB1, 0xCA, 0x5B, 0x29, 0xB8, 0xCD, 0x5C, 0x2E, 0xBF,
+       0x90, 0x01, 0x73, 0xE2, 0x97, 0x06, 0x74, 0xE5, 0x9E, 0x0F, 0x7D, 0xEC, 0x99, 0x08, 0x7A, 0xEB,
+       0x8C, 0x1D, 0x6F, 0xFE, 0x8B, 0x1A, 0x68, 0xF9, 0x82, 0x13, 0x61, 0xF0, 0x85, 0x14, 0x66, 0xF7,
+       0xA8, 0x39, 0x4B, 0xDA, 0xAF, 0x3E, 0x4C, 0xDD, 0xA6, 0x37, 0x45, 0xD4, 0xA1, 0x30, 0x42, 0xD3,
+       0xB4, 0x25, 0x57, 0xC6, 0xB3, 0x22, 0x50, 0xC1, 0xBA, 0x2B, 0x59, 0xC8, 0xBD, 0x2C, 0x5E, 0xCF
+};
+/*================= CRC TABLE=========================*/
+
+/* CMUX Channel */
+typedef struct cmux_channel {
+       GSList *co;
+       TcoreHal *hal;
+       MuxChannelState state;
+       CMUX_Channels channel_id;
+       int frame_type;
+       unsigned char ext_bit;
+       unsigned char cr_bit;
+       unsigned char poll_final_bit;
+} CHANNEL;
+
+/* CMUX callback prototype */
+typedef gboolean (*mux_cb_func)(CHANNEL *channel_ptr);
+
+/* CMUX structure */
+typedef struct cmux {
+       MuxState state;
+       CHANNEL *channel_info[MAX_CMUX_CHANNELS_SUPPORTED];
+       int is_waiting;
+       int msg_len;
+       int cur_main_buf_len;
+       TcorePlugin *plugin;
+       TcoreHal *phy_hal;
+       CoreObject *modem_co;
+       mux_cb_func cb_func;
+       int info_field_len;
+       unsigned char *info_field;
+} MUX;
+
+/* Global pointer MUX Object pointer */
+MUX *g_mux_obj_ptr = NULL;
+
+/* CMUX mode of operation */
+int g_mux_mode = 0; /* BASIC mode */
+
+struct cmux_channel_object {
+       char *channel_id_name;
+       char *core_object_name[MAX_CMUX_CORE_OBJECTS];
+};
+
+/* Core Object names need to be verified, define a MACRO globally */
+struct cmux_channel_object cmux_channel_core_object[] = {
+       {"channel_0", {"control", NULL, NULL}},
+       {"channel_1", {"call", NULL, NULL}},
+       {"channel_2", {"sim", NULL, NULL}},
+       {"channel_3", {"sat", NULL, NULL}},
+       {"channel_4", {"umts_sms", NULL, NULL}},
+       {"channel_5", {"ss", NULL, NULL}},
+       {"channel_6", {"umts_network", NULL, NULL}},
+       {"channel_7", {"modem", "umts_ps", NULL}},
+};
+
+/* All the local functions declared below */
+static unsigned char calc_crc(unsigned char *header, int length);
+static int rcv_crc_check(unsigned char *data, unsigned char len, unsigned char rcv_FCS);
+MUX* tcore_cmux_new(void);
+static void tcore_cmux_free(void);
+void tcore_cmux_link_core_object_hal(CMUX_Channels channel_id, TcorePlugin *plugin);
+static gboolean tcore_cmux_recv_mux_data(CHANNEL *channel_ptr);
+static void tcore_cmux_process_rcv_frame(unsigned char *data, int len);
+static void tcore_cmux_process_channel_data(CHANNEL *channel_info_ptr);
+static void tcore_cmux_control_channel_handle(void);
+static void tcore_cmux_flush_channel_data(void);
+static void tcore_cmux_channel_init(CMUX_Channels channel_id);
+static void tcore_cmux_close_channel(int channel_id);
+static unsigned char* tcore_encode_cmux_frame(unsigned char *data, int length, int channel_id, int frame_type, unsigned char EA_bit, unsigned char CR_bit, unsigned char PF_bit, int *out_data_len);
+static TReturn tcore_cmux_send_data(int data_len, unsigned char *data);
+
+static TReturn tcore_cmux_hal_power(TcoreHal *h, gboolean flag)
+{
+       TcorePlugin *p = NULL;
+       struct custom_data *user_data = NULL;
+
+       dbg("Entry");
+
+       p = tcore_hal_ref_plugin(h);
+       if (!p) {
+               err("Plugin is undefined");
+               return TCORE_RETURN_FAILURE;
+       }
+
+       user_data = tcore_hal_ref_user_data(h);
+       if (!user_data) {
+               err("User data is undefined");
+               return TCORE_RETURN_FAILURE;
+       }
+
+       tcore_hal_set_power_state(h, TRUE);
+
+       dbg("Exit");
+       return TCORE_RETURN_SUCCESS;
+}
+
+static TReturn tcore_cmux_hal_send(TcoreHal *h, unsigned int data_len, void *data)
+{
+       unsigned char *send_data = NULL;
+       char *channel_name = NULL;
+       int channel_id = MAX_CMUX_CHANNELS_SUPPORTED;
+       int len = 0;
+       int i = 0;
+       int ret;
+
+       dbg("Entry");
+
+       /* Check if Logical HAL is Powered ON */
+       if (tcore_hal_get_power_state(h) == FALSE) {
+               err("HAL is not Powered UP");
+               return TCORE_RETURN_FAILURE;
+       }
+
+       channel_name = tcore_hal_get_name(h);
+       dbg("HAL name: %s", channel_name)
+       if (channel_name) {
+               while (i < MAX_CMUX_CHANNELS_SUPPORTED) {
+                       if (0 == strcmp((char *) cmux_channel_core_object[i].channel_id_name, (char *) channel_name)) {
+                               channel_id = i;
+                               dbg("Found Channel ID: %d", channel_id);
+
+                               /* Free memory */
+                               free(channel_name);
+                               break;
+                       }
+                       i++;
+               }
+       } else {
+               err("No name defined for HAL");
+               return TCORE_RETURN_FAILURE;
+       }
+
+       if (channel_id > MAX_CMUX_CHANNELS_SUPPORTED) {
+               err("Failed to find Channel ID");
+               return TCORE_RETURN_FAILURE;
+       }
+
+       /* Muxing operation and Frame creation */
+       /* Encoding frame */
+       send_data = tcore_encode_cmux_frame(data, data_len, channel_id, CMUX_COMMAND_UIH, 1, 1, 0, &len);
+       if (0 == len) {
+               err("Failed to encode");
+               return TCORE_RETURN_FAILURE;
+       }
+
+       /* Send CMUX data */
+       ret = tcore_cmux_send_data(len, send_data);
+
+       dbg("Exit");
+       return TCORE_RETURN_SUCCESS;
+}
+
+/* CMUX supported HAL (Logical HAL) operations */
+static struct tcore_hal_operations mux_hops = {
+       .power = tcore_cmux_hal_power,
+       .send = tcore_cmux_hal_send,
+};
+
+static TReturn tcore_cmux_send_data(int data_len, unsigned char *data)
+{
+       TReturn ret = TCORE_RETURN_SUCCESS;
+
+       dbg("Entry");
+
+       /* Directly send to Physical HAL */
+       ret = tcore_hal_send_data(g_mux_obj_ptr->phy_hal, data_len, (void *) data);
+       if (TCORE_RETURN_SUCCESS != ret) {
+               err("Failed to send CMUX data");
+       } else {
+               dbg("Successfully sent CMUX data");
+       }
+
+       dbg("Exit");
+       return ret;
+}
+static gboolean tcore_cmux_recv_mux_data(CHANNEL *channel_ptr)
+{
+       TcoreHal *hal = NULL;
+
+       dbg("Entry");
+
+       /* Dereferencing HAL from Channel Pointer */
+       hal = channel_ptr->hal;
+
+       dbg("Dispatching to logical HAL - hal: %x", (unsigned int)hal);
+       tcore_hal_dispatch_response_data(hal, 0, g_mux_obj_ptr->info_field_len, g_mux_obj_ptr->info_field);
+
+       dbg("Exit");
+       return TRUE;
+}
+
+void tcore_cmux_link_core_object_hal(CMUX_Channels channel_id, TcorePlugin *plugin)
+{
+       TcoreHal *hal = NULL;
+       CoreObject *co = NULL;
+       int index;
+
+       dbg("Entry");
+
+       if (CMUX_CHANNEL_0 != channel_id) {
+               dbg("Normal channel [%d]", channel_id);
+
+               /* Creating Logical HAL for Core Object - Mode - 'AT mode' */
+               hal = tcore_hal_new(plugin, cmux_channel_core_object[channel_id].channel_id_name, &mux_hops, TCORE_HAL_MODE_AT);
+               dbg("hal: %p", hal);
+
+               /* Update Logical HAL of CMUX Channel */
+               g_mux_obj_ptr->channel_info[channel_id]->hal = hal;
+
+               index = 0;
+               while (NULL != cmux_channel_core_object[channel_id].core_object_name[index]) {
+                       /* Retrieving Core Object */
+                       dbg("Core Object: '%s'", cmux_channel_core_object[channel_id].core_object_name[index]);
+                       co = tcore_plugin_ref_core_object(plugin, cmux_channel_core_object[channel_id].core_object_name[index]);
+                       dbg("co: %p", co);
+
+                       if (0 == strcmp((const char *) cmux_channel_core_object[channel_id].core_object_name[index], "modem")) {
+                               g_mux_obj_ptr->modem_co = co;
+                               dbg("'modem' Core object reference is stored");
+                       }
+
+                       /* Set Logical HAL to Core objects */
+                       tcore_object_set_hal(co, hal);
+
+                       /* Update Core Object list of CMUX Channel */
+                       g_mux_obj_ptr->channel_info[channel_id]->co = g_slist_append(g_mux_obj_ptr->channel_info[channel_id]->co, co);
+
+                       /* Next Core Object of the channel */
+                       index++;
+               }
+       } else {
+               /* Control Channel */
+               dbg("Control channel");
+
+               /* Creating Logical HAL for Core Object - Mode - 'AT mode' */
+               hal = tcore_hal_new(plugin, cmux_channel_core_object[channel_id].channel_id_name, &mux_hops, TCORE_HAL_MODE_AT);
+               dbg("hal: %p", hal);
+
+               /* Update Logical HAL of CMUX Channel */
+               g_mux_obj_ptr->channel_info[channel_id]->hal = hal;
+       }
+
+       /* Set Logical HAL Power State to TRUE */
+       tcore_hal_set_power_state(hal, TRUE);
+       dbg("HAL Power is SET");
+
+       dbg("Exit");
+       return;
+}
+
+MUX* tcore_cmux_new(void)
+{
+       MUX *mux = NULL;
+       int i = 0;
+
+       /* Allocating memory for mux */
+       mux = (MUX *) calloc(sizeof(MUX), 1);
+       if (!mux) {
+               err("Failed to allocate memory");
+               return NULL;
+       }
+
+       /* Allocating memory for info_field */
+       mux->info_field = (unsigned char *) calloc(MAX_CMUX_BUFFER_SIZE, 1);
+       if (!mux->info_field) {
+               err("Failed to allocate memory for info field");
+               goto ERROR;
+       }
+
+       /* MUX State initialize to MUX_NOT_INITIALIZED */
+       mux->state = MUX_NOT_INITIALIZED;
+
+       /* Allocating memory for channel_info */
+       for (i = 0; i < MAX_CMUX_CHANNELS_SUPPORTED; i++) {
+               mux->channel_info[i] = (CHANNEL *) calloc(sizeof(CHANNEL), 1);
+               /* Check for Memory allocation failure */
+               if (!mux->channel_info[i]) {
+                       err("Failed to allocate memory for channel_info of channel: %d", i);
+                       goto ERROR;
+               }
+       }
+
+       return mux;
+
+ERROR:
+       /* Free allocated memory */
+       if (mux) {
+               if (mux->info_field) {
+                       free(mux->info_field);
+               }
+
+               for (i = 0; i < MAX_CMUX_CHANNELS_SUPPORTED; i++) {
+                       if (mux->channel_info[i]) {
+                               free(mux->channel_info[i]);
+                       }
+               }
+
+               free(mux);
+       }
+
+       err("Exit");
+       return NULL;
+}
+
+static unsigned char calc_crc(unsigned char *header, int length)
+{
+       unsigned char FCS = 0xFF; /*Init*/
+       unsigned char crc = 0x00;
+
+       /* 'length' is the number of bytes in the message, 'header' points to message */
+       while (length--) {
+               FCS = crc_table[FCS ^ *header++];
+       }
+
+       /*Ones complement*/
+       crc = (0xFF - FCS);
+
+       dbg("Exit - crc: 0x%02x", crc)
+       return crc;
+}
+
+static unsigned char* tcore_encode_cmux_frame(unsigned char *data,
+                                                                                         int length,
+                                                                                         int channel_id,
+                                                                                         int frame_type,
+                                                                                         unsigned char EA_bit,
+                                                                                         unsigned char CR_bit,
+                                                                                         unsigned char PF_bit,
+                                                                                         int *out_data_len)
+{
+       int frame_length = 0;
+       int total_frame_length = 0;
+       int crc_len = 0;
+
+       dbg("Entry");
+
+       /* Flush channel data */
+       tcore_cmux_flush_channel_data();
+
+       if (length > MAX_CMUX_BUFFER_SIZE) {
+               err("Length - %d  exceeds the limit", length);
+               return NULL;
+       }
+
+       /* Flag Octet */
+       g_mux_obj_ptr->info_field[frame_length++] = (char) 0xF9;
+
+       /* Mode of Operation */
+       if (0x00 == g_mux_mode) {                /* BASIC */
+               /* EA: Extension Bit
+               * C/R: Command Response
+               */
+               g_mux_obj_ptr->info_field[frame_length] = g_mux_obj_ptr->info_field[frame_length] | ((EA_bit & 0x01) | ((CR_bit << 1) & 0x02));
+
+               /* DLCI: Data Link Connection Identifier */
+               /* Check if the channel is within range */
+               if (channel_id < MAX_CMUX_CHANNELS_SUPPORTED && channel_id >= 0) {
+                       dbg("Channel ID: %d", channel_id);
+                       g_mux_obj_ptr->info_field[frame_length] = g_mux_obj_ptr->info_field[frame_length] | ((unsigned char) channel_id << 2);
+               } else {
+                       err("Channel is out of range[0-8]");
+                       return NULL;
+               }
+               frame_length++;
+
+               /* Control Field
+                 * The content of the control field defines the type of frame.
+                 * ****************************************************************
+                 * Frame Type                                                                          0 1 2 3  4   5 6 7
+                 * SABM (Set Asynchronous Balanced Mode)                               1 1 1 1 P/F 1 0 0
+                 * UA (Unnumbered Acknowledgement)                                     1 1 0 0 P/F 1 1 0
+                 * DM (Disconnected Mode)                                                              1 1 1 1 P/F 0 0 0
+                 * DISC (Disconnect)                                                                   1 1 0 0 P/F 0 1 0
+                 * UIH (Unnumbered Information with Header check)                      1 1 1 1 P/F 1 1 1
+                 *****************************************************************/
+               if (PF_bit) {
+                       g_mux_obj_ptr->info_field[frame_length++] = frame_type | 0x10;
+               } else {
+                       g_mux_obj_ptr->info_field[frame_length++] = frame_type;
+               }
+
+               /* 5.2.1.5 Length Indicator */
+               if (length < 128) {
+                       g_mux_obj_ptr->info_field[frame_length++] = (char) length << 1 | 0x01;
+
+                       /* CRC calculatable length */
+                       crc_len = 3;
+               } else {
+                       g_mux_obj_ptr->info_field[frame_length++] = (char) (length << 1);  // Need to change
+                       g_mux_obj_ptr->info_field[frame_length++] = (char) (length >> 7);  // Need to change
+
+                       /* CRC calculatable length */
+                       crc_len = 4;
+               }
+
+               /* We need to divide the frames into maximum frame length supported by IMC.
+               * If IMC supports length according to 27.010 , we can send max of 16,384 bytes.
+               * Need to discuss with IMC.
+               */
+
+               /* 5.2.1.4 Information Field*/
+               if (length > 0) {
+                       memcpy((g_mux_obj_ptr->info_field + frame_length), data, length);
+                       frame_length += length;
+               } else {
+                       dbg("info field length is zero");
+               }
+
+               /*5.2.1.6 Frame Checking Sequence Field (FCS)*/
+               g_mux_obj_ptr->info_field[frame_length++] = calc_crc(g_mux_obj_ptr->info_field + 1, crc_len);
+
+               /*Flag Octet*/
+               g_mux_obj_ptr->info_field[frame_length++] = 0xF9;
+
+               total_frame_length = frame_length;
+       } else if (0x01 == g_mux_mode) {        /* TBD MUX_MODE_ADVANCE */
+               dbg("Advanced MUX mode : TBD");
+       }
+
+       *out_data_len = total_frame_length;
+       dbg("*out_data_len: %d", *out_data_len);
+
+       dbg("Exit total_frame_length: %d", total_frame_length);
+       return g_mux_obj_ptr->info_field;
+}
+
+static int rcv_crc_check(unsigned char *data, unsigned char len, unsigned char rcv_FCS)
+{
+       unsigned char FCS = 0xFF;
+
+       /* 'len' is the number of bytes in the message, 'data' points to message */
+       while (len--) {
+               FCS = crc_table[FCS ^ *data++];
+       }
+
+       /*Ones complement*/
+       FCS = crc_table[FCS ^ rcv_FCS];
+
+       /* 0xCF is the reversed order of 11110011 */
+       if (0xCF == FCS) {      /* FCS is OK */
+               return 1;
+       } else {            /* FCS is NOT OK */
+               return 0;
+       }
+}
+
+static void tcore_cmux_flush_channel_data(void)
+{
+       dbg("Entry");
+
+       g_mux_obj_ptr->info_field_len = 0x0;
+       memset(g_mux_obj_ptr->info_field, 0x0, MAX_CMUX_BUFFER_SIZE);
+
+       dbg("Exit");
+       return;
+}
+
+static void tcore_cmux_control_channel_handle(void)
+{
+       unsigned char cmd_type;
+       int msg_len = 0;
+       unsigned char *msg_start_ptr = NULL;
+
+       dbg("Entry");
+
+       /* 5.4.6.1 Message format
+         * All messages sent between the multiplexers conform to the following type, length, value format:
+         * Type Length Value 1 Value2  \85
+         */
+       if (g_mux_obj_ptr->info_field_len > 0) {
+               msg_start_ptr = g_mux_obj_ptr->info_field;
+               cmd_type = g_mux_obj_ptr->info_field[0];
+
+               /* The EA bit is an extension bit. The EA bit is set to 1 in the last octet of the sequence;
+                 * in other octets EA is set to 0.
+                 *
+                 * Search for the last octet
+                 */
+               while ((*msg_start_ptr++ & 0x01)) { // TBD
+                       msg_len++;
+               }
+
+               if ((cmd_type & 0x02) == 0x02) { // This is a command Request
+                       switch (cmd_type) {
+                       case CMUX_COMMAND_MSC:
+                       {
+                               dbg("Modem Status Command");
+                               break;
+                       }
+
+                       case CMUX_COMMAND_CLD:
+                       {
+                               dbg("Multiplexer close down");
+                               tcore_cmux_close();
+                               break;
+                       }
+
+                       default:
+                       {
+                               /* We will be supporting these commands in Phase 2 */
+                               dbg("Default");
+                               break;
+                       }
+                       }
+               }
+       } else {
+               err("Frame length is less than ZERO");
+       }
+
+       dbg("Exit");
+       return;
+}
+
+static void tcore_cmux_process_channel_data(CHANNEL *channel_info_ptr)
+{
+       int frame_type;
+       int channel_id;
+       int len;
+       unsigned char *send_data = NULL;
+       static int count = 0;
+       int ret;
+
+       dbg("Entry");
+
+       channel_id = channel_info_ptr->channel_id;
+       dbg("Channel ID: %d", channel_id);
+
+       frame_type = channel_info_ptr->frame_type & 0xEF;
+       dbg("frame_type: 0x%x", frame_type);
+
+       switch (frame_type) {
+       case CMUX_COMMAND_UI:
+       case CMUX_COMMAND_UIH:
+       {
+               dbg("Received UI/UIH Frame");
+               if (0 == channel_id) {              /* This is control info */
+                       dbg("Control information");
+                       tcore_cmux_control_channel_handle();
+               } else {
+                       dbg("Normal information");
+                       // put in the logical HAL queue, this goes to the Cobject
+                       tcore_cmux_recv_mux_data(channel_info_ptr);
+               }
+               break;
+       }
+
+       case CMUX_COMMAND_UA:
+       {
+               dbg("Received UA Frame");
+               dbg("channel_info_ptr->state: %d", channel_info_ptr->state);
+               if (MUX_CHANNEL_SABM_SEND_WAITING_FOR_UA == channel_info_ptr->state) {
+                       channel_info_ptr->state = MUX_CHANNEL_ESTABLISHED;
+
+                       count++;
+                       dbg("Count: %d", count);
+                       if (MAX_CMUX_CHANNELS_SUPPORTED == count) {
+                               /* Indicate to CoreObject */
+                               CoreObject *co = NULL;
+
+                               /* 'modem' Core Object */
+                               co = g_mux_obj_ptr->modem_co;
+                               if (NULL == co) {
+                                       err("'modem' Core object is not present");
+                                       return;
+                               }
+
+                               /* Emit callback */
+                               dbg("Emit Core object callback");
+                               tcore_object_emit_callback(co, "CMUX-UP", NULL);
+                               dbg("Emitted Core object callback");
+
+                               /* Reset 'count' */
+                               count = 0;
+                       }
+               } else if (MUX_CHANNEL_DISC_SEND_WAITING_FOR_UA == channel_info_ptr->state) {
+                       channel_info_ptr->state = MUX_CHANNEL_CLOSED;
+
+                       if (0 == channel_id) {
+                               g_mux_obj_ptr->state = MUX_CLOSED;
+                               tcore_cmux_close();
+                       }
+               } else {
+                       err("Received UA in wrong state!!!");
+               }
+               break;
+       }
+
+       case CMUX_COMMAND_DM:
+       {
+               /* 5.4.1 DLC Establishment : If the responding station is not ready or unwilling
+                 * to establish the particular DLC it will reply with a DM frame with the
+                 * F-bit set to 1.
+                 */
+               dbg("Received DM Frame");
+               if ((MUX_CHANNEL_ESTABLISHED == channel_info_ptr->state)
+                       || (MUX_CHANNEL_SABM_SEND_WAITING_FOR_UA == channel_info_ptr->state)) {
+                       /* Channel State set to Close */
+                       channel_info_ptr->state = MUX_CHANNEL_CLOSED;
+               }
+
+               /* Flush the Channel data */
+               tcore_cmux_flush_channel_data();
+
+               break;
+       }
+
+       case CMUX_COMMAND_DISC:
+       {
+               dbg("Received DISC Frame");
+               if (0 == channel_info_ptr->poll_final_bit) {
+                       /* In the case where a CMUX_COMMAND_SABM or CMUX_COMMAND_DISC command with
+                         * the P bit set to 0 is received then the received frame shall be discarded.
+                         */
+
+                       /* Flush the Channel data */
+                       tcore_cmux_flush_channel_data();
+               } else {
+                       if (MUX_CHANNEL_CLOSED == channel_info_ptr->state) {
+                               /* If a CMUX_COMMAND_DISC command is received while in disconnected mode
+                                 * a CMUX_COMMAND_DM response should be sent
+                                 */
+
+                               /* Encoding frame */
+                               send_data = tcore_encode_cmux_frame(NULL, 0, channel_id, CMUX_COMMAND_DM, 1, 1, 1, &len);
+                       } else {         // send Unnumbered Acknowledgement
+                               send_data = tcore_encode_cmux_frame(NULL, 0, channel_id, CMUX_COMMAND_UA, 1, 1, 1, &len);
+                       }
+
+                       if (0 == len) {
+                               err("Failed to encode");
+                               return;
+                       }
+
+                       /* Send CMUX data */
+                       ret = tcore_cmux_send_data(len, send_data);
+
+                       /* Flush the Channel data */
+                       tcore_cmux_flush_channel_data();
+
+                       /* 5.3.4 Disconnect (DISC) command: CMUX_COMMAND_DISC command sent at DLCI 0
+                         * have the same meaning as the Multiplexer Close Down command
+                         */
+                       if (0 == channel_id) {
+                               g_mux_obj_ptr->state = MUX_CLOSED;
+
+                               /* Close CMUX */
+                               tcore_cmux_close();
+                       }
+               }
+               break;
+       }
+
+       case CMUX_COMMAND_SABM:
+       {
+               dbg("Received SABM Frame");
+               if (0 == channel_info_ptr->poll_final_bit) {
+                       /* In the case where a CMUX_COMMAND_SABM or CMUX_COMMAND_DISC command with
+                         * the P bit set to 0 is received then the received frame shall be discarded.
+                         */
+
+                       /* Flush the Channel data */
+                       tcore_cmux_flush_channel_data();
+               } else {
+                       /* Encoding frame */
+                       send_data = tcore_encode_cmux_frame(NULL, 0, channel_id, CMUX_COMMAND_UA, 1, 1, 1, &len);
+                       if (0 != len) {
+                               /* Send CMUX data */
+                               ret = tcore_cmux_send_data(len, send_data);
+                       } else {
+                               err("Failed to encode");
+                       }
+
+                       if (channel_info_ptr->state != MUX_CHANNEL_ESTABLISHED) {
+                               /* Channel State set to Established */
+                               channel_info_ptr->state = MUX_CHANNEL_ESTABLISHED;
+                       }
+               }
+               break;
+       }
+       }
+
+       dbg("Exit");
+       return;
+}
+
+static void tcore_cmux_process_rcv_frame(unsigned char *data, int len)
+{
+       unsigned char *frame_process_ptr = data;
+       unsigned char *buf_start_ptr = data;
+
+       CHANNEL *ch = NULL;
+       unsigned char channel_id;
+       int header_length;
+
+       dbg("Entry");
+
+       tcore_cmux_flush_channel_data();
+
+       /* Get the Channel ID : 1st byte will be flag (F9)..Flag checking is already done.*/
+       channel_id = (*++frame_process_ptr >> 2) & 0x3F;
+
+       if (channel_id < MAX_CMUX_CHANNELS_SUPPORTED) {          // max channel is 8
+               ch = g_mux_obj_ptr->channel_info[channel_id];
+
+               ch->channel_id = channel_id;
+
+               // get the EA bit
+               ch->ext_bit = *frame_process_ptr & 0x01;
+
+               // get the CR bit
+               ch->cr_bit = (*frame_process_ptr++ >> 1) & 0x01;
+
+               // get the Frame Type
+               ch->frame_type = *frame_process_ptr++;
+
+               // get the poll/Final bit
+               ch->poll_final_bit = (ch->frame_type & 0x10) >> 4;
+
+               // get the length . TBD
+               if (*frame_process_ptr & 0x01) {                        // if, len < 127
+                       g_mux_obj_ptr->info_field_len = *frame_process_ptr++ >> 1;
+                       header_length = 3;
+               } else {
+                       g_mux_obj_ptr->info_field_len = *(frame_process_ptr + 1) << 7;
+                       g_mux_obj_ptr->info_field_len = g_mux_obj_ptr->info_field_len | ((*frame_process_ptr++ & 0xFE) >> 1);
+                       header_length = 4;
+                       frame_process_ptr++;
+               }
+               dbg("info_field_len: %d", g_mux_obj_ptr->info_field_len);
+
+               /* Copy received information field */
+               memcpy(g_mux_obj_ptr->info_field, frame_process_ptr, g_mux_obj_ptr->info_field_len);
+
+               frame_process_ptr = frame_process_ptr + g_mux_obj_ptr->info_field_len;
+
+               // CRC check of the header
+               if (rcv_crc_check(buf_start_ptr + 1, header_length, *frame_process_ptr)) {
+                       dbg("Calling tcore_cmux_process_channel_data");
+                       tcore_cmux_process_channel_data(ch);
+               } else {
+                       err("CRC check of the header FAILED.. Drop the packet !!");
+               }
+       } else {
+               err("Incorrect channel... Drop the packet !!");
+       }
+
+       dbg("Exit");
+       return;
+}
+
+int tcore_cmux_rcv_from_hal(unsigned char *data, size_t length)
+{
+       #define TCORE_MUX_DECODE_FLAG_HUNT 0
+       #define TCORE_MUX_DECODE_ADDR_HUNT 1
+       #define TCORE_MUX_DECODE_CONTROL_HUNT 2
+       #define TCORE_MUX_DECODE_LENGTH1_HUNT 3
+       #define TCORE_MUX_DECODE_LENGTH2_HUNT 4
+       #define TCORE_MUX_DECODE_DATA_HUNT 5
+       #define TCORE_MUX_DECODE_FCS_HUNT 6
+
+       static int decode_state = TCORE_MUX_DECODE_FLAG_HUNT;
+       static unsigned char dec_fcs = 0xff;
+       static unsigned char mux_buffer[4096];
+       static unsigned char* dec_data = mux_buffer;
+       static unsigned short dec_length = 0;
+       static size_t full_frame_len = 0;
+
+       size_t pos = -1;
+       int cp_len = 0;
+
+DECODE_STATE_CHANGE:
+       if (++pos >= length)
+       {
+               return 1;
+       }
+
+       switch(decode_state)
+       {
+       case TCORE_MUX_DECODE_FLAG_HUNT: full_frame_len = 0; dec_length = 0; dec_fcs = 0xff; dec_data = mux_buffer; goto FLAG_HUNT; break;
+       case TCORE_MUX_DECODE_ADDR_HUNT: goto ADDR_HUNT; break;
+       case TCORE_MUX_DECODE_CONTROL_HUNT: goto CONTROL_HUNT; break;
+       case TCORE_MUX_DECODE_LENGTH1_HUNT: goto LENGTH1_HUNT; break;
+       case TCORE_MUX_DECODE_LENGTH2_HUNT: goto LENGTH2_HUNT; break;
+       case TCORE_MUX_DECODE_DATA_HUNT: goto DATA_HUNT; break;
+       case TCORE_MUX_DECODE_FCS_HUNT: goto FCS_HUNT; break;
+       }
+
+FLAG_HUNT:
+       while (data[pos] != 0xF9) {
+               if (++pos >= length) {
+                       return 1;
+               }
+       }
+       decode_state = TCORE_MUX_DECODE_ADDR_HUNT;
+       goto DECODE_STATE_CHANGE;
+
+ADDR_HUNT:
+       while (data[pos] == 0xF9) {
+               if (++pos >= length) {
+                       return 1;
+               }
+       }
+
+       dec_fcs = crc_table[dec_fcs^data[pos]];
+       decode_state = TCORE_MUX_DECODE_CONTROL_HUNT;
+       *dec_data++ = 0xF9;
+       *dec_data++ = data[pos];
+       full_frame_len += 2;
+       goto DECODE_STATE_CHANGE;
+
+CONTROL_HUNT:
+       dec_fcs = crc_table[dec_fcs^data[pos]];
+       decode_state = TCORE_MUX_DECODE_LENGTH1_HUNT;
+       *dec_data++ = data[pos];
+       full_frame_len++;
+       goto DECODE_STATE_CHANGE;
+
+LENGTH1_HUNT:
+       dec_length = data[pos] >> 1;
+       dec_fcs = crc_table[dec_fcs^data[pos]];
+       if (data[pos] & 0x1)
+       { // ea
+               if (dec_length > 0)
+               {
+                       decode_state = TCORE_MUX_DECODE_DATA_HUNT;
+               }
+               else
+               {
+                       decode_state = TCORE_MUX_DECODE_FCS_HUNT;
+               }
+       }
+       else
+       {
+               decode_state = TCORE_MUX_DECODE_LENGTH2_HUNT;
+       }
+
+       *dec_data++ = data[pos];
+       full_frame_len++;
+       goto DECODE_STATE_CHANGE;
+
+LENGTH2_HUNT:
+       dec_length |= ((unsigned short)data[pos] << 7);
+       dec_fcs = crc_table[dec_fcs^data[pos]];
+       decode_state = TCORE_MUX_DECODE_DATA_HUNT;
+       *dec_data++ = data[pos];
+       full_frame_len++;
+       goto DECODE_STATE_CHANGE;
+
+DATA_HUNT:
+       if (dec_length < (length - pos)) // frame data fully available in the buffer
+       {
+               cp_len = dec_length;
+               decode_state = TCORE_MUX_DECODE_FCS_HUNT;
+       }
+       else    // frame data partially available in the buffer
+       {
+               cp_len = (length - pos);
+               decode_state = TCORE_MUX_DECODE_DATA_HUNT;
+       }
+
+       memcpy(dec_data, data + pos, cp_len);
+       dec_data += cp_len;
+       pos += (cp_len - 1);
+       dec_length -= cp_len;
+       full_frame_len += cp_len;
+
+       goto DECODE_STATE_CHANGE;
+
+FCS_HUNT:
+       //if (crc_table[dec_fcs^data[pos]] == 0xCF) // valid FCS, store frame.
+       {
+               *dec_data++ = data[pos];
+               *dec_data++ = 0xF9;
+               full_frame_len += 2;
+               tcore_cmux_process_rcv_frame(mux_buffer, full_frame_len);
+       }
+
+       // enter flag hunt mode
+       decode_state = TCORE_MUX_DECODE_FLAG_HUNT;
+       goto DECODE_STATE_CHANGE;
+}
+
+static void tcore_cmux_channel_init(CMUX_Channels channel_id)
+{
+       CHANNEL *ch = NULL;
+
+       ch = g_mux_obj_ptr->channel_info[channel_id];
+       memset(ch, 0x0, sizeof(CHANNEL));
+
+       ch->channel_id = channel_id;
+       ch->state = MUX_CHANNEL_SABM_SEND_WAITING_FOR_UA;
+
+       ch->co = NULL;
+       ch->hal = NULL;
+
+       /* TODO - Check if required */
+       ch->frame_type = CMUX_COMMAND_SABM;
+       ch->ext_bit = 0x01;
+       ch->cr_bit = 0x01;
+       ch->poll_final_bit = 0x01;
+
+       dbg("Channel ID %d initialized", channel_id);
+
+       return;
+}
+
+static void tcore_cmux_close_channel(int channel_id)
+{
+       CHANNEL *ch = NULL;
+       unsigned char *send_data = NULL;
+       int ret, len = 0;
+
+       dbg("Entry");
+
+       ch = g_mux_obj_ptr->channel_info[channel_id];
+
+       if (ch->state != MUX_CHANNEL_CLOSED) {
+               ch->frame_type = CMUX_COMMAND_DISC;
+               ch->ext_bit = 0x01;
+               ch->cr_bit = 0x01;
+               ch->state = MUX_CHANNEL_DISC_SEND_WAITING_FOR_UA;
+
+               /* Send DSC command */
+               /* Encoding frame */
+               send_data = tcore_encode_cmux_frame(NULL, 0, channel_id, CMUX_COMMAND_DISC, 0x01, 0x01, 0x01, &len);
+               if (0 != len) {
+                       /* Send CMUX data */
+                       ret = tcore_cmux_send_data(len, send_data);
+               } else {
+                       err("Failed to encode");
+               }
+       } else {
+               /* Channel is already closed */
+               err("Channel is already closed");
+       }
+
+       dbg("Exit");
+       return;
+}
+
+static void tcore_cmux_free(void)
+{
+       int channel;
+
+       dbg("Entry");
+
+       if (g_mux_obj_ptr) {
+               /* Free Information Field */
+               if (g_mux_obj_ptr->info_field) {
+                       free(g_mux_obj_ptr->info_field);
+                       g_mux_obj_ptr->info_field = NULL;
+               }
+
+               for (channel = 0; channel < MAX_CMUX_CHANNELS_SUPPORTED; channel++) {
+                       /* Free Channel Information */
+                       if (g_mux_obj_ptr->channel_info[channel]) {
+                               free(g_mux_obj_ptr->channel_info[channel]);
+                               g_mux_obj_ptr->channel_info[channel] = NULL;
+                       }
+               }
+
+               /* Free MUX Object */
+               free(g_mux_obj_ptr);
+               g_mux_obj_ptr = NULL;
+       } else {
+               err("MUX Object doesn't exist");
+       }
+
+       dbg("Exit");
+       return;
+}
+
+TReturn tcore_cmux_init(TcorePlugin *plugin, TcoreHal *hal)
+{
+       unsigned char *data = NULL;
+       int data_len = 0;
+
+       int index;
+
+       TReturn ret = TCORE_RETURN_SUCCESS;
+
+       dbg("Entry");
+
+       dbg("Physical HAL: %x", (unsigned int)hal);
+
+       /* Creat new CMUX Object */
+       g_mux_obj_ptr = tcore_cmux_new();
+       if (NULL == g_mux_obj_ptr) {
+               err("Failed to create MUX object");
+
+               ret = TCORE_RETURN_FAILURE;
+               goto ERROR;
+       }
+
+       /* Save Plugin */
+       g_mux_obj_ptr->plugin = plugin;
+
+       /* Save Physical HAL */
+       g_mux_obj_ptr->phy_hal = hal;
+
+       /* Setting Receive callback function for data received from Physical HAL */
+       g_mux_obj_ptr->cb_func = tcore_cmux_recv_mux_data;
+
+       /* After MUX setup, AT parse functionality of PHY HAL should be disabled,
+         * here we change the mode of PHYSICAL HAL to Transparent.
+         */
+       tcore_hal_set_mode(g_mux_obj_ptr->phy_hal, TCORE_HAL_MODE_TRANSPARENT);
+       dbg("Physical HAL mode changed to Transparent");
+
+       /* Initialize all the Channels */
+       /* Open all Channels */
+       for (index = 0; index < MAX_CMUX_CHANNELS_SUPPORTED; index++) {
+               dbg("Initialize the Channel %d", index);
+               tcore_cmux_channel_init((CMUX_Channels) index);
+
+               dbg("Opening Channel %d", index);
+               /* Encode CMUX Frame */
+               data = tcore_encode_cmux_frame(NULL, 0, index, CMUX_COMMAND_SABM, 0x01, 0x01, 0x01, &data_len);
+               if (0 == data_len) {
+                       err("Failed to encode");
+
+                       ret = TCORE_RETURN_FAILURE;
+                       goto ERROR;
+               }
+               dbg("data_len: %d data: %s", data_len, data);
+
+               /* Send CMUX data */
+               tcore_cmux_send_data(data_len, data);
+               dbg("CMUX Control Request sent to CP");
+
+               /* Set Core object and HAL */
+               tcore_cmux_link_core_object_hal((CMUX_Channels) index, plugin);
+       }
+
+       dbg("Exit");
+       return ret;
+
+ERROR:
+       /* Free the allocated CMUX memory */
+       tcore_cmux_free();
+
+       err("Exit");
+       return ret;
+}
+
+void tcore_cmux_close(void)
+{
+       int channel = 0;
+       int index = 0;
+       CoreObject *co = NULL;
+       GSList *co_list = NULL;
+
+       dbg("Entry");
+
+       for (channel = 0; channel < MAX_CMUX_CHANNELS_SUPPORTED; channel++) {
+               dbg("Channel ID: %d", channel);
+               index = 0;
+
+               /* Close Channel - Send DSC command */
+               tcore_cmux_close_channel(channel);
+
+               /* Revert Physical HAL as HAL of each Core Object associated to this Channel */
+               while (NULL != cmux_channel_core_object[channel].core_object_name[index]) {
+                       co = NULL;
+
+                       /* Core Objects list */
+                       co_list = g_mux_obj_ptr->channel_info[channel]->co;
+                       dbg("Core Objects list : %p", co_list);
+
+                       /* Core Object list may contain multiple Core Objects.
+                         * Revert to Physical HAL for each of the Core Objects associated
+                         * with this Channel
+                         */
+                       while (NULL != co_list) {
+                               if (NULL != co_list->data) {
+                                       if (!strcmp((const char *) cmux_channel_core_object[channel].core_object_name[index], (const char *) tcore_object_ref_name((CoreObject *) co_list->data))) {
+                                               co = (CoreObject *) co_list->data;
+                                               dbg("Core Object found ");
+                                               break;
+                                       }
+                               }
+
+                               /* To next Core Object in the list */
+                               co_list = co_list->next;
+                       }
+
+                       /* Set the previous Physical HAL as HAL for Core Object */
+                       if (NULL != co) {
+                               tcore_object_set_hal(co, g_mux_obj_ptr->phy_hal);
+                       } else {
+                               /* Proceed to next Channel */
+                               err("No more Core Objects present in this Channel");
+                               break;
+                       }
+
+                       /* To next Core Object */
+                       index++;
+               }
+
+               /* Free Logical HAL for Channel */
+               tcore_hal_free(g_mux_obj_ptr->channel_info[channel]->hal);
+               g_mux_obj_ptr->channel_info[channel]->hal = NULL;
+       }
+
+       /* Change the mode of PHYSICAL HAL to Custom */
+       tcore_hal_set_mode(g_mux_obj_ptr->phy_hal, TCORE_HAL_MODE_AT);
+
+       /* Free all the allocated memory */
+       tcore_cmux_free();
+
+       dbg("Exit");
+       return;
+}
diff --git a/src/plugin.c b/src/plugin.c
new file mode 100644 (file)
index 0000000..47f7a98
--- /dev/null
@@ -0,0 +1,277 @@
+/*
+ * 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 "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;
+       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;
+
+       if (filename)
+               p->filename = strdup(filename);
+
+       p->desc = desc;
+       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->list_co) {
+               for (list = plugin->list_co; list; list = list->next) {
+                       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_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) {
+               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) {
+               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) {
+               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..8937177
--- /dev/null
@@ -0,0 +1,692 @@
+/*
+ * 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 "hal.h"
+#include "user_request.h"
+#include "core_object.h"
+
+
+struct tcore_queue_type {
+       TcoreHal *hal;
+       GQueue *gq;
+       unsigned int next_id;
+};
+
+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;
+
+       guint timer_src;
+
+       UserRequest *ur;
+       TcorePlugin *plugin;
+       CoreObject *co;
+       TcoreQueue *queue;
+};
+
+enum search_field {
+       SEARCH_FIELD_ID_ALL = 0x01,
+       SEARCH_FIELD_ID_WAIT = 0x11,
+       SEARCH_FIELD_ID_SENT = 0x21,
+       SEARCH_FIELD_COMMAND_ALL = 0x02,
+       SEARCH_FIELD_COMMAND_WAIT = 0x12,
+       SEARCH_FIELD_COMMAND_SENT = 0x22,
+};
+
+static gboolean _on_pending_timeout(gpointer user_data)
+{
+       TcorePending *p = user_data;
+
+       dbg("pending timeout!!");
+
+       if (!p)
+               return FALSE;
+
+       tcore_pending_emit_timeout_callback(p);
+
+       p->on_response = NULL;
+       tcore_hal_dispatch_response_data(p->queue->hal, p->id, 0, NULL);
+
+       return FALSE;
+}
+
+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", (unsigned int)pending, pending->id);
+
+       if ((tcore_hal_get_mode(pending->queue->hal) != TCORE_HAL_MODE_AT)
+               && (tcore_hal_get_mode(pending->queue->hal) != TCORE_HAL_MODE_TRANSPARENT))
+       {
+               if (pending->data)
+                       free(pending->data);
+       }
+
+       if (pending->timer_src) {
+               g_source_remove(pending->timer_src);
+       }
+
+       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) {
+               if (pending->data_len != 0) {
+                       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);
+       }
+       else {
+               pending->data = data;
+       }
+
+       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);
+
+       if (result == TRUE) {
+               if (pending->flag_auto_free_after_sent == FALSE && pending->timeout > 0) {
+                       /* timer */
+                       dbg("start pending timer! (%d secs)", pending->timeout);
+                       pending->timer_src = g_timeout_add_seconds(pending->timeout, _on_pending_timeout, pending);
+               }
+       }
+
+       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(TcoreHal *h)
+{
+       TcoreQueue *queue;
+
+       queue = calloc(sizeof(struct tcore_queue_type), 1);
+       if (!queue)
+               return FALSE;
+
+       queue->hal = h;
+
+       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);
+}
+
+static void _tcore_queue_push_head(TcoreQueue *queue, TcorePending *pending)
+{
+       int i = -1;
+       TcorePending *tmp;
+
+       do {
+               i++;
+               tmp = g_queue_peek_nth(queue->gq, i);
+               if (!tmp) {
+                       break;
+               }
+
+               if (tmp->priority == TCORE_PENDING_PRIORITY_IMMEDIATELY)
+                       continue;
+
+               break;
+       } while (1);
+
+       g_queue_push_nth(queue->gq, pending, i);
+}
+
+TReturn tcore_queue_push(TcoreQueue *queue, TcorePending *pending)
+{
+       enum tcore_pending_priority priority;
+
+       if (!queue || !pending)
+               return TCORE_RETURN_EINVAL;
+
+       if (pending->id == 0) {
+               pending->id = queue->next_id;
+               queue->next_id++;
+       }
+
+       tcore_pending_get_priority(pending, &priority);
+       switch (priority) {
+               case TCORE_PENDING_PRIORITY_IMMEDIATELY:
+               case TCORE_PENDING_PRIORITY_HIGH:
+                       pending->queue = queue;
+                       _tcore_queue_push_head(queue, pending);
+                       break;
+
+               case TCORE_PENDING_PRIORITY_DEFAULT:
+               case TCORE_PENDING_PRIORITY_LOW:
+                       pending->queue = queue;
+                       g_queue_push_tail(queue->gq, pending);
+                       break;
+
+               default:
+                       return TCORE_RETURN_EINVAL;
+                       break;
+       }
+
+       dbg("pending(0x%x) push to queue. queue length=%d",
+                       (unsigned int)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_by_pending(TcoreQueue *queue, TcorePending *pending)
+{
+       TcorePending *tmp;
+       int i = 0;
+
+       if (!queue)
+               return NULL;
+
+       do {
+               tmp = g_queue_peek_nth(queue->gq, i);
+               if (!tmp)
+                       return NULL;
+
+               if (tmp == pending) {
+                       g_queue_pop_nth(queue->gq, i);
+                       return tmp;
+               }
+
+               i++;
+       } while(1);
+
+       return NULL;
+}
+
+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_full(TcoreQueue *queue, unsigned int id,
+               enum tcore_request_command command, enum search_field field, gboolean flag_pop)
+{
+       TcorePending *pending = NULL;
+       int i = 0;
+       UserRequest *ur;
+
+       if (!queue)
+               return NULL;
+
+       do {
+               pending = g_queue_peek_nth(queue->gq, i);
+               if (!pending)
+                       return NULL;
+
+               if ((field & 0xF0) == 0x10) {
+                       /* search option is wait pending */
+                       if (pending->flag_sent) {
+                               i++;
+                               continue;
+                       }
+               }
+               else if ((field & 0xF0) == 0x20) {
+                       /* search option is sent pending */
+                       if (pending->flag_sent == FALSE) {
+                               i++;
+                               continue;
+                       }
+               }
+
+               if ((field & 0x0F) == SEARCH_FIELD_ID_ALL) {
+                       if (pending->id == id) {
+                               if (flag_pop == TRUE) {
+                                       pending = g_queue_pop_nth(queue->gq, i);
+                               }
+                               break;
+                       }
+               }
+               else if ((field & 0x0F) == SEARCH_FIELD_COMMAND_ALL) {
+                       ur = tcore_pending_ref_user_request(pending);
+                       if (tcore_user_request_get_command(ur) == command) {
+                               if (flag_pop == TRUE) {
+                                       pending = g_queue_pop_nth(queue->gq, i);
+                               }
+                               break;
+                       }
+               }
+
+               i++;
+       } while (pending != NULL);
+
+       return pending;
+}
+
+TcorePending *tcore_queue_search_by_command(TcoreQueue *queue,
+               enum tcore_request_command command, gboolean flag_sent)
+{
+       if (flag_sent)
+               return _tcore_queue_search_full(queue, 0, command, SEARCH_FIELD_COMMAND_SENT, FALSE);
+
+       return _tcore_queue_search_full(queue, 0, command, SEARCH_FIELD_COMMAND_WAIT, FALSE);
+}
+
+TcorePending *tcore_queue_pop_by_id(TcoreQueue *queue, unsigned int id)
+{
+       if (!queue)
+               return NULL;
+
+       return _tcore_queue_search_full(queue, id, 0, SEARCH_FIELD_ID_ALL, TRUE);
+}
+
+TcorePending *tcore_queue_ref_pending_by_id(TcoreQueue *queue, unsigned int id)
+{
+       if (!queue)
+               return NULL;
+
+       return _tcore_queue_search_full(queue, id, 0, SEARCH_FIELD_ID_ALL, 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;
+               }
+       } while (pending != NULL);
+
+       if (pending->flag_sent == TRUE) {
+               dbg("pending(0x%x) is waiting state.", (unsigned int)pending);
+               return NULL;
+       }
+
+       return pending;
+}
+
+unsigned int tcore_queue_get_length(TcoreQueue *queue)
+{
+       if (!queue)
+               return 0;
+
+       return g_queue_get_length(queue->gq);
+}
+
+TcoreHal *tcore_queue_ref_hal(TcoreQueue *queue)
+{
+       if (!queue)
+               return NULL;
+
+       return queue->hal;
+}
+
+TReturn tcore_queue_cancel_pending_by_command(TcoreQueue *queue, enum tcore_request_command command)
+{
+       TcorePending *pending;
+
+       if (!queue)
+               return TCORE_RETURN_EINVAL;
+
+       while (1) {
+               pending = _tcore_queue_search_full(queue, 0, command, SEARCH_FIELD_COMMAND_ALL, FALSE);
+               if (!pending)
+                       break;
+
+               dbg("pending(0x%x) cancel", (unsigned int)pending);
+
+               if (queue->hal) {
+                       tcore_hal_dispatch_response_data(queue->hal, pending->id, 0, NULL);
+               }
+               else {
+                       pending = tcore_queue_pop_by_pending(queue, pending);
+                       tcore_pending_emit_response_callback(pending, 0, NULL);
+                       tcore_user_request_unref(tcore_pending_ref_user_request(pending));
+                       tcore_pending_free(pending);
+               }
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
diff --git a/src/server.c b/src/server.c
new file mode 100644 (file)
index 0000000..85e3d56
--- /dev/null
@@ -0,0 +1,586 @@
+/*
+ * 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"
+#include "udev.h"
+#include "util.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;
+       TcoreUdev *udev;
+};
+
+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)
+{
+       char *version;
+
+       if (!s || !s->mainloop)
+               return TCORE_RETURN_EINVAL;
+
+       version = tcore_util_get_version();
+       if (version) {
+               dbg("libtcore version: %s", version);
+               free(version);
+       }
+
+       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 (g_strcmp0(name, TCORE_PLUGIN_DEFAULT) == 0) {
+               return _find_default_plugin(s);
+       }
+
+       for (list = s->plugins; list; list = list->next) {
+               p = list->data;
+               if (!p) {
+                       continue;
+               }
+
+               if (g_strcmp0(tcore_plugin_get_description(p)->name, 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 (g_strcmp0(tcore_communicator_ref_name(comm), 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 (g_strcmp0(tcore_storage_ref_name(strg), 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 (g_strcmp0(buf, name) == 0) {
+                       free(buf);
+                       return hal;
+               }
+
+               free(buf);
+       }
+
+       return NULL;
+}
+
+TReturn tcore_server_link_udev(Server *s, TcoreUdev *udev)
+{
+       if (!s || !udev)
+               return TCORE_RETURN_EINVAL;
+
+       s->udev = udev;
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+TcoreUdev *tcore_server_ref_udev(Server *s)
+{
+       if (!s)
+               return NULL;
+
+       return s->udev;
+}
+
+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);
+
+       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;
+               else
+                       dbg("failed...");
+       }
+
+       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..a422a1c
--- /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 -1;
+       }
+
+       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 NULL;
+       }
+
+       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;
+
+               for (; cb_data != NULL; cb_data = g_slist_next(cb_data)) {
+                       tmp_cb = cb_data->data;
+                       tmp_cb->cb_fn(key, value, tmp_cb->user_data);
+                       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/udev.c b/src/udev.c
new file mode 100644 (file)
index 0000000..ed9d34b
--- /dev/null
@@ -0,0 +1,228 @@
+/*
+ * 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 <stdlib.h>
+
+#include <glib.h>
+
+#include "tcore.h"
+#include "udev.h"
+
+struct tcore_udev_type {
+       Server *server;
+
+       GUdevClient *client;
+       GUdevEnumerator *enumer;
+       GSList *enumer_callbacks;
+       GSList *callbacks;
+};
+
+struct udev_enumer_callback_type {
+       TcoreUdevEnumerCallback func;
+       void *user_data;
+};
+
+struct udev_callback_type {
+       TcoreUdevCallback func;
+       char *subsystem;
+       char *action;
+       void *user_data;
+};
+
+static const gchar *_default_subsystems[] = { NULL, };
+
+static void _on_uevent(GUdevClient *client, gchar *action, GUdevDevice *device, gpointer user_data)
+{
+       TcoreUdev *udev = user_data;
+       GSList *cb = NULL;
+       struct udev_callback_type *node;
+
+       if (!udev)
+               return;
+
+       dbg("action = '%s'", action);
+
+       for (cb = udev->callbacks; cb; cb = cb->next) {
+               node = cb->data;
+               if (!node)
+                       continue;
+
+               if (node->action)
+                       if (g_strcmp0(node->action, action) != 0)
+                               continue;
+
+               if (node->subsystem)
+                       if (g_strcmp0(node->subsystem, g_udev_device_get_subsystem(device)) != 0)
+                               continue;
+
+               if (!node->func)
+                       continue;
+
+               node->func(udev, device, node->user_data);
+       }
+}
+
+TcoreUdev *tcore_udev_new(Server *s, const gchar **subsystems)
+{
+       TcoreUdev *udev;
+
+       udev = calloc(sizeof(struct tcore_udev_type), 1);
+       if (!udev)
+               return NULL;
+
+       if (!subsystems) {
+               subsystems = _default_subsystems;
+       }
+
+       udev->server = s;
+       udev->client = g_udev_client_new(subsystems);
+       if (!udev->client) {
+               free(udev);
+               return NULL;
+       }
+
+       g_signal_connect(udev->client, "uevent", G_CALLBACK(_on_uevent), udev);
+
+       udev->enumer = g_udev_enumerator_new(udev->client);
+
+       return udev;
+}
+
+void tcore_udev_free(TcoreUdev *udev)
+{
+       if (!udev)
+               return;
+
+       if (udev->client)
+               g_object_unref(udev->client);
+
+       if (udev->enumer)
+               g_object_unref(udev->enumer);
+
+       free(udev);
+}
+
+Server *tcore_udev_ref_server(TcoreUdev *udev)
+{
+       if (!udev)
+               return NULL;
+
+       return udev->server;
+}
+
+GUdevClient *tcore_udev_ref_client(TcoreUdev *udev)
+{
+       if (!udev)
+               return NULL;
+
+       return udev->client;
+}
+
+GUdevEnumerator *tcore_udev_ref_enumerator(TcoreUdev *udev)
+{
+       if (!udev)
+               return NULL;
+
+       return udev->enumer;
+}
+
+TReturn tcore_udev_add_enumerator_callback(TcoreUdev *udev, TcoreUdevEnumerCallback func, void *user_data)
+{
+       struct udev_enumer_callback_type *node;
+
+       if (!udev || !func)
+               return TCORE_RETURN_FAILURE;
+
+       node = calloc(sizeof(struct udev_enumer_callback_type), 1);
+       if (!node)
+               return TCORE_RETURN_ENOMEM;
+
+       node->func = func;
+       node->user_data = user_data;
+
+       udev->enumer_callbacks = g_slist_append(udev->enumer_callbacks, node);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+GList *tcore_udev_exec_enumerator(TcoreUdev *udev, gboolean event_emit_flag)
+{
+       GList *list = NULL;
+       GSList *cb = NULL;
+       struct udev_enumer_callback_type *node;
+
+       if (!udev) {
+               return NULL;
+       }
+
+       list = g_udev_enumerator_execute(udev->enumer);
+       if (!list) {
+               return NULL;
+       }
+
+       if (event_emit_flag == FALSE)
+               return list;
+
+       for (cb = udev->enumer_callbacks; cb; cb = cb->next) {
+               node = cb->data;
+               if (!node) {
+                       continue;
+               }
+
+               if (!node->func)
+                       continue;
+
+               node->func(udev, list, node->user_data);
+       }
+
+       return list;
+}
+
+TReturn tcore_udev_add_callback(TcoreUdev *udev, const char *subsystem, const char *action, TcoreUdevCallback func, void *user_data)
+{
+       struct udev_callback_type *node;
+
+       if (!udev || !func)
+               return TCORE_RETURN_FAILURE;
+
+       node = calloc(sizeof(struct udev_callback_type), 1);
+       if (!node)
+               return TCORE_RETURN_ENOMEM;
+
+       node->func = func;
+       node->user_data = user_data;
+
+       if (subsystem)
+               node->subsystem = strdup(subsystem);
+
+       if (action)
+               node->action = strdup(action);
+
+       udev->callbacks = g_slist_append(udev->callbacks, node);
+
+       dbg("subsystem = [%s]", node->subsystem);
+       dbg("action = [%s]", node->action);
+       dbg("callbacks length = %d", g_slist_length(udev->callbacks));
+
+       return TCORE_RETURN_SUCCESS;
+}
+
diff --git a/src/user_request.c b/src/user_request.c
new file mode 100644 (file)
index 0000000..edd10e2
--- /dev/null
@@ -0,0 +1,304 @@
+/*
+ * 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 {
+       int ref;
+       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->ref > 0) {
+               ur->ref--;
+               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.", (unsigned int)ur);
+
+       free(ur);
+}
+
+UserRequest *tcore_user_request_ref(UserRequest *ur)
+{
+       if (!ur)
+               return NULL;
+
+       ur->ref++;
+
+       return ur;
+}
+
+void tcore_user_request_unref(UserRequest *ur)
+{
+       if (!ur)
+               return;
+
+       if (ur->ref > 0)
+               ur->ref--;
+       else
+               tcore_user_request_free(ur);
+
+       return;
+}
+
+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;
+       ur->ui.user_data = ui->user_data;
+
+       if (ur->ui.appname) {
+               dbg("free old appname (%s)", ur->ui.appname);
+               free(ur->ui.appname);
+               ur->ui.appname = NULL;
+       }
+
+       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;
+
+       if (metainfo_len > 0 && metainfo != NULL) {
+               ur->metainfo = calloc(metainfo_len, 1);
+               if (!ur->metainfo)
+                       return TCORE_RETURN_ENOMEM;
+
+               ur->metainfo_len = metainfo_len;
+               memcpy(ur->metainfo, metainfo, metainfo_len);
+       }
+       else {
+               ur->metainfo = NULL;
+               ur->metainfo_len = 0;
+       }
+
+       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..0b10ba5
--- /dev/null
@@ -0,0 +1,1525 @@
+/*
+ * 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 <iconv.h>
+
+#include "tcore.h"
+#include "util.h"
+
+
+#define        tabGsmUniMax2 9
+#define        tabGsmUniMax 42
+
+static gboolean                _find_gsm_code_exception_table(unsigned short src);
+static int             _get_gsm_code_size(unsigned short* src, int src_len);
+static gboolean                _convert_gsm_to_unicode(unsigned short *dest, int dest_len, unsigned char *src, unsigned int src_len);
+static int                     _convert_gsm_to_ucs2(unsigned short* dest, unsigned char* src, unsigned int src_len);
+static void            _convert_gsm_to_utf8(unsigned char *dest, unsigned short *dest_len,     unsigned char *src, unsigned int src_len);
+static gboolean                _convert_unicode_to_gsm(unsigned char* dest, int dest_len, unsigned short* src, int src_len);
+static char*           _convert_ucs_to_utf8(unsigned char *src, int src_len);
+static int                     _convert_ucs2_to_gsm(unsigned char* dest, unsigned short* src, unsigned int src_len);
+static int                     _convert_ucs2_to_utf8(char *out, unsigned short *out_len, char *in, unsigned short in_len);
+static void            _convert_alpha_field_ucs2_to_utf8(unsigned char *out, unsigned short *out_len, unsigned char *in, unsigned short in_len);
+static int                     _convert_utf8_to_unicode(unsigned short* dest, unsigned char* src, unsigned int src_len);
+
+typedef struct {
+       char gsm;
+       unsigned short unicode;
+} GsmUniTable;
+
+const GsmUniTable gsm_unicode2_table[] = {
+               { 0x14, 0x005E }, { 0x28, 0x007B }, { 0x29, 0x007D }, { 0x2F, 0x005C },
+               { 0x3C, 0x005B }, { 0x3D, 0x007E }, { 0x3E, 0x005D }, { 0x40, 0x007C },
+               { 0x65, 0x20AC } };
+
+const GsmUniTable gsm_unicode_table[] = {
+               { 0x00, 0x0040 }, { 0x01, 0x00A3 }, { 0x02, 0x0024 }, { 0x03, 0x00A5 },
+               { 0x04, 0x00E8 }, { 0x05, 0x00E9 }, { 0x06, 0x00F9 }, { 0x07, 0x00EC }, { 0x08, 0x00F2 },
+               { 0x09, 0x00E7 }, { 0x0B, 0x00D8 }, { 0x0C, 0x00F8 }, { 0x0E, 0x00C5 }, { 0x0F, 0x00E5 },
+               { 0x10, 0x0394 }, { 0x11, 0x005F }, { 0x12, 0x03A6 }, { 0x13, 0x0393 }, { 0x14, 0x039B },
+               { 0x15, 0x03A9 }, { 0x16, 0x03A0 }, { 0x17, 0x03A8 }, { 0x18, 0x03A3 }, { 0x19, 0x0398 },
+               { 0x1A, 0x039E }, { 0x1C, 0x00C6 }, { 0x1D, 0x00E6 }, { 0x1E, 0x00DF }, { 0x1F, 0x00C9 },
+               { 0x24, 0x00A4 }, { 0x40, 0x00A1 }, { 0x5B, 0x00C4 }, { 0x5C, 0x00D6 }, { 0x5D, 0x00D1 },
+               { 0x5E, 0x00DC }, { 0x5F, 0x00A7 }, { 0x60, 0x00BF }, { 0x7B, 0x00E4 }, { 0x7C, 0x00F6 },
+               { 0x7D, 0x00F1 }, { 0x7E, 0x00FC }, { 0x7F, 0x00E0 }, };
+
+
+
+
+static gboolean _find_gsm_code_exception_table(unsigned short src)
+{
+       if ((src >= 0x0020 && src <= 0x0023)
+                       || (src >= 0x0025 && src <= 0x003F)
+                       || (src >= 0x0041 && src <= 0x005A)
+                       || (src >= 0x0061 && src <= 0x007A)
+                       || src == 0x000A || src == 0x000D)
+               return TRUE;
+       return FALSE;
+}
+
+static int _get_gsm_code_size(unsigned short* src, int src_len)
+{
+       gboolean in_table = FALSE;
+       gboolean in_sec_table = FALSE;
+       int i, gsm_len = 0;
+
+       if (NULL == src) {
+               dbg( "INPUT PARAM was NULL");
+               return -1;
+       }
+
+       for (; src_len > 0 && src; src_len--) {
+               if (_find_gsm_code_exception_table(*src) == TRUE) {
+                       src++;
+                       gsm_len++;
+                       continue;
+               }
+               in_table = FALSE;
+               for (i = 0; i < tabGsmUniMax; i++) {
+                       if (*src == gsm_unicode_table[i].unicode) {
+                               src++;
+                               in_table = TRUE;
+                               gsm_len++;
+                               break;
+                       }
+               }
+               if (in_table == FALSE) {
+                       in_sec_table = FALSE;
+                       for (i = 0; i < tabGsmUniMax2; i++) {/* second table */
+                               if (*src == gsm_unicode2_table[i].unicode) {
+                                       src++;
+                                       in_table = TRUE;
+                                       in_sec_table = TRUE;
+                                       gsm_len += 2;
+                                       break;
+                               }
+                       }
+                       if (in_sec_table == FALSE) {/* second*/
+                               if (_find_gsm_code_exception_table(*src) == FALSE) {
+                                       dbg( "GSM Char[%d], gsm_len[%d]", *src, gsm_len);
+                                       return -1;
+                               }
+                               src++;
+                               gsm_len++;
+                       }
+               }
+       }
+       return gsm_len;
+}
+
+static gboolean _convert_gsm_to_unicode(unsigned short *dest, int dest_len, unsigned char *src, unsigned int src_len)
+{
+       int index, tmp_len;
+
+       if(!dest || !src) {
+               dbg( "dest(%p) or src(%p) is null",dest, src);
+               return FALSE;
+       }
+
+       if(!src_len){
+               dest[0] = '\0';
+               return TRUE;
+       }
+
+       dbg("source string (%s) len(%d)", src, src_len);
+
+       for(index = 0; index < (int)src_len; index++){
+               if(src[index] == 0x1B)
+                       src_len--;
+       }
+       dbg("strlen excluding escape character (%d)", src_len);
+
+       tmp_len = _convert_gsm_to_ucs2(dest, src, src_len);
+       dest[tmp_len] = '\0';
+
+       return TRUE;
+}
+
+static int _convert_gsm_to_ucs2(unsigned short* dest, unsigned char* src, unsigned int src_len)
+{
+       int index;
+       unsigned short* org;
+
+       org = dest;
+
+       for(index=0; index < (int)src_len; index++){
+               int table_index=0;
+               gboolean b_tabled = FALSE;
+
+               /*
+                * if the first byte is 0x1B, it is the escape character.
+                * The byte value shoulbe be changed to unicode.
+                */
+               if(*src == 0x1B){
+                       src++; index++;//move to next byte
+                       for(table_index=0; table_index < tabGsmUniMax2; table_index++){
+                               if(*src == gsm_unicode2_table[table_index].gsm){
+                                       *dest = gsm_unicode2_table[table_index].unicode;
+                                       b_tabled = TRUE;
+                                       break;
+                               }
+                       }
+
+                       //if matched data is not in table, it should be changed to NULL;
+                       if(!b_tabled){
+                               *dest = 0x0020;
+                       }
+               }
+               else{
+                       for(table_index=0; table_index < tabGsmUniMax; table_index++){
+                               if(*src == gsm_unicode_table[table_index].gsm){
+                                       *dest = gsm_unicode_table[table_index].unicode;
+                                       b_tabled = TRUE;
+                                       break;
+                               }
+                       }
+
+                       //if matched data is not in table, it is using original value;
+                       if(!b_tabled){
+                               *dest = *src;
+                       }
+               }
+
+               //move to next position
+               src++; dest++;
+       }
+
+       dbg("cvt sr(%s), the size of data (%d) ", org, dest - org);
+       return (dest - org);
+}
+
+static void _convert_gsm_to_utf8(unsigned char* dest, unsigned short* dest_len, unsigned char* src, unsigned int src_len)
+{
+       int tmp_len = 0;
+       char *target_tmp = NULL;
+       unsigned char *raw_unicode = NULL;
+       unsigned short tmp_dest[SAT_TEXT_STRING_LEN_MAX];
+
+       memset(tmp_dest, 0 , SAT_TEXT_STRING_LEN_MAX);
+
+       _convert_gsm_to_unicode(tmp_dest, SAT_TEXT_STRING_LEN_MAX, src, src_len);
+       while(tmp_dest[tmp_len] != '\0')
+               tmp_len++;
+       tmp_len++; // add null character
+
+       tmp_len = tmp_len*2; //for byte align
+       raw_unicode = (unsigned char*)malloc(tmp_len);
+       memset(raw_unicode, 0, tmp_len);
+
+       memcpy(raw_unicode, (unsigned char*)tmp_dest, tmp_len);
+
+       *dest_len = tmp_len;
+       target_tmp = _convert_ucs_to_utf8(raw_unicode, tmp_len);
+       if(!target_tmp){
+               dbg( "str is NULL");
+               g_free(raw_unicode);
+               return;
+       }
+
+       memcpy(dest, target_tmp, strlen((const char*)target_tmp));
+       dbg("final utf8 str (%s), length (%d)", dest, tmp_len);
+
+       g_free(raw_unicode);
+       g_free(target_tmp);
+       return;
+}
+
+static gboolean _convert_unicode_to_gsm(unsigned char* dest, int dest_len, unsigned short* src, int src_len)
+{
+       char* tmp_str;
+       int gc_len = 0;
+
+       if ((NULL == dest) || (NULL == src)) {
+               dbg( "INPUT PARAM was NULL");
+               return FALSE;
+       }
+
+       if (src_len == 0)
+               return FALSE;
+
+       gc_len = _get_gsm_code_size(src, src_len);
+       if (0 >= gc_len) {
+               dbg( "Warning: Error[%d] while finding the GSM Code Size", gc_len);
+               return FALSE;
+       }
+
+       if (dest_len < gc_len) {
+               if (dest_len == sizeof(void*)) {
+                       dbg( "Out buffer size seems to be small (%s)", dest);
+               } else {
+                       dbg("Buffer size is too small (%s): dest_len(%d), gc_len(%d)", dest, dest_len, gc_len);
+               }
+               return FALSE;
+       }
+
+       tmp_str = calloc(1, (unsigned short) gc_len);
+       if (tmp_str == NULL) {
+               dbg( "Memory Allocation Failed!");
+               return FALSE;
+       }
+
+       gc_len = _convert_ucs2_to_gsm((unsigned char*) tmp_str, src, src_len);
+       if (gc_len != -1) {
+               memcpy((char*) dest, (char*) tmp_str, gc_len);
+               free(tmp_str);
+               return TRUE;
+       }
+
+       free(tmp_str);
+       return FALSE;
+}
+
+static char* _convert_ucs_to_utf8(unsigned char* src, int src_len)
+{
+       char* utf_str = NULL;
+       iconv_t cd = NULL;
+       size_t ileft = 0;
+       size_t oleft = 0;
+       int err = 0;
+
+       char* pIn = NULL;
+       char* in_buf = NULL;
+       char* out_buf = NULL;
+
+       if (!src) {
+               dbg("src is null");
+               return NULL;
+       }
+
+       ileft = src_len * 2;//over allocate as utf-8 may occupy 3 bytes
+       oleft = src_len * 3;//over allocate as utf-8 may occupy 3 bytes
+       pIn = in_buf = (char*) malloc(ileft + 2);
+       utf_str = out_buf = (char *) malloc(oleft + 1);
+
+       memset(in_buf, 0x00, ileft + 2);
+       memset(out_buf, 0x00, oleft + 1);
+       memcpy(in_buf, src, ileft);
+
+       in_buf[ileft] = '\0';
+
+       cd = iconv_open("UTF-8", "UCS-2");
+       err = iconv(cd, (char**) &in_buf, &ileft, &out_buf, &oleft);
+
+       utf_str[src_len * 2 - ileft] = '\0';
+       iconv_close(cd);
+       free(pIn);
+       return utf_str;
+}
+
+static int _convert_ucs2_to_gsm(unsigned char* dest, unsigned short* src, unsigned int src_len)
+{
+       unsigned char* rear = NULL;
+       unsigned short* p;
+       unsigned char temp;
+       gboolean in_table = FALSE;
+       gboolean in_sec_table = FALSE;
+       int i, gc_len = 0;
+
+       if ((!dest) || (!src) || (0x00 == src_len)) {
+               dbg( "Warning: Wrong Input");
+               return -1;
+       }
+
+       rear = dest;
+       p = src;
+
+       for (; src_len > 0 && p; src_len--) {
+               in_table = FALSE;
+               for (i = 0; i < tabGsmUniMax; i++) { /* is in table  */
+                       if (*p == gsm_unicode_table[i].unicode) {
+                               temp = (unsigned char) (gsm_unicode_table[i].gsm);
+                               *rear = temp;
+                               rear++;
+                               p++;
+                               in_table = TRUE;
+                               gc_len++;
+                               break;
+                       }
+               }
+               if (in_table == FALSE) {
+                       in_sec_table = FALSE;
+                       for (i = 0; i < tabGsmUniMax2; i++) { /* second table*/
+                               if (*p == gsm_unicode2_table[i].unicode) {
+                                       *rear = 0x1B;
+                                       rear++;
+                                       temp = (unsigned char) (gsm_unicode2_table[i].gsm);
+                                       *rear = temp;
+                                       rear++;
+                                       p++;
+                                       in_table = TRUE;
+                                       in_sec_table = TRUE;
+                                       gc_len += 2;
+                                       break;
+                               }
+                       }
+                       if (in_sec_table == FALSE) { /* second */
+                               if (_find_gsm_code_exception_table(*p) == FALSE)
+                                       return -1;
+                               temp = (unsigned char) (*p); /* isn't in table. but it's just able to be converted to GSM (0x00?? -> 0x??)*/
+                               *rear = temp;
+                               rear++;
+                               p++;
+                               gc_len++;
+                       }
+               }
+       }
+       src = p;
+       return gc_len;
+}
+
+static int _convert_ucs2_to_utf8(char *out, unsigned short *out_len, char *in, unsigned short in_len)
+{
+       char *p_o = NULL;
+       size_t src_len = in_len;
+       size_t dest_len = in_len*3;
+
+       iconv_t cd = iconv_open("UTF-8", "UCS2");
+       if (cd == (iconv_t) (-1)) {
+               perror("iconv_open");
+               return 0;
+       }
+
+       p_o = out;
+
+       dbg("expected input bytes:%d dest_len:%d\n", src_len, dest_len);
+
+       if (iconv(cd, &in, &src_len, &p_o, &dest_len) == (size_t)(-1)) {
+               dbg("failed to iconv errno:%d", errno);
+       } else {
+               dbg("remained input bytes:%d processed bytes:%d", src_len, in_len*3-dest_len);
+               out[in_len*3-dest_len] = '\0';
+       }
+       *out_len = in_len*3-dest_len;
+       dbg("out_len[%d], output[%s]", *out_len, out);
+       iconv_close(cd);
+       return 0;
+}
+
+static void _convert_alpha_field_ucs2_to_utf8(unsigned char *out, unsigned short *out_len, unsigned char *in, unsigned short in_len)
+{
+       //input string UNSIGNED CHAR *IN should be encoded with BIG-ENDIAN
+       switch(in[0]) {
+               case 0x80: {
+                       unsigned char num = in_len/2;   //number of characters
+                       int i = 0;
+                       int data_loc = 1;       //starting location of data
+                       unsigned short* in_buf = NULL;
+                       dbg("[UCS2] prefix case:[0x80]");
+                       in_buf = (unsigned short*)malloc(num * sizeof(unsigned short));
+                       for(i=0; i<num; i++,data_loc++) {
+                               in_buf[i] = ((unsigned short)in[data_loc]<<8) + (unsigned short)in[data_loc+1];
+                               data_loc++;
+                               dbg("[UCS2]in_buf[%d]=0x%04x", i, in_buf[i]);
+                       }
+                       _convert_ucs2_to_utf8((char*)out, out_len, (char*) in_buf, num*2);
+                       if(in_buf!=NULL)        free(in_buf);
+               } break;
+
+               case 0x81: {
+                       unsigned char num = in[1];      //number of characters
+                       unsigned short base = (unsigned short) in[2] << 7;      //base pointer for UCS2 type
+                       int i = 0;
+                       int data_loc = 3;       //starting location of data
+                       unsigned short* in_buf = NULL;
+                       dbg("[UCS2] prefix case:[0x81]");
+                       in_buf = (unsigned short*)malloc(num * sizeof(unsigned short));
+                       for(i=0; i<num; i++,data_loc++) {
+                               if(in[data_loc]<0x80) { // if the MSB is zero (0x80 => 1000b), then remaining 7 bits are GSM default character.
+                                       _convert_gsm_to_ucs2(&in_buf[i], (unsigned char *)&in[data_loc], 1);
+                                       dbg("[UCS2]in_buf[%d]=0x%04x", i, in_buf[i]);
+                               } else {        // if the MSB is 1 then the remaining 7 bits are offset value added to Base Pointer which the result defines the UCS2 character.
+                                       in_buf[i] = base + ((unsigned short)(in[data_loc]) & 0x7F);
+                                       dbg("[UCS2]in_buf[%d]=0x%04x", i, in_buf[i]);
+                               }
+                       }
+                       _convert_ucs2_to_utf8((char*)out, out_len, (char*) in_buf, num*2);
+                       if(in_buf!=NULL)        free(in_buf);
+
+               } break;
+
+               case 0x82: {
+                       unsigned char num = in[1];      //number of characters
+                       unsigned short base = ((unsigned short) in[2] << 8) | (unsigned short) in[3];   //base pointer for UCS2 type
+                       int i = 0;
+                       int data_loc = 4;       //starting location of data
+                       unsigned short* in_buf = NULL;
+                       dbg("[UCS2] prefix case:[0x82]");
+                       in_buf = (unsigned short*)malloc(num * sizeof(unsigned short));
+                       for(i=0; i<num; i++,data_loc++) {
+                               if(in[data_loc]<0x80) {
+                                       _convert_gsm_to_ucs2(&in_buf[i], (unsigned char *)&in[data_loc], (unsigned int)1);
+                                       dbg("[UCS2]in_buf[%d]=0x%04x", i, in_buf[i]);
+                               } else {
+                                       in_buf[i] = base + ((unsigned short)(in[data_loc]) & 0x7F);
+                                       dbg("[UCS2]in_buf[%d]=0x%04x", i, in_buf[i]);
+                               }
+                       }
+                       _convert_ucs2_to_utf8((char*)out, out_len, (char*) in_buf, num*2);
+                       if(in_buf!=NULL)        free(in_buf);
+               } break;
+
+               default: {
+                       unsigned char num = in_len/2;   //number of characters
+                       int i = 0;
+                       int data_loc = 0;       //starting location of data
+                       unsigned short* in_buf = NULL;
+                       dbg("[UCS2] non-prefix case.");
+                       in_buf = (unsigned short*)malloc(num * sizeof(unsigned short));
+                       for(i=0; i<num; i++,data_loc++) {
+                               in_buf[i] = ((unsigned short)in[data_loc]<<8) + (unsigned short)in[data_loc+1];
+                               data_loc++;
+                               dbg("[UCS2]in_buf[%d]=0x%04x", i, in_buf[i]);
+                       }
+                       _convert_ucs2_to_utf8((char*)out, out_len, (char*) in_buf, num*2);
+                       if(in_buf!=NULL)        free(in_buf);
+               } break;
+       }
+}
+
+static int _convert_utf8_to_unicode(unsigned short* dest, unsigned char* src, unsigned int src_len)
+{
+       unsigned short* org = NULL;
+       unsigned char hi = 0;
+       unsigned char mid = 0;
+       unsigned char low = 0;
+
+       if ((NULL == dest) || (NULL == src)) {
+               dbg( "INPUT PARAM NULL");
+               return -1;
+       }
+
+       org = dest;
+
+       while (src_len > 0 && (*src != '\0')) {
+               if (*src < 0x80) {
+                       *dest = (*src & 0x7F);
+                       dest++;
+                       src++;
+                       src_len--;
+               } else if (((0xC0 <= *src) && (*src < 0xE0)) && (*(src + 1) >= 0x80)) {
+                       hi = *src & 0x1F;
+                       low = *(src+1) & 0x3F;
+                       *dest = (hi << 6) | low;
+                       dest++;
+                       src += 2;
+                       src_len -= 2;
+               } else if ((*src >= 0xE0) && (*(src + 1) >= 0x80) && (*(src + 2) >= 0x80)) {
+                       hi = *src & 0x0F;
+                       mid = *(src+1) & 0x3F;
+                       low = *(src+2) & 0x3F;
+                       *dest = (hi << 12) | (mid << 6) | low;
+                       dest++;
+                       src += 3;
+                       src_len -= 3;
+               } else {
+                       *dest = (*src & 0x7F);
+                       dest++;
+                       src++;
+                       src_len--;
+                       dbg( "utf8 incorrect range");
+               }
+       }
+       *dest = 0;
+       return (dest - org);
+}
+
+
+
+gboolean tcore_util_convert_utf8_to_gsm(unsigned char *dest, int *dest_len, unsigned char* src, int src_len)
+{
+       unsigned short *uc = NULL;
+       int gc_len = 0;
+       int uc_len = 0;
+
+       if (src == NULL || src_len == 0) {
+               dbg( "WARNING: Invalid Parameter");
+               return FALSE;
+       }
+
+       uc = (unsigned short*) calloc(src_len + 1, sizeof(unsigned short));
+       if (!uc) {
+               dbg( "WARNING: calloc Failed");
+               return FALSE;
+       }
+
+       /*Converting from UTF8 => UNICODE*/
+       uc_len = _convert_utf8_to_unicode(uc, src, src_len);
+       dbg( "uc_len:[%d]", uc_len);
+       if(uc_len == -1) {
+               dbg( "_convert_utf8_to_unicode returns false!");
+               free(uc);
+               return FALSE;
+       }
+
+       /*Finding the GSMCode Size*/
+       gc_len = _get_gsm_code_size(uc, uc_len);
+       dbg( "gc_len:[%d]", gc_len);
+       if ( gc_len == -1) {
+               dbg( "SM- DATA is not in GSM7BIT Character Set & Error:[%d]",   gc_len);
+               free(uc);
+               return FALSE;
+       }
+
+       *dest_len = gc_len;
+       /*Converting from UNICODE ==> GSM CODE */
+       if (_convert_unicode_to_gsm((unsigned char*) dest, *dest_len, uc, uc_len) == FALSE) {
+               dbg( "_convert_unicode_to_gsm Failed");
+               *dest_len = 0x00;
+               free(uc);
+               return FALSE;
+       }
+
+       if(uc)
+               free(uc);
+       return TRUE;
+}
+
+gboolean tcore_util_convert_utf8_to_ucs2(unsigned char* dest, int* dest_len,   unsigned char* src, int src_len)
+{
+       gsize byte_converted = 0;
+       gsize byte_read = 0;
+       gchar* str_converted = NULL;
+       GError *error = NULL;
+       int i;
+       char tmp_char;
+
+       if (dest == NULL || dest_len == NULL || src == NULL) {
+               dbg( "Invalid Input Parameter");
+               return FALSE;
+       }
+
+       /*Converting from UTF8 => UCS-2 using the g_convert*/
+       str_converted = (gchar*) g_convert((gchar*) src, (gsize) src_len,
+                                                                                                                                               (gchar*) "UCS-2", (gchar*) "UTF8",
+                                                                                                                                               (gsize*) &byte_read, (gsize*) &byte_converted,
+                                                                                                                                               &error);
+       if (str_converted == NULL) {
+               dbg( "str_converted is NULL");
+               if (error != NULL) {
+                       dbg( "Problem while conversion UTF8 => UCS2, ErrorCode[%d]", error->code);
+               }
+               return FALSE;
+       }
+
+       dbg( "src_len[%u], byte_read[%u], byte_converted[%u]", src_len, byte_read, byte_converted);
+       *dest_len = (int) byte_converted;
+
+       if (byte_converted % 2 != 0) {
+               dbg( "string length is wrong!");
+       } else {
+               for (i = 0; i < (int)byte_converted; i++) {
+                       if (i % 2 == 0) {
+                               tmp_char = str_converted[i];
+                               str_converted[i] = str_converted[i + 1];
+                               str_converted[i + 1] = tmp_char;
+                       }
+               }
+       }
+       memcpy((unsigned char*) dest, (unsigned char*) str_converted, byte_converted);
+       g_free(str_converted);
+       return TRUE;
+}
+
+gboolean tcore_util_convert_string_to_utf8(unsigned char *dest, unsigned short *dest_len,
+               enum alphabet_format dcs, const unsigned char *src, unsigned short src_len)
+{
+       dbg("dcs=[0x%02x]", dcs );
+       dbg("src=[%s], src_len=[%d]", src, src_len);
+
+       if(src==NULL || src_len==0) {
+               err("src is NULL or src_len is 0");
+               return FALSE;
+       }
+
+       switch (dcs) {
+               case ALPHABET_FORMAT_SMS_DEFAULT: {
+                       unsigned char* tmp_dest_str = NULL;
+                       dbg( "case : [ALPHABET_FORMAT_SMS_DEFAULT]");
+                       tmp_dest_str = (unsigned char*)tcore_util_unpack_gsm7bit((const unsigned char *)src, src_len);
+
+                       if(!tmp_dest_str) {
+                               err("temp_dest_str is NULL");
+                               return FALSE;
+                       }
+                       _convert_gsm_to_utf8(dest, dest_len, tmp_dest_str, strlen((const char*)tmp_dest_str));
+                       if(tmp_dest_str) {
+                               free(tmp_dest_str);
+                       }
+               }       break;
+
+               case ALPHABET_FORMAT_8BIT_DATA: {       //GSM7bit with bit 8 set to 0
+                       int tmp_str_len = 0;
+                       unsigned char *src_buf = NULL;
+                       src_buf = (unsigned char*)malloc(src_len);
+                       if(NULL == src_buf){
+                               err("src_buf is NULL!");
+                               return FALSE;
+                       }
+                       memcpy(src_buf, src, src_len);
+
+                       /*get string length*/
+                       /* 0xFF is the end of string */
+                       while (src[tmp_str_len] != 0xFF && tmp_str_len < src_len) {
+                               tmp_str_len++;
+                       }
+                       /* last space character must be deleted */
+                       while (src[tmp_str_len - 1] == 0x20 && tmp_str_len > 0) {
+                               tmp_str_len--;
+                       }
+                       dbg( "case : [ALPHABET_FORMAT_8BIT_DATA]");
+                       dbg( "tmp_str_len[%d]", tmp_str_len);
+
+                       _convert_gsm_to_utf8(dest, dest_len, src_buf, tmp_str_len);
+                       free(src_buf);
+               }       break;
+
+               case ALPHABET_FORMAT_UCS2: {
+                       unsigned char *src_buf = NULL;
+                       src_buf = (unsigned char*)malloc(src_len);
+                       if(NULL == src_buf){
+                               err("src_buf is NULL");
+                               return FALSE;
+                       }
+                       memcpy(src_buf, src, src_len);
+                       dbg( "case : [ALPHABET_FORMAT_UCS2]");
+                       _convert_alpha_field_ucs2_to_utf8(dest, dest_len, src_buf, src_len);
+                       free(src_buf);
+               }       break;
+
+               default: {
+                       dbg("not handled alpha format[0x%02x]", dcs);
+                       return FALSE;
+               }       break;
+       }
+       return TRUE;
+}
+
+void tcore_util_swap_byte_order(unsigned short* dest, const unsigned short* src, int src_len)
+{
+       int i = 0;
+
+       for (i = 0; i < src_len; i++) {
+               dest[i] = (src[i] << 8) + (src[i] >> 8);
+       }
+}
+
+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_schar(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_schar(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;
+       }
+
+       memset(&sai, 0, sizeof(struct sockaddr_in));
+       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) == 0x04)
+                               dcs = TCORE_DCS_TYPE_8_BIT;
+                       break;
+       }
+
+       return dcs;
+}
+
+#define CONVERT_HEXCHAR_TO_INT(h, i) if ((h) >= '0' && (h) <= '9') (i) = (h) - '0'; \
+       else if ((h) >= 'A' && (h) <= 'F') (i) = (h) - 'A' + 10; \
+       else if ((h) >= 'a' && (h) <= 'f') (i) = (h) - 'a' + 10; \
+       else (i) = 0;
+
+
+unsigned char *tcore_util_decode_hex(const char *src, int len)
+{
+       unsigned char *buf;
+       int i = 0;
+       int j = 0;
+       int out_len = 0;
+       int value1 = 0;
+       int value2 = 0;
+
+       if (!src)
+               return NULL;
+
+       if (len == -1) {
+               out_len = strlen(src) / 2 + 1;
+       }
+       else {
+               out_len = len;
+       }
+
+       buf = calloc(out_len, 1);
+       if (!buf)
+               return NULL;
+
+       for (; j < out_len; i+= 2, j++) {
+               CONVERT_HEXCHAR_TO_INT(src[i], value1);
+               CONVERT_HEXCHAR_TO_INT(src[i+1], value2);
+
+               buf[j] = (value1 << 4) + value2;
+       }
+
+       return buf;
+}
+
+unsigned char *tcore_util_unpack_gsm7bit(const unsigned char *src, unsigned int src_len)
+{
+       unsigned 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;
+}
+
+unsigned char *tcore_util_pack_gsm7bit(const unsigned char *src, unsigned int src_len)
+{
+       unsigned 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) {
+                       free(dest);
+                       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;
+}
+
+char* tcore_util_convert_bcd2ascii(const char* src, int src_len, int max_len)
+{
+       int index = 0, len=0;
+       char l_bcd = 0x00, h_bcd = 0x0F;
+       char *dest = NULL;
+
+       if(!src)
+               return NULL;
+
+       if(src_len*2 > max_len){
+               err("PARSER - number length exceeds the max");
+               return NULL;
+       }
+
+       dest = malloc((src_len*2)*sizeof(char)+1);
+       memset(dest, 0, (src_len*2)*sizeof(char)+1);
+
+       for(index = 0; index < src_len; index++){
+               l_bcd = src[index] & 0x0F;
+               h_bcd = (src[index] & 0xF0) >> 0x04;
+
+               switch(l_bcd){
+                       case 0x0A:
+                               dest[len++] = '*';
+                               break;
+                       case 0x0B:
+                               dest[len++] = '#';
+                               break;
+                       case 0x0C:
+                               dest[len++] = 'p'; //Pause
+                               break;
+                       case 0x0D:
+                               dest[len++] = '?'; //Wild Card character
+                               break;
+                       case 0x0E: //ignore, RFU
+                       case 0x0F: //ignore in l_bcd
+                               break;
+                       default:
+                               dest[len++] = l_bcd+'0'; //digits 0~9
+                               break;
+               }//l_lbcd switch
+
+               switch(h_bcd){
+                       case 0x0A:
+                               dest[len++] = '*';
+                               break;
+                       case 0x0B:
+                               dest[len++] = '#';
+                               break;
+                       case 0x0C:
+                               dest[len++] = 'p'; //Pause
+                               break;
+                       case 0x0D:
+                               dest[len++] = '?'; //Wild Card character
+                               break;
+                       case 0x0E: //ignore, RFU
+                       case 0x0F:
+                               dest[len] = '\0'; //Null termination
+                               break;
+                       default:
+                               dest[len++] = h_bcd+'0'; //digits 0~9
+                               break;
+               }//h_bcd switch
+       }
+
+       if(h_bcd != 0x0F)
+               dest[len] = '\0';
+
+       dbg("PARSER - number(%s) len(%d)", dest, len);
+       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;
+}
+
+char *tcore_util_get_version(void)
+{
+       return strdup(TCORE_VERSION);
+}
+
diff --git a/tcore.pc.in b/tcore.pc.in
new file mode 100644 (file)
index 0000000..bd55cd1
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@PREFIX@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: tcore
+Description: SLP Telephony core API
+Version: 1.0
+Requires: glib-2.0 gobject-2.0 gudev-1.0
+Libs: -L${libdir} -ltcore -ldl
+Cflags: -I${includedir}/tcore
+