revise logging and coding style
[platform/core/connectivity/nfc-manager-neard.git] / daemon / net_nfc_server_system_handler.c
index fc3c53f..9cdf65f 100644 (file)
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "net_nfc_gdbus.h"
 #include "net_nfc_debug_internal.h"
+#include "net_nfc_gdbus.h"
 #include "net_nfc_server_common.h"
 #include "net_nfc_server_context.h"
 #include "net_nfc_server_system_handler.h"
@@ -24,61 +24,46 @@ static NetNfcGDbusPopup *popup_skeleton = NULL;
 
 static gboolean popup_handle_set(NetNfcGDbusPopup *popup_manager,
                GDBusMethodInvocation *invocation,
-               gboolean state,
-               gint focus_state,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean popup_handle_get(NetNfcGDbusPopup *popup_manager,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean popup_handle_set(NetNfcGDbusPopup *popup_manager,
-               GDBusMethodInvocation *invocation,
-               gboolean state,
+               gint state,
                gint focus_state,
                GVariant *smack_privilege,
                gpointer user_data)
 {
-       INFO_MSG(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       bool ret;
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "w") == false) {
-               DEBUG_ERR_MSG("permission denied, and finished request");
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "w");
+       if (false == ret)
+       {
+               NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
-       net_nfc_server_gdbus_set_launch_state(
-                       g_dbus_method_invocation_get_sender(invocation),
+       net_nfc_server_gdbus_set_launch_state(g_dbus_method_invocation_get_sender(invocation),
                        state, focus_state);
 
-       net_nfc_gdbus_popup_complete_set(popup_manager, invocation);
+       net_nfc_gdbus_popup_complete_set(popup_manager, invocation, NET_NFC_OK);
 
        return TRUE;
 }
 
 static gboolean popup_handle_get(NetNfcGDbusPopup *popup_manager,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege,
-               gpointer user_data)
+               GDBusMethodInvocation *invocation, GVariant *smack_privilege, gpointer user_data)
 {
+       bool ret;
        gboolean state;
 
-       INFO_MSG(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "r") == false) {
-               DEBUG_ERR_MSG("permission denied, and finished request");
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "r");
+       if (false == ret)
+       {
+               NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
@@ -86,49 +71,40 @@ static gboolean popup_handle_get(NetNfcGDbusPopup *popup_manager,
        state = net_nfc_server_gdbus_get_launch_state(
                        g_dbus_method_invocation_get_sender(invocation));
 
-       net_nfc_gdbus_popup_complete_get(popup_manager, invocation, state);
+       net_nfc_gdbus_popup_complete_get(popup_manager, invocation, NET_NFC_OK, state);
 
        return TRUE;
 }
 
 gboolean net_nfc_server_system_handler_init(GDBusConnection *connection)
 {
-       GError *error = NULL;
        gboolean result;
+       GError *error = NULL;
 
        if (popup_skeleton)
                g_object_unref(popup_skeleton);
 
        popup_skeleton = net_nfc_gdbus_popup_skeleton_new();
-       if (popup_skeleton == NULL)
+       if (NULL == popup_skeleton)
        {
-               DEBUG_ERR_MSG("Failed to allocate popup skeleton");
+               NFC_ERR("Failed to allocate popup skeleton");
 
                return FALSE;
        }
 
-       g_signal_connect(popup_skeleton,
-                       "handle-set",
-                       G_CALLBACK(popup_handle_set),
-                       NULL);
-
-       g_signal_connect(popup_skeleton,
-                       "handle-get",
-                       G_CALLBACK(popup_handle_get),
-                       NULL);
-
-       result = g_dbus_interface_skeleton_export(
-                       G_DBUS_INTERFACE_SKELETON(popup_skeleton),
-                       connection,
-                       "/org/tizen/NetNfcService/Popup",
-                       &error);
-       if (result == FALSE)
+       g_signal_connect(popup_skeleton, "handle-set", G_CALLBACK(popup_handle_set), NULL);
+
+       g_signal_connect(popup_skeleton, "handle-get", G_CALLBACK(popup_handle_get), NULL);
+
+       result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(popup_skeleton),
+                       connection, "/org/tizen/NetNfcService/Popup", &error);
+       if (FALSE == result)
        {
-               DEBUG_ERR_MSG("Can not skeleton_export %s", error->message);
+               NFC_ERR("Can not skeleton_export %s", error->message);
 
                g_error_free(error);
-               g_object_unref(popup_skeleton);
-               popup_skeleton = NULL;
+
+               net_nfc_server_system_handler_deinit();
        }
 
        return result;
@@ -136,10 +112,9 @@ gboolean net_nfc_server_system_handler_init(GDBusConnection *connection)
 
 void net_nfc_server_system_handler_deinit(void)
 {
-       if(popup_skeleton)
+       if (popup_skeleton)
        {
                g_object_unref(popup_skeleton);
                popup_skeleton = NULL;
        }
-
 }