tizen 2.4 release accepted/tizen_2.4_mobile accepted/tizen/2.4/mobile/20151029.033509 submit/tizen_2.4/20151028.064035 tizen_2.4_mobile_release
authorjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 07:37:37 +0000 (16:37 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 07:37:37 +0000 (16:37 +0900)
21 files changed:
CMakeLists.txt
include/mobileap.h
include/mobileap_bluetooth.h
include/mobileap_common.h
include/mobileap_handler.h
include/mobileap_notification.h
include/mobileap_softap.h
include/mobileap_usb.h
include/mobileap_wifi.h
include/tethering-dbus-interface.xml
mobileap-agent.manifest
packaging/mobileap-agent.spec
src/mobileap_bluetooth.c
src/mobileap_common.c
src/mobileap_handler.c
src/mobileap_main.c
src/mobileap_network.c
src/mobileap_notification.c
src/mobileap_softap.c
src/mobileap_usb.c
src/mobileap_wifi.c

index 7243cd2..9505780 100755 (executable)
@@ -26,10 +26,11 @@ ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 
 MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 
-INCLUDE_DIRECTORIES(${INCLUDE_DIR})
+INCLUDE_DIRECTORIES(${INCLUDE_DIR} ${CMAKE_SOURCE_DIR})
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED gio-2.0 dlog dbus-glib-1 deviced vconf notification capi-network-connection capi-network-bluetooth appcore-common capi-network-wifi capi-network-wifi-direct alarm-service appsvc libssl)
+pkg_check_modules(pkgs REQUIRED gio-2.0 gio-unix-2.0 dbus-1 dlog  deviced vconf notification capi-network-connection capi-network-bluetooth appcore-common capi-network-wifi capi-network-wifi-direct alarm-service appsvc libssl)
+
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
@@ -44,22 +45,35 @@ IF("${ARCH}" STREQUAL "arm")
        ADD_DEFINITIONS("-DTARGET")
        MESSAGE("add -DTARGET")
 ENDIF("${ARCH}" STREQUAL "arm")
-
-FIND_PROGRAM(DBUS_BINDING_TOOL NAMES dbus-binding-tool)
-EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=tethering ${INCLUDE_DIR}/tethering-dbus-interface.xml --mode=glib-server --output=${INCLUDE_DIR}/tethering-server-stub.h")
+IF(TIZEN_TV)
+       ADD_DEFINITIONS(-DTIZEN_TV)
+ENDIF(TIZEN_TV)
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DVENDOR=\"${APP_VENDOR}\"")
 ADD_DEFINITIONS("-DAPPNAME=\"${APP_NAME}\"")
 ADD_DEFINITIONS("-DAPP_DIR=\"${APP_DIR}\"")
 
+IF(TIZEN_WLAN_BOARD_SPRD)
+       ADD_DEFINITIONS(-DTIZEN_WLAN_BOARD_SPRD)
+ENDIF(TIZEN_WLAN_BOARD_SPRD)
+
 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -pie")
 
-ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+ADD_CUSTOM_COMMAND(
+       WORKING_DIRECTORY
+       OUTPUT ${CMAKE_BINARY_DIR}/tethering-server-stub.c
+       COMMAND gdbus-codegen --interface-prefix org.tizen.
+                       --generate-c-code tethering-server-stub
+                       --c-generate-object-manager
+                       --generate-docbook generated-docs
+                       ${INCLUDE_DIR}/tethering-dbus-interface.xml
+                       COMMENT "Generating GDBus .c/.h")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS} ${CMAKE_BINARY_DIR}/tethering-server-stub.c)
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
 
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/org.tizen.tethering.service DESTINATION share/dbus-1/services)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/org.tizen.tethering.service DESTINATION share/dbus-1/system-services)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tethering_dump.sh DESTINATION /opt/etc/dump.d/module.d/)
 
index a5ad66f..5461349 100644 (file)
 extern "C" {
 #endif
 
-/* Client / Agent common */
-#define DBUS_STRUCT_UINT_STRING (dbus_g_type_get_struct ("GValueArray", \
-                       G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID))
-
-#define DBUS_STRUCT_STATIONS (dbus_g_type_get_struct ("GValueArray", \
-                       G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, \
-                       G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID))
-
-#define DBUS_STRUCT_STATION (dbus_g_type_get_struct ("GValueArray", \
-                       G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, \
-                       G_TYPE_INVALID))
-
-#define DBUS_STRUCT_INTERFACE (dbus_g_type_get_struct ("GValueArray", \
-                       G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, \
-                       G_TYPE_STRING, G_TYPE_INVALID))
-
-
 #define TETHERING_SERVICE_OBJECT_PATH  "/Tethering"
 #define TETHERING_SERVICE_NAME         "org.tizen.tethering"
 #define TETHERING_SERVICE_INTERFACE    "org.tizen.tethering"
