Merge from tizen_3.0 branch 11/116111/1 accepted/tizen/common/20170227.043028 accepted/tizen/ivi/20170224.065437 accepted/tizen/ivi/20170228.012726 accepted/tizen/mobile/20170224.065317 accepted/tizen/mobile/20170228.012636 accepted/tizen/tv/20170224.065344 accepted/tizen/tv/20170228.012652 accepted/tizen/unified/20170309.034317 accepted/tizen/wearable/20170224.065356 accepted/tizen/wearable/20170228.012708 submit/tizen/20170224.040753 submit/tizen/20170227.061058 submit/tizen_unified/20170308.100410
authorWootak Jung <wootak.jung@samsung.com>
Thu, 23 Feb 2017 01:39:32 +0000 (10:39 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 23 Feb 2017 04:34:36 +0000 (13:34 +0900)
Below patches are applied from tizen_3.0
- Fix memory leak issue
- Fix incorrect cid assignment issue
- Fix alwayson and memory leak issue
- Update architecture of ps-plugin newly

Change-Id: I6e39df523f8e185ae152226717d4f8549bf1d2fd

38 files changed:
CMakeLists.txt
include/ps_common.h
include/ps_context.h [new file with mode: 0644]
include/ps_hook.h [new file with mode: 0644]
include/ps_log.h
include/ps_main.h
include/ps_master.h [new file with mode: 0644]
include/ps_modem.h [new file with mode: 0644]
include/ps_service.h [new file with mode: 0644]
include/ps_tcore_interface.h [new file with mode: 0644]
interface/CMakeLists.txt [new file with mode: 0644]
interface/include/ps_context_interface.h [new file with mode: 0644]
interface/include/ps_master_interface.h [new file with mode: 0644]
interface/include/ps_modem_interface.h [new file with mode: 0644]
interface/include/ps_service_interface.h [new file with mode: 0644]
interface/introspection/context.xml [moved from introspection/context.xml with 100% similarity]
interface/introspection/master.xml [moved from introspection/master.xml with 100% similarity]
interface/introspection/modem.xml [moved from introspection/modem.xml with 69% similarity]
interface/introspection/service.xml [moved from introspection/service.xml with 100% similarity]
interface/src/ps_context_interface.c [new file with mode: 0644]
interface/src/ps_master_interface.c [new file with mode: 0644]
interface/src/ps_modem_interface.c [new file with mode: 0644]
interface/src/ps_service_interface.c [new file with mode: 0644]
packaging/tel-plugin-packetservice.spec
resources/3g/dnet_db_init.sql
resources/dnet_db.sql
resources/lte/dnet_db_init.sql
src/ps_context.c
src/ps_hook.c [new file with mode: 0644]
src/ps_log.c
src/ps_main.c
src/ps_master.c
src/ps_modem.c
src/ps_service.c
src/ps_tcore-interface.c
src/ps_util.c
test_src/CMakeLists.txt [deleted file]
test_src/main.c [deleted file]

index 26fd7b8..0e958f6 100644 (file)
@@ -14,23 +14,20 @@ endif()
 
 # Set required packages
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 gio-2.0 gio-unix-2.0 tcore iniparser vconf alarm-service libxml-2.0 libtzplatform-config)
+pkg_check_modules(pkgs REQUIRED glib-2.0 gio-2.0 gio-unix-2.0 tcore iniparser vconf alarm-service libxml-2.0
+       libtzplatform-config capi-system-device)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include/ ${CMAKE_SOURCE_DIR}/cmake_tmp )
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/interface/ ${CMAKE_SOURCE_DIR}/interface/include ${CMAKE_SOURCE_DIR}/include/ ${CMAKE_SOURCE_DIR}/cmake_tmp )
 
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wmissing-declarations -Wcast-align -Wall -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable")
 
 ### Purge unused code ###
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -ffunction-sections -Wl,--gc-sections")
 
-IF (CONNECT_DEFAULT_CONNECTION_WITHOUT_TIMER)
-  ADD_DEFINITIONS("-DCONNECT_DEFAULT_CONNECTION_WITHOUT_TIMER")
-ENDIF (CONNECT_DEFAULT_CONNECTION_WITHOUT_TIMER)
-
 IF (SUPPORT_VOLTE)
   ADD_DEFINITIONS("-DTIZEN_SUPPORT_VOLTE")
   SET(RES_DIR ${CMAKE_SOURCE_DIR}/resources/lte)
@@ -44,10 +41,9 @@ ADD_DEFINITIONS("-DFEATURE_TLOG_DEBUG")
 ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"PS\"")
 ADD_DEFINITIONS("-DPLUGIN_VERSION=${VERSION}")
 ADD_DEFINITIONS("-DEXPORT_API=__attribute__((visibility(\"default\")))")
+
+# model definitions #
 ADD_DEFINITIONS("-DTIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL")
-IF(PREPAID_SIM_APN_SUPPORT)
-       ADD_DEFINITIONS("-DPREPAID_SIM_APN_SUPPORT")
-ENDIF(PREPAID_SIM_APN_SUPPORT)
 
 MESSAGE(${CMAKE_C_FLAGS})
 MESSAGE(${pkgs_LDFLAGS})
@@ -60,18 +56,17 @@ SET(SRCS
        src/ps_service.c
        src/ps_context.c
        src/ps_tcore-interface.c
+       src/ps_hook.c
        src/ps_log.c
        src/ps_util.c
-       ${CMAKE_BINARY_DIR}/generated-code.c
 )
 
-ADD_CUSTOM_COMMAND(
-       OUTPUT ${CMAKE_BINARY_DIR}/generated-code.c
-       COMMAND gdbus-codegen --interface-prefix com.tcore.ps. --generate-c-code generated-code --c-namespace PacketService --c-generate-object-manager --generate-docbook generated-docs ${CMAKE_SOURCE_DIR}/introspection/master.xml ${CMAKE_SOURCE_DIR}/introspection/modem.xml ${CMAKE_SOURCE_DIR}/introspection/service.xml ${CMAKE_SOURCE_DIR}/introspection/context.xml
-       COMMENT "Generating GDBus .c/.h")
+ADD_SUBDIRECTORY(interface)
 
 # library build
-ADD_LIBRARY(ps-plugin SHARED ${SRCS})
+ADD_LIBRARY(ps-plugin SHARED ${SRCS} ${INTERFACE_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/interface/generated-code.c)
+SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/interface/generated-code.c PROPERTIES GENERATED 1)
+ADD_DEPENDENCIES(ps-plugin generated_code)
 TARGET_LINK_LIBRARIES(ps-plugin ${pkgs_LDFLAGS})
 SET_TARGET_PROPERTIES(ps-plugin PROPERTIES PREFIX "" OUTPUT_NAME ps-plugin)
 
@@ -82,9 +77,4 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/resources/500.dnet_db_upgrade_24_30.sh DESTINA
 INSTALL(FILES ${RES_DIR}/dnet_db_init.sql DESTINATION ${DATAROOTDIR}/ps-plugin)
 #INSTALL(FILES ${CMAKE_SOURCE_DIR}/resources/apns-conf.xml DESTINATION ${DATAROOTDIR}/ps-plugin)
 INSTALL(TARGETS ps-plugin LIBRARY DESTINATION ${LIBDIR}/telephony/plugins)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION ${DATAROOTDIR}/license RENAME tel-plugin-packetservice)
-
-IF (TIZEN_ENGINEER_MODE)
-#  ADD_SUBDIRECTORY(test_src)
-ENDIF (TIZEN_ENGINEER_MODE)
-
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION ${DATAROOTDIR}/license RENAME tel-plugin-packetservice)
\ No newline at end of file
index 5b977b5..f919213 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef __PS_COMMON_H__
 #define __PS_COMMON_H__
 
-#define PS_DBUS_SERVICE        "com.tcore.ps"
+#define PS_DBUS_SERVICE "com.tcore.ps"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -29,6 +29,7 @@
 #include <glib.h>
 #include <gio/gio.h>
 #include <alarm.h>
+#include <device/power.h>
 
 #include <tcore.h>
 #include <plugin.h>
 #include <core_object.h>
 #include <hal.h>
 
-#include "generated-code.h"
-#include "ps_log.h"
-
-#define FAIL_RESPONSE(ivc,msg) g_dbus_method_invocation_return_error(ivc, \
-               G_DBUS_ERROR, G_DBUS_ERROR_FAILED, msg);
+#define FAIL_RESPONSE(ivc, msg) g_dbus_method_invocation_return_error(ivc, \
+                                                                     G_DBUS_ERROR, G_DBUS_ERROR_FAILED, msg);
 
 
 #define PS_NO_PENDING_REQUEST 0x00
 
 
 /*Storage Key value*/
-#define KEY_TELEPHONY_READY            STORAGE_KEY_TELEPHONY_READY
-#define KEY_3G_ENABLE                          STORAGE_KEY_3G_ENABLE
-#define KEY_DATA_ROAMING_SETTING       STORAGE_KEY_SETAPPL_STATE_DATA_ROAMING_BOOL
-#define KEY_POWER_SAVING_MODE          STORAGE_KEY_POWER_SAVING_MODE
-#define KEY_PM_STATE                           STORAGE_KEY_PM_STATE
-#define KEY_NETWORK_RESTRICT_MODE   STORAGE_KEY_SETAPPL_NETWORK_RESTRICT_MODE
+#define KEY_TELEPHONY_READY             STORAGE_KEY_TELEPHONY_READY
+#define KEY_3G_ENABLE                   STORAGE_KEY_3G_ENABLE
+#define KEY_DATA_ROAMING_SETTING        STORAGE_KEY_SETAPPL_STATE_DATA_ROAMING_BOOL
+#define KEY_POWER_SAVING_MODE           STORAGE_KEY_POWER_SAVING_MODE
+#define KEY_PM_STATE                    STORAGE_KEY_PM_STATE
+#define KEY_NETWORK_RESTRICT_MODE       STORAGE_KEY_SETAPPL_NETWORK_RESTRICT_MODE
 #ifdef POWER_SAVING_FEATURE_WEARABLE
-#define KEY_WECONN_ALL_CONNECTED       STORAGE_KEY_WECONN_ALL_CONNECTED
+#define KEY_WECONN_ALL_CONNECTED        STORAGE_KEY_WECONN_ALL_CONNECTED
 #endif
-#define KEY_SAP_CONNECTION_TYPE                STORAGE_KEY_SAP_CONNECTION_TYPE
-#define KEY_WIFI_STATE STORAGE_KEY_WIFI_STATE_INT
-
-#define PS_ERR_PERM_DENIED "Permission Denied"
-#define PS_ERR_INTERNAL "Internal Error"
-#define PS_ERR_NO_SERVICE "NO service"
-#define PS_ERR_TRASPORT "No Transport"
-#define PS_ERR_NO_PROFILE "No Profile"
+#define KEY_SAP_CONNECTION_TYPE         STORAGE_KEY_SAP_CONNECTION_TYPE
+#define KEY_WIFI_STATE                  STORAGE_KEY_WIFI_STATE_INT
+
+#define PS_ERR_PERM_DENIED   "Permission Denied"
+#define PS_ERR_INTERNAL      "Internal Error"
+#define PS_ERR_NO_SERVICE    "NO service"
+#define PS_ERR_TRASPORT      "No Transport"
+#define PS_ERR_NO_PROFILE    "No Profile"
 #define PS_ERR_WRONG_PROFILE "Wrong Profile"
-#define PS_ERR_MAX "Unknown Error"
+#define PS_ERR_MAX           "Unknown Error"
 
-#define BOOL2STRING(a) ((a == TRUE) ? ("TRUE") : ("FALSE"))
-#define CHAR2STRING(a) g_strdup_printf("%c", a)
-#define INT2STRING(a)  g_strdup_printf("%d", a)
+#define BOOL2STRING(a)  ((a == TRUE) ? ("TRUE") : ("FALSE"))
+#define CHAR2STRING(a)  g_strdup_printf("%c", a)
+#define INT2STRING(a)   g_strdup_printf("%d", a)
 
 /* Tizen Power saving mode */
-#define POWER_SAVING_MODE_NORMAL   0x00
-#define POWER_SAVING_MODE_POWERFUL 0x01
+#define POWER_SAVING_MODE_NORMAL    0x00
+#define POWER_SAVING_MODE_POWERFUL  0x01
 #define POWER_SAVING_MODE_EMERGENCY 0x02
-#define POWER_SAVING_MODE_WEARABLE 0x03
+#define POWER_SAVING_MODE_WEARABLE  0x03
 #define POWER_SAVING_MODE_DATA_ALLOWED 0x10
 
 /*Tizen CDMA dummy Profile Index*/
 #define PS_CDMA_DUMMY_PROFILE_IDX 0
 #define PS_CDMA_DUMMY_PROFILE_PLMN "00000"
 
+/*Tizen IMS emergency Profile Index*/
+#define PS_IMS_EMERGENCY_PROFILE_PLMN "11111"
+
+/*pdp retry timer*/
+#define PDP_RETRY_TIME_OUT_DEFAULT  5
+#define PDP_RETRY_TIME_OUT_MAX      1800
+
+#define IP_LEN 48
+
+#define NET_IMS_MASK_REGI (NETWORK_IMS_REG_FEATURE_TYPE_VOLTE | NETWORK_IMS_REG_FEATURE_TYPE_SMS | NETWORK_IMS_REG_FEATURE_TYPE_VT)
+
 typedef enum {
        PS_SUBS_PRIMARY,
        PS_SUBS_SECONDARY,
        PS_SUBS_TERTIARY,
-       PS_SUBS_MAX = 0xFF
+       PS_SUBS_MAX = PS_SUBS_TERTIARY,
 } ps_subs_type;
 
 enum ps_modem_state {
@@ -124,34 +133,54 @@ enum ps_modem_state {
        PS_MODEM_STATE_LOW = 0x02,
 };
 
-enum ps_pdp_permanet_reject {
+enum ps_pdp_reject_cause {
        /*3GPP spec defined Call End reasons*/
-       PS_PDP_PERMANENT_REJECT_OPERATOR_DETERMINED_BARRING                            = 8,
-       PS_PDP_PERMANENT_REJECT_LLC_SNDCP_FAILURE                                      = 25,
-       PS_PDP_PERMANENT_REJECT_INSUFFICIENT_RESOURCES                                 = 26,
-       PS_PDP_PERMANENT_REJECT_UNKNOWN_APN                                            = 27,
-       PS_PDP_PERMANENT_REJECT_UNKNOWN_PDP                                            = 28,
-       PS_PDP_PERMANENT_REJECT_AUTH_FAILED                                            = 29,
-       PS_PDP_PERMANENT_REJECT_GGSN_REJECT                                            = 30,
-       PS_PDP_PERMANENT_REJECT_ACTIVATION_REJECT                                      = 31,
-       PS_PDP_PERMANENT_REJECT_OPTION_NOT_SUPPORTED                                   = 32,
-       PS_PDP_PERMANENT_REJECT_OPTION_UNSUBSCRIBED                                    = 33,
-       PS_PDP_PERMANENT_REJECT_OPTION_TEMP_OOO                                        = 34,
-       PS_PDP_PERMANENT_REJECT_NSAPI_ALREADY_USED                                     = 35,
-       PS_PDP_PERMANENT_REJECT_IP_V4_ONLY_ALLOWED                                     = 50,
-       PS_PDP_PERMANENT_REJECT_IP_V6_ONLY_ALLOWED                                     = 51,
-       PS_PDP_PERMANENT_REJECT_SINGLE_ADDR_BEARER_ONLY                                = 52,
-       PS_PDP_PERMANENT_REJECT_MESSAGE_INCORRECT_SEMANTIC                             = 95,
-       PS_PDP_PERMANENT_REJECT_INVALID_MANDATORY_INFO                                 = 96,
-       PS_PDP_PERMANENT_REJECT_MESSAGE_TYPE_UNSUPPORTED                               = 97,
-       PS_PDP_PERMANENT_REJECT_MSG_TYPE_NONCOMPATIBLE_STATE                           = 98,
-       PS_PDP_PERMANENT_REJECT_UNKNOWN_INFO_ELEMENT                                   = 99,
-       PS_PDP_PERMANENT_REJECT_CONDITIONAL_IE_ERROR                                   = 100,
-       PS_PDP_PERMANENT_REJECT_MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE                    = 101,
-       PS_PDP_PERMANENT_REJECT_PROTOCOL_ERROR                                         = 111,
-       PS_PDP_PERMANENT_REJECT_APN_TYPE_CONFLICT                                      = 112,
+       PS_PDP_REJ_FAIL_NONE = 0,
+       PS_PDP_REJ_OPERATOR_DETERMINED_BARRING = 8,
+       PS_PDP_REJ_LLC_SNDCP_FAILURE = 25,
+       PS_PDP_REJ_INSUFFICIENT_RESOURCES = 26,
+       PS_PDP_REJ_UNKNOWN_APN = 27,
+       PS_PDP_REJ_UNKNOWN_PDP = 28,
+       PS_PDP_REJ_AUTH_FAILED = 29,
+       PS_PDP_REJ_GGSN_REJECT = 30,
+       PS_PDP_REJ_ACTIVATION_REJECT = 31,
+       PS_PDP_REJ_OPTION_NOT_SUPPORTED = 32,
+       PS_PDP_REJ_OPTION_UNSUBSCRIBED = 33,
+       PS_PDP_REJ_OPTION_TEMP_OOO = 34,
+       PS_PDP_REJ_NSAPI_ALREADY_USED = 35,
+       PS_PDP_REJ_IP_V4_ONLY_ALLOWED = 50,
+       PS_PDP_REJ_IP_V6_ONLY_ALLOWED = 51,
+       PS_PDP_REJ_SINGLE_ADDR_BEARER_ONLY = 52,
+       PS_PDP_REJ_REQ_APN_NOT_SUPPORTED_IN_CURRENT_RAT_AND_PLMN = 66,
+       PS_PDP_REJ_MESSAGE_INCORRECT_SEMANTIC = 95,
+       PS_PDP_REJ_INVALID_MANDATORY_INFO = 96,
+       PS_PDP_REJ_MESSAGE_TYPE_UNSUPPORTED = 97,
+       PS_PDP_REJ_MSG_TYPE_NONCOMPATIBLE_STATE = 98,
+       PS_PDP_REJ_UNKNOWN_INFO_ELEMENT = 99,
+       PS_PDP_REJ_CONDITIONAL_IE_ERROR = 100,
+       PS_PDP_REJ_MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE = 101,
+       PS_PDP_REJ_PROTOCOL_ERROR = 111,
+       PS_PDP_REJ_APN_TYPE_CONFLICT = 112,
+       PS_PDP_REJ_HANDOFF = 12,
+       PS_PDP_REJ_PARTIAL_RETRY = 13,
+       PS_PDP_REJ_UNSPECIFIED = 14,
+       PS_PDP_REJ_PDN_THROTTLED = -8,
+       PS_PDP_REJ_IPV6_RS = -9,
+       PS_PDP_REJ_IPV6_PCSCF = -10,
+       PS_PDP_REJ_IMPLICITY_DETACH = -11,
+       PS_PDP_REJ_TIMER_T3396_STOPPED = -12,
+       PS_PDP_REJ_TIMER_T3396_STARTED = -13,
+       PS_PDP_REJ_TIMER_T3396_DEACTIVATED = -14,
+       PS_PDP_REJ_IPV6_REFRESH = -15,
+       PS_PDP_REJ_T3340_RUNNING = -16,
 };
 
+enum ps_nas_timer_state {
+       PS_NAS_TIMER_STATE_UNKNOWN = -1,
+       PS_NAS_TIMER_STATE_START = 0x01,
+       PS_NAS_TIMER_STATE_STOP = 0x02,
+       PS_NAS_TIMER_STATE_EXPIRE = 0x03,
+};
 
 enum ps_wifi_state {
        PS_WIFI_STATE_OFF = 0,
@@ -159,30 +188,44 @@ enum ps_wifi_state {
        PS_WIFI_STATE_CONNECTED = 2
 };
 
+enum ims_data_state {
+       IMS_DATA_STATE_SUSPEND = 0,
+       IMS_DATA_STATE_RESUME,
+};
+
+enum ims_data_pdn {
+       IMS_DATA_PDN_UNKNOWN = 0,
+       IMS_DATA_PDN_INTERNET,
+       IMS_DATA_PDN_IMS,
+       IMS_DATA_PDN_EMERGENCY,
+       IMS_DATA_PDN_CBS,
+       IMS_DATA_PDN_WIFI,
+};
+
 typedef struct packet_service_master {
-       gchar *path;
        TcorePlugin *plg;
+       Storage *strg;
        GDBusConnection *conn;
-       PacketServiceMaster *if_obj;
+       gpointer if_obj;
        GHashTable *modems;
 
        gboolean initial_pdp_conn; // If FALSE, PDP never been connected for any of slots.
 } ps_master_t;
 
 typedef struct packet_service_modem {
-       gcharpath;
-       gpointer p_master;
+       gchar *path;
+       ps_master_t *p_master;
        TcorePlugin *plg;
        CoreObject *co_modem;
        GDBusConnection *conn;
-       PacketServiceModem *if_obj;
+       gpointer if_obj;
 
        /* Temp DBus value */
        GDBusMethodInvocation *invocation;
        gint type;
 
        /* Value from modem */
-       gcharoperator;
+       gchar *operator;
        int powered;
        gboolean sim_init;
        gboolean reset_profile;
@@ -196,11 +239,15 @@ typedef struct packet_service_modem {
 
        gboolean data_allowed;
        gint ps_mode;
+       gint pm_state;
+       gint roaming_apn;
 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
        unsigned char hook_flag;
        gboolean mode_pref_changed;
        GQueue *work_queue;
+       alarm_id_t deact_timer_src;
 #endif
+       ps_subs_type subs_type;
        gchar *cp_name;
        GHashTable *services;
        GSList *contexts;
@@ -211,11 +258,12 @@ typedef struct packet_service_service {
        gchar *path;
        TcorePlugin *plg;
        GDBusConnection *conn;
-       PacketServiceService *if_obj;
+       gpointer if_obj;
 
-       gpointer p_modem;
+       ps_modem_t *p_modem;
        CoreObject *co_network;
        CoreObject *co_ps;
+       ps_subs_type subs_type;
 
        gboolean ps_attached;
        gboolean roaming;
@@ -234,22 +282,20 @@ typedef struct packet_service_service {
 } ps_service_t;
 
 typedef struct {
-       PacketServiceContext *obj_context;
+       gpointer obj_context;
        void *invocation;
        void *user_data;
 } ps_remove_profile_data;
 
 typedef struct packet_service_context {
-       gcharpath;
-       gcharmccmnc;
+       gchar *path;
+       gchar *mccmnc;
        GDBusConnection *conn;
-       PacketServiceContext *if_obj;
+       gpointer if_obj;
        TcorePlugin *plg;
 
        gboolean alwayson;
-#ifdef PREPAID_SIM_APN_SUPPORT
        gboolean prepaid_alwayson;
-#endif
        gboolean is_default;
        gboolean hidden;
        gboolean editable;
@@ -262,6 +308,7 @@ typedef struct packet_service_context {
        gpointer p_service;
        int profile_id;
        CoreObject *co_context;
+       ps_subs_type subs_type;
 
        gpointer async_context;
        gpointer user_data;
@@ -272,204 +319,33 @@ typedef struct packet_service_context {
        /* PDP retry timer */
        alarm_id_t timer_src;
        guint connection_timeout;
-} ps_context_t;
-
-
-/*MASTER*/
-void           __remove_master(gpointer master, gpointer user_data);
-gpointer    _ps_master_create_master(GDBusConnection *conn, TcorePlugin *p);
-gboolean    _ps_master_create_modems(gpointer master,TcorePlugin *p);
-gboolean    _ps_master_destroy_modem(gpointer object, TcorePlugin *plugin);
-gboolean    _ps_master_get_storage_value_bool(gpointer master, enum tcore_storage_key key);
-gboolean    _ps_master_get_storage_value_int(gpointer master, enum tcore_storage_key key);
-gboolean    _ps_master_set_storage_value_bool(gpointer master, enum tcore_storage_key key, gboolean value);
-gboolean    _ps_master_set_storage_value_int(gpointer master, enum tcore_storage_key key, gint value);
-gboolean       _ps_master_set_always_on_control(gpointer master, gboolean enable);
-
-/*MODEM*/
-void           __remove_modem_handler(gpointer modem);
-gpointer    _ps_modem_create_modem(GDBusConnection *conn, TcorePlugin *p, gpointer master,
-                               gchar* modem_name, gpointer co_modem, gchar *cp_name);
-void        _ps_modem_destroy_modem(GDBusConnection *conn, gpointer object);
-gboolean    _ps_modem_processing_flight_mode(gpointer object, gboolean enable);
-gboolean    _ps_modem_processing_power_enable(gpointer modem, int enable);
-gboolean    _ps_modem_processing_sim_complete(gpointer modem, gboolean complete, gchar *operator);
-gboolean       _ps_modem_set_reset_profile(gpointer object, gboolean value);
-gboolean       _ps_modem_get_reset_profile(gpointer object);
-GSource * _ps_modem_get_profile_reset_gsource(gpointer object);
-gboolean _ps_modem_set_profile_reset_gsource(gpointer object, GSource * source);
-gboolean  _ps_modem_remove_profile_reset_gsource(gpointer object);
-gboolean    _ps_modem_set_sim_enabled(gpointer object, gboolean value);
-gboolean       _ps_modem_connect_default_context(gpointer object);
-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_roaming(gpointer object);
-void        _ps_modem_set_roaming(gpointer object, gboolean value);
-gboolean    _ps_modem_set_psmode(gpointer modem, gint value);
-gint           _ps_modem_get_psmode(gpointer modem);
-gint           _ps_modem_get_roaming_apn_support(gpointer object);
-void           _ps_modem_set_roaming_apn_support(gpointer object, gboolean value);
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-guchar         _ps_modem_get_hook_flag(gpointer modem);
-#endif
-gboolean    _ps_modem_get_flght_mode(gpointer object);
-gboolean    _ps_modem_get_sim_init(gpointer object);
-int    _ps_modem_get_power(gpointer object);
-gchar*      _ps_modem_ref_operator(gpointer object);
-gboolean       _ps_modem_get_properties_handler(gpointer object, GVariantBuilder * properties);
-GVariant*      _ps_modem_get_properties(gpointer object, GVariantBuilder *properties);
-gpointer       _ps_modem_ref_master(gpointer modem);
-GHashTable* _ps_modem_ref_services(gpointer modem);
-gchar*      _ps_modem_ref_path(gpointer modem);
-gpointer    _ps_modem_ref_plugin(gpointer modem);
-gpointer    _ps_modem_ref_dbusconn(gpointer modem);
-gpointer    _ps_modem_ref_co_modem(gpointer modem);
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-gpointer       _ps_modem_ref_work_queue(gpointer modem);
-#endif
-gchar*         _ps_modem_ref_cp_name(gpointer modem);
-gpointer       _ps_modem_ref_contexts(gpointer modem);
-ps_subs_type _ps_modem_get_subs_type(gpointer modem);
-gboolean _ps_modem_initiate_reset_profile(gpointer modem);
-
-/*SERVICE*/
-void           __remove_service_handler(gpointer service);
-gpointer    _ps_service_create_service(GDBusConnection *conn, TcorePlugin *p,
-                               gpointer modem, CoreObject *co_network, CoreObject *co_ps, gchar* path);
-gboolean    _ps_service_ref_context(gpointer object, gpointer context);
-gboolean    _ps_service_ref_contexts(gpointer service, GSList *contexts, gchar *operator);
-gboolean       _ps_service_unref_context(gpointer object, gpointer context);
-gboolean       _ps_service_get_properties_handler(gpointer object, GVariantBuilder *properties);
-GVariant*      _ps_service_get_properties(gpointer object, GVariantBuilder *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);
-gpointer    _ps_service_ref_modem(gpointer object);
-gboolean    _ps_service_set_context_devinfo(gpointer service, struct tnoti_ps_pdp_ipconfiguration *devinfo);
-gboolean       _ps_service_set_context_bearerinfo(gpointer object, struct tnoti_ps_dedicated_bearer_info *bearer_info);
-int            _ps_service_define_context(gpointer object, gpointer context);
-int         _ps_service_activate_context(gpointer service, gpointer context);
-gboolean    _ps_service_deactivate_context(gpointer service, gpointer context);
-void        _ps_service_set_retry_timeout_value(gpointer service, guint value);
-void        _ps_service_connection_timer(gpointer service, gpointer context);
-void        _ps_service_reset_connection_timer(gpointer context);
-int         _ps_service_connect_default_context(gpointer service);
-#ifdef PREPAID_SIM_APN_SUPPORT
-gboolean    _ps_service_connect_last_connected_context(gpointer object);
-int         _ps_service_connect_default_prepaid_context(gpointer object);
-gboolean    _ps_service_connect_last_connected_context_ex(gpointer service, gpointer object, gboolean *defined, gchar *operator);
-gpointer    _ps_service_return_context_by_cid(gpointer object, int context_id);
-#endif
-void        _ps_service_remove_contexts(gpointer object);
-void        _ps_service_disconnect_contexts(gpointer service);
-void   _ps_service_disconnect_internet_mms_tethering_contexts(gpointer object);
-gboolean    _ps_service_processing_network_event(gpointer service, gboolean ps_attached, gboolean roaming);
-gpointer    _ps_service_return_default_context(gpointer object, int svc_cat_id);
-gboolean    _ps_service_set_connected(gpointer service, gpointer cstatus, gboolean enabled);
-void           _ps_service_set_ps_defined(ps_service_t *service, gboolean value, int cid);
-gboolean    _ps_service_set_ps_attached(gpointer service, gboolean value);
-gboolean    _ps_service_set_number_of_pdn_cnt(gpointer object, gchar *operator);
-gboolean    _ps_service_set_roaming(gpointer service, gboolean value);
-gboolean    _ps_service_get_roaming(gpointer object);
-gboolean    _ps_service_set_restricted(gpointer object, gboolean value);
-gboolean    _ps_service_get_restricted(gpointer object);
-gboolean _ps_service_set_ims_activation_requested(gpointer object, gboolean enabled);
-gboolean _ps_service_get_ims_activation_requested(gpointer object);
-gboolean _ps_service_set_epdg_status(gpointer object, gboolean available);
-gboolean _ps_service_get_epdg_status(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);
-int            _ps_service_update_roaming_apn(gpointer object);
-void           _ps_service_set_attach_apn(ps_service_t *service);
-
-/*CONTEXT*/
-void           __remove_context_handler(gpointer context);
-gboolean    _ps_context_initialize(gpointer plugin);
-gboolean    _ps_context_reset_profile_table(gchar *cp_name);
-gboolean    _ps_context_fill_profile_table_from_ini_file(gchar *cp_name);
-gboolean    _ps_context_reset_hashtable(gpointer modem);
-GSList*        _ps_context_create_hashtable(gpointer modem, gboolean roaming);
-gboolean    _ps_context_add_context(gpointer modem, gchar *operator, GHashTable *property);
-gboolean       _ps_context_get_properties_handler(gpointer context, GVariantBuilder *properties);
-GVariant*      _ps_context_get_properties(gpointer context, GVariantBuilder *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);
-#ifdef PREPAID_SIM_APN_SUPPORT
-gboolean    _ps_context_get_prepaid_alwayson_enable(gpointer object);
-int         _ps_context_get_profile_id(gpointer object);
-#endif
-gchar*      _ps_context_ref_path(gpointer context);
-gpointer    _ps_context_ref_co_context(gpointer context);
-gboolean    _ps_context_set_connected(gpointer context, gboolean enabled);
-gboolean       _ps_context_set_profile_enable(gpointer object, gboolean value);
-gboolean       _ps_context_get_profile_enable(gpointer object);
-gboolean       _ps_context_set_ps_defined(gpointer object, gboolean value);
-gboolean       _ps_context_get_ps_defined(gpointer object);
-gboolean    _ps_context_set_alwayson_enable(gpointer object, gboolean enabled);
-gboolean    _ps_context_get_default_context(gpointer object, int svc_cat_id);
-gboolean    _ps_context_remove_context(gpointer context);
-gboolean    _ps_context_reset_user_data(gpointer object);
-gboolean _ps_context_create_cdma_profile(gchar* mccmnc, gchar* cp_name);
-gpointer    _ps_context_get_user_data(gpointer object);
-TReturn     _ps_connection_hdlr(gpointer object);
-void        _ps_default_connection_hdlr(gpointer object);
-gint        _ps_context_get_number_of_pdn(gchar *operator, gchar *cp_name);
-gboolean       _ps_context_handle_ifaceup(gpointer user_data);
-gboolean       _ps_context_handle_ifacedown(gpointer user_data);
-gboolean       _ps_context_set_bearer_info(gpointer object, struct tnoti_ps_dedicated_bearer_info *bearer_info);
-gboolean       _ps_context_check_is_roaming_apn_support(gchar* mccmnc, gchar* cp_name);
-
-/*PLUGIN INTERFACE*/
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-void        _ps_get_network_mode(gpointer data);
-#endif
-gboolean    _ps_hook_co_modem_event(gpointer modem);
-gboolean    _ps_free_co_modem_event(gpointer modem);
-gboolean    _ps_get_co_modem_values(gpointer modem);
-gboolean    _ps_hook_co_network_event(gpointer service);
-gboolean    _ps_free_co_network_event(gpointer service);
-gboolean    _ps_get_co_network_values(gpointer service);
-gboolean    _ps_hook_co_ps_event(gpointer service);
-gboolean       _ps_free_modem_event(gpointer modem);
-gboolean    _ps_free_co_ps_event(gpointer service);
-gboolean _ps_free_co_modem_event(gpointer modem);
-gboolean    _ps_update_cellular_state_key(gpointer service);
 
+       /* IMS deregist */
+       gint ims_timer_id;
+       GMainLoop *ims_mainloop;
+} ps_context_t;
 /* Utilities */
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-void __ps_hook_response_cb(UserRequest *ur, enum tcore_response_command command, unsigned int data_len, const void *data, void *user_data);
-void __ps_modem_cp_reset_send_pending_request_response(gpointer data);
-#endif
 enum tcore_hook_return ps_handle_dds(Server *s, UserRequest *ur, void *user_data);
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_data);
-void __ps_send_pending_user_request(gpointer data);
-#endif
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-typedef enum {
-       ON_REQUEST,
-       ON_NON_CALL_NOTI_HOOK,
-       ON_CALL_NOTI_HOOK,
-}__ps_call_flow_type;
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-void __ps_check_handle_modem_off_request(gpointer data, __ps_call_flow_type type,enum tcore_notification_command command);
-#endif
-#endif /* #ifdef POWER_SAVING_FEATURE_WEARABLE */
-
 enum tcore_hook_return __on_hook_modem_added(Server *s, CoreObject *source, enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data);
 enum tcore_hook_return __on_hook_modem_removed(Server *s, CoreObject *source, enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data);
 
 /* util.c */
-GSource * ps_util_gsource_dispatch(GMainContext *main_context, gint priority, GSourceFunc cb, gpointer data);
+GSource *ps_util_gsource_dispatch(GMainContext *main_context, gint priority, GSourceFunc cb, gpointer data);
 gboolean ps_util_thread_dispatch(GMainContext *main_context, gint priority, GSourceFunc cb, gpointer data);
-int  ps_util_system_command(char * command);
-void ps_util_load_xml_file(const char *docname, const char *groupname, void **i_doc, void **i_root_node);
-void ps_util_unload_xml_file(void **i_doc, void **i_root_node);
+int      ps_util_system_command(char *command);
+void     ps_util_load_xml_file(const char *docname, const char *groupname, void **i_doc, void **i_root_node);
+void     ps_util_unload_xml_file(void **i_doc, void **i_root_node);
+
+gboolean ps_util_check_permanent_reject_cause(int cause, gboolean roaming);
+
+struct work_queue_data {
+       unsigned int id;
+       UserRequest *ur;
+};
+
+gboolean     ps_util_add_waiting_job(GQueue *queue, unsigned int id, UserRequest *ur);
+UserRequest *ps_util_peek_waiting_job(GQueue *queue, unsigned int id);
+UserRequest *ps_util_pop_waiting_job(GQueue *queue, unsigned int id);
+guint        ps_util_get_waiting_job_count(GQueue *queue, unsigned int id);
 
 #endif /* __PS_COMMON_H__ */
diff --git a/include/ps_context.h b/include/ps_context.h
new file mode 100644 (file)
index 0000000..d7f5fcd
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Rajashekar Reddy <r.ereddy@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.
+ *
+ */
+
+#pragma once
+
+void          __remove_context_handler(gpointer context);
+gboolean      _ps_context_initialize(TcorePlugin *plugin);
+gboolean      _ps_context_reset_profile_table(gchar *cp_name);
+gboolean      _ps_context_fill_profile_table_from_ini_file(gchar *cp_name);
+GSList *      _ps_context_create_hashtable(ps_modem_t *modem, gboolean roaming);
+gboolean      _ps_context_add_context(ps_modem_t *modem, gchar *operator, GHashTable *property);
+gboolean      _ps_context_get_properties_handler(ps_context_t *context, GVariantBuilder *properties);
+GVariant *    _ps_context_get_properties(ps_context_t *context, GVariantBuilder *properties);
+gboolean      _ps_context_set_service(ps_context_t *context, ps_service_t *service);
+ps_service_t *_ps_context_ref_service(ps_context_t *context);
+gboolean      _ps_context_get_alwayson_enable(ps_context_t *context);
+gboolean      _ps_context_get_prepaid_alwayson_enable(ps_context_t *context);
+int           _ps_context_get_profile_id(ps_context_t *context);
+gchar *       _ps_context_ref_path(ps_context_t *context);
+CoreObject *  _ps_context_ref_co_context(ps_context_t *context);
+gboolean      _ps_context_set_connected(ps_context_t *context, gboolean enabled);
+gboolean      _ps_context_set_profile_enable(ps_context_t *context, gboolean value);
+gboolean      _ps_context_get_profile_enable(ps_context_t *context);
+gboolean      _ps_context_set_ps_defined(ps_context_t *context, gboolean value);
+gboolean      _ps_context_get_ps_defined(ps_context_t *context);
+gboolean      _ps_context_set_alwayson_enable(ps_context_t *contex, gboolean enabled);
+gboolean      _ps_context_get_default_context(ps_context_t *contex, int svc_cat_id);
+gboolean      _ps_context_remove_context(ps_context_t *context);
+gboolean      _ps_context_reset_user_data(ps_context_t *context);
+gboolean      _ps_context_create_cdma_profile(gchar *mccmnc, gchar *cp_name);
+gpointer      _ps_context_get_user_data(ps_context_t *context);
+TReturn       _ps_connection_hdlr(ps_context_t *context);
+void          _ps_default_connection_hdlr(ps_context_t *context);
+gint          _ps_context_get_number_of_pdn(gchar *operator, ps_service_t *service);
+gboolean      _ps_context_handle_ifaceup(ps_context_t *context);
+gboolean      _ps_context_handle_ifacedown(ps_context_t *context);
+gboolean      _ps_context_set_bearer_info(ps_context_t *context, struct tnoti_ps_dedicated_bearer_info *bearer_info);
+gboolean      _ps_context_check_is_roaming_apn_support(gchar *mccmnc, gchar *cp_name);
+gboolean      _ps_context_handling_nas_timer(ps_context_t *context, gboolean value);
+gboolean      _ps_context_set_default_connection_enable(ps_context_t *context, gboolean enabled);
+gboolean _ps_context_update_attach_apn(GSList *contexts, const gchar *mccmnc);
+
+#ifdef TIZEN_SUPPORT_VOLTE
+void     _ps_context_hook_deregister_ims_cb(UserRequest *ur, enum tcore_response_command command, unsigned int data_len, const void *data, void *user_data);
+gboolean _ps_context_deregister_ims_timeout(gpointer user_data);
+TReturn  _ps_context_deregister_ims(ps_context_t *context);
+#endif
+
+gpointer _ps_context_create_database_handle(const char *cp_name);
+gboolean __ps_context_update_database(ps_context_t *context);
+gboolean _ps_context_remove_database(ps_context_t *context);
+gboolean _ps_context_update_default_internet_to_db(ps_context_t *context, gboolean enabled);
+
+void _ps_context_emit_property_changed_signal(ps_context_t *context);
diff --git a/include/ps_hook.h b/include/ps_hook.h
new file mode 100644 (file)
index 0000000..e7573f6
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Rajashekar Reddy <r.ereddy@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.
+ *
+ */
+
+#pragma once
+
+/* HOOK */
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
+guchar   _ps_hook_get_hook_flag(ps_modem_t *modem);
+GQueue * _ps_hook_ref_work_queue(ps_modem_t *modem);
+gboolean _ps_hook_add_modem_hooks(ps_modem_t *modem);
+gboolean _ps_hook_free_modem_hooks(ps_modem_t *modem);
+void     _ps_hook_cp_reset_send_pending_request_response(ps_modem_t *modem);
+void     _ps_hook_send_pending_user_request(ps_modem_t *modem);
+#endif
index 2b032d2..2168f33 100644 (file)
 
 #pragma once
 
-#define PS_LOG_TAG_BUFFER 32
-
-extern const gchar *ps_log_get_cp_name(CoreObject *co);
-
-#define ps_err_ex_co(c,...) do {       \
-               gchar tag_buffer[PS_LOG_TAG_BUFFER];  \
-               int subs_type = tcore_object_ref_subscription_type(c);  \
-               g_snprintf(tag_buffer, PS_LOG_TAG_BUFFER, "%s/SUBS-%d", MODULE_TAG, subs_type);  \
-               err_ex(tag_buffer, "[ERROR] "__VA_ARGS__);      \
-       } while (0)
-
-#define ps_warn_ex_co(c,...) do {      \
-               gchar tag_buffer[PS_LOG_TAG_BUFFER];  \
-               int subs_type = tcore_object_ref_subscription_type(c);  \
-               g_snprintf(tag_buffer, PS_LOG_TAG_BUFFER, "%s/SUBS-%d", MODULE_TAG, subs_type);  \
-               warn_ex(tag_buffer, "[WARN] "__VA_ARGS__);      \
-       } while (0)
-
-#define ps_msg_ex_co(c,...) do {       \
-               gchar tag_buffer[PS_LOG_TAG_BUFFER];  \
-               int subs_type = tcore_object_ref_subscription_type(c);  \
-               g_snprintf(tag_buffer, PS_LOG_TAG_BUFFER, "%s/SUBS-%d", MODULE_TAG, subs_type);  \
-               msg_ex(tag_buffer, __VA_ARGS__);        \
-       } while (0)
-
-#define ps_dbg_ex_co(c,...) do {       \
-               gchar tag_buffer[PS_LOG_TAG_BUFFER];  \
-               int subs_type = tcore_object_ref_subscription_type(c);  \
-               g_snprintf(tag_buffer, PS_LOG_TAG_BUFFER, "%s/SUBS-%d", MODULE_TAG, subs_type);  \
-               dbg_ex(tag_buffer, __VA_ARGS__);        \
-       } while (0)
-
-#define ps_info_ex_co(c,...) do {      \
-               gchar tag_buffer[PS_LOG_TAG_BUFFER];  \
-               int subs_type = tcore_object_ref_subscription_type(c);  \
-               g_snprintf(tag_buffer, PS_LOG_TAG_BUFFER, "%s/SUBS-%d", MODULE_TAG, subs_type);  \
-               info_ex(tag_buffer, __VA_ARGS__);       \
-       } while (0)
+#include "ps_common.h"
+
+const gchar *ps_log_get_tag_by_modem(ps_modem_t *modem);
+const gchar *ps_log_get_tag_by_service(ps_service_t *service);
+const gchar *ps_log_get_tag_by_context(ps_context_t *context);
+
+#define ps_err_ex_modem(m, ...) do {    \
+               const gchar *tag = ps_log_get_tag_by_modem(m);  \
+               err_ex(tag, "[ERROR] "__VA_ARGS__); \
+} while (0)
+
+#define ps_warn_ex_modem(m, ...) do {   \
+               const gchar *tag = ps_log_get_tag_by_modem(m);  \
+               warn_ex(tag, "[WARN] "__VA_ARGS__); \
+} while (0)
+
+#define ps_dbg_ex_modem(m, ...) do {    \
+               const gchar *tag = ps_log_get_tag_by_modem(m);  \
+               dbg_ex(tag, __VA_ARGS__);       \
+} while (0)
+
+#define ps_info_ex_modem(m, ...) do {   \
+               const gchar *tag = ps_log_get_tag_by_modem(m);  \
+               info_ex(tag, __VA_ARGS__);      \
+} while (0)
+
+#define ps_err_ex_svc(s, ...) do {      \
+               const gchar *tag = ps_log_get_tag_by_service(s);        \
+               err_ex(tag, "[ERROR] "__VA_ARGS__); \
+} while (0)
+
+#define ps_warn_ex_svc(s, ...) do {     \
+               const gchar *tag = ps_log_get_tag_by_service(s);        \
+               warn_ex(tag, "[WARN] "__VA_ARGS__); \
+} while (0)
+
+#define ps_dbg_ex_svc(s, ...) do {      \
+               const gchar *tag = ps_log_get_tag_by_service(s);        \
+               dbg_ex(tag, __VA_ARGS__);       \
+} while (0)
+
+#define ps_info_ex_svc(s, ...) do {     \
+               const gchar *tag = ps_log_get_tag_by_service(s);        \
+               info_ex(tag, __VA_ARGS__);      \
+} while (0)
+
+#define ps_err_ex_ctx(c, ...) do {      \
+               const gchar *tag = ps_log_get_tag_by_context(c);        \
+               err_ex(tag, "[ERROR] "__VA_ARGS__); \
+} while (0)
+
+#define ps_warn_ex_ctx(c, ...) do {     \
+               const gchar *tag = ps_log_get_tag_by_context(c);        \
+               warn_ex(tag, "[WARN] "__VA_ARGS__); \
+} while (0)
+
+#define ps_dbg_ex_ctx(c, ...) do {      \
+               const gchar *tag = ps_log_get_tag_by_context(c);        \
+               dbg_ex(tag, __VA_ARGS__);       \
+} while (0)
+
+#define ps_info_ex_ctx(c, ...) do {     \
+               const gchar *tag = ps_log_get_tag_by_context(c);        \
+               info_ex(tag, __VA_ARGS__);      \
+} while (0)
 
index d86585f..a43d400 100644 (file)
@@ -27,4 +27,5 @@ gboolean ps_main_init(TcorePlugin *plugin);
 
 void ps_main_exit(TcorePlugin *plugin);
 
-#endif /* __PS_MAIN_H__ */
\ No newline at end of file
+#endif /* __PS_MAIN_H__ */
+
diff --git a/include/ps_master.h b/include/ps_master.h
new file mode 100644 (file)
index 0000000..74623f5
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Rajashekar Reddy <r.ereddy@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.
+ *
+ */
+
+#pragma once
+#define PS_MASTER_PATH  "/"
+
+/*MASTER*/
+void         __remove_master(gpointer data, gpointer user_data);
+ps_master_t *_ps_master_create_master(GDBusConnection *conn, TcorePlugin *p);
+gboolean     _ps_master_create_modems(ps_master_t *master, TcorePlugin *p);
+gboolean     _ps_master_destroy_modem(ps_master_t *master, TcorePlugin *plugin);
+gboolean     _ps_master_get_storage_value_bool(ps_master_t *master, enum tcore_storage_key key);
+gboolean     _ps_master_get_storage_value_int(ps_master_t *master, enum tcore_storage_key key);
+char        *_ps_master_get_storage_value_string(ps_master_t *master, enum tcore_storage_key key);
+gboolean     _ps_master_set_storage_value_bool(ps_master_t *master, enum tcore_storage_key key, gboolean value);
+gboolean     _ps_master_set_storage_value_int(ps_master_t *master, enum tcore_storage_key key, gint value);
+gboolean     _ps_master_set_storage_value_string(ps_master_t *master, enum tcore_storage_key key, char *value);
+gboolean     _ps_master_set_always_on_control(ps_master_t *master, gboolean enable);
diff --git a/include/ps_modem.h b/include/ps_modem.h
new file mode 100644 (file)
index 0000000..5d5f505
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Rajashekar Reddy <r.ereddy@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.
+ *
+ */
+
+#pragma once
+
+
+/*MODEM*/
+void        __remove_modem_handler(gpointer modem);
+ps_modem_t *_ps_modem_create_modem(GDBusConnection *conn, TcorePlugin *p, ps_master_t *master,
+                                  gchar *modem_name, CoreObject *co_modem, gchar *cp_name);
+void             _ps_modem_destroy_modem(GDBusConnection *conn, ps_modem_t *modem);
+gboolean         _ps_modem_processing_flight_mode(ps_modem_t *modem, gboolean enable);
+gboolean         _ps_modem_processing_power_enable(ps_modem_t *modem, int enable);
+gboolean         _ps_modem_processing_no_sim(ps_modem_t *modem);
+gboolean         _ps_modem_processing_sim_complete(ps_modem_t *modem, gboolean complete, gchar *operator);
+gboolean         _ps_modem_processing_sim_refresh(ps_modem_t *modem);
+gboolean         _ps_modem_set_attach_apn(ps_modem_t *modem);
+gboolean         _ps_modem_get_reset_profile(ps_modem_t *modem);
+GSource *        _ps_modem_get_profile_reset_gsource(ps_modem_t *modem);
+gboolean         _ps_modem_set_profile_reset_gsource(ps_modem_t *modem, GSource *source);
+gboolean         _ps_modem_remove_profile_reset_gsource(ps_modem_t *modem);
+gboolean         _ps_modem_set_sim_enabled(ps_modem_t *modem, gboolean value);
+gboolean         _ps_modem_connect_default_context(ps_modem_t *modem);
+gboolean         _ps_modem_set_data_allowed(ps_modem_t *modem, gboolean value);
+gboolean         _ps_modem_get_data_allowed(ps_modem_t *modem);
+gboolean         _ps_modem_set_data_roaming_allowed(ps_modem_t *modem, gboolean value);
+gboolean         _ps_modem_get_data_roaming_allowed(ps_modem_t *modem);
+gboolean         _ps_modem_set_pm_state(ps_modem_t *modem, gint pm_state);
+gboolean         _ps_modem_set_data_roaming_apn(ps_modem_t *modem, int value);
+int              _ps_modem_get_data_roaming_apn(ps_modem_t *modem);
+gboolean         _ps_modem_get_roaming(ps_modem_t *modem);
+void             _ps_modem_set_roaming(ps_modem_t *modem, gboolean value);
+gboolean         _ps_modem_set_psmode(ps_modem_t *modem, gint value);
+gint             _ps_modem_get_psmode(ps_modem_t *modem);
+gint             _ps_modem_get_roaming_apn_support(ps_modem_t *modem);
+void             _ps_modem_set_roaming_apn_support(ps_modem_t *modem, gboolean value);
+gboolean         _ps_modem_get_flght_mode(ps_modem_t *modem);
+gboolean         _ps_modem_get_sim_init(ps_modem_t *modem);
+int              _ps_modem_get_power(ps_modem_t *modem);
+gchar *          _ps_modem_ref_operator(ps_modem_t *modem);
+gboolean         _ps_modem_get_properties_handler(ps_modem_t *modem, GVariantBuilder *properties);
+GVariant *       _ps_modem_get_properties(ps_modem_t *modem, GVariantBuilder *properties);
+ps_master_t *    _ps_modem_ref_master(ps_modem_t *modem);
+GHashTable *     _ps_modem_ref_services(ps_modem_t *modem);
+gchar *          _ps_modem_ref_path(ps_modem_t *modem);
+TcorePlugin *    _ps_modem_ref_plugin(ps_modem_t *modem);
+GDBusConnection *_ps_modem_ref_dbusconn(ps_modem_t *modem);
+CoreObject *     _ps_modem_ref_co_modem(ps_modem_t *modem);
+gchar *          _ps_modem_ref_cp_name(ps_modem_t *modem);
+GSList *         _ps_modem_ref_contexts(ps_modem_t *modem);
+ps_subs_type     _ps_modem_get_subs_type(ps_modem_t *modem);
+gboolean         _ps_modem_initiate_reset_profile(ps_modem_t *modem);
diff --git a/include/ps_service.h b/include/ps_service.h
new file mode 100644 (file)
index 0000000..62791d0
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Rajashekar Reddy <r.ereddy@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.
+ *
+ */
+
+#pragma once
+
+/*SERVICE*/
+void          __remove_service_handler(gpointer service);
+ps_service_t *_ps_service_create_service(GDBusConnection *conn, TcorePlugin *p,
+                                        ps_modem_t *modem, CoreObject *co_network, CoreObject *co_ps, gchar *path);
+gboolean     _ps_service_ref_context(ps_service_t *service, ps_context_t *context);
+gboolean     _ps_service_ref_contexts(ps_service_t *service, GSList *contexts, gchar *operator);
+gboolean     _ps_service_unref_context(ps_service_t *service, ps_context_t *context);
+gboolean     _ps_service_get_properties_handler(ps_service_t *service, GVariantBuilder *properties);
+GVariant *   _ps_service_get_properties(ps_service_t *service, GVariantBuilder *properties);
+gchar *      _ps_service_ref_path(ps_service_t *service);
+TcorePlugin *_ps_service_ref_plugin(ps_service_t *service);
+CoreObject * _ps_service_ref_co_network(ps_service_t *service);
+CoreObject * _ps_service_ref_co_ps(ps_service_t *service);
+ps_modem_t * _ps_service_ref_modem(ps_service_t *service);
+gboolean     _ps_service_set_context_devinfo(ps_service_t *service, struct tnoti_ps_pdp_ipconfiguration *devinfo);
+gboolean     _ps_service_set_context_bearerinfo(ps_service_t *service, struct tnoti_ps_dedicated_bearer_info *bearer_info);
+int          _ps_service_define_context(ps_service_t *service, ps_context_t *context);
+int          _ps_service_activate_context(ps_service_t *service, ps_context_t *context);
+int     _ps_service_deactivate_context(ps_service_t *service, ps_context_t *context);
+void         _ps_service_set_retry_timeout_value(ps_context_t *context, guint value);
+void         _ps_service_connection_timer(ps_service_t *service, ps_context_t *context);
+void         _ps_service_reset_connection_timer(ps_context_t *context);
+int          _ps_service_connect_default_context(ps_service_t *service);
+gboolean                _ps_service_connect_last_connected_context(ps_service_t *service);
+int                     _ps_service_connect_default_prepaid_context(ps_service_t *service);
+gboolean                _ps_service_connect_last_connected_context_ex(ps_service_t *service, ps_context_t *context, gboolean *defined, gchar *operator);
+ps_context_t           *_ps_service_return_context_by_cid(ps_service_t *service, int context_id);
+void                    _ps_service_remove_contexts(ps_service_t *service);
+void                    _ps_service_disconnect_contexts(ps_service_t *service);
+void                    _ps_service_disconnect_internet_mms_tethering_contexts(ps_service_t *service);
+gboolean                _ps_service_processing_network_event(ps_service_t *service, gboolean ps_attached, gboolean roaming);
+ps_context_t *          _ps_service_return_default_context(ps_service_t *service, int svc_cat_id);
+gboolean                _ps_service_set_connected(ps_service_t *service, gpointer cstatus, gboolean enabled);
+void                    _ps_service_set_ps_defined(ps_service_t *service, gboolean value, int cid);
+gboolean                _ps_service_set_ps_attached(ps_service_t *service, gboolean value);
+gboolean                _ps_service_set_number_of_pdn_cnt(ps_service_t *service, gchar *operator);
+gboolean                _ps_service_set_roaming(ps_service_t *service, gboolean value);
+gboolean                _ps_service_get_roaming(ps_service_t *service);
+gboolean                _ps_service_set_restricted(ps_service_t *service, gboolean value);
+gboolean                _ps_service_get_restricted(ps_service_t *service);
+gboolean                _ps_service_set_ims_activation_requested(ps_service_t *service, gboolean enabled);
+gboolean                _ps_service_get_ims_activation_requested(ps_service_t *service);
+gboolean                _ps_service_set_epdg_ip_configuration(ps_service_t *service, gint cid, char *ipv4_addr, char *ipv6_addr);
+gboolean                _ps_service_set_epdg_status(ps_service_t *service, gboolean available);
+gboolean                _ps_service_get_epdg_status(ps_service_t *service);
+gboolean                _ps_service_set_access_technology(ps_service_t *service, enum telephony_network_access_technology value);
+enum telephony_ps_state _ps_service_check_cellular_state(ps_service_t *service);
+int                     _ps_service_update_roaming_apn(ps_service_t *service);
+void                    _ps_service_set_attach_apn(ps_service_t *service);
+void                    _ps_service_handling_nas_timer(ps_service_t *service, gboolean state);
diff --git a/include/ps_tcore_interface.h b/include/ps_tcore_interface.h
new file mode 100644 (file)
index 0000000..400672c
--- /dev/null
@@ -0,0 +1,34 @@
+
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Rajashekar Reddy <r.ereddy@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.
+ *
+ */
+
+#pragma once
+
+/*PLUGIN INTERFACE*/
+gboolean _ps_add_co_modem_event(ps_modem_t *modem);
+gboolean _ps_free_co_modem_event(ps_modem_t *modem);
+gboolean _ps_get_co_modem_values(ps_modem_t *modem);
+gboolean _ps_add_co_network_event(ps_service_t *service);
+gboolean _ps_free_co_network_event(ps_service_t *service);
+gboolean _ps_get_co_network_values(ps_service_t *service);
+gboolean _ps_add_co_ps_event(ps_service_t *service);
+gboolean _ps_free_co_ps_event(ps_service_t *service);
+gboolean _ps_update_cellular_state_key(ps_service_t *service);
diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7d18c44
--- /dev/null
@@ -0,0 +1,38 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(interface C)
+
+#INCLUDE(FindPkgConfig)
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED glib-2.0 gio-2.0 gio-unix-2.0 tcore iniparser)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include/  ${CMAKE_CURRENT_SOURCE_DIR}/../include/ )
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wextra -fvisibility=hidden -fPIC")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wmissing-declarations -Wcast-align")
+
+### Purge unused code ###
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -ffunction-sections -Wl,--gc-sections")
+SET(INTROSPECTION_PATH "${CMAKE_CURRENT_SOURCE_DIR}/introspection")
+
+ADD_CUSTOM_COMMAND(
+       OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated-code.c
+       COMMAND gdbus-codegen --interface-prefix com.tcore.ps. --generate-c-code generated-code --c-namespace PacketService --c-generate-object-manager --generate-docbook generated-docs ${INTROSPECTION_PATH}/master.xml ${INTROSPECTION_PATH}/modem.xml ${INTROSPECTION_PATH}/service.xml ${INTROSPECTION_PATH}/context.xml
+       COMMENT "Generating GDBus .c/.h")
+
+ADD_CUSTOM_TARGET(generated_code DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/generated-code.c)
+
+SET(INTERFACE_SRCS
+       ${CMAKE_CURRENT_SOURCE_DIR}/src/ps_master_interface.c
+       ${CMAKE_CURRENT_SOURCE_DIR}/src/ps_modem_interface.c
+       ${CMAKE_CURRENT_SOURCE_DIR}/src/ps_service_interface.c
+       ${CMAKE_CURRENT_SOURCE_DIR}/src/ps_context_interface.c
+       #${CMAKE_CURRENT_BINARY_DIR}/generated-code.c
+       PARENT_SCOPE
+)
diff --git a/interface/include/ps_context_interface.h b/interface/include/ps_context_interface.h
new file mode 100644 (file)
index 0000000..726d763
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#pragma once
+
+void ps_context_emit_property_changed_signal(ps_context_t *context);
+void ps_context_emit_dedicated_bearer_info_signal(ps_context_t *context);
+void ps_service_complete_remove_profile(ps_context_t *context, gboolean enabled);
+gboolean ps_context_setup_interface(ps_context_t *context_data);
diff --git a/interface/include/ps_master_interface.h b/interface/include/ps_master_interface.h
new file mode 100644 (file)
index 0000000..7e469e1
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#pragma once
+
+void ps_master_emit_modem_added_signal(ps_master_t *master, ps_modem_t *modem);
+gboolean ps_master_setup_interface(ps_master_t *master_data);
diff --git a/interface/include/ps_modem_interface.h b/interface/include/ps_modem_interface.h
new file mode 100644 (file)
index 0000000..3e464f2
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#pragma once
+
+void ps_modem_emit_property_changed_signal(ps_modem_t *modem);
+void ps_modem_emit_service_added_signal(ps_modem_t *modem, ps_service_t *service);
+gboolean ps_modem_setup_interface(ps_modem_t *modem_data);
diff --git a/interface/include/ps_service_interface.h b/interface/include/ps_service_interface.h
new file mode 100644 (file)
index 0000000..12f3abb
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#pragma once
+
+void ps_service_emit_property_changed_signal(ps_service_t *service);
+void ps_service_emit_context_added_signal(ps_service_t *service, ps_context_t *context);
+void ps_service_emit_context_removed_signal(ps_service_t *service, ps_context_t *context);
+gboolean ps_service_setup_interface(ps_service_t *service_data);
similarity index 69%
rename from introspection/modem.xml
rename to interface/introspection/modem.xml
index 203497a..a5c249d 100644 (file)
                        <arg  type="b" name="result" direction="out" />
                </method>
                <method name="GoDormantAll">
-                        <arg  type="i" name="result" direction="out" />
-               </method>               
+                       <arg  type="i" name="result" direction="out" />
+               </method>
+               <!--
+                       SetAttach
+                       @attach_req_info: (0xff0000 & (attach << 16)) |(0x00ff00 & (reattach << 8)) | (0x0000ff & detachreason);
+               -->
+               <method name="SetAttach">
+                       <arg  type="i" name="attach_req_info" direction="in" />
+                       <arg  type="i" name="result" direction="out" />
+               </method>
+               <method name="SetInternalDataOn">
+                       <arg  type="b" name="onoff" direction="in" />
+                       <arg  type="b" name="result" direction="out" />
+               </method>
                <signal name="PropertyChanged">
                        <arg type="a{ss}" name="modem_property" direction="out" />
                </signal>
diff --git a/interface/src/ps_context_interface.c b/interface/src/ps_context_interface.c
new file mode 100644 (file)
index 0000000..469747b
--- /dev/null
@@ -0,0 +1,825 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@samsung.com>
+ *             Arun Shukla <arun.shukla@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_common.h"
+#include "ps_context.h"
+#include "ps_service.h"
+#include "ps_master.h"
+#include "ps_modem.h"
+#include "ps_log.h"
+#include "ps_context_interface.h"
+#include "generated-code.h"
+
+#include <tcore.h>
+#include <plugin.h>
+#include <server.h>
+#include <storage.h>
+#include <core_object.h>
+#include <co_ps.h>
+#include <co_context.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <iniparser.h>
+
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+static gboolean _ps_context_set_user_data(ps_context_t *context, gpointer user_data)
+{
+       g_return_val_if_fail(context != NULL, FALSE);
+       context->user_data = user_data;
+       return TRUE;
+}
+
+static GVariant *__ps_context_get_profile_properties(ps_context_t *context, GVariantBuilder *properties)
+{
+       gchar *s_authtype = NULL, *s_role = NULL, *s_type = NULL, *s_roam_pdp_type = NULL;
+       CoreObject *co_context;
+       char *apn, *username, *password, *proxy_addr, *home_url, *profile_name;
+
+       g_return_val_if_fail(context != NULL, NULL);
+       g_return_val_if_fail(properties != NULL, NULL);
+
+       //ps_dbg_ex_ctx(context, "get profile properties, path(%s)", _ps_context_ref_path(context));
+
+       co_context = _ps_context_ref_co_context(context);
+       s_authtype = g_strdup_printf("%d", tcore_context_get_auth(co_context));
+       s_role = g_strdup_printf("%d", tcore_context_get_role(co_context));
+       s_type = g_strdup_printf("%d", tcore_context_get_type(co_context));
+       s_roam_pdp_type = g_strdup_printf("%d", tcore_context_get_roam_pdp_type(co_context));
+
+       apn = tcore_context_get_apn(co_context);
+       username = tcore_context_get_username(co_context);
+       password = tcore_context_get_password(co_context);
+       proxy_addr = tcore_context_get_proxy(co_context);
+       home_url = tcore_context_get_mmsurl(co_context);
+       profile_name = tcore_context_get_profile_name(co_context);
+       g_variant_builder_init(properties, G_VARIANT_TYPE("a{ss}"));
+
+       g_variant_builder_add(properties, "{ss}", "path", context->path);
+       if (apn)
+               g_variant_builder_add(properties, "{ss}", "apn", apn);
+
+       if (s_authtype)
+               g_variant_builder_add(properties, "{ss}", "auth_type", s_authtype);
+
+       if (username)
+               g_variant_builder_add(properties, "{ss}", "auth_id", username);
+
+       if (password)
+               g_variant_builder_add(properties, "{ss}", "auth_pwd", password);
+
+       if (s_type)
+               g_variant_builder_add(properties, "{ss}", "pdp_protocol", s_type);
+
+       if (s_roam_pdp_type)
+               g_variant_builder_add(properties, "{ss}", "roam_pdp_protocol", s_roam_pdp_type);
+
+       if (proxy_addr)
+               g_variant_builder_add(properties, "{ss}", "proxy_addr", proxy_addr);
+
+       if (home_url)
+               g_variant_builder_add(properties, "{ss}", "home_url", home_url);
+
+       if (s_role)
+               g_variant_builder_add(properties, "{ss}", "svc_ctg_id", s_role);
+
+       g_variant_builder_add(properties, "{ss}", "profile_name", profile_name);
+       g_variant_builder_add(properties, "{ss}", "hidden", BOOL2STRING(context->hidden));
+       g_variant_builder_add(properties, "{ss}", "editable", BOOL2STRING(context->editable));
+       g_variant_builder_add(properties, "{ss}", "default_internet_conn", BOOL2STRING(context->is_default));
+       g_variant_builder_add(properties, "{ss}", "profile_enable", BOOL2STRING(context->profile_enable));
+
+       /* Freeing locally allocated memory */
+       g_free(s_authtype);
+       g_free(s_role);
+       g_free(s_type);
+       g_free(s_roam_pdp_type);
+       g_free(apn);
+       g_free(username);
+       g_free(password);
+       g_free(proxy_addr);
+       g_free(home_url);
+       g_free(profile_name);
+
+       //ps_dbg_ex_ctx(context, "Exiting");
+
+       return g_variant_builder_end(properties);
+}
+
+static gboolean __ps_context_update_profile(ps_context_t *context, GHashTable *property)
+{
+       CoreObject *co_context = _ps_context_ref_co_context(context);
+       GHashTableIter iter;
+       gpointer key, value;
+
+       g_return_val_if_fail(co_context != NULL, 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);
+                       info("APN (%s)", value);
+               } else if (g_str_equal(key, "profile_name") == TRUE) {
+                       tcore_context_set_profile_name(co_context, (const char *)value);
+               } else if (g_str_equal(key, "auth_type") == TRUE) {
+                       int i_tmp = 0;
+                       if (value) {
+                               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, "pdp_protocol") == TRUE) {
+                       int i_tmp = 0;
+                       if (value) {
+                               i_tmp = atoi((const char *)value);
+                               tcore_context_set_type(co_context, i_tmp);
+                               info("pdp type (%d)", i_tmp);
+                       }
+               } else if (g_str_equal(key, "roam_pdp_protocol") == TRUE) {
+                       int i_tmp = 0;
+                       if (value) {
+                               i_tmp = atoi((const char *)value);
+                               tcore_context_set_roam_pdp_type(co_context, i_tmp);
+                               info("Roam pdp type (%d)", i_tmp);
+                       }
+               } 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);
+               } else if (g_str_equal(key, "svc_ctg_id") == TRUE) {
+                       tcore_context_set_role(co_context, atoi((const char *)value));
+               } else if (g_str_equal(key, "profile_enable") == TRUE) {
+                       if (value) {
+                               gboolean tmp = TRUE;
+                               if (g_str_equal(value, "FALSE") == TRUE)
+                                       tmp = FALSE;
+                               _ps_context_set_profile_enable(context, tmp);
+                       }
+               }
+       }
+
+       return __ps_context_update_database(context);
+}
+
+static gboolean on_context_get_properties(PacketServiceContext *obj_context,
+                                         GDBusMethodInvocation *invocation,
+                                         gpointer user_data)
+{
+       GVariant *gv = NULL;
+       GVariantBuilder property;
+       ps_context_t *context = user_data;
+
+       ps_info_ex_ctx(context, "Entered");
+       gv = _ps_context_get_properties(context, &property);
+       packet_service_context_complete_get_properties(obj_context, invocation, gv);
+       return TRUE;
+}
+
+static gboolean on_context_get_profile(PacketServiceContext *obj_context,
+                                      GDBusMethodInvocation *invocation,
+                                      gpointer user_data)
+{
+       GVariant *gv = NULL;
+       GVariantBuilder profile;
+       ps_context_t *context = user_data;
+
+       ps_info_ex_ctx(context, "Entered");
+       gv = __ps_context_get_profile_properties(context, &profile);
+       packet_service_context_complete_get_profile(obj_context, invocation, gv);
+
+       return TRUE;
+}
+
+static gboolean on_context_handle_activate(PacketServiceContext *obj_context,
+                                          GDBusMethodInvocation *invocation,
+                                          gpointer user_data)
+{
+       gboolean rv = FALSE;
+       TReturn result = TCORE_RETURN_FAILURE;
+
+       gchar *apn = NULL;
+       int context_state = 0;
+       unsigned int max_pdn = 0, num_of_active_cids = 0;
+       unsigned char cid_def = 0;
+       GSList *active_cids = NULL;
+
+       ps_service_t *service = NULL;
+       ps_context_t *context = user_data;
+       ps_context_t *c_def_context = NULL;
+
+       CoreObject *co_ps;
+       CoreObject *co_context;
+       CoreObject *c_def_co_context;
+
+       if (!context) {
+               err("activation request object is NULL");
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
+               return TRUE;
+       }
+
+       service = _ps_context_ref_service(context);
+       if (!service) {
+               err("service object is null");
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
+               return TRUE;
+       }
+
+       co_context = _ps_context_ref_co_context(context);
+       co_ps = _ps_service_ref_co_ps(service);
+       if (!co_ps) {
+               ps_err_ex_ctx(context, "core object is null");
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
+               return TRUE;
+       }
+
+       ps_info_ex_ctx(context, "activate context(%s)", _ps_context_ref_path(context));
+
+       context_state = tcore_context_get_state(co_context);
+       if (context_state != CONTEXT_STATE_DEACTIVATED) {
+               ps_warn_ex_ctx(context, "operation is in progress");
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               return TRUE;
+       }
+
+       apn = tcore_context_get_apn(co_context);
+       ps_info_ex_ctx(context, "requested context(%p) co_context(%p) apn (%s)", context, co_context, apn);
+       /* check apn is activated or not */
+       rv = tcore_ps_is_active_apn(co_ps, apn);
+       g_free(apn);
+       if (rv) {
+               ps_info_ex_ctx(context, "requested apn is already activated");
+
+               result = _ps_connection_hdlr(context);
+               if (result != TCORE_RETURN_SUCCESS) {
+                       FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+                       return TRUE;
+               }
+
+               packet_service_context_complete_activate(obj_context, invocation, context->path);
+               context_state = tcore_context_get_state(co_context);
+               if (context_state == CONTEXT_STATE_ACTIVATED) {
+                       ps_info_ex_ctx(context, "context is already connected");
+                       _ps_context_set_connected(context, TRUE);
+               }
+
+               ps_dbg_ex_ctx(context, "success to open connection request");
+               return TRUE;
+       }
+
+       active_cids = tcore_ps_get_active_cids(co_ps);
+       num_of_active_cids = g_slist_length(active_cids);
+       max_pdn = tcore_ps_get_num_of_pdn(co_ps);
+       ps_info_ex_ctx(context, "activate cids(%d), max pdn(%d)", num_of_active_cids, max_pdn);
+       if (num_of_active_cids < max_pdn) {
+               ps_dbg_ex_ctx(context, "enough to active another pdn");
+
+               result = _ps_connection_hdlr(context);
+               if (result != TCORE_RETURN_SUCCESS) {
+                       FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+                       return TRUE;
+               }
+
+               ps_dbg_ex_ctx(context, "success to open connection request");
+               packet_service_context_complete_activate(obj_context, invocation, context->path);
+               return TRUE;
+       }
+
+       /* find the current default connection */
+       c_def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
+       if (!c_def_context) {
+               ps_err_ex_ctx(context, "default context is NULL");
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
+               return TRUE;
+       }
+
+       c_def_co_context = _ps_context_ref_co_context(c_def_context);
+       cid_def = tcore_context_get_id(c_def_co_context);
+       if (cid_def == 0) {
+               ps_err_ex_ctx(context, "it is not avaiable to open connection");
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
+               return TRUE;
+       }
+
+       /* check the status of def context */
+       context_state = tcore_context_get_state(c_def_co_context);
+       if (context_state != CONTEXT_STATE_ACTIVATED) {
+               enum co_context_role context_role;
+               context_role = tcore_context_get_role(c_def_co_context);
+               ps_err_ex_ctx(context, "default connection is in progress, new context_state[%d], role[%d]", context_state, context_role);
+               if (context_state == CONTEXT_STATE_ACTIVATING &&
+                   (context_role == CONTEXT_ROLE_MMS || context_role == CONTEXT_ROLE_PREPAID_MMS)) {
+                       _ps_context_set_user_data(c_def_context, context);
+                       packet_service_context_complete_activate(obj_context, invocation, context->path);
+                       return TRUE;
+               }
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
+               return TRUE;
+       }
+
+       _ps_service_reset_connection_timer(c_def_context);
+       _ps_context_set_user_data(c_def_context, context);
+       result = tcore_ps_deactivate_cid(co_ps, cid_def);
+       if (result != TCORE_RETURN_SUCCESS) {
+               ps_err_ex_ctx(context, "fail to deactivate exist network connection");
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
+               return TRUE;
+       }
+
+       packet_service_context_complete_activate(obj_context, invocation, context->path);
+       return TRUE;
+
+}
+
+static gboolean on_context_handle_deactiavte(PacketServiceContext *obj_context,
+                                            GDBusMethodInvocation *invocation,
+                                            gpointer user_data)
+{
+       int rv;
+       CoreObject *co_context;
+       int context_state = 0;
+       ps_context_t *context = user_data;
+       ps_service_t *service = _ps_context_ref_service(context);
+
+       if (!context) {
+               err("deactivation request object is NULL");
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
+               return TRUE;
+       }
+
+       co_context = _ps_context_ref_co_context(context);
+
+       context_state = tcore_context_get_state(co_context);
+       ps_info_ex_ctx(context, "requested context(%p) co_context(%p), context_state %d", context, co_context, context_state);
+       if (context_state != CONTEXT_STATE_ACTIVATED) {
+               ps_err_ex_ctx(context, "operation is in progress");
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               return TRUE;
+       }
+
+       ps_info_ex_ctx(context, "deactivate context(%s)", _ps_context_ref_path(context));
+
+       /*
+        * In this case, any request is not coming that alwayson flag to be FALSE
+        * from "SetAlwayson" method. So, need to be set FALSE internally.
+        * Otherwise, ps-plugin calls activation request continuously
+        * although other connection is activated(i.g. wifi).
+        */
+       _ps_context_set_alwayson_enable(context, FALSE);
+       _ps_service_reset_connection_timer(context);
+       rv = _ps_service_deactivate_context(service, context);
+       if (rv != TCORE_RETURN_SUCCESS) {
+               ps_err_ex_ctx(context, "fail to deactivate context connection");
+               FAIL_RESPONSE(invocation, PS_ERR_TRASPORT);
+               return TRUE;
+       }
+
+       ps_dbg_ex_ctx(context, "success to deactivate context");
+       packet_service_context_complete_deactivate(obj_context, invocation, context->path);
+
+       context_state = tcore_context_get_state(co_context);
+       if (context_state == CONTEXT_STATE_DEACTIVATED) {
+               ps_info_ex_ctx(context, "context is already disconnected");
+               context->ps_defined = FALSE;
+               _ps_context_set_connected(context, FALSE);
+       }
+
+       return TRUE;
+}
+
+static gboolean on_context_set_default_connection(PacketServiceContext *obj_context,
+                                                 GDBusMethodInvocation *invocation,
+                                                 gpointer user_data)
+{
+       int rv = 0;
+       int role = CONTEXT_ROLE_UNKNOWN;
+       gboolean is_default = FALSE;
+
+       ps_service_t *service = NULL;
+       ps_service_t *c_def_service = NULL;
+       ps_context_t *context = user_data;
+       ps_context_t *c_def_context = NULL;
+       CoreObject *co_ps = NULL;
+       CoreObject *co_context = NULL;
+       CoreObject *c_def_co_context = NULL;
+
+       if (!context) {
+               err("activation request object is NULL");
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
+               return TRUE;
+       }
+
+       service = _ps_context_ref_service(context);
+       if (!service) {
+               err("service object is null");
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
+               return TRUE;
+       }
+
+       co_context = _ps_context_ref_co_context(context);
+       ps_info_ex_ctx(context, "start default connection");
+       role = tcore_context_get_role(co_context);
+       is_default = tcore_context_get_default_profile(co_context);
+
+       if (is_default) {
+               ps_err_ex_ctx(context, "already default profile for role (%d).", role);
+               goto OUT;
+       }
+
+       c_def_context = _ps_service_return_default_context(service, role);
+       ps_info_ex_ctx(context, "current default connection (%p)", c_def_context);
+       if (!c_def_context) {
+               ps_err_ex_ctx(context, "No current default connection.");
+               goto OUT;
+       }
+
+       c_def_service = _ps_context_ref_service(c_def_context);
+       c_def_co_context = _ps_context_ref_co_context(c_def_context);
+
+       /* First, send deactivation request first. */
+       rv = _ps_service_deactivate_context(c_def_service, c_def_context);
+       if (rv == TCORE_RETURN_PS_ACTIVATING) {
+               ps_err_ex_ctx(context, "fail to deactivate default connection, rv(%d)", rv);
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               return TRUE;
+       }
+
+       /* Normal deactivation case. */
+       if (tcore_context_get_state(c_def_co_context) == CONTEXT_STATE_DEACTIVATING) {
+               ps_dbg_ex_ctx(context, "deactivation request in current ps (%p)", c_def_context);
+               _ps_context_set_user_data(c_def_context, context);
+       } else {
+               int cid = -1;
+
+               ps_dbg_ex_ctx(context, "[Not normal] deactivation request in current ps (%p)", c_def_context);
+
+               cid = tcore_context_get_id(c_def_co_context);
+               _ps_context_set_ps_defined(c_def_context, FALSE);
+               co_ps = _ps_service_ref_co_ps(service);
+               tcore_ps_set_cid_active(co_ps, cid, FALSE);
+               tcore_ps_clear_context_id(co_ps, c_def_co_context);
+       }
+
+       /* unset default info of previous connection */
+       _ps_context_set_alwayson_enable(c_def_context, FALSE);
+       _ps_context_set_default_connection_enable(c_def_context, FALSE);
+       tcore_context_set_default_profile(c_def_co_context, FALSE);
+
+       /* db update - release default connection */
+       ps_dbg_ex_ctx(context, "context(%p): release default connection property.", c_def_context);
+       _ps_context_update_default_internet_to_db(c_def_context, FALSE);
+       /* Allow Connman to update profile information. */
+       _ps_context_emit_property_changed_signal(c_def_context);
+
+       ps_info_ex_ctx(context, "activation requeset in new ps (%p)", context);
+ OUT:
+       _ps_default_connection_hdlr(context);
+       /* Update Attach APN required. */
+       _ps_context_update_attach_apn(service->contexts, context->mccmnc);
+       packet_service_context_complete_set_default_connection(obj_context, invocation, TRUE);
+       return TRUE;
+
+}
+
+static gboolean on_context_modify_profile(PacketServiceContext *obj_context,
+                                         GDBusMethodInvocation *invocation,
+                                         GVariant *property,
+                                         gpointer user_data)
+{
+       GVariantIter g_iter;
+       gchar *g_value;
+       gchar *g_key;
+
+       gboolean rv = FALSE;
+       int context_state = 0;
+       ps_context_t *context = user_data;
+       ps_service_t *service = _ps_context_ref_service(context);
+       GHashTable *profile_property = NULL;
+
+       ps_info_ex_ctx(context, "modify context's profile properties");
+
+       /*Creating the profile property hash for for internal handling*/
+       /*Create a hash table for the profile property as all fucntion already use ghash table */
+       profile_property = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+       g_variant_iter_init(&g_iter, property);
+       while (g_variant_iter_next(&g_iter, "{ss}", &g_key, &g_value)) {
+
+               g_hash_table_insert(profile_property, g_strdup(g_key), g_strdup(g_value));
+               /* must free data for ourselves */
+               g_free(g_value);
+               g_free(g_key);
+       }
+
+       rv = __ps_context_update_profile(context, profile_property);
+       if (rv != TRUE) {
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               g_hash_table_destroy(profile_property);
+               return TRUE;
+       }
+
+       context_state = tcore_context_get_state(_ps_context_ref_co_context(context));
+       if (context_state == CONTEXT_STATE_ACTIVATING) {
+               ps_info_ex_ctx(context, "Modify profile in activating state, set deactivate flag.");
+               context->deact_required = TRUE;
+               goto EXIT;
+       }
+
+       _ps_service_deactivate_context(service, context);
+       if (context_state == CONTEXT_STATE_DEACTIVATED) {
+               ps_dbg_ex_ctx(context, "context is already disconnected");
+               _ps_context_set_connected(context, FALSE);
+       }
+ EXIT:
+       packet_service_context_complete_modify_profile(obj_context, invocation, TRUE);
+       g_hash_table_destroy(profile_property);
+       return TRUE;
+}
+
+static gboolean on_context_remove_profile(PacketServiceContext *obj_context,
+                                         GDBusMethodInvocation *invocation, gpointer user_data)
+{
+       ps_context_t *context = user_data;
+       ps_service_t *service = _ps_context_ref_service(context);
+       ps_modem_t *modem = _ps_service_ref_modem(service);
+       CoreObject *co_context = _ps_context_ref_co_context(context);
+       gboolean attach_apn = tcore_context_get_attach_apn(co_context);
+       int context_state = 0;
+
+       if (!service || !modem) {
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               return TRUE;
+       }
+
+       context_state = tcore_context_get_state(context->co_context);
+       ps_info_ex_ctx(context, "context_state: %d", context_state);
+
+       /* PLM P160712-04390 fix - Remove profile only if context is in DEACTIVATED state
+         * 1. If context is in DEACTIVATED state, remove profile and send response
+         * 2. If context is in ACTIVATING state, set deact_required flag to TRUE and send deactivation request on activation notification.
+         *     Remove profile on deactivation notification and send response
+         * 3. If context is in ACTIVATED or DEACTIVATING state, send deactivation request.
+         *     Remove profile on deactivation notification and send response
+         */
+       if (context_state == CONTEXT_STATE_DEACTIVATED) {
+               ps_dbg_ex_ctx(context, "context is already disconnected");
+               _ps_context_remove_database(context);
+               _ps_service_unref_context(service, context);
+               service->contexts = g_slist_remove(service->contexts, context);
+               _ps_context_remove_context(context);
+               context = NULL;
+
+               /* Update Attach APN required. */
+               if (attach_apn)
+                       _ps_context_update_attach_apn(service->contexts, modem->operator);
+
+               packet_service_context_complete_remove_profile(obj_context, invocation, TRUE);
+               goto EXIT;
+       } else if (context_state == CONTEXT_STATE_ACTIVATING) {
+               ps_info_ex_ctx(context, "Remove profile in activating state, set remove_profile_required flag.");
+               context->deact_required = TRUE;
+       } else {
+               _ps_service_deactivate_context(context->p_service, context);
+               ps_info_ex_ctx(context, "Remove profile in deactivating/activated state, set remove_profile_required flag.");
+       }
+       context->remove_profile_required = TRUE;
+       context->remove_profile_cb_data = g_malloc0(sizeof(ps_remove_profile_data));
+       context->remove_profile_cb_data->obj_context = obj_context;
+       context->remove_profile_cb_data->invocation = invocation;
+       context->remove_profile_cb_data->user_data = user_data;
+
+ EXIT:
+       ps_dbg_ex_ctx(context, "Exit");
+       return TRUE;
+}
+
+
+gboolean _ps_context_handling_nas_timer(ps_context_t *context, gboolean value)
+{
+       GError *error = NULL;
+       GDBusConnection *connection = NULL;
+       GVariant *reply;
+       GVariant *params = NULL;
+       gboolean result = FALSE;
+       gint errorcode = -1;
+       char *dev_name = NULL;
+
+       dev_name = tcore_context_get_ipv4_devname(_ps_context_ref_co_context(context));
+       ps_dbg_ex_ctx(context, "dev_name(%s)", dev_name);
+
+       params = g_variant_new("(sb)", dev_name, value);
+
+       connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (!connection) {
+               ps_err_ex_ctx(context, "Failed to get system bus %s", error->message);
+               g_error_free(error);
+               return FALSE;
+       }
+
+#define NETCONFIG_SERVICE            "net.netconfig"
+#define NETCONFIG_NETWORK_PATH      "/net/netconfig/network"
+#define NETCONFIG_NETWORK_INTERFACE NETCONFIG_SERVICE ".network"
+#define DBUS_REPLY_TIMEOUT          (120 * 1000)
+
+       reply = g_dbus_connection_call_sync(connection,
+                                           NETCONFIG_SERVICE,
+                                           NETCONFIG_NETWORK_PATH,
+                                           NETCONFIG_NETWORK_INTERFACE,
+                                           "DropPackets",
+                                           params,
+                                           NULL,
+                                           G_DBUS_CALL_FLAGS_NONE,
+                                           DBUS_REPLY_TIMEOUT,
+                                           NULL,
+                                           &error);
+
+       if (!reply) {
+               if (error) {
+                       ps_err_ex_ctx(context,
+                                     "g_dbus_connection_call_sync() failed"
+                                     "error [%d: %s]", error->code, error->message);
+                       g_error_free(error);
+               } else {
+                       ps_err_ex_ctx(context,
+                                     "g_dbus_connection_call_sync() failed");
+               }
+               return FALSE;
+       }
+
+       g_variant_get(reply, "(bi)", &result, &errorcode);
+       ps_dbg_ex_ctx(context, "result(%d), error(%d)", result, errorcode);
+
+       return TRUE;
+}
+
+void ps_context_emit_property_changed_signal(ps_context_t *context)
+{
+       GVariant *gv = NULL;
+       GVariantBuilder property;
+
+       gv = _ps_context_get_properties(context, &property);
+       ps_dbg_ex_ctx(context, "emit : [PropertyChanged] context(%p)", context);
+       packet_service_context_emit_property_changed(context->if_obj, gv);
+}
+
+void ps_context_emit_dedicated_bearer_info_signal(ps_context_t *context)
+{
+       GVariant *gv = NULL;
+       CoreObject *co_context = NULL;
+       struct dedicated_bearer_info bearer_info;
+       GVariantBuilder properties;
+       guint i = 0;
+       char *num_dedicated_bearer, *primary_context_id;
+       char *secondary_context_id, *qci, *gbr_dl, *gbr_ul, *max_br_dl, *max_br_ul;
+
+       g_return_if_fail(context != NULL);
+
+       co_context = _ps_context_ref_co_context(context);
+       tcore_context_get_bearer_info(co_context, &bearer_info);
+
+       if (bearer_info.num_dedicated_bearer == 0) {
+               ps_warn_ex_ctx(context, "No dedicated bearer information");
+               return;
+       }
+
+       g_variant_builder_init(&properties, G_VARIANT_TYPE("a{ss}"));
+
+       primary_context_id = INT2STRING(tcore_context_get_id(co_context));
+       g_variant_builder_add(&properties, "{ss}", "primary_context_id", primary_context_id);
+       g_free(primary_context_id);
+
+       num_dedicated_bearer = CHAR2STRING(bearer_info.num_dedicated_bearer);
+       g_variant_builder_add(&properties, "{ss}", "num_dedicated_bearer", num_dedicated_bearer);
+       g_free(num_dedicated_bearer);
+
+       secondary_context_id = INT2STRING(bearer_info.secondary_context_id);
+       g_variant_builder_add(&properties, "{ss}", "secondary_context_id", secondary_context_id);
+       g_free(secondary_context_id);
+
+       for (i = 0; i < bearer_info.num_dedicated_bearer; i++) {
+               char *buf;
+               buf = g_strdup_printf("%s_%d", "qci", i);
+               qci = CHAR2STRING(bearer_info.qos[i].qci);
+               g_variant_builder_add(&properties, "{ss}", buf, qci);
+               g_free(buf);
+               g_free(qci);
+
+               buf = g_strdup_printf("%s_%d", "gbr_dl", i);
+               gbr_dl = INT2STRING(bearer_info.qos[i].gbr_dl);
+               g_variant_builder_add(&properties, "{ss}", buf, gbr_dl);
+               g_free(buf);
+               g_free(gbr_dl);
+
+               buf = g_strdup_printf("%s_%d", "gbr_ul", i);
+               gbr_ul = INT2STRING(bearer_info.qos[i].gbr_ul);
+               g_variant_builder_add(&properties, "{ss}", buf, gbr_ul);
+               g_free(buf);
+               g_free(gbr_ul);
+
+               buf = g_strdup_printf("%s_%d", "max_br_dl", i);
+               max_br_dl = INT2STRING(bearer_info.qos[i].max_br_dl);
+               g_variant_builder_add(&properties, "{ss}", buf, max_br_dl);
+               g_free(buf);
+               g_free(max_br_dl);
+
+               buf = g_strdup_printf("%s_%d", "max_br_ul", i);
+               max_br_ul = INT2STRING(bearer_info.qos[i].max_br_ul);
+               g_variant_builder_add(&properties, "{ss}", buf, max_br_ul);
+               g_free(buf);
+               g_free(max_br_ul);
+       }
+       gv = g_variant_builder_end(&properties);
+
+       packet_service_context_emit_dedicated_bearer_info(context->if_obj, gv);
+       ps_warn_ex_ctx(context, "context (%p) emit the dedicated bearer infomation signal", context);
+}
+
+void ps_service_complete_remove_profile(ps_context_t *context, gboolean enabled)
+{
+       ps_dbg_ex_ctx(context, "emit : [ProfileRemoved]");
+       packet_service_context_complete_remove_profile(context->remove_profile_cb_data->obj_context, context->remove_profile_cb_data->invocation, enabled);
+}
+
+gboolean ps_context_setup_interface(ps_context_t *context_data)
+{
+       PacketServiceContext* context;
+       GError *error = NULL;
+
+       ps_dbg_ex_ctx(context_data, "creating the skeleton object for context");
+       context = packet_service_context_skeleton_new();
+       if (NULL == context)
+               return FALSE;
+       context_data->if_obj = (gpointer)context;
+       info("Entered");
+
+       g_signal_connect(context,
+                        "handle-get-properties",
+                        G_CALLBACK(on_context_get_properties),
+                        context_data);
+
+       g_signal_connect(context,
+                        "handle-get-profile",
+                        G_CALLBACK(on_context_get_profile),
+                        context_data);
+
+       g_signal_connect(context,
+                        "handle-activate",
+                        G_CALLBACK(on_context_handle_activate),
+                        context_data);
+
+       g_signal_connect(context,
+                        "handle-deactivate",
+                        G_CALLBACK(on_context_handle_deactiavte),
+                        context_data);
+
+       g_signal_connect(context,
+                        "handle-set-default-connection",
+                        G_CALLBACK(on_context_set_default_connection),
+                        context_data);
+
+       g_signal_connect(context,
+                        "handle-modify-profile",
+                        G_CALLBACK(on_context_modify_profile),
+                        context_data);
+
+       g_signal_connect(context,
+                        "handle-remove-profile",
+                        G_CALLBACK(on_context_remove_profile),
+                        context_data);
+
+       ps_dbg_ex_ctx(context_data, "exporting the interface object to the dbus connection for context");
+
+       /*exporting the interface object to the path mention for context*/
+       if (TRUE != g_dbus_interface_skeleton_export((G_DBUS_INTERFACE_SKELETON(context)), context_data->conn, context_data->path, &error)) {
+               ps_err_ex_ctx(context_data, "Failed to export interaface with message [%s] & ID[%d] ", error->message, error->code);
+               return FALSE;
+       }
+       ps_info_ex_ctx(context_data, "Successfully new object created for the interface for path [%s]", context_data->path);
+
+       return TRUE;
+}
diff --git a/interface/src/ps_master_interface.c b/interface/src/ps_master_interface.c
new file mode 100644 (file)
index 0000000..719aa3d
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@samsung.com>
+ *         Arun Shukla <arun.shukla@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <unistd.h>
+
+#include "ps_common.h"
+#include "generated-code.h"
+#include "ps_master_interface.h"
+#include "ps_modem.h"
+#include "ps_master.h"
+
+#include <server.h>
+#include <plugin.h>
+#include <storage.h>
+#include <hal.h>
+#include <user_request.h>
+#include <co_context.h>
+
+
+static gboolean on_master_get_modems(PacketServiceMaster *obj_master,
+                                    GDBusMethodInvocation *invocation,
+                                    gpointer user_data)
+{
+       GVariantBuilder b_modem;
+       GVariant *modems;
+       GHashTableIter iter;
+       gpointer key, value;
+       ps_master_t *master = user_data;
+
+       if (master->modems == NULL) {
+               err("No modem Present");
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               return TRUE;
+       }
+
+       g_variant_builder_init(&b_modem, G_VARIANT_TYPE("a{sa{ss}}"));
+       g_hash_table_iter_init(&iter, master->modems);
+
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               gchar *path = _ps_modem_ref_path(value);
+               dbg("modem path [%s]", path);
+
+               g_variant_builder_open(&b_modem, G_VARIANT_TYPE("{sa{ss}}"));
+               g_variant_builder_add(&b_modem, "s", path);
+               if (FALSE == _ps_modem_get_properties_handler(value, &b_modem)) {
+                       err("Unable to get the modem properties");
+                       g_variant_builder_close(&b_modem);
+                       FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+                       return TRUE;
+               }
+               g_variant_builder_close(&b_modem);
+       }
+       modems = g_variant_builder_end(&b_modem);
+
+       packet_service_master_complete_get_modems(obj_master, invocation, modems);
+       return TRUE;
+}
+
+static gboolean on_master_set_alwayson(PacketServiceMaster *obj_master,
+                                      GDBusMethodInvocation *invocation,
+                                      gboolean enable,
+                                      gpointer user_data)
+{
+       gboolean result;
+       ps_master_t *master = user_data;
+
+       info("enable : [%d]", enable);
+       result = _ps_master_set_always_on_control(master, enable);
+       if (result)
+               packet_service_master_complete_set_alwayson(obj_master, invocation, result);
+       else
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+
+       return TRUE;
+}
+
+void ps_master_emit_modem_added_signal(ps_master_t *master, ps_modem_t *modem)
+{
+       GVariant *gv = NULL;
+       GVariantBuilder properties;
+
+       gv = _ps_modem_get_properties(modem, &properties);
+       dbg("emit : [ModemAdded]");
+       packet_service_master_emit_modem_added(master->if_obj, gv);
+}
+
+gboolean ps_master_setup_interface(ps_master_t *master_data)
+{
+       PacketServiceMaster *master;
+       GError *error = NULL;
+
+       dbg("master object create");
+       master = packet_service_master_skeleton_new();
+       if (NULL == master)
+               return FALSE;
+       master_data->if_obj = (gpointer)master;
+       dbg("Entered");
+
+       g_signal_connect(master,
+                        "handle-get-modems",
+                        G_CALLBACK(on_master_get_modems),
+                        master_data);
+
+       g_signal_connect(master,
+                        "handle-set-alwayson",
+                        G_CALLBACK(on_master_set_alwayson),
+                        master_data);
+       /*exporting the interface object to the path mention for master*/
+       if (TRUE != g_dbus_interface_skeleton_export((G_DBUS_INTERFACE_SKELETON(master)), master_data->conn, PS_MASTER_PATH, &error)) {
+               err("Failed to export interaface with message [%s] & ID[%d] ", error->message, error->code);
+               return FALSE;
+       }
+
+       return TRUE;
+}
diff --git a/interface/src/ps_modem_interface.c b/interface/src/ps_modem_interface.c
new file mode 100644 (file)
index 0000000..e95565f
--- /dev/null
@@ -0,0 +1,614 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@samsung.com>
+ *         Arun Shukla <arun.shukla@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_common.h"
+#include "generated-code.h"
+#include "ps_modem_interface.h"
+#include "ps_log.h"
+#include "ps_context.h"
+#include "ps_tcore_interface.h"
+#include "ps_service.h"
+#include "ps_modem.h"
+
+#include <server.h>
+#include <plugin.h>
+#include <user_request.h>
+#include <core_object.h>
+#include <co_context.h>
+#include <co_ps.h>
+
+struct ps_thread_data {
+       ps_modem_t *modem;
+       GThread *selfi;
+};
+
+static gboolean __ps_modem_set_reset_profile(ps_modem_t *modem, gboolean value)
+{
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       if (modem->reset_profile != value) {
+               modem->reset_profile = value;
+               ps_info_ex_modem(modem, "modem(%p) reset_profile(%d)", modem, modem->reset_profile);
+       }
+
+       return TRUE;
+}
+
+static gboolean __ps_modem_thread_finish_cb(gpointer data)
+{
+       struct ps_thread_data *thread_data = data;
+       ps_modem_t *modem;
+       GHashTableIter iter;
+       gpointer key, value;
+
+       if (!thread_data) {
+               err("thread_data is NULL !!");
+               return FALSE;
+       }
+
+       modem = thread_data->modem;
+
+       ps_dbg_ex_modem(modem, "Thread %p return is complete", thread_data->selfi);
+
+       _ps_get_co_modem_values(thread_data->modem);
+       __ps_modem_set_reset_profile(thread_data->modem, FALSE);
+       packet_service_modem_complete_reset_profile(thread_data->modem->if_obj, thread_data->modem->invocation, TRUE);
+
+       g_thread_join(thread_data->selfi);
+       ps_info_ex_modem(modem, "Clean up of thread %p is complete", thread_data->selfi);
+       thread_data->modem->invocation = NULL;
+       _ps_modem_remove_profile_reset_gsource(thread_data->modem);
+       thread_data->modem = NULL;
+       thread_data->selfi = NULL;
+       g_free(thread_data);
+
+       /* Try to re-connect default contexts after reset profile is complete */
+       g_hash_table_iter_init(&iter, modem->services);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE)
+               _ps_service_connect_default_context(value);
+
+       return FALSE;
+}
+
+static gpointer __ps_modem_regenerate_database(gpointer data)
+{
+       gboolean rv = FALSE;
+       ps_modem_t *modem = data;
+       struct ps_thread_data *thread_data = NULL;
+
+       thread_data = g_try_malloc0(sizeof(*thread_data));
+       if (!thread_data) {
+               ps_err_ex_modem(modem, "memory alloc is fail !!!");
+               return NULL;
+       }
+       thread_data->modem = modem;
+       thread_data->selfi = g_thread_self();
+
+       _ps_context_reset_profile_table(modem->cp_name);
+       /* Re-generate global APN database */
+       if (g_str_has_suffix(modem->cp_name, "1"))
+               rv = ps_util_system_command("/usr/bin/sqlite3 /opt/dbspace/.dnet2.db < /usr/share/ps-plugin/dnet_db_init.sql");
+       else
+               rv = ps_util_system_command("/usr/bin/sqlite3 /opt/dbspace/.dnet.db < /usr/share/ps-plugin/dnet_db_init.sql");
+       ps_dbg_ex_modem(modem, "system command sent, rv(%d)", rv);
+       rv = _ps_context_fill_profile_table_from_ini_file(modem->cp_name);
+
+#ifdef TIZEN_SUPPORT_LTE
+       if (tfeature_is_supported(TFEATURE_DEVICE_WEARABLE)) {
+               if (tfeature_is_supported(TFEATURE_OPERATOR_SKT) || tfeature_is_supported(TFEATURE_OPERATOR_KT) || tfeature_is_supported(TFEATURE_OPERATOR_LGT)) {
+                       if (g_str_has_suffix(modem->cp_name, "1"))
+                               rv = ps_util_system_command("/usr/bin/sqlite3 /opt/dbspace/.dnet2.db < /usr/share/ps-plugin/dnet_db_init_addition.sql");
+                       else
+                               rv = ps_util_system_command("/usr/bin/sqlite3 /opt/dbspace/.dnet.db < /usr/share/ps-plugin/dnet_db_init_addition.sql");
+                       ps_dbg_ex_modem(modem, "system command sent for additional apn, rv(%d)", rv);
+               }
+       }
+#endif
+
+       if (TRUE == ps_util_thread_dispatch(g_main_context_default(), G_PRIORITY_LOW, (GSourceFunc)__ps_modem_thread_finish_cb, thread_data))
+               ps_info_ex_modem(modem, "Thread %p processing is complete", thread_data->selfi);
+
+       return NULL;
+}
+
+static gboolean on_modem_get_properties(PacketServiceModem *obj_modem,
+                                       GDBusMethodInvocation *invocation,
+                                       gpointer user_data)
+{
+       GVariant *gv = NULL;
+       GVariantBuilder properties;
+       ps_modem_t *modem = user_data;
+
+       ps_info_ex_modem(modem, "get modem properties");
+
+       gv = _ps_modem_get_properties(user_data, &properties);
+       packet_service_modem_complete_get_properties(obj_modem, invocation, gv);
+       return TRUE;
+}
+
+static gboolean on_modem_get_services(PacketServiceModem *obj_modem,
+                                     GDBusMethodInvocation *invocation,
+                                     gpointer user_data)
+{
+       GVariantBuilder b_service;
+       GVariant *services;
+
+       GHashTableIter iter;
+       gpointer key, value;
+       ps_modem_t *modem = user_data;
+
+       ps_info_ex_modem(modem, "modem get service interface");
+
+       if (!modem->services) {
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               return TRUE;
+       }
+
+       g_variant_builder_init(&b_service, G_VARIANT_TYPE("a{sa{ss}}"));
+       g_hash_table_iter_init(&iter, modem->services);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               ps_service_t *service = value;
+               gchar *path = _ps_service_ref_path(service);
+
+               ps_dbg_ex_modem(modem, "path added [%s]", path);
+               g_variant_builder_open(&b_service, G_VARIANT_TYPE("{sa{ss}}"));
+               g_variant_builder_add(&b_service, "s", path);
+               if (FALSE == _ps_service_get_properties_handler(service, &b_service)) {
+                       g_variant_builder_close(&b_service);
+                       FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+                       return TRUE;
+               }
+               g_variant_builder_close(&b_service);
+       }
+
+       services = g_variant_builder_end(&b_service);
+       packet_service_modem_complete_get_services(obj_modem, invocation, services);
+       return TRUE;
+}
+
+static gboolean on_modem_go_dormant_all(PacketServiceModem *obj_modem,
+                                       GDBusMethodInvocation *invocation,
+                                       gpointer user_data)
+{
+       int result = -1;
+       GHashTableIter iter;
+       gpointer key, value;
+       ps_modem_t *modem = user_data;
+
+       ps_info_ex_modem(modem, "modem go dormant all interface");
+
+       if (!modem->services) {
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               return TRUE;
+       }
+
+       g_hash_table_iter_init(&iter, modem->services);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               ps_service_t *service = value;
+               ps_dbg_ex_modem(modem, "service (%p), send dormant request, ", service);
+               result = tcore_ps_send_dormant_request(_ps_service_ref_co_ps(service), NULL);
+       }
+
+       packet_service_modem_complete_go_dormant_all(obj_modem, invocation, result);
+       return TRUE;
+}
+
+static gboolean on_modem_get_profile_list(PacketServiceModem *obj_modem,
+                                         GDBusMethodInvocation *invocation,
+                                         gpointer user_data)
+{
+       guint len = 0, index;
+       gchar **strv = NULL;
+       GSList *profiles = NULL;
+       GSList *profiles_temp = NULL;
+       ps_modem_t *modem = user_data;
+
+       ps_info_ex_modem(modem, "master get the profile list");
+
+       if (!modem->contexts) {
+               ps_err_ex_modem(modem, "no profiles");
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
+               return TRUE;
+       }
+
+       for (index = 0; index < g_slist_length(modem->contexts); index++) {
+               ps_context_t *context = g_slist_nth_data(modem->contexts, index);
+               gchar *s_path = _ps_context_ref_path(context);
+
+               ps_dbg_ex_modem(modem, "context(%p), path(%s)", context, s_path);
+               if (s_path)
+                       profiles = g_slist_append(profiles, g_strdup((const char *)s_path));
+       }
+
+       if (!profiles) {
+               ps_warn_ex_modem(modem, "no profiles");
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
+               return TRUE;
+       }
+
+       len = g_slist_length(profiles);
+       strv = g_new(gchar *, len + 1);
+
+       /*
+        * fix memory leak
+        *  - Shouldn't move profiles GSList position directly
+        */
+       profiles_temp = profiles;
+       index = 0;
+       while (profiles_temp) {
+               strv[index++] = g_strdup(profiles_temp->data);
+               profiles_temp = g_slist_next(profiles_temp);
+       }
+       strv[index] = NULL;
+       packet_service_modem_complete_get_profile_list(obj_modem,
+                                                      invocation, (const gchar *const *)strv);
+
+       g_strfreev(strv);
+       g_slist_free_full(profiles, g_free);
+       ps_dbg_ex_modem(modem, "Exiting");
+       return TRUE;
+}
+
+static gboolean on_modem_add_profile(PacketServiceModem *obj_modem,
+                                    GDBusMethodInvocation *invocation,
+                                    GVariant *property,
+                                    gpointer user_data)
+{
+       GVariantIter g_iter;
+       gchar *g_value;
+       gchar *g_key;
+
+       gboolean rv = FALSE;
+       gchar *operator = NULL;
+       ps_modem_t *modem = user_data;
+       GHashTable *profile_property = NULL;
+       gchar *isTesterAPN = NULL;
+       gchar *mccmnc = NULL;
+
+       ps_info_ex_modem(modem, "add profile request");
+
+       operator = _ps_modem_ref_operator(modem);
+
+       if (!operator) {
+               ps_warn_ex_modem(modem, "there is no active modem");
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               return TRUE;
+       }
+
+       /*Create a hash table for the profile property as all function already use ghash table */
+       profile_property = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+       g_variant_iter_init(&g_iter, property);
+       while (g_variant_iter_next(&g_iter, "{ss}", &g_key, &g_value)) {
+
+               ps_info_ex_modem(modem, " '%s' value '%s'", g_key, g_value);
+
+               if (g_strcmp0("set_tester_apn", g_key) == 0)
+                       isTesterAPN = g_strdup(g_value);
+               else if (g_strcmp0("mccmnc", g_key) == 0)
+                       mccmnc = g_strdup(g_value);
+
+               g_hash_table_insert(profile_property, g_strdup(g_key), g_strdup(g_value));
+               /* must free data for ourselves */
+               g_free(g_value);
+               g_free(g_key);
+       }
+       if (isTesterAPN) {
+               operator = mccmnc;
+               ps_info_ex_modem(modem, "Tester set APN with operator(%s)", operator);
+               g_free(isTesterAPN);
+       }
+
+       rv = _ps_context_add_context(modem, operator, profile_property);
+       if (rv != TRUE) {
+               ps_err_ex_modem(modem, "Failed to add the Profile");
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               g_hash_table_destroy(profile_property);
+               g_free(mccmnc);
+               return TRUE;
+       }
+
+       packet_service_modem_complete_add_profile(obj_modem, invocation, TRUE);
+
+       g_hash_table_destroy(profile_property);
+       g_free(mccmnc);
+       ps_dbg_ex_modem(modem, "Exiting");
+       return TRUE;
+}
+
+void ps_modem_emit_property_changed_signal(ps_modem_t *modem)
+{
+       GVariant *gv = NULL;
+       GVariantBuilder properties;
+
+       gv = _ps_modem_get_properties(modem, &properties);
+       ps_dbg_ex_modem(modem, "emit : [PropertyChanged]");
+       packet_service_modem_emit_property_changed(modem->if_obj, gv);
+}
+
+void ps_modem_emit_service_added_signal(ps_modem_t *modem, ps_service_t *service)
+{
+       GVariant *gv = NULL;
+       GVariantBuilder property;
+
+       gv = _ps_service_get_properties(service, &property);
+       ps_dbg_ex_modem(modem, "emit : [ServiceAdded]");
+       packet_service_modem_emit_service_added(modem->if_obj, gv);
+}
+
+gboolean _ps_modem_initiate_reset_profile(ps_modem_t *modem)
+{
+       GHashTableIter iter;
+       gpointer key, key_value;
+
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       ps_dbg_ex_modem(modem, "Reseting the hash table");
+       if (modem->powered != PS_MODEM_STATE_ONLINE) {
+               gint index = 0, count = 0;
+               ps_context_t *pscontext;
+
+               count = g_slist_length(modem->contexts);
+               /* Remove contexts directly as there is no service */
+               for (index = 0; index < count; ) {
+                       ps_service_t *service = NULL;
+                       pscontext = g_slist_nth_data(modem->contexts, index);
+                       ps_warn_ex_modem(modem, "Remove context(%p), count(%d), index(%d)", pscontext, count, index);
+
+                       service = _ps_context_ref_service(pscontext);
+                       if (service) {
+                               index = 0;
+                               count--;
+                               _ps_service_unref_context(service, pscontext);
+                               _ps_context_remove_context(pscontext);
+                       } else {
+                               index++;
+                               _ps_context_remove_context(pscontext);
+                       }
+               }
+               g_slist_free(modem->contexts);
+               modem->contexts = NULL;
+
+               g_hash_table_iter_init(&iter, modem->services);
+               while (g_hash_table_iter_next(&iter, &key, &key_value) == TRUE) {
+                       ps_service_t *service = key_value;
+                       ps_warn_ex_modem(modem, "Remove contexts on service(%p)", service);
+                       g_slist_free(service->contexts);
+                       service->contexts = NULL;
+               }
+       } else {
+               /* Remove contexts through only service. */
+               g_hash_table_iter_init(&iter, modem->services);
+               while (g_hash_table_iter_next(&iter, &key, &key_value) == TRUE) {
+                       ps_service_t *service = key_value;
+                       ps_warn_ex_modem(modem, "Remove contexts on service(%p)", service);
+                       _ps_service_remove_contexts(service);
+               }
+       }
+
+       if (modem->type == 0) {
+               GThread *thread;
+               gchar *name = g_strdup_printf("REGEN-DB-%s", modem->cp_name);
+
+               thread = g_thread_new(name, __ps_modem_regenerate_database, modem);
+               g_free(name);
+               if (G_UNLIKELY(!thread)) {
+                       ps_err_ex_modem(modem, "Thread is not created");
+                       FAIL_RESPONSE(modem->invocation, PS_ERR_INTERNAL);
+                       _ps_modem_remove_profile_reset_gsource(modem);
+               } else {
+                       ps_dbg_ex_modem(modem, "Thread(%p) is created", thread);
+               }
+
+               return FALSE;
+       }
+#ifdef TIZEN_SUPPORT_LTE
+       else {
+               /* reset profile by CSC*/
+               if (tfeature_is_supported(TFEATURE_DEVICE_WEARABLE)) {
+                       if (tfeature_is_supported(TFEATURE_OPERATOR_SKT) || tfeature_is_supported(TFEATURE_OPERATOR_KT) || tfeature_is_supported(TFEATURE_OPERATOR_LGT)) {
+                               gboolean rv = FALSE;
+                               if (g_str_has_suffix(modem->cp_name, "1"))
+                                       rv = ps_util_system_command("/usr/bin/sqlite3 /opt/dbspace/.dnet2.db < /usr/share/ps-plugin/dnet_db_init_addition.sql");
+                               else
+                                       rv = ps_util_system_command("/usr/bin/sqlite3 /opt/dbspace/.dnet.db < /usr/share/ps-plugin/dnet_db_init_addition.sql");
+                               ps_dbg_ex_modem(modem, "system command sent for additional apn, rv(%d)", rv);
+                       }
+               }
+       }
+#endif
+       /* Create contexts again. */
+       _ps_get_co_modem_values(modem);
+       __ps_modem_set_reset_profile(modem, FALSE);
+       packet_service_modem_complete_reset_profile(modem->if_obj, modem->invocation, TRUE);
+       modem->invocation = NULL;
+
+       _ps_modem_remove_profile_reset_gsource(modem);
+
+       /* Try to re-connect default contexts after reset profile is complete */
+       g_hash_table_iter_init(&iter, modem->services);
+       while (g_hash_table_iter_next(&iter, &key, &key_value) == TRUE) {
+               ps_service_t *service = key_value;
+               /* only available case */
+               _ps_service_connect_default_context(service);
+       }
+
+       ps_dbg_ex_modem(modem, "Exiting");
+       return FALSE;
+}
+
+static gboolean on_modem_reset_profile(PacketServiceModem *obj_modem,
+                                      GDBusMethodInvocation *invocation,
+                                      gint type,
+                                      gpointer user_data)
+{
+       gboolean contexts_active;
+       ps_modem_t *modem = user_data;
+       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
+       CoreObject *co_ps;
+       int state;
+
+       if (modem->services == NULL)
+               return TRUE;
+
+       ps_info_ex_modem(modem, "reset profile request type(%d)", type);
+
+       if (_ps_modem_get_reset_profile(modem) == TRUE) {
+               ps_err_ex_modem(modem, "Reset Profile is already in Progress");
+               packet_service_modem_complete_reset_profile(obj_modem, invocation, FALSE);
+               ps_dbg_ex_modem(modem, "Exiting");
+               return FALSE;
+       }
+
+       __ps_modem_set_reset_profile(modem, TRUE);
+
+       co_ps = tcore_plugin_ref_core_object(tcore_object_ref_plugin(co_modem), CORE_OBJECT_TYPE_PS);
+
+       modem->invocation = invocation;
+       modem->type = type;
+
+       contexts_active = tcore_ps_any_context_activating_activated(co_ps, &state);
+
+       if (contexts_active == TRUE) {
+               ps_info_ex_modem(modem, "Contexts are in [%d] state", state);
+               if (state == CONTEXT_STATE_ACTIVATED) {
+                       GHashTableIter iter;
+                       gpointer key, value;
+
+                       ps_dbg_ex_modem(modem, "Contexts are in Actived state. Sending Diconnect Notification to all connected contexts");
+
+                       g_hash_table_iter_init(&iter, modem->services);
+                       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+                               ps_service_t *service = value;
+                               _ps_service_disconnect_contexts(service);
+                       }
+               } else if (state == CONTEXT_STATE_ACTIVATING) {
+                       ps_dbg_ex_modem(modem, "Contexts are in Activating state. Wait for them to connect");
+               }
+       } else {
+               ps_info_ex_modem(modem, "No contexts are in activating or activated state. Profiles reset is being initiated");
+               _ps_modem_initiate_reset_profile(modem);
+       }
+
+       return TRUE;
+}
+
+static gboolean on_modem_set_attach(PacketServiceModem *obj_modem,
+                                   GDBusMethodInvocation *invocation, gint attach_req_info, gpointer user_data)
+{
+       int result = -1;
+
+       GHashTableIter iter;
+       gpointer key, value;
+       ps_modem_t *modem = user_data;
+
+       //attach_req_info = (0xff0000 & attach) |(0x00ff00 & reattach) | (0x0000ff & detachreason)
+       ps_info_ex_modem(modem, "attach req info (att:%d, reatt:%d, detachreason:%x)",
+                        (0xff0000 & attach_req_info) ? TRUE : FALSE,
+                        (0x00ff00 & attach_req_info) ? TRUE : FALSE, (0x0000ff & attach_req_info));
+
+       if (!modem->services) {
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               return TRUE;
+       }
+
+       g_hash_table_iter_init(&iter, modem->services);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               ps_service_t *service = value;
+               ps_dbg_ex_modem(modem, "service (%p), send set_attach request, ", service);
+               result = tcore_ps_set_attach_request(_ps_service_ref_co_ps(service), attach_req_info);
+       }
+
+       packet_service_modem_complete_set_attach(obj_modem, invocation, result);
+       return TRUE;
+}
+
+static gboolean on_modem_set_internal_data_on(PacketServiceModem *obj_modem,
+                                             GDBusMethodInvocation *invocation, gboolean onoff, gpointer user_data)
+{
+       ps_modem_t *modem = user_data;
+
+       ps_info_ex_modem(modem, "internal data on/off [%d] (without DB OP)", onoff);
+       _ps_modem_set_data_allowed(modem, onoff);
+
+       packet_service_modem_complete_set_internal_data_on(obj_modem, invocation, TRUE);
+       return TRUE;
+}
+
+gboolean ps_modem_setup_interface(ps_modem_t *modem_data)
+{
+       PacketServiceModem* modem;
+       GError *error = NULL;
+
+       modem = packet_service_modem_skeleton_new();
+       if (modem == NULL)
+               return FALSE;
+       modem_data->if_obj = (gpointer)modem;
+       ps_dbg_ex_modem(modem_data, "Entered");
+
+       g_signal_connect(modem,
+                        "handle-get-properties",
+                        G_CALLBACK(on_modem_get_properties),
+                        modem_data);
+
+       g_signal_connect(modem,
+                        "handle-get-services",
+                        G_CALLBACK(on_modem_get_services),
+                        modem_data);
+
+       g_signal_connect(modem,
+                        "handle-go-dormant-all",
+                        G_CALLBACK(on_modem_go_dormant_all),
+                        modem_data);
+
+       g_signal_connect(modem,
+                        "handle-get-profile-list",
+                        G_CALLBACK(on_modem_get_profile_list),
+                        modem_data);
+
+       g_signal_connect(modem,
+                        "handle-add-profile",
+                        G_CALLBACK(on_modem_add_profile),
+                        modem_data);
+
+       g_signal_connect(modem,
+                        "handle-reset-profile",
+                        G_CALLBACK(on_modem_reset_profile),
+                        modem_data);
+
+       g_signal_connect(modem,
+                        "handle-set-attach",
+                        G_CALLBACK(on_modem_set_attach),
+                        modem_data);
+
+       g_signal_connect(modem,
+                        "handle-set-internal-data-on",
+                        G_CALLBACK(on_modem_set_internal_data_on),
+                        modem_data);
+
+       /*exporting the interface object to the path mention for modem*/
+       if (TRUE != g_dbus_interface_skeleton_export((G_DBUS_INTERFACE_SKELETON(modem)), modem_data->conn, modem_data->path, &error)) {
+               ps_err_ex_modem(modem_data, "Failed to export interaface with message [%s] & ID[%d] ", error->message, error->code);
+               return FALSE;
+       }
+       return TRUE;
+
+}
diff --git a/interface/src/ps_service_interface.c b/interface/src/ps_service_interface.c
new file mode 100644 (file)
index 0000000..363ec35
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@samsung.com>
+ *         Arun Shukla <arun.shukla@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_common.h"
+#include "generated-code.h"
+#include "ps_service_interface.h"
+#include "ps_log.h"
+#include "ps_context.h"
+#include "ps_service.h"
+
+#include <core_object.h>
+#include <co_ps.h>
+#include <co_context.h>
+#include <co_network.h>
+#include <storage.h>
+
+static gboolean on_service_get_properties(PacketServiceService *obj_service,
+                                         GDBusMethodInvocation *invocation,
+                                         gpointer user_data)
+{
+       GVariant *gv = NULL;
+       GVariantBuilder property;
+       ps_service_t *service = user_data;
+
+       ps_info_ex_svc(service, "get service properties");
+       gv = _ps_service_get_properties(service, &property);
+       packet_service_service_complete_get_properties(obj_service, invocation, gv);
+       return TRUE;
+}
+
+static gboolean on_service_get_context(PacketServiceService *obj_service,
+                                      GDBusMethodInvocation *invocation,
+                                      gpointer user_data)
+{
+       GVariantBuilder b_context;
+       GVariant *contexts;
+       unsigned int index;
+       ps_service_t *service = user_data;
+
+       ps_info_ex_svc(service, "modem get contexts interface");
+
+       if (service->contexts == NULL) {
+               ps_err_ex_svc(service, "No context present for service");
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               return TRUE;
+       }
+
+       g_variant_builder_init(&b_context, G_VARIANT_TYPE("a{sa{ss}}"));
+       for (index = 0; index < g_slist_length(service->contexts); index++) {
+               ps_context_t *context = g_slist_nth_data(service->contexts, index);
+               gchar *path = _ps_context_ref_path(context);
+
+               g_variant_builder_open(&b_context, G_VARIANT_TYPE("{sa{ss}}"));
+               g_variant_builder_add(&b_context, "s", path);
+
+               if (FALSE == _ps_context_get_properties_handler(context, &b_context)) {
+                       ps_err_ex_svc(service, "Failed to get property");
+                       g_variant_builder_close(&b_context);
+                       FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+                       return TRUE;
+               }
+               g_variant_builder_close(&b_context);
+       }
+
+       contexts = g_variant_builder_end(&b_context);
+       packet_service_service_complete_get_contexts(obj_service, invocation, contexts);
+       return TRUE;
+}
+
+
+void ps_service_emit_property_changed_signal(ps_service_t *service)
+{
+       GVariant *gv = NULL;
+       GVariantBuilder property;
+
+       gv = _ps_service_get_properties(service, &property);
+       ps_dbg_ex_svc(service, "emit : [PropertyChanged]");
+       packet_service_service_emit_property_changed(service->if_obj, gv);
+}
+
+void ps_service_emit_context_added_signal(ps_service_t *service, ps_context_t *context)
+{
+       GVariant *gv = NULL;
+       GVariantBuilder property;
+
+       gv = _ps_context_get_properties(context, &property);
+       ps_dbg_ex_svc(service, "emit : [ContextAdded]");
+       packet_service_service_emit_context_added(service->if_obj, gv);
+}
+
+void ps_service_emit_context_removed_signal(ps_service_t *service, ps_context_t *context)
+{
+       ps_dbg_ex_svc(service, "emit : [ContextRemoved]");
+       packet_service_service_emit_context_removed(service->if_obj, context->path);
+}
+
+gboolean ps_service_setup_interface(ps_service_t *service_data)
+{
+       PacketServiceService *service;
+       GError *error = NULL;
+
+       service = packet_service_service_skeleton_new();
+       if (service == NULL)
+               return FALSE;
+       service_data->if_obj = (gpointer)service;
+       ps_info_ex_svc(service_data, "Entered");
+
+       g_signal_connect(service,
+                        "handle-get-properties",
+                        G_CALLBACK(on_service_get_properties),
+                        service_data);
+
+       g_signal_connect(service,
+                        "handle-get-contexts",
+                        G_CALLBACK(on_service_get_context),
+                        service_data);
+
+       ps_dbg_ex_svc(service_data, "Exiting");
+       /*exporting the interface object to the path mention for master*/
+       if (TRUE != g_dbus_interface_skeleton_export((G_DBUS_INTERFACE_SKELETON(service)), service_data->conn, service_data->path, &error)) {
+               ps_err_ex_svc(service_data, "Failed to export interaface with message [%s] & ID[%d] ", error->message, error->code);
+               return FALSE;
+       }
+
+       return TRUE;
+}
index c8ee778..1cb7640 100644 (file)
@@ -3,8 +3,8 @@
 %global __provides_exclude_from ^(.*\\.tv)$
 
 %define major 0
-%define minor 3
-%define patchlevel 39
+%define minor 4
+%define patchlevel 3
 
 Name:           tel-plugin-packetservice
 Version:        %{major}.%{minor}.%{patchlevel}
@@ -26,7 +26,8 @@ BuildRequires:  pkgconfig(iniparser)
 BuildRequires:  pkgconfig(tcore)
 BuildRequires:  pkgconfig(db-util)
 BuildRequires:  pkgconfig(vconf)
-BuildRequires:         pkgconfig(alarm-service)
+BuildRequires:  pkgconfig(alarm-service)
+BuildRequires:  pkgconfig(capi-system-device)
 BuildRequires:  pkgconfig(libtzplatform-config)
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
index a0debd3..47856e5 100644 (file)
@@ -1606,3 +1606,27 @@ INSERT INTO "pdp_profile" VALUES(1605,'KT Roaming Tethering','tethering.ktfwing.
 INSERT INTO "pdp_profile" VALUES(1606,'SKT Roaming','roaming.sktelecom.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1087,1,0,1,1,0,1,1);
 INSERT INTO "pdp_profile" VALUES(1607,'SKT Roaming MMS','roaming.sktelecom.com',0,NULL,NULL,2,2,'smart.nate.com:9093','http://omms.nate.com:9082/oma_mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1087,2,0,1,1,0,1,1);
 INSERT INTO "pdp_profile" VALUES(1608,'SKT Roaming Tethering','roaming.sktelecom.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1087,5,0,1,1,0,1,1);
+INSERT INTO "pdp_profile" VALUES(1609,'NtcHTTP','ntnet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1128,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1610,'Ntmms','ntmms',0,NULL,NULL,6,6,'192.80.7.133:8000','http://192.80.11.180',300,NULL,NULL,NULL,NULL,NULL,NULL,1128,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1611,'Ncellgprs','web',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,678,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1612,'NcellMMS','mms',0,NULL,NULL,6,6,'192.168.19.15:8080','http://192.168.19.15',300,NULL,NULL,NULL,NULL,NULL,NULL,678,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1613,'Dialog internet','dialogbb',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,783,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1614,'KIT MMS','dialogbb',0,NULL,NULL,6,6,'192.168.122.2:8080','http://mms.dialog.lk:3130/mmsc',300,NULL,NULL,NULL,NULL,NULL,NULL,783,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1615,'Mobitel','mobitel3g',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,785,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1616,'Mobitel-MMS','wapmms',0,NULL,NULL,6,6,'192.168.50.163:8080','http://192.168.50.165',300,NULL,NULL,NULL,NULL,NULL,NULL,785,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1617,'Etisalat WEB','web3g',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,784,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1618,'Etisalat MMS','mms',0,NULL,NULL,6,6,'192.168.104.4:9401','http://mms.etisalat.lk:8085',300,NULL,NULL,NULL,NULL,NULL,NULL,784,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1619,'Airtel Internet','AirtelLive',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,588,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1620,'Airtel MMS','AirtelLive',0,NULL,NULL,6,6,'10.200.184.86:8080','http://mmsc/',300,NULL,NULL,NULL,NULL,NULL,NULL,588,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1621,'Hutch Internet','htwap',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,589,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1622,'GP-INTERNET','gpinternet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,61,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1623,'GP MMS','gpmms',0,NULL,NULL,6,6,NULL,'http://mmsc.grameenphone.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,61,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1624,'Banglalink-WEB','blweb',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,60,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1625,'Banglalink MMS','blmms',0,NULL,NULL,6,6,'10.10.55.34:8799','http://mmsc1:10021/mmsc/01',300,NULL,NULL,NULL,NULL,NULL,NULL,60,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1626,'TT-INTERNET','wap',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,62,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1627,'TT-MMS','MMS',0,NULL,NULL,6,6,'10.5.4.40:8080','http://10.5.4.22:38090/was',300,NULL,NULL,NULL,NULL,NULL,NULL,62,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1628,'Robi-INTERNET','internet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1129,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1629,'Robi MMS','WAP',0,NULL,NULL,6,6,'10.16.18.77:9028','http://10.16.18.40:38090/was',300,NULL,NULL,NULL,NULL,NULL,NULL,1129,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1630,'Airtel-INTERNET','internet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,59,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1631,'Airtel MMS','mms',0,NULL,NULL,6,6,'10.6.0.2:8080','http://10.6.0.21/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,59,2,0,1,1,0,0,1);
+
index c0b3a45..4b0b806 100644 (file)
@@ -1,5 +1,5 @@
 PRAGMA journal_mode = PERSIST;
-                                      
+
 DROP TABLE IF EXISTS "fd_blacklist";
 CREATE TABLE fd_blacklist(
        plmn    INTEGER
@@ -28,7 +28,7 @@ CREATE TABLE max_pdp(
        network_info_id INTEGER UNIQUE,
        max_pdp_3g INTEGER
   );
-  
+
 DROP TABLE IF EXISTS "pdp_profile";
 CREATE TABLE pdp_profile(
        profile_id           INTEGER PRIMARY KEY,
@@ -75,8 +75,8 @@ INSERT INTO "svc_category" VALUES(7,'user defined');
 
 CREATE INDEX pdp_profile_ix_1 ON pdp_profile (network_info_id);
 
-INSERT INTO fast_dormancy VALUES(0,568,-1,5,-1,-1);
-INSERT INTO fast_dormancy VALUES(1,566,-1,10,-1,-1);
+INSERT INTO fast_dormancy VALUES(0,568,-1,5000,-1,-1);
+INSERT INTO fast_dormancy VALUES(1,566,-1,10000,-1,-1);
 
 INSERT INTO network_info VALUES(0,"CDMA_NETWORK","00000");
 INSERT INTO network_info VALUES(1,"R5","45001");
@@ -384,14 +384,14 @@ INSERT INTO network_info VALUES(302, "IND INDOSAT","51021");
 INSERT INTO network_info VALUES(303, "IND INDOSAT","51001");
 INSERT INTO network_info VALUES(304, "IND TELKOMSEL","51010");
 INSERT INTO network_info VALUES(305, "AXIS","51008");
-INSERT INTO network_info VALUES(306, "AIRCEL","40442");
-INSERT INTO network_info VALUES(307, "Aircel","405805");
-INSERT INTO network_info VALUES(308, "Aircel","405806");
-INSERT INTO network_info VALUES(309, "Aircel","405804");
-INSERT INTO network_info VALUES(310, "Aircel","405803");
-INSERT INTO network_info VALUES(311, "Aircel","405802");
-INSERT INTO network_info VALUES(312, "Aircel","405800");
-INSERT INTO network_info VALUES(313, "Aircel","405801");
+INSERT INTO network_info VALUES(306, "Aircel South","40442");
+INSERT INTO network_info VALUES(307, "Aircel North","405805");
+INSERT INTO network_info VALUES(308, "Aircel North","405806");
+INSERT INTO network_info VALUES(309, "Aircel North","405804");
+INSERT INTO network_info VALUES(310, "Aircel South","405803");
+INSERT INTO network_info VALUES(311, "Aircel North","405802");
+INSERT INTO network_info VALUES(312, "Aircel North","405800");
+INSERT INTO network_info VALUES(313, "Aircel South","405801");
 INSERT INTO network_info VALUES(314, "CellOne","40479");
 INSERT INTO network_info VALUES(315, "CellOne","40473");
 INSERT INTO network_info VALUES(316, "CellOne","40438");
@@ -441,7 +441,7 @@ INSERT INTO network_info VALUES(359, "IDEA","40404");
 INSERT INTO network_info VALUES(360, "IDEA","40407");
 INSERT INTO network_info VALUES(361, "IDEA","405799");
 INSERT INTO network_info VALUES(362, "IDEA","405845");
-INSERT INTO network_info VALUES(363, "IDEA","40444");
+INSERT INTO network_info VALUES(363, "IDEA KARNATAKA","40444");
 INSERT INTO network_info VALUES(364, "IDEA","405846");
 INSERT INTO network_info VALUES(365, "IDEA","40456");
 INSERT INTO network_info VALUES(366, "IDEA","40489");
@@ -456,33 +456,33 @@ INSERT INTO network_info VALUES(374, "IDEA","405852");
 INSERT INTO network_info VALUES(375, "IDEA","405853");
 INSERT INTO network_info VALUES(376, "IDEA","40412");
 INSERT INTO network_info VALUES(377, "IDEA","40422");
-INSERT INTO network_info VALUES(378, "IDEA","40414");
+INSERT INTO network_info VALUES(378, "IDEA PUNJAB","40414");
 INSERT INTO network_info VALUES(379, "IDEA","405849");
 INSERT INTO network_info VALUES(380, "IDEA","40478");
 INSERT INTO network_info VALUES(381, "IN-DOLPHIN","40468");
 INSERT INTO network_info VALUES(382, "IN-DOLPHIN","40469");
-INSERT INTO network_info VALUES(383, "Reliance","40436");
-INSERT INTO network_info VALUES(384, "Reliance","40418");
-INSERT INTO network_info VALUES(385, "Reliance","40409");
-INSERT INTO network_info VALUES(386, "Reliance","40452");
-INSERT INTO network_info VALUES(387, "Reliance","40450");
-INSERT INTO network_info VALUES(388, "Reliance","40467");
-INSERT INTO network_info VALUES(389, "Reliance","40485");
-INSERT INTO network_info VALUES(390, "Reliance","40483");
-INSERT INTO network_info VALUES(391, "Reliance","40509");
-INSERT INTO network_info VALUES(392, "Reliance","40513");
-INSERT INTO network_info VALUES(393, "Reliance","40507");
-INSERT INTO network_info VALUES(394, "Reliance","40515");
-INSERT INTO network_info VALUES(395, "Reliance","40511");
-INSERT INTO network_info VALUES(396, "Reliance","40505");
-INSERT INTO network_info VALUES(397, "Reliance","40520");
-INSERT INTO network_info VALUES(398, "Reliance","40518");
-INSERT INTO network_info VALUES(399, "Reliance","40519");
-INSERT INTO network_info VALUES(400, "Reliance","40501");
-INSERT INTO network_info VALUES(401, "Reliance","40521");
-INSERT INTO network_info VALUES(402, "Reliance","40506");
-INSERT INTO network_info VALUES(403, "Reliance","40510");
-INSERT INTO network_info VALUES(404, "Reliance","40522");
+INSERT INTO network_info VALUES(383, "Reliance Rtel","40436");
+INSERT INTO network_info VALUES(384, "Reliance Rtel","40418");
+INSERT INTO network_info VALUES(385, "Reliance Rtel","40409");
+INSERT INTO network_info VALUES(386, "Reliance Rtel","40452");
+INSERT INTO network_info VALUES(387, "Reliance Rtel","40450");
+INSERT INTO network_info VALUES(388, "Reliance Rtel","40467");
+INSERT INTO network_info VALUES(389, "Reliance Rtel","40485");
+INSERT INTO network_info VALUES(390, "Reliance Rtel","40483");
+INSERT INTO network_info VALUES(391, "Reliance RCOM","40509");
+INSERT INTO network_info VALUES(392, "Reliance RCOM","40513");
+INSERT INTO network_info VALUES(393, "Reliance RCOM","40507");
+INSERT INTO network_info VALUES(394, "Reliance RCOM","40515");
+INSERT INTO network_info VALUES(395, "Reliance RCOM","40511");
+INSERT INTO network_info VALUES(396, "Reliance RCOM","40505");
+INSERT INTO network_info VALUES(397, "Reliance RCOM","40520");
+INSERT INTO network_info VALUES(398, "Reliance RCOM","40518");
+INSERT INTO network_info VALUES(399, "Reliance RCOM","40519");
+INSERT INTO network_info VALUES(400, "Reliance RCOM","40501");
+INSERT INTO network_info VALUES(401, "Reliance RCOM","40521");
+INSERT INTO network_info VALUES(402, "Reliance RCOM","40506");
+INSERT INTO network_info VALUES(403, "Reliance RCOM","40510");
+INSERT INTO network_info VALUES(404, "Reliance RCOM","40522");
 INSERT INTO network_info VALUES(405, "IND-JIO","405859");
 INSERT INTO network_info VALUES(406, "IND-JIO","405860");
 INSERT INTO network_info VALUES(407, "IND-JIO","405861");
@@ -1118,49 +1118,49 @@ INSERT INTO "network_info" VALUES(1036,'PLMN_374129','374129');
 INSERT INTO "network_info" VALUES(1037,'PLMN_37413','37413');
 INSERT INTO "network_info" VALUES(1038,'PLMN_374130','374130');
 INSERT INTO "network_info" VALUES(1039,'PLMN_37635','37635');
-INSERT INTO "network_info" VALUES(1040,'PLMN_40417','40417');
+INSERT INTO "network_info" VALUES(1040,'Aircel East','40417');
 INSERT INTO "network_info" VALUES(1041,'PLMN_404206','404206');
 INSERT INTO "network_info" VALUES(1042,'PLMN_40421','40421');
-INSERT INTO "network_info" VALUES(1043,'PLMN_40425','40425');
-INSERT INTO "network_info" VALUES(1044,'PLMN_40428','40428');
-INSERT INTO "network_info" VALUES(1045,'PLMN_40429','40429');
+INSERT INTO "network_info" VALUES(1043,'Aircel East','40425');
+INSERT INTO "network_info" VALUES(1044,'Aircel East','40428');
+INSERT INTO "network_info" VALUES(1045,'Aircel East','40429');
 INSERT INTO "network_info" VALUES(1046,'PLMN_40430','40430');
-INSERT INTO "network_info" VALUES(1047,'PLMN_40433','40433');
-INSERT INTO "network_info" VALUES(1048,'PLMN_40435','40435');
-INSERT INTO "network_info" VALUES(1049,'PLMN_40437','40437');
-INSERT INTO "network_info" VALUES(1050,'PLMN_40441','40441');
-INSERT INTO "network_info" VALUES(1051,'PLMN_40491','40491');
-INSERT INTO "network_info" VALUES(1052,'PLMN_40503','40503');
-INSERT INTO "network_info" VALUES(1053,'PLMN_40504','40504');
-INSERT INTO "network_info" VALUES(1054,'PLMN_40508','40508');
-INSERT INTO "network_info" VALUES(1055,'PLMN_40512','40512');
-INSERT INTO "network_info" VALUES(1056,'PLMN_40514','40514');
-INSERT INTO "network_info" VALUES(1057,'PLMN_40517','40517');
-INSERT INTO "network_info" VALUES(1058,'PLMN_40523','40523');
+INSERT INTO "network_info" VALUES(1047,'Aircel East','40433');
+INSERT INTO "network_info" VALUES(1048,'Aircel North','40435');
+INSERT INTO "network_info" VALUES(1049,'Aircel North','40437');
+INSERT INTO "network_info" VALUES(1050,'Aircel South','40441');
+INSERT INTO "network_info" VALUES(1051,'Aircel East','40491');
+INSERT INTO "network_info" VALUES(1052,'Reliance RCOM','40503');
+INSERT INTO "network_info" VALUES(1053,'Reliance RCOM','40504');
+INSERT INTO "network_info" VALUES(1054,'Reliance RCOM','40508');
+INSERT INTO "network_info" VALUES(1055,'Reliance RCOM','40512');
+INSERT INTO "network_info" VALUES(1056,'Reliance RCOM','40514');
+INSERT INTO "network_info" VALUES(1057,'Reliance RCOM','40517');
+INSERT INTO "network_info" VALUES(1058,'Reliance RCOM','40523');
 INSERT INTO "network_info" VALUES(1059,'PLMN_405026','405026');
 INSERT INTO "network_info" VALUES(1060,'PLMN_405028','405028');
 INSERT INTO "network_info" VALUES(1061,'PLMN_405033','405033');
 INSERT INTO "network_info" VALUES(1062,'PLMN_405040','405040');
-INSERT INTO "network_info" VALUES(1063,'PLMN_405807','405807');
-INSERT INTO "network_info" VALUES(1064,'PLMN_405808','405808');
-INSERT INTO "network_info" VALUES(1065,'PLMN_405809','405809');
-INSERT INTO "network_info" VALUES(1066,'PLMN_405810','405810');
-INSERT INTO "network_info" VALUES(1067,'PLMN_405811','405811');
-INSERT INTO "network_info" VALUES(1068,'PLMN_405812','405812');
+INSERT INTO "network_info" VALUES(1063,'Aircel_North','405807');
+INSERT INTO "network_info" VALUES(1064,'Aircel_North','405808');
+INSERT INTO "network_info" VALUES(1065,'Aircel South','405809');
+INSERT INTO "network_info" VALUES(1066,'Aircel_North','405810');
+INSERT INTO "network_info" VALUES(1067,'Aircel_North','405811');
+INSERT INTO "network_info" VALUES(1068,'Aircel_North','405812');
 INSERT INTO "network_info" VALUES(1069,'PLMN_405826','405826');
-INSERT INTO "network_info" VALUES(1070,'PLMN_405847','405847');
-INSERT INTO "network_info" VALUES(1071,'PLMN_405851','405851');
+INSERT INTO "network_info" VALUES(1070,'IDEA','405847');
+INSERT INTO "network_info" VALUES(1071,'IDEA','405851');
 INSERT INTO "network_info" VALUES(1072,'PLMN_405881','405881');
 INSERT INTO "network_info" VALUES(1073,'PLMN_405882','405882');
 INSERT INTO "network_info" VALUES(1074,'PLMN_405883','405883');
 INSERT INTO "network_info" VALUES(1075,'PLMN_405884','405884');
 INSERT INTO "network_info" VALUES(1076,'PLMN_405885','405885');
 INSERT INTO "network_info" VALUES(1077,'PLMN_405886','405886');
-INSERT INTO "network_info" VALUES(1078,'PLMN_405908','405908');
-INSERT INTO "network_info" VALUES(1079,'PLMN_405909','405909');
-INSERT INTO "network_info" VALUES(1080,'PLMN_405910','405910');
-INSERT INTO "network_info" VALUES(1081,'PLMN_405911','405911');
-INSERT INTO "network_info" VALUES(1082,'PLMN_404891','404891');
+INSERT INTO "network_info" VALUES(1078,'IDEA','405908');
+INSERT INTO "network_info" VALUES(1079,'IDEA','405909');
+INSERT INTO "network_info" VALUES(1080,'IDEA','405910');
+INSERT INTO "network_info" VALUES(1081,'IDEA','405911');
+INSERT INTO "network_info" VALUES(1082,'IDEA','404891');
 INSERT INTO "network_info" VALUES(1083,'PLMN_404220','404220');
 INSERT INTO "network_info" VALUES(1084,'PLMN_405932','405932');
 INSERT INTO "network_info" VALUES(1085,'MTC Touch','41503');
@@ -1205,3 +1205,15 @@ INSERT INTO network_info VALUES(1123, "Telenor","41406");
 INSERT INTO network_info VALUES(1124, "Glo NG","62170");
 INSERT INTO network_info VALUES(1125, "Etisalat Nigeria","62190");
 INSERT INTO network_info VALUES(1126, "ASIACELL","41850");
+INSERT INTO network_info VALUES(1127, "KT","45028");
+INSERT INTO network_info VALUES(1128, "Nepal Telecom","42901");
+INSERT INTO network_info VALUES(1129, "Robi","47002");
+INSERT INTO network_info VALUES(1130, "GPS Test","262800");
+INSERT INTO network_info VALUES(1131, "Ericsson Test-SIM","311390");
+INSERT INTO network_info VALUES(1132, "Verizon","310004");
+INSERT INTO network_info VALUES(1133, "ALU Test-SIM","310028");
+INSERT INTO network_info VALUES(1134, "Verizon","311270");
+INSERT INTO network_info VALUES(1135, "Verizon","312770");
+INSERT INTO network_info VALUES(1136, "IMS_NETWORK","11111");
+INSERT INTO network_info VALUES(1137, "Verizon","246081");
+INSERT INTO network_info VALUES(1138, "Verizon","24681");
\ No newline at end of file
index b4b7e53..6fc1c23 100644 (file)
@@ -464,34 +464,34 @@ INSERT INTO "pdp_profile" VALUES(463,'Edge MMS Prepay','ppmms',0,NULL,NULL,2,2,'
 INSERT INTO "pdp_profile" VALUES(464,'PLAT-OTA-MMS','plateaumms',0,NULL,'mmsc',2,2,'208.254.124.11:8080','208.254.124.11:8514',300,NULL,NULL,NULL,NULL,NULL,NULL,889,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(465,'PLATWEB','plateauweb',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,889,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(466,'My Multi Media','mms.c1.ama',0,'cell1mms','cell1',2,2,NULL,'http://mms.iot1.com/amarillo/mms.php',300,NULL,NULL,NULL,NULL,NULL,NULL,1004,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(467,'T-Mobile US 160','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,925,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(468,'T-Mobile US 160','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,925,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(467,'T-Mobile US 160','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,925,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(468,'T-Mobile US 160','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,925,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(469,'DataConnect','isp.cingular',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,873,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(470,'Cingular MMS','wap.cingular',0,'WAP@CINGULARGPRS.COM','CINGULAR1',2,2,'66.209.11.32:8080','http://mmsc.cingular.com',300,NULL,NULL,NULL,NULL,NULL,NULL,873,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(471,'T-Mobile US 200','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,922,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(472,'T-Mobile US 200','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,922,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(473,'T-Mobile US 210','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,921,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(474,'T-Mobile US 210','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,921,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(475,'T-Mobile US 220','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,924,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(476,'T-Mobile US 220','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,924,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(477,'T-Mobile US 230','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,926,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(478,'T-Mobile US 230','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,926,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(479,'T-Mobile US 240','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,927,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(480,'T-Mobile US 240','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,927,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(481,'T-Mobile US 250','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,923,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(482,'T-Mobile US 250','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,923,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(483,'T-Mobile US','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,918,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(484,'T-Mobile US','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,918,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(485,'T-Mobile US 270','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,920,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(486,'T-Mobile US 270','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,920,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(487,'T-Mobile US 310','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,916,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(488,'T-Mobile US 310','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,916,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(471,'T-Mobile US 200','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,922,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(472,'T-Mobile US 200','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,922,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(473,'T-Mobile US 210','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,921,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(474,'T-Mobile US 210','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,921,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(475,'T-Mobile US 220','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,924,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(476,'T-Mobile US 220','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,924,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(477,'T-Mobile US 230','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,926,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(478,'T-Mobile US 230','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,926,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(479,'T-Mobile US 240','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,927,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(480,'T-Mobile US 240','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,927,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(481,'T-Mobile US 250','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,923,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(482,'T-Mobile US 250','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,923,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(483,'T-Mobile US','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,918,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(484,'T-Mobile US','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,918,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(485,'T-Mobile US 270','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,920,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(486,'T-Mobile US 270','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,920,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(487,'T-Mobile US 310','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,916,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(488,'T-Mobile US 310','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,916,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(489,'Cingular 380 ATT','proxy',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,872,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(490,'Cingular 380 ATT','proxy',0,NULL,NULL,2,2,NULL,'http://mmsc.cingular.com/',300,NULL,NULL,NULL,NULL,NULL,NULL,872,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(491,'AWS MMS','proxy',0,NULL,NULL,2,2,'10.250.250.55:8080','http://mmsc.mymmode.com',300,NULL,NULL,NULL,NULL,NULL,NULL,872,2,0,1,0,0,0,1);
 INSERT INTO "pdp_profile" VALUES(492,'Celloneet MMS','mms.celloneet.com',0,'user1@mms.celloneet.com','celloneet',2,2,'63.99.231.135:8080','http://mms.celloneet.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1005,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(493,'Cingular 410','wap.cingular',0,'WAP@CINGULARGPRS.COM','CINGULAR1',2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,875,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(494,'Cingular 410','wap.cingular',0,'WAP@CINGULARGPRS.COM','CINGULAR1',2,2,NULL,'http://mmsc.cingular.com/',300,NULL,NULL,NULL,NULL,NULL,NULL,875,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(493,'Nextgenphone','nxtgenphone',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,875,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(494,'Nextgenphone MMS','nxtgenphone',0,NULL,NULL,6,6,NULL,'http://mmsc.mobile.att.net',300,NULL,NULL,NULL,NULL,NULL,NULL,875,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(495,'CBW MMS','wap.gocbw.com',0,NULL,NULL,2,2,'216.68.79.202:80','http://mms.gocbw.com:8088/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,883,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(496,'DataConnect','isp.cingular',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,888,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(497,'MediaNet','wap.cingular',0,'WAP@CINGULARGPRS.COM','CINGULAR1',2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,888,1,0,1,0,0,0,1);
@@ -499,24 +499,24 @@ INSERT INTO "pdp_profile" VALUES(498,'MediaNet','wap.cingular',0,'WAP@CINGULARGP
 INSERT INTO "pdp_profile" VALUES(499,'DataConnect','isp.cingular',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1006,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(500,'MediaNet','wap.cingular',0,'WAP@CINGULARGPRS.COM','CINGULAR1',2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1006,1,0,1,0,0,0,1);
 INSERT INTO "pdp_profile" VALUES(501,'MediaNet','wap.cingular',0,'WAP@CINGULARGPRS.COM','CINGULAR1',2,2,'66.209.11.32:8080','http://mmsc.cingular.com',300,NULL,NULL,NULL,NULL,NULL,NULL,1006,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(502,'T-Mobile US 490','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,917,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(503,'T-Mobile US 490','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,917,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(502,'T-Mobile US 490','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,917,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(503,'T-Mobile US 490','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,917,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(504,'GoodCall Picture Message','good.call',0,NULL,NULL,2,2,'66.150.33.125:8080','http://mms.suncom.net:8088/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,917,2,0,1,0,0,0,1);
 INSERT INTO "pdp_profile" VALUES(505,'Suncom MMS','mms',0,NULL,NULL,2,2,'66.150.33.125:8080','http://mms.suncom.net:8088/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,917,2,0,1,0,0,0,1);
 INSERT INTO "pdp_profile" VALUES(506,'DobsonMMS','dobsoncellularwap',0,NULL,NULL,2,2,'172.23.1.252:8799','http://mmsc',300,NULL,NULL,NULL,NULL,NULL,NULL,1007,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(507,'ChinookMMS','wapgw.chinookwireless.net',0,NULL,NULL,2,2,'204.181.155.195:8080','http://mms.cellonenation.net/mms/',300,NULL,NULL,NULL,NULL,NULL,NULL,898,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(508,'T-Mobile US 580','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,919,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(509,'T-Mobile US 580','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,919,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(508,'T-Mobile US 580','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,919,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(509,'T-Mobile US 580','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,919,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(510,'CellularOne MMS','cellular1wap',0,NULL,NULL,2,2,'172.23.1.252:8799','http://mmsc',300,NULL,NULL,NULL,NULL,NULL,NULL,937,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(511,'EpicINT','internet.epictouch',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1008,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(512,'EpicMMS','mms.epictouch',0,NULL,NULL,2,2,'63.99.231.135:8080','http://mmsc.westlinkcom.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1008,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(513,'T-Mobile US 660','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,914,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(514,'T-Mobile US 660','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,914,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(513,'T-Mobile US 660','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,914,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(514,'T-Mobile US 660','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,914,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(515,'WEB 2','i2.iwireless.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,892,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(516,'Picture Messaging','wap1.iwireless.com',0,NULL,NULL,2,2,'209.4.229.31:9401','http://mmsc.iwireless.dataonair.net:6672',300,NULL,NULL,NULL,NULL,NULL,NULL,892,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(517,'PIAPicture Messaging','wap9.iwireless.com',0,NULL,NULL,2,2,'209.4.229.32:9401','http://mmsc.iwireless.dataonair.net:6672',300,NULL,NULL,NULL,NULL,NULL,NULL,892,2,0,1,0,0,0,1);
-INSERT INTO "pdp_profile" VALUES(518,'T-Mobile US 800','epc.tmobile.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,915,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(519,'T-Mobile US 800','epc.tmobile.com',0,NULL,NULL,2,2,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,915,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(518,'T-Mobile US 800','epc.tmobile.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,915,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(519,'T-Mobile US 800','epc.tmobile.com',0,NULL,NULL,6,6,NULL,'http://mms.msg.eng.t-mobile.com/mms/wapenc',300,NULL,NULL,NULL,NULL,NULL,NULL,915,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(520,'Internet','isp',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,928,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(521,'MMS','mms',0,NULL,NULL,2,2,'12.108.12.13:3128','http://mms.edgemobile.net/mmsc',300,NULL,NULL,NULL,NULL,NULL,NULL,928,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(522,'Edge MMS Prepay','ppmms',0,NULL,NULL,2,2,'12.108.12.13:3128','http://mms.edgemobile.net/mmsc',300,NULL,NULL,NULL,NULL,NULL,NULL,928,2,0,1,0,0,0,1);
@@ -1165,10 +1165,10 @@ INSERT INTO "pdp_profile" VALUES(1164,'SK Telecom','lte.sktelecom.com',0,NULL,NU
 INSERT INTO "pdp_profile" VALUES(1165,'SK Telecom','lte.sktelecom.com',0,NULL,NULL,6,6,'lteoma.nate.com:9093','http://omms.nate.com:9082/oma_mms',300,NULL,NULL,NULL,NULL,NULL,NULL,568,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1166,'SK Telecom','lte.sktelecom.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,568,5,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1167,'SK Telecom IMS','ims',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,568,0,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1168,'KT','lte.ktfwing.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,566,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1169,'KT','lte.ktfwing.com',0,NULL,NULL,2,2,NULL,'http://mmsc.ktfwing.com:9082',300,NULL,NULL,NULL,NULL,NULL,NULL,566,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1170,'LG U+','internet.lguplus.co.kr',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,567,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1171,'LG U+ MMS','ims.lguplus.co.kr',0,NULL,NULL,2,2,NULL,'http://omammsc.uplus.co.kr:9084',300,NULL,NULL,NULL,NULL,NULL,NULL,567,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1168,'KT','lte.ktfwing.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,566,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1169,'KT','lte.ktfwing.com',0,NULL,NULL,6,6,NULL,'http://mmsc.ktfwing.com:9082',300,NULL,NULL,NULL,NULL,NULL,NULL,566,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1170,'LG U+','internet.lguplus.co.kr',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,567,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1171,'LG U+ MMS','ims.lguplus.co.kr',0,NULL,NULL,6,6,NULL,'http://omammsc.uplus.co.kr:9084',300,NULL,NULL,NULL,NULL,NULL,NULL,567,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1172,'LG U+ Tethering','tethering.lguplus.co.kr',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,567,5,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1173,'LG U+ Roaming','wroaming.lguplus.co.kr',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,567,1,0,1,1,0,1,1);
 INSERT INTO "pdp_profile" VALUES(1174,'LG U+ Roaming','wroaming.lguplus.co.kr',0,NULL,NULL,6,6,NULL,'http://omammsc.uplus.co.kr:9084',300,NULL,NULL,NULL,NULL,NULL,NULL,567,2,0,1,1,0,1,1);
@@ -1590,76 +1590,190 @@ INSERT INTO "pdp_profile" VALUES(1589,'MMS GPRS UY','mms.ctimovil.com.uy',0,'cti
 INSERT INTO "pdp_profile" VALUES(1590,'Sprint','Sprint',0,'Sprint','*',2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,913,0,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1591,'Boost_Mobile','Boost_Mobile',0,'Boost_Mobile','*',2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1120,0,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1592,'Virgin Mobile','Virgin Mobile',0,'Virgin Mobile','*',2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1121,0,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1593,'GCF Lab.1','test',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,2,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1594,'GCF Lab.1 MMS','test',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,2,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1595,'GCF Lab.2','test',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,3,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1596,'GCF Lab.2 MMS','test',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,3,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1597,'TestBed 2','annam.dyn',0,'mms','mms',2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1122,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1598,'TestBed 2','annam.dyn',0,'mms','mms',2,2,'10.200.60.15:3128','http://10.200.60.21:8088/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1122,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1593,'GCF Lab.1','test',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,2,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1594,'GCF Lab.1 MMS','test',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,2,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1595,'GCF Lab.2','test',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,3,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1596,'GCF Lab.2 MMS','test',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,3,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1597,'TestBed 2','annam.dyn',0,'mms','mms',6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1122,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1598,'TestBed 2','annam.dyn',0,'mms','mms',6,6,'10.200.60.15:3128','http://10.200.60.21:8088/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1122,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1599,'TestBed 2 IMS','ims',0,NULL,NULL,5,5,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1122,0,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1600,'Default','cdma.only',1,NULL,NULL,1,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,0,1,1,0,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1601,'Default MMS','cdma.only',1,NULL,NULL,1,1,NULL,NULL,300,0,0,NULL,0,NULL,NULL,0,2,1,0,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1602,'SK Telecom Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,568,6,1,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1603,'KT IMS','ims.ktfwing.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,566,0,1,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1604,'KT Emergency',NULL,0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,566,6,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1603,'KT IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,566,0,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1604,'KT Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,566,6,1,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1605,'LG U+ Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,567,6,1,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1606,'LG U+ IMS','ims.lguplus.co.kr',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,567,0,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1606,'LG U+ IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,567,0,1,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1607,'GCF Lab.1 IMS','ims',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,2,0,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1608,'GCF Lab.2 IMS','ims',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,3,0,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1609,'GCF Lab.1 IMS Emergency','emergency',0,NULL,NULL,5,5,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,2,6,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1610,'GCF Lab.2 IMS Emergency','emergency',0,NULL,NULL,5,5,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,3,6,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1611,'KT Roaming','lte.ktfwing.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,566,1,0,1,1,0,1,1);
-INSERT INTO "pdp_profile" VALUES(1612,'KT Roaming MMS','lte.ktfwing.com',0,NULL,NULL,2,2,NULL,'http://mmsc.ktfwing.com:9082',300,NULL,NULL,NULL,NULL,NULL,NULL,566,2,0,1,1,0,1,1);
+INSERT INTO "pdp_profile" VALUES(1611,'KT Roaming','lte.ktfwing.com',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,566,1,0,1,1,0,1,1);
+INSERT INTO "pdp_profile" VALUES(1612,'KT Roaming MMS','lte.ktfwing.com',0,NULL,NULL,6,6,NULL,'http://mmsc.ktfwing.com:9082',300,NULL,NULL,NULL,NULL,NULL,NULL,566,2,0,1,1,0,1,1);
 INSERT INTO "pdp_profile" VALUES(1613,'KT Roaming Tethering','lte150.ktfwing.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,566,5,0,1,1,0,1,1);
 INSERT INTO "pdp_profile" VALUES(1614,'SKT Roaming','roaming.sktelecom.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,568,1,0,1,1,0,1,1);
-INSERT INTO "pdp_profile" VALUES(1615,'SKT Roaming MMS','roaming.sktelecom.com',0,NULL,NULL,2,2,'smart.nate.com:9093','http://omms.nate.com:9082/oma_mms',300,NULL,NULL,NULL,NULL,NULL,NULL,568,2,0,1,1,0,1,1);
+INSERT INTO "pdp_profile" VALUES(1615,'SKT Roaming MMS','roaming.sktelecom.com',0,NULL,NULL,2,2,'lteoma.nate.com:9093','http://omms.nate.com:9082/oma_mms',300,NULL,NULL,NULL,NULL,NULL,NULL,568,2,0,1,1,0,1,1);
 INSERT INTO "pdp_profile" VALUES(1616,'SKT Roaming Tethering','roaming.sktelecom.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,568,5,0,1,1,0,1,1);
 INSERT INTO "pdp_profile" VALUES(1617,'KT Tethering','tethering.ktfwing.com',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,566,5,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1618,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,405,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(1619,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,405,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1620,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,406,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1621,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,406,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1622,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,407,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1623,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,407,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1624,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,408,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1625,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,408,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1626,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,409,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1627,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,409,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1628,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,410,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1629,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,410,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1630,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,411,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1631,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,411,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1632,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,412,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1633,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,412,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1634,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,413,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1635,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,413,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1636,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,414,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1637,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,414,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1638,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,415,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1639,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,415,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1640,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,416,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1641,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,416,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1642,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,417,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1643,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,417,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1644,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,418,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1645,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,418,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1646,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,419,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1647,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,419,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1648,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,420,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1649,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,420,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1650,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,421,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1651,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,421,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1652,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,422,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1653,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,422,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1654,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,423,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1655,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,423,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1656,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,424,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1657,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,424,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1658,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,425,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1659,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,425,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1660,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,426,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1661,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,426,0,0,0,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1662,'KT DATA','lte.safetynet.or.kr',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1127,1,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1663,'KT IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1127,0,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1664,'KT MMS','IMS',0,NULL,NULL,2,2,NULL,'mmsc.safetynet.or.kr:9082',300,NULL,NULL,NULL,NULL,NULL,NULL,1127,2,0,1,1,0,0,1);
-INSERT INTO "pdp_profile" VALUES(1665,'KT roaming MMS','lte.safetynet.or.kr',0,NULL,NULL,2,2,NULL,'mmsc.safetynet.or.kr:9082',300,NULL,NULL,NULL,NULL,NULL,NULL,1127,2,0,1,1,0,1,1);
+INSERT INTO "pdp_profile" VALUES(1620,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,405,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1621,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,406,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1622,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,406,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1623,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,406,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1624,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,407,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1625,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,407,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1626,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,407,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1627,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,408,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1628,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,408,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1629,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,408,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1630,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,409,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1631,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,409,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1632,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,409,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1633,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,410,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1634,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,410,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1635,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,410,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1636,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,411,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1637,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,411,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1638,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,411,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1639,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,412,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1640,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,412,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1641,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,412,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1642,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,413,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1643,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,413,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1644,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,413,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1645,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,414,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1646,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,414,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1647,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,414,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1648,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,415,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1649,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,415,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1650,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,415,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1651,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,416,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1652,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,416,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1653,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,416,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1654,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,417,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1655,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,417,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1656,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,417,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1657,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,418,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1658,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,418,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1659,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,418,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1660,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,419,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1661,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,419,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1662,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,419,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1663,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,420,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1664,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,420,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1665,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,420,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1666,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,421,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1667,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,421,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1668,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,421,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1669,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,422,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1670,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,422,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1671,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,422,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1672,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,423,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1673,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,423,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1674,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,423,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1675,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,424,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1676,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,424,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1677,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,424,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1678,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,425,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1679,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,425,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1680,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,425,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1681,'Jio 4G','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,426,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1682,'IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,426,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1683,'Jio UT','jionet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,426,7,1,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1684,'KT DATA','lte.safetynet.or.kr',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1127,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1685,'KT IMS','IMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1127,0,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1686,'KT MMS','IMS',0,NULL,NULL,2,2,NULL,'mmsc.safetynet.or.kr:9082',300,NULL,NULL,NULL,NULL,NULL,NULL,1127,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1687,'KT roaming MMS','lte.safetynet.or.kr',0,NULL,NULL,2,2,NULL,'mmsc.safetynet.or.kr:9082',300,NULL,NULL,NULL,NULL,NULL,NULL,1127,2,0,1,1,0,1,1);
+INSERT INTO "pdp_profile" VALUES(1688,'Verizon IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,936,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1689,'Verizon Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,936,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1690,'Verizon CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,936,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1691,'VZW Test FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,936,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1692,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,936,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1693,'Verizon IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,937,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1694,'Verizon Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,937,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1695,'Verizon CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,937,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1696,'VZW Test FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,937,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1697,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,937,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1698,'Verizon IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,938,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1699,'Verizon Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,938,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1700,'Verizon CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,938,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1701,'VZW Test FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,938,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1702,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,938,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1703,'Verizon IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1137,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1704,'Verizon Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1137,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1705,'Verizon CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1137,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1706,'VZW Test FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1137,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1707,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1137,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1708,'Verizon IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1138,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1709,'Verizon Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1138,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1710,'Verizon CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1138,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1711,'VZW Test FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1138,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1712,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1138,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1713,'ATT IMS','ims',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,875,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1714,'SUPL TEST','t-camo-2g3g-01.erricson.se',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1130,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1715,'Ericsson Test-SIM Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1131,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1716,'Ericsson Test-SIM FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1131,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1717,'Ericsson Test-SIM IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1131,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1718,'Ericsson Test-SIM CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1131,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1719,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1131,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1720,'VZW Test Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1138,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1721,'VZW Test FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1138,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1722,'VZW Test IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1138,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1723,'VZW Test CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1138,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1724,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1138,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1725,'VZW Test Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1137,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1726,'VZW Test FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1137,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1727,'VZW Test IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1137,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1728,'VZW Test CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1137,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1729,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1137,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1730,'VZW Test Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1132,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1731,'VZW Test FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1132,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1732,'VZW Test IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1132,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1733,'VZW Test CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1132,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1734,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1132,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1735,'ALU Test-SIM Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1133,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1736,'ALU Test-SIM FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1133,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1737,'ALU Test-SIM IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1133,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1738,'ALU Test-SIM CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1133,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1739,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1133,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1740,'VZW Test Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1134,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1741,'VZW Test FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1134,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1742,'VZW Test IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1134,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1743,'VZW Test CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1134,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1744,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1134,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1745,'VZW Test Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1135,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1746,'VZW Test FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1135,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1747,'VZW Test IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1135,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1748,'VZW Test CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,1135,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1749,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1135,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1750,'VZW Roaming Internet','VZWINTERNET',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,673,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1751,'VZW Roaming FOTA','VZWADMIN',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,673,9,1,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1752,'VZW Roaming IMS','VZWIMS',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,673,0,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1753,'VZW Roaming CBS','VZWAPP',0,NULL,NULL,6,6,NULL,'http://mms.vtext.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,673,2,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1754,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,673,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1755,'LG U+ OTA','ota.lguplus.co.kr',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,567,8,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1756,'IMS Emergency',NULL,0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1136,6,0,0,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1757,'NtcHTTP','ntnet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1128,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1758,'Ntmms','ntmms',0,NULL,NULL,6,6,'192.80.7.133:8000','http://192.80.11.180',300,NULL,NULL,NULL,NULL,NULL,NULL,1128,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1759,'Ncellgprs','web',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,678,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1760,'NcellMMS','mms',0,NULL,NULL,6,6,'192.168.19.15:8080','http://192.168.19.15',300,NULL,NULL,NULL,NULL,NULL,NULL,678,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1761,'Dialog internet','dialogbb',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,783,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1762,'KIT MMS','dialogbb',0,NULL,NULL,6,6,'192.168.122.2:8080','http://mms.dialog.lk:3130/mmsc',300,NULL,NULL,NULL,NULL,NULL,NULL,783,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1763,'Mobitel','mobitel3g',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,785,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1764,'Mobitel-MMS','wapmms',0,NULL,NULL,6,6,'192.168.50.163:8080','http://192.168.50.165',300,NULL,NULL,NULL,NULL,NULL,NULL,785,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1765,'Etisalat WEB','web3g',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,784,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1766,'Etisalat MMS','mms',0,NULL,NULL,6,6,'192.168.104.4:9401','http://mms.etisalat.lk:8085',300,NULL,NULL,NULL,NULL,NULL,NULL,784,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1767,'Airtel Internet','AirtelLive',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,588,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1768,'Airtel MMS','AirtelLive',0,NULL,NULL,6,6,'10.200.184.86:8080','http://mmsc/',300,NULL,NULL,NULL,NULL,NULL,NULL,588,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1769,'Hutch Internet','htwap',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,589,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1770,'GP-INTERNET','gpinternet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,61,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1771,'GP MMS','gpmms',0,NULL,NULL,6,6,NULL,'http://mmsc.grameenphone.com/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,61,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1772,'Banglalink-WEB','blweb',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,60,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1773,'Banglalink MMS','blmms',0,NULL,NULL,6,6,'10.10.55.34:8799','http://mmsc1:10021/mmsc/01',300,NULL,NULL,NULL,NULL,NULL,NULL,60,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1774,'TT-INTERNET','wap',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,62,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1775,'TT-MMS','MMS',0,NULL,NULL,6,6,'10.5.4.40:8080','http://10.5.4.22:38090/was',300,NULL,NULL,NULL,NULL,NULL,NULL,62,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1776,'Robi-INTERNET','internet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,1129,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1777,'Robi MMS','WAP',0,NULL,NULL,6,6,'10.16.18.77:9028','http://10.16.18.40:38090/was',300,NULL,NULL,NULL,NULL,NULL,NULL,1129,2,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1778,'Airtel-INTERNET','internet',0,NULL,NULL,6,6,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,59,1,0,1,1,0,0,1);
+INSERT INTO "pdp_profile" VALUES(1779,'Airtel MMS','mms',0,NULL,NULL,6,6,'10.6.0.2:8080','http://10.6.0.21/servlets/mms',300,NULL,NULL,NULL,NULL,NULL,NULL,59,2,0,1,1,0,0,1);
index e896109..5944190 100644 (file)
  *
  */
 
-
 #include "ps_common.h"
-#include "generated-code.h"
+#include "ps_context.h"
+#include "ps_modem.h"
+#include "ps_service.h"
+#include "ps_master.h"
+#include "ps_context_interface.h"
+#include "ps_service_interface.h"
 
 #include <tzplatform_config.h>
 #include <tcore.h>
@@ -32,6 +36,9 @@
 #include <core_object.h>
 #include <co_ps.h>
 #include <co_context.h>
+#include <co_network.h>
+#include <user_request.h>
+#include <vconf.h>
 
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 
-#define MODULE_TAG "PS-CONTEXT"
+#include "ps_log.h"
 
-#define PROP_DEFAULT           FALSE
-#define PROP_DEFAULT_STR       NULL
 #define DATABASE_PATH_0                tzplatform_mkpath(TZ_SYS_DB, ".dnet.db")
 #define DATABASE_PATH_1                tzplatform_mkpath(TZ_SYS_DB, ".dnet2.db")
-#define DELAY_TO_SIGNAL_EMIT 1
-
-#define TIMEOUT_DEFAULT                5
-#define TIMEOUT_MAX                    1800
 
 typedef struct {
        const char *mccmnc;
@@ -63,43 +64,15 @@ typedef struct {
 } OperatorTable;
 
 #define FREE_AND_ASSIGN(ptr, value) do { \
-       if (ptr) \
-               g_free(ptr);\
-       ptr = g_strdup(value); \
+               if (ptr) \
+                       g_free(ptr); \
+               ptr = g_strdup(value); \
 } while (0)
 
 static Storage *strg_db;
 
-/*FIXME*/
-OperatorTable attach_apn_preference[] = {
-       {"45005", "", CONTEXT_TYPE_IPV4V6, CONTEXT_ROLE_IMS, "220.103.220.10", "2001:2d8:00e0:0220::10"},
-       {"45006", "", CONTEXT_TYPE_IPV4V6, CONTEXT_ROLE_IMS, "", ""},
-       {"45008", "", CONTEXT_TYPE_IPV4V6, CONTEXT_ROLE_IMS, "", ""},
-       {"45028", "", CONTEXT_TYPE_IPV4V6, CONTEXT_ROLE_IMS, "", ""},
-};
-
-static void __ps_context_emit_dedicated_bearer_info_signal(ps_context_t *context);
-static void __ps_context_emit_property_changed_signal(ps_context_t *context);
-static void _ps_context_setup_interface(PacketServiceContext *context, ps_context_t *context_data);
-
-static gboolean __ps_context_create_storage_handle(gpointer plugin);
-static gchar *__ps_context_create_path(char *profile_name, int profile_id, int svc_ctg_id, gchar *cp_name);
-static gboolean __ps_context_update_attach_apn(GSList *contexts, const gchar *mccmnc);
-static gboolean __ps_context_create_co_context(gpointer context, GHashTable *property, gchar *cp_name);
-static gboolean __ps_context_update_profile(ps_context_t *context, GHashTable *property);
-static gboolean __ps_context_update_database(ps_context_t *context);
-static gboolean __ps_context_update_default_internet_to_db(ps_context_t *context, gboolean enabled);
-static gboolean __ps_context_remove_database(ps_context_t *context);
-static int __ps_context_insert_network_id_to_database(gchar *mccmnc, gchar *cp_name);
-static int __ps_context_load_network_id_from_database(gchar *mccmnc, gchar *cp_name);
-static gchar *__ps_context_load_network_name_from_database(int network_id, gchar *cp_name);
-static int __ps_context_load_profile_id_from_database(gchar *cp_name);
-static int __ps_context_load_num_of_pdn_from_database(gchar *mccmnc, gchar *cp_name);
-static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int index, gchar *cp_name);
-static int __ps_context_insert_profile_to_database(GHashTable *property, int network_id, gchar *cp_name);
-static int __ps_context_get_network_id(gchar *mccmnc, gchar *cp_name);
-GVariant *__ps_context_get_profile_properties(gpointer context, GVariantBuilder *properties);
-static gboolean __ps_context_set_default_connection_enable(gpointer object, gboolean enabled);
+static gchar *  __ps_context_load_network_name_from_database(int network_id, gchar *cp_name);
+static int      __ps_context_load_profile_id_from_database(gchar *cp_name);
 
 void __remove_context_handler(gpointer data)
 {
@@ -112,148 +85,53 @@ void __remove_context_handler(gpointer data)
 
        /*Need to UNexport and Unref the master Object */
        g_object_unref(context->if_obj);
-
-       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context removed for the path [%s]", context->path);
+       ps_info_ex_ctx(context, "context removed for the path [%s]", context->path);
 
        g_free(context->path);
        g_free(context->mccmnc);
        g_free(context);
-
-       dbg("Exiting");
-       return;
-}
-
-static void __ps_context_emit_dedicated_bearer_info_signal(ps_context_t *context)
-{
-       GVariant *gv = NULL;
-       CoreObject *co_network = NULL, *co_context = NULL;
-       struct dedicated_bearer_info bearer_info;
-       GVariantBuilder properties;
-       guint i = 0;
-       char *num_dedicated_bearer, *primary_context_id;
-       char *secondary_context_id, *qci, *gbr_dl, *gbr_ul, *max_br_dl, *max_br_ul;
-
-       g_return_if_fail(context != NULL);
-
-       co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
-       co_context = _ps_context_ref_co_context(context);
-       tcore_context_get_bearer_info(co_context, &bearer_info);
-
-       if (bearer_info.num_dedicated_bearer == 0) {
-               ps_warn_ex_co(co_network, "No dedicated bearer information");
-               return;
-       }
-
-       g_variant_builder_init(&properties, G_VARIANT_TYPE("a{ss}"));
-
-       primary_context_id = INT2STRING(tcore_context_get_id(co_context));
-       g_variant_builder_add(&properties, "{ss}", "primary_context_id", primary_context_id);
-       g_free(primary_context_id);
-
-       num_dedicated_bearer = CHAR2STRING(bearer_info.num_dedicated_bearer);
-       g_variant_builder_add(&properties, "{ss}", "num_dedicated_bearer", num_dedicated_bearer);
-       g_free(num_dedicated_bearer);
-
-       secondary_context_id = INT2STRING(bearer_info.secondary_context_id);
-       g_variant_builder_add(&properties, "{ss}", "secondary_context_id", secondary_context_id);
-       g_free(secondary_context_id);
-
-       for (i = 0; i < bearer_info.num_dedicated_bearer ; i++) {
-               char *buf;
-               buf = g_strdup_printf("%s_%d", "qci", i);
-               qci = CHAR2STRING(bearer_info.qos[i].qci);
-               g_variant_builder_add(&properties, "{ss}", buf, qci);
-               g_free(buf);
-               g_free(qci);
-
-               buf = g_strdup_printf("%s_%d", "gbr_dl", i);
-               gbr_dl = INT2STRING(bearer_info.qos[i].gbr_dl);
-               g_variant_builder_add(&properties, "{ss}", buf, gbr_dl);
-               g_free(buf);
-               g_free(gbr_dl);
-
-               buf = g_strdup_printf("%s_%d", "gbr_ul", i);
-               gbr_ul = INT2STRING(bearer_info.qos[i].gbr_ul);
-               g_variant_builder_add(&properties, "{ss}", buf, gbr_ul);
-               g_free(buf);
-               g_free(gbr_ul);
-
-               buf = g_strdup_printf("%s_%d", "max_br_dl", i);
-               max_br_dl = INT2STRING(bearer_info.qos[i].max_br_dl);
-               g_variant_builder_add(&properties, "{ss}", buf, max_br_dl);
-               g_free(buf);
-               g_free(max_br_dl);
-
-               buf = g_strdup_printf("%s_%d", "max_br_ul", i);
-               max_br_ul = INT2STRING(bearer_info.qos[i].max_br_ul);
-               g_variant_builder_add(&properties, "{ss}", buf, max_br_ul);
-               g_free(buf);
-               g_free(max_br_ul);
-       }
-       gv = g_variant_builder_end(&properties);
-
-       packet_service_context_emit_dedicated_bearer_info(context->if_obj, gv);
-       ps_warn_ex_co(co_network, "context (%p) emit the dedicated bearer infomation signal", context);
-}
-
-void __ps_context_emit_property_changed_signal(ps_context_t *context)
-{
-       GVariant *gv = NULL;
-       GVariantBuilder property;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
-
-       ps_dbg_ex_co(co_network, "get context Properties");
-
-       gv = _ps_context_get_properties(context, &property);
-       packet_service_context_emit_property_changed(context->if_obj, gv);
-
-       ps_dbg_ex_co(co_network, "context (%p) emit the context property changed signal", context);
-       return;
 }
 
 /*     Funtion : _ps_context_remove_context
  *     Description : removes and unregister the interface for the context
  */
-gboolean _ps_context_remove_context(gpointer context)
+gboolean _ps_context_remove_context(ps_context_t *context)
 {
-       ps_context_t *pscontext = context;
-       ps_service_t *service = _ps_context_ref_service(pscontext);
+       ps_service_t *service;
+       CoreObject *co_context;
 
-       g_return_val_if_fail(pscontext != NULL, FALSE);
-       g_return_val_if_fail(pscontext->path != NULL, FALSE);
+       g_return_val_if_fail(context != NULL, FALSE);
+       g_return_val_if_fail(context->path != NULL, FALSE);
 
-       dbg("remove context (%s)", pscontext->path);
+       ps_dbg_ex_ctx(context, "remove context (%s)", context->path);
 
        /*Removing the context from the static list */
        _ps_service_reset_connection_timer(context);
        _ps_context_set_connected(context, FALSE);
 
        /* Unexport object */
-       g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(pscontext->if_obj));
+       g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(context->if_obj));
 
        /* remove context from the list (modem, service) */
-       if (service) {
-               tcore_ps_remove_context(service->co_ps,
-                       (CoreObject *)_ps_context_ref_co_context(context));
-       }
-       tcore_context_free(pscontext->co_context);
+       service = _ps_context_ref_service(context);
+       co_context = _ps_context_ref_co_context(context);
+       if (service)
+               tcore_ps_remove_context(_ps_service_ref_co_ps(service), co_context);
+
+       tcore_context_free(co_context);
 
        /* free allocated resources for context. */
-       g_free(pscontext->mccmnc);
-       g_free(pscontext->path);
-       g_free(pscontext);
+       g_free(context->mccmnc);
+       g_free(context->path);
+       g_free(context);
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Exiting");
        return TRUE;
 }
 
-static gboolean __ps_context_create_storage_handle(gpointer plugin)
+static gboolean __ps_context_create_storage_handle(TcorePlugin *plugin)
 {
-       TcorePlugin *p = plugin;
-
-       strg_db = tcore_server_find_storage(tcore_plugin_ref_server(p), "database");
+       strg_db = tcore_server_find_storage(tcore_plugin_ref_server(plugin), "database");
        dbg("Storage: (%p)", strg_db);
-
        return TRUE;
 }
 
@@ -291,27 +169,21 @@ static gchar *__ps_context_create_path(char *profile_name, int profile_id, int s
        return path;
 }
 
-static gboolean __ps_context_update_attach_apn(GSList *contexts, const gchar *mccmnc)
+gboolean _ps_context_update_attach_apn(GSList *contexts, const gchar *mccmnc)
 {
        gboolean ret = FALSE;
        unsigned int pos = 0;
        enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
        CoreObject *default_internet = NULL;
 
-#ifndef TIZEN_SUPPORT_VOLTE
-       warn("VoLTE is NOT supported, use default setting.");
+#ifdef TIZEN_SUPPORT_VOLTE
+       role = CONTEXT_ROLE_IMS;
+#else
        role = CONTEXT_ROLE_INTERNET;
-       goto UPDATE;
 #endif
+       warn("Set attach pdn to %d", role);
 
-       if (contexts == NULL || mccmnc == NULL)
-               return ret;
-
-       info("Internet profile by default.");
-       role = CONTEXT_ROLE_INTERNET;
-
-UPDATE:
-        for (pos = 0; pos < g_slist_length(contexts); pos++) {
+       for (pos = 0; pos < g_slist_length(contexts); pos++) {
                ps_context_t *context = g_slist_nth_data(contexts, pos);
                CoreObject *co_context = _ps_context_ref_co_context(context);
                int p_role = tcore_context_get_role(co_context);
@@ -334,7 +206,7 @@ UPDATE:
                        }
                        g_free(apn);
                }
-        }
+       }
 
        if (ret != TRUE && default_internet) {
                warn("Attach APN preference: role[%d] but there is no matched profile.", role);
@@ -344,11 +216,10 @@ UPDATE:
        return ret;
 }
 
-static gboolean __ps_context_create_co_context(gpointer object, GHashTable *property, gchar *cp_name)
+static gboolean __ps_context_create_co_context(ps_context_t *context, GHashTable *property, gchar *cp_name)
 {
        GHashTableIter iter;
        gpointer key, value;
-       ps_context_t *context = NULL;
        CoreObject *co_context = NULL;
 
        gchar *path = NULL;
@@ -361,112 +232,112 @@ static gboolean __ps_context_create_co_context(gpointer object, GHashTable *prop
        gboolean is_roaming_apn = FALSE, profile_enable = TRUE, attach_apn = FALSE;
        gboolean default_pdn = FALSE;
 
-       g_hash_table_iter_init(&iter, (GHashTable *) property);
+       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*/
                        if (value) {
-                               profile_id = atoi((const char *) value);
+                               profile_id = atoi((const char *)value);
                                info("profile id (%d)", profile_id);
                        }
                } else if (g_str_equal(key, "4") == TRUE) {
                        g_free(profile_name);
-                       profile_name = g_strdup((const char *) value);
+                       profile_name = g_strdup((const char *)value);
                        info("profile name (%s)", profile_name);
                } else if (g_str_equal(key, "5") == TRUE) {
                        g_free(apn);
-                       apn = g_strdup((const char *) value);
+                       apn = g_strdup((const char *)value);
                        info("APN (%s)", apn);
                } else if (g_str_equal(key, "6") == TRUE) {
                        if (value) {
-                               auth_type = atoi((const char *) value);
+                               auth_type = atoi((const char *)value);
                                info("auth type (%d)", auth_type);
                        }
                } else if (g_str_equal(key, "7") == TRUE) {
                        g_free(auth_id);
-                       auth_id = g_strdup((const char *) value);
+                       auth_id = g_strdup((const char *)value);
                        info("auth id (%s)", auth_id);
                } else if (g_str_equal(key, "8") == TRUE) {
                        g_free(auth_pwd);
-                       auth_pwd = g_strdup((const char *) value);
+                       auth_pwd = g_strdup((const char *)value);
                        info("auth pwd (%s)", auth_pwd);
                } else if (g_str_equal(key, "9") == TRUE) {
-                       if (!value || g_strcmp0((const gchar *) value, "") == 0) {
+                       if (!value || g_strcmp0((const gchar *)value, "") == 0) {
                                g_free(proxy_addr);
-                               proxy_addr = g_strdup((const char *) value);
+                               proxy_addr = g_strdup((const char *)value);
                        } else {
                                gboolean b_regex = FALSE;
-                               b_regex = g_regex_match_simple("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+:[0-9]*", (const gchar *) value, 0, 0);
+                               b_regex = g_regex_match_simple("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+:[0-9]*", (const gchar *)value, 0, 0);
 
                                if (b_regex) {
                                        int port_num = 0;
                                        gchar **tmp_proxy = NULL;
 
-                                       tmp_proxy = g_strsplit_set((const gchar *) value, ".:", -1);
+                                       tmp_proxy = g_strsplit_set((const gchar *)value, ".:", -1);
                                        port_num = atoi(tmp_proxy[4]);
 
                                        if (port_num <= 0) {
                                                g_free(proxy_addr);
                                                proxy_addr = g_strdup_printf("%d.%d.%d.%d",
-                                                       atoi(tmp_proxy[0]), atoi(tmp_proxy[1]), atoi(tmp_proxy[2]), atoi(tmp_proxy[3]));
+                                                                            atoi(tmp_proxy[0]), atoi(tmp_proxy[1]), atoi(tmp_proxy[2]), atoi(tmp_proxy[3]));
                                        } else {
                                                g_free(proxy_addr);
                                                proxy_addr = g_strdup_printf("%d.%d.%d.%d:%d",
-                                                       atoi(tmp_proxy[0]), atoi(tmp_proxy[1]), atoi(tmp_proxy[2]), atoi(tmp_proxy[3]), port_num);
+                                                                            atoi(tmp_proxy[0]), atoi(tmp_proxy[1]), atoi(tmp_proxy[2]), atoi(tmp_proxy[3]), port_num);
                                        }
                                        g_strfreev(tmp_proxy);
                                } else {
                                        g_free(proxy_addr);
-                                       proxy_addr = g_strdup((const char *) value);
+                                       proxy_addr = g_strdup((const char *)value);
                                } /* not in regular experssion */
                        }
                        info("proxy addr (%s)", proxy_addr);
                } else if (g_str_equal(key, "10") == TRUE) {
                        g_free(home_url);
-                       home_url = g_strdup((const char *) value);
+                       home_url = g_strdup((const char *)value);
                        info("home url (%s)", home_url);
                } else if (g_str_equal(key, "11") == TRUE) {
                        if (value) {
-                               pdp_type = atoi((const char *) value);
+                               pdp_type = atoi((const char *)value);
                                info("pdp type (%d)", pdp_type);
                        }
                } else if (g_str_equal(key, "19") == TRUE) {
                        if (value) {
-                               svc_ctg_id = atoi((const char *) value);
+                               svc_ctg_id = atoi((const char *)value);
                                info("context category type (%d)", svc_ctg_id);
                        }
                } else if (g_str_equal(key, "20") == TRUE) {
                        if (value) {
-                               hidden = atoi((const char *) value);
+                               hidden = atoi((const char *)value);
                                info("hidden profile (%d)", hidden);
                        }
                } else if (g_str_equal(key, "21") == TRUE) {
                        if (value) {
-                               editable = atoi((const char *) value);
+                               editable = atoi((const char *)value);
                                info("editable profile (%d)", editable);
                        }
                } else if (g_str_equal(key, "22") == TRUE) {
                        if (value) {
-                               default_conn = atoi((const char*) value);
+                               default_conn = atoi((const char *)value);
                                info("default connection profile (%d)", default_conn);
                        }
                } else if (g_str_equal(key, "23") == TRUE) {
                        if (value) {
-                               user_defined = atoi((const char*) value);
+                               user_defined = atoi((const char *)value);
                                info("user defined profile (%d)", user_defined);
                        }
                } else if (g_str_equal(key, "24") == TRUE) {
                        if (value) {
-                               is_roaming_apn = atoi((const char*) value);
+                               is_roaming_apn = atoi((const char *)value);
                                info("roaming APN profile (%d)", is_roaming_apn);
                        }
                } else if (g_str_equal(key, "25") == TRUE) {
                        if (value) {
-                               profile_enable = atoi((const char*) value);
+                               profile_enable = atoi((const char *)value);
                                info("profile enable (%d)", profile_enable);
                        }
                } else if (g_str_equal(key, "26") == TRUE) {
                        if (value) {
-                               roam_pdp_type = atoi((const char *) value);
+                               roam_pdp_type = atoi((const char *)value);
                                info("Roam pdp type (%d)", roam_pdp_type);
                        }
                }
@@ -474,7 +345,6 @@ static gboolean __ps_context_create_co_context(gpointer object, GHashTable *prop
 
        path = __ps_context_create_path(profile_name, profile_id, svc_ctg_id, cp_name);
 
-       context = (ps_context_t *)object;
        co_context = tcore_context_new(context->plg, path, NULL);
        tcore_context_set_type(co_context, pdp_type);
        tcore_context_set_roam_pdp_type(co_context, roam_pdp_type);
@@ -493,14 +363,16 @@ static gboolean __ps_context_create_co_context(gpointer object, GHashTable *prop
        context->profile_id = profile_id;
        context->editable = editable;
        context->is_default = default_conn;
-       _ps_context_set_profile_enable(context, profile_enable);
        context->path = path;
        context->co_context = co_context;
-       switch(svc_ctg_id) {
+       _ps_context_set_profile_enable(context, profile_enable);
+
+       switch (svc_ctg_id) {
        case CONTEXT_ROLE_INTERNET:
                if (default_conn)
-                       attach_apn = TRUE; /* ME's default setting */
+                       attach_apn = TRUE;
                context->hidden = hidden;
+               default_pdn = TRUE;
        break;
 
        case CONTEXT_ROLE_MMS:
@@ -510,6 +382,8 @@ static gboolean __ps_context_create_co_context(gpointer object, GHashTable *prop
        break;
 
        case CONTEXT_ROLE_IMS:
+               if (default_conn)
+                       attach_apn = TRUE;
                context->hidden = TRUE;
        break;
 
@@ -535,149 +409,91 @@ static gboolean __ps_context_create_co_context(gpointer object, GHashTable *prop
        return TRUE;
 }
 
-static gpointer __ps_context_create_context(GDBusConnection *conn, TcorePlugin *p,
-               gchar *mccmnc, GHashTable *property, gchar *cp_name)
+static ps_context_t *__ps_context_create_context(GDBusConnection *conn, TcorePlugin *p,
+                                                gchar *mccmnc, GHashTable *property, gchar *cp_name)
 {
-       PacketServiceContext *context;
-       GError *error = NULL;
        ps_context_t *new_context;
-       gchar *path = NULL;
+
 
        /*Initializing the master list for internal referencing*/
        new_context = g_try_malloc0(sizeof(ps_context_t));
-       if (NULL == new_context) {
+       if (!new_context) {
                err("[%s] Unable to allocate memory for context", cp_name);
-               goto FAILURE;
-       }
-       dbg("[%s] creating the skeleton object", cp_name);
-       context = packet_service_context_skeleton_new();
-       if (NULL == context) {
-               g_free(new_context);
-               goto FAILURE;
+               return NULL;
        }
 
        dbg("[%s] Assigning the memory location for the internal data", cp_name);
        new_context->conn = conn;
        new_context->plg = p;
-       new_context->if_obj = context;
        new_context->mccmnc = g_strdup(mccmnc);
-       new_context->connection_timeout = TIMEOUT_DEFAULT;
+       new_context->connection_timeout = PDP_RETRY_TIME_OUT_DEFAULT;
+       if (g_str_has_suffix(cp_name, "0"))
+               new_context->subs_type = PS_SUBS_PRIMARY;
+       else
+               new_context->subs_type = PS_SUBS_SECONDARY;
 
-       __ps_context_create_co_context(new_context, property , cp_name);
+       __ps_context_create_co_context(new_context, property, cp_name);
        _ps_context_set_alwayson_enable(new_context, TRUE);
-       path = _ps_context_ref_path(new_context);
-       _ps_context_setup_interface(context, new_context);
-
-       dbg("[%s] exporting the interface object to the dbus connection", cp_name);
-       /*exporting the interface object to the path mention for master*/
-       g_dbus_interface_skeleton_export((G_DBUS_INTERFACE_SKELETON(context)),
-                       conn,
-                       path,
-                       &error);
-
-       g_assert_no_error(error);
-
-       info("Successfully new object created for the interface for path [%s]", path);
+       if (!ps_context_setup_interface(new_context)) {
+               g_free(new_context->mccmnc);
+               g_free(new_context);
+               return NULL;
+       }
        return new_context;
-
-FAILURE:
-       /*To do : handle failure */
-       err("[%s] Unable to allocate memory for the new object", cp_name);
-       return NULL;
 }
 
-static gboolean __ps_context_update_profile(ps_context_t *context, GHashTable *property)
+gpointer _ps_context_create_database_handle(const char *cp_name)
 {
-       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, "profile_name") == TRUE) {
-                       tcore_context_set_profile_name(co_context, (const char *) value);
-               } else if (g_str_equal(key, "auth_type") == TRUE) {
-                       int i_tmp = 0;
-                       if (value) {
-                               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, "pdp_protocol") == TRUE) {
-                       int i_tmp = 0;
-                       if (value) {
-                               i_tmp = atoi((const char *) value);
-                               tcore_context_set_type(co_context, i_tmp);
-                       }
-               } else if (g_str_equal(key, "roam_pdp_protocol") == TRUE) {
-                       int i_tmp = 0;
-                       if (value) {
-                               i_tmp = atoi((const char *) value);
-                               tcore_context_set_roam_pdp_type(co_context, i_tmp);
-                       }
-               } 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);
-               } else if (g_str_equal(key, "profile_enable") == TRUE) {
-                       if (value) {
-                               gboolean tmp = TRUE;
-                               if (g_str_equal(value, "FALSE") == TRUE)
-                                       tmp = FALSE;
-                               _ps_context_set_profile_enable(context, tmp);
-                       }
-               }
-       }
-
-       return __ps_context_update_database(context);
+       if (g_str_has_suffix(cp_name, "1"))
+               return tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
+       else
+               return tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
 }
 
-static gboolean __ps_context_update_default_internet_to_db(ps_context_t *context, gboolean enabled)
+gboolean __ps_context_update_database(ps_context_t *context)
 {
        gpointer handle;
        GHashTable *in_param;
        char szQuery[3000];
        gboolean rv = FALSE;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
-       char *cp_name = _ps_modem_ref_cp_name(_ps_service_ref_modem(_ps_context_ref_service(context)));
+       ps_service_t *service = _ps_context_ref_service(context);
+       CoreObject *co_context = _ps_context_ref_co_context(context);
+       char *cp_name = _ps_modem_ref_cp_name(_ps_service_ref_modem(service));
 
        g_return_val_if_fail(context != NULL, FALSE);
+       g_return_val_if_fail(co_context != NULL, FALSE);
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
-               ps_err_ex_co(co_network, "Failed to get Storage handle");
-               return FALSE;
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
+               ps_err_ex_ctx(context, "Failed to get Storage handle");
+               return rv;
        }
 
        /* Initialize parameters */
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
-       g_hash_table_insert(in_param, "1",
-                       g_strdup_printf("%d", enabled));                                /* Profile enabled/disabled */
-       g_hash_table_insert(in_param, "2",
-                       g_strdup_printf("%d", context->profile_id));    /* Profile ID */
+       g_hash_table_insert(in_param, "1", tcore_context_get_apn(co_context)); /* APN */
+       g_hash_table_insert(in_param, "2", g_strdup_printf("%d", tcore_context_get_auth(co_context))); /* Auth Type */
+       g_hash_table_insert(in_param, "3", tcore_context_get_username(co_context)); /* Username */
+       g_hash_table_insert(in_param, "4", tcore_context_get_password(co_context)); /* Password */
+       g_hash_table_insert(in_param, "5", tcore_context_get_proxy(co_context));    /* Proxy */
+       g_hash_table_insert(in_param, "6", tcore_context_get_mmsurl(co_context));   /* MMS URL */
+       g_hash_table_insert(in_param, "7", tcore_context_get_profile_name(co_context)); /* Profile Name */
+       g_hash_table_insert(in_param, "8", g_strdup_printf("%d", tcore_context_get_type(co_context))); /* PDP protocol */
+       g_hash_table_insert(in_param, "9", g_strdup_printf("%d", tcore_context_get_roam_pdp_type(co_context))); /* Roam PDP protocol */
+       g_hash_table_insert(in_param, "10", g_strdup_printf("%d", tcore_context_get_role(co_context))); /* Svc Category */
+       g_hash_table_insert(in_param, "11", g_strdup_printf("%d", _ps_context_get_profile_enable(context))); /* Profile Enable */
+       g_hash_table_insert(in_param, "12", g_strdup_printf("%d", context->profile_id)); /* Profile ID */
 
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               " update pdp_profile set \
-                default_internet_con = ? \
-                where profile_id = ?");
+                " update pdp_profile set \
+                apn = ?, auth_type = ?, auth_id = ?, auth_pwd = ?, \
+                proxy_ip_addr = ?, home_url = ?, profile_name = ?, \
+                pdp_protocol = ?, roam_pdp_protocol = ?, svc_category_id = ?, profile_enable = ? where profile_id = ?");
 
        rv = tcore_storage_update_query_database(strg_db, handle, szQuery, in_param);
-       ps_info_ex_co(co_network, "Update Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       ps_info_ex_ctx(context, "Update Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        /* Free resources */
        g_hash_table_destroy(in_param);
@@ -688,62 +504,37 @@ static gboolean __ps_context_update_default_internet_to_db(ps_context_t *context
        return rv;
 }
 
-static gboolean __ps_context_update_database(ps_context_t *context)
+gboolean _ps_context_update_default_internet_to_db(ps_context_t *context, gboolean enabled)
 {
        gpointer handle;
        GHashTable *in_param;
        char szQuery[3000];
        gboolean rv = FALSE;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
-       char *cp_name = _ps_modem_ref_cp_name(_ps_service_ref_modem(_ps_context_ref_service(context)));
+       ps_service_t *service = _ps_context_ref_service(context);
+       char *cp_name = _ps_modem_ref_cp_name(_ps_service_ref_modem(service));
 
        g_return_val_if_fail(context != NULL, FALSE);
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
-               ps_err_ex_co(co_network, "Failed to get Storage handle");
-               return rv;
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
+               ps_err_ex_ctx(context, "Failed to get Storage handle");
+               return FALSE;
        }
 
        /* Initialize parameters */
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
-       g_hash_table_insert(in_param, "1",
-                       tcore_context_get_apn(context->co_context));                                            /* APN */
-       g_hash_table_insert(in_param, "2",
-                       g_strdup_printf("%d", tcore_context_get_auth(context->co_context)));    /* Auth Type */
-       g_hash_table_insert(in_param, "3",
-                       tcore_context_get_username(context->co_context));                                       /* Username */
-       g_hash_table_insert(in_param, "4",
-                       tcore_context_get_password(context->co_context));                                       /* Password */
-       g_hash_table_insert(in_param, "5",
-                       tcore_context_get_proxy(context->co_context));                                          /* Proxy */
-       g_hash_table_insert(in_param, "6",
-                       tcore_context_get_mmsurl(context->co_context));                                         /* MMS URL */
-       g_hash_table_insert(in_param, "7",
-                       tcore_context_get_profile_name(context->co_context));                                           /* Profile Name */
-       g_hash_table_insert(in_param, "8",
-                       g_strdup_printf("%d", tcore_context_get_type(context->co_context))); /* PDP protocol */
-       g_hash_table_insert(in_param, "9",
-                       g_strdup_printf("%d", tcore_context_get_roam_pdp_type(context->co_context))); /* Roam PDP protocol */
-       g_hash_table_insert(in_param, "10",
-                       g_strdup_printf("%d", _ps_context_get_profile_enable(context))); /* Profile Enable */
-       g_hash_table_insert(in_param, "11",
-                       g_strdup_printf("%d", context->profile_id));                                            /* Profile ID */
+       g_hash_table_insert(in_param, "1", g_strdup_printf("%d", enabled)); /* Profile enabled/disabled */
+       g_hash_table_insert(in_param, "2", g_strdup_printf("%d", context->profile_id)); /* Profile ID */
 
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               " update pdp_profile set \
-                apn = ?, auth_type = ?, auth_id = ?, auth_pwd = ?, \
-                proxy_ip_addr = ?, home_url = ?, profile_name = ?, \
-                pdp_protocol = ?, roam_pdp_protocol = ?, profile_enable = ? where profile_id = ?");
+                " update pdp_profile set \
+                default_internet_con = ? \
+                where profile_id = ?");
 
        rv = tcore_storage_update_query_database(strg_db, handle, szQuery, in_param);
-       ps_info_ex_co(co_network, "Update Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       ps_info_ex_ctx(context, "Update Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        /* Free resources */
        g_hash_table_destroy(in_param);
@@ -754,39 +545,34 @@ static gboolean __ps_context_update_database(ps_context_t *context)
        return rv;
 }
 
-static gboolean __ps_context_remove_database(ps_context_t *context)
+gboolean _ps_context_remove_database(ps_context_t *context)
 {
        gpointer handle;
        GHashTable *in_param;
        char szQuery[1000];
        gboolean rv = FALSE;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
-       char *cp_name = _ps_modem_ref_cp_name(_ps_service_ref_modem(_ps_context_ref_service(context)));
+       ps_service_t *service = _ps_context_ref_service(context);
+       char *cp_name = _ps_modem_ref_cp_name(_ps_service_ref_modem(service));
 
        g_return_val_if_fail(context != NULL, FALSE);
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
-               ps_err_ex_co(co_network, "Failed to get Storage handle");
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
+               ps_err_ex_ctx(context, "Failed to get Storage handle");
                return rv;
        }
 
        /* Initialize parameters */
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
-       g_hash_table_insert(in_param, "1",
-                       g_strdup_printf("%d", context->profile_id));    /* Profile ID */
+       g_hash_table_insert(in_param, "1", g_strdup_printf("%d", context->profile_id)); /* Profile ID */
 
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               " delete from pdp_profile where profile_id = ? ");
+                " delete from pdp_profile where profile_id = ? ");
 
        rv = tcore_storage_remove_query_database(strg_db, handle, szQuery, in_param);
-       ps_info_ex_co(co_network, "Remove from Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       ps_info_ex_ctx(context, "Remove from Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        /* Free resources */
        g_hash_table_destroy(in_param);
@@ -808,12 +594,8 @@ static int __ps_context_insert_network_id_to_database(gchar *mccmnc, gchar *cp_n
        gpointer key, value;
        int network_id = 0;
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
                err("[%s] Failed to get Storage handle", cp_name);
                return rv;
        }
@@ -827,7 +609,7 @@ static int __ps_context_insert_network_id_to_database(gchar *mccmnc, gchar *cp_n
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               "select max(network_info_id) as network_id from network_info");
+                "select max(network_info_id) as network_id from network_info");
 
        rv = tcore_storage_read_query_database(strg_db, handle, szQuery, NULL, &out_param, 1);
        info("[%s] Read Database: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
@@ -863,11 +645,11 @@ static int __ps_context_insert_network_id_to_database(gchar *mccmnc, gchar *cp_n
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               " insert into network_info(network_info_id, network_name, mccmnc) values(?, ?, ?) ");
+                " insert into network_info(network_info_id, network_name, mccmnc) values(?, ?, ?) ");
 
        /* Initialize parameters */
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
-       g_hash_table_insert(in_param, "1", g_strdup_printf("%d", network_id));  /* Network ID */
+       g_hash_table_insert(in_param, "1", g_strdup_printf("%d", network_id));  /* Network ID */
        g_hash_table_insert(in_param, "2", g_strdup_printf("PLMN_%s", mccmnc));
        g_hash_table_insert(in_param, "3", g_strdup(mccmnc));
 
@@ -901,12 +683,8 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
        gchar *auth_id = NULL, *auth_pwd = NULL, *proxy_addr = NULL, *is_roaming_apn = NULL;
        gchar *home_url = NULL, *svc_id = NULL, *pdp_protocol = NULL, *roam_pdp_protocol = NULL;
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
                err("[%s] Failed to get Storage handle", cp_name);
                return 0;
        }
@@ -915,7 +693,6 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
        if (profile_id < 0) {
                err("[%s] Failed to get last Profile ID", cp_name);
                profile_id = 0;
-
                goto EXIT;
        }
 
@@ -924,7 +701,7 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
 
        g_hash_table_iter_init(&iter, property);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-               if (g_str_equal(key, "profile_name") == TRUE) {                 /* Profile Name */
+               if (g_str_equal(key, "profile_name") == TRUE) {                 /* Profile Name */
                        if (value != NULL) {
                                FREE_AND_ASSIGN(profile_name, value);
                        } else {
@@ -933,43 +710,43 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
 
                                profile_name = __ps_context_load_network_name_from_database(network_id, cp_name);
                        }
-               } else if (g_str_equal(key, "apn") == TRUE) {                   /* APN */
+               } else if (g_str_equal(key, "apn") == TRUE) {                   /* APN */
                        FREE_AND_ASSIGN(apn, value);
-               } else if (g_str_equal(key, "auth_type") == TRUE) {     /* Auth Type */
+               } else if (g_str_equal(key, "auth_type") == TRUE) {     /* Auth Type */
                        FREE_AND_ASSIGN(auth_type, value);
-               } else if (g_str_equal(key, "auth_id") == TRUE) {               /* Auth ID */
+               } else if (g_str_equal(key, "auth_id") == TRUE) {               /* Auth ID */
                        FREE_AND_ASSIGN(auth_id, value);
-               } else if (g_str_equal(key, "auth_pwd") == TRUE) {      /* Auth Password */
+               } else if (g_str_equal(key, "auth_pwd") == TRUE) {      /* Auth Password */
                        FREE_AND_ASSIGN(auth_pwd, value);
-               } else if (g_str_equal(key, "proxy_addr") == TRUE) {    /* Proxy Address */
+               } else if (g_str_equal(key, "proxy_addr") == TRUE) {    /* Proxy Address */
                        FREE_AND_ASSIGN(proxy_addr, value);
-               } else if (g_str_equal(key, "home_url") == TRUE) {      /* Home URL */
+               } else if (g_str_equal(key, "home_url") == TRUE) {      /* Home URL */
                        FREE_AND_ASSIGN(home_url, value);
-               } else if (g_str_equal(key, "svc_ctg_id") == TRUE) {    /* Service ID */
+               } else if (g_str_equal(key, "svc_ctg_id") == TRUE) {    /* Service ID */
                        FREE_AND_ASSIGN(svc_id, value);
-               } else if (g_str_equal(key, "pdp_protocol") == TRUE) {  /* PDP protocol */
+               } else if (g_str_equal(key, "pdp_protocol") == TRUE) {  /* PDP protocol */
                        FREE_AND_ASSIGN(pdp_protocol, value);
-               } else if (g_str_equal(key, "roam_pdp_protocol") == TRUE) {     /* Roam PDP protocol */
+               } else if (g_str_equal(key, "roam_pdp_protocol") == TRUE) {     /* Roam PDP protocol */
                        FREE_AND_ASSIGN(roam_pdp_protocol, value);
-               } else if (g_str_equal(key, "is_roaming_apn") == TRUE) {        /* Roam APN */
+               } else if (g_str_equal(key, "is_roaming_apn") == TRUE) {        /* Roam APN */
                        FREE_AND_ASSIGN(is_roaming_apn, value);
                }
        }
 
        /* Set default PDP protocol */
-       if (pdp_protocol == NULL) {
+       if (!pdp_protocol) {
                dbg("[%s] default pdp_protocol = IPv4v6", cp_name);
                pdp_protocol = g_strdup_printf("%d", CONTEXT_TYPE_IPV4V6);
        }
 
        /* Set default Roam PDP protocol */
-       if (roam_pdp_protocol == NULL) {
+       if (!roam_pdp_protocol) {
                dbg("[%s] default roam_pdp_protocol = IPv4v6", cp_name);
                roam_pdp_protocol = g_strdup_printf("%d", CONTEXT_TYPE_IPV4V6);
        }
 
        /* Set default Roam PDP protocol */
-       if (is_roaming_apn == NULL) {
+       if (!is_roaming_apn) {
                dbg("[%s] default is_roaming_apn = 0", cp_name);
                is_roaming_apn = g_strdup_printf("%d", 0);
        }
@@ -977,30 +754,28 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
        /* Initialize parameters */
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
 
-       g_hash_table_insert(in_param, "1",
-                       g_strdup_printf("%d", profile_id));                     /* Profile ID */
-       g_hash_table_insert(in_param, "2", profile_name);       /* Profile Name */
-       g_hash_table_insert(in_param, "3", apn);                        /* APN */
-       g_hash_table_insert(in_param, "4", auth_type);          /* Auth Type */
-       g_hash_table_insert(in_param, "5", auth_id);            /* Auth ID */
-       g_hash_table_insert(in_param, "6", auth_pwd);           /* Auth Password */
-       g_hash_table_insert(in_param, "7", pdp_protocol);               /* PDP Protocol */
-       g_hash_table_insert(in_param, "8", roam_pdp_protocol);          /* Roam PDP Protocol */
-       g_hash_table_insert(in_param, "9", proxy_addr);         /* Proxy Address */
-       g_hash_table_insert(in_param, "10", home_url);          /* Home URL */
-       g_hash_table_insert(in_param, "11",
-                       g_strdup_printf("%d", network_id));                     /* Network ID */
-       g_hash_table_insert(in_param, "12", svc_id);            /* Service ID */
-       g_hash_table_insert(in_param, "13", is_roaming_apn);    /* Roaming APN */
+       g_hash_table_insert(in_param, "1", g_strdup_printf("%d", profile_id)); /* Profile ID */
+       g_hash_table_insert(in_param, "2", profile_name);       /* Profile Name */
+       g_hash_table_insert(in_param, "3", apn);                        /* APN */
+       g_hash_table_insert(in_param, "4", auth_type);          /* Auth Type */
+       g_hash_table_insert(in_param, "5", auth_id);            /* Auth ID */
+       g_hash_table_insert(in_param, "6", auth_pwd);           /* Auth Password */
+       g_hash_table_insert(in_param, "7", pdp_protocol);               /* PDP Protocol */
+       g_hash_table_insert(in_param, "8", roam_pdp_protocol);          /* Roam PDP Protocol */
+       g_hash_table_insert(in_param, "9", proxy_addr);         /* Proxy Address */
+       g_hash_table_insert(in_param, "10", home_url);          /* Home URL */
+       g_hash_table_insert(in_param, "11", g_strdup_printf("%d", network_id));                 /* Network ID */
+       g_hash_table_insert(in_param, "12", svc_id);            /* Service ID */
+       g_hash_table_insert(in_param, "13", is_roaming_apn);    /* Roaming APN */
 
        info("[%s] Profile ID: [%d] Profile name: [%s] APN :[%s] Auth Type [%s] Auth ID: [%s] "
-               "Auth Password: [%s] PDP Protocol: [%s] Roam PDP Protocol: [%s] Proxy Address: [%s] Home URL: [%s] Service ID: [%s] Roaming apn: [%s]",
-               cp_name, profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol, roam_pdp_protocol, proxy_addr, home_url, svc_id, is_roaming_apn);
+            "Auth Password: [%s] PDP Protocol: [%s] Roam PDP Protocol: [%s] Proxy Address: [%s] Home URL: [%s] Service ID: [%s] Roaming apn: [%s]",
+            cp_name, profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol, roam_pdp_protocol, proxy_addr, home_url, svc_id, is_roaming_apn);
 
        /* SQL Query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               " insert into pdp_profile(\
+                " insert into pdp_profile(\
                 profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, \
                 pdp_protocol, roam_pdp_protocol, proxy_ip_addr, home_url, linger_time, \
                 network_info_id, svc_category_id, hidden, editable, \
@@ -1018,7 +793,7 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
        /* Free resources */
        g_hash_table_destroy(in_param);
 
-EXIT:
+ EXIT:
        /* De-initialize Storage */
        tcore_storage_remove_handle(strg_db, handle);
 
@@ -1037,12 +812,8 @@ static int __ps_context_load_network_id_from_database(gchar *mccmnc, gchar *cp_n
 
        int network_id = -1;
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
                err("[%s] Failed to get Storage handle", cp_name);
                return network_id;
        }
@@ -1054,7 +825,7 @@ static int __ps_context_load_network_id_from_database(gchar *mccmnc, gchar *cp_n
        /* SQL Query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               "select network_info_id from network_info where mccmnc = ? ");
+                "select network_info_id from network_info where mccmnc = ? ");
 
        rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, &out_param, 1);
        info("[%s] Read Database: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
@@ -1072,8 +843,6 @@ static int __ps_context_load_network_id_from_database(gchar *mccmnc, gchar *cp_n
                                                network_id = 0;
                                        else
                                                network_id = atoi((const char *)value2);
-
-                                       /* TODO - Check this out */
                                        break;
                                }
                        }
@@ -1102,12 +871,8 @@ static gchar *__ps_context_load_network_name_from_database(int network_id, gchar
 
        gchar *network_name = NULL;
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
                err("[%s] Failed to get Storage handle", cp_name);
                return NULL;
        }
@@ -1119,7 +884,7 @@ static gchar *__ps_context_load_network_name_from_database(int network_id, gchar
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               "select network_name from network_info where network_info_id = ? ");
+                "select network_name from network_info where network_info_id = ? ");
 
        rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, &out_param, 1);
        info("[%s] Read Database: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
@@ -1135,8 +900,6 @@ static gchar *__ps_context_load_network_name_from_database(int network_id, gchar
                                if (g_str_equal(key2, "0") == TRUE) {
                                        g_free(network_name);
                                        network_name = g_strdup(value2);
-
-                                       /* TODO - Check this logic */
                                        break;
                                }
                        }
@@ -1165,12 +928,8 @@ static int __ps_context_load_profile_id_from_database(gchar *cp_name)
 
        int profile_id = -1;
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
                err("[%s] Failed to get Storage handle", cp_name);
                return profile_id;
        }
@@ -1178,7 +937,7 @@ static int __ps_context_load_profile_id_from_database(gchar *cp_name)
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               "select max(profile_id) as last_profile from pdp_profile");
+                "select max(profile_id) as last_profile from pdp_profile");
 
        rv = tcore_storage_read_query_database(strg_db, handle, szQuery, NULL, &out_param, 1);
        info("[%s] Read Database: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
@@ -1196,8 +955,6 @@ static int __ps_context_load_profile_id_from_database(gchar *cp_name)
                                                profile_id = 0;
                                        else
                                                profile_id = atoi((const char *)value2);
-
-                                       /* TODO - Check this logic */
                                        break;
                                }
                        }
@@ -1213,7 +970,7 @@ static int __ps_context_load_profile_id_from_database(gchar *cp_name)
        return profile_id;
 }
 
-static int __ps_context_load_num_of_pdn_from_database(gchar *mccmnc, gchar *cp_name)
+static int __ps_context_load_num_of_pdn_from_database(gchar *mccmnc, ps_service_t *service)
 {
        gpointer handle;
        GHashTable *in_param, *out_param;
@@ -1222,15 +979,20 @@ static int __ps_context_load_num_of_pdn_from_database(gchar *mccmnc, gchar *cp_n
 
        GHashTableIter iter;
        gpointer key, value;
-
+       gchar *cp_name = _ps_modem_ref_cp_name(_ps_service_ref_modem(service));
+       int modem_cnt = tcore_server_get_modems_count(tcore_plugin_ref_server(_ps_service_ref_plugin(service)));
+       int max_pdn = 0;
        int num_of_pdn = 0;
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
+       if (modem_cnt > 1)
+               max_pdn = PS_MAX_CID;
+       else {
+               info("single modem MAX_PDN -> 5");
+               max_pdn = 5;
+       }
+
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
                err("[%s] Failed to get Storage handle", cp_name);
                return 0;
        }
@@ -1242,7 +1004,7 @@ static int __ps_context_load_num_of_pdn_from_database(gchar *mccmnc, gchar *cp_n
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               "select a.max_pdp_3g from max_pdp a, network_info b \
+                "select a.max_pdp_3g from max_pdp a, network_info b \
                where a.network_info_id = b.network_info_id and b.mccmnc = ? ");
 
        rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, &out_param, 1);
@@ -1258,14 +1020,12 @@ static int __ps_context_load_num_of_pdn_from_database(gchar *mccmnc, gchar *cp_n
                        while (g_hash_table_iter_next(&iter2, &key2, &value2) == TRUE) {
                                if (g_str_equal(key2, "0") == TRUE) {
                                        if (!value2 || (g_strcmp0((const char *)value2, "") == 0)) {
-                                               num_of_pdn = 3;
+                                               num_of_pdn = max_pdn;
                                                dbg("[%s] There is NO value... Using 'default'", cp_name);
                                        } else {
-                                               num_of_pdn = atoi((const char *) value2);
+                                               num_of_pdn = atoi((const char *)value2);
                                                dbg("[%s] value (%d)", cp_name, num_of_pdn);
                                        }
-
-                                       /* TODO - Check this logic */
                                        break;
                                }
                        }
@@ -1274,10 +1034,10 @@ static int __ps_context_load_num_of_pdn_from_database(gchar *mccmnc, gchar *cp_n
 
        if (num_of_pdn <= 0) {
                info("[%s] Loaded value is wrong... restoring to 'default'", cp_name);
-               num_of_pdn = PS_MAX_CID;
-       } else if (num_of_pdn > PS_MAX_CID) {
-               info("[%s] Loaded value is gretaer than 3... restoring to 'default'", cp_name);
-               num_of_pdn = PS_MAX_CID;
+               num_of_pdn = max_pdn;
+       } else if (num_of_pdn > max_pdn) {
+               info("[%s] Loaded value is gretaer than %d... restoring to 'default'", max_pdn, cp_name);
+               num_of_pdn = max_pdn;
        }
 
        /* Free resources */
@@ -1299,12 +1059,8 @@ static gboolean __ps_context_remove_profile_tuple(dictionary *dic, int profile_i
        gchar *section_key = NULL;
        char szQuery[5000];
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
                err("[%s] Failed to get Storage handle", cp_name);
                return rv;
        }
@@ -1320,7 +1076,7 @@ static gboolean __ps_context_remove_profile_tuple(dictionary *dic, int profile_i
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               " delete from pdp_profile where network_info_id = ?");
+                " delete from pdp_profile where network_info_id = ?");
 
        rv = tcore_storage_insert_query_database(strg_db, handle, szQuery, in_param);
        info("[%s] delete from pdp_profile where network_info_id = %s, result(%d)", cp_name, network_info_id, rv);
@@ -1339,12 +1095,8 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
        GHashTable *in_param;
        gboolean rv = FALSE;
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
                err("[%s] Failed to get Storage handle", cp_name);
                return rv;
        }
@@ -1352,7 +1104,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
        /* Initialize parameters */
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
 
-       {/* profile id */
+       { /* profile id */
                gchar *profile_id;
                gchar *item_key = NULL;
                int max_profile_id = -1;
@@ -1361,7 +1113,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(item_key);
                /* In case of upgrade of Tizen OS, validation of profile_id is required. */
                max_profile_id = __ps_context_load_profile_id_from_database(cp_name);
-               if (profile_id == NULL) {
+               if (!profile_id) {
                        if (max_profile_id == -1) {
                                err("[%s] profile_id is mandatory but not provided.", cp_name);
                                goto EXIT;
@@ -1371,50 +1123,50 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                        int tmp_id = atoi(profile_id);
                        if (max_profile_id != -1 && max_profile_id >= tmp_id) {
                                warn("[%s] profile_id:[%d] is less than max_profile_id:[%d]", cp_name, tmp_id, max_profile_id);
-                               tmp_id = max_profile_id+1;
+                               tmp_id = max_profile_id + 1;
                        }
                        g_hash_table_insert(in_param, "1", g_strdup_printf("%d", tmp_id));
                }
        }
 
-       {/* profile name */
+       { /* profile name */
                gchar *profile_name;
                gchar *item_key = NULL;
                item_key = g_strdup_printf("connection:profile_name_%d", profile_index);
                profile_name = iniparser_getstring(dic, item_key, NULL);
-               if (profile_name == NULL)
+               if (!profile_name)
                        g_hash_table_insert(in_param, "2", g_strdup("TEMP"));
                else
                        g_hash_table_insert(in_param, "2", g_strdup(profile_name));
                g_free(item_key);
        }
 
-       {/* apn */
+       { /* apn */
                gchar *apn;
                gchar *item_key = NULL;
                item_key = g_strdup_printf("connection:apn_%d", profile_index);
                apn = iniparser_getstring(dic, item_key, NULL);
                g_free(item_key);
-               if (apn == NULL) {
+               if (!apn) {
                        err("[%s] apn is mandatory but not provided.", cp_name);
                        goto EXIT;
                }
                g_hash_table_insert(in_param, "3", g_strdup(apn));
        }
 
-       {/* auth type */
+       { /* auth type */
                gchar *auth_type;
                gchar *item_key = NULL;
                item_key = g_strdup_printf("connection:auth_type_%d", profile_index);
                auth_type = iniparser_getstring(dic, item_key, NULL);
-               if (auth_type == NULL)
+               if (!auth_type)
                        g_hash_table_insert(in_param, "4", g_strdup_printf("%d", CONTEXT_AUTH_NONE));
                else
                        g_hash_table_insert(in_param, "4", g_strdup(auth_type));
                g_free(item_key);
        }
 
-       {/* auth id */
+       { /* auth id */
                gchar *auth_id;
                gchar *item_key = NULL;
                item_key = g_strdup_printf("connection:auth_id_%d", profile_index);
@@ -1423,7 +1175,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(item_key);
        }
 
-       {/* auth pwd */
+       { /* auth pwd */
                gchar *auth_pwd;
                gchar *item_key = NULL;
                item_key = g_strdup_printf("connection:auth_pwd_%d", profile_index);
@@ -1432,31 +1184,31 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(item_key);
        }
 
-       {/* pdp protocol */
+       { /* pdp protocol */
                gchar *pdp_protocol;
                gchar *item_key = NULL;
                item_key = g_strdup_printf("connection:pdp_protocol_%d", profile_index);
                pdp_protocol = iniparser_getstring(dic, item_key, NULL);
-               if (pdp_protocol == NULL)
+               if (!pdp_protocol)
                        g_hash_table_insert(in_param, "7", g_strdup_printf("%d", CONTEXT_TYPE_IPV4V6));
                else
                        g_hash_table_insert(in_param, "7", g_strdup(pdp_protocol));
                g_free(item_key);
        }
 
-       {/* roam pdp protocol */
+       { /* roam pdp protocol */
                gchar *roam_pdp_protocol;
                gchar *item_key = NULL;
                item_key = g_strdup_printf("connection:roam_pdp_protocol_%d", profile_index);
                roam_pdp_protocol = iniparser_getstring(dic, item_key, NULL);
-               if (roam_pdp_protocol == NULL)
+               if (!roam_pdp_protocol)
                        g_hash_table_insert(in_param, "8", g_strdup_printf("%d", CONTEXT_TYPE_IPV4V6));
                else
                        g_hash_table_insert(in_param, "8", g_strdup(roam_pdp_protocol));
                g_free(item_key);
        }
 
-       {/* proxy ip */
+       { /* proxy ip */
                gchar *proxy_ip_addr;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:proxy_ip_addr_%d", profile_index);
@@ -1465,7 +1217,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(section_key);
        }
 
-       {/* home url */
+       { /* home url */
                gchar *home_url;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:home_url_%d", profile_index);
@@ -1474,7 +1226,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(section_key);
        }
 
-       {/* linger time */
+       { /* linger time */
                gchar *linger_time;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:linger_time_%d", profile_index);
@@ -1483,7 +1235,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(section_key);
        }
 
-       {/* traffic class */
+       { /* traffic class */
                gchar *traffic_class;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:traffic_class_%d", profile_index);
@@ -1492,7 +1244,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(section_key);
        }
 
-       {/* is static ip address */
+       { /* is static ip address */
                gchar *is_static_ip_addr;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:is_static_ip_addr_%d", profile_index);
@@ -1501,7 +1253,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(section_key);
        }
 
-       {/* ip address if static ip is true */
+       { /* ip address if static ip is true */
                gchar *ip_addr;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:ip_addr_%d", profile_index);
@@ -1510,7 +1262,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(section_key);
        }
 
-       {/* is static dns address */
+       { /* is static dns address */
                gchar *is_static_dns_addr;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:is_static_dns_addr_%d", profile_index);
@@ -1519,7 +1271,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(section_key);
        }
 
-       {/* dns address 1 */
+       { /* dns address 1 */
                gchar *dns_addr1;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:dns_addr1_%d", profile_index);
@@ -1528,7 +1280,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(section_key);
        }
 
-       {/* dns address 2 */
+       { /* dns address 2 */
                gchar *dns_addr2;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:dns_addr2_%d", profile_index);
@@ -1537,7 +1289,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(section_key);
        }
 
-       {/* network info id */
+       { /* network info id */
                gchar *network_info_id;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:network_info_id_%d", profile_index);
@@ -1546,73 +1298,73 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                g_free(section_key);
        }
 
-       {/* service category id */
+       { /* service category id */
                gchar *svc_category_id;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:svc_category_id_%d", profile_index);
                svc_category_id = iniparser_getstring(dic, section_key, NULL);
-               if (svc_category_id == NULL)
+               if (!svc_category_id)
                        g_hash_table_insert(in_param, "19", g_strdup_printf("%d", CONTEXT_ROLE_UNKNOWN));
                else
                        g_hash_table_insert(in_param, "19", g_strdup(svc_category_id));
                g_free(section_key);
        }
 
-       {/* hidden */
+       { /* hidden */
                gchar *hidden;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:hidden_%d", profile_index);
                hidden = iniparser_getstring(dic, section_key, NULL);
-               if (hidden == NULL)
+               if (!hidden)
                        g_hash_table_insert(in_param, "20", g_strdup_printf("%d", FALSE));
                else
                        g_hash_table_insert(in_param, "20", g_strdup(hidden));
                g_free(section_key);
        }
 
-       {/* editable */
+       { /* editable */
                gchar *editable;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:editable_%d", profile_index);
                editable = iniparser_getstring(dic, section_key, NULL);
-               if (editable == NULL)
+               if (!editable)
                        g_hash_table_insert(in_param, "21", g_strdup_printf("%d", TRUE));
                else
                        g_hash_table_insert(in_param, "21", g_strdup(editable));
                g_free(section_key);
        }
 
-       {/* default internet connection */
+       { /* default internet connection */
                gchar *default_internet_con;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:default_internet_con_%d", profile_index);
                default_internet_con = iniparser_getstring(dic, section_key, NULL);
-               if (default_internet_con == NULL)
+               if (!default_internet_con)
                        g_hash_table_insert(in_param, "22", g_strdup_printf("%d", FALSE));
                else
                        g_hash_table_insert(in_param, "22", g_strdup(default_internet_con));
                g_free(section_key);
        }
 
-       {/* insert data into table */
+       { /* insert data into table */
                gchar *is_roaming_apn;
                gchar *section_key = NULL;
                section_key = g_strdup_printf("connection:is_roaming_apn_%d", profile_index);
                is_roaming_apn = iniparser_getstring(dic, section_key, NULL);
-               if (is_roaming_apn == NULL)
+               if (!is_roaming_apn)
                        g_hash_table_insert(in_param, "23", g_strdup_printf("%d", FALSE));
                else
                        g_hash_table_insert(in_param, "23", g_strdup(is_roaming_apn));
                g_free(section_key);
        }
 
-       {/* insert data into table */
+       { /* insert data into table */
                char szQuery[5000];
 
                /* SQL query */
                memset(szQuery, 0x0, sizeof(szQuery));
                snprintf(szQuery, sizeof(szQuery), "%s",
-                       " insert into pdp_profile(\
+                        " insert into pdp_profile(\
                         profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, \
                         pdp_protocol,  roam_pdp_protocol, proxy_ip_addr, home_url, linger_time, \
                         traffic_class, is_static_ip_addr, ip_addr, is_static_dns_addr, dns_addr1, dns_addr2, \
@@ -1627,7 +1379,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                info("[%s] Insert to Database: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
        }
 
-EXIT:
+ EXIT:
        /* Free resources */
        g_hash_table_destroy(in_param);
 
@@ -1653,117 +1405,31 @@ static int __ps_context_get_network_id(gchar *mccmnc, gchar *cp_name)
        return network_id;
 }
 
-GVariant *__ps_context_get_profile_properties(gpointer object, GVariantBuilder *properties)
+gboolean _ps_context_set_default_connection_enable(ps_context_t *context, gboolean enabled)
 {
-       gchar *s_authtype = NULL, *s_role = NULL, *s_type = NULL, *s_roam_pdp_type = NULL;
-       ps_context_t *context = NULL;
-       char *apn, *username, *password, *proxy_addr, *home_url, *profile_name;
-
-       g_return_val_if_fail(object != NULL, NULL);
-       g_return_val_if_fail(properties != NULL, NULL);
-
-       context = (ps_context_t *) object;
-       ps_dbg_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)),
-               "get profile properties, path(%s)", _ps_context_ref_path(context));
-
-       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));
-       s_type = g_strdup_printf("%d", tcore_context_get_type(context->co_context));
-       s_roam_pdp_type = g_strdup_printf("%d", tcore_context_get_roam_pdp_type(context->co_context));
-
-       apn = tcore_context_get_apn(context->co_context);
-       username = tcore_context_get_username(context->co_context);
-       password = tcore_context_get_password(context->co_context);
-       proxy_addr = tcore_context_get_proxy(context->co_context);
-       home_url = tcore_context_get_mmsurl(context->co_context);
-       profile_name = tcore_context_get_profile_name(context->co_context);
-       g_variant_builder_init(properties, G_VARIANT_TYPE("a{ss}"));
-
-       g_variant_builder_add(properties, "{ss}", "path", context->path);
-       if (apn)
-               g_variant_builder_add(properties, "{ss}", "apn", apn);
-
-       if (s_authtype)
-               g_variant_builder_add(properties, "{ss}", "auth_type", s_authtype);
-
-       if (username)
-               g_variant_builder_add(properties, "{ss}", "auth_id", username);
-
-       if (password)
-               g_variant_builder_add(properties, "{ss}", "auth_pwd", password);
-
-       if (s_type)
-               g_variant_builder_add(properties, "{ss}", "pdp_protocol", s_type);
-
-       if (s_roam_pdp_type)
-               g_variant_builder_add(properties, "{ss}", "roam_pdp_protocol", s_roam_pdp_type);
-
-       if (proxy_addr)
-               g_variant_builder_add(properties, "{ss}", "proxy_addr", proxy_addr);
-
-       if (home_url)
-               g_variant_builder_add(properties, "{ss}", "home_url", home_url);
-
-       if (s_role)
-               g_variant_builder_add(properties, "{ss}", "svc_ctg_id", s_role);
-
-       g_variant_builder_add(properties, "{ss}", "profile_name", profile_name);
-       g_variant_builder_add(properties, "{ss}", "hidden", BOOL2STRING(context->hidden));
-       g_variant_builder_add(properties, "{ss}", "editable", BOOL2STRING(context->editable));
-       g_variant_builder_add(properties, "{ss}", "default_internet_conn", BOOL2STRING(context->is_default));
-       g_variant_builder_add(properties, "{ss}", "profile_enable", BOOL2STRING(context->profile_enable));
-
-       /* Freeing locally allocated memory */
-       g_free(s_authtype);
-       g_free(s_role);
-       g_free(s_type);
-       g_free(s_roam_pdp_type);
-       g_free(apn);
-       g_free(username);
-       g_free(password);
-       g_free(proxy_addr);
-       g_free(home_url);
-       g_free(profile_name);
-
-       ps_dbg_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "Exiting");
-
-       return g_variant_builder_end(properties);
-}
-
-static gboolean __ps_context_set_default_connection_enable(gpointer object, gboolean enabled)
-{
-       ps_context_t *context = object;
-
        g_return_val_if_fail(context != NULL, FALSE);
-
        context->is_default = enabled;
        return TRUE;
 }
 
-static gpointer __ps_context_add_context(gpointer modem, gchar *mccmnc, int profile_id)
+static gpointer __ps_context_add_context(ps_modem_t *modem, gchar *mccmnc, int profile_id)
 {
        gpointer handle;
        GHashTable *in_param, *out_param;
        char szQuery[5000];
        gboolean rv = FALSE;
 
-       ps_modem_t *mdm = modem;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(mdm);
        GDBusConnection *conn = NULL;
        TcorePlugin *p = NULL;
        gchar *path = NULL;
 
        GHashTableIter iter;
-       gpointer object = NULL;
+       ps_context_t *context = NULL;
        gpointer key, value;
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(mdm->cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
-               ps_err_ex_co(co_modem, "Failed to get Storage handle");
+       handle = _ps_context_create_database_handle(modem->cp_name);
+       if (!handle) {
+               ps_err_ex_modem(modem, "Failed to get Storage handle");
                return NULL;
        }
 
@@ -1774,7 +1440,7 @@ static gpointer __ps_context_add_context(gpointer modem, gchar *mccmnc, int prof
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               "select \
+                "select \
                 a.network_info_id, a.network_name, a.mccmnc, \
                 b.profile_id, b.profile_name, b.apn, \
                 b.auth_type, b.auth_id, b.auth_pwd, \
@@ -1786,21 +1452,21 @@ static gpointer __ps_context_add_context(gpointer modem, gchar *mccmnc, int prof
                 where b.profile_id = ? and a.network_info_id = b.network_info_id ");
 
        rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, &out_param, 27);
-       ps_info_ex_co(co_modem, "Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       ps_info_ex_modem(modem, "Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
 
-       ps_info_ex_co(co_modem, "Create profile by Profile ID: [%d]", profile_id);
+       ps_info_ex_modem(modem, "Create profile by Profile ID: [%d]", profile_id);
        conn = _ps_modem_ref_dbusconn(modem);
        p = _ps_modem_ref_plugin(modem);
 
        g_hash_table_iter_init(&iter, out_param);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
                /* Create context */
-               object = __ps_context_create_context(conn, p, mccmnc, (GHashTable *)value, mdm->cp_name);
-               path = _ps_context_ref_path(object);
+               context = __ps_context_create_context(conn, p, mccmnc, (GHashTable *)value, modem->cp_name);
+               path = _ps_context_ref_path(context);
 
                /* Insert to contexts */
-               mdm->contexts = g_slist_append(mdm->contexts, object);
-               ps_dbg_ex_co(co_modem, "context (%p, %s) insert to hash", object, path);
+               modem->contexts = g_slist_append(modem->contexts, context);
+               ps_dbg_ex_modem(modem, "context (%p, %s) insert to hash", context, path);
        }
 
        /* Free resources */
@@ -1810,10 +1476,10 @@ static gpointer __ps_context_add_context(gpointer modem, gchar *mccmnc, int prof
        /* De-initialize Storage */
        tcore_storage_remove_handle(strg_db, handle);
 
-       return object;
+       return context;
 }
 
-gboolean _ps_context_check_is_roaming_apn_support(gchar* mccmnc, gchar* cp_name)
+gboolean _ps_context_check_is_roaming_apn_support(gchar *mccmnc, gchar *cp_name)
 {
        gpointer handle;
        GHashTable *in_param, *out_param;
@@ -1822,12 +1488,8 @@ gboolean _ps_context_check_is_roaming_apn_support(gchar* mccmnc, gchar* cp_name)
        guint profile_cnt;
        int network_info_id = -1;
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
                err("[%s] Failed to get Storage handle", cp_name);
                return ret;
        }
@@ -1850,7 +1512,7 @@ gboolean _ps_context_check_is_roaming_apn_support(gchar* mccmnc, gchar* cp_name)
 
        profile_cnt = g_hash_table_size(out_param);
        if (profile_cnt > 0) {
-               info("[%s] roaming profiles for (mccmnc: %s [%d]) exists: count[%d]", cp_name, mccmnc, network_info_id,  profile_cnt);
+               info("[%s] roaming profiles for (mccmnc: %s [%d]) exists: count[%d]", cp_name, mccmnc, network_info_id, profile_cnt);
                ret = TRUE;
        }
        /* Free resources */
@@ -1862,7 +1524,7 @@ gboolean _ps_context_check_is_roaming_apn_support(gchar* mccmnc, gchar* cp_name)
        return ret;
 }
 
-gboolean _ps_context_initialize(gpointer plugin)
+gboolean _ps_context_initialize(TcorePlugin *plugin)
 {
        gboolean rv = TRUE;
 
@@ -1878,12 +1540,8 @@ gboolean _ps_context_reset_profile_table(gchar *cp_name)
        char szQuery[1000];
        gboolean rv = FALSE;
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
                err("[%s] Failed to get Storage handle", cp_name);
                return rv;
        }
@@ -1913,7 +1571,7 @@ gboolean _ps_context_fill_profile_table_from_ini_file(gchar *cp_name)
        else
                dic = iniparser_load("/opt/system/csc-default/data/csc-default-data-connection.ini");
 
-       if (dic == NULL) {
+       if (!dic) {
                err("[%s] fail to load the csc default file", cp_name);
                return FALSE;
        }
@@ -1955,7 +1613,7 @@ gboolean _ps_context_fill_profile_table_from_ini_file(gchar *cp_name)
        return TRUE;
 }
 
-GSList* _ps_context_create_hashtable(gpointer modem, gboolean roaming)
+GSList *_ps_context_create_hashtable(ps_modem_t *modem, gboolean roaming)
 {
        gpointer handle;
        GHashTable *in_param;
@@ -1965,36 +1623,29 @@ GSList* _ps_context_create_hashtable(gpointer modem, gboolean roaming)
        int retry = 1;
        unsigned int index;
 
-       ps_modem_t *mdm = modem;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(mdm);
-
-       /* Initialize Storage */
-       if (g_str_has_suffix(mdm->cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
-               ps_err_ex_co(co_modem, "Failed to get Storage handle");
+       handle = _ps_context_create_database_handle(modem->cp_name);
+       if (!handle) {
+               ps_err_ex_modem(modem, "Failed to get Storage handle");
                return NULL;
        }
 
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
 
        /* Check/Store roaming APN support at every SIM init complete. */
-       roaming_apn = _ps_context_check_is_roaming_apn_support(mdm->operator, mdm->cp_name);
+       roaming_apn = _ps_context_check_is_roaming_apn_support(modem->operator, modem->cp_name);
        _ps_modem_set_roaming_apn_support(modem, roaming_apn);
 
-       if(roaming) {
+       if (roaming) {
                /* Check roaming APN support first in the Roaming network. */
-               ps_warn_ex_co(co_modem, "Roaming Network[%s], Roaming APN Support[%s]",
-                       roaming ? "TRUE" : "FALSE", roaming_apn ? "TRUE" : "FALSE");
+               ps_warn_ex_modem(modem, "Roaming Network[%s], Roaming APN Support[%s]",
+                                roaming ? "TRUE" : "FALSE", roaming_apn ? "TRUE" : "FALSE");
                roaming = roaming_apn;
        }
-       ps_info_ex_co(co_modem, "create profile by mccmnc (%s)", mdm->operator);
+       ps_info_ex_modem(modem, "create profile by mccmnc (%s)", modem->operator);
 
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
-               "select \
+                "select \
                 a.network_info_id, a.network_name, a.mccmnc, \
                 b.profile_id, b.profile_name, b.apn, \
                 b.auth_type, b.auth_id, b.auth_pwd, \
@@ -2005,35 +1656,35 @@ GSList* _ps_context_create_hashtable(gpointer modem, gboolean roaming)
                 from network_info a, pdp_profile b \
                 where a.mccmnc = ? and b.is_roaming_apn = ? and a.network_info_id = b.network_info_id ");
 
-       g_hash_table_insert(in_param, "1", g_strdup(mdm->operator));
+       g_hash_table_insert(in_param, "1", g_strdup(modem->operator));
        g_hash_table_insert(in_param, "2", g_strdup_printf("%d", roaming));
 
        for (retry = 0; retry < 5; retry++) {
-               ps_dbg_ex_co(co_modem, "Reading database", mdm->operator);
+               ps_dbg_ex_modem(modem, "Reading database", modem->operator);
                rv = tcore_storage_read_query_database_in_order(strg_db, handle, szQuery, in_param, &out_param, 27);
                if (rv != FALSE)
                        break;
        }
-       ps_info_ex_co(co_modem, "Read Database: [%s], Retry[%d]", (rv == TRUE ? "SUCCESS" : "FAIL"), retry);
+       ps_info_ex_modem(modem, "Read Database: [%s], Retry[%d]", (rv == TRUE ? "SUCCESS" : "FAIL"), retry);
 
        for (index = 0; index < g_slist_length(out_param); index++) {
                gchar *path = NULL;
-               gpointer object = NULL;
+               ps_context_t *context = NULL;
                GHashTable *value = NULL;
 
                value = g_slist_nth_data(out_param, index);
-               if(value == NULL)
+               if (!value)
                        continue;
                /* Create new 'context' */
-               object = __ps_context_create_context(mdm->conn, mdm->plg, mdm->operator, value, mdm->cp_name);
-               path = _ps_context_ref_path(object);
+               context = __ps_context_create_context(modem->conn, modem->plg, modem->operator, value, modem->cp_name);
+               path = _ps_context_ref_path(context);
 
-               mdm->contexts = g_slist_append(mdm->contexts, object);
-               ps_dbg_ex_co(co_modem, "context (%p, %s) insert to linked-list", object, path);
+               modem->contexts = g_slist_append(modem->contexts, context);
+               ps_dbg_ex_modem(modem, "context (%p, %s) insert to linked-list", context, path);
        }
 #ifdef TIZEN_SUPPORT_VOLTE
        /* Update Attach APN here. */
-       __ps_context_update_attach_apn(mdm->contexts, mdm->operator);
+       _ps_context_update_attach_apn(modem->contexts, modem->operator);
 #endif
        g_hash_table_destroy(in_param);
        g_slist_free_full(out_param, (GDestroyNotify)g_hash_table_destroy);
@@ -2041,30 +1692,28 @@ GSList* _ps_context_create_hashtable(gpointer modem, gboolean roaming)
        /* De-initialize Storage */
        tcore_storage_remove_handle(strg_db, handle);
 
-       ps_dbg_ex_co(co_modem, "Exiting");
-       return mdm->contexts;
+       ps_dbg_ex_modem(modem, "Exiting");
+       return modem->contexts;
 }
 
-gboolean _ps_context_add_context(gpointer modem, gchar *operator, GHashTable *property)
+gboolean _ps_context_add_context(ps_modem_t *modem, gchar *operator, GHashTable *property)
 {
        GHashTable *services = NULL;
-       gpointer context = NULL;
-       ps_modem_t *mdm = modem;
-
+       ps_context_t *context = NULL;
        GHashTableIter iter;
        gpointer key, value;
        int network_id = 0;
        int profile_id = 0;
 
-       network_id = __ps_context_get_network_id(operator, mdm->cp_name);
+       network_id = __ps_context_get_network_id(operator, modem->cp_name);
        if (network_id <= 0) {
-               ps_err_ex_co(_ps_modem_ref_co_modem(mdm), "fail to add network info");
+               ps_err_ex_modem(modem, "fail to add network info");
                return FALSE;
        }
 
-       profile_id = __ps_context_insert_profile_to_database(property, network_id, mdm->cp_name);
+       profile_id = __ps_context_insert_profile_to_database(property, network_id, modem->cp_name);
        if (profile_id <= 0) {
-               ps_err_ex_co(_ps_modem_ref_co_modem(mdm), "fail to insert profile info to database");
+               ps_err_ex_modem(modem, "fail to insert profile info to database");
                return FALSE;
        }
 
@@ -2077,44 +1726,46 @@ gboolean _ps_context_add_context(gpointer modem, gchar *operator, GHashTable *pr
                return FALSE;
 
        g_hash_table_iter_init(&iter, services);
-       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE)
-               _ps_service_ref_context(value, context);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               ps_service_t *service = value;
+               _ps_service_ref_context(service, context);
+       }
 
        return TRUE;
 }
 
-gboolean _ps_context_get_properties_handler(gpointer object, GVariantBuilder *properties)
+gboolean _ps_context_get_properties_handler(ps_context_t *context, GVariantBuilder *properties)
 {
        int context_state = 0;
        gboolean active = FALSE;
-       ps_context_t *context = object;
        char *dev_name = NULL;
        char *proxy = NULL;
        char *ipv4_address, *ipv4_gateway, *ipv4_dns1, *ipv4_dns2;
        char *ipv6_address, *ipv6_gateway, *ipv6_dns1, *ipv6_dns2;
+       CoreObject *co_context = _ps_context_ref_co_context(context);
 
        g_return_val_if_fail(context != NULL, FALSE);
        g_return_val_if_fail(properties != NULL, FALSE);
 
-       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "get context properties");
-       context_state =    tcore_context_get_state(context->co_context);
+       ps_info_ex_ctx(context, "get context properties");
+       context_state = tcore_context_get_state(co_context);
        if (context_state == CONTEXT_STATE_ACTIVATED)
                active = TRUE;
 
        /* IPV4 data */
-       ipv4_address = tcore_context_get_ipv4_addr(context->co_context);
-       ipv4_gateway = tcore_context_get_ipv4_gw(context->co_context);
-       ipv4_dns1 = tcore_context_get_ipv4_dns1(context->co_context);
-       ipv4_dns2 = tcore_context_get_ipv4_dns2(context->co_context);
+       ipv4_address = tcore_context_get_ipv4_addr(co_context);
+       ipv4_gateway = tcore_context_get_ipv4_gw(co_context);
+       ipv4_dns1 = tcore_context_get_ipv4_dns1(co_context);
+       ipv4_dns2 = tcore_context_get_ipv4_dns2(co_context);
 
        /* IPV6 data */
-       ipv6_address = tcore_context_get_ipv6_addr(context->co_context);
-       ipv6_gateway = tcore_context_get_ipv6_gw(context->co_context);
-       ipv6_dns1 = tcore_context_get_ipv6_dns1(context->co_context);
-       ipv6_dns2 = tcore_context_get_ipv6_dns2(context->co_context);
+       ipv6_address = tcore_context_get_ipv6_addr(co_context);
+       ipv6_gateway = tcore_context_get_ipv6_gw(co_context);
+       ipv6_dns1 = tcore_context_get_ipv6_dns1(co_context);
+       ipv6_dns2 = tcore_context_get_ipv6_dns2(co_context);
 
-       proxy = tcore_context_get_proxy(context->co_context);
-       dev_name = tcore_context_get_ipv4_devname(context->co_context);
+       proxy = tcore_context_get_proxy(co_context);
+       dev_name = tcore_context_get_ipv4_devname(co_context);
 
        g_variant_builder_open(properties, G_VARIANT_TYPE("a{ss}"));
 
@@ -2136,13 +1787,13 @@ gboolean _ps_context_get_properties_handler(gpointer object, GVariantBuilder *pr
 
        /* Adding IPV6 data to builder */
        g_variant_builder_add(properties, "{ss}", "ipv6_address",
-               (ipv6_address == NULL ? "::" : ipv6_address));
+                             (ipv6_address == NULL ? "::" : ipv6_address));
        g_variant_builder_add(properties, "{ss}", "ipv6_gateway",
-               (ipv6_gateway == NULL ? "::" : ipv6_gateway));
+                             (ipv6_gateway == NULL ? "::" : ipv6_gateway));
        g_variant_builder_add(properties, "{ss}", "ipv6_dns1",
-               (ipv6_dns1 == NULL ? "::" : ipv6_dns1));
+                             (ipv6_dns1 == NULL ? "::" : ipv6_dns1));
        g_variant_builder_add(properties, "{ss}", "ipv6_dns2",
-               (ipv6_dns2 == NULL ? "::" : ipv6_dns2));
+                             (ipv6_dns2 == NULL ? "::" : ipv6_dns2));
 
        if (proxy)
                g_variant_builder_add(properties, "{ss}", "proxy", proxy);
@@ -2165,65 +1816,62 @@ gboolean _ps_context_get_properties_handler(gpointer object, GVariantBuilder *pr
        g_free(proxy);
        g_free(dev_name);
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "Exiting");
+       ps_dbg_ex_ctx(context, "Exiting");
        return TRUE;
 }
 
 
-GVariant *_ps_context_get_properties(gpointer object, GVariantBuilder *properties)
+GVariant *_ps_context_get_properties(ps_context_t *context, GVariantBuilder *properties)
 {
        int context_state = 0;
        gboolean active = FALSE;
-       ps_context_t *context = object;
        char *dev_name = NULL;
        char *proxy = NULL;
        char *ipv4_address, *ipv4_gateway, *ipv4_dns1, *ipv4_dns2;
        char *ipv6_address, *ipv6_gateway, *ipv6_dns1, *ipv6_dns2;
        pcscf_addr *pcscf_ipv4, *pcscf_ipv6;
        unsigned int i;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
+       CoreObject *co_context;
 
        g_return_val_if_fail(context != NULL, NULL);
        g_return_val_if_fail(properties != NULL, NULL);
 
-       ps_info_ex_co(co_network, "get context properties");
+       ps_info_ex_ctx(context, "get context properties");
 
-       context_state =    tcore_context_get_state(context->co_context);
+       co_context = _ps_context_ref_co_context(context);
+       context_state = tcore_context_get_state(co_context);
        if (context_state == CONTEXT_STATE_ACTIVATED)
                active = TRUE;
 
        active &= context->b_active;
 
        /* IPV4 data */
-       ipv4_address = tcore_context_get_ipv4_addr(context->co_context);
-       ipv4_gateway = tcore_context_get_ipv4_gw(context->co_context);
-       ipv4_dns1 = tcore_context_get_ipv4_dns1(context->co_context);
-       ipv4_dns2 = tcore_context_get_ipv4_dns2(context->co_context);
+       ipv4_address = tcore_context_get_ipv4_addr(co_context);
+       ipv4_gateway = tcore_context_get_ipv4_gw(co_context);
+       ipv4_dns1 = tcore_context_get_ipv4_dns1(co_context);
+       ipv4_dns2 = tcore_context_get_ipv4_dns2(co_context);
 
        /* IPV6 data */
-       ipv6_address = tcore_context_get_ipv6_addr(context->co_context);
-       ipv6_gateway = tcore_context_get_ipv6_gw(context->co_context);
-       ipv6_dns1 = tcore_context_get_ipv6_dns1(context->co_context);
-       ipv6_dns2 = tcore_context_get_ipv6_dns2(context->co_context);
+       ipv6_address = tcore_context_get_ipv6_addr(co_context);
+       ipv6_gateway = tcore_context_get_ipv6_gw(co_context);
+       ipv6_dns1 = tcore_context_get_ipv6_dns1(co_context);
+       ipv6_dns2 = tcore_context_get_ipv6_dns2(co_context);
 
        /* P-CSCF data */
-       pcscf_ipv4 = tcore_context_get_pcscf_ipv4_addr(context->co_context);
-       pcscf_ipv6 = tcore_context_get_pcscf_ipv6_addr(context->co_context);
+       pcscf_ipv4 = tcore_context_get_pcscf_ipv4_addr(co_context);
+       pcscf_ipv6 = tcore_context_get_pcscf_ipv6_addr(co_context);
 
-       proxy = tcore_context_get_proxy(context->co_context);
-       dev_name = tcore_context_get_ipv4_devname(context->co_context);
+       proxy = tcore_context_get_proxy(co_context);
+       dev_name = tcore_context_get_ipv4_devname(co_context);
 
-       ps_info_ex_co(co_network, "ipv4_address[%s] ipv4_gateway[%s] ipv4_dns1[%s] ipv4_dns2[%s]",
-               ipv4_address, ipv4_gateway, ipv4_dns1, ipv4_dns2);
+       ps_dbg_ex_ctx(context, "ipv4_address[%s] ipv4_gateway[%s] ipv4_dns1[%s] ipv4_dns2[%s]",
+                     ipv4_address, ipv4_gateway, ipv4_dns1, ipv4_dns2);
 
-       ps_info_ex_co(co_network, "ipv6_address[%s] ipv6_gateway[%s] ipv6_dns1[%s] ipv6_dns2[%s]",
-               ipv6_address, ipv6_gateway, ipv6_dns1, ipv6_dns2);
+       ps_dbg_ex_ctx(context, "ipv6_address[%s] ipv6_gateway[%s] ipv6_dns1[%s] ipv6_dns2[%s]",
+                     ipv6_address, ipv6_gateway, ipv6_dns1, ipv6_dns2);
 
        g_variant_builder_init(properties, G_VARIANT_TYPE("a{ss}"));
 
-       ps_info_ex_co(co_network, "path[%s]",
-               context->path);
-
        g_variant_builder_add(properties, "{ss}", "path", (context->path));
        g_variant_builder_add(properties, "{ss}", "active", (BOOL2STRING(active)));
        g_variant_builder_add(properties, "{ss}", "routing_only", (BOOL2STRING(context->b_routing_only)));
@@ -2243,13 +1891,13 @@ GVariant *_ps_context_get_properties(gpointer object, GVariantBuilder *propertie
 
        /* Adding IPV6 data to builder */
        g_variant_builder_add(properties, "{ss}", "ipv6_address",
-               (ipv6_address == NULL ? "::" : ipv6_address));
+                             (ipv6_address == NULL ? "::" : ipv6_address));
        g_variant_builder_add(properties, "{ss}", "ipv6_gateway",
-               (ipv6_gateway == NULL ? "::" : ipv6_gateway));
+                             (ipv6_gateway == NULL ? "::" : ipv6_gateway));
        g_variant_builder_add(properties, "{ss}", "ipv6_dns1",
-               (ipv6_dns1 == NULL ? "::" : ipv6_dns1));
+                             (ipv6_dns1 == NULL ? "::" : ipv6_dns1));
        g_variant_builder_add(properties, "{ss}", "ipv6_dns2",
-               (ipv6_dns2 == NULL ? "::" : ipv6_dns2));
+                             (ipv6_dns2 == NULL ? "::" : ipv6_dns2));
 
        if (ipv6_address) {
                gboolean ipv6_link_only = FALSE;
@@ -2271,10 +1919,10 @@ GVariant *_ps_context_get_properties(gpointer object, GVariantBuilder *propertie
                g_variant_builder_add(properties, "{ss}", "pcscf_ipv4_count", buf);
                g_free(buf);
 
-               ps_info_ex_co(co_network, "pcscf_ipv4_count[%d]", pcscf_ipv4->count);
+               ps_info_ex_ctx(context, "pcscf_ipv4_count[%d]", pcscf_ipv4->count);
                for (i = 0; i < pcscf_ipv4->count; i++) {
                        buf = g_strdup_printf("%s_%d", "pcscf_ipv4_addr", i);
-                       ps_info_ex_co(co_network, "pcscf_ipv4_addr[%d] - %s", i, pcscf_ipv4->addr[i]);
+                       ps_info_ex_ctx(context, "pcscf_ipv4_addr[%d] - %s", i, pcscf_ipv4->addr[i]);
                        g_variant_builder_add(properties, "{ss}", buf, pcscf_ipv4->addr[i]);
                        g_free(buf);
                }
@@ -2285,14 +1933,18 @@ GVariant *_ps_context_get_properties(gpointer object, GVariantBuilder *propertie
 
        if (pcscf_ipv6) {
                char *buf;
+               gchar addr_buf[IP_LEN] = { 0, }, addr_secure[IP_LEN] = { 0, };
 
                buf = g_strdup_printf("%d", pcscf_ipv6->count);
                g_variant_builder_add(properties, "{ss}", "pcscf_ipv6_count", buf);
                g_free(buf);
-               ps_info_ex_co(co_network, "pcscf_ipv6_count[%d]", pcscf_ipv6->count);
+               ps_info_ex_ctx(context, "pcscf_ipv6_count[%d]", pcscf_ipv6->count);
                for (i = 0; i < pcscf_ipv6->count; i++) {
                        buf = g_strdup_printf("%s_%d", "pcscf_ipv6_addr", i);
-                       ps_info_ex_co(co_network, "pcscf_ipv6_addr[%d] - %s", i, pcscf_ipv6->addr[i]);
+                       memset(addr_buf, 0, IP_LEN);
+                       g_strlcpy(addr_buf, pcscf_ipv6->addr[i], IP_LEN);
+                       //tcore_util_convert_ipv6_secure_log(addr_buf, addr_secure, IP_LEN);
+                       ps_info_ex_ctx(context, "pcscf_ipv6_addr[%d] - %s", i, addr_secure);
                        g_variant_builder_add(properties, "{ss}", buf, pcscf_ipv6->addr[i]);
                        g_free(buf);
                }
@@ -2325,20 +1977,20 @@ GVariant *_ps_context_get_properties(gpointer object, GVariantBuilder *propertie
        g_free(proxy);
        g_free(dev_name);
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "Exiting");
+       ps_dbg_ex_ctx(context, "Exiting");
        return g_variant_builder_end(properties);
 }
 
-gboolean _ps_context_set_alwayson_enable(gpointer object, gboolean enabled)
+gboolean _ps_context_set_alwayson_enable(ps_context_t *context, gboolean enabled)
 {
-       ps_context_t *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->is_default) || role == CONTEXT_ROLE_INTERNET)
+       role = tcore_context_get_role(_ps_context_ref_co_context(context));
+       if (((role == CONTEXT_ROLE_INTERNET) && context->is_default)
+           || role == CONTEXT_ROLE_INTERNET) {
                context->alwayson = enabled;
+       }
 
 #ifdef PREPAID_SIM_APN_SUPPORT
        if ((role == CONTEXT_ROLE_PREPAID_INTERNET) && context->is_default)
@@ -2348,87 +2000,72 @@ gboolean _ps_context_set_alwayson_enable(gpointer object, gboolean enabled)
        return TRUE;
 }
 
-gboolean _ps_context_get_default_context(gpointer object, int svc_cat_id)
+gboolean _ps_context_get_default_context(ps_context_t *context, int svc_cat_id)
 {
-       ps_context_t *context = object;
        int role = CONTEXT_ROLE_UNKNOWN;
        g_return_val_if_fail(context != NULL, FALSE);
 
-       role = tcore_context_get_role(context->co_context);
+       role = tcore_context_get_role(_ps_context_ref_co_context(context));
        if (role == svc_cat_id && context->is_default)
                return TRUE;
 
        return FALSE;
 }
 
-gboolean _ps_context_set_service(gpointer object, gpointer service)
+gboolean _ps_context_set_service(ps_context_t *context, ps_service_t *service)
 {
-       ps_context_t *context = object;
        g_return_val_if_fail(context != NULL, FALSE);
-
        context->p_service = service;
        return TRUE;
 }
 
-gpointer _ps_context_ref_service(gpointer object)
+ps_service_t *_ps_context_ref_service(ps_context_t *context)
 {
-       ps_context_t *context = object;
        g_return_val_if_fail(context != NULL, NULL);
-
        return context->p_service;
 }
 
-gchar *_ps_context_ref_path(gpointer object)
+gchar *_ps_context_ref_path(ps_context_t *context)
 {
-       ps_context_t *context = object;
        g_return_val_if_fail(context != NULL, NULL);
-
        return context->path;
 }
 
-gboolean _ps_context_get_alwayson_enable(gpointer object)
+gboolean _ps_context_get_alwayson_enable(ps_context_t *context)
 {
-       ps_context_t *context = object;
        g_return_val_if_fail(context != NULL, FALSE);
-       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context (%p) alwayson (%d)", context, context->alwayson);
+       ps_info_ex_ctx(context, "context (%p) alwayson (%d)", context, context->alwayson);
        return context->alwayson;
 }
 
-#ifdef PREPAID_SIM_APN_SUPPORT
-gboolean _ps_context_get_prepaid_alwayson_enable(gpointer object)
+gboolean _ps_context_get_prepaid_alwayson_enable(ps_context_t *context)
 {
-       ps_context_t *context = object;
        g_return_val_if_fail(context != NULL, FALSE);
-       dbg("prepaid context (%p) alwayson (%d)",
-               context, context->prepaid_alwayson);
+       dbg("prepaid context (%p) alwayson (%d)", context, context->prepaid_alwayson);
        return context->prepaid_alwayson;
 }
 
-int _ps_context_get_profile_id(gpointer object)
+int _ps_context_get_profile_id(ps_context_t *context)
 {
-       ps_context_t *context = object;
        g_return_val_if_fail(context != NULL, -1);
        dbg("profile_id[%d]", context->profile_id);
        return context->profile_id;
 }
-#endif
 
-gpointer _ps_context_ref_co_context(gpointer object)
+CoreObject *_ps_context_ref_co_context(ps_context_t *context)
 {
-       ps_context_t *context = object;
        g_return_val_if_fail(context != NULL, NULL);
-
        return context->co_context;
 }
 
-gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
+gboolean _ps_context_set_connected(ps_context_t *context, gboolean enabled)
 {
        gchar *ipv4 = NULL;
        gchar *ipv6 = NULL;
-       ps_context_t *context = object;
-       Storage *strg_vconf = NULL;
-       ps_modem_t *p_modem = NULL;
-       CoreObject *co_network = NULL;
+       ps_master_t *master = NULL;
+       ps_modem_t *modem = NULL;
+       ps_service_t *service = NULL;
+       CoreObject *co_context = NULL;
 
        gboolean b_roaming_checker = TRUE;
        gboolean data_allowed = FALSE;
@@ -2437,17 +2074,18 @@ gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
 
        enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
 
-       dbg("Entry [enabled :%d]", enabled);
-
+       dbg("enabled :%d", enabled);
        g_return_val_if_fail(context != NULL, FALSE);
 
-       co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
-       strg_vconf = tcore_server_find_storage(tcore_plugin_ref_server(context->plg), "vconf");
-       data_allowed = tcore_storage_get_bool(strg_vconf, STORAGE_KEY_3G_ENABLE);
-       ipv4 = tcore_context_get_ipv4_addr(context->co_context);
-       ipv6 = tcore_context_get_ipv6_addr(context->co_context);
-       role = tcore_context_get_role(context->co_context);
-       p_modem = _ps_service_ref_modem(context->p_service);
+       service = _ps_context_ref_service(context);
+       modem = _ps_service_ref_modem(service);
+       master = _ps_modem_ref_master(modem);
+       data_allowed = _ps_master_get_storage_value_bool(master, STORAGE_KEY_3G_ENABLE);
+       co_context = _ps_context_ref_co_context(context);
+       ipv4 = tcore_context_get_ipv4_addr(co_context);
+       ipv6 = tcore_context_get_ipv6_addr(co_context);
+       role = tcore_context_get_role(co_context);
+
 
        if (role == CONTEXT_ROLE_MMS || role == CONTEXT_ROLE_PREPAID_MMS)
                b_mms_checker = TRUE;
@@ -2456,32 +2094,32 @@ gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
                b_ims_checker = TRUE;
 
 #if !defined(TIZEN_SUPPORT_MMS_CONNECT_FORCE)
-               ps_dbg_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "csc runtime feature disabled");
+               ps_dbg_ex_ctx(context, "csc runtime feature disabled");
                b_mms_checker = FALSE;
 #endif
 
        context->b_active = enabled;
-       if (!b_ims_checker && (_ps_modem_get_roaming(p_modem)) && !(_ps_modem_get_data_roaming_allowed(p_modem))) {
-               ps_info_ex_co(co_network, "roaming network is not allowed");
+       if (!b_ims_checker && (_ps_modem_get_roaming(modem)) && !(_ps_modem_get_data_roaming_allowed(modem))) {
+               ps_info_ex_ctx(context, "roaming network is not allowed");
                b_roaming_checker = FALSE;
        }
 
        if (enabled) {
                gint ps_mode = 0;
 
-               tcore_context_set_state(context->co_context, CONTEXT_STATE_ACTIVATED);
+               tcore_context_set_state(co_context, CONTEXT_STATE_ACTIVATED);
 
                if (context->deact_required == TRUE) {
-                       ps_info_ex_co(co_network, "Deactivation is required for context(%p)", context);
-                       _ps_service_deactivate_context(context->p_service, context);
+                       ps_dbg_ex_ctx(context, "Deactivation is required for context(%p)", context);
+                       _ps_service_deactivate_context(service, context);
                        context->deact_required = FALSE;
                        goto EXIT;
                }
 
                if (ipv4) {
                        if ((g_str_equal(ipv4, "0.0.0.0") == TRUE) && (ipv6 == NULL)) {
-                               ps_warn_ex_co(co_network, "ip address is NULL");
-                               _ps_service_deactivate_context(context->p_service, context);
+                               ps_warn_ex_ctx(context, "ip address is NULL");
+                               _ps_service_deactivate_context(service, context);
                                goto EXIT;
                        }
                }
@@ -2490,46 +2128,52 @@ gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
                /* In case of PDP is disconnected by network in UPS mode.
                 * default internet PDP could be activated if LCD was on at trigger time.
                 */
-               ps_mode = _ps_modem_get_psmode(p_modem);
+               ps_mode = _ps_modem_get_psmode(modem);
                if (ps_mode > POWER_SAVING_MODE_NORMAL && ps_mode < POWER_SAVING_MODE_WEARABLE) {
-                       gint pm_state = tcore_storage_get_int(strg_vconf, STORAGE_KEY_PM_STATE);
-                       ps_info_ex_co(co_network, "ps_mode: %d", ps_mode);
+                       gint pm_state = _ps_master_get_storage_value_int(master, STORAGE_KEY_PM_STATE);
+                       ps_info_ex_ctx(context, "ps_mode: %d", ps_mode);
                        if (pm_state == 3 && _ps_context_get_default_context(context, CONTEXT_ROLE_INTERNET)) {
-                               char *devname = tcore_context_get_ipv4_devname(context->co_context);
+                               char *devname = tcore_context_get_ipv4_devname(co_context);
                                if (TCORE_RETURN_SUCCESS != tcore_util_netif_down(devname))
-                                       ps_err_ex_co(co_network, "Failed to bring up interface");
+                                       ps_err_ex_ctx(context, "Failed to bring up interface");
 
-                               ps_warn_ex_co(co_network, "[EXCEPTION] do not emit signal for PDP activation.");
+                               ps_warn_ex_ctx(context, "[EXCEPTION] do not emit signal for PDP activation.");
                                context->b_notify = TRUE;
+                               g_free(devname);
                                goto EXIT;
                        }
                }
 
                if (b_roaming_checker && (data_allowed || b_mms_checker || b_ims_checker))
-                       __ps_context_emit_property_changed_signal(context);
+                       ps_context_emit_property_changed_signal(context);
        } else {
                if (context->deact_required == TRUE) {
-                       ps_info_ex_co(co_network, "set deact_required flag of context(%p) to FALSE", context);
+                       ps_dbg_ex_ctx(context, "set deact_required flag of context(%p) to FALSE", context);
                        context->deact_required = FALSE;
                }
-               tcore_context_set_state(context->co_context, CONTEXT_STATE_DEACTIVATED);
-               tcore_context_reset_devinfo(context->co_context);
-               __ps_context_emit_property_changed_signal(context);
+               tcore_context_set_state(co_context, CONTEXT_STATE_DEACTIVATED);
+               if ((_ps_service_get_epdg_status(_ps_context_ref_service(context)) == TRUE)
+                   && (tcore_context_get_role(co_context) == CONTEXT_ROLE_IMS)) {
+                       ps_info_ex_ctx(context, "Do NOT reset devinfo for IMS PDN as ePDG is available");
+
+               } else {
+                       tcore_context_reset_devinfo(co_context);
+               }
+
+               ps_context_emit_property_changed_signal(context);
                if (context->remove_profile_required == TRUE) {
-                       ps_service_t *service = _ps_context_ref_service(context);
-                       CoreObject *co_context = _ps_context_ref_co_context(context);
                        gboolean attach_apn = tcore_context_get_attach_apn(co_context);
 
-                       ps_info_ex_co(co_network, "set remove_profile_required flag of context(%p) to FALSE", context);
+                       ps_info_ex_ctx(context, "set remove_profile_required flag of context(%p) to FALSE", context);
                        context->remove_profile_required = FALSE;
-                       __ps_context_remove_database(context);
+                       _ps_context_remove_database(context);
 
                        /* Send remove profile response */
-                       packet_service_context_complete_remove_profile(context->remove_profile_cb_data->obj_context, context->remove_profile_cb_data->invocation, TRUE);
+                       ps_service_complete_remove_profile(context, TRUE);
                        g_free(context->remove_profile_cb_data);
                        context->remove_profile_cb_data = NULL;
 
-                       if (service == NULL) {
+                       if (!service) {
                                err("service is NULL");
                                goto EXIT;
                        }
@@ -2540,10 +2184,10 @@ gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
 
                        /* Update Attach APN required. */
                        if (attach_apn)
-                               __ps_context_update_attach_apn(service->contexts, p_modem->operator);
+                               _ps_context_update_attach_apn(service->contexts, _ps_modem_ref_operator(modem));
                }
        }
-EXIT:
+ EXIT:
        if (ipv4)
                free(ipv4);
 
@@ -2552,105 +2196,87 @@ EXIT:
        return TRUE;
 }
 
-gboolean _ps_context_set_profile_enable(gpointer object, gboolean value)
+gboolean _ps_context_set_profile_enable(ps_context_t *context, gboolean value)
 {
-       ps_context_t *context = object;
-
-       dbg("Entry [value :%d]", value);
-
        g_return_val_if_fail(context != NULL, FALSE);
 
        if (context->profile_enable != value) {
                context->profile_enable = value;
                info("context(%p) profile_enable(%d)", context, context->profile_enable);
        }
+       tcore_context_set_disable_apn(_ps_context_ref_co_context(context), !value);
        return TRUE;
 }
 
-gboolean _ps_context_get_profile_enable(gpointer object)
+gboolean _ps_context_get_profile_enable(ps_context_t *context)
 {
-       ps_context_t *context = object;
-
-       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context(%p), profile_enable(%d)", context, context->profile_enable);
-
+       ps_info_ex_ctx(context, "context(%p), profile_enable(%d)", context, context->profile_enable);
        return context->profile_enable;
 }
 
-gboolean _ps_context_set_ps_defined(gpointer object, gboolean value)
+gboolean _ps_context_set_ps_defined(ps_context_t *context, gboolean value)
 {
-       ps_context_t *context = (ps_context_t *)object;
-
        dbg("Entry [value :%d]", value);
-
        g_return_val_if_fail(context != NULL, FALSE);
 
        if (context->ps_defined != value) {
                context->ps_defined = value;
-               ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context(%p) ps_defined(%d)", context, context->ps_defined);
+               ps_info_ex_ctx(context, "context(%p) ps_defined(%d)", context, context->ps_defined);
        }
        return TRUE;
 }
 
-gboolean _ps_context_get_ps_defined(gpointer object)
+gboolean _ps_context_get_ps_defined(ps_context_t *context)
 {
-       ps_context_t *context = (ps_context_t *)object;
-
-       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context(%p), ps_defined(%d)", context, context->ps_defined);
-
+       ps_info_ex_ctx(context, "context(%p), ps_defined(%d)", context, context->ps_defined);
        return context->ps_defined;
 }
 
-gboolean _ps_context_reset_user_data(gpointer object)
+gboolean _ps_context_reset_user_data(ps_context_t *context)
 {
-       ps_context_t *context = (ps_context_t *)object;
-
        g_return_val_if_fail(context != NULL, FALSE);
        context->user_data = NULL;
-
        return TRUE;
 }
 
-gboolean _ps_context_set_bearer_info(gpointer object, struct tnoti_ps_dedicated_bearer_info *bearer_info)
+gboolean _ps_context_set_bearer_info(ps_context_t *context, struct tnoti_ps_dedicated_bearer_info *bearer_info)
 {
-       ps_context_t *context = (ps_context_t *)object;
-       CoreObject *co_context = NULL;
+       CoreObject *co_context;
 
        g_return_val_if_fail(context != NULL, FALSE);
        g_return_val_if_fail(bearer_info != NULL, FALSE);
 
-       co_context = _ps_context_ref_co_context(object);
+       co_context = _ps_context_ref_co_context(context);
 
        if (bearer_info->dedicated_bearer.num_dedicated_bearer > 0) {
-               ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "num_dedicated_bearer: %d", bearer_info->dedicated_bearer.num_dedicated_bearer);
+               ps_info_ex_ctx(context, "num_dedicated_bearer: %d", bearer_info->dedicated_bearer.num_dedicated_bearer);
                /* reset previous bearer info. */
                tcore_context_reset_bearer_info(co_context);
                tcore_context_set_bearer_info(co_context, bearer_info);
-               __ps_context_emit_dedicated_bearer_info_signal(context);
+               ps_context_emit_dedicated_bearer_info_signal(context);
        }
 
        return TRUE;
 }
 
-gpointer _ps_context_get_user_data(gpointer object)
+gpointer _ps_context_get_user_data(ps_context_t *context)
 {
-       ps_context_t *context = (ps_context_t *)object;
+       g_return_val_if_fail(context != NULL, NULL);
        return context->user_data;
 }
 
-TReturn _ps_connection_hdlr(gpointer object)
+TReturn _ps_connection_hdlr(ps_context_t *context)
 {
        int rv = TCORE_RETURN_FAILURE;
-       ps_context_t *pscontext = object;
-       ps_service_t *service = _ps_context_ref_service(pscontext);
-       CoreObject *co_network = _ps_service_ref_co_network(service);
+       ps_service_t *service = _ps_context_ref_service(context);
 
-       rv = _ps_service_activate_context(pscontext->p_service, pscontext);
+       rv = _ps_service_activate_context(service, context);
        if (rv != TCORE_RETURN_SUCCESS) {
-               ps_err_ex_co(co_network, "fail to activate context connection");
+               ps_err_ex_ctx(context, "fail to activate context connection");
                return rv;
        }
 
-       ps_dbg_ex_co(co_network, "success to activate context");
+       ps_dbg_ex_ctx(context, "success to activate context");
        return rv;
 }
 
@@ -2661,12 +2287,8 @@ gboolean _ps_context_create_cdma_profile(gchar *mccmnc, gchar *cp_name)
        GHashTable *in_param;
        char szQuery[5000];
 
-       /* Initialize Storage */
-       if (g_str_has_suffix(cp_name, "1"))
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_1);
-       else
-               handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
-       if (handle == NULL) {
+       handle = _ps_context_create_database_handle(cp_name);
+       if (!handle) {
                err("[%s] Failed to get Storage handle", cp_name);
                return FALSE;
        }
@@ -2674,7 +2296,7 @@ gboolean _ps_context_create_cdma_profile(gchar *mccmnc, gchar *cp_name)
        /* Make default MMS profile for CDMA */
        memset(szQuery, 0, 5000);
        snprintf(szQuery, sizeof(szQuery), "%s",
-       " update pdp_profile set  \
+                " update pdp_profile set  \
         home_url = ? \
         where profile_id = 1 and svc_category_id = 2 ");
 
@@ -2692,76 +2314,77 @@ gboolean _ps_context_create_cdma_profile(gchar *mccmnc, gchar *cp_name)
        return rv;
 }
 
-void _ps_default_connection_hdlr(gpointer object)
+void _ps_default_connection_hdlr(ps_context_t *context)
 {
-       ps_context_t *pscontext = (ps_context_t *)object;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(pscontext));
+       ps_service_t *service = _ps_context_ref_service(context);
+       CoreObject *co_context = _ps_context_ref_co_context(context);
 
-       __ps_context_update_default_internet_to_db(pscontext, TRUE);
+       _ps_context_update_default_internet_to_db(context, TRUE);
 
        /* set request profile */
-       tcore_context_set_default_profile(pscontext->co_context, TRUE);
-       __ps_context_set_default_connection_enable(pscontext, TRUE);
-       _ps_context_set_alwayson_enable(pscontext, TRUE);
-       __ps_context_emit_property_changed_signal(pscontext);
+       tcore_context_set_default_profile(co_context, TRUE);
+       _ps_context_set_default_connection_enable(context, TRUE);
+       _ps_context_set_alwayson_enable(context, TRUE);
+       ps_context_emit_property_changed_signal(context);
 
-       if (CONTEXT_ROLE_INTERNET == tcore_context_get_role(_ps_context_ref_co_context(object))) {
+       if (CONTEXT_ROLE_INTERNET == tcore_context_get_role(co_context)) {
                int rv = TCORE_RETURN_FAILURE;
-               ps_dbg_ex_co(co_network, "activation requeset in new ps (%p)", pscontext);
+               ps_dbg_ex_ctx(context, "activation requeset in new ps (%p)", context);
                /* request to connect */
-               _ps_service_reset_connection_timer(pscontext);
-               rv = _ps_service_connect_default_context(pscontext->p_service);
+               _ps_service_reset_connection_timer(context);
+               rv = _ps_service_connect_default_context(service);
                if (rv == TCORE_RETURN_PS_NETWORK_NOT_READY) {
                        unsigned char cid = -1;
-                       ps_service_t * p_service = (ps_service_t *)pscontext->p_service;
+                       CoreObject *co_ps = _ps_service_ref_co_ps(service);
 
-                       ps_dbg_ex_co(co_network, "PS is not attached yet, release resources.");
+                       ps_dbg_ex_ctx(context, "PS is not attached yet, release resources.");
 
-                       cid = tcore_context_get_id(pscontext->co_context);
-                       _ps_context_set_ps_defined((gpointer)pscontext, FALSE);
-                       tcore_ps_set_cid_active(p_service->co_ps, cid, FALSE);
-                       tcore_ps_clear_context_id(p_service->co_ps, pscontext->co_context);
+                       cid = tcore_context_get_id(co_context);
+                       _ps_context_set_ps_defined(context, FALSE);
+                       tcore_ps_set_cid_active(co_ps, cid, FALSE);
+                       tcore_ps_clear_context_id(co_ps, co_context);
                } else if (rv == TCORE_RETURN_PS_ACTIVATION_ON_HOLD) {
                        /*
                         * We need to clear the context for Activation 'ON HOLD'
                         */
-                       ps_info_ex_co(co_network, "Activation is ON HOLD");
+                       ps_info_ex_ctx(context, "Activation is ON HOLD");
                }
        }
-       ps_info_ex_co(co_network, "complete to change the default connection");
+       ps_info_ex_ctx(context, "complete to change the default connection");
 }
 
-gint _ps_context_get_number_of_pdn(gchar *operator, gchar *cp_name)
+gint _ps_context_get_number_of_pdn(gchar *operator, ps_service_t *service)
 {
        gint num_of_pdn = 0;
 
-       num_of_pdn = __ps_context_load_num_of_pdn_from_database(operator, cp_name);
-       info("[%s] loaded num_of_pdn (%d) for %s", cp_name, num_of_pdn);
+       num_of_pdn = __ps_context_load_num_of_pdn_from_database(operator, service);
+       info("loaded num_of_pdn = %d", num_of_pdn);
 
        return num_of_pdn;
 }
 
-gboolean _ps_context_handle_ifaceup(gpointer user_data)
+gboolean _ps_context_handle_ifaceup(ps_context_t *context)
 {
-       ps_context_t *pscontext = user_data;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(pscontext));
+       ps_service_t *service = _ps_context_ref_service(context);
+       CoreObject *co_context = _ps_context_ref_co_context(context);
+
        int context_state = 0;
 
-       context_state =  tcore_context_get_state(pscontext->co_context);
-       ps_info_ex_co(co_network, "context_state: %d", context_state);
+       context_state = tcore_context_get_state(co_context);
+       ps_info_ex_ctx(context, "context_state: %d", context_state);
        if (context_state == CONTEXT_STATE_ACTIVATED) {
-               char *devname = tcore_context_get_ipv4_devname(pscontext->co_context);
-               gint ps_mode = _ps_modem_get_psmode(_ps_service_ref_modem(pscontext->p_service));
+               char *devname = tcore_context_get_ipv4_devname(co_context);
+               gint ps_mode = _ps_modem_get_psmode(_ps_service_ref_modem(service));
                if (TCORE_RETURN_SUCCESS != tcore_util_netif_up(devname))
-                       ps_err_ex_co(co_network, "Failed to bring up interface");
+                       ps_err_ex_ctx(context, "Failed to bring up interface");
 
                if (ps_mode > POWER_SAVING_MODE_NORMAL && ps_mode < POWER_SAVING_MODE_WEARABLE) {
                        /* If this flag is true, Connman won't update cellular service state. */
-                       if (pscontext->b_notify) {
-                               ps_warn_ex_co(co_network, "[EXCEPTION] notify status change to upper layer.");
-                               pscontext->b_routing_only = FALSE;
+                       if (context->b_notify) {
+                               ps_warn_ex_ctx(context, "[EXCEPTION] notify status change to upper layer.");
+                               context->b_routing_only = FALSE;
                        } else {
-                               pscontext->b_routing_only = TRUE;
+                               context->b_routing_only = TRUE;
                        }
                }
                /*
@@ -2774,501 +2397,51 @@ gboolean _ps_context_handle_ifaceup(gpointer user_data)
                 * So, we add work-around patch set here.
                 * ===============================================================================
                 */
-               if (pscontext->b_active == FALSE) {
-                       pscontext->b_active = TRUE;
-                       ps_dbg_ex_co(co_network, "Celluar profile: Emit property signal to provide IP configuration, devname(%s)", devname);
-                       __ps_context_emit_property_changed_signal(pscontext);
+               if (context->b_active == FALSE) {
+                       context->b_active = TRUE;
+                       ps_dbg_ex_ctx(context, "Celluar profile: Emit property signal to provide IP configuration, devname(%s)", devname);
+                       ps_context_emit_property_changed_signal(context);
                }
-               pscontext->b_routing_only = FALSE;
-               pscontext->b_notify = FALSE;
+               context->b_routing_only = FALSE;
+               context->b_notify = FALSE;
+               g_free(devname);
                return TRUE;
        } else if (context_state == CONTEXT_STATE_DEACTIVATED) {
                /* trigger PDP activation.  */
-               _ps_service_activate_context(pscontext->p_service, pscontext);
+               _ps_service_activate_context(service, context);
        }
        return FALSE;
 }
 
-gboolean _ps_context_handle_ifacedown(gpointer user_data)
+gboolean _ps_context_handle_ifacedown(ps_context_t *context)
 {
-       ps_context_t *pscontext = user_data;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(pscontext));
-       int context_state = 0;
+       CoreObject *co_context = _ps_context_ref_co_context(context);
+       int context_state = tcore_context_get_state(co_context);
 
-       context_state =  tcore_context_get_state(pscontext->co_context);
-       ps_info_ex_co(co_network, "context_state: %d", context_state);
+       ps_info_ex_ctx(context, "context_state: %d", context_state);
        if (context_state == CONTEXT_STATE_ACTIVATED) {
-               char *devname = tcore_context_get_ipv4_devname(pscontext->co_context);
-               gint ps_mode = _ps_modem_get_psmode(_ps_service_ref_modem(pscontext->p_service));
-               ps_dbg_ex_co(co_network, "Cellular profile: Do not send PDP deactivation request message to Modem.");
+               ps_service_t *service = _ps_context_ref_service(context);
+               char *devname = tcore_context_get_ipv4_devname(co_context);
+               gint ps_mode = _ps_modem_get_psmode(_ps_service_ref_modem(service));
+               ps_dbg_ex_ctx(context, "Cellular profile: Do not send PDP deactivation request message to Modem.");
                if (ps_mode > POWER_SAVING_MODE_NORMAL && ps_mode < POWER_SAVING_MODE_WEARABLE) {
                        /* If this flag is true, Connman won't update cellular service state. */
-                       pscontext->b_routing_only = TRUE;
+                       context->b_routing_only = TRUE;
                } else {
-                       ps_warn_ex_co(co_network, "reset socket connections, devname(%s)", devname);
-                       if (TCORE_RETURN_SUCCESS != tcore_util_reset_ipv4_socket(devname, tcore_context_get_ipv4_addr(pscontext->co_context)))
-                               ps_err_ex_co(co_network, "Failed to reset socket.");
+                       ps_warn_ex_ctx(context, "reset socket connections, devname(%s)", devname);
+                       if (TCORE_RETURN_SUCCESS != tcore_util_reset_ipv4_socket(devname, tcore_context_get_ipv4_addr(co_context)))
+                               ps_err_ex_ctx(context, "Failed to reset socket.");
                }
 
                if (TCORE_RETURN_SUCCESS != tcore_util_netif_down(devname))
-                       ps_err_ex_co(co_network, "Failed to bring down interface");
-               if (pscontext->b_active == TRUE) {
-                       pscontext->b_active = FALSE;
-                       __ps_context_emit_property_changed_signal(pscontext);
+                       ps_err_ex_ctx(context, "Failed to bring down interface");
+               if (context->b_active == TRUE) {
+                       context->b_active = FALSE;
+                       ps_context_emit_property_changed_signal(context);
                }
-               pscontext->b_routing_only = FALSE;
+               context->b_routing_only = FALSE;
+               g_free(devname);
                return TRUE;
        }
        return FALSE;
 }
-
-static gboolean on_context_get_properties(PacketServiceContext *obj_context,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       GVariant *gv = NULL;
-       GVariantBuilder property;
-
-       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(user_data)), "Entered");
-       gv = _ps_context_get_properties(user_data, &property);
-       packet_service_context_complete_get_properties(obj_context, invocation, gv);
-       return TRUE;
-}
-
-static gboolean on_context_get_profile(PacketServiceContext *obj_context,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       GVariant *gv = NULL;
-       GVariantBuilder profile;
-
-       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(user_data)), "Entered");
-       gv = __ps_context_get_profile_properties(user_data, &profile);
-       packet_service_context_complete_get_profile(obj_context, invocation, gv);
-
-       return TRUE;
-}
-
-static gboolean on_context_handle_activate(PacketServiceContext *obj_context,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       gboolean rv = FALSE;
-       TReturn result = TCORE_RETURN_FAILURE;
-
-       gchar *apn = NULL;
-       int context_state = 0;
-       unsigned int max_pdn = 0, num_of_active_cids = 0;
-       gpointer p_service = NULL; gpointer co_ps = NULL;
-       gpointer c_def_context = NULL; unsigned char cid_def = 0;
-       GSList *active_cids = NULL;
-       CoreObject *co_network;
-
-       ps_context_t *pscontext = user_data;
-
-       if (pscontext == NULL) {
-               err("activation request object is NULL");
-               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
-               return TRUE;
-       }
-
-       p_service = pscontext->p_service;
-       if (!p_service) {
-               err("service object is null");
-               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
-               return TRUE;
-       }
-
-       co_network = _ps_service_ref_co_network(_ps_context_ref_service(pscontext));
-       co_ps = _ps_service_ref_co_ps(p_service);
-       if (!co_ps) {
-               ps_err_ex_co(co_network, "core object is null");
-               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
-               return TRUE;
-       }
-
-       ps_info_ex_co(co_network, "activate context(%s)", _ps_context_ref_path(pscontext));
-
-       apn = (gchar *)tcore_context_get_apn(pscontext->co_context);
-
-       context_state = tcore_context_get_state(pscontext->co_context);
-       if (context_state != CONTEXT_STATE_DEACTIVATED) {
-               ps_warn_ex_co(co_network, "operation is in progress");
-               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-               return TRUE;
-       }
-
-       ps_info_ex_co(co_network, "requested context(%p) co_context(%p) apn (%s)", pscontext, pscontext->co_context, apn);
-       /* check apn is activated or not */
-       rv = tcore_ps_is_active_apn(co_ps, (const char *)apn);
-       if (rv) {
-               ps_info_ex_co(co_network, "requested apn is already activated");
-
-               result = _ps_connection_hdlr(pscontext);
-               if (result != TCORE_RETURN_SUCCESS) {
-                       FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-                       return TRUE;
-               }
-
-               packet_service_context_complete_activate(obj_context, invocation, pscontext->path);
-               context_state = tcore_context_get_state(pscontext->co_context);
-               if (context_state == CONTEXT_STATE_ACTIVATED) {
-                       ps_info_ex_co(co_network, "context is already connected");
-                       _ps_context_set_connected(pscontext, TRUE);
-               }
-
-               ps_dbg_ex_co(co_network, "success to open connection request");
-               return TRUE;
-       }
-
-       active_cids = tcore_ps_get_active_cids(co_ps);
-       num_of_active_cids = g_slist_length(active_cids);
-       max_pdn = tcore_ps_get_num_of_pdn(co_ps);
-       ps_info_ex_co(co_network, "activate cids(%d), max pdn(%d)", num_of_active_cids, max_pdn);
-       if (num_of_active_cids < max_pdn) {
-               ps_dbg_ex_co(co_network, "enough to active another pdn");
-
-               /* Set context activation requested */
-               if (CONTEXT_ROLE_IMS == tcore_context_get_role(_ps_context_ref_co_context(pscontext)))
-                       _ps_service_set_ims_activation_requested(p_service, TRUE);
-
-               result = _ps_connection_hdlr(pscontext);
-               if (result != TCORE_RETURN_SUCCESS) {
-                       FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-                       return TRUE;
-               }
-
-               ps_dbg_ex_co(co_network, "success to open connection request");
-               packet_service_context_complete_activate(obj_context, invocation, pscontext->path);
-               return TRUE;
-       }
-
-       /* find the current default connection */
-       c_def_context = _ps_service_return_default_context(p_service, CONTEXT_ROLE_INTERNET);
-       if (c_def_context == NULL) {
-               ps_err_ex_co(co_network, "default context is NULL");
-               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
-               return TRUE;
-       }
-       cid_def = tcore_context_get_id(((ps_context_t *)c_def_context)->co_context);
-       if (cid_def == 0) {
-               ps_err_ex_co(co_network, "it is not avaiable to open connection");
-               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
-               return TRUE;
-       }
-
-       /* check the status of def context */
-       context_state = tcore_context_get_state(((ps_context_t *)c_def_context)->co_context);
-       if (context_state != CONTEXT_STATE_ACTIVATED) {
-               enum co_context_role context_role;
-               context_role = tcore_context_get_role(pscontext->co_context);
-               ps_err_ex_co(co_network, "default connection is in progress, new context_state[%d], role[%d]", context_state, context_role);
-               if (context_state == CONTEXT_STATE_ACTIVATING &&
-                       (context_role == CONTEXT_ROLE_MMS ||context_role == CONTEXT_ROLE_PREPAID_MMS)) {
-                       ((ps_context_t *)c_def_context)->user_data = pscontext;
-                       packet_service_context_complete_activate(obj_context, invocation, pscontext->path);
-                       return TRUE;
-               }
-               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
-               return TRUE;
-       }
-
-       _ps_service_reset_connection_timer(c_def_context);
-       ((ps_context_t *)c_def_context)->user_data = pscontext;
-       result = tcore_ps_deactivate_cid(co_ps, cid_def);
-       if (result != TCORE_RETURN_SUCCESS) {
-               ps_err_ex_co(co_network, "fail to deactivate exist network connection");
-               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
-               return TRUE;
-       }
-
-       packet_service_context_complete_activate(obj_context, invocation, pscontext->path);
-       return TRUE;
-
-}
-
-static gboolean on_context_handle_deactiavte(PacketServiceContext *obj_context,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       gboolean rv = FALSE;
-       CoreObject *co_network;
-       int context_state = 0;
-       ps_context_t *pscontext = user_data;
-       ps_service_t *service = _ps_context_ref_service(pscontext);
-
-       if (pscontext == NULL) {
-               err("deactivation request object is NULL");
-               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
-               return TRUE;
-       }
-
-       co_network = _ps_service_ref_co_network(_ps_context_ref_service(pscontext));
-
-       /* Set context activation requested */
-       if (CONTEXT_ROLE_IMS == tcore_context_get_role(_ps_context_ref_co_context(pscontext)))
-               _ps_service_set_ims_activation_requested(service, FALSE);
-
-       context_state = tcore_context_get_state(pscontext->co_context);
-       ps_info_ex_co(co_network, "requested context(%p) co_context(%p), context_state %d", pscontext, pscontext->co_context, context_state);
-       if (context_state != CONTEXT_STATE_ACTIVATED) {
-               ps_err_ex_co(co_network, "operation is in progress");
-               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-               return TRUE;
-       }
-
-       ps_info_ex_co(co_network, "deactivate context(%s)", _ps_context_ref_path(pscontext));
-
-       _ps_service_reset_connection_timer(pscontext);
-       _ps_context_set_alwayson_enable(pscontext, FALSE);
-       rv = _ps_service_deactivate_context(service, pscontext);
-       if (rv != TCORE_RETURN_SUCCESS) {
-               ps_err_ex_co(co_network, "fail to deactivate context connection");
-               FAIL_RESPONSE(invocation, PS_ERR_TRASPORT);
-               return TRUE;
-       }
-
-       ps_dbg_ex_co(co_network, "success to deactivate context");
-       packet_service_context_complete_deactivate(obj_context, invocation, pscontext->path);
-
-       context_state =  tcore_context_get_state(pscontext->co_context);
-       if (context_state == CONTEXT_STATE_DEACTIVATED) {
-               ps_info_ex_co(co_network, "context is already disconnected");
-               pscontext->ps_defined = FALSE;
-               _ps_context_set_connected(pscontext, FALSE);
-       }
-
-       return TRUE;
-}
-
-static gboolean on_context_set_default_connection(PacketServiceContext *obj_context,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       int rv = 0;
-       int role = CONTEXT_ROLE_UNKNOWN;
-       gboolean is_default = FALSE;
-
-       gpointer co_ps = NULL;
-       gpointer cur_default_ctx = NULL;
-       ps_service_t *service = NULL;
-       ps_context_t *pscontext = user_data;
-       CoreObject *co_network = NULL;
-
-       if (pscontext == NULL) {
-               err("activation request object is NULL");
-               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
-               return TRUE;
-       }
-
-       co_network = _ps_service_ref_co_network(_ps_context_ref_service(pscontext));
-       ps_info_ex_co(co_network, "start default connection");
-       role = tcore_context_get_role(pscontext->co_context);
-       is_default = tcore_context_get_default_profile(pscontext->co_context);
-
-       service = pscontext->p_service;
-
-       if (is_default) {
-               ps_err_ex_co(co_network, "already default profile for role (%d).", role);
-               goto OUT;
-       }
-
-       cur_default_ctx = _ps_service_return_default_context(service, role);
-       ps_info_ex_co(co_network, "current default connection (%p)", cur_default_ctx);
-
-       if (!cur_default_ctx) {
-               ps_err_ex_co(co_network, "No current default connection.");
-               goto OUT;
-       }
-
-       /* First, send deactivation request first. */
-       rv = _ps_service_deactivate_context(((ps_context_t *)cur_default_ctx)->p_service, cur_default_ctx);
-       if (rv == TCORE_RETURN_PS_ACTIVATING) {
-               ps_err_ex_co(co_network, "fail to deactivate default connection, rv(%d)", rv);
-               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-               return TRUE;
-       }
-
-       /* Normal deactivation case. */
-       if (tcore_context_get_state(((ps_context_t *)cur_default_ctx)->co_context) == CONTEXT_STATE_DEACTIVATING) {
-               ps_dbg_ex_co(co_network, "deactivation request in current ps (%p)", cur_default_ctx);
-               ((ps_context_t *)cur_default_ctx)->user_data = pscontext;
-       } else {
-               int cid = -1;
-
-               ps_dbg_ex_co(co_network, "[Not normal] deactivation request in current ps (%p)", cur_default_ctx);
-
-               cid = tcore_context_get_id(((ps_context_t *)cur_default_ctx)->co_context);
-               _ps_context_set_ps_defined(cur_default_ctx, FALSE);
-               co_ps = _ps_service_ref_co_ps(service);
-               tcore_ps_set_cid_active((CoreObject *)co_ps, cid, FALSE);
-               tcore_ps_clear_context_id((CoreObject *)co_ps, ((ps_context_t *)cur_default_ctx)->co_context);
-       }
-
-       /* unset default info of previous connection */
-       _ps_context_set_alwayson_enable(cur_default_ctx, FALSE);
-       __ps_context_set_default_connection_enable(cur_default_ctx, FALSE);
-       tcore_context_set_default_profile(((ps_context_t *)cur_default_ctx)->co_context, FALSE);
-
-       /* db update - release default connection */
-       ps_dbg_ex_co(co_network, "context(%p): release default connection property.", cur_default_ctx);
-       __ps_context_update_default_internet_to_db((ps_context_t *)cur_default_ctx, FALSE);
-       /* Allow Connman to update profile information. */
-       __ps_context_emit_property_changed_signal(cur_default_ctx);
-
-       ps_info_ex_co(co_network, "activation requeset in new ps (%p)", pscontext);
-OUT:
-       _ps_default_connection_hdlr(pscontext);
-       /* Update Attach APN required. */
-       __ps_context_update_attach_apn(service->contexts, pscontext->mccmnc);
-       packet_service_context_complete_set_default_connection(obj_context, invocation, TRUE);
-       return TRUE;
-
-}
-
-static gboolean on_context_modify_profile(PacketServiceContext *obj_context,
-               GDBusMethodInvocation *invocation,
-               GVariant *property,
-               gpointer user_data)
-{
-       GVariantIter g_iter;
-       gchar *g_value;
-       gchar *g_key;
-
-       gboolean rv = FALSE;
-       int context_state = 0;
-       ps_context_t *context = user_data;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
-       GHashTable *profile_property = NULL;
-
-       ps_info_ex_co(co_network, "modify context's profile properties");
-
-       /*Creating the profile property hash for for internal handling*/
-       /*Create a hash table for the profile property as all fucntion already use ghash table */
-       profile_property = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
-       g_variant_iter_init(&g_iter, property);
-       while (g_variant_iter_next(&g_iter, "{ss}", &g_key, &g_value)) {
-
-               g_hash_table_insert(profile_property, g_strdup(g_key), g_strdup(g_value));
-               /* must free data for ourselves */
-               g_free(g_value);
-               g_free(g_key);
-       }
-
-       rv = __ps_context_update_profile(context, profile_property);
-       if (rv != TRUE) {
-               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-               g_hash_table_destroy(profile_property);
-               return TRUE;
-       }
-
-       context_state = tcore_context_get_state(context->co_context);
-       if (context_state == CONTEXT_STATE_ACTIVATING) {
-               ps_info_ex_co(co_network, "Modify profile in activating state, set deactivate flag.");
-               context->deact_required = TRUE;
-               goto EXIT;
-       }
-
-       _ps_service_deactivate_context(context->p_service, context);
-       if (context_state == CONTEXT_STATE_DEACTIVATED) {
-               ps_dbg_ex_co(co_network, "context is already disconnected");
-               _ps_context_set_connected(context, FALSE);
-       }
-EXIT:
-       packet_service_context_complete_modify_profile(obj_context, invocation, TRUE);
-       g_hash_table_destroy(profile_property);
-       return TRUE;
-}
-
-static gboolean on_context_remove_profile(PacketServiceContext *obj_context,
-       GDBusMethodInvocation *invocation, gpointer user_data)
-{
-       ps_context_t *context = user_data;
-       ps_service_t *service = _ps_context_ref_service(context);
-       ps_modem_t* modem = _ps_service_ref_modem(service);
-       CoreObject *co_network = _ps_service_ref_co_network(service);
-       CoreObject *co_context = _ps_context_ref_co_context(context);
-       gboolean attach_apn = tcore_context_get_attach_apn(co_context);
-       int context_state = 0;
-
-       if (service == NULL || modem == NULL) {
-               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-               return TRUE;
-       }
-       ps_info_ex_co(co_network, "Remove context.");
-
-       context_state = tcore_context_get_state(context->co_context);
-       ps_info_ex_co(co_network, "context_state: %d", context_state);
-
-       if (context_state == CONTEXT_STATE_DEACTIVATED) {
-               ps_dbg_ex_co(co_network, "context is already disconnected");
-               __ps_context_remove_database(context);
-               _ps_service_unref_context(service, context);
-               service->contexts = g_slist_remove(service->contexts, context);
-               _ps_context_remove_context(context);
-
-               /* Update Attach APN required. */
-               if (attach_apn)
-                       __ps_context_update_attach_apn(service->contexts, modem->operator);
-
-               packet_service_context_complete_remove_profile(obj_context, invocation, TRUE);
-               goto EXIT;
-       } else if (context_state == CONTEXT_STATE_ACTIVATING) {
-               ps_info_ex_co(co_network, "Remove profile in activating state, set remove_profile_required flag.");
-               context->deact_required = TRUE;
-       } else {
-               _ps_service_deactivate_context(context->p_service, context);
-               ps_info_ex_co(co_network, "Remove profile in deactivating/activated state, set remove_profile_required flag.");
-       }
-       context->remove_profile_required = TRUE;
-       context->remove_profile_cb_data = g_malloc0(sizeof(ps_remove_profile_data));
-       context->remove_profile_cb_data->obj_context = obj_context;
-       context->remove_profile_cb_data->invocation = invocation;
-       context->remove_profile_cb_data->user_data = user_data;
-
-EXIT:
-       ps_dbg_ex_co(co_network, "Exit");
-       return TRUE;
-}
-
-static void _ps_context_setup_interface(PacketServiceContext *context, ps_context_t *context_data)
-{
-       info("Entered");
-
-       g_signal_connect(context,
-                       "handle-get-properties",
-                       G_CALLBACK(on_context_get_properties),
-                       context_data);
-
-       g_signal_connect(context,
-                       "handle-get-profile",
-                       G_CALLBACK(on_context_get_profile),
-                       context_data);
-
-       g_signal_connect(context,
-                       "handle-activate",
-                       G_CALLBACK(on_context_handle_activate),
-                       context_data);
-
-       g_signal_connect(context,
-                       "handle-deactivate",
-                       G_CALLBACK(on_context_handle_deactiavte),
-                       context_data);
-
-       g_signal_connect(context,
-                       "handle-set-default-connection",
-                       G_CALLBACK(on_context_set_default_connection),
-                       context_data);
-
-       g_signal_connect(context,
-                       "handle-modify-profile",
-                       G_CALLBACK(on_context_modify_profile),
-                       context_data);
-
-       g_signal_connect(context,
-                       "handle-remove-profile",
-                       G_CALLBACK(on_context_remove_profile),
-                       context_data);
-       dbg("Exiting");
-       return;
-}
diff --git a/src/ps_hook.c b/src/ps_hook.c
new file mode 100644 (file)
index 0000000..0d293a2
--- /dev/null
@@ -0,0 +1,1034 @@
+/*
+ * tel-plugin-packetservice
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongHoo Park <donghoo.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "ps_common.h"
+#include "ps_hook.h"
+#include "ps_context.h"
+#include "ps_modem.h"
+#include "ps_service.h"
+
+#include <server.h>
+#include <plugin.h>
+#include <co_ps.h>
+#include <co_context.h>
+#include <co_modem.h>
+#include <co_sim.h>
+#include <type/network.h>
+#include <co_network.h>
+#include <co_call.h>
+#include <user_request.h>
+
+#include "ps_log.h"
+
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
+typedef enum {
+       ON_REQUEST,
+       ON_NON_CALL_NOTI_HOOK,
+       ON_CALL_NOTI_HOOK,
+} __ps_call_flow_type;
+
+static gboolean __ps_set_network_mode(int mode, void *data)
+{
+       int c_mode = 0;
+       gboolean roaming = FALSE;
+       struct treq_network_set_mode req;
+
+       UserRequest *ur = NULL;
+       ps_modem_t *modem = data;
+
+       CoreObject *co_network = NULL;
+
+       memset(&req, 0, sizeof(struct treq_network_set_mode));
+
+       co_network = tcore_plugin_ref_core_object(tcore_object_ref_plugin(modem->co_modem),
+                                                 CORE_OBJECT_TYPE_NETWORK);
+       c_mode = mode;
+
+       if (modem->data_allowed)
+               c_mode |= NETWORK_MODE_LTE;
+       else
+               c_mode &= ~NETWORK_MODE_LTE;
+
+       roaming = tcore_network_get_roaming_state(co_network);
+       if (modem->data_allowed && roaming)
+               c_mode &= ~NETWORK_MODE_LTE;
+
+       ps_dbg_ex_modem(modem, "candidate mode(%d), current mode(%d), roaming(%d), data allowed(%d)", c_mode, mode, roaming, modem->data_allowed);
+       if (c_mode == mode)
+               return FALSE;
+
+       req.mode = c_mode;
+
+       ur = tcore_user_request_new(NULL, tcore_plugin_ref_plugin_name(tcore_object_ref_plugin(co_network)));
+       tcore_user_request_set_data(ur, sizeof(struct treq_network_set_mode), &req);
+       tcore_user_request_set_command(ur, TREQ_NETWORK_SET_MODE);
+
+       if (TCORE_RETURN_SUCCESS != tcore_server_dispatch_request(tcore_plugin_ref_server(tcore_object_ref_plugin(modem->co_modem)), ur)) {
+               ps_err_ex_modem(modem, "Failed to dispatch");
+               tcore_user_request_unref(ur);
+       }
+
+       return TRUE;
+}
+
+/* Function will be used in case any dispatch request failed in ps plugin */
+static void __ps_send_ur_dispatch_failure_response(UserRequest *ur, enum tcore_response_command command)
+{
+       err("User request dispatch failed so need to send response for command [%d]", command);
+       switch (command) {
+       case TRESP_NETWORK_SEARCH: {
+               struct tresp_network_search search_rsp;
+               memset(&search_rsp, 0, sizeof(struct tresp_network_search));
+
+               search_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
+               search_rsp.list_count = 0;
+               tcore_user_request_send_response(ur, TRESP_NETWORK_SEARCH,
+                                                sizeof(struct tresp_network_search), &search_rsp);
+       }
+       break;
+
+       case TRESP_NETWORK_SET_PLMN_SELECTION_MODE: {
+               struct tresp_network_set_plmn_selection_mode set_plmn_selection_mode_rsp;
+               memset(&set_plmn_selection_mode_rsp, 0, sizeof(struct tresp_network_set_plmn_selection_mode));
+
+               set_plmn_selection_mode_rsp.result = TCORE_RETURN_FAILURE;
+               tcore_user_request_send_response(ur, TRESP_NETWORK_SET_PLMN_SELECTION_MODE,
+                                                sizeof(struct tresp_network_set_plmn_selection_mode), &set_plmn_selection_mode_rsp);
+       }
+       break;
+
+       case TRESP_NETWORK_SET_MODE: {
+               struct tresp_network_set_mode set_rsp;
+               memset(&set_rsp, 0, sizeof(struct tresp_network_set_mode));
+
+               set_rsp.result = TCORE_RETURN_FAILURE;
+               tcore_user_request_send_response(ur, TRESP_NETWORK_SET_MODE,
+                                                sizeof(struct tresp_network_search), &set_rsp);
+       }
+       break;
+
+       case TRESP_NETWORK_GET_MODE: {
+               struct tresp_network_get_mode get_rsp;
+               memset(&get_rsp, 0, sizeof(struct tresp_network_get_mode));
+
+               get_rsp.result = TCORE_RETURN_FAILURE;
+               tcore_user_request_send_response(ur, TRESP_NETWORK_GET_MODE,
+                                                sizeof(struct tresp_network_get_mode), &get_rsp);
+       }
+       break;
+
+       case TRESP_MODEM_POWER_OFF: {
+               struct tresp_modem_power_off set_power_off_rsp;
+               memset(&set_power_off_rsp, 0, sizeof(struct tresp_modem_power_off));
+
+               set_power_off_rsp.result = TCORE_RETURN_FAILURE;
+               tcore_user_request_send_response(ur, TRESP_MODEM_POWER_OFF,
+                                                sizeof(struct tresp_modem_power_off), &set_power_off_rsp);
+       }
+       break;
+
+       case TRESP_MODEM_POWER_LOW: {
+               struct tresp_modem_power_low set_power_low_rsp;
+               memset(&set_power_low_rsp, 0, sizeof(struct tresp_modem_power_low));
+
+               set_power_low_rsp.result = TCORE_RETURN_FAILURE;
+               tcore_user_request_send_response(ur, TRESP_MODEM_POWER_LOW,
+                                                sizeof(struct tresp_modem_power_low), &set_power_low_rsp);
+       }
+       break;
+
+       case TRESP_MODEM_SET_FLIGHTMODE: {
+               struct tresp_modem_set_flightmode set_flight_mode_rsp;
+               memset(&set_flight_mode_rsp, 0, sizeof(struct tresp_modem_set_flightmode));
+
+               set_flight_mode_rsp.result = TCORE_RETURN_FAILURE;
+               tcore_user_request_send_response(ur, TRESP_MODEM_SET_FLIGHTMODE,
+                                                sizeof(struct tresp_modem_set_flightmode), &set_flight_mode_rsp);
+       }
+       break;
+
+       default:
+               err("Command type not expected [%d]", command);
+       }
+       /* Unref User request */
+       tcore_user_request_unref(ur);
+}
+
+static void __ps_hook_response_cb(UserRequest *ur, enum tcore_response_command command,
+                                 unsigned int data_len, const void *data, void *user_data)
+{
+       ps_modem_t *modem = user_data;
+       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
+       guint count;
+       guint id;
+       id = ((command & ~TCORE_RESPONSE) & TCORE_REQUEST);
+
+       ps_dbg_ex_modem(modem, "Entered");
+       count = ps_util_get_waiting_job_count(modem->work_queue, id);
+
+       if (count != 0) {
+               ur = ps_util_pop_waiting_job(modem->work_queue, id);
+               if (ur) {
+                       CoreObject *co_network = NULL;
+                       TReturn ret = TCORE_RETURN_SUCCESS;
+
+                       co_network = tcore_plugin_ref_core_object(tcore_object_ref_plugin(co_modem),
+                                                                 CORE_OBJECT_TYPE_NETWORK);
+
+                       ps_info_ex_modem(modem, "Sending Pending Request of type = id", id);
+                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+                       if ((command == TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH)
+                           || (command == TRESP_NETWORK_SEARCH)
+                           || (command == TRESP_NETWORK_SET_PLMN_SELECTION_MODE)
+                           || (command == TRESP_NETWORK_SET_MODE)
+                           || (command == TRESP_NETWORK_GET_MODE))
+                               ret = tcore_object_dispatch_request(co_network, ur);
+                       else if ((command == TRESP_MODEM_SET_FLIGHTMODE)
+                                || (command == TRESP_MODEM_POWER_LOW)
+                                || (command == TRESP_MODEM_POWER_OFF))
+                               ret = tcore_object_dispatch_request(co_modem, ur);
+                       if (TCORE_RETURN_SUCCESS != ret) {
+                               /* send responce wrt to command */
+                               __ps_send_ur_dispatch_failure_response(ur, command);
+                       }
+                       return;
+               }
+       }
+
+       switch (command) {
+       case TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH:
+       case TRESP_NETWORK_SEARCH:
+               ps_dbg_ex_modem(modem, "TRESP_NETWORK_SEARCH  response received");
+               if (count == 0)
+                       modem->hook_flag &= PS_RESET_NETWORK_SEARCH_FLAG;
+               break;
+
+       case TRESP_NETWORK_SET_PLMN_SELECTION_MODE:
+               ps_dbg_ex_modem(modem, "TRESP_NETWORK_SET_PLMN_SELECTION_MODE response received ");
+               if (count == 0)
+                       modem->hook_flag &= PS_NETWORK_RESET_SELECTION_FLAG;
+               break;
+
+       case TRESP_NETWORK_SET_MODE: {
+               ps_dbg_ex_modem(modem, "TRESP_NETWORK_SET_MODE response received ");
+
+               if (count == 0) {
+                       modem->hook_flag &= PS_NETWORK_RESET_SELECT_MODE_FLAG;
+                       modem->mode_pref_changed = FALSE;
+               }
+               ps_dbg_ex_modem(modem, "mode_pref_changed : %d", modem->mode_pref_changed);
+       }
+       break;
+
+       case TRESP_NETWORK_GET_MODE: {
+               gboolean rv = FALSE;
+               const struct tresp_network_get_mode *resp_get_mode = data;
+               ps_dbg_ex_modem(modem, "TRESP_NETWORK_GET_MODE response received mode (mode:[%d])", resp_get_mode->mode);
+
+               if (count == 0)
+                       modem->hook_flag &= PS_NETWORK_RESET_GET_MODE_FLAG;
+
+               rv = __ps_set_network_mode(resp_get_mode->mode, modem);
+               if (rv) {
+                       ps_dbg_ex_modem(modem, "network set mode request!");
+                       return;
+               }
+       }
+       break;
+
+       case TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION:
+               ps_dbg_ex_modem(modem, "TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION response received ");
+               if (count == 0)
+                       modem->hook_flag &= PS_NETWORK_RESET_SET_DEFAULT_DATA_SUBS;
+               break;
+
+       case TRESP_MODEM_SET_FLIGHTMODE: {
+               GHashTableIter iter;
+               gpointer key, service;
+               ps_context_t *def_context = NULL, *ims_context = NULL;
+
+               ps_dbg_ex_modem(modem, "TRESP_MODEM_SET_FLIGHTMODE response received ");
+               if (count == 0)
+                       modem->hook_flag &= PS_NETWORK_RESET_SET_FLIGHT_MODE_FLAG;
+
+               g_hash_table_iter_init(&iter, modem->services);
+               while (g_hash_table_iter_next(&iter, &key, &service) == TRUE) {
+                       def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
+                       if (def_context)
+                               _ps_context_set_alwayson_enable(def_context, TRUE);
+
+                       ims_context = _ps_service_return_default_context(service, CONTEXT_ROLE_IMS);
+                       if (ims_context)
+                               _ps_context_set_alwayson_enable(ims_context, TRUE);
+
+               }
+       }
+       break;
+
+       case TRESP_MODEM_POWER_LOW:
+               ps_dbg_ex_modem(modem, "TRESP_MODEM_POWER_LOW response received ");
+               if (count == 0)
+                       modem->hook_flag &= PS_NETWORK_RESET_SET_POWER_LOW_FLAG;
+               break;
+
+       case TRESP_MODEM_POWER_OFF:
+               ps_dbg_ex_modem(modem, "TRESP_MODEM_POWER_OFF response received ");
+               if (count == 0)
+                       modem->hook_flag &= PS_NETWORK_RESET_SET_POWER_OFF_FLAG;
+               break;
+
+       case TRESP_SIM_SET_POWERSTATE:
+               ps_dbg_ex_modem(modem, "TRESP_SIM_SET_POWERSTATE response received ");
+               if (count == 0)
+                       modem->hook_flag &= PS_SIM_SET_POWER_STATE_FLAG;
+               break;
+
+       default: {
+               ps_warn_ex_modem(modem, "Unexpected response ");
+       }
+       break;
+       }
+
+       ps_info_ex_modem(modem, "After unset - FLAG %x", modem->hook_flag);
+       if (modem->hook_flag == PS_NO_PENDING_REQUEST
+           && command != TRESP_MODEM_POWER_LOW
+           && command != TRESP_MODEM_POWER_OFF
+           && modem->mode_pref_changed == FALSE) {
+               _ps_modem_connect_default_context(modem);
+       }
+}
+
+static void __ps_modem_get_mode_pref_change(ps_modem_t *modem, UserRequest *ur)
+{
+       enum telephony_network_service_type svc_type;
+       enum tcore_request_command cmd;
+       CoreObject *co_network = NULL;
+       const struct treq_network_set_mode *req;
+
+       cmd = tcore_user_request_get_command(ur);
+       if (cmd != TREQ_NETWORK_SET_MODE) {
+               ps_warn_ex_modem(modem, "Not a TREQ_NETWORK_SET_MODE");
+               modem->mode_pref_changed = FALSE;
+               return;
+       }
+       modem->mode_pref_changed = TRUE;
+
+       co_network = tcore_plugin_ref_core_object(tcore_object_ref_plugin(modem->co_modem),
+                                                 CORE_OBJECT_TYPE_NETWORK);
+       req = tcore_user_request_ref_data(ur, NULL);
+
+       tcore_network_get_service_type(co_network, &svc_type);
+       ps_dbg_ex_modem(modem, "mode_pref[0x%x], svc_type[%d]", req->mode, svc_type);
+       switch (svc_type) {
+       case NETWORK_SERVICE_TYPE_2G:
+       case NETWORK_SERVICE_TYPE_2_5G:
+       case NETWORK_SERVICE_TYPE_2_5G_EDGE: {
+               if (req->mode == NETWORK_MODE_GSM)
+                       modem->mode_pref_changed = FALSE;
+       }
+       break;
+
+       case NETWORK_SERVICE_TYPE_3G:
+       case NETWORK_SERVICE_TYPE_HSDPA: {
+               if (req->mode & NETWORK_MODE_WCDMA)
+                       modem->mode_pref_changed = FALSE;
+       }
+       break;
+
+       case NETWORK_SERVICE_TYPE_LTE: {
+               if (req->mode & NETWORK_MODE_LTE)
+                       modem->mode_pref_changed = FALSE;
+       }
+       break;
+
+       default:
+               break;
+       }
+
+       ps_dbg_ex_modem(modem, "mode_pref_changed : %d", modem->mode_pref_changed);
+}
+
+static int __ps_deactivation_timeout_handler(alarm_id_t alarm_id, void *data)
+{
+       ps_modem_t *modem = data;
+
+       if (alarm_id > 0) {
+               ps_dbg_ex_modem(modem, "remove connection retry timer (%d)", alarm_id);
+               alarmmgr_remove_alarm(alarm_id);
+       }
+
+       ps_dbg_ex_modem(modem, "Deactivation timeout, proceed pending cmd");
+       /* Handle any pending request if present */
+       _ps_hook_send_pending_user_request(modem);
+       return 1;
+}
+
+static void __ps_set_deactivation_timeout(ps_modem_t *modem, int timeout)
+{
+       int ret;
+       int result = 0;
+
+       /* Acquire lock */
+       ret = device_power_request_lock(POWER_LOCK_CPU, 0);
+       if (ret < 0)
+               ps_dbg_ex_modem(modem, "ret : (0x%x)", ret);
+
+       result = alarmmgr_add_alarm_withcb(ALARM_TYPE_VOLATILE, (time_t)(timeout),
+                                          0, __ps_deactivation_timeout_handler, modem, &(modem->deact_timer_src));
+
+       /* Release lock */
+       ret = device_power_release_lock(POWER_LOCK_CPU);
+       if (ret < 0)
+               ps_dbg_ex_modem(modem, "ret : (0x%x)", ret);
+
+       if (result != ALARMMGR_RESULT_SUCCESS) {
+               ps_dbg_ex_modem(modem, "Failed to add alarm(%d)", result);
+               return;
+       }
+
+       ps_dbg_ex_modem(modem, "deactivation timeout - timer src(%d), timeout(%d)", modem->deact_timer_src, timeout);
+}
+
+static void __ps_modem_set_hook_flag(ps_modem_t *modem, enum tcore_request_command cmd)
+{
+       switch (cmd) {
+       case TREQ_NETWORK_SEARCH:
+               ps_dbg_ex_modem(modem, "TREQ_NETWORK_SEARCH");
+               modem->hook_flag |= PS_NETWORK_SEARCH_PENDING;
+               ps_dbg_ex_modem(modem, "TREQ_NETWORK_SEARCH setting flag %x", modem->hook_flag);
+               break;
+
+       case TREQ_NETWORK_SET_PLMN_SELECTION_MODE:
+               modem->hook_flag |= PS_NETWORK_SELECTION_PENDING;
+               ps_dbg_ex_modem(modem, "TREQ_NETWORK_SET_PLMN_SELECTION_MODE setting flag %x", modem->hook_flag);
+               break;
+
+       case TREQ_NETWORK_SET_MODE:
+               modem->hook_flag |= PS_NETWORK_SELECT_MODE;
+               ps_dbg_ex_modem(modem, "TREQ_NETWORK_SET_MODE setting flag %x", modem->hook_flag);
+               break;
+
+       case TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION:
+               modem->hook_flag |= PS_NETWORK_SET_DEFAULT_DATA_SUBS;
+               ps_dbg_ex_modem(modem, "TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION setting flag %x", modem->hook_flag);
+               break;
+
+       case TREQ_MODEM_SET_FLIGHTMODE:
+               modem->hook_flag |= PS_NETWORK_SET_FLIGHT_MODE;
+               ps_dbg_ex_modem(modem, "TREQ_MODEM_SET_FLIGHTMODE setting flag %x", modem->hook_flag);
+               break;
+
+       case TREQ_MODEM_POWER_OFF:
+               modem->hook_flag |= PS_NETWORK_SET_POWER_OFF;
+               ps_dbg_ex_modem(modem, "TREQ_MODEM_POWER_OFF setting flag %x", modem->hook_flag);
+               break;
+
+       case TREQ_MODEM_POWER_LOW:
+               modem->hook_flag |= PS_NETWORK_SET_POWER_LOW;
+               ps_dbg_ex_modem(modem, "TREQ_MODEM_POWER_LOW setting flag %x", modem->hook_flag);
+               break;
+
+       case TREQ_SIM_SET_POWERSTATE:
+               modem->hook_flag |= PS_SIM_SET_POWER_STATE;
+               ps_dbg_ex_modem(modem, "TREQ_SIM_SET_POWERSTATE setting flag %x", modem->hook_flag);
+               break;
+
+       default:
+               ps_dbg_ex_modem(modem, "Not handled request");
+               break;
+       }
+       ps_info_ex_modem(modem, "After set - FLAG %x", modem->hook_flag);
+}
+
+static enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_data)
+{
+       gboolean ret = FALSE;
+       TReturn rv = TCORE_RETURN_FAILURE;
+
+       CoreObject *co_ps = NULL;
+       TcorePlugin *target_plg = NULL;
+       int value = 0;
+       guint job_cnt = 0;
+       ps_modem_t *modem = user_data;
+       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
+       GHashTableIter iter;
+       gpointer key, service;
+
+       char *modem_name = NULL;
+       enum tcore_request_command cmd = tcore_user_request_get_command(ur);
+
+       ps_dbg_ex_modem(modem, "Entered");
+
+       modem_name = tcore_user_request_get_modem_name(ur);
+       if (!modem_name)
+               return TCORE_HOOK_RETURN_CONTINUE;
+
+       target_plg = tcore_object_ref_plugin(co_modem);
+       if (g_strcmp0(tcore_server_get_cp_name_by_plugin(target_plg), modem_name) != 0) {
+               ps_info_ex_modem(modem, "request modem (%s) not matched current modem(%s)",
+                                modem_name,
+                                tcore_server_get_cp_name_by_plugin(target_plg));
+               free(modem_name);
+
+               if (cmd == TREQ_NETWORK_SEARCH || cmd == TREQ_MODEM_SET_FLIGHTMODE) {
+                       co_ps = tcore_plugin_ref_core_object(target_plg, CORE_OBJECT_TYPE_PS);
+                       if (!co_ps) {
+                               ps_err_ex_modem(modem, "No ps core object present ");
+                               return TCORE_HOOK_RETURN_CONTINUE;
+                       }
+
+                       if (FALSE == tcore_ps_any_context_activating_activated(co_ps, &value)) {
+                               ps_dbg_ex_modem(modem, "No activating/activated context present");
+                               /* Block PS always-on while network operations. */
+                               __ps_modem_set_hook_flag(modem, cmd);
+                               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+                               return TCORE_HOOK_RETURN_CONTINUE;
+                       }
+
+                       ps_info_ex_modem(modem, "Value returned [%d]", value);
+                       if (CONTEXT_STATE_ACTIVATED == value) {
+                               ps_dbg_ex_modem(modem, "Internet/mms/tethering  Activated/Activating context present need to deactivate them");
+                               if (cmd == TREQ_NETWORK_SEARCH) {
+                                       g_hash_table_iter_init(&iter, modem->services);
+                                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE)
+                                               _ps_service_disconnect_internet_mms_tethering_contexts(service);
+                               } else {
+                                       rv = tcore_ps_deactivate_contexts(co_ps);
+                                       if (rv != TCORE_RETURN_SUCCESS) {
+                                               ps_dbg_ex_modem(modem, "fail to deactivation");
+                                               return TCORE_HOOK_RETURN_CONTINUE;
+                                       }
+                               }
+                       } else if (CONTEXT_STATE_ACTIVATING == value) {
+                               if (cmd == TREQ_MODEM_SET_FLIGHTMODE) {
+                                       ps_info_ex_modem(modem, "No need to stop these request for pdp in activating state ");
+                                       return TCORE_HOOK_RETURN_CONTINUE;
+                               }
+                               ps_dbg_ex_modem(modem, "For rest command will wait for activation successful ");
+                       }
+                       if (!modem->work_queue) {
+                               ps_err_ex_modem(modem, "no queue present unable to handle request");
+                               return TCORE_HOOK_RETURN_CONTINUE;
+                       }
+
+                       job_cnt = ps_util_get_waiting_job_count(modem->work_queue, cmd);
+                       if (job_cnt) {
+                               ps_err_ex_modem(modem, "duplicated job for cmd(%d)", cmd);
+
+                               if (cmd == TREQ_NETWORK_SEARCH) {
+                                       struct tresp_network_search search_rsp;
+                                       memset(&search_rsp, 0, sizeof(struct tresp_network_search));
+
+                                       search_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
+                                       search_rsp.list_count = 0;
+                                       tcore_user_request_send_response(ur, TRESP_NETWORK_SEARCH,
+                                                                        sizeof(struct tresp_network_search), &search_rsp);
+                               } else if (cmd == TREQ_MODEM_SET_FLIGHTMODE) {
+                                       struct tresp_modem_set_flightmode set_flight_mode;
+                                       memset(&set_flight_mode, 0, sizeof(struct tresp_modem_set_flightmode));
+
+                                       set_flight_mode.result = TCORE_RETURN_OPERATION_ABORTED;
+                                       tcore_user_request_send_response(ur, TRESP_MODEM_SET_FLIGHTMODE,
+                                                                        sizeof(struct tresp_modem_set_flightmode), &set_flight_mode);
+                               }
+
+                               tcore_user_request_unref(ur);
+                               return TCORE_HOOK_RETURN_STOP_PROPAGATION;
+                       }
+                       ret = ps_util_add_waiting_job(modem->work_queue, cmd, ur);
+                       if (!ret) {
+                               ps_err_ex_modem(modem, "fail to add the request to queue");
+                               return TCORE_HOOK_RETURN_CONTINUE;
+                       }
+
+                       __ps_modem_get_mode_pref_change(modem, ur);
+                       __ps_modem_set_hook_flag(modem, cmd);
+                       return TCORE_HOOK_RETURN_STOP_PROPAGATION;
+               } else if (cmd == TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH) {
+                       UserRequest *ur_pending = NULL;
+                       ur_pending = ps_util_pop_waiting_job(modem->work_queue, TREQ_NETWORK_SEARCH);
+
+                       if (!ur_pending) {
+                               ps_dbg_ex_modem(modem, "no pendig search request");
+                               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+                               return TCORE_HOOK_RETURN_CONTINUE;
+                       } else {
+                               struct tresp_network_search search_rsp;
+                               struct tresp_network_set_cancel_manual_search search_cancel_rsp;
+
+                               memset(&search_rsp, 0, sizeof(struct tresp_network_search));
+                               memset(&search_cancel_rsp, 0, sizeof(struct tresp_network_set_cancel_manual_search));
+
+                               search_rsp.list_count = 0;
+                               ps_dbg_ex_modem(modem, "send search response to upper layer");
+                               tcore_user_request_send_response(ur_pending, TRESP_NETWORK_SEARCH, sizeof(struct tresp_network_search), &search_rsp);
+                               tcore_user_request_unref(ur_pending);
+
+                               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+                               search_cancel_rsp.result = TCORE_RETURN_SUCCESS;
+                               tcore_user_request_send_response(ur, TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH,
+                                                                sizeof(struct tresp_network_set_cancel_manual_search), &search_cancel_rsp);
+
+                               return TCORE_HOOK_RETURN_STOP_PROPAGATION;
+                       }
+               }
+               return TCORE_HOOK_RETURN_CONTINUE;
+       }
+
+       if (modem_name)
+               free(modem_name);
+
+       co_ps = tcore_plugin_ref_core_object(target_plg, CORE_OBJECT_TYPE_PS);
+       if (!co_ps)
+               return TCORE_HOOK_RETURN_CONTINUE;
+
+       if (cmd == TREQ_MODEM_POWER_ON) {
+               if (modem->powered == PS_MODEM_STATE_ONLINE) {
+                       struct tresp_modem_power_on set_power_on;
+                       memset(&set_power_on, 0, sizeof(struct tresp_modem_power_on));
+                       ps_dbg_ex_modem(modem, "FLAG: 0x%x", modem->hook_flag);
+
+                       if (modem->hook_flag & PS_NETWORK_SET_POWER_LOW) {
+                               ps_dbg_ex_modem(modem, "LOW power request is pending, send abort response");
+                               set_power_on.result = TCORE_RETURN_OPERATION_ABORTED;
+                               tcore_user_request_send_response(ur, TRESP_MODEM_POWER_ON,
+                                                                sizeof(struct tresp_modem_power_on), &set_power_on);
+                       } else {
+                               ps_dbg_ex_modem(modem, "No pending LOW power request, send success response.");
+                               set_power_on.result = TCORE_RETURN_EALREADY;
+                               tcore_user_request_send_response(ur, TRESP_MODEM_POWER_ON,
+                                                                sizeof(struct tresp_modem_power_on), &set_power_on);
+                       }
+                       tcore_user_request_unref(ur);
+                       return TCORE_HOOK_RETURN_STOP_PROPAGATION;
+               }
+               return TCORE_HOOK_RETURN_CONTINUE;
+       }
+       if (FALSE == tcore_ps_any_context_activating_activated(co_ps, &value)) {
+               ps_dbg_ex_modem(modem, "No activating/activated context present");
+               /* Block PS always-on while network operations. */
+               __ps_modem_get_mode_pref_change(modem, ur);
+               __ps_modem_set_hook_flag(modem, cmd);
+               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+               return TCORE_HOOK_RETURN_CONTINUE;
+       }
+
+       ps_info_ex_modem(modem, "Value returned [%d]", value);
+       if (CONTEXT_STATE_ACTIVATED == value) {
+               ps_dbg_ex_modem(modem, "Internet/mms/tethering Activated/Activating context present need to deactivate them");
+               if (cmd == TREQ_NETWORK_SEARCH || cmd == TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH) {
+                       g_hash_table_iter_init(&iter, modem->services);
+                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE)
+                               _ps_service_disconnect_internet_mms_tethering_contexts(service);
+               } else {
+                       rv = tcore_ps_deactivate_contexts(co_ps);
+                       if (cmd == TREQ_MODEM_SET_FLIGHTMODE || cmd == TREQ_MODEM_POWER_OFF)
+                               __ps_set_deactivation_timeout(modem, 10);
+                       if (rv != TCORE_RETURN_SUCCESS) {
+                               ps_dbg_ex_modem(modem, "fail to deactivation");
+                               return TCORE_HOOK_RETURN_CONTINUE;
+                       }
+               }
+       } else if (CONTEXT_STATE_ACTIVATING == value) {
+               if ((cmd == TREQ_MODEM_SET_FLIGHTMODE) || (cmd == TREQ_MODEM_POWER_OFF)) {
+                       ps_info_ex_modem(modem, "No need to stop these request for pdp in activating state ");
+                       return TCORE_HOOK_RETURN_CONTINUE;
+               }
+               ps_dbg_ex_modem(modem, "For rest command will wait for activation successful ");
+       }
+
+       if (!modem->work_queue) {
+               ps_err_ex_modem(modem, "no queue present unable to handle request");
+               return TCORE_HOOK_RETURN_CONTINUE;
+       }
+
+       job_cnt = ps_util_get_waiting_job_count(modem->work_queue, cmd);
+       if (job_cnt) {
+               ps_err_ex_modem(modem, "duplicated job for cmd(%d)", cmd);
+
+               if (cmd == TREQ_NETWORK_SEARCH) {
+                       struct tresp_network_search search_rsp;
+                       memset(&search_rsp, 0, sizeof(struct tresp_network_search));
+
+                       search_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
+                       search_rsp.list_count = 0;
+                       tcore_user_request_send_response(ur, TRESP_NETWORK_SEARCH,
+                                                        sizeof(struct tresp_network_search), &search_rsp);
+               } else if (cmd == TREQ_NETWORK_SET_PLMN_SELECTION_MODE) {
+                       struct tresp_network_set_plmn_selection_mode set_plmn_mode_rsp;
+                       memset(&set_plmn_mode_rsp, 0, sizeof(struct tresp_network_set_plmn_selection_mode));
+
+                       set_plmn_mode_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
+                       tcore_user_request_send_response(ur, TRESP_NETWORK_SET_PLMN_SELECTION_MODE,
+                                                        sizeof(struct tresp_network_set_plmn_selection_mode), &set_plmn_mode_rsp);
+               } else if (cmd == TREQ_NETWORK_SET_MODE) {
+                       struct tresp_network_set_mode setmode_rsp;
+                       memset(&setmode_rsp, 0, sizeof(struct tresp_network_set_mode));
+
+                       setmode_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
+                       tcore_user_request_send_response(ur, TRESP_NETWORK_SET_MODE,
+                                                        sizeof(struct tresp_network_set_mode), &setmode_rsp);
+               } else if (cmd == TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH) {
+                       struct tresp_network_set_cancel_manual_search search_cancel_rsp;
+                       memset(&search_cancel_rsp, 0, sizeof(struct tresp_network_set_cancel_manual_search));
+
+                       search_cancel_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
+                       tcore_user_request_send_response(ur, TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH,
+                                                        sizeof(struct tresp_network_set_cancel_manual_search), &search_cancel_rsp);
+               } else if (cmd == TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION) {
+                       struct tresp_network_set_default_data_subscription default_data_rsp;
+                       memset(&default_data_rsp, 0, sizeof(struct tresp_network_set_default_data_subscription));
+
+                       default_data_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
+                       tcore_user_request_send_response(ur, TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION,
+                                                        sizeof(struct tresp_network_set_default_data_subscription), &default_data_rsp);
+               } else if (cmd == TREQ_MODEM_SET_FLIGHTMODE) {
+                       struct tresp_modem_set_flightmode set_flight_mode;
+                       memset(&set_flight_mode, 0, sizeof(struct tresp_modem_set_flightmode));
+
+                       set_flight_mode.result = TCORE_RETURN_OPERATION_ABORTED;
+                       tcore_user_request_send_response(ur, TRESP_MODEM_SET_FLIGHTMODE,
+                                                        sizeof(struct tresp_modem_set_flightmode), &set_flight_mode);
+               } else if (cmd == TREQ_MODEM_POWER_OFF) {
+                       struct tresp_modem_power_off set_power_off;
+                       memset(&set_power_off, 0, sizeof(struct tresp_modem_power_off));
+
+                       set_power_off.result = TCORE_RETURN_OPERATION_ABORTED;
+                       tcore_user_request_send_response(ur, TRESP_MODEM_POWER_OFF,
+                                                        sizeof(struct tresp_modem_power_off), &set_power_off);
+
+               } else if (cmd == TREQ_MODEM_POWER_LOW) {
+                       struct tresp_modem_power_low set_power_low;
+                       memset(&set_power_low, 0, sizeof(struct tresp_modem_power_low));
+
+                       set_power_low.result = TCORE_RETURN_OPERATION_ABORTED;
+                       tcore_user_request_send_response(ur, TRESP_MODEM_POWER_LOW,
+                                                        sizeof(struct tresp_modem_power_low), &set_power_low);
+
+               } else if (cmd == TREQ_SIM_SET_POWERSTATE) {
+                       struct tresp_sim_set_powerstate set_power;
+                       memset(&set_power, 0, sizeof(struct tresp_sim_set_powerstate));
+
+                       set_power.result = TCORE_RETURN_OPERATION_ABORTED;
+                       tcore_user_request_send_response(ur, TRESP_SIM_SET_POWERSTATE,
+                                                        sizeof(struct tresp_sim_set_powerstate), &set_power);
+
+               }
+               tcore_user_request_unref(ur);
+               return TCORE_HOOK_RETURN_STOP_PROPAGATION;
+       }
+
+       ps_dbg_ex_modem(modem, "Deactivation request is sent, wait for call disconnect notification ");
+
+       if (TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH == cmd) {
+               UserRequest *ur_pending = NULL;
+               ur_pending = ps_util_pop_waiting_job(modem->work_queue, TREQ_NETWORK_SEARCH);
+
+               if (!ur_pending) {
+                       ps_dbg_ex_modem(modem, "no pendig search request");
+                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+                       return TCORE_HOOK_RETURN_CONTINUE;
+               } else {
+                       struct tresp_network_search search_rsp;
+                       struct tresp_network_set_cancel_manual_search search_cancel_rsp;
+
+                       memset(&search_rsp, 0, sizeof(struct tresp_network_search));
+                       memset(&search_cancel_rsp, 0, sizeof(struct tresp_network_set_cancel_manual_search));
+
+                       search_rsp.list_count = 0;
+                       ps_dbg_ex_modem(modem, "send search response to upper layer");
+                       tcore_user_request_send_response(ur_pending, TRESP_NETWORK_SEARCH, sizeof(struct tresp_network_search), &search_rsp);
+                       tcore_user_request_unref(ur_pending);
+
+                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+                       search_cancel_rsp.result = TCORE_RETURN_SUCCESS;
+                       tcore_user_request_send_response(ur, TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH,
+                                                        sizeof(struct tresp_network_set_cancel_manual_search), &search_cancel_rsp);
+
+                       return TCORE_HOOK_RETURN_STOP_PROPAGATION;
+               }
+       }
+
+       ret = ps_util_add_waiting_job(modem->work_queue, cmd, ur);
+       if (!ret) {
+               ps_err_ex_modem(modem, "fail to add the request to queue");
+               return TCORE_HOOK_RETURN_CONTINUE;
+       }
+
+       __ps_modem_get_mode_pref_change(modem, ur);
+       __ps_modem_set_hook_flag(modem, cmd);
+       return TCORE_HOOK_RETURN_STOP_PROPAGATION;
+}
+
+guchar _ps_hook_get_hook_flag(ps_modem_t *modem)
+{
+       g_return_val_if_fail(modem != NULL, FALSE);
+       return modem->hook_flag;
+}
+
+GQueue *_ps_hook_ref_work_queue(ps_modem_t *modem)
+{
+       g_return_val_if_fail(modem != NULL, NULL);
+       return modem->work_queue;
+}
+
+void _ps_hook_cp_reset_send_pending_request_response(ps_modem_t *modem)
+{
+       gpointer queue_data = NULL;
+
+       ps_info_ex_modem(modem, "Entered");
+       queue_data = g_queue_pop_head(modem->work_queue);
+       while (queue_data) {
+               struct work_queue_data *wqd = queue_data;
+               if (wqd->ur) {
+                       enum tcore_request_command cmd = tcore_user_request_get_command(wqd->ur);
+
+                       if (cmd == TREQ_NETWORK_SEARCH) {
+                               struct tresp_network_search search_rsp;
+                               memset(&search_rsp, 0, sizeof(struct tresp_network_search));
+
+                               search_rsp.result = TCORE_RETURN_FAILURE;
+                               search_rsp.list_count = 0;
+                               tcore_user_request_send_response(wqd->ur, TRESP_NETWORK_SEARCH,
+                                                                sizeof(struct tresp_network_search), &search_rsp);
+                       } else if (cmd == TREQ_NETWORK_SET_PLMN_SELECTION_MODE) {
+                               struct tresp_network_set_plmn_selection_mode set_plmn_mode_rsp;
+                               memset(&set_plmn_mode_rsp, 0, sizeof(struct tresp_network_set_plmn_selection_mode));
+
+                               set_plmn_mode_rsp.result = TCORE_RETURN_FAILURE;
+                               tcore_user_request_send_response(wqd->ur, TRESP_NETWORK_SET_PLMN_SELECTION_MODE,
+                                                                sizeof(struct tresp_network_set_plmn_selection_mode), &set_plmn_mode_rsp);
+                       } else if (cmd == TREQ_NETWORK_SET_MODE) {
+                               struct tresp_network_set_mode setmode_rsp;
+                               memset(&setmode_rsp, 0, sizeof(struct tresp_network_set_mode));
+
+                               setmode_rsp.result = TCORE_RETURN_FAILURE;
+                               tcore_user_request_send_response(wqd->ur, TRESP_NETWORK_SET_MODE,
+                                                                sizeof(struct tresp_network_set_mode), &setmode_rsp);
+                       } else if (cmd == TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH) {
+                               struct tresp_network_set_cancel_manual_search search_cancel_rsp;
+                               memset(&search_cancel_rsp, 0, sizeof(struct tresp_network_set_cancel_manual_search));
+
+                               search_cancel_rsp.result = TCORE_RETURN_FAILURE;
+                               tcore_user_request_send_response(wqd->ur, TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH,
+                                                                sizeof(struct tresp_network_set_cancel_manual_search), &search_cancel_rsp);
+                       } else if (cmd == TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION) {
+                               struct tresp_network_set_default_data_subscription default_data_rsp;
+                               memset(&default_data_rsp, 0, sizeof(struct tresp_network_set_default_data_subscription));
+
+                               default_data_rsp.result = TCORE_RETURN_FAILURE;
+                               tcore_user_request_send_response(wqd->ur, TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION,
+                                                                sizeof(struct tresp_network_set_default_data_subscription), &default_data_rsp);
+                       } else if (cmd == TREQ_MODEM_SET_FLIGHTMODE) {
+                               struct tresp_modem_set_flightmode set_flight_mode;
+                               memset(&set_flight_mode, 0, sizeof(struct tresp_modem_set_flightmode));
+
+                               set_flight_mode.result = TCORE_RETURN_FAILURE;
+                               tcore_user_request_send_response(wqd->ur, TRESP_MODEM_SET_FLIGHTMODE,
+                                                                sizeof(struct tresp_modem_set_flightmode), &set_flight_mode);
+                       } else if (cmd == TREQ_MODEM_POWER_OFF) {
+                               struct tresp_modem_power_off set_power_off;
+                               memset(&set_power_off, 0, sizeof(struct tresp_modem_power_off));
+
+                               set_power_off.result = TCORE_RETURN_FAILURE;
+                               tcore_user_request_send_response(wqd->ur, TRESP_MODEM_POWER_OFF,
+                                                                sizeof(struct tresp_modem_power_off), &set_power_off);
+
+                       } else if (cmd == TREQ_MODEM_POWER_LOW) {
+                               struct tresp_modem_power_low set_power_low;
+                               memset(&set_power_low, 0, sizeof(struct tresp_modem_power_low));
+
+                               set_power_low.result = TCORE_RETURN_FAILURE;
+                               tcore_user_request_send_response(wqd->ur, TRESP_MODEM_POWER_LOW,
+                                                                sizeof(struct tresp_modem_power_low), &set_power_low);
+
+                       } else if (cmd == TREQ_SIM_SET_POWERSTATE) {
+                               struct tresp_sim_set_powerstate set_power;
+                               memset(&set_power, 0, sizeof(struct tresp_sim_set_powerstate));
+
+                               set_power.result = TCORE_RETURN_FAILURE;
+                               tcore_user_request_send_response(wqd->ur, TRESP_SIM_SET_POWERSTATE,
+                                                                sizeof(struct tresp_sim_set_powerstate), &set_power);
+
+                       } else {
+                               ps_err_ex_modem(modem, "Unexpected command ");
+                       }
+                       tcore_user_request_unref(wqd->ur);
+
+                       /* Memory Free */
+                       free(wqd);
+               }
+               queue_data = g_queue_pop_head(modem->work_queue);
+       }
+}
+
+void _ps_hook_send_pending_user_request(ps_modem_t *modem)
+{
+       TcorePlugin *plugin = NULL;
+       CoreObject *co_network = NULL;
+       CoreObject *co_modem = NULL;
+       CoreObject *co_sim = NULL;
+       gpointer queue_data = NULL;
+
+       co_modem = _ps_modem_ref_co_modem(modem);
+       plugin = tcore_object_ref_plugin(co_modem);
+       co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
+       co_sim = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SIM);
+
+       ps_dbg_ex_modem(modem, "Extracting the user request from the work queue");
+
+       queue_data = g_queue_pop_head(modem->work_queue);
+       while (queue_data) {
+               struct work_queue_data *wqd = queue_data;
+               ps_info_ex_modem(modem, " sending Pending request [%x]", wqd->id);
+               if (wqd->ur) {
+                       ps_dbg_ex_modem(modem, "Setting responce hook for request ");
+                       tcore_user_request_set_response_hook(wqd->ur, __ps_hook_response_cb, modem);
+
+                       switch (wqd->id) {
+                       case TREQ_NETWORK_SEARCH:
+                       case TREQ_NETWORK_SET_MODE:
+                       case TREQ_NETWORK_SET_PLMN_SELECTION_MODE:
+                       case TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION: {
+                               char *modem_name;
+                               TcorePlugin *modem_plugin, *ur_modem_plugin;
+
+                               modem_name = tcore_user_request_get_modem_name(wqd->ur);
+                               if (!modem_name)
+                                       return;
+
+                               modem_plugin = tcore_object_ref_plugin(co_modem);
+                               ur_modem_plugin = tcore_server_find_plugin(tcore_plugin_ref_server(modem_plugin), modem_name);
+                               if (modem_plugin != ur_modem_plugin) {
+                                       ps_info_ex_modem(modem, "request modem (%s) not matched current modem(%s)",
+                                                        modem_name, tcore_server_get_cp_name_by_plugin(modem_plugin));
+                                       /* Network search request enqueued for other sim, so dispatch it */
+                                       if (wqd->id == TREQ_NETWORK_SEARCH) {
+                                               CoreObject *co_other_network;
+
+                                               co_other_network = tcore_plugin_ref_core_object(ur_modem_plugin, CORE_OBJECT_TYPE_NETWORK);
+                                               if (co_other_network == NULL) {
+                                                       ps_warn_ex_modem(modem, "No network core object in other modem plugin");
+                                               } else {
+                                                       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_other_network, wqd->ur))
+                                                               ps_err_ex_modem(modem, "Failed to dispatch ");
+                                               }
+                                               free(modem_name);
+                                               break;
+                                       } else {
+                                               return;
+                                       }
+                               }
+                               free(modem_name);
+                               if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_network, wqd->ur))
+                                       ps_err_ex_modem(modem, "Failed to dispatch ");
+                       }
+                       break;
+
+                       case TREQ_MODEM_SET_FLIGHTMODE:
+                       case TREQ_MODEM_POWER_OFF: {
+                               char *modem_name;
+                               TcorePlugin *modem_plugin, *ur_modem_plugin;
+
+                               modem_name = tcore_user_request_get_modem_name(wqd->ur);
+                               if (!modem_name)
+                                       return;
+
+                               modem_plugin = tcore_object_ref_plugin(co_modem);
+                               ur_modem_plugin = tcore_server_find_plugin(tcore_plugin_ref_server(modem_plugin), modem_name);
+                               if (modem_plugin != ur_modem_plugin) {
+                                       ps_info_ex_modem(modem, "request modem (%s) not matched current modem(%s)",
+                                                        modem_name, tcore_server_get_cp_name_by_plugin(modem_plugin));
+                                       /* Flight mode request enqueued for other sim, so dispatch it */
+                                       if (wqd->id == TREQ_MODEM_SET_FLIGHTMODE) {
+                                               CoreObject *co_other_modem;
+
+                                               co_other_modem = tcore_plugin_ref_core_object(ur_modem_plugin, CORE_OBJECT_TYPE_MODEM);
+                                               if (co_other_modem == NULL) {
+                                                       ps_warn_ex_modem(modem, "No modem core object in other modem plugin");
+                                               } else {
+                                                       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_other_modem, wqd->ur))
+                                                               ps_err_ex_modem(modem, "Failed to dispatch ");
+                                               }
+                                               free(modem_name);
+                                               break;
+                                       } else {
+                                               free(modem_name);
+                                               return;
+                                       }
+                               }
+                               free(modem_name);
+
+                               if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_modem, wqd->ur))
+                                       ps_err_ex_modem(modem, "Failed to dispatch ");
+                       }
+                       break;
+
+                       case TREQ_MODEM_POWER_LOW:
+                               if (modem->hook_flag & PS_NETWORK_SET_POWER_LOW)
+                                       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_modem, wqd->ur))
+                                               err("Failed to dispatch ");
+                               break;
+
+                       case TREQ_SIM_SET_POWERSTATE:
+                               if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_sim, wqd->ur))
+                                       ps_err_ex_modem(modem, "Failed to dispatch ");
+                               break;
+
+                       default:
+                               ps_err_ex_modem(modem, "No expected request ");
+                       }
+               }
+
+               /* Freeing Allocated memory*/
+               free(wqd);
+               queue_data = g_queue_pop_head(modem->work_queue);
+       }
+
+       ps_dbg_ex_modem(modem, "All pending request sent ");
+}
+
+gboolean _ps_hook_add_modem_hooks(ps_modem_t *modem)
+{
+       Server *s = NULL;
+       g_return_val_if_fail(modem != NULL, FALSE);
+       s = tcore_plugin_ref_server(_ps_modem_ref_plugin(modem));
+
+       /* Adding hooks for special Network Requests */
+       tcore_server_add_request_hook(s, TREQ_NETWORK_SEARCH, ps_handle_hook, modem);
+       tcore_server_add_request_hook(s, TREQ_NETWORK_SET_PLMN_SELECTION_MODE, ps_handle_hook, modem);
+       tcore_server_add_request_hook(s, TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH, ps_handle_hook, modem);
+       tcore_server_add_request_hook(s, TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION, ps_handle_hook, modem);
+       tcore_server_add_request_hook(s, TREQ_SIM_SET_POWERSTATE, ps_handle_hook, modem);
+       tcore_server_add_request_hook(s, TREQ_MODEM_SET_FLIGHTMODE, ps_handle_hook, modem);
+       tcore_server_add_request_hook(s, TREQ_MODEM_POWER_OFF, ps_handle_hook, modem);
+       tcore_server_add_request_hook(s, TREQ_MODEM_POWER_LOW, ps_handle_hook, modem);
+       tcore_server_add_request_hook(s, TREQ_MODEM_POWER_ON, ps_handle_hook, modem);
+
+       return TRUE;
+}
+
+gboolean _ps_hook_free_modem_hooks(ps_modem_t *modem)
+{
+       return TRUE;
+}
+
+#endif /* TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL */
index 5e8bfd8..f09cd76 100644 (file)
 
 #include <glib.h>
 
-const gchar *ps_log_get_cp_name(CoreObject *co);
+#include "ps_log.h"
 
-const gchar *ps_log_get_cp_name(CoreObject *co)
+const char *ps_log_tag_name[PS_SUBS_MAX] = {
+       [PS_SUBS_PRIMARY] = "PS/SUBS-0",
+       [PS_SUBS_SECONDARY] = "PS/SUBS-1",
+};
+
+const gchar *ps_log_get_tag_by_modem(ps_modem_t *modem)
 {
-       const char *cp_name;
-       cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(co));
+       ps_subs_type subs_type = modem ? modem->subs_type : PS_SUBS_PRIMARY;
+       return ps_log_tag_name[subs_type];
+}
 
-       return cp_name;
+const gchar *ps_log_get_tag_by_service(ps_service_t *service)
+{
+       ps_subs_type subs_type = service ? service->subs_type : PS_SUBS_PRIMARY;
+       return ps_log_tag_name[subs_type];
 }
+
+const gchar *ps_log_get_tag_by_context(ps_context_t *context)
+{
+       ps_subs_type subs_type = context ? context->subs_type : PS_SUBS_PRIMARY;
+       return ps_log_tag_name[subs_type];
+}
+
index 0dedd90..2477ee4 100644 (file)
 #include <plugin.h>
 
 #include "ps_main.h"
-#include <ps_common.h>
-
+#include "ps_common.h"
+#include "ps_context.h"
+#include "ps_master.h"
+#include "ps_modem.h"
 /*
  * PS plugin Private information
  */
@@ -52,7 +54,7 @@ static void __packet_service_cleanup(PsPrivInfo *priv_info)
 
        /* Cleaning up the master list */
        g_slist_foreach(priv_info->master,
-               __remove_master, NULL);
+                       __remove_master, NULL);
 
        /* Unowning the Gdbus */
        g_bus_unown_name(priv_info->bus_id);
@@ -68,10 +70,10 @@ static void __packet_service_cleanup(PsPrivInfo *priv_info)
 }
 
 static void on_bus_acquired(GDBusConnection *conn,
-       const gchar *name, gpointer user_data)
+                           const gchar *name, gpointer user_data)
 {
        gboolean rv = FALSE;
-       gpointer *master = NULL;
+       ps_master_t *master = NULL;
 
        TcorePlugin *p = user_data;
        PsPrivInfo *priv_info = tcore_plugin_ref_user_data(p);
@@ -107,7 +109,7 @@ static void on_bus_acquired(GDBusConnection *conn,
 
        return;
 
-FAILURE:
+ FAILURE:
        ps_main_exit(p);
 }
 
@@ -149,14 +151,14 @@ gboolean ps_main_init(TcorePlugin *p)
        g_assert_no_error(error);
 
        conn = g_dbus_connection_new_for_address_sync(address,
-               G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
-               G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
-               NULL,
-               NULL,
-               &error);
+                                                     G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
+                                                     G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
+                                                     NULL,
+                                                     NULL,
+                                                     &error);
        g_assert_no_error(error);
        if (!conn)
-               err("Failure: G-dBus Connection failed"); /* TODO - Clean-up */
+               err("Failure: G-dBus Connection failed");  /* TODO - Clean-up */
 
        /*
         * Storing the G-dBus connection in Private information of PS Plugin
@@ -164,15 +166,15 @@ gboolean ps_main_init(TcorePlugin *p)
        priv_info->conn = conn;
 
        id = g_bus_own_name_on_connection(conn,
-               PS_DBUS_SERVICE,
-               G_BUS_NAME_OWNER_FLAGS_REPLACE,
-               on_bus_acquired,
-               NULL,
-               p,
-               NULL);
+                                         PS_DBUS_SERVICE,
+                                         G_BUS_NAME_OWNER_FLAGS_REPLACE,
+                                         on_bus_acquired,
+                                         NULL,
+                                         p,
+                                         NULL);
 
        info("PacketService - dBus address: [%s] dBus connection ID: [%d]",
-               address, id);
+            address, id);
        g_free(address);
 
        /*
index 478f4ae..b8d89d3 100644 (file)
 #include <unistd.h>
 
 #include "ps_common.h"
-#include "generated-code.h"
+#include "ps_context.h"
+#include "ps_master.h"
+#include "ps_modem.h"
+#include "ps_service.h"
+#include "ps_master_interface.h"
 
 #include <server.h>
 #include <plugin.h>
 #include <storage.h>
-#include <hal.h>
-#include <user_request.h>
 #include <co_context.h>
 
-#define PS_MASTER_PATH "/"
-#define PROP_DEFAULT           FALSE
-#define PROP_DEFAULT_STR       NULL
+#include "ps_log.h"
 
 /* [Wearable][sap-stack] SAPInterface.h */
-#define SAP_CONN_TYPE_ALL      0x00
-#define SAP_CONN_TYPE_BT       0x01
-#define SAP_CONN_TYPE_MOBILE   0x10 /* scs */
+#define SAP_CONN_TYPE_ALL       0x00
+#define SAP_CONN_TYPE_BT        0x01
+#define SAP_CONN_TYPE_MOBILE    0x10 /* scs */
 
-static void __ps_master_emit_modem_added_signal(ps_master_t *master, gpointer modem);
-/*static void __ps_master_emit_modem_removed_signal(ps_master_t *master, gpointer modem);*/
-static void _ps_master_setup_interface(PacketServiceMaster *master, ps_master_t *master_data);
+#define _PS_CHECK_STRG(master) { \
+               if (G_UNLIKELY(!master->strg)) { \
+                       warn("Updating strg"); \
+                       master->strg = tcore_server_find_storage(tcore_plugin_ref_server(master->plg), "vconf"); \
+               } \
+} \
 
-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);
 
-static void __ps_master_handle_ups_mode(gpointer object, gchar *request)
+static void __ps_master_handle_ups_mode(ps_modem_t *modem, gchar *request)
 {
-       ps_modem_t *modem = object;
        GSList *contexts = NULL;
        unsigned int index;
 
-       if (modem == NULL)
+       if (G_UNLIKELY(!modem))
                return;
 
        info("send dbus %s requeset", request);
        contexts = modem->contexts;
-       if (contexts == NULL) {
+       if (!contexts) {
                err("no profiles");
                return;
        }
 
        for (index = 0; index < g_slist_length(contexts); index++) {
-               gchar *s_path = NULL;
-               gpointer value = g_slist_nth_data(contexts, index);
-               ps_context_t *pscontext = (ps_context_t *)value;
-               int role = tcore_context_get_role(pscontext->co_context);
+               ps_context_t *context = g_slist_nth_data(contexts, index);
+               CoreObject *co_context = _ps_context_ref_co_context(context);
+               int role = tcore_context_get_role(co_context);
 
-               s_path = _ps_context_ref_path(value);
-               dbg("value(%p), path(%s)", value, s_path);
+               dbg("context(%p), path(%s), role(%d)", context, _ps_context_ref_path(context), role);
 
-               if (role == CONTEXT_ROLE_INTERNET && pscontext->is_default) {
+               if (role == CONTEXT_ROLE_INTERNET && context->is_default) {
                        if (!g_strcmp0(request, "IfaceDown"))
-                               _ps_context_handle_ifacedown(value);
+                               _ps_context_handle_ifacedown(context);
                        else if (!g_strcmp0(request, "IfaceUp"))
-                               _ps_context_handle_ifaceup(value);
+                               _ps_context_handle_ifaceup(context);
                } else if (role == CONTEXT_ROLE_UNKNOWN || role == CONTEXT_ROLE_USER_DEFINED) {
                        warn("Not supported profile type: %d", role);
                        continue;
                } else {
-                       if (CONTEXT_STATE_ACTIVATED != tcore_context_get_state(pscontext->co_context))
+                       if (CONTEXT_STATE_ACTIVATED != tcore_context_get_state(co_context))
                                continue;
 
                        if (!g_strcmp0(request, "InterfaceDown")) {
                                warn("disconnect context request.");
-                               _ps_service_deactivate_context(pscontext->p_service, pscontext);
+                               _ps_service_deactivate_context(_ps_context_ref_service(context), context);
                        }
                }
        }
-       return;
+}
+
+static void __ps_master_register_key_callback(ps_master_t *master, enum tcore_storage_key key)
+{
+       _PS_CHECK_STRG(master);
+       tcore_storage_set_key_callback(master->strg, key, __ps_master_storage_key_callback, master);
+}
+
+static void __ps_master_deregister_key_callback(ps_master_t *master, enum tcore_storage_key key)
+{
+       _PS_CHECK_STRG(master);
+       tcore_storage_remove_key_callback(master->strg, key, __ps_master_storage_key_callback);
 }
 
 void __remove_master(gpointer data, gpointer user_data)
 {
        ps_master_t *master = data;
+       Server *s;
 
-       info("Entered");
+       info("master:[%p]", master);
 
        /*Deinit alarm*/
        alarmmgr_fini();
 
-       /* Remove notification hooks */
-       tcore_server_remove_notification_hook(tcore_plugin_ref_server(master->plg), __on_hook_modem_added);
-       tcore_server_remove_notification_hook(tcore_plugin_ref_server(master->plg), __on_hook_modem_removed);
+       /*Registering the key callbacks for values in storage settings */
+       __ps_master_deregister_key_callback(master, KEY_TELEPHONY_READY);
+       __ps_master_deregister_key_callback(master, KEY_3G_ENABLE);
+       __ps_master_deregister_key_callback(master, KEY_DATA_ROAMING_SETTING);
+#if defined(TIZEN_UPS_ENABLED)
+       __ps_master_deregister_key_callback(master, KEY_POWER_SAVING_MODE);
+       __ps_master_deregister_key_callback(master, KEY_PM_STATE);
+#endif
+
+       s = tcore_plugin_ref_server(master->plg);
+
+       tcore_server_remove_notification_hook(s, __on_hook_modem_added);
+       tcore_server_remove_notification_hook(s, __on_hook_modem_removed);
 
        /*Need to remove the compelete hash table*/
        g_hash_table_remove_all(master->modems);
@@ -116,46 +137,12 @@ void __remove_master(gpointer data, gpointer user_data)
        g_object_unref(master->if_obj);
 
        /*Need to free the memory allocated for the members of the master*/
-       g_free(master->path);
        g_free(master);
-
-       dbg("Exiting");
-       return;
-}
-
-static void __ps_master_emit_modem_added_signal(ps_master_t *master, gpointer modem)
-{
-       GVariant *gv = NULL;
-       GVariantBuilder properties;
-
-       dbg("get modem properties");
-
-       gv = _ps_modem_get_properties(modem, &properties);
-       packet_service_master_emit_modem_added(master->if_obj, gv);
+       master = NULL;
 
        dbg("Exiting");
 }
 
-#if 0
-static void __ps_master_emit_modem_removed_signal(ps_master_t *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);
-}
-#endif
-
-static void __ps_master_register_key_callback(gpointer object, enum tcore_storage_key key)
-{
-       ps_master_t *master = (ps_master_t *) object;
-       Server *s = tcore_plugin_ref_server(master->plg);
-       static Storage *strg;
-
-       strg = tcore_server_find_storage(s, "vconf");
-       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;
@@ -164,11 +151,10 @@ static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *v
        gboolean type_check = FALSE;
        ps_master_t *master = (ps_master_t *)user_data;
 
-       dbg("storage key(%d) callback", key);
        g_return_if_fail(master != NULL);
 
        tmp = (GVariant *)value;
-       if (!tmp) {
+       if (G_UNLIKELY(!tmp)) {
                err("value is null");
                return;
        }
@@ -184,20 +170,17 @@ static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *v
                        g_variant_unref(tmp);
                        return;
                }
-       break;
+               break;
 
        case KEY_POWER_SAVING_MODE:
        case KEY_PM_STATE:
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-       case KEY_WECONN_ALL_CONNECTED:
-#endif
                type_check = g_variant_is_of_type(tmp, G_VARIANT_TYPE_INT32);
                if (!type_check) {
                        err("wrong variant data type");
                        g_variant_unref(tmp);
                        return;
                }
-       break;
+               break;
 
        default:
                warn("unknown key (0x%x)", key);
@@ -209,18 +192,6 @@ static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *v
                if (key == KEY_3G_ENABLE) {
                        gboolean data_allowed = g_variant_get_boolean(tmp);
                        msg("[PSINFO] data_allowed [%d] changed", data_allowed);
-#if defined(TIZEN_PS_FORCE_ATTACH_DETACH)
-                       if (_ps_master_get_storage_value_int(master, KEY_WECONN_ALL_CONNECTED) > 0) {
-                               if (data_allowed) {
-                                       int sap_conn_type = SAP_CONN_TYPE_ALL;
-                                       sap_conn_type = _ps_master_get_storage_value_int(master, KEY_SAP_CONNECTION_TYPE);
-                                       if (sap_conn_type == SAP_CONN_TYPE_BT) {
-                                               warn("[Companion mode] ignore data_allowed.");
-                                               return;
-                                       }
-                               }
-                       }
-#endif
                        _ps_modem_set_data_allowed(h_value, data_allowed);
                } else if (key == KEY_DATA_ROAMING_SETTING) {
                        gboolean roaming_allowed = g_variant_get_boolean(tmp);
@@ -233,7 +204,7 @@ static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *v
                        if (curr_ps_mode & POWER_SAVING_MODE_DATA_ALLOWED)
                                new_ps_mode |= POWER_SAVING_MODE_DATA_ALLOWED;
 
-                       info("curr_ps_mode [0X%x] new_ps_mode[0X%x]", curr_ps_mode, new_ps_mode);
+                       info("[PSINFO] curr_ps_mode [0X%x] new_ps_mode[0X%x]", curr_ps_mode, new_ps_mode);
                        _ps_modem_set_psmode(h_value, new_ps_mode);
                } else if (key == KEY_PM_STATE) {
                        gint pm_state = g_variant_get_int32(tmp);
@@ -246,17 +217,21 @@ static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *v
                                warn("UPS by FMM: Do not change data network state.");
                                return;
                        }
-                       if (pm_state == 3) {/* LCD Off */
+                       if (pm_state == 3) { /* LCD Off */
                                if (ps_mode > POWER_SAVING_MODE_NORMAL && ps_mode < POWER_SAVING_MODE_WEARABLE) {
                                        msg("[PSINFO] LCD OFF. Start Deactivate with power saving [%d]", ps_mode);
                                        /* send dbus request pdp context deactivation. */
                                        __ps_master_handle_ups_mode(h_value, "IfaceDown");
+                               } else {
+                                       _ps_modem_set_pm_state(h_value, pm_state);
                                }
                        } else { /* LCD On or dimming */
                                if (ps_mode > POWER_SAVING_MODE_NORMAL && ps_mode < POWER_SAVING_MODE_WEARABLE) {
                                        msg("[PSINFO] pm_state(%d) changed. Start activate with power saving [%d]", pm_state, ps_mode);
                                        /* send dbus request pdp context activation. */
                                        __ps_master_handle_ups_mode(h_value, "IfaceUp");
+                               } else {
+                                       _ps_modem_set_pm_state(h_value, pm_state);
                                }
                        }
                } else if (key == KEY_NETWORK_RESTRICT_MODE) {
@@ -290,56 +265,77 @@ static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *v
                } else if (key == KEY_TELEPHONY_READY) {
                        gboolean b_telephony_ready = _ps_master_get_storage_value_bool(master, KEY_TELEPHONY_READY);
                        if (b_telephony_ready)
-                               __ps_master_emit_modem_added_signal(master, h_value);
+                               ps_master_emit_modem_added_signal(master, h_value);
                }
        }
 
-       return;
 }
 
-gpointer _ps_master_create_master(GDBusConnection *conn, TcorePlugin *p)
+static gboolean __ps_master_create_modem(ps_master_t *master, TcorePlugin *modem_plg)
 {
-       PacketServiceMaster *master = NULL;
-       ps_master_t *new_master = NULL;
-       GError *error = NULL;
+       ps_modem_t *modem = NULL, *tmp = NULL;
+       gchar *modem_name = NULL;
+       gchar *cp_name = NULL;
+       CoreObject *co_modem = NULL;
+       gboolean key_telephony_ready;
 
-       dbg("master object create");
-       g_return_val_if_fail(conn != NULL, NULL);
+       g_return_val_if_fail(master != NULL, FALSE);
 
-       /*creating the master object for the interface com.tcore.ps.master*/
-       master = packet_service_master_skeleton_new();
-       g_return_val_if_fail(master != NULL, NULL);
+       cp_name = (gchar *)tcore_server_get_cp_name_by_plugin(modem_plg);
+       modem_name = g_strdup_printf("/%s", cp_name);
+       tmp = g_hash_table_lookup(master->modems, modem_name);
+       if (tmp != NULL) {
+               dbg("modem (%p) already existed", tmp);
+               g_free(modem_name);
+               return FALSE;
+       }
 
-       /*Alarm manager init*/
-       dbg("init alarm manager.");
-       if (alarmmgr_init("packetservice") != ALARMMGR_RESULT_SUCCESS) {
-               err("Failed to init alarm manager");
-               goto FAILURE;
+       dbg("create modem(%s) objects", modem_name);
+       co_modem = tcore_plugin_ref_core_object(modem_plg, CORE_OBJECT_TYPE_MODEM);
+       modem = _ps_modem_create_modem(master->conn, master->plg, master, modem_name, co_modem, cp_name);
+       if (!modem) {
+               err("fail to create modem");
+               g_free(modem_name);
+               return FALSE;
        }
 
+       g_hash_table_insert(master->modems, g_strdup(modem_name), modem);
+       info("modem (%p) created at path %s", modem, modem_name);
+       key_telephony_ready = _ps_master_get_storage_value_bool(master, KEY_TELEPHONY_READY);
+       if (key_telephony_ready)
+               ps_master_emit_modem_added_signal(master, modem);
+       else
+               warn("Wait for telephony ready");
+
+       g_free(modem_name);
+       return TRUE;
+}
+
+ps_master_t *_ps_master_create_master(GDBusConnection *conn, TcorePlugin *p)
+{
+       ps_master_t *new_master = NULL;
+
+       dbg("master object create");
+       g_return_val_if_fail(conn != NULL, NULL);
+
        /*Initializing the master list for internal referencing*/
        new_master = g_try_malloc0(sizeof(ps_master_t));
-       if (NULL == new_master) {
+       if (G_UNLIKELY(!new_master)) {
                err("Unable to allocate memory for master");
-               goto FAILURE;
+               return NULL;
        }
 
        new_master->conn = conn;
-       new_master->path = g_strdup(PS_MASTER_PATH);
        new_master->plg = p;
-       new_master->if_obj = master;
        new_master->modems = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, __remove_modem_handler);
+       new_master->strg = tcore_server_find_storage(tcore_plugin_ref_server(p), "vconf");
 
        /*Setting Up the call backs for the interface*/
-       _ps_master_setup_interface(master, new_master);
-
-       /*exporting the interface object to the path mention for master*/
-       g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(master),
-                       conn,
-                       PS_MASTER_PATH,
-                       &error);
+       if (!ps_master_setup_interface(new_master)) {
+               g_free(new_master);
+               return NULL;
+       }
 
-       g_assert_no_error(error);
 
        /*Registering the key callbacks for values in storage settings */
        __ps_master_register_key_callback(new_master, KEY_TELEPHONY_READY);
@@ -350,154 +346,52 @@ gpointer _ps_master_create_master(GDBusConnection *conn, TcorePlugin *p)
        __ps_master_register_key_callback(new_master, KEY_PM_STATE);
 #endif
        /* __ps_master_register_key_callback(new_master, KEY_PM_STATE); */
-#if defined(TIZEN_PS_FORCE_ATTACH_DETACH)
-       __ps_master_register_key_callback(new_master, KEY_WECONN_ALL_CONNECTED);
-#endif
 
+       /*Alarm manager init*/
+       dbg("init alarm manager.");
+       if (alarmmgr_init("packetservice") != ALARMMGR_RESULT_SUCCESS) {
+               err("Failed to init alarm manager");
+               g_free(new_master);
+               return NULL;
+       }
        /*Adding Hook for modem addition laters*/
        tcore_server_add_notification_hook(tcore_plugin_ref_server(p),
-               TNOTI_SERVER_ADDED_MODEM_PLUGIN, __on_hook_modem_added, new_master);
+                                          TNOTI_SERVER_ADDED_MODEM_PLUGIN, __on_hook_modem_added, new_master);
 
        /*Adding Hook for modem removal laters*/
        tcore_server_add_notification_hook(tcore_plugin_ref_server(p),
-               TNOTI_SERVER_REMOVED_MODEM_PLUGIN, __on_hook_modem_removed, new_master);
+                                          TNOTI_SERVER_REMOVED_MODEM_PLUGIN, __on_hook_modem_removed, new_master);
 
        info("Successfully created the master");
        return new_master;
-
-FAILURE:
-       err("Unable to create master");
-       g_object_unref(master);
-       return NULL;
 }
 
-gboolean _ps_master_create_modems(gpointer object, TcorePlugin *modem_plg)
+gboolean _ps_master_create_modems(ps_master_t *master, TcorePlugin *modem_plg)
 {
+       g_return_val_if_fail(master != NULL, FALSE);
 
-       gpointer modem = NULL, tmp = NULL;
-       ps_master_t *master = NULL;
-       CoreObject *co_modem = NULL;
-       gchar *modem_name = NULL;
-       gchar *cp_name = NULL;
-       gboolean key_telephony_ready;
-
-       g_return_val_if_fail(object != NULL, FALSE);
-       dbg("create modem objects");
-
-       master = (ps_master_t *)object;
-       key_telephony_ready = _ps_master_get_storage_value_bool(master, KEY_TELEPHONY_READY);
-       if (modem_plg) {
-               cp_name = (gchar *)tcore_server_get_cp_name_by_plugin(modem_plg);
-               modem_name = g_strdup_printf("/%s", cp_name);
-               tmp = g_hash_table_lookup(master->modems, modem_name);
-               if (tmp != NULL) {
-                       dbg("modem (%p) already existed", tmp);
-                       g_free(modem_name);
-                       return FALSE;
-               }
-
-               co_modem = tcore_plugin_ref_core_object(modem_plg, CORE_OBJECT_TYPE_MODEM);
-
-               modem = _ps_modem_create_modem(master->conn, master->plg,
-                       master, modem_name, co_modem, cp_name);
-               if (modem == NULL) {
-                       err("fail to create modem");
-                       g_free(modem_name);
-                       return FALSE;
-               }
-
-               g_hash_table_insert(master->modems, g_strdup(modem_name), modem);
-               info("modem (%p) created at path %s", modem , modem_name);
-
-               if (key_telephony_ready) {
-                       __ps_master_emit_modem_added_signal(master, modem);
-               } else {
-                       warn("Wait for telephony ready");
-               }
-
-               g_free(modem_name);
-       } else {
-
-               /*Need to walk through all modem if any present before packet service intialization*/
-               Server *s;
-               TcorePlugin *p = NULL;
-               GSList *plist_head = NULL;
-               GSList *plist = NULL;
-               GSList *modemlist_head = NULL;
-               GSList *modemlist = NULL;
-
-               s = tcore_plugin_ref_server(master->plg);
-               plist_head = tcore_server_get_modem_plugin_list(s);
-
-               if (!plist_head) {
-                       warn("Modem plugin is not present");
-                       return TRUE;
-               }
-
-               plist = plist_head;
-
-               while (plist) {
-                       p = plist->data;
-                       modemlist_head = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_MODEM);
-                       if (!modemlist_head) {
-                               warn("Found no modem core-objects");
-                               plist = plist->next;
-                               continue;
-                       }
-                       modemlist = modemlist_head;
-                       while (modemlist) {
-                               co_modem = modemlist->data;
-                               cp_name = (gchar *)tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(co_modem));
-                               modem_name = g_strdup_printf("/%s", cp_name);
-                               tmp = g_hash_table_lookup(master->modems, modem_name);
-                               if (tmp != NULL) {
-                                       dbg("modem (%p) already existed", tmp);
-                                       modemlist = modemlist->next;
-                                       g_free(modem_name);
-                                       continue;
-                               }
-
-                               modem = _ps_modem_create_modem(master->conn, master->plg, master, modem_name, co_modem, cp_name);
-                               if (!modem) {
-                                       err("Fail to create modem ");
-                                       modemlist = modemlist->next;
-                                       g_free(modem_name);
-                                       continue;
-                               }
-
-                               g_hash_table_insert(master->modems, g_strdup(modem_name), modem);
-                               info("modem (%p) created at path %s", modem , modem_name);
-                               if (key_telephony_ready) {
-                                       __ps_master_emit_modem_added_signal(master, modem);
-                               } else {
-                                       warn("Wait for telephony ready");
-                               }
-                               g_free(modem_name);
-                               modemlist = modemlist->next;
-                       }
-                       g_slist_free(modemlist_head);
-                       plist = plist->next;
+       if (!modem_plg) {
+               GSList *modem_list, *iter;
+               Server *s = tcore_plugin_ref_server(master->plg);
+               gboolean ret = FALSE;
+               modem_list = tcore_server_get_modem_plugin_list(s);
+               for (iter = modem_list; iter != NULL; iter = iter->next) {
+                       TcorePlugin *modem_p = iter->data;
+                       ret = __ps_master_create_modem(master, modem_p);
                }
-
-               g_slist_free(plist_head);
-       }
-       return TRUE;
+               g_slist_free(modem_list);
+               return ret;
+       } else
+               return __ps_master_create_modem(master, modem_plg);
 }
 
-gboolean _ps_master_destroy_modem(gpointer object, TcorePlugin *plugin)
+gboolean _ps_master_destroy_modem(ps_master_t *master, TcorePlugin *plugin)
 {
-       ps_master_t *master = NULL;
-
        gchar *modem_name;
-       gpointer modem;
+       ps_modem_t *modem;
 
        dbg("destroy modem object");
-
-       master = (ps_master_t *)object;
-
-       modem_name = g_strdup_printf("/%s",
-                       tcore_server_get_cp_name_by_plugin(plugin));
-
+       modem_name = g_strdup_printf("/%s", tcore_server_get_cp_name_by_plugin(plugin));
        modem = g_hash_table_lookup(master->modems, modem_name);
        if (modem == NULL) {
                warn("modem '%s' doesn't exists", modem_name);
@@ -517,81 +411,66 @@ gboolean _ps_master_destroy_modem(gpointer object, TcorePlugin *plugin)
        return TRUE;
 }
 
-gboolean _ps_master_get_storage_value_bool(gpointer object, enum tcore_storage_key key)
+gboolean _ps_master_get_storage_value_bool(ps_master_t *master, enum tcore_storage_key key)
 {
-       Server *s = NULL;
-       Storage *strg = NULL;
-       ps_master_t *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);;
+       _PS_CHECK_STRG(master);
+       return tcore_storage_get_bool(master->strg, key);
 }
 
-gint _ps_master_get_storage_value_int(gpointer object, enum tcore_storage_key key)
+gint _ps_master_get_storage_value_int(ps_master_t *master, enum tcore_storage_key key)
 {
-       Server *s = NULL;
-       Storage *strg = NULL;
-       ps_master_t *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_int(strg, key);;
+       _PS_CHECK_STRG(master);
+       return tcore_storage_get_int(master->strg, key);
 }
 
-gboolean _ps_master_set_storage_value_bool(gpointer object, enum tcore_storage_key key, gboolean value)
+char *_ps_master_get_storage_value_string(ps_master_t *master, enum tcore_storage_key key)
 {
-       Server *s = NULL;
-       Storage *strg = NULL;
-       ps_master_t *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);
+       _PS_CHECK_STRG(master);
+       return tcore_storage_get_string(master->strg, key);
 }
 
-gboolean _ps_master_set_storage_value_int(gpointer object, enum tcore_storage_key key, gint value)
+gboolean _ps_master_set_storage_value_bool(ps_master_t *master, enum tcore_storage_key key, gboolean value)
 {
-       Server *s = NULL;
-       Storage *strg = NULL;
-       ps_master_t *master = object;
+       g_return_val_if_fail(master != NULL, FALSE);
+       _PS_CHECK_STRG(master);
+       return tcore_storage_set_bool(master->strg, key, value);
+}
 
+gboolean _ps_master_set_storage_value_int(ps_master_t *master, enum tcore_storage_key key, gint value)
+{
        g_return_val_if_fail(master != NULL, FALSE);
-       s = tcore_plugin_ref_server(master->plg);
-       strg = tcore_server_find_storage(s, "vconf");
+       _PS_CHECK_STRG(master);
+       return tcore_storage_set_int(master->strg, key, value);
+}
 
-       return tcore_storage_set_int(strg, key, value);
+gboolean _ps_master_set_storage_value_string(ps_master_t *master, enum tcore_storage_key key, char *value)
+{
+       g_return_val_if_fail(master != NULL, FALSE);
+       _PS_CHECK_STRG(master);
+       return tcore_storage_set_string(master->strg, key, value);
 }
 
-gboolean _ps_master_set_always_on_control(gpointer user_data, gboolean enable)
+gboolean _ps_master_set_always_on_control(ps_master_t *master, gboolean enable)
 {
-       ps_master_t *master = user_data;
        GHashTableIter iter;
        gpointer key, value;
 
        g_return_val_if_fail(master != NULL, FALSE);
        g_return_val_if_fail(master->modems != NULL, FALSE);
 
-       dbg("Entered");
-
        g_hash_table_iter_init(&iter, master->modems);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
                unsigned int i;
                ps_modem_t *modem = value;
 
-               if (modem == NULL)
-                       continue;
-               if (modem->contexts == NULL)
+               if (!modem || !modem->contexts)
                        continue;
 
                for (i = 0; i < g_slist_length(modem->contexts); i++) {
-                       ps_context_t *context = (ps_context_t*)g_slist_nth_data(modem->contexts, i);
+                       ps_context_t *context = (ps_context_t *)g_slist_nth_data(modem->contexts, i);
                        gchar *path = _ps_context_ref_path(context);
                        if (path) {
                                dbg("context(%s)", path);
@@ -602,78 +481,3 @@ gboolean _ps_master_set_always_on_control(gpointer user_data, gboolean enable)
        return TRUE;
 }
 
-static gboolean on_master_get_modems(PacketServiceMaster *obj_master,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       GVariantBuilder b_modem;
-       GVariant *modems;
-
-       GHashTableIter iter;
-       gpointer key, value;
-       ps_master_t *master = user_data;
-
-       info("Entered");
-
-       if (master->modems == NULL) {
-               err("No modem Present");
-               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-               return TRUE;
-       }
-
-       g_variant_builder_init(&b_modem, G_VARIANT_TYPE("a{sa{ss}}"));
-
-       g_hash_table_iter_init(&iter, master->modems);
-       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-               gchar *path = NULL;
-               path = _ps_modem_ref_path(value);
-               dbg("modem path [%s]", path);
-
-               g_variant_builder_open(&b_modem, G_VARIANT_TYPE("{sa{ss}}"));
-               g_variant_builder_add(&b_modem, "s", path);
-               if (FALSE == _ps_modem_get_properties_handler(value, &b_modem)) {
-                       err("Unable to get the modem properties");
-                       g_variant_builder_close(&b_modem);
-                       FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-                       return TRUE;
-               }
-               g_variant_builder_close(&b_modem);
-       }
-       modems = g_variant_builder_end(&b_modem);
-
-       packet_service_master_complete_get_modems(obj_master, invocation, modems);
-       return TRUE;
-}
-
-static gboolean on_master_set_alwayson(PacketServiceMaster *obj_master,
-               GDBusMethodInvocation *invocation,
-               gboolean enable,
-               gpointer user_data)
-{
-       gboolean result = FALSE;
-
-       info("Entered");
-       result = _ps_master_set_always_on_control(user_data, enable);
-       if (result)
-               packet_service_master_complete_set_alwayson(obj_master, invocation, result);
-       else
-               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-       return TRUE;
-}
-
-static void _ps_master_setup_interface(PacketServiceMaster *master, ps_master_t *master_data)
-{
-       dbg("Entered");
-
-       g_signal_connect(master,
-                       "handle-get-modems",
-                       G_CALLBACK(on_master_get_modems),
-                       master_data);
-
-       g_signal_connect(master,
-                       "handle-set-alwayson",
-                       G_CALLBACK(on_master_set_alwayson),
-                       master_data);
-       return;
-
-}
index 714482b..45bce7f 100644 (file)
@@ -19,9 +19,7 @@
  * limitations under the License.
  *
  */
-
 #include "ps_common.h"
-#include "generated-code.h"
 
 #include <tzplatform_config.h>
 #include <server.h>
 #include <core_object.h>
 #include <co_context.h>
 #include <co_ps.h>
+#include <co_network.h>
+#include "ps_log.h"
 
-#define MODULE_TAG "PS-MODEM"
-
-#define PROP_DEFAULT   FALSE
-#define PROP_DEFAULT_STR   NULL
-#define DATABASE_PATH_0        tzplatform_mkpath(TZ_SYS_DB, ".dnet.db")
-#define DATABASE_PATH_1        tzplatform_mkpath(TZ_SYS_DB, ".dnet2.db")
-
-struct ps_thread_data {
-       ps_modem_t *modem;
-       GThread *selfi;
-};
-
-static void __ps_modem_emit_property_changed_signal(ps_modem_t *modem);
-static void __ps_modem_emit_service_added_signal(ps_modem_t *modem, gpointer service);
-/*static void __ps_modem_emit_service_removed_signal(ps_modem_t *modem, gpointer service);*/
-static void _ps_modem_setup_interface(PacketServiceModem *modem, ps_modem_t *modem_data);
-
-static void __ps_modem_create_service(GDBusConnection *conn, TcorePlugin *p,
-       gpointer modem, CoreObject *co_modem);
-static void __ps_modem_remove_service(ps_modem_t *modem, gpointer service);
-static void __ps_modem_get_ps_setting_from_storage(ps_modem_t *object);
-static void __ps_modem_processing_modem_event(gpointer object);
-
-static gboolean __ps_modem_set_powered(ps_modem_t *modem, int value);
-static gboolean __ps_modem_set_sim_complete(ps_modem_t *modem, gboolean value, gchar *operator);
+#include "ps_context.h"
+#include "ps_master.h"
+#include "ps_modem.h"
+#include "ps_service.h"
+#include "ps_tcore_interface.h"
+#include "ps_hook.h"
+#include "ps_modem_interface.h"
 
-static gboolean __ps_modem_thread_finish_cb(gpointer data)
-{
-       struct ps_thread_data *thread_data = data;
-       ps_modem_t *modem;
-       GHashTableIter iter;
-       gpointer key, value;
 
-       if (!thread_data) {
-               err("thread_data is NULL !!");
-               return FALSE;
-       }
+static void __ps_modem_processing_modem_event(ps_modem_t *modem);
 
-       modem = thread_data->modem;
-
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "Thread %p return is complete", thread_data->selfi);
-
-       _ps_get_co_modem_values(thread_data->modem);
-       _ps_modem_set_reset_profile(thread_data->modem, FALSE);
-       packet_service_modem_complete_reset_profile(thread_data->modem->if_obj, thread_data->modem->invocation, TRUE);
-
-       g_thread_join(thread_data->selfi);
-       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "Clean up of thread %p is complete", thread_data->selfi);
-       thread_data->modem->invocation = NULL;
-       _ps_modem_remove_profile_reset_gsource(thread_data->modem);
-       thread_data->modem = NULL;
-       thread_data->selfi = NULL;
-       g_free(thread_data);
-
-       /* Try to re-connect default contexts after reset profile is complete */
-       g_hash_table_iter_init(&iter, modem->services);
-       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE)
-               _ps_service_connect_default_context(value);
-
-       return FALSE;
-}
-
-static gpointer __ps_modem_regenerate_database(gpointer data)
-{
-       gboolean rv = FALSE;
-       ps_modem_t *modem = data;
-       struct ps_thread_data *thread_data = NULL;
-       gchar *command = NULL;
-
-       thread_data = g_try_malloc0(sizeof(*thread_data));
-       if (!thread_data) {
-               ps_err_ex_co(_ps_modem_ref_co_modem(modem), "memory alloc is fail !!!");
-               return NULL;
-       }
-       thread_data->modem = modem;
-       thread_data->selfi = g_thread_self();
-
-       _ps_context_reset_profile_table(modem->cp_name);
-       /* Re-generate global APN database */
-       if (g_str_has_suffix(modem->cp_name, "1"))
-               command = g_strdup_printf("/usr/bin/sqlite3 %s < /usr/share/ps-plugin/dnet_db_init.sql", DATABASE_PATH_1);
-       else
-               command = g_strdup_printf("/usr/bin/sqlite3 %s < /usr/share/ps-plugin/dnet_db_init.sql", DATABASE_PATH_0);
-       rv = ps_util_system_command(command);
-       ps_dbg_ex_co(modem->co_modem, "system command sent, rv(%d)", rv);
-       rv = _ps_context_fill_profile_table_from_ini_file(modem->cp_name);
-
-       if (TRUE == ps_util_thread_dispatch(g_main_context_default(), G_PRIORITY_LOW, (GSourceFunc)__ps_modem_thread_finish_cb, thread_data))
-               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "Thread %p processing is complete", thread_data->selfi);
-
-       g_free(command);
-
-       return NULL;
-}
 
 void __remove_modem_handler(gpointer data)
 {
@@ -135,10 +52,10 @@ void __remove_modem_handler(gpointer data)
                return;
        }
 
-       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "Entered");
+       ps_info_ex_modem(modem, "Entered");
 
 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-       __ps_modem_cp_reset_send_pending_request_response(modem);
+       _ps_hook_cp_reset_send_pending_request_response(modem);
 #endif
        /*Need to remove the compelete hash table*/
        g_hash_table_remove_all(modem->services);
@@ -161,48 +78,13 @@ void __remove_modem_handler(gpointer data)
        g_free(modem);
 
        dbg("Exiting");
-       return;
-}
-
-static void __ps_modem_emit_property_changed_signal(ps_modem_t *modem)
-{
-       GVariant *gv = NULL;
-       GVariantBuilder properties;
-
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "get modem properties");
-
-       gv = _ps_modem_get_properties(modem, &properties);
-       packet_service_modem_emit_property_changed(modem->if_obj, gv);
-
-       return;
 }
 
-static void __ps_modem_emit_service_added_signal(ps_modem_t *modem, gpointer service)
-{
-       GVariant *gv = NULL;
-       GVariantBuilder property;
-
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "get service properties");
-
-       gv = _ps_service_get_properties(service, &property);
-       packet_service_modem_emit_service_added(modem->if_obj, gv);
-       return;
-}
-/* blocked may be used later
-static void __ps_modem_emit_service_removed_signal(ps_modem_t *modem, gpointer service)
-{
-       ps_service_t *psservice = service;
-       packet_service_modem_emit_service_removed(modem->if_obj, psservice->path);
-       return;
-}
-*/
-
 static void __ps_modem_create_service(GDBusConnection *conn, TcorePlugin *p,
-               gpointer modem, CoreObject *co_modem)
+                                     ps_modem_t *modem, CoreObject *co_modem)
 {
        gchar *t_path = NULL;
-       GObject *object = NULL;
-
+       ps_service_t *service = NULL;
        CoreObject *co_ps = NULL;
        CoreObject *co_network = NULL;
        TcorePlugin *target_plg = NULL;
@@ -214,44 +96,39 @@ static void __ps_modem_create_service(GDBusConnection *conn, TcorePlugin *p,
                return;
 
        t_path = g_strdup_printf("%s/%s", _ps_modem_ref_path(modem), "umts_ps");
-       if (NULL != g_hash_table_lookup(((ps_modem_t *) modem)->services, t_path)) {
-               ps_dbg_ex_co(co_modem, "service (%s) already exist!!!", t_path);
+       if (NULL != g_hash_table_lookup(modem->services, t_path)) {
+               ps_dbg_ex_modem(modem, "service (%s) already exist!!!", t_path);
                g_free(t_path);
                return;
        }
-       ps_info_ex_co(co_modem, "service path (%s)", t_path);
-       object = _ps_service_create_service(conn, p, modem, co_network, co_ps, t_path);
-       if (object == NULL) {
-               ps_err_ex_co(co_modem, "Failed to create service ");
+       ps_info_ex_modem(modem, "service path (%s)", t_path);
+       service = _ps_service_create_service(conn, p, modem, co_network, co_ps, t_path);
+       if (G_UNLIKELY(!service)) {
+               ps_err_ex_modem(modem, "Failed to create service ");
                g_free(t_path);
                return;
        }
 
-       g_hash_table_insert(((ps_modem_t *) modem)->services, g_strdup(t_path), object);
-       ps_dbg_ex_co(co_modem, "service (%p) insert to hash", object);
-       __ps_modem_emit_service_added_signal((ps_modem_t *) modem, object);
+       g_hash_table_insert(modem->services, g_strdup(t_path), service);
+       ps_dbg_ex_modem(modem, "service (%p) insert to hash", service);
+       ps_modem_emit_service_added_signal(modem, service);
 
        g_free(t_path);
-       return;
 }
 
-static void __ps_modem_remove_service(ps_modem_t *modem, gpointer service)
+static void __ps_modem_remove_service(ps_modem_t *modem, ps_service_t *service)
 {
-       ps_service_t *psservice = service;
-
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "Entered");
+       ps_dbg_ex_modem(modem, "Entered");
 
        /*Unexporting the interface for the modem*/
-       if (psservice->if_obj) {
-               g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(psservice->if_obj));
-               g_object_unref(psservice->if_obj);
-               psservice->if_obj = NULL;
+       if (service->if_obj) {
+               g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(service->if_obj));
+               g_object_unref(service->if_obj);
+               service->if_obj = NULL;
        }
 
        g_hash_table_remove(modem->services, _ps_service_ref_path(service));
-
-       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "Successfully removed the service from the modem");
-       return;
+       ps_info_ex_modem(modem, "Successfully removed the service from the modem");
 }
 
 static gboolean __ps_modem_set_powered(ps_modem_t *modem, gboolean value)
@@ -260,8 +137,8 @@ static gboolean __ps_modem_set_powered(ps_modem_t *modem, gboolean value)
 
        if (modem->powered != value) {
                modem->powered = value;
-               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) powered(%d)", modem, modem->powered);
-               __ps_modem_emit_property_changed_signal(modem);
+               ps_info_ex_modem(modem, "modem(%p) powered(%d)", modem, modem->powered);
+               ps_modem_emit_property_changed_signal(modem);
        }
        return TRUE;
 }
@@ -275,9 +152,9 @@ static gboolean __ps_modem_set_sim_complete(ps_modem_t *modem, gboolean value, g
                modem->sim_init = value;
                if (value && operator != NULL && !modem->operator)
                        modem->operator = g_strdup(operator);
-               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem [%p] SIM-Init [%s]", modem, (modem->sim_init ? "INITIALIZED" : "UNINITIALIZED"));
+               ps_info_ex_modem(modem, "modem [%p] SIM-Init [%s]", modem, (modem->sim_init ? "INITIALIZED" : "UNINITIALIZED"));
 
-               __ps_modem_emit_property_changed_signal(modem);
+               ps_modem_emit_property_changed_signal(modem);
        }
 
        return TRUE;
@@ -289,43 +166,36 @@ static gboolean __ps_modem_set_flght_mode(ps_modem_t *modem, gboolean value)
 
        if (modem->flight_mode != value) {
                modem->flight_mode = value;
-               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) flight_mode(%d)", modem, modem->flight_mode);
-               __ps_modem_emit_property_changed_signal(modem);
+               ps_info_ex_modem(modem, "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(ps_modem_t *object)
+static void __ps_modem_get_ps_setting_from_storage(ps_modem_t *modem)
 {
        gboolean key_3g_enable = FALSE, key_roaming_allowed = FALSE;
-       gboolean key_nw_restrict_mode = FALSE;
-       gint key_ps_mode = 0;
-       ps_modem_t *modem = NULL;
-       CoreObject *co_modem;
+       gint key_ps_mode = 0, key_roaming_apn = 0;
 
-       modem = (ps_modem_t *) object;
-       co_modem = _ps_modem_ref_co_modem(modem);
        key_3g_enable = _ps_master_get_storage_value_bool(modem->p_master, KEY_3G_ENABLE);
        key_roaming_allowed = _ps_master_get_storage_value_bool(modem->p_master, KEY_DATA_ROAMING_SETTING);
        key_ps_mode = _ps_master_get_storage_value_int(modem->p_master, KEY_POWER_SAVING_MODE);
-       key_nw_restrict_mode = _ps_master_get_storage_value_bool(modem->p_master, KEY_NETWORK_RESTRICT_MODE);
 
        _ps_modem_set_data_allowed(modem, key_3g_enable);
        _ps_modem_set_data_roaming_allowed(modem, key_roaming_allowed);
+       _ps_modem_set_data_roaming_apn(modem, key_roaming_apn);
 
 #if defined(TIZEN_UPS_ENABLED)
        _ps_modem_set_psmode(modem, key_ps_mode);
 #endif
-       ps_dbg_ex_co(co_modem, "data allowed(%d) roaming allowed(%d) power saving mode(%d), network restrict mode (%d)",
-               key_3g_enable, key_roaming_allowed, key_ps_mode, key_nw_restrict_mode);
-       return;
+       ps_dbg_ex_modem(modem, "data allowed(%d) roaming allowed(%d) power saving mode(%d)",
+                       key_3g_enable, key_roaming_allowed, key_ps_mode);
 }
 
-static void __ps_modem_processing_modem_event(gpointer object)
+static void __ps_modem_processing_modem_event(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        GHashTableIter iter;
        gpointer key, value;
 #ifdef PREPAID_SIM_APN_SUPPORT
@@ -340,57 +210,50 @@ static void __ps_modem_processing_modem_event(gpointer object)
        g_hash_table_iter_init(&iter, modem->services);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
                gboolean s_roaming = FALSE;
+               ps_service_t *service = value;
 
-               s_roaming = _ps_service_get_roaming(value);
-               _ps_update_cellular_state_key(value);
+               s_roaming = _ps_service_get_roaming(service);
+               _ps_update_cellular_state_key(service);
 
                if (modem->powered == PS_MODEM_STATE_OFFLINE) {
-                       _ps_service_remove_contexts(value);
-                       _ps_free_co_ps_event(value);
-                       _ps_free_co_network_event(value);
-                       __ps_modem_remove_service(modem, value);
+                       _ps_service_remove_contexts(service);
+                       _ps_free_co_ps_event(service);
+                       _ps_free_co_network_event(service);
+                       __ps_modem_remove_service(modem, service);
                        continue;
                }
 
                if (modem->flight_mode) {
-                       _ps_service_disconnect_contexts(value);
+                       _ps_service_disconnect_contexts(service);
                        continue;
                } else if (!modem->data_allowed || (s_roaming && !modem->roaming_allowed)) {
-                       _ps_service_disconnect_internet_mms_tethering_contexts(value);
+                       _ps_service_disconnect_internet_mms_tethering_contexts(service);
                        continue;
                }
 
                /* only available case */
 #ifdef PREPAID_SIM_APN_SUPPORT
-               ret = _ps_service_connect_last_connected_context(value);
-               dbg("ret[%d]", ret);
+               ret = _ps_service_connect_last_connected_context(service);
+               ps_dbg_ex_modem(modem, "ret[%d]", ret);
                if (ret == TRUE)
-                       return; /* No need to activate default context */
+                       return;  /* No need to activate default context */
 #endif
-               _ps_service_connect_default_context(value);
+               _ps_service_connect_default_context(service);
        }
-
-       return;
 }
 
-gpointer _ps_modem_create_modem(GDBusConnection *conn, TcorePlugin *p, gpointer master,
-       char *modem_name, gpointer co_modem , gchar *cp_name)
+ps_modem_t *_ps_modem_create_modem(GDBusConnection *conn, TcorePlugin *p, ps_master_t *master,
+                                  char *modem_name, CoreObject *co_modem, gchar *cp_name)
 {
-       PacketServiceModem *modem;
        ps_modem_t *new_modem;
-       GError *error = NULL;
 
-       ps_dbg_ex_co(co_modem, "modem object create");
        g_return_val_if_fail(conn != NULL, NULL);
        g_return_val_if_fail(master != NULL, NULL);
 
-       /*creating the master object for the interface com.tcore.ps.modem*/
-       modem = packet_service_modem_skeleton_new();
-
        /*Initializing the modem list for internal referencing*/
        new_modem = g_try_malloc0(sizeof(ps_modem_t));
-       if (NULL == new_modem) {
-               ps_err_ex_co(co_modem, "Unable to allocate memory for modem");
+       if (G_UNLIKELY(!new_modem)) {
+               err("Unable to allocate memory for modem");
                return NULL;
        }
 
@@ -398,8 +261,8 @@ gpointer _ps_modem_create_modem(GDBusConnection *conn, TcorePlugin *p, gpointer
        /*Add work queue to keep user request in case of handling active PDP context*/
        new_modem->hook_flag = 0x00;
        new_modem->work_queue = g_queue_new();
-       if (NULL == new_modem->work_queue) {
-               ps_err_ex_co(co_modem, "Unable to get work queue for modem");
+       if (G_UNLIKELY(!new_modem->work_queue)) {
+               err("Unable to get work queue for modem");
                g_free(new_modem);
                return NULL;
        }
@@ -410,65 +273,28 @@ gpointer _ps_modem_create_modem(GDBusConnection *conn, TcorePlugin *p, gpointer
        new_modem->co_modem = co_modem;
        new_modem->path = g_strdup(modem_name);
        new_modem->cp_name = g_strdup(cp_name);
-       new_modem->if_obj = modem;
+       if (g_str_has_suffix(cp_name, "0"))
+               new_modem->subs_type = PS_SUBS_PRIMARY;
+       else
+               new_modem->subs_type = PS_SUBS_SECONDARY;
        new_modem->services = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, __remove_service_handler);
 
        __ps_modem_get_ps_setting_from_storage(new_modem);
-       _ps_hook_co_modem_event(new_modem);
+       _ps_add_co_modem_event(new_modem);
        _ps_get_co_modem_values(new_modem);
 
        /*Setting the interface call backs functions*/
-       _ps_modem_setup_interface(modem, new_modem);
-
-       /*exporting the interface object to the path mention for modem*/
-       g_dbus_interface_skeleton_export((G_DBUS_INTERFACE_SKELETON(modem)),
-                       conn,
-                       modem_name,
-                       &error);
-
-       g_assert_no_error(error);
-
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-       /* Adding hooks for special Network Requests */
-       tcore_server_add_request_hook(tcore_plugin_ref_server(p),
-                       TREQ_NETWORK_SEARCH,
-                       ps_handle_hook, new_modem);
-       tcore_server_add_request_hook(tcore_plugin_ref_server(p),
-                       TREQ_NETWORK_SET_PLMN_SELECTION_MODE,
-                       ps_handle_hook, new_modem);
-       tcore_server_add_request_hook(tcore_plugin_ref_server(p),
-                       TREQ_NETWORK_SET_MODE,
-                       ps_handle_hook, new_modem);
-       tcore_server_add_request_hook(tcore_plugin_ref_server(p),
-                       TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH,
-                       ps_handle_hook, new_modem);
-       tcore_server_add_request_hook(tcore_plugin_ref_server(p),
-                       TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION,
-                       ps_handle_hook, new_modem);
-       tcore_server_add_request_hook(tcore_plugin_ref_server(p),
-                       TREQ_SIM_SET_POWERSTATE,
-                       ps_handle_hook, new_modem);
-       tcore_server_add_request_hook(tcore_plugin_ref_server(p),
-                       TREQ_MODEM_SET_FLIGHTMODE,
-                       ps_handle_hook, new_modem);
-       tcore_server_add_request_hook(tcore_plugin_ref_server(p),
-                       TREQ_MODEM_POWER_OFF,
-                       ps_handle_hook, new_modem);
-       tcore_server_add_request_hook(tcore_plugin_ref_server(p),
-                       TREQ_MODEM_POWER_LOW,
-                       ps_handle_hook, new_modem);
-       tcore_server_add_request_hook(tcore_plugin_ref_server(p),
-                       TREQ_MODEM_POWER_ON,
-                       ps_handle_hook, new_modem);
-#endif
+       if (!ps_modem_setup_interface(new_modem)) {
+               g_free(new_modem);
+               return NULL;
+       }
 
-       ps_info_ex_co(co_modem, "Successfully created the modem");
+       ps_info_ex_modem(new_modem, "Successfully created the modem");
        return new_modem;
 }
 
-void _ps_modem_destroy_modem(GDBusConnection *conn, gpointer object)
+void _ps_modem_destroy_modem(GDBusConnection *conn, ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        GHashTableIter iter;
        gpointer key, value;
        GSList *list = NULL;
@@ -479,22 +305,24 @@ void _ps_modem_destroy_modem(GDBusConnection *conn, gpointer object)
        if (modem->services == NULL)
                return;
 
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "Clearing all services");
+       ps_dbg_ex_modem(modem, "Clearing all services");
        g_hash_table_iter_init(&iter, modem->services);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               ps_service_t *service = value;
+
                /* Update Cellular state */
-               _ps_service_set_ps_attached(value, FALSE);
-               _ps_update_cellular_state_key(value);
+               _ps_service_set_ps_attached(service, FALSE);
+               _ps_update_cellular_state_key(service);
 
                /* Remove contexts */
-               _ps_service_remove_contexts(value);
+               _ps_service_remove_contexts(service);
 
                /* Clear hooks */
-               _ps_free_co_ps_event(value);
-               _ps_free_co_network_event(value);
+               _ps_free_co_ps_event(service);
+               _ps_free_co_network_event(service);
 
                /* To avoid hashtable assertion */
-               list = g_slist_append(list, value);
+               list = g_slist_append(list, service);
        }
 
        for (list_iter = list; list_iter; list_iter = g_slist_next(list_iter)) {
@@ -507,11 +335,8 @@ void _ps_modem_destroy_modem(GDBusConnection *conn, gpointer object)
        /* Clear modem hooks */
        _ps_free_co_modem_event(modem);
 }
-
-gboolean _ps_modem_processing_flight_mode(gpointer object, gboolean enable)
+gboolean _ps_modem_processing_flight_mode(ps_modem_t *modem, gboolean enable)
 {
-       ps_modem_t *modem = object;
-
        g_return_val_if_fail(modem != NULL, FALSE);
 
        if (modem->flight_mode == enable)
@@ -521,14 +346,12 @@ gboolean _ps_modem_processing_flight_mode(gpointer object, gboolean enable)
        return TRUE;
 }
 
-gboolean _ps_modem_processing_power_enable(gpointer object, int modem_state)
+gboolean _ps_modem_processing_power_enable(ps_modem_t *modem, int modem_state)
 {
-       ps_modem_t *modem = object;
-
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem->powered [%d], Modem->sim_init [%d], modem_state [%d]",
-               modem->powered, modem->sim_init, modem_state);
+       ps_info_ex_modem(modem, "modem->powered [%d], Modem->sim_init [%d], modem_state [%d]",
+                        modem->powered, modem->sim_init, modem_state);
 
        if (modem->powered == modem_state)
                return TRUE;
@@ -538,17 +361,18 @@ gboolean _ps_modem_processing_power_enable(gpointer object, int modem_state)
        if (modem_state == PS_MODEM_STATE_ONLINE) {
                __ps_modem_create_service(modem->conn, modem->plg, modem, modem->co_modem);
                if (modem->sim_init == TRUE && modem->operator != NULL) {
-                       GSList *contexts = (GSList*)_ps_modem_ref_contexts(modem);
+                       GSList *contexts = (GSList *)_ps_modem_ref_contexts(modem);
 
                        if (contexts != NULL) {
                                GHashTableIter iter;
                                gpointer key, value;
-                               ps_warn_ex_co(_ps_modem_ref_co_modem(modem), "contexts exist, SIM init complete before Modem Power On event.");
+                               ps_warn_ex_modem(modem, "contexts exist, SIM init complete before Modem Power On event.");
                                g_hash_table_iter_init(&iter, modem->services);
                                while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-                                       _ps_service_set_number_of_pdn_cnt(value, modem->operator);
-                                       _ps_service_ref_contexts(value, contexts, modem->operator);
-                                       _ps_service_set_attach_apn(value);
+                                       ps_service_t *service = value;
+                                       _ps_service_set_number_of_pdn_cnt(service, modem->operator);
+                                       _ps_service_ref_contexts(service, contexts, modem->operator);
+//                                     _ps_service_set_attach_apn(service);
                                }
                        }
                }
@@ -561,23 +385,79 @@ gboolean _ps_modem_processing_power_enable(gpointer object, int modem_state)
        return TRUE;
 }
 
-gboolean _ps_modem_processing_sim_complete(gpointer object, gboolean complete, gchar *operator)
+gboolean _ps_modem_processing_no_sim(ps_modem_t *modem)
+{
+#ifdef TIZEN_SUPPORT_VOLTE
+       GSList *contexts = _ps_modem_ref_contexts(modem);
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       if (contexts) {
+               ps_dbg_ex_modem(modem, "Contexts exits");
+               return FALSE;
+       }
+
+       ps_dbg_ex_modem(modem, "Entered");
+
+       if (!modem->operator)
+               modem->operator = g_strdup(PS_IMS_EMERGENCY_PROFILE_PLMN);
+
+       ps_dbg_ex_modem(modem, "Creating Hash table...");
+       contexts = _ps_context_create_hashtable(modem, modem->roaming);
+       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_t *service = value;
+                       _ps_service_set_number_of_pdn_cnt(service, modem->operator);
+                       _ps_service_ref_contexts(service, contexts, modem->operator);
+                       _ps_service_set_attach_apn(service);
+               }
+       } else {
+               ps_err_ex_modem(modem, "Failed to create HASH table");
+               return FALSE;
+       }
+
+       ps_dbg_ex_modem(modem, "Exiting");
+#endif
+       return TRUE;
+}
+
+gboolean _ps_modem_processing_sim_complete(ps_modem_t *modem, gboolean complete, gchar *operator)
 {
-       ps_modem_t *modem = object;
-       CoreObject *co_modem;
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       co_modem = _ps_modem_ref_co_modem(modem);
-       ps_dbg_ex_co(co_modem, "Entered: sim_init[%d]", modem->sim_init);
+       ps_dbg_ex_modem(modem, "Entered: sim_init[%d]", modem->sim_init);
 
        if (modem->sim_init == complete && !modem->reset_profile) {
-               ps_dbg_ex_co(co_modem, "No change in SIM state");
+#ifdef TIZEN_SUPPORT_VOLTE
+               GSList *contexts = (GSList *)_ps_modem_ref_contexts(modem);
+
+               ps_dbg_ex_modem(modem, "No change in SIM state");
+
+               if (contexts != NULL) {
+                       GHashTableIter iter;
+                       gpointer key, value;
+                       ps_warn_ex_modem(modem, "contexts exist, SIM init complete before Modem Power On event.");
+                       g_hash_table_iter_init(&iter, modem->services);
+                       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+                               ps_service_t *service = value;
+                               _ps_service_set_number_of_pdn_cnt(service, modem->operator);
+                               _ps_service_ref_contexts(service, contexts, modem->operator);
+                               _ps_service_set_attach_apn(service);
+                       }
+               }
+               return TRUE;
+#else
+               ps_dbg_ex_modem(modem, "No change in SIM state");
                return TRUE;
+#endif
        } else {
                gboolean different_sim = FALSE;
 
                if (operator && (g_strcmp0(modem->operator, operator) != 0)) {
-                       ps_info_ex_co(co_modem, "Previous operator: [%s] Present operator: [%s]", modem->operator, operator);
+                       ps_info_ex_modem(modem, "Previous operator: [%s] Present operator: [%s]", modem->operator, operator);
                        g_free(modem->operator);
 
                        modem->operator = g_strdup(operator);
@@ -609,22 +489,28 @@ gboolean _ps_modem_processing_sim_complete(gpointer object, gboolean complete, g
                 */
                if (modem->sim_init == TRUE) {
                        if ((different_sim || modem->reset_profile) && (modem->operator != NULL)) {
-                               GSList *contexts;
 
-                               ps_dbg_ex_co(co_modem, "Creating Hash table...");
-                               contexts = _ps_context_create_hashtable(object, modem->roaming);
+                               GSList *contexts = (GSList *)_ps_modem_ref_contexts(modem);
+                               if (contexts) {
+                                       ps_dbg_ex_modem(modem, "Contexts exits");
+                                       return FALSE;
+                               }
+
+                               ps_dbg_ex_modem(modem, "Creating Hash table...");
+                               contexts = _ps_context_create_hashtable(modem, modem->roaming);
                                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_set_number_of_pdn_cnt(value, modem->operator);
-                                               _ps_service_ref_contexts(value, contexts, modem->operator);
-                                               _ps_service_set_attach_apn(value);
+                                               ps_service_t *service = value;
+                                               _ps_service_set_number_of_pdn_cnt(service, modem->operator);
+                                               _ps_service_ref_contexts(service, contexts, modem->operator);
+                                               //_ps_service_set_attach_apn(service);
                                        }
                                } else {
-                                       ps_err_ex_co(co_modem, "Failed to create HASH table");
+                                       ps_err_ex_modem(modem, "Failed to create HASH table");
                                        return FALSE;
                                }
                        }
@@ -637,65 +523,142 @@ gboolean _ps_modem_processing_sim_complete(gpointer object, gboolean complete, g
 
                        g_hash_table_iter_init(&iter, modem->services);
                        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-                               ps_info_ex_co(co_modem, "Remove contexts on service(%p)", value);
-                               _ps_service_remove_contexts(value);
+                               ps_service_t *service = value;
+                               ps_info_ex_modem(modem, "Remove contexts on service(%p)", service);
+                               _ps_service_remove_contexts(service);
+                       }
+               }
+       }
+ EXIT:
+       ps_dbg_ex_modem(modem, "Exiting");
+       return TRUE;
+}
+
+gboolean _ps_modem_processing_sim_refresh(ps_modem_t *modem)
+{
+#ifdef TIZEN_SUPPORT_VOLTE
+       GHashTableIter iter;
+       gpointer key, value;
+       unsigned int index;
+
+       ps_dbg_ex_modem(modem, "Entered");
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       if (!modem->services)
+               goto EXIT;
+
+       g_hash_table_iter_init(&iter, modem->services);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               ps_service_t *service = value;
+               for (index = 0; index < g_slist_length(service->contexts); index++) {
+                       ps_context_t *context = g_slist_nth_data(service->contexts, index);
+                       CoreObject *co_context = _ps_context_ref_co_context(context);
+
+                       if (tcore_context_get_role(co_context) == CONTEXT_ROLE_IMS) {
+                               gboolean ims_registered = FALSE, ims_deregistering = FALSE;
+                               struct tel_network_ims_registration_info ims_reg_info = { 0, };
+
+                               tcore_network_get_ims_reg_info(_ps_service_ref_co_network(service), &ims_reg_info);
+                               if (ims_reg_info.feature_mask & NET_IMS_MASK_REGI)
+                                       ims_registered = TRUE;
+                               ims_deregistering = tcore_network_get_ims_on_deregistering(_ps_service_ref_co_network(service));
+
+                               ps_dbg_ex_svc(service, "ims_registered(%d), ims_deregistering(%d), context_state(%d), flight_mode(%d)",
+                                             ims_registered, ims_deregistering, tcore_context_get_state(co_context), modem->flight_mode);
+
+                               if (!modem->flight_mode) {
+                                       if (ims_registered && !ims_deregistering) {
+                                               if (_ps_context_deregister_ims(context) == TCORE_RETURN_SUCCESS)
+                                                       return TRUE;
+                                       }
+                               }
                        }
                }
        }
-EXIT:
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "Exiting");
+ EXIT:
+#endif
+       ps_dbg_ex_modem(modem, "Exiting");
        return TRUE;
 }
 
-gboolean _ps_modem_set_reset_profile(gpointer object, gboolean value)
+gboolean _ps_modem_set_attach_apn(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
+       unsigned int index;
+       GSList *contexts = NULL;
 
        g_return_val_if_fail(modem != NULL, FALSE);
+       contexts = (GSList *)_ps_modem_ref_contexts(modem);
+       ps_dbg_ex_modem(modem, "Entered");
+
+       for (index = 0; index < g_slist_length(modem->contexts); index++) {
+               ps_context_t *context = g_slist_nth_data(modem->contexts, index);
+               ps_service_t *service = _ps_context_ref_service(context);
+               CoreObject *co_context = _ps_context_ref_co_context(context);
+               if (service == NULL)
+                       continue;
+               tcore_ps_clear_context_id(_ps_service_ref_co_ps(service), co_context);
+       }
 
-       if (modem->reset_profile != value) {
-               modem->reset_profile = value;
-               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) reset_profile(%d)", modem, modem->reset_profile);
+       if (contexts != NULL) {
+               GHashTableIter iter;
+               gpointer key, value;
+               ps_warn_ex_modem(modem, "contexts exist, Set attach apn");
+               g_hash_table_iter_init(&iter, modem->services);
+               while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+                       ps_service_t *service = value;
+                       _ps_service_set_number_of_pdn_cnt(service, modem->operator);
+                       _ps_service_ref_contexts(service, contexts, modem->operator);
+                       _ps_service_set_attach_apn(service);
+               }
        }
 
+       ps_dbg_ex_modem(modem, "Exiting");
        return TRUE;
+
 }
 
-gboolean _ps_modem_get_reset_profile(gpointer object)
+int _ps_modem_get_data_roaming_apn(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
+       g_return_val_if_fail(modem != NULL, FALSE);
+       return modem->roaming_apn;
+}
 
+gboolean _ps_modem_set_data_roaming_apn(ps_modem_t *modem, int value)
+{
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) reset_profile(%d)", modem, modem->reset_profile);
+       if (modem->roaming_apn != value) {
+               modem->roaming_apn = value;
+               ps_info_ex_modem(modem, "modem(%p) roaming_apn(%d)", modem, modem->roaming_apn);
+       }
 
-       return modem->reset_profile;
+       return TRUE;
 }
 
-GSource *_ps_modem_get_profile_reset_gsource(gpointer object)
+gboolean _ps_modem_get_reset_profile(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
+       g_return_val_if_fail(modem != NULL, FALSE);
 
-       g_return_val_if_fail(modem != NULL, NULL);
+       ps_info_ex_modem(modem, "modem(%p) reset_profile(%d)", modem, modem->reset_profile);
 
-       return modem->reset_profile_gsource;
+       return modem->reset_profile;
 }
 
-gboolean _ps_modem_set_profile_reset_gsource(gpointer object, GSource *source)
+GSource *_ps_modem_get_profile_reset_gsource(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
+       g_return_val_if_fail(modem != NULL, NULL);
+       return modem->reset_profile_gsource;
+}
 
+gboolean _ps_modem_set_profile_reset_gsource(ps_modem_t *modem, GSource *source)
+{
        g_return_val_if_fail(modem != NULL, FALSE);
-
        modem->reset_profile_gsource = source;
-
        return TRUE;
 }
 
-gboolean  _ps_modem_remove_profile_reset_gsource(gpointer object)
+gboolean _ps_modem_remove_profile_reset_gsource(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
-
        g_return_val_if_fail(modem != NULL, FALSE);
 
        if (NULL != modem->reset_profile_gsource) {
@@ -706,218 +669,235 @@ gboolean  _ps_modem_remove_profile_reset_gsource(gpointer object)
        return TRUE;
 }
 
-gboolean _ps_modem_set_sim_enabled(gpointer object, gboolean value)
+gboolean _ps_modem_set_sim_enabled(ps_modem_t *modem, gboolean value)
 {
-       ps_modem_t *modem = object;
-
        g_return_val_if_fail(modem != NULL, FALSE);
 
        if (modem->sim_init != value) {
                modem->sim_init = value;
-               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) sim_enabled(%d)", modem, modem->sim_init);
+               ps_info_ex_modem(modem, "modem(%p) sim_enabled(%d)", modem, modem->sim_init);
        }
        return TRUE;
 }
 
-gboolean _ps_modem_connect_default_context(gpointer object)
+gboolean _ps_modem_connect_default_context(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        GHashTableIter iter;
        gpointer key, value;
 
        g_return_val_if_fail(modem != NULL, FALSE);
 
        g_hash_table_iter_init(&iter, modem->services);
-       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE)
-               _ps_service_connect_default_context(value);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               ps_service_t *service = value;
+               _ps_service_connect_default_context(service);
+       }
 
        return TRUE;
 }
 
-gboolean _ps_modem_set_data_allowed(gpointer object, gboolean value)
+gboolean _ps_modem_set_data_allowed(ps_modem_t *modem, gboolean value)
 {
-       ps_modem_t *modem = object;
-
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       if (modem->data_allowed != value)  {
+       if (modem->data_allowed != value) {
                modem->data_allowed = value;
-               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) data allowed(%d)", modem, modem->data_allowed);
-               __ps_modem_emit_property_changed_signal(modem);
+               ps_info_ex_modem(modem, "modem(%p) data allowed(%d)", modem, modem->data_allowed);
+               ps_modem_emit_property_changed_signal(modem);
                __ps_modem_processing_modem_event(modem);
+
+               if (modem->data_allowed) {
+                       GHashTableIter iter;
+                       gpointer key, service;
+                       ps_context_t *def_context = NULL, *ims_context = NULL;
+
+                       g_hash_table_iter_init(&iter, modem->services);
+                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE) {
+                               def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
+                               if (def_context)
+                                       _ps_context_set_alwayson_enable(def_context, TRUE);
+                               ims_context = _ps_service_return_default_context(service, CONTEXT_ROLE_IMS);
+                               if (ims_context)
+                                       _ps_context_set_alwayson_enable(ims_context, TRUE);
+
+                       }
+                       __ps_modem_processing_modem_event(modem);
+               }
        }
 
        return TRUE;
 }
 
-gboolean _ps_modem_get_data_allowed(gpointer object)
+gboolean _ps_modem_get_data_allowed(ps_modem_t *modem)
 {
-       ps_modem_t *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)
+gboolean _ps_modem_set_data_roaming_allowed(ps_modem_t *modem, gboolean roaming_allowed)
 {
-       ps_modem_t *modem = object;
-
        g_return_val_if_fail(modem != NULL, FALSE);
 
        if (modem->roaming_allowed != roaming_allowed) {
                modem->roaming_allowed = roaming_allowed;
-               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) roaming allowed(%d)", modem, modem->roaming_allowed);
-               __ps_modem_emit_property_changed_signal(modem);
+               ps_info_ex_modem(modem, "modem(%p) roaming allowed(%d)", modem, modem->roaming_allowed);
+               ps_modem_emit_property_changed_signal(modem);
 
                if (!modem->services)
                        return TRUE;
 
-               if (modem->roaming)
+               if (modem->roaming) {
+                       GHashTableIter iter;
+                       gpointer key, service;
+                       ps_context_t *def_context = NULL, *ims_context = NULL;
+
+                       g_hash_table_iter_init(&iter, modem->services);
+                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE) {
+                               def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
+                               if (def_context)
+                                       _ps_context_set_alwayson_enable(def_context, TRUE);
+
+                               ims_context = _ps_service_return_default_context(service, CONTEXT_ROLE_IMS);
+                               if (ims_context)
+                                       _ps_context_set_alwayson_enable(ims_context, TRUE);
+                       }
                        __ps_modem_processing_modem_event(modem);
+               }
        }
 
        return TRUE;
 }
 
-gboolean _ps_modem_set_psmode(gpointer object, gint value)
+gboolean _ps_modem_set_pm_state(ps_modem_t *modem, gint pm_state)
 {
-       ps_modem_t *modem = object;
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       if (modem->pm_state != pm_state) {
+               modem->pm_state = pm_state;
+               ps_info_ex_modem(modem, "modem(%p) pm_state(%d)", modem, modem->pm_state);
+
+               if (!modem->services)
+                       return TRUE;
+
+               if (modem->pm_state == 1) {
+                       GHashTableIter iter;
+                       gpointer key, service;
+                       ps_context_t *def_context = NULL, *ims_context = NULL;
 
+                       g_hash_table_iter_init(&iter, modem->services);
+                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE) {
+                               def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
+                               if (def_context && def_context->timer_src > 0) {
+                                       ps_info_ex_modem(modem, "reset pdp retry timer (%d)", def_context->timer_src);
+                                       _ps_service_set_retry_timeout_value(def_context, PDP_RETRY_TIME_OUT_DEFAULT);
+                                       _ps_service_connection_timer(service, def_context);
+                               }
+
+                               ims_context = _ps_service_return_default_context(service, CONTEXT_ROLE_IMS);
+                               if (ims_context && ims_context->timer_src > 0) {
+                                       ps_info_ex_modem(modem, "reset pdp retry timer (%d)", ims_context->timer_src);
+                                       _ps_service_set_retry_timeout_value(ims_context, PDP_RETRY_TIME_OUT_DEFAULT);
+                                       _ps_service_connection_timer(service, ims_context);
+                               }
+                       }
+               }
+       }
+
+       return TRUE;
+
+}
+
+gboolean _ps_modem_set_psmode(ps_modem_t *modem, gint value)
+{
        g_return_val_if_fail(modem != NULL, FALSE);
 
        if (modem->ps_mode != value) {
                modem->ps_mode = value;
-               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) power saving mode(%d)", modem, modem->ps_mode);
+               ps_info_ex_modem(modem, "modem(%p) power saving mode(%d)", modem, modem->ps_mode);
        }
 
        return TRUE;
 }
 
-gboolean _ps_modem_get_roaming(gpointer object)
+gboolean _ps_modem_get_roaming(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, FALSE);
-
        return modem->roaming;
 }
 
-void _ps_modem_set_roaming(gpointer object, gboolean value)
+void _ps_modem_set_roaming(ps_modem_t *modem, gboolean value)
 {
-       ps_modem_t *modem = object;
        g_return_if_fail(modem != NULL);
 
        if (modem->roaming != value) {
                modem->roaming = value;
-               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) roaming(%d)", modem, modem->roaming);
+               ps_info_ex_modem(modem, "modem(%p) roaming(%d)", modem, modem->roaming);
        }
 }
 
-gint _ps_modem_get_roaming_apn_support(gpointer object)
+gint _ps_modem_get_roaming_apn_support(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
-
        g_return_val_if_fail(modem != NULL, FALSE);
-
        return modem->roaming_apn_support;
 }
 
-void _ps_modem_set_roaming_apn_support(gpointer object, gboolean value)
+void _ps_modem_set_roaming_apn_support(ps_modem_t *modem, gboolean value)
 {
-       ps_modem_t *modem = object;
        g_return_if_fail(modem != NULL);
-
        if (modem->roaming_apn_support != value) {
                modem->roaming_apn_support = value;
-               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) roaming_apn_support(%d)", modem, modem->roaming);
+               ps_info_ex_modem(modem, "modem(%p) roaming_apn_support(%d)", modem, modem->roaming_apn_support);
        }
 }
 
-gint _ps_modem_get_psmode(gpointer object)
+gint _ps_modem_get_psmode(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
-
        g_return_val_if_fail(modem != NULL, FALSE);
-
        return modem->ps_mode;
 }
 
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-guchar _ps_modem_get_hook_flag(gpointer object)
+gboolean _ps_modem_get_data_roaming_allowed(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
-
        g_return_val_if_fail(modem != NULL, FALSE);
-
-       return modem->hook_flag;
-}
-#endif
-
-gboolean _ps_modem_get_data_roaming_allowed(gpointer object)
-{
-       ps_modem_t *modem = object;
-       g_return_val_if_fail(modem != NULL, FALSE);
-
        return modem->roaming_allowed;
 }
 
-gboolean _ps_modem_get_flght_mode(gpointer object)
+gboolean _ps_modem_get_flght_mode(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, FALSE);
-
        return modem->flight_mode;
 }
 
-gboolean _ps_modem_get_sim_init(gpointer object)
+gboolean _ps_modem_get_sim_init(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, FALSE);
-
        return modem->sim_init;
 }
 
-gboolean _ps_modem_get_power(gpointer object)
+gboolean _ps_modem_get_power(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, FALSE);
-
        return modem->powered;
 }
 
-char *_ps_modem_ref_operator(gpointer object)
+char *_ps_modem_ref_operator(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, FALSE);
-
        return modem->operator;
 }
 
-ps_subs_type _ps_modem_get_subs_type(gpointer object)
+ps_subs_type _ps_modem_get_subs_type(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
-       const gchar *cp_name;
-
        g_return_val_if_fail(modem != NULL, FALSE);
-
-       cp_name = modem->cp_name;
-       if (g_str_has_suffix(cp_name, "0"))
-               return PS_SUBS_PRIMARY;
-       else if (g_str_has_suffix(cp_name, "1"))
-               return PS_SUBS_SECONDARY;
-       else if (g_str_has_suffix(cp_name, "2"))
-               return PS_SUBS_TERTIARY;
-
-       return PS_SUBS_MAX;
+       return modem->subs_type;
 }
 
-gboolean _ps_modem_get_properties_handler(gpointer object, GVariantBuilder *properties)
+gboolean _ps_modem_get_properties_handler(ps_modem_t *modem, GVariantBuilder *properties)
 {
-       ps_modem_t *modem = object;
-
        g_return_val_if_fail(modem != NULL, FALSE);
        g_return_val_if_fail(properties != NULL, FALSE);
 
-       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "get modem properties");
+       ps_info_ex_modem(modem, "get modem properties");
 
        g_variant_builder_open(properties, G_VARIANT_TYPE("a{ss}"));
        g_variant_builder_add(properties, "{ss}", "path", modem->path);
@@ -931,21 +911,17 @@ gboolean _ps_modem_get_properties_handler(gpointer object, GVariantBuilder *prop
        g_variant_builder_add(properties, "{ss}", "data_allowed", BOOL2STRING(modem->data_allowed));
        g_variant_builder_close(properties);
 
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "Exiting");
        return TRUE;
 }
 
-GVariant *_ps_modem_get_properties(gpointer object, GVariantBuilder *properties)
+GVariant *_ps_modem_get_properties(ps_modem_t *modem, GVariantBuilder *properties)
 {
-       ps_modem_t *modem = object;
-
        g_return_val_if_fail(modem != NULL, FALSE);
        g_return_val_if_fail(properties != NULL, FALSE);
 
-       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "get modem properties");
+       ps_info_ex_modem(modem, "get modem properties");
 
        g_variant_builder_init(properties, G_VARIANT_TYPE("a{ss}"));
-
        g_variant_builder_add(properties, "{ss}", "path", modem->path);
 
        if (modem->operator)
@@ -956,441 +932,53 @@ GVariant *_ps_modem_get_properties(gpointer object, GVariantBuilder *properties)
        g_variant_builder_add(properties, "{ss}", "roaming_allowed", BOOL2STRING(modem->roaming_allowed));
        g_variant_builder_add(properties, "{ss}", "data_allowed", BOOL2STRING(modem->data_allowed));
 
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "Exiting");
        return g_variant_builder_end(properties);
 }
 
-gpointer _ps_modem_ref_master(gpointer object)
+ps_master_t *_ps_modem_ref_master(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, NULL);
-
        return modem->p_master;
 }
 
-GHashTable *_ps_modem_ref_services(gpointer object)
+GHashTable *_ps_modem_ref_services(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, NULL);
-
        return modem->services;
 }
 
-char *_ps_modem_ref_path(gpointer object)
+char *_ps_modem_ref_path(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, NULL);
-
        return modem->path;
 }
 
-gpointer _ps_modem_ref_plugin(gpointer object)
+TcorePlugin *_ps_modem_ref_plugin(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, NULL);
-
        return modem->plg;
 }
 
-gpointer _ps_modem_ref_dbusconn(gpointer object)
+GDBusConnection *_ps_modem_ref_dbusconn(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, NULL);
-
        return modem->conn;
 }
 
-gpointer _ps_modem_ref_co_modem(gpointer object)
+CoreObject *_ps_modem_ref_co_modem(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, NULL);
-
        return modem->co_modem;
 }
 
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-gpointer _ps_modem_ref_work_queue(gpointer object)
-{
-       ps_modem_t *modem = object;
-       g_return_val_if_fail(modem != NULL, NULL);
-
-       return modem->work_queue;
-}
-#endif
-
-gchar *_ps_modem_ref_cp_name(gpointer object)
+gchar *_ps_modem_ref_cp_name(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, NULL);
-
        return modem->cp_name;
 }
 
-gpointer _ps_modem_ref_contexts(gpointer object)
+GSList *_ps_modem_ref_contexts(ps_modem_t *modem)
 {
-       ps_modem_t *modem = object;
        g_return_val_if_fail(modem != NULL, NULL);
        return modem->contexts;
 }
-
-static gboolean on_modem_get_properties(PacketServiceModem *obj_modem,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       GVariant *gv = NULL;
-       GVariantBuilder properties;
-       ps_modem_t *modem = user_data;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
-
-       ps_info_ex_co(co_modem, "get modem properties");
-
-       gv = _ps_modem_get_properties(user_data, &properties);
-       packet_service_modem_complete_get_properties(obj_modem, invocation, gv);
-       return TRUE;
-}
-
-static gboolean on_modem_get_services(PacketServiceModem *obj_modem,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       GVariantBuilder b_service;
-       GVariant *services;
-
-       GHashTableIter iter;
-       gpointer key, value;
-       ps_modem_t *modem = user_data;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
-
-       ps_info_ex_co(co_modem, "modem get service interface");
-
-       if (modem->services == NULL) {
-               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-               return TRUE;
-       }
-
-       g_variant_builder_init(&b_service, G_VARIANT_TYPE("a{sa{ss}}"));
-       g_hash_table_iter_init(&iter, modem->services);
-       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-               gchar *path = NULL;
-
-               g_variant_builder_open(&b_service, G_VARIANT_TYPE("{sa{ss}}"));
-               path = _ps_service_ref_path(value);
-               ps_dbg_ex_co(co_modem, "path added [%s]", path);
-               g_variant_builder_add(&b_service, "s", g_strdup(path));
-               if (FALSE == _ps_service_get_properties_handler(value, &b_service)) {
-                       g_variant_builder_close(&b_service);
-                       FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-                       return TRUE;
-               }
-               g_variant_builder_close(&b_service);
-       }
-
-       services = g_variant_builder_end(&b_service);
-       packet_service_modem_complete_get_services(obj_modem, invocation, services);
-       return TRUE;
-}
-
-static gboolean on_modem_go_dormant_all(PacketServiceModem *obj_modem,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       int result = -1;
-
-       GHashTableIter iter;
-       gpointer key, value;
-       ps_modem_t *modem = user_data;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
-
-       ps_info_ex_co(co_modem, "modem go dormant all interface");
-
-       if (modem->services == NULL) {
-               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-               return TRUE;
-       }
-
-       g_hash_table_iter_init(&iter, modem->services);
-       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-               ps_service_t *service = value;
-               ps_dbg_ex_co(co_modem, "service (%p), send dormant request, ", service);
-               result = tcore_ps_send_dormant_request(service->co_ps, NULL);
-       }
-
-       packet_service_modem_complete_go_dormant_all(obj_modem, invocation, result);
-       return TRUE;
-}
-
-static gboolean on_modem_get_profile_list(PacketServiceModem *obj_modem,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       guint len = 0, index;
-       gchar **strv = NULL;
-       GSList *profiles = NULL;
-       GSList *profiles_temp = NULL;
-       ps_modem_t *modem = user_data;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
-
-       ps_info_ex_co(co_modem, "master get the profile list");
-
-       if (modem->contexts == NULL) {
-               ps_err_ex_co(co_modem, "no profiles");
-               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
-               return TRUE;
-       }
-
-       for (index = 0; index < g_slist_length(modem->contexts); index++) {
-               gchar *s_path = NULL;
-               gpointer value = g_slist_nth_data(modem->contexts, index);
-
-               s_path = _ps_context_ref_path(value);
-               ps_dbg_ex_co(co_modem, "value(%p), path(%s)", value, s_path);
-               if (s_path)
-                       profiles = g_slist_append(profiles, g_strdup((const char *)s_path));
-       }
-
-       if (profiles == NULL) {
-               ps_warn_ex_co(co_modem, "no profiles");
-               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
-               return TRUE;
-       }
-
-       len = g_slist_length(profiles);
-       strv = g_new(gchar *, len+1);
-
-       /*
-        * fix memory leak
-        *  - Shouldn't move profiles GSList position directly
-        */
-       for (index = 0; index < len; index++) {
-               profiles_temp = g_slist_nth(profiles, index);
-               if(profiles_temp == NULL)
-                       continue;
-               strv[index] = g_strdup(profiles_temp->data);
-       }
-       strv[index] = NULL;
-       packet_service_modem_complete_get_profile_list(obj_modem,
-                               invocation, (const gchar *const *)strv);
-
-       g_strfreev(strv);
-       g_slist_free_full(profiles, g_free);
-       ps_dbg_ex_co(co_modem, "Exiting");
-       return TRUE;
-}
-
-static gboolean on_modem_add_profile(PacketServiceModem *obj_modem,
-               GDBusMethodInvocation *invocation,
-               GVariant *property,
-               gpointer user_data)
-{
-       GVariantIter g_iter;
-       gchar *g_value;
-       gchar *g_key;
-
-       gboolean rv = FALSE;
-       gchar *operator = NULL;
-       ps_modem_t *modem = user_data;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
-       GHashTable *profile_property = NULL;
-
-       ps_info_ex_co(co_modem, "add profile request");
-
-       operator = _ps_modem_ref_operator(modem);
-
-       if (!operator) {
-               ps_warn_ex_co(co_modem, "there is no active modem");
-               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-               return TRUE;
-       }
-
-       /*Create a hash table for the profile property as all function already use ghash table */
-       profile_property = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
-       g_variant_iter_init(&g_iter, property);
-       while (g_variant_iter_next(&g_iter, "{ss}", &g_key, &g_value)) {
-
-               ps_info_ex_co(co_modem, " '%s' value '%s'", g_key, g_value);
-               g_hash_table_insert(profile_property, g_strdup(g_key), g_strdup(g_value));
-               /* must free data for ourselves */
-               g_free(g_value);
-               g_free(g_key);
-       }
-
-       rv = _ps_context_add_context(modem, operator, profile_property);
-       if (rv != TRUE) {
-               ps_err_ex_co(co_modem, "Failed to add the Profile");
-               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-               g_hash_table_destroy(profile_property);
-               return TRUE;
-       }
-
-       packet_service_modem_complete_add_profile(obj_modem, invocation, TRUE);
-
-       g_hash_table_destroy(profile_property);
-       ps_dbg_ex_co(co_modem, "Exiting");
-       return TRUE;
-}
-
-gboolean _ps_modem_initiate_reset_profile(gpointer value)
-{
-       CoreObject *co_modem;
-       ps_modem_t *modem = value;
-       GHashTableIter iter;
-       gpointer key, key_value;
-
-       g_return_val_if_fail(modem != NULL, FALSE);
-
-       co_modem = _ps_modem_ref_co_modem(modem);
-
-       ps_dbg_ex_co(co_modem, "Reseting the hash table");
-       if (modem->powered != PS_MODEM_STATE_ONLINE) {
-               gint index, count;
-               ps_context_t *pscontext;
-
-               count = g_slist_length(modem->contexts);
-               /* Remove contexts directly as there is no service */
-               for (index = 0; index < count; index++) {
-                       pscontext = g_slist_nth_data(modem->contexts, index);
-                       ps_warn_ex_co(co_modem, "Remove context(%p)", pscontext);
-                       _ps_context_remove_context(pscontext);
-               }
-               g_slist_free(modem->contexts);
-               modem->contexts = NULL;
-
-               g_hash_table_iter_init(&iter, modem->services);
-               while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-                       ps_service_t *service;
-                       service = (ps_service_t *)value;
-                       ps_warn_ex_co(co_modem, "Remove contexts on service(%p)", value);
-                       g_slist_free(service->contexts);
-                       service->contexts = NULL;
-               }
-       } else {
-               /* Remove contexts through only service. */
-               g_hash_table_iter_init(&iter, modem->services);
-               while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-                       ps_warn_ex_co(co_modem, "Remove contexts on service(%p)", value);
-                       _ps_service_remove_contexts(value);
-               }
-       }
-
-       if (modem->type == 0) {
-               GThread *thread;
-               gchar *name = g_strdup_printf("REGEN-DB-%s", modem->cp_name);
-
-               thread = g_thread_new(name, __ps_modem_regenerate_database, modem);
-               g_free(name);
-               if (thread == NULL) {
-                       ps_err_ex_co(co_modem, "Thread is not created");
-                       FAIL_RESPONSE(modem->invocation , PS_ERR_INTERNAL);
-                       _ps_modem_remove_profile_reset_gsource(modem);
-               } else {
-                       ps_dbg_ex_co(co_modem, "Thread(%p) is created", thread);
-               }
-
-               return FALSE;
-       }
-       /* Create contexts again. */
-       _ps_get_co_modem_values(modem);
-       _ps_modem_set_reset_profile(modem, FALSE);
-       packet_service_modem_complete_reset_profile(modem->if_obj, modem->invocation, TRUE);
-       modem->invocation = NULL;
-
-       _ps_modem_remove_profile_reset_gsource(modem);
-
-       /* Try to re-connect default contexts after reset profile is complete */
-       g_hash_table_iter_init(&iter, modem->services);
-       while (g_hash_table_iter_next(&iter, &key, &key_value) == TRUE) {
-               /* only available case */
-               _ps_service_connect_default_context(key_value);
-       }
-
-       ps_dbg_ex_co(co_modem, "Exiting");
-       return FALSE;
-}
-
-static gboolean on_modem_reset_profile(PacketServiceModem *obj_modem,
-               GDBusMethodInvocation *invocation,
-               gint type,
-               gpointer user_data)
-{
-       TReturn rv;
-       gboolean contexts_active;
-       ps_modem_t *modem = user_data;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
-       CoreObject *co_ps;
-       int state;
-
-       ps_info_ex_co(co_modem, "reset profile request type(%d)", type);
-
-       if (_ps_modem_get_reset_profile(modem) == TRUE) {
-               ps_err_ex_co(co_modem, "Reset Profile is already in Progress");
-               packet_service_modem_complete_reset_profile(obj_modem, invocation, FALSE);
-               ps_dbg_ex_co(co_modem, "Exiting");
-               return FALSE;
-       }
-
-       _ps_modem_set_reset_profile(modem, TRUE);
-
-       co_ps = tcore_plugin_ref_core_object(tcore_object_ref_plugin(_ps_modem_ref_co_modem(modem)),
-                                                                               CORE_OBJECT_TYPE_PS);
-
-       modem->invocation = invocation;
-       modem->type = type;
-
-       contexts_active = tcore_ps_any_context_activating_activated(co_ps, &state);
-
-       if (contexts_active == TRUE) {
-               ps_info_ex_co(co_modem, "Contexts are in [%d] state", state);
-               if (state == CONTEXT_STATE_ACTIVATED) {
-                       ps_dbg_ex_co(co_modem, "Contexts are in Actived state. Sending Diconnect Notification to all connected contexts");
-                       rv = tcore_ps_deactivate_contexts(co_ps);
-                       if (rv != TCORE_RETURN_SUCCESS)
-                               ps_err_ex_co(co_modem, "fail to deactivation");
-               } else if (state == CONTEXT_STATE_ACTIVATING) {
-                       ps_dbg_ex_co(co_modem, "Contexts are in Activating state. Wait for them to connect");
-               }
-       } else {
-               ps_info_ex_co(co_modem, "No contexts are in activating or activated state. Profiles reset is being initiated");
-               _ps_modem_initiate_reset_profile(modem);
-       }
-
-       return TRUE;
-}
-
-
-static void _ps_modem_setup_interface(PacketServiceModem *modem, ps_modem_t *modem_data)
-{
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem_data), "Entered");
-
-       g_signal_connect(modem,
-                       "handle-get-properties",
-                       G_CALLBACK(on_modem_get_properties),
-                       modem_data);
-
-       g_signal_connect(modem,
-                       "handle-get-services",
-                       G_CALLBACK(on_modem_get_services),
-                       modem_data);
-
-       g_signal_connect(modem,
-                       "handle-go-dormant-all",
-                       G_CALLBACK(on_modem_go_dormant_all),
-                       modem_data);
-
-       g_signal_connect(modem,
-                       "handle-get-profile-list",
-                       G_CALLBACK(on_modem_get_profile_list),
-                       modem_data);
-
-       g_signal_connect(modem,
-                       "handle-add-profile",
-                       G_CALLBACK(on_modem_add_profile),
-                       modem_data);
-
-       g_signal_connect(modem,
-                       "handle-reset-profile",
-                       G_CALLBACK(on_modem_reset_profile),
-                       modem_data);
-
-       return;
-}
-
index a23568c..79cae9e 100644 (file)
  */
 
 #include "ps_common.h"
-#include "generated-code.h"
+#include "ps_context.h"
+#include "ps_master.h"
+#include "ps_modem.h"
+#include "ps_service.h"
+#include "ps_hook.h"
+#include "ps_tcore_interface.h"
+#include "ps_service_interface.h"
 
 #include <core_object.h>
 #include <co_ps.h>
 #include <co_context.h>
 #include <co_network.h>
 #include <storage.h>
+#include <vconf.h>
+#include <arpa/inet.h>
 
-#define MODULE_TAG "PS-SERVICE"
+#include <user_request.h>
 
-#define PROP_DEFAULT   FALSE
-#define PROP_DEFAULT_STR   NULL
+#include "ps_log.h"
 
-#define TIMEOUT_DEFAULT                5
-#define TIMEOUT_MAX                    1800
-
-
-static void __ps_service_emit_property_changed_signal(ps_service_t *service);
-static void __ps_service_emit_context_added_signal(ps_service_t *service, gpointer context);
-static void __ps_service_emit_context_removed_signal(ps_service_t *service, gpointer context);
-static void _ps_service_setup_interface(PacketServiceService *service, ps_service_t *service_data);
-
-static char *__ps_service_act2string(enum telephony_network_access_technology act);
-static gboolean __ps_service_check_connection_option(gpointer service, gpointer context);
-static int __ps_service_connetion_timeout_handler(alarm_id_t alarm_id, void *context);
+static guint __ps_service_convert_ipv4_address_int(char *ip_address)
+{
+#define HEX_ENCODING_VALUE 16
+       gchar **temp_str = NULL;
+       char *temp_address;
+       guint address;
+
+       if (!ip_address)
+               return 0;
+
+       temp_str = g_strsplit(ip_address, ".", 5);
+       temp_address = g_strdup_printf("%02x%02x%02x%02x", atoi(temp_str[0]), atoi(temp_str[1]), atoi(temp_str[2]), atoi(temp_str[3]));
+       /* Free resources */
+       g_strfreev(temp_str);
+
+       address = strtoul(temp_address, (char **)NULL, HEX_ENCODING_VALUE);
+       g_free(temp_address);
+       return address;
+}
 
 void __remove_service_handler(gpointer data)
 {
@@ -56,7 +70,7 @@ void __remove_service_handler(gpointer data)
                return;
        }
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "Entered");
+       ps_info_ex_svc(service, "Entered");
        /*Need to remove the compelete hash table*/
        g_slist_free(service->contexts);
 
@@ -70,48 +84,6 @@ void __remove_service_handler(gpointer data)
        /*Need to free the memory of the internal structure*/
        g_free(service->path);
        g_free(service);
-
-       dbg("Exiting");
-       return;
-}
-
-static void __ps_service_emit_property_changed_signal(ps_service_t *service)
-{
-       GVariant *gv = NULL;
-       GVariantBuilder property;
-
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "get service properties");
-
-       gv = _ps_service_get_properties(service, &property);
-       packet_service_service_emit_property_changed(service->if_obj, gv);
-
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Exiting");
-       return;
-}
-
-static void __ps_service_emit_context_added_signal(ps_service_t *service, gpointer context)
-{
-       GVariant *gv = NULL;
-       GVariantBuilder property;
-
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "get service properties");
-
-       gv = _ps_context_get_properties(context, &property);
-       packet_service_service_emit_context_added(service->if_obj, gv);
-
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Exiting");
-       return;
-}
-
-static void __ps_service_emit_context_removed_signal(ps_service_t *service, gpointer context)
-{
-       ps_context_t *pscontext = context;
-
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Entered");
-       packet_service_service_emit_context_removed(service->if_obj, pscontext->path);
-
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Exiting");
-       return;
 }
 
 static char *__ps_service_act2string(enum telephony_network_access_technology act)
@@ -145,7 +117,7 @@ static char *__ps_service_act2string(enum telephony_network_access_technology ac
        return NULL;
 }
 
-static gboolean __ps_service_check_connection_option(gpointer object, gpointer context)
+static gboolean __ps_service_check_connection_option(ps_service_t *service, ps_context_t *context)
 {
        gboolean b_connect = TRUE;
        gboolean power = FALSE, sim = FALSE, data = FALSE, flight = FALSE;
@@ -158,15 +130,12 @@ static gboolean __ps_service_check_connection_option(gpointer object, gpointer c
        gboolean nw_ops = FALSE;
 #endif
 
-       ps_service_t *service = object;
        ps_modem_t *modem = _ps_service_ref_modem(service);
        ps_master_t *master = _ps_modem_ref_master(modem);
-       ps_context_t *ps_context = context;
-       CoreObject *co_context = (CoreObject *)_ps_context_ref_co_context(context);
-       CoreObject *co_network = _ps_service_ref_co_network(service);
+       CoreObject *co_context = _ps_context_ref_co_context(context);
 
-       if (TRUE != _ps_context_get_profile_enable(ps_context)) {
-               ps_warn_ex_co(co_network, "Profile is disabled.");
+       if (TRUE != _ps_context_get_profile_enable(context)) {
+               ps_warn_ex_svc(service, "Profile is disabled.");
                return FALSE;
        }
 
@@ -175,7 +144,7 @@ static gboolean __ps_service_check_connection_option(gpointer object, gpointer c
        flight = _ps_modem_get_flght_mode(modem);
        profile_reset = _ps_modem_get_reset_profile(modem);
 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-       hook_flag = _ps_modem_get_hook_flag(modem);
+       hook_flag = _ps_hook_get_hook_flag(modem);
        if (hook_flag != PS_NO_PENDING_REQUEST)
                nw_ops = TRUE;
 #endif
@@ -183,38 +152,20 @@ static gboolean __ps_service_check_connection_option(gpointer object, gpointer c
                power = TRUE;
 
        b_connect &= power;
-       b_connect &= sim;
 
        role = tcore_context_get_role(co_context);
-       if (role == CONTEXT_ROLE_IMS || role == CONTEXT_ROLE_IMS_EMERGENCY || role == CONTEXT_ROLE_IMS_UT) {
-               ps_info_ex_co(co_network, "Do not check data and data roaming allowed value in case of IMS type");
+       if (role == CONTEXT_ROLE_IMS || role == CONTEXT_ROLE_IMS_EMERGENCY || role == CONTEXT_ROLE_IMS_UT
+           || role == CONTEXT_ROLE_FOTA || role == CONTEXT_ROLE_BIP) {
+               ps_info_ex_svc(service, "Do not check data and data roaming allowed value in case of IMS type");
        } else {
                if (service->roaming) {
                        gboolean roaming_allowed = FALSE;
                        roaming_allowed = _ps_modem_get_data_roaming_allowed(modem);
-                       ps_warn_ex_co(co_network, "roaming_allowed:[%d]", roaming_allowed);
+                       ps_warn_ex_svc(service, "roaming_allowed:[%d]", roaming_allowed);
                        b_connect &= roaming_allowed;
                }
 
-#if defined(TIZEN_SUPPORT_MMS_CONNECT_FORCE)
-               ps_dbg_ex_co(co_network, "csc runtime feature enabled");
-               if (role != CONTEXT_ROLE_MMS && role != CONTEXT_ROLE_PREPAID_MMS) {
-                       b_connect &= data;
-               } else {
-                       char *tmp_apn = NULL;
-                       tmp_apn = tcore_context_get_apn(co_context);
-                       ps_info_ex_co(co_network, "csc runtime feature is enabled: apn[%s]", tmp_apn);
-                       if (ps_feature_get_bool(PS_FEATURE_OPERATOR_SKT)) {
-                               if (data)
-                                       tcore_context_set_apn(co_context, "web.sktelecom.com");
-                               else
-                                       tcore_context_set_apn(co_context, "mmsonly.sktelecom.com");
-                       }
-               }
-#else
-               ps_dbg_ex_co(co_network, "csc runtime feature disabled");
                b_connect &= data;
-#endif
        }
 
        b_connect &= !flight;
@@ -223,9 +174,10 @@ static gboolean __ps_service_check_connection_option(gpointer object, gpointer c
 #endif
        b_connect &= !service->restricted;
        b_connect &= !profile_reset;
-#ifndef TIZEN_PS_FORCE_ATTACH_DETACH
-       b_connect &= service->ps_attached;
-#endif
+       if (role != CONTEXT_ROLE_IMS_EMERGENCY) {
+               b_connect &= service->ps_attached;
+               b_connect &= sim;
+       }
        ps_mode = _ps_modem_get_psmode(modem);
 
        /*
@@ -240,28 +192,24 @@ static gboolean __ps_service_check_connection_option(gpointer object, gpointer c
         */
        if (master && master->initial_pdp_conn == FALSE) {
                int wifi_state = PS_WIFI_STATE_OFF;
-               Server *s = NULL;
-               Storage *strg = NULL;
 
-               s = tcore_plugin_ref_server(service->plg);
-               strg = tcore_server_find_storage(s, "vconf");
-               wifi_state = tcore_storage_get_int(strg, KEY_WIFI_STATE);
+               wifi_state = _ps_master_get_storage_value_int(master, KEY_WIFI_STATE);
                if (wifi_state == PS_WIFI_STATE_CONNECTED) {
                        if (service->wifi_connected_checked == FALSE) {
-                               ps_info_ex_co(co_network, "DO NOT set PDP retry timer when WiFi connected but PDP never been connected yet.");
+                               ps_info_ex_svc(service, "DO NOT set PDP retry timer when WiFi connected but PDP never been connected yet.");
                                b_connect &= FALSE;
                                service->wifi_connected_checked = TRUE;
                        } else {
-                               ps_info_ex_co(co_network, "Wifi connected state was already checked.");
+                               ps_info_ex_svc(service, "Wifi connected state was already checked.");
                        }
                }
        }
 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-       ps_info_ex_co(co_network, "b_connect(%d), power(%d), sim init(%d), data allowed(%d), flight mode(%d) restricted(%d) ps_attached(%d), ps_mode(%d), fook_flag(%d)",
-               b_connect, power, sim, data, flight, service->restricted, service->ps_attached, ps_mode, hook_flag);
+       ps_info_ex_svc(service, "b_connect(%d), power(%d), sim init(%d), data allowed(%d), flight mode(%d) restricted(%d) ps_attached(%d), ps_mode(%d), fook_flag(%d)",
+                      b_connect, power, sim, data, flight, service->restricted, service->ps_attached, ps_mode, hook_flag);
 #else
-       ps_info_ex_co(co_network, "b_connect(%d), power(%d), sim init(%d), data allowed(%d), flight mode(%d) restricted(%d) ps_attached(%d), ps_mode(%d)",
-               b_connect, power, sim, data, flight, service->restricted, service->ps_attached, ps_mode);
+       ps_info_ex_svc(service, "b_connect(%d), power(%d), sim init(%d), data allowed(%d), flight mode(%d) restricted(%d) ps_attached(%d), ps_mode(%d)",
+                      b_connect, power, sim, data, flight, service->restricted, service->ps_attached, ps_mode);
 #endif
        /* In case of ME in LCD off & UPS mode.
         * Do not allow PDP activation.
@@ -271,12 +219,11 @@ static gboolean __ps_service_check_connection_option(gpointer object, gpointer c
                ups_mode = ps_mode & ~POWER_SAVING_MODE_DATA_ALLOWED;
                emc_data_allowed = ps_mode & POWER_SAVING_MODE_DATA_ALLOWED;
                if (emc_data_allowed == FALSE &&
-                       (ups_mode > POWER_SAVING_MODE_NORMAL && ups_mode < POWER_SAVING_MODE_WEARABLE)) {
-                       Storage *strg_vconf = tcore_server_find_storage(tcore_plugin_ref_server(service->plg), "vconf");
-                       gint pm_state = tcore_storage_get_int(strg_vconf, STORAGE_KEY_PM_STATE);
+                   (ups_mode > POWER_SAVING_MODE_NORMAL && ups_mode < POWER_SAVING_MODE_WEARABLE)) {
+                       gint pm_state = _ps_master_get_storage_value_int(master, STORAGE_KEY_PM_STATE);
                        if (pm_state == 3 &&
-                                       (role != CONTEXT_ROLE_IMS &&  role != CONTEXT_ROLE_IMS_EMERGENCY &&  role != CONTEXT_ROLE_IMS_UT)) {
-                               ps_warn_ex_co(co_network, "PDP activation is not allowed in LCD off & UPS mode.");
+                           (role != CONTEXT_ROLE_IMS &&  role != CONTEXT_ROLE_IMS_EMERGENCY &&  role != CONTEXT_ROLE_IMS_UT)) {
+                               ps_warn_ex_svc(service, "PDP activation is not allowed in LCD off & UPS mode.");
                                b_connect = FALSE;
                        }
                }
@@ -289,42 +236,50 @@ static int __ps_service_connetion_timeout_handler(alarm_id_t alarm_id, void *con
        int rv = 0;
        ps_context_t *ps_context = context;
        ps_service_t *service = _ps_context_ref_service(ps_context);
+       enum co_context_role role;
        if (service == NULL) {
                err("service is NULL!!!");
                return rv;
        }
 
        if (ps_context->timer_src > 0) {
-               ps_info_ex_co(_ps_service_ref_co_network(service), "remove connection retry timer (%d)", ps_context->timer_src);
+               ps_info_ex_svc(service, "remove connection retry timer (%d)", ps_context->timer_src);
                alarmmgr_remove_alarm(ps_context->timer_src);
                ps_context->timer_src = 0;
        }
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "Re-try for %d type", tcore_context_get_role(_ps_context_ref_co_context(ps_context)));
+       role = tcore_context_get_role(_ps_context_ref_co_context(ps_context));
+       ps_info_ex_svc(service, "Re-try for %d type is_epdg_available: %d",
+                      role, service->is_epdg_available);
+       if ((role == CONTEXT_ROLE_IMS) && (service->is_epdg_available == TRUE)) {
+               ps_info_ex_svc(service, "Do not re-try for IMS PDN as ePDG is available");
+               return rv;
+       }
+
+       ps_info_ex_svc(service, "Re-try for context role [%d]", tcore_context_get_role(_ps_context_ref_co_context(ps_context)));
        rv = _ps_service_activate_context(service, ps_context);
-       ps_info_ex_co(_ps_service_ref_co_network(service), "return rv(%d)", rv);
+       ps_info_ex_svc(service, "return rv(%d)", rv);
        return rv;
 }
 
-static gboolean __ps_service_check_is_network_in_serivce(gpointer object)
+static gboolean __ps_service_check_is_network_in_serivce(ps_service_t *service)
 {
-       ps_service_t *service = object;
-       CoreObject *co_network = NULL;
+       CoreObject *co_network = _ps_service_ref_co_network(service);
        enum telephony_network_service_type service_type = NETWORK_SERVICE_TYPE_UNKNOWN;
        gboolean rv = FALSE;
 
-       co_network = _ps_service_ref_co_network(service);
        tcore_network_get_service_type(co_network, &service_type);
-       ps_warn_ex_co(co_network, "service_type[%d]", service_type);
+       ps_warn_ex_svc(service, "service_type[%d]", service_type);
        switch (service_type) {
-               case NETWORK_SERVICE_TYPE_UNKNOWN:
-               case NETWORK_SERVICE_TYPE_NO_SERVICE:
-               case NETWORK_SERVICE_TYPE_EMERGENCY:
-               case NETWORK_SERVICE_TYPE_SEARCH:
-                       break;
-               default:
-                       rv = TRUE;
-                       break;
+       case NETWORK_SERVICE_TYPE_UNKNOWN:
+       case NETWORK_SERVICE_TYPE_NO_SERVICE:
+       case NETWORK_SERVICE_TYPE_EMERGENCY:
+       case NETWORK_SERVICE_TYPE_SEARCH:
+               break;
+
+       default:
+               rv = TRUE;
+               break;
        }
        return rv;
 }
@@ -333,14 +288,17 @@ static TReturn __ps_service_set_attach_apn(ps_service_t *service, CoreObject *co
 {
        TReturn rv;
        char *apn = tcore_context_get_apn(co_context);
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "'Attach APN(%d)' [%s]", tcore_context_get_role(co_context), apn);
+       CoreObject *co_ps = _ps_service_ref_co_ps(service);
+
+       ps_dbg_ex_svc(service, "'Attach APN(%d)' [%s]", tcore_context_get_role(co_context), apn);
 
        if (set_cid)
-               tcore_context_set_id(co_context, set_cid); // internet
+               tcore_context_set_id(co_context, set_cid);  // internet
 
-       rv = tcore_ps_define_context(service->co_ps, co_context, NULL);
+       //rv = tcore_ps_define_context(co_ps, co_context, 0, NULL);
+       rv = tcore_ps_define_context(co_ps, co_context, NULL);
        if (rv != TCORE_RETURN_SUCCESS)
-               ps_err_ex_co(_ps_service_ref_co_network(service), "fail to define context");
+               ps_err_ex_svc(service, "fail to define context");
 
        g_free(apn);
        return rv;
@@ -350,31 +308,24 @@ void _ps_service_set_attach_apn(ps_service_t *service)
 {
        unsigned int index;
        int default_data_subs;
-       ps_subs_type subscription_type;
-       Server *s = NULL;
-       Storage *strg;
+       ps_subs_type subs_type;
        ps_modem_t *modem = NULL;
-
-       if (service->attach_apn_complete == TRUE) {
-               ps_info_ex_co(_ps_service_ref_co_network(service), "Attach APN already completed");
-               return;
-       }
+       ps_master_t *master = NULL;
 
        modem = _ps_service_ref_modem(service);
+       master = _ps_modem_ref_master(modem);
 
        /* Check for default data subscription value if matchs for modem then only attach */
-       subscription_type = _ps_modem_get_subs_type(modem);
-       s = tcore_plugin_ref_server(_ps_service_ref_plugin(service));
-       strg = tcore_server_find_storage(s, "vconf");
-       default_data_subs = tcore_storage_get_int(strg, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
-       if (default_data_subs != (int)subscription_type) {
-               ps_warn_ex_co(_ps_service_ref_co_network(service), "Ignore Attach APN for non-dds sim [DDS - SIM%d]", default_data_subs + 1);
+       subs_type = _ps_modem_get_subs_type(modem);
+       default_data_subs = _ps_master_get_storage_value_int(master, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
+       if (default_data_subs != (int)subs_type) {
+               ps_warn_ex_svc(service, "Ignore Attach APN for non-dds sim [DDS - SIM%d]", default_data_subs + 1);
                return;
        }
 
        for (index = 0; index < g_slist_length(service->contexts); index++) {
-               gpointer ps_context = g_slist_nth_data(service->contexts, index);
-               CoreObject *co_context = _ps_context_ref_co_context(ps_context);
+               ps_context_t *context = g_slist_nth_data(service->contexts, index);
+               CoreObject *co_context = _ps_context_ref_co_context(context);
                gboolean attach_apn = tcore_context_get_attach_apn(co_context);
                if (attach_apn) {
                        __ps_service_set_attach_apn(service, co_context, 0);
@@ -384,117 +335,107 @@ void _ps_service_set_attach_apn(ps_service_t *service)
        }
 }
 
-gpointer _ps_service_create_service(GDBusConnection *conn, TcorePlugin *p, gpointer p_modem,
-               CoreObject *co_network, CoreObject *co_ps, gchar *path)
+ps_service_t *_ps_service_create_service(GDBusConnection *conn, TcorePlugin *p, ps_modem_t *modem,
+                                        CoreObject *co_network, CoreObject *co_ps, gchar *path)
 {
-       PacketServiceService *service;
-       GError *error = NULL;
        ps_service_t *new_service;
 
-       ps_dbg_ex_co(co_network, "service object create");
        g_return_val_if_fail(conn != NULL, NULL);
-       g_return_val_if_fail(p_modem != NULL, NULL);
+       g_return_val_if_fail(modem != NULL, NULL);
 
-       /*creating the master object for the interface com.tcore.ps.modem*/
-       service = packet_service_service_skeleton_new();
+       ps_dbg_ex_modem(modem, "service object create");
 
        /*Initializing the modem list for internal referencing*/
        new_service = g_try_malloc0(sizeof(ps_service_t));
        if (NULL == new_service) {
-               ps_err_ex_co(co_network, "Unable to allocate memory for master");
+               ps_err_ex_modem(modem, "Unable to allocate memory for master");
                goto FAILURE;
        }
 
        new_service->conn = conn;
        new_service->plg = p;
-       new_service->p_modem = p_modem;
+       new_service->p_modem = modem;
        new_service->co_network = co_network;
        new_service->co_ps = co_ps;
        new_service->path = g_strdup(path);
-       new_service->if_obj = service;
+       new_service->subs_type = modem->subs_type;
 
-       /*exporting the interface object to the path mention for master*/
-       if (TRUE != g_dbus_interface_skeleton_export((G_DBUS_INTERFACE_SKELETON(service)), conn, path, &error)) {
-               ps_err_ex_co(co_network, "Failed to export interaface with message [%s] & ID[%d] ", error->message, error->code);
-               goto FAILURE;
-       }
-
-       _ps_hook_co_network_event(new_service);
+       _ps_add_co_network_event(new_service);
        _ps_get_co_network_values(new_service);
-       _ps_hook_co_ps_event(new_service);
+       _ps_add_co_ps_event(new_service);
 
        /*Setting up the interface for the service */
-       _ps_service_setup_interface(service, new_service);
+       if (!ps_service_setup_interface(new_service)) {
+               g_free(new_service->path);
+               goto FAILURE;
+       }
 
-//     new_service->connection_timeout = TIMEOUT_DEFAULT;
-       ps_info_ex_co(co_network, "Successfully Created the service");
+//     new_service->connection_timeout = PDP_RETRY_TIME_OUT_DEFAULT;
+       ps_info_ex_modem(modem, "Successfully Created the service");
        return new_service;
 
-FAILURE:
+ FAILURE:
        /*To Do: Handle failure case*/
        g_free(new_service);
-       g_assert_no_error(error);
        return NULL;
 }
 
-gboolean _ps_service_ref_context(gpointer object, gpointer context)
+gboolean _ps_service_ref_context(ps_service_t *service, ps_context_t *context)
 {
        gpointer tmp = NULL;
-       ps_service_t *service = object;
-       CoreObject *co_network = NULL;
 
        g_return_val_if_fail(service != NULL, FALSE);
 
-       co_network = _ps_service_ref_co_network(service);
-       ps_dbg_ex_co(co_network, "service refer to context");
+       ps_dbg_ex_svc(service, "service refer to context");
+
        tmp = g_slist_find(service->contexts, context);
-       if (tmp != NULL) {
-               ps_dbg_ex_co(co_network, "context(%p) already existed", tmp);
+       if (tmp) {
+               ps_dbg_ex_svc(service, "context(%p) already existed", tmp);
                return FALSE;
        }
 
        _ps_context_set_service(context, service);
-       tcore_ps_add_context(service->co_ps, (CoreObject *) _ps_context_ref_co_context(context));
+       tcore_ps_add_context(_ps_service_ref_co_ps(service), _ps_context_ref_co_context(context));
        service->contexts = g_slist_append(service->contexts, context);
 
-       ps_info_ex_co(co_network, "context(%p) insert to linked-list", context);
-       __ps_service_emit_context_added_signal(service, context);
+       ps_info_ex_svc(service, "context(%p) insert to linked-list", context);
+       ps_service_emit_context_added_signal(service, context);
 
        return TRUE;
 }
 
-gboolean _ps_service_ref_contexts(gpointer object, GSList *contexts, gchar *operator)
+gboolean _ps_service_ref_contexts(ps_service_t *service, GSList *contexts, gchar *operator)
 {
-       ps_service_t *service = object;
        gboolean ret = TRUE;
        int rv;
        unsigned int index, count;
-       CoreObject *co_network = NULL;
+
        g_return_val_if_fail(service != NULL, FALSE);
+
        count = g_slist_length(contexts);
-       co_network = _ps_service_ref_co_network(service);
-       ps_dbg_ex_co(co_network, "service refer to contexts: count(%d)", count);
+       ps_dbg_ex_svc(service, "service refer to contexts: count(%d)", count);
 
        for (index = 0; index < count; index++) {
-               gpointer tmp = NULL, value = NULL;
+               gpointer tmp = NULL;
+               ps_context_t *context = g_slist_nth_data(contexts, index);
+               CoreObject *co_context = _ps_context_ref_co_context(context);
 
-               value = g_slist_nth_data(contexts, index);
-               tmp = g_slist_find(service->contexts, value);
-               if (tmp != NULL) {
-                       ps_dbg_ex_co(co_network, "context(%p) already existed", tmp);
+               tmp = g_slist_find(service->contexts, context);
+               if (tmp) {
+                       ps_dbg_ex_svc(service, "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));
-               service->contexts = g_slist_append(service->contexts, value);
+               _ps_context_set_service(context, service);
+               tcore_ps_add_context(_ps_service_ref_co_ps(service), co_context);
+               service->contexts = g_slist_append(service->contexts, context);
 
-               ps_info_ex_co(co_network, "context(%p) path(%s) insert to linked-list", value, _ps_context_ref_path(value));
-               __ps_service_emit_context_added_signal(service, value);
+               ps_info_ex_svc(service, "context(%p) path(%s) insert to linked-list", context, _ps_context_ref_path(context));
+               ps_service_emit_context_added_signal(service, context);
 
 #ifdef PREPAID_SIM_APN_SUPPORT
-               ret = _ps_service_connect_last_connected_context_ex(service, value, NULL, operator);
-               dbg("ret[%d]", ret);
+               ret = _ps_service_connect_last_connected_context_ex(service, context, NULL, operator);
+               ps_info_ex_svc(service, "ret[%d]", ret);
                if (ret == TRUE) {
                        /* process next available profile */
                        continue;
@@ -502,35 +443,33 @@ gboolean _ps_service_ref_contexts(gpointer object, GSList *contexts, gchar *oper
 #endif
 
                if (service->ps_attached) {
-                       gboolean f_awo = _ps_context_get_alwayson_enable(value);
+                       gboolean f_awo = _ps_context_get_alwayson_enable(context);
                        gboolean ims_activation_requested = FALSE;
 
                        if (f_awo) {
-                               rv = _ps_service_define_context(service, value);
-                               ps_info_ex_co(co_network, "Always-on started, return rv(%d)", rv);
+                               rv = _ps_service_define_context(service, context);
+                               ps_info_ex_svc(service, "Always-on started, return rv(%d)", rv);
                        }
 
                        ims_activation_requested = _ps_service_get_ims_activation_requested(service);
-                       if (ims_activation_requested && (CONTEXT_ROLE_IMS == tcore_context_get_role(_ps_context_ref_co_context(value)))) {
-                               rv = _ps_service_define_context(service, value);
-                               ps_info_ex_co(co_network, "IMS PDN rv(%d)", rv);
+                       if (ims_activation_requested && (CONTEXT_ROLE_IMS == tcore_context_get_role(co_context))) {
+                               rv = _ps_service_define_context(service, context);
+                               ps_info_ex_svc(service, "IMS PDN rv(%d)", rv);
                                ims_activation_requested = FALSE;
                        }
                }
        }
-       ps_dbg_ex_co(co_network, "service->contexts: count(%d)", g_slist_length(service->contexts));
+       ps_dbg_ex_svc(service, "service->contexts: count(%d)", g_slist_length(service->contexts));
        _ps_update_cellular_state_key(service);
        return ret;
 }
 
-gboolean _ps_service_get_properties_handler(gpointer object, GVariantBuilder *properties)
+gboolean _ps_service_get_properties_handler(ps_service_t *service, GVariantBuilder *properties)
 {
-       ps_service_t *service = object;
-
        g_return_val_if_fail(service != NULL, FALSE);
        g_return_val_if_fail(properties != NULL, FALSE);
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "get service properties");
+       ps_info_ex_svc(service, "get service properties");
 
        g_variant_builder_open(properties, G_VARIANT_TYPE("a{ss}"));
        g_variant_builder_add(properties, "{ss}", "path", service->path);
@@ -539,18 +478,16 @@ gboolean _ps_service_get_properties_handler(gpointer object, GVariantBuilder *pr
        g_variant_builder_add(properties, "{ss}", "act", __ps_service_act2string(service->act));
        g_variant_builder_close(properties);
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Exiting");
+       ps_dbg_ex_svc(service, "Exiting");
        return TRUE;
 }
 
-GVariant *_ps_service_get_properties(gpointer object, GVariantBuilder *properties)
+GVariant *_ps_service_get_properties(ps_service_t *service, GVariantBuilder *properties)
 {
-       ps_service_t *service = object;
-
        g_return_val_if_fail(service != NULL, FALSE);
        g_return_val_if_fail(properties != NULL, FALSE);
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "get service properties");
+       ps_info_ex_svc(service, "get service properties");
 
        g_variant_builder_init(properties, G_VARIANT_TYPE("a{ss}"));
 
@@ -559,74 +496,63 @@ GVariant *_ps_service_get_properties(gpointer object, GVariantBuilder *propertie
        g_variant_builder_add(properties, "{ss}", "roaming", BOOL2STRING(service->roaming));
        g_variant_builder_add(properties, "{ss}", "act", __ps_service_act2string(service->act));
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Exiting");
+       ps_dbg_ex_svc(service, "Exiting");
        return g_variant_builder_end(properties);
 }
 
-gchar *_ps_service_ref_path(gpointer object)
+gchar *_ps_service_ref_path(ps_service_t *service)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, NULL);
-
        return service->path;
 }
 
-gpointer _ps_service_ref_plugin(gpointer object)
+TcorePlugin *_ps_service_ref_plugin(ps_service_t *service)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, NULL);
-
        return service->plg;
 }
 
-gpointer _ps_service_ref_co_network(gpointer object)
+CoreObject *_ps_service_ref_co_network(ps_service_t *service)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, NULL);
-
        return service->co_network;
 }
 
-gpointer _ps_service_ref_co_ps(gpointer object)
+CoreObject *_ps_service_ref_co_ps(ps_service_t *service)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, NULL);
-
        return service->co_ps;
 }
 
-gpointer _ps_service_ref_modem(gpointer object)
+ps_modem_t *_ps_service_ref_modem(ps_service_t *service)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, NULL);
-
        return service->p_modem;
 }
 
-gboolean _ps_service_set_context_devinfo(gpointer object, struct tnoti_ps_pdp_ipconfiguration *devinfo)
+gboolean _ps_service_set_context_devinfo(ps_service_t *service, struct tnoti_ps_pdp_ipconfiguration *devinfo)
 {
-       GSList *contexts = NULL;
-       ps_service_t *service = object;
+       GSList *co_contexts = NULL;
        CoreObject *co_context = NULL;
 
        g_return_val_if_fail(service != NULL, FALSE);
        g_return_val_if_fail(devinfo != NULL, FALSE);
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "set context device info for cid %d", devinfo->context_id);
+       ps_info_ex_svc(service, "set context device info for cid %d", devinfo->context_id);
 
-       contexts = tcore_ps_ref_context_by_id(service->co_ps, devinfo->context_id);
-       if (!contexts) {
-               ps_err_ex_co(_ps_service_ref_co_network(service), "fail to ref context by cid.");
+       co_contexts = tcore_ps_ref_context_by_id(_ps_service_ref_co_ps(service), devinfo->context_id);
+       if (!co_contexts) {
+               ps_err_ex_svc(service, "fail to ref context by cid.");
                return FALSE;
        }
 
-       while (contexts) {
+       while (co_contexts) {
                ps_modem_t *modem = NULL;
                int role = CONTEXT_ROLE_UNKNOWN;
 
-               co_context = contexts->data;
+               co_context = co_contexts->data;
                if (!co_context) {
-                       contexts = contexts->next;
+                       co_contexts = co_contexts->next;
                        continue;
                }
 
@@ -634,13 +560,13 @@ gboolean _ps_service_set_context_devinfo(gpointer object, struct tnoti_ps_pdp_ip
                role = tcore_context_get_role(co_context);
                modem = _ps_service_ref_modem(service);
                if (g_strcmp0(modem->operator, "45005") == 0 && role == CONTEXT_ROLE_IMS) {
-                       ps_dbg_ex_co(_ps_service_ref_co_network(service), "SKT IMS PDN");
+                       ps_dbg_ex_svc(service, "SKT IMS PDN");
                        /*IPv4*/
                        if (devinfo->pcscf_ipv4_count == 0) {
                                char ipv4[16];
                                snprintf(ipv4, 16, "%d.%d.%d.%d",
-                                       devinfo->ip_address[0], devinfo->ip_address[1],
-                                       devinfo->ip_address[2], devinfo->ip_address[3]);
+                                        devinfo->ip_address[0], devinfo->ip_address[1],
+                                        devinfo->ip_address[2], devinfo->ip_address[3]);
                                if (!g_str_equal(ipv4, "0.0.0.0")) {
                                        devinfo->pcscf_ipv4 = g_try_malloc0(sizeof(char *));
                                        if (devinfo->pcscf_ipv4 == NULL)
@@ -663,103 +589,99 @@ gboolean _ps_service_set_context_devinfo(gpointer object, struct tnoti_ps_pdp_ip
 
                tcore_context_set_devinfo(co_context, devinfo);
 
-               contexts = contexts->next;
+               co_contexts = co_contexts->next;
        }
 
        return TRUE;
 }
 
-gboolean _ps_service_set_context_bearerinfo(gpointer object, struct tnoti_ps_dedicated_bearer_info *bearer_info)
+gboolean _ps_service_set_context_bearerinfo(ps_service_t *service, struct tnoti_ps_dedicated_bearer_info *bearer_info)
 {
-       GSList *contexts = NULL;
-       ps_service_t *service = object;
+       GSList *co_contexts = NULL;
        CoreObject *co_context = NULL;
 
        g_return_val_if_fail(service != NULL, FALSE);
        g_return_val_if_fail(bearer_info != NULL, FALSE);
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "set context bearer info");
+       ps_info_ex_svc(service, "set context bearer info");
 
-       contexts = tcore_ps_ref_context_by_id(service->co_ps, bearer_info->primary_context_id);
-       if (!contexts) {
-               ps_err_ex_co(_ps_service_ref_co_network(service), "fail to ref context by cid.");
+       co_contexts = tcore_ps_ref_context_by_id(_ps_service_ref_co_ps(service), bearer_info->primary_context_id);
+       if (!co_contexts) {
+               ps_err_ex_svc(service, "fail to ref context by cid.");
                return FALSE;
        }
 
-       while (contexts) {
+       while (co_contexts) {
                unsigned int index;
 
-               co_context = contexts->data;
+               co_context = co_contexts->data;
                if (!co_context) {
-                       contexts = contexts->next;
+                       co_contexts = co_contexts->next;
                        continue;
                }
 
                for (index = 0; index < g_slist_length(service->contexts); index++) {
-                       gpointer value = g_slist_nth_data(service->contexts, index);
-                       if (co_context == _ps_context_ref_co_context(value)) {
-                               _ps_context_set_bearer_info(value, bearer_info);
+                       ps_context_t *context = g_slist_nth_data(service->contexts, index);
+                       if (co_context == _ps_context_ref_co_context(context)) {
+                               _ps_context_set_bearer_info(context, bearer_info);
                                break;
                        }
                }
 
-               contexts = contexts->next;
+               co_contexts = co_contexts->next;
        }
 
        return TRUE;
 }
 
-int _ps_service_define_context(gpointer object, gpointer context)
+int _ps_service_define_context(ps_service_t *service, ps_context_t *context)
 {
-       ps_service_t *service = object;
        CoreObject *co_context = NULL;
        gboolean b_connect = TRUE;
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "define context(%p)", context);
        g_return_val_if_fail(service != NULL, FALSE);
+       ps_dbg_ex_svc(service, "define context(%p)", context);
 
        b_connect = __ps_service_check_connection_option(service, context);
        if (!b_connect)
                return TCORE_RETURN_EPERM;
 
-       return tcore_ps_define_context(service->co_ps, co_context, NULL);
+//     return tcore_ps_define_context(_ps_service_ref_co_ps(service), co_context, 0, NULL);
+       return tcore_ps_define_context(_ps_service_ref_co_ps(service), co_context, NULL);
 }
 
-int _ps_service_activate_context(gpointer object, gpointer context)
+int _ps_service_activate_context(ps_service_t *service, ps_context_t *context)
 {
-       ps_service_t *service = object;
        ps_modem_t *modem = NULL;
+       ps_master_t *master = NULL;
        CoreObject *co_context = NULL;
        gboolean b_connect = TRUE;
        gboolean ps_defined;
        int ret = TCORE_RETURN_SUCCESS;
        int default_data_subs = 1;
-       ps_subs_type subscription_type = 1;
-       Server *s = NULL;
-       Storage *strg;
-       CoreObject *co_network = _ps_service_ref_co_network(service);
+       ps_subs_type subs_type = 1;
+       CoreObject *co_ps = _ps_service_ref_co_ps(service);
 
        g_return_val_if_fail(service != NULL, FALSE);
 
-       ps_dbg_ex_co(co_network, "activate context(%p)", context);
-       s = tcore_plugin_ref_server(_ps_service_ref_plugin(service));
-       strg = tcore_server_find_storage(s, "vconf");
+       ps_dbg_ex_svc(service, "activate context(%p)", context);
 
        modem = _ps_service_ref_modem(service);
+       master = _ps_modem_ref_master(modem);
        ps_defined = _ps_context_get_ps_defined(context);
-       co_context = (CoreObject *)_ps_context_ref_co_context(context);
+       co_context = _ps_context_ref_co_context(context);
 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
        if (modem->hook_flag != PS_NO_PENDING_REQUEST) {
-               ps_info_ex_co(co_network, "Pending request present in queue with flag %x", modem->hook_flag);
+               ps_info_ex_svc(service, "Pending request present in queue with flag %x", modem->hook_flag);
                ret = TCORE_RETURN_FAILURE;
                goto EXIT;
        }
 #endif
        /* Check for default data subscription value if matchs for modem then only activate */
-       subscription_type = _ps_modem_get_subs_type(modem);
-       default_data_subs = tcore_storage_get_int(strg, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
-       if ((default_data_subs != -1) && (default_data_subs != (int)subscription_type)) {
-               ps_warn_ex_co(co_network, "activation  for only [SIM%d] selected by Setting", default_data_subs + 1);
+       subs_type = _ps_modem_get_subs_type(modem);
+       default_data_subs = _ps_master_get_storage_value_int(master, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
+       if ((default_data_subs != -1) && (default_data_subs != (int)subs_type)) {
+               ps_warn_ex_svc(service, "activation  for only [SIM%d] selected by Setting", default_data_subs + 1);
                ret = TCORE_RETURN_FAILURE;
                goto EXIT;
        }
@@ -770,14 +692,29 @@ int _ps_service_activate_context(gpointer object, gpointer context)
                goto EXIT;
        }
 
+#ifdef TIZEN_SUPPORT_VOLTE
+       if (CONTEXT_ROLE_IMS == tcore_context_get_role(co_context)) {
+               enum telephony_network_service_type svc_type;
+               CoreObject *co_network = _ps_service_ref_co_network(service);
+               tcore_network_get_service_type(co_network, &svc_type);
+
+               if (svc_type != NETWORK_SERVICE_TYPE_LTE) {
+                       ps_warn_ex_svc(service, "IMS PDN is not allowed in %d network", svc_type);
+                       goto EXIT;
+               }
+               tcore_network_set_ims_on_deregistering(_ps_service_ref_co_network(service), FALSE);
+       }
+#endif
+
        if (!ps_defined) {
-               ps_info_ex_co(co_network, "pdp profile is not defined yet, define first. ");
-               ret = tcore_ps_define_context(service->co_ps, co_context, NULL);
+               ps_info_ex_svc(service, "pdp profile is not defined yet, define first. ");
+               //ret = tcore_ps_define_context(co_ps, co_context, manual_cid, NULL);
+               ret = tcore_ps_define_context(co_ps, co_context, NULL);
        } else {
-               ps_info_ex_co(co_network, "pdp profile is defined, activate context. ");
-               ret = tcore_ps_activate_context(service->co_ps, co_context, NULL);
+               ps_info_ex_svc(service, "pdp profile is defined, activate context. ");
+               ret = tcore_ps_activate_context(co_ps, co_context, NULL);
        }
-EXIT:
+ EXIT:
        if (ret != TCORE_RETURN_SUCCESS) {
                if (ps_defined) {
                        /*
@@ -786,82 +723,120 @@ EXIT:
                         * CONTEXT_STATE_DEACTIVATING: Do not clear resources.
                         */
                        if (CONTEXT_STATE_DEACTIVATED == tcore_context_get_state(co_context)) {
-                               ps_warn_ex_co(co_network, "fail to activate context after PDP define complete, clear resources.");
+                               ps_warn_ex_svc(service, "fail to activate context after PDP define complete, clear resources.");
                                _ps_context_set_ps_defined(context, FALSE);
-                               tcore_ps_clear_context_id(service->co_ps, co_context);
+                               tcore_ps_clear_context_id(co_ps, co_context);
                        } else {
-                               ps_err_ex_co(co_network, "invalid context state.");
+                               ps_err_ex_svc(service, "invalid context state.");
                        }
                }
        }
        return ret;
 }
 
-gboolean _ps_service_deactivate_context(gpointer object, gpointer context)
+int _ps_service_deactivate_context(ps_service_t *service, ps_context_t *context)
 {
-       ps_service_t *service = object;
-       CoreObject *co_context = NULL;
-       TReturn ret;
+#ifdef TIZEN_SUPPORT_VOLTE
+       enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
+       ps_modem_t *modem = NULL;
+       gboolean ims_registered = FALSE, ims_deregistering = FALSE;
+       struct tel_network_ims_registration_info ims_reg_info = { 0, };
+#endif
+       CoreObject *co_context = _ps_context_ref_co_context(context);
+       CoreObject *co_ps = _ps_service_ref_co_ps(service);
+       TReturn ret = TCORE_RETURN_SUCCESS;
 
        g_return_val_if_fail(service != NULL, FALSE);
-       ps_info_ex_co(_ps_service_ref_co_network(service), "deactivate context(%p)", context);
-       co_context = (CoreObject *)_ps_context_ref_co_context(context);
+       ps_info_ex_svc(service, "deactivate context(%p)", context);
+
+#ifdef TIZEN_SUPPORT_VOLTE
+       role = tcore_context_get_role(co_context);
+       modem = _ps_service_ref_modem(service);
+
+       tcore_network_get_ims_reg_info(_ps_service_ref_co_network(service), &ims_reg_info);
+       if (ims_reg_info.feature_mask & NET_IMS_MASK_REGI)
+               ims_registered = TRUE;
 
-       ret = tcore_ps_deactivate_context(service->co_ps, co_context, NULL);
+       ims_deregistering = tcore_network_get_ims_on_deregistering(_ps_service_ref_co_network(service));
+
+       ps_dbg_ex_svc(service, "role(%d), ims_registered(%d), ims_deregistering(%d), context_state(%d), flight_mode(%d)",
+                     role, ims_registered, ims_deregistering, tcore_context_get_state(co_context), modem->flight_mode);
+
+       if (!modem->flight_mode) {
+               if (role == CONTEXT_ROLE_IMS && (tcore_context_get_state(co_context) == CONTEXT_STATE_ACTIVATED) && ims_registered && !ims_deregistering)
+                       if (_ps_context_deregister_ims(context) == TCORE_RETURN_SUCCESS)
+                               return TCORE_RETURN_SUCCESS;
+
+               ret = tcore_ps_deactivate_context(co_ps, co_context, NULL);
+       }
+#else
+       ret = tcore_ps_deactivate_context(co_ps, co_context, NULL);
+#endif
        if (ret == TCORE_RETURN_PS_DEACTIVATED) {
-               ps_info_ex_co(_ps_service_ref_co_network(service), "context is deactivated");
+                       ps_info_ex_svc(service, "context is deactivated");
                return TCORE_RETURN_SUCCESS;
        }
        return ret;
 }
 
-void _ps_service_set_retry_timeout_value(gpointer object, guint value)
+void _ps_service_set_retry_timeout_value(ps_context_t *context, guint value)
 {
-       ps_context_t *ps_context = object;
-       ps_service_t *service = _ps_context_ref_service(ps_context);;
-       g_return_if_fail(ps_context != NULL);
+       ps_service_t *service = _ps_context_ref_service(context);
+       g_return_if_fail(context != NULL);
 
-       if (ps_context->connection_timeout != value) {
-               ps_context->connection_timeout = value;
-               ps_dbg_ex_co(_ps_service_ref_co_network(service), "current timeout (%d)", ps_context->connection_timeout);
+       if (context->connection_timeout != value) {
+               context->connection_timeout = value;
+               ps_dbg_ex_svc(service, "current timeout (%d)", context->connection_timeout);
        }
 }
 
-void _ps_service_connection_timer(gpointer object, gpointer context)
+void _ps_service_connection_timer(ps_service_t *service, ps_context_t *context)
 {
        int result = 0;
        gboolean f_awo = FALSE;
        gboolean ims_activation_requested = FALSE;
-       ps_service_t *service = object;
-       ps_context_t *ps_context = context;
+       int ret;
+       CoreObject *co_context = _ps_context_ref_co_context(context);
 
        g_return_if_fail(service != NULL);
 
-       f_awo = _ps_context_get_alwayson_enable(ps_context);
+       f_awo = _ps_context_get_alwayson_enable(context);
        ims_activation_requested = _ps_service_get_ims_activation_requested(service);
-       if (!f_awo && (!ims_activation_requested && (CONTEXT_ROLE_IMS != tcore_context_get_role(_ps_context_ref_co_context(ps_context)))))
+       if (!f_awo && (!ims_activation_requested && (CONTEXT_ROLE_IMS != tcore_context_get_role(co_context))))
                return;
 
-       if (ps_context->timer_src > 0) {
-               ps_info_ex_co(_ps_service_ref_co_network(service), "remove connection retry timer (%d)", ps_context->timer_src);
-               alarmmgr_remove_alarm(ps_context->timer_src);
-               ps_context->timer_src = 0;
+       if (context->timer_src > 0) {
+               ps_info_ex_svc(service, "remove connection retry timer (%d)", context->timer_src);
+               alarmmgr_remove_alarm(context->timer_src);
+               context->timer_src = 0;
        }
-       result = alarmmgr_add_alarm_withcb(ALARM_TYPE_VOLATILE, (time_t)(ps_context->connection_timeout),
-                       0, __ps_service_connetion_timeout_handler, ps_context, &(ps_context->timer_src));
+
+       /* Acquire lock */
+       ret = device_power_request_lock(POWER_LOCK_CPU, 0);
+       if (ret < 0)
+               ps_err_ex_svc(service, "ret : (0x%x)", ret);
+
+       result = alarmmgr_add_alarm_withcb(ALARM_TYPE_VOLATILE, (time_t)(context->connection_timeout),
+                                          0, __ps_service_connetion_timeout_handler, context, &(context->timer_src));
+
+       /* Release lock */
+       device_power_release_lock(POWER_LOCK_CPU);
+       if (ret < 0)
+               ps_err_ex_svc(service, "ret : (0x%x)", ret);
+
        if (result != ALARMMGR_RESULT_SUCCESS) {
-               ps_err_ex_co(_ps_service_ref_co_network(service), "Failed to add alarm(%d)", result);
+               ps_err_ex_svc(service, "Failed to add alarm(%d)", result);
                return;
        }
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "cellular service timer started timer src(%d), timeout(%d)",
-               ps_context->timer_src, ps_context->connection_timeout);
-       ps_context->connection_timeout = (ps_context->connection_timeout)*2;
-       if (ps_context->connection_timeout >= TIMEOUT_MAX)
-               ps_context->connection_timeout = TIMEOUT_MAX;
+       ps_info_ex_svc(service, "cellular service timer started timer src(%d), timeout(%d)",
+                      context->timer_src, context->connection_timeout);
+       context->connection_timeout = (context->connection_timeout) * 2;
+       if (context->connection_timeout >= PDP_RETRY_TIME_OUT_MAX)
+               context->connection_timeout = PDP_RETRY_TIME_OUT_MAX;
 }
 
-void _ps_service_reset_connection_timer(gpointer context)
+void _ps_service_reset_connection_timer(ps_context_t *context)
 {
        gboolean f_awo = FALSE;
 #ifdef PREPAID_SIM_APN_SUPPORT
@@ -869,15 +844,12 @@ void _ps_service_reset_connection_timer(gpointer context)
 #endif
        gboolean ims_activation_requested = FALSE;
        ps_service_t *service = NULL;
-       ps_context_t *ps_context = context;
 
-       f_awo = _ps_context_get_alwayson_enable(ps_context);
-       service = _ps_context_ref_service(ps_context);
+       f_awo = _ps_context_get_alwayson_enable(context);
        service = _ps_context_ref_service(context);
-       if (service == NULL) {
-               err("service is NULL!!!");
+       ims_activation_requested = _ps_service_get_ims_activation_requested(service);
+       if (!f_awo && (!ims_activation_requested && (CONTEXT_ROLE_IMS != tcore_context_get_role(_ps_context_ref_co_context(context)))))
                return;
-       }
 
 #ifdef PREPAID_SIM_APN_SUPPORT
        p_awo = _ps_context_get_prepaid_alwayson_enable(context);
@@ -885,91 +857,82 @@ void _ps_service_reset_connection_timer(gpointer context)
                return;
 #endif
 
-       ims_activation_requested = _ps_service_get_ims_activation_requested(service);
-       if (!f_awo && (!ims_activation_requested && (CONTEXT_ROLE_IMS != tcore_context_get_role(_ps_context_ref_co_context(ps_context)))))
+       service = _ps_context_ref_service(context);
+       if (service == NULL) {
+               err("service is NULL!!!");
                return;
+       }
+       context->connection_timeout = PDP_RETRY_TIME_OUT_DEFAULT;
 
-       ps_context->connection_timeout = TIMEOUT_DEFAULT;
-
-       if (ps_context->timer_src > 0) {
-               ps_warn_ex_co(_ps_service_ref_co_network(service), "remove connection retry timer (%d)", ps_context->timer_src);
-               alarmmgr_remove_alarm(ps_context->timer_src);
-               ps_context->timer_src = 0;
+       if (context->timer_src > 0) {
+               ps_warn_ex_svc(service, "remove connection retry timer (%d)", context->timer_src);
+               alarmmgr_remove_alarm(context->timer_src);
+               context->timer_src = 0;
        }
 }
 
-gboolean _ps_service_unref_context(gpointer object, gpointer context)
+gboolean _ps_service_unref_context(ps_service_t *service, ps_context_t *context)
 {
-       ps_service_t *service = object;
        ps_modem_t *modem = _ps_service_ref_modem(service);
-       ps_context_t *pscontext = context;
 
        g_return_val_if_fail(service != NULL, FALSE);
        g_return_val_if_fail(modem != NULL, FALSE);
        g_return_val_if_fail(context != NULL, FALSE);
-       g_return_val_if_fail(pscontext->path != NULL, FALSE);
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "service unref context (%s)", pscontext->path);
+       g_return_val_if_fail(context->path != NULL, FALSE);
+
+       ps_dbg_ex_modem(modem, "service unref context (%s)", context->path);
 
        _ps_service_deactivate_context(service, context);
        /* remove context from the list (modem, service) */
-       modem->contexts = g_slist_remove(modem->contexts, pscontext);
-       __ps_service_emit_context_removed_signal(service, pscontext);
+       modem->contexts = g_slist_remove(modem->contexts, context);
+       ps_service_emit_context_removed_signal(service, context);
        return TRUE;
 }
 
-void _ps_service_remove_contexts(gpointer object)
+void _ps_service_remove_contexts(ps_service_t *service)
 {
        unsigned int index;
-       ps_service_t *service = object;
        guint count;
 
        g_return_if_fail(service != NULL);
        count = g_slist_length(service->contexts);
-       ps_info_ex_co(_ps_service_ref_co_network(service), "service remove all contexts: count(%d)", count);
+       ps_info_ex_svc(service, "service remove all contexts: count(%d)", count);
 
        for (index = 0; index < count; index++) {
-               gpointer value = NULL;
-               value = g_slist_nth_data(service->contexts, index);
-               ps_dbg_ex_co(_ps_service_ref_co_network(service), "path(%s), value(%p) context", _ps_context_ref_path(value), value);
-               _ps_service_unref_context(service, value);
-               _ps_context_remove_context(value);
+               ps_context_t *context = g_slist_nth_data(service->contexts, index);
+               ps_dbg_ex_svc(service, "path(%s), context(%p)", _ps_context_ref_path(context), context);
+               _ps_service_unref_context(service, context);
+               _ps_context_remove_context(context);
        }
        g_slist_free(service->contexts);
        service->contexts = NULL;
-       return;
 }
 
-void _ps_service_disconnect_contexts(gpointer object)
+void _ps_service_disconnect_contexts(ps_service_t *service)
 {
        unsigned int index;
-       ps_service_t *service = object;
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "service disconnect all contexts");
        g_return_if_fail(service != NULL);
+       ps_info_ex_svc(service, "service disconnect all contexts");
 
        for (index = 0; index < g_slist_length(service->contexts); index++) {
-               gpointer value = g_slist_nth_data(service->contexts, index);
-               _ps_service_reset_connection_timer(value);
-               _ps_service_deactivate_context(service, value);
+               ps_context_t *context = g_slist_nth_data(service->contexts, index);
+               _ps_service_reset_connection_timer(context);
+               _ps_service_deactivate_context(service, context);
        }
-
-       return;
 }
 
-void _ps_service_disconnect_internet_mms_tethering_contexts(gpointer object)
+void _ps_service_disconnect_internet_mms_tethering_contexts(ps_service_t *service)
 {
        unsigned int index;
-       ps_service_t *service = object;
-       CoreObject *co_context = NULL;
-       enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "Service disconnect Internet/MMS/Tethering contexts");
        g_return_if_fail(service != NULL);
+       ps_info_ex_svc(service, "Service disconnect Internet/MMS/Tethering contexts");
 
        for (index = 0; index < g_slist_length(service->contexts); index++) {
-               gpointer value = g_slist_nth_data(service->contexts, index);
-               co_context = (CoreObject *)_ps_context_ref_co_context(value);
-               role = tcore_context_get_role(co_context);
+               ps_context_t *context = g_slist_nth_data(service->contexts, index);
+               CoreObject *co_context = _ps_context_ref_co_context(context);
+               enum co_context_role role = tcore_context_get_role(co_context);
 
                /*
                 * Deactivate following type of contexts -
@@ -985,238 +948,218 @@ void _ps_service_disconnect_internet_mms_tethering_contexts(gpointer object)
                case CONTEXT_ROLE_PREPAID_INTERNET:
                case CONTEXT_ROLE_PREPAID_MMS:
                case CONTEXT_ROLE_TETHERING:
-                       _ps_service_reset_connection_timer(value);
-                       _ps_service_deactivate_context(service, value);
-               break;
+                       _ps_service_reset_connection_timer(context);
+                       _ps_service_deactivate_context(service, context);
+                       break;
 
-               default: {
-                       ps_warn_ex_co(_ps_service_ref_co_network(service), "Need not deactivate for %d PDN type", role);
+               default:
+                       ps_warn_ex_svc(service, "Need not deactivate for %d PDN type", role);
                        continue;
                }
+       }
+}
+
+int _ps_service_connect_default_context(ps_service_t *service)
+{
+       int rv = 0;
+       unsigned int index;
+       gboolean ims_activation_requested = FALSE;
+       gboolean reset_profile = FALSE;
+       ps_modem_t *modem = NULL;
+
+       g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
+
+       ps_dbg_ex_svc(service, "service connect default context");
+
+       modem = _ps_service_ref_modem(service);
+       reset_profile = _ps_modem_get_reset_profile(modem);
+       if (reset_profile) {
+               ps_err_ex_svc(service, "reset_profile(%d) retun", reset_profile);
+               return 0;
+       }
+
+       ims_activation_requested = _ps_service_get_ims_activation_requested(service);
+
+       for (index = 0; index < g_slist_length(service->contexts); index++) {
+               ps_context_t *context = g_slist_nth_data(service->contexts, index);
+               gboolean f_awo = FALSE;
+
+               f_awo = _ps_context_get_alwayson_enable(context);
+               if (f_awo) {
+                       enum co_context_state context_state;
+
+                       /*  FIX: Kiran PLM P141111-07502 */
+                       /* _ps_service_reset_connection_timer(value); */
+                       rv = _ps_service_activate_context(service, context);
+                       context_state = tcore_context_get_state(_ps_context_ref_co_context(context));
+                       if (context_state == CONTEXT_STATE_ACTIVATED) {
+                               ps_info_ex_svc(service, "context is already connected");
+                               _ps_context_set_connected(context, TRUE);
+                       }
+                       ps_info_ex_svc(service, "return rv(%d)", rv);
+//                     break;
+               }
+
+               if (ims_activation_requested && (CONTEXT_ROLE_IMS == tcore_context_get_role(_ps_context_ref_co_context(context)))) {
+                       rv = _ps_service_activate_context(service, context);
+                       ps_info_ex_svc(service, "return rv(%d)", rv);
+                       ims_activation_requested = FALSE;
                }
        }
+
+       return rv;
 }
 
-#ifdef PREPAID_SIM_APN_SUPPORT
-gboolean _ps_service_connect_last_connected_context_ex(gpointer service, gpointer object,
-       gboolean *defined, char *operator)
+gboolean _ps_service_connect_last_connected_context_ex(ps_service_t *service, ps_context_t *context,
+                                                      gboolean *defined, char *operator)
 {
+       ps_modem_t *modem = NULL;
+       ps_master_t *master = NULL;
        int profile_id = -1;
        int current_profile_id = -1;
-       Storage *strg_vconf = NULL;
-       ps_context_t *context;
        gchar *last_connected_operator = NULL;
        gboolean last_connected_profile = FALSE;
        int rv;
 
-       dbg("Entry");
-       context = object;
-       strg_vconf = tcore_server_find_storage(tcore_plugin_ref_server(context->plg), "vconf");
-       if (strg_vconf) {
-               last_connected_profile =  tcore_storage_get_bool(strg_vconf,
-                                       STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL);
-               dbg("last_connected_profile [%s]", last_connected_profile ? "TRUE" : "FALSE");
-               /* Last connected profile exist */
-               if (last_connected_profile) {
-                       /* Fetch last connected profile's operator */
-                       last_connected_operator =  tcore_storage_get_string(strg_vconf,
-                               STORAGE_KEY_TELEPHONY_LAST_CONNECTED_CONTEXT_PLMN);
-                       dbg("last_connected_operator[%s] current operator[%s]", last_connected_operator, operator);
-
-                       if (g_strcmp0(last_connected_operator, operator) != 0) {
-                               /* different SIM, So reset STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL
-                                   and continue to activate default profile.
-                                 */
-                                dbg("Different SIM, reset last connected context");
-                                tcore_storage_set_bool(strg_vconf,
-                                       STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL, FALSE);
+       ps_info_ex_svc(service, "Entry");
+       modem = _ps_service_ref_modem(service);
+       master = _ps_modem_ref_master(modem);
+       last_connected_profile = _ps_master_get_storage_value_bool(master, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL);
+       ps_info_ex_svc(service, "last_connected_profile [%s]", last_connected_profile ? "TRUE" : "FALSE");
+       /* Last connected profile exist */
+       if (last_connected_profile) {
+               /* Fetch last connected profile's operator */
+               last_connected_operator = _ps_master_get_storage_value_string(master, STORAGE_KEY_TELEPHONY_LAST_CONNECTED_CONTEXT_PLMN);
+               ps_info_ex_svc(service, "last_connected_operator[%s] current operator[%s]", last_connected_operator, operator);
+
+               if (g_strcmp0(last_connected_operator, operator) != 0) {
+                       /* different SIM, So reset STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL
+                          and continue to activate default profile */
+                       ps_info_ex_svc(service, "Different SIM, reset last connected context");
+                       _ps_master_set_storage_value_bool(master, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL, FALSE);
+               } else {
+                       /* Fetch last connected context profile id */
+                       ps_info_ex_svc(service, "Fetch last connected context profile id");
+                       profile_id = _ps_master_get_storage_value_int(master, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID);
+
+                       /* Fetch current context profile id */
+                       current_profile_id = _ps_context_get_profile_id(context);
+                       ps_info_ex_svc(service, "last connected context profile id[%d], current context profile id[%d]", profile_id, current_profile_id);
+
+                       if (profile_id != current_profile_id) {
+                               ps_info_ex_svc(service, "Current context profile id and last connected profile does not match ..");
+                               /* Current context profile id and last connected profile does not match
+                                  Check for next available profile */
+                               return TRUE;
                        } else {
-                               /*Fetch last connected context profile id */
-                               dbg("Fetch last connected context profile id");
-                               profile_id = tcore_storage_get_int(strg_vconf,
-                                               STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID);
-
-                               /* Fetch current context profile id */
-                               current_profile_id = _ps_context_get_profile_id(context);
-                               dbg("last connected context profile id[%d], current context profile id[%d]",
-                                       profile_id, current_profile_id);
-
-                               if (profile_id  != current_profile_id) {
-                                       dbg("Current context profile id and last connected profile does not match ..");
-                                       /* Current context profile id and last connected profile does not match
-                                            Check for next available profile.
-                                          */
-                                       return TRUE;
-                               } else {
-                                       /* activate last connected context */
-                                       dbg("activate last connected context");
-                                       rv =  _ps_service_define_context(service, context);
-                                       dbg("return rv(%d)", rv);
-                                       if (defined)
-                                               *defined = TRUE;
-                                       return TRUE;
-                               }
+                               /* activate last connected context */
+                               ps_info_ex_svc(service, "activate last connected context");
+                               rv = _ps_service_define_context(service, context);
+                               ps_info_ex_svc(service, "return rv(%d)", rv);
+                               if (defined)
+                                       *defined = TRUE;
+                               return TRUE;
                        }
-
-               } else  {
-                       dbg("There is no last connected profile");
                }
        } else {
-               dbg("invalid storage handle");
+               ps_info_ex_svc(service, "There is no last connected profile");
        }
 
        return FALSE;
 }
 
-gboolean _ps_service_connect_last_connected_context(gpointer object)
+gboolean _ps_service_connect_last_connected_context(ps_service_t *service)
 {
        gboolean ret;
        gboolean defined = FALSE;
-       ps_service_t *service = object;
        gchar *operator = NULL;
        unsigned int index;
 
-       dbg("Entry");
-
        g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
        operator = _ps_modem_ref_operator(_ps_service_ref_modem(service));
 
        for (index = 0; index < g_slist_length(service->contexts); index++) {
-               gpointer ps_context = g_slist_nth_data(service->contexts, index);
+               ps_context_t *ps_context = g_slist_nth_data(service->contexts, index);
                ret = _ps_service_connect_last_connected_context_ex(service, ps_context, &defined, operator);
-               dbg("ret[%d]", ret);
+               ps_info_ex_svc(service, "ret[%d]", ret);
                if (defined == TRUE) {
-                       dbg("context[%p]", ps_context);
+                       ps_info_ex_svc(service, "context[%p]", ps_context);
                        return defined;
                }
        }
        return FALSE;
 }
-#endif
 
-int _ps_service_connect_default_context(gpointer object)
+int _ps_service_connect_default_prepaid_context(ps_service_t *service)
 {
        int rv = 0;
        unsigned int index;
-       ps_service_t *service = object;
-       gboolean ims_activation_requested = FALSE;
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "service connect default context");
        g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
 
-       ims_activation_requested = _ps_service_get_ims_activation_requested(service);
-
        for (index = 0; index < g_slist_length(service->contexts); index++) {
-               gpointer value = g_slist_nth_data(service->contexts, index);
+               ps_context_t *context = g_slist_nth_data(service->contexts, index);
                gboolean f_awo = FALSE;
-
-               f_awo = _ps_context_get_alwayson_enable(value);
+               f_awo = _ps_context_get_prepaid_alwayson_enable(context);
                if (f_awo) {
-                       enum co_context_state context_state;
-                       CoreObject *co_network = _ps_service_ref_co_network(service);
-
-                       /*  FIX: Kiran PLM P141111-07502 */
-                       /* _ps_service_reset_connection_timer(value); */
-                       rv = _ps_service_activate_context(service, value);
-                       context_state = tcore_context_get_state(((ps_context_t *)value)->co_context);
-                       if (context_state == CONTEXT_STATE_ACTIVATED) {
-                               ps_info_ex_co(co_network, "context is already connected");
-                               _ps_context_set_connected(value, TRUE);
-                       }
-                       ps_info_ex_co(co_network, "return rv(%d)", rv);
-//                     break;
-               }
-
-               if (ims_activation_requested && (CONTEXT_ROLE_IMS == tcore_context_get_role(_ps_context_ref_co_context(value)))) {
-                       rv = _ps_service_activate_context(service, value);
-                       ps_info_ex_co(_ps_service_ref_co_network(service), "return rv(%d)", rv);
-                       ims_activation_requested = FALSE;
-               }
-       }
-
-       return rv;
-}
-
-#ifdef PREPAID_SIM_APN_SUPPORT
-int _ps_service_connect_default_prepaid_context(gpointer object)
-{
-       int rv = 0;
-       ps_service_t *service = object;
-       unsigned int index;
-       dbg("Entry");
-
-       g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
-
-       for (index = 0; index < g_slist_length(service->contexts); index++) {
-               gpointer ps_context = g_slist_nth_data(service->contexts, index);
-               gboolean f_awo = FALSE;
-               f_awo = _ps_context_get_prepaid_alwayson_enable(ps_context);
-               if (f_awo) {
-                       _ps_service_reset_connection_timer(ps_context);
-                       rv = _ps_service_activate_context(service, ps_context);
-                       dbg("return rv(%d)", rv);
+                       _ps_service_reset_connection_timer(context);
+                       rv = _ps_service_activate_context(service, context);
+                       ps_info_ex_svc(service, "return rv(%d)", rv);
                        break;
                }
        }
-       dbg("Exit - rv[%d]", rv);
+       ps_info_ex_svc(service, "Exit - rv[%d]", rv);
        return rv;
 }
 
-gpointer _ps_service_return_context_by_cid(gpointer object, int context_id)
+ps_context_t *_ps_service_return_context_by_cid(ps_service_t *service, int context_id)
 {
-       ps_service_t *service = object;
        unsigned int index;
 
        g_return_val_if_fail(service != NULL, NULL);
 
        for (index = 0; index < g_slist_length(service->contexts); index++) {
-               gpointer ps_context = g_slist_nth_data(service->contexts, index);
-               int tmp_cid;
-               CoreObject *co_context = NULL;
-
-               co_context = _ps_context_ref_co_context(ps_context);
-               tmp_cid = tcore_context_get_id(co_context);
+               ps_context_t *context = g_slist_nth_data(service->contexts, index);
+               CoreObject *co_context = _ps_context_ref_co_context(context);
+               int tmp_cid = tcore_context_get_id(co_context);
 
                if (tmp_cid != context_id)
                        continue;
 
-               return ps_context;
+               return context;
        }
        return NULL;
 }
-#endif
 
-gpointer _ps_service_return_default_context(gpointer object, int svc_cat_id)
+ps_context_t *_ps_service_return_default_context(ps_service_t *service, int svc_cat_id)
 {
        unsigned int index;
-       ps_service_t *service = object;
 
        g_return_val_if_fail(service != NULL, NULL);
 
        for (index = 0; index < g_slist_length(service->contexts); index++) {
-               gpointer value = g_slist_nth_data(service->contexts, index);
+               ps_context_t *context = g_slist_nth_data(service->contexts, index);
                gboolean b_default = FALSE;
-               b_default = _ps_context_get_default_context(value, svc_cat_id);
+               b_default = _ps_context_get_default_context(context, svc_cat_id);
 
                if (b_default)
-                       return value;
+                       return context;
        }
 
        return NULL;
 }
 
-int _ps_service_update_roaming_apn(gpointer object)
+int _ps_service_update_roaming_apn(ps_service_t *service)
 {
        int rv = 0;
-       ps_service_t *service = object;
-       ps_modem_t *modem = _ps_service_ref_modem(object);
+       ps_modem_t *modem = _ps_service_ref_modem(service);
        gboolean p_from = FALSE; /* default <FLASE> : Home newtwork */
        GSList *contexts = NULL;
 
        g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
        g_return_val_if_fail(modem != NULL, TCORE_RETURN_FAILURE);
 
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "roaming status: %d", service->roaming);
+       ps_dbg_ex_svc(service, "roaming status: %d", service->roaming);
        /* 1) Remove all contexts
         * 2) Load Home/Roaming profiles from database.
 
@@ -1227,11 +1170,11 @@ int _ps_service_update_roaming_apn(gpointer object)
 
        p_from = _ps_modem_get_roaming_apn_support(modem);
        if (p_from) {
-               _ps_service_remove_contexts(object);
+               _ps_service_remove_contexts(service);
                contexts = _ps_context_create_hashtable((gpointer)modem, service->roaming);
                if (contexts != NULL) {
-                       rv = _ps_service_set_number_of_pdn_cnt(object, modem->operator);
-                       rv = _ps_service_ref_contexts(object, contexts, modem->operator);
+                       rv = _ps_service_set_number_of_pdn_cnt(service, modem->operator);
+                       rv = _ps_service_ref_contexts(service, contexts, modem->operator);
                }
        } else {
                /* Iterate through each context and check home and roaming pdp protocol type.
@@ -1240,166 +1183,135 @@ int _ps_service_update_roaming_apn(gpointer object)
                  */
                enum co_context_type home_pdp_protocol, roam_pdp_protocol;
                guint index;
-               ps_context_t *pscontext;
 
                for (index = 0; index < g_slist_length(service->contexts); index++) {
-                       pscontext = g_slist_nth_data(service->contexts, index);
-                       home_pdp_protocol = tcore_context_get_type(pscontext->co_context);
-                       roam_pdp_protocol = tcore_context_get_roam_pdp_type(pscontext->co_context);
+                       ps_context_t *context = g_slist_nth_data(service->contexts, index);
+                       home_pdp_protocol = tcore_context_get_type(_ps_context_ref_co_context(context));
+                       roam_pdp_protocol = tcore_context_get_roam_pdp_type(_ps_context_ref_co_context(context));
                        if (home_pdp_protocol == roam_pdp_protocol) {
-                               ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "home and roam pdp protocol type matched. No need to de-activate");
+                               ps_dbg_ex_svc(service, "home and roam pdp protocol type matched. No need to de-activate");
                                continue;
                        }
 
                        /* De-activate context as home and roam pdp protocol type mismatched */
-                       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "home[%d] and roam[%d] pdp protocol type mis-matched. De-activate if context is already activated",
-                               home_pdp_protocol, roam_pdp_protocol);
-                       _ps_service_reset_connection_timer(pscontext);
-                       _ps_service_deactivate_context(service, pscontext);
+                       ps_info_ex_modem(modem, "home[%d] and roam[%d] pdp protocol type mis-matched. De-activate if context is already activated",
+                                        home_pdp_protocol, roam_pdp_protocol);
+                       _ps_service_reset_connection_timer(context);
+                       _ps_service_deactivate_context(service, context);
                }
        }
        dbg("rv: %d", rv);
        return rv;
 }
 
-gboolean _ps_service_processing_network_event(gpointer object, gboolean ps_attached, gboolean roaming)
+gboolean _ps_service_processing_network_event(ps_service_t *service, gboolean ps_attached, gboolean roaming)
 {
 #ifdef PREPAID_SIM_APN_SUPPORT
        gboolean ret = TRUE;
 #endif
-       ps_service_t *service = object;
-       CoreObject *co_network = NULL;
        gboolean prev_roaming_status;
        g_return_val_if_fail(service != NULL, FALSE);
 
-       co_network = _ps_service_ref_co_network(service);
        prev_roaming_status = _ps_service_get_roaming(service);
-       if(__ps_service_check_is_network_in_serivce(service) != TRUE)
-               ps_warn_ex_co(co_network, "Update roaming status only in IN SRV");
+       if (__ps_service_check_is_network_in_serivce(service) != TRUE &&
+           !_ps_modem_get_roaming_apn_support(_ps_service_ref_modem(service)))
+               ps_warn_ex_svc(service, "Update roaming status only in IN SRV");
        else
                _ps_service_set_roaming(service, roaming);
+
        _ps_service_set_ps_attached(service, ps_attached);
        _ps_update_cellular_state_key(service);
 
        if (prev_roaming_status != _ps_service_get_roaming(service)) {
                gboolean roaming_allowed = FALSE;
-               roaming_allowed = _ps_modem_get_data_roaming_allowed(service->p_modem);
-               _ps_service_update_roaming_apn(object);
+               roaming_allowed = _ps_modem_get_data_roaming_allowed(_ps_service_ref_modem(service));
+               _ps_service_update_roaming_apn(service);
 
                if (!roaming_allowed && roaming) {
-                       ps_info_ex_co(co_network, "Roaming allowed (%d), Roaming status (%d)", roaming_allowed, roaming);
+                       ps_info_ex_svc(service, "Roaming allowed (%d), Roaming status (%d)", roaming_allowed, roaming);
                        _ps_service_disconnect_contexts(service);
                        return TRUE;
                }
        }
 
        if (service->ps_attached) {
+               ps_context_t *def_context = NULL;
 #ifdef PREPAID_SIM_APN_SUPPORT
                ret = _ps_service_connect_last_connected_context(service);
-               dbg("ret[%d]", ret);
+               ps_dbg_ex_svc(service, "ret[%d]", ret);
                if (ret == TRUE)
-                       return ret; /* No need to activate default context */
-#else
-               gpointer defined_context = NULL;
-               unsigned int index;
-
-               for (index = 0; index < g_slist_length(service->contexts); index++) {
-                       gpointer value = g_slist_nth_data(service->contexts, index);
-                       CoreObject *co_context = NULL;
-                       gboolean b_define = FALSE;
-                       int context_state = 0; int cid = 0;
-
-                       b_define = _ps_context_get_ps_defined(value);
-                       co_context = (CoreObject *)_ps_context_ref_co_context(value);
-                       context_state = tcore_context_get_state(co_context);
-                       cid = tcore_context_get_id(co_context);
-
-                       ps_dbg_ex_co(co_network, "context(%p) defined(%d) cid(%d) activated(%d)", value, b_define, cid, context_state);
-                       if (b_define && cid == 1 && context_state == CONTEXT_STATE_DEACTIVATED) {
-                               ps_dbg_ex_co(co_network, "defined context(%p) is found", value);
-                               defined_context = value;
-                               break;
-                       }
-               }
-
-               if (defined_context) {
-                       int rv = 0;
-                       rv = _ps_service_activate_context(service, defined_context);
-                       ps_dbg_ex_co(co_network, "activation result (%d)", rv);
-               } else {
-                       _ps_service_connect_default_context(service);
-               }
-
-               return TRUE;
+                       return TRUE; /* No need to activate default context */
 #endif
-       }
-
-       if (service->ps_attached)
+               def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
+               if (def_context)
+                       _ps_context_set_alwayson_enable(def_context, TRUE);
                _ps_service_connect_default_context(service);
+       }
 
        return TRUE;
 }
 
-gboolean _ps_service_set_connected(gpointer object, gpointer cstatus, gboolean enabled)
+gboolean _ps_service_set_connected(ps_service_t *service, gpointer cstatus, gboolean enabled)
 {
        unsigned int index;
-       gboolean def_awo = FALSE, def_ims_activation = FALSE, b_def_conn = FALSE;
+       gboolean def_awo = FALSE, b_def_conn = FALSE;
        gpointer def_conn = NULL;
        gpointer requested_conn = NULL;
+#ifdef TIZEN_SUPPORT_VOLTE
+       gboolean def_ims_activation = FALSE;
+       ps_modem_t *modem = _ps_service_ref_modem(service);
+#endif
+       ps_master_t *master = _ps_modem_ref_master(_ps_service_ref_modem(service));
 
-       ps_service_t *service = (ps_service_t *) object;
-       ps_master_t *master = _ps_modem_ref_master(_ps_service_ref_modem(object));
        struct tnoti_ps_call_status *call_status = NULL;
-       CoreObject *co_network;
 
-       co_network = _ps_service_ref_co_network(service);
        call_status = (struct tnoti_ps_call_status *)cstatus;
 
        if (enabled && master && master->initial_pdp_conn == FALSE) {
-               ps_info_ex_co(co_network, "Initial PDP connection.");
+               ps_info_ex_svc(service, "Initial PDP connection.");
                master->initial_pdp_conn = TRUE;
        }
 
        for (index = 0; index < g_slist_length(service->contexts); index++) {
-               gpointer value = g_slist_nth_data(service->contexts, index);
+               ps_context_t *context = g_slist_nth_data(service->contexts, index);
+               CoreObject *co_context = _ps_context_ref_co_context(context);
                int tmp_cid;
                gboolean b_tmp_def = FALSE;
-               CoreObject *context = NULL;
                gpointer b_user_data = NULL;
 
-               context = _ps_context_ref_co_context(value);
-               tmp_cid = tcore_context_get_id(context);
-
-               if (tmp_cid != call_status->context_id) continue;
+               tmp_cid = tcore_context_get_id(co_context);
+               if (tmp_cid != call_status->context_id)
+                       continue;
 
                /* if there is default context in disconnected cid, it has to retry auto connection */
-               b_tmp_def = _ps_context_get_default_context(value, CONTEXT_ROLE_INTERNET);
+               b_tmp_def = _ps_context_get_default_context(context, CONTEXT_ROLE_INTERNET);
                if (!b_def_conn)
                        b_def_conn = b_tmp_def;
 
                /* if disconnected connection has the user data, it is a priority connection. */
-               b_user_data = _ps_context_get_user_data(value);
+               b_user_data = _ps_context_get_user_data(context);
                if (b_user_data) {
-                       def_conn = value;
+                       def_conn = context;
                        requested_conn = b_user_data;
                }
 
                if (!enabled) {
                        gchar *ipv4 = NULL;
-
-                       ps_info_ex_co(co_network, "Reset socket connections.");
-
-                       tcore_ps_clear_context_id(service->co_ps, context);
-                       ipv4 = tcore_context_get_ipv4_addr(context);
-                       tcore_util_reset_ipv4_socket(tcore_context_get_ipv4_devname(context), (const char *)ipv4);
+                       gchar *devname = NULL;
+                       ps_info_ex_svc(service, "Reset socket connections.");
+                       tcore_ps_clear_context_id(_ps_service_ref_co_ps(service), co_context);
+                       ipv4 = tcore_context_get_ipv4_addr(co_context);
+                       devname = tcore_context_get_ipv4_devname(co_context);
+                       tcore_util_reset_ipv4_socket((const char *)devname, (const char *)ipv4);
+                       free(ipv4);
+                       g_free(devname);
                }
-
-               _ps_context_set_connected(value, enabled);
+               _ps_context_set_connected(context, enabled);
        }
 
        /* connect to request profile */
        if (!enabled && requested_conn) {
-               ps_info_ex_co(co_network, "connect to request profile (%p)", requested_conn);
+               ps_info_ex_svc(service, "connect to request profile (%p)", requested_conn);
                _ps_connection_hdlr(requested_conn);
                _ps_service_reset_connection_timer(def_conn);
                _ps_context_reset_user_data(def_conn);
@@ -1411,7 +1323,7 @@ gboolean _ps_service_set_connected(gpointer object, gpointer cstatus, gboolean e
                gint ps_mode = 0;
                def_conn = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
                def_awo = _ps_context_get_alwayson_enable(def_conn);
-#if 1
+
                if (def_awo) {
                        /*
                         * In case of ME in LCD off & UPS mode.
@@ -1419,10 +1331,9 @@ gboolean _ps_service_set_connected(gpointer object, gpointer cstatus, gboolean e
                         */
                        ps_mode = _ps_modem_get_psmode(_ps_service_ref_modem(service));
                        if (ps_mode > POWER_SAVING_MODE_NORMAL && ps_mode < POWER_SAVING_MODE_WEARABLE) {
-                               Storage *strg_vconf = tcore_server_find_storage(_ps_service_ref_plugin(service), "vconf");
-                               gint pm_state = tcore_storage_get_int(strg_vconf, STORAGE_KEY_PM_STATE);
+                               gint pm_state = _ps_master_get_storage_value_int(master, STORAGE_KEY_PM_STATE);
                                if (pm_state == 3) {
-                                       ps_warn_ex_co(co_network, "PDP retry timer is not allowed in LCD off & UPS mode.");
+                                       ps_warn_ex_svc(service, "PDP retry timer is not allowed in LCD off & UPS mode.");
                                        return TRUE;
                                }
                        }
@@ -1434,77 +1345,42 @@ gboolean _ps_service_set_connected(gpointer object, gpointer cstatus, gboolean e
                                _ps_service_connection_timer(service, def_conn);
                        } else {
 
-                               /* disconnect from user intention */
-#if defined(CONNECT_DEFAULT_CONNECTION_WITHOUT_TIMER)
-                               if (call_status->result == 2000) {
-                                       ps_dbg_ex_co(co_network, "user intended disconnect / connect default connection without timer");
-                                       __ps_service_connetion_timeout_handler(((ps_context_t *)def_conn)->timer_src, (ps_context_t *)def_conn);
-                                       return TRUE;
-                               }
-#endif
                                /* with unexpected disconnection from network/me */
-                               _ps_service_set_retry_timeout_value(def_conn, TIMEOUT_DEFAULT);
+                               _ps_service_set_retry_timeout_value(def_conn, PDP_RETRY_TIME_OUT_DEFAULT);
                                _ps_service_connection_timer(service, def_conn);
                        }
                }
 
-               def_ims_activation = _ps_service_get_ims_activation_requested(service);
-               if (def_ims_activation) {
-                       gpointer def_ims = NULL;
+#ifdef TIZEN_SUPPORT_VOLTE
+               if (tfeature_is_supported(TFEATURE_FUNCTION_IMS_PDN_AUTO_ACTIVATE))
+                       def_ims_activation = _ps_service_get_ims_activation_requested(service);
 
-                       def_ims =  _ps_service_return_default_context(service, CONTEXT_ROLE_IMS);
-                       ps_info_ex_co(co_network, "Continue re-try for IMS PDN");
-
-                       /* retry connection */
-                       _ps_service_connection_timer(service, def_ims);
-               }
-#else
-               if (!def_awo) {
-                       ps_info_ex_co(co_network, "there is no always on connection");
-                       return TRUE;
-               }
+               if (def_ims_activation) {
+                       ps_context_t *def_ims = NULL;
+                       CoreObject *co_network = NULL;
+                       gboolean reset_profile = FALSE;
+                       enum telephony_network_service_type svc_type;
 
-               /* In case of ME in LCD off & UPS mode.
-                * Do not enable PDP retry timer for default internet context.
-                */
-               ps_mode = _ps_modem_get_psmode(_ps_service_ref_modem(service));
-               if (ps_mode > POWER_SAVING_MODE_NORMAL && ps_mode < POWER_SAVING_MODE_WEARABLE) {
-                       Storage *strg_vconf = tcore_server_find_storage(_ps_service_ref_plugin(service), "vconf");
-                       gint pm_state = tcore_storage_get_int(strg_vconf, STORAGE_KEY_PM_STATE);
-                       if (pm_state == 3) {
-                               ps_warn_ex_co(co_network, "PDP retry timer is not allowed in LCD off & UPS mode.");
-                               return TRUE;
-                       }
-               }
+                       co_network = _ps_service_ref_co_network(service);
+                       tcore_network_get_service_type(co_network, &svc_type);
+                       def_ims = _ps_service_return_default_context(service, CONTEXT_ROLE_IMS);
+                       reset_profile = _ps_modem_get_reset_profile(modem);
 
-               /* always on TRUE and default connection - NORMAL RETRY */
-               /* always on TRUE and no default connection - WAIT 5 Secs for retry from application */
-               if (b_def_conn) {
-                       /* retry connection */
-                       _ps_service_connection_timer(service, def_conn);
-               } else if (b_def_ims) {
-                       /* retry connection */
-                       _ps_service_connection_timer(service, def_ims);
-               } else {
+                       ps_dbg_ex_svc(service, "svc_type[%d], reset_profile(%d)", svc_type, reset_profile);
 
-                       /* disconnect from user intention */
-#if defined(CONNECT_DEFAULT_CONNECTION_WITHOUT_TIMER)
-                       if (call_status->result == 2000) {
-                               ps_dbg_ex_co(co_network, "user intended disconnect / connect default connection without timer");
-                               __ps_service_connetion_timeout_handler(def_conn->timer_src, def_conn);
-                               return TRUE;
+                       if (def_ims && svc_type == NETWORK_SERVICE_TYPE_LTE && !reset_profile) {
+                               ps_info_ex_svc(service, "Continue re-try for IMS PDN");
+                               _ps_service_connection_timer(service, def_ims);
+                       } else {
+                               ps_warn_ex_svc(service, "IMS PDN retry timer is allowed in LTE mode.");
                        }
-#endif
-                       /* with unexpected disconnection from network/me */
-                       _ps_service_set_retry_timeout_value(def_conn, TIMEOUT_DEFAULT);
-                       _ps_service_connection_timer(service, def_conn);
                }
 #endif
        }
 
        /* To send deactivation request of default profile */
        if (enabled && requested_conn) {
-               ps_info_ex_co(co_network, "Send deactivation to default profile and connect to request profile (%p)", requested_conn);
+               ps_info_ex_svc(service, "Send deactivation to default profile and connect to request profile (%p)", requested_conn);
                return FALSE;
        }
 
@@ -1514,166 +1390,181 @@ gboolean _ps_service_set_connected(gpointer object, gpointer cstatus, gboolean e
 void _ps_service_set_ps_defined(ps_service_t *service, gboolean value, int cid)
 {
        unsigned int index;
-       CoreObject *co_network;
 
        g_return_if_fail(service != NULL);
 
-       co_network = _ps_service_ref_co_network(service);
        for (index = 0; index < g_slist_length(service->contexts); index++) {
-               gpointer ps_context = g_slist_nth_data(service->contexts, index);
-               CoreObject *co_context = _ps_context_ref_co_context(ps_context);
+               ps_context_t *context = g_slist_nth_data(service->contexts, index);
+               CoreObject *co_context = _ps_context_ref_co_context(context);
+               CoreObject *co_ps = _ps_service_ref_co_ps(service);
                unsigned char context_id = tcore_context_get_id(co_context);
+               int role = tcore_context_get_role(co_context);
                if (context_id == cid) {
-                       //gboolean attach_apn = tcore_context_get_attach_apn(co_context);
                        gboolean proceed_activation = TRUE;
 
                        /* Check attach apn complete */
-                       if (value /*&& attach_apn*/ && !service->attach_apn_complete) {
-                               int role = tcore_context_get_role(co_context);
-                               ps_info_ex_co(co_network, "Initial define of attach APN is complete for profile role(%d)", role);
+                       if (value && (!service->attach_apn_complete && role != CONTEXT_ROLE_IMS_EMERGENCY)) {
+                               ps_info_ex_svc(service, "Initial define of attach APN is complete for profile role(%d)", role);
                                service->attach_apn_complete = TRUE;
 
-                               if(TRUE == _ps_context_get_default_context(ps_context, CONTEXT_ROLE_INTERNET) && service->ps_attached)
+                               if (TRUE == _ps_context_get_default_context(context, CONTEXT_ROLE_INTERNET) && service->ps_attached)
                                        proceed_activation = TRUE;
                                else {
                                        proceed_activation = FALSE;
-                                       tcore_ps_clear_context_id(service->co_ps, co_context);
+                                       tcore_ps_clear_context_id(co_ps, co_context);
                                }
                        }
                        proceed_activation &= value;
 
                        /* Set 'ps_defined' */
-                       _ps_context_set_ps_defined(ps_context, proceed_activation);
+                       _ps_context_set_ps_defined(context, proceed_activation);
 
                        if (proceed_activation) {
                                /* Activate if define is completed */
-                               ps_dbg_ex_co(co_network, "define is complete, activate context for cid(%d)", cid);
-                               if (_ps_service_activate_context(service, ps_context) == TCORE_RETURN_SUCCESS) {
-                                       ps_dbg_ex_co(co_network, "Successful activate context");
-                                       tcore_ps_set_cid_active(service->co_ps, cid, TRUE);
+                               ps_dbg_ex_svc(service, "define is complete, activate context for cid(%d)", cid);
+                               if (_ps_service_activate_context(service, context) == TCORE_RETURN_SUCCESS) {
+                                       ps_dbg_ex_svc(service, "Successful activate context");
+                                       tcore_ps_set_cid_active(co_ps, cid, TRUE);
                                }
                        }
                        break;
                }
        }
 
-       return;
 }
 
-gboolean _ps_service_set_ps_attached(gpointer object, gboolean value)
+gboolean _ps_service_set_ps_attached(ps_service_t *service, gboolean value)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
 
        if (service->ps_attached != value) {
                service->ps_attached = value;
-               ps_info_ex_co(_ps_service_ref_co_network(service), "service(%p) ps_attached(%d)", service, service->ps_attached);
-               __ps_service_emit_property_changed_signal(service);
+               ps_info_ex_svc(service, "service(%p) ps_attached(%d)", service, service->ps_attached);
+               ps_service_emit_property_changed_signal(service);
        }
        return TRUE;
 }
 
-gboolean _ps_service_get_restricted(gpointer object)
+gboolean _ps_service_get_restricted(ps_service_t *service)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
-
        return service->restricted;
 }
 
-gboolean _ps_service_set_restricted(gpointer object, gboolean value)
+gboolean _ps_service_set_restricted(ps_service_t *service, gboolean value)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
 
        if (service->restricted != value) {
                service->restricted = value;
-               ps_info_ex_co(_ps_service_ref_co_network(service), "service(%p) restricted(%d)", service, service->restricted);
+               ps_info_ex_svc(service, "service(%p) restricted(%d)", service, service->restricted);
                _ps_update_cellular_state_key(service);
        }
        return TRUE;
 }
 
-gboolean _ps_service_set_ims_activation_requested(gpointer object, gboolean enabled)
+gboolean _ps_service_set_ims_activation_requested(ps_service_t *service, gboolean enabled)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
-
        service->ims_activation_requested = enabled;
-
-       ps_info_ex_co(_ps_service_ref_co_network(service), "service (%p) ims_activation_requested (%d)", service, service->ims_activation_requested);
+       ps_info_ex_svc(service, "service (%p) ims_activation_requested (%d)", service, service->ims_activation_requested);
        return TRUE;
 }
 
-gboolean _ps_service_get_ims_activation_requested(gpointer object)
+gboolean _ps_service_get_ims_activation_requested(ps_service_t *service)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
+       ps_info_ex_svc(service, "service (%p) ims_activation_requested (%d)", service, service->ims_activation_requested);
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "service (%p) ims_activation_requested (%d)", service, service->ims_activation_requested);
        if (_ps_service_get_epdg_status(service) == TRUE)
                return FALSE;
 
        return service->ims_activation_requested;
 }
 
-gboolean _ps_service_set_epdg_status(gpointer object, gboolean available)
+gboolean _ps_service_set_epdg_ip_configuration(ps_service_t *service, gint cid, char *ipv4_addr, char *ipv6_addr)
 {
-       ps_service_t *service = object;
+       GSList *contexts = NULL;
+       CoreObject *co_context = NULL;
+       guint pdp_address;
+       unsigned char ip_address[IPV4_ADDR_LEN];
+
        g_return_val_if_fail(service != NULL, FALSE);
 
-       service->is_epdg_available = available;
+       ps_info_ex_svc(service, "service (%p) ipv4_addr (%s) ipv6_addr (%s)", service, ipv4_addr, ipv6_addr);
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "service (%p) available (%d) ", service, service->is_epdg_available);
+       contexts = tcore_ps_ref_context_by_id(service->co_ps, cid);
+       while (contexts) {
+               co_context = contexts->data;
+               if (!co_context) {
+                       contexts = contexts->next;
+                       continue;
+               }
+               if (tcore_context_get_role(co_context) == CONTEXT_ROLE_IMS) {
+                       if (ipv4_addr) {
+                               char addr_buf[40];
+                               pdp_address = __ps_service_convert_ipv4_address_int(ipv4_addr);
+                               pdp_address = htonl(pdp_address);
+                               memcpy(&ip_address, &pdp_address, IPV4_ADDR_LEN);
+                               tcore_context_set_ipv4_addr(co_context, ip_address);
+                               snprintf(addr_buf, 20, "%d.%d.%d.%d", ip_address[0], ip_address[1], ip_address[2], ip_address[3]);
+                               ps_info_ex_svc(service, "[IPv4] IP Address: [%s]", addr_buf);
+                       }
+                       tcore_context_set_ipv6_addr(co_context, ipv6_addr);
+                       break;
+               }
+               contexts = contexts->next;
+       }
 
        return TRUE;
 }
 
-gboolean _ps_service_get_epdg_status(gpointer object)
+gboolean _ps_service_set_epdg_status(ps_service_t *service, gboolean available)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
+       service->is_epdg_available = available;
+       ps_info_ex_svc(service, "service (%p) available (%d) ", service, service->is_epdg_available);
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "service (%p) available (%d) ", service, service->is_epdg_available);
+       return TRUE;
+}
 
+gboolean _ps_service_get_epdg_status(ps_service_t *service)
+{
+       g_return_val_if_fail(service != NULL, FALSE);
        return service->is_epdg_available;
 }
 
-gboolean _ps_service_set_number_of_pdn_cnt(gpointer object, gchar *operator)
+gboolean _ps_service_set_number_of_pdn_cnt(ps_service_t *service, gchar *operator)
 {
        int rv = 0;
        int num_of_pdn = 0;
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Entered");
-       num_of_pdn = _ps_context_get_number_of_pdn(operator, _ps_modem_ref_cp_name(_ps_service_ref_modem(object)));
-       rv = tcore_ps_set_num_of_pdn(service->co_ps, num_of_pdn);
+       ps_dbg_ex_svc(service, "Entered");
+       num_of_pdn = _ps_context_get_number_of_pdn(operator, service);
+       rv = tcore_ps_set_num_of_pdn(_ps_service_ref_co_ps(service), num_of_pdn);
 
        if (rv != TCORE_RETURN_SUCCESS)
-               ps_err_ex_co(_ps_service_ref_co_network(service), "error to get maximum number of pdn");
+               ps_err_ex_svc(service, "error to get maximum number of pdn");
 
        dbg("Exiting");
        return TRUE;
 }
 
-gboolean _ps_service_get_roaming(gpointer object)
+gboolean _ps_service_get_roaming(ps_service_t *service)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
-
        return service->roaming;
 }
 
-gboolean _ps_service_set_roaming(gpointer object, gboolean value)
+gboolean _ps_service_set_roaming(ps_service_t *service, gboolean value)
 {
-       ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
 
        if (service->roaming != value) {
                service->roaming = value;
-               ps_info_ex_co(_ps_service_ref_co_network(service), "service(%p) roaming(%d)", service, service->roaming);
-               __ps_service_emit_property_changed_signal(service);
+               ps_info_ex_svc(service, "service(%p) roaming(%d)", service, service->roaming);
+               ps_service_emit_property_changed_signal(service);
        }
 
        return TRUE;
@@ -1713,39 +1604,36 @@ static void _indicator_cb_dns_reply(GObject *src, GAsyncResult *res, gpointer us
        return;
 }
 
-gboolean _ps_service_set_access_technology(gpointer object,
-               enum telephony_network_access_technology value)
+gboolean _ps_service_set_access_technology(ps_service_t *service,
+                                          enum telephony_network_access_technology value)
 {
 #ifdef PREPAID_SIM_APN_SUPPORT
        gboolean ret = TRUE;
 #endif
-       ps_service_t *service = object;
-       CoreObject *co_network = NULL;
        enum telephony_network_access_technology p_act = 0;
        g_return_val_if_fail(service != NULL, FALSE);
 
        if (service->act != value) {
                p_act = service->act;
                service->act = value;
-               co_network = _ps_service_ref_co_network(service);
-               ps_info_ex_co(co_network, "service(%p) P ACT(%d) Access Technology(%d)", service, p_act, service->act);
+               ps_info_ex_svc(service, "service(%p) P ACT(%d) Access Technology(%d)", service, p_act, service->act);
 
                if (p_act == NETWORK_ACT_LTE && (service->act >= NETWORK_ACT_GSM && service->act < NETWORK_ACT_LTE)) {
                        GResolver *r = NULL;
 
-                       ps_dbg_ex_co(co_network, "send the dns pkt for keeping connection");
+                       ps_dbg_ex_svc(service, "send the dns pkt for keeping connection");
 
                        r = g_resolver_get_default();
-                       g_resolver_lookup_by_name_async(r, "www.google.com", NULL, _indicator_cb_dns_reply, NULL);
+                       g_resolver_lookup_by_name_async(r, "www.tizen.org", NULL, _indicator_cb_dns_reply, NULL);
                }
 
                if (service->act > NETWORK_ACT_UNKNOWN && service->act < NETWORK_ACT_NOT_SPECIFIED) {
                        _ps_update_cellular_state_key(service);
 #ifdef PREPAID_SIM_APN_SUPPORT
                        ret = _ps_service_connect_last_connected_context(service);
-                       dbg("ret[%d]", ret);
+                       ps_info_ex_svc(service, "ret[%d]", ret);
                        if (ret == TRUE)
-                               return ret; /* No need to activate default context */
+                               return ret;  /* No need to activate default context */
 #endif
                        _ps_service_connect_default_context(service);
                }
@@ -1754,21 +1642,24 @@ gboolean _ps_service_set_access_technology(gpointer object,
        return TRUE;
 }
 
-enum telephony_ps_state _ps_service_check_cellular_state(gpointer object)
+enum telephony_ps_state _ps_service_check_cellular_state(ps_service_t *service)
 {
        gboolean state = FALSE;
-       ps_service_t *service = object;
+       ps_modem_t *modem;
+
        g_return_val_if_fail(service != NULL, TELEPHONY_PS_NO_SERVICE);
 
-       state = _ps_modem_get_flght_mode(service->p_modem);
+       modem = _ps_service_ref_modem(service);
+
+       state = _ps_modem_get_flght_mode(modem);
        if (state)
                return TELEPHONY_PS_FLIGHT_MODE;
 
-       state = _ps_modem_get_power(service->p_modem);
+       state = _ps_modem_get_power(modem);
        if (!state)
                return TELEPHONY_PS_NO_SERVICE;
 
-       state = _ps_modem_get_sim_init(service->p_modem);
+       state = _ps_modem_get_sim_init(modem);
        if (!state)
                return TELEPHONY_PS_NO_SERVICE;
 
@@ -1778,87 +1669,64 @@ enum telephony_ps_state _ps_service_check_cellular_state(gpointer object)
        if (!service->ps_attached)
                return TELEPHONY_PS_NO_SERVICE;
 
-       state = _ps_modem_get_data_allowed(service->p_modem);
+       state = _ps_modem_get_data_allowed(modem);
        if (!state)
                return TELEPHONY_PS_3G_OFF;
 
-       state = _ps_modem_get_data_roaming_allowed(service->p_modem);
+       state = _ps_modem_get_data_roaming_allowed(modem);
        if (service->roaming && !state)
                return TELEPHONY_PS_ROAMING_OFF;
 
        return TELEPHONY_PS_ON;
 }
 
-static gboolean on_service_get_properties(PacketServiceService *obj_service,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       GVariant *gv = NULL;
-       GVariantBuilder property;
-       ps_info_ex_co(_ps_service_ref_co_network(user_data), "get service properties");
-
-       gv = _ps_service_get_properties(user_data, &property);
-       packet_service_service_complete_get_properties(obj_service, invocation, gv);
-       return TRUE;
-}
-
-static gboolean
-on_service_get_context(PacketServiceService *obj_service,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
+void _ps_service_handling_nas_timer(ps_service_t *service, gboolean state)
 {
-       GVariantBuilder b_context;
-       GVariant *contexts;
-
        unsigned int index;
-       ps_service_t *service = user_data;
-       CoreObject *co_network = _ps_service_ref_co_network(service);
-
-       ps_info_ex_co(co_network, "modem get contexts interface");
 
-       if (service->contexts == NULL) {
-               ps_err_ex_co(co_network, "No context present for service");
-               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-               return TRUE;
-       }
+       g_return_if_fail(service != NULL);
+       ps_info_ex_svc(service, "Handleing nas timer, state(%d)", state);
 
-       g_variant_builder_init(&b_context, G_VARIANT_TYPE("a{sa{ss}}"));
        for (index = 0; index < g_slist_length(service->contexts); index++) {
-               gpointer value = g_slist_nth_data(service->contexts, index);
-               gchar *path = NULL;
-               g_variant_builder_open(&b_context, G_VARIANT_TYPE("{sa{ss}}"));
-               path = _ps_context_ref_path(value);
-               ps_info_ex_co(co_network, "path: [%s]", path);
-
-               g_variant_builder_add(&b_context, "s", g_strdup(path));
-               if (FALSE == _ps_context_get_properties_handler(value, &b_context)) {
-                       ps_err_ex_co(co_network, "Failed to get property");
-                       g_variant_builder_close(&b_context);
-                       FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
-                       return TRUE;
-               }
-               g_variant_builder_close(&b_context);
+               ps_context_t *context = g_slist_nth_data(service->contexts, index);
+               CoreObject *co_context = _ps_context_ref_co_context(context);
+               enum co_context_state co_state = tcore_context_get_state(co_context);
+
+               if (co_state == CONTEXT_STATE_ACTIVATED) {
+                       enum co_context_role role = tcore_context_get_role(co_context);
+                       enum ims_data_pdn data_pdn = IMS_DATA_PDN_UNKNOWN;
+                       enum ims_data_state data_state = IMS_DATA_STATE_RESUME;
+                       gboolean drop_packet = FALSE;
+
+                       if (role == CONTEXT_ROLE_INTERNET)
+                               data_pdn = IMS_DATA_PDN_INTERNET;
+                       else if (role == CONTEXT_ROLE_IMS)
+                               data_pdn = IMS_DATA_PDN_IMS;
+                       else if (role == CONTEXT_ROLE_IMS_EMERGENCY)
+                               data_pdn = IMS_DATA_PDN_EMERGENCY;
+                       else if (role == CONTEXT_ROLE_MMS)
+                               data_pdn = IMS_DATA_PDN_CBS;
+
+                       if (state == PS_NAS_TIMER_STATE_START) {
+                               data_state = IMS_DATA_STATE_SUSPEND;
+                               drop_packet = TRUE;
+                       } else {
+                               data_state = IMS_DATA_STATE_RESUME;
+                               drop_packet = FALSE;
+                       }
 
-       }
+                       ps_info_ex_svc(service, "co_context(%p) co_state(%d) role(%d) data_pdn(%d) data_state(%d) drop_packet(%d)",
+                               co_context, co_state, role, data_pdn, data_state, drop_packet);
 
-       contexts = g_variant_builder_end(&b_context);
-       packet_service_service_complete_get_contexts(obj_service, invocation, contexts);
-       return TRUE;
-}
+/*
+                       if (tcore_context_get_drop_packet(co_context) != drop_packet) {
+                               tcore_context_set_drop_packet(co_context, drop_packet);
+                               _ps_context_handling_nas_timer(context, drop_packet);
 
-static void _ps_service_setup_interface(PacketServiceService *service, ps_service_t *service_data)
-{
-       ps_info_ex_co(_ps_service_ref_co_network(service_data), "Entered");
-       g_signal_connect(service,
-                       "handle-get-properties",
-                       G_CALLBACK(on_service_get_properties),
-                       service_data);
-
-       g_signal_connect(service,
-                       "handle-get-contexts",
-                       G_CALLBACK(on_service_get_context),
-                       service_data);
-
-       ps_dbg_ex_co(_ps_service_ref_co_network(service_data), "Exiting");
+                               if (role == CONTEXT_ROLE_IMS)
+                                       tcore_ps_set_ims_data_state(_ps_service_ref_co_ps(service), data_pdn, data_state);
+                       }
+*/
+               }
+       }
 }
-
index 82ed11c..8563992 100644 (file)
  */
 
 #include "ps_common.h"
+#include "ps_context.h"
+#include "ps_modem.h"
+#include "ps_service.h"
+#include "ps_master.h"
+#include "ps_tcore_interface.h"
+#include "ps_hook.h"
 
 #include <server.h>
 #include <plugin.h>
 #include <co_sim.h>
 #include <type/network.h>
 #include <co_network.h>
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-#include <co_call.h>
-#endif
 #include <user_request.h>
-
-#define MODULE_TAG "PS-INF"
-
-#define TIMEOUT_MAX                    1280
+#include <vconf.h>
+#include "ps_log.h"
 
 enum ps_call_state {
        PS_CALL_STATE_RESULT_OK = 0x00,
@@ -45,128 +46,6 @@ enum ps_call_state {
        PS_CALL_STATE_RESULT_NO_CARRIER = 0x03
 };
 
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-struct work_queue_data {
-       unsigned int id;
-       UserRequest *ur;
-};
-
-static void __ps_modem_set_hook_flag(ps_modem_t *modem , enum tcore_request_command cmd);
-static void __ps_modem_get_mode_pref_change(ps_modem_t *modem, UserRequest *ur);
-
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-static gboolean __ps_is_any_call_in_progress(TcorePlugin *plugin, __ps_call_flow_type type, enum tcore_notification_command command);
-static enum tcore_hook_return __on_hook_voice_call_status(Server *s, CoreObject *co_call,
-               enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data);
-#endif
-
-static UserRequest *ps_util_peek_waiting_job(GQueue *queue, unsigned int id)
-{
-       int iter = 0;
-       struct work_queue_data *wqd = NULL;
-
-       g_return_val_if_fail((NULL != queue), NULL);
-
-       do {
-               wqd = g_queue_peek_nth(queue, iter);
-               if (NULL == wqd)
-                       break;
-               if (wqd->id == id) {
-                       break;
-               }
-               iter++;
-       } while (TRUE);
-
-       if (NULL == wqd) {
-               warn("Work queue data is 0");
-               return NULL;
-       }
-
-       return wqd->ur;
-}
-
-static gboolean ps_util_add_waiting_job(GQueue *queue, unsigned int id, UserRequest *ur)
-{
-       struct work_queue_data *wqd;
-
-       if (!queue)
-               return FALSE;
-
-       wqd = calloc(sizeof(struct work_queue_data), 1);
-       if (!wqd)
-               return FALSE;
-
-       wqd->id = id;
-       wqd->ur = ur;
-       g_queue_push_tail(queue, wqd);
-
-       dbg("id = %d, ur = 0x%x", wqd->id, wqd->ur);
-       return TRUE;
-}
-
-static guint ps_util_get_count_waiting_job(GQueue *queue, unsigned int id)
-{
-       guint i = 0;
-       guint count = 0;
-       struct work_queue_data *wqd = NULL;
-
-       if (!queue)
-               return count;
-
-       dbg("job count: %d", g_queue_get_length(queue));
-
-       do {
-               wqd = g_queue_peek_nth(queue, i);
-               if (!wqd)
-                       break;
-
-               if (wqd->id == id)
-                       count++;
-
-               i++;
-       } while (wqd != NULL);
-
-       dbg("count: %d, id = %d", count, id);
-
-       return count;
-}
-
-static UserRequest *ps_util_pop_waiting_job(GQueue *queue, unsigned int id)
-{
-       int i = 0;
-       UserRequest *ur;
-       struct work_queue_data *wqd;
-
-       if (!queue)
-               return NULL;
-
-       dbg("before waiting job count: %d", g_queue_get_length(queue));
-
-       do {
-               wqd = g_queue_peek_nth(queue, i);
-               if (!wqd)
-                       return NULL;
-
-               if (wqd->id == id) {
-                       wqd = g_queue_pop_nth(queue, i);
-                       break;
-               }
-
-               i++;
-       } while (wqd != NULL);
-
-       dbg("after  waiting job count: %d", g_queue_get_length(queue));
-
-       if (!wqd)
-               return NULL;
-
-       ur = wqd->ur;
-       free(wqd);
-
-       return ur;
-}
-#endif
-
 static void __ps_handle_prop_dnet_connection_status(CoreObject *co_ps, void *user_data)
 {
        const char *value = NULL;
@@ -174,1099 +53,109 @@ static void __ps_handle_prop_dnet_connection_status(CoreObject *co_ps, void *use
        guint index;
        ps_service_t *service = (ps_service_t *)user_data;
 
-       value = tcore_object_ref_property (co_ps, PROP_DNET_CONNECTION_STATUS);
-       ps_info_ex_co(co_ps, "Dnet connection status = %s", value);
+       value = tcore_object_ref_property(co_ps, PROP_DNET_CONNECTION_STATUS);
+       ps_info_ex_svc(service, "Dnet connection status = %s", value);
 
        if (!value || strlen(value) == 0)
                return;
 
-       if (g_strrstr (value, "disconnected")) {
+       if (g_strrstr(value, "disconnected")) {
                for (index = 0; index < g_slist_length(service->contexts); index++) {
-                       gpointer ps_context = g_slist_nth_data(service->contexts, index);
-                       CoreObject *co_context = _ps_context_ref_co_context(ps_context);
+                       ps_context_t *context = g_slist_nth_data(service->contexts, index);
+                       CoreObject *co_context = _ps_context_ref_co_context(context);
                        if (tcore_context_get_role(co_context) == CONTEXT_ROLE_INTERNET) {
                                context_id = value[0];
-                               ps_info_ex_co(co_ps, "TNOTI_PS_CALL_STATUS - CID: [%d] State: [%d]", context_id, PS_CALL_STATE_RESULT_NO_CARRIER);
-                               _ps_context_set_ps_defined(ps_context, FALSE);
+                               ps_info_ex_svc(service, "TNOTI_PS_CALL_STATUS - CID: [%d] State: [%d]", context_id, PS_CALL_STATE_RESULT_NO_CARRIER);
+                               _ps_context_set_ps_defined(context, FALSE);
                                tcore_ps_set_cid_active(co_ps, context_id, FALSE);
                                tcore_ps_set_cid_connected(co_ps, context_id, FALSE);
-                               _ps_context_set_connected(ps_context, FALSE);
+                               _ps_context_set_connected(context, FALSE);
                                break;
                        }
                }
        }
 }
 
-static gboolean __ps_on_prop_changed (CoreObject *co_ps, const void *event_info,
-               void *user_data)
+static gboolean __ps_on_prop_changed(CoreObject *co_ps, const void *event_info,
+                                    void *user_data)
 {
        GSList *key = (GSList *)event_info;
 
-       if (CORE_OBJECT_KEY_FIND(key, PROP_DNET_CONNECTION_STATUS)) {
+       if (CORE_OBJECT_KEY_FIND(key, PROP_DNET_CONNECTION_STATUS))
                __ps_handle_prop_dnet_connection_status(co_ps, user_data);
-       }
-       return TRUE;
-}
-
-static gboolean __ps_check_pdp_permanent_reject_cause(int cause)
-{
-       gboolean ret = TRUE;
-
-       switch (cause) {
-       case PS_PDP_PERMANENT_REJECT_OPERATOR_DETERMINED_BARRING:
-       case PS_PDP_PERMANENT_REJECT_UNKNOWN_APN:
-       case PS_PDP_PERMANENT_REJECT_UNKNOWN_PDP:
-       case PS_PDP_PERMANENT_REJECT_AUTH_FAILED:
-       case PS_PDP_PERMANENT_REJECT_GGSN_REJECT:
-       case PS_PDP_PERMANENT_REJECT_OPTION_NOT_SUPPORTED:
-       case PS_PDP_PERMANENT_REJECT_OPTION_UNSUBSCRIBED:
-               dbg("Permanent reject cause");
-               ret = FALSE;
-       break;
-
-       default:
-       break;
-       }
-
-       return ret;
-}
-
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-static gboolean __ps_set_network_mode(int mode, void *data)
-{
-       int c_mode = 0;
-       gboolean roaming = FALSE;
-       struct treq_network_set_mode req;
-
-       UserRequest *ur = NULL;
-       ps_modem_t *modem = data;
-
-       CoreObject *co_network = NULL;
-
-       memset(&req, 0, sizeof(struct treq_network_set_mode));
-
-       co_network = tcore_plugin_ref_core_object(tcore_object_ref_plugin(modem->co_modem),
-                       CORE_OBJECT_TYPE_NETWORK);
-       c_mode = mode;
-
-       if (modem->data_allowed)
-               c_mode |= NETWORK_MODE_LTE;
-       else
-               c_mode &= ~NETWORK_MODE_LTE;
-
-       roaming = tcore_network_get_roaming_state(co_network);
-       if (modem->data_allowed && roaming)
-               c_mode &= ~NETWORK_MODE_LTE;
-
-       ps_dbg_ex_co(co_network, "candidate mode(%d), current mode(%d), roaming(%d), data allowed(%d)", c_mode, mode, roaming, modem->data_allowed);
-       if (c_mode == mode) {
-               return FALSE;
-       }
-
-       req.mode = c_mode;
-
-       ur = tcore_user_request_new(NULL, tcore_plugin_ref_plugin_name(tcore_object_ref_plugin(co_network)));
-       tcore_user_request_set_data(ur, sizeof(struct treq_network_set_mode), &req);
-       tcore_user_request_set_command(ur, TREQ_NETWORK_SET_MODE);
-
-       if (TCORE_RETURN_SUCCESS != tcore_server_dispatch_request(tcore_plugin_ref_server(tcore_object_ref_plugin(modem->co_modem)), ur)) {
-               ps_err_ex_co(co_network, "Failed to dispatch");
-               tcore_user_request_unref(ur);
-       }
-
        return TRUE;
 }
 
-/* Function will be used in case any dispatch request failed in ps plugin */
-static void __ps_send_ur_dispatch_failure_response(UserRequest *ur, enum tcore_response_command command)
-{
-       err("User request dispatch failed so need to send response for command [%d]", command);
-       switch (command) {
-       case TRESP_NETWORK_SEARCH: {
-               struct tresp_network_search search_rsp;
-               memset(&search_rsp, 0, sizeof(struct tresp_network_search));
-
-               search_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
-               search_rsp.list_count = 0;
-               tcore_user_request_send_response(ur, TRESP_NETWORK_SEARCH,
-                       sizeof(struct tresp_network_search), &search_rsp);
-       }
-       break;
-
-       case TRESP_NETWORK_SET_PLMN_SELECTION_MODE: {
-               struct tresp_network_set_plmn_selection_mode set_plmn_selection_mode_rsp;
-               memset(&set_plmn_selection_mode_rsp, 0, sizeof(struct tresp_network_set_plmn_selection_mode));
-
-               set_plmn_selection_mode_rsp.result =  TCORE_RETURN_FAILURE;
-               tcore_user_request_send_response(ur, TRESP_NETWORK_SET_PLMN_SELECTION_MODE,
-                       sizeof(struct tresp_network_set_plmn_selection_mode), &set_plmn_selection_mode_rsp);
-       }
-       break;
-
-       case TRESP_NETWORK_SET_MODE: {
-               struct tresp_network_set_mode set_rsp;
-               memset(&set_rsp, 0, sizeof(struct tresp_network_set_mode));
-
-               set_rsp.result =  TCORE_RETURN_FAILURE;
-               tcore_user_request_send_response(ur, TRESP_NETWORK_SET_MODE,
-                       sizeof(struct tresp_network_search), &set_rsp);
-       }
-       break;
-
-       case TRESP_NETWORK_GET_MODE: {
-               struct tresp_network_get_mode get_rsp;
-               memset(&get_rsp, 0, sizeof(struct tresp_network_get_mode));
-
-               get_rsp.result =  TCORE_RETURN_FAILURE;
-               tcore_user_request_send_response(ur, TRESP_NETWORK_GET_MODE,
-                       sizeof(struct tresp_network_get_mode), &get_rsp);
-       }
-       break;
-
-       case TRESP_MODEM_POWER_OFF: {
-               struct tresp_modem_power_off set_power_off_rsp;
-               memset(&set_power_off_rsp, 0, sizeof(struct tresp_modem_power_off));
-
-               set_power_off_rsp.result =  TCORE_RETURN_FAILURE;
-               tcore_user_request_send_response(ur, TRESP_MODEM_POWER_OFF,
-                       sizeof(struct tresp_modem_power_off), &set_power_off_rsp);
-       }
-       break;
-
-       case TRESP_MODEM_POWER_LOW: {
-               struct tresp_modem_power_low set_power_low_rsp;
-               memset(&set_power_low_rsp, 0, sizeof(struct tresp_modem_power_low));
-
-               set_power_low_rsp.result =  TCORE_RETURN_FAILURE;
-               tcore_user_request_send_response(ur, TRESP_MODEM_POWER_LOW,
-                       sizeof(struct tresp_modem_power_low), &set_power_low_rsp);
-       }
-       break;
-
-       case TRESP_MODEM_SET_FLIGHTMODE: {
-               struct tresp_modem_set_flightmode set_flight_mode_rsp;
-               memset(&set_flight_mode_rsp, 0, sizeof(struct tresp_modem_set_flightmode));
-
-               set_flight_mode_rsp.result =  TCORE_RETURN_FAILURE;
-               tcore_user_request_send_response(ur, TRESP_MODEM_SET_FLIGHTMODE,
-                       sizeof(struct tresp_modem_set_flightmode), &set_flight_mode_rsp);
-       }
-       break;
-
-       default:
-               err("Command type not expected [%d]", command);
-       }
-       /* Unref User request */
-       tcore_user_request_unref(ur);
-}
-
-void __ps_hook_response_cb(UserRequest *ur, enum tcore_response_command command,
-       unsigned int data_len, const void *data, void *user_data)
-{
-       ps_modem_t *modem = user_data;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
-       guint count;
-       guint id;
-       id = ((command & ~TCORE_RESPONSE) & TCORE_REQUEST);
-
-       ps_dbg_ex_co(co_modem, "Entered");
-       count = ps_util_get_count_waiting_job(modem->work_queue, id);
-
-       if (count != 0) {
-               ur = ps_util_pop_waiting_job(modem->work_queue, id);
-               if (ur) {
-                       CoreObject *co_network = NULL;
-                       TReturn ret = TCORE_RETURN_SUCCESS;
-
-                       co_network = tcore_plugin_ref_core_object(tcore_object_ref_plugin(modem->co_modem),
-                               CORE_OBJECT_TYPE_NETWORK);
-
-                       ps_info_ex_co(co_modem, "Sending Pending Request of type = id", id);
-                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                       if ((command == TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH)
-                                       || (command == TRESP_NETWORK_SEARCH)
-                                       || (command == TRESP_NETWORK_SET_PLMN_SELECTION_MODE)
-                                       || (command == TRESP_NETWORK_SET_MODE)
-                                       || (command == TRESP_NETWORK_GET_MODE)
-                                       || (command == TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION))
-                               ret = tcore_object_dispatch_request(co_network , ur);
-                       else if ((command == TRESP_MODEM_SET_FLIGHTMODE)
-                                       || (command == TRESP_MODEM_POWER_LOW)
-                                       || (command == TRESP_MODEM_POWER_OFF))
-                               ret = tcore_object_dispatch_request(modem->co_modem , ur);
-                       if (TCORE_RETURN_SUCCESS != ret) {
-                               /* send responce wrt to command */
-                               __ps_send_ur_dispatch_failure_response(ur, command);
-                       }
-                       return;
-               }
-       }
-
-       switch (command) {
-       case TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH:
-       case TRESP_NETWORK_SEARCH:
-               ps_dbg_ex_co(co_modem, "TRESP_NETWORK_SEARCH  response received");
-               if (count == 0)
-                       modem->hook_flag &= PS_RESET_NETWORK_SEARCH_FLAG;
-       break;
-
-       case TRESP_NETWORK_SET_PLMN_SELECTION_MODE:
-               ps_dbg_ex_co(co_modem, "TRESP_NETWORK_SET_PLMN_SELECTION_MODE response received ");
-               if (count == 0)
-                       modem->hook_flag &= PS_NETWORK_RESET_SELECTION_FLAG;
-       break;
-
-       case TRESP_NETWORK_SET_MODE: {
-               ps_dbg_ex_co(co_modem, "TRESP_NETWORK_SET_MODE response received ");
-
-               if (count == 0) {
-                       modem->hook_flag &= PS_NETWORK_RESET_SELECT_MODE_FLAG;
-                       modem->mode_pref_changed = FALSE;
-               }
-               ps_dbg_ex_co(co_modem, "mode_pref_changed : %d", modem->mode_pref_changed);
-       }
-       break;
-
-       case TRESP_NETWORK_GET_MODE: {
-               gboolean rv = FALSE;
-               const struct tresp_network_get_mode *resp_get_mode = data;
-               ps_dbg_ex_co(co_modem, "TRESP_NETWORK_GET_MODE response received mode (mode:[%d])", resp_get_mode->mode);
-
-               if (count == 0)
-                       modem->hook_flag &= PS_NETWORK_RESET_GET_MODE_FLAG;
-
-               rv = __ps_set_network_mode(resp_get_mode->mode, modem);
-               if (rv) {
-                       ps_dbg_ex_co(co_modem, "network set mode request!");
-                       return;
-               }
-       }
-       break;
-
-       case TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION:
-               ps_dbg_ex_co(co_modem, "TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION response received ");
-               if (count == 0)
-                       modem->hook_flag &= PS_NETWORK_RESET_SET_DEFAULT_DATA_SUBS;
-       break;
-
-       case TRESP_MODEM_SET_FLIGHTMODE:
-               ps_dbg_ex_co(co_modem, "TRESP_MODEM_SET_FLIGHTMODE response received ");
-               if (count == 0)
-                       modem->hook_flag &= PS_NETWORK_RESET_SET_FLIGHT_MODE_FLAG;
-       break;
-
-       case TRESP_MODEM_POWER_LOW:
-               ps_dbg_ex_co(co_modem, "TRESP_MODEM_POWER_LOW response received ");
-               if (count == 0)
-                       modem->hook_flag &= PS_NETWORK_RESET_SET_POWER_LOW_FLAG;
-       break;
-
-       case TRESP_MODEM_POWER_OFF:
-               ps_dbg_ex_co(co_modem, "TRESP_MODEM_POWER_OFF response received ");
-               if (count == 0)
-                       modem->hook_flag &= PS_NETWORK_RESET_SET_POWER_OFF_FLAG;
-       break;
-
-       case TRESP_SIM_SET_POWERSTATE:
-               ps_dbg_ex_co(co_modem, "TRESP_SIM_SET_POWERSTATE response received ");
-               if (count == 0)
-                       modem->hook_flag &= PS_SIM_SET_POWER_STATE_FLAG;
-       break;
-
-       default: {
-               ps_warn_ex_co(co_modem, "Unexpected response ");
-       }
-       break;
-       }
-
-       ps_info_ex_co(co_modem, "After unset - FLAG %x", modem->hook_flag);
-       if (modem->hook_flag == PS_NO_PENDING_REQUEST
-                       && command != TRESP_MODEM_POWER_LOW
-                       && command != TRESP_MODEM_POWER_OFF
-                       && modem->mode_pref_changed == FALSE) {
-               _ps_modem_connect_default_context(modem);
-       }
-}
-
-void __ps_modem_get_mode_pref_change(ps_modem_t *modem, UserRequest *ur)
-{
-       enum telephony_network_service_type svc_type;
-       enum tcore_request_command cmd;
-       CoreObject *co_network = NULL;
-       const struct treq_network_set_mode *req;
-
-       cmd = tcore_user_request_get_command(ur);
-       if (cmd != TREQ_NETWORK_SET_MODE) {
-               ps_warn_ex_co(_ps_modem_ref_co_modem(modem), "Not a TREQ_NETWORK_SET_MODE");
-               modem->mode_pref_changed = FALSE;
-               return;
-       }
-       modem->mode_pref_changed = TRUE;
-
-       co_network = tcore_plugin_ref_core_object(tcore_object_ref_plugin(modem->co_modem),
-               CORE_OBJECT_TYPE_NETWORK);
-       req = tcore_user_request_ref_data(ur, NULL);
-
-       tcore_network_get_service_type(co_network, &svc_type);
-       ps_dbg_ex_co(co_network, "mode_pref[0x%x], svc_type[%d]", req->mode, svc_type);
-       switch (svc_type) {
-       case NETWORK_SERVICE_TYPE_2G:
-       case NETWORK_SERVICE_TYPE_2_5G:
-       case NETWORK_SERVICE_TYPE_2_5G_EDGE: {
-               if (req->mode == NETWORK_MODE_GSM)
-                       modem->mode_pref_changed = FALSE;
-       }
-       break;
-
-       case NETWORK_SERVICE_TYPE_3G:
-       case NETWORK_SERVICE_TYPE_HSDPA: {
-               if (req->mode & NETWORK_MODE_WCDMA)
-                       modem->mode_pref_changed = FALSE;
-       }
-       break;
-
-       case NETWORK_SERVICE_TYPE_LTE: {
-               if (req->mode & NETWORK_MODE_LTE)
-                       modem->mode_pref_changed = FALSE;
-       }
-       break;
-
-       default:
-       break;
-       }
-
-       ps_dbg_ex_co(co_network, "mode_pref_changed : %d", modem->mode_pref_changed);
-}
-
-void __ps_modem_cp_reset_send_pending_request_response(gpointer data)
-{
-       gpointer *queue_data = NULL;
-       ps_modem_t *modem = data;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
-
-       ps_info_ex_co(co_modem, "Entered");
-       queue_data = g_queue_pop_head(modem->work_queue);
-       while (queue_data) {
-               struct work_queue_data *wqd = (struct work_queue_data *)queue_data;
-               if (wqd->ur) {
-                       enum tcore_request_command cmd = tcore_user_request_get_command(wqd->ur);
-
-                       if (cmd == TREQ_NETWORK_SEARCH) {
-                               struct tresp_network_search search_rsp;
-                               memset(&search_rsp, 0, sizeof(struct tresp_network_search));
-
-                               search_rsp.result = TCORE_RETURN_FAILURE;
-                               search_rsp.list_count = 0;
-                               tcore_user_request_send_response(wqd->ur, TRESP_NETWORK_SEARCH,
-                               sizeof(struct tresp_network_search), &search_rsp);
-                       } else if (cmd == TREQ_NETWORK_SET_PLMN_SELECTION_MODE) {
-                               struct tresp_network_set_plmn_selection_mode set_plmn_mode_rsp;
-                               memset(&set_plmn_mode_rsp, 0, sizeof(struct tresp_network_set_plmn_selection_mode));
-
-                               set_plmn_mode_rsp.result = TCORE_RETURN_FAILURE;
-                               tcore_user_request_send_response(wqd->ur, TRESP_NETWORK_SET_PLMN_SELECTION_MODE,
-                               sizeof(struct tresp_network_set_plmn_selection_mode), &set_plmn_mode_rsp);
-                       } else if (cmd == TREQ_NETWORK_SET_MODE) {
-                               struct tresp_network_set_mode setmode_rsp;
-                               memset(&setmode_rsp, 0, sizeof(struct tresp_network_set_mode));
-
-                               setmode_rsp.result = TCORE_RETURN_FAILURE;
-                               tcore_user_request_send_response(wqd->ur, TRESP_NETWORK_SET_MODE,
-                               sizeof(struct tresp_network_set_mode), &setmode_rsp);
-                       } else if (cmd == TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH) {
-                               struct tresp_network_set_cancel_manual_search search_cancel_rsp;
-                               memset(&search_cancel_rsp, 0, sizeof(struct tresp_network_set_cancel_manual_search));
-
-                               search_cancel_rsp.result = TCORE_RETURN_FAILURE;
-                               tcore_user_request_send_response(wqd->ur, TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH,
-                               sizeof(struct tresp_network_set_cancel_manual_search), &search_cancel_rsp);
-                       } else if (cmd == TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION) {
-                               struct tresp_network_set_default_data_subscription default_data_rsp;
-                               memset(&default_data_rsp, 0, sizeof(struct tresp_network_set_default_data_subscription));
-
-                               default_data_rsp.result = TCORE_RETURN_FAILURE;
-                               tcore_user_request_send_response(wqd->ur, TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION,
-                               sizeof(struct tresp_network_set_default_data_subscription), &default_data_rsp);
-                       } else if (cmd == TREQ_MODEM_SET_FLIGHTMODE) {
-                               struct tresp_modem_set_flightmode set_flight_mode;
-                               memset(&set_flight_mode, 0, sizeof(struct tresp_modem_set_flightmode));
-
-                               set_flight_mode.result = TCORE_RETURN_FAILURE;
-                               tcore_user_request_send_response(wqd->ur, TRESP_MODEM_SET_FLIGHTMODE,
-                               sizeof(struct tresp_modem_set_flightmode), &set_flight_mode);
-                       } else if (cmd == TREQ_MODEM_POWER_OFF) {
-                               struct tresp_modem_power_off set_power_off;
-                               memset(&set_power_off,  0, sizeof(struct tresp_modem_power_off));
-
-                               set_power_off.result = TCORE_RETURN_FAILURE;
-                               tcore_user_request_send_response(wqd->ur, TRESP_MODEM_POWER_OFF,
-                               sizeof(struct tresp_modem_power_off), &set_power_off);
-
-                       } else if (cmd == TREQ_MODEM_POWER_LOW) {
-                               struct tresp_modem_power_low set_power_low;
-                               memset(&set_power_low, 0, sizeof(struct tresp_modem_power_low));
-
-                               set_power_low.result = TCORE_RETURN_FAILURE;
-                               tcore_user_request_send_response(wqd->ur, TRESP_MODEM_POWER_LOW,
-                               sizeof(struct tresp_modem_power_low), &set_power_low);
-
-                       } else if (cmd == TREQ_SIM_SET_POWERSTATE) {
-                               struct tresp_sim_set_powerstate set_power;
-                               memset(&set_power, 0, sizeof(struct tresp_sim_set_powerstate));
-
-                               set_power.result = TCORE_RETURN_FAILURE;
-                               tcore_user_request_send_response(wqd->ur, TRESP_SIM_SET_POWERSTATE,
-                               sizeof(struct tresp_sim_set_powerstate), &set_power);
-
-                       } else {
-                               ps_err_ex_co(co_modem, "Unexpected command ");
-                       }
-                       tcore_user_request_unref(wqd->ur);
-
-                       /* Memory Free */
-                       free(wqd);
-               }
-               queue_data = g_queue_pop_head(modem->work_queue);
-       }
-}
-#endif
-
-static void __ps_modem_cp_reset_handler(gpointer object)
+static void __ps_modem_cp_reset_handler(ps_modem_t *modem)
 {
        unsigned int index;
-       ps_modem_t *modem = object;
+#ifdef TIZEN_SUPPORT_VOLTE
+       enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
+#endif
 
-       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "disconnect all contexts");
+       ps_info_ex_modem(modem, "disconnect all contexts");
        /* send deactivation request to clear resources. */
        for (index = 0; index < g_slist_length(modem->contexts); index++) {
-               gpointer context = g_slist_nth_data(modem->contexts, index);
+               ps_context_t *context = g_slist_nth_data(modem->contexts, index);
                ps_service_t *service = _ps_context_ref_service(context);
                CoreObject *co_context = _ps_context_ref_co_context(context);
-               if(service == NULL)
+               if (service == NULL)
                        continue;
-               tcore_ps_deactivate_context(service->co_ps, co_context, NULL);
-               tcore_context_set_state(co_context, CONTEXT_STATE_DEACTIVATED);
-       }
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-       /* check for any pending request in modem queue and respond with error */
-       __ps_modem_cp_reset_send_pending_request_response(modem);
-
-       /* reset modem flag */
-       modem->hook_flag  &= PS_NO_PENDING_REQUEST;
-#endif
-}
-
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-void __ps_modem_set_hook_flag(ps_modem_t *modem , enum tcore_request_command cmd)
-{
-       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
-
-       switch (cmd) {
-       case TREQ_NETWORK_SEARCH:
-               ps_dbg_ex_co(co_modem, "TREQ_NETWORK_SEARCH");
-               modem->hook_flag |= PS_NETWORK_SEARCH_PENDING;
-               ps_dbg_ex_co(co_modem, "TREQ_NETWORK_SEARCH setting flag %x", modem->hook_flag);
-       break;
-
-       case TREQ_NETWORK_SET_PLMN_SELECTION_MODE:
-               modem->hook_flag |= PS_NETWORK_SELECTION_PENDING;
-               ps_dbg_ex_co(co_modem, "TREQ_NETWORK_SET_PLMN_SELECTION_MODE setting flag %x", modem->hook_flag);
-       break;
-
-       case TREQ_NETWORK_SET_MODE:
-               modem->hook_flag |= PS_NETWORK_SELECT_MODE;
-               ps_dbg_ex_co(co_modem, "TREQ_NETWORK_SET_MODE setting flag %x", modem->hook_flag);
-       break;
-
-       case TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION:
-               modem->hook_flag |= PS_NETWORK_SET_DEFAULT_DATA_SUBS;
-               ps_dbg_ex_co(co_modem, "TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION setting flag %x", modem->hook_flag);
-       break;
-
-       case TREQ_MODEM_SET_FLIGHTMODE:
-               modem->hook_flag |= PS_NETWORK_SET_FLIGHT_MODE;
-               ps_dbg_ex_co(co_modem, "TREQ_MODEM_SET_FLIGHTMODE setting flag %x", modem->hook_flag);
-       break;
-
-       case TREQ_MODEM_POWER_OFF:
-               modem->hook_flag |= PS_NETWORK_SET_POWER_OFF;
-               ps_dbg_ex_co(co_modem, "TREQ_MODEM_POWER_OFF setting flag %x", modem->hook_flag);
-       break;
-
-       case TREQ_MODEM_POWER_LOW:
-               modem->hook_flag |= PS_NETWORK_SET_POWER_LOW;
-               ps_dbg_ex_co(co_modem, "TREQ_MODEM_POWER_LOW setting flag %x", modem->hook_flag);
-       break;
-
-       case TREQ_SIM_SET_POWERSTATE:
-               modem->hook_flag |= PS_SIM_SET_POWER_STATE;
-               ps_dbg_ex_co(co_modem, "TREQ_SIM_SET_POWERSTATE setting flag %x", modem->hook_flag);
-       break;
-
-       default:
-               ps_dbg_ex_co(co_modem, "Not handled request");
-       break;
-       }
-       ps_info_ex_co(co_modem, "After set - FLAG %x", modem->hook_flag);
-}
-
-enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_data)
-{
-       gboolean ret = FALSE;
-       TReturn rv = TCORE_RETURN_FAILURE;
-
-       CoreObject *co_ps = NULL;
-       TcorePlugin *target_plg = NULL;
-       int value = 0;
-       guint job_cnt = 0;
-       ps_modem_t *modem = user_data;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
-       GHashTableIter iter;
-       gpointer key, service;
-
-       char *modem_name = NULL;
-       enum tcore_request_command cmd = tcore_user_request_get_command(ur);
-
-       ps_dbg_ex_co(co_modem, "Entered");
-
-       modem_name = tcore_user_request_get_modem_name(ur);
-       if (!modem_name)
-               return TCORE_HOOK_RETURN_CONTINUE;
-
-       if (cmd == TREQ_MODEM_SET_FLIGHTMODE) {
-               const struct treq_modem_set_flightmode *req;
-
-               req = tcore_user_request_ref_data(ur, NULL);
-               if (req->enable == TRUE) {
-                       g_hash_table_iter_init(&iter, modem->services);
-                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE)
-                               _ps_service_set_ims_activation_requested(service, FALSE);
-               }
-       }
-
-       target_plg = tcore_object_ref_plugin(modem->co_modem);
-       if (g_strcmp0(tcore_server_get_cp_name_by_plugin(target_plg), modem_name) != 0) {
-               ps_info_ex_co(co_modem, "request modem (%s) not matched current modem(%s)",
-                               modem_name,
-                               tcore_server_get_cp_name_by_plugin(target_plg));
-               free(modem_name);
-
-               if (cmd == TREQ_NETWORK_SEARCH || cmd == TREQ_MODEM_SET_FLIGHTMODE
-                       || cmd == TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION
-                       || cmd == TREQ_NETWORK_SET_PLMN_SELECTION_MODE) {
-                       co_ps = tcore_plugin_ref_core_object(target_plg, CORE_OBJECT_TYPE_PS);
-                       if (!co_ps) {
-                               ps_err_ex_co(co_modem, "No ps core object present ");
-                               return TCORE_HOOK_RETURN_CONTINUE;
-                       }
-
-                       if (cmd == TREQ_NETWORK_SEARCH || cmd == TREQ_NETWORK_SET_PLMN_SELECTION_MODE) {
-                               if (FALSE == tcore_ps_any_internet_mms_tethering_context_activating_activated(co_ps, &value)) {
-                                       ps_info_ex_co(co_modem, "No internet/mms/tethering activating/activated context present");
-                                       /* Block PS always-on while network operations. */
-                                       __ps_modem_set_hook_flag(modem, cmd);
-                                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                                       return TCORE_HOOK_RETURN_CONTINUE;
-                               }
-                               ps_info_ex_co(co_modem, "Value returned [%d]", value);
-                               if (CONTEXT_STATE_ACTIVATED == value) {
-                                       ps_dbg_ex_co(co_modem, "Internet/mms/tethering context present in ACTIVATED state. Send deactivate requests");
-                                       g_hash_table_iter_init(&iter, modem->services);
-                                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE)
-                                               _ps_service_disconnect_internet_mms_tethering_contexts(service);
-                               } else if (CONTEXT_STATE_ACTIVATING == value) {
-                                       ps_info_ex_co(co_modem, "Internet/mms/tethering context present in ACTIVATING state. Wait for activation successful ");
-                               }
-                       } else {
-                               if (FALSE == tcore_ps_any_context_activating_activated(co_ps, &value)) {
-                                       ps_info_ex_co(co_modem, "No internet/mms/tethering/IMS/UT activating/activated context present");
-                                       /* Block PS always-on while network operations. */
-                                       __ps_modem_set_hook_flag(modem, cmd);
-                                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                                       return TCORE_HOOK_RETURN_CONTINUE;
-                               }
-                               ps_info_ex_co(co_modem, "Value returned [%d]", value);
-                               if (CONTEXT_STATE_ACTIVATED == value) {
-                                       ps_dbg_ex_co(co_modem, "Internet/mms/tethering/IMS/UT context present in ACTIVATED state. Send deactivate requests");
-                                       rv = tcore_ps_deactivate_contexts(co_ps);
-                                       if (rv != TCORE_RETURN_SUCCESS) {
-                                               ps_dbg_ex_co(co_modem, "fail to deactivation");
-                                               return TCORE_HOOK_RETURN_CONTINUE;
-                                       }
-                               } else if (CONTEXT_STATE_ACTIVATING == value) {
-                                       if (cmd == TREQ_MODEM_SET_FLIGHTMODE)  {
-                                               ps_info_ex_co(co_modem, "No need to stop these request for pdp in activating state ");
-                                               return TCORE_HOOK_RETURN_CONTINUE;
-                                       }
-                                       ps_info_ex_co(co_modem, "Internet/mms/tethering/IMS/UT context present in ACTIVATING state. Wait for activation successful ");
-                               }
-                       }
-
-                       if (!modem->work_queue) {
-                               ps_err_ex_co(co_modem, "no queue present unable to handle request");
-                               return TCORE_HOOK_RETURN_CONTINUE;
-                       }
-
-                       job_cnt = ps_util_get_count_waiting_job(modem->work_queue, cmd);
-                       if (job_cnt) {
-                               ps_err_ex_co(co_modem, "duplicated job for cmd(%d)", cmd);
-
-                               if (cmd == TREQ_NETWORK_SEARCH) {
-                                       struct tresp_network_search search_rsp;
-                                       memset(&search_rsp, 0, sizeof(struct tresp_network_search));
-
-                                       search_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
-                                       search_rsp.list_count = 0;
-                                       tcore_user_request_send_response(ur, TRESP_NETWORK_SEARCH,
-                                               sizeof(struct tresp_network_search), &search_rsp);
-                               } else if (cmd == TREQ_MODEM_SET_FLIGHTMODE) {
-                                       struct tresp_modem_set_flightmode set_flight_mode;
-                                       memset(&set_flight_mode, 0, sizeof(struct tresp_modem_set_flightmode));
-
-                                       set_flight_mode.result = TCORE_RETURN_OPERATION_ABORTED;
-                                       tcore_user_request_send_response(ur, TRESP_MODEM_SET_FLIGHTMODE,
-                                               sizeof(struct tresp_modem_set_flightmode), &set_flight_mode);
-                               }
-
-                               tcore_user_request_unref(ur);
-                               return TCORE_HOOK_RETURN_STOP_PROPAGATION;
-                       }
-                       ret = ps_util_add_waiting_job(modem->work_queue, cmd , ur);
-                       if (!ret) {
-                               ps_err_ex_co(co_modem, "fail to add the request to queue");
-                               return TCORE_HOOK_RETURN_CONTINUE;
-                       }
-
-                       __ps_modem_get_mode_pref_change(modem, ur);
-                       __ps_modem_set_hook_flag(modem, cmd);
-                       return TCORE_HOOK_RETURN_STOP_PROPAGATION;
-               } else if (cmd == TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH) {
-                       UserRequest *ur_pending = NULL;
-                       ur_pending = ps_util_pop_waiting_job(modem->work_queue, TREQ_NETWORK_SEARCH);
-
-                       if (!ur_pending) {
-                               ps_dbg_ex_co(co_modem, "no pendig search request");
-                               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                               return TCORE_HOOK_RETURN_CONTINUE;
-                       } else {
-                               struct tresp_network_search search_rsp;
-                               struct tresp_network_set_cancel_manual_search search_cancel_rsp;
-
-                               memset(&search_rsp, 0, sizeof(struct tresp_network_search));
-                               memset(&search_cancel_rsp, 0, sizeof(struct tresp_network_set_cancel_manual_search));
-
-                               search_rsp.list_count = 0;
-                               ps_dbg_ex_co(co_modem, "send search response to upper layer");
-                               tcore_user_request_send_response(ur_pending, TRESP_NETWORK_SEARCH, sizeof(struct tresp_network_search), &search_rsp);
-                               tcore_user_request_unref(ur_pending);
-
-                               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                               search_cancel_rsp.result = TCORE_RETURN_SUCCESS;
-                               tcore_user_request_send_response(ur, TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH,
-                                       sizeof(struct tresp_network_set_cancel_manual_search), &search_cancel_rsp);
-
-                               return TCORE_HOOK_RETURN_STOP_PROPAGATION;
-                       }
-               }
-               return TCORE_HOOK_RETURN_CONTINUE;
-       }
-
-       if (modem_name)
-               free(modem_name);
-
-       co_ps = tcore_plugin_ref_core_object(target_plg, CORE_OBJECT_TYPE_PS);
-       if (!co_ps)
-               return TCORE_HOOK_RETURN_CONTINUE;
-
-       if (cmd == TREQ_MODEM_POWER_ON) {
-               if (modem->powered == PS_MODEM_STATE_ONLINE) {
-                       struct tresp_modem_power_on set_power_on;
-                       memset(&set_power_on,  0, sizeof(struct tresp_modem_power_on));
-                       ps_dbg_ex_co(co_modem, "FLAG: 0x%x", modem->hook_flag);
-
-                       if (modem->hook_flag & PS_NETWORK_SET_POWER_LOW) {
-                               ps_dbg_ex_co(co_modem, "LOW power request is pending, send abort response");
-                               set_power_on.result = TCORE_RETURN_OPERATION_ABORTED;
-                               tcore_user_request_send_response(ur, TRESP_MODEM_POWER_ON,
-                                       sizeof(struct tresp_modem_power_on), &set_power_on);
-                       } else {
-                               ps_dbg_ex_co(co_modem, "No pending LOW power request, send success response.");
-                               set_power_on.result = TCORE_RETURN_EALREADY;
-                               tcore_user_request_send_response(ur, TRESP_MODEM_POWER_ON,
-                                       sizeof(struct tresp_modem_power_on), &set_power_on);
-                       }
-                       tcore_user_request_unref(ur);
-                       return TCORE_HOOK_RETURN_STOP_PROPAGATION;
-               }
-               return TCORE_HOOK_RETURN_CONTINUE;
-       }
-
-       if (cmd == TREQ_NETWORK_SEARCH || cmd == TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH
-                        || cmd == TREQ_NETWORK_SET_PLMN_SELECTION_MODE) {
-               if (FALSE == tcore_ps_any_internet_mms_tethering_context_activating_activated(co_ps, &value)) {
-                       ps_info_ex_co(co_modem, "No internet/mms/tethering activating/activated context present");
-                       __ps_modem_get_mode_pref_change(modem, ur);
-                       __ps_modem_set_hook_flag(modem, cmd);
-                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                       return TCORE_HOOK_RETURN_CONTINUE;
-               }
-               ps_info_ex_co(co_modem, "Value returned [%d]", value);
-               if (CONTEXT_STATE_ACTIVATED == value) {
-                       ps_dbg_ex_co(co_modem, "Internet/mms/tethering context present in ACTIVATED state. Send deactivate requests");
-                       g_hash_table_iter_init(&iter, modem->services);
-                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE)
-                               _ps_service_disconnect_internet_mms_tethering_contexts(service);
-               } else if (CONTEXT_STATE_ACTIVATING == value) {
-                       ps_info_ex_co(co_modem, "Internet/mms/tethering context present in ACTIVATING state. Wait for activation successful ");
-               }
-       } else {
-               if (FALSE == tcore_ps_any_context_activating_activated(co_ps, &value)) {
-                       ps_info_ex_co(co_modem, "No internet/mms/tethering/IMS/UT activating/activated context present");
-                       /* Block PS always-on while network operations. */
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-                       if ((cmd != TREQ_MODEM_POWER_LOW)
-                                       || (FALSE == __ps_is_any_call_in_progress(tcore_object_ref_plugin(modem->co_modem), ON_REQUEST, TNOTI_UNKNOWN))) {
-                               __ps_modem_set_hook_flag(modem, cmd);
-                               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                               return TCORE_HOOK_RETURN_CONTINUE;
-                       }
-#else
-                       __ps_modem_get_mode_pref_change(modem, ur);
-                       __ps_modem_set_hook_flag(modem, cmd);
-                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                       return TCORE_HOOK_RETURN_CONTINUE;
-#endif
-               }
-               ps_info_ex_co(co_modem, "Value returned [%d]", value);
-               if (CONTEXT_STATE_ACTIVATED == value) {
-                       ps_dbg_ex_co(co_modem, "Internet/mms/tethering/IMS/UT context present in ACTIVATED state. Send deactivate requests");
-                       rv = tcore_ps_deactivate_contexts(co_ps);
-                       if (rv != TCORE_RETURN_SUCCESS) {
-                               ps_dbg_ex_co(co_modem, "fail to deactivation");
-                               return TCORE_HOOK_RETURN_CONTINUE;
-                       }
-               } else if (CONTEXT_STATE_ACTIVATING == value) {
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-                       if ((cmd != TREQ_MODEM_POWER_LOW)
-                                       || (FALSE == __ps_is_any_call_in_progress(tcore_object_ref_plugin(modem->co_modem), ON_REQUEST, TNOTI_UNKNOWN))) {
-                               return TCORE_HOOK_RETURN_CONTINUE;
-                       }
-#else
-                       if ((cmd == TREQ_MODEM_SET_FLIGHTMODE) || (cmd == TREQ_MODEM_POWER_OFF)) {
-                               ps_info_ex_co(co_modem, "No need to stop these request for pdp in activating state ");
-                               return TCORE_HOOK_RETURN_CONTINUE;
-                       }
-#endif
-                       ps_info_ex_co(co_modem, "Internet/mms/tethering/IMS/UT context present in ACTIVATING state. Wait for activation successful ");
-               }
-       }
-
-       if (!modem->work_queue) {
-               ps_err_ex_co(co_modem, "no queue present unable to handle request");
-               return TCORE_HOOK_RETURN_CONTINUE;
-       }
-
-       job_cnt = ps_util_get_count_waiting_job(modem->work_queue, cmd);
-       if (job_cnt) {
-               ps_err_ex_co(co_modem, "duplicated job for cmd(%d)", cmd);
-
-               if (cmd == TREQ_NETWORK_SEARCH) {
-                       struct tresp_network_search search_rsp;
-                       memset(&search_rsp, 0, sizeof(struct tresp_network_search));
-
-                       search_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
-                       search_rsp.list_count = 0;
-                       tcore_user_request_send_response(ur, TRESP_NETWORK_SEARCH,
-                               sizeof(struct tresp_network_search), &search_rsp);
-               } else if (cmd == TREQ_NETWORK_SET_PLMN_SELECTION_MODE) {
-                       struct tresp_network_set_plmn_selection_mode set_plmn_mode_rsp;
-                       memset(&set_plmn_mode_rsp, 0, sizeof(struct tresp_network_set_plmn_selection_mode));
-
-                       set_plmn_mode_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
-                       tcore_user_request_send_response(ur, TRESP_NETWORK_SET_PLMN_SELECTION_MODE,
-                               sizeof(struct tresp_network_set_plmn_selection_mode), &set_plmn_mode_rsp);
-               } else if (cmd == TREQ_NETWORK_SET_MODE) {
-                       struct tresp_network_set_mode setmode_rsp;
-                       memset(&setmode_rsp, 0, sizeof(struct tresp_network_set_mode));
-
-                       setmode_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
-                       tcore_user_request_send_response(ur, TRESP_NETWORK_SET_MODE,
-                               sizeof(struct tresp_network_set_mode), &setmode_rsp);
-               } else if (cmd == TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH) {
-                       struct tresp_network_set_cancel_manual_search search_cancel_rsp;
-                       memset(&search_cancel_rsp, 0, sizeof(struct tresp_network_set_cancel_manual_search));
-
-                       search_cancel_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
-                       tcore_user_request_send_response(ur, TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH,
-                               sizeof(struct tresp_network_set_cancel_manual_search), &search_cancel_rsp);
-               } else if (cmd == TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION) {
-                       struct tresp_network_set_default_data_subscription default_data_rsp;
-                       memset(&default_data_rsp, 0, sizeof(struct tresp_network_set_default_data_subscription));
-
-                       default_data_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
-                       tcore_user_request_send_response(ur, TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION,
-                               sizeof(struct tresp_network_set_default_data_subscription), &default_data_rsp);
-               } else if (cmd == TREQ_MODEM_SET_FLIGHTMODE) {
-                       struct tresp_modem_set_flightmode set_flight_mode;
-                       memset(&set_flight_mode, 0, sizeof(struct tresp_modem_set_flightmode));
-
-                       set_flight_mode.result = TCORE_RETURN_OPERATION_ABORTED;
-                       tcore_user_request_send_response(ur, TRESP_MODEM_SET_FLIGHTMODE,
-                               sizeof(struct tresp_modem_set_flightmode), &set_flight_mode);
-               } else if (cmd == TREQ_MODEM_POWER_OFF) {
-                       struct tresp_modem_power_off set_power_off;
-                       memset(&set_power_off,  0, sizeof(struct tresp_modem_power_off));
-
-                       set_power_off.result = TCORE_RETURN_OPERATION_ABORTED;
-                       tcore_user_request_send_response(ur, TRESP_MODEM_POWER_OFF,
-                               sizeof(struct tresp_modem_power_off), &set_power_off);
-
-               } else if (cmd == TREQ_MODEM_POWER_LOW) {
-                       struct tresp_modem_power_low set_power_low;
-                       memset(&set_power_low, 0, sizeof(struct tresp_modem_power_low));
-
-                       set_power_low.result = TCORE_RETURN_OPERATION_ABORTED;
-                       tcore_user_request_send_response(ur, TRESP_MODEM_POWER_LOW,
-                               sizeof(struct tresp_modem_power_low), &set_power_low);
-
-               } else if (cmd == TREQ_SIM_SET_POWERSTATE) {
-                       struct tresp_sim_set_powerstate set_power;
-                       memset(&set_power, 0, sizeof(struct tresp_sim_set_powerstate));
-
-                       set_power.result = TCORE_RETURN_OPERATION_ABORTED;
-                       tcore_user_request_send_response(ur, TRESP_SIM_SET_POWERSTATE,
-                               sizeof(struct tresp_sim_set_powerstate), &set_power);
-
-               }
-               tcore_user_request_unref(ur);
-               return TCORE_HOOK_RETURN_STOP_PROPAGATION;
-       }
-
-       ps_info_ex_co(co_modem, "Deactivation request is sent, wait for call disconnect notification ");
-
-       if (TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH == cmd) {
-               UserRequest *ur_pending = NULL;
-               ur_pending = ps_util_pop_waiting_job(modem->work_queue, TREQ_NETWORK_SEARCH);
-
-               if (!ur_pending) {
-                       ps_dbg_ex_co(co_modem, "no pendig search request");
-                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                       return TCORE_HOOK_RETURN_CONTINUE;
-               } else {
-                       struct tresp_network_search search_rsp;
-                       struct tresp_network_set_cancel_manual_search search_cancel_rsp;
-
-                       memset(&search_rsp, 0, sizeof(struct tresp_network_search));
-                       memset(&search_cancel_rsp, 0, sizeof(struct tresp_network_set_cancel_manual_search));
-
-                       search_rsp.list_count = 0;
-                       ps_dbg_ex_co(co_modem, "send search response to upper layer");
-                       tcore_user_request_send_response(ur_pending, TRESP_NETWORK_SEARCH, sizeof(struct tresp_network_search), &search_rsp);
-                       tcore_user_request_unref(ur_pending);
-
-                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                       search_cancel_rsp.result = TCORE_RETURN_SUCCESS;
-                       tcore_user_request_send_response(ur, TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH,
-                               sizeof(struct tresp_network_set_cancel_manual_search), &search_cancel_rsp);
-
-                       return TCORE_HOOK_RETURN_STOP_PROPAGATION;
+#ifdef TIZEN_SUPPORT_VOLTE
+               role = tcore_context_get_role(co_context);
+               ps_info_ex_modem(modem, "role(%d)", role);
+               if (role == CONTEXT_ROLE_IMS && !tcore_network_get_ims_on_deregistering(_ps_service_ref_co_network(service))) {
+                       if (_ps_context_deregister_ims(context) == TCORE_RETURN_SUCCESS)
+                               tcore_context_set_state(co_context, CONTEXT_STATE_DEACTIVATED);
                }
-       }
-
-       ret = ps_util_add_waiting_job(modem->work_queue, cmd , ur);
-       if (!ret) {
-               ps_err_ex_co(co_modem, "fail to add the request to queue");
-               return TCORE_HOOK_RETURN_CONTINUE;
-       }
-
-       __ps_modem_get_mode_pref_change(modem, ur);
-       __ps_modem_set_hook_flag(modem, cmd);
-       return TCORE_HOOK_RETURN_STOP_PROPAGATION;
-}
-
-void __ps_send_pending_user_request(gpointer data)
-{
-       ps_modem_t *modem =  data;
-       TcorePlugin *plugin = NULL;
-       CoreObject *co_network = NULL;
-       CoreObject *co_sim = NULL;
-       gpointer *queue_data = NULL;
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-       UserRequest *ur_power_low = NULL;
-#endif
-
-       plugin = tcore_object_ref_plugin(modem->co_modem);
-       co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
-       co_sim = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SIM);
-
-       ps_dbg_ex_co(co_network, "Extracting the user request from the work queue");
-
-       queue_data = g_queue_pop_head(modem->work_queue);
-       while (queue_data) {
-               struct work_queue_data *wqd = (struct work_queue_data *)queue_data;
-               ps_info_ex_co(co_network, " sending Pending request [%x]", wqd->id);
-               if (wqd->ur) {
-                       ps_dbg_ex_co(co_network, "Setting responce hook for request ");
-                       tcore_user_request_set_response_hook(wqd->ur, __ps_hook_response_cb, modem);
-
-                       switch (wqd->id) {
-                       case TREQ_NETWORK_SEARCH:
-                       case TREQ_NETWORK_SET_MODE:
-                       case TREQ_NETWORK_SET_PLMN_SELECTION_MODE:
-                       case TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION: {
-                               char *modem_name;
-                               TcorePlugin *modem_plugin, *ur_modem_plugin;
-
-                               modem_name = tcore_user_request_get_modem_name(wqd->ur);
-                               if (!modem_name)
-                                       return;
-
-                               modem_plugin = tcore_object_ref_plugin(modem->co_modem);
-                               ur_modem_plugin = tcore_server_find_plugin(tcore_plugin_ref_server(modem_plugin), modem_name);
-                               if (modem_plugin != ur_modem_plugin) {
-                                       ps_info_ex_co(co_network, "request modem (%s) not matched current modem(%s)",
-                                                       modem_name, tcore_server_get_cp_name_by_plugin(modem_plugin));
-                                       /* Network search request enqueued for other sim, so dispatch it */
-                                       if (wqd->id == TREQ_NETWORK_SEARCH || wqd->id == TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION
-                                               || wqd->id == TREQ_NETWORK_SET_PLMN_SELECTION_MODE) {
-                                               CoreObject *co_other_network;
-
-                                               co_other_network = tcore_plugin_ref_core_object(ur_modem_plugin, CORE_OBJECT_TYPE_NETWORK);
-                                               if (co_other_network == NULL) {
-                                                       ps_warn_ex_co(co_network, "No network core object in other modem plugin");
-                                               } else {
-                                                       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_other_network, wqd->ur))
-                                                               ps_err_ex_co(co_network, "Failed to dispatch ");
-                                               }
-                                               free(modem_name);
-                                               break;
-                                       } else {
-                                               return;
-                                       }
-                               }
-                               free(modem_name);
-                               if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_network, wqd->ur))
-                                       ps_err_ex_co(co_network, "Failed to dispatch ");
-                       }
-                       break;
-
-                       case TREQ_MODEM_SET_FLIGHTMODE:
-                       case TREQ_MODEM_POWER_OFF: {
-                               char *modem_name;
-                               TcorePlugin *modem_plugin, *ur_modem_plugin;
-
-                               modem_name = tcore_user_request_get_modem_name(wqd->ur);
-                               if (!modem_name)
-                                       return;
-
-                               modem_plugin = tcore_object_ref_plugin(modem->co_modem);
-                               ur_modem_plugin = tcore_server_find_plugin(tcore_plugin_ref_server(modem_plugin), modem_name);
-                               if (modem_plugin != ur_modem_plugin) {
-                                       ps_info_ex_co(co_network, "request modem (%s) not matched current modem(%s)",
-                                                       modem_name, tcore_server_get_cp_name_by_plugin(modem_plugin));
-                                       /* Flight mode request enqueued for other sim, so dispatch it */
-                                       if (wqd->id == TREQ_MODEM_SET_FLIGHTMODE) {
-                                               CoreObject *co_other_modem;
-
-                                               co_other_modem = tcore_plugin_ref_core_object(ur_modem_plugin, CORE_OBJECT_TYPE_MODEM);
-                                               if (co_other_modem == NULL) {
-                                                       ps_warn_ex_co(co_network, "No modem core object in other modem plugin");
-                                               } else {
-                                                       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_other_modem, wqd->ur))
-                                                               ps_err_ex_co(co_network, "Failed to dispatch ");
-                                               }
-                                               free(modem_name);
-                                               break;
-                                       } else {
-                                               free(modem_name);
-                                               return;
-                                       }
-                               }
-                               free(modem_name);
-
-                               if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(modem->co_modem, wqd->ur))
-                                       ps_err_ex_co(co_network, "Failed to dispatch ");
-                       }
-                       break;
-
-                       case TREQ_MODEM_POWER_LOW:
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-                               ur_power_low = wqd->ur;
-#else
-                               if (modem->hook_flag & PS_NETWORK_SET_POWER_LOW)
-                                       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(modem->co_modem, wqd->ur))
-                                               err("Failed to dispatch ");
 #endif
-                       break;
-
-                       case TREQ_SIM_SET_POWERSTATE:
-                               if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_sim, wqd->ur))
-                                       ps_err_ex_co(co_network, "Failed to dispatch ");
-                       break;
+               tcore_ps_deactivate_context(_ps_service_ref_co_ps(service), co_context, NULL);
+               tcore_context_set_state(co_context, CONTEXT_STATE_DEACTIVATED);
 
-                       default:
-                               ps_err_ex_co(co_network, "No expected request ");
-                       }
-               }
+               //due to pendig UR needs to clear AP resources
+               tcore_ps_clear_context_id(_ps_service_ref_co_ps(service), co_context);
+               _ps_context_set_connected(context, FALSE);
 
-               /* Freeing Allocated memory*/
-               free(wqd);
-               queue_data = g_queue_pop_head(modem->work_queue);
        }
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
+       /* check for any pending request in modem queue and respond with error */
+       _ps_hook_cp_reset_send_pending_request_response(modem);
 
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-       if (ur_power_low) {
-               if(FALSE == ps_util_add_waiting_job(modem->work_queue, TREQ_MODEM_POWER_LOW, ur_power_low)) {
-                       err("fail to add the request to queue");
-                       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(modem->co_modem, ur_power_low)) {
-                               __ps_send_ur_dispatch_failure_response(ur_power_low, TRESP_MODEM_POWER_LOW);
-                               modem->hook_flag &= PS_NETWORK_RESET_SET_POWER_LOW_FLAG;
-                       }
-               } else
-                       __ps_check_handle_modem_off_request(modem, ON_REQUEST, TNOTI_UNKNOWN);
-       }
+       /* reset modem flag */
+       modem->hook_flag &= PS_NO_PENDING_REQUEST;
 #endif
-
-       ps_dbg_ex_co(co_network, "All pending request sent ");
 }
-#endif
 
 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)
+                                                   enum tcore_notification_command command, unsigned int data_len, void *data,
+                                                   void *user_data)
 {
        ps_modem_t *modem = NULL;
-       ps_service_t *ps_service = user_data;
+       ps_service_t *service = user_data;
        CoreObject *co_network;
-       gpointer co_ps = NULL;
+       CoreObject *co_ps = NULL;
        GSList *co_list;
 
        gboolean b_data_allowed = FALSE;
        gboolean b_roaming_checker = TRUE;
        gboolean b_mms_checker = FALSE;
        gboolean b_ims_checker = FALSE;
+       gboolean b_allowed_on_data_off = FALSE;
 
-       struct tnoti_ps_call_status *cstatus = NULL;
-#ifdef PREPAID_SIM_APN_SUPPORT
-       Storage *strg_vconf = NULL;
-       TcorePlugin *plg;
-       ps_context_t *context = NULL;
-#endif
+       struct tnoti_ps_call_status *cstatus = data;
 
-       dbg("ps call status event");
-       g_return_val_if_fail(ps_service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
+       g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
 
-       co_network = _ps_service_ref_co_network(ps_service);
-       cstatus = (struct tnoti_ps_call_status *) data;
-       co_ps = (CoreObject *)_ps_service_ref_co_ps(ps_service);
+       co_network = _ps_service_ref_co_network(service);
+       co_ps = _ps_service_ref_co_ps(service);
        if (co_ps != source) {
-               ps_warn_ex_co(co_network, "Received notification for different Subscription - neglecting the notification!!!");
+               ps_warn_ex_svc(service, "Received notification for different Subscription - neglecting the notification!!!");
                return TCORE_HOOK_RETURN_CONTINUE;
        }
 
-       modem = _ps_service_ref_modem(ps_service);
+       modem = _ps_service_ref_modem(service);
        if (!modem) {
-               ps_err_ex_co(co_network, "modem does not exist");
+               ps_err_ex_modem(modem, "modem does not exist");
                return TCORE_HOOK_RETURN_CONTINUE;
        }
 
@@ -1288,24 +177,28 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
                        b_ims_checker = TRUE;
                        break;
                }
+               if (role == CONTEXT_ROLE_BIP || role == CONTEXT_ROLE_FOTA) {
+                       b_allowed_on_data_off = TRUE;
+                       break;
+               }
        }
 
 #if !defined(TIZEN_SUPPORT_MMS_CONNECT_FORCE)
-               ps_dbg_ex_co(co_network, "csc runtime feature disabled");
+               ps_dbg_ex_modem(modem, "csc runtime feature disabled");
                b_mms_checker = FALSE;
 #endif
 
        if (!b_ims_checker && (_ps_modem_get_roaming(modem)) && !(_ps_modem_get_data_roaming_allowed(modem))) {
-               ps_info_ex_co(co_network, "roaming network is not allowed");
+               ps_info_ex_modem(modem, "roaming network is not allowed");
                b_roaming_checker = FALSE;
        }
 
-       ps_info_ex_co(co_network, "data_allowed(%d) call status event cid(%d) state(%d) reason(%d)",
-                       b_data_allowed, cstatus->context_id, cstatus->state, cstatus->result);
+       ps_info_ex_modem(modem, "data_allowed(%d) call status event cid(%d) state(%d) reason(%d)",
+                        b_data_allowed, cstatus->context_id, cstatus->state, cstatus->result);
 
-       if (!b_roaming_checker || (!b_data_allowed && !b_mms_checker && !b_ims_checker)) {
-               ps_dbg_ex_co(co_network, "mismatched: roaming checker(%d) data_allowed(%d) mms_checker(%d) b_ims_checker(%d)",
-                        b_roaming_checker, b_data_allowed, b_mms_checker, b_ims_checker);
+       if (!b_roaming_checker || (!b_data_allowed && !b_mms_checker && !b_ims_checker && !b_allowed_on_data_off)) {
+               ps_dbg_ex_modem(modem, "mismatched: roaming checker(%d) data_allowed(%d) mms_checker(%d) b_ims_checker(%d)",
+                               b_roaming_checker, b_data_allowed, b_mms_checker, b_ims_checker);
 
                if (cstatus->state == PS_CALL_STATE_RESULT_OK) {
                        /*
@@ -1314,131 +207,139 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
                         * although define process is triggered, 'attach_apn_complete' flag does not set TRUE.
                         * So, when Data Roaming option is enabled, pdp activation is not triggered.
                         */
-                       if (((ps_service_t *)ps_service)->attach_apn_complete) {
-                               _ps_service_set_connected(ps_service, cstatus, FALSE);
+                       if (service->attach_apn_complete) {
+                               _ps_service_set_connected(service, cstatus, FALSE);
                                tcore_ps_set_cid_active(co_ps, cstatus->context_id, FALSE);
                        } else {
-                               _ps_service_set_ps_defined(ps_service, TRUE, cstatus->context_id);
+                               _ps_service_set_ps_defined(service, TRUE, cstatus->context_id);
                        }
                        return TCORE_HOOK_RETURN_CONTINUE;
                } else if (cstatus->state == PS_CALL_STATE_RESULT_CONNECT) {
-                       _ps_service_set_connected(ps_service, cstatus, TRUE);
-                       _ps_service_disconnect_contexts(ps_service);
+                       _ps_service_set_connected(service, cstatus, TRUE);
+                       _ps_service_disconnect_contexts(service);
                        return TCORE_HOOK_RETURN_CONTINUE;
                }
        }
 
-       ps_dbg_ex_co(co_network, "service(%p) status(%d)", ps_service, cstatus->state);
-       if (cstatus->state == PS_CALL_STATE_RESULT_OK) {                /* DEFINE */
-               _ps_service_set_ps_defined(ps_service, TRUE, cstatus->context_id);
-       } else if (cstatus->state == PS_CALL_STATE_RESULT_CONNECT) {    /* CONNECTED */
+       ps_dbg_ex_modem(modem, "service(%p) status(%d)", service, cstatus->state);
+       if (cstatus->state == PS_CALL_STATE_RESULT_OK) {                /* DEFINE */
+               _ps_service_set_ps_defined(service, TRUE, cstatus->context_id);
+       } else if (cstatus->state == PS_CALL_STATE_RESULT_CONNECT) {    /* CONNECTED */
                TReturn rv;
 
                if (tcore_ps_get_cid_active(co_ps, cstatus->context_id) == FALSE) {
-                       ps_dbg_ex_co(co_network, "DDS scenario");
+                       ps_dbg_ex_modem(modem, "DDS scenario");
 
                        /* De-activate context */
                        rv = tcore_ps_deactivate_contexts(co_ps);
                        if (rv != TCORE_RETURN_SUCCESS) {
-                               ps_err_ex_co(co_network, "fail to deactivation");
+                               ps_err_ex_modem(modem, "fail to deactivation");
                                return TCORE_HOOK_RETURN_CONTINUE;
                        }
                } else {
                        gboolean ret = TRUE;
+                       gboolean need_deactivate = FALSE;
 
-                       ret = _ps_service_set_connected(ps_service, cstatus, TRUE);
+                       ret = _ps_service_set_connected(service, cstatus, TRUE);
                        tcore_ps_set_cid_connected(co_ps, cstatus->context_id, TRUE);
+
+                       if (ret == FALSE || (_ps_modem_get_reset_profile(modem) == TRUE))
+                               need_deactivate = TRUE;
+
 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-                       if (ret == FALSE || g_queue_get_length((GQueue *)_ps_modem_ref_work_queue(modem)) || (_ps_modem_get_reset_profile(modem) == TRUE)) {
-#else
-                       if (ret == FALSE || (_ps_modem_get_reset_profile(modem) == TRUE)) {
+                       if (g_queue_get_length(_ps_hook_ref_work_queue(modem)))
+                               need_deactivate = TRUE;
 #endif
-                               ps_info_ex_co(co_network, "Special request present in queue or pending activation request");
 
+                       if (need_deactivate) {
+                               ps_info_ex_modem(modem, "Special request present in queue or pending activation request");
 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-                               if (ps_util_peek_waiting_job((GQueue *)_ps_modem_ref_work_queue(modem), TREQ_NETWORK_SEARCH) ||
-                                       ps_util_peek_waiting_job((GQueue *)_ps_modem_ref_work_queue(modem), TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH) ||
-                                       ps_util_peek_waiting_job((GQueue *)_ps_modem_ref_work_queue(modem),  TREQ_NETWORK_SET_PLMN_SELECTION_MODE)) {
+                               if (ps_util_peek_waiting_job(_ps_hook_ref_work_queue(modem), TREQ_NETWORK_SEARCH) ||
+                                   ps_util_peek_waiting_job(_ps_hook_ref_work_queue(modem), TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH) ||
+                                   ps_util_peek_waiting_job(_ps_hook_ref_work_queue(modem), TREQ_NETWORK_SET_PLMN_SELECTION_MODE)) {
                                        GHashTableIter iter;
-                                       gpointer key, service;
+                                       gpointer key, tmp_service;
 
-                                       ps_info_ex_co(co_network, "Network search/selection/cancel searchrequest is in queue");
+                                       ps_info_ex_modem(modem, "Network search/selection/cancel searchrequest is in queue");
                                        g_hash_table_iter_init(&iter, modem->services);
-                                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE)
-                                               _ps_service_disconnect_internet_mms_tethering_contexts(service);
+                                       while (g_hash_table_iter_next(&iter, &key, &tmp_service) == TRUE)
+                                               _ps_service_disconnect_internet_mms_tethering_contexts(tmp_service);
                                } else
 #endif
                                {
                                        rv = tcore_ps_deactivate_contexts(co_ps);
                                        if (rv != TCORE_RETURN_SUCCESS) {
-                                               ps_dbg_ex_co(co_network, "fail to deactivation");
+                                               ps_dbg_ex_modem(modem, "fail to deactivation");
                                                return TCORE_HOOK_RETURN_CONTINUE;
                                        }
                                }
                        }
                }
-       } else if (cstatus->state == PS_CALL_STATE_RESULT_NO_CARRIER) { /* DISCONNECTED-NO CARRIER */
-               gpointer def_context = NULL;
-               unsigned char def_cid = 0;
+       } else if (cstatus->state == PS_CALL_STATE_RESULT_NO_CARRIER) { /* DISCONNECTED-NO CARRIER */
+               ps_context_t *def_context = NULL, *ims_context = NULL;
+               unsigned char def_cid = 0, ims_cid = 0;
                int value = 0;
                gboolean retry = TRUE;
-
 #ifdef PREPAID_SIM_APN_SUPPORT
                unsigned char prepaid_cid = 0;
-               gpointer prepaid_def_context = NULL;
-               TReturn rv = 0;
+               ps_context_t *prepaid_def_context = NULL;
 #endif
 
-               retry = __ps_check_pdp_permanent_reject_cause(cstatus->result);
+               retry = ps_util_check_permanent_reject_cause(cstatus->result, _ps_modem_get_roaming(modem));
                /* if retry not permitted by network */
                if (FALSE == retry) {
-                       ps_dbg_ex_co(co_network, "DO NOT RETRY NETWORK CONNECTION AUTOMATICALLY");
-                       ps_info_ex_co(co_network, "permanent reject cause (%d)", cstatus->result);
+                       ps_dbg_ex_modem(modem, "DO NOT RETRY NETWORK CONNECTION AUTOMATICALLY");
+                       ps_info_ex_modem(modem, "permanent reject cause (%d), roaming(%d)", cstatus->result, _ps_modem_get_roaming(modem));
 
-                       def_context = _ps_service_return_default_context(ps_service, CONTEXT_ROLE_INTERNET);
+                       def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
                        if (def_context) {
-                               gpointer co_context = NULL;
-                               co_context = _ps_context_ref_co_context(def_context);
+                               CoreObject *co_context = _ps_context_ref_co_context(def_context);
                                def_cid = tcore_context_get_id(co_context);
                        }
+
+                       ims_context = _ps_service_return_default_context(service, CONTEXT_ROLE_IMS);
+                       if (ims_context) {
+                               CoreObject *co_context = _ps_context_ref_co_context(ims_context);
+                               ims_cid = tcore_context_get_id(co_context);
+                       }
                }
 
 #ifdef PREPAID_SIM_APN_SUPPORT
                if (def_context == NULL) {
-                       def_context = _ps_service_return_default_context(ps_service, CONTEXT_ROLE_INTERNET);
+                       def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
                        if (def_context) {
-                               gpointer co_context = NULL;
+                               CoreObject *co_context = NULL;
                                co_context = _ps_context_ref_co_context(def_context);
                                def_cid = tcore_context_get_id(co_context);
                        }
                }
 
-               prepaid_def_context = _ps_service_return_default_context(ps_service, CONTEXT_ROLE_PREPAID_INTERNET);
-               dbg("prepaid_def_context[%p]", prepaid_def_context);
+               prepaid_def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_PREPAID_INTERNET);
+               ps_dbg_ex_modem(modem, "prepaid_def_context[%p]", prepaid_def_context);
                if (prepaid_def_context) {
-                       gpointer co_context = NULL;
+                       CoreObject *co_context = NULL;
                        co_context = _ps_context_ref_co_context(prepaid_def_context);
                        prepaid_cid = tcore_context_get_id(co_context);
                }
-               dbg("prepaid_cid[%d]", prepaid_cid);
+               ps_dbg_ex_modem(modem, "prepaid_cid[%d]", prepaid_cid);
 #endif
 
-               _ps_service_set_ps_defined(ps_service, FALSE, cstatus->context_id);
+               _ps_service_set_ps_defined(service, FALSE, cstatus->context_id);
                tcore_ps_set_cid_active(co_ps, cstatus->context_id, FALSE);
                tcore_ps_set_cid_connected(co_ps, cstatus->context_id, FALSE);
-               _ps_service_set_connected(ps_service, cstatus, FALSE);
+               _ps_service_set_connected(service, cstatus, FALSE);
 
                if (FALSE == tcore_ps_any_internet_mms_tethering_context_activating_activated(co_ps, &value)) {
-                       ps_dbg_ex_co(co_network, "No internet/mms/tethering open connections, publish disconnected signal");
+                       ps_dbg_ex_modem(modem, "No context open connections, publish disconnected signal");
 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
                        /* Handle any pending request if present */
-                       modem = _ps_service_ref_modem(ps_service);
-                       __ps_send_pending_user_request(modem);
+                       modem = _ps_service_ref_modem(service);
+                       _ps_hook_send_pending_user_request(modem);
 #endif
                        /* Ensured that set_reset_profile is always done default thread's context */
                        if (_ps_modem_get_reset_profile(modem) == TRUE) {
                                /* Initiate Reset Profile */
-                               ps_info_ex_co(co_network, "Profiles are being reset");
+                               ps_info_ex_modem(modem, "Profiles are being reset");
                                /* Shouldn't invoke set profile directly, as it will remove hooks registered to server while being hook callback*/
                                if (NULL == _ps_modem_get_profile_reset_gsource(modem)) {
                                        GSource *gsource = NULL;
@@ -1451,215 +352,217 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
 #ifdef PREPAID_SIM_APN_SUPPORT
                /* Has prepaid APN */
                if (prepaid_def_context) {
-                       ps_dbg_ex_co(co_network, "Context id: %d", cstatus->context_id);
-                       ps_dbg_ex_co(co_network, "retry: %s", retry ? "TRUE" : "FALSE");
+                       ps_master_t * master = NULL;
+                       ps_context_t *context = NULL;
+                       int rv = 0;
+
+                       ps_dbg_ex_modem(modem, "Context id: %d", cstatus->context_id);
+                       ps_dbg_ex_modem(modem, "retry: %s", retry ? "TRUE" : "FALSE");
 
                        if (cstatus->context_id == def_cid) {
-                               dbg("Resetting connection time for default context");
+                               ps_dbg_ex_modem(modem, "Resetting connection time for default context");
                                _ps_service_reset_connection_timer(def_context);
 
                                /* Connect to default prepaid internet */
-                               rv = _ps_service_connect_default_prepaid_context(ps_service);
-                               dbg("prepaid internet connect - rv[%d]", rv);
+                               rv = _ps_service_connect_default_prepaid_context(service);
+                               ps_dbg_ex_modem(modem, "prepaid internet connect - rv[%d]", rv);
                        } else if (cstatus->context_id == prepaid_cid) {
                                /* Reset connection */
-                               dbg("Resetting connection time for prepaid internet context");
+                               ps_dbg_ex_modem(modem, "Resetting connection time for prepaid internet context");
                                _ps_service_reset_connection_timer(prepaid_def_context);
 
                                /* Connect to default internet */
-                               rv =  _ps_service_connect_default_context(ps_service);
-                               dbg("default internet connect - rv[%d]", rv);
+                               rv =  _ps_service_connect_default_context(service);
+                               ps_dbg_ex_modem(modem, "default internet connect - rv[%d]", rv);
                        }
 
                        /* Reset Last connected, Profile ID and Operator vconf keys. */
-                       dbg("Reset vconf keys...");
-                       plg = _ps_service_ref_plugin(ps_service);
-                       strg_vconf = tcore_server_find_storage(tcore_plugin_ref_server(plg),
-                                                       "vconf");
-                       if (strg_vconf) {
-                               tcore_storage_set_string(strg_vconf,
-                                       STORAGE_KEY_TELEPHONY_LAST_CONNECTED_CONTEXT_PLMN, NULL);
-                               /* Get context*/
-                               context = _ps_service_return_context_by_cid(ps_service,
-                                                       cstatus->context_id);
-                               dbg("context[%p]", context);
-                               if (context) {
-                                       /*Set profile ID */
-                                       dbg("Reset profile id");
-                                       tcore_storage_set_int(strg_vconf,
-                                               STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID, -1);
-                                       /* set vconf last connected profile */
-                                       dbg("set vconf last connected profile to FALSE");
-                                       tcore_storage_set_bool(strg_vconf,
-                                               STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL, FALSE);
-                               }
+                       ps_dbg_ex_modem(modem, "Reset vconf keys...");
+                       master = _ps_modem_ref_master(modem);
+                       _ps_master_set_storage_value_string(master, STORAGE_KEY_TELEPHONY_LAST_CONNECTED_CONTEXT_PLMN, NULL);
+                       /* Get context*/
+                       context = _ps_service_return_context_by_cid(service, cstatus->context_id);
+                       ps_dbg_ex_modem(modem, "context[%p]", context);
+                       if (context) {
+                               /* Set profile ID */
+                               ps_dbg_ex_modem(modem, "Reset profile id");
+                               _ps_master_set_storage_value_int(master, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID, -1);
+                               /* set vconf last connected profile */
+                               ps_dbg_ex_modem(modem, "set vconf last connected profile to FALSE");
+                               _ps_master_set_storage_value_bool(master, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL, FALSE);
                        }
                }
 #endif
 
-               ps_info_ex_co(co_network, "Internet/mms/tethering context activating or activated [%d]", value);
-               if (FALSE == retry)
-                       if (cstatus->context_id == def_cid)
+               ps_info_ex_modem(modem, "Any context activating or activated [%d]", value);
+               if (FALSE == retry) {
+                       if (cstatus->context_id == def_cid) {
                                _ps_service_reset_connection_timer(def_context);
+                               _ps_context_set_alwayson_enable(def_context, FALSE);
+                       } else if (cstatus->context_id == ims_cid) {
+                               _ps_service_reset_connection_timer(ims_context);
+                               _ps_context_set_alwayson_enable(ims_context, FALSE);
+                       }
+               }
        } /* disconnected case */
 
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 
-static enum tcore_hook_return __on_hook_call_status_0(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
+#if 0 // TODO: libtcore need to be updated
+static enum tcore_hook_return __on_hook_gprs_backoff_timer(Server *s, CoreObject *source,
+                                                          enum tcore_notification_command command, unsigned int data_len, void *data,
+                                                          void *user_data)
 {
-       return __on_hook_call_status(s, source, command, data_len, data, user_data);
-}
+       ps_service_t *service = user_data;
+       CoreObject *co_context = NULL;
+       CoreObject *co_ps = NULL;
+       struct tnoti_ps_backoff_timer *backoff = data;
+       unsigned int retryArray[] = { 0, };
 
-static enum tcore_hook_return __on_hook_call_status_1(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_call_status(s, source, command, data_len, data, user_data);
-}
+       g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
 
+       co_ps = _ps_service_ref_co_ps(service);
+       if (co_ps != source)
+               return TCORE_HOOK_RETURN_CONTINUE;
 
-static enum tcore_hook_return __on_hook_session_data_counter_0(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       gpointer service = user_data;
-       g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
+       ps_dbg_ex_svc(service, "cid(%d) apn(%s) result(%d) retry_time(%d)", backoff->context_id, backoff->apn, backoff->result, backoff->retry_time);
+       if (!strlen(backoff->apn)) {
+               ps_warn_ex_svc(service, "Invalid APN");
+               return TCORE_HOOK_RETURN_CONTINUE;
+       }
+
+       co_context = tcore_ps_ref_context_by_apn(co_ps, backoff->apn);
+       if (!co_context) {
+               ps_warn_ex_svc(service, "Couldn't find matched context from apn(%s)", backoff->apn);
+               return TCORE_HOOK_RETURN_CONTINUE;
+       }
+
+       if (backoff->retry_time != 0xFFFFFFFF && backoff->retry_time > 0) {
+               if (backoff->retry_time > 72 * 60 * 60)
+                       backoff->retry_time = 72 * 60 * 60;
+
+               ps_info_ex_svc(service, "retry_time(%d) was set", backoff->retry_time);
+               retryArray[0] = backoff->retry_time;
+               tcore_context_set_max_retry_count(co_context, 1);
+               tcore_context_set_retry_timer_array(co_context, retryArray, 1);
+       }
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "session data counter event");
+       if (backoff->result == PS_PDP_REJ_TIMER_T3396_DEACTIVATED) {
+               ps_info_ex_svc(service, "T3396_DEACTIVATED, PDN.apn(%s)", backoff->apn);
+               tcore_context_set_throttled_apn(co_context, TRUE);
+       } else if (backoff->result == PS_PDP_REJ_TIMER_T3396_STOPPED) {
+               ps_err_ex_svc(service, "T3396_STOPPED, PDN.apn(%s)", backoff->apn);
+               tcore_context_set_throttled_apn(co_context, FALSE);
+               _ps_service_connect_default_context(service);
+       }
 
        return TCORE_HOOK_RETURN_CONTINUE;
 }
+#endif
 
-static enum tcore_hook_return __on_hook_session_data_counter_1(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
+#if 0 // TODO: libtcore need to be updated
+static enum tcore_hook_return __on_hook_gprs_nas_timer(Server *s, CoreObject *source,
+                                                      enum tcore_notification_command command, unsigned int data_len, void *data,
+                                                      void *user_data)
 {
-       gpointer service = user_data;
+       ps_service_t *service = user_data;
+       struct tnoti_ps_nas_timer *nas_timer = data;
+
        g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "session data counter event");
+       if (nas_timer->timer_type == 0x01) { /*T3346*/
+               if (nas_timer->timer_status == PS_NAS_TIMER_STATE_START) {
+                       ps_info_ex_svc(service, "T3346 START(%d)", nas_timer->timer_status);
+                       _ps_service_handling_nas_timer(service, nas_timer->timer_status);
+               } else if (nas_timer->timer_status == PS_NAS_TIMER_STATE_STOP
+                               || nas_timer->timer_status == PS_NAS_TIMER_STATE_EXPIRE) {
+                       ps_info_ex_svc(service, "T3346 STOP(%d)", nas_timer->timer_status);
+                       _ps_service_handling_nas_timer(service, nas_timer->timer_status);
+               }
+       }
 
        return TCORE_HOOK_RETURN_CONTINUE;
 }
+#endif
 
 static enum tcore_hook_return __on_hook_dedicated_bearerinfo(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
+                                                            enum tcore_notification_command command, unsigned int data_len, void *data,
+                                                            void *user_data)
 {
-       gpointer service = user_data;
+       ps_service_t *service = user_data;
        CoreObject *co_ps = NULL;
-       struct tnoti_ps_dedicated_bearer_info *bearer_info = NULL;
+       struct tnoti_ps_dedicated_bearer_info *bearer_info = data;
 
        g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_CONTINUE);
 
-       bearer_info = (struct tnoti_ps_dedicated_bearer_info *) data;
-       co_ps = (CoreObject *)_ps_service_ref_co_ps(service);
-       if (co_ps != source) {
-               ps_warn_ex_co(co_ps, "Received notification for different Subscription - neglecting the notification!!!");
+       co_ps = _ps_service_ref_co_ps(service);
+       if (co_ps != source)
                return TCORE_HOOK_RETURN_CONTINUE;
-       }
 
        _ps_service_set_context_bearerinfo(service, bearer_info);
-
-       ps_info_ex_co(co_ps, "dedicated bearer information event");
+       ps_info_ex_svc(service, "dedicated bearer information event");
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 
-static enum tcore_hook_return __on_hook_dedicated_bearerinfo_0(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_dedicated_bearerinfo(s, source, command, data_len, data, user_data);
-}
-
-static enum tcore_hook_return __on_hook_dedicated_bearerinfo_1(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_dedicated_bearerinfo(s, source, command, data_len, data, user_data);
-}
-
 static enum tcore_hook_return __on_hook_default_data_subscription(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
+                                                                 enum tcore_notification_command command, unsigned int data_len, void *data,
+                                                                 void *user_data)
 {
-       gpointer service = user_data;
+       ps_service_t *service = user_data;
        const struct tnoti_network_default_data_subs *default_data_subs_info = data;
 
        if (default_data_subs_info->default_subs != (enum telephony_network_default_data_subs)tcore_object_ref_subscription_type(_ps_service_ref_co_ps(service)))
                return TCORE_HOOK_RETURN_CONTINUE;
 
-       ps_info_ex_co(_ps_service_ref_co_network(service), "'default' data subscription information event");
+       ps_info_ex_svc(service, "'default' data subscription information event");
        _ps_service_connect_default_context(service);
 
        return TCORE_HOOK_RETURN_CONTINUE;
 }
-
-static enum tcore_hook_return __on_hook_default_data_subscription_0(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_default_data_subscription(s, source, command, data_len, data, user_data);
-}
-
-static enum tcore_hook_return __on_hook_default_data_subscription_1(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_default_data_subscription(s, source, command, data_len, data, user_data);
-}
-
 static enum tcore_hook_return __on_hook_epdg_status(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
+                                                   enum tcore_notification_command command, unsigned int data_len, void *data,
+                                                   void *user_data)
 {
-       gpointer service = user_data;
+       ps_service_t *service = user_data;
        const struct tnoti_network_epdg_status *noti = (const struct tnoti_network_epdg_status *)data;
        gboolean available = FALSE;
-       gboolean restart_connection = FALSE;
-       CoreObject *co_network = _ps_service_ref_co_network(service);
-
-       if (noti) {
-               if ((noti->status == NETWORK_EPDG_STATUS_AVAILABLE) ||
-                               (noti->status == NETWORK_EPDG_STATUS_CONNECTED) ||
-                               (noti->status == NETWORK_EPDG_STATUS_HO_LTE_TO_IWLAN)) {
-                       available = TRUE;
-               } else if (noti->status == NETWORK_EPDG_STATUS_UNAVAILABLE) {
-                       restart_connection = TRUE;
-               }
-       }
 
-       ps_info_ex_co(co_network, "ePDG: [%s]", ((available == TRUE) ? "AVAILABLE" : "UNAVAILABLE"));
+       g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_CONTINUE);
+       g_return_val_if_fail(noti != NULL, TCORE_HOOK_RETURN_CONTINUE);
+
+       if ((noti->status == NETWORK_EPDG_STATUS_AVAILABLE) ||
+               (noti->status == NETWORK_EPDG_STATUS_CONNECTED) ||
+               (noti->status == NETWORK_EPDG_STATUS_HO_LTE_TO_IWLAN)) {
+               available = TRUE;
+       }
 
+       ps_info_ex_svc(service, "ePDG: [%s]", ((available == TRUE) ? "AVAILABLE" : "UNAVAILABLE"));
        _ps_service_set_epdg_status(service, available);
 
+       if (noti->status == NETWORK_EPDG_STATUS_HO_LTE_TO_IWLAN)
+               _ps_service_set_epdg_ip_configuration(service, noti->cid, noti->ipv4_address, noti->ipv6_address);
        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)
+                                                       enum tcore_notification_command command, unsigned int data_len, void *data,
+                                                       void *user_data)
 {
-       gpointer service = user_data;
+       ps_service_t *service = user_data;
        CoreObject *co_ps = NULL;
-       CoreObject *co_network = NULL;
-       struct tnoti_ps_pdp_ipconfiguration *devinfo = NULL;
+       struct tnoti_ps_pdp_ipconfiguration *devinfo = data;
        char ipv4[16], ipv4_dns_1[16], ipv4_dns_2[16];
 
        g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
 
-       co_network = _ps_service_ref_co_network(service);
-       devinfo = (struct tnoti_ps_pdp_ipconfiguration *) data;
-       co_ps = (CoreObject *)_ps_service_ref_co_ps(service);
+       co_ps = _ps_service_ref_co_ps(service);
        if (co_ps != source) {
-               ps_warn_ex_co(co_network, "Received notification for different Subscription - neglecting the notification!!!");
+               ps_warn_ex_svc(service, "Received notification for different Subscription - neglecting the notification!!!");
                return TCORE_HOOK_RETURN_CONTINUE;
        }
 
-       ps_info_ex_co(co_network, "ip configuration event");
+       ps_info_ex_svc(service, "ip configuration event");
 
        /*
         * In case IPv4 address is available and DNS address
@@ -1668,14 +571,14 @@ static enum tcore_hook_return __on_hook_ipconfiguration(Server *s, CoreObject *s
         * DNS 2 - Open DNS
         */
        snprintf(ipv4, 16, "%d.%d.%d.%d",
-               devinfo->ip_address[0], devinfo->ip_address[1],
-               devinfo->ip_address[2], devinfo->ip_address[3]);
+                devinfo->ip_address[0], devinfo->ip_address[1],
+                devinfo->ip_address[2], devinfo->ip_address[3]);
        if (!g_str_equal(ipv4, "0.0.0.0")) {
                snprintf(ipv4_dns_1, 16, "%d.%d.%d.%d",
-                       devinfo->primary_dns[0], devinfo->primary_dns[1],
-                       devinfo->primary_dns[2], devinfo->primary_dns[3]);
+                        devinfo->primary_dns[0], devinfo->primary_dns[1],
+                        devinfo->primary_dns[2], devinfo->primary_dns[3]);
                if (g_str_equal(ipv4_dns_1, "0.0.0.0")) {
-                       ps_err_ex_co(co_network, "[IPV4]primary dns address is 0");
+                       ps_err_ex_svc(service, "[IPV4]primary dns address is 0");
 
                        /* google dns 1st */
                        devinfo->primary_dns[0] = 8;
@@ -1685,11 +588,11 @@ static enum tcore_hook_return __on_hook_ipconfiguration(Server *s, CoreObject *s
                }
 
                snprintf(ipv4_dns_2, 16, "%d.%d.%d.%d",
-                       devinfo->secondary_dns[0], devinfo->secondary_dns[1],
-                       devinfo->secondary_dns[2], devinfo->secondary_dns[3]);
+                        devinfo->secondary_dns[0], devinfo->secondary_dns[1],
+                        devinfo->secondary_dns[2], devinfo->secondary_dns[3]);
                if (g_str_equal(ipv4_dns_2, "0.0.0.0")) {
                        /* open dns 2nd */
-                       ps_err_ex_co(co_network, "[IPV4]secondary dns address is 0");
+                       ps_err_ex_svc(service, "[IPV4]secondary dns address is 0");
                        devinfo->secondary_dns[0] = 208;
                        devinfo->secondary_dns[1] = 67;
                        devinfo->secondary_dns[2] = 222;
@@ -1705,12 +608,12 @@ static enum tcore_hook_return __on_hook_ipconfiguration(Server *s, CoreObject *s
         */
        if (devinfo->ipv6_address != NULL) {
                if (devinfo->ipv6_primary_dns == NULL) {
-                       ps_err_ex_co(co_network, "[IPV6]primary dns address is 0");
+                       ps_err_ex_svc(service, "[IPV6]primary dns address is 0");
                        devinfo->ipv6_primary_dns = g_strdup("2001:4860:4860::8888");
 
                }
                if (devinfo->ipv6_secondary_dns == NULL) {
-                       ps_err_ex_co(co_network, "[IPV6]secondary dns address is 0");
+                       ps_err_ex_svc(service, "[IPV6]secondary dns address is 0");
                        devinfo->ipv6_secondary_dns = g_strdup("2620:0:ccc::2");
                }
        }
@@ -1720,60 +623,45 @@ static enum tcore_hook_return __on_hook_ipconfiguration(Server *s, CoreObject *s
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 
-
-static enum tcore_hook_return __on_hook_ipconfiguration_0(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_ipconfiguration(s, source, command, data_len, data, user_data);
-}
-
-static enum tcore_hook_return __on_hook_ipconfiguration_1(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_ipconfiguration(s, source, command, data_len, data, user_data);
-}
-
 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)
+                                               enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
 {
-       gpointer modem = user_data;
+       ps_modem_t *modem = user_data;
        CoreObject *co_modem;
-       struct tnoti_modem_power *modem_power = NULL;
-       int  power = PS_MODEM_STATE_UNKNOWN;
+       struct tnoti_modem_power *modem_power = data;
+       int power = PS_MODEM_STATE_UNKNOWN;
 
        CORE_OBJECT_CHECK_RETURN(source, CORE_OBJECT_TYPE_MODEM, TCORE_HOOK_RETURN_CONTINUE);
 
        g_return_val_if_fail(modem != NULL, TCORE_HOOK_RETURN_CONTINUE);
+       g_return_val_if_fail(modem_power != NULL, TCORE_HOOK_RETURN_CONTINUE);
+
        co_modem = _ps_modem_ref_co_modem(modem);
        if (co_modem != source) {
-               ps_dbg_ex_co(co_modem, "Notification for other modem!");
+               ps_dbg_ex_modem(modem, "Notification for other modem!");
                return TCORE_HOOK_RETURN_CONTINUE;
        }
 
-       modem_power = (struct tnoti_modem_power *)data;
-       g_return_val_if_fail(modem_power != NULL, TCORE_HOOK_RETURN_CONTINUE);
-       ps_info_ex_co(co_modem, "powered event called: state [%d]", modem_power->state);
+       ps_info_ex_modem(modem, "powered event called: state [%d]", modem_power->state);
 
        switch (modem_power->state) {
        case MODEM_STATE_ONLINE:
                power = PS_MODEM_STATE_ONLINE;
-       break;
+               break;
 
        case MODEM_STATE_LOW:
                power = PS_MODEM_STATE_LOW;
-       break;
+               break;
 
        case MODEM_STATE_ERROR:
        case MODEM_STATE_RESET:
                /* Reset hook flag in any present */
                __ps_modem_cp_reset_handler(modem);
-       break;
+               break;
 
        default:
-               ps_warn_ex_co(co_modem, "Unhandled modem power event.");
-       break;
+               ps_warn_ex_modem(modem, "Unhandled modem power event.");
+               break;
        }
 
        if (power != PS_MODEM_STATE_UNKNOWN)
@@ -1782,63 +670,35 @@ static enum tcore_hook_return __on_hook_powered(Server *s, CoreObject *source,
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 
-
-static enum tcore_hook_return __on_hook_powered_0(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
-       return __on_hook_powered(s, source, command, data_len, data, user_data);
-}
-
-static enum tcore_hook_return __on_hook_powered_1(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
-       return __on_hook_powered(s, source, command, data_len, data, user_data);
-}
-
 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)
+                                              enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
 {
-       gpointer modem = user_data;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
-       struct tnoti_modem_flight_mode *modem_flight = NULL;
+       ps_modem_t *modem = user_data;
+       struct tnoti_modem_flight_mode *modem_flight = data;
 
        g_return_val_if_fail(modem != NULL, TCORE_HOOK_RETURN_CONTINUE);
-       ps_info_ex_co(co_modem, "flight mode event called");
+       ps_info_ex_modem(modem, "flight mode event called");
 
-       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_flight_0(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
-       return __on_hook_flight(s, source, command, data_len, data, user_data);
-}
-
-static enum tcore_hook_return __on_hook_flight_1(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
-       return __on_hook_flight(s, source, command, data_len, data, user_data);
-}
-
 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)
+                                                    enum tcore_notification_command command, unsigned int data_len, void *data,
+                                                    void *user_data)
 {
-       gpointer service = user_data;
+       ps_service_t *service = user_data;
        gboolean ps_attached = FALSE;
-       struct tnoti_network_registration_status *regist_status;
+       struct tnoti_network_registration_status *regist_status = data;
        CoreObject *co_network;
 
        g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_CONTINUE);
 
-       co_network = (CoreObject *)_ps_service_ref_co_network(service);
+       co_network = _ps_service_ref_co_network(service);
        if (co_network != source)
                return TCORE_HOOK_RETURN_CONTINUE;
 
-       regist_status = (struct tnoti_network_registration_status *) data;
        if (regist_status->ps_domain_status == NETWORK_SERVICE_DOMAIN_STATUS_FULL)
                ps_attached = TRUE;
 
@@ -1848,127 +708,81 @@ static enum tcore_hook_return __on_hook_net_register(Server *s, CoreObject *sour
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 
-static enum tcore_hook_return __on_hook_net_register_0(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_net_register(s, source, command, data_len, data, user_data);
-}
-
-static enum tcore_hook_return __on_hook_net_register_1(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_net_register(s, source, command, data_len, data, user_data);
-}
-
 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)
+                                                  enum tcore_notification_command command, unsigned int data_len, void *data,
+                                                  void *user_data)
 {
-       gpointer service = user_data;
-       struct tnoti_network_change *network_change;
+       ps_service_t *service = user_data;
+       struct tnoti_network_change *network_change = data;
        CoreObject *co_network;
 
        g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_CONTINUE);
 
-       co_network = (CoreObject *)_ps_service_ref_co_network(service);
+       co_network = _ps_service_ref_co_network(service);
        if (co_network != source)
                return TCORE_HOOK_RETURN_CONTINUE;
 
-       network_change = (struct tnoti_network_change *) data;
-       ps_dbg_ex_co(co_network, "plmn(%s) act(%d)", network_change->plmn, network_change->act);
+       ps_dbg_ex_svc(service, "plmn(%s) act(%d)", network_change->plmn, network_change->act);
        _ps_service_set_access_technology(service, network_change->act);
 
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 
-static enum tcore_hook_return __on_hook_net_change_0(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_net_change(s, source, command, data_len, data, user_data);
-}
-
-static enum tcore_hook_return __on_hook_net_change_1(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_net_change(s, source, command, data_len, data, user_data);
-}
-
 static enum tcore_hook_return __on_hook_net_restricted_state(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
+                                                            enum tcore_notification_command command, unsigned int data_len, void *data,
+                                                            void *user_data)
 {
-       gpointer service = user_data;
-       struct tnoti_network_restricted_state *network_restricted;
+       ps_service_t *service = user_data;
+       struct tnoti_network_restricted_state *network_restricted = data;
        CoreObject *co_network;
 
        g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_CONTINUE);
 
-       co_network = (CoreObject *)_ps_service_ref_co_network(service);
+       co_network = _ps_service_ref_co_network(service);
        if (co_network != source)
                return TCORE_HOOK_RETURN_CONTINUE;
 
-       network_restricted = (struct tnoti_network_restricted_state *) data;
-       ps_dbg_ex_co(co_network, "network restricted state(%d)", network_restricted->restricted_state);
-
+       ps_dbg_ex_svc(service, "network restricted state(%d)", network_restricted->restricted_state);
        _ps_service_set_restricted(service, ((network_restricted->restricted_state & NETWORK_RESTRICTED_STATE_PS_ALL) ? TRUE : FALSE));
 
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 
-static enum tcore_hook_return __on_hook_net_restricted_state_0(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_net_restricted_state(s, source, command, data_len, data, user_data);
-}
-
-
-static enum tcore_hook_return __on_hook_net_restricted_state_1(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data,
-               void *user_data)
-{
-       return __on_hook_net_restricted_state(s, source, command, data_len, data, user_data);
-}
-
 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)
+                                                enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
 {
-       struct tnoti_sim_status *sim_data;
+       struct tnoti_sim_status *sim_data = data;
        ps_modem_t *modem = user_data;
-       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
-       gchar *cp_name, *source_cp_name;
+       const gchar *cp_name, *source_cp_name;
 
-       ps_info_ex_co(co_modem, "sim init event called");
+       ps_info_ex_modem(modem, "sim init event called");
 
-       g_return_val_if_fail(user_data != NULL, TCORE_HOOK_RETURN_CONTINUE);
+       g_return_val_if_fail(modem != NULL, TCORE_HOOK_RETURN_CONTINUE);
 
        cp_name = _ps_modem_ref_cp_name(modem);
-       source_cp_name = (gchar *)tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source));
+       source_cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source));
        if (g_strcmp0(cp_name, source_cp_name) != 0) {
-               ps_dbg_ex_co(co_modem, "Received notification for different Subscription - neglecting the notification!!!");
+               ps_dbg_ex_modem(modem, "Received notification for different Subscription - neglecting the notification!!!");
                return TCORE_HOOK_RETURN_CONTINUE;
        }
 
-       sim_data = (struct tnoti_sim_status *)data;
-       ps_info_ex_co(co_modem, "sim status is (%d)", sim_data->sim_status);
+       ps_info_ex_modem(modem, "sim status is (%d)", sim_data->sim_status);
 
        switch (sim_data->sim_status) {
+       case SIM_STATUS_INITIALIZING:
+               break;
+
        case SIM_STATUS_INIT_COMPLETED: {
                struct tel_sim_imsi *sim_imsi = NULL;
                enum tel_sim_type sim_type = SIM_TYPE_UNKNOWN;
                sim_type = tcore_sim_get_type(source);
 
                if (sim_type == SIM_TYPE_NVSIM) {
-                       ps_info_ex_co(co_modem, "initial boot from CDMA network.");
-                       _ps_modem_processing_sim_complete((gpointer)user_data, TRUE, PS_CDMA_DUMMY_PROFILE_PLMN);
+                       ps_info_ex_modem(modem, "initial boot from CDMA network.");
+                       _ps_modem_processing_sim_complete(modem, TRUE, PS_CDMA_DUMMY_PROFILE_PLMN);
                } else {
                        sim_imsi = tcore_sim_get_imsi(source);
-                       _ps_modem_processing_sim_complete((gpointer)user_data, TRUE, (gchar *)sim_imsi->plmn);
-
+                       _ps_modem_processing_sim_complete(modem, TRUE, sim_imsi->plmn);
                        g_free(sim_imsi);
                }
        }
@@ -1979,218 +793,43 @@ static enum tcore_hook_return __on_hook_sim_init(Server *s, CoreObject *source,
        case SIM_STATUS_CARD_CRASHED: /* FALLTHROUGH */
        case SIM_STATUS_CARD_POWEROFF:
                /* Set SIM complete FALSE, operator is not required */
-               _ps_modem_processing_sim_complete((gpointer)user_data, FALSE, NULL);
+               _ps_modem_processing_sim_complete(modem, FALSE, NULL);
+               _ps_modem_processing_no_sim(modem);
+               break;
 
-               /* TODO: Handle CDMA specific case */
-       break;
+       case SIM_STATUS_CARD_NOT_PRESENT:
+               _ps_modem_processing_no_sim(modem);
+               break;
 
        default:
-               ps_dbg_ex_co(co_modem,  "Unhandled SIM state: [%d]", sim_data->sim_status);
-       break;
+               ps_dbg_ex_modem(modem, "Unhandled SIM state: [%d]", sim_data->sim_status);
+               _ps_modem_processing_no_sim(modem);
+               break;
        }
 
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-static gboolean __ps_is_any_call_in_progress(TcorePlugin *plugin, __ps_call_flow_type type, enum tcore_notification_command command)
-{
-       CoreObject *co_call = 0;
-       int total_call_cnt = 0;
-
-       gboolean call_in_progress = FALSE;
-
-       co_call = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL);
-
-       total_call_cnt = tcore_call_object_total_length(co_call);
-       ps_info_ex_co(co_call, "totall call cnt (%d)", total_call_cnt);
-
-       if (((type == ON_REQUEST || type == ON_NON_CALL_NOTI_HOOK) && total_call_cnt !=  0)
-               || ((type == ON_CALL_NOTI_HOOK)
-               && ((command != TNOTI_CALL_STATUS_IDLE) || (total_call_cnt > 1))))      {
-               ps_info_ex_co(co_call, "call is still connected");
-               call_in_progress = TRUE;
-       } else {
-               ps_info_ex_co(co_call, "No call is in progress");
-       }
-
-       return call_in_progress;
-}
-
-
-/* Check for pending TREQ_MODEM_POWER_OFF request */
-void __ps_check_handle_modem_off_request(gpointer data, __ps_call_flow_type type, enum tcore_notification_command command)
+#if 0 // TODO: libtcore need to be updated
+static enum tcore_hook_return __on_hook_sim_refresh(Server *s, CoreObject *source,
+                                                   enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
 {
-       ps_modem_t *modem = data;
-
-       if (!modem)
-               return;
-
-       if (modem->hook_flag & PS_NETWORK_SET_POWER_LOW) {
-               UserRequest *ur = NULL;
-               ur = ps_util_pop_waiting_job(modem->work_queue, TREQ_MODEM_POWER_LOW);
-               if (ur) {
-                       gboolean call_in_progress;
-                       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "Sending Pending SET POWER LOW");
-
-                       /* Checking if any voice or MMS is in progress, if so, delay Modem power off.
-                          Need to hook on both voice call status and MMS profile de-activation.
-                       */
-                       call_in_progress = __ps_is_any_call_in_progress(tcore_object_ref_plugin(modem->co_modem), type, command);
-
-                       if (call_in_progress) {
-                               gboolean ret;
-                               /* add to the waiting queue and continue and wait till there is no call or MMS */
-                               ret = ps_util_add_waiting_job(modem->work_queue, TREQ_MODEM_POWER_LOW , ur);
-                               if (!ret) {
-                                       ps_err_ex_co(_ps_modem_ref_co_modem(modem), "fail to add the request to queue");
-                                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                                       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(modem->co_modem, ur)) {
-                                               __ps_send_ur_dispatch_failure_response(ur, TRESP_MODEM_POWER_LOW);
-                                               modem->hook_flag &= PS_NETWORK_RESET_SET_POWER_LOW_FLAG;
+       struct tnoti_sim_refresh_stage *sim_data = data;
+       ps_modem_t *modem = user_data;
 
-                                       }
-                               }
-                       } else {
-                               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                               if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(modem->co_modem, ur)) {
-                                       __ps_send_ur_dispatch_failure_response(ur, TRESP_MODEM_POWER_LOW);
-                                       modem->hook_flag &= PS_NETWORK_RESET_SET_POWER_LOW_FLAG;
-                               }
-                       }
-               }
-       } else {
-               ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "No pending TREQ_MODEM_POWER_LOW reqeust");
-       }
-}
+       ps_info_ex_modem(modem, "sim stage is (%d)", sim_data->stage);
 
-static enum tcore_hook_return __on_hook_voice_call_status(Server *s, CoreObject *co_call,
-               enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
-       __ps_check_handle_modem_off_request(user_data, ON_CALL_NOTI_HOOK, command);
+       if (sim_data->stage == SIM_REFRESH_START)
+               _ps_modem_processing_sim_refresh(modem);
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 #endif
-#endif
-
-static enum tcore_hook_return __on_hook_sim_init_0(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
-       return  __on_hook_sim_init(s, source, command,  data_len, data, user_data);
-}
-
-static enum tcore_hook_return __on_hook_sim_init_1(Server *s, CoreObject *source,
-               enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
-       return  __on_hook_sim_init(s, source, command,  data_len, data, user_data);
-}
-
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-void _ps_get_network_mode(gpointer data)
-{
-       UserRequest *ur = NULL;
-       ps_modem_t *modem =  data;
-       CoreObject *co_network = NULL;
-
-       co_network = tcore_plugin_ref_core_object(tcore_object_ref_plugin(modem->co_modem),
-                       CORE_OBJECT_TYPE_NETWORK);
-
-       ps_dbg_ex_co(co_network, "network get mode by data allowed option");
-
-       ur = tcore_user_request_new(NULL, NULL);
-       tcore_user_request_set_data(ur, 0, NULL);
-       tcore_user_request_set_command(ur, TREQ_NETWORK_GET_MODE);
-       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-
-       __ps_modem_set_hook_flag(modem, TREQ_NETWORK_GET_MODE);
-
-       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_network, ur)) {
-               __ps_send_ur_dispatch_failure_response(ur, TRESP_NETWORK_GET_MODE);
-               modem->hook_flag &= PS_NETWORK_RESET_GET_MODE_FLAG;
-       }
-
-       return;
-}
-#endif
-
-gboolean _ps_hook_co_modem_event(gpointer modem)
-{
-       Server *s = NULL;
-       TcorePlugin *p;
-       CoreObject *co_modem;
-       const char *modem_name = NULL;
-       g_return_val_if_fail(modem != NULL, FALSE);
-
-       p = _ps_modem_ref_plugin(modem);
-       s = tcore_plugin_ref_server(p);
-       co_modem = _ps_modem_ref_co_modem(modem);
-
-       modem_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(co_modem));
-       if (TRUE == g_str_has_suffix(modem_name , "0")) {
-               tcore_server_add_notification_hook(s, TNOTI_MODEM_POWER, __on_hook_powered_0, modem);
-               tcore_server_add_notification_hook(s, TNOTI_MODEM_FLIGHT_MODE, __on_hook_flight_0, modem);
-               tcore_server_add_notification_hook(s, TNOTI_SIM_STATUS, __on_hook_sim_init_0, modem);
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-#ifdef POWER_SAVING_FEATURE_WEARABLE /* TODO: Modify for DSDS support */
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_IDLE, __on_hook_voice_call_status, modem);
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_ACTIVE, __on_hook_voice_call_status, modem);
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_HELD, __on_hook_voice_call_status, modem);
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_DIALING, __on_hook_voice_call_status, modem);
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_ALERT, __on_hook_voice_call_status, modem);
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_INCOMING, __on_hook_voice_call_status, modem);
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_WAITING, __on_hook_voice_call_status, modem);
-#endif /* #ifdef POWER_SAVING_FEATURE_WEARABLE */
-#endif
-       } else {
-               tcore_server_add_notification_hook(s, TNOTI_MODEM_POWER, __on_hook_powered_1, modem);
-               tcore_server_add_notification_hook(s, TNOTI_MODEM_FLIGHT_MODE, __on_hook_flight_1, modem);
-               tcore_server_add_notification_hook(s, TNOTI_SIM_STATUS, __on_hook_sim_init_1, modem);
-#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-#ifdef POWER_SAVING_FEATURE_WEARABLE /* TODO: Modify for DSDS support */
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_IDLE, __on_hook_voice_call_status, modem);
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_ACTIVE, __on_hook_voice_call_status, modem);
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_HELD, __on_hook_voice_call_status, modem);
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_DIALING, __on_hook_voice_call_status, modem);
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_ALERT, __on_hook_voice_call_status, modem);
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_INCOMING, __on_hook_voice_call_status, modem);
-               tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_WAITING, __on_hook_voice_call_status, modem);
-#endif /* #ifdef POWER_SAVING_FEATURE_WEARABLE */
-#endif
-       }
-       return TRUE;
-}
-
-gboolean _ps_free_co_modem_event(gpointer modem)
-{
-       Server *s = NULL;
-       TcorePlugin *p;
-       CoreObject *co_modem;
-       const char *modem_name = NULL;
-       g_return_val_if_fail(modem != NULL, FALSE);
-
-       p = _ps_modem_ref_plugin(modem);
-       s = tcore_plugin_ref_server(p);
-       co_modem = _ps_modem_ref_co_modem(modem);
-
-       modem_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(co_modem));
-       if (TRUE == g_str_has_suffix(modem_name , "0")) {
-               tcore_server_remove_notification_hook(s, __on_hook_powered_0);
-               tcore_server_remove_notification_hook(s, __on_hook_flight_0);
-               tcore_server_remove_notification_hook(s, __on_hook_sim_init_0);
-       } else {
-               tcore_server_remove_notification_hook(s, __on_hook_powered_1);
-               tcore_server_remove_notification_hook(s, __on_hook_flight_1);
-               tcore_server_remove_notification_hook(s, __on_hook_sim_init_1);
-       }
-       return TRUE;
-}
 
 enum tcore_hook_return __on_hook_modem_added(Server *s,
-               CoreObject *source, enum tcore_notification_command command,
-               unsigned int data_len, void *data, void *user_data)
+                                            CoreObject *source, enum tcore_notification_command command,
+                                            unsigned int data_len, void *data, void *user_data)
 {
-       gpointer *master = user_data;
+       ps_master_t *master = user_data;
        TcorePlugin *plg = data;
 
        if (FALSE == _ps_master_create_modems(master, plg))
@@ -2200,10 +839,10 @@ enum tcore_hook_return __on_hook_modem_added(Server *s,
 }
 
 enum tcore_hook_return __on_hook_modem_removed(Server *s,
-               CoreObject *source, enum tcore_notification_command command,
-               unsigned int data_len, void *data, void *user_data)
+                                              CoreObject *source, enum tcore_notification_command command,
+                                              unsigned int data_len, void *data, void *user_data)
 {
-       gpointer *master = user_data;
+       ps_master_t *master = user_data;
        TcorePlugin *plg = data;
 
        if (FALSE == _ps_master_destroy_modem(master, plg))
@@ -2212,7 +851,7 @@ enum tcore_hook_return __on_hook_modem_removed(Server *s,
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 
-gboolean _ps_get_co_modem_values(gpointer modem)
+gboolean _ps_get_co_modem_values(ps_modem_t *modem)
 {
        TcorePlugin *plg;
        CoreObject *co_modem = NULL;
@@ -2224,7 +863,7 @@ gboolean _ps_get_co_modem_values(gpointer modem)
        int sim_status = 0;
        enum tel_sim_type sim_type = SIM_TYPE_UNKNOWN;
        struct tel_sim_imsi *sim_imsi = NULL;
-       int  power = PS_MODEM_STATE_UNKNOWN;
+       int power = PS_MODEM_STATE_UNKNOWN;
 
        g_return_val_if_fail(ps_modem != NULL, FALSE);
 
@@ -2249,17 +888,17 @@ gboolean _ps_get_co_modem_values(gpointer modem)
        switch (modem_power_state) {
        case MODEM_STATE_ONLINE:
                power = PS_MODEM_STATE_ONLINE;
-       break;
+               break;
 
        case MODEM_STATE_LOW:
                power = PS_MODEM_STATE_LOW;
-       break;
+               break;
 
        case MODEM_STATE_ERROR:
        case MODEM_STATE_RESET:
        default:
-               ps_warn_ex_co(co_modem, "Unhandled modem power event.");
-       break;
+               ps_warn_ex_modem(modem, "Unhandled modem power event.");
+               break;
        }
 
        _ps_modem_processing_flight_mode(ps_modem, flight_mode);
@@ -2271,38 +910,12 @@ gboolean _ps_get_co_modem_values(gpointer modem)
        if (sim_type == SIM_TYPE_NVSIM)
                _ps_modem_processing_sim_complete(ps_modem, sim_init, PS_CDMA_DUMMY_PROFILE_PLMN);
        else
-               _ps_modem_processing_sim_complete(ps_modem, sim_init, (gchar *)sim_imsi->plmn);
+               _ps_modem_processing_sim_complete(ps_modem, sim_init, sim_imsi->plmn);
        g_free(sim_imsi);
        return TRUE;
 }
 
-gboolean _ps_hook_co_network_event(gpointer service)
-{
-       Server *s = NULL;
-       TcorePlugin *p;
-       CoreObject *co_network = NULL;
-       const char *modem_name = NULL;
-
-       g_return_val_if_fail(service != NULL, FALSE);
-
-       p = _ps_service_ref_plugin(service);
-       s = tcore_plugin_ref_server(p);
-       co_network = _ps_service_ref_co_network(service);
-
-       modem_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(co_network));
-       if (TRUE == g_str_has_suffix(modem_name , "0")) {
-               tcore_server_add_notification_hook(s, TNOTI_NETWORK_REGISTRATION_STATUS, __on_hook_net_register_0, service);
-               tcore_server_add_notification_hook(s, TNOTI_NETWORK_CHANGE, __on_hook_net_change_0, service);
-               tcore_server_add_notification_hook(s, TNOTI_NETWORK_RESTRICTED_STATE, __on_hook_net_restricted_state_0, service);
-       } else {
-               tcore_server_add_notification_hook(s, TNOTI_NETWORK_REGISTRATION_STATUS, __on_hook_net_register_1, service);
-               tcore_server_add_notification_hook(s, TNOTI_NETWORK_CHANGE, __on_hook_net_change_1, service);
-               tcore_server_add_notification_hook(s, TNOTI_NETWORK_RESTRICTED_STATE, __on_hook_net_restricted_state_1, service);
-       }
-       return TRUE;
-}
-
-gboolean _ps_get_co_network_values(gpointer service)
+gboolean _ps_get_co_network_values(ps_service_t *service)
 {
        CoreObject *co_network = NULL;
        gboolean ps_attached = FALSE;
@@ -2314,7 +927,7 @@ gboolean _ps_get_co_network_values(gpointer service)
        g_return_val_if_fail(service != NULL, FALSE);
 
        co_network = _ps_service_ref_co_network(service);
-       ps_dbg_ex_co(co_network, "Entered ");
+       ps_dbg_ex_svc(service, "Entered ");
 
        tcore_network_get_service_status(co_network, TCORE_NETWORK_SERVICE_DOMAIN_TYPE_PACKET, &ps_status);
        tcore_network_get_access_technology(co_network, &act);
@@ -2332,140 +945,117 @@ gboolean _ps_get_co_network_values(gpointer service)
        return TRUE;
 }
 
-gboolean _ps_hook_co_ps_event(gpointer service)
+gboolean _ps_add_co_ps_event(ps_service_t *service)
 {
-       Server *s = NULL;
-       TcorePlugin *p;
-       CoreObject *co_ps = NULL;
-       const char *modem_name = NULL;
+       Server *s;
        g_return_val_if_fail(service != NULL, FALSE);
+       ps_dbg_ex_svc(service, "Entered ");
+       s = tcore_plugin_ref_server(_ps_service_ref_plugin(service));
+       tcore_server_add_notification_hook(s, TNOTI_PS_CALL_STATUS, __on_hook_call_status, service);
+       tcore_server_add_notification_hook(s, TNOTI_PS_PDP_IPCONFIGURATION, __on_hook_ipconfiguration, service);
+       tcore_server_add_notification_hook(s, TNOTI_PS_DEDICATED_BEARER_INFO, __on_hook_dedicated_bearerinfo, service);
+       tcore_server_add_notification_hook(s, TNOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION, __on_hook_default_data_subscription, service);
+//     tcore_server_add_notification_hook(s, TNOTI_PS_GPRS_BACKOFF_TIMER, __on_hook_gprs_backoff_timer, service);
+//     tcore_server_add_notification_hook(s, TNOTI_PS_GPRS_NAS_TIMER, __on_hook_gprs_nas_timer, service);
+       tcore_server_add_notification_hook(s, TNOTI_NETWORK_EPDG_STATUS, __on_hook_epdg_status, service);
+       tcore_object_add_callback(_ps_service_ref_co_ps(service), CORE_OBJECT_EVENT_PROPERTY_CHANGED, __ps_on_prop_changed, service);
+       return TRUE;
+}
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Entered ");
-       p = _ps_service_ref_plugin(service);
-       s = tcore_plugin_ref_server(p);
-       co_ps = _ps_service_ref_co_ps(service);
+gboolean _ps_add_co_network_event(ps_service_t *service)
+{
+       Server *s;
 
-       modem_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(co_ps));
-       tcore_object_add_callback (co_ps, CORE_OBJECT_EVENT_PROPERTY_CHANGED, __ps_on_prop_changed, service);
-       if (TRUE == g_str_has_suffix(modem_name , "0")) {
-               tcore_server_add_notification_hook(s, TNOTI_PS_CALL_STATUS, __on_hook_call_status_0, service);
-               tcore_server_add_notification_hook(s, TNOTI_PS_CURRENT_SESSION_DATA_COUNTER, __on_hook_session_data_counter_0, service);
-               tcore_server_add_notification_hook(s, TNOTI_PS_PDP_IPCONFIGURATION, __on_hook_ipconfiguration_0, service);
-               tcore_server_add_notification_hook(s, TNOTI_PS_DEDICATED_BEARER_INFO, __on_hook_dedicated_bearerinfo_0, service);
-               tcore_server_add_notification_hook(s, TNOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION, __on_hook_default_data_subscription_0, service);
-       } else {
-               tcore_server_add_notification_hook(s, TNOTI_PS_CALL_STATUS, __on_hook_call_status_1, service);
-               tcore_server_add_notification_hook(s, TNOTI_PS_CURRENT_SESSION_DATA_COUNTER, __on_hook_session_data_counter_1, service);
-               tcore_server_add_notification_hook(s, TNOTI_PS_PDP_IPCONFIGURATION, __on_hook_ipconfiguration_1, service);
-               tcore_server_add_notification_hook(s, TNOTI_PS_DEDICATED_BEARER_INFO, __on_hook_dedicated_bearerinfo_1, service);
-               tcore_server_add_notification_hook(s, TNOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION, __on_hook_default_data_subscription_1, service);
-       }
+       g_return_val_if_fail(service != NULL, FALSE);
 
-       tcore_server_add_notification_hook(s, TNOTI_NETWORK_EPDG_STATUS, __on_hook_epdg_status, service);
+       s = tcore_plugin_ref_server(_ps_service_ref_plugin(service));
+
+       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);
+       tcore_server_add_notification_hook(s, TNOTI_NETWORK_RESTRICTED_STATE, __on_hook_net_restricted_state, service);
 
        return TRUE;
 }
 
-gboolean _ps_free_modem_event(gpointer modem)
+gboolean _ps_add_co_modem_event(ps_modem_t *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);
+       s = tcore_plugin_ref_server(_ps_modem_ref_plugin(modem));
 
-       tcore_server_remove_notification_hook(s, __on_hook_powered);
-       tcore_server_remove_notification_hook(s, __on_hook_flight);
-       tcore_server_remove_notification_hook(s, __on_hook_sim_init);
+       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);
+//     tcore_server_add_notification_hook(s, TNOTI_SIM_REFRESH_STAGE, __on_hook_sim_refresh, modem);
 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-       tcore_server_remove_notification_hook(s, __on_hook_voice_call_status);
-#endif /* #ifdef POWER_SAVING_FEATURE_WEARABLE */
+       _ps_hook_add_modem_hooks(modem);
 #endif
        return TRUE;
-
 }
 
-gboolean _ps_free_co_ps_event(gpointer service)
+gboolean _ps_free_co_ps_event(ps_service_t *service)
 {
-       Server *s = NULL;
-       TcorePlugin *p;
-       CoreObject *co_ps = NULL;
-       CoreObject *co_network;
-       const char *modem_name = NULL;
-
+       Server *s;
        g_return_val_if_fail(service != NULL, FALSE);
-       co_network = _ps_service_ref_co_network(service);
-
-       ps_dbg_ex_co(co_network, "Entered ");
-       p = _ps_service_ref_plugin(service);
-       s = tcore_plugin_ref_server(p);
-       co_ps = _ps_service_ref_co_ps(service);
-
-       modem_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(co_ps));
-       if (modem_name)
-               ps_dbg_ex_co(co_network, "modem name %s", modem_name);
-
-       tcore_object_del_callback(co_ps, CORE_OBJECT_EVENT_PROPERTY_CHANGED, __ps_on_prop_changed);
-       if (TRUE == g_str_has_suffix(modem_name , "0")) {
-               tcore_server_remove_notification_hook(s, __on_hook_call_status_0);
-               tcore_server_remove_notification_hook(s, __on_hook_session_data_counter_0);
-               tcore_server_remove_notification_hook(s, __on_hook_ipconfiguration_0);
-        } else {
-               tcore_server_remove_notification_hook(s, __on_hook_call_status_1);
-               tcore_server_remove_notification_hook(s, __on_hook_session_data_counter_1);
-               tcore_server_remove_notification_hook(s, __on_hook_ipconfiguration_1);
-        }
-        return TRUE;
+       ps_dbg_ex_svc(service, "Entered ");
+       s = tcore_plugin_ref_server(_ps_service_ref_plugin(service));
+       tcore_object_del_callback(_ps_service_ref_co_ps(service), CORE_OBJECT_EVENT_PROPERTY_CHANGED, __ps_on_prop_changed);
+       tcore_server_remove_notification_hook(s, __on_hook_call_status);
+       tcore_server_remove_notification_hook(s, __on_hook_ipconfiguration);
+       tcore_server_remove_notification_hook(s, __on_hook_dedicated_bearerinfo);
+       tcore_server_remove_notification_hook(s, __on_hook_default_data_subscription);
+//     tcore_server_remove_notification_hook(s, __on_hook_gprs_backoff_timer);
+//     tcore_server_remove_notification_hook(s, __on_hook_gprs_nas_timer);
+       tcore_server_remove_notification_hook(s, __on_hook_epdg_status);
+       return TRUE;
 }
 
-gboolean _ps_free_co_network_event(gpointer service)
+gboolean _ps_free_co_network_event(ps_service_t *service)
 {
-       Server *s = NULL;
-       TcorePlugin *p;
-       CoreObject *co_network = NULL;
-       const char *modem_name = NULL;
+       Server *s;
        g_return_val_if_fail(service != NULL, FALSE);
+       ps_dbg_ex_svc(service, "Entered");
+       s = tcore_plugin_ref_server(_ps_service_ref_plugin(service));
+       tcore_server_remove_notification_hook(s, __on_hook_net_register);
+       tcore_server_remove_notification_hook(s, __on_hook_net_change);
+       tcore_server_remove_notification_hook(s, __on_hook_net_restricted_state);
+       return TRUE;
+}
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Entered ");
-       p = _ps_service_ref_plugin(service);
-       s = tcore_plugin_ref_server(p);
-       co_network = _ps_service_ref_co_network(service);
-
-       modem_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(co_network));
-       if (TRUE == g_str_has_suffix(modem_name , "0")) {
-               tcore_server_remove_notification_hook(s, __on_hook_net_register_0);
-               tcore_server_remove_notification_hook(s, __on_hook_net_change_0);
-               tcore_server_remove_notification_hook(s, __on_hook_net_restricted_state_0);
-       } else {
-               tcore_server_remove_notification_hook(s, __on_hook_net_register_1);
-               tcore_server_remove_notification_hook(s, __on_hook_net_change_1);
-               tcore_server_remove_notification_hook(s, __on_hook_net_restricted_state_1);
-       }
+gboolean _ps_free_co_modem_event(ps_modem_t *modem)
+{
+       Server *s;
+       g_return_val_if_fail(modem != NULL, FALSE);
+       s = tcore_plugin_ref_server(_ps_modem_ref_plugin(modem));
+       tcore_server_remove_notification_hook(s, __on_hook_powered);
+       tcore_server_remove_notification_hook(s, __on_hook_flight);
+       tcore_server_remove_notification_hook(s, __on_hook_sim_init);
+//     tcore_server_remove_notification_hook(s, __on_hook_sim_refresh);
        return TRUE;
 }
 
-gboolean _ps_update_cellular_state_key(gpointer object)
+gboolean _ps_update_cellular_state_key(ps_service_t *service)
 {
-       Server *s = NULL;
-       static Storage *strg;
        int current_state = 0;
        int stored_state = 0;
-       ps_service_t *service = object;
-       CoreObject *co_network = _ps_service_ref_co_network(service);
-       ps_modem_t *modem = _ps_service_ref_modem(service);
-       ps_subs_type subscription_type = _ps_modem_get_subs_type(modem);
+       ps_modem_t *modem;
+       ps_master_t *master;
+       ps_subs_type subs_type;
        int selected_sim = -1;
 
-       ps_dbg_ex_co(co_network, "Update cellular state for [SIM%d]", subscription_type + 1);
+       g_return_val_if_fail(service != NULL, FALSE);
 
-       s = tcore_plugin_ref_server(_ps_service_ref_plugin(service));
-       strg = tcore_server_find_storage(s, "vconf");
+       modem = _ps_service_ref_modem(service);
+       master = _ps_modem_ref_master(modem);
+       subs_type = _ps_modem_get_subs_type(modem);
 
-       selected_sim = tcore_storage_get_int(strg, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
-       if ((selected_sim != -1) && (selected_sim != (int)subscription_type)) {
-               ps_warn_ex_co(co_network, "Update for only [SIM%d] selected by Setting", selected_sim + 1);
+       ps_dbg_ex_svc(service, "Update cellular state for [SIM%d]", subs_type + 1);
+
+       selected_sim = _ps_master_get_storage_value_int(master, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
+       if ((selected_sim != -1) && (selected_sim != (int)subs_type)) {
+               ps_warn_ex_svc(service, "Update for only [SIM%d] selected by Setting", selected_sim + 1);
                return FALSE;
        }
 
@@ -2474,12 +1064,11 @@ gboolean _ps_update_cellular_state_key(gpointer object)
        if (tcore_modem_get_flight_mode_state(modem->co_modem) == TRUE)
                current_state = TELEPHONY_PS_FLIGHT_MODE;
 
-       stored_state = tcore_storage_get_int(strg, STORAGE_KEY_CELLULAR_STATE);
+       stored_state = _ps_master_get_storage_value_int(master, STORAGE_KEY_CELLULAR_STATE);
        if (current_state != stored_state) {
-               ps_info_ex_co(co_network, "Cellular state, current: [%d], stored: [%d]", current_state, stored_state);
-               tcore_storage_set_int(strg, STORAGE_KEY_CELLULAR_STATE, current_state);
+               ps_info_ex_svc(service, "Cellular state, current: [%d], stored: [%d]", current_state, stored_state);
+               _ps_master_set_storage_value_int(master, STORAGE_KEY_CELLULAR_STATE, current_state);
        }
 
        return TRUE;
 }
-
index c07d56d..97d8c20 100644 (file)
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
-
+#include <vconf.h>
 #include "ps_common.h"
+#include <co_context.h>
 
 GSource *ps_util_gsource_dispatch(GMainContext *main_context,
-       gint priority, GSourceFunc cb, gpointer data)
+                                 gint priority, GSourceFunc cb, gpointer data)
 {
        GSource *request_source = NULL;
 
@@ -43,7 +44,7 @@ GSource *ps_util_gsource_dispatch(GMainContext *main_context,
 }
 
 gboolean ps_util_thread_dispatch(GMainContext *main_context,
-       gint priority, GSourceFunc cb, gpointer data)
+                                gint priority, GSourceFunc cb, gpointer data)
 {
 
        GSource *request_source;
@@ -107,7 +108,7 @@ int ps_util_system_command(char *command)
 }
 
 void ps_util_load_xml_file(const char *docname,
-       const char *groupname, void **i_doc, void **i_root_node)
+                          const char *groupname, void **i_doc, void **i_root_node)
 {
        xmlDocPtr *doc = (xmlDocPtr *)i_doc;
        xmlNodePtr *root_node = (xmlNodePtr *)i_root_node;
@@ -120,7 +121,7 @@ void ps_util_load_xml_file(const char *docname,
                if (*root_node) {
                        dbg("*root_node->name: [%s]", (*root_node)->name);
                        if (0 == xmlStrcmp((*root_node)->name,
-                                       (const unsigned char *)groupname)) {
+                                          (const unsigned char *)groupname)) {
                                dbg("root_node is found !!!");
                                return;
                        } else {
@@ -152,3 +153,115 @@ void ps_util_unload_xml_file(void **i_doc, void **i_root_node)
                        *root_node = NULL;
        }
 }
+
+gboolean ps_util_check_permanent_reject_cause(int cause, gboolean roaming)
+{
+       /* No permanent reject cause in platform side */
+       return TRUE;
+}
+
+UserRequest *ps_util_peek_waiting_job(GQueue *queue, unsigned int id)
+{
+       int iter = 0;
+       struct work_queue_data *wqd = NULL;
+
+       g_return_val_if_fail((NULL != queue), NULL);
+
+       do {
+               wqd = g_queue_peek_nth(queue, iter);
+               if (NULL == wqd)
+                       break;
+               if (wqd->id == id)
+                       break;
+               iter++;
+       } while (TRUE);
+
+       if (NULL == wqd) {
+               warn("Work queue data is 0");
+               return NULL;
+       }
+
+       return wqd->ur;
+}
+
+gboolean ps_util_add_waiting_job(GQueue *queue, unsigned int id, UserRequest *ur)
+{
+       struct work_queue_data *wqd;
+
+       if (!queue)
+               return FALSE;
+
+       wqd = calloc(sizeof(struct work_queue_data), 1);
+       if (!wqd)
+               return FALSE;
+
+       wqd->id = id;
+       wqd->ur = ur;
+       g_queue_push_tail(queue, wqd);
+
+       dbg("id = %d, ur = 0x%x", wqd->id, wqd->ur);
+       return TRUE;
+}
+
+guint ps_util_get_waiting_job_count(GQueue *queue, unsigned int id)
+{
+       guint i = 0;
+       guint count = 0;
+       struct work_queue_data *wqd = NULL;
+
+       if (!queue)
+               return count;
+
+       dbg("job count: %d", g_queue_get_length(queue));
+
+       do {
+               wqd = g_queue_peek_nth(queue, i);
+               if (!wqd)
+                       break;
+
+               if (wqd->id == id)
+                       count++;
+
+               i++;
+       } while (wqd != NULL);
+
+       dbg("count: %d, id = %d", count, id);
+
+       return count;
+}
+
+UserRequest *ps_util_pop_waiting_job(GQueue *queue, unsigned int id)
+{
+       int i = 0;
+       UserRequest *ur;
+       struct work_queue_data *wqd;
+
+       if (!queue)
+               return NULL;
+
+       dbg("before waiting job count: %d", g_queue_get_length(queue));
+
+       do {
+               wqd = g_queue_peek_nth(queue, i);
+               if (!wqd)
+                       return NULL;
+
+               if (wqd->id == id) {
+                       wqd = g_queue_pop_nth(queue, i);
+                       break;
+               }
+
+               i++;
+       } while (wqd != NULL);
+
+       dbg("after  waiting job count: %d", g_queue_get_length(queue));
+
+       if (!wqd)
+               return NULL;
+
+       ur = wqd->ur;
+       free(wqd);
+
+       return ur;
+}
+
diff --git a/test_src/CMakeLists.txt b/test_src/CMakeLists.txt
deleted file mode 100644 (file)
index 376699b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(apnbuilder C)
-
-SET(apnbuilder
-       main.c
-)
-
-ADD_EXECUTABLE(apnbuilder ${apnbuilder})
-TARGET_LINK_LIBRARIES(apnbuilder ${pkgs_LDFLAGS} "-L${CMAKE_BINARY_DIR} -ltcore")
-INSTALL(TARGETS apnbuilder RUNTIME DESTINATION ${TIZEN_TEST_BIN_DIR})
diff --git a/test_src/main.c b/test_src/main.c
deleted file mode 100644 (file)
index cd3a94e..0000000
+++ /dev/null
@@ -1,948 +0,0 @@
-/*
- * libslp-tapi
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Ja-young Gu <jygu@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <wait.h>
-#include <errno.h>
-
-#include <tzplatform_config.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-#include <db-util.h>
-#include <libxml/xmlmemory.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#define DATABASE_PATH tzplatform_mkpath(TZ_SYS_DB, ".dnet.db")
-#define msg(fmt, args...) do { printf(fmt "\n", ##args); fflush(stdout); } while (0)
-
-enum context_type {
-       CONTEXT_TYPE_UNKNOWN,
-       CONTEXT_TYPE_X25,
-       CONTEXT_TYPE_IP,
-       CONTEXT_TYPE_IHOST,
-       CONTEXT_TYPE_PPP,
-       CONTEXT_TYPE_IPV6,
-       CONTEXT_TYPE_IPV4V6,
-};
-
-enum context_role {
-       CONTEXT_ROLE_UNKNOWN,
-       CONTEXT_ROLE_INTERNET,
-       CONTEXT_ROLE_MMS,
-       CONTEXT_ROLE_PREPAID_INTERNET,
-       CONTEXT_ROLE_PREPAID_MMS,
-       CONTEXT_ROLE_TETHERING,
-       CONTEXT_ROLE_USER_DEFINED,
-};
-
-static int __system_command(char *command)
-{
-       int pid = 0,
-       status = 0;
-       const char *environ[] = { NULL };
-
-       if (command == NULL)
-               return -1;
-
-       msg("%s", command);
-
-       pid = fork();
-       if (pid == -1)
-               return -1;
-
-       if (pid == 0) {
-               char *argv[4];
-
-               argv[0] = "sh";
-               argv[1] = "-c";
-               argv[2] = (char *)command;
-               argv[3] = 0;
-
-               execve("/bin/sh", argv, (char **)environ);
-               exit(127);
-       }
-
-       do {
-               if (waitpid(pid, &status, 0) == -1) {
-                       if (errno != EINTR)
-                               return -1;
-               } else {
-                       if (WIFEXITED(status))
-                               return WEXITSTATUS(status);
-                       else if (WIFSIGNALED(status))
-                               return WTERMSIG(status);
-                       else if (WIFSTOPPED(status))
-                               return WSTOPSIG(status);
-               }
-       } while (!WIFEXITED(status) && !WIFSIGNALED(status));
-
-       return 0;
-}
-
-static void __load_xml_file(const char *docname, const char *groupname, void **i_doc, void **i_root_node)
-{
-       xmlDocPtr *doc = (xmlDocPtr *)i_doc;
-       xmlNodePtr *root_node = (xmlNodePtr *)i_root_node;
-
-       msg("docname:%s, groupname:%s", docname, groupname);
-
-       *doc = xmlParseFile(docname);
-       if (*doc) {
-               *root_node = xmlDocGetRootElement(*doc);
-               if (*root_node) {
-                       msg("*root_node->name:%s", (*root_node)->name);
-                       if (0 == xmlStrcmp((*root_node)->name, (const unsigned char *)groupname)) {
-                               msg("root_node is found !!!");
-                               return;
-                       } else {
-                               msg("Cannot find root node.");
-                               *root_node = NULL;
-                       }
-               }
-               xmlFreeDoc(*doc);
-               *doc = NULL;
-       } else {
-               msg("fail to parse doc(%s)", docname);
-       }
-}
-
-static void __unload_xml_file(void **i_doc, void **i_root_node)
-{
-       xmlDocPtr *doc = (xmlDocPtr *)i_doc;
-       xmlNodePtr *root_node = (xmlNodePtr *)i_root_node;
-
-       msg("unloading XML");
-       if (doc && *doc) {
-               xmlFreeDoc(*doc);
-               *doc = NULL;
-               if (root_node)
-                       *root_node = NULL;
-       }
-}
-
-static void *create_handle(const char *path)
-{
-       int rv = 0;
-       sqlite3 *handle = NULL;
-
-       rv = db_util_open(path, &handle, 0);
-       if (rv != SQLITE_OK) {
-               msg("fail to connect database rv(%d)", rv);
-               return NULL;
-       }
-
-       msg("connected to %s", path);
-       return handle;
-}
-
-static gboolean remove_handle(void *handle)
-{
-       if (!handle)
-               return FALSE;
-
-       db_util_close(handle);
-
-       msg("disconnected from database");
-       return TRUE;
-}
-
-static gboolean read_query_database(void *handle, const char *query, GHashTable *in_param,
-               GHashTable *out_param, int out_param_cnt)
-{
-       int rv = 0, index = 0, outter_index = 0;
-       sqlite3_stmt *stmt = NULL;
-       char szQuery[5000+1];   /* +1 is for NULL Termination Character '\0' */
-
-       GHashTableIter iter;
-       gpointer key, value;
-
-       msg("read query");
-
-       memset(szQuery, '\0', 5001);
-       strncpy(szQuery, query, 5000);
-
-       rv = sqlite3_prepare_v2(handle, szQuery, strlen(szQuery), &stmt, NULL);
-       if (rv != SQLITE_OK) {
-               msg("fail to connect to table (%d)", rv);
-               return FALSE;
-       }
-
-       if (in_param) {
-               g_hash_table_iter_init(&iter, in_param);
-               while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-                       msg("key(%s), value(%s)", (const char *)key, (const char *)value);
-
-                       if (!value || g_strcmp0((const char *) value, "") == 0) {
-                               msg("bind null");
-                               rv = sqlite3_bind_null(stmt, atoi((const char *) key));
-                       } else {
-                               msg("bind value");
-                               rv = sqlite3_bind_text(stmt, atoi((const char *) key), (const char *) value, strlen((const char *) value),
-                                               SQLITE_STATIC);
-                       }
-
-                       if (rv != SQLITE_OK) {
-                               msg("fail to bind data (%d)", rv);
-                               return FALSE;
-                       }
-               }
-       }
-
-       rv = sqlite3_step(stmt);
-       msg("read query executed (%d)", rv);
-
-       while (rv == SQLITE_ROW) {
-
-               char tmp_key_outter[10];
-               GHashTable *out_param_data;
-
-               out_param_data = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
-
-               for (index = 0; index < out_param_cnt; index++) {
-                       char *tmp = NULL, tmp_key[10];
-                       tmp = (char *) sqlite3_column_text(stmt, index);
-                       snprintf(tmp_key, sizeof(tmp_key), "%d", index);
-                       g_hash_table_insert(out_param_data, g_strdup(tmp_key), g_strdup(tmp));
-               }
-
-               snprintf(tmp_key_outter, sizeof(tmp_key_outter), "%d", outter_index);
-               g_hash_table_insert(out_param, g_strdup(tmp_key_outter), out_param_data);
-               outter_index++;
-               rv = sqlite3_step(stmt);
-       }
-
-       sqlite3_finalize(stmt);
-       return TRUE;
-}
-
-static gboolean query_database(void *handle, const char *query, GHashTable *in_param)
-{
-       int rv = 0;
-       sqlite3_stmt *stmt = NULL;
-       char szQuery[5000+1];   /* +1 is for NULL Termination Character '\0' */
-
-       GHashTableIter iter;
-       gpointer key, value;
-       msg("query database");
-
-       memset(szQuery, '\0', 5001);
-       strncpy(szQuery, query, 5000);
-
-       rv = sqlite3_prepare_v2(handle, szQuery, strlen(szQuery), &stmt, NULL);
-       if (rv != SQLITE_OK) {
-               msg("fail to connect to table (%d)", rv);
-               return FALSE;
-       }
-
-       if (in_param) {
-               g_hash_table_iter_init(&iter, in_param);
-               while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-                       msg("key(%s), value(%s)", (const char *)key, (const char *)value);
-
-                       if (!value || g_strcmp0((const char *) value, "") == 0) {
-                               msg("bind null");
-                               rv = sqlite3_bind_null(stmt, atoi((const char *) key));
-                       } else {
-                               msg("bind value");
-                               rv = sqlite3_bind_text(stmt, atoi((const char *) key), (const char *) value, strlen((const char *) value),
-                                               SQLITE_STATIC);
-                       }
-
-                       if (rv != SQLITE_OK) {
-                               msg("fail to bind data (%d)", rv);
-                               return FALSE;
-                       }
-               }
-       }
-
-       rv = sqlite3_step(stmt);
-       msg("query executed (%d)", rv);
-       sqlite3_finalize(stmt);
-
-       if (rv != SQLITE_DONE)
-               return FALSE;
-
-       return TRUE;
-}
-
-static gboolean __reset_database(void)
-{
-       gpointer handle;
-       char szQuery[5000];
-       gboolean rv = FALSE;
-
-       /* Initialize Storage */
-       handle = create_handle(DATABASE_PATH);
-       if (handle == NULL) {
-               msg("Failed to get Storage handle");
-               return rv;
-       }
-
-       /* SQL query */
-       memset(szQuery, 0x0, sizeof(szQuery));
-       strcat(szQuery, " delete from pdp_profile");
-
-       rv = query_database(handle, szQuery, NULL);
-       msg("Reset profile table: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
-
-       /* De-initialize Storage */
-       remove_handle(handle);
-
-       return rv;
-}
-
-static int __insert_network_id_to_database(gchar *mccmnc)
-{
-       gpointer handle;
-       GHashTable *in_param, *out_param;
-       char szQuery[5000];
-       gboolean rv = FALSE;
-
-       GHashTableIter iter;
-       gpointer key, value;
-       int network_id = 0;
-
-       /* Initialize Database */
-       handle = create_handle(DATABASE_PATH);
-       if (handle == NULL) {
-               msg("Failed to get Storage handle");
-               return rv;
-       }
-
-       /*
-        * Check the maximum Network ID that exists in database,
-        * if NONE exists, then 'Network ID' would be equal to 1
-        * else if there exists a valid maximum entry; 'Network ID' would be incremented value.
-        */
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
-                               (GDestroyNotify) g_hash_table_destroy);
-
-       /* SQL query */
-       memset(szQuery, 0x0, sizeof(szQuery));
-       strcpy(szQuery, "select max(network_info_id) as network_id from network_info");
-
-       rv = read_query_database(handle, szQuery, NULL, out_param, 1);
-       msg("Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
-
-       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) {
-                               msg("key2(%s) value2(%s)", (const char *)key2, (const char *)value2);
-                               if (g_str_equal(key2, "0") == TRUE) {
-                                       if (!value2 || g_strcmp0((const char *)value2, "") == 0)
-                                               network_id = 0;
-                                       else
-                                               network_id = atoi((const char *)value2);
-
-                                       /* TODO - Check this logic */
-                                       break;
-                               }
-                       }
-               }
-       }
-
-       /* Free Resources */
-       g_hash_table_destroy(out_param);
-
-       /* Increment Network ID */
-       network_id++;
-
-       /* SQL query */
-       memset(szQuery, 0x0, sizeof(szQuery));
-       strcpy(szQuery, " insert into network_info(network_info_id, network_name, mccmnc) values(?, ?, ?) ");
-
-       /* Initialize parameters */
-       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
-       g_hash_table_insert(in_param, "1", g_strdup_printf("%d", network_id));  /* Network ID */
-       g_hash_table_insert(in_param, "2", g_strdup_printf("PLMN_%s", mccmnc));
-       g_hash_table_insert(in_param, "3", g_strdup(mccmnc));
-
-       rv = query_database(handle, szQuery, in_param);
-       if (rv == FALSE) {
-               msg("Failed to insert query to Storage");
-               network_id = 0;
-       }
-
-       /* Free resources */
-       g_hash_table_destroy(in_param);
-
-       /* De-initialize Storage */
-       remove_handle(handle);
-
-       return network_id;
-}
-
-
-static int __load_network_id_from_database(gchar *mccmnc)
-{
-       gpointer handle;
-       GHashTable *in_param, *out_param;
-       char szQuery[5000];
-       gboolean rv = FALSE;
-
-       GHashTableIter iter;
-       gpointer key, value;
-
-       int network_id = -1;
-
-       /* Initialize Storage */
-       handle = create_handle(DATABASE_PATH);
-       if (handle == NULL) {
-               msg("Failed to get Storage handle");
-               return network_id;
-       }
-
-       /* Initialize parameters */
-       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
-       g_hash_table_insert(in_param, "1", g_strdup(mccmnc));
-
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
-                       (GDestroyNotify) g_hash_table_destroy);
-
-       /* SQL Query */
-       memset(szQuery, 0x0, sizeof(szQuery));
-       strcpy(szQuery, "select network_info_id from network_info where mccmnc = ? ");
-
-       rv = read_query_database(handle, szQuery, in_param, out_param, 1);
-       msg("Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
-
-       g_hash_table_iter_init(&iter, out_param);
-       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-               GHashTableIter iter2;
-               gpointer key2, value2;
-
-               if (value) {
-                       g_hash_table_iter_init(&iter2, (GHashTable *)value);
-                       while (g_hash_table_iter_next(&iter2, &key2, &value2) == TRUE) {
-                               if (g_str_equal(key2, "0") == TRUE) {
-                                       if (!value2 || (g_strcmp0((const char *)value2, "") == 0))
-                                               network_id = 0;
-                                       else
-                                               network_id = atoi((const char *)value2);
-
-                                       /* TODO - Check this out */
-                                       break;
-                               }
-                       }
-               }
-       }
-
-       /* Free resources */
-       g_hash_table_destroy(in_param);
-       g_hash_table_destroy(out_param);
-
-       /* De-initialize Storage */
-       remove_handle(handle);
-
-       return network_id;
-}
-
-
-static int __get_network_id(gchar *mccmnc)
-{
-       int network_id;
-
-       network_id = __load_network_id_from_database(mccmnc);
-       msg("network id(%d)", network_id);
-       if (network_id > 0)
-               return network_id;
-
-       network_id = __insert_network_id_to_database(mccmnc);
-       if (network_id <= 0)
-               return -1;
-
-       return network_id;
-}
-
-static int __load_profile_id_from_database(void)
-{
-       gpointer handle;
-       GHashTable *out_param;
-       char szQuery[5000];
-       gboolean rv = FALSE;
-
-       GHashTableIter iter;
-       gpointer key, value;
-
-       int profile_id = -1;
-
-       /* Initialize Database */
-       handle = create_handle(DATABASE_PATH);
-       if (handle == NULL) {
-               msg("Failed to get Storage handle");
-               return profile_id;
-       }
-
-       /* Initialize parameters */
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
-                       (GDestroyNotify) g_hash_table_destroy);
-
-       /* SQL query */
-       memset(szQuery, 0x0, sizeof(szQuery));
-       strcpy(szQuery, "select max(profile_id) as last_profile from pdp_profile");
-
-       rv = read_query_database(handle, szQuery, NULL, out_param, 1);
-       msg("Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
-
-       g_hash_table_iter_init(&iter, out_param);
-       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-               GHashTableIter iter2;
-               gpointer key2, value2;
-
-               if (value) {
-                       g_hash_table_iter_init(&iter2, (GHashTable *)value);
-                       while (g_hash_table_iter_next(&iter2, &key2, &value2) == TRUE) {
-                               if (g_str_equal(key2, "0") == TRUE) {
-                                       if (!value2 || (g_strcmp0((const char *)value2, "") == 0))
-                                               profile_id = 0;
-                                       else
-                                               profile_id = atoi((const char *)value2);
-
-                                       /* TODO - Check this logic */
-                                       break;
-                               }
-                       }
-               }
-       }
-
-       /* Free resources */
-       g_hash_table_destroy(out_param);
-       /* De-initialize Storage */
-       remove_handle(handle);
-       return profile_id;
-}
-
-static gboolean __get_default_profile_from_database(int network_info_id, int svc_category_id)
-{
-       gpointer handle;
-       GHashTable *in_param, *out_param;
-       char szQuery[5000];
-       gboolean rv, ret = FALSE;
-       guint profile_cnt;
-
-       /* Initialize Storage */
-       handle = create_handle(DATABASE_PATH);
-       if (handle == NULL) {
-               msg("Failed to get Storage handle");
-               return FALSE;
-       }
-
-       /* Initialize parameters */
-       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
-       g_hash_table_insert(in_param, "1", g_strdup_printf("%d", network_info_id));
-       g_hash_table_insert(in_param, "2", g_strdup_printf("%d", svc_category_id));
-
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
-                       (GDestroyNotify) g_hash_table_destroy);
-
-       /* SQL query */
-       memset(szQuery, 0x0, sizeof(szQuery));
-       strcpy(szQuery, "select profile_id from pdp_profile ");
-       strcat(szQuery, "where network_info_id = ? and svc_category_id = ? and default_internet_con = 1");
-
-       rv = read_query_database(handle, szQuery, in_param, out_param, 1);
-       msg("Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
-
-       profile_cnt = g_hash_table_size(out_param);
-       if (profile_cnt > 0) {
-               msg("default profile for (svc_category_id: %d, network_info_id: %d) exists: count[%d]",
-                       svc_category_id, network_info_id, profile_cnt);
-               ret = TRUE;
-       }
-       /* Free resources */
-       g_hash_table_destroy(in_param);
-       g_hash_table_destroy(out_param);
-
-       /* De-initialize Database */
-       remove_handle(handle);
-       return ret;
-}
-
-static gboolean __insert_apns_to_database(GHashTable *in_param)
-{
-       gpointer handle;
-       char szQuery[5000];
-       gboolean rv = FALSE;
-
-       if (in_param == NULL) {
-               msg("in_param is NULL !!!");
-               return rv;
-       }
-
-       /* Initialize Database */
-       handle = create_handle(DATABASE_PATH);
-       if (handle == NULL) {
-               msg("Failed to get db handle");
-               return rv;
-       }
-       /* SQL query */
-       memset(szQuery, 0x0, sizeof(szQuery));
-       strcpy(szQuery, " insert into pdp_profile(");
-       strcat(szQuery, " profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, ");
-       strcat(szQuery, " pdp_protocol, svc_category_id, proxy_ip_addr, home_url, linger_time, ");
-       strcat(szQuery, " network_info_id, hidden, editable, default_internet_con, user_defined) values(");
-       strcat(szQuery, " ?, ?, ?, ?, ?, ?, ");/* 1, 2, 3, 4, 5, 6(auth_pwd) */
-       strcat(szQuery, " ?, ?, ?, ?, 300, ");/* 7, 8, 9, 10(home_url) */
-       strcat(szQuery, " ?, 0, 1, ?, 0)");/* 11, 12(default_internet_con) */
-
-       rv = query_database(handle, szQuery, in_param);
-       msg("Insert to Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
-
-       /* De-initialize Database */
-       remove_handle(handle);
-       return rv;
-}
-
-static gboolean __duplicate_profile_by_type(GHashTable *in_param, gpointer node, int svc_category_id)
-{
-       gpointer tmp;
-       xmlNode *cur_node = node;
-       gchar *in_tuple = NULL;
-       int profile_index;
-
-       if (!in_param || !node)
-               return FALSE;
-
-       tmp = g_hash_table_lookup(in_param, "1");
-       if (tmp) { /* profile_id */
-               profile_index = atoi((char *)tmp);
-               profile_index++;
-               g_hash_table_insert(in_param, "1", g_strdup_printf("%d", profile_index));
-               msg("profile_id = %d", profile_index);
-       } else {
-               return FALSE;
-       }
-
-       {/* svc_category_id */
-               g_hash_table_insert(in_param, "8", g_strdup_printf("%d", svc_category_id));
-               msg("svc_category_id = %d", svc_category_id);
-       }
-
-       {/* proxy ip */
-               gchar *proxy_ip_addr = NULL, *proxy = NULL, *port = NULL;
-
-               if (svc_category_id == CONTEXT_ROLE_MMS) {
-                       proxy = (char *)xmlGetProp(cur_node, (const unsigned char *)"mmsproxy");
-                       port = (char *)xmlGetProp(cur_node, (const unsigned char *)"mmsport");
-               } else {
-                       proxy = (char *)xmlGetProp(cur_node, (const unsigned char *)"proxy");
-                       port = (char *)xmlGetProp(cur_node, (const unsigned char *)"port");
-               }
-               if (proxy && port) {
-                       proxy_ip_addr = g_strdup_printf("%s:%s", proxy, port);
-                       in_tuple = g_strdup(proxy_ip_addr);
-                       g_free(proxy_ip_addr);
-               } else {
-                       in_tuple = g_strdup("");
-               }
-               g_hash_table_insert(in_param, "9", g_strdup(in_tuple));
-               msg("proxy_ip_addr = %s", in_tuple);
-               g_free(in_tuple);
-       }
-
-       {/* home url */
-               gchar *mmsc = NULL;
-               mmsc = (char *)xmlGetProp(cur_node, (const unsigned char *)"mmsc");
-               if (mmsc && svc_category_id == CONTEXT_ROLE_MMS)
-                       in_tuple = g_strdup(mmsc);
-               else
-                       in_tuple = g_strdup("");
-               g_hash_table_insert(in_param, "10", g_strdup(in_tuple));
-               msg("home_url = %s", in_tuple);
-               g_free(in_tuple);
-       }
-
-       {/* default internet connection */
-               int default_internet_con = 1; /* default */
-
-               tmp = g_hash_table_lookup(in_param, "11"); /* network_info_id */
-               if (tmp) {
-                       int network_info_id = atoi((char *)tmp);
-                       msg("network_info_id = %d", network_info_id);
-                       if (network_info_id > 0 && __get_default_profile_from_database(network_info_id, svc_category_id))
-                               default_internet_con = 0;
-               }
-               g_hash_table_insert(in_param, "12", g_strdup_printf("%d", default_internet_con));
-               msg("default_internet_con = %d", default_internet_con);
-       }
-
-       /* insert duplacte profile to database. */
-       return __insert_apns_to_database(in_param);
-}
-
-static GHashTable *__construct_profile_tuples(gpointer node)
-{
-       xmlNode *cur_node = node;
-       GHashTable *in_param = NULL;
-       gchar *in_tuple = NULL;
-       int profile_id = 0, network_info_id = -1, svc_category_id = 0;
-
-       if (!cur_node)
-               return NULL;
-
-       /* Initialize parameters */
-       in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
-
-       {/* profile id */
-               profile_id = __load_profile_id_from_database();
-               profile_id++;
-               g_hash_table_insert(in_param, "1", g_strdup_printf("%d", profile_id));
-               msg("profile_id = %d", profile_id);
-       }
-
-       {/* profile name */
-               gchar *profile_name = NULL;
-               profile_name = (char *)xmlGetProp(cur_node, (const unsigned char *)"carrier");
-               if (profile_name)
-                       in_tuple = g_strdup(profile_name);
-               else
-                       in_tuple = g_strdup_printf("TEMP_PROFILE_%d", profile_id);
-
-               g_hash_table_insert(in_param, "2", g_strdup(in_tuple));
-               msg("profile_name = %s", in_tuple);
-               g_free(in_tuple);
-       }
-
-       {/* apn */
-               gchar *apn = NULL;
-               apn = (char *)xmlGetProp(cur_node, (const unsigned char *)"apn");
-               if (apn)
-                       in_tuple = g_strdup(apn);
-               else
-                       in_tuple = g_strdup("");
-               g_hash_table_insert(in_param, "3", g_strdup(in_tuple));
-               msg("apn = %s", in_tuple);
-               g_free(in_tuple);
-       }
-
-       {/* auth type */
-               gchar *auth_type = NULL, *auth = NULL;
-               auth_type = (char *)xmlGetProp(cur_node, (const unsigned char *)"auth_type");
-               auth = (char *)xmlGetProp(cur_node, (const unsigned char *)"auth");
-               if (auth_type)
-                       in_tuple = g_strdup(auth_type);
-               else if (auth)
-                       in_tuple = g_strdup(auth);
-               else
-                       in_tuple = g_strdup("0"); /* CONTEXT_AUTH_NONE */
-
-               g_hash_table_insert(in_param, "4", g_strdup(in_tuple));
-               msg("auth_type = %s", in_tuple);
-               g_free(in_tuple);
-       }
-
-       {/* auth id */
-               gchar *auth_id = NULL;
-               auth_id = (char *)xmlGetProp(cur_node, (const unsigned char *)"user");
-               if (auth_id)
-                       in_tuple = g_strdup(auth_id);
-               else
-                       in_tuple = g_strdup("");
-               g_hash_table_insert(in_param, "5", g_strdup(in_tuple));
-               msg("auth_id = %s", in_tuple);
-               g_free(in_tuple);
-       }
-
-       {/* auth pwd */
-               gchar *auth_pwd = NULL;
-               auth_pwd = (char *)xmlGetProp(cur_node, (const unsigned char *)"password");
-               if (auth_pwd)
-                       in_tuple = g_strdup(auth_pwd);
-               else
-                       in_tuple = g_strdup("");
-               g_hash_table_insert(in_param, "6", g_strdup(in_tuple));
-               msg("auth_pwd = %s", in_tuple);
-               g_free(in_tuple);
-       }
-
-       {/* pdp protocol */
-               gchar *protocol = NULL;
-               int pdp_protocol = CONTEXT_TYPE_IP;
-               protocol = (char *)xmlGetProp(cur_node, (const unsigned char *)"protocol");
-               if (protocol) {
-                       if (!g_strcmp0(protocol, "IPV6"))
-                               pdp_protocol = CONTEXT_TYPE_IPV6;
-                       else if (!g_strcmp0(protocol, "IPV4V6"))
-                               pdp_protocol = CONTEXT_TYPE_IPV4V6;
-               }
-               g_hash_table_insert(in_param, "7", g_strdup_printf("%d", pdp_protocol));
-               msg("protocol = %s", protocol);
-       }
-
-       {/* service category id */
-               gchar *svc_type = NULL;
-               svc_type = (char *)xmlGetProp(cur_node, (const unsigned char *)"type");
-               if (NULL != g_strrstr(svc_type, "default"))
-                       svc_category_id = CONTEXT_ROLE_INTERNET;
-               else if (!g_strcmp0(svc_type, "mms"))
-                       svc_category_id = CONTEXT_ROLE_MMS;
-               else if (!g_strcmp0(svc_type, "dun"))
-                       svc_category_id = CONTEXT_ROLE_TETHERING;
-
-               g_hash_table_insert(in_param, "8", g_strdup_printf("%d", svc_category_id));
-               msg("svc_category_id = %d", svc_category_id);
-       }
-
-       {/* proxy ip */
-               gchar *proxy_ip_addr = NULL, *proxy = NULL, *port = NULL;
-
-               if (svc_category_id == CONTEXT_ROLE_MMS) {
-                       proxy = (char *)xmlGetProp(cur_node, (const unsigned char *)"mmsproxy");
-                       port = (char *)xmlGetProp(cur_node, (const unsigned char *)"mmsport");
-               } else {
-                       proxy = (char *)xmlGetProp(cur_node, (const unsigned char *)"proxy");
-                       port = (char *)xmlGetProp(cur_node, (const unsigned char *)"port");
-               }
-               if (proxy && port) {
-                       proxy_ip_addr = g_strdup_printf("%s:%s", proxy, port);
-                       in_tuple = g_strdup(proxy_ip_addr);
-                       g_free(proxy_ip_addr);
-               } else {
-                       in_tuple = g_strdup("");
-               }
-               g_hash_table_insert(in_param, "9", g_strdup(in_tuple));
-               msg("proxy_ip_addr = %s", in_tuple);
-               g_free(in_tuple);
-       }
-
-       {/* home url */
-               gchar *mmsc = NULL;
-               mmsc = (char *)xmlGetProp(cur_node, (const unsigned char *)"mmsc");
-               if (mmsc && svc_category_id == CONTEXT_ROLE_MMS)
-                       in_tuple = g_strdup(mmsc);
-               else
-                       in_tuple = g_strdup("");
-               g_hash_table_insert(in_param, "10", g_strdup(in_tuple));
-               msg("home_url = %s", in_tuple);
-               g_free(in_tuple);
-       }
-
-       {/* network info id */
-               gchar *plmn = NULL, *mcc = NULL, *mnc = NULL;
-               mcc = (char *)xmlGetProp(cur_node, (const unsigned char *)"mcc");
-               mnc = (char *)xmlGetProp(cur_node, (const unsigned char *)"mnc");
-
-               if (mcc && mnc) {
-                       plmn = g_strdup_printf("%s%s", mcc, mnc);
-                       msg("mccmnc = %s", plmn);
-                       network_info_id = __get_network_id(plmn);
-                       g_free(plmn);
-               }
-               g_hash_table_insert(in_param, "11", g_strdup_printf("%d", network_info_id));
-               msg("network_info_id = %d", network_info_id);
-       }
-
-       {/* default internet connection */
-               int default_internet_con = 1;
-               if (__get_default_profile_from_database(network_info_id, svc_category_id))
-                       default_internet_con = 0;
-               g_hash_table_insert(in_param, "12", g_strdup_printf("%d", default_internet_con));
-               msg("default_internet_con = %d", default_internet_con);
-       }
-
-       return in_param;
-}
-
-static gboolean __init_global_apns_from_xml(const char *file_path)
-{
-       xmlNode *cur_node = NULL;
-       xmlNodePtr cur, root_node;
-       void *xml_doc = NULL, *xml_root_node = NULL;
-       char *version = NULL;
-       gboolean ret = FALSE;
-
-       /* remove pdp_profile table first. */
-       __reset_database();
-
-       __load_xml_file(file_path, "apns", &xml_doc, &xml_root_node);
-       if (!xml_root_node) {
-               msg("[APNS CONF] Load error - Root node is NULL.");
-               goto EXIT;
-       }
-       root_node = (xmlNodePtr)xml_root_node;
-       version = (char *)xmlGetProp(root_node, (const unsigned char *)"version");
-       if (version)
-               msg("apns-conf.xml <apns version=\"%s\">", version);
-       cur = root_node->xmlChildrenNode;
-       /* Compare property */
-       for (cur_node = cur; cur_node; cur_node = cur_node->next) {
-               if (cur_node->type == XML_ELEMENT_NODE) {
-                       GHashTable *in_param = NULL;
-                       gchar *svc_type = NULL;
-                       gboolean rv = FALSE;
-
-                       in_param = __construct_profile_tuples(cur_node);
-                       rv = __insert_apns_to_database(in_param);
-                       if (rv == FALSE)
-                               continue;
-
-                       /* duplicate profiles for the same APNs */
-                       svc_type = (char *)xmlGetProp(cur_node, (const unsigned char *)"type");
-                       if (NULL != g_strrstr(svc_type, "default")) {
-                               if (NULL != g_strrstr(svc_type, "mms")) {
-                                       /* type="default, supl, mms" */
-                                       __duplicate_profile_by_type(in_param, cur_node, CONTEXT_ROLE_MMS);
-                                       if (NULL != g_strrstr(svc_type, "dun")) {
-                                               /* type="default, supl, mms, dun" */
-                                               __duplicate_profile_by_type(in_param, cur_node, CONTEXT_ROLE_TETHERING);
-                                       }
-                               } else if (NULL != g_strrstr(svc_type, "dun")) {
-                                       /* type="default, supl, dun" */
-                                       __duplicate_profile_by_type(in_param, cur_node, CONTEXT_ROLE_TETHERING);
-                               }
-                       }
-                       g_hash_table_destroy(in_param);
-               }
-       }
-EXIT:
-       __unload_xml_file(&xml_doc, &xml_root_node);
-       return ret;
-}
-
-
-int main(int arg, char **argv)
-{
-       int rv;
-       gchar *command = NULL;
-       __init_global_apns_from_xml("/usr/share/ps-plugin/apns-conf.xml");
-       rv = __system_command("/bin/mkdir /opt/usr/share/telephony");
-       msg("system command sent, rv(%d)", rv);
-       /* remove exist sql */
-       rv = __system_command("/bin/rm /opt/usr/share/telephony/dnet_db_init.sql");
-       msg("system command sent, rv(%d)", rv);
-       /* Dump pdp_profile to sql */
-       command = g_strdup_printf("/usr/bin/sqlite3 %s .dump | grep \"INSERT INTO \\\"pdp_profile\\\"\" > /opt/usr/share/telephony/dnet_db_init.sql", DATABASE_PATH);
-       rv = __system_command(command);
-       msg("system command sent, rv(%d)", rv);
-       g_free(command);
-       return 0;
-}
-