telepathy-glib: tp_account_channel_request_new_file_transfer: add

Simon McVittie smcv at kemper.freedesktop.org
Mon Apr 30 11:57:29 PDT 2012


Module: telepathy-glib
Branch: master
Commit: 190bd127672dd8baa8c8415a543fd97dc2099d4b
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=190bd127672dd8baa8c8415a543fd97dc2099d4b

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Mon Apr 16 19:36:31 2012 +0100

tp_account_channel_request_new_file_transfer: add

Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Reviewed-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48780

---

 docs/reference/telepathy-glib-sections.txt |    1 +
 telepathy-glib/account-channel-request.c   |   63 ++++++++++++++++++++++++++++
 telepathy-glib/account-channel-request.h   |    9 ++++
 3 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 17d17fa..e497bc3 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -6036,6 +6036,7 @@ tp_account_channel_request_set_request_property
 tp_account_channel_request_new_text
 tp_account_channel_request_new_audio_call
 tp_account_channel_request_new_audio_video_call
+tp_account_channel_request_new_file_transfer
 tp_account_channel_request_create_and_handle_channel_async
 tp_account_channel_request_create_and_handle_channel_finish
 tp_account_channel_request_ensure_and_handle_channel_async
diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c
index a5e43c4..674aef5 100644
--- a/telepathy-glib/account-channel-request.c
+++ b/telepathy-glib/account-channel-request.c
@@ -2001,3 +2001,66 @@ tp_account_channel_request_new_audio_video_call (
   g_hash_table_unref (request);
   return self;
 }
+
+/**
+ * tp_account_channel_request_new_file_transfer:
+ * @account: a #TpAccount
+ * @filename: a suggested name for the file, which should not contain
+ *  directories or directory separators (for example, if you are sending
+ * a file called /home/user/monkey.pdf, set this to monkey.pdf)
+ * @mime_type: (allow-none): the MIME type (content-type) of the file;
+ *  a %NULL value is allowed, and is treated as
+ *  "application/octet-stream"
+ * @size: the file's size in bytes
+ * @user_action_time: the time of the user action that caused this request,
+ *  or one of the special values %TP_USER_ACTION_TIME_NOT_USER_ACTION or
+ *  %TP_USER_ACTION_TIME_CURRENT_TIME (see
+ *  #TpAccountChannelRequest:user-action-time)
+ *
+ * Convenience function to create a new #TpAccountChannelRequest object,
+ * which will yield a FileTransfer channel to send a file to a contact.
+ *
+ * After creating the request, you will also need to set the "target"
+ * of the channel by calling one of the following functions:
+ *
+ * * tp_account_channel_request_set_target_contact()
+ * * tp_account_channel_request_set_target_id()
+ *
+ * Returns: a new #TpAccountChannelRequest object
+ *
+ * Since: 0.19.UNRELEASED
+ */
+TpAccountChannelRequest *
+tp_account_channel_request_new_file_transfer (
+    TpAccount *account,
+    const gchar *filename,
+    const gchar *mime_type,
+    guint64 size,
+    gint64 user_action_time)
+{
+  TpAccountChannelRequest *self;
+  GHashTable *request;
+
+  g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
+  g_return_val_if_fail (!tp_str_empty (filename), NULL);
+  g_return_val_if_fail (mime_type == NULL || mime_type[0] != '\0', NULL);
+
+  if (mime_type == NULL)
+    mime_type = "application/octet-stream";
+
+  request = tp_asv_new (
+      TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
+          TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER,
+      TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_FILENAME, G_TYPE_STRING, filename,
+      TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_TYPE, G_TYPE_STRING, mime_type,
+      TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_SIZE, G_TYPE_UINT64, size,
+      NULL);
+
+  self = g_object_new (TP_TYPE_ACCOUNT_CHANNEL_REQUEST,
+      "account", account,
+      "request", request,
+      "user-action-time", user_action_time,
+      NULL);
+  g_hash_table_unref (request);
+  return self;
+}
diff --git a/telepathy-glib/account-channel-request.h b/telepathy-glib/account-channel-request.h
index 913739e..1de6dd5 100644
--- a/telepathy-glib/account-channel-request.h
+++ b/telepathy-glib/account-channel-request.h
@@ -102,6 +102,15 @@ TpAccountChannelRequest *tp_account_channel_request_new_audio_video_call (
     TpAccount *account,
     gint64 user_action_time) G_GNUC_WARN_UNUSED_RESULT;
 
+/* File transfer */
+
+TpAccountChannelRequest *tp_account_channel_request_new_file_transfer (
+    TpAccount *account,
+    const gchar *filename,
+    const gchar *mime_type,
+    guint64 size,
+    gint64 user_action_time) G_GNUC_WARN_UNUSED_RESULT;
+
 /* Channel target (shared between all channel types) */
 
 void tp_account_channel_request_set_target_contact (



More information about the telepathy-commits mailing list