libpurple/mediamanager.h

branch
release-2.x.y
changeset 36333
4fe1034f3dce
parent 36331
d729a9b21265
child 36346
f4c32aca3f1f
--- a/libpurple/mediamanager.h	Mon Jul 07 16:27:42 2014 -0400
+++ b/libpurple/mediamanager.h	Mon Jul 21 17:53:41 2014 -0400
@@ -38,6 +38,30 @@
 #include "account.h"
 #include "media.h"
 
+/**
+ * PurpleMediaAppDataCallbacks:
+ * @readable: Called when the stream has received data and is readable.
+ * @writable: Called when the stream has become writable or has stopped being
+ * writable.
+ *
+ * A set of callbacks that can be installed on an Application data session with
+ * purple_media_manager_set_application_data_callbacks()
+ *
+ * Once installed the @readable callback will get called as long as data is
+ * available to read, so the data must be read completely.
+ * The @writable callback will only be called when the writable state of the
+ * stream changes. The @writable argument defines whether the stream has
+ * become writable or stopped being writable.
+ *
+ */
+typedef struct {
+	void      (*readable)    (PurpleMediaManager *manager, PurpleMedia *media,
+		const gchar *session_id, const gchar *participant, gpointer user_data);
+	void      (*writable)    (PurpleMediaManager *manager, PurpleMedia *media,
+		const gchar *session_id, const gchar *participant, gboolean writable,
+		gpointer user_data);
+} PurpleMediaAppDataCallbacks;
+
 G_BEGIN_DECLS
 
 #define PURPLE_TYPE_MEDIA_MANAGER            (purple_media_manager_get_type())
@@ -285,6 +309,71 @@
  */
 GType purple_media_manager_get_backend_type(PurpleMediaManager *manager);
 
+/**
+ * purple_media_manager_set_application_data_callbacks:
+ * @manager: The manager to register the callbacks with.
+ * @media: The media instance to register the callbacks with.
+ * @session_id: The session to register the callbacks with.
+ * @participant: The participant to register the callbacks with.
+ * @callbacks: The callbacks to be set on the session.
+ * @user_data: a user_data argument for the callbacks.
+ * @notify: a destroy notify function.
+ *
+ * Set callbacks on a session to be called when the stream becomes writable
+ * or readable for media sessions of type #PURPLE_MEDIA_APPLICATION
+ */
+void purple_media_manager_set_application_data_callbacks(
+	PurpleMediaManager *manager, PurpleMedia *media, const gchar *session_id,
+	const gchar *participant, PurpleMediaAppDataCallbacks *callbacks,
+	gpointer user_data, GDestroyNotify notify);
+
+/**
+ * purple_media_manager_send_application_data:
+ * @manager: The manager to send data with.
+ * @media: The media instance to which the session belongs.
+ * @session_id: The session to send data to.
+ * @participant: The participant to send data to.
+ * @buffer: The buffer of data to send.
+ * @size: The size of @buffer
+ * @blocking: Whether to block until the data was send or not.
+ *
+ * Sends a buffer of data to a #PURPLE_MEDIA_APPLICATION session.
+ * If @blocking is set, unless an error occured, the function will not return
+ * until the data has been flushed into the network.
+ * If the stream is not writable, the data will be queued. It is the
+ * responsability of the user to stop sending data when the stream isn't
+ * writable anymore. It is also the responsability of the user to only start
+ * sending data after the stream has been configured correctly (encryption
+ * parameters for example).
+ *
+ * Returns: Number of bytes sent or -1 in case of error.
+ */
+gint purple_media_manager_send_application_data (
+	PurpleMediaManager *manager, PurpleMedia *media, const gchar *session_id,
+	const gchar *participant, gpointer buffer, guint size, gboolean blocking);
+
+/**
+ * purple_media_manager_receive_application_data:
+ * @manager: The manager to receive data with.
+ * @media: The media instance to which the session belongs.
+ * @session_id: The session to receive data from.
+ * @participant: The participant to receive data from.
+ * @buffer: The buffer to receive data into.
+ * @max_size: The max_size of @buffer
+ * @blocking: Whether to block until the buffer is entirely filled or return
+ * with currently available data.
+ *
+ * Receive a buffer of data from a #PURPLE_MEDIA_APPLICATION session.
+ * If @blocking is set, unless an error occured, the function will not return
+ * until @max_size bytes are read.
+ *
+ * Returns: Number of bytes received or -1 in case of error.
+ */
+gint purple_media_manager_receive_application_data (
+	PurpleMediaManager *manager, PurpleMedia *media, const gchar *session_id,
+	const gchar *participant, gpointer buffer, guint max_size,
+	gboolean blocking);
+
 /*}@*/
 
 #ifdef __cplusplus

mercurial