/pidgin/main: c0b60f37a7db: Backport warning fixes for libpurple...

Tomasz Wasilczyk twasilczyk at pidgin.im
Tue May 6 07:03:55 EDT 2014


Changeset: c0b60f37a7dbc59d227a3146f9e61b59888bf402
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-05-06 13:03 +0200
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/c0b60f37a7db

Description:

Backport warning fixes for libpurple from default

diffstat:

 libpurple/media/backend-fs2.c      |  82 ++++++++++++++++++++++++++++++++++---
 libpurple/plugins/ssl/ssl-gnutls.c |  46 +++++++++-----------
 libpurple/util.c                   |  12 +++++
 3 files changed, 107 insertions(+), 33 deletions(-)

diffs (truncated from 360 to 300 lines):

diff --git a/libpurple/media/backend-fs2.c b/libpurple/media/backend-fs2.c
--- a/libpurple/media/backend-fs2.c
+++ b/libpurple/media/backend-fs2.c
@@ -179,6 +179,66 @@ static void
 purple_media_backend_fs2_init(PurpleMediaBackendFs2 *self)
 {}
 
+static FsCandidateType
+purple_media_candidate_type_to_fs(PurpleMediaCandidateType type)
+{
+	switch (type) {
+		case PURPLE_MEDIA_CANDIDATE_TYPE_HOST:
+			return FS_CANDIDATE_TYPE_HOST;
+		case PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX:
+			return FS_CANDIDATE_TYPE_SRFLX;
+		case PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX:
+			return FS_CANDIDATE_TYPE_PRFLX;
+		case PURPLE_MEDIA_CANDIDATE_TYPE_RELAY:
+			return FS_CANDIDATE_TYPE_RELAY;
+		case PURPLE_MEDIA_CANDIDATE_TYPE_MULTICAST:
+			return FS_CANDIDATE_TYPE_MULTICAST;
+	}
+	g_return_val_if_reached(FS_CANDIDATE_TYPE_HOST);
+}
+
+static PurpleMediaCandidateType
+purple_media_candidate_type_from_fs(FsCandidateType type)
+{
+	switch (type) {
+		case FS_CANDIDATE_TYPE_HOST:
+			return PURPLE_MEDIA_CANDIDATE_TYPE_HOST;
+		case FS_CANDIDATE_TYPE_SRFLX:
+			return PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX;
+		case FS_CANDIDATE_TYPE_PRFLX:
+			return PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX;
+		case FS_CANDIDATE_TYPE_RELAY:
+			return PURPLE_MEDIA_CANDIDATE_TYPE_RELAY;
+		case FS_CANDIDATE_TYPE_MULTICAST:
+			return PURPLE_MEDIA_CANDIDATE_TYPE_MULTICAST;
+	}
+	g_return_val_if_reached(PURPLE_MEDIA_CANDIDATE_TYPE_HOST);
+}
+
+static FsNetworkProtocol
+purple_media_network_protocol_to_fs(PurpleMediaNetworkProtocol protocol)
+{
+	switch (protocol) {
+		case PURPLE_MEDIA_NETWORK_PROTOCOL_UDP:
+			return FS_NETWORK_PROTOCOL_UDP;
+		case PURPLE_MEDIA_NETWORK_PROTOCOL_TCP:
+			return FS_NETWORK_PROTOCOL_TCP;
+	}
+	g_return_val_if_reached(FS_NETWORK_PROTOCOL_TCP);
+}
+
+static PurpleMediaNetworkProtocol
+purple_media_network_protocol_from_fs(FsNetworkProtocol protocol)
+{
+	switch (protocol) {
+		case FS_NETWORK_PROTOCOL_UDP:
+			return PURPLE_MEDIA_NETWORK_PROTOCOL_UDP;
+		case FS_NETWORK_PROTOCOL_TCP:
+			return PURPLE_MEDIA_NETWORK_PROTOCOL_TCP;
+	}
+	g_return_val_if_reached(PURPLE_MEDIA_NETWORK_PROTOCOL_TCP);
+}
+
 static gboolean
 event_probe_cb(GstPad *srcpad, GstEvent *event, gboolean release_pad)
 {
@@ -522,8 +582,8 @@ candidate_to_fs(PurpleMediaCandidate *ca
 			NULL);
 
 	fscandidate = fs_candidate_new(foundation,
-			component_id, type,
-			proto, ip, port);
+			component_id, purple_media_candidate_type_to_fs(type),
+			purple_media_network_protocol_to_fs(proto), ip, port);
 
 	fscandidate->base_ip = base_ip;
 	fscandidate->base_port = base_port;
