diff --git a/obexd/client/ftp.c b/obexd/client/ftp.c
index 5d1fa5c..e81d443 100644
--- a/obexd/client/ftp.c
+++ b/obexd/client/ftp.c
#include <config.h>
#endif
+#include <errno.h>
#include <string.h>
+#include <gw-obex.h>
+#include <gdbus.h>
+
+#include "log.h"
+
#include "session.h"
#include "transfer.h"
+#include "driver.h"
#include "ftp.h"
-#define FTP_INTERFACE "org.openobex.FileTransfer"
+#define FTP_INTERFACE "org.openobex.FileTransfer"
+#define FTP_UUID "00001106-0000-1000-8000-00805f9b34fb"
+#define PCSUITE_UUID "00005005-0000-1000-8000-0002ee000001"
+
+static DBusConnection *conn = NULL;
struct ftp_data {
struct obc_session *session;
- DBusConnection *conn;
DBusMessage *msg;
};
else
reply = dbus_message_new_method_return(ftp->msg);
- g_dbus_send_message(ftp->conn, reply);
+ g_dbus_send_message(conn, reply);
dbus_message_unref(ftp->msg);
ftp->msg = NULL;
obc_transfer_clear_buffer(transfer);
done:
- g_dbus_send_message(ftp->conn, reply);
+ g_dbus_send_message(conn, reply);
dbus_message_unref(ftp->msg);
ftp->msg = NULL;
}
struct ftp_data *ftp = data;
obc_session_unref(ftp->session);
- dbus_connection_unref(ftp->conn);
g_free(ftp);
}
-gboolean ftp_register_interface(DBusConnection *connection, const char *path,
- void *user_data)
+static int ftp_probe(struct obc_session *session)
{
- struct obc_session *session = user_data;
struct ftp_data *ftp;
+ const char *path;
+
+ path = obc_session_get_path(session);
+
+ DBG("%s", path);
ftp = g_try_new0(struct ftp_data, 1);
if (!ftp)
- return FALSE;
+ return -ENOMEM;
ftp->session = obc_session_ref(session);
- ftp->conn = dbus_connection_ref(connection);
- if (!g_dbus_register_interface(connection, path, FTP_INTERFACE,
- ftp_methods, NULL, NULL, ftp, ftp_free)) {
+ if (!g_dbus_register_interface(conn, path, FTP_INTERFACE, ftp_methods,
+ NULL, NULL, ftp, ftp_free)) {
ftp_free(ftp);
- return FALSE;
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+static void ftp_remove(struct obc_session *session)
+{
+ const char *path = obc_session_get_path(session);
+
+ DBG("%s", path);
+
+ g_dbus_unregister_interface(conn, path, FTP_INTERFACE);
+}
+
+static struct obc_driver ftp = {
+ .service = "FTP",
+ .uuid = FTP_UUID,
+ .target = OBEX_FTP_UUID,
+ .target_len = OBEX_FTP_UUID_LEN,
+ .probe = ftp_probe,
+ .remove = ftp_remove
+};
+
+static struct obc_driver pcsuite = {
+ .service = "PCSUITE",
+ .uuid = PCSUITE_UUID,
+ .target = OBEX_FTP_UUID,
+ .target_len = OBEX_FTP_UUID_LEN,
+ .probe = ftp_probe,
+ .remove = ftp_remove
+};
+
+int ftp_init(void)
+{
+ int err;
+
+ DBG("");
+
+ conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+ if (!conn)
+ return -EIO;
+
+ err = obc_driver_register(&ftp);
+ if (err < 0)
+ goto failed;
+
+ err = obc_driver_register(&pcsuite);
+ if (err < 0) {
+ obc_driver_unregister(&ftp);
+ goto failed;
}
- return TRUE;
+ return 0;
+
+failed:
+ dbus_connection_unref(conn);
+ conn = NULL;
+ return err;
}
-void ftp_unregister_interface(DBusConnection *connection, const char *path)
+void ftp_exit(void)
{
- g_dbus_unregister_interface(connection, path, FTP_INTERFACE);
+ DBG("");
+
+ dbus_connection_unref(conn);
+ conn = NULL;
+
+ obc_driver_unregister(&ftp);
+ obc_driver_unregister(&pcsuite);
}
diff --git a/obexd/client/ftp.h b/obexd/client/ftp.h
index 1af2a3d..3d90968 100644
--- a/obexd/client/ftp.h
+++ b/obexd/client/ftp.h
*
* OBEX Client
*
- * Copyright (C) 2007-2010 Intel Corporation
* Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org>
*
*
*
*/
-#include <gdbus.h>
-
-gboolean ftp_register_interface(DBusConnection *connection, const char *path,
- void *user_data);
-void ftp_unregister_interface(DBusConnection *connection, const char *path);
+int ftp_init(void);
+void ftp_exit(void);
diff --git a/obexd/client/manager.c b/obexd/client/manager.c
index 7e1eb1b..44de5d8 100644
--- a/obexd/client/manager.c
+++ b/obexd/client/manager.c
#include "session.h"
#include "manager.h"
#include "opp.h"
+#include "ftp.h"
#define CLIENT_SERVICE "org.openobex.client"
void (*exit) (void);
} targets[] = {
{ "opp", opp_init, opp_exit },
+ { "ftp", ftp_init, ftp_exit },
{ }
};
diff --git a/obexd/client/session.c b/obexd/client/session.c
index 4bcf225..9436507 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
#include "log.h"
#include "pbap.h"
#include "sync.h"
-#include "ftp.h"
#include "transfer.h"
#include "session.h"
#include "btio.h"