/soc/2013/ankitkv/gobjectification: dbe6ee43aaa7: Created conver...

Ankit Vani a at nevitus.org
Fri Jun 21 17:46:48 EDT 2013


Changeset: dbe6ee43aaa77b3ff695d0ce5683bae6cd5ddc3e
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-22 03:16 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/dbe6ee43aaa7

Description:

Created conversationtypes.[ch] for PurpleChatConversation and PurpleIMConversation

diffstat:

 libpurple/Makefile.am         |     3 +
 libpurple/conversation.c      |  1091 +----------------------------------------
 libpurple/conversation.h      |   691 -------------------------
 libpurple/conversationtypes.c |  1113 +++++++++++++++++++++++++++++++++++++++++
 libpurple/conversationtypes.h |   730 ++++++++++++++++++++++++++
 5 files changed, 1847 insertions(+), 1781 deletions(-)

diffs (truncated from 3774 to 300 lines):

diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -48,6 +48,7 @@ purple_coresources = \
 	cmds.c \
 	connection.c \
 	conversation.c \
+	conversationtypes.c \
 	conversations.c \
 	core.c \
 	debug.c \
@@ -120,6 +121,7 @@ purple_coreheaders = \
 	cmds.h \
 	connection.h \
 	conversation.h \
+	conversationtypes.h \
 	conversations.h \
 	core.h \
 	dbus-maybe.h \
@@ -185,6 +187,7 @@ purple_enumheaders = \
 	cipher.h \
 	circularbuffer.h \
 	conversation.h \
+	conversationtypes.h \
 	conversations.h \
 	hash.h \
 	smiley.h \
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -33,16 +33,8 @@
 #include "signals.h"
 #include "util.h"
 
-#define SEND_TYPED_TIMEOUT_SECONDS 5
-
 /** @copydoc _PurpleConversationPrivate */
-typedef struct _PurpleConversationPrivate         PurpleConversationPrivate;
-/** @copydoc _PurpleChatConversationPrivate */
-typedef struct _PurpleChatConversationPrivate     PurpleChatConversationPrivate;
-/** @copydoc _PurpleIMConversationPrivate */
-typedef struct _PurpleIMConversationPrivate       PurpleIMConversationPrivate;
-/** @copydoc _PurpleChatConversationBuddyPrivate */
-typedef struct _PurpleChatConversationBuddyPrivate  PurpleChatConversationBuddyPrivate;
+typedef struct _PurpleConversationPrivate  PurpleConversationPrivate;
 
 /**
  * A core representation of a conversation between two or more people.
@@ -72,77 +64,6 @@ struct _PurpleConversationPrivate
 	GList *message_history;         /**< Message history, as a GList of PurpleConversationMessage's */
 };
 
-/**
- * Data specific to Chats.
- */
-struct _PurpleChatConversationPrivate
-{
-	GList *in_room;                  /**< The users in the room.
-	                                  *   @deprecated Will be removed in 3.0.0 TODO
-									  */
-	GList *ignored;                  /**< Ignored users.                */
-	char  *who;                      /**< The person who set the topic. */
-	char  *topic;                    /**< The topic.                    */
-	int    id;                       /**< The chat ID.                  */
-	char *nick;                      /**< Your nick in this chat.       */
-
-	gboolean left;                   /**< We left the chat and kept the window open */
-	GHashTable *users;               /**< Hash table of the users in the room. */
-};
-
-/**
- * Data specific to Instant Messages.
- */
-struct _PurpleIMConversationPrivate
-{
-	PurpleIMConversationTypingState typing_state;      /**< The current typing state.    */
-	guint  typing_timeout;             /**< The typing timer handle.     */
-	time_t type_again;                 /**< The type again time.         */
-	guint  send_typed_timeout;         /**< The type again timer handle. */
-
-	PurpleBuddyIcon *icon;               /**< The buddy icon.              */
-};
-
-/**
- * Data for "Chat Buddies"
- */
-struct _PurpleChatConversationBuddyPrivate
-{
-	/** The chat participant's name in the chat. */
-	char *name;
-
-	/** The chat participant's alias, if known; @a NULL otherwise. */
-	char *alias;
-
-	/**
-	 * A string by which this buddy will be sorted, or @c NULL if the
-	 * buddy should be sorted by its @c name.  (This is currently always
-	 * @c NULL.
-	 */
-	char *alias_key;
-
-	/**
-	 * @a TRUE if this chat participant is on the buddy list;
-	 * @a FALSE otherwise.
-	 */
-	gboolean buddy;
-
-	/**
-	 * A bitwise OR of flags for this participant, such as whether they
-	 * are a channel operator.
-	 */
-	PurpleChatConversationBuddyFlags flags;
-
-	/**
-	 * A hash table of attributes about the user, such as real name,
-	 * user\@host, etc.
-	 */
-	GHashTable *attributes;
-
-	/** The UI can put whatever it wants here. */
-	gpointer ui_data;
-};
-
 /** TODO GBoxed
  * Description of a conversation message
  */
@@ -1084,185 +1005,6 @@ purple_conversation_update(PurpleConvers
 					 "conversation-updated", conv, type);
 }
 
