Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:52:15 +0000 (01:52 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:52:15 +0000 (01:52 +0900)
37 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/rules [new file with mode: 0755]
debian/tel-plugin-packetservice.install.in [new file with mode: 0644]
debian/tel-plugin-packetservice.postinst [new file with mode: 0755]
include/ps-context.h [new file with mode: 0644]
include/ps-error.h [new file with mode: 0644]
include/ps-master.h [new file with mode: 0644]
include/ps-modem.h [new file with mode: 0644]
include/ps-service.h [new file with mode: 0644]
include/ps.h [new file with mode: 0644]
interfaces/ps-iface-context.xml [new file with mode: 0644]
interfaces/ps-iface-master.xml [new file with mode: 0644]
interfaces/ps-iface-modem.xml [new file with mode: 0644]
interfaces/ps-iface-service.xml [new file with mode: 0644]
packaging/0001-main-Create-modems-only-when-one-modem-is-added.patch [new file with mode: 0644]
packaging/0002-dnet_db_data-Change-SFR-internet-APN-and-add-Bouygue.patch [new file with mode: 0644]
packaging/0003-context-Fix-context-creation-issue.patch [new file with mode: 0644]
packaging/tel-plugin-packetservice.spec [new file with mode: 0644]
resources/dnet_db.sql [new file with mode: 0644]
resources/dnet_db_data.sql [new file with mode: 0644]
src/context.c [new file with mode: 0644]
src/error.c [new file with mode: 0644]
src/main.c [new file with mode: 0644]
src/master.c [new file with mode: 0644]
src/modem.c [new file with mode: 0644]
src/ps-plugin.conf [new file with mode: 0644]
src/service.c [new file with mode: 0644]
src/tcore-interface.c [new file with mode: 0644]
tel-plugin-packetservice.manifest [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..db07791
--- /dev/null
@@ -0,0 +1,83 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(ps-plugin C)
+
+#INCLUDE(FindPkgConfig)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+SET(DATAROOTDIR "\${prefix}/share")
+if(NOT DEFINED SYSCONFDIR)
+       SET(SYSCONFDIR "/etc")
+endif()
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED glib-2.0 dbus-glib-1 dlog tcore iniparser)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align")
+
+ADD_DEFINITIONS("-DFEATURE_DLOG_DEBUG")
+ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"TEL_PLUGIN_PACKETSERVICE\"")
+
+MESSAGE(${CMAKE_C_FLAGS})
+MESSAGE(${CMAKE_EXE_LINKER_FLAGS})
+
+SET(SRCS
+               src/main.c
+               src/master.c
+               src/modem.c
+               src/service.c
+               src/context.c
+               src/error.c
+               src/tcore-interface.c
+)
+
+# library build
+ADD_LIBRARY(ps-plugin SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(ps-plugin ${pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(ps-plugin PROPERTIES PREFIX "" OUTPUT_NAME ps-plugin)
+
+ADD_CUSTOM_TARGET(ps-iface-master-glue.h
+       COMMAND dbus-binding-tool --mode=glib-server --prefix=ps_iface_master
+       --output=${CMAKE_SOURCE_DIR}/include/ps-iface-master-glue.h
+       ${CMAKE_SOURCE_DIR}/interfaces/ps-iface-master.xml
+       DEPENDS ${CMAKE_SOURCE_DIR}/interfaces/ps-iface-master.xml
+)
+ADD_CUSTOM_TARGET(ps-iface-modem-glue.h
+       COMMAND dbus-binding-tool --mode=glib-server --prefix=ps_iface_modem
+       --output=${CMAKE_SOURCE_DIR}/include/ps-iface-modem-glue.h
+       ${CMAKE_SOURCE_DIR}/interfaces/ps-iface-modem.xml
+       DEPENDS ${CMAKE_SOURCE_DIR}/interfaces/ps-iface-modem.xml
+)
+ADD_CUSTOM_TARGET(ps-iface-service-glue.h
+       COMMAND dbus-binding-tool --mode=glib-server --prefix=ps_iface_service
+       --output=${CMAKE_SOURCE_DIR}/include/ps-iface-service-glue.h
+       ${CMAKE_SOURCE_DIR}/interfaces/ps-iface-service.xml
+       DEPENDS ${CMAKE_SOURCE_DIR}/interfaces/ps-iface-service.xml
+)
+ADD_CUSTOM_TARGET(ps-iface-context-glue.h
+       COMMAND dbus-binding-tool --mode=glib-server --prefix=ps_iface_context
+       --output=${CMAKE_SOURCE_DIR}/include/ps-iface-context-glue.h
+       ${CMAKE_SOURCE_DIR}/interfaces/ps-iface-context.xml
+       DEPENDS ${CMAKE_SOURCE_DIR}/interfaces/ps-iface-context.xml
+)
+
+ADD_DEPENDENCIES(${PROJECT_NAME} ps-iface-master-glue.h)
+ADD_DEPENDENCIES(${PROJECT_NAME} ps-iface-modem-glue.h)
+ADD_DEPENDENCIES(${PROJECT_NAME} ps-iface-service-glue.h)
+ADD_DEPENDENCIES(${PROJECT_NAME} ps-iface-context-glue.h)
+
+# install
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/src/ps-plugin.conf DESTINATION ${SYSCONFDIR}/dbus-1/system.d)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/resources/dnet_db.sql DESTINATION ${DATAROOTDIR}/ps-plugin)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/resources/dnet_db_data.sql DESTINATION ${DATAROOTDIR}/ps-plugin)
+INSTALL(TARGETS ps-plugin LIBRARY DESTINATION lib/telephony/plugins)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME tel-plugin-packetservice)
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..d89078c
--- /dev/null
@@ -0,0 +1,103 @@
+tel-plugin-packetservice (0.1.12) unstable; urgency=low
+
+  * Modify ntt docomo profile info 
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_0.1.12
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Thu, 24 May 2012 10:58:46 +0900
+
+tel-plugin-packetservice (0.1.11) unstable; urgency=low
+
+  * Implement context reset after modem crash
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_0.1.11
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Wed, 23 May 2012 17:32:09 +0900
+
+tel-plugin-packetservice (0.1.10) unstable; urgency=low
+
+  * Add the valid type checking logic of storage callback
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_0.1.10
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Thu, 19 Apr 2012 14:43:16 +0900
+
+tel-plugin-packetservice (0.1.9) unstable; urgency=low
+
+  * Fix Add profile bug
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_0.1.9
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Mon, 09 Apr 2012 16:40:48 +0900
+
+tel-plugin-packetservice (0.1.8) unstable; urgency=low
+
+  * version up for code sync with public binary
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_0.1.8
+
+ -- Kyeongchul Kim <kyeongchul.kim@samsung.com>  Mon, 02 Apr 2012 12:24:50 +0900
+
+tel-plugin-packetservice (0.1.7) unstable; urgency=low
+
+  * Fix add profile
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_0.1.7
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Thu, 29 Mar 2012 13:56:11 +0900
+
+tel-plugin-packetservice (0.1.6) unstable; urgency=low
+
+  * Fix prefix (TAPI_ to TCORE_)
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_0.1.6
+
+ -- Inho Oh <inho48.oh@samsung.com>  Tue, 27 Mar 2012 22:19:11 +0900
+
+tel-plugin-packetservice (0.1.5) unstable; urgency=low
+
+  * Fix obs build break in x86
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_0.1.5
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Wed, 21 Mar 2012 13:01:27 +0900
+
+tel-plugin-packetservice (0.1.4) unstable; urgency=low
+
+  * Fix update cellular state
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_0.1.4
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Mon, 19 Mar 2012 15:26:47 +0900
+
+tel-plugin-packetservice (0.1.3) unstable; urgency=low
+
+  * Fix build break
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_0.1.3
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Sat, 17 Mar 2012 20:55:21 +0900
+
+tel-plugin-packetservice (0.1.2) unstable; urgency=low
+
+  * Fix build break in OBS and Add .spec file for OBS
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_0.1.2
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Fri, 16 Mar 2012 23:23:22 +0900
+
+tel-plugin-packetservice (0.1.1) unstable; urgency=low
+
+  * Fix bugs
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_0.1.1
+
+ -- DongHoo Park <donghoo.park@samsung.com>  Fri, 16 Mar 2012 20:04:05 +0900
+
+tel-plugin-packetservice (0.1.0) unstable; urgency=low
+
+  * initialze
+  * Git: slp/pkgs/t/tel-plugin-packetservice
+  * Tag: tel-plugin-packetservice_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..407b626
--- /dev/null
@@ -0,0 +1,21 @@
+Source: tel-plugin-packetservice
+Section: libs
+Priority: extra
+Maintainer: DongHoo Park <donghoo.park@samsung.com>
+Uploaders: DongHoo Park <donghoo.park@samsung.com>
+Build-Depends: debhelper (>= 5),
+               libdbus-glib-1-dev, libtcore-dev, libglib2.0-dev, dlog-dev, libslp-db-util-dev
+Standards-Version: 0.0.0
+
+Package: tel-plugin-packetservice
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends},
+Description: telephony client API library (Shared Object)
+
+Package: tel-plugin-packetservice-dbg
+Section: debug
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, tel-plugin-packetservice (= ${Source-Version})
+Description: telephony client API library (dbg package)
+
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..efd61ff
--- /dev/null
@@ -0,0 +1,6 @@
+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/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..2d21d0e
--- /dev/null
@@ -0,0 +1,123 @@
+#!/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
+
+rmpkg:
+       rm ../tel-plugin-packetservice*.deb
+       rm ../tel-plugin-packetservice*.changes
+
+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=tel-plugin-packetservice-dbg
+       dh_compress
+       dh_fixperms
+#      dh_perl
+       dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+#      dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/debian/tel-plugin-packetservice.install.in b/debian/tel-plugin-packetservice.install.in
new file mode 100644 (file)
index 0000000..4471952
--- /dev/null
@@ -0,0 +1,4 @@
+@PREFIX@/lib/*
+@PREFIX@/etc/dbus-1/system.d/*
+/tmp/dnet_db.sql
+/tmp/dnet_db_data.sql
\ No newline at end of file
diff --git a/debian/tel-plugin-packetservice.postinst b/debian/tel-plugin-packetservice.postinst
new file mode 100755 (executable)
index 0000000..374b83a
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+#create db
+mkdir -p /opt/dbspace/
+
+if [ ! -f /opt/dbspace/.dnet.db ]
+then
+ sqlite3 /opt/dbspace/.dnet.db < /tmp/dnet_db.sql
+ sqlite3 /opt/dbspace/.dnet.db < /tmp/dnet_db_data.sql
+fi
+
+ rm -f /tmp/dnet_db.sql
+ rm -f /tmp/dnet_db_data.sql
+
+#Change File Permission
+if [ -f /opt/dbspace/.dnet.db ]
+then
+       chmod 600 /opt/dbspace/.dnet.db
+fi
+
+if [ -f /opt/dbspace/.dnet.db-journal ]
+then
+       chmod 644 /opt/dbspace/.dnet.db-journal
+fi
\ No newline at end of file
diff --git a/include/ps-context.h b/include/ps-context.h
new file mode 100644 (file)
index 0000000..ac66b36
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 __PS_CONTEXT_H__
+#define __PS_CONTEXT_H__
+
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct PsContext               PsContext;
+typedef struct PsContextClass  PsContextClass;
+
+#define PS_TYPE_CONTEXT                                ( ps_context_get_type() )
+#define PS_CONTEXT(obj)                                ( G_TYPE_CHECK_INSTANCE_CAST( (obj), PS_TYPE_CONTEXT, PsContext ) )
+#define PS_IS_CONTEXT(obj)                     ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), PS_TYPE_CONTEXT) )
+
+#define PS_CONTEXT_CLASS(klass)                ( G_TYPE_CHECK_CLASS_CAST( (klass), PS_TYPE_CONTEXT, PsContextClass ) )
+#define PS_IS_CONTEXT_CLASS(klass)     ( G_TYPE_CHECK_CLASS_TYPE( (klass), PS_TYPE_CONTEXT ) )
+#define PS_CONTEXT_GET_CLASS(obj)      ( G_TYPE_INSTANCE_GET_CLASS( (obj), PS_TYPE_CONTEXT, PsContextClass ) )
+
+GType    ps_context_get_type(void);
+
+G_END_DECLS
+
+#endif /* __PS_CONTEXT_H__ */
diff --git a/include/ps-error.h b/include/ps-error.h
new file mode 100644 (file)
index 0000000..4dea0f5
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 __PS_ERROR_H__
+#define __PS_ERROR_H__
+
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+       PS_ERR_INTERNAL,
+       PS_ERR_NO_SERVICE,
+       PS_ERR_TRASPORT,
+       PS_ERR_NO_PROFILE,
+       PS_ERR_WRONG_PROFILE,
+       PS_ERR_MAX
+} PS_ERR;
+
+GQuark ps_error_quark(void);
+
+#define    PS_ERROR    ( ps_error_quark() )
+
+G_END_DECLS
+
+#endif /* __PS_ERROR_H__ */
diff --git a/include/ps-master.h b/include/ps-master.h
new file mode 100644 (file)
index 0000000..d9fc8da
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 __PS_MASTER_H__
+#define __PS_MASTER_H__
+
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct PsMaster                        PsMaster;
+typedef struct PsMasterClass   PsMasterClass;
+
+#define PS_TYPE_MASTER                         ( ps_master_get_type() )
+#define PS_MASTER(obj)                         ( G_TYPE_CHECK_INSTANCE_CAST( (obj), PS_TYPE_MASTER, PsMaster ) )
+#define PS_IS_MASTER(obj)                      ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), PS_TYPE_MASTER) )
+
+#define PS_MASTER_CLASS(klass)         ( G_TYPE_CHECK_CLASS_CAST( (klass), PS_TYPE_MASTER, PsMasterClass ) )
+#define PS_IS_MASTER_CLASS(klass)      ( G_TYPE_CHECK_CLASS_TYPE( (klass), PS_TYPE_MASTER ) )
+#define PS_MASTER_GET_CLASS(obj)       ( G_TYPE_INSTANCE_GET_CLASS( (obj), PS_TYPE_MASTER, PsMasterClass ) )
+
+GType ps_master_get_type(void);
+
+G_END_DECLS
+
+#endif /* __PS_MASTER_H__ */
diff --git a/include/ps-modem.h b/include/ps-modem.h
new file mode 100644 (file)
index 0000000..2384272
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 __PS_MODEM_H__
+#define __PS_MODEM_H__
+
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct PsModem         PsModem;
+typedef struct PsModemClass    PsModemClass;
+
+#define PS_TYPE_MODEM                          ( ps_modem_get_type() )
+#define PS_MODEM(obj)                          ( G_TYPE_CHECK_INSTANCE_CAST( (obj),PS_TYPE_MODEM, PsModem ) )
+#define PS_IS_MODEM(obj)                       ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), PS_TYPE_MODEM) )
+
+#define PS_MODEM_CLASS(klass)          ( G_TYPE_CHECK_CLASS_CAST( (klass), PS_TYPE_MODEM, PsModemClass ) )
+#define PS_IS_MODEM_CLASS(klass)       ( G_TYPE_CHECK_CLASS_TYPE( (klass), PS_TYPE_MODEM ) )
+#define PS_MODEM_GET_CLASS(obj)                ( G_TYPE_INSTANCE_GET_CLASS( (obj), PS_TYPE_MODEM, PsModemClass ) )
+
+GType ps_modem_get_type(void);
+
+G_END_DECLS
+
+#endif /* __PS_MODEM_H__ */
diff --git a/include/ps-service.h b/include/ps-service.h
new file mode 100644 (file)
index 0000000..b5a38c1
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 __PS_SERVICE_H__
+#define __PS_SERVICE_H__
+
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct PsService               PsService;
+typedef struct PsServiceClass  PsServiceClass;
+
+#define PS_TYPE_SERVICE                                ( ps_service_get_type() )
+#define PS_SERVICE(obj)                                ( G_TYPE_CHECK_INSTANCE_CAST( (obj),PS_TYPE_SERVICE, PsService ) )
+#define PS_IS_SERVICE(obj)                     ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), PS_TYPE_SERVICE) )
+
+#define PS_SERVICE_CLASS(klass)                ( G_TYPE_CHECK_CLASS_CAST( (klass), PS_TYPE_SERVICE, PsServiceClass ) )
+#define PS_IS_SERVICE_CLASS(klass)     ( G_TYPE_CHECK_CLASS_TYPE( (klass), PS_TYPE_SERVICE ) )
+#define PS_SERVICE_GET_CLASS(obj)      ( G_TYPE_INSTANCE_GET_CLASS( (obj), PS_TYPE_SERVICE, PsServiceClass ) )
+
+GType ps_service_get_type(void);
+
+G_END_DECLS
+
+#endif /* __PS_SERVICE_H__ */
diff --git a/include/ps.h b/include/ps.h
new file mode 100644 (file)
index 0000000..86ebf47
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 __PS_H__
+#define __PS_H__
+
+#define PS_DBUS_SERVICE        "com.tcore.ps"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+
+#include <tcore.h>
+#include <plugin.h>
+#include <storage.h>
+#include <server.h>
+#include <core_object.h>
+#include <hal.h>
+
+/*Storage Key value*/
+#define KEY_3G_ENABLE                          STORAGE_KEY_3G_ENABLE
+#define KEY_DATA_ROAMING_SETTING       STORAGE_KEY_SETAPPL_STATE_DATA_ROAMING_BOOL
+
+/*MASTER*/
+gpointer    _ps_master_create_master(DBusGConnection *conn, TcorePlugin *p);
+gboolean    _ps_master_create_modems(gpointer master);
+gboolean    _ps_master_get_storage_value(gpointer master, enum tcore_storage_key key);
+gboolean    _ps_master_set_storage_value(gpointer master, enum tcore_storage_key key, gboolean value);
+
+/*MODEM*/
+gpointer    _ps_modem_create_modem(DBusGConnection *conn, TcorePlugin *p, gpointer master,
+                               gchar* modem_name, gpointer co_modem);
+gboolean    _ps_modem_processing_flight_mode(gpointer object, gboolean enable);
+gboolean    _ps_modem_processing_power_enable(gpointer modem, gboolean enable);
+gboolean    _ps_modem_processing_sim_complete(gpointer modem, gboolean complete, gchar *operator);
+gboolean    _ps_modem_set_sim_enabled(gpointer object, gboolean value);
+gboolean    _ps_modem_set_data_allowed(gpointer modem, gboolean value);
+gboolean    _ps_modem_get_data_allowed(gpointer modem);
+gboolean    _ps_modem_set_data_roaming_allowed(gpointer modem, gboolean value);
+gboolean    _ps_modem_get_data_roaming_allowed(gpointer modem);
+gboolean    _ps_modem_get_flght_mode(gpointer object);
+gboolean    _ps_modem_get_sim_init(gpointer object);
+gboolean    _ps_modem_get_power(gpointer object);
+gchar*      _ps_modem_ref_operator(gpointer object);
+gboolean    _ps_modem_get_properties(gpointer modem, GHashTable *properties);
+GHashTable* _ps_modem_ref_services(gpointer modem);
+gchar*      _ps_modem_ref_path(gpointer modem);
+gpointer    _ps_modem_ref_plugin(gpointer modem);
+gpointer    _ps_modem_ref_dbusconn(gpointer modem);
+gpointer    _ps_modem_ref_co_modem(gpointer modem);
+
+/*SERVICE*/
+gpointer    _ps_service_create_service(DBusGConnection *conn, TcorePlugin *p,
+                               gpointer modem, CoreObject *co_network, CoreObject *co_ps, gchar* path);
+gboolean    _ps_service_ref_context(gpointer object, gpointer context);
+gboolean    _ps_service_ref_contexts(gpointer service, GHashTable *contexts, gchar *operator);
+gboolean    _ps_service_unref_context(gpointer service, gpointer context);
+gboolean    _ps_service_get_properties(gpointer service, GHashTable *properties);
+gchar*      _ps_service_ref_path(gpointer service);
+gpointer    _ps_service_ref_plugin(gpointer service);
+gpointer    _ps_service_ref_co_network(gpointer service);
+gpointer    _ps_service_ref_co_ps(gpointer service);
+gboolean    _ps_service_set_context_info(gpointer service, struct tnoti_ps_pdp_ipconfiguration *devinfo);
+int            _ps_service_define_context(gpointer object, gpointer context);
+int         _ps_service_activate_context(gpointer service, gpointer context);
+gboolean    _ps_service_deactivate_context(gpointer service, gpointer context);
+void        _ps_service_connection_timer(gpointer service, gpointer context);
+void        _ps_service_reset_connection_timer(gpointer context);
+void        _ps_service_connect_default_context(gpointer service);
+void        _ps_service_remove_contexts(gpointer object);
+void        _ps_service_disconnect_contexts(gpointer service);
+gboolean    _ps_service_processing_network_event(gpointer service, gboolean ps_attached, gboolean roaming);
+gpointer    _ps_service_return_default_context(gpointer object);
+gboolean    _ps_service_set_connected(gpointer service, int context_id, gboolean enabled);
+void           _ps_service_set_ps_defined(gpointer *object, gboolean value, int cid);
+gboolean    _ps_service_set_ps_attached(gpointer service, gboolean value);
+gboolean    _ps_service_set_roaming(gpointer service, gboolean value);
+gboolean    _ps_service_get_roaming(gpointer object);
+gboolean    _ps_service_set_access_technology(gpointer service,
+                               enum telephony_network_access_technology value);
+enum telephony_ps_state
+                       _ps_service_check_cellular_state(gpointer object);
+
+/*CONTEXT*/
+gboolean    _ps_context_initialize(gpointer plugin);
+gboolean    _ps_context_reset_profile_table(void);
+gboolean    _ps_context_fill_profile_table_from_ini_file(void);
+gboolean    _ps_context_reset_hashtable(void);
+GHashTable* _ps_context_create_hashtable(DBusGConnection *conn, TcorePlugin *p, gchar *mccmnc);
+GHashTable* _ps_context_ref_hashtable(void);
+gboolean    _ps_context_add_context(gpointer modem, gchar *operator, GHashTable *property);
+gboolean    _ps_context_get_properties(gpointer context, GHashTable *properties);
+gboolean    _ps_context_set_service(gpointer context, gpointer service);
+gpointer    _ps_context_ref_service(gpointer object);
+gboolean    _ps_context_get_alwayson_enable(gpointer object);
+gchar*      _ps_context_ref_path(gpointer context);
+gpointer    _ps_context_ref_co_context(gpointer context);
+gboolean    _ps_context_set_connected(gpointer context, gboolean enabled);
+gboolean       _ps_context_set_ps_defined(gpointer *object, gboolean value, int cid);
+gboolean       _ps_context_get_ps_defined(gpointer *object);
+gboolean    _ps_context_set_alwayson_enable(gpointer object, gboolean enabled);
+gboolean    _ps_context_get_default_internet(gpointer object);
+gboolean    _ps_context_remove_context(gpointer context);
+
+/*PLUGIN INTERFACE*/
+gboolean    _ps_hook_co_modem_event(gpointer modem);
+gboolean    _ps_get_co_modem_values(gpointer modem);
+gboolean    _ps_hook_co_network_event(gpointer service);
+gboolean    _ps_free_co_network_event(gpointer service);
+gboolean    _ps_get_co_network_values(gpointer service);
+gboolean    _ps_hook_co_ps_event(gpointer service);
+gboolean    _ps_free_co_ps_event(gpointer service);
+gboolean    _ps_update_cellular_state_key(gpointer service);
+
+#endif /* __PS_H__ */
diff --git a/interfaces/ps-iface-context.xml b/interfaces/ps-iface-context.xml
new file mode 100644 (file)
index 0000000..6ca8463
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/">
+       <interface name="com.tcore.ps.context">
+               <method name="GetProperties">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
+                               <arg  type="a{ss}" name="context_property" direction="out" />
+               </method>
+               <method name="GetProfile">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
+                               <arg  type="a{ss}" name="profile_property" direction="out" />
+               </method>               
+               <method name="Activate">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
+                               <arg  type="s" name="context_path" direction="out" />
+               </method>
+               <method name="Deactivate">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
+                               <arg  type="s" name="context_path" direction="out" />   
+               </method>
+               <method name="SetDefaultConnection">
+                       <arg  type="b" name="result" direction="out" />
+               </method>
+               <method name="ModifyProfile">
+                       <arg  type="a{ss}" name="profile_property" direction="in" />
+                       <arg  type="b" name="result" direction="out" />
+               </method>
+               <method name="RemoveProfile">
+                       <arg  type="b" name="result" direction="out" />
+               </method>               
+               <signal name="PropertyChanged">
+                       <arg type="a{ss}" name="context_property" direction="out" />
+               </signal>
+       </interface>
+</node>
diff --git a/interfaces/ps-iface-master.xml b/interfaces/ps-iface-master.xml
new file mode 100644 (file)
index 0000000..86ae535
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/">
+       <interface name="com.tcore.ps.master">
+               <method name="GetModems">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
+                               <arg  type="a{sa{ss}}" name="modem_hash" direction="out" />
+               </method>
+               <method name="GetProfileList">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
+                               <arg  type="as" name="profile_list" direction="out" />
+               </method>
+               <method name="AddProfile">
+                       <arg  type="a{ss}" name="profile_property" direction="in" />
+                       <arg  type="b" name="result" direction="out" />
+               </method>
+               <method name="ResetProfile">
+                       <arg  type="b" name="result" direction="out" />
+               </method>
+               <signal name="ModemAdded">
+                       <arg  type="a{ss}" name="modem" direction="out" />
+               </signal>
+               <signal name="ModemRemoved">
+                       <arg type="o" name="modem_path" direction="out" />
+               </signal>
+       </interface>
+</node>
diff --git a/interfaces/ps-iface-modem.xml b/interfaces/ps-iface-modem.xml
new file mode 100644 (file)
index 0000000..702fac8
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/">
+       <interface name="com.tcore.ps.modem">
+               <method name="GetProperties">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
+                               <arg  type="a{ss}" name="modem_property" direction="out" />
+               </method>
+               <method name="GetServices">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
+                               <arg  type="a{sa{ss}}" name="service_hash" direction="out" />
+               </method>
+               <signal name="PropertyChanged">
+                       <arg type="a{ss}" name="modem_property" direction="out" />
+               </signal>
+               <signal name="ServiceAdded">
+                       <arg type="a{ss}" name="service" direction="out" />
+               </signal>
+               <signal name="ServiceRemoved">
+                       <arg  type="s" name="service_path" direction="out" />
+               </signal>
+       </interface>
+</node>
+
diff --git a/interfaces/ps-iface-service.xml b/interfaces/ps-iface-service.xml
new file mode 100644 (file)
index 0000000..1b47dbc
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/">
+       <interface name="com.tcore.ps.service">
+               <method name="GetProperties">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
+                               <arg  type="a{ss}" name="service_property" direction="out" />
+               </method>
+               <method name="GetContexts">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
+                               <arg  type="a{sa{ss}}" name="context_hash" direction="out" />
+               </method>
+               <signal name="PropertyChanged">
+                       <arg type="a{ss}" name="service_property" direction="out" />
+               </signal>
+               <signal name="ContextAdded">
+                       <arg type="a{ss}" name="context" direction="out" />
+               </signal>
+               <signal name="ContextRemoved">
+                       <arg  type="s" name="context_path" direction="out" />
+               </signal>
+       </interface>
+</node>
+
diff --git a/packaging/0001-main-Create-modems-only-when-one-modem-is-added.patch b/packaging/0001-main-Create-modems-only-when-one-modem-is-added.patch
new file mode 100644 (file)
index 0000000..e22e929
--- /dev/null
@@ -0,0 +1,49 @@
+From ddb37eaa4cb56a44fa2531e5ae828f3a84eaa49b Mon Sep 17 00:00:00 2001
+From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
+Date: Wed, 10 Oct 2012 16:50:27 +0200
+Subject: [PATCH 1/3] main: Create modems only when one modem is added
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+---
+ src/main.c |   17 ++++++++++++++++-
+ 1 file changed, 16 insertions(+), 1 deletion(-)
+
+diff --git a/src/main.c b/src/main.c
+index c07a1e1..5c4e27b 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -34,6 +34,18 @@ static gboolean on_load()
+       return TRUE;
+ }
++static enum tcore_hook_return __on_hook_modem_added(Server *s, CoreObject *source,
++              enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
++{
++      gpointer *master = user_data;
++
++      dbg("modem added event called");
++
++      _ps_master_create_modems(master);
++
++      return TCORE_HOOK_RETURN_CONTINUE;
++}
++
+ static gboolean on_init(TcorePlugin *p)
+ {
+       gpointer *master;
+@@ -57,7 +69,10 @@ static gboolean on_init(TcorePlugin *p)
+       }
+       master = _ps_master_create_master(conn, p);
+-      rv = _ps_master_create_modems(master);
++
++      tcore_server_add_notification_hook(tcore_plugin_ref_server(p),
++                                              TNOTI_MODEM_ADDED,
++                                              __on_hook_modem_added, master);
+       dbg("initialized PacketService plugin!");
+       return TRUE;
+-- 
+1.7.10.4
+
diff --git a/packaging/0002-dnet_db_data-Change-SFR-internet-APN-and-add-Bouygue.patch b/packaging/0002-dnet_db_data-Change-SFR-internet-APN-and-add-Bouygue.patch
new file mode 100644 (file)
index 0000000..c70104f
--- /dev/null
@@ -0,0 +1,44 @@
+From d42754b918740bddb60447f97a5fa6071f96622b Mon Sep 17 00:00:00 2001
+From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
+Date: Mon, 15 Oct 2012 18:12:23 +0200
+Subject: [PATCH 2/3] dnet_db_data: Change SFR internet APN and add Bouygues
+ operator
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+---
+ resources/dnet_db_data.sql |    5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/resources/dnet_db_data.sql b/resources/dnet_db_data.sql
+index 3844a63..a33b95c 100644
+--- a/resources/dnet_db_data.sql
++++ b/resources/dnet_db_data.sql
+@@ -27,6 +27,7 @@ INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (26, '
+ INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (27, 'Tizen', '11111');
+ INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (28, 'T Mobile UK', '23430');
+ INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (29, 'T Mobile PL', '26002');
++INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (30, 'F-Bouygues Telecom', '20820');
+ INSERT INTO "max_pdp"(network_info_id, max_pdp_3g) VALUES(1, 2);
+ INSERT INTO "max_pdp"(network_info_id, max_pdp_3g) VALUES(2, 3);
+@@ -71,7 +72,7 @@ INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, au
+ INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(39, 'O2 MMS','internet',0,NULL,NULL,1,'82.113.100.5:8080','http://10.81.0.7:8002',300,0,0,NULL,0,NULL,NULL,18,2, 0, 1, 0);
+ INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(40, 'SKT Internet','web.sktelecom.com',0,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,19,1,0,1,1);
+ INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(41, 'SKT MMS','web.sktelecom.com',0,NULL,NULL,0,'220.103.230.150:9093','http://omms.nate.com:9082/oma_mms',300, 0,0,NULL,0,NULL,NULL,19,2, 0, 1, 0);
+-INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(42, 'SFR Internet','sl2sfr',1,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,20,1,0,1,1);
++INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(42, 'SFR Internet','push',1,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,20,1,0,1,1);
+ INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(43, 'SFR MMS','mmssfr',1,NULL,NULL,1,'10.151.0.1:8080','http://mms1',300,0,0,NULL,0,NULL,NULL,20,2, 0, 1, 0);
+ INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(44, 'T Mobile Internet','internet.t-mobile',1,'t-mobile','tm',1,NULL,NULL,150,0,0,NULL,0,NULL,NULL,21,1,0,1,1);
+ INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(45, 'T Mobile MMS','internet.t-mobile',1,'t-mobile','tm',1,'172.28.23.131:8008','http://mms.t-mobile.de/servlets/mms',150,0,0,NULL,0,NULL,NULL,21,2, 0, 1, 0);
+@@ -91,5 +92,7 @@ INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, au
+ INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(59, 'T Mobile MMS','general.t-mobile.uk',1,'user','tm',1,'149.254.201.135:8080','http://mmsc.t-mobile.co.uk:8002',300, 0,0,NULL,0,NULL,NULL,28,2, 0, 1, 0);
+ INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(60, 'T Mobile Internet','internet',0,NULL,NULL,1,NULL,NULL,300, 0,0,NULL,0,NULL,NULL,29,1,0,1,1);
+ INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(61, 'T Mobile MMS','mms',0,NULL,NULL,1,'213.158.194.226:8080','http://mms/servlets/mms',300, 0,0,NULL,0,NULL,NULL,29,2, 0, 1, 0);
++INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(62, 'Bouygues Internet',NULL,0,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,30,1,0,1,1);
++INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)      VALUES(63, 'Bouygues MMS','mms.bouygtel.com',1,NULL,NULL,1,'62.201.129.226:8080','http://mms.bouyguestelecom.fr/mms/wapenc',300,0,0,NULL,0,NULL,NULL,30,2, 0, 1, 0);
+-- 
+1.7.10.4
+
diff --git a/packaging/0003-context-Fix-context-creation-issue.patch b/packaging/0003-context-Fix-context-creation-issue.patch
new file mode 100644 (file)
index 0000000..4633937
--- /dev/null
@@ -0,0 +1,64 @@
+From bc75ead8cdd5510afbdceb3627573331c699dae6 Mon Sep 17 00:00:00 2001
+From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
+Date: Tue, 23 Oct 2012 14:30:17 +0200
+Subject: [PATCH 3/3] context: Fix context creation issue
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+New internet context is always set as default internet connection.
+Check proxy_addr formatting before filling in data base.
+---
+ src/context.c |   23 ++++++++++++++++++++++-
+ 1 file changed, 22 insertions(+), 1 deletion(-)
+
+diff --git a/src/context.c b/src/context.c
+index db775a8..152db83 100644
+--- a/src/context.c
++++ b/src/context.c
+@@ -881,6 +881,19 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
+       }
++      /*
++       * Whether a profile is created with no proxy address and port,
++       * settings application is passing ':' as proxy_addr value.
++       * Checking proxy _address creation on application is needed, but
++       * address:port formatting is also double check in packet service
++       * telephony plugin.
++       */
++      if (g_strcmp0(proxy_addr, ":") == 0) {
++              dbg("Invalid proxy address, set it to NULL");
++              g_free(proxy_addr);
++              proxy_addr = NULL;
++      }
++
+       dbg("apn (%s), auth_type (%s), auth_id(%s), auth_pwd(%s), proxy_addr(%s), home_url(%s), svc_id(%s)",
+               apn, auth_type, auth_id, auth_pwd, proxy_addr, home_url, svc_id);
+@@ -899,7 +912,7 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
+       strcat(szQuery," network_info_id, svc_category_id, hidden, editable, default_internet_con) values( ");
+       strcat(szQuery," ?, ?, ?, ?, ?, ?,");//1,2,3,4,5,6
+       strcat(szQuery," 1, ?, ?, 300,");//7,8
+-      strcat(szQuery," ?, ?, 0, 1, 0)");//9,10
++      strcat(szQuery," ?, ?, 0, 1, ?)");//9,10,11
+       insert_key1 = g_strdup_printf("%d", profile_id);
+       insert_key2 = g_strdup_printf("%d", network_id);
+@@ -924,6 +937,14 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
+       g_hash_table_insert(in_param, "9", g_strdup(insert_key2));
+       g_hash_table_insert(in_param, "10", g_strdup(svc_id));
++      /* If profile received is Internet type */
++      if (g_strcmp0(svc_id, "1") == 0) {
++              dbg("Set new internet profile as default Internet connection");
++              g_hash_table_insert(in_param, "11", g_strdup("1"));
++      /* Profile is MMS or other type don't set it as default */
++      } else
++              g_hash_table_insert(in_param, "11", g_strdup("0"));
++
+       g_free(insert_key1);g_free(insert_key2);g_free(profile_name);
+       g_free(apn);g_free(auth_type);g_free(auth_id);g_free(auth_pwd);
+       g_free(proxy_addr);g_free(home_url);g_free(svc_id);
+-- 
+1.7.10.4
+
diff --git a/packaging/tel-plugin-packetservice.spec b/packaging/tel-plugin-packetservice.spec
new file mode 100644 (file)
index 0000000..8dc48c4
--- /dev/null
@@ -0,0 +1,82 @@
+#sbs-git:slp/pkgs/t/tel-plugin-packetservice
+Name:       tel-plugin-packetservice
+Summary:    Telephony Packet Service library
+Version: 0.1.36
+Release:    1
+Group:      System/Libraries
+License:    Apache
+Source0:    tel-plugin-packetservice-%{version}.tar.gz
+%ifarch %ix86
+%if "%{simulator}" != "1"
+patch0: 0001-main-Create-modems-only-when-one-modem-is-added.patch
+patch1: 0002-dnet_db_data-Change-SFR-internet-APN-and-add-Bouygue.patch
+patch2: 0003-context-Fix-context-creation-issue.patch
+%endif
+%endif
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(dbus-glib-1)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(tcore)
+BuildRequires:  pkgconfig(iniparser)
+
+%description
+Telephony Packet Service library
+
+%prep
+%setup -q
+%ifarch %ix86
+%if "%{simulator}" != "1"
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%endif
+%endif
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DSYSCONFDIR=%{_sysconfdir}
+make %{?jobs:-j%jobs}
+
+%post 
+/sbin/ldconfig
+
+#create db
+mkdir -p /opt/dbspace
+
+if [ ! -f /opt/dbspace/.dnet.db ]
+then
+  sqlite3 /opt/dbspace/.dnet.db < /usr/share/ps-plugin/dnet_db.sql
+  sqlite3 /opt/dbspace/.dnet.db < /usr/share/ps-plugin/dnet_db_data.sql
+fi
+
+rm -f /usr/share/ps-plugin/dnet_db.sql
+rm -f /usr/share/ps-plugin/dnet_db_data.sql
+
+#change file permission
+if [ -f /opt/dbspace/.dnet.db ]
+then
+       chmod 660 /opt/dbspace/.dnet.db
+fi
+
+if [ -f /opt/dbspace/.dnet.db-journal ]
+then
+       chmod 664 /opt/dbspace/.dnet.db-journal
+fi
+
+%postun -p /sbin/ldconfig
+
+%install
+%make_install
+mkdir -p %{buildroot}/usr/share/license
+
+%files
+%manifest tel-plugin-packetservice.manifest
+%defattr(-,root,root,-)
+#%doc COPYING
+/usr/share/ps-plugin/dnet_db.sql
+/usr/share/ps-plugin/dnet_db_data.sql
+%{_sysconfdir}/dbus-1/system.d/*
+%{_libdir}/telephony/plugins/ps-plugin*
+/usr/share/license/tel-plugin-packetservice
diff --git a/resources/dnet_db.sql b/resources/dnet_db.sql
new file mode 100644 (file)
index 0000000..9f618cb
--- /dev/null
@@ -0,0 +1,69 @@
+PRAGMA journal_mode = PERSIST;
+                                      
+DROP TABLE IF EXISTS "fd_blacklist";
+CREATE TABLE fd_blacklist(
+       plmn    INTEGER
+);
+
+DROP TABLE IF EXISTS "network_info";
+CREATE TABLE network_info(
+       network_info_id INTEGER PRIMARY KEY,
+       network_name TEXT,
+       mccmnc TEXT
+       );
+
+DROP TABLE IF EXISTS "fast_dormancy";
+CREATE TABLE fast_dormancy(
+       dormant_id      INTEGER PRIMARY KEY,
+       network_info_id INTEGER UNIQUE,
+       lcd_on_timeout INTEGER,
+       lcd_off_timeout INTEGER
+  );
+
+DROP TABLE IF EXISTS "max_pdp";
+CREATE TABLE max_pdp(
+       max_id  INTEGER PRIMARY KEY,
+       network_info_id INTEGER UNIQUE,
+       max_pdp_3g INTEGER
+  );
+  
+DROP TABLE IF EXISTS "pdp_profile";
+CREATE TABLE pdp_profile(
+       profile_id      INTEGER PRIMARY KEY,
+       profile_name    TEXT,
+       apn     TEXT,
+       auth_type       INTEGER,
+       auth_id TEXT,
+       auth_pwd        TEXT,
+       pdp_protocol    INTEGER,
+       proxy_ip_addr   TEXT,
+       home_url        TEXT,
+       linger_time     INTEGER,
+       traffic_class   INTEGER,
+       is_static_ip_addr       INTEGER,
+       ip_addr TEXT,
+       is_static_dns_addr      INTEGER,
+       dns_addr1       TEXT,
+       dns_addr2       TEXT,
+       network_info_id INTEGER,
+       svc_category_id INTEGER,
+       hidden  INTEGER,
+       editable        INTEGER,
+       default_internet_con    INTEGER
+       );
+
+DROP TABLE IF EXISTS "svc_category";
+CREATE TABLE svc_category(
+       svc_category_id INTEGER PRIMARY KEY,
+       svc_name        TEXT
+       );
+       
+INSERT INTO "svc_category" VALUES(0,'LTE IMS');
+INSERT INTO "svc_category" VALUES(1,'internet');
+INSERT INTO "svc_category" VALUES(2,'mms');
+INSERT INTO "svc_category" VALUES(3,'prepaid internet');
+INSERT INTO "svc_category" VALUES(4,'prepaid mms');
+INSERT INTO "svc_category" VALUES(5,'tethering');
+INSERT INTO "svc_category" VALUES(6,'user defined');
+
+CREATE INDEX pdp_profile_ix_1 ON pdp_profile (network_info_id);
diff --git a/resources/dnet_db_data.sql b/resources/dnet_db_data.sql
new file mode 100644 (file)
index 0000000..3844a63
--- /dev/null
@@ -0,0 +1,95 @@
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (1, 'Samsung 3G', '45001');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (2, 'Vodafone.de', '26202');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (3, 'Vodafone.uk', '23415');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (4, 'O2 UK', '23410');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (5, 'Movistar', '21407');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (6, 'Orange ES', '21403');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (7, 'Orange UK', '23433');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (8, 'Orange FR', '20801');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (9, 'ATnT', '31041');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (10, 'Airtel India', '40445');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (11, 'Vodafone India', '40486');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (12, 'China Unicom', '46001');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (13, 'BSNL', '40471');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (14, 'Vodafone India Delhi', '40411');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (15, 'Airtel India Delhi', '40410');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (16, 'E Plus', '26203');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (17, 'Vodafone ES', '21401');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (18, 'Orange DE', '26207');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (19, 'SKT', '45005');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (20, 'F SFR', '20810');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (21, 'T Mobile DE', '26201');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (22, 'NTT Docomo JP', '44010');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (23, 'KT', '45008');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (24, 'play', '26006');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (25, 'Plus GSM', '26001');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (26, 'T Mobile US', '31026');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (27, 'Tizen', '11111');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (28, 'T Mobile UK', '23430');
+INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (29, 'T Mobile PL', '26002');
+
+INSERT INTO "max_pdp"(network_info_id, max_pdp_3g) VALUES(1, 2);
+INSERT INTO "max_pdp"(network_info_id, max_pdp_3g) VALUES(2, 3);
+
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(1, 'Samsung3G','nate.sktelecom.com',0,NULL,NULL,1,'168.219.61.250:8080','http://www.samsung.com',300, 0,0,NULL,0,NULL,NULL,1,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(2, 'Samsung3G MMS','nate.sktelecom.com',0,NULL,NULL,1,'165.213.73.234:7082','http://165.213.73.234:7082/01030016056=01030016056',300, 0,0,NULL,0,NULL,NULL,1,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(3, 'Voda DE Web','web.vodafone.de',0,NULL,NULL,1,NULL,'http://www.vodafone.de',300, 0,0,NULL,0,NULL,NULL,2,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(4, 'Voda DE MMS','event.vodafone.de',0,NULL,NULL,1,'139.7.29.17:80','http://139.7.24.1/servlets/mms',300, 0,0,NULL,0,NULL,NULL,2,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(5, 'Voda DE Wap','wap.vodafone.de',0,NULL,NULL,1,'139.7.29.1:80','http://live.vodafone.com',300, 0,0,NULL,0,NULL,NULL,2,5, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(6, 'Voda UK 3G','internet',0,'wap','wap',1,NULL,NULL,300, 0,0,NULL,0,NULL,NULL,3,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(7, 'Voda UK MMS','wap.vodafone.co.uk',0,'wap','wap',1,'212.183.137.12:8799','http://mms.vodafone.co.uk/servlets/mms',300, 0,0,NULL,0,NULL,NULL,3,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(9, 'O2 UK Web','mobile.o2.co.uk',0,'o2web','password',1,NULL,'',120,0,0,NULL,0,NULL,NULL,4,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(10, 'O2 UK MMS','wap.o2.co.uk',0,'o2wap','password',1,'193.113.200.195:8080','http://mmsc.mms.o2.co.uk:8002',120,0,0,NULL,0,NULL,NULL,4,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(11, 'Movistar 3G','movistar.es',1,'movistar','movistar',1,NULL,'http://wap.movistar.com',300, 0,0,NULL,0,NULL,NULL,5,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(12, 'Movista MMS','mms.movistar.es',1,'MOVISTAR@mms','MOVISTAR',1,'10.138.255.5:8080','http://mms.movistar.com',300, 0,0,NULL,0,NULL,NULL,5,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(13, 'Orange Internet','internet',1,'orange','orange',1,NULL,'http://www.orange.es',300, 0,0,NULL,0,NULL,NULL,6,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(14, 'Orange MMS','orangemms',1,'orange','orange',1,'172.22.188.25:8080','http://mms.orange.es',300, 0,0,NULL,0,NULL,NULL,6,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(15, 'Orange World','orangeworld',1,'orange','orange',1,'10.132.61.10:8080','http://wap.orange.es',300, 0,0,NULL,0,NULL,NULL,6,5, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(16, 'Orange Internet','orangeinternet',1,NULL,NULL,1,NULL,'http://orangeworld.co.uk/',300, 0,0,NULL,0,NULL,NULL,7,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(17, 'Orange MMS','orangemms',1,NULL,NULL,1,'192.168.224.10:8080','http://mms.orange.co.uk/',300, 0,0,NULL,0,NULL,NULL,7,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(18, 'Orange world','orange',1,'orange','orange',1,NULL,'http://www.orange.fr/',0,0,0,NULL,0,NULL,NULL,8,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(19, 'Orange MMS','orange.acte',1,'orange','orange',1,'192.168.10.200:8080','http://mms.orange.fr/',300, 0,0,NULL,0,NULL,NULL,8,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(20, 'ATnT ISP','wap.cingular',0,NULL,NULL,1,'wireless.cingular.com:80',NULL,0,0,0,NULL,0,NULL,NULL,9,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(21, 'ATnT MMS','wap.cingular',0,NULL,NULL,1,'wireless.cingular.com:80','http://mmsc.cingular.com/',0,0,0,NULL,0,NULL,NULL,9,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(22, 'Airtel India','airtelgprs.com',0,NULL,NULL,1,NULL,'http://airtel.in',0,0,0,NULL,0,NULL,NULL,10,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(23, 'Airtel MMS','airtelmms.com',0,NULL,NULL,1,'100.1.201.172:8799','http://100.1.201.171:10021/mmsc',0,0,0,NULL,0,NULL,NULL,10,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(24, 'Vodafone India 3G','www',0,NULL,NULL,1,NULL,'http://www.vodafone.in',0,0,0,NULL,0,NULL,NULL,11,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(25, 'Vodadone India MMS','portalnmms',0,NULL,NULL,1,'10.10.1.100:9401','http://mms1.live.vodafone.in/mms/',0,0,0,NULL,0,NULL,NULL,11,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(26, 'China Unicom 3G','uninet',0,NULL,NULL,1,NULL,'http://www.wo.com.cn',0,0,0,NULL,0,NULL,NULL,12,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(27, 'China Unicom MMS','3gwap',0,NULL,NULL,1,'10.0.0.172:80','http://mmsc.myuni.com.cn',0,0,0,NULL,0,NULL,NULL,12,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(28, 'BSNL 3G India','gprssouth.cellone.in',0,'ppp','ppp123',1,NULL,'http://www.bsnl.co.in',300,0,0,NULL,0,NULL,NULL,13,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(29, 'BSNL India MMS','bsnlmms',0,NULL,NULL,1,'10.210.10.11:8080','http://bsnlmmsc.in:8514',0,0,0,NULL,0,NULL,NULL,13,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(30, 'Vodafone 3G India Delhi','portalnmms',0,NULL,NULL,1,'10.10.1.100:9401','http://www.vodafone.in',0,0,0,NULL,0,NULL,NULL,14,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(31, 'Vodafone India Delhi MMS','portalnmms',0,NULL,NULL,1,'10.10.1.100:9401','http://mms1.live.vodafone.in/mms/',0,0,0,NULL,0,NULL,NULL,14,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(32, 'Airtel 3G India Delhi','airtelgprs.com',0,NULL,NULL,1,'100.1.200.99:8080','http://airtel.in',0,0,0,NULL,0,NULL,NULL,15,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(33, 'Airtel India Delhi MMS','airtelmms.com',0,NULL,NULL,1,'100.1.201.172:8799','http://100.1.201.171:10021/mmsc',0,0,0,NULL,0,NULL,NULL,15,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(34, 'E Plus 3G','internet.eplus.de',1,'eplus','internet',1,NULL,NULL,60,0,0,NULL,0,'212.23.97.2','212.23.97.3',16,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(35, 'E Plus MMS','mms.eplus.de',1,'mms','eplus',1,'212.23.97.153:5080','http://mms/eplus',60,0,0,NULL,0,NULL,NULL,16,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(36, 'Voda ES Web','airtelnet.es',0,'vodafone','vodafone',1,NULL,'http://www.vodafone.es',300,0,0,NULL,0,NULL,NULL,17,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(37, 'Voda ES MMS','mms.vodafone.net',0,'wap@wap','wap125',1,'212.73.32.10:80','http://www.vodafone.es',300, 0,0,NULL,0,NULL,NULL,17,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(38, 'O2 Internet','internet',0,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,18,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(39, 'O2 MMS','internet',0,NULL,NULL,1,'82.113.100.5:8080','http://10.81.0.7:8002',300,0,0,NULL,0,NULL,NULL,18,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(40, 'SKT Internet','web.sktelecom.com',0,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,19,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(41, 'SKT MMS','web.sktelecom.com',0,NULL,NULL,0,'220.103.230.150:9093','http://omms.nate.com:9082/oma_mms',300, 0,0,NULL,0,NULL,NULL,19,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(42, 'SFR Internet','sl2sfr',1,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,20,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(43, 'SFR MMS','mmssfr',1,NULL,NULL,1,'10.151.0.1:8080','http://mms1',300,0,0,NULL,0,NULL,NULL,20,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(44, 'T Mobile Internet','internet.t-mobile',1,'t-mobile','tm',1,NULL,NULL,150,0,0,NULL,0,NULL,NULL,21,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(45, 'T Mobile MMS','internet.t-mobile',1,'t-mobile','tm',1,'172.28.23.131:8008','http://mms.t-mobile.de/servlets/mms',150,0,0,NULL,0,NULL,NULL,21,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(46, 'NTT Docomo JP','spmode.ne.jp',0,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,22,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(47, 'NTT Docomo JP','mopera.net',0,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,22,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(48, 'KT Internet','default.ktfwing.com',0,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,23,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(49, 'KT MMS','default.ktfwing.com',0,NULL,NULL,1,NULL,'http://mmsc.ktfwing.com:9082',300,0,0,NULL,0,NULL,NULL,23,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(50, 'Play Internet','internet',0,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,24,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(51, 'Play MMS','mms',0,NULL,NULL,1,'10.10.25.5:8080','http://10.10.28.164/mms/wapenc',300,0,0,NULL,0,NULL,NULL,24,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(52, 'Plus GSM Internet','www.plusgsm.pl',0,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,25,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(53, 'Plus GSM MMS','mms.plusgsm.pl',0,NULL,NULL,1,'212.2.96.16:8080','http://mms.plusgsm.pl:8002',300,0,0,NULL,0,NULL,NULL,25,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(54, 'T Mobile Internet','epc.tmobile.com',0,NULL,NULL,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,26,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(55, 'T Mobile MMS','epc.tmobile.com',0,NULL,NULL,1,NULL,'http://mms.msg.english.t-mobile.com/mms/wapenc',300,0,0,NULL,0,NULL,NULL,26,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(56, 'Tizen Internet','emul.tizen.com',0,NULL,NULL,1,NULL,'http://www.samsung.com',300, 0,0,NULL,0,NULL,NULL,27,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(57, 'Tizen3G MMS','emul.tizen.com',0,NULL,NULL,1,NULL,'http://tizen.mms.server.com',300, 0,0,NULL,0,NULL,NULL,27,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(58, 'T Mobile Internet','general.t-mobile.uk',1,'user','tm',1,NULL,'http://www.t-mobile-favourites.co.uk',300, 0,0,NULL,0,NULL,NULL,28,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(59, 'T Mobile MMS','general.t-mobile.uk',1,'user','tm',1,'149.254.201.135:8080','http://mmsc.t-mobile.co.uk:8002',300, 0,0,NULL,0,NULL,NULL,28,2, 0, 1, 0);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(60, 'T Mobile Internet','internet',0,NULL,NULL,1,NULL,NULL,300, 0,0,NULL,0,NULL,NULL,29,1,0,1,1);
+INSERT INTO "pdp_profile" (profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time, traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id, hidden, editable, default_internet_con)       VALUES(61, 'T Mobile MMS','mms',0,NULL,NULL,1,'213.158.194.226:8080','http://mms/servlets/mms',300, 0,0,NULL,0,NULL,NULL,29,2, 0, 1, 0);
+
+
diff --git a/src/context.c b/src/context.c
new file mode 100644 (file)
index 0000000..db775a8
--- /dev/null
@@ -0,0 +1,1715 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 "ps-context.h"
+
+#include "ps.h"
+#include "ps-error.h"
+
+#include <tcore.h>
+#include <plugin.h>
+#include <server.h>
+#include <storage.h>
+#include <core_object.h>
+#include <co_context.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <iniparser.h>
+
+#define PROP_DEFAULT           FALSE
+#define PROP_DEFAULT_STR       NULL
+#define BOOL2STRING(a)         ((a==TRUE) ? ("TRUE"):("FALSE"))
+#define DATABASE_PATH          "/opt/dbspace/.dnet.db"
+
+/*Properties*/
+enum {
+       PROP_CONTEXT_O,
+
+       PROP_CONTEXT_PATH,
+       PROP_CONTEXT_CONN,
+       PROP_CONTEXT_PLUGIN,
+       PROP_CONTEXT_MCCMNC
+};
+
+enum {
+       SIG_CONTEXT_PROPERTY_CHANGED,
+       SIG_CONTEXT_LAST
+};
+
+static guint32 signals[SIG_CONTEXT_LAST] = { 0, };
+
+struct PsContextClass {
+       GObjectClass parent;
+
+       //method and signals
+       void (*property_changed)(PsContext *context, GHashTable *context_property);
+};
+
+struct PsContext {
+       GObject parent;
+
+       gchar* path;
+       gchar* mccmnc;
+       DBusGConnection *conn;
+       TcorePlugin *plg;
+
+       gboolean alwayson;
+       gboolean default_internet;
+       gboolean hidden;
+       gboolean editable;
+       gboolean ps_defined;
+       gpointer p_service;
+       int profile_id;
+       CoreObject *co_context;
+};
+
+static Storage *strg_db;
+static gpointer handle;
+static GHashTable *contexts;
+
+G_DEFINE_TYPE(PsContext, ps_context, G_TYPE_OBJECT);
+
+static void     __ps_context_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+static void     __ps_context_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+
+gboolean        ps_iface_context_get_properties(PsContext *pscontext, DBusGMethodInvocation *context);
+gboolean        ps_iface_context_get_profile(PsContext *pscontext, DBusGMethodInvocation *context);
+gboolean        ps_iface_context_activate(PsContext *pscontext, DBusGMethodInvocation *context);
+gboolean        ps_iface_context_deactivate(PsContext *pscontext, DBusGMethodInvocation *context);
+gboolean        ps_iface_context_set_default_connection(PsContext *pscontext, gboolean* result, GError **error);
+gboolean        ps_iface_context_modify_profile(PsContext *pscontext, GHashTable *profile_property, gboolean* result, GError **error);
+gboolean        ps_iface_context_remove_profile(PsContext *pscontext, gboolean* result, GError **error);
+
+static void     __ps_context_emit_property_changed_signal(PsContext *context);
+
+static void     __remove_context(gpointer data);
+static gboolean __remove_contexts(gpointer key, gpointer value, gpointer user_data);
+static gboolean __ps_context_remove_context(gpointer context);
+static gboolean __ps_context_create_storage_handle(gpointer plugin);
+static gboolean __ps_context_create_context_hash(void);
+static gchar*   __ps_context_create_path(char *profile_name, int profile_id, int svc_ctg_id);
+static gboolean __ps_context_create_co_context(gpointer context, GHashTable *property);
+static gboolean __ps_context_update_profile(PsContext *context, GHashTable *property);
+static gboolean __ps_context_update_database(PsContext *context);
+static gboolean __ps_context_update_default_internet_to_db(PsContext *context, gboolean enabled);
+static gboolean __ps_context_remove_database(PsContext *context);
+static int      __ps_context_insert_network_id_to_database(gchar *mccmnc);
+static int      __ps_context_load_network_id_from_database(gchar *mccmnc);
+static gchar*   __ps_context_load_network_name_from_database(int network_id);
+static int      __ps_context_load_profile_id_from_database(void);
+static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int index);
+static int      __ps_context_insert_profile_to_database(GHashTable *property, int network_id);
+static int      __ps_context_get_network_id(gchar *mccmnc);
+static gboolean __ps_context_get_profile_properties(gpointer context, GHashTable *properties);
+static gboolean __ps_context_set_default_connection_enable(gpointer object, gboolean enabled);
+
+#include "ps-iface-context-glue.h"
+
+static void ps_context_init(PsContext *context)
+{
+       dbg("context initialize");
+
+       context->path = NULL;
+       context->mccmnc = NULL;
+       context->conn = NULL;
+       context->plg = NULL;
+
+       context->alwayson = PROP_DEFAULT;
+       context->default_internet = PROP_DEFAULT;
+       context->hidden = PROP_DEFAULT;
+       context->editable = PROP_DEFAULT;
+       context->p_service = NULL;
+       context->profile_id = 0;
+       context->co_context = NULL;
+
+       return;
+}
+
+static void ps_context_class_init(PsContextClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+       //class init
+       dbg("context class init");
+
+       object_class->get_property = __ps_context_get_property;
+       object_class->set_property = __ps_context_set_property;
+
+       //dbus register
+       dbus_g_object_type_install_info(PS_TYPE_CONTEXT, &dbus_glib_ps_iface_context_object_info);
+
+       //property add
+       g_object_class_install_property(
+                       object_class,
+                       PROP_CONTEXT_CONN,
+                       g_param_spec_boxed("conn", "CONNECTION", "DBus connection", DBUS_TYPE_G_CONNECTION,
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+       g_object_class_install_property(
+                       object_class,
+                       PROP_CONTEXT_PATH,
+                       g_param_spec_string("path", "PATH", "Context Path", PROP_DEFAULT_STR,
+                                       G_PARAM_READWRITE));
+       g_object_class_install_property(
+                       object_class,
+                       PROP_CONTEXT_MCCMNC,
+                       g_param_spec_string("mccmnc", "MCCMNC", "Profile Country and Context Provider Code",
+                                       PROP_DEFAULT_STR, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+       g_object_class_install_property(
+                       object_class,
+                       PROP_CONTEXT_PLUGIN,
+                       g_param_spec_pointer("plg", "PLUGIN", "Plug in Object",
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       //add signal handler
+       signals[SIG_CONTEXT_PROPERTY_CHANGED] = g_signal_new("property-changed",
+                       G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST,
+                       G_STRUCT_OFFSET(PsContextClass, property_changed), NULL, NULL,
+                       g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, DBUS_TYPE_G_STRING_STRING_HASHTABLE);
+
+       return;
+}
+
+static void __ps_context_set_property(GObject *object, guint prop_id, const GValue *value,
+               GParamSpec *pspec)
+{
+       PsContext *context = PS_CONTEXT(object);
+
+       switch (prop_id) {
+               case PROP_CONTEXT_CONN: {
+                       context->conn = g_value_get_boxed(value);
+                       msg("context (%p) set conn(%p)", context, context->conn);
+               }
+                       break;
+               case PROP_CONTEXT_PLUGIN: {
+                       context->plg = g_value_get_pointer(value);
+                       msg("context (%p) set plg(%p)", context, context->plg);
+               }
+                       break;
+               case PROP_CONTEXT_PATH: {
+                       if (context->path) {
+                               g_free(context->path);
+                       }
+                       context->path = g_value_dup_string(value);
+                       msg("context (%p) path(%s)", context, context->path);
+               }
+                       break;
+               case PROP_CONTEXT_MCCMNC: {
+                       if (context->mccmnc) {
+                               g_free(context->mccmnc);
+                       }
+                       context->mccmnc = g_value_dup_string(value);
+                       msg("context (%p) mccmnc(%s)", context, context->mccmnc);
+               }
+                       break;
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+                       break;
+       } //end of switch
+
+       return;
+}
+
+static void __ps_context_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+       return;
+}
+
+static void __ps_context_emit_property_changed_signal(PsContext *context)
+{
+       GHashTable *property;
+
+       property = g_hash_table_new(g_str_hash, g_str_equal);
+       _ps_context_get_properties(context, property);
+       g_signal_emit(context, signals[SIG_CONTEXT_PROPERTY_CHANGED], 0, property);
+       g_hash_table_destroy(property);
+       dbg("context (%p) emit the context property changed signal", context);
+       return;
+}
+
+gboolean ps_iface_context_get_properties(PsContext *pscontext, DBusGMethodInvocation *context)
+{
+       GHashTable *property;
+
+       dbg("Get properties of context(%s)", _ps_context_ref_path(pscontext));
+       property = g_hash_table_new(g_str_hash, g_str_equal);
+       _ps_context_get_properties(pscontext, property);
+
+       dbus_g_method_return(context, property);
+       g_hash_table_destroy(property);
+       return TRUE;
+}
+
+gboolean ps_iface_context_get_profile(PsContext *pscontext, DBusGMethodInvocation *context)
+{
+       GHashTable *profile;
+
+       dbg("Get profile properties of context(%s)", _ps_context_ref_path(pscontext));
+       profile = g_hash_table_new(g_str_hash, g_str_equal);
+       __ps_context_get_profile_properties(pscontext, profile);
+
+       dbus_g_method_return(context, profile);
+       g_hash_table_destroy(profile);
+       return TRUE;
+}
+
+gboolean ps_iface_context_activate(PsContext *pscontext, DBusGMethodInvocation *context)
+{
+       int rv = 0;
+       int context_state = 0;
+       GError *error = NULL;
+
+       dbg("activate context(%s)", _ps_context_ref_path(pscontext));
+
+       /*support always on connection*/
+       _ps_context_set_alwayson_enable(pscontext, TRUE);
+       _ps_service_reset_connection_timer(pscontext);
+
+       rv = _ps_service_activate_context(pscontext->p_service, pscontext);
+       if (rv != TCORE_RETURN_SUCCESS) {
+               dbg("fail to activate context connection");
+               g_set_error(&error, PS_ERROR, PS_ERR_TRASPORT, "fail to activate context err(%d)", rv);
+               goto FAIL;
+       }
+
+       dbg("success to activate context");
+       dbus_g_method_return(context, pscontext->path);
+
+       context_state = tcore_context_get_state(pscontext->co_context);
+       if (context_state == CONTEXT_STATE_ACTIVATED) {
+               dbg("context is already connected");
+               _ps_context_set_connected(pscontext, TRUE);
+       }
+
+       return TRUE;
+
+FAIL:
+       dbus_g_method_return_error(context, error);
+       return TRUE;
+}
+
+gboolean ps_iface_context_deactivate(PsContext *pscontext, DBusGMethodInvocation *context)
+{
+       int rv = 0;
+       int context_state = 0;
+       GError *error = NULL;
+
+       dbg("deactivate context(%s)", _ps_context_ref_path(pscontext));
+
+       _ps_service_reset_connection_timer(pscontext);
+       _ps_context_set_alwayson_enable(pscontext, FALSE);
+       rv = _ps_service_deactivate_context(pscontext->p_service, pscontext);
+       if (rv != TCORE_RETURN_SUCCESS) {
+               dbg("fail to deactivate context connection");
+               g_set_error(&error, PS_ERROR, PS_ERR_TRASPORT, "fail to deactivate context err(%d)", rv);
+               goto FAIL;
+       }
+
+       dbg("success to deactivate context");
+       dbus_g_method_return(context, pscontext->path);
+
+       context_state =  tcore_context_get_state(pscontext->co_context);
+       if (context_state == CONTEXT_STATE_DEACTIVATED) {
+               dbg("context is already disconnected");
+               _ps_context_set_connected(pscontext, FALSE);
+       }
+
+       return TRUE;
+
+FAIL:
+       dbus_g_method_return_error(context, error);
+       return TRUE;
+}
+
+gboolean ps_iface_context_set_default_connection(PsContext *pscontext, gboolean* result, GError **error)
+{
+/*
+ * if current default and target profile is the same, just return success
+ *
+ * in different case, current connection should be diconnected, and trying to connection new one
+ */
+       int role = CONTEXT_ROLE_UNKNOWN;
+       gpointer cur_default_ctx = NULL;
+       gpointer service = NULL;
+
+       role = tcore_context_get_role(pscontext->co_context);
+       if(role != CONTEXT_ROLE_INTERNET){
+               dbg("only internet profile type can be set to default internet profile");
+               *result = FALSE;
+               return TRUE;
+       }
+
+       service = pscontext->p_service;
+       cur_default_ctx = _ps_service_return_default_context(service);
+
+       dbg("default ctx(%p), request ctx(%p)", cur_default_ctx, pscontext);
+       if(cur_default_ctx == pscontext){
+               dbg("already default internet connection");
+               *result = TRUE;
+               return TRUE;
+       }
+
+       //unset current profile
+       _ps_context_set_alwayson_enable(cur_default_ctx, FALSE);
+       __ps_context_set_default_connection_enable(cur_default_ctx, FALSE);
+       //disconnect connection
+       _ps_service_deactivate_context(((PsContext *)cur_default_ctx)->p_service, cur_default_ctx);
+       //db update - release default connection
+       __ps_context_update_default_internet_to_db((PsContext *)cur_default_ctx, FALSE);
+
+       //db update - set default connection
+       __ps_context_update_default_internet_to_db(pscontext, TRUE);
+       //set request profile
+       __ps_context_set_default_connection_enable(pscontext, TRUE);
+       _ps_context_set_alwayson_enable(pscontext, TRUE);
+       //request to connect
+       _ps_service_connect_default_context(pscontext->p_service);
+       dbg("complete to change the default connection");
+
+       *result = TRUE;
+       return TRUE;
+}
+
+gboolean ps_iface_context_modify_profile(PsContext *context, GHashTable *profile_property,
+               gboolean* result, GError **error)
+{
+       gboolean rv = FALSE;
+       int context_state = 0;
+
+       *result = TRUE;
+       dbg("modify context's profile properties");
+
+       rv = __ps_context_update_profile(context, profile_property);
+       if (rv != TRUE) {
+               g_set_error(error, PS_ERROR, PS_ERR_INTERNAL, "fail to modify profile");
+               *result = FALSE;
+               return TRUE;
+       }
+
+       context_state = tcore_context_get_state(context->co_context);
+       if (context_state == CONTEXT_STATE_DEACTIVATED)
+               return TRUE;
+
+       _ps_service_deactivate_context(context->p_service, context);
+       context_state = tcore_context_get_state(context->co_context);
+       if (context_state == CONTEXT_STATE_DEACTIVATED) {
+               dbg("context is already disconnected");
+               _ps_context_set_connected(context, FALSE);
+       }
+
+       return TRUE;
+}
+
+gboolean ps_iface_context_remove_profile(PsContext *context, gboolean* result, GError **error)
+{
+       gchar* ctx_path = NULL;
+       gboolean rv = FALSE;
+
+       ctx_path = g_strdup(_ps_context_ref_path(context));
+
+       __ps_context_remove_database(context);
+       rv = __ps_context_remove_context(context);
+       g_hash_table_remove(contexts, ctx_path);
+
+       *result = rv;
+       g_free(ctx_path);
+       return TRUE;
+}
+
+static void __remove_context(gpointer data)
+{
+       dbg("context removed");
+       return;
+}
+
+static gboolean __remove_contexts(gpointer key, gpointer value, gpointer user_data)
+{
+       gchar *context_path = (gchar *) key;
+       dbg("context(%s) remove", context_path);
+       __ps_context_remove_context(value);
+       return TRUE;
+}
+
+gboolean _ps_context_remove_context(gpointer context)
+{
+       dbus_g_connection_unregister_g_object(((PsContext *)context)->conn, (GObject *) context);
+       g_hash_table_remove(contexts, _ps_context_ref_path(context));
+       g_object_unref(context);
+       return TRUE;
+}
+
+static gboolean __ps_context_remove_context(gpointer context)
+{
+       dbg("remove context and profile");
+
+       _ps_service_reset_connection_timer(context);
+
+       dbus_g_connection_unregister_g_object(((PsContext *)context)->conn, (GObject *) context);
+
+       _ps_context_set_alwayson_enable(context, FALSE);
+       _ps_service_deactivate_context(((PsContext *)context)->p_service, context);
+       _ps_context_set_connected(context, FALSE);
+       _ps_service_unref_context(((PsContext *)context)->p_service, context);
+
+       tcore_context_free(((PsContext *)context)->co_context);
+       g_object_unref(context);
+
+       return TRUE;
+}
+
+static gboolean __ps_context_create_storage_handle(gpointer plugin)
+{
+       TcorePlugin *p = plugin;
+       Server *s = tcore_plugin_ref_server(p);
+       strg_db = tcore_server_find_storage(s, "database");
+
+       handle = tcore_storage_create_handle(strg_db, DATABASE_PATH);
+       if (!handle)
+               err("fail to create database handle");
+
+       dbg("storage(%p) handle (%p)", strg_db, handle);
+       return TRUE;
+}
+
+static gboolean __ps_context_create_context_hash()
+{
+       g_return_val_if_fail(contexts == NULL, FALSE);
+
+       contexts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, __remove_context);
+       if (contexts == NULL) {
+               err("fail to create context hashtable");
+               return FALSE;
+       }
+
+       dbg("context hashtable(%p)", contexts);
+       return TRUE;
+}
+
+static gchar* __ps_context_create_path(char *profile_name, int profile_id, int svc_ctg_id)
+{
+       gchar **strv, *str, *path;
+       gchar *delimiters = " !\"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~";
+
+       strv = g_strsplit_set(profile_name, delimiters, -1);
+       str = g_strjoinv("_", strv);
+       dbg("converted string %s", str);
+       path = g_strdup_printf("/context/%s_%d_%d", str, profile_id, svc_ctg_id);
+       g_strfreev(strv);
+       g_free(str);
+       dbg("path (%s)", path);
+
+       return path;
+}
+
+static gboolean __ps_context_create_co_context(gpointer object, GHashTable *property)
+{
+       GHashTableIter iter;
+       gpointer key, value;
+       PsContext *context = NULL;
+       CoreObject *co_context = NULL;
+
+       gchar *path = NULL;
+       int profile_id = 0;
+       gchar *profile_name = NULL;
+       gchar *apn = NULL;
+       gchar *auth_id = NULL, *auth_pwd = NULL, *home_url = NULL, *proxy_addr = NULL;
+       int auth_type = 0,svc_ctg_id = 0;
+       gboolean hidden = FALSE, editable = FALSE, default_conn = FALSE;
+
+       g_hash_table_iter_init(&iter, (GHashTable *) property);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               if (g_str_equal(key, "3") == TRUE) { /*Profile ID*/
+                       profile_id = atoi((const char*) value);
+                       dbg("profile id (%d)", profile_id);
+               }
+               else if (g_str_equal(key, "4") == TRUE) {
+                       profile_name = g_strdup((const char*) value);
+                       dbg("profile name (%s)", profile_name);
+               }
+               else if (g_str_equal(key, "5") == TRUE) {
+                       apn = g_strdup((const char*) value);
+                       dbg("APN (%s)", apn);
+               }
+               else if (g_str_equal(key, "6") == TRUE) {
+                       auth_type = atoi((const char*) value);
+                       dbg("auth type (%d)", auth_type);
+               }
+               else if (g_str_equal(key, "7") == TRUE) {
+                       auth_id = g_strdup((const char*) value);
+                       dbg("auth id (%s)", auth_id);
+               }
+               else if (g_str_equal(key, "8") == TRUE) {
+                       auth_pwd = g_strdup((const char*) value);
+                       dbg("auth pwd (%s)", auth_pwd);
+               }
+               else if (g_str_equal(key, "9") == TRUE) {
+                       proxy_addr = g_strdup((const char*) value);
+                       dbg("proxy addr (%s)", proxy_addr);
+               }
+               else if (g_str_equal(key, "10") == TRUE) {
+                       home_url = g_strdup((const char*) value);
+                       dbg("home url (%s)", home_url);
+               }
+               else if (g_str_equal(key, "19") == TRUE) {
+                       svc_ctg_id = atoi((const char*) value);
+                       dbg("context category type (%d)", svc_ctg_id);
+               }
+               else if (g_str_equal(key, "20") == TRUE) {
+                       hidden = atoi((const char*) value);
+                       dbg("hidden profile (%d)", hidden);
+               }
+               else if (g_str_equal(key, "21") == TRUE) {
+                       editable = atoi((const char*) value);
+                       dbg("editable profile (%d)", editable);
+               }
+               else if (g_str_equal(key, "22") == TRUE) {
+                       default_conn = atoi((const char*) value);
+                       dbg("default connection profile (%d)", default_conn);
+               }
+       }
+
+       path = __ps_context_create_path(profile_name, profile_id, svc_ctg_id);
+
+       context = (PsContext *) object;
+       co_context = tcore_context_new(context->plg, path, NULL);
+       tcore_context_set_state(co_context, CONTEXT_STATE_DEACTIVATED);
+       tcore_context_set_role(co_context, svc_ctg_id);
+       tcore_context_set_apn(co_context, apn);
+       tcore_context_set_auth(co_context, auth_type);
+       tcore_context_set_username(co_context, auth_id);
+       tcore_context_set_password(co_context, auth_pwd);
+       tcore_context_set_proxy(co_context, proxy_addr);
+       tcore_context_set_mmsurl(co_context, home_url);
+       tcore_context_set_profile_name(co_context, profile_name);
+
+       context->profile_id = profile_id;
+       context->hidden = hidden;
+       context->editable = editable;
+       context->default_internet = default_conn;
+       context->path = g_strdup(path);
+       context->co_context = co_context;
+
+       g_free(path);
+       return TRUE;
+}
+
+static gpointer __ps_context_create_context(DBusGConnection *conn, TcorePlugin *p,
+               gchar *mccmnc, GHashTable *property)
+{
+       guint rv = 0;
+       GError *error = NULL;
+       DBusGProxy *proxy;
+       GObject *object = NULL;
+       gchar *path = NULL;
+
+       proxy = dbus_g_proxy_new_for_name(conn, "org.freedesktop.DBus", "/org/freedesktop/DBus",
+                       "org.freedesktop.DBus");
+
+       if (!dbus_g_proxy_call(proxy, "RequestName", &error, G_TYPE_STRING, PS_DBUS_SERVICE,
+                       G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &rv, G_TYPE_INVALID)) {
+               err("Failed to acquire context(%s) error(%s)", PS_DBUS_SERVICE, error->message);
+               return NULL;
+       }
+
+       object = g_object_new(PS_TYPE_CONTEXT, "conn", conn, "plg", p, "mccmnc", mccmnc);
+
+       __ps_context_create_co_context(object, property);
+       _ps_context_set_alwayson_enable(object, TRUE);
+       path = _ps_context_ref_path(object);
+
+       dbus_g_connection_register_g_object(conn, g_strdup(path), object);
+       msg("context(%p) register dbus path(%s)", object, path);
+
+       return object;
+}
+
+static gboolean __ps_context_update_profile(PsContext *context, GHashTable *property)
+{
+       CoreObject *co_context = NULL;
+       GHashTableIter iter;
+       gpointer key, value;
+
+       co_context = context->co_context;
+       if (!co_context)
+               return FALSE;
+
+       g_hash_table_iter_init(&iter, property);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               if (g_str_equal(key, "apn") == TRUE) {
+                       tcore_context_set_apn(co_context, (const char *) value);
+               }
+               else if (g_str_equal(key, "auth_type") == TRUE) {
+                       int i_tmp = 0;
+                       i_tmp = atoi((const char *) value);
+                       tcore_context_set_auth(co_context, i_tmp);
+               }
+               else if (g_str_equal(key, "auth_id") == TRUE) {
+                       tcore_context_set_username(co_context, (const char *) value);
+               }
+               else if (g_str_equal(key, "auth_pwd") == TRUE) {
+                       tcore_context_set_password(co_context, (const char *) value);
+               }
+               else if (g_str_equal(key, "proxy_addr") == TRUE) {
+                       tcore_context_set_proxy(co_context, (const char *) value);
+               }
+               else if (g_str_equal(key, "home_url") == TRUE) {
+                       tcore_context_set_mmsurl(co_context, (const char *) value);
+               }
+       }
+
+       return __ps_context_update_database(context);
+}
+
+static gboolean __ps_context_update_default_internet_to_db(PsContext *context, gboolean enabled)
+{
+       gchar *s_id = NULL, *s_enabled = NULL;
+       gboolean rv = FALSE;
+       char szQuery[3000];
+
+       GHashTable *in_param;
+       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+
+       strcpy(szQuery, " update pdp_profile set ");
+       strcat(szQuery, " default_internet_con = ?");
+       strcat(szQuery, " where profile_id = ?");
+
+       s_id = g_strdup_printf("%d", context->profile_id);
+       s_enabled = g_strdup_printf("%d", enabled);
+
+       g_hash_table_insert(in_param, "1", g_strdup(s_enabled));
+       g_hash_table_insert(in_param, "2", g_strdup(s_id));
+
+       rv = tcore_storage_update_query_database(strg_db, handle, szQuery, in_param);
+       g_hash_table_destroy(in_param);
+
+       g_free(s_id);
+       g_free(s_enabled);
+
+       return rv;
+}
+
+static gboolean __ps_context_update_database(PsContext *context)
+{
+       gchar *s_id = NULL, *s_authtype = NULL;
+       gchar *s_apn = NULL, *s_username = NULL, *s_pwd = NULL, *s_proxy = NULL, *s_mms = NULL;
+       gboolean rv = FALSE;
+       char szQuery[3000];
+
+       GHashTable *in_param;
+       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+
+       strcpy(szQuery, " update pdp_profile set ");
+       strcat(szQuery, " apn = ?, auth_type = ?, auth_id = ?, auth_pwd = ?, ");
+       strcat(szQuery, " proxy_ip_addr = ?, home_url = ?");
+       strcat(szQuery, " where profile_id = ?");
+
+       s_id = g_strdup_printf("%d", context->profile_id);
+       s_authtype = g_strdup_printf("%d", tcore_context_get_auth(context->co_context));
+
+       s_apn = tcore_context_get_apn(context->co_context);
+       s_username = tcore_context_get_username(context->co_context);
+       s_pwd = tcore_context_get_password(context->co_context);
+       s_proxy = tcore_context_get_proxy(context->co_context);
+       s_mms = tcore_context_get_mmsurl(context->co_context);
+
+       g_hash_table_insert(in_param, "1", g_strdup(s_apn));
+       g_hash_table_insert(in_param, "2", g_strdup(s_authtype));
+       g_hash_table_insert(in_param, "3", g_strdup(s_username));
+       g_hash_table_insert(in_param, "4", g_strdup(s_pwd));
+       g_hash_table_insert(in_param, "5", g_strdup(s_proxy));
+       g_hash_table_insert(in_param, "6", g_strdup(s_mms));
+       g_hash_table_insert(in_param, "7", g_strdup(s_id));
+
+       rv = tcore_storage_update_query_database(strg_db, handle, szQuery, in_param);
+       g_hash_table_destroy(in_param);
+
+       g_free(s_id);
+       g_free(s_authtype);
+       g_free(s_apn);
+       g_free(s_username);
+       g_free(s_pwd);
+       g_free(s_proxy);
+       g_free(s_mms);
+
+       return rv;
+}
+
+static gboolean __ps_context_remove_database(PsContext *context)
+{
+       gchar *s_id = NULL;
+       gboolean rv = FALSE;
+       char szQuery[1000];
+
+       GHashTable *in_param;
+       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+
+       memset(szQuery, 0, sizeof(szQuery));
+       strcpy(szQuery, " delete from pdp_profile where profile_id = ? ");
+
+       s_id = g_strdup_printf("%d", context->profile_id);
+       g_hash_table_insert(in_param, "1", g_strdup(s_id));
+
+       rv = tcore_storage_remove_query_database(strg_db, handle, szQuery, in_param);
+       g_free(s_id);
+       g_hash_table_destroy(in_param);
+
+       return rv;
+}
+
+static int __ps_context_insert_network_id_to_database(gchar *mccmnc)
+{
+       char szQuery[5000];
+       int network_id = 0;
+       gboolean rv = FALSE;
+       gchar *insert_key = NULL;
+       GHashTableIter iter;
+       gpointer key, value;
+       GHashTable *in_param, *out_param;
+
+       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+                               (GDestroyNotify) g_hash_table_destroy);
+
+       memset(szQuery, 0, sizeof(szQuery));
+       strcpy(szQuery,"select max(network_info_id) as network_id from network_info");
+
+       tcore_storage_read_query_database(strg_db, handle, szQuery, NULL, out_param, 1);
+
+       g_hash_table_iter_init(&iter, out_param);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               GHashTableIter iter2;
+               gpointer key2, value2;
+
+               if(value){
+                       g_hash_table_iter_init(&iter2, (GHashTable *) value);
+                       while (g_hash_table_iter_next(&iter2, &key2, &value2) == TRUE) {
+                               dbg("key2(%s) value2(%s)",key2, value2);
+                               if (g_str_equal(key2, "0") == TRUE) {
+                                       if (!value2 || g_strcmp0((const char*) value2, "") == 0 ) {
+                                               network_id = 0;
+                                       }
+                                       else{
+                                               network_id = atoi((const char*) value2);
+                                       }
+                               }
+                       }
+                       break;
+               }
+       }
+
+       g_hash_table_destroy(out_param);
+       network_id++;
+
+
+       memset(szQuery, 0, sizeof(szQuery));
+       strcpy(szQuery," insert into network_info( network_info_id, network_name, mccmnc) values( ?, ?, ?) ");
+
+       insert_key = g_strdup_printf("%d", network_id);
+       g_hash_table_insert(in_param, "1", g_strdup(insert_key));
+       g_hash_table_insert(in_param, "2", "TEMP_NETWORK");
+       g_hash_table_insert(in_param, "3", g_strdup(mccmnc));
+
+       rv = tcore_storage_insert_query_database(strg_db, handle, szQuery, in_param);
+       if(!rv)
+               return 0;
+
+       g_free(insert_key);
+       return network_id;
+}
+
+static int __ps_context_insert_profile_to_database(GHashTable *property, int network_id)
+{
+       int profile_id = 0;
+       char szQuery[5000];
+
+       gboolean rv = FALSE;
+       GHashTableIter iter;
+       gpointer key, value;
+       GHashTable *in_param;
+       gchar *insert_key1 = NULL, *insert_key2 = NULL;
+       gchar *profile_name=NULL, *apn=NULL, *auth_type=NULL, *auth_id = NULL, *auth_pwd = NULL;
+       gchar *proxy_addr = NULL, *home_url = NULL, *svc_id = NULL, *keyword=NULL, *network_name= NULL;
+
+       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+
+       g_hash_table_iter_init(&iter, property);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+
+               if (g_str_equal(key, "apn") == TRUE) {
+                       apn = g_strdup(value);
+               }
+               else if (g_str_equal(key, "keyword") == TRUE) {
+                       keyword = g_strdup(value);
+               }
+               else if (g_str_equal(key, "auth_type") == TRUE) {
+                       auth_type = g_strdup(value);
+               }
+               else if (g_str_equal(key, "auth_id") == TRUE) {
+                       auth_id = g_strdup(value);
+               }
+               else if (g_str_equal(key, "auth_pwd") == TRUE) {
+                       auth_pwd = g_strdup(value);
+               }
+               else if (g_str_equal(key, "proxy_addr") == TRUE) {
+                       proxy_addr = g_strdup(value);
+               }
+               else if (g_str_equal(key, "home_url") == TRUE) {
+                       home_url = g_strdup(value);
+               }
+               else if (g_str_equal(key, "svc_ctg_id") == TRUE) {
+                       svc_id = g_strdup(value);
+               }
+
+       }
+
+       dbg("apn (%s), auth_type (%s), auth_id(%s), auth_pwd(%s), proxy_addr(%s), home_url(%s), svc_id(%s)",
+               apn, auth_type, auth_id, auth_pwd, proxy_addr, home_url, svc_id);
+
+       profile_id = __ps_context_load_profile_id_from_database();
+       if(profile_id < 0){
+               dbg("fail to get last profile id");
+               return 0;
+       }
+       dbg("last profile id(%d)", profile_id);
+       profile_id++;
+
+       memset(szQuery, 0, sizeof(szQuery));
+       strcpy(szQuery," insert into pdp_profile( ");
+       strcat(szQuery," profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, ");
+       strcat(szQuery," pdp_protocol, proxy_ip_addr, home_url, linger_time, ");
+       strcat(szQuery," network_info_id, svc_category_id, hidden, editable, default_internet_con) values( ");
+       strcat(szQuery," ?, ?, ?, ?, ?, ?,");//1,2,3,4,5,6
+       strcat(szQuery," 1, ?, ?, 300,");//7,8
+       strcat(szQuery," ?, ?, 0, 1, 0)");//9,10
+
+       insert_key1 = g_strdup_printf("%d", profile_id);
+       insert_key2 = g_strdup_printf("%d", network_id);
+       network_name = __ps_context_load_network_name_from_database(network_id);
+
+       if(keyword){
+               profile_name = g_strdup_printf("%s (%s)", network_name, keyword);
+       }
+       else{
+               profile_name = g_strdup_printf("%s", network_name);
+       }
+       dbg("profile name (%s)", profile_name);
+
+       g_hash_table_insert(in_param, "1", g_strdup(insert_key1));
+       g_hash_table_insert(in_param, "2", g_strdup(profile_name));
+       g_hash_table_insert(in_param, "3", g_strdup(apn));
+       g_hash_table_insert(in_param, "4", g_strdup(auth_type));
+       g_hash_table_insert(in_param, "5", g_strdup(auth_id));
+       g_hash_table_insert(in_param, "6", g_strdup(auth_pwd));
+       g_hash_table_insert(in_param, "7", g_strdup(proxy_addr));
+       g_hash_table_insert(in_param, "8", g_strdup(home_url));
+       g_hash_table_insert(in_param, "9", g_strdup(insert_key2));
+       g_hash_table_insert(in_param, "10", g_strdup(svc_id));
+
+       g_free(insert_key1);g_free(insert_key2);g_free(profile_name);
+       g_free(apn);g_free(auth_type);g_free(auth_id);g_free(auth_pwd);
+       g_free(proxy_addr);g_free(home_url);g_free(svc_id);
+
+       rv = tcore_storage_insert_query_database(strg_db, handle, szQuery, in_param);
+       g_hash_table_destroy(in_param);
+
+       if(!rv)
+               return 0;
+
+       return profile_id;
+}
+
+static int __ps_context_load_network_id_from_database(gchar *mccmnc)
+{
+       char szQuery[5000];
+       int network_id = 0;
+       GHashTableIter iter;
+       gpointer key, value;
+       GHashTable *in_param, *out_param;
+
+       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+                       (GDestroyNotify) g_hash_table_destroy);
+
+       memset(szQuery, 0, sizeof(szQuery));
+       strcpy(szQuery,"select network_info_id from network_info where mccmnc = ? ");
+
+       g_hash_table_insert(in_param, "1", g_strdup(mccmnc));
+       tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, out_param, 1);
+
+       g_hash_table_iter_init(&iter, out_param);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               GHashTableIter iter2;
+               gpointer key2, value2;
+
+               if(value){
+                       g_hash_table_iter_init(&iter2, (GHashTable *) value);
+                       while (g_hash_table_iter_next(&iter2, &key2, &value2) == TRUE) {
+                               if (g_str_equal(key2, "0") == TRUE) {
+                                       if (!value2 || g_strcmp0((const char*) value2, "") == 0) {
+                                               network_id = 0;
+                                       }
+                                       else{
+                                               network_id = atoi((const char*) value2);
+                                       }
+                               }
+                       }
+                       break;
+               }
+       }
+
+       g_hash_table_destroy(in_param);
+       g_hash_table_destroy(out_param);
+
+       return network_id;
+}
+
+static gchar* __ps_context_load_network_name_from_database(int network_id)
+{
+       char szQuery[5000];
+       gchar *network_name = NULL;
+       gchar *insert_key1 = NULL;
+       GHashTableIter iter;
+       gpointer key, value;
+       GHashTable *in_param, *out_param;
+
+       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+                       (GDestroyNotify) g_hash_table_destroy);
+
+       memset(szQuery, 0, sizeof(szQuery));
+       strcpy(szQuery,"select network_name from network_info where network_info_id = ? ");
+
+       insert_key1 = g_strdup_printf("%d", network_id);
+       g_hash_table_insert(in_param, "1", g_strdup(insert_key1));
+       tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, out_param, 1);
+
+       g_hash_table_iter_init(&iter, out_param);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               GHashTableIter iter2;
+               gpointer key2, value2;
+
+               if(value){
+                       g_hash_table_iter_init(&iter2, (GHashTable *) value);
+                       while (g_hash_table_iter_next(&iter2, &key2, &value2) == TRUE) {
+                               if (g_str_equal(key2, "0") == TRUE) {
+                                       network_name = g_strdup(value2);
+                               }
+                       }
+                       break;
+               }
+       }
+
+       g_hash_table_destroy(in_param);
+       g_hash_table_destroy(out_param);
+       g_free(insert_key1);
+
+       return network_name;
+}
+
+static int __ps_context_load_profile_id_from_database(void)
+{
+       char szQuery[5000];
+       int profile_id = 0;
+       GHashTableIter iter;
+       gpointer key, value;
+       GHashTable *out_param;
+
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+                       (GDestroyNotify) g_hash_table_destroy);
+
+       memset(szQuery, 0, sizeof(szQuery));
+       strcpy(szQuery,"select max(profile_id) as last_profile from pdp_profile");
+
+       tcore_storage_read_query_database(strg_db, handle, szQuery, NULL, out_param, 1);
+
+       g_hash_table_iter_init(&iter, out_param);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               GHashTableIter iter2;
+               gpointer key2, value2;
+
+               if(value){
+                       g_hash_table_iter_init(&iter2, (GHashTable *) value);
+                       while (g_hash_table_iter_next(&iter2, &key2, &value2) == TRUE) {
+                               if (g_str_equal(key2, "0") == TRUE) {
+                                       if(!value2 || g_strcmp0((const char*) value2, "") == 0){
+                                               profile_id = 0;
+                                       }
+                                       else{
+                                               profile_id = atoi((const char*) value2);
+                                       }
+                               }
+                       }
+                       break;
+               }
+       }
+
+       g_hash_table_destroy(out_param);
+       return profile_id;
+}
+
+static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int index)
+{
+       gboolean rv = FALSE;
+       GHashTable *in_param;
+
+       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+
+       {//profile id
+               gchar *profile_id;
+               gchar* item_key = NULL;
+               item_key = g_strdup_printf("connection:profile_id_%d", index);
+               profile_id = iniparser_getstr(dic, item_key);
+               g_hash_table_insert(in_param, "1", g_strdup(profile_id));
+               g_free(item_key);
+       }
+
+       {//profile name
+               gchar *profile_name;
+               gchar* item_key = NULL;
+               item_key = g_strdup_printf("connection:profile_name_%d", index);
+               profile_name = iniparser_getstr(dic, item_key);
+               g_hash_table_insert(in_param, "2", g_strdup(profile_name));
+               g_free(item_key);
+       }
+
+       {//apn
+               gchar *apn;
+               gchar *item_key = NULL;
+               item_key = g_strdup_printf("connection:apn_%d", index);
+               apn = iniparser_getstr(dic, item_key);
+               g_hash_table_insert(in_param, "3", g_strdup(apn));
+               g_free(item_key);
+       }
+
+       {//auth type
+               gchar *auth_type;
+               gchar *item_key = NULL;
+               item_key = g_strdup_printf("connection:auth_type_%d", index);
+               auth_type = iniparser_getstr(dic, item_key);
+               g_hash_table_insert(in_param, "4", g_strdup(auth_type));
+               g_free(item_key);
+       }
+
+       {//auth id
+               gchar *auth_id;
+               gchar *item_key = NULL;
+               item_key = g_strdup_printf("connection:auth_id_%d", index);
+               auth_id = iniparser_getstr(dic, item_key);
+               g_hash_table_insert(in_param, "5", g_strdup(auth_id));
+               g_free(item_key);
+       }
+
+       {//auth pwd
+               gchar *auth_pwd;
+               gchar *item_key = NULL;
+               item_key = g_strdup_printf("connection:auth_pwd_%d", index);
+               auth_pwd = iniparser_getstr(dic, item_key);
+               g_hash_table_insert(in_param, "6", g_strdup(auth_pwd));
+               g_free(item_key);
+       }
+
+       {//pdp protocol
+               gchar *pdp_protocol;
+               gchar *item_key = NULL;
+               item_key = g_strdup_printf("connection:pdp_protocol_%d", index);
+               pdp_protocol = iniparser_getstr(dic, item_key);
+               g_hash_table_insert(in_param, "7", g_strdup(pdp_protocol));
+               g_free(item_key);
+       }
+
+       {// proxy ip
+               gchar *proxy_ip_addr;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:proxy_ip_addr_%d", index);
+               proxy_ip_addr = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "8", g_strdup(proxy_ip_addr));
+               g_free(section_key);
+       }
+
+       {//home url
+               gchar *home_url;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:home_url_%d", index);
+               home_url = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "9", g_strdup(home_url));
+               g_free(section_key);
+       }
+
+       {//linger time
+               gchar *linger_time;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:linger_time_%d", index);
+               linger_time = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "10", g_strdup(linger_time));
+               g_free(section_key);
+       }
+
+       {//traffic class
+               gchar *traffic_class;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:traffic_class_%d", index);
+               traffic_class = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "11", g_strdup(traffic_class));
+               g_free(section_key);
+       }
+
+       {//is static ip address
+               gchar *is_static_ip_addr;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:is_static_ip_addr_%d", index);
+               is_static_ip_addr = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "12", g_strdup(is_static_ip_addr));
+               g_free(section_key);
+       }
+
+       {//ip address if static ip is true
+               gchar *ip_addr;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:ip_addr_%d", index);
+               ip_addr = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "13", g_strdup(ip_addr));
+               g_free(section_key);
+       }
+
+       {//is static dns address
+               gchar *is_static_dns_addr;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:is_static_dns_addr_%d", index);
+               is_static_dns_addr = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "14", g_strdup(is_static_dns_addr));
+               g_free(section_key);
+       }
+
+       {//dns address 1
+               gchar *dns_addr1;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:dns_addr1_%d", index);
+               dns_addr1 = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "15", g_strdup(dns_addr1));
+               g_free(section_key);
+       }
+
+       {//dns address 2
+               gchar *dns_addr2;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:dns_addr2_%d", index);
+               dns_addr2 = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "16", g_strdup(dns_addr2));
+               g_free(section_key);
+       }
+
+       {//network info id
+               gchar *network_info_id;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:network_info_id_%d", index);
+               network_info_id = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "17", g_strdup(network_info_id));
+               g_free(section_key);
+       }
+
+       {//service category id
+               gchar *svc_category_id;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:svc_category_id_%d", index);
+               svc_category_id = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "18", g_strdup(svc_category_id));
+               g_free(section_key);
+       }
+
+       {//hidden
+               gchar *hidden;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:hidden_%d", index);
+               hidden = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "19", g_strdup(hidden));
+               g_free(section_key);
+       }
+
+       {//editable
+               gchar *editable;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:editable_%d", index);
+               editable = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "20", g_strdup(editable));
+               g_free(section_key);
+       }
+
+       {//default internet connection
+               gchar *default_internet_con;
+               gchar *section_key = NULL;
+               section_key = g_strdup_printf("connection:default_internet_con_%d", index);
+               default_internet_con = iniparser_getstr(dic, section_key);
+               g_hash_table_insert(in_param, "21", g_strdup(default_internet_con));
+               g_free(section_key);
+       }
+
+       {//insert data into table
+               char szQuery[5000];
+
+               memset(szQuery, 0, 5000);
+               strcpy(szQuery," insert into pdp_profile( ");
+               strcat(szQuery," profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, ");
+               strcat(szQuery," pdp_protocol, proxy_ip_addr, home_url, linger_time,");
+               strcat(szQuery," traffic_class, is_static_ip_addr, ip_addr, is_static_dns_addr,dns_addr1, dns_addr2,");
+               strcat(szQuery," network_info_id, svc_category_id, hidden, editable, default_internet_con) values( ");
+               strcat(szQuery," ?, ?, ?, ?, ?, ?,");//1,2,3,4,5,6(auth_pwd)
+               strcat(szQuery," ?, ?, ?, ?,");//7,8,9,10(linger_time)
+               strcat(szQuery," ?, ?, ?, ?, ?, ?,");//11,12,13,14,15,16(dns_addr2)
+               strcat(szQuery," ?, ?, ?, ?, ?)");//17,18,19,20,21(default_internet_con)
+
+               rv = tcore_storage_insert_query_database(strg_db, handle, szQuery, in_param);
+               dbg("insert into pdp_profile result(%d)", rv);
+               g_hash_table_destroy(in_param);
+       }
+
+       return rv;
+}
+
+static int __ps_context_get_network_id(gchar *mccmnc)
+{
+       int network_id;
+
+       network_id = __ps_context_load_network_id_from_database(mccmnc);
+       dbg("network id(%d)", network_id);
+       if(network_id > 0)
+               return network_id;
+
+       network_id = __ps_context_insert_network_id_to_database(mccmnc);
+       if(network_id <= 0 )
+               return -1;
+
+       return network_id;
+}
+
+static gboolean __ps_context_get_profile_properties(gpointer object, GHashTable *properties)
+{
+       gchar *s_authtype = NULL, *s_role = NULL;
+       PsContext *context = NULL;
+
+       g_return_val_if_fail(object != NULL, FALSE);
+       g_return_val_if_fail(properties != NULL, FALSE);
+
+       context = (PsContext *) object;
+       dbg("get profile properties");
+
+       s_authtype = g_strdup_printf("%d", tcore_context_get_auth(context->co_context));
+       s_role = g_strdup_printf("%d", tcore_context_get_role(context->co_context));
+
+       g_hash_table_insert(properties, "path", g_strdup(context->path));
+       g_hash_table_insert(properties, "apn", tcore_context_get_apn(context->co_context));
+       g_hash_table_insert(properties, "auth_type", g_strdup(s_authtype));
+       g_hash_table_insert(properties, "auth_id", tcore_context_get_username(context->co_context));
+       g_hash_table_insert(properties, "auth_pwd", tcore_context_get_password(context->co_context));
+       g_hash_table_insert(properties, "proxy_addr", tcore_context_get_proxy(context->co_context));
+       g_hash_table_insert(properties, "home_url", tcore_context_get_mmsurl(context->co_context));
+       g_hash_table_insert(properties, "svc_ctg_id", g_strdup(s_role));
+       g_hash_table_insert(properties, "profile_name", tcore_context_get_profile_name(context->co_context));
+       g_hash_table_insert(properties, "hidden", g_strdup(BOOL2STRING(context->hidden)));
+       g_hash_table_insert(properties, "editable", g_strdup(BOOL2STRING(context->editable)));
+       g_hash_table_insert(properties, "default_internet_conn", g_strdup(BOOL2STRING(context->default_internet)));
+
+       g_free(s_authtype);
+       g_free(s_role);
+
+       return TRUE;
+}
+
+static gboolean __ps_context_set_default_connection_enable(gpointer object, gboolean enabled)
+{
+       PsContext *context = object;
+       int role = CONTEXT_ROLE_UNKNOWN;
+       g_return_val_if_fail(context != NULL, FALSE);
+
+       role = tcore_context_get_role(context->co_context);
+       if(role == CONTEXT_ROLE_INTERNET){
+               context->default_internet = enabled;
+       }
+
+       return TRUE;
+}
+
+static gpointer __ps_context_add_context(gpointer modem, gchar *mccmnc, int profile_id)
+{
+       char szQuery[5000];
+       DBusGConnection *conn = NULL;
+       TcorePlugin *p = NULL;
+
+       GHashTableIter iter;
+       gpointer object = NULL;
+       gpointer key, value;
+       gchar *insert_key1 = NULL;
+       GHashTable *in_param, *out_param;
+       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+                       (GDestroyNotify) g_hash_table_destroy);
+
+       dbg("create profile by profile id (%d)", profile_id);
+       conn = _ps_modem_ref_dbusconn(modem);
+       p = _ps_modem_ref_plugin(modem);
+
+       memset(szQuery, '\0', 5000);
+       strcpy(szQuery, "select");
+       strcat(szQuery, " a.network_info_id, a.network_name, a.mccmnc,"); //0 , 1, 2
+       strcat(szQuery, " b.profile_id, b.profile_name, b.apn, "); //3, 4, 5
+       strcat(szQuery, " b.auth_type, b.auth_id, b.auth_pwd,"); //6, 7, 8
+       strcat(szQuery, " b.proxy_ip_addr, b.home_url, b.pdp_protocol, "); //9, 10 , 11
+       strcat(szQuery, " b.linger_time, b.traffic_class, b.is_static_ip_addr, b.ip_addr,"); //12, 13, 14, 15
+       strcat(szQuery, " b.is_static_dns_addr, b.dns_addr1, b.dns_addr2, b.svc_category_id, b.hidden, b.editable, b.default_internet_con"); //16, 17, 18, 19, 20, 21, 22
+       strcat(szQuery, " from network_info a, pdp_profile b");
+       strcat(szQuery, " where b.profile_id = ? and a.network_info_id = b.network_info_id ");
+
+       insert_key1 = g_strdup_printf("%d", profile_id);
+       g_hash_table_insert(in_param, "1", g_strdup(insert_key1));
+       tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, out_param, 23);
+
+       g_hash_table_iter_init(&iter, out_param);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               gchar *path = NULL;
+
+               object = __ps_context_create_context(conn, p, mccmnc, (GHashTable *) value);
+               path = _ps_context_ref_path(object);
+
+               g_hash_table_insert(contexts, g_strdup(path), object);
+               dbg("context (%p, %s) insert to hash", object, path);
+       }
+
+       g_hash_table_destroy(in_param);
+       g_hash_table_destroy(out_param);
+       g_free(insert_key1);
+
+       return object;
+}
+
+gboolean _ps_context_initialize(gpointer plugin)
+{
+       gboolean rv = TRUE;
+
+       dbg("global variable initialized");
+       rv &=__ps_context_create_storage_handle(plugin);
+       rv &=__ps_context_create_context_hash();
+
+       return rv;
+}
+
+gboolean _ps_context_reset_profile_table(void)
+{
+       gboolean rv = FALSE;
+       GHashTable *in_param;
+       char szQuery[5000];
+
+       memset(szQuery, '\0', 5000);
+       strcat(szQuery, " delete from pdp_profile");
+
+       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+       rv = tcore_storage_remove_query_database(strg_db, handle, szQuery, in_param);
+
+       g_hash_table_destroy(in_param);
+       return rv;
+}
+
+gboolean _ps_context_fill_profile_table_from_ini_file(void)
+{
+       int index = 1;
+       int data_exist = 0;
+
+       dictionary *dic = NULL;
+       dic = iniparser_load("/opt/system/csc-default/data/csc-default-data-connection.ini");
+
+       if(dic == NULL){
+               dbg("fail to load the csc default file");
+               return FALSE;
+       }
+
+       do{
+               gchar *section_key = NULL;
+
+               section_key = g_strdup_printf("connection:profile_id_%d", index);
+               dbg("section key (%s)", section_key);
+               data_exist = iniparser_find_entry(dic, section_key);
+               if(!data_exist){
+                       g_free(section_key);
+                       iniparser_freedict(dic);
+                       dbg("no more data in ini");
+                       return TRUE;
+               }
+
+               __ps_context_insert_profile_tuple(dic, index);
+
+               g_free(section_key);
+               index++;
+
+       }while(data_exist);
+
+       return TRUE;
+}
+
+gboolean _ps_context_reset_hashtable(void)
+{
+       if(!contexts)
+               return TRUE;
+
+       g_hash_table_foreach_remove(contexts, __remove_contexts, NULL);
+       return TRUE;
+}
+
+GHashTable* _ps_context_create_hashtable(DBusGConnection *conn, TcorePlugin *p, gchar *mccmnc)
+{
+       char szQuery[5000];
+       GHashTableIter iter;
+       gpointer key, value;
+       GHashTable *in_param, *out_param;
+       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+                       (GDestroyNotify) g_hash_table_destroy);
+
+       dbg("create profile by mccmnc (%s)", mccmnc);
+
+       memset(szQuery, '\0', 5000);
+       strcpy(szQuery, "select");
+       strcat(szQuery, " a.network_info_id, a.network_name, a.mccmnc,"); //0 , 1, 2
+       strcat(szQuery, " b.profile_id, b.profile_name, b.apn, "); //3, 4, 5
+       strcat(szQuery, " b.auth_type, b.auth_id, b.auth_pwd,"); //6, 7, 8
+       strcat(szQuery, " b.proxy_ip_addr, b.home_url, b.pdp_protocol, "); //9, 10 , 11
+       strcat(szQuery, " b.linger_time, b.traffic_class, b.is_static_ip_addr, b.ip_addr,"); //12, 13, 14, 15
+       strcat(szQuery, " b.is_static_dns_addr, b.dns_addr1, b.dns_addr2, b.svc_category_id, b.hidden, b.editable, b.default_internet_con"); //16,17, 18, 19, 20, 21, 22
+       strcat(szQuery, " from network_info a, pdp_profile b");
+       strcat(szQuery, " where a.mccmnc= ? and a.network_info_id = b.network_info_id ");
+
+       g_hash_table_insert(in_param, "1", g_strdup(mccmnc));
+       tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, out_param, 23);
+
+       g_hash_table_iter_init(&iter, out_param);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               gchar *path = NULL;
+               gpointer object = NULL;
+
+               object = __ps_context_create_context(conn, p, mccmnc, (GHashTable *) value);
+               path = _ps_context_ref_path(object);
+
+               g_hash_table_insert(contexts, g_strdup(path), object);
+               dbg("context (%p, %s) insert to hash", object, path);
+       }
+
+       g_hash_table_destroy(in_param);
+       g_hash_table_destroy(out_param);
+
+       return contexts;
+}
+
+GHashTable* _ps_context_ref_hashtable(void)
+{
+       g_return_val_if_fail(contexts != NULL, NULL);
+       return contexts;
+}
+
+gboolean _ps_context_add_context(gpointer modem, gchar *operator, GHashTable *property)
+{
+       GHashTable *services = NULL;
+       gpointer context = NULL;
+
+       GHashTableIter iter;
+       gpointer key, value;
+       int network_id = 0;
+       int profile_id = 0;
+
+       network_id = __ps_context_get_network_id(operator);
+       if(network_id <= 0){
+               dbg("fail to add network info");
+               return FALSE;
+       }
+
+       profile_id = __ps_context_insert_profile_to_database(property, network_id);
+       if(profile_id <= 0){
+               dbg("fail to insert profile info to database");
+               return FALSE;
+       }
+
+       context = __ps_context_add_context(modem, operator, profile_id);
+       if(!context)
+               return FALSE;
+
+       services = _ps_modem_ref_services(modem);
+       if(!services)
+               return FALSE;
+
+       g_hash_table_iter_init(&iter, services);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               _ps_service_ref_context(value, context);
+       }
+
+       return TRUE;
+}
+
+gboolean _ps_context_get_properties(gpointer object, GHashTable *properties)
+{
+       int context_state = 0;
+       gboolean active = FALSE;
+       PsContext *context = object;
+
+       dbg("get context properties");
+       g_return_val_if_fail(context != NULL, FALSE);
+       g_return_val_if_fail(properties != NULL, FALSE);
+
+       context_state =    tcore_context_get_state(context->co_context);
+       if (context_state == CONTEXT_STATE_ACTIVATED)
+               active = TRUE;
+
+       g_hash_table_insert(properties, "path", g_strdup(context->path));
+       g_hash_table_insert(properties, "active", g_strdup(BOOL2STRING(active)));
+       g_hash_table_insert(properties, "ipv4_address", tcore_context_get_ipv4_addr(context->co_context));
+       g_hash_table_insert(properties, "ipv4_gateway", tcore_context_get_ipv4_gw(context->co_context));
+       g_hash_table_insert(properties, "ipv4_dns1", tcore_context_get_ipv4_dns1(context->co_context));
+       g_hash_table_insert(properties, "ipv4_dns2", tcore_context_get_ipv4_dns2(context->co_context));
+       g_hash_table_insert(properties, "ipv6_address", "::" );
+       g_hash_table_insert(properties, "ipv6_gateway", "::" );
+       g_hash_table_insert(properties, "ipv6_dns1", "::" );
+       g_hash_table_insert(properties, "ipv6_dns2", "::" );
+       g_hash_table_insert(properties, "proxy", tcore_context_get_proxy(context->co_context));
+       g_hash_table_insert(properties, "dev_name", tcore_context_get_ipv4_devname(context->co_context));
+
+       return TRUE;
+}
+
+gboolean _ps_context_set_alwayson_enable(gpointer object, gboolean enabled)
+{
+       PsContext *context = object;
+       int role = CONTEXT_ROLE_UNKNOWN;
+       g_return_val_if_fail(context != NULL, FALSE);
+
+       role = tcore_context_get_role(context->co_context);
+       if(role == CONTEXT_ROLE_INTERNET && context->default_internet){
+               context->alwayson = enabled;
+       }
+
+       return TRUE;
+}
+
+gboolean _ps_context_get_default_internet(gpointer object)
+{
+       PsContext *context = object;
+       int role = CONTEXT_ROLE_UNKNOWN;
+       g_return_val_if_fail(context != NULL, FALSE);
+
+       role = tcore_context_get_role(context->co_context);
+       if(role == CONTEXT_ROLE_INTERNET && context->default_internet){
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
+gboolean _ps_context_set_service(gpointer object, gpointer service)
+{
+       PsContext *context = object;
+       g_return_val_if_fail(context != NULL, FALSE);
+
+       context->p_service = service;
+       return TRUE;
+}
+
+gpointer _ps_context_ref_service(gpointer object)
+{
+       PsContext *context = object;
+       g_return_val_if_fail(context != NULL, FALSE);
+
+       return context->p_service;
+}
+
+gchar* _ps_context_ref_path(gpointer object)
+{
+       PsContext *context = object;
+       g_return_val_if_fail(context != NULL, NULL);
+
+       return context->path;
+}
+
+gboolean _ps_context_get_alwayson_enable(gpointer object)
+{
+       PsContext *context = object;
+       g_return_val_if_fail(context != NULL, FALSE);
+
+       return context->alwayson;
+}
+
+gpointer _ps_context_ref_co_context(gpointer object)
+{
+       PsContext *context = object;
+       g_return_val_if_fail(context != NULL, NULL);
+
+       return context->co_context;
+}
+
+gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
+{
+       gchar *ipv4 = NULL;
+       PsContext *context = object;
+       g_return_val_if_fail(context != NULL, FALSE);
+
+
+       ipv4 = tcore_context_get_ipv4_addr(context->co_context);
+
+       if (enabled) {
+
+               tcore_context_set_state(context->co_context, CONTEXT_STATE_ACTIVATED);
+               if( g_str_equal(ipv4, "0.0.0.0") == TRUE ){
+                       dbg("ip address is 0.0.0.0");
+                       _ps_service_deactivate_context(context->p_service, context);
+                       return TRUE;
+               }
+               _ps_service_reset_connection_timer(context);
+
+       }
+       else {
+               tcore_context_set_state(context->co_context, CONTEXT_STATE_DEACTIVATED);
+               tcore_context_reset_devinfo(context->co_context);
+               _ps_service_connection_timer(context->p_service, context);
+       }
+
+       __ps_context_emit_property_changed_signal(context);
+       g_free(ipv4);
+       return TRUE;
+}
+
+gboolean _ps_context_set_ps_defined(gpointer *object, gboolean value, int cid)
+{
+       PsContext *context = (PsContext *)object;
+
+       g_return_val_if_fail(context != NULL, FALSE);
+       
+       if(tcore_context_get_id(context->co_context) == (unsigned int)cid){
+               context->ps_defined = value;
+               dbg("context(%p) ps_defined(%d)", context, context->ps_defined);
+               return TRUE;
+       }
+       dbg("context(%p) does not have cid(%d)",context, cid);
+
+       return FALSE;
+}
+
+gboolean _ps_context_get_ps_defined(gpointer *object)
+{
+       PsContext *context = (PsContext *)object;
+
+       dbg("context(%p), ps_defined(%d)", context, context->ps_defined);
+
+       return context->ps_defined;
+}
diff --git a/src/error.c b/src/error.c
new file mode 100644 (file)
index 0000000..b63990e
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 "ps-error.h"
+
+GQuark ps_error_quark(void)
+{
+       static GQuark quark = 0;
+
+       if (!quark) quark = g_quark_from_static_string("ps_error");
+
+       return quark;
+}
diff --git a/src/main.c b/src/main.c
new file mode 100644 (file)
index 0000000..c07a1e1
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 <glib.h>
+#include <dbus/dbus-glib.h>
+
+#include <tcore.h>
+#include <plugin.h>
+
+#include <ps.h>
+
+static gboolean on_load()
+{
+       dbg("PacketService plugin load!");
+       return TRUE;
+}
+
+static gboolean on_init(TcorePlugin *p)
+{
+       gpointer *master;
+       DBusGConnection *conn;
+       GError *error = NULL;
+       gboolean rv=FALSE;
+
+       //get dbus connection
+       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+       if (conn == NULL) {
+               err("fail to get dbus(%s)", error->message);
+               return FALSE;
+       }
+       dbg("get dbus connection(%p)", conn);
+
+       dbg("plugin pointer (%p)", p);
+       rv = _ps_context_initialize(p);
+       if(rv != TRUE){
+               dbg("fail to initialize context global variable");
+               return FALSE;
+       }
+
+       master = _ps_master_create_master(conn, p);
+       rv = _ps_master_create_modems(master);
+
+       dbg("initialized PacketService plugin!");
+       return TRUE;
+}
+
+static void on_unload(TcorePlugin *p)
+{
+       dbg("i'm unload!");
+       return;
+}
+
+struct tcore_plugin_define_desc plugin_define_desc =
+{
+       .name = "PACKETSERVICE",
+       .priority = TCORE_PLUGIN_PRIORITY_MID + 1,
+       .version = 1,
+       .load = on_load,
+       .init = on_init,
+       .unload = on_unload
+};
diff --git a/src/master.c b/src/master.c
new file mode 100644 (file)
index 0000000..d931798
--- /dev/null
@@ -0,0 +1,561 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 <unistd.h>
+
+#include "ps-master.h"
+
+#include "ps.h"
+#include "ps-error.h"
+
+#include <server.h>
+#include <plugin.h>
+#include <storage.h>
+#include <hal.h>
+
+#define PS_MASTER_PATH "/"
+#define PROP_DEFAULT           FALSE
+#define PROP_DEFAULT_STR       NULL
+#define BOOL2STRING(a)         ((a==TRUE) ? ("TRUE"):("FALSE"))
+
+/*Properties*/
+
+enum {
+       PROP_MASTER_O,
+       PROP_MASTER_PLUGIN,
+       PROP_MASTER_CONN,
+       PROP_MASTER_PATH
+};
+
+enum {
+        SIG_MASTER_MODEM_ADDED,
+        SIG_MASTER_MODEM_REMOVED,
+        SIG_MASTER_LAST
+};
+
+static guint32 signals[SIG_MASTER_LAST] = {0,};
+
+struct PsMasterClass {
+       GObjectClass parent;
+
+       void (*modem_added)(PsMaster *master, gchar *modem_path);
+       void (*modem_removed)(PsMaster *master, gchar *modem_path);
+};
+
+struct PsMaster {
+       GObject parent;
+
+       //member variable
+       gchar *path;
+       TcorePlugin *plg;
+       DBusGConnection *conn;
+       GHashTable *modems;
+};
+
+G_DEFINE_TYPE(PsMaster, ps_master, G_TYPE_OBJECT);
+
+/*Function Declaration*/
+static void __ps_master_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void __ps_master_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+
+gboolean ps_iface_master_get_modems(PsMaster *master, DBusGMethodInvocation *context);
+gboolean ps_iface_master_get_profile_list(PsMaster *master, DBusGMethodInvocation *context);
+gboolean ps_iface_master_add_profile(PsMaster *master, GHashTable *profile_property, gboolean *result, GError **error);
+gboolean ps_iface_master_reset_profile(PsMaster *master, gboolean *result, GError **error);
+
+static void __ps_master_emit_modem_added_signal(PsMaster *master, gpointer modem);
+/*static void __ps_master_emit_modem_removed_signal(PsMaster *master, gpointer modem);*/
+
+static void __remove_modem(gpointer data);
+static void __ps_master_register_key_callback(gpointer master, enum tcore_storage_key key);
+static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *value, void *user_data);
+
+#include "ps-iface-master-glue.h"
+
+static void ps_master_init(PsMaster *master)
+{
+       dbg("ps master init");
+       master->plg = NULL;
+       master->conn = NULL;
+       master->path = PROP_DEFAULT_STR;
+       master->modems = g_hash_table_new_full(g_str_hash,g_str_equal, g_free, __remove_modem);
+       return;
+}
+
+static void ps_master_class_init(PsMasterClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+       dbg("class_init");
+
+       //set property
+       object_class->get_property = __ps_master_get_property;
+       object_class->set_property = __ps_master_set_property;
+
+       //register class to dbus
+       dbus_g_object_type_install_info(PS_TYPE_MASTER, &dbus_glib_ps_iface_master_object_info);
+
+       //add properties
+       g_object_class_install_property(
+                       object_class,
+                       PROP_MASTER_PLUGIN,
+                       g_param_spec_pointer("plg", "PLUGIN", "Plug in Object",
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       g_object_class_install_property(
+                       object_class,
+                       PROP_MASTER_CONN,
+                       g_param_spec_boxed("conn", "CONNECTION", "DBus connection", DBUS_TYPE_G_CONNECTION,
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       g_object_class_install_property(
+                       object_class,
+                       PROP_MASTER_PATH,
+                       g_param_spec_string("path", "Path", "Object path", NULL,
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       //add signal handler
+       signals[SIG_MASTER_MODEM_ADDED] = g_signal_new("modem-added", G_OBJECT_CLASS_TYPE(klass),
+                       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(PsMasterClass, modem_added), NULL, NULL,
+                       g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, DBUS_TYPE_G_STRING_STRING_HASHTABLE);
+
+       signals[SIG_MASTER_MODEM_REMOVED] = g_signal_new("modem-removed", G_OBJECT_CLASS_TYPE(klass),
+                       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(PsMasterClass, modem_removed), NULL, NULL,
+                       g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, DBUS_TYPE_G_OBJECT_PATH);
+
+       return;
+}
+
+static void __ps_master_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+       return;
+}
+
+static void __ps_master_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+       PsMaster *master = PS_MASTER(object);
+
+       switch (prop_id) {
+               case PROP_MASTER_PLUGIN: {
+                       master->plg = g_value_get_pointer(value);
+                       msg("master(%p) set plg(%p)", master, master->plg);
+               }
+                       break;
+               case PROP_MASTER_CONN: {
+                       master->conn = g_value_get_boxed(value);
+                       msg("master(%p) set conn(%p)", master, master->conn);
+               }
+                       break;
+               case PROP_MASTER_PATH: {
+                       if (master->path) g_free(master->path);
+                       master->path = g_value_dup_string(value);
+                       msg("master(%p) set path(%s)", master, master->path);
+               }
+                       break;
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+                       break;
+       } //swtich end
+
+       return;
+}
+
+gboolean ps_iface_master_get_modems(PsMaster *master, DBusGMethodInvocation *context)
+{
+       GError *error = NULL;
+       GHashTableIter iter;
+       gpointer key, value;
+       GHashTable *modems;
+
+       dbg("master get modems interface");
+
+       if (master->modems == NULL) {
+               g_set_error(&error, PS_ERROR, PS_ERR_INTERNAL, "master(%p) does not have modems", master);
+               dbus_g_method_return_error(context, error);
+               return FALSE;
+       }
+
+       modems = g_hash_table_new_full(g_direct_hash, g_str_equal, g_free,
+                       (GDestroyNotify) g_hash_table_destroy);
+
+       g_hash_table_iter_init(&iter, master->modems);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               gchar *path = NULL;
+               GHashTable *properties = NULL;
+               gboolean rv = FALSE;
+
+               properties = g_hash_table_new(g_str_hash, g_str_equal);
+               rv = _ps_modem_get_properties(value, properties);
+               if (rv != TRUE) {
+                       g_set_error(&error, PS_ERROR, PS_ERR_INTERNAL, "fail to get properties modem(%p)",
+                                       value);
+                       dbus_g_method_return_error(context, error);
+                       g_hash_table_destroy(properties);
+                       g_hash_table_destroy(modems);
+                       return TRUE;
+               }
+
+               path = _ps_modem_ref_path(value);
+               g_hash_table_insert(modems, g_strdup(path), properties);
+               dbg("modem (%p) inserted into hash", value);
+       }
+
+       dbus_g_method_return(context, modems);
+       g_hash_table_destroy(modems);
+
+       return TRUE;
+}
+
+gboolean ps_iface_master_get_profile_list(PsMaster *master, DBusGMethodInvocation *context)
+{
+       int index = 0;
+       GError *error = NULL;
+       GHashTableIter iter;
+       gpointer key, value;
+
+       guint len =0;
+       gchar **strv = NULL;
+       GHashTable *contexts = NULL;
+       GSList *profiles = NULL;
+
+       contexts = _ps_context_ref_hashtable();
+       if (contexts == NULL) {
+               err("no profiles");
+               g_set_error(&error, PS_ERROR, PS_ERR_NO_PROFILE, "profile does not exists");
+               dbus_g_method_return_error(context, error);
+               return TRUE;
+       }
+
+       g_hash_table_iter_init(&iter, contexts);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               gchar *s_path = NULL;
+
+               s_path = _ps_context_ref_path(value);
+               dbg("key(%s), value(%p), path(%s)", (gchar *)key, value, s_path);
+               if(s_path)
+                       profiles = g_slist_append(profiles, g_strdup((const gchar*)s_path));
+       }
+
+       if (profiles == NULL) {
+               err("no profiles");
+               g_set_error(&error, PS_ERROR, PS_ERR_NO_PROFILE, "profile does not exists");
+               dbus_g_method_return_error(context, error);
+               return TRUE;
+       }
+
+       len = g_slist_length(profiles);
+       strv = g_new(gchar *, len+1);
+
+       do{
+               strv[index] = g_strdup(profiles->data);
+               index++;
+       }while(  (profiles = g_slist_next(profiles)) );
+       strv[index] = NULL;
+
+       dbus_g_method_return(context, strv);
+       g_strfreev(strv);
+       profiles = g_slist_nth(profiles, 0);
+       g_slist_free_full(profiles, g_free);
+       return TRUE;
+}
+
+gboolean ps_iface_master_add_profile(PsMaster *master, GHashTable *profile_property,
+               gboolean *result, GError **error)
+{
+       GHashTableIter iter;
+       gpointer key, value;
+       gboolean rv = FALSE;
+       gchar *operator = NULL;
+
+       dbg("add profile request");
+
+       g_hash_table_iter_init(&iter, master->modems);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               operator = _ps_modem_ref_operator(value);
+               if(operator)
+                       break;
+       }
+
+       if(!operator){
+               dbg("there is no active modem");
+               g_set_error(error, PS_ERROR, PS_ERR_INTERNAL,"fail to add profile");
+               *result = FALSE;
+               return TRUE;
+       }
+
+       rv = _ps_context_add_context(value, operator, profile_property);
+       if(rv != TRUE){
+               g_set_error(error, PS_ERROR, PS_ERR_INTERNAL,"fail to add profile");
+               *result = FALSE;
+               return TRUE;
+       }
+
+       dbg("success to add profile");
+       *result = TRUE;
+
+       return TRUE;
+}
+
+gboolean ps_iface_master_reset_profile(PsMaster *master, gboolean *result, GError **error)
+{
+       GHashTableIter iter;
+       gpointer key, value;
+       gboolean rv = FALSE;
+       int b_check = 0;
+
+       *result = TRUE;
+
+       dbg("reset profile request");
+
+       if (master->modems == NULL) {
+               dbg("modem does not exist");
+               g_set_error(error, PS_ERROR, PS_ERR_INTERNAL, "fail to get modem");
+               *result = FALSE;
+               return TRUE;
+       }
+
+       b_check = access("/opt/system/csc-default/data/csc-default-data-connection.ini", F_OK);
+       if( b_check != 0 ){
+               dbg("csc file was not there");
+               g_set_error(error, PS_ERROR, PS_ERR_INTERNAL, "no csc data file");
+               *result = FALSE;
+               return TRUE;
+       }
+
+       g_hash_table_iter_init(&iter, master->modems);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               dbg("key(%s), value(%p) context", key, value);
+               _ps_modem_processing_power_enable(value, FALSE);
+               _ps_modem_set_sim_enabled(value, FALSE);
+       }
+
+       _ps_context_reset_hashtable();
+       _ps_context_reset_profile_table();
+       rv = _ps_context_fill_profile_table_from_ini_file();
+
+       g_hash_table_iter_init(&iter, master->modems);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               _ps_get_co_modem_values(value);
+       }
+
+       if(!rv){
+               dbg("csc data was wrong");
+               g_set_error(error, PS_ERROR, PS_ERR_INTERNAL, "fail to load csc data");
+               *result = FALSE;
+       }
+
+       return TRUE;
+}
+
+static void __ps_master_emit_modem_added_signal(PsMaster *master, gpointer modem)
+{
+       GHashTable *properties = NULL;
+
+       properties = g_hash_table_new(g_str_hash, g_str_equal);
+       _ps_modem_get_properties(modem, properties);
+       g_signal_emit(master, signals[SIG_MASTER_MODEM_ADDED], 0, properties);
+       dbg("master (%p) emit the modem(%p) added signal", master, modem);
+       g_hash_table_destroy(properties);
+       return;
+}
+
+/*static void __ps_master_emit_modem_removed_signal(PsMaster *master, gpointer modem)
+{
+       g_signal_emit(master, signals[SIG_MASTER_MODEM_REMOVED], 0, _ps_modem_ref_path(modem));
+       dbg("master (%p) emit the modem(%p) removed signal", master, modem);
+       return;
+}*/
+
+static void __remove_modem(gpointer data)
+{
+       dbg("remove modem (%p)", data);
+       return;
+}
+
+static void __ps_master_register_key_callback(gpointer object, enum tcore_storage_key key)
+{
+       gpointer handle = NULL;
+       PsMaster *master = (PsMaster *) object;
+       Server *s = tcore_plugin_ref_server(master->plg);
+       static Storage *strg;
+
+       strg = tcore_server_find_storage(s, "vconf");
+       handle = tcore_storage_create_handle(strg, "vconf");
+       if (!handle)
+               err("fail to create vconf handle");
+
+       tcore_storage_set_key_callback(strg, key, __ps_master_storage_key_callback, object);
+
+       return;
+}
+
+static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *value, void *user_data)
+{
+       GVariant *tmp = NULL;
+       GHashTableIter iter;
+       gpointer h_key, h_value;
+       gboolean type_check = FALSE;
+       PsMaster *master = (PsMaster *)user_data;
+
+       dbg("storage key(%d) callback", key);
+       g_return_if_fail(master != NULL);
+
+       tmp = (GVariant *)value;
+       if(!tmp){
+               err("value is null");
+               return;
+       }
+
+       type_check = g_variant_is_of_type(tmp, G_VARIANT_TYPE_BOOLEAN);
+       if(!type_check){
+               err("wrong variant data type");
+               g_variant_unref(tmp);
+               return;
+       }
+
+       g_hash_table_iter_init(&iter, master->modems);
+       while (g_hash_table_iter_next(&iter, &h_key, &h_value) == TRUE) {
+               if(key == KEY_3G_ENABLE){
+                       gboolean data_allowed = g_variant_get_boolean(tmp);
+                       _ps_modem_set_data_allowed(h_value, data_allowed);
+               }
+               else if(key == KEY_DATA_ROAMING_SETTING){
+                       gboolean roaming_allowed = g_variant_get_boolean(tmp);
+                       _ps_modem_set_data_roaming_allowed(h_value, roaming_allowed);
+               }
+       }
+
+       g_variant_unref(tmp);
+       return;
+}
+
+gpointer _ps_master_create_master(DBusGConnection *conn, TcorePlugin *p)
+{
+       guint rv;
+       GObject *object;
+       DBusGProxy *proxy;
+       GError *error = NULL;
+
+       dbg("master object create");
+       g_return_val_if_fail(conn != NULL, NULL);
+
+       proxy = dbus_g_proxy_new_for_name(conn, "org.freedesktop.DBus", "/org/freedesktop/DBus",
+                       "org.freedesktop.DBus");
+
+       if (!dbus_g_proxy_call(proxy, "RequestName", &error, G_TYPE_STRING, PS_DBUS_SERVICE,
+                       G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &rv, G_TYPE_INVALID)) {
+               err("Failed to acquire service(%s) error(%s)", PS_DBUS_SERVICE, error->message);
+               return NULL;
+       }
+
+       object = g_object_new(PS_TYPE_MASTER, "plg", p, "conn", conn, "path", PS_MASTER_PATH, NULL);
+       dbus_g_connection_register_g_object(conn, PS_MASTER_PATH, object);
+       msg("master(%p) register dbus path(%s)", object, PS_MASTER_PATH);
+
+       __ps_master_register_key_callback(object, KEY_3G_ENABLE);
+       __ps_master_register_key_callback(object, KEY_DATA_ROAMING_SETTING);
+
+       return object;
+}
+
+gboolean _ps_master_create_modems(gpointer object)
+{
+       Server *s = NULL;
+       GSList *plist = NULL;
+       gpointer modem = NULL, tmp = NULL;
+       PsMaster *master = NULL;
+
+       dbg("create modem objects");
+       g_return_val_if_fail(object != NULL, FALSE);
+
+       master = (PsMaster *) object;
+       s = tcore_plugin_ref_server(master->plg);
+       plist = tcore_server_ref_plugins(s);
+
+       if (NULL == plist) {
+               dbg("fail to get plugin-in list.");
+               return FALSE;
+       }
+
+       for (; plist != NULL; plist = g_slist_next(plist)) {
+               TcorePlugin *p = NULL;
+               CoreObject *co_modem = NULL;
+               GSList *modemlists = NULL;
+               gchar *modem_name = NULL;
+
+               p = plist->data;
+               modemlists = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_MODEM);
+               dbg("plug-in %p, modemlists(%p)", p, modemlists);
+               if (!modemlists)
+                       continue;
+
+               co_modem = modemlists->data;
+               g_slist_free(modemlists);
+
+               modem_name = g_strdup_printf("/%s", tcore_object_ref_name(co_modem));
+               tmp = g_hash_table_lookup(master->modems, modem_name);
+               if (tmp != NULL) {
+                       dbg("modem (%p) already existed", tmp);
+                       continue;
+               }
+
+               modem = _ps_modem_create_modem(master->conn, master->plg, master, modem_name, co_modem);
+               if (modem == NULL) {
+                       dbg("fail to create modem");
+                       return FALSE;
+               }
+
+               g_hash_table_insert(master->modems, g_strdup(modem_name), modem);
+               dbg("modem (%p) created", modem);
+
+               __ps_master_emit_modem_added_signal(master, modem);
+
+               g_free(modem_name);
+       }
+
+       return TRUE;
+}
+
+gboolean _ps_master_get_storage_value(gpointer object, enum tcore_storage_key key)
+{
+       Server *s = NULL;
+       Storage *strg = NULL;
+       PsMaster *master = object;
+
+       g_return_val_if_fail(master != NULL, FALSE);
+       s = tcore_plugin_ref_server(master->plg);
+       strg = tcore_server_find_storage(s, "vconf");
+
+       return tcore_storage_get_bool(strg, key);
+}
+
+gboolean _ps_master_set_storage_value(gpointer object, enum tcore_storage_key key, gboolean value)
+{
+       Server *s = NULL;
+       Storage *strg = NULL;
+       PsMaster *master = object;
+
+       g_return_val_if_fail(master != NULL, FALSE);
+       s = tcore_plugin_ref_server(master->plg);
+       strg = tcore_server_find_storage(s, "vconf");
+
+       return tcore_storage_set_bool(strg, key, value);
+}
diff --git a/src/modem.c b/src/modem.c
new file mode 100644 (file)
index 0000000..ab60e78
--- /dev/null
@@ -0,0 +1,735 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 "ps-modem.h"
+
+#include "ps.h"
+#include "ps-error.h"
+
+#include <server.h>
+#include <plugin.h>
+#include <core_object.h>
+
+#define PROP_DEFAULT   FALSE
+#define PROP_DEFAULT_STR   NULL
+#define BOOL2STRING(a) ((a==TRUE) ? ("TRUE"):("FALSE"))
+
+/*Properties*/
+
+enum {
+       PROP_MODEM_O,
+
+       PROP_MODEM_PATH,
+       PROP_MODEM_MASTER,
+       PROP_MODEM_PLUGIN,
+       PROP_MODEM_COMODEM,
+       PROP_MODEM_CONN,
+};
+
+enum {
+       SIG_MODEM_SERVICE_ADDED,
+       SIG_MODEM_SERVICE_REMOVED,
+       SIG_MODEM_PROPERTY_CHANGED,
+       SIG_MODEM_LAST
+};
+
+static guint32 signals[SIG_MODEM_LAST] = { 0, };
+
+struct PsModemClass {
+       GObjectClass parent;
+
+       //method and signals
+       void (*service_added)(PsModem *modem, gchar *service_path);
+       void (*service_removed)(PsModem *modem, gchar *service_path);
+       void (*property_changed)(PsModem *modem, GHashTable *modem_property);
+};
+
+struct PsModem {
+       GObject parent;
+
+       gchar* path;
+       gpointer p_master;
+       TcorePlugin *plg;
+       CoreObject *co_modem;
+       DBusGConnection *conn;
+
+       /*Value from modem*/
+       gchar* operator;
+       gboolean powered;
+       gboolean sim_init;
+       gboolean flight_mode;
+       gboolean roaming_allowed;
+       gboolean data_allowed;
+
+       GHashTable *services;
+};
+
+G_DEFINE_TYPE(PsModem, ps_modem, G_TYPE_OBJECT);
+
+/*Function Declaration*/
+static void __ps_modem_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void __ps_modem_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+
+gboolean ps_iface_modem_get_properties(PsModem *modem, DBusGMethodInvocation *context);
+gboolean ps_iface_modem_get_services(PsModem *modem, DBusGMethodInvocation *context);
+
+static void __ps_modem_emit_property_changed_signal(PsModem *modem);
+static void __ps_modem_emit_service_added_signal(PsModem *modem, gpointer service);
+/*static void __ps_modem_emit_service_removed_signal(PsModem *modem, gpointer service);*/
+
+static void __remove_service(gpointer data);
+static void __ps_modem_create_service(DBusGConnection *conn, TcorePlugin *p,
+               gpointer modem, CoreObject *co_modem);
+static void __ps_modem_remove_service(PsModem *modem, gpointer service);
+static gboolean __ps_modem_set_powered(PsModem *modem, gboolean value);
+static gboolean __ps_modem_set_sim_complete(PsModem *modem, gboolean value, gchar *operator);
+static void __ps_modem_get_ps_setting_from_storage(GObject *object);
+static void __ps_modem_processing_modem_event(gpointer object);
+
+#include "ps-iface-modem-glue.h"
+
+static void ps_modem_init(PsModem *modem)
+{
+       dbg("modem initialize");
+
+       modem->path = PROP_DEFAULT_STR;
+       modem->p_master = NULL;
+       modem->plg = NULL;
+       modem->co_modem = NULL;
+       modem->conn = NULL;
+
+       modem->operator = PROP_DEFAULT_STR;
+       modem->powered = PROP_DEFAULT;
+       modem->sim_init = PROP_DEFAULT;
+       modem->flight_mode = PROP_DEFAULT;
+       modem->roaming_allowed = PROP_DEFAULT;
+       modem->data_allowed = PROP_DEFAULT;
+
+       modem->services = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, __remove_service);
+       return;
+}
+
+static void ps_modem_class_init(PsModemClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+       //class init
+       dbg("class init");
+
+       object_class->get_property = __ps_modem_get_property;
+       object_class->set_property = __ps_modem_set_property;
+
+       //dbus register
+       dbus_g_object_type_install_info(PS_TYPE_MODEM, &dbus_glib_ps_iface_modem_object_info);
+
+       //add properties
+       g_object_class_install_property(
+                       object_class,
+                       PROP_MODEM_PATH,
+                       g_param_spec_string("path", "PATH", "Modem Path", NULL,
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       g_object_class_install_property(
+                       object_class,
+                       PROP_MODEM_MASTER,
+                       g_param_spec_pointer("p_master", "MASTER", "Master Object",
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       g_object_class_install_property(
+                       object_class,
+                       PROP_MODEM_PLUGIN,
+                       g_param_spec_pointer("plg", "PLUGIN", "Plug in Object",
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       g_object_class_install_property(
+                       object_class,
+                       PROP_MODEM_COMODEM,
+                       g_param_spec_pointer("co_modem", "COREOBJECTMODEM", "CoreObject Modem",
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       g_object_class_install_property(
+                       object_class,
+                       PROP_MODEM_CONN,
+                       g_param_spec_boxed("conn", "CONNECTION", "DBus connection", DBUS_TYPE_G_CONNECTION,
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       //add signal handler
+       signals[SIG_MODEM_SERVICE_ADDED] = g_signal_new("service-added", G_OBJECT_CLASS_TYPE(klass),
+                       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(PsModemClass, service_added), NULL, NULL,
+                       g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, DBUS_TYPE_G_STRING_STRING_HASHTABLE);
+
+       signals[SIG_MODEM_SERVICE_REMOVED] = g_signal_new("service-removed", G_OBJECT_CLASS_TYPE(klass),
+                       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(PsModemClass, service_removed), NULL, NULL,
+                       g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, DBUS_TYPE_G_OBJECT_PATH);
+
+       signals[SIG_MODEM_PROPERTY_CHANGED] = g_signal_new("property-changed",
+                       G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST,
+                       G_STRUCT_OFFSET(PsModemClass, property_changed), NULL, NULL,
+                       g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, DBUS_TYPE_G_STRING_STRING_HASHTABLE);
+
+       return;
+}
+
+static void __ps_modem_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+       return;
+}
+
+static void __ps_modem_set_property(GObject *object, guint prop_id, const GValue *value,
+               GParamSpec *pspec)
+{
+       PsModem *modem = PS_MODEM(object);
+
+       switch (prop_id) {
+               case PROP_MODEM_PATH: {
+                       if (modem->path) g_free(modem->path);
+                       modem->path = g_value_dup_string(value);
+                       msg("modem(%p) set path(%s)", modem, modem->path);
+               }
+                       break;
+               case PROP_MODEM_MASTER: {
+                       modem->p_master = g_value_get_pointer(value);
+                       msg("modem(%p) set master(%p)", modem, modem->p_master);
+               }
+                       break;
+               case PROP_MODEM_PLUGIN: {
+                       modem->plg = g_value_get_pointer(value);
+                       msg("modem(%p) set plg(%p)", modem, modem->plg);
+               }
+                       break;
+               case PROP_MODEM_COMODEM: {
+                       modem->co_modem = g_value_get_pointer(value);
+                       msg("modem(%p) set coreobject modem(%p)", modem, modem->co_modem);
+               }
+                       break;
+               case PROP_MODEM_CONN: {
+                       modem->conn = g_value_get_boxed(value);
+                       msg("modem(%p) set conn(%p)", modem, modem->conn);
+               }
+                       break;
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+                       break;
+       } //swtich end
+
+       return;
+}
+
+gboolean ps_iface_modem_get_properties(PsModem *modem, DBusGMethodInvocation *context)
+{
+       GError *error = NULL;
+       gboolean rv = FALSE;
+       GHashTable *properties = NULL;
+
+       dbg("get modem properties");
+
+       properties = g_hash_table_new(g_str_hash, g_str_equal);
+       rv = _ps_modem_get_properties(modem, properties);
+       if (rv != TRUE) {
+               g_set_error(&error, PS_ERROR, PS_ERR_INTERNAL, "fail to get properties modem(%p)", modem);
+               dbus_g_method_return_error(context, error);
+               g_hash_table_destroy(properties);
+               return FALSE;
+       }
+
+       dbus_g_method_return(context, properties);
+       g_hash_table_destroy(properties);
+
+       return FALSE;
+}
+
+gboolean ps_iface_modem_get_services(PsModem *modem, DBusGMethodInvocation *context)
+{
+       GError *error = NULL;
+       GHashTableIter iter;
+       gpointer key, value;
+       GHashTable *services;
+
+       dbg("modem get service interface");
+
+       if (modem->services == NULL) {
+               g_set_error(&error, PS_ERROR, PS_ERR_INTERNAL, "modem(%p) does not have services",
+                               modem);
+               dbus_g_method_return_error(context, error);
+               return FALSE;
+       }
+
+       services = g_hash_table_new_full(g_direct_hash, g_str_equal, g_free,
+                       (GDestroyNotify) g_hash_table_destroy);
+
+       g_hash_table_iter_init(&iter, modem->services);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               gboolean rv = FALSE;
+               gchar *path = NULL;
+               GHashTable *properties = NULL;
+
+               properties = g_hash_table_new(g_str_hash, g_str_equal);
+               rv = _ps_service_get_properties(value, properties);
+               if (rv != TRUE) {
+                       g_set_error(&error, PS_ERROR, PS_ERR_INTERNAL, "fail to get properties service(%p)",
+                                       value);
+                       dbus_g_method_return_error(context, error);
+                       g_hash_table_destroy(properties);
+                       g_hash_table_destroy(services);
+                       return FALSE;
+               }
+
+               path = _ps_service_ref_path(value);
+               g_hash_table_insert(services, g_strdup(path), properties);
+               dbg("service (%p) inserted into hash", value);
+       }
+
+       dbus_g_method_return(context, services);
+       g_hash_table_destroy(services);
+
+       return TRUE;
+}
+
+static void __ps_modem_emit_property_changed_signal(PsModem *modem)
+{
+       GHashTable *properties = NULL;
+
+       properties = g_hash_table_new(g_str_hash, g_str_equal);
+       _ps_modem_get_properties(modem, properties);
+       g_signal_emit(modem, signals[SIG_MODEM_PROPERTY_CHANGED], 0, properties);
+       dbg("modem (%p) emit property changed signal", modem);
+       g_hash_table_destroy(properties);
+
+       return;
+}
+
+static void __ps_modem_emit_service_added_signal(PsModem *modem, gpointer service)
+{
+       GHashTable *properties = NULL;
+
+       properties = g_hash_table_new(g_str_hash, g_str_equal);
+       _ps_service_get_properties(service, properties);
+       g_signal_emit(modem, signals[SIG_MODEM_SERVICE_ADDED], 0, properties);
+       dbg("modem (%p) emit the service(%p) added signal", modem, service);
+       g_hash_table_destroy(properties);
+       return;
+}
+
+/*static void __ps_modem_emit_service_removed_signal(PsModem *modem, gpointer service)
+{
+       g_signal_emit(modem, signals[SIG_MODEM_SERVICE_REMOVED], 0, _ps_service_ref_path(service));
+       dbg("modem (%p) emit the service(%p) removed signal", modem, service);
+       return;
+}*/
+
+static void __remove_service(gpointer data)
+{
+       return;
+}
+
+static void __ps_modem_create_service(DBusGConnection *conn, TcorePlugin *p,
+               gpointer modem, CoreObject *co_modem)
+{
+       gchar *t_path = NULL;
+       GObject *object = NULL;
+
+       GSList *co_pslist = NULL;
+       GSList *co_networks = NULL;
+       CoreObject *co_ps = NULL;
+       CoreObject *co_network = NULL;
+       TcorePlugin *target_plg = NULL;
+
+       target_plg = tcore_object_ref_plugin(co_modem);
+       co_pslist = tcore_plugin_get_core_objects_bytype(target_plg, CORE_OBJECT_TYPE_PS);
+       if (!co_pslist)
+               return;
+       co_ps = co_pslist->data;
+       g_slist_free(co_pslist);
+
+       co_networks = tcore_plugin_get_core_objects_bytype(target_plg, CORE_OBJECT_TYPE_NETWORK);
+       if (!co_networks)
+               return;
+       co_network = co_networks->data;
+       g_slist_free(co_networks);
+
+       if(!co_ps || !co_network)
+               return;
+
+       t_path = g_strdup_printf("%s_%s", _ps_modem_ref_path(modem), tcore_object_ref_name(co_ps));
+       dbg("service path (%s)", t_path);
+       object = _ps_service_create_service(conn,p, modem, co_network, co_ps, t_path);
+
+       g_hash_table_insert( ((PsModem *) modem)->services, g_strdup(t_path), object);
+       dbg("service (%p) insert to hash", object);
+       __ps_modem_emit_service_added_signal((PsModem *) modem, object);
+
+       g_free(t_path);
+
+       return;
+}
+
+static void __ps_modem_remove_service(PsModem *modem, gpointer service)
+{
+       //unregister dbus
+       dbus_g_connection_unregister_g_object(modem->conn, (GObject *)service);
+       //remove object from hash table
+       g_hash_table_remove(modem->services, _ps_service_ref_path(service));
+       g_object_unref(service);
+
+       return;
+}
+
+static gboolean __ps_modem_set_powered(PsModem *modem, gboolean value)
+{
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       modem->powered = value;
+       dbg("modem(%p) powered(%d)", modem, modem->powered);
+       __ps_modem_emit_property_changed_signal(modem);
+       return TRUE;
+}
+
+static gboolean __ps_modem_set_sim_complete(PsModem *modem, gboolean value, gchar *operator)
+{
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       modem->sim_init = value;
+       if (value && operator != NULL && !modem->operator)
+               modem->operator = g_strdup(operator);
+
+       dbg("modem(%p) sim init(%d) operator(%s)", modem, modem->sim_init, modem->operator);
+       __ps_modem_emit_property_changed_signal(modem);
+       return TRUE;
+}
+
+static gboolean __ps_modem_set_flght_mode(PsModem *modem, gboolean value)
+{
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       modem->flight_mode = value;
+       dbg("modem(%p) flight_mode(%d)", modem, modem->flight_mode);
+       __ps_modem_emit_property_changed_signal(modem);
+       __ps_modem_processing_modem_event(modem);
+
+       return TRUE;
+}
+
+static void __ps_modem_get_ps_setting_from_storage(GObject *object)
+{
+       gboolean key_3g_enable = FALSE, key_roaming_allowed = FALSE;
+       PsModem *modem = NULL;
+
+       modem = (PsModem *) object;
+       key_3g_enable = _ps_master_get_storage_value(modem->p_master, KEY_3G_ENABLE);
+       key_roaming_allowed = _ps_master_get_storage_value(modem->p_master, KEY_DATA_ROAMING_SETTING);
+
+       _ps_modem_set_data_allowed(modem, key_3g_enable);
+       _ps_modem_set_data_roaming_allowed(modem, key_roaming_allowed);
+
+       dbg("data allowed(%d) roaming allowed(%d)", key_3g_enable, key_roaming_allowed);
+
+       return;
+}
+
+static void __ps_modem_processing_modem_event(gpointer object)
+{
+       PsModem * modem = object;
+       GHashTableIter iter;
+       gpointer key, value;
+
+       g_return_if_fail(modem != NULL);
+
+       if(!modem->services)
+               return;
+
+       g_hash_table_iter_init(&iter, modem->services);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               gboolean s_roaming = FALSE;
+
+               s_roaming = _ps_service_get_roaming(value);
+               _ps_update_cellular_state_key(value);
+
+               if(!modem->powered){
+                       _ps_service_remove_contexts(value);
+                       _ps_free_co_ps_event(value);
+                       _ps_free_co_network_event(value);
+                       __ps_modem_remove_service(modem, value);
+                       continue;
+               }
+
+               if(modem->flight_mode || !modem->data_allowed || (s_roaming && !modem->roaming_allowed) ){
+                       _ps_service_disconnect_contexts(value);
+                       continue;
+               }
+
+               //only available case
+               _ps_service_connect_default_context(value);
+       }
+
+       return;
+}
+
+gpointer _ps_modem_create_modem(DBusGConnection *conn, TcorePlugin *p, gpointer master,
+               gchar* modem_name, gpointer co_modem)
+{
+       guint rv = 0;
+       GObject *object;
+       DBusGProxy *proxy;
+       GError *error = NULL;
+
+       dbg("modem object create");
+       g_return_val_if_fail(conn != NULL, NULL);
+       g_return_val_if_fail(master != NULL, NULL);
+
+       proxy = dbus_g_proxy_new_for_name(conn, "org.freedesktop.DBus", "/org/freedesktop/DBus",
+                       "org.freedesktop.DBus");
+
+       if (!dbus_g_proxy_call(proxy, "RequestName", &error, G_TYPE_STRING, PS_DBUS_SERVICE,
+                       G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &rv, G_TYPE_INVALID)) {
+               err("Failed to acquire service(%s) error(%s)", PS_DBUS_SERVICE, error->message);
+               return NULL;
+       }
+
+       object = g_object_new(PS_TYPE_MODEM, "path", modem_name, "p_master", master, "plg", p, "co_modem",
+                       co_modem, "conn", conn, NULL);
+
+       __ps_modem_get_ps_setting_from_storage(object);
+       _ps_hook_co_modem_event(object);
+       _ps_get_co_modem_values(object);
+
+       dbus_g_connection_register_g_object(conn, modem_name, object);
+       msg("modem(%p) register dbus path(%s)", object, modem_name);
+
+       return object;
+}
+
+gboolean _ps_modem_processing_flight_mode(gpointer object, gboolean enable)
+{
+       PsModem * modem = object;
+
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       if (modem->flight_mode == enable)
+               return TRUE;
+
+       __ps_modem_set_flght_mode(modem, enable);
+       return TRUE;
+}
+
+gboolean _ps_modem_processing_power_enable(gpointer object, gboolean enable)
+{
+       PsModem * modem = object;
+
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       if (modem->powered == enable)
+               return TRUE;
+
+       __ps_modem_set_powered(modem, enable);
+       if (enable)
+               __ps_modem_create_service(modem->conn, modem->plg, modem, modem->co_modem);
+       else
+               __ps_modem_processing_modem_event(modem);
+
+       return TRUE;
+}
+
+gboolean _ps_modem_processing_sim_complete(gpointer object, gboolean complete, gchar *operator)
+{
+       PsModem * modem = object;
+       GHashTable *contexts = NULL;
+
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       if (modem->sim_init == complete)
+               return TRUE;
+
+       __ps_modem_set_sim_complete(modem, complete, operator);
+       if (modem->sim_init == TRUE && modem->operator != NULL)
+               contexts = _ps_context_create_hashtable(modem->conn, modem->plg, modem->operator);
+
+       if (contexts != NULL) {
+               GHashTableIter iter;
+               gpointer key, value;
+               g_hash_table_iter_init(&iter, modem->services);
+
+               while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+                       _ps_service_ref_contexts(value, contexts, modem->operator);
+               }
+       }
+
+       return TRUE;
+}
+
+gboolean _ps_modem_set_sim_enabled(gpointer object, gboolean value)
+{
+       PsModem * modem = object;
+
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       modem->sim_init = value;
+       dbg("modem(%p) sim_enabled(%d)", modem, modem->sim_init);
+       return TRUE;
+}
+
+gboolean _ps_modem_set_data_allowed(gpointer object, gboolean value)
+{
+       PsModem * modem = object;
+
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       modem->data_allowed = value;
+       dbg("modem(%p) data allowed(%d)", modem, modem->data_allowed);
+       __ps_modem_emit_property_changed_signal(modem);
+       __ps_modem_processing_modem_event(modem);
+
+       return TRUE;
+}
+
+gboolean _ps_modem_get_data_allowed(gpointer object)
+{
+       PsModem * modem = object;
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       return modem->data_allowed;
+}
+
+gboolean _ps_modem_set_data_roaming_allowed(gpointer object, gboolean roaming_allowed)
+{
+       PsModem * modem = object;
+       GHashTableIter iter;
+       gpointer key, value;
+       gboolean s_roaming = FALSE;
+
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       modem->roaming_allowed = roaming_allowed;
+       dbg("modem(%p) roaming allowed(%d)", modem, modem->roaming_allowed);
+       __ps_modem_emit_property_changed_signal(modem);
+
+       if(!modem->services)
+               return TRUE;
+
+       g_hash_table_iter_init(&iter, modem->services);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               s_roaming = _ps_service_get_roaming(value);
+               break;
+       }
+
+       if(s_roaming)
+               __ps_modem_processing_modem_event(modem);
+
+       return TRUE;
+}
+
+gboolean _ps_modem_get_data_roaming_allowed(gpointer object)
+{
+       PsModem * modem = object;
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       return modem->roaming_allowed;
+}
+
+gboolean _ps_modem_get_flght_mode(gpointer object)
+{
+       PsModem * modem = object;
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       return modem->flight_mode;
+}
+
+gboolean _ps_modem_get_sim_init(gpointer object)
+{
+       PsModem * modem = object;
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       return modem->sim_init;
+}
+
+gboolean _ps_modem_get_power(gpointer object)
+{
+       PsModem * modem = object;
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       return modem->powered;
+}
+
+gchar* _ps_modem_ref_operator(gpointer object)
+{
+       PsModem * modem = object;
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       return modem->operator;
+}
+
+gboolean _ps_modem_get_properties(gpointer object, GHashTable *properties)
+{
+       PsModem *modem = object;
+
+       dbg("get modem properties");
+       g_return_val_if_fail(modem != NULL, FALSE);
+       g_return_val_if_fail(properties != NULL, FALSE);
+
+       g_hash_table_insert(properties, "path", g_strdup(modem->path));
+       g_hash_table_insert(properties, "operator", g_strdup(modem->operator));
+       g_hash_table_insert(properties, "powered", BOOL2STRING(modem->powered));
+       g_hash_table_insert(properties, "sim_init", BOOL2STRING(modem->sim_init));
+       g_hash_table_insert(properties, "flight_mode", BOOL2STRING(modem->flight_mode));
+       g_hash_table_insert(properties, "roaming_allowed", BOOL2STRING(modem->roaming_allowed));
+       g_hash_table_insert(properties, "data_allowed", BOOL2STRING(modem->data_allowed));
+
+       return TRUE;
+}
+
+GHashTable* _ps_modem_ref_services(gpointer object)
+{
+       PsModem *modem = object;
+       g_return_val_if_fail(modem != NULL, NULL);
+
+       return modem->services;
+}
+
+gchar* _ps_modem_ref_path(gpointer object)
+{
+       PsModem *modem = object;
+       g_return_val_if_fail(modem != NULL, NULL);
+
+       return modem->path;
+}
+
+gpointer _ps_modem_ref_plugin(gpointer object)
+{
+       PsModem *modem = object;
+       g_return_val_if_fail(modem != NULL, NULL);
+
+       return modem->plg;
+}
+
+gpointer _ps_modem_ref_dbusconn(gpointer object)
+{
+       PsModem *modem = object;
+       g_return_val_if_fail(modem != NULL, NULL);
+
+       return modem->conn;
+}
+
+gpointer _ps_modem_ref_co_modem(gpointer object)
+{
+       PsModem *modem = object;
+       g_return_val_if_fail(modem != NULL, NULL);
+
+       return modem->co_modem;
+}
diff --git a/src/ps-plugin.conf b/src/ps-plugin.conf
new file mode 100644 (file)
index 0000000..92be767
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+    <policy user="0">
+        <allow own=""/>
+        <allow send_destination="com.tcore.ps"/>
+        <allow send_interface="com.tcore.ps.master"/>
+        <allow send_interface="com.tcore.ps.modem"/>
+        <allow send_interface="com.tcore.ps.service"/>
+        <allow send_interface="com.tcore.ps.context"/>
+    </policy>
+    <policy user="5000">
+        <allow own="com.tcore.ps"/>
+        <allow send_destination="com.tcore.ps"/>
+        <allow send_interface="com.tcore.ps.master"/>
+        <allow send_interface="com.tcore.ps.modem"/>
+        <allow send_interface="com.tcore.ps.service"/>
+        <allow send_interface="com.tcore.ps.context"/>
+    </policy>
+    <policy at_console="true">
+        <allow send_destination="com.tcore.ps"/>
+    </policy>
+    <policy context="default">
+        <deny send_destination="com.tcore.ps"/>
+    </policy>
+</busconfig>
diff --git a/src/service.c b/src/service.c
new file mode 100644 (file)
index 0000000..bd4fd79
--- /dev/null
@@ -0,0 +1,960 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 "ps-service.h"
+
+#include "ps.h"
+#include "ps-error.h"
+
+#include <core_object.h>
+#include <co_ps.h>
+
+#define PROP_DEFAULT   FALSE
+#define PROP_DEFAULT_STR   NULL
+#define BOOL2STRING(a) ((a==TRUE) ? ("TRUE"):("FALSE"))
+
+#define TIMEOUT_DEFAULT                5
+#define TIMEOUT_MAX                    1280
+
+guint connection_timeout;
+guint timer_src;
+
+/*Properties*/
+
+enum {
+       PROP_SERVICE_O,
+
+       PROP_SERVICE_PATH,
+       PROP_SERVICE_PLUGIN,
+       PROP_SERVICE_CONN,
+       PROP_SERVICE_P_MODEM,
+       PROP_SERVICE_CO_NETWORK,
+       PROP_SERVICE_CO_PS
+};
+
+enum {
+       SIG_SERVICE_CONTEXT_ADDED,
+       SIG_SERVICE_CONTEXT_REMOVED,
+       SIG_SERVICE_PROPERTY_CHANGED,
+       SIG_SERVICE_LAST
+};
+
+static guint32 signals[SIG_SERVICE_LAST] = {0,};
+
+struct PsServiceClass {
+       GObjectClass parent;
+
+       //method and signals
+       void (*context_added)(PsService *service, gchar *context_path);
+       void (*context_removed)(PsService *service, gchar *context_path);
+       void (*property_changed)(PsService *service, GHashTable *service_property);
+};
+
+struct PsService {
+       GObject parent;
+
+       gchar *path;
+       TcorePlugin *plg;
+       DBusGConnection *conn;
+       gpointer p_modem;
+       CoreObject *co_network;
+       CoreObject *co_ps;
+
+       gboolean ps_attached;
+       gboolean roaming;
+       enum telephony_network_access_technology act;
+
+       GHashTable *contexts;
+};
+
+G_DEFINE_TYPE(PsService, ps_service, G_TYPE_OBJECT);
+
+/*Function Declaration*/
+static void __ps_service_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void __ps_service_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+
+gboolean ps_iface_service_get_properties(PsService *service, DBusGMethodInvocation *context);
+gboolean ps_iface_service_get_contexts(PsService *service, DBusGMethodInvocation *context);
+
+static void __ps_service_emit_property_changed_signal(PsService *service);
+static void __ps_service_emit_context_added_signal(PsService *service, gpointer context);
+static void __ps_service_emit_context_removed_signal(PsService *service, gpointer context);
+
+static void __remove_context(gpointer data);
+static char *__ps_service_act2string(enum telephony_network_access_technology act);
+static gboolean __ps_service_check_connection_option(gpointer service);
+static gboolean __ps_service_connetion_timeout_handler(gpointer user_data);
+
+#include "ps-iface-service-glue.h"
+
+static void ps_service_init(PsService *service)
+{
+       dbg("service initialize");
+
+       service->path = PROP_DEFAULT_STR;
+       service->plg = NULL;
+       service->conn = NULL;
+       service->p_modem = NULL;
+       service->co_network = NULL;
+       service->co_ps = NULL;
+
+       service->ps_attached = PROP_DEFAULT;
+       service->roaming = PROP_DEFAULT;
+       service->act = NETWORK_ACT_UNKNOWN;
+
+       service->contexts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, __remove_context);
+       return;
+}
+
+static void ps_service_class_init(PsServiceClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+       //class init
+       dbg("class init");
+
+       object_class->get_property = __ps_service_get_property;
+       object_class->set_property = __ps_service_set_property;
+
+       //dbus register
+       dbus_g_object_type_install_info(PS_TYPE_SERVICE, &dbus_glib_ps_iface_service_object_info);
+
+       //add properties
+       g_object_class_install_property(
+                       object_class,
+                       PROP_SERVICE_PATH,
+                       g_param_spec_string("path", "PATH", "Technology Path", NULL,
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       g_object_class_install_property(
+                       object_class,
+                       PROP_SERVICE_P_MODEM,
+                       g_param_spec_pointer("p_modem", "MODEM", "Parent Modem Object",
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       g_object_class_install_property(
+                       object_class,
+                       PROP_SERVICE_PLUGIN,
+                       g_param_spec_pointer("plg", "PLUGIN", "Plug in Object",
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       g_object_class_install_property(
+                       object_class,
+                       PROP_SERVICE_CO_NETWORK,
+                       g_param_spec_pointer("co_network", "COREOBJECT NETWORK", "CoreObject of Network",
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       g_object_class_install_property(
+                       object_class,
+                       PROP_SERVICE_CO_PS,
+                       g_param_spec_pointer("co_ps", "COREOBJECTPS", "CoreObject of PS",
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       g_object_class_install_property(
+                       object_class,
+                       PROP_SERVICE_CONN,
+                       g_param_spec_boxed("conn", "CONNECTION", "DBus connection", DBUS_TYPE_G_CONNECTION,
+                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+       //add signal handler
+       signals[SIG_SERVICE_CONTEXT_ADDED] = g_signal_new("context-added", G_OBJECT_CLASS_TYPE(klass),
+                       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(PsServiceClass, context_added), NULL, NULL,
+                       g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, DBUS_TYPE_G_STRING_STRING_HASHTABLE);
+
+       signals[SIG_SERVICE_CONTEXT_REMOVED] = g_signal_new("context-removed",
+                       G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST,
+                       G_STRUCT_OFFSET(PsServiceClass, context_removed), NULL, NULL,
+                       g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, DBUS_TYPE_G_OBJECT_PATH);
+
+       signals[SIG_SERVICE_PROPERTY_CHANGED] = g_signal_new("property-changed",
+                       G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST,
+                       G_STRUCT_OFFSET(PsServiceClass, property_changed), NULL, NULL,
+                       g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, DBUS_TYPE_G_STRING_STRING_HASHTABLE);
+
+       return;
+}
+
+static void __ps_service_get_property(GObject *object, guint prop_id, GValue *value,
+               GParamSpec *pspec)
+{
+       return;
+}
+
+static void __ps_service_set_property(GObject *object, guint prop_id, const GValue *value,
+               GParamSpec *pspec)
+{
+       PsService *service = PS_SERVICE(object);
+
+       switch (prop_id) {
+               case PROP_SERVICE_PATH: {
+                       if (service->path) g_free(service->path);
+                       service->path = g_value_dup_string(value);
+                       msg("service(%p) set path(%s)", service, service->path);
+               }
+                       break;
+               case PROP_SERVICE_P_MODEM: {
+                       service->p_modem = g_value_get_pointer(value);
+                       msg("service(%p) set modem(%p)", service, service->p_modem);
+               }
+                       break;
+               case PROP_SERVICE_PLUGIN: {
+                       service->plg = g_value_get_pointer(value);
+                       msg("service(%p) set plg(%p)", service, service->plg);
+               }
+                       break;
+               case PROP_SERVICE_CO_NETWORK: {
+                       service->co_network = g_value_get_pointer(value);
+                       msg("service(%p) set co_network(%p)", service, service->co_network);
+               }
+                       break;
+               case PROP_SERVICE_CO_PS: {
+                       service->co_ps = g_value_get_pointer(value);
+                       msg("service(%p) set co_ps(%p)", service, service->co_ps);
+               }
+                       break;
+               case PROP_SERVICE_CONN: {
+                       service->conn = g_value_get_boxed(value);
+                       msg("service(%p) set conn(%p)", service, service->conn);
+               }
+                       break;
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+                       break;
+       } //swtich end
+
+       return;
+}
+
+gboolean ps_iface_service_get_properties(PsService *service, DBusGMethodInvocation *context)
+{
+       GError *error = NULL;
+       gboolean rv = FALSE;
+       GHashTable *properties = NULL;
+
+       dbg("get service properties");
+
+       properties = g_hash_table_new(g_str_hash, g_str_equal);
+       rv = _ps_service_get_properties(service, properties);
+       if (rv != TRUE) {
+               g_set_error(&error, PS_ERROR, PS_ERR_INTERNAL, "fail to get properties service(%p)",
+                               service);
+               dbus_g_method_return_error(context, error);
+               g_hash_table_destroy(properties);
+               return FALSE;
+       }
+
+       dbus_g_method_return(context, properties);
+       g_hash_table_destroy(properties);
+       return TRUE;
+}
+
+gboolean ps_iface_service_get_contexts(PsService *service, DBusGMethodInvocation *context)
+{
+       GError *error = NULL;
+       GHashTableIter iter;
+       gpointer key, value;
+       GHashTable *contexts;
+
+       dbg("service get contexts interface");
+
+       if (service->contexts == NULL) {
+               g_set_error(&error, PS_ERROR, PS_ERR_INTERNAL, "service(%p) does not have contexts",
+                               service);
+               dbus_g_method_return_error(context, error);
+               return FALSE;
+       }
+
+       contexts = g_hash_table_new_full(g_direct_hash, g_str_equal, g_free,
+                       (GDestroyNotify) g_hash_table_destroy);
+
+       g_hash_table_iter_init(&iter, service->contexts);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               gboolean rv = FALSE;
+               gchar *path = NULL;
+               GHashTable *properties = NULL;
+
+               properties = g_hash_table_new(g_str_hash, g_str_equal);
+               rv = _ps_context_get_properties(value, properties);
+               if (rv != TRUE) {
+                       g_set_error(&error, PS_ERROR, PS_ERR_INTERNAL, "fail to get properties context(%p)",
+                                       value);
+                       dbus_g_method_return_error(context, error);
+                       g_hash_table_destroy(properties);
+                       g_hash_table_destroy(contexts);
+                       return FALSE;
+               }
+
+               path = _ps_context_ref_path(value);
+               g_hash_table_insert(contexts, g_strdup(path), properties);
+               dbg("service (%p) inserted into hash", value);
+       }
+
+       dbus_g_method_return(context, contexts);
+       g_hash_table_destroy(contexts);
+
+       return TRUE;
+}
+
+static void __ps_service_emit_property_changed_signal(PsService *service)
+{
+       GHashTable *properties = NULL;
+
+       properties = g_hash_table_new(g_str_hash, g_str_equal);
+       _ps_service_get_properties(service, properties);
+       g_signal_emit(service, signals[SIG_SERVICE_PROPERTY_CHANGED], 0, properties);
+       dbg("service (%p) emit property changed signal", service);
+       g_hash_table_destroy(properties);
+
+       return;
+}
+
+static void __ps_service_emit_context_added_signal(PsService *service, gpointer context)
+{
+       GHashTable *properties = NULL;
+
+       properties = g_hash_table_new(g_str_hash, g_str_equal);
+       _ps_context_get_properties(context, properties);
+       g_signal_emit(service, signals[SIG_SERVICE_CONTEXT_ADDED], 0, properties);
+       dbg("service (%p) emit the context(%p) added signal", service, context);
+       g_hash_table_destroy(properties);
+       return;
+}
+
+static void __ps_service_emit_context_removed_signal(PsService *service, gpointer context)
+{
+       g_signal_emit(service, signals[SIG_SERVICE_CONTEXT_REMOVED], 0, _ps_context_ref_path(context));
+       dbg("service (%p) emit the context(%p) removed signal", service, context);
+       return;
+}
+
+static void __remove_context(gpointer data)
+{
+       return;
+}
+
+static char *__ps_service_act2string(enum telephony_network_access_technology act)
+{
+       switch (act) {
+               case NETWORK_ACT_GSM:
+               case NETWORK_ACT_GPRS:
+               case NETWORK_ACT_EGPRS:
+               case NETWORK_ACT_UMTS:
+               case NETWORK_ACT_GSM_UTRAN:
+                       return "GSM";
+               case NETWORK_ACT_IS95A:
+               case NETWORK_ACT_IS95B:
+               case NETWORK_ACT_CDMA_1X:
+               case NETWORK_ACT_EVDO_REV0:
+               case NETWORK_ACT_CDMA_1X_EVDO_REV0:
+               case NETWORK_ACT_EVDO_REVA:
+               case NETWORK_ACT_CDMA_1X_EVDO_REVA:
+               case NETWORK_ACT_EVDV:
+                       return "CDMA";
+               case NETWORK_ACT_LTE:
+                       return "LTE";
+               case NETWORK_ACT_UNKNOWN:
+               default:
+                       return "unknown";
+       }
+
+       return NULL;
+}
+
+static gboolean __ps_service_check_connection_option(gpointer object)
+{
+       gboolean b_connect = TRUE;
+       gboolean power, sim, data, flight;
+       PsService *service = object;
+
+       if(service->roaming){
+               b_connect &=_ps_modem_get_data_roaming_allowed(service->p_modem);
+       }
+
+       power = _ps_modem_get_power(service->p_modem);
+       sim = _ps_modem_get_sim_init(service->p_modem);
+       data = _ps_modem_get_data_allowed(service->p_modem);
+       flight = _ps_modem_get_flght_mode(service->p_modem);
+       b_connect &= power;
+       b_connect &= sim;
+       b_connect &= data;
+       b_connect &= !flight;
+       dbg("power(%d), sim init(%d), data allowed(%d), filght mode(%d)", power, sim, data, flight);
+
+       return b_connect;
+}
+
+static gboolean __ps_service_connetion_timeout_handler(gpointer context)
+{
+       int rv = 0;
+       PsService *service = NULL;
+
+       service = _ps_context_ref_service(context);
+       rv = _ps_service_activate_context(service, context);
+       dbg("return rv(%d)", rv);
+
+       return FALSE;
+}
+
+gpointer _ps_service_create_service(DBusGConnection *conn, TcorePlugin *p, gpointer p_modem,
+               CoreObject *co_network, CoreObject *co_ps, gchar* path)
+{
+       guint rv = 0;
+       GObject *object;
+       DBusGProxy *proxy;
+       GError *error = NULL;
+
+       dbg("service object create");
+       g_return_val_if_fail(conn != NULL, NULL);
+       g_return_val_if_fail(p_modem != NULL, NULL);
+
+       proxy = dbus_g_proxy_new_for_name(conn, "org.freedesktop.DBus", "/org/freedesktop/DBus",
+                       "org.freedesktop.DBus");
+
+       if (!dbus_g_proxy_call(proxy, "RequestName", &error, G_TYPE_STRING, PS_DBUS_SERVICE,
+                       G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &rv, G_TYPE_INVALID)) {
+               err("Failed to acquire context(%s) error(%s)", PS_DBUS_SERVICE, error->message);
+               return NULL;
+       }
+
+       object = g_object_new(PS_TYPE_SERVICE, "conn", conn, "plg", p, "p_modem", p_modem, "co_network",
+                       co_network, "co_ps", co_ps, "path", path, NULL);
+
+       _ps_hook_co_network_event(object);
+       _ps_get_co_network_values(object);
+       _ps_hook_co_ps_event(object);
+
+       dbus_g_connection_register_g_object(conn, path, object);
+       msg("service(%p) register dbus path(%s)", object, path);
+
+       return object;
+}
+
+gboolean _ps_service_ref_context(gpointer object, gpointer context)
+{
+       gpointer tmp = NULL;
+       gchar *s_path = NULL;
+       PsService *service = object;
+
+       dbg("service refer to context");
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       s_path = _ps_context_ref_path(context);
+       tmp = g_hash_table_lookup(service->contexts, s_path);
+       if (tmp != NULL) {
+               dbg("context(%p) already existed", tmp);
+               return FALSE;
+       }
+
+       _ps_context_set_service(context, service);
+       tcore_ps_add_context(service->co_ps, (CoreObject *) _ps_context_ref_co_context(context));
+       g_hash_table_insert(service->contexts, g_strdup(s_path), context);
+
+       dbg("context(%p) insert to hash", context);
+       __ps_service_emit_context_added_signal(service, context);
+
+       //_ps_service_connect_default_context(service);
+       return TRUE;
+}
+
+gboolean _ps_service_ref_contexts(gpointer object, GHashTable *contexts, gchar *operator)
+{
+       GHashTableIter iter;
+       gpointer key, value;
+       PsService *service = object;
+       gboolean ret = TRUE;
+       int rv;
+
+       dbg("service refer to contexts");
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       g_hash_table_iter_init(&iter, contexts);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               gchar *s_path = NULL;
+               gpointer tmp = NULL;
+               gboolean f_awo = FALSE;
+
+               s_path = _ps_context_ref_path(value);
+               tmp = g_hash_table_lookup(service->contexts, s_path);
+               if (tmp != NULL) {
+                       dbg("context(%p) already existed", tmp);
+                       continue;
+               }
+
+               _ps_context_set_service(value, service);
+               tcore_ps_add_context(service->co_ps, (CoreObject *) _ps_context_ref_co_context(value));
+               g_hash_table_insert(service->contexts, g_strdup(s_path), value);
+
+               dbg("context(%p) insert to hash", value);
+               __ps_service_emit_context_added_signal(service, value);
+       
+               f_awo = _ps_context_get_alwayson_enable(value);
+               if(f_awo){
+                       rv = _ps_service_define_context(service, value);
+                       dbg("return rv(%d)", rv);
+               }
+       }
+
+       _ps_update_cellular_state_key(service);
+       //_ps_service_connect_default_context(service); 
+       return ret;
+}
+
+gboolean _ps_service_unref_context(gpointer object, gpointer context)
+{
+       PsService *service = object;
+
+       dbg("service unref contexts");
+       g_return_val_if_fail(service != NULL, FALSE);
+       g_return_val_if_fail(context != NULL, FALSE);
+
+       dbg("remove context(%p) from service(%p)", context, service);
+       tcore_ps_remove_context(service->co_ps, (CoreObject *) _ps_context_ref_co_context(context));
+       g_hash_table_remove(service->contexts, _ps_context_ref_path(context));
+       __ps_service_emit_context_removed_signal(service, context);
+
+       return TRUE;
+}
+
+gboolean _ps_service_get_properties(gpointer object, GHashTable *properties)
+{
+       PsService *service = object;
+
+       dbg("get service properties");
+       g_return_val_if_fail(service != NULL, FALSE);
+       g_return_val_if_fail(properties != NULL, FALSE);
+
+       g_hash_table_insert(properties, "path", g_strdup(service->path));
+       g_hash_table_insert(properties, "ps_attached", BOOL2STRING(service->ps_attached));
+       g_hash_table_insert(properties, "roaming", BOOL2STRING(service->roaming));
+       g_hash_table_insert(properties, "act", __ps_service_act2string(service->act));
+
+       return TRUE;
+}
+
+gchar* _ps_service_ref_path(gpointer object)
+{
+       PsService *service = object;
+       g_return_val_if_fail(service != NULL, NULL);
+
+       return service->path;
+}
+
+gpointer _ps_service_ref_plugin(gpointer object)
+{
+       PsService *service = object;
+       g_return_val_if_fail(service != NULL, NULL);
+
+       return service->plg;
+}
+
+gpointer _ps_service_ref_co_network(gpointer object)
+{
+       PsService *service = object;
+       g_return_val_if_fail(service != NULL, NULL);
+
+       return service->co_network;
+}
+
+gpointer _ps_service_ref_co_ps(gpointer object)
+{
+       PsService *service = object;
+       g_return_val_if_fail(service != NULL, NULL);
+
+       return service->co_ps;
+}
+
+gboolean _ps_service_set_context_info(gpointer object, struct tnoti_ps_pdp_ipconfiguration *devinfo)
+{
+       GSList* contexts = NULL;
+       PsService *service = object;
+
+       dbg("set context info");
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       contexts = tcore_ps_ref_context_by_id(service->co_ps, devinfo->context_id);
+
+       if (NULL == contexts) {
+               dbg("fail to ref context by cid.");
+               return FALSE;
+       }
+       
+       for (; contexts != NULL; contexts = g_slist_next(contexts)) {
+               CoreObject *co_context = NULL;
+
+               co_context = contexts->data;
+               if (NULL == co_context)
+                       continue;
+
+               tcore_context_set_devinfo(co_context, devinfo);
+       }
+
+       return TRUE;
+}
+
+int _ps_service_define_context(gpointer object, gpointer context)
+{
+       PsService *service = object;
+       CoreObject *co_context = NULL;
+       gboolean b_connect = TRUE;
+
+       dbg("define context(%p)", context);
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       co_context = (CoreObject *)_ps_context_ref_co_context(context);
+
+       b_connect = __ps_service_check_connection_option(service);
+       if(!b_connect)
+               return TCORE_RETURN_EPERM;
+
+       return tcore_ps_define_context(service->co_ps, co_context, NULL);
+}
+
+int _ps_service_activate_context(gpointer object, gpointer context)
+{
+       PsService *service = object;
+       CoreObject *co_context = NULL;
+       gboolean b_connect = TRUE;
+       gboolean ps_defined;
+       int ret = TCORE_RETURN_FAILURE;
+
+       dbg("activate context(%p)", context);
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       co_context = (CoreObject *)_ps_context_ref_co_context(context);
+
+       b_connect = __ps_service_check_connection_option(service);      
+       b_connect &= service->ps_attached;
+       if(!b_connect)
+               return TCORE_RETURN_EPERM;
+
+       ps_defined = _ps_context_get_ps_defined(context);
+       if(!ps_defined) {
+               dbg("pdp profile is not defined yet, define first. ");
+               ret = tcore_ps_define_context(service->co_ps, co_context, NULL);
+       }
+       else {
+               dbg("pdp profile is defined, activate context. ");
+               ret = tcore_ps_activate_context(service->co_ps, co_context, NULL);
+       }
+       
+       return ret;
+}
+
+gboolean _ps_service_deactivate_context(gpointer object, gpointer context)
+{
+       PsService *service = object;
+       CoreObject *co_context = NULL;
+
+       dbg("deactivate context(%p)", context);
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       co_context = (CoreObject *)_ps_context_ref_co_context(context);
+
+       return tcore_ps_deactivate_context(service->co_ps, co_context, NULL);
+}
+
+void _ps_service_connection_timer(gpointer object, gpointer context)
+{
+       gboolean f_awo = FALSE;
+
+       f_awo = _ps_context_get_alwayson_enable(context);
+       if(!f_awo)
+               return;
+
+       timer_src = g_timeout_add_seconds(connection_timeout, __ps_service_connetion_timeout_handler, context);
+
+       dbg("cellular service timer started timer src(%d), timeout(%d)", timer_src, connection_timeout);
+       connection_timeout = connection_timeout*2;
+       if(connection_timeout > TIMEOUT_MAX)
+               connection_timeout = TIMEOUT_MAX;
+
+       return;
+}
+
+void _ps_service_reset_connection_timer(gpointer context)
+{
+       gboolean f_awo = FALSE;
+
+       f_awo = _ps_context_get_alwayson_enable(context);
+       if(!f_awo)
+               return;
+
+       connection_timeout = TIMEOUT_DEFAULT;
+
+       if (timer_src != 0) {
+               dbg("remove connection retry timer (%d)", timer_src);
+               g_source_remove(timer_src);
+               timer_src = 0;
+       }
+
+       return;
+}
+
+void _ps_service_remove_contexts(gpointer object)
+{
+       GHashTableIter iter;
+       gpointer key, value;
+       PsService *service = object;
+
+       dbg("service remove all contexts");
+       g_return_if_fail(service != NULL);
+
+       g_hash_table_iter_init(&iter, service->contexts);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               gpointer co_context = NULL;
+
+               dbg("key(%s), value(%p) context", key, value);
+               co_context = _ps_context_ref_co_context(value);
+
+               _ps_service_reset_connection_timer(value);
+               _ps_context_set_alwayson_enable(value, FALSE);
+               _ps_service_deactivate_context(service, value);
+               _ps_context_set_connected(value, FALSE);
+               tcore_ps_remove_context(service->co_ps, co_context);
+               tcore_context_free(co_context);
+
+               __ps_service_emit_context_removed_signal(service, value);
+               _ps_context_remove_context(value);
+       }
+
+       g_hash_table_remove_all(service->contexts);
+       return;
+}
+
+void _ps_service_disconnect_contexts(gpointer object)
+{
+       GHashTableIter iter;
+       gpointer key, value;
+       PsService *service = object;
+
+       dbg("service disconnect all contexts");
+       g_return_if_fail(service != NULL);
+
+       g_hash_table_iter_init(&iter, service->contexts);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               _ps_service_reset_connection_timer(value);
+               _ps_service_deactivate_context(service, value);
+       }
+
+       return;
+}
+
+void _ps_service_connect_default_context(gpointer object)
+{
+       GHashTableIter iter;
+       gpointer key, value;
+       PsService *service = object;
+
+       dbg("service connect default context");
+       g_return_if_fail(service != NULL);
+
+       g_hash_table_iter_init(&iter, service->contexts);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               gboolean f_awo = FALSE;
+               f_awo = _ps_context_get_alwayson_enable(value);
+
+               if(f_awo){
+                       int rv = 0;
+                       _ps_service_reset_connection_timer(value);
+                       rv = _ps_service_activate_context(service, value);
+                       dbg("return rv(%d)", rv);
+                       break;
+               }
+       }
+
+       return;
+}
+
+gpointer _ps_service_return_default_context(gpointer object)
+{
+       GHashTableIter iter;
+       gpointer key, value;
+       PsService *service = object;
+
+       g_return_val_if_fail(service != NULL, NULL);
+
+       g_hash_table_iter_init(&iter, service->contexts);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               gboolean b_default = FALSE;
+               b_default = _ps_context_get_default_internet(value);
+
+               if(b_default){
+                       return value;
+               }
+       }
+
+       return NULL;
+}
+
+gboolean _ps_service_processing_network_event(gpointer object, gboolean ps_attached, gboolean roaming)
+{
+       PsService *service = object;
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       _ps_update_cellular_state_key(service);
+       if(service->ps_attached == ps_attached && service->roaming == roaming)
+               return TRUE;
+
+       _ps_service_set_ps_attached(service, ps_attached);
+       _ps_service_set_roaming(service, roaming);
+
+       if(service->ps_attached)
+               _ps_service_connect_default_context(service);
+
+       return TRUE;
+}
+
+gboolean _ps_service_set_connected(gpointer object, int context_id, gboolean enabled)
+{
+       GHashTableIter iter;
+       gpointer key, value;
+       PsService *service = NULL;
+
+       service = (PsService *) object;
+       g_hash_table_iter_init(&iter, service->contexts);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               CoreObject *context = NULL;
+               int tmp_cid;
+
+               context = _ps_context_ref_co_context(value);
+               tmp_cid = tcore_context_get_id(context);
+
+               if (tmp_cid != context_id) continue;
+
+               if(!enabled)
+                       tcore_ps_clear_context_id(service->co_ps, context);
+
+               _ps_context_set_connected(value, enabled);
+       }
+
+       return TRUE;
+}
+
+void _ps_service_set_ps_defined(gpointer *object, gboolean value, int cid)
+{      
+       PsService *service = (PsService*)object;
+       GHashTableIter iter;
+       gpointer key, out;      
+
+       g_return_if_fail(service != NULL);
+
+       g_hash_table_iter_init(&iter, service->contexts);
+       while (g_hash_table_iter_next(&iter, &key, &out) == TRUE) {             
+               gboolean r_actvate = 0;
+               r_actvate = _ps_context_set_ps_defined(out, value, cid);
+               r_actvate &= value;
+               if(r_actvate) {
+                       int rv;
+                       dbg("define is complete, activate context for cid(%d)", cid);
+                       rv = _ps_service_activate_context(service, out);
+                       dbg("rv(%d)",rv);
+                       break;
+               }
+       }
+               
+       return;
+}
+
+gboolean _ps_service_set_ps_attached(gpointer object, gboolean value)
+{
+       PsService *service = object;
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       service->ps_attached = value;
+       dbg("service(%p) ps_attached(%d)", service, service->ps_attached);
+
+       return TRUE;
+}
+
+gboolean _ps_service_get_roaming(gpointer object)
+{
+       PsService *service = object;
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       return service->roaming;
+}
+
+gboolean _ps_service_set_roaming(gpointer object, gboolean value)
+{
+       PsService *service = object;
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       service->roaming = value;
+       dbg("service(%p) roaming(%d)", service, service->roaming);
+       __ps_service_emit_property_changed_signal(service);
+
+       return TRUE;
+}
+
+gboolean _ps_service_set_access_technology(gpointer object,
+               enum telephony_network_access_technology value)
+{
+       PsService *service = object;
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       service->act = value;
+       dbg("service(%p) Access Technology(%d)", service, service->act);
+
+       if(service->act > NETWORK_ACT_UNKNOWN && service->act < NETWORK_ACT_NOT_SPECIFIED){
+               _ps_update_cellular_state_key(service);
+               _ps_service_connect_default_context(service);
+       }
+
+       return TRUE;
+}
+
+enum telephony_ps_state _ps_service_check_cellular_state(gpointer object)
+{
+       gboolean state = FALSE;
+       PsService *service = object;
+       g_return_val_if_fail(service != NULL, TELEPHONY_PS_NO_SERVICE);
+
+       state = _ps_modem_get_power(service->p_modem);
+       if(!state){
+               return TELEPHONY_PS_NO_SERVICE;
+       }
+
+       state = _ps_modem_get_sim_init(service->p_modem);
+       if(!state){
+               return TELEPHONY_PS_NO_SERVICE;
+       }
+
+       if(!service->ps_attached){
+               return TELEPHONY_PS_NO_SERVICE;
+       }
+
+       state = _ps_modem_get_flght_mode(service->p_modem);
+       if(state){
+               return TELEPHONY_PS_FLIGHT_MODE;
+       }
+
+       state = _ps_modem_get_data_roaming_allowed(service->p_modem);
+       if(service->roaming && !state){
+               return TELEPHONY_PS_ROAMING_OFF;
+       }
+
+       state = _ps_modem_get_data_allowed(service->p_modem);
+       if(!state){
+               return TELEPHONY_PS_3G_OFF;
+       }
+
+       return TELEPHONY_PS_ON;
+}
diff --git a/src/tcore-interface.c b/src/tcore-interface.c
new file mode 100644 (file)
index 0000000..43c2b3e
--- /dev/null
@@ -0,0 +1,364 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@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 "ps.h"
+
+#include <server.h>
+#include <plugin.h>
+#include <storage.h>
+#include <co_ps.h>
+#include <co_modem.h>
+#include <co_sim.h>
+#include <co_network.h>
+
+static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *source,
+               enum tcore_notification_command command, unsigned int data_len, void *data,
+               void *user_data)
+{
+       gpointer service = user_data;
+       struct tnoti_ps_call_status *cstatus = NULL;
+
+       dbg("call status event");
+       g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
+
+       cstatus = (struct tnoti_ps_call_status *) data;
+       dbg("call status event cid(%d) state(%d) reason(%d)",
+                       cstatus->context_id, cstatus->state, cstatus->result);
+
+       //send activation event / deactivation event
+       if (cstatus->state == 0) {/* OK: PDP define is complete. */
+               dbg("service is ready to activate");
+               _ps_service_set_ps_defined(service, TRUE, cstatus->context_id);
+               //_ps_service_connect_default_context(service);
+       }
+       else if (cstatus->state == 1) {/* CONNECTED */
+               dbg("service is activated");
+               _ps_service_set_connected(service, cstatus->context_id, TRUE);
+       }
+       else if (cstatus->state == 3) { /* NO CARRIER */
+               dbg("service is deactivated");
+               _ps_service_set_ps_defined(service, FALSE, cstatus->context_id);
+               _ps_service_set_connected(service, cstatus->context_id, FALSE);
+       }
+
+       return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return __on_hook_session_data_counter(Server *s, CoreObject *source,
+               enum tcore_notification_command command, unsigned int data_len, void *data,
+               void *user_data)
+{
+       g_return_val_if_fail(user_data != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
+
+       dbg("session data counter event");
+
+       return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return __on_hook_ipconfiguration(Server *s, CoreObject *source,
+               enum tcore_notification_command command, unsigned int data_len, void *data,
+               void *user_data)
+{
+       gpointer service = user_data;
+       CoreObject *co_ps = NULL;
+       struct tnoti_ps_pdp_ipconfiguration *devinfo = NULL;
+
+       g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
+
+       devinfo = (struct tnoti_ps_pdp_ipconfiguration *) data;
+       co_ps = (CoreObject *) _ps_service_ref_co_ps(service);
+
+       if (co_ps != source) {
+               dbg("ps object is different");
+               return TCORE_HOOK_RETURN_CONTINUE;
+       }
+
+       dbg("ip configuration event");
+       _ps_service_set_context_info(service, devinfo);
+
+       return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return __on_hook_powered(Server *s, CoreObject *source,
+               enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
+{
+       gpointer modem = user_data;
+       struct tnoti_modem_power *modem_power = NULL;
+
+       gboolean power = FALSE;
+
+       dbg("powered event called");
+
+       g_return_val_if_fail(modem != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
+
+       modem_power = (struct tnoti_modem_power *)data;
+
+       if ( modem_power->state == MODEM_STATE_ONLINE )
+               power = TRUE;
+       else
+               power = FALSE;
+
+       _ps_modem_processing_power_enable(modem, power);
+
+       return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return __on_hook_flight(Server *s, CoreObject *source,
+               enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
+{
+       gpointer modem = user_data;
+       struct tnoti_modem_flight_mode *modem_flight = NULL;
+       dbg("flight event called");
+
+       g_return_val_if_fail(modem != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
+
+       modem_flight = (struct tnoti_modem_flight_mode *)data;
+       _ps_modem_processing_flight_mode(modem, modem_flight->enable);
+
+       return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return __on_hook_net_register(Server *s, CoreObject *source,
+               enum tcore_notification_command command, unsigned int data_len, void *data,
+               void *user_data)
+{
+       gpointer service = user_data;
+       gboolean ps_attached = FALSE;
+       struct tnoti_network_registration_status *regist_status;
+
+       dbg("network register event called");
+       g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
+
+       regist_status = (struct tnoti_network_registration_status *) data;
+       if (regist_status->ps_domain_status == NETWORK_SERVICE_DOMAIN_STATUS_FULL)
+               ps_attached = TRUE;
+
+       _ps_service_processing_network_event(service, ps_attached, regist_status->roaming_status);
+
+       return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return __on_hook_net_change(Server *s, CoreObject *source,
+               enum tcore_notification_command command, unsigned int data_len, void *data,
+               void *user_data)
+{
+       gpointer service = user_data;
+       struct tnoti_network_change *network_change;
+
+       dbg("network change event called");
+       g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
+
+       network_change = (struct tnoti_network_change *) data;
+       dbg("plmn(%s) act(%d)", network_change->plmn, network_change->act);
+       _ps_service_set_access_technology(service, network_change->act);
+
+       return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return __on_hook_sim_init(Server *s, CoreObject *source,
+               enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
+{
+       struct tnoti_sim_status *sim_data;
+
+       dbg("sim init event called");
+       g_return_val_if_fail(user_data != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
+
+       sim_data = (struct tnoti_sim_status *)data;
+       dbg("sim status is (%d)", sim_data->sim_status);
+
+       if( sim_data->sim_status == SIM_STATUS_INIT_COMPLETED){
+               struct tel_sim_imsi *sim_imsi = NULL;
+               sim_imsi = tcore_sim_get_imsi(source);
+               _ps_modem_processing_sim_complete( (gpointer)user_data, TRUE, (gchar *)sim_imsi->plmn);
+               g_free(sim_imsi);
+       }
+
+       return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+gboolean _ps_hook_co_modem_event(gpointer modem)
+{
+       Server *s = NULL;
+       TcorePlugin *p;
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       p = _ps_modem_ref_plugin(modem);
+       s = tcore_plugin_ref_server(p);
+
+       tcore_server_add_notification_hook(s, TNOTI_MODEM_POWER, __on_hook_powered, modem);
+       tcore_server_add_notification_hook(s, TNOTI_MODEM_FLIGHT_MODE, __on_hook_flight, modem);
+       tcore_server_add_notification_hook(s, TNOTI_SIM_STATUS, __on_hook_sim_init, modem);
+
+       return TRUE;
+}
+
+gboolean _ps_get_co_modem_values(gpointer modem)
+{
+       TcorePlugin *plg;
+       CoreObject *co_modem = NULL;
+       CoreObject *co_sim = NULL;
+
+       GSList *co_lists = NULL;
+       gboolean sim_init = FALSE, modem_powered = FALSE, flight_mode = FALSE;
+       int sim_status = 0;
+       struct tel_sim_imsi *sim_imsi = NULL;
+
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       co_modem = _ps_modem_ref_co_modem(modem);
+       if (!co_modem)
+               return FALSE;
+
+       plg = tcore_object_ref_plugin(co_modem);
+       if (!plg)
+               return FALSE;
+
+       co_lists = tcore_plugin_get_core_objects_bytype(plg, CORE_OBJECT_TYPE_SIM);
+       if (!co_lists)
+               return FALSE;
+
+       co_sim = co_lists->data;
+       g_slist_free(co_lists);
+
+       sim_status = tcore_sim_get_status(co_sim);
+       if(sim_status == SIM_STATUS_INIT_COMPLETED)
+               sim_init = TRUE;
+
+       sim_imsi = tcore_sim_get_imsi(co_sim);
+       modem_powered = tcore_modem_get_powered(co_modem);
+       flight_mode = tcore_modem_get_flight_mode_state(co_modem);
+
+       _ps_modem_processing_flight_mode(modem, flight_mode);
+       _ps_modem_processing_power_enable(modem, modem_powered);
+       _ps_modem_processing_sim_complete(modem, sim_init, (gchar *)sim_imsi->plmn);
+
+       g_free(sim_imsi);
+       return TRUE;
+}
+
+gboolean _ps_hook_co_network_event(gpointer service)
+{
+       Server *s = NULL;
+       TcorePlugin *p;
+
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       p = _ps_service_ref_plugin(service);
+       s = tcore_plugin_ref_server(p);
+
+       tcore_server_add_notification_hook(s, TNOTI_NETWORK_REGISTRATION_STATUS, __on_hook_net_register, service);
+       tcore_server_add_notification_hook(s, TNOTI_NETWORK_CHANGE, __on_hook_net_change, service);
+
+       return TRUE;
+}
+
+gboolean _ps_get_co_network_values(gpointer service)
+{
+       CoreObject *co_network = NULL;
+       gboolean ps_attached = FALSE;
+
+       enum telephony_network_service_domain_status ps_status;
+       enum telephony_network_access_technology act;
+
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       co_network = _ps_service_ref_co_network(service);
+
+       tcore_network_get_service_status(co_network, TCORE_NETWORK_SERVICE_DOMAIN_TYPE_PACKET, &ps_status);
+       tcore_network_get_access_technology(co_network, &act);
+
+       if (ps_status == NETWORK_SERVICE_DOMAIN_STATUS_FULL)
+               ps_attached = TRUE;
+
+       _ps_service_set_roaming(service, tcore_network_get_roaming_state(co_network));
+       _ps_service_set_ps_attached(service, ps_attached);
+       _ps_service_set_access_technology(service, act);
+
+       return TRUE;
+}
+
+gboolean _ps_hook_co_ps_event(gpointer service)
+{
+       Server *s = NULL;
+       TcorePlugin *p;
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       p = _ps_service_ref_plugin(service);
+       s = tcore_plugin_ref_server(p);
+
+       tcore_server_add_notification_hook(s, TNOTI_PS_CALL_STATUS, __on_hook_call_status, service);
+       tcore_server_add_notification_hook(s, TNOTI_PS_CURRENT_SESSION_DATA_COUNTER, __on_hook_session_data_counter, service);
+       tcore_server_add_notification_hook(s, TNOTI_PS_PDP_IPCONFIGURATION, __on_hook_ipconfiguration, service);
+
+       return TRUE;
+}
+
+gboolean _ps_free_co_ps_event(gpointer service)
+{
+       Server *s = NULL;
+       TcorePlugin *p;
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       p = _ps_service_ref_plugin(service);
+       s = tcore_plugin_ref_server(p);
+
+       tcore_server_remove_notification_hook(s, __on_hook_call_status);
+       tcore_server_remove_notification_hook(s, __on_hook_session_data_counter);
+       tcore_server_remove_notification_hook(s, __on_hook_ipconfiguration);
+
+       return TRUE;
+}
+
+gboolean _ps_free_co_network_event(gpointer service)
+{
+       Server *s = NULL;
+       TcorePlugin *p;
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       p = _ps_service_ref_plugin(service);
+       s = tcore_plugin_ref_server(p);
+
+       tcore_server_remove_notification_hook(s, __on_hook_net_register);
+       tcore_server_remove_notification_hook(s, __on_hook_net_change);
+
+       return TRUE;
+}
+
+gboolean _ps_update_cellular_state_key(gpointer service)
+{
+       Server *s = NULL;
+       gpointer handle = NULL;
+       static Storage *strg;
+       int err_reason = 0;
+
+       s = tcore_plugin_ref_server( (TcorePlugin *)_ps_service_ref_plugin(service) );
+       strg = tcore_server_find_storage(s, "vconf");
+       handle = tcore_storage_create_handle(strg, "vconf");
+       if (!handle){
+               err("fail to create vconf handle");
+               return FALSE;
+       }
+
+       err_reason = _ps_service_check_cellular_state(service);
+       tcore_storage_set_int(strg,STORAGE_KEY_CELLULAR_STATE, err_reason);
+
+       return TRUE;
+}
diff --git a/tel-plugin-packetservice.manifest b/tel-plugin-packetservice.manifest
new file mode 100644 (file)
index 0000000..573257c
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+  <domain name="_"/>    
+ </request>
+</manifest>