pidgin: 8bae3778: Fix compatibility with glib < 2.4 for g_...

nosnilmot at pidgin.im nosnilmot at pidgin.im
Thu Aug 14 22:50:45 EDT 2008


-----------------------------------------------------------------
Revision: 8bae3778af422c41094db4e639f2cf45e6ee6259
Ancestor: bc9a91e9f07ce92699379793270ab1fdbccdb7e8
Author: nosnilmot at pidgin.im
Date: 2008-08-15T02:42:52
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8bae3778af422c41094db4e639f2cf45e6ee6259

Modified files:
        ChangeLog.API libpurple/protocols/msn/contact.c
        libpurple/protocols/msn/msn.c libpurple/protocols/msn/page.c
        libpurple/util.c libpurple/util.h

ChangeLog: 

Fix compatibility with glib < 2.4 for g_markup_printf_escaped. untested.

-------------- next part --------------
============================================================
--- ChangeLog.API	dc9cb7b12cec97d50f305c0cc091c7cf4a8b1c56
+++ ChangeLog.API	9c37982e70884cc7994ad55fdc09fe5624aeafc9
@@ -21,6 +21,7 @@ version 2.5.0 (??/??/2008):
 		* purple_cmds_get_handle, purple_cmds_init, purple_cmds_uninit
 		* cmd-added and cmd-removed signals
 		* purple_get_host_name
+		* purple_markup_printf_escaped
 		* purple_util_fetch_url_len (temporary function overload to add max_len param)
 		* purple_util_fetch_url_request_len
 
============================================================
--- libpurple/protocols/msn/contact.c	a595e1136c24e79aeed249ea889ff1501dfc693b
+++ libpurple/protocols/msn/contact.c	5ba5a695c8bb6f77891a8662b624566bd1d3589b
@@ -221,7 +221,7 @@ msn_create_address_book(MsnSession *sess
 	
 	purple_debug_info("msn", "Creating an Address Book.\n");
 
-	body = g_markup_printf_escaped(MSN_ADD_ADDRESSBOOK_TEMPLATE,
+	body = purple_markup_printf_escaped(MSN_ADD_ADDRESSBOOK_TEMPLATE,
 		msn_nexus_get_token_str(session->nexus, MSN_AUTH_CONTACTS),
 		session->user->passport);
 
@@ -408,7 +408,7 @@ msn_get_contact_list(MsnSession *session
 		update_str = g_strdup_printf(MSN_GET_CONTACT_UPDATE_XML,update_time);
 	}
 
-	body = g_markup_printf_escaped(MSN_GET_CONTACT_TEMPLATE, partner_scenario_str,
+	body = purple_markup_printf_escaped(MSN_GET_CONTACT_TEMPLATE, partner_scenario_str,
 		msn_nexus_get_token_str(session->nexus, MSN_AUTH_CONTACTS),
 		update_str ? update_str : "");
 
@@ -807,7 +807,7 @@ msn_get_address_book(MsnSession *session
 	else if (LastChanged != NULL)
 		update_str = g_strdup_printf(MSN_GET_ADDRESS_UPDATE_XML, LastChanged);
 
-	body = g_markup_printf_escaped(MSN_GET_ADDRESS_TEMPLATE,
+	body = purple_markup_printf_escaped(MSN_GET_ADDRESS_TEMPLATE,
 		MsnSoapPartnerScenarioText[partner_scenario],
 		msn_nexus_get_token_str(session->nexus, MSN_AUTH_CONTACTS),
 		update_str ? update_str : "");
============================================================
--- libpurple/protocols/msn/msn.c	b9b7cd1cefd7fa9b552eac0f7f0c19a36d5fd27f
+++ libpurple/protocols/msn/msn.c	9a20e992d2605b5cbfb8bcfa771ca165458c54c2
@@ -714,7 +714,7 @@ msn_tooltip_text(PurpleBuddy *buddy, Pur
 			char *tmp2;
 
 			if (purple_presence_is_idle(presence)) {
-				tmp2 = g_markup_printf_escaped("%s/%s", name, _("Idle"));
+				tmp2 = purple_markup_printf_escaped("%s/%s", name, _("Idle"));
 			} else {
 				tmp2 = g_markup_escape_text(name, -1);
 			}
============================================================
--- libpurple/protocols/msn/page.c	87b3a90e5c7da3b501ec94a98e4de356a4772751
+++ libpurple/protocols/msn/page.c	2f6d4a5b23f2b7f45c6737486b11cf70ef097353
@@ -53,7 +53,7 @@ msn_page_gen_payload(const MsnPage *page
 
 	g_return_val_if_fail(page != NULL, NULL);
 
-	str = g_markup_printf_escaped(
+	str = purple_markup_printf_escaped(
 			"<TEXT xml:space=\"preserve\" enc=\"utf-8\">%s</TEXT>",
 			msn_page_get_body(page));
 
============================================================
--- libpurple/util.c	d5bfc977156b3630b9296aa7732f9d652e20ba2c
+++ libpurple/util.c	13db01f84fa89231eda318e12229e8d3ddd69d44
@@ -2499,6 +2499,29 @@ purple_markup_get_tag_name(const char *t
 	return g_strndup(tag+1, i-1);
 }
 
+char *
+purple_markup_printf_escaped(const char *format, ...)
+{
+	va_list args;
+	char *ret;
+
+#if GLIB_CHECK_VERSION(2,4,0)
+	va_start(args, format);
+	ret = g_markup_vprintf_escaped(format, args);
+	va_end(args);
+#else
+	char *tmp;
+
+	va_start(args, format);
+	tmp = g_strdup_vprintf(format, args);
+	va_end(args);
+	ret = g_markup_escape_text(tmp, -1);
+	g_free(tmp);
+
+#endif
+
+	return ret;
+}
 /**************************************************************************
  * Path/Filename Functions
  **************************************************************************/
============================================================
--- libpurple/util.h	62c0624b2e3267b01a6bd6c85f825d393d1859fc
+++ libpurple/util.h	be2bdaa8abf444e50e814f04d4d8325b0f534437
@@ -576,6 +576,21 @@ char * purple_markup_get_css_property(co
 char * purple_markup_get_css_property(const gchar *style, const gchar *opt);
 
 
+/**
+ *
+ * Formats arguments according to @a format, escaping all string and character
+ * arguments in the fashion of g_markup_escape_text(). This is useful when you
+ * want to insert literal strings into XML-style markup output, without having
+ * to worry that the strings might themselves contain markup.
+ *
+ * This exists for Glib backwards compatibility reasons.
+ *
+ * @param format The format
+ *
+ * @return The string
+ */
+char * purple_markup_printf_escaped(const char *format, ...);
+
 /*@}*/
 
 


More information about the Commits mailing list