/pidgin/main: 5c9d451155c5: Clang warnings: clean up finch

Tomasz Wasilczyk twasilczyk at pidgin.im
Fri Oct 4 14:51:58 EDT 2013


Changeset: 5c9d451155c5ceb7ce9aa1bd7630bfbc90e3cda5
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2013-10-04 20:51 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/5c9d451155c5

Description:

Clang warnings: clean up finch

diffstat:

 finch/gntmedia.c           |   4 +-
 finch/gntnotify.c          |  48 ++++++++++++++++++++++++---------------------
 finch/plugins/gnttinyurl.c |   2 +-
 finch/plugins/lastlog.c    |   2 +-
 4 files changed, 30 insertions(+), 26 deletions(-)

diffs (153 lines):

diff --git a/finch/gntmedia.c b/finch/gntmedia.c
--- a/finch/gntmedia.c
+++ b/finch/gntmedia.c
@@ -408,9 +408,9 @@ call_cmd_cb(PurpleConversation *conv, co
 	if (!purple_prpl_initiate_media(account,
 			purple_conversation_get_name(conv),
 			PURPLE_MEDIA_AUDIO))
-		return PURPLE_CMD_STATUS_FAILED;
+		return PURPLE_CMD_RET_FAILED;
 
-	return PURPLE_CMD_STATUS_OK;
+	return PURPLE_CMD_RET_OK;
 }
 
 static GstElement *
diff --git a/finch/gntnotify.c b/finch/gntnotify.c
--- a/finch/gntnotify.c
+++ b/finch/gntnotify.c
@@ -47,20 +47,20 @@ static struct
 } emaildialog;
 
 static void
-notify_msg_window_destroy_cb(GntWidget *window, PurpleNotifyMsgType type)
+notify_msg_window_destroy_cb(GntWidget *window, PurpleNotifyType type)
 {
 	purple_notify_close(type, window);
 }
 
 static void *
