diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c
index c70286e..e29d3c9 100644
--- a/obexd/client/pbap.c
+++ b/obexd/client/pbap.c
*
* OBEX Client
*
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
+ * Copyright (C) 2007-2008 Intel Corporation
+ * Copyright (C) 2007-2008 Marcel Holtmann <marcel@holtmann.org>
+ *
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/stat.h>
-
#include <glib.h>
#include <gdbus.h>
#include "session.h"
+#include "pbap.h"
-static DBusMessage *pbap_pull_phone_book(DBusConnection *connection,
+static DBusMessage *pbap_pull_phonebook(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
return NULL;
}
-static DBusMessage *pbap_set_phone_book(DBusConnection *connection,
+static DBusMessage *pbap_set_phonebook(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
return NULL;
return NULL;
}
-GDBusMethodTable pbap_methods[] = {
-/* PullPhoneBook input parameters : Name, Filter, Format, MaxListCount, ListStartOffset */
- { "PullPhoneBook", "styqq", "s", pbap_pull_phone_book,
+static GDBusMethodTable pbap_methods[] = {
+ /* PullPhoneBook input parameters : Name, Filter, Format,
+ MaxListCount, ListStartOffset */
+ { "PullPhoneBook", "styqq", "s", pbap_pull_phonebook,
G_DBUS_METHOD_FLAG_ASYNC },
-/* SetPhoneBook input parameters : Name */
- { "SetPhoneBook", "s", "", pbap_set_phone_book },
-/* PullvCardListing input parameters : Name, Order, SearchValue, SearchAttribute, MaxListCount, ListStartOffset */
+ /* SetPhoneBook input parameters : Name */
+ { "SetPhoneBook", "s", "", pbap_set_phonebook },
+ /* PullvCardListing input parameters : Name, Order, SearchValue,
+ SearchAttribute, MaxListCount, ListStartOffset */
{ "PullvCardListing", "sysyqq", "s", pbap_pull_vcard_listing,
G_DBUS_METHOD_FLAG_ASYNC },
-/* PullPhoneBook input parameters : Name, Filter, Format */
+ /* PullPhoneBook input parameters : Name, Filter, Format */
{ "PullvCardEntry", "sty", "s", pbap_pull_vcard_entry,
G_DBUS_METHOD_FLAG_ASYNC },
{ }
};
+
+gboolean pbap_register_interface(DBusConnection *connection, const char *path,
+ void *user_data, GDBusDestroyFunction destroy)
+{
+ return g_dbus_register_interface(connection, path, PBAP_INTERFACE,
+ pbap_methods, NULL, NULL, user_data, destroy);
+}
+
+void pbap_unregister_interface(DBusConnection *connection, const char *path)
+{
+ g_dbus_unregister_interface(connection, path, PBAP_INTERFACE);
+}
diff --git a/obexd/client/pbap.h b/obexd/client/pbap.h
new file mode 100644
index 0000000..76d7819
--- /dev/null
+++ b/obexd/client/pbap.h
+/*
+ *
+ * OBEX Client
+ *
+ * Copyright (C) 2007-2008 Intel Corporation
+ * Copyright (C) 2007-2008 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <gdbus.h>
+
+#define PBAP_INTERFACE "org.openobex.PhonebookAccess"
+
+gboolean pbap_register_interface(DBusConnection *connection, const char *path,
+ void *user_data, GDBusDestroyFunction destroy);
+void pbap_unregister_interface(DBusConnection *connection, const char *path);
diff --git a/obexd/client/session.c b/obexd/client/session.c
index 2e2c159..30231fd 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
+#include "pbap.h"
#include "session.h"
#define AGENT_INTERFACE "org.openobex.Agent"
#define SESSION_BASEPATH "/org/openobex"
#define FTP_INTERFACE "org.openobex.FileTransfer"
-#define PBAP_INTERFACE "org.openobex.PhonebookAccess"
#define DEFAULT_BUFFER_SIZE 4096
-extern GDBusMethodTable pbap_methods[];
-
static guint64 counter = 0;
struct callback_data {
close(session->sock);
if (session->conn) {
- if (session->transfer_path)
- g_dbus_unregister_interface(session->conn,
- session->transfer_path, TRANSFER_INTERFACE);
+ if (session->transfer_path) {
+ switch (session->uuid) {
+ case OBEX_FILETRANS_SVCLASS_ID:
+ g_dbus_unregister_interface(session->conn,
+ session->transfer_path,
+ TRANSFER_INTERFACE);
+ break;
+ case PBAP_PSE_SVCLASS_ID:
+ pbap_unregister_interface(session->conn,
+ session->transfer_path);
+ break;
+ }
+ }
dbus_connection_unref(session->conn);
}
return;
complete:
-
if (len == 0)
agent_notify_complete(session->conn, session->agent_name,
session->agent_path, session->transfer_path);
int session_register(struct session_data *session)
{
- GDBusMethodTable *methods;
- const char *iface;
+ gboolean result = FALSE;
+
+ session->path = g_strdup_printf("%s/session%ju",
+ SESSION_BASEPATH, counter++);
+
+ if (g_dbus_register_interface(session->conn, session->path,
+ SESSION_INTERFACE, session_methods,
+ NULL, NULL, session, NULL) == FALSE)
+ return -EIO;
switch (session->uuid) {
case OBEX_FILETRANS_SVCLASS_ID:
- iface = FTP_INTERFACE;
- methods = ftp_methods;
+ result = g_dbus_register_interface(session->conn,
+ session->path, FTP_INTERFACE,
+ ftp_methods, NULL, NULL, session, NULL);
break;
case PBAP_PSE_SVCLASS_ID:
- iface = PBAP_INTERFACE;
- methods = pbap_methods;
+ result = pbap_register_interface(session->conn,
+ session->path, session, NULL);
break;
- default:
- return -EINVAL;
}
- session->path = g_strdup_printf("%s/session%ju",
- SESSION_BASEPATH, counter++);
-
- if (g_dbus_register_interface(session->conn, session->path,
- SESSION_INTERFACE,
- session_methods, NULL, NULL,
- session, NULL) == FALSE)
- return -EIO;
-
- if (g_dbus_register_interface(session->conn, session->path,
- iface,
- methods, NULL, NULL,
- session, NULL) == FALSE) {
+ if (result == FALSE) {
g_dbus_unregister_interface(session->conn,
- session->path, SESSION_INTERFACE);
+ session->path, SESSION_INTERFACE);
return -EIO;
}
session->owner_watch = g_dbus_add_disconnect_watch(session->conn,
- session->owner, owner_disconnected, session,
- NULL);
+ session->owner, owner_disconnected,
+ session, NULL);
session_ref(session);