diff --git a/obexd/src/dbus.h b/obexd/src/dbus.h
index 3c85aae..8042b27 100644
--- a/obexd/src/dbus.h
+++ b/obexd/src/dbus.h
const gchar *type, gint32 length, gint32 time,
gchar **new_folder, gchar **new_name);
-void register_transfer(guint32 id);
+void register_transfer(guint32 id, struct obex_session *os);
void unregister_transfer(guint32 id);
+
+void register_session(guint32 id);
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index fac69c6..282fa82 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
return reply;
}
+static DBusMessage *transfer_cancel(DBusConnection *connection,
+ DBusMessage *msg, void *user_data)
+{
+ struct obex_session *os = user_data;
+
+ if (!os)
+ return invalid_args(msg);
+
+ os->cancelled = TRUE;
+
+ return dbus_message_new_method_return(msg);
+}
+
static GDBusMethodTable manager_methods[] = {
{ "RegisterAgent", "o", "", register_agent },
{ "UnregisterAgent", "o", "", unregister_agent },
};
static GDBusSignalTable manager_signals[] = {
- { "TransferStarted", "o" },
- { "TransferCompleted", "ob" },
- { "SessionCreated", "o" },
+ { "TransferStarted", "o" },
+ { "TransferCompleted", "ob" },
+ { "SessionCreated", "o" },
{ "SessionRemoved", "o" },
{ }
};
static GDBusMethodTable transfer_methods[] = {
- { "Cancel", "" },
+ { "Cancel", "", "", transfer_cancel },
{ }
};
g_free(path);
}
-void register_transfer(guint32 id)
+void register_transfer(guint32 id, struct obex_session *os)
{
gchar *path = g_strdup_printf("/transfer%u", id);
if (!g_dbus_register_interface(connection, path,
TRANSFER_INTERFACE,
transfer_methods, transfer_signals,
- NULL, NULL, NULL)) {
+ NULL, os, NULL)) {
error("Cannot register Transfer interface.");
g_free(path);
return;
diff --git a/obexd/src/obex.c b/obexd/src/obex.c
index d4dc3bf..86cfc67 100644
--- a/obexd/src/obex.c
+++ b/obexd/src/obex.c
debug("obex_write name: %s type: %s tx_mtu: %d fd: %d",
os->name, os->type, os->tx_mtu, os->fd);
+ if (os->cancelled)
+ return -EPERM;
+
if (os->fd < 0) {
if (os->buf == NULL)
return -EIO;
gint32 len = 0;
const guint8 *buffer;
+ if (os->cancelled)
+ return -EPERM;
+
size = OBEX_ObjectReadStream(obex, obj, &buffer);
if (size < 0) {
error("Error on OBEX stream");
diff --git a/obexd/src/obex.h b/obexd/src/obex.h
index 1e74168..7cb307b 100644
--- a/obexd/src/obex.h
+++ b/obexd/src/obex.h
gint32 offset;
gint32 size;
gint fd;
+ gboolean cancelled;
const guint8 *target;
struct obex_commands *cmds;
struct server *server;
diff --git a/obexd/src/opp.c b/obexd/src/opp.c
index 6c674b3..851e432 100644
--- a/obexd/src/opp.c
+++ b/obexd/src/opp.c
#include <glib.h>
#include "logging.h"
-#include "dbus.h"
#include "obex.h"
+#include "dbus.h"
#define VCARD_TYPE "text/x-vcard"
#define VCARD_FILE CONFIGDIR "/vcard.vcf"