summaryrefslogtreecommitdiff
path: root/telepathy-glib/account-channel-request.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-04-16 19:36:31 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-04-30 19:19:57 +0100
commit190bd127672dd8baa8c8415a543fd97dc2099d4b (patch)
treee6683b95f07e5f9f6a0ab478f49ef9684267afe4 /telepathy-glib/account-channel-request.c
parent0c4e961c10b5afbc322d6a36529b63c6f5f71496 (diff)
downloadtelepathy-glib-190bd127672dd8baa8c8415a543fd97dc2099d4b.tar.gz
tp_account_channel_request_new_file_transfer: add
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48780
Diffstat (limited to 'telepathy-glib/account-channel-request.c')
-rw-r--r--telepathy-glib/account-channel-request.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c
index a5e43c4bf..674aef59f 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;
+}