pidgin/pidgin

Port purple_media_set_require_encryption api
port-changes-from-branch-2.x.y-to-default
20 months ago, Fabrice Bellet
a7be471404ba
Parents 905872c9dd7a
Children 334fd0d7c7e6
Port purple_media_set_require_encryption api
--- a/libpurple/media.c Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/media.c Thu Oct 03 10:34:22 2019 +0200
@@ -1240,6 +1240,19 @@
}
gboolean
+purple_media_set_require_encryption(PurpleMedia *media, const gchar *sess_id,
+ const gchar *participant, gboolean require_encryption)
+{
+#ifdef USE_VV
+ g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
+ return purple_media_backend_set_require_encryption(media->priv->backend,
+ sess_id, participant, require_encryption);
+#else
+ return FALSE;
+#endif
+}
+
+gboolean
purple_media_codecs_ready(PurpleMedia *media, const gchar *sess_id)
{
#ifdef USE_VV
--- a/libpurple/media.h Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/media.h Thu Oct 03 10:34:22 2019 +0200
@@ -412,6 +412,20 @@
const gchar *key, gsize key_len);
/**
+ * Sets whether a session participant's media requires encryption.
+ *
+ * @param media The media object to find the session in.
+ * @param sess_id The id of the session to set parameters of.
+ * @param participant The participant of the session to set parameters of.
+ * @param require_encryption TRUE if the media requires encryption.
+ *
+ * @since 2.14.0
+ */
+gboolean purple_media_set_require_encryption(PurpleMedia *media,
+ const gchar *sess_id, const gchar *participant,
+ gboolean require_encryption);
+
+/**
* purple_media_codecs_ready:
* @media: The media object to find the session in.
* @sess_id: The session id of the session to check.
--- a/libpurple/media/backend-fs2.c Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/media/backend-fs2.c Thu Oct 03 10:34:22 2019 +0200
@@ -74,6 +74,9 @@
PurpleMediaBackend *self, const gchar *sess_id,
const gchar *participant, const gchar *cipher,
const gchar *auth, const gchar *key, gsize key_len);
+static gboolean purple_media_backend_fs2_set_require_encryption(
+ PurpleMediaBackend *self, const gchar *sess_id,
+ const gchar *participant, gboolean require_encryption);
static gboolean purple_media_backend_fs2_set_remote_codecs(
PurpleMediaBackend *self,
const gchar *sess_id, const gchar *participant,
@@ -505,6 +508,8 @@
purple_media_backend_fs2_set_encryption_parameters;
iface->set_decryption_parameters =
purple_media_backend_fs2_set_decryption_parameters;
+ iface->set_require_encryption =
+ purple_media_backend_fs2_set_require_encryption;
iface->set_params = purple_media_backend_fs2_set_params;
iface->get_available_params = purple_media_backend_fs2_get_available_params;
iface->send_dtmf = purple_media_backend_fs2_send_dtmf;
@@ -2380,6 +2385,25 @@
}
static gboolean
+purple_media_backend_fs2_set_require_encryption(PurpleMediaBackend *self,
+ const gchar *sess_id, const gchar *participant,
+ gboolean require_encryption)
+{
+ PurpleMediaBackendFs2Stream *stream;
+ gboolean result;
+
+ stream = get_stream(PURPLE_MEDIA_BACKEND_FS2(self), sess_id,
+ participant);
+ if (!stream) {
+ return FALSE;
+ }
+
+ g_object_set(stream->stream, "require-encryption",
+ require_encryption, NULL);
+ return TRUE;
+}
+
+static gboolean
purple_media_backend_fs2_set_send_codec(PurpleMediaBackend *self,
const gchar *sess_id, PurpleMediaCodec *codec)
{
--- a/libpurple/media/backend-iface.c Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/media/backend-iface.c Thu Oct 03 10:34:22 2019 +0200
@@ -219,6 +219,24 @@
sess_id, participant, cipher, auth, key, key_len);
}
+gboolean
+purple_media_backend_set_require_encryption(PurpleMediaBackend *self,
+ const gchar *sess_id, const gchar *participant,
+ gboolean require_encryption)
+{
+ PurpleMediaBackendInterface *backend_iface;
+
+ g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
+ backend_iface = PURPLE_MEDIA_BACKEND_GET_INTERFACE(self);
+
+ if (!backend_iface->set_require_encryption) {
+ return FALSE;
+ }
+
+ return backend_iface->set_require_encryption(self,
+ sess_id, participant, require_encryption);
+}
+
void
purple_media_backend_set_params(PurpleMediaBackend *self,
guint num_params, GParameter *params)
--- a/libpurple/media/backend-iface.h Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/media/backend-iface.h Thu Oct 03 10:34:22 2019 +0200
@@ -90,6 +90,9 @@
const gchar *sess_id, const gchar *participant,
const gchar *cipher, const gchar *auth,
const gchar *key, gsize key_len);
+ gboolean (*set_require_encryption) (PurpleMediaBackend *self,
+ const gchar *sess_id, const gchar *participant,
+ gboolean require_encryption);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
void (*set_params) (PurpleMediaBackend *self,
guint num_params, GParameter *params);
@@ -254,6 +257,19 @@
const gchar *key, gsize key_len);
/**
+ * purple_media_backend_set_require_encryption:
+ * @self The media object to find the session in.
+ * @sess_id The id of the session to set parameters of.
+ * @participant The participant of the session to set parameters of.
+ * @require_encryption TRUE if the media requires encryption.
+ *
+ * Sets whether a session participant's media requires encryption.
+ */
+gboolean purple_media_backend_set_require_encryption(PurpleMediaBackend *self,
+ const gchar *sess_id, const gchar *participant,
+ gboolean require_encryption);
+
+/**
* purple_media_backend_set_params:
* @self: The media backend to set the parameters on.
* @num_params: The number of parameters to pass to backend