/soc/2013/ankitkv/gobjectification: c0eccc6696da: Merged default...

Ankit Vani a at nevitus.org
Sat Jun 14 18:16:54 EDT 2014


Changeset: c0eccc6696dad15cb50cf7bc3e3d46b292dc3d4e
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2014-06-15 03:46 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/c0eccc6696da

Description:

Merged default branch

diffstat:

 doc/reference/libpurple/libpurple-docs.xml  |   18 +-
 finch/gntconv.c                             |   38 +---
 finch/plugins/gnttinyurl.c                  |   28 +-
 libpurple/conversation.c                    |  227 +++++++--------------------
 libpurple/conversation.h                    |   87 +----------
 libpurple/conversations.c                   |   22 +-
 libpurple/conversationtypes.c               |   32 +---
 libpurple/example/nullclient.c              |   19 +-
 libpurple/internal.h                        |   27 ++-
 libpurple/message.c                         |   21 +-
 libpurple/message.h                         |  163 ++++++++++++++++++-
 libpurple/plugins/signals-test.c            |   14 +-
 libpurple/protocols/jabber/message.c        |    2 +-
 libpurple/server.c                          |    7 +-
 pidgin/gtkblist.c                           |   16 +-
 pidgin/gtkconv.c                            |  157 ++++++++++--------
 pidgin/plugins/crazychat/cc_pidgin_plugin.c |    7 +-
 pidgin/plugins/gtk-signals-test.c           |   24 +-
 pidgin/plugins/notify.c                     |    5 +-
 pidgin/plugins/unity.c                      |    5 +-
 pidgin/win32/gtkwin32dep.c                  |   14 +-
 pidgin/win32/gtkwin32dep.h                  |    2 +-
 22 files changed, 438 insertions(+), 497 deletions(-)

diffs (truncated from 1840 to 300 lines):

diff --git a/doc/reference/libpurple/libpurple-docs.xml b/doc/reference/libpurple/libpurple-docs.xml
--- a/doc/reference/libpurple/libpurple-docs.xml
+++ b/doc/reference/libpurple/libpurple-docs.xml
@@ -38,7 +38,6 @@
       <xi:include href="xml/pounce.xml" />
       <xi:include href="xml/circularbuffer.xml" />
       <xi:include href="xml/cipher.xml" />
-      <xi:include href="xml/cmds.xml" />
       <xi:include href="xml/connection.xml" />
       <xi:include href="xml/conversation.xml" />
       <xi:include href="xml/conversationtypes.xml" />
@@ -54,7 +53,6 @@
       <xi:include href="xml/http.xml" />
       <xi:include href="xml/idle.xml" />
       <xi:include href="xml/keyring.xml" />
-      <xi:include href="xml/log.xml" />
       <xi:include href="xml/memorypool.xml" />
       <xi:include href="xml/desktopitem.xml" />
       <xi:include href="xml/mime.xml" />
@@ -98,6 +96,14 @@
 
   <reference label="">
     <reference label="a">
+      <title>Messaging</title>
+
+        <xi:include href="xml/message.xml" />
+        <xi:include href="xml/log.xml" />
+        <xi:include href="xml/cmds.xml" />
+    </reference>
+
+    <reference label="b">
       <title>Ciphers and Hashes</title>
 
         <xi:include href="xml/aescipher.xml" />
@@ -112,7 +118,7 @@
         <xi:include href="xml/sha256hash.xml" />
     </reference>
 
-    <reference label="b">
+    <reference label="c">
       <title>Smiley APIs</title>
 
         <xi:include href="xml/smiley.xml" />
@@ -122,7 +128,7 @@
         <xi:include href="xml/smiley-parser.xml" />
     </reference>
 
-    <reference label="c">
+    <reference label="d">
       <title>Graphics</title>
 
         <xi:include href="xml/image.xml" />
@@ -130,7 +136,7 @@
         <xi:include href="xml/whiteboard.xml" />
     </reference>
 
-    <reference label="d">
+    <reference label="e">
       <title>Media APIs</title>
 
         <xi:include href="xml/media.xml" />
@@ -142,7 +148,7 @@
         <xi:include href="xml/enum-types.xml" />
     </reference>
 
-    <reference label="e">
+    <reference label="f">
       <title>D-Bus Server APIs</title>
 
         <xi:include href="xml/dbus-bindings.xml" />
diff --git a/finch/gntconv.c b/finch/gntconv.c
--- a/finch/gntconv.c
+++ b/finch/gntconv.c
@@ -60,8 +60,6 @@
 
 #include "config.h"
 
