/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "bt-service-event.h"
#include "bt-service-util.h"
#include "bt-service-obex-agent.h"
-#include "marshal.h"
+#include "bt-service-obex-server.h"
static GDBusConnection *conn = NULL;
+static GDBusConnection *auth_reply_conn = NULL;
static GSList *obex_agent_list = NULL;
typedef struct {
int openobex_id;
int obex_agent_id;
+ int obex_reply_id;
/* callback data */
gpointer authorize_data;
" <method name='Complete'>"
" <annotation name='org.freedesktop.DBus.GLib.Async' value=''/>"
" <arg type='o' name='transfer'/>"
- " </method>"
+" </method>"
" <method name='Release'>"
" <annotation name='org.freedesktop.DBus.GLib.Async' value=''/>"
" </method>"
" </interface>"
"</node>";
+static const gchar obex_service_reply_xml3[] =
+"<node name='/'>"
+" <interface name='org.bluez.obex.reply'>"
+" <method name='ReplyAuthorize'>"
+" <arg type='u' name='accept' direction='in'/>"
+" </method>"
+" </interface>"
+"</node>";
+
static bt_obex_agent_info *__find_obex_agent_info(char *path)
{
GSList *l;
if (info->name == NULL) {
info->name = sender;
} else {
- if (g_strcmp0(sender, info->name) != 0) {
+ if (g_strcmp0(sender, info->name) != 0)
goto fail;
- }
}
if (info->request_cb == NULL)
sender = (char *)g_dbus_method_invocation_get_sender(invocation);
- if (g_strcmp0(sender, info->name) != 0) {
+ if (g_strcmp0(sender, info->name) != 0)
goto fail;
- }
if (info->progress_cb == NULL)
goto fail;
sender = (char *)g_dbus_method_invocation_get_sender(invocation);
- if (g_strcmp0(sender, info->name) != 0) {
+ if (g_strcmp0(sender, info->name) != 0)
goto fail;
- }
if (info->error_cb == NULL)
goto fail;
sender = (char *)g_dbus_method_invocation_get_sender(invocation);
- if (g_strcmp0(sender, info->name) != 0) {
+ if (g_strcmp0(sender, info->name) != 0)
goto fail;
- }
if (info->complete_cb == NULL)
goto fail;
if (info->name) {
/*In H2 if user denies auth,release will come without request and hence
info->name will be NULL */
- if (g_strcmp0(sender, info->name) != 0) {
+ if (g_strcmp0(sender, info->name) != 0)
goto fail;
- }
}
if (info->release_cb == NULL)
info->release_cb(invocation, info->release_data);
return;
+ } else if (g_strcmp0(method_name, "ReplyAuthorize") == 0) {
+ const guint accept;
+
+ g_variant_get(parameters, "(u)", &accept);
+ BT_DBG("Accept: %d", accept);
+
+ if (accept == 0) {
+ BT_DBG("Transfer accepted");
+ _bt_obex_server_reply_accept();
+ } else {
+ BT_ERR("Transfer denied");
+ _bt_obex_server_reject_authorize();
+ }
}
fail:
BT_ERR("Fail case");
g_error_free(error);
return;
}
+ auth_reply_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error != NULL) {
+ BT_ERR("Fail to get dbus: %s", error->message);
+ g_error_free(error);
+ return;
+ }
}
- info = (bt_obex_agent_info *)malloc (sizeof(bt_obex_agent_info));
+ info = (bt_obex_agent_info *)malloc(sizeof(bt_obex_agent_info));
if (info) {
memset(info, 0, sizeof(bt_obex_agent_info));
info->path = g_strdup(path);
if (info->obex_agent_id)
g_dbus_connection_unregister_object(conn,
info->obex_agent_id);
+ if (info->obex_reply_id)
+ g_dbus_connection_unregister_object(auth_reply_conn,
+ info->obex_reply_id);
g_free(info);
}
{
bt_obex_agent_info *info;
GDBusProxy *proxy;
- GDBusNodeInfo *new_conn_node;
+ GDBusNodeInfo *new_conn_node = NULL;
+ GDBusNodeInfo *auth_reply_node = NULL;
GError *err = NULL;
info = __find_obex_agent_info((char *)path);
NULL, NULL, &err);
g_dbus_node_info_unref(new_conn_node);
if (err) {
- BT_INFO("Dbus Err: %s", err->message);
+ BT_ERR("Dbus Err: %s", err->message);
g_clear_error(&err);
return FALSE;
}
if (info->openobex_id == 0)
BT_ERR("Error while registering object");
+
new_conn_node = g_dbus_node_info_new_for_xml(obex_service_agent_xml2, NULL);
+ if (new_conn_node == NULL)
+ return FALSE;
info->obex_agent_id = g_dbus_connection_register_object(conn, info->path,
new_conn_node->interfaces[0],
if (info->obex_agent_id == 0)
BT_ERR("Error while registering object");
if (err) {
- BT_INFO("Dbus Err: %s", err->message);
+ BT_ERR("Dbus Err: %s", err->message);
+ g_clear_error(&err);
+ return FALSE;
+ }
+
+ auth_reply_node = g_dbus_node_info_new_for_xml(obex_service_reply_xml3, NULL);
+
+ if (auth_reply_node == NULL) {
+ BT_ERR("Fail to create the node info for xml");
+ return FALSE;
+ }
+
+ info->obex_reply_id = g_dbus_connection_register_object(auth_reply_conn, info->path,
+ auth_reply_node->interfaces[0], &method_table, NULL, NULL, &err);
+ g_dbus_node_info_unref(auth_reply_node);
+ if (info->obex_reply_id == 0)
+ BT_ERR("Error while registering object");
+ if (err) {
+ BT_ERR("Dbus Err: %s", err->message);
g_clear_error(&err);
return FALSE;
}
bt_obex_authorize_cb func, gpointer data)
{
bt_obex_agent_info *info = __find_obex_agent_info(object_path);;
+ if (info == NULL)
+ return;
- if (info) {
- info->authorize_cb = func;
- info->authorize_data = data;
- }
+ info->authorize_cb = func;
+ info->authorize_data = data;
}
void _bt_obex_set_release_cb(char *object_path,
bt_obex_release_cb func, gpointer data)
{
bt_obex_agent_info *info = __find_obex_agent_info(object_path);;
-
- /* Fix : NULL_RETURNS */
if (info == NULL)
return;
bt_obex_request_cb func, gpointer data)
{
bt_obex_agent_info *info = __find_obex_agent_info(object_path);;
-
- /* Fix : NULL_RETURNS */
if (info == NULL)
return;
bt_obex_progress_cb func, gpointer data)
{
bt_obex_agent_info *info = __find_obex_agent_info(object_path);;
-
- /* Fix : NULL_RETURNS */
if (info == NULL)
return;
void _bt_obex_set_complete_cb(char *object_path,
bt_obex_complete_cb func, gpointer data)
{
- bt_obex_agent_info *info =__find_obex_agent_info(object_path);;
-
- /* Fix : NULL_RETURNS */
+ bt_obex_agent_info *info = __find_obex_agent_info(object_path);;
if (info == NULL)
return;
bt_obex_error_cb func, gpointer data)
{
bt_obex_agent_info *info = __find_obex_agent_info(object_path);;
-
- /* Fix : NULL_RETURNS */
if (info == NULL)
return;