--- /dev/null
+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>
--- /dev/null
+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 required packages
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED glib-2.0 dbus-glib-1 dlog db-util tcore)
+
+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=\"PS\"")
+
+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 ${PREFIX}/etc/dbus-1/system.d)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/resources/dnet_db.sql DESTINATION /tmp)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/resources/dnet_db_data.sql DESTINATION /tmp)
+INSTALL(TARGETS ps-plugin LIBRARY DESTINATION lib/telephony/plugins)
--- /dev/null
+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
--- /dev/null
+PacketService Plugin
+DongHoo Park - evilpanda
\ No newline at end of file
--- /dev/null
+tel-plugin-packetservice (0.1.7) unstable; urgency=low
+
+ * Fix add profile
+ * Git: 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: 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: 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: 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: 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: 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: 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: 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
--- /dev/null
+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)
+
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License version 2.1.
+
+The full text of the LGPL 2.1 can be found in
+/usr/share/common-licenses.
--- /dev/null
+usr/bin
+usr/sbin
--- /dev/null
+#!/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
--- /dev/null
+@PREFIX@/lib/*
+@PREFIX@/etc/dbus-1/system.d/*
+/tmp/dnet_db.sql
+/tmp/dnet_db_data.sql
\ No newline at end of file
--- /dev/null
+#!/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
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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__ */
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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__ */
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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__ */
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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__ */
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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__ */
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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);
+gchar* _ps_modem_ref_operator(gpointer object);
+gboolean _ps_modem_get_properties(gpointer modem, GHashTable *properties);
+gchar* _ps_modem_ref_path(gpointer modem);
+gpointer _ps_modem_ref_plugin(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_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_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_disconnect_contexts(gpointer service);
+gboolean _ps_service_processing_network_event(gpointer service, gboolean ps_attached, gboolean roaming);
+gboolean _ps_service_set_connected(gpointer service, int context_id, gboolean enabled);
+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_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);
+
+/*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_get_co_network_values(gpointer service);
+gboolean _ps_hook_co_ps_event(gpointer service);
+gboolean _ps_update_cellular_state_key(gpointer service);
+
+#endif /* __PS_H__ */
--- /dev/null
+<?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="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>
--- /dev/null
+<?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>
--- /dev/null
+<?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>
+
--- /dev/null
+<?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>
+
--- /dev/null
+#sbs-git:slp/pkgs/t/tel-plugin-packetservice
+Name: tel-plugin-packetservice
+Summary: Telephony Packet Service library
+Version: 0.1.7
+Release: 1
+Group: System/Libraries
+License: Apache
+Source0: tel-plugin-packetservice-%{version}.tar.gz
+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(db-util)
+
+%description
+Telephony Packet Service library
+
+%prep
+%setup -q
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+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 < /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
+
+%postun -p /sbin/ldconfig
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%files
+%defattr(-,root,root,-)
+#%doc COPYING
+/tmp/dnet_db.sql
+/tmp/dnet_db_data.sql
+/usr/etc/dbus-1/system.d/*
+%{_libdir}/telephony/plugins/ps-plugin*
--- /dev/null
+PRAGMA journal_mode = PERSIST;
+
+DROP TABLE IF EXISTS "fd_blacklist";
+CREATE TABLE fd_blacklist(
+ plmn INTEGER
+);
+
+DROP TABLE IF EXISTS "etc_profile";
+CREATE TABLE etc_profile(
+ profile_id INTEGER PRIMARY KEY,
+ transport_type INTEGER,
+ proxy_ip_addr TEXT
+ );
+
+INSERT INTO "etc_profile" (profile_id, transport_type, proxy_ip_addr) VALUES(8,2,'168.219.61.250:8080');
+
+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,
+ enable_status INTEGER,
+ 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,
+ transport_type INTEGER,
+ 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,
+ is_secure_connection INTEGER,
+ app_protocol_type 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
+ );
+
+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,'wap');
+
+CREATE INDEX pdp_profile_ix_1 ON pdp_profile (network_info_id);
--- /dev/null
+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 "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, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(1,0,'Samsung3G','nate.sktelecom.com',0,NULL,NULL,1,'168.219.61.250:8080','http://www.samsung.com',300,0,4,0,0,NULL,0,NULL,NULL,1,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(2,0,'Samsung3G MMS','nate.sktelecom.com',0,NULL,NULL,1,'165.213.73.234:7082','http://165.213.73.234:7082/01030016056=01030016056',300,0,4,0,0,NULL,0,NULL,NULL,1,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(3,0,'Voda DE Web','web.vodafone.de',0,NULL,NULL,1,NULL,'http://www.vodafone.de',0,0,1,0,0,NULL,0,NULL,NULL,2,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(4,0,'Voda DE MMS','event.vodafone.de',0,NULL,NULL,1,'139.7.29.17:80','http://139.7.24.1/servlets/mms',300,0,4,0,0,NULL,0,NULL,NULL,2,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(5,0,'Voda DE Wap','wap.vodafone.de',0,NULL,NULL,1,'139.7.29.1:80','http://live.vodafone.com',300,0,4,0,0,NULL,0,NULL,NULL,2,5);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(6,0,'Voda UK 3G','internet',0,'wap','wap',1,NULL,NULL,300,0,1,0,0,NULL,0,NULL,NULL,3,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(7,0,'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,4,0,0,NULL,0,NULL,NULL,3,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(9,0,'O2 UK Web','mobile.o2.co.uk',0,'o2web','password',1,NULL,'',120,0,4,0,0,NULL,0,NULL,NULL,4,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(10,0,'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,4,0,0,NULL,0,NULL,NULL,4,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(11,0,'Movistar 3G','movistar.es',1,'movistar','movistar',1,NULL,'http://wap.movistar.com',300,0,4,0,0,NULL,0,NULL,NULL,5,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(12,0,'Movista MMS','mms.movistar.es',1,'MOVISTAR@mms','MOVISTAR',1,'10.138.255.5:8080','http://mms.movistar.com',300,0,4,0,0,NULL,0,NULL,NULL,5,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(13,0,'Orange Internet','internet',1,'orange','orange',1,NULL,'http://www.orange.es',300,0,4,0,0,NULL,0,NULL,NULL,6,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(14,0,'Orange MMS','orangemms',1,'orange','orange',1,'172.22.188.25:8080','http://mms.orange.es',300,0,4,0,0,NULL,0,NULL,NULL,6,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(15,0,'Orange World','orangeworld',1,'orange','orange',1,'10.132.61.10:8080','http://wap.orange.es',300,0,4,0,0,NULL,0,NULL,NULL,6,5);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(16,0,'Orange Internet','orangeinternet',1,NULL,NULL,1,NULL,'http://orangeworld.co.uk/',300,0,4,0,0,NULL,0,NULL,NULL,7,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(17,0,'Orange MMS','orangemms',1,NULL,NULL,1,'192.168.224.10:8080','http://mms.orange.co.uk/',300,0,4,0,0,NULL,0,NULL,NULL,7,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(18,0,'Orange world','orange',1,'orange','orange',1,'192.168.10.100:8080','http://www.orange.fr/',0,0,4,0,0,NULL,0,NULL,NULL,8,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(19,0,'Orange MMS','orange.acte',1,'orange','orange',1,'192.168.10.200:8080','http://mms.orange.fr/',300,0,4,0,0,NULL,0,NULL,NULL,8,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(20,0,'ATnT ISP','wap.cingular',0,NULL,NULL,1,'wireless.cingular.com:80',NULL,0,0,4,0,0,NULL,0,NULL,NULL,9,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(21,0,'ATnT MMS','wap.cingular',0,NULL,NULL,1,'wireless.cingular.com:80','http://mmsc.cingular.com/',0,0,4,0,0,NULL,0,NULL,NULL,9,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(22,0,'Airtel India','airtelgprs.com',0,NULL,NULL,1,NULL,'http://airtel.in',0,0,1,0,0,NULL,0,NULL,NULL,10,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(23,0,'Airtel MMS','airtelmms.com',0,NULL,NULL,1,'100.1.201.172:8799','http://100.1.201.171:10021/mmsc',0,0,4,0,0,NULL,0,NULL,NULL,10,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(24,0,'Vodafone India 3G','www',0,NULL,NULL,1,NULL,'http://www.vodafone.in',0,0,1,0,0,NULL,0,NULL,NULL,11,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(25,0,'Vodadone India MMS','portalnmms',0,NULL,NULL,1,'10.10.1.100:9401','http://mms1.live.vodafone.in/mms/',0,0,4,0,0,NULL,0,NULL,NULL,11,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(26,0,'China Unicom 3G','uninet',0,NULL,NULL,1,NULL,'http://www.wo.com.cn',0,0,1,0,0,NULL,0,NULL,NULL,12,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(27,0,'China Unicom MMS','3gwap',0,NULL,NULL,1,'10.0.0.172:80','http://mmsc.myuni.com.cn',0,0,4,0,0,NULL,0,NULL,NULL,12,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(28,0,'BSNL 3G India','gprssouth.cellone.in',0,'ppp','ppp123',1,NULL,'http://www.bsnl.co.in',300,0,1,0,0,NULL,0,NULL,NULL,13,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(29,0,'BSNL India MMS','bsnlmms',0,NULL,NULL,1,'10.210.10.11:8080','http://bsnlmmsc.in:8514',0,0,4,0,0,NULL,0,NULL,NULL,13,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(30,0,'Vodafone 3G India Delhi','portalnmms',0,NULL,NULL,1,'10.10.1.100:9401','http://www.vodafone.in',0,0,1,0,0,NULL,0,NULL,NULL,14,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(31,0,'Vodafone India Delhi MMS','portalnmms',0,NULL,NULL,1,'10.10.1.100:9401','http://mms1.live.vodafone.in/mms/',0,0,4,0,0,NULL,0,NULL,NULL,14,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(32,0,'Airtel 3G India Delhi','airtelgprs.com',0,NULL,NULL,1,'100.1.200.99:8080','http://airtel.in',0,0,1,0,0,NULL,0,NULL,NULL,15,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(33,0,'Airtel India Delhi MMS','airtelmms.com',0,NULL,NULL,1,'100.1.201.172:8799','http://100.1.201.171:10021/mmsc',0,0,4,0,0,NULL,0,NULL,NULL,15,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(34,0,'E Plus 3G','internet.eplus.de',1,'eplus','internet',1,NULL,NULL,60,0,4,0,0,NULL,0,'212.23.97.2','212.23.97.3',16,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(35,0,'E Plus MMS','mms.eplus.de',1,'mms','eplus',1,'212.23.97.153:5080','http://mms/eplus',60,0,4,0,0,NULL,0,NULL,NULL,16,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(36,0,'Voda ES Web','airtelnet.es',0,'vodafone','vodafone',1,NULL,'http://www.vodafone.es',300,0,1,0,0,NULL,0,NULL,NULL,17,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(37,0,'Voda ES MMS','mms.vodafone.net',0,'wap@wap','wap125',1,'212.73.32.10:80','http://www.vodafone.es',300,0,4,0,0,NULL,0,NULL,NULL,17,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(38,0,'O2 Internet','internet',0,NULL,NULL,1,NULL,NULL,300,0,1,0,0,NULL,0,NULL,NULL,18,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(39,0,'O2 MMS','internet',0,NULL,NULL,1,'82.113.100.5:8080','http://10.81.0.7:8002',300,0,1,0,0,NULL,0,NULL,NULL,18,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(40,0,'SKT Internet','web.sktelecom.com',0,NULL,NULL,1,NULL,NULL,300,0,1,0,0,NULL,0,NULL,NULL,19,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(41,0,'SKT MMS','web.sktelecom.com',0,NULL,NULL,0,'220.103.230.150:9093','http://omms.nate.com:9082/oma_mms',300,0,4,0,0,NULL,0,NULL,NULL,19,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(42,0,'SFR Internet','sl2sfr',1,NULL,NULL,1,NULL,NULL,300,0,1,0,0,NULL,0,NULL,NULL,20,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(43,0,'SFR MMS','mmssfr',1,NULL,NULL,1,'10.151.0.1:8080','http://mms1',300,0,1,0,0,NULL,0,NULL,NULL,20,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(44,0,'T Mobile Internet','internet.t-mobile',1,'t-mobile','tm',1,NULL,NULL,150,0,1,0,0,NULL,0,NULL,NULL,21,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(45,0,'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,1,0,0,NULL,0,NULL,NULL,21,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(46,0,'NTT Docomo JP','spmode.ne.jp',0,NULL,NULL,1,NULL,NULL,300,0,1,0,0,NULL,0,NULL,NULL,22,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(47,0,'NTT Docomo JP','mopera.net',0,NULL,NULL,1,NULL,NULL,300,0,1,0,0,NULL,0,NULL,NULL,22,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(48,0,'KT Internet','default.ktfwing.com',0,NULL,NULL,1,NULL,NULL,300,0,1,0,0,NULL,0,NULL,NULL,23,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(49,0,'KT MMS','default.ktfwing.com',0,NULL,NULL,1,NULL,'http://mmsc.ktfwing.com:9082',300,0,1,0,0,NULL,0,NULL,NULL,23,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(50,0,'Play Internet','internet',0,NULL,NULL,1,NULL,NULL,300,0,1,0,0,NULL,0,NULL,NULL,24,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(51,0,'Play MMS','mms',0,NULL,NULL,1,'10.10.25.5:8080','http://10.10.28.164/mms/wapenc',300,0,1,0,0,NULL,0,NULL,NULL,24,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(52,0,'Plus GSM Internet','www.plusgsm.pl',0,NULL,NULL,1,NULL,NULL,300,0,1,0,0,NULL,0,NULL,NULL,25,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(53,0,'Plus GSM MMS','mms.plusgsm.pl',0,NULL,NULL,1,'212.2.96.16:8080','http://mms.plusgsm.pl:8002',300,0,1,0,0,NULL,0,NULL,NULL,25,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(54,0,'T Mobile Internet','epc.tmobile.com',0,NULL,NULL,1,NULL,NULL,300,0,1,0,0,NULL,0,NULL,NULL,26,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(55,0,'T Mobile MMS','epc.tmobile.com',0,NULL,NULL,1,NULL,'http://mms.msg.english.t-mobile.com/mms/wapenc',300,0,1,0,0,NULL,0,NULL,NULL,26,2);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(56,0,'Tizen Internet','emul.tizen.com',0,NULL,NULL,1,NULL,'http://www.samsung.com',300,0,4,0,0,NULL,0,NULL,NULL,27,1);
+INSERT INTO "pdp_profile" (profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol,proxy_ip_addr,home_url,linger_time,is_secure_connection,app_protocol_type,traffic_class,is_static_ip_addr,ip_addr,is_static_dns_addr,dns_addr1,dns_addr2,network_info_id,svc_category_id) VALUES(57,0,'Tizen3G MMS','emul.tizen.com',0,NULL,NULL,1,NULL,'http://tizen.mms.server.com',300,0,4,0,0,NULL,0,NULL,NULL,27,2);
+
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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>
+
+#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;
+ 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_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(PsContext *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 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_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 int __ps_context_load_profile_id_from_database(void);
+static int __ps_context_insert_profile_to_database(GHashTable *property, int network_id);
+static gboolean __ps_context_reset_database(void);
+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_alwayson_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->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_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_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)
+{
+ gboolean rv = FALSE;
+ __ps_context_remove_database(context);
+ rv = __ps_context_remove_context(context);
+ *result = rv;
+ 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;
+}
+
+static gboolean __ps_context_remove_context(PsContext *context)
+{
+ dbg("remove context and profile");
+
+ dbus_g_connection_unregister_g_object(context->conn, (GObject *) context);
+
+ __ps_context_set_alwayson_enable(context, FALSE);
+ _ps_service_deactivate_context(context->p_service, context);
+ _ps_context_set_connected(context, FALSE);
+ _ps_service_unref_context(context->p_service, context);
+ g_hash_table_remove(contexts, _ps_context_ref_path(context));
+
+ tcore_context_free(context->co_context);
+ //__ps_context_remove_database(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 svc_ctg_id)
+{
+ gchar **strv, *str, *path;
+
+ strv = g_strsplit(profile_name, " ", 0);
+ str = g_strjoinv("_", strv);
+ path = g_strdup_printf("/context/%s_%d", str, 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;
+ int auth_type = 0;
+ gchar *auth_id = NULL, *auth_pwd = NULL, *home_url = NULL, *proxy_addr = NULL;
+ int pdp_protocol = 0, svc_ctg_id = 0;
+
+ 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, "11") == TRUE) {
+ pdp_protocol = atoi((const char*) value);
+ dbg("pdp protocol (%d)", pdp_protocol);
+ }
+ else if (g_str_equal(key, "21") == TRUE) {
+ svc_ctg_id = atoi((const char*) value);
+ dbg("context category type (%d)", svc_ctg_id);
+ }
+ }
+
+ path = __ps_context_create_path(profile_name, svc_ctg_id);
+
+ context = (PsContext *) object;
+ co_context = tcore_context_new(context->plg, path);
+ 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);
+
+ context->profile_id = profile_id;
+ 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_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) 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) {
+ if (g_str_equal(key, "0") == TRUE) {
+ 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;
+
+ 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, "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 FALSE;
+ }
+ profile_id++;
+
+ memset(szQuery, 0, sizeof(szQuery));
+ strcpy(szQuery," insert into pdp_profile( ");
+ strcat(szQuery," profile_id, transport_type, profile_name, apn, auth_type, auth_id, auth_pwd, ");
+ strcat(szQuery," pdp_protocol, proxy_ip_addr, home_url, linger_time, is_secure_connection, app_protocol_type, ");
+ strcat(szQuery," network_info_id, svc_category_id) values( ");
+ strcat(szQuery," ?, 1, ? , ?, ?, ?, ?, ");//1,2,3,4,5,6
+ strcat(szQuery," 1, ?, ?, 300, 0, 1, ");//7,8
+ strcat(szQuery," ?, ? )");//9,10
+
+ insert_key1 = g_strdup_printf("%d", profile_id);
+ insert_key2 = g_strdup_printf("%d", network_id);
+ profile_name = g_strdup_printf("tmp_profile%d", profile_id);
+
+ 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 FALSE;
+
+ return TRUE;
+}
+
+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(key, "0") == TRUE) {
+ network_id = atoi((const char*) value2);
+ }
+ }
+ break;
+ }
+ }
+
+ g_hash_table_destroy(in_param);
+ g_hash_table_destroy(out_param);
+
+ return network_id;
+}
+
+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(key, "0") == TRUE) {
+ profile_id = atoi((const char*) value2);
+ }
+ }
+ break;
+ }
+ }
+
+ g_hash_table_destroy(out_param);
+ return profile_id;
+}
+
+static gboolean __ps_context_reset_database(void)
+{
+ int rv = 0;
+ gchar *extract_sql, *recover_sql, *remove_tmp;
+
+ extract_sql = g_strdup("tar --extract --file=/opt/system/customer_selected/preconfig/customer.tar.gz opt/dbspace/.dnet.db -C /tmp");
+ dbg("system extract command (%s)", extract_sql);
+ rv = system(extract_sql);
+
+ recover_sql = g_strdup("sqlite3 /opt/dbspace/.dnet.db \"attach database '/tmp/opt/dbspace/.dnet.db' as csc; replace into pdp_profile select * from csc.pdp_profile;\" ");
+ dbg("system recover db command (%s)", recover_sql);
+ rv = system(recover_sql);
+
+ remove_tmp = g_strdup("rm -rf /tmp/opt/dbspace/.dnet.db");
+ dbg("system recover db command (%s)", remove_tmp);
+ rv = system(remove_tmp);
+
+ g_free(extract_sql);
+ g_free(recover_sql);
+ g_free(remove_tmp);
+
+ return TRUE;
+}
+
+static int __ps_context_get_network_id(gchar *mccmnc)
+{
+ int network_id;
+
+ network_id = __ps_context_load_network_id_from_database(mccmnc);
+ 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_free(s_authtype);
+ g_free(s_role);
+
+ return TRUE;
+}
+
+static 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->alwayson = enabled;
+ }
+
+ return TRUE;
+}
+
+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_hashtable(void)
+{
+ if(!contexts)
+ return TRUE;
+
+ g_hash_table_foreach_remove(contexts, __remove_contexts, NULL);
+ __ps_context_reset_database();
+ 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.is_secure_connection, b.app_protocol_type, b.traffic_class,"); //12, 13, 14, 15
+ strcat(szQuery, " b.is_static_ip_addr, b.ip_addr, b.is_static_dns_addr, b.dns_addr1, b.dns_addr2, b.svc_category_id"); //16,17, 18, 19, 20, 21
+ 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, 22);
+
+ 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)
+{
+ gboolean rv = FALSE;
+ int network_id = 0;
+
+ network_id = __ps_context_get_network_id(operator);
+ if(network_id <= 0){
+ dbg("fail to add network info");
+ return FALSE;
+ }
+
+ rv = __ps_context_insert_profile_to_database(property, network_id);
+ if(rv != TRUE){
+ dbg("fail to insert profile info to database");
+ return FALSE;
+ }
+
+ _ps_modem_set_sim_enabled(modem, FALSE);
+ g_hash_table_foreach_remove(contexts, __remove_contexts, NULL);
+ _ps_modem_processing_sim_complete(modem, TRUE, operator);
+
+ 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_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;
+}
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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;
+}
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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
+};
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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-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;
+ 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 FALSE;
+ }
+
+ 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 FALSE;
+ }
+
+ 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));
+ }
+
+ 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;
+ GSList *data_list= NULL, *sim_list = NULL;
+ GSList *tmp_data_l= NULL, *tmp_sim_l = NULL;
+
+ 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 FALSE;
+ }
+
+ g_hash_table_iter_init(&iter, master->modems);
+ while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+ gboolean b_data_allowed = FALSE, b_sim_init = FALSE;
+ gchar *modem_name = (gchar *) key;
+ dbg("modem (%s) does not allowed data connection", modem_name);
+
+ b_data_allowed = _ps_modem_get_data_allowed(value);
+ data_list = g_slist_append(data_list, GINT_TO_POINTER(b_data_allowed));
+ b_sim_init = _ps_modem_get_sim_init(value);
+ sim_list = g_slist_append(sim_list, GINT_TO_POINTER(b_sim_init));
+
+ _ps_modem_set_sim_enabled(value, FALSE);
+ _ps_modem_set_data_allowed(value, FALSE);
+ }
+
+ _ps_context_reset_hashtable();
+
+ tmp_data_l = data_list;
+ tmp_sim_l = sim_list;
+ g_hash_table_iter_init(&iter, master->modems);
+ while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+ gchar *operator = NULL;
+ gchar *modem_name = (gchar *) key;
+
+ operator =_ps_modem_ref_operator(value);
+ if(operator)
+ _ps_modem_processing_sim_complete(value, (gboolean)tmp_sim_l->data, operator);
+
+ dbg("modem (%s) allows data connection", modem_name);
+ _ps_modem_set_data_allowed(value, (gboolean)tmp_data_l->data);
+
+ tmp_sim_l = tmp_sim_l->next;
+ tmp_data_l = tmp_data_l->next;
+ }
+
+ g_free(data_list); g_free(sim_list);
+ *result = TRUE;
+ 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;
+ PsMaster *master = (PsMaster *)user_data;
+
+ dbg("storage key(%d) callback", key);
+ g_return_if_fail(master != NULL);
+
+ tmp = (GVariant *)value;
+
+ 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);
+
+ do {
+ 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;
+ 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);
+ g_slist_free(modemlists);
+ } while ((plist = g_slist_next(plist)));
+
+ 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);
+}
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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 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;
+ 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;
+ 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);
+ co_networks = tcore_plugin_get_core_objects_bytype(target_plg, CORE_OBJECT_TYPE_NETWORK);
+ co_ps = co_pslist->data;
+ co_network = co_networks->data;
+
+ 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);
+ g_slist_free(co_pslist);
+ g_slist_free(co_networks);
+
+ 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) {
+
+ _ps_update_cellular_state_key(value);
+ if(modem->flight_mode || !modem->data_allowed || !modem->roaming_allowed ){
+ _ps_service_disconnect_contexts(value);
+ }
+ _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);
+
+ 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;
+}
+
+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;
+}
+
+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_co_modem(gpointer object)
+{
+ PsModem *modem = object;
+ g_return_val_if_fail(modem != NULL, NULL);
+
+ return modem->co_modem;
+}
--- /dev/null
+<!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="root">
+ <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="inhouse">
+ <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>
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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;
+ 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;
+ 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;
+ PsService *service = object;
+
+ if(service->roaming){
+ b_connect &=_ps_modem_get_data_roaming_allowed(service->p_modem);
+ }
+
+ b_connect &= _ps_modem_get_sim_init(service->p_modem);
+ b_connect &= _ps_modem_get_data_allowed(service->p_modem);
+ b_connect &= !_ps_modem_get_flght_mode(service->p_modem);
+ b_connect &= service->ps_attached;
+
+ 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_contexts(gpointer object, GHashTable *contexts, gchar *operator)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+ PsService *service = object;
+
+ 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;
+
+ 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);
+ }
+
+ _ps_update_cellular_state_key(service);
+ _ps_service_connect_default_context(service);
+ return TRUE;
+}
+
+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);
+ do {
+ CoreObject *co_context = NULL;
+
+ co_context = contexts->data;
+ if (!co_context) continue;
+
+ tcore_context_set_devinfo(co_context, devinfo);
+
+ } while ((contexts = g_slist_next(contexts)));
+
+ return TRUE;
+}
+
+int _ps_service_activate_context(gpointer object, gpointer context)
+{
+ PsService *service = object;
+ CoreObject *co_context = NULL;
+ gboolean b_connect = TRUE;
+
+ dbg("activate 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_activate_context(service->co_ps, co_context, NULL);
+}
+
+gboolean _ps_service_deactivate_context(gpointer object, gpointer context)
+{
+ PsService *service = object;
+ CoreObject *co_context = NULL;
+
+ dbg("deactivate 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_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 && (service->act > NETWORK_ACT_UNKNOWN && service->act < NETWORK_ACT_LTE)){
+ int rv = 0;
+ _ps_service_reset_connection_timer(value);
+ rv = _ps_service_activate_context(service, value);
+ dbg("return rv(%d)", rv);
+ break;
+ }
+ }
+
+ return;
+}
+
+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;
+}
+
+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_LTE){
+ _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_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;
+}
--- /dev/null
+/*
+ * PacketService Control Module
+ *
+ * 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 == 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_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("powered 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;
+ _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);
+ plg = tcore_object_ref_plugin(co_modem);
+ co_lists = tcore_plugin_get_core_objects_bytype(plg, CORE_OBJECT_TYPE_SIM);
+ co_sim = co_lists->data;
+
+ 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_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;
+}