aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2008-11-22 00:14:57 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-11-22 00:14:57 +0800
commit02fd95152f9b9cbd647a3b0e439585502f4b8892 (patch)
tree846ebdaebee6fa5fbc5af07ed277919eb71ee7a5
parent3ce271c0a36a688ee902360cde82762c0bceda59 (diff)
downloadgsoc2013-empathy-02fd95152f9b9cbd647a3b0e439585502f4b8892.tar
gsoc2013-empathy-02fd95152f9b9cbd647a3b0e439585502f4b8892.tar.gz
gsoc2013-empathy-02fd95152f9b9cbd647a3b0e439585502f4b8892.tar.bz2
gsoc2013-empathy-02fd95152f9b9cbd647a3b0e439585502f4b8892.tar.lz
gsoc2013-empathy-02fd95152f9b9cbd647a3b0e439585502f4b8892.tar.xz
gsoc2013-empathy-02fd95152f9b9cbd647a3b0e439585502f4b8892.tar.zst
gsoc2013-empathy-02fd95152f9b9cbd647a3b0e439585502f4b8892.zip
Implemented accept_file and empathy_receive_file in empathy-file. (Jonny Lamb)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk> svn path=/trunk/; revision=1755
-rw-r--r--libempathy/empathy-file.c86
1 files changed, 68 insertions, 18 deletions
diff --git a/libempathy/empathy-file.c b/libempathy/empathy-file.c
index 8313934dc..bec3a9b6c 100644
--- a/libempathy/empathy-file.c
+++ b/libempathy/empathy-file.c
@@ -527,24 +527,6 @@ empathy_file_get_channel (EmpathyFile *file)
return priv->channel;
}
-/**
- * empathy_file_accept:
- * @file: an #EmpathyFile
- *
- * Accepts a file transfer that's in the "local pending" state (i.e.
- * EMP_FILE_TRANSFER_STATE_LOCAL_PENDING).
- */
-void
-empathy_file_accept (EmpathyFile *file)
-{
- EmpathyFilePriv *priv;
-
- g_return_if_fail (EMPATHY_IS_FILE (file));
-
- /* TODO: accept file here */
- if (priv) ;
-}
-
static void
file_destroy_cb (TpChannel *file_channel, EmpathyFile *file)
{
@@ -631,6 +613,74 @@ _get_local_socket (EmpathyFile *file)
return fd;
}
+/**
+ * empathy_file_accept:
+ * @file: an #EmpathyFile
+ *
+ * Accepts a file transfer that's in the "local pending" state (i.e.
+ * EMP_FILE_TRANSFER_STATE_LOCAL_PENDING).
+ */
+void
+empathy_file_accept (EmpathyFile *file)
+{
+ EmpathyFilePriv *priv;
+ GValue *address;
+ GValue nothing = { 0 };
+ GError *error = NULL;
+
+ g_return_if_fail (EMPATHY_IS_FILE (file));
+
+ priv = GET_PRIV (file);
+
+ g_return_if_fail (priv->out_stream != NULL);
+
+ DEBUG ("Accepting file: filename=%s", priv->filename);
+
+ g_value_init (&nothing, G_TYPE_STRING);
+ g_value_set_string (&nothing, "");
+
+ if (!emp_cli_channel_type_file_run_accept_file (TP_PROXY (priv->channel),
+ -1, TP_SOCKET_ADDRESS_TYPE_UNIX, TP_SOCKET_ACCESS_CONTROL_LOCALHOST,
+ &nothing, &address, &error, NULL))
+ {
+ DEBUG ("Accept error: %s",
+ error ? error->message : "No message given");
+ g_clear_error (&error);
+ }
+
+ if (priv->unix_socket_path)
+ g_free (priv->unix_socket_path);
+
+ priv->unix_socket_path = g_value_dup_string (address);
+ g_value_unset (address);
+
+ DEBUG ("Got unix socket path: %s", priv->unix_socket_path);
+}
+
+static void
+receive_file (EmpathyFile *file)
+{
+ EmpathyFilePriv *priv;
+ GInputStream *socket_stream;
+ gint socket_fd;
+
+ priv = GET_PRIV (file);
+
+ socket_fd = _get_local_socket (file);
+
+ if (socket_fd < 0)
+ return;
+
+ socket_stream = g_unix_input_stream_new (socket_fd, TRUE);
+
+ priv->cancellable = g_cancellable_new ();
+
+ copy_stream (socket_stream, priv->out_stream, priv->cancellable);
+
+ g_object_unref (socket_stream);
+}
+
+
static void
send_file (EmpathyFile *file)
{