@@ -58,11 +41,10 @@ extern "C" {
 #define SIGNAL_NAME_LOW_BATTERY_MODE   "low_batt_mode"
 #define SIGNAL_NAME_FLIGHT_MODE                "flight_mode"
 #define SIGNAL_NAME_POWER_SAVE_MODE            "power_save_mode"
-#define SIGNAL_NAME_DHCP_STATUS                "dhcp_status"
 #define SIGNAL_NAME_SECURITY_TYPE_CHANGED      "security_type_changed"
 #define SIGNAL_NAME_SSID_VISIBILITY_CHANGED    "ssid_visibility_changed"
 #define SIGNAL_NAME_PASSPHRASE_CHANGED         "passphrase_changed"
-
+#define SIGNAL_NAME_DHCP_STATUS                "dhcp_status"
 #define SIGNAL_MSG_NOT_AVAIL_INTERFACE "Interface is not available"
 #define SIGNAL_MSG_TIMEOUT             "There is no connection for a while"
 #define SIGNAL_MSG_SSID_VISIBLE                "ssid_visible"
@@ -114,7 +96,6 @@ typedef enum {
 #define MOBILE_AP_STR_INFO_LEN         20      /**< length of the ip or mac address*/
 #define MOBILE_AP_STR_HOSTNAME_LEN     33      /**< length of the hostname */
 #define MOBILE_AP_NAME_UNKNOWN         "UNKNOWN"
-
 /**
 * Mobile AP error code
 */
index f37f8e2..168b2dd 100644 (file)
 #define PS_RECHECK_INTERVAL 500
 #define PS_RECHECK_COUNT_MAX 5
 
-void _bt_get_remote_device_name(TetheringObject *obj, const char *mac, char **name);
-mobile_ap_error_code_e _disable_bt_tethering(TetheringObject *obj);
+void _bt_get_remote_device_name(const char *mac, char **name);
+mobile_ap_error_code_e _disable_bt_tethering(Tethering *obj);
 gboolean _is_trying_bt_operation(void);
 
-gboolean tethering_enable_bt_tethering(TetheringObject *obj,
-               DBusGMethodInvocation *context);
-gboolean tethering_disable_bt_tethering(TetheringObject *obj,
-               DBusGMethodInvocation *context);
+gboolean tethering_enable_bt_tethering(Tethering *obj,
+               GDBusMethodInvocation *context);
+gboolean tethering_disable_bt_tethering(Tethering *obj,
+               GDBusMethodInvocation *context);
 
 #endif /* __MOBILEAP_BLUETOOTH_H__ */
index c5c1678..475ed7f 100755 (executable)
 #define __MOBILEAP_COMMON_H__
 
 #include <glib.h>
+#include <gio/gio.h>
 
 #include "mobileap_softap.h"
+#include <tethering-server-stub.h>
 
 gint _slist_find_station_by_interface(gconstpointer a, gconstpointer b);
 gint _slist_find_station_by_mac(gconstpointer a, gconstpointer b);
 gint _slist_find_station_by_ip_addr(gconstpointer a, gconstpointer b);
 
-void _emit_mobileap_dbus_signal(TetheringObject *obj,
-               mobile_ap_sig_e num, const gchar *message);
 void _send_dbus_station_info(const char *member,
                mobile_ap_station_info_t *info);
 void _update_station_count(int count);
@@ -37,7 +37,7 @@ int _remove_station_info_all(mobile_ap_type_e type);
 int _get_station_info(gconstpointer data, GCompareFunc func,
                mobile_ap_station_info_t **si);
 int _get_station_count(gconstpointer data, GCompareFunc func, int *count);
-int _station_info_foreach(GFunc func, void *user_data);
+GVariant *_station_info_foreach(void);
 int _add_interface_routing(const char *interface, const in_addr_t gateway);
 int _del_interface_routing(const char *interface, const in_addr_t gateway);
 int _add_routing_rule(const char *interface);
@@ -45,5 +45,5 @@ int _del_routing_rule(const char *interface);
 int _flush_ip_address(const char *interface);
 int _execute_command(const char *cmd);
 int _get_tethering_type_from_ip(const char *ip, mobile_ap_type_e *type);
-
+Tethering *_get_tethering_obj(void);
 #endif /* __MOBILEAP_COMMON_H__ */
index 8315858..91a221e 100644 (file)
@@ -27,7 +27,7 @@ typedef struct {
 } changed_state_t;
 
 void _register_vconf_cb(void *user_data);
-void _unregister_vconf_cb(void *user_data);
+void _unregister_vconf_cb(void);
 
 gboolean _is_power_save_survival_mode(void);
 int _sp_timeout_handler(alarm_id_t alarm_id, void *user_param);
index 7117359..6b38ef6 100644 (file)
@@ -45,7 +45,6 @@
 #define MH_STR_CONFIGURE_TETHERING     "IDS_MOBILEAP_BODY_TAP_TO_CONFIGURE_TETHERING"
 #define MH_STR_TETHERING_ACTIVE        _("IDS_MOBILEAP_BODY_TETHERING_ACTIVE_ABB")
 #define MH_STR_BT_VISIBILITY   _("IDS_ST_BODY_BLUETOOTH_VISIBILITY_HAS_TIMED_OUT_YOUR_DEVICE_MIGHT_NOT_BE_FOUND")
-#define MH_STR_TETHERING_ENABLED       _("IDS_COM_BODY_TETHERING_ENABLED")
 
 int _create_timeout_noti(const char *icon_path);
 int _delete_timeout_noti(void);
index 14ce713..f507323 100755 (executable)
@@ -19,9 +19,8 @@
 #define __MOBILEAP_SOFTAP_H__
 
 #include <glib.h>
+#include <glib-object.h>
 #include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
 #include <dlog.h>
 #include <vconf.h>
 #include <netinet/in.h>
@@ -98,6 +97,7 @@
 #define HOSTAPD_CONF_FILE      "/opt/var/lib/misc/hostapd.conf"
 #define HOSTAPD_CTRL_INTF_DIR  "/opt/var/lib/misc/hostapd"
 #define HOSTAPD_CONF_LEN       1024
+#ifndef TIZEN_WLAN_BOARD_SPRD
 #define HOSTAPD_CONF           "interface=%s\n" \
                                "driver=nl80211\n" \
                                "ctrl_interface=%s\n" \
                                "hw_mode=g\n" \
                                "max_num_sta=%d\n" \
                                "ieee80211n=1\n"
+#else
+#define HOSTAPD_CONF           "interface=%s\n" \
+                               "driver=nl80211\n" \
+                               "ctrl_interface=%s\n" \
+                               "ssid=%s\n" \
+                               "channel=%d\n" \
+                               "ignore_broadcast_ssid=%d\n" \
+                               "hw_mode=g\n" \
+                               "max_num_sta=%d\n" \
+                               "ieee80211n=1\n" \
+                               "wowlan_triggers=any\n"
+#endif
+
 #define HOSTAPD_DEBUG_FILE     "/var/log/hostapd.log"
 #define HOSTAPD_REQ_MAX_LEN    128
 #define HOSTAPD_RETRY_MAX      5
@@ -165,23 +178,6 @@ typedef struct {
 } softap_settings_t;
 
 typedef struct {
-       /* The parent class object state. */
-       GObject parent;
-
-       int init_count;
-
-       softap_settings_t softap_settings;
-} TetheringObject;
-
-typedef struct {
-       /* The parent class state. */
-       GObjectClass parent;
-
-       /* class member */
-       guint signals[E_SIGNAL_MAX];
-} TetheringObjectClass;
-
-typedef struct {
        unsigned int number;    /* Number of connected device */
                                /* BSSID list of connected device */
        char bssid[MOBILE_AP_MAX_WIFI_STA][MOBILE_AP_STR_INFO_LEN];
@@ -221,8 +217,8 @@ void _unregister_wifi_station_handler(void);
 
 void _block_device_sleep(void);
 void _unblock_device_sleep(void);
-int _init_tethering(TetheringObject *obj);
-gboolean _deinit_tethering(TetheringObject *obj);
+int _init_tethering(void);
+gboolean _deinit_tethering(void);
 gboolean _mobileap_clear_state(int state);
 gboolean _terminate_mobileap_agent(gpointer user_data);
 
index 74f9a30..500bd82 100644 (file)
 
 #include "mobileap_softap.h"
 
-mobile_ap_error_code_e _disable_usb_tethering(TetheringObject *obj);
+mobile_ap_error_code_e _disable_usb_tethering(Tethering *obj);
 gboolean _is_trying_usb_operation(void);
 
-gboolean tethering_enable_usb_tethering(TetheringObject *obj,
-                                               DBusGMethodInvocation *context);
-gboolean tethering_disable_usb_tethering(TetheringObject *obj,
-                                               DBusGMethodInvocation *context);
+gboolean tethering_enable_usb_tethering(Tethering *obj,
+                                               GDBusMethodInvocation *context);
+gboolean tethering_disable_usb_tethering(Tethering *obj,
+                                               GDBusMethodInvocation *context);
 #endif /* __MOBILEAP_USB_H__ */
index 61e3f71..07534a0 100644 (file)
@@ -39,40 +39,40 @@ typedef struct {
 } wifi_saved_settings;
 
 int _get_wifi_name_from_lease_info(const char *mac, char **name_buf);
-void _add_wifi_device_to_array(softap_device_info_t *di, GPtrArray *array);
-mobile_ap_error_code_e _enable_wifi_tethering(TetheringObject *obj, gchar *ssid,
+mobile_ap_error_code_e _enable_wifi_tethering(Tethering *obj, gchar *ssid,
        gchar *passphrase, int hide_mode, softap_security_type_e security_type);
-mobile_ap_error_code_e _disable_wifi_tethering(TetheringObject *obj);
+mobile_ap_error_code_e _disable_wifi_tethering(Tethering *obj);
 gboolean _is_trying_wifi_operation(void);
-mobile_ap_error_code_e _reload_softap_settings(TetheringObject *obj,
+mobile_ap_error_code_e _reload_softap_settings(Tethering *obj,
                gchar *ssid, gchar *key, gint hide_mode, gint security_type);
-mobile_ap_error_code_e _reload_softap_settings_for_ap(TetheringObject *obj,
+mobile_ap_error_code_e _reload_softap_settings_for_ap(Tethering *obj,
        gchar *ssid, gchar *key, gint hide_mode, gint security_type);
 
 /* Dbus method */
-mobile_ap_error_code_e _enable_wifi_ap(TetheringObject *obj, gchar *ssid,
+mobile_ap_error_code_e _enable_wifi_ap(Tethering *obj, gchar *ssid,
                gchar *passphrase, int hide_mode,
                 softap_security_type_e security_type);
-mobile_ap_error_code_e _disable_wifi_ap(TetheringObject *obj);
-gboolean tethering_enable_wifi_tethering(TetheringObject *obj, gchar *ssid,
-               gchar *key, gint hide_mode, gint security_type,
-               DBusGMethodInvocation *context);
+mobile_ap_error_code_e _disable_wifi_ap(Tethering *obj);
+gboolean tethering_enable_wifi_tethering(Tethering *obj,
+               GDBusMethodInvocation *context, gchar *ssid,
+               gchar *key, gint visibility, gint security_type);
 
-gboolean tethering_disable_wifi_tethering(TetheringObject *obj,
-               DBusGMethodInvocation *context);
+softap_settings_t  *_get_softap_settings();
 
-gboolean tethering_reload_wifi_settings(TetheringObject *obj, gchar *ssid,
-               gchar *key, gint visibility, gint security_type,
-               DBusGMethodInvocation *context);
+gboolean tethering_disable_wifi_tethering(Tethering *obj,
+               GDBusMethodInvocation *context);
 
-gboolean tethering_reload_wifi_ap_settings(TetheringObject *obj, gchar *ssid,
-                gchar *key, gint hide_mode,
-                gint security, DBusGMethodInvocation *context);
+gboolean tethering_reload_wifi_settings(Tethering *obj,
+               GDBusMethodInvocation *context,
+               gchar *ssid, gchar *key, gint visibility, gint security_type);
 
-gboolean tethering_enable_wifi_ap(TetheringObject *obj, gchar *ssid,
-               gchar *key, gint hide_mode, gint security_type,
-               DBusGMethodInvocation *context);
+gboolean tethering_reload_wifi_ap_settings(Tethering *obj,
+                               GDBusMethodInvocation *context, gchar *ssid, gchar *key,
+                               gint hide_mode, gint security);
 
-gboolean tethering_disable_wifi_ap(TetheringObject *obj,
-               DBusGMethodInvocation *context);
+gboolean tethering_enable_wifi_ap(Tethering *obj, GDBusMethodInvocation *context,
+               gchar *ssid, gchar *key, gint hide_mode, gint security_type);
+
+gboolean tethering_disable_wifi_ap(Tethering *obj,
+               GDBusMethodInvocation *context);
 #endif /* __MOBILEAP_WIFI_H__ */
index ad6127b..0277102 100644 (file)
                <!-- Method definitions -->
 
                <method name="disable">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
                        <arg type="u" name="type" direction="out"/>
                        <arg type="u" name="result" direction="out"/>
                </method>
 
                <method name="enable_wifi_tethering">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
                        <arg type="s" name="ssid" direction="in"/>
                        <arg type="s" name="key" direction="in"/>
                        <arg type="i" name="visibility" direction="in"/>
                        <arg type="i" name="security" direction="in"/>
-                       <arg type="u" name="type" direction="out"/>
                        <arg type="u" name="result" direction="out"/>
                </method>
 
+               <method name="cont_enable_wifi_tethering">
+               </method>
+
+               <method name="cancel_enable_wifi_tethering">
+               </method>
+
                <method name="disable_wifi_tethering">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
                        <arg type="u" name="type" direction="out"/>
                        <arg type="u" name="result" direction="out"/>
                </method>
 
                <method name="enable_bt_tethering">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
-                       <arg type="u" name="type" direction="out"/>
                        <arg type="u" name="result" direction="out"/>
                </method>
 
+               <method name="cont_enable_bt_tethering">
+               </method>
+
+               <method name="cancel_enable_bt_tethering">
+               </method>
+
                <method name="disable_bt_tethering">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
                        <arg type="u" name="type" direction="out"/>
                        <arg type="u" name="result" direction="out"/>
                </method>
 
                <method name="enable_usb_tethering">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
-                       <arg type="u" name="type" direction="out"/>
                        <arg type="u" name="result" direction="out"/>
                </method>
 
+               <method name="cont_enable_usb_tethering">
+               </method>
+
+               <method name="cancel_enable_usb_tethering">
+               </method>
+
                <method name="disable_usb_tethering">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
                        <arg type="u" name="type" direction="out"/>
                        <arg type="u" name="result" direction="out"/>
                </method>
 
                <method name="enable_wifi_ap">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
                        <arg type="s" name="ssid" direction="in"/>
                        <arg type="s" name="key" direction="in"/>
                        <arg type="i" name="visibility" direction="in"/>
                        <arg type="i" name="security" direction="in"/>
-                       <arg type="u" name="type" direction="out"/>
                        <arg type="u" name="result" direction="out"/>
                </method>
 
                <method name="disable_wifi_ap">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
                        <arg type="u" name="type" direction="out"/>
                        <arg type="u" name="result" direction="out"/>
                </method>
 
                <method name="reload_wifi_settings">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
                        <arg type="s" name="ssid" direction="in"/>
                        <arg type="s" name="key" direction="in"/>
                        <arg type="i" name="visibility" direction="in"/>
@@ -81,7 +85,6 @@
                </method>
 
                <method name="reload_wifi_ap_settings">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
                        <arg type="s" name="ssid" direction="in"/>
                        <arg type="s" name="key" direction="in"/>
                        <arg type="i" name="visibility" direction="in"/>
                </method>
 
                <method name="get_station_info">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
-                       <arg type="u" name="type" direction="out"/>
-                       <arg type="a(usssu)" name="station" direction="out"/>
+               <arg type="a(a{sv})" name="station" direction="out"/>
                </method>
 
                <method name="get_data_packet_usage">
-                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
                        <arg type="u" name="type" direction="out"/>
                        <arg type="t" name="rx_data" direction="out"/>
                        <arg type="t" name="tx_data" direction="out"/>
 
                <!-- Signal (D-Bus) definitions -->
                <signal name="net_closed">
-                       <arg type="s" name="arg1" direction="out"/>
                </signal>
 
                <signal name="sta_connected">
                </signal>
 
                <signal name="wifi_on">
-                       <arg type="s" name="arg1" direction="out"/>
                </signal>
 
                <signal name="wifi_off">
                </signal>
 
                <signal name="usb_on">
-                       <arg type="s" name="arg1" direction="out"/>
                </signal>
 
                <signal name="usb_off">
                </signal>
 
                <signal name="bluetooth_on">
-                       <arg type="s" name="arg1" direction="out"/>
                </signal>
 
                <signal name="bluetooth_off">
                </signal>
 
                <signal name="wifi_ap_on">
-                       <arg type="s" name="arg1" direction="out"/>
                </signal>
 
                <signal name="wifi_ap_off">
                </signal>
 
                <signal name="no_data_timeout">
-                       <arg type="s" name="arg1" direction="out"/>
                </signal>
 
                <signal name="low_batt_mode">
-                       <arg type="s" name="arg1" direction="out"/>
                </signal>
 
                <signal name="flight_mode">
-                       <arg type="s" name="arg1" direction="out"/>
                </signal>
+
                <signal name="power_save_mode">
-                       <arg type="s" name="arg1" direction="out"/>
+               </signal>
+
+               <signal name="dhcp_status">
+                       <arg type="s" name="signalName" direction="out"/>
+                       <arg type="u" name="type" direction="out"/>
+                       <arg type="s" name="ip" direction="out"/>
+                       <arg type="s" name="mac" direction="out"/>
+                       <arg type="s" name="hostName" direction="out"/>
+                       <arg type="u" name="tm" direction="out"/>
                </signal>
        </interface>
-</node>
\ No newline at end of file
+</node>
index 9e1197e..327a05f 100644 (file)
@@ -6,9 +6,6 @@
                        <smack request="bt-service::platform" type="w"/>
                        <smack request="bt-service::public" type="w"/>
                        <smack request="secure-storage::tethering" type="rw"/>
-                       <smack request="mdm-server::admin" type="r"/>
-                       <smack request="mdm-server::security" type="r"/>
-                       <smack request="mdm-server::restriction" type="r"/>
                        <smack request="deviced::display" type="rw"/>
                        <smack request="connman" type="rw"/>
                        <smack request="connman::get" type="rw"/>
                        <smack request="alarm-server::alarm" type="w"/>
                        <smack request="system::use_internet" type="w"/>
                        <smack request="telephony_framework::api_ps_public" type="rw"/>
+                       <smack request="tizen::vconf::public::r" type="rwx"/>
+                       <smack request="tizen::vconf::wifidirect" type="rwx"/>
+                       <smack request="tizen::vconf::tethering::admin" type="rwx"/>
+                       <smack request="tizen::vconf::setting::admin" type="rl"/>
+                       <smack request="wifi-direct" type="w"/>
+                       <smack request="syslogd" type="w"/>
+                       <smack request="tizen::vconf::public::r::platform::rw" type="rl"/>
+                       <smack request="device::app_logging" type="rw"/>
+                       <smack request="device::sys_logging" type="rw"/>
+                       <smack request="notification::db" type="rw"/>
+                       <smack request="wpasupplicant" type="rwx"/>
+                       <smack request="_" type="wx"/>
+                       <smack request="sdbd" type="r"/>
+                       <smack request="pkgmgr::db" type="rw"/>
+                       <smack request="dbus" type="rx"/>
+                       <smack request="data-provider-master::notification" type="w"/>
                </request>
                <permit>
                        <smack permit="system::use_internet" type="w"/>
+                       <smack permit="dbus" type="rx"/>
                </permit>
        </define>
        <request>
                <domain name="mobileap-agent"/>
        </request>
        <assign>
-               <filesystem path="/usr/share/dbus-1/services/org.tizen.tethering.service" label="_"/>
+               <filesystem path="/usr/share/dbus-1/system-services/org.tizen.tethering.service" label="_"/>
                <dbus name="org.tizen.tethering" own="mobileap-agent" bus="system">
                        <node name="/Tethering">
                                <interface name="org.tizen.tethering">
index 077d62b..0d9f566 100644 (file)
@@ -1,12 +1,17 @@
 Name:          mobileap-agent
 Summary:       Mobile AP daemon for setting tethering environments
-Version:       1.0.17
+Version:       1.0.36
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
 Source0:       %{name}-%{version}.tar.gz
+
+%if "%{?tizen_profile_name}" == "tv"
+ExcludeArch: %{arm} %ix86 x86_64
+%endif
+
 BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: pkgconfig(gio-2.0)
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(gthread-2.0)
 BuildRequires: pkgconfig(deviced)
@@ -24,7 +29,9 @@ BuildRequires:        pkgconfig(appsvc)
 BuildRequires: pkgconfig(libssl)
 BuildRequires: cmake
 Requires(post):        /usr/bin/vconftool
+%if "%{?tizen_profile_name}" != "tv"
 Requires(post):        bluetooth-agent
+%endif
 Requires(post):        ss-server
 Requires:      iproute2
 Requires:      iptables
@@ -43,6 +50,12 @@ export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
 export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
 
 %cmake -DCMAKE_BUILD_TYPE="" \
+%if "%{?tizen_profile_name}" == "tv"
+       -DTIZEN_TV=1 \
+%endif
+%if "%{?tizen_target_name}" == "Z300H"
+       -DTIZEN_WLAN_BOARD_SPRD=1 \
+%endif
        .
 
 make %{?jobs:-j%jobs}
@@ -52,18 +65,15 @@ make %{?jobs:-j%jobs}
 %make_install
 
 %post
-/usr/bin/vconftool set -t string memory/private/mobileap-agent/ssid "" -u 0 -i -f -s system::vconf_network
-/usr/bin/vconftool set -t int memory/mobile_hotspot/connected_device "0" -u 0 -i -f -s system::vconf_network
-/usr/bin/vconftool set -t int memory/mobile_hotspot/mode "0" -u 0 -i -f -s system::vconf_network
-/usr/bin/vconftool set -t int db/mobile_hotspot/security "1" -u 5000 -f -s system::vconf_network
-/usr/bin/vconftool set -t int db/mobile_hotspot/hide "0" -u 5000 -f -s system::vconf_network
+/usr/bin/vconftool set -t string memory/private/mobileap-agent/ssid "" -u 0 -i -s system::vconf_network
 
 /bin/chmod +x /opt/etc/dump.d/module.d/tethering_dump.sh
 
 %files
 %manifest mobileap-agent.manifest
 %defattr(-,root,root,-)
-/usr/share/dbus-1/services/org.tizen.tethering.service
+/usr/share/dbus-1/system-services/org.tizen.tethering.service
+
 %{_bindir}/mobileap-agent
 /opt/etc/dump.d/module.d/tethering_dump.sh
 
index 43cd1c2..c7e7825 100755 (executable)
 #include <stdio.h>
 #include <glib.h>
 #include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
 #include <bluetooth.h>
+#ifndef TIZEN_TV
+#include <bluetooth_internal.h>
+#endif
 
 #include "mobileap_softap.h"
 #include "mobileap_common.h"
@@ -40,7 +41,7 @@ static __bt_remote_device_s __bt_remote_devices[MOBILE_AP_MAX_BT_STA] = {
        {NULL, NULL, IP_ADDRESS_BT_3},
        {NULL, NULL, IP_ADDRESS_BT_4}};
 
-static DBusGMethodInvocation *g_context = NULL;
+static GDBusMethodInvocation *g_context = NULL;
 
 static void __bt_nap_connection_changed(bool connected, const char *remote_address,
                                const char *interface_name, void *user_data);
@@ -148,7 +149,7 @@ static void __del_bt_remote_all(void)
        return;
 }
 
-static mobile_ap_error_code_e __init_bt(TetheringObject *obj)
+static mobile_ap_error_code_e __init_bt(Tethering *obj)
 {
        int ret;
 
@@ -200,7 +201,7 @@ static gboolean __is_bt_adapter_on(void)
                return FALSE;
 }
 
-gboolean __bt_adapter_timeout_cb(gpointer data)
+gboolean __bt_adapter_timeout_cb(Tethering *obj)
 {
        DBG("+\n");
 
@@ -216,8 +217,7 @@ gboolean __bt_adapter_timeout_cb(gpointer data)
                        ERR("_enable_bt_tethering() is failed because of bt_adapter_eanbled() failed:n");
                        _mobileap_clear_state(MOBILE_AP_STATE_BT);
                        __deinit_bt();
-                       dbus_g_method_return(g_context,
-                                       MOBILE_AP_ENABLE_BT_TETHERING_CFM, MOBILE_AP_ERROR_INTERNAL);
+                       tethering_complete_enable_bt_tethering(obj, g_context, MOBILE_AP_ERROR_INTERNAL);
                        g_context = NULL;
                        _unblock_device_sleep();
                        DBG("-\n");
@@ -229,32 +229,36 @@ gboolean __bt_adapter_timeout_cb(gpointer data)
        }
 }
 
-static mobile_ap_error_code_e __turn_on_bt_adapter(TetheringObject *obj)
+static mobile_ap_error_code_e __turn_on_bt_adapter(gpointer data)
 {
        int ret;
 
+       Tethering *obj = (Tethering *)data;
+
        ret = bt_adapter_enable();
        if (ret == BT_ERROR_NOW_IN_PROGRESS) {
                if (__recheck_bt_adapter_timer) {
                        g_source_remove(__recheck_bt_adapter_timer);
                }
                __recheck_bt_adapter_timer = g_timeout_add(PS_RECHECK_INTERVAL,
-                               __bt_adapter_timeout_cb, NULL);
+                               __bt_adapter_timeout_cb, obj);
                return MOBILE_AP_ERROR_NONE;
        }
 
        if (ret != BT_ERROR_NONE && ret != BT_ERROR_ALREADY_DONE) {
                ERR("bt_adapter_enable is failed : %d\n", ret);
+#ifndef TIZEN_TV
                if (ret == BT_ERROR_PERMISSION_DENIED)
                        return MOBILE_AP_ERROR_PERMISSION_DENIED;
                else
+#endif
                        return MOBILE_AP_ERROR_RESOURCE;
        }
 
        return MOBILE_AP_ERROR_NONE;
 }
 
-static mobile_ap_error_code_e __turn_on_bt_nap(TetheringObject *obj)
+static mobile_ap_error_code_e __turn_on_bt_nap(Tethering *obj)
 {
        int bt_ret = BT_ERROR_NONE;
 
@@ -268,9 +272,11 @@ static mobile_ap_error_code_e __turn_on_bt_nap(TetheringObject *obj)
        if (bt_ret != BT_ERROR_NONE && bt_ret != BT_ERROR_ALREADY_DONE) {
                bt_nap_unset_connection_state_changed_cb();
                ERR("bt_nap_activate is failed : %d\n", bt_ret);
+#ifndef TIZEN_TV
                if (bt_ret == BT_ERROR_PERMISSION_DENIED)
                        return MOBILE_AP_ERROR_PERMISSION_DENIED;
                else
+#endif
                        return MOBILE_AP_ERROR_RESOURCE;
        }
 
@@ -281,11 +287,11 @@ static void __turn_off_bt_nap(void)
 {
        int bt_ret;
 
-       bt_ret = bt_nap_disconnect_all();
+       bt_ret = bt_nap_deactivate();
        if (bt_ret != BT_ERROR_NONE)
-               ERR("bt_nap_disconnect_all is failed : %d\n", bt_ret);
+               ERR("bt_nap_deactivate is failed : %d\n", bt_ret);
        else
-               DBG("bt_nap_disconnect_all is called\n");
+               DBG("bt_nap_deactivate is called\n");
 
        bt_ret = bt_nap_unset_connection_state_changed_cb();
        if (bt_ret != BT_ERROR_NONE)
@@ -294,7 +300,7 @@ static void __turn_off_bt_nap(void)
        return;
 }
 
-mobile_ap_error_code_e _enable_bt_tethering(TetheringObject *obj)
+mobile_ap_error_code_e _enable_bt_tethering(Tethering *obj)
 {
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
 
@@ -309,24 +315,25 @@ mobile_ap_error_code_e _enable_bt_tethering(TetheringObject *obj)
                return MOBILE_AP_ERROR_RESOURCE;
        }
 
-       ret = _init_tethering(obj);
+       ret = _init_tethering();
        if (ret != MOBILE_AP_ERROR_NONE) {
                return ret;
        }
 
        ret = __turn_on_bt_nap(obj);
        if (ret != MOBILE_AP_ERROR_NONE) {
-               _deinit_tethering(obj);
+               _deinit_tethering();
                return ret;
        }
        _delete_timeout_noti();
        _init_timeout_cb(MOBILE_AP_TYPE_BT, (void *)obj);
        _start_timeout_cb(MOBILE_AP_TYPE_BT, time(NULL) + TETHERING_CONN_TIMEOUT);
 
+       DBG("-\n");
        return ret;
 }
 
-mobile_ap_error_code_e _disable_bt_tethering(TetheringObject *obj)
+mobile_ap_error_code_e _disable_bt_tethering(Tethering *obj)
 {
        int ret = BT_ERROR_NONE;
        if (!_mobileap_is_enabled(MOBILE_AP_STATE_BT)) {
@@ -347,7 +354,7 @@ mobile_ap_error_code_e _disable_bt_tethering(TetheringObject *obj)
        __del_bt_remote_all();
        _deinit_timeout_cb(MOBILE_AP_TYPE_BT);
 
-       _deinit_tethering(obj);
+       _deinit_tethering();
        _mobileap_clear_state(MOBILE_AP_STATE_BT);
        _unblock_device_sleep();
 
@@ -417,7 +424,7 @@ static void __bt_adapter_state_changed(int result, bt_adapter_state_e adapter_st
                return;
 
        int ret = MOBILE_AP_ERROR_RESOURCE;
-       TetheringObject *obj = (TetheringObject *)user_data;
+       Tethering *obj = (Tethering *)user_data;
 
        if (result != BT_ERROR_NONE) {
                ERR("BT Adapter operation is failed : %d\n", result);
@@ -428,8 +435,7 @@ static void __bt_adapter_state_changed(int result, bt_adapter_state_e adapter_st
                        "enabled" : "disabled");
        if (adapter_state == BT_ADAPTER_DISABLED) {
                _disable_bt_tethering(obj);
-               _emit_mobileap_dbus_signal(obj, E_SIGNAL_BT_TETHER_OFF,
-                               SIGNAL_MSG_NOT_AVAIL_INTERFACE);
+               tethering_emit_bluetooth_off(obj, SIGNAL_MSG_NOT_AVAIL_INTERFACE);
                return;
        } else {
                ret = _enable_bt_tethering(obj);
@@ -439,9 +445,9 @@ static void __bt_adapter_state_changed(int result, bt_adapter_state_e adapter_st
                        goto FAIL;
                }
 
-               _emit_mobileap_dbus_signal(obj, E_SIGNAL_BT_TETHER_ON, NULL);
-               dbus_g_method_return(g_context,
-                               MOBILE_AP_ENABLE_BT_TETHERING_CFM, ret);
+               tethering_emit_bluetooth_on(obj);
+               _create_tethering_active_noti();
+               tethering_complete_enable_bt_tethering(obj, g_context, ret);
                __handle_bt_adapter_visibility();
                g_context = NULL;
                _unblock_device_sleep();
@@ -450,8 +456,7 @@ static void __bt_adapter_state_changed(int result, bt_adapter_state_e adapter_st
        }
 
 FAIL:
-       dbus_g_method_return(g_context,
-                       MOBILE_AP_ENABLE_BT_TETHERING_CFM, ret);
+       tethering_complete_enable_bt_tethering(obj, g_context, ret);
        g_context = NULL;
        _mobileap_clear_state(MOBILE_AP_STATE_BT);
        _unblock_device_sleep();
@@ -459,9 +464,9 @@ FAIL:
        return;
 }
 
-void _bt_get_remote_device_name(TetheringObject *obj, const char *mac, char **name)
+void _bt_get_remote_device_name(const char *mac, char **name)
 {
-       if (obj == NULL || mac == NULL || name == NULL) {
+       if (mac == NULL || name == NULL) {
                ERR("Invalid param\n");
                return;
        }
@@ -524,8 +529,9 @@ static void __handle_bt_adapter_visibility()
        bt_adapter_set_visibility_mode_changed_cb(__bt_adapter_visibility_changed_cb, NULL);
        DBG("-\n");
 }
-gboolean tethering_enable_bt_tethering(TetheringObject *obj,
-               DBusGMethodInvocation *context)
+
+gboolean tethering_enable_bt_tethering(Tethering *obj,
+               GDBusMethodInvocation *context)
 {
        mobile_ap_error_code_e ret;
        gboolean ret_val = FALSE;
@@ -537,8 +543,7 @@ gboolean tethering_enable_bt_tethering(TetheringObject *obj,
 
        if (g_context) {
                DBG("It is turnning on\n");
-               dbus_g_method_return(context,
-                               MOBILE_AP_ENABLE_BT_TETHERING_CFM,
+               tethering_complete_enable_bt_tethering(obj, context,
                                MOBILE_AP_ERROR_IN_PROGRESS);
                return FALSE;
        }
@@ -559,7 +564,7 @@ gboolean tethering_enable_bt_tethering(TetheringObject *obj,
 
        if (__is_bt_adapter_on() == FALSE) {
                DBG("Bluetooth is deactivated\n");
-               if (__turn_on_bt_adapter(obj) != MOBILE_AP_ERROR_NONE) {
+               if (__turn_on_bt_adapter((gpointer)obj) != MOBILE_AP_ERROR_NONE) {
                        ERR("__turn_on_bt_adapter is failed\n");
                        ret = MOBILE_AP_ERROR_INTERNAL;
                        _mobileap_clear_state(MOBILE_AP_STATE_BT);
@@ -576,23 +581,23 @@ gboolean tethering_enable_bt_tethering(TetheringObject *obj,
                _mobileap_clear_state(MOBILE_AP_STATE_BT);
                __deinit_bt();
        } else {
-               _emit_mobileap_dbus_signal(obj, E_SIGNAL_BT_TETHER_ON, NULL);
+               tethering_emit_bluetooth_on(obj);
+               _create_tethering_active_noti();
                __handle_bt_adapter_visibility();
                ret_val = TRUE;
        }
 
 DONE:
-       dbus_g_method_return(g_context,
-                       MOBILE_AP_ENABLE_BT_TETHERING_CFM, ret);
+       tethering_complete_enable_bt_tethering(obj, g_context, ret);
        g_context = NULL;
 
        _unblock_device_sleep();
-
+       DBG("-\n");
        return ret_val;
 }
 
-gboolean tethering_disable_bt_tethering(TetheringObject *obj,
-               DBusGMethodInvocation *context)
+gboolean tethering_disable_bt_tethering(Tethering *obj,
+               GDBusMethodInvocation *context)
 {
        mobile_ap_error_code_e ret;
 
@@ -603,12 +608,14 @@ gboolean tethering_disable_bt_tethering(TetheringObject *obj,
 
        ret = _disable_bt_tethering(obj);
        if (ret != MOBILE_AP_ERROR_NONE) {
-               dbus_g_method_return(context, MOBILE_AP_DISABLE_BT_TETHERING_CFM, ret);
+               tethering_complete_disable_bt_tethering(obj, context,
+                               MOBILE_AP_DISABLE_BT_TETHERING_CFM, ret);
                return FALSE;
        }
 
-       _emit_mobileap_dbus_signal(obj, E_SIGNAL_BT_TETHER_OFF, NULL);
-       dbus_g_method_return(context, MOBILE_AP_DISABLE_BT_TETHERING_CFM, ret);
+       tethering_emit_bluetooth_off(obj, NULL);
+       tethering_complete_disable_bt_tethering(obj, context,
+                       MOBILE_AP_DISABLE_BT_TETHERING_CFM, ret);
        return TRUE;
 }
 
index 39a1989..adbe599 100755 (executable)
 #include <arpa/inet.h>
 
 #include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
 
 #include "mobileap_notification.h"
 #include "mobileap_common.h"
 
-#define TETHERING_OBJECT_GET_CLASS(obj) \
-       (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-       TETHERING_TYPE_OBJECT , TetheringObjectClass))
-
-extern DBusConnection *tethering_conn;
-
 static GSList *station_list = NULL;
 
 gint _slist_find_station_by_interface(gconstpointer a, gconstpointer b)
@@ -65,61 +57,23 @@ gint _slist_find_station_by_ip_addr(gconstpointer a, gconstpointer b)
        return g_ascii_strcasecmp(si->ip, ip_addr);
 }
 
-void _emit_mobileap_dbus_signal(TetheringObject *obj,
-                               mobile_ap_sig_e num, const gchar *message)
-{
-       TetheringObjectClass *klass = TETHERING_OBJECT_GET_CLASS(obj);
-
-       SDBG("Emitting signal id [%d], with message [%s]\n", num, message);
-
-       if (num == E_SIGNAL_WIFI_TETHER_ON ||
-                       num == E_SIGNAL_USB_TETHER_ON || num == E_SIGNAL_BT_TETHER_ON) {
-               _create_tethering_active_noti();
-       }
-
-       g_signal_emit(obj, klass->signals[num], 0, message);
-}
-
 void _send_dbus_station_info(const char *member, mobile_ap_station_info_t *info)
 {
-       if (tethering_conn == NULL)
-               return;
 
+       DBG("+\n");
        if (member == NULL || info == NULL) {
                ERR("Invalid param\n");
                return;
        }
-
-       DBusMessage *msg = NULL;
-       char *ip = info->ip;
-       char *mac = info->mac;
-       char *hostname = info->hostname;
-
-       msg = dbus_message_new_signal(TETHERING_SERVICE_OBJECT_PATH,
-                       TETHERING_SERVICE_INTERFACE,
-                       SIGNAL_NAME_DHCP_STATUS);
-       if (!msg) {
-               ERR("Unable to allocate D-Bus signal\n");
-               return;
-       }
-
-       if (!dbus_message_append_args(msg,
-                               DBUS_TYPE_STRING, &member,
-                               DBUS_TYPE_UINT32, &info->interface,
-                               DBUS_TYPE_STRING, &ip,
-                               DBUS_TYPE_STRING, &mac,
-                               DBUS_TYPE_STRING, &hostname,
-                               DBUS_TYPE_UINT32, &info->tm,
-                               DBUS_TYPE_INVALID)) {
-               ERR("Event sending failed\n");
-               dbus_message_unref(msg);
+       Tethering *obj = _get_tethering_obj();
+       if (obj == NULL) {
+               ERR("tethering object is null\n");
                return;
        }
-
-       dbus_connection_send(tethering_conn, msg, NULL);
-       dbus_message_unref(msg);
-
-       return;
+       DBG("signal is   %s", member);
+       tethering_emit_dhcp_status(obj, member, info->interface, info->ip, info->mac,
+                       info->hostname, info->tm);
+       DBG("-\n");
 }
 
 void _update_station_count(int count)
@@ -340,16 +294,46 @@ int _get_station_count(gconstpointer data, GCompareFunc func, int *count)
        return MOBILE_AP_ERROR_NONE;
 }
 
-int _station_info_foreach(GFunc func, void *user_data)
+GVariant * _station_info_foreach()
 {
-       if (func == NULL) {
-               ERR("Invalid param\n");
-               return MOBILE_AP_ERROR_INVALID_PARAM;
-       }
+       GSList *l = NULL;
+       GVariant *params = NULL;
+       GVariantBuilder *inner_builder;
+       GVariantBuilder *outer_builder;
+       mobile_ap_station_info_t *st = NULL;
 
-       g_slist_foreach(station_list, func, user_data);
+       outer_builder = g_variant_builder_new(G_VARIANT_TYPE ("a(a{sv})"));
 
-       return MOBILE_AP_ERROR_NONE;
+       for (l = station_list; l != NULL; l = g_slist_next(l)) {
+               st = (mobile_ap_station_info_t *)l->data;
+
+               inner_builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+               g_variant_builder_add(inner_builder, "{sv}", "Type",
+                                       g_variant_new_int32(st->interface));
+               g_variant_builder_add(inner_builder, "{sv}", "IP",
+                                       g_variant_new_string(st->ip));
+               g_variant_builder_add(inner_builder, "{sv}", "MAC",
+                                       g_variant_new_string(st->mac));
+               if (st->hostname) {
+                       g_variant_builder_add(inner_builder, "{sv}", "Name",
+                                               g_variant_new_string(st->hostname));
+               }
+               g_variant_builder_add(inner_builder, "{sv}", "Time",
+                                       g_variant_new_int32(st->tm));
+
+               g_variant_builder_add(outer_builder, "(@a{sv})", g_variant_builder_end(inner_builder));
+
+               g_variant_builder_unref(inner_builder);
+       }
+
+       params = g_variant_new("(@a(a{sv}))", g_variant_builder_end(outer_builder));
+       if (params == NULL) {
+               ERR("params IS NULL\n");
+       } else {
+               SDBG("outer builder print  %s", g_variant_print(params, TRUE));
+       }
+       g_variant_builder_unref(outer_builder);
+       return params;
 }
 
 int _add_interface_routing(const char *interface, const in_addr_t gateway)
index 89915c1..54b701d 100644 (file)
@@ -17,8 +17,6 @@
 
 #include <glib.h>
 #include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
 #include <stdlib.h>
 
 #include "mobileap_softap.h"
@@ -54,7 +52,7 @@ static void __handle_network_cellular_state_changed_cb(keynode_t *key, void *dat
                return;
        }
 
-       TetheringObject *obj = (TetheringObject *)data;
+       Tethering *obj = (Tethering *)data;
        int vconf_key = 0;
 
        if (!_mobileap_is_enabled(MOBILE_AP_STATE_WIFI | MOBILE_AP_STATE_WIFI_AP)) {
@@ -80,7 +78,7 @@ static void __handle_network_cellular_state_changed_cb(keynode_t *key, void *dat
        if (_mobileap_is_enabled(MOBILE_AP_STATE_USB))
                _disable_usb_tethering(obj);
 
-       _emit_mobileap_dbus_signal(obj, E_SIGNAL_FLIGHT_MODE, NULL);
+       tethering_emit_flight_mode(obj);
 
        return;
 }
@@ -92,9 +90,9 @@ static void __handle_device_name_changed_cb(keynode_t *key, void *data)
                return;
        }
 
-       TetheringObject *obj = (TetheringObject *)data;
+       Tethering *obj = (Tethering *)data;
        char *vconf_key = NULL;
-       softap_settings_t new_settings;
+       softap_settings_t *new_settings = _get_softap_settings();
        softap_security_type_e sec_type;
 
        if (!_mobileap_is_enabled(MOBILE_AP_STATE_WIFI | MOBILE_AP_STATE_WIFI_AP)) {
@@ -107,21 +105,19 @@ static void __handle_device_name_changed_cb(keynode_t *key, void *data)
        }
        vconf_key = vconf_keynode_get_str(key);
 
-       if (g_strcmp0(vconf_key, obj->softap_settings.ssid) != 0) {
+       if (g_strcmp0(vconf_key, new_settings->ssid) != 0) {
                DBG("Device name is changed\n");
-               new_settings = obj->softap_settings;
-               if (!g_strcmp0(new_settings.security_type, SOFTAP_SECURITY_TYPE_WPA2_PSK_STR)) {
+               if (!g_strcmp0(new_settings->security_type, SOFTAP_SECURITY_TYPE_WPA2_PSK_STR)) {
                        sec_type = SOFTAP_SECURITY_TYPE_WPA2_PSK;
                } else {
                        sec_type = SOFTAP_SECURITY_TYPE_OPEN;
                }
-               g_strlcpy(new_settings.ssid, vconf_key, sizeof(new_settings.ssid));
                if (_mobileap_is_enabled(MOBILE_AP_STATE_WIFI)) {
-                       _reload_softap_settings(obj, new_settings.ssid, new_settings.key,
-                                       new_settings.hide_mode, sec_type);
+                       _reload_softap_settings(obj, vconf_key, new_settings->key,
+                                       new_settings->hide_mode, sec_type);
                } else if (_mobileap_is_enabled(MOBILE_AP_STATE_WIFI_AP)) {
-                       _reload_softap_settings_for_ap(obj, new_settings.ssid, new_settings.key,
-                                       new_settings.hide_mode, sec_type);
+                       _reload_softap_settings_for_ap(obj, vconf_key, new_settings->key,
+                                       new_settings->hide_mode, sec_type);
                }
        }
        return;
@@ -211,13 +207,8 @@ void _register_vconf_cb(void *user_data)
        return;
 }
 
-void _unregister_vconf_cb(void *user_data)
+void _unregister_vconf_cb(void)
 {
-       if (user_data == NULL) {
-               ERR("Invalid param\n");
-               return;
-       }
-
        vconf_reg_t vconf_reg[] = {
                {VCONFKEY_NETWORK_CELLULAR_STATE,
                        __handle_network_cellular_state_changed_cb, NULL},
@@ -252,7 +243,7 @@ static gboolean __wifi_timeout_cb(gpointer data)
                return FALSE;
        }
 
-       TetheringObject *obj = (TetheringObject *)data;
+       Tethering *obj = (Tethering *)data;
 
        if (_mobileap_is_enabled(MOBILE_AP_STATE_WIFI) == FALSE) {
                ERR("There is no conn. via Wi-Fi tethernig. But nothing to do\n");
@@ -260,9 +251,9 @@ static gboolean __wifi_timeout_cb(gpointer data)
        }
 
        _disable_wifi_tethering(obj);
-       _emit_mobileap_dbus_signal(obj,
-                       E_SIGNAL_WIFI_TETHER_OFF, SIGNAL_MSG_TIMEOUT);
-
+       tethering_emit_wifi_off(obj, SIGNAL_MSG_TIMEOUT);
+       //_launch_toast_popup(MOBILE_AP_TETHERING_TIMEOUT_TOAST_POPUP);
+       _create_timeout_noti(MH_NOTI_ICON_WIFI);
        DBG("-\n");
        return FALSE;
 }
@@ -275,7 +266,7 @@ static gboolean __bt_timeout_cb(gpointer data)
                return FALSE;
        }
 
-       TetheringObject *obj = (TetheringObject *)data;
+       Tethering *obj = (Tethering *)data;
 
        if (_mobileap_is_enabled(MOBILE_AP_STATE_BT) == FALSE) {
                ERR("There is no conn. via BT tethering. But nothing to do\n");
@@ -283,9 +274,9 @@ static gboolean __bt_timeout_cb(gpointer data)
        }
 
        _disable_bt_tethering(obj);
-       _emit_mobileap_dbus_signal(obj,
-                       E_SIGNAL_BT_TETHER_OFF, SIGNAL_MSG_TIMEOUT);
-
+       tethering_emit_bluetooth_off(obj, SIGNAL_MSG_TIMEOUT);
+       //_launch_toast_popup(MOBILE_AP_TETHERING_TIMEOUT_TOAST_POPUP);
+       _create_timeout_noti(MH_NOTI_ICON_BT);
        DBG("-\n");
        return FALSE;
 }
index c906bb4..8d544c0 100644 (file)
@@ -19,8 +19,6 @@
 #include <unistd.h>
 #include <glib.h>
 #include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include "mobileap_notification.h"
 #include "mobileap_iptables.h"
 
-GType tethering_object_get_type(void);
-#define TETHERING_TYPE_OBJECT (tethering_object_get_type())
-G_DEFINE_TYPE(TetheringObject, tethering_object, G_TYPE_OBJECT)
-
 GMainLoop *mainloop = NULL;
 int mobileap_state = MOBILE_AP_STATE_NONE;
-DBusConnection *tethering_conn = NULL;
-
-gboolean tethering_disable(TetheringObject *obj, DBusGMethodInvocation *context);
-gboolean tethering_get_station_info(TetheringObject *obj,
-               DBusGMethodInvocation *context);
-gboolean tethering_get_data_packet_usage(TetheringObject *obj,
-               DBusGMethodInvocation *context);
-
-#include "tethering-server-stub.h"
-
-static void tethering_object_init(TetheringObject *obj)
-{
-       DBG("+\n");
-       g_assert(obj != NULL);
-
-       obj->init_count = 0;
-       memset(&obj->softap_settings, 0x00, sizeof(obj->softap_settings));
-}
-
-static void tethering_object_finalize(GObject *obj)
-{
-       DBG("+\n");
-
-       G_OBJECT_CLASS(tethering_object_parent_class)->finalize(obj);
-}
 
-static void tethering_object_class_init(TetheringObjectClass *klass)
+GDBusObjectManagerServer *manager_server = NULL;
+guint owner_id = 0;
+GDBusConnection *teth_gdbus_conn = NULL;
+Tethering *tethering_obj = NULL;
+static int init_count = 0;
+guint conn_sig_id = 0;
+guint deleted_sig_id = 0;
+gboolean tethering_disable(Tethering *obj, GDBusMethodInvocation *context);
+gboolean tethering_get_station_info(Tethering *obj,
+               GDBusMethodInvocation *context);
+gboolean tethering_get_data_packet_usage(Tethering *obj,
+               GDBusMethodInvocation *context);
+
+Tethering *_get_tethering_obj(void)
 {
-       GObjectClass *object_class = (GObjectClass *)klass;
-       const gchar *signalNames[E_SIGNAL_MAX] = {
-               SIGNAL_NAME_NET_CLOSED,
-               SIGNAL_NAME_STA_CONNECT,
-               SIGNAL_NAME_STA_DISCONNECT,
-               SIGNAL_NAME_WIFI_TETHER_ON,
-               SIGNAL_NAME_WIFI_TETHER_OFF,
-               SIGNAL_NAME_USB_TETHER_ON,
-               SIGNAL_NAME_USB_TETHER_OFF,
-               SIGNAL_NAME_BT_TETHER_ON,
-               SIGNAL_NAME_BT_TETHER_OFF,
-               SIGNAL_NAME_WIFI_AP_ON,
-               SIGNAL_NAME_WIFI_AP_OFF,
-               SIGNAL_NAME_NO_DATA_TIMEOUT,
-               SIGNAL_NAME_LOW_BATTERY_MODE,
-               SIGNAL_NAME_FLIGHT_MODE,
-               SIGNAL_NAME_POWER_SAVE_MODE,
-               SIGNAL_NAME_SECURITY_TYPE_CHANGED,
-               SIGNAL_NAME_SSID_VISIBILITY_CHANGED,
-               SIGNAL_NAME_PASSPHRASE_CHANGED
-       };
-
-       int i = 0;
-
-       g_assert(klass != NULL);
-
-       object_class->finalize = tethering_object_finalize;
-
-       DBG("Creating signals\n");
-
-       for (i = 0; i < E_SIGNAL_MAX; i++) {
-               guint signalId;
-
-               signalId = g_signal_new(signalNames[i],
-                                       G_OBJECT_CLASS_TYPE(klass),
-                                       G_SIGNAL_RUN_LAST,
-                                       0, NULL, NULL,
-                                       g_cclosure_marshal_VOID__STRING,
-                                       G_TYPE_NONE, 1, G_TYPE_STRING);
-               klass->signals[i] = signalId;
-       }
-
-       DBG("Binding to GLib/D-Bus\n");
-
-       dbus_g_object_type_install_info(TETHERING_TYPE_OBJECT,
-                                       &dbus_glib_tethering_object_info);
-}
-
-static void __add_station_info_to_array(gpointer data, gpointer user_data)
-{
-       mobile_ap_station_info_t *si = (mobile_ap_station_info_t *)data;
-       GPtrArray *array = (GPtrArray *)user_data;
-       GValue value = {0, {{0}}};
-
-       g_value_init(&value, DBUS_STRUCT_STATIONS);
-       g_value_take_boxed(&value,
-                       dbus_g_type_specialized_construct(DBUS_STRUCT_STATIONS));
-       dbus_g_type_struct_set(&value, 0, si->interface, 1, si->ip,
-                       2, si->mac, 3, si->hostname, 4, (guint)(si->tm), G_MAXUINT);
-       g_ptr_array_add(array, g_value_get_boxed(&value));
+       return tethering_obj;
 }
 
 gboolean _mobileap_set_state(int state)
@@ -269,14 +192,14 @@ void _unblock_device_sleep(void)
                DBG("PM control [SUCCESS]\n");
 }
 
-int _init_tethering(TetheringObject *obj)
+int _init_tethering(void)
 {
        int ret = MOBILE_AP_ERROR_NONE;
 
-       DBG("obj->init_count: %d\n", obj->init_count);
+       DBG("init_count: %d\n", init_count);
 
-       if (obj->init_count > 0) {
-               obj->init_count++;
+       if (init_count > 0) {
+               init_count++;
                return MOBILE_AP_ERROR_NONE;
        }
 
@@ -285,27 +208,27 @@ int _init_tethering(TetheringObject *obj)
        }
        _mh_core_execute_dhcp_server();
 
-       obj->init_count++;
+       init_count++;
 
        return ret;
 }
 
-gboolean _deinit_tethering(TetheringObject *obj)
+gboolean _deinit_tethering(void)
 {
-       DBG("obj->init_count: %d\n", obj->init_count);
+       DBG("obj->init_count: %d\n", init_count);
 
        guint idle_id;
 
-       if (obj->init_count > 1) {
-               obj->init_count--;
+       if (init_count > 1) {
+               init_count--;
                return TRUE;
-       } else if (obj->init_count <= 0) {
+       } else if (init_count <= 0) {
                ERR("Already deinitialized\n");
-               obj->init_count = 0;
+               init_count = 0;
                return TRUE;
        }
 
-       obj->init_count = 0;
+       init_count = 0;
 
        _mh_core_terminate_dhcp_server();
 
@@ -321,7 +244,7 @@ gboolean _deinit_tethering(TetheringObject *obj)
        return TRUE;
 }
 
-gboolean tethering_disable(TetheringObject *obj, DBusGMethodInvocation *context)
+gboolean tethering_disable(Tethering *obj, GDBusMethodInvocation *context)
 {
        int ret = MOBILE_AP_ERROR_NONE;
 
@@ -332,7 +255,7 @@ gboolean tethering_disable(TetheringObject *obj, DBusGMethodInvocation *context)
        if (_mobileap_is_disabled()) {
                ERR("Mobile hotspot has not been enabled\n");
                ret = MOBILE_AP_ERROR_NOT_ENABLED;
-               dbus_g_method_return(context, MOBILE_AP_DISABLE_CFM, ret);
+               tethering_complete_disable(obj, context, MOBILE_AP_DISABLE_CFM, ret);
                return FALSE;
        }
 
@@ -340,33 +263,32 @@ gboolean tethering_disable(TetheringObject *obj, DBusGMethodInvocation *context)
        _disable_bt_tethering(obj);
        _disable_usb_tethering(obj);
 
-       dbus_g_method_return(context, MOBILE_AP_DISABLE_CFM, ret);
+       tethering_complete_disable(obj, context, MOBILE_AP_DISABLE_CFM, ret);
 
        return TRUE;
 }
 
-gboolean tethering_get_station_info(TetheringObject *obj,
-                                               DBusGMethodInvocation *context)
+gboolean tethering_get_station_info(Tethering *obj,
+                       GDBusMethodInvocation *context)
 {
        DBG("+\n");
 
-       GPtrArray *array = g_ptr_array_new();
+       GVariant *var = NULL;
 
        g_assert(obj != NULL);
        g_assert(context != NULL);
 
-       _station_info_foreach(__add_station_info_to_array, array);
+       var = _station_info_foreach();
 
-       dbus_g_method_return(context, MOBILE_AP_GET_STATION_INFO_CFM, array);
-       g_ptr_array_free(array, TRUE);
+       g_dbus_method_invocation_return_value(context, var);
+       g_variant_unref(var);
 
        DBG("-\n");
-
        return TRUE;
 }
 
-gboolean tethering_get_data_packet_usage(TetheringObject *obj,
-                                               DBusGMethodInvocation *context)
+gboolean tethering_get_data_packet_usage(Tethering *obj,
+                               GDBusMethodInvocation *context)
 {
        char *if_name = NULL;
        unsigned long long wifi_tx_bytes = 0;
@@ -379,7 +301,8 @@ gboolean tethering_get_data_packet_usage(TetheringObject *obj,
        unsigned long long rx_bytes = 0;
 
        if (_get_network_interface_name(&if_name) == FALSE) {
-               dbus_g_method_return(context, MOBILE_AP_GET_DATA_PACKET_USAGE_CFM,
+               tethering_complete_get_data_packet_usage(obj, context,
+                               MOBILE_AP_GET_DATA_PACKET_USAGE_CFM,
                                0ULL, 0ULL);
                return FALSE;
        }
@@ -400,60 +323,53 @@ gboolean tethering_get_data_packet_usage(TetheringObject *obj,
        tx_bytes = wifi_tx_bytes + bt_tx_bytes + usb_tx_bytes;
        rx_bytes = wifi_rx_bytes + bt_rx_bytes + usb_rx_bytes;
 
-       dbus_g_method_return(context, MOBILE_AP_GET_DATA_PACKET_USAGE_CFM,
+       tethering_complete_get_data_packet_usage(obj, context, MOBILE_AP_GET_DATA_PACKET_USAGE_CFM,
                        tx_bytes, rx_bytes);
 
        return TRUE;
 }
 
-static DBusHandlerResult __dnsmasq_signal_filter(DBusConnection *conn,
-               DBusMessage *msg, void *user_data)
+void static __handle_dnsmasq_dhcp_status_changed_cb(GDBusConnection *connection,
+                       const gchar *sender_name, const gchar *object_path,
+                       const gchar *interface_name, const gchar *signal_name,
+                       GVariant *parameters, gpointer user_data)
 {
-       if (!user_data) {
-               ERR("Invalid param\n");
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-       }
-
+       DBG("+\n");
        char *ip_addr = NULL;
        char *mac = NULL;
        char *name = NULL;
        char *bt_remote_device_name = NULL;
-       DBusError error;
        mobile_ap_type_e type = MOBILE_AP_TYPE_MAX;
-       TetheringObject *obj = (TetheringObject *)user_data;
        mobile_ap_station_info_t *info = NULL;
        int n_station = 0;
        time_t tm;
 
-       dbus_error_init(&error);
-       if (dbus_message_is_signal(msg, DNSMASQ_DBUS_INTERFACE,
-                               "DhcpConnected")) {
-               if (!dbus_message_get_args(msg, &error,
-                                       DBUS_TYPE_STRING, &ip_addr,
-                                       DBUS_TYPE_STRING, &mac,
-                                       DBUS_TYPE_STRING, &name,
-                                       DBUS_TYPE_INVALID)) {
-                       ERR("Cannot read message, cause: %s\n", error.message);
-                       dbus_error_free(&error);
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
+       if (signal_name == NULL) {
+               ERR("singal name is NULL\n");
+               return;
+       }
+       g_variant_get(parameters, "(sss)",  &ip_addr, &mac, &name);
+       if (!g_strcmp0(signal_name, "DhcpConnected")) {
                SDBG("DhcpConnected signal : %s  %s %s\n", ip_addr, mac, name);
                /*
                 * DHCP ACK received, destroy timeout if exists
                 */
+               if (ip_addr == NULL || mac == NULL) {
+                       goto EXIT;
+               }
                _destroy_dhcp_ack_timer(mac);
 
                if (_get_tethering_type_from_ip(ip_addr, &type) != MOBILE_AP_ERROR_NONE)
-                       return DBUS_HANDLER_RESULT_HANDLED;
+                       goto EXIT;
 
                if (_mobileap_is_enabled_by_type(type) == FALSE) {
-                       return DBUS_HANDLER_RESULT_HANDLED;
+                       goto EXIT;
                }
 
-               info = (mobile_ap_station_info_t *)malloc(sizeof(mobile_ap_station_info_t));
+               info = (mobile_ap_station_info_t *)g_malloc(sizeof(mobile_ap_station_info_t));
                if (info == NULL) {
                        ERR("malloc failed\n");
-                       return DBUS_HANDLER_RESULT_HANDLED;
+                       goto EXIT;
                }
 
                info->interface = type;
@@ -466,7 +382,7 @@ static DBusHandlerResult __dnsmasq_signal_filter(DBusConnection *conn,
                        else
                                info->hostname = g_strdup(name);
                } else if (type == MOBILE_AP_TYPE_BT) {
-                       _bt_get_remote_device_name(obj, mac, &bt_remote_device_name);
+                       _bt_get_remote_device_name(mac, &bt_remote_device_name);
                        if (bt_remote_device_name == NULL)
                                info->hostname = g_strdup(MOBILE_AP_NAME_UNKNOWN);
                        else
@@ -474,11 +390,11 @@ static DBusHandlerResult __dnsmasq_signal_filter(DBusConnection *conn,
                }
                time(&tm);
                info->tm = tm;
-
                if (_add_station_info(info) != MOBILE_AP_ERROR_NONE) {
+                       ERR("_add_station_info is failed\n");
                        g_free(info->hostname);
-                       free(info);
-                       return DBUS_HANDLER_RESULT_HANDLED;
+                       g_free(info);
+                       goto EXIT;
                }
 
                _get_station_count((gconstpointer)type,
@@ -487,40 +403,120 @@ static DBusHandlerResult __dnsmasq_signal_filter(DBusConnection *conn,
                        _stop_timeout_cb(type);
 
                _send_dbus_station_info("DhcpConnected", info);
-
-               return DBUS_HANDLER_RESULT_HANDLED;
-       } else if (dbus_message_is_signal(msg, DNSMASQ_DBUS_INTERFACE,
-                               "DhcpLeaseDeleted")) {
-               if (!dbus_message_get_args(msg, &error,
-                                       DBUS_TYPE_STRING, &ip_addr,
-                                       DBUS_TYPE_STRING, &mac,
-                                       DBUS_TYPE_STRING, &name,
-                                       DBUS_TYPE_INVALID)) {
-                       ERR("Cannot read message, cause: %s\n", error.message);
-                       dbus_error_free(&error);
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
+       } else if (!g_strcmp0(signal_name, "DhcpLeaseDeleted")) {
                SDBG("DhcpLeaseDeleted signal : %s %s %s\n", ip_addr, mac, name);
-
                _remove_station_info(ip_addr, _slist_find_station_by_ip_addr);
+       } else {
+               SDBG("UNKNOWN member signal\n");
+       }
+EXIT :
+       g_free(ip_addr);
+       g_free(mac);
+       g_free(name);
+       DBG("-\n");
+}
+
+static void on_bus_acquired_cb (GDBusConnection *connection, const gchar *name,
+                               gpointer user_data)
+{
+       DBG("+\n");
+       GDBusInterfaceSkeleton *intf = NULL;
+       teth_gdbus_conn = connection;
 
-               return DBUS_HANDLER_RESULT_HANDLED;
+       manager_server = g_dbus_object_manager_server_new(TETHERING_SERVICE_OBJECT_PATH);
+       if(manager_server == NULL) {
+               DBG("Manager server not created.");
+               return;
        }
+       tethering_obj = tethering_skeleton_new();
+       intf = G_DBUS_INTERFACE_SKELETON(tethering_obj);
+       if (!g_dbus_interface_skeleton_export(intf, connection,
+                       TETHERING_SERVICE_OBJECT_PATH, NULL)) {
+               ERR("Export with path failed");
+       } else {
+               DBG("Export sucessss");
+       }
+
+       g_signal_connect(tethering_obj, "handle-enable-wifi-tethering",
+                       G_CALLBACK(tethering_enable_wifi_tethering), NULL);
+       g_signal_connect(tethering_obj, "handle-enable-bt-tethering",
+                       G_CALLBACK(tethering_enable_bt_tethering), NULL);
+       g_signal_connect(tethering_obj, "handle-enable-usb-tethering",
+                       G_CALLBACK(tethering_enable_usb_tethering), NULL);
+       g_signal_connect(tethering_obj, "handle-disable-wifi-tethering",
+                       G_CALLBACK(tethering_disable_wifi_tethering), NULL);
+       g_signal_connect(tethering_obj, "handle-disable-bt-tethering",
+                       G_CALLBACK(tethering_disable_bt_tethering), NULL);
+       g_signal_connect(tethering_obj, "handle-disable-usb-tethering",
+                       G_CALLBACK(tethering_disable_usb_tethering), NULL);
+       g_signal_connect(tethering_obj, "handle-enable-wifi-ap",
+                       G_CALLBACK(tethering_enable_wifi_ap), NULL);
+
+       g_signal_connect(tethering_obj, "handle-disable-wifi-ap",
+                       G_CALLBACK(tethering_disable_wifi_ap), NULL);
+       g_signal_connect(tethering_obj, "handle-reload-wifi-settings",
+                       G_CALLBACK(tethering_reload_wifi_settings), NULL);
+       g_signal_connect(tethering_obj, "handle-reload-wifi-ap-settings",
+                       G_CALLBACK(tethering_reload_wifi_ap_settings), NULL);
+       g_signal_connect(tethering_obj, "handle-get-station-info",
+                       G_CALLBACK(tethering_get_station_info), NULL);
+       g_signal_connect(tethering_obj, "handle-get-data-packet-usage",
+                       G_CALLBACK(tethering_get_data_packet_usage), NULL);
 
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       _init_network((void *)tethering_obj);
+       _register_vconf_cb((void *)tethering_obj);
+
+       conn_sig_id = g_dbus_connection_signal_subscribe(connection, NULL, DNSMASQ_DBUS_INTERFACE,
+                       "DhcpConnected", NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
+                       __handle_dnsmasq_dhcp_status_changed_cb, NULL, NULL);
+       deleted_sig_id = g_dbus_connection_signal_subscribe(connection, NULL, DNSMASQ_DBUS_INTERFACE,
+                       "DhcpLeaseDeleted", NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
+                       __handle_dnsmasq_dhcp_status_changed_cb, NULL, NULL);
+
+       g_dbus_object_manager_server_set_connection(manager_server, connection);
+       DBG("-\n");
 }
 
-int main(int argc, char **argv)
+static void on_name_acquired_cb(GDBusConnection *connection, const gchar *name,
+               gpointer user_data)
 {
-       const char *rule = "type='signal',interface='"DNSMASQ_DBUS_INTERFACE"'";
+       DBG("+\n");
+
+       DBG("-\n");
+}
+
+static void on_name_lost_db(GDBusConnection *conn, const gchar *name,
+               gpointer user_data)
+{
+       DBG("+\n");
+       /* May service name is already in use */
+       ERR("Service name is already in use");
 
-       TetheringObject *tethering_obj = NULL;
-       DBusGConnection *tethering_bus = NULL;
-       DBusGProxy *tethering_bus_proxy = NULL;
-       DBusError dbus_error;
-       GError *error = NULL;
-       guint result = 0;
-       int ret;
+       /* The result of DBus name request is only permitted,
+        *  such as DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER.
+        */
+       exit(2);
+
+       DBG("-\n");
+}
+
+static int __tethering_setup_gdbus(void)
+{
+       DBG("+\n");
+
+       owner_id = g_bus_own_name(DBUS_BUS_SYSTEM, TETHERING_SERVICE_NAME,
+                               G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired_cb,
+                               on_name_acquired_cb, on_name_lost_db, NULL, NULL);
+
+       if (!owner_id) {
+               ERR("g_bus_own_name is failed\n");
+               return -1;
+       }
+       return 0;
+}
+int main(int argc, char **argv)
+{
+       int ret = 0;
 
        DBG("+\n");
 
@@ -534,57 +530,11 @@ int main(int argc, char **argv)
                return 0;
        }
 
-       /* D-Bus init */
-       tethering_bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
-       if (error != NULL) {
-               ERR("Couldn't connect to system bus[%s]\n", error->message);
-               g_error_free(error);
-               goto failure;
-       }
-
-       tethering_bus_proxy = dbus_g_proxy_new_for_name(tethering_bus,
-                       DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
-       if (tethering_bus_proxy == NULL) {
-               ERR("Failed to get a proxy for D-Bus\n");
-               goto failure;
-       }
-       if (!dbus_g_proxy_call(tethering_bus_proxy, "RequestName", &error,
-                              G_TYPE_STRING, TETHERING_SERVICE_NAME,
-                              G_TYPE_UINT, 0, G_TYPE_INVALID,
-                              G_TYPE_UINT, &result, G_TYPE_INVALID)) {
-               ERR("dbus_g_proxy_call is failed\n");
-               if (error) {
-                       ERR("D-Bus.RequestName RPC failed[%s]\n",
-                                       error->message);
-                       g_error_free(error);
-               }
-               goto failure;
-       }
-       if (result != 1) {
-               ERR("Failed to get the primary well-known name.\n");
-               goto failure;
-       }
-       g_object_unref(tethering_bus_proxy);
-       tethering_bus_proxy = NULL;
-
-       tethering_obj = g_object_new(TETHERING_TYPE_OBJECT, NULL);
-       if (tethering_obj == NULL) {
-               ERR("Failed to create one Tethering instance.\n");
-               goto failure;
-       }
-       dbus_g_connection_register_g_object(tethering_bus,
-                       TETHERING_SERVICE_OBJECT_PATH, G_OBJECT(tethering_obj));
-
-       tethering_conn = dbus_g_connection_get_connection(tethering_bus);
-       dbus_error_init(&dbus_error);
-       dbus_bus_add_match(tethering_conn, rule, &dbus_error);
-       if (dbus_error_is_set(&dbus_error)) {
-               ERR("Cannot add D-BUS match rule, cause: %s", dbus_error.message);
-               dbus_error_free(&dbus_error);
-               goto failure;
+       ret = __tethering_setup_gdbus();
+       if (ret < 0) {
+               ERR("tethering_setup_gdbus is failed\n");
+               return 0;
        }
-       dbus_connection_add_filter(tethering_conn, __dnsmasq_signal_filter, tethering_obj, NULL);
-
        /* Platform modules */
        if (appcore_set_i18n(MOBILEAP_LOCALE_COMMON_PKG, MOBILEAP_LOCALE_COMMON_RES) < 0) {
                ERR("appcore_set_i18n is failed\n");
@@ -595,9 +545,7 @@ int main(int argc, char **argv)
                mobileap_state = MOBILE_AP_STATE_NONE;
        }
 
-       _init_network((void *)tethering_obj);
        _register_wifi_station_handler();
-       _register_vconf_cb((void *)tethering_obj);
 
        ret = wifi_initialize();
        if (ret != WIFI_ERROR_NONE) {
@@ -623,27 +571,16 @@ int main(int argc, char **argv)
                ERR("wifi_deinitialize() is failed : %d\n", ret);
        }
 
-       _unregister_vconf_cb((void *)tethering_obj);
+       _unregister_vconf_cb();
        _unregister_wifi_station_handler();
        _deinit_network();
 
-       dbus_connection_remove_filter(tethering_conn, __dnsmasq_signal_filter, tethering_obj);
-       dbus_bus_remove_match(tethering_conn, rule, NULL);
+       g_dbus_connection_signal_unsubscribe(teth_gdbus_conn, conn_sig_id);
+       g_dbus_connection_signal_unsubscribe(teth_gdbus_conn, deleted_sig_id);
 
        g_object_unref(tethering_obj);
-       dbus_g_connection_unref(tethering_bus);
-
-       DBG("-\n");
-       return 0;
-
- failure:
-       if (tethering_obj)
-               g_object_unref(tethering_obj);
-       if (tethering_bus_proxy)
-               g_object_unref(tethering_bus_proxy);
-       if (tethering_bus)
-               dbus_g_connection_unref(tethering_bus);
-
+       g_bus_unown_name(owner_id);
+       g_object_unref(manager_server);
        DBG("-\n");
        return 0;
 }
index 337faab..3f30fb7 100644 (file)
@@ -54,7 +54,7 @@ typedef struct {
        unsigned short new_dest_port;
 } port_forward_info_s;
 
-static TetheringObject *obj = NULL;
+static Tethering *obj = NULL;
 static connection_h connection = NULL;
 static tethering_cellular_profile_s c_prof = {NULL, __NO_SERVICE};
 static guint net_timeout_id;
@@ -89,9 +89,11 @@ static mobile_ap_error_code_e __get_conn_error(int conn_error)
                err = MOBILE_AP_ERROR_ALREADY_ENABLED;
                break;
 
+#ifndef TIZEN_TV
        case CONNECTION_ERROR_PERMISSION_DENIED:
                err = MOBILE_AP_ERROR_PERMISSION_DENIED;
                break;
+#endif
 
        case CONNECTION_ERROR_DHCP_FAILED:
                err = MOBILE_AP_ERROR_DHCP;
@@ -352,9 +354,7 @@ static void __handle_open_network_error(void)
        ret = _disable_usb_tethering(obj);
        DBG("_disable_usb_tethering returns %d\n", ret);
 
-       _emit_mobileap_dbus_signal(obj, E_SIGNAL_NET_CLOSED, NULL);
-
-       return;
+       tethering_emit_net_closed(obj);
 }
 
 static gboolean __is_equal_profile(connection_profile_h a, connection_profile_h b)
@@ -1128,7 +1128,7 @@ gboolean _init_network(void *user_data)
 
        int ret;
 
-       obj = (TetheringObject *)user_data;
+       obj = (Tethering *)user_data;
 
        ret = connection_create(&connection);
        if (ret != CONNECTION_ERROR_NONE) {
index b338570..b193af4 100644 (file)
 
 #include <glib.h>
 #include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
 #include <stdio.h>
 #include <string.h>
 #include <notification.h>
+#include <notification_list.h>
+#include <notification_text_domain.h>
+#include <notification_internal.h>
 #include <bluetooth.h>
+#include <bundle_internal.h>
 
 #include "mobileap_softap.h"
 #include "mobileap_notification.h"
 
-#define MH_NOTI_LAUNCH_PKGNAME "setting-mobileap-efl"
+#define MH_NOTI_LAUNCH_PKGNAME "ug-setting-mobileap-efl"
 #define MH_NOTI_CALLER_PKGNAME "mobileap-agent"
 #define MH_LOCALE_DOMAIN       "ug-setting-mobileap-efl"
 #define MH_LOCALE_DIR "/usr/ug/res/locale"
@@ -252,7 +254,9 @@ int _create_connected_noti(int count, const char *icon_path)
        b = bundle_create();
        bundle_add(b, "caller", "notification");
 
-       appsvc_set_pkgname(b, "setting-mobileap-efl");
+#ifndef TIZEN_TV
+       appsvc_set_pkgname(b, "ug-setting-mobileap-efl");
+#endif
 
        ret = notification_set_execute_option(noti,
                        NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "Launch", NULL, b);
@@ -439,7 +443,7 @@ void _create_tethering_active_noti(void)
                active_count++;
 
        if (active_count == 1)
-               __create_status_noti(_("IDS_COM_BODY_TETHERING_ENABLED"));
+               __create_status_noti(_("IDS_MOBILEAP_BODY_TETHERING_ACTIVE_ABB"));
 
        return;
 }
@@ -449,10 +453,8 @@ void _create_bt_tethering_active_noti(void)
        int ret;
        bt_adapter_visibility_mode_e mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE;
        int duration;
-       int str_len;
        char *str1 = NULL;
        char *str2 = NULL;
-       char *str = NULL;
 
        if (!_mobileap_is_enabled(MOBILE_AP_STATE_WIFI) &&
                        !_mobileap_is_enabled(MOBILE_AP_STATE_USB)) {
index 42d65cb..e6dc33e 100755 (executable)
@@ -21,7 +21,6 @@
 #include <sys/ioctl.h>
 #include <glib.h>
 #include <glib-object.h>
-#include <dbus/dbus-glib.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -193,8 +192,11 @@ static int __execute_hostapd(const mobile_ap_type_e type, const char *ssid,
                g_free(conf);
                return MOBILE_AP_ERROR_RESOURCE;
        }
-       fputs(conf, fp);
-       g_free(conf);
+
+       if (conf) {
+               fputs(conf, fp);
+               g_free(conf);
+       }
        fclose(fp);
 
        pid = fork();
@@ -1245,17 +1247,6 @@ int _mh_core_disable_masquerade(const char *ext_if)
        return MOBILE_AP_ERROR_NONE;
 }
 
-void _mh_core_add_data_to_array(GPtrArray *array, guint type, gchar *dev_name)
-{
-       GValue value = {0, {{0}}};
-
-       g_value_init(&value, DBUS_STRUCT_UINT_STRING);
-       g_value_take_boxed(&value,
-                       dbus_g_type_specialized_construct(DBUS_STRUCT_UINT_STRING));
-       dbus_g_type_struct_set(&value, 0, type, 1, dev_name, G_MAXUINT);
-       g_ptr_array_add(array, g_value_get_boxed(&value));
-}
-
 int _mh_core_set_ip_address(const char *if_name, const in_addr_t ip)
 {
        struct ifreq ifr;
@@ -1345,8 +1336,11 @@ static gboolean __send_station_event_cb(gpointer data)
 
 static void __handle_station_signal(int sig)
 {
-       g_idle_add(__send_station_event_cb, GINT_TO_POINTER(sig));
-       return;
+       int idle_id = 0;
+       idle_id = g_idle_add(__send_station_event_cb, GINT_TO_POINTER(sig));
+       if (idle_id == 0) {
+               ERR("g_idle_add is failed\n");
+       }
 }
 
 void _register_wifi_station_handler(void)
index 063325c..ae444ac 100755 (executable)
@@ -17,8 +17,6 @@
 
 #include <glib.h>
 #include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/socket.h>
@@ -30,7 +28,7 @@
 #include "mobileap_common.h"
 #include "mobileap_usb.h"
 
-static DBusGMethodInvocation *g_context = NULL;
+static GDBusMethodInvocation *g_context = NULL;
 static gboolean in_progress = FALSE;
 static GDBusConnection *conn = NULL;
 static guint subscription_id = 0;
@@ -54,7 +52,7 @@ static void __usb_device_state_change_cb(GDBusConnection *connection,
        GVariant *parameters, gpointer user_data)
 {
        unsigned int value = 0;
-       TetheringObject *obj = (TetheringObject *)user_data;
+       Tethering *obj = (Tethering *)user_data;
 
        if (NULL == parameters || NULL == obj) {
                ERR("Paramters Invalid \n");
@@ -76,12 +74,10 @@ static void __usb_device_state_change_cb(GDBusConnection *connection,
                _disable_usb_tethering(obj);
 
                if (g_context) {
-                       dbus_g_method_return(g_context, MOBILE_AP_ENABLE_USB_TETHERING_CFM,
-                               MOBILE_AP_ERROR_RESOURCE);
+                       tethering_complete_enable_usb_tethering(obj, g_context, MOBILE_AP_ERROR_RESOURCE);
                        g_context = NULL;
                } else {
-                       _emit_mobileap_dbus_signal(obj, E_SIGNAL_USB_TETHER_OFF,
-                                       SIGNAL_MSG_NOT_AVAIL_INTERFACE);
+                       tethering_emit_usb_off(obj, SIGNAL_MSG_NOT_AVAIL_INTERFACE);
                }
        }
 
@@ -139,9 +135,9 @@ static void __handle_usb_disconnect_cb(keynode_t *key, void *data)
                return;
        }
 
-       char *vconf_name;
+       char *vconf_name = NULL;
        int vconf_key;
-       TetheringObject *obj = (TetheringObject *)data;
+       Tethering *obj = (Tethering *)data;
 
        if (!_mobileap_is_enabled(MOBILE_AP_STATE_USB)) {
                ERR("USB tethering is not enabled\n");
@@ -154,7 +150,15 @@ static void __handle_usb_disconnect_cb(keynode_t *key, void *data)
        }
 
        vconf_name = vconf_keynode_get_name(key);
+       if (vconf_name == NULL) {
+               ERR("vconf_keynode_get_name is failed\n");
+               return;
+       }
        vconf_key = vconf_keynode_get_int(key);
+       if (vconf_key < 0) {
+               ERR("vconf_keynode_get_int is failed\n");
+               return;
+       }
        SDBG("key = %s, value = %d(int)\n", vconf_name, vconf_key);
 
        /*
@@ -172,13 +176,12 @@ static void __handle_usb_disconnect_cb(keynode_t *key, void *data)
        _disable_usb_tethering(obj);
 
        if (g_context) {
-               dbus_g_method_return(g_context,
-                               MOBILE_AP_ENABLE_USB_TETHERING_CFM,
-                               MOBILE_AP_ERROR_RESOURCE);
+               g_dbus_method_invocation_return_value(g_context,
+                               g_variant_new("(uu)", MOBILE_AP_ENABLE_USB_TETHERING_CFM,
+                                               MOBILE_AP_ERROR_RESOURCE));
                g_context = NULL;
        } else {
-               _emit_mobileap_dbus_signal(obj, E_SIGNAL_USB_TETHER_OFF,
-                               SIGNAL_MSG_NOT_AVAIL_INTERFACE);
+               tethering_emit_usb_off(obj, SIGNAL_MSG_NOT_AVAIL_INTERFACE);
        }
 
        return;
@@ -191,7 +194,7 @@ static void __handle_usb_mode_change(keynode_t *key, void *data)
                return;
        }
 
-       TetheringObject *obj = (TetheringObject *)data;
+       Tethering *obj = (Tethering *)data;
        int ret;
        int vconf_key;
        guint idle_id;
@@ -227,21 +230,17 @@ static void __handle_usb_mode_change(keynode_t *key, void *data)
                        ERR("USB Mode is changed suddenly\n");
                        _disable_usb_tethering(obj);
                        if (g_context) {
-                               dbus_g_method_return(g_context,
-                                               MOBILE_AP_ENABLE_USB_TETHERING_CFM,
-                                               MOBILE_AP_ERROR_RESOURCE);
+                               tethering_complete_enable_usb_tethering(obj, g_context, MOBILE_AP_ERROR_RESOURCE);
                                g_context = NULL;
                        }
                        return;
                }
                _add_interface_routing(USB_IF, IP_ADDRESS_USB);
                _add_routing_rule(USB_IF);
-
-               _emit_mobileap_dbus_signal(obj, E_SIGNAL_USB_TETHER_ON, NULL);
+               tethering_emit_usb_on(obj);
+               _create_tethering_active_noti();
                if (g_context) {
-                       dbus_g_method_return(g_context,
-                                       MOBILE_AP_ENABLE_USB_TETHERING_CFM,
-                                       MOBILE_AP_ERROR_NONE);
+                       tethering_complete_enable_usb_tethering(obj, g_context, MOBILE_AP_ERROR_NONE);
                        g_context = NULL;
                }
        } else {
@@ -253,11 +252,9 @@ static void __handle_usb_mode_change(keynode_t *key, void *data)
                DBG("USB tethering is disabled\n");
                vconf_ignore_key_changed(VCONFKEY_SETAPPL_USB_MODE_INT,
                                __handle_usb_mode_change);
-               _emit_mobileap_dbus_signal(obj, E_SIGNAL_USB_TETHER_OFF, NULL);
+               tethering_emit_usb_off(obj, NULL);
                if (g_context) {
-                       dbus_g_method_return(g_context,
-                                       MOBILE_AP_DISABLE_USB_TETHERING_CFM,
-                                       MOBILE_AP_ERROR_NONE);
+                       tethering_complete_disable_usb_tethering(obj, g_context, MOBILE_AP_DISABLE_USB_TETHERING_CFM, NULL);
                        g_context = NULL;
                }
 
@@ -268,7 +265,7 @@ static void __handle_usb_mode_change(keynode_t *key, void *data)
        }
 }
 
-mobile_ap_error_code_e _enable_usb_tethering(TetheringObject *obj)
+mobile_ap_error_code_e _enable_usb_tethering(Tethering *obj)
 {
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
        int vconf_ret;
@@ -298,7 +295,7 @@ mobile_ap_error_code_e _enable_usb_tethering(TetheringObject *obj)
                goto FAIL;
        }
 
-       ret = _init_tethering(obj);
+       ret = _init_tethering();
        if (ret != MOBILE_AP_ERROR_NONE) {
                goto FAIL;
        }
@@ -311,7 +308,7 @@ mobile_ap_error_code_e _enable_usb_tethering(TetheringObject *obj)
                ERR("Error getting vconf\n");
                vconf_ignore_key_changed(VCONFKEY_SETAPPL_USB_MODE_INT,
                                __handle_usb_mode_change);
-               _deinit_tethering(obj);
+               _deinit_tethering();
                ret = MOBILE_AP_ERROR_RESOURCE;
                goto FAIL;
        }
@@ -341,7 +338,7 @@ FAIL:
        return ret;
 }
 
-mobile_ap_error_code_e _disable_usb_tethering(TetheringObject *obj)
+mobile_ap_error_code_e _disable_usb_tethering(Tethering *obj)
 {
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
 
@@ -351,7 +348,7 @@ mobile_ap_error_code_e _disable_usb_tethering(TetheringObject *obj)
                return ret;
        }
 
-       _deinit_tethering(obj);
+       _deinit_tethering();
 
        if (_remove_station_info_all(MOBILE_AP_TYPE_USB) != MOBILE_AP_ERROR_NONE) {
                ERR("_remove_station_info_all is failed. Ignore it\n");
@@ -379,8 +376,7 @@ mobile_ap_error_code_e _disable_usb_tethering(TetheringObject *obj)
        return ret;
 }
 
-gboolean tethering_enable_usb_tethering(TetheringObject *obj,
-               DBusGMethodInvocation *context)
+gboolean tethering_enable_usb_tethering(Tethering *obj, GDBusMethodInvocation *context)
 {
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
        gboolean ret_val = FALSE;
@@ -392,9 +388,7 @@ gboolean tethering_enable_usb_tethering(TetheringObject *obj,
 
        if (g_context) {
                DBG("It is turnning on\n");
-               dbus_g_method_return(context,
-                               MOBILE_AP_ENABLE_USB_TETHERING_CFM,
-                               MOBILE_AP_ERROR_IN_PROGRESS);
+               tethering_complete_enable_usb_tethering(obj, g_context, MOBILE_AP_ERROR_IN_PROGRESS);
                return FALSE;
        }
 
@@ -406,20 +400,21 @@ gboolean tethering_enable_usb_tethering(TetheringObject *obj,
                goto DONE;
        } else {
                DBG("Don't need to wait for usb-setting\n");
-               _emit_mobileap_dbus_signal(obj, E_SIGNAL_USB_TETHER_ON, NULL);
+               tethering_emit_usb_on(obj);
+               _create_tethering_active_noti();
                ret_val = TRUE;
        }
 
 DONE:
-       dbus_g_method_return(g_context,
-                       MOBILE_AP_ENABLE_USB_TETHERING_CFM, ret);
+       tethering_complete_enable_usb_tethering(obj, g_context, ret);
+
        g_context = NULL;
 
        return ret_val;
 }
 
-gboolean tethering_disable_usb_tethering(TetheringObject *obj,
-               DBusGMethodInvocation *context)
+gboolean tethering_disable_usb_tethering(Tethering *obj,
+               GDBusMethodInvocation *context)
 {
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
        int usb_mode = SETTING_USB_NONE_MODE;
@@ -432,7 +427,7 @@ gboolean tethering_disable_usb_tethering(TetheringObject *obj,
 
        if (g_context) {
                DBG("It is turnning on\n");
-               dbus_g_method_return(context,
+               tethering_complete_disable_usb_tethering(obj, context,
                                MOBILE_AP_DISABLE_USB_TETHERING_CFM,
                                MOBILE_AP_ERROR_IN_PROGRESS);
                return FALSE;
@@ -442,7 +437,7 @@ gboolean tethering_disable_usb_tethering(TetheringObject *obj,
 
        ret = _disable_usb_tethering(obj);
        if (ret != MOBILE_AP_ERROR_NONE) {
-               dbus_g_method_return(g_context,
+               tethering_complete_disable_usb_tethering(obj, g_context,
                                MOBILE_AP_DISABLE_USB_TETHERING_CFM, ret);
                g_context = NULL;
                return FALSE;
@@ -469,8 +464,8 @@ gboolean tethering_disable_usb_tethering(TetheringObject *obj,
 DONE:
        vconf_ignore_key_changed(VCONFKEY_SETAPPL_USB_MODE_INT,
                        __handle_usb_mode_change);
-       _emit_mobileap_dbus_signal(obj, E_SIGNAL_USB_TETHER_OFF, NULL);
-       dbus_g_method_return(g_context,
+       tethering_emit_usb_off(obj, NULL);
+       tethering_complete_disable_usb_tethering(obj, g_context,
                        MOBILE_AP_DISABLE_USB_TETHERING_CFM, ret);
        g_context = NULL;
 
index 8f6d505..9423947 100755 (executable)
@@ -17,8 +17,6 @@
 
 #include <glib.h>
 #include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 
 static mobile_ap_error_code_e __update_softap_settings(softap_settings_t *st,
        gchar *ssid, gchar *passphrase, int hide_mode, softap_security_type_e security_type);
-static int __turn_off_wifi(TetheringObject *obj);
+static int __turn_off_wifi(Tethering *obj);
 
-static DBusGMethodInvocation *g_context = NULL;
+static GDBusMethodInvocation *g_context = NULL;
 static guint wifi_recovery_timeout_id = 0;
 static gboolean prev_wifi_on = FALSE;
 static wifi_saved_settings wifi_settings = {0, NULL, NULL, 0};
+static softap_settings_t obj_softap_settings = {0, "", "", ""};
 
+softap_settings_t *_get_softap_settings()
+{
+       return &obj_softap_settings;
+}
 static void _wifi_direct_state_cb(int error_code, wifi_direct_device_state_e state, void *user_data)
 {
        bool wifi_state = false;
@@ -53,7 +56,7 @@ static void _wifi_direct_state_cb(int error_code, wifi_direct_device_state_e sta
                return;
        }
 
-       TetheringObject *obj = (TetheringObject *)user_data;
+       Tethering *obj = (Tethering *)user_data;
        int ret = 0;
 
        if (state != WIFI_DIRECT_DEVICE_STATE_DEACTIVATED) {
@@ -87,12 +90,12 @@ static void _wifi_direct_state_cb(int error_code, wifi_direct_device_state_e sta
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("_enable_wifi_tethering is failed\n");
        } else {
-               _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_TETHER_ON, NULL);
+               tethering_emit_wifi_on(obj);
+               _create_tethering_active_noti();
        }
 
 DONE:
-       dbus_g_method_return(g_context,
-                       MOBILE_AP_ENABLE_WIFI_TETHERING_CFM, ret);
+       tethering_complete_enable_wifi_tethering(obj, g_context, ret);
        g_context = NULL;
 
        g_free(wifi_settings.ssid);
@@ -119,7 +122,7 @@ static void __wifi_deactivated_cb(wifi_error_e result, void *user_data)
                return;
        }
 
-       TetheringObject *obj = (TetheringObject *)user_data;
+       Tethering *obj = (Tethering *)user_data;
        int ret;
 
        if (result != WIFI_ERROR_NONE) {
@@ -136,12 +139,13 @@ static void __wifi_deactivated_cb(wifi_error_e result, void *user_data)
                ERR("_enable_wifi_tethering is failed\n");
        } else {
                prev_wifi_on = TRUE;
-               _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_TETHER_ON, NULL);
+               tethering_emit_wifi_on(obj);
+               _create_tethering_active_noti();
        }
 
 DONE:
-       dbus_g_method_return(g_context,
-                       MOBILE_AP_ENABLE_WIFI_TETHERING_CFM, ret);
+       tethering_complete_enable_wifi_tethering(obj, g_context, ret);
+
        g_context = NULL;
 
        g_free(wifi_settings.ssid);
@@ -152,7 +156,7 @@ DONE:
        return;
 }
 
-static int __turn_off_wifi(TetheringObject *obj)
+static int __turn_off_wifi(Tethering *obj)
 {
        int ret;
 
@@ -216,7 +220,7 @@ static gboolean __is_wifi_direct_on(void)
        return wifi_direct_state != 0 ? TRUE : FALSE;
 }
 
-static int __turn_off_wifi_direct(TetheringObject *obj)
+static int __turn_off_wifi_direct(Tethering *obj)
 {
        int ret;
 
@@ -295,12 +299,12 @@ static gboolean __is_equal_softap_settings(softap_settings_t *a, softap_settings
        return TRUE;
 }
 
-mobile_ap_error_code_e _reload_softap_settings(TetheringObject *obj,
+mobile_ap_error_code_e _reload_softap_settings(Tethering *obj,
                gchar *ssid, gchar *key, gint hide_mode, gint security_type)
 {
        gboolean backup_prev_wifi_on = prev_wifi_on;
        mobile_ap_error_code_e ret;
-       softap_settings_t *old_settings = &obj->softap_settings;
+       softap_settings_t *old_settings = _get_softap_settings();
        softap_settings_t new_settings;
 
        if (obj == NULL || ssid == NULL || !strlen(ssid)) {
@@ -338,17 +342,18 @@ mobile_ap_error_code_e _reload_softap_settings(TetheringObject *obj,
                ERR("_enable_wifi_tethering is failed : %d\n", ret);
                return ret;
        }
-       _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_TETHER_ON, NULL);
+       tethering_emit_wifi_on(obj);
+       _create_tethering_active_noti();
 
        return MOBILE_AP_ERROR_NONE;
 }
 
-mobile_ap_error_code_e _reload_softap_settings_for_ap(TetheringObject *obj,
+mobile_ap_error_code_e _reload_softap_settings_for_ap(Tethering *obj,
        gchar *ssid, gchar *key, gint hide_mode, gint security_type)
 {
        gboolean backup_prev_wifi_on = prev_wifi_on;
        mobile_ap_error_code_e ret;
-       softap_settings_t *old_settings = &obj->softap_settings;
+       softap_settings_t *old_settings = _get_softap_settings();
        softap_settings_t new_settings;
 
        if (obj == NULL || ssid == NULL || !strlen(ssid)) {
@@ -426,62 +431,7 @@ int _get_wifi_name_from_lease_info(const char *mac, char **name_buf)
        return MOBILE_AP_ERROR_NONE;
 }
 
-void _add_wifi_device_to_array(softap_device_info_t *di, GPtrArray *array)
-{
-       int i = 0;
-       GIOChannel *io = NULL;
-       gchar *line = NULL;
-       gchar *device_name = NULL;
-       gchar ip_addr[MOBILE_AP_STR_INFO_LEN] = {0, };
-       gchar mac_addr[MOBILE_AP_STR_INFO_LEN] = {0, };
-       gchar name[MOBILE_AP_STR_HOSTNAME_LEN] = {0, };
-       gchar expire[MOBILE_AP_STR_INFO_LEN] = {0, };
-       gchar extra[MOBILE_AP_STR_INFO_LEN] = {0, };
-
-       int found = 0;
-
-       for (i = 0; i < di->number; i++)
-               SDBG("bssid[%d]:%s\n", i, di->bssid[i]);
-
-       DBG("Number of connected device:%d\n", di->number);
-
-       io = g_io_channel_new_file(DNSMASQ_LEASES_FILE, "r", NULL);
-
-       while (g_io_channel_read_line(io, &line, NULL, NULL, NULL) ==
-                                                       G_IO_STATUS_NORMAL) {
-               sscanf(line, "%19s %19s %19s %19s %19s", expire, mac_addr,
-                                                       ip_addr, name, extra);
-               SDBG("mac_addr:%s ip_addr:%s name:%s expire:%s\n", mac_addr,
-                                                       ip_addr, name, expire);
-
-               for (i = 0; i < di->number; i++) {
-                       if (g_ascii_strcasecmp(di->bssid[i], mac_addr) == 0) {
-                               if (!strcmp(name, "*"))
-                                       device_name = MOBILE_AP_NAME_UNKNOWN;
-                               else
-                                       device_name = name;
-
-                               _mh_core_add_data_to_array(array, MOBILE_AP_TYPE_WIFI,
-                                                               device_name);
-
-                               found++;
-
-                               break;
-                       }
-               }
-
-               g_free(line);
-       }
-       g_io_channel_unref(io);
-
-       /* Set the name UNKNOWN unless we got the name. */
-       for (i = found; i < di->number; i++) {
-               _mh_core_add_data_to_array(array, MOBILE_AP_TYPE_WIFI,
-                                                       MOBILE_AP_NAME_UNKNOWN);
-       }
-}
-
-mobile_ap_error_code_e _enable_wifi_tethering(TetheringObject *obj, gchar *ssid,
+mobile_ap_error_code_e _enable_wifi_tethering(Tethering *obj, gchar *ssid,
        gchar *passphrase, int hide_mode, softap_security_type_e security_type)
 {
        mobile_ap_error_code_e ret;
@@ -514,8 +464,8 @@ mobile_ap_error_code_e _enable_wifi_tethering(TetheringObject *obj, gchar *ssid,
                return ret;
        }
 
-       /* Update Wi-Fi hotspot data to common object */
-       ret = __update_softap_settings(&obj->softap_settings, ssid, passphrase,
+       /* Update Wi-Fi hotspot data to global settings pointer */
+       ret = __update_softap_settings(&obj_softap_settings, ssid, passphrase,
                        hide_mode, security_type);
        if (ret != MOBILE_AP_ERROR_NONE) {
                _mobileap_clear_state(MOBILE_AP_STATE_WIFI);
@@ -523,13 +473,13 @@ mobile_ap_error_code_e _enable_wifi_tethering(TetheringObject *obj, gchar *ssid,
        }
 
        if (vconf_set_str(VCONFKEY_MOBILE_HOTSPOT_SSID,
-                               obj->softap_settings.ssid) < 0) {
+                       obj_softap_settings.ssid) < 0) {
                ERR("vconf_set_str is failed\n");
        }
 
        /* Initialize tethering */
        _block_device_sleep();
-       ret = _init_tethering(obj);
+       ret = _init_tethering();
        if (ret != MOBILE_AP_ERROR_NONE) {
                _mobileap_clear_state(MOBILE_AP_STATE_WIFI);
                goto DONE;
@@ -537,12 +487,12 @@ mobile_ap_error_code_e _enable_wifi_tethering(TetheringObject *obj, gchar *ssid,
 
        /* Upload driver */
        ret = _mh_core_enable_softap(MOBILE_AP_TYPE_WIFI,
-                       obj->softap_settings.ssid,
-                       obj->softap_settings.security_type,
-                       obj->softap_settings.key,
-                       obj->softap_settings.hide_mode);
+                       obj_softap_settings.ssid,
+                       obj_softap_settings.security_type,
+                       obj_softap_settings.key,
+                       obj_softap_settings.hide_mode);
        if (ret != MOBILE_AP_ERROR_NONE) {
-               _deinit_tethering(obj);
+               _deinit_tethering();
                _mobileap_clear_state(MOBILE_AP_STATE_WIFI);
                goto DONE;
        }
@@ -559,9 +509,9 @@ DONE:
        return ret;
 }
 
-mobile_ap_error_code_e _enable_wifi_ap(TetheringObject *obj,
-                gchar *ssid, gchar *passphrase, int hide_mode,
-                softap_security_type_e security_type)
+mobile_ap_error_code_e _enable_wifi_ap(Tethering *obj,
+                                       gchar *ssid, gchar *passphrase, int hide_mode,
+                                       softap_security_type_e security_type)
 {
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
 
@@ -590,8 +540,7 @@ mobile_ap_error_code_e _enable_wifi_ap(TetheringObject *obj,
        if (!_mobileap_set_state(MOBILE_AP_STATE_WIFI_AP)) {
                return MOBILE_AP_ERROR_RESOURCE;
        }
-
-       ret = __update_softap_settings(&obj->softap_settings, ssid, passphrase,
+       ret = __update_softap_settings(&obj_softap_settings, ssid, passphrase,
                        hide_mode, security_type);
        if (ret != MOBILE_AP_ERROR_NONE) {
                _mobileap_clear_state(MOBILE_AP_STATE_WIFI_AP);
@@ -600,7 +549,7 @@ mobile_ap_error_code_e _enable_wifi_ap(TetheringObject *obj,
 
        _block_device_sleep();
 
-       if (_init_tethering(obj) != MOBILE_AP_ERROR_NONE) {
+       if (_init_tethering() != MOBILE_AP_ERROR_NONE) {
                _mobileap_clear_state(MOBILE_AP_STATE_WIFI_AP);
                ret = MOBILE_AP_ERROR_RESOURCE;
                goto DONE;
@@ -608,12 +557,12 @@ mobile_ap_error_code_e _enable_wifi_ap(TetheringObject *obj,
 
        /* Upload driver */
        ret = _mh_core_enable_softap(MOBILE_AP_TYPE_WIFI_AP,
-                       obj->softap_settings.ssid,
-                       obj->softap_settings.security_type,
-                       obj->softap_settings.key,
-                       obj->softap_settings.hide_mode);
+                       obj_softap_settings.ssid,
+                       obj_softap_settings.security_type,
+                       obj_softap_settings.key,
+                       obj_softap_settings.hide_mode);
        if (ret != MOBILE_AP_ERROR_NONE) {
-               _deinit_tethering(obj);
+               _deinit_tethering();
                _mobileap_clear_state(MOBILE_AP_STATE_WIFI_AP);
                goto DONE;
        }
@@ -629,7 +578,7 @@ DONE:
        return ret;
 }
 
-mobile_ap_error_code_e _disable_wifi_tethering(TetheringObject *obj)
+mobile_ap_error_code_e _disable_wifi_tethering(Tethering *obj)
 {
        int ret;
        int state;
@@ -660,7 +609,7 @@ mobile_ap_error_code_e _disable_wifi_tethering(TetheringObject *obj)
                goto DONE;
        }
 
-       _deinit_tethering(obj);
+       _deinit_tethering();
        _mobileap_clear_state(state);
 
        if (prev_wifi_on == TRUE) {
@@ -677,7 +626,7 @@ DONE:
        return ret;
 }
 
-mobile_ap_error_code_e _disable_wifi_ap(TetheringObject *obj)
+mobile_ap_error_code_e _disable_wifi_ap(Tethering *obj)
 {
        int ret;
        int state;
@@ -708,7 +657,7 @@ mobile_ap_error_code_e _disable_wifi_ap(TetheringObject *obj)
                goto DONE;
        }
 
-       _deinit_tethering(obj);
+       _deinit_tethering();
        _mobileap_clear_state(state);
 
        DBG("_disable_wifi_ap is done\n");
@@ -718,26 +667,23 @@ DONE:
        return ret;
 }
 
-gboolean tethering_enable_wifi_tethering(TetheringObject *obj, gchar *ssid,
-               gchar *key, gint visibility, gint security_type,
-               DBusGMethodInvocation *context)
+gboolean tethering_enable_wifi_tethering(Tethering *obj,
+               GDBusMethodInvocation *context, gchar *ssid,
+               gchar *key, gint visibility, gint security_type)
 {
+       DBG("+\n");
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
        gboolean ret_val = FALSE;
        bool wifi_state = false;
-
-       DBG("+\n");
        g_assert(obj != NULL);
        g_assert(context != NULL);
 
        if (g_context) {
                DBG("It is turnning on\n");
-               dbus_g_method_return(context,
-                               MOBILE_AP_ENABLE_WIFI_TETHERING_CFM,
+               tethering_complete_enable_wifi_tethering(obj, g_context,
                                MOBILE_AP_ERROR_IN_PROGRESS);
                return FALSE;
        }
-
        g_context = context;
 
        wifi_settings.ssid = g_strdup(ssid);
@@ -784,13 +730,13 @@ gboolean tethering_enable_wifi_tethering(TetheringObject *obj, gchar *ssid,
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("_enable_wifi_tethering is failed\n");
        } else {
-               _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_TETHER_ON, NULL);
+               tethering_emit_wifi_on(obj);
+               _create_tethering_active_noti();
                ret_val = TRUE;
        }
 
 DONE:
-       dbus_g_method_return(g_context,
-                       MOBILE_AP_ENABLE_WIFI_TETHERING_CFM, ret);
+       tethering_complete_enable_wifi_tethering(obj, g_context, ret);
        g_context = NULL;
 
        g_free(wifi_settings.ssid);
@@ -800,8 +746,8 @@ DONE:
        return ret_val;
 }
 
-gboolean tethering_disable_wifi_tethering(TetheringObject *obj,
-               DBusGMethodInvocation *context)
+gboolean tethering_disable_wifi_tethering(Tethering *obj,
+               GDBusMethodInvocation *context)
 {
        int ret = MOBILE_AP_ERROR_NONE;
 
@@ -811,8 +757,10 @@ gboolean tethering_disable_wifi_tethering(TetheringObject *obj,
 
        ret = _disable_wifi_tethering(obj);
 
-       _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_TETHER_OFF, NULL);
-       dbus_g_method_return(context, MOBILE_AP_DISABLE_WIFI_TETHERING_CFM, ret);
+       tethering_emit_wifi_off(obj, NULL);
+       tethering_complete_disable_wifi_tethering(obj, context,
+                       MOBILE_AP_DISABLE_WIFI_TETHERING_CFM, ret);
+
 
        if (ret != MOBILE_AP_ERROR_NONE)
                return FALSE;
@@ -820,8 +768,8 @@ gboolean tethering_disable_wifi_tethering(TetheringObject *obj,
        return TRUE;
 }
 
-gboolean tethering_enable_wifi_ap(TetheringObject *obj, gchar *ssid, gchar *key,
-       gint visibility, gint security_type, DBusGMethodInvocation *context)
+gboolean tethering_enable_wifi_ap(Tethering *obj, GDBusMethodInvocation *context,
+               gchar *ssid, gchar *key, gint visibility, gint security_type)
 {
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
        gboolean ret_val = FALSE;
@@ -841,17 +789,15 @@ gboolean tethering_enable_wifi_ap(TetheringObject *obj, gchar *ssid, gchar *key,
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("_enable_wifi_tethering is failed\n");
        } else {
-               _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_AP_ON, NULL);
+               tethering_emit_wifi_ap_on(obj);
                ret_val = TRUE;
        }
-
-       dbus_g_method_return(context, MOBILE_AP_ENABLE_WIFI_AP_CFM, ret);
-
+       tethering_complete_enable_wifi_ap(obj, context, ret);
        return ret_val;
 }
 
-gboolean tethering_disable_wifi_ap(TetheringObject *obj,
-               DBusGMethodInvocation *context)
+gboolean tethering_disable_wifi_ap(Tethering *obj,
+               GDBusMethodInvocation *context)
 {
        int ret = MOBILE_AP_ERROR_NONE;
 
@@ -860,9 +806,9 @@ gboolean tethering_disable_wifi_ap(TetheringObject *obj,
        g_assert(context != NULL);
 
        ret = _disable_wifi_ap(obj);
-
-       _emit_mobileap_dbus_signal(obj, E_SIGNAL_WIFI_AP_OFF, NULL);
-       dbus_g_method_return(context, MOBILE_AP_DISABLE_WIFI_AP_CFM, ret);
+       tethering_emit_wifi_ap_off(obj, NULL);
+       tethering_complete_disable_wifi_ap(obj, g_context,
+                       MOBILE_AP_ENABLE_WIFI_AP_CFM, ret);
 
        if (ret != MOBILE_AP_ERROR_NONE)
                return FALSE;
@@ -870,9 +816,9 @@ gboolean tethering_disable_wifi_ap(TetheringObject *obj,
        return TRUE;
 }
 
-gboolean tethering_reload_wifi_settings(TetheringObject *obj, gchar *ssid,
-               gchar *key, gint visibility, gint security_type,
-               DBusGMethodInvocation *context)
+gboolean tethering_reload_wifi_settings(Tethering *obj,
+               GDBusMethodInvocation *context, gchar *ssid,
+               gchar *key, gint visibility, gint security_type)
 {
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
        gboolean ret_val = TRUE;
@@ -887,13 +833,14 @@ gboolean tethering_reload_wifi_settings(TetheringObject *obj, gchar *ssid,
                ret_val = FALSE;
        }
 
-       dbus_g_method_return(context, ret);
+       tethering_complete_reload_wifi_settings(obj, context, ret);
 
        return ret_val;
 }
 
-gboolean tethering_reload_wifi_ap_settings(TetheringObject *obj, gchar *ssid,
-       gchar *key, gint visibility, gint security, DBusGMethodInvocation *context)
+gboolean tethering_reload_wifi_ap_settings(Tethering *obj,
+               GDBusMethodInvocation *context, gchar *ssid,
+       gchar *key, gint visibility, gint security)
 {
 
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
@@ -909,7 +856,7 @@ gboolean tethering_reload_wifi_ap_settings(TetheringObject *obj, gchar *ssid,
                ret_val = FALSE;
        }
 
-       dbus_g_method_return(context, ret);
+       tethering_complete_reload_wifi_ap_settings(obj, context, ret);
        return ret_val;
 }