@@ -560,8 +620,10 @@ candidate_from_fs(FsCandidate *fscandida
 		return NULL;
 
 	candidate = purple_media_candidate_new(fscandidate->foundation,
-		fscandidate->component_id, fscandidate->type,
-		fscandidate->proto, fscandidate->ip, fscandidate->port);
+		fscandidate->component_id,
+		purple_media_candidate_type_from_fs(fscandidate->type),
+		purple_media_network_protocol_from_fs(fscandidate->proto),
+		fscandidate->ip, fscandidate->port);
 	g_object_set(candidate,
 			"base-ip", fscandidate->base_ip,
 			"base-port", fscandidate->base_port,
@@ -1855,7 +1917,9 @@ append_relay_info(GValueArray *relay_inf
 		memset(&value, 0, sizeof(GValue));
 		g_value_init(&value, GST_TYPE_STRUCTURE);
 		gst_value_set_structure(&value, turn_setup);
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 		relay_info = g_value_array_append(relay_info, &value);
+G_GNUC_END_IGNORE_DEPRECATIONS
 		gst_structure_free(turn_setup);
 	}
 
@@ -1950,7 +2014,9 @@ create_stream(PurpleMediaBackendFs2 *sel
 	}
 
 	if (turn_ip && !strcmp("nice", transmitter) && !got_turn_from_prpl) {
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 		GValueArray *relay_info = g_value_array_new(0);
+G_GNUC_END_IGNORE_DEPRECATIONS
 		gint port;
 		const gchar *username =	purple_prefs_get_string(
 				"/purple/network/turn_username");
@@ -1977,11 +2043,11 @@ create_stream(PurpleMediaBackendFs2 *sel
 		purple_debug_info("backend-fs2",
 			"Setting relay-info on new stream\n");
 		_params[_num_params].name = "relay-info";
-		g_value_init(&_params[_num_params].value,
-			G_TYPE_VALUE_ARRAY);
-		g_value_set_boxed(&_params[_num_params].value,
-			relay_info);
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+		g_value_init(&_params[_num_params].value, G_TYPE_VALUE_ARRAY);
+		g_value_set_boxed(&_params[_num_params].value, relay_info);
 		g_value_array_free(relay_info);
+G_GNUC_END_IGNORE_DEPRECATIONS
 		_num_params++;
 	}
 
diff --git a/libpurple/plugins/ssl/ssl-gnutls.c b/libpurple/plugins/ssl/ssl-gnutls.c
--- a/libpurple/plugins/ssl/ssl-gnutls.c
+++ b/libpurple/plugins/ssl/ssl-gnutls.c
@@ -34,7 +34,7 @@
 
 typedef struct
 {
-	gnutls_session session;
+	gnutls_session_t session;
 	guint handshake_handler;
 	guint handshake_timer;
 } PurpleSslGnutlsData;
@@ -284,9 +284,9 @@ static void ssl_gnutls_handshake_cb(gpoi
 		g_list_free(peers);
 
 		{
-			const gnutls_datum *cert_list;
+			const gnutls_datum_t *cert_list;
 			unsigned int cert_list_size = 0;
-			gnutls_session session=gnutls_data->session;
+			gnutls_session_t session=gnutls_data->session;
 			int i;
 
 			cert_list =
@@ -303,13 +303,13 @@ static void ssl_gnutls_handshake_cb(gpoi
 				gchar tbuf[256];
 				gsize tsz=sizeof(tbuf);
 				gchar * tasc = NULL;
-				gnutls_x509_crt cert;
+				gnutls_x509_crt_t cert;
 
 				gnutls_x509_crt_init(&cert);
 				gnutls_x509_crt_import (cert, &cert_list[i],
 						GNUTLS_X509_FMT_DER);
 
-				gnutls_x509_crt_get_fingerprint(cert, GNUTLS_MAC_SHA,
+				gnutls_x509_crt_get_fingerprint(cert, GNUTLS_DIG_SHA,
 						fpr_bin, &fpr_bin_sz);
 
 				fpr_asc =
@@ -386,7 +386,6 @@ static void
 ssl_gnutls_connect(PurpleSslConnection *gsc)
 {
 	PurpleSslGnutlsData *gnutls_data;
-	static const int cert_type_priority[2] = { GNUTLS_CRT_X509, 0 };
 
 	gnutls_data = g_new0(PurpleSslGnutlsData, 1);
 	gsc->private_data = gnutls_data;
@@ -413,9 +412,6 @@ ssl_gnutls_connect(PurpleSslConnection *
 	gnutls_set_default_priority(gnutls_data->session);
 #endif
 
-	gnutls_certificate_type_set_priority(gnutls_data->session,
-		cert_type_priority);
-
 	gnutls_credentials_set(gnutls_data->session, GNUTLS_CRD_CERTIFICATE,
 		xcred);
 
@@ -519,7 +515,7 @@ ssl_gnutls_write(PurpleSslConnection *gs
 
 /* Forward declarations are fun! */
 static PurpleCertificate *
-x509_import_from_datum(const gnutls_datum dt, gnutls_x509_crt_fmt mode);
+x509_import_from_datum(const gnutls_datum_t dt, gnutls_x509_crt_fmt_t mode);
 /* indeed! */
 static gboolean
 x509_certificate_signed_by(PurpleCertificate * crt,
@@ -537,7 +533,7 @@ ssl_gnutls_get_peer_certificates(PurpleS
 	GList * peer_certs = NULL;
 
 	/* List of raw certificates as given by GnuTLS */
-	const gnutls_datum *cert_list;
+	const gnutls_datum_t *cert_list;
 	unsigned int cert_list_size = 0;
 
 	unsigned int i;
@@ -585,7 +581,7 @@ static PurpleCertificateScheme x509_gnut
 /** Refcounted GnuTLS certificate data instance */
 typedef struct {
 	gint refcount;
-	gnutls_x509_crt crt;
+	gnutls_x509_crt_t crt;
 } x509_crtdata_t;
 
 /** Helper functions for reference counting */
@@ -627,7 +623,7 @@ x509_crtdata_delref(x509_crtdata_t *cd)
  * @return A newly allocated Certificate structure of the x509_gnutls scheme
  */
 static PurpleCertificate *
-x509_import_from_datum(const gnutls_datum dt, gnutls_x509_crt_fmt mode)
+x509_import_from_datum(const gnutls_datum_t dt, gnutls_x509_crt_fmt_t mode)
 {
 	/* Internal certificate data structure */
 	x509_crtdata_t *certdat;
@@ -662,7 +658,7 @@ x509_import_from_file(const gchar * file
 	PurpleCertificate *crt;  /* Certificate being constructed */
 	gchar *buf;        /* Used to load the raw file data */
 	gsize buf_sz;      /* Size of the above */
-	gnutls_datum dt; /* Struct to pass down to GnuTLS */
+	gnutls_datum_t dt; /* Struct to pass down to GnuTLS */
 
 	purple_debug_info("gnutls",
 			  "Attempting to load X.509 certificate from %s\n",
@@ -705,7 +701,7 @@ x509_importcerts_from_file(const gchar *
 	gchar *begin, *end;
 	GSList *crts = NULL;
 	gsize buf_sz;      /* Size of the above */
-	gnutls_datum dt; /* Struct to pass down to GnuTLS */
+	gnutls_datum_t dt; /* Struct to pass down to GnuTLS */
 
 	purple_debug_info("gnutls",
 			  "Attempting to load X.509 certificates from %s\n",
@@ -751,7 +747,7 @@ x509_importcerts_from_file(const gchar *
 static gboolean
 x509_export_certificate(const gchar *filename, PurpleCertificate *crt)
 {
-	gnutls_x509_crt crt_dat; /* GnuTLS cert struct */
+	gnutls_x509_crt_t crt_dat; /* GnuTLS cert struct */
 	int ret;
 	gchar * out_buf; /* Data to output */
 	size_t out_size; /* Output size */
@@ -857,8 +853,8 @@ static gboolean
 x509_certificate_signed_by(PurpleCertificate * crt,
 			   PurpleCertificate * issuer)
 {
-	gnutls_x509_crt crt_dat;
-	gnutls_x509_crt issuer_dat;
+	gnutls_x509_crt_t crt_dat;
+	gnutls_x509_crt_t issuer_dat;
 	unsigned int verify; /* used to store result from GnuTLS verifier */
 	int ret;
 	gchar *crt_id = NULL;
@@ -963,7 +959,7 @@ x509_sha1sum(PurpleCertificate *crt)
 {
 	size_t hashlen = 20; /* SHA1 hashes are 20 bytes */
 	size_t tmpsz = hashlen; /* Throw-away variable for GnuTLS to stomp on*/
-	gnutls_x509_crt crt_dat;
+	gnutls_x509_crt_t crt_dat;
 	GByteArray *hash; /**< Final hash container */
 	guchar hashbuf[hashlen]; /**< Temporary buffer to contain hash */
 
@@ -973,7 +969,7 @@ x509_sha1sum(PurpleCertificate *crt)
 
 	/* Extract the fingerprint */
 	g_return_val_if_fail(
-		0 == gnutls_x509_crt_get_fingerprint(crt_dat, GNUTLS_MAC_SHA,
+		0 == gnutls_x509_crt_get_fingerprint(crt_dat, GNUTLS_DIG_SHA,
 						     hashbuf, &tmpsz),
 		NULL);
 
@@ -990,7 +986,7 @@ x509_sha1sum(PurpleCertificate *crt)
 static gchar *
 x509_cert_dn (PurpleCertificate *crt)
 {
-	gnutls_x509_crt cert_dat;
+	gnutls_x509_crt_t cert_dat;
 	gchar *dn = NULL;
 	size_t dn_size;
 
@@ -1023,7 +1019,7 @@ x509_cert_dn (PurpleCertificate *crt)
 static gchar *
 x509_issuer_dn (PurpleCertificate *crt)
 {
-	gnutls_x509_crt cert_dat;
+	gnutls_x509_crt_t cert_dat;
 	gchar *dn = NULL;
 	size_t dn_size;
 
@@ -1057,7 +1053,7 @@ x509_issuer_dn (PurpleCertificate *crt)
 static gchar *



More information about the Commits mailing list