-finch_notify_message(PurpleNotifyMsgType type, const char *title,
-	const char *primary, const char *secondary,
+finch_notify_common(PurpleNotifyType ntype, PurpleNotifyMsgType msgtype,
+	const char *title, const char *primary, const char *secondary,
 	PurpleRequestCommonParameters *cpar)
 {
 	GntWidget *window, *button;
 	GntTextFormatFlags pf = 0, sf = 0;
 
-	switch (type)
+	switch (msgtype)
 	{
 		case PURPLE_NOTIFY_MSG_ERROR:
 			sf |= GNT_TEXT_FLAG_BOLD;
@@ -85,24 +85,16 @@ finch_notify_message(PurpleNotifyMsgType
 
 	if (secondary) {
 		GntWidget *msg;
-		/* XXX: This is broken.  type is PurpleNotifyMsgType, not
-		 * PurpleNotifyType.  Also, the if() followed by the
-		 * inner switch doesn't make much sense.
-		 */
-		if ((int)type == (int)PURPLE_NOTIFY_FORMATTED) {
+		if (ntype == PURPLE_NOTIFY_FORMATTED) {
 			int width = -1, height = -1;
 			char *plain = (char*)secondary;
 			msg = gnt_text_view_new();
 			gnt_text_view_set_flag(GNT_TEXT_VIEW(msg), GNT_TEXT_VIEW_TOP_ALIGN | GNT_TEXT_VIEW_NO_SCROLL);
-			switch ((int)type) {
-				case (int)PURPLE_NOTIFY_FORMATTED:
-					plain = purple_markup_strip_html(secondary);
-					if (gnt_util_parse_xhtml_to_textview(secondary, GNT_TEXT_VIEW(msg)))
-						break;
-					/* Fallthrough */
-				default:
-					gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(msg), plain, sf);
-			}
+
+			plain = purple_markup_strip_html(secondary);
+			if (!gnt_util_parse_xhtml_to_textview(secondary, GNT_TEXT_VIEW(msg)))
+				gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(msg), plain, sf);
+
 			gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(msg), button);
 			gnt_util_get_text_bound(plain, &width, &height);
 			gnt_widget_set_size(msg, width + 3, height + 1);
@@ -119,7 +111,7 @@ finch_notify_message(PurpleNotifyMsgType
 	g_signal_connect_swapped(G_OBJECT(button), "activate",
 			G_CALLBACK(gnt_widget_destroy), window);
 	g_signal_connect(G_OBJECT(window), "destroy",
-			G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type));
+			G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(ntype));
 
 	gnt_widget_show(window);
 	return window;
@@ -146,6 +138,15 @@ static void finch_close_notify(PurpleNot
 	gnt_widget_destroy(widget);
 }
 
+static void *
+finch_notify_message(PurpleNotifyMsgType type, const char *title,
+	const char *primary, const char *secondary,
+	PurpleRequestCommonParameters *cpar)
+{
+	return finch_notify_common(PURPLE_NOTIFY_MESSAGE, type, title, primary,
+		secondary, cpar);
+}
+
 static void *finch_notify_formatted(const char *title, const char *primary,
 		const char *secondary, const char *text)
 {
@@ -157,7 +158,8 @@ static void *finch_notify_formatted(cons
 	void *ret;
 
 	purple_markup_html_to_xhtml(t, &xhtml, NULL);
-	ret = finch_notify_message(PURPLE_NOTIFY_FORMATTED, title, primary, xhtml, NULL);
+	ret = finch_notify_common(PURPLE_NOTIFY_FORMATTED,
+		PURPLE_NOTIFY_MSG_INFO, title, primary, xhtml, NULL);
 
 	g_free(t);
 	g_free(xhtml);
@@ -250,7 +252,8 @@ finch_notify_emails(PurpleConnection *gc
 		return NULL;
 	}
 
-	ret = finch_notify_message(PURPLE_NOTIFY_EMAIL, _("New Mail"), _("You have mail!"), message->str, NULL);
+	ret = finch_notify_common(PURPLE_NOTIFY_EMAIL, PURPLE_NOTIFY_MSG_INFO,
+		_("New Mail"), _("You have mail!"), message->str, NULL);
 	g_string_free(message, TRUE);
 	return ret;
 }
@@ -504,7 +507,8 @@ finch_notify_searchresults(PurpleConnect
 static void *
 finch_notify_uri(const char *url)
 {
-	return finch_notify_message(PURPLE_NOTIFY_URI, _("URI"), url, NULL, NULL);
+	return finch_notify_common(PURPLE_NOTIFY_URI, PURPLE_NOTIFY_MSG_INFO,
+		_("URI"), url, NULL, NULL);
 }
 
 static PurpleNotifyUiOps ops =
diff --git a/finch/plugins/gnttinyurl.c b/finch/plugins/gnttinyurl.c
--- a/finch/plugins/gnttinyurl.c
+++ b/finch/plugins/gnttinyurl.c
@@ -384,7 +384,7 @@ tinyurl_notify_uri(const char *uri)
 	/* XXX: The following expects that finch_notify_message gets called. This
 	 * may not always happen, e.g. when another plugin sets its own
 	 * notify_message. So tread carefully. */
-	win = purple_notify_message(NULL, PURPLE_NOTIFY_URI, _("URI"), uri,
+	win = purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, _("URI"), uri,
 			_("Please wait while TinyURL fetches a shorter URL ..."), NULL, NULL, NULL);
 	if (!GNT_IS_WINDOW(win) || !g_object_get_data(G_OBJECT(win), "info-widget"))
 		return win;
diff --git a/finch/plugins/lastlog.c b/finch/plugins/lastlog.c
--- a/finch/plugins/lastlog.c
+++ b/finch/plugins/lastlog.c
@@ -88,7 +88,7 @@ lastlog_cb(PurpleConversation *conv, con
 
 	g_signal_connect(G_OBJECT(win), "key_pressed", G_CALLBACK(window_kpress_cb), tv);
 	g_strfreev(strings);
-	return PURPLE_CMD_STATUS_OK;
+	return PURPLE_CMD_RET_OK;
 }
 
 static gboolean



More information about the Commits mailing list