summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2008-11-05 16:57:13 -0300
committerVinicius Costa Gomes <vinicius.gomes@openbossa.org>2008-11-06 10:48:54 -0300
commit82b593fac3c758792b5b228218c845c96a5ef3ad (patch)
tree731451a31ce171721ce901b886b27b533c3c0c74
parent93e13b8aa7a9479c1a69c94350f46235d346963d (diff)
downloadobexd-82b593fac3c758792b5b228218c845c96a5ef3ad.tar.gz
Adds Error to Agent methods
We needed a way to inform the agent that some error happened during a transfer.
-rw-r--r--client/session.c45
-rw-r--r--doc/client-api.txt7
-rwxr-xr-xtest/send-files6
3 files changed, 52 insertions, 6 deletions
diff --git a/client/session.c b/client/session.c
index 25b04be..3e6e54b 100644
--- a/client/session.c
+++ b/client/session.c
@@ -481,11 +481,34 @@ static void agent_notify_complete(DBusConnection *conn, const char *agent_name,
g_dbus_send_message(conn, message);
}
+static void agent_notify_error(DBusConnection *conn, const char *agent_name,
+ const char *agent_path, const char *transfer_path,
+ const char *error_msg)
+{
+ DBusMessage *message;
+
+ if (agent_name == NULL || agent_path == NULL)
+ return;
+
+ message = dbus_message_new_method_call(agent_name,
+ agent_path, AGENT_INTERFACE, "Error");
+
+ dbus_message_set_no_reply(message, TRUE);
+
+ dbus_message_append_args(message,
+ DBUS_TYPE_OBJECT_PATH, &transfer_path,
+ DBUS_TYPE_STRING, &error_msg,
+ DBUS_TYPE_INVALID);
+
+ g_dbus_send_message(conn, message);
+}
+
static void abort_transfer(struct session_data *session)
{
- agent_notify_complete(session->conn, session->agent_name,
- session->agent_path, session->transfer_path);
+ agent_notify_error(session->conn, session->agent_name,
+ session->agent_path, session->transfer_path,
+ "The transfer was cancelled");
gw_obex_xfer_abort(session->xfer, NULL);
@@ -885,8 +908,13 @@ static void get_xfer_progress(GwObexXfer *xfer, gpointer user_data)
complete:
- agent_notify_complete(session->conn, session->agent_name,
- session->agent_path, session->transfer_path);
+ if (ret == TRUE)
+ agent_notify_complete(session->conn, session->agent_name,
+ session->agent_path, session->transfer_path);
+ else
+ agent_notify_error(session->conn, session->agent_name,
+ session->agent_path, session->transfer_path,
+ "Error getting object");
gw_obex_xfer_close(xfer, NULL);
gw_obex_xfer_free(xfer);
@@ -1172,8 +1200,13 @@ static void put_xfer_progress(GwObexXfer *xfer, gpointer user_data)
complete:
- agent_notify_complete(session->conn, session->agent_name,
- session->agent_path, session->transfer_path);
+ if (len == 0)
+ agent_notify_complete(session->conn, session->agent_name,
+ session->agent_path, session->transfer_path);
+ else
+ agent_notify_error(session->conn, session->agent_name,
+ session->agent_path, session->transfer_path,
+ "Error sending object");
gw_obex_xfer_close(session->xfer, NULL);
gw_obex_xfer_free(session->xfer);
diff --git a/doc/client-api.txt b/doc/client-api.txt
index f54a470..102cb2c 100644
--- a/doc/client-api.txt
+++ b/doc/client-api.txt
@@ -183,3 +183,10 @@ Methods void Release()
argument for convenience.
void Complete(object transfer)
+
+ Informs that the transfer has completed sucessfully.
+
+ void Error(object transfer, string message)
+
+ Informs that the transfer has been terminated because
+ of some error.
diff --git a/test/send-files b/test/send-files
index 1974ee0..caf00b9 100755
--- a/test/send-files
+++ b/test/send-files
@@ -35,6 +35,12 @@ class Agent(dbus.service.Object):
return
@dbus.service.method("org.openobex.Agent",
+ in_signature="os", out_signature="")
+ def Error(self, path, error):
+ print "Transfer finished with an error: %s" % (error)
+ return
+
+ @dbus.service.method("org.openobex.Agent",
in_signature="", out_signature="")
def Release(self):
mainloop.quit()