-static void finch_write_common(PurpleConversation *conv, const char *who,
-		const char *message, PurpleMessageFlags flags, time_t mtime);
 static void generate_send_to_menu(FinchConv *ggc);
 static void generate_e2ee_menu(FinchConv *ggc);
 
@@ -309,8 +307,8 @@ update_buddy_typing(PurpleAccount *accou
 static void
 chat_left_cb(PurpleConversation *conv, gpointer null)
 {
-	finch_write_common(conv, NULL, _("You have left this chat."),
-			PURPLE_MESSAGE_SYSTEM, time(NULL));
+	purple_conversation_write_system_message(conv,
+		_("You have left this chat."), 0);
 }
 
 static void
@@ -987,13 +985,13 @@ finch_destroy_conversation(PurpleConvers
 }
 
 static void
-finch_write_common(PurpleConversation *conv, const char *who, const char *message,
-		PurpleMessageFlags flags, time_t mtime)
+finch_write_conv(PurpleConversation *conv, PurpleMessage *msg)
 {
 	FinchConv *ggconv = FINCH_CONV(conv);
 	char *strip, *newline;
 	GntTextFormatFlags fl = 0;
 	int pos;
+	PurpleMessageFlags flags = purple_message_get_flags(msg);
 
 	g_return_if_fail(ggconv != NULL);
 
@@ -1015,6 +1013,7 @@ finch_write_common(PurpleConversation *c
 
 	/* Unnecessary to print the timestamp for delayed message */
 	if (purple_prefs_get_bool("/finch/conversations/timestamps")) {
+		time_t mtime = purple_message_get_time(msg);
 		if (!mtime)
 			time(&mtime);
 		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
@@ -1027,15 +1026,16 @@ finch_write_common(PurpleConversation *c
 		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
 					_("<AUTO-REPLY> "), GNT_TEXT_FLAG_BOLD);
 
-	if (who && *who && (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) &&
+	if (purple_message_get_author(msg) && (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) &&
 			!(flags & PURPLE_MESSAGE_NOTIFY))
 	{
 		char * name = NULL;
 		GntTextFormatFlags msgflags = GNT_TEXT_FLAG_NORMAL;
 		gboolean me = FALSE;
+		gchar *msg_text = g_strdup(purple_message_get_contents(msg));
 
-		if (purple_message_meify((char*)message, -1)) {
-			name = g_strdup_printf("*** %s", who);
+		if (purple_message_meify(msg_text, -1)) {
+			name = g_strdup_printf("*** %s", purple_message_get_author(msg));
 			if (!(flags & PURPLE_MESSAGE_SEND) &&
 					(flags & PURPLE_MESSAGE_NICK))
 				msgflags = gnt_color_pair(color_message_highlight);
@@ -1043,7 +1043,7 @@ finch_write_common(PurpleConversation *c
 				msgflags = gnt_color_pair(color_message_action);
 			me = TRUE;
 		} else {
-			name =  g_strdup_printf("%s", who);
+			name =  g_strdup_printf("%s", purple_message_get_author(msg));
 			if (flags & PURPLE_MESSAGE_SEND)
 				msgflags = gnt_color_pair(color_message_send);
 			else if (flags & PURPLE_MESSAGE_NICK)
@@ -1051,6 +1051,7 @@ finch_write_common(PurpleConversation *c
 			else
 				msgflags = gnt_color_pair(color_message_receive);
 		}
+		purple_message_set_contents(msg, msg_text); /* might be "meified" */
 		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
 				name, msgflags);
 		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), me ? " " : ": ", GNT_TEXT_FLAG_NORMAL);
@@ -1062,7 +1063,7 @@ finch_write_common(PurpleConversation *c
 		fl |= GNT_TEXT_FLAG_BOLD;
 
 	/* XXX: Remove this workaround when textview can parse messages. */
-	newline = purple_strdup_withhtml(message);
+	newline = purple_strdup_withhtml(purple_message_get_contents(msg));
 	strip = purple_markup_strip_html(newline);
 	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
 				strip, fl);
@@ -1090,21 +1091,6 @@ finch_write_common(PurpleConversation *c
 	}
 }
 
-static void
-finch_write_conv(PurpleConversation *conv, const char *who, const char *alias,
-		const char *message, PurpleMessageFlags flags, time_t mtime)
-{
-	const char *name;
-	if (alias && *alias)
-		name = alias;
-	else if (who && *who)
-		name = who;
-	else
-		name = NULL;
-
-	finch_write_common(conv, name, message, flags, mtime);
-}
-
 static const char *
 chat_flag_text(PurpleChatUserFlags flags)
 {
diff --git a/finch/plugins/gnttinyurl.c b/finch/plugins/gnttinyurl.c
--- a/finch/plugins/gnttinyurl.c
+++ b/finch/plugins/gnttinyurl.c
@@ -246,26 +246,24 @@ static void free_urls(gpointer data, gpo
 	g_free(data);
 }
 
-static gboolean writing_msg(PurpleAccount *account, char *sender, char **message,
-				PurpleConversation *conv, PurpleMessageFlags flags)
+static gboolean writing_msg(PurpleConversation *conv, PurpleMessage *msg, gpointer _unused)
 {
 	GString *t;
 	GList *iter, *urls, *next;
 	int c = 0;
 
-	if ((flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_INVISIBLE)))
+	if (purple_message_get_flags(msg) & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_INVISIBLE))
 		return FALSE;
 
 	urls = g_object_get_data(G_OBJECT(conv), "TinyURLs");
 	if (urls != NULL) /* message was cancelled somewhere? Reset. */
 		g_list_foreach(urls, free_urls, NULL);
 	g_list_free(urls);
-	urls = extract_urls(*message);
+	urls = extract_urls(purple_message_get_contents(msg));
 	if (!urls)
 		return FALSE;
 
-	t = g_string_new(*message);
-	g_free(*message);
+	t = g_string_new(g_strdup(purple_message_get_contents(msg)));
 	for (iter = urls; iter; iter = next) {
 		next = iter->next;
 		if (g_utf8_strlen((char *)iter->data, -1) >= purple_prefs_get_int(PREF_LENGTH)) {
@@ -289,21 +287,23 @@ static gboolean writing_msg(PurpleAccoun
 			urls = g_list_delete_link(urls, iter);
 		}
 	}
-	*message = t->str;
-	g_string_free(t, FALSE);
-	if (conv == NULL)
-		conv = PURPLE_CONVERSATION(purple_im_conversation_new(account, sender));
-	g_object_set_data(G_OBJECT(conv), "TinyURLs", urls);
+	purple_message_set_contents(msg, t->str);
+	g_string_free(t, TRUE);
+	if (conv != NULL)
+		g_object_set_data(G_OBJECT(conv), "TinyURLs", urls);
 	return FALSE;
 }
 
-static void wrote_msg(PurpleAccount *account, char *sender, char *message,
-				PurpleConversation *conv, PurpleMessageFlags flags)
+static void wrote_msg(PurpleConversation *conv, PurpleMessage *pmsg,
+	gpointer _unused)
 {
 	GList *urls;
 
+	if (purple_message_get_flags(pmsg) & PURPLE_MESSAGE_SEND)
+		return;
+
 	urls = g_object_get_data(G_OBJECT(conv), "TinyURLs");
-	if ((flags & PURPLE_MESSAGE_SEND) || urls == NULL)
+	if (urls == NULL)
 		return;
 
 	process_urls(conv, urls);
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -56,8 +56,7 @@ struct _PurpleConversationPrivate
 	PurpleConversationUiOps *ui_ops;  /* UI-specific operations.           */
 
 	PurpleConnectionFlags features;   /* The supported features            */
-	GList *message_history;           /* Message history, as a GList of
-	                                       PurpleConversationMessage's       */
+	GList *message_history; /* Message history, as a GList of PurpleMessages */
 
 	PurpleE2eeState *e2ee_state;      /* End-to-end encryption state.      */
 
@@ -67,19 +66,6 @@ struct _PurpleConversationPrivate
 	PurpleSmileyList *remote_smileys;
 };
 
-/*
- * Description of a conversation message
- */
-struct _PurpleConversationMessage
-{
-	char *who;
-	char *what;
-	PurpleMessageFlags flags;
-	time_t when;
-	PurpleConversation *conv;
-	char *alias;
-};
-
 /* GObject Property enums */
 enum
 {
@@ -216,58 +202,20 @@ open_log(PurpleConversation *conv)
 							   conv, time(NULL), NULL));
 }
 
-/* Functions that deal with PurpleConversationMessage */
+/* Functions that deal with PurpleMessage history */
 
 static void
-add_message_to_history(PurpleConversation *conv, const char *who, const char *alias,
-		const char *message, PurpleMessageFlags flags, time_t when)
+add_message_to_history(PurpleConversation *conv, PurpleMessage *msg)
 {
 	PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
-	PurpleConversationMessage *msg;
-	PurpleConnection *gc;
 



More information about the Commits mailing list