pidgin/pidgin

d4d7095686cf
Merged in purple-media-require-encryption-api-addition (pull request #523)

Purple media require encryption api addition

Approved-by: Elliott Sales de Andrade
Approved-by: Gary Kramlich
--- a/ChangeLog.API Wed Jul 24 17:51:29 2019 -0500
+++ b/ChangeLog.API Sat Jul 27 03:23:16 2019 +0000
@@ -5,6 +5,7 @@
Added:
* purple_media_manager_enumerate_elements
* purple_request_screenshare_media
+ * purple_media_set_require_encryption
version 2.13.0:
libpurple:
--- a/libpurple/media.c Wed Jul 24 17:51:29 2019 -0500
+++ b/libpurple/media.c Sat Jul 27 03:23:16 2019 +0000
@@ -1323,6 +1323,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 Wed Jul 24 17:51:29 2019 -0500
+++ b/libpurple/media.h Sat Jul 27 03:23:16 2019 +0000
@@ -386,6 +386,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);
+
+/**
* Gets whether a session's codecs are ready to be used.
*
* @param media The media object to find the session in.
--- a/libpurple/media/backend-fs2.c Wed Jul 24 17:51:29 2019 -0500
+++ b/libpurple/media/backend-fs2.c Sat Jul 27 03:23:16 2019 +0000
@@ -97,6 +97,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);
#endif
static gboolean purple_media_backend_fs2_set_remote_codecs(
PurpleMediaBackend *self,
@@ -580,6 +583,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;
#endif
iface->set_params = purple_media_backend_fs2_set_params;
iface->get_available_params = purple_media_backend_fs2_get_available_params;
@@ -2802,6 +2807,26 @@
gst_structure_free(srtp);
return result;
}
+
+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;
+}
+
#endif /* GST 1.0+ */
static gboolean
--- a/libpurple/media/backend-iface.c Wed Jul 24 17:51:29 2019 -0500
+++ b/libpurple/media/backend-iface.c Sat Jul 27 03:23:16 2019 +0000
@@ -222,6 +222,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)
+{
+ PurpleMediaBackendIface *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 Wed Jul 24 17:51:29 2019 -0500
+++ b/libpurple/media/backend-iface.h Sat Jul 27 03:23:16 2019 +0000
@@ -75,6 +75,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);
void (*set_params) (PurpleMediaBackend *self,
guint num_params, GParameter *params);
const gchar **(*get_available_params) (void);
@@ -244,6 +247,20 @@
const gchar *key, gsize key_len);
/**
+ * Sets whether a session participant's media requires encryption.
+ *
+ * @param self 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_backend_set_require_encryption(PurpleMediaBackend *self,
+ const gchar *sess_id, const gchar *participant,
+ gboolean require_encryption);
+
+/**
* Sets various optional parameters of the media backend.
*
* @param self The media backend to set the parameters on.