/pidgin/main: e03cbceed96a: connection: Drop description argumen...

Mike Ruprecht <[email protected]> Sun, 28 Aug 2016 23:58:01 -0400
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: e03cbceed96a77e89f4f40c59693a0c13902863e
Author:	 Mike Ruprecht <[email protected]>
Date:	 2016-08-26 03:04 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/e03cbceed96a

Description:

connection: Drop description argument from purple_connection_g_error()

purple_connection_g_error() had a description argument in order to
simply prefix the message before passing it off to
purple_connection_error(). I've since discovered that g_prefix_error()
exists, which provides the same functionality in a standardized way.

This patch removes the description argument from
purple_connection_g_error() in favor of g_prefix_error() and updates
any uses of the former to use the latter.

diffstat:

 libpurple/connection.c        |   8 ++------
 libpurple/connection.h        |   5 +----
 libpurple/protocols/irc/irc.c |  12 ++++++------
 3 files changed, 9 insertions(+), 16 deletions(-)

diffs (85 lines):

diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -543,11 +543,9 @@ purple_connection_ssl_error (PurpleConne
 }
 
 void
-purple_connection_g_error(PurpleConnection *pc, const GError *error,
-		const gchar *description)
+purple_connection_g_error(PurpleConnection *pc, const GError *error)
 {
 	PurpleConnectionError reason;
-	gchar *tmp;
 
 	if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
 		/* Not a connection error. Ignore. */
@@ -578,9 +576,7 @@ purple_connection_g_error(PurpleConnecti
 		reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
 	}
 
-	tmp = g_strdup_printf(description, error->message);
-	purple_connection_error(pc, reason, tmp);
-	g_free(tmp);
+	purple_connection_error(pc, reason, error->message);
 }
 
 gboolean
diff --git a/libpurple/connection.h b/libpurple/connection.h
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -510,8 +510,6 @@ purple_connection_ssl_error (PurpleConne
  * purple_connection_g_error
  * @gc: Connection the error is associated with
  * @error: Error information
- * @description: Extra string which further explains the error.
- *               Substitutes a "%s" with the GError message.
  *
  * Closes a connection similar to purple_connection_error(), but
  * takes a GError which is then converted to purple error codes.
@@ -524,8 +522,7 @@ purple_connection_ssl_error (PurpleConne
  */
 void
 purple_connection_g_error(PurpleConnection *pc,
-                          const GError *error,
-                          const gchar *description);
+                          const GError *error);
 
 /**
  * purple_connection_error_is_fatal:
diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c
--- a/libpurple/protocols/irc/irc.c
+++ b/libpurple/protocols/irc/irc.c
@@ -107,8 +107,8 @@ irc_flush_cb(GObject *source, GAsyncResu
 			res, &error);
 
 	if (!result) {
-		purple_connection_g_error(gc, error,
-				_("Lost connection with server: %s"));
+		g_prefix_error(&error, _("Lost connection with server: "));
+		purple_connection_g_error(gc, error);
 		g_clear_error(&error);
 		return;
 	}
@@ -427,8 +427,8 @@ irc_login_cb(GObject *source, GAsyncResu
 			res, &error);
 
 	if (conn == NULL) {
-		purple_connection_g_error(gc, error,
-				_("Unable to connect: %s"));
+		g_prefix_error(&error, _("Unable to connect: "));
+		purple_connection_g_error(gc, error);
 		g_clear_error(&error);
 		return;
 	}
@@ -598,8 +598,8 @@ irc_read_input_cb(GObject *source, GAsyn
 			G_DATA_INPUT_STREAM(source), res, &len, &error);
 
 	if (line == NULL && error != NULL) {
-		purple_connection_g_error(gc, error,
-				_("Lost connection with server: %s"));
+		g_prefix_error(&error, _("Lost connection with server: "));
+		purple_connection_g_error(gc, error);
 		g_clear_error(&error);
 		return;
 	} else if (line == NULL) {

_______________________________________________
Commits mailing list
[email protected]
https://pidgin.im/cgi-bin/mailman/listinfo/commits