-/**************************************************************************
- * IM Conversation API
- **************************************************************************/
-void
-purple_im_conversation_set_icon(PurpleIMConversation *im, PurpleBuddyIcon *icon)
-{
-	g_return_if_fail(im != NULL);
-
-	if (im->icon != icon)
-	{
-		purple_buddy_icon_unref(im->icon);
-
-		im->icon = (icon == NULL ? NULL : purple_buddy_icon_ref(icon));
-	}
-
-	purple_conversation_update(purple_im_conversation_get_conversation(im),
-							 PURPLE_CONVERSATION_UPDATE_ICON);
-}
-
-PurpleBuddyIcon *
-purple_im_conversation_get_icon(const PurpleIMConversation *im)
-{
-	g_return_val_if_fail(im != NULL, NULL);
-
-	return im->icon;
-}
-
-void
-purple_im_conversation_set_typing_state(PurpleIMConversation *im, PurpleIMConversationTypingState state)
-{
-	g_return_if_fail(im != NULL);
-
-	if (im->typing_state != state)
-	{
-		im->typing_state = state;
-
-		switch (state)
-		{
-			case PURPLE_IM_CONVERSATION_TYPING:
-				purple_signal_emit(purple_conversations_get_handle(),
-								   "buddy-typing", im->conv->account, im->conv->name);
-				break;
-			case PURPLE_IM_CONVERSATION_TYPED:
-				purple_signal_emit(purple_conversations_get_handle(),
-								   "buddy-typed", im->conv->account, im->conv->name);
-				break;
-			case PURPLE_IM_CONVERSATION_NOT_TYPING:
-				purple_signal_emit(purple_conversations_get_handle(),
-								   "buddy-typing-stopped", im->conv->account, im->conv->name);
-				break;
-		}
-
-		purple_im_conversation_update_typing(im);
-	}
-}
-
-PurpleIMConversationTypingState
-purple_im_conversation_get_typing_state(const PurpleIMConversation *im)
-{
-	g_return_val_if_fail(im != NULL, 0);
-
-	return im->typing_state;
-}
-
-void
-purple_im_conversation_start_typing_timeout(PurpleIMConversation *im, int timeout)
-{
-	PurpleConversation *conv;
-
-	g_return_if_fail(im != NULL);
-
-	if (im->typing_timeout > 0)
-		purple_im_conversation_stop_typing_timeout(im);
-
-	conv = purple_im_conversation_get_conversation(im);
-
-	im->typing_timeout = purple_timeout_add_seconds(timeout, reset_typing_cb, conv);
-}
-
-void
-purple_im_conversation_stop_typing_timeout(PurpleIMConversation *im)
-{
-	g_return_if_fail(im != NULL);
-
-	if (im->typing_timeout == 0)
-		return;
-
-	purple_timeout_remove(im->typing_timeout);
-	im->typing_timeout = 0;
-}
-
-guint
-purple_im_conversation_get_typing_timeout(const PurpleIMConversation *im)
-{
-	g_return_val_if_fail(im != NULL, 0);
-
-	return im->typing_timeout;
-}
-
-void
-purple_im_conversation_set_type_again(PurpleIMConversation *im, unsigned int val)
-{
-	g_return_if_fail(im != NULL);
-
-	if (val == 0)
-		im->type_again = 0;
-	else
-		im->type_again = time(NULL) + val;
-}
-
-time_t
-purple_im_conversation_get_type_again(const PurpleIMConversation *im)
-{
-	g_return_val_if_fail(im != NULL, 0);
-
-	return im->type_again;
-}
-
-void
-purple_im_conversation_start_send_typed_timeout(PurpleIMConversation *im)
-{
-	g_return_if_fail(im != NULL);
-
-	im->send_typed_timeout = purple_timeout_add_seconds(SEND_TYPED_TIMEOUT_SECONDS,
-	                                                    send_typed_cb,
-	                                                    purple_im_conversation_get_conversation(im));
-}
-
-void
-purple_im_conversation_stop_send_typed_timeout(PurpleIMConversation *im)
-{
-	g_return_if_fail(im != NULL);
-
-	if (im->send_typed_timeout == 0)
-		return;
-
-	purple_timeout_remove(im->send_typed_timeout);
-	im->send_typed_timeout = 0;
-}
-
-guint
-purple_im_conversation_get_send_typed_timeout(const PurpleIMConversation *im)
-{
-	g_return_val_if_fail(im != NULL, 0);
-
-	return im->send_typed_timeout;
-}
-
-void
-purple_im_conversation_update_typing(PurpleIMConversation *im)
-{
-	g_return_if_fail(im != NULL);
-
-	purple_conversation_update(purple_im_conversation_get_conversation(im),
-							 PURPLE_CONVERSATION_UPDATE_TYPING);
-}
-
-void
-purple_im_conversation_write(PurpleIMConversation *im, const char *who, const char *message,
-			  PurpleConversationMessageFlags flags, time_t mtime)
-{
-	PurpleConversation *c;
-
-	g_return_if_fail(im != NULL);
-	g_return_if_fail(message != NULL);
-
-	c = purple_im_conversation_get_conversation(im);
-
-	if ((flags & PURPLE_CONVERSATION_MESSAGE_RECV) == PURPLE_CONVERSATION_MESSAGE_RECV) {
-		purple_im_conversation_set_typing_state(im, PURPLE_IM_CONVERSATION_NOT_TYPING);



More information about the Commits mailing list