/soc/2013/ankitkv/gobjectification: 0b1b22f5e2ec: Begun GObjecti...
Ankit Vani
a at nevitus.org
Fri Jun 21 09:26:31 EDT 2013
Changeset: 0b1b22f5e2ec142f63b9d2abedac4754fcdedd39
Author: Ankit Vani <a at nevitus.org>
Date: 2013-06-21 18:56 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/0b1b22f5e2ec
Description:
Begun GObjectification of PurpleConversation.
* Moved things around
* Renamed enum names and values according to GObject standards
* Renamed IM API to purple_im_conversation_action()
* Renamed Chat API to purple_chat_conversation_action()
* Added purple_get_conversations to conversations API as purple_conversations_get()
* Added purple_get_ims to conversations API as purple_conversations_get_ims()
* Added purple_get_chats to conversations API as purple_conversations_get_chats()
diffstat:
libpurple/conversation.c | 1018 +++++++++++++-------------------------------
libpurple/conversation.h | 515 ++++++++++------------
libpurple/conversations.c | 386 +++++++++++++++++
libpurple/conversations.h | 66 ++-
4 files changed, 980 insertions(+), 1005 deletions(-)
diffs (truncated from 3750 to 300 lines):
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -35,15 +35,48 @@
#define SEND_TYPED_TIMEOUT_SECONDS 5
+/** @copydoc _PurpleConversationPrivate */
+typedef struct _PurpleConversationPrivate PurpleConversationPrivate;
+/** @copydoc _PurpleChatConversationPrivate */
+typedef struct _PurpleChatConversationPrivate PurpleChatConversationPrivate;
+/** @copydoc _PurpleIMConversationPrivate */
+typedef struct _PurpleIMConversationPrivate PurpleIMConversationPrivate;
+
+/**
+ * A core representation of a conversation between two or more people.
+ *
+ * The conversation can be an IM or a chat.
+ */
+struct _PurpleConversationPrivate
+{
+ PurpleConversationType type; /**< The type of conversation. */
+
+ PurpleAccount *account; /**< The user using this conversation. */
+
+
+ char *name; /**< The name of the conversation. */
+ char *title; /**< The window title. */
+
+ gboolean logging; /**< The status of logging. */
+
+ GList *logs; /**< This conversation's logs */
+
+ PurpleConversationUiOps *ui_ops; /**< UI-specific operations. */
+ void *ui_data; /**< UI-specific data. */
+
+ GHashTable *data; /**< Plugin-specific data. */
+
+ PurpleConnectionFlags features; /**< The supported features */
+ GList *message_history; /**< Message history, as a GList of PurpleConversationMessage's */
+};
+
/**
* Data specific to Chats.
*/
-struct _PurpleConvChat
+struct _PurpleChatConversationPrivate
{
- PurpleConversation *conv; /**< The parent conversation. */
-
GList *in_room; /**< The users in the room.
- * @deprecated Will be removed in 3.0.0
+ * @deprecated Will be removed in 3.0.0 TODO
*/
GList *ignored; /**< Ignored users. */
char *who; /**< The person who set the topic. */
@@ -58,11 +91,9 @@ struct _PurpleConvChat
/**
* Data specific to Instant Messages.
*/
-struct _PurpleConvIm
+struct _PurpleIMConversationPrivate
{
- PurpleConversation *conv; /**< The parent conversation. */
-
- PurpleTypingState typing_state; /**< The current typing state. */
+ 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. */
@@ -73,7 +104,7 @@ struct _PurpleConvIm
/**
* Data for "Chat Buddies"
*/
-struct _PurpleConvChatBuddy
+struct _PurpleChatConversationBuddy
{
/** The chat participant's name in the chat. */
char *name;
@@ -98,7 +129,7 @@ struct _PurpleConvChatBuddy
* A bitwise OR of flags for this participant, such as whether they
* are a channel operator.
*/
- PurpleConvChatBuddyFlags flags;
+ PurpleChatConversationBuddyFlags flags;
/**
* A hash table of attributes about the user, such as real name,
@@ -111,60 +142,18 @@ struct _PurpleConvChatBuddy
};
/**
- * A core representation of a conversation between two or more people.
- *
- * The conversation can be an IM or a chat.
- */
-struct _PurpleConversation
-{
- PurpleConversationType type; /**< The type of conversation. */
-
- PurpleAccount *account; /**< The user using this conversation. */
-
-
- char *name; /**< The name of the conversation. */
- char *title; /**< The window title. */
-
- gboolean logging; /**< The status of logging. */
-
- GList *logs; /**< This conversation's logs */
-
- union
- {
- PurpleConvIm *im; /**< IM-specific data. */
- PurpleConvChat *chat; /**< Chat-specific data. */
- void *misc; /**< Misc. data. */
-
- } u;
-
- PurpleConversationUiOps *ui_ops; /**< UI-specific operations. */
- void *ui_data; /**< UI-specific data. */
-
- GHashTable *data; /**< Plugin-specific data. */
-
- PurpleConnectionFlags features; /**< The supported features */
- GList *message_history; /**< Message history, as a GList of PurpleConvMessage's */
-};
-
-/**
* Description of a conversation message
*/
-struct _PurpleConvMessage
+struct _PurpleConversationMessage
{
char *who;
char *what;
- PurpleMessageFlags flags;
+ PurpleConversationMessageFlags flags;
time_t when;
PurpleConversation *conv;
char *alias;
};
-
-static GList *conversations = NULL;
-static GList *ims = NULL;
-static GList *chats = NULL;
-static PurpleConversationUiOps *default_ops = NULL;
-
/**
* A hash table used for efficient lookups of conversations by name.
* struct _purple_hconv => PurpleConversation*
@@ -212,22 +201,16 @@ static gboolean _purple_conversation_use
return !g_utf8_collate(a, b);
}
-void
-purple_conversations_set_ui_ops(PurpleConversationUiOps *ops)
-{
- default_ops = ops;
-}
-
static gboolean
reset_typing_cb(gpointer data)
{
PurpleConversation *c = (PurpleConversation *)data;
- PurpleConvIm *im;
-
- im = PURPLE_CONV_IM(c);
-
- purple_conv_im_set_typing_state(im, PURPLE_NOT_TYPING);
- purple_conv_im_stop_typing_timeout(im);
+ PurpleIMConversationPrivate *priv;
+
+ im = PURPLE_IM_CONVERSATION_GET_PRIVATE(c);
+
+ purple_im_conversation_set_typing_state(im, PURPLE_IM_CONVERSATION_NOT_TYPING);
+ purple_im_conversation_stop_typing_timeout(im);
return FALSE;
}
@@ -245,12 +228,12 @@ send_typed_cb(gpointer data)
name = purple_conversation_get_name(conv);
if (gc != NULL && name != NULL) {
- /* We set this to 1 so that PURPLE_TYPING will be sent
+ /* We set this to 1 so that PURPLE_IM_CONVERSATION_TYPING will be sent
* if the Purple user types anything else.
*/
- purple_conv_im_set_type_again(PURPLE_CONV_IM(conv), 1);
-
- serv_send_typing(gc, name, PURPLE_TYPED);
+ purple_im_conversation_set_type_again(PURPLE_IM_CONVERSATION_GET_PRIVATE(conv), 1);
+
+ serv_send_typing(gc, name, PURPLE_IM_CONVERSATION_TYPED);
purple_debug(PURPLE_DEBUG_MISC, "conversation", "typed...\n");
}
@@ -259,7 +242,7 @@ send_typed_cb(gpointer data)
}
static void
-common_send(PurpleConversation *conv, const char *message, PurpleMessageFlags msgflags)
+common_send(PurpleConversation *conv, const char *message, PurpleConversationMessageFlags msgflags)
{
PurpleConversationType type;
PurpleAccount *account;
@@ -280,23 +263,23 @@ common_send(PurpleConversation *conv, co
/* Always linkfy the text for display, unless we're
* explicitly asked to do otheriwse*/
- if (!(msgflags & PURPLE_MESSAGE_INVISIBLE)) {
- if(msgflags & PURPLE_MESSAGE_NO_LINKIFY)
+ if (!(msgflags & PURPLE_CONVERSATION_MESSAGE_INVISIBLE)) {
+ if(msgflags & PURPLE_CONVERSATION_MESSAGE_NO_LINKIFY)
displayed = g_strdup(message);
else
displayed = purple_markup_linkify(message);
}
if (displayed && (conv->features & PURPLE_CONNECTION_HTML) &&
- !(msgflags & PURPLE_MESSAGE_RAW)) {
+ !(msgflags & PURPLE_CONVERSATION_MESSAGE_RAW)) {
sent = g_strdup(displayed);
} else
sent = g_strdup(message);
- msgflags |= PURPLE_MESSAGE_SEND;
-
- if (type == PURPLE_CONV_TYPE_IM) {
- PurpleConvIm *im = PURPLE_CONV_IM(conv);
+ msgflags |= PURPLE_CONVERSATION_MESSAGE_SEND;
+
+ if (type == PURPLE_CONVERSATION_TYPE_IM) {
+ PurpleIMConversationPrivate *priv = PURPLE_IM_CONVERSATION_GET_PRIVATE(conv);
purple_signal_emit(purple_conversations_get_handle(), "sending-im-msg",
account,
@@ -308,7 +291,7 @@ common_send(PurpleConversation *conv, co
sent, msgflags);
if ((err > 0) && (displayed != NULL))
- purple_conv_im_write(im, NULL, displayed, msgflags, time(NULL));
+ purple_im_conversation_write(im, NULL, displayed, msgflags, time(NULL));
purple_signal_emit(purple_conversations_get_handle(), "sent-im-msg",
account,
@@ -318,14 +301,14 @@ common_send(PurpleConversation *conv, co
else {
purple_signal_emit(purple_conversations_get_handle(), "sending-chat-msg",
account, &sent,
- purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)));
+ purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION_GET_PRIVATE(conv)));
if (sent != NULL && sent[0] != '\0') {
- err = serv_chat_send(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), sent, msgflags);
+ err = serv_chat_send(gc, purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION_GET_PRIVATE(conv)), sent, msgflags);
purple_signal_emit(purple_conversations_get_handle(), "sent-chat-msg",
account, sent,
- purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)));
+ purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION_GET_PRIVATE(conv)));
}
}
@@ -366,23 +349,23 @@ common_send(PurpleConversation *conv, co
static void
open_log(PurpleConversation *conv)
{
- conv->logs = g_list_append(NULL, purple_log_new(conv->type == PURPLE_CONV_TYPE_CHAT ? PURPLE_LOG_CHAT :
+ conv->logs = g_list_append(NULL, purple_log_new(conv->type == PURPLE_CONVERSATION_TYPE_CHAT ? PURPLE_LOG_CHAT :
PURPLE_LOG_IM, conv->name, conv->account,
conv, time(NULL), NULL));
}
-/* Functions that deal with PurpleConvMessage */
+/* Functions that deal with PurpleConversationMessage */
static void
add_message_to_history(PurpleConversation *conv, const char *who, const char *alias,
- const char *message, PurpleMessageFlags flags, time_t when)
+ const char *message, PurpleConversationMessageFlags flags, time_t when)
{
- PurpleConvMessage *msg;
+ PurpleConversationMessage *msg;
PurpleConnection *gc;
gc = purple_account_get_connection(conv->account);
- if (flags & PURPLE_MESSAGE_SEND) {
+ if (flags & PURPLE_CONVERSATION_MESSAGE_SEND) {
const char *me = NULL;
if (gc)
me = purple_connection_get_display_name(gc);
@@ -391,8 +374,8 @@ add_message_to_history(PurpleConversatio
who = me;
}
- msg = g_new0(PurpleConvMessage, 1);
- PURPLE_DBUS_REGISTER_POINTER(msg, PurpleConvMessage);
+ msg = g_new0(PurpleConversationMessage, 1);
More information about the Commits
mailing list