/soc/2013/ankitkv/gobjectification: 3180ebbd06be: Added GObject ...
Ankit Vani
a at nevitus.org
Fri Jun 21 13:41:57 EDT 2013
Changeset: 3180ebbd06becf6e6620e80c8dfd706d2519e626
Author: Ankit Vani <a at nevitus.org>
Date: 2013-06-21 23:11 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/3180ebbd06be
Description:
Added GObject structures, moved things around, renamed functions as GObject methods.
* Added GObject instance, class and private structures for:
- PurpleChatConversation, subclassing PurpleConversation
- PurpleIMConversation, subclassing PurpleConversation
- PurpleChatConversationBuddy
- PurpleConversationMessage
* Renamed purple_chat_conversation_cb_ functions to purple_chat_conversation_buddy_ methods for PurpleChatConversationBuddy
* Renamed purple_find_conversation_with_account() to purple_conversations_find_with_account(), in conversations API
* Renamed purple_conv_ functions to purple_conversation_
* Renamed purple_conversation_present_error() to purple_conversation_helper_present_error since it's not a PurpleConversation method
* Renamed purple_chat_conversation_is_user_ignored() to purple_chat_conversation_is_ignored_user(), to match with other ignore API
* Renamed purple_chat_conversation_left() to purple_chat_conversation_leave()
diffstat:
libpurple/conversation.c | 169 ++++---------
libpurple/conversation.h | 556 ++++++++++++++++++++++++++-------------------
libpurple/conversations.c | 34 ++
libpurple/conversations.h | 13 +
4 files changed, 431 insertions(+), 341 deletions(-)
diffs (truncated from 1341 to 300 lines):
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -36,11 +36,15 @@
#define SEND_TYPED_TIMEOUT_SECONDS 5
/** @copydoc _PurpleConversationPrivate */
-typedef struct _PurpleConversationPrivate PurpleConversationPrivate;
+typedef struct _PurpleConversationPrivate PurpleConversationPrivate;
/** @copydoc _PurpleChatConversationPrivate */
-typedef struct _PurpleChatConversationPrivate PurpleChatConversationPrivate;
+typedef struct _PurpleChatConversationPrivate PurpleChatConversationPrivate;
/** @copydoc _PurpleIMConversationPrivate */
-typedef struct _PurpleIMConversationPrivate PurpleIMConversationPrivate;
+typedef struct _PurpleIMConversationPrivate PurpleIMConversationPrivate;
+/** @copydoc _PurpleChatConversationBuddyPrivate */
+typedef struct _PurpleChatConversationBuddyPrivate PurpleChatConversationBuddyPrivate;
+/** @copydoc _PurpleConversationMessagePrivate */
+typedef struct _PurpleConversationMessagePrivate PurpleConversationMessagePrivate;
/**
* A core representation of a conversation between two or more people.
@@ -104,7 +108,7 @@ struct _PurpleIMConversationPrivate
/**
* Data for "Chat Buddies"
*/
-struct _PurpleChatConversationBuddy
+struct _PurpleChatConversationBuddyPrivate
{
/** The chat participant's name in the chat. */
char *name;
@@ -144,7 +148,7 @@ struct _PurpleChatConversationBuddy
/**
* Description of a conversation message
*/
-struct _PurpleConversationMessage
+struct _PurpleConversationMessagePrivate
{
char *who;
char *what;
@@ -321,7 +325,7 @@ common_send(PurpleConversation *conv, co
if (err == -E2BIG) {
msg = _("Unable to send message: The message is too large.");
- if (!purple_conv_present_error(who, account, msg)) {
+ if (!purple_conversation_helper_present_error(who, account, msg)) {
char *msg2 = g_strdup_printf(_("Unable to send message to %s."), who);
purple_notify_error(gc, NULL, msg2, _("The message is too large."));
g_free(msg2);
@@ -334,7 +338,7 @@ common_send(PurpleConversation *conv, co
else {
msg = _("Unable to send message.");
- if (!purple_conv_present_error(who, account, msg)) {
+ if (!purple_conversation_helper_present_error(who, account, msg)) {
char *msg2 = g_strdup_printf(_("Unable to send message to %s."), who);
purple_notify_error(gc, NULL, msg2, NULL);
g_free(msg2);
@@ -449,7 +453,7 @@ purple_conversation_new(PurpleConversati
g_return_val_if_fail(name != NULL, NULL);
/* Check if this conversation already exists. */
- if ((conv = purple_find_conversation_with_account(type, name, account)) != NULL)
+ if ((conv = purple_conversations_find_with_account(type, name, account)) != NULL)
{
if (purple_conversation_get_type(conv) == PURPLE_CONVERSATION_TYPE_CHAT &&
!purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION_GET_PRIVATE(conv))) {
@@ -677,7 +681,7 @@ purple_conversation_destroy(PurpleConver
g_hash_table_destroy(conv->u.chat->users);
conv->u.chat->users = NULL;
- g_list_foreach(conv->u.chat->in_room, (GFunc)purple_chat_conversation_cb_destroy, NULL);
+ g_list_foreach(conv->u.chat->in_room, (GFunc)purple_chat_conversation_buddy_destroy, NULL);
g_list_free(conv->u.chat->in_room);
g_list_foreach(conv->u.chat->ignored, (GFunc)g_free, NULL);
@@ -865,21 +869,6 @@ purple_conversation_autoset_title(Purple
}
void
-purple_conversation_foreach(void (*func)(PurpleConversation *conv))
-{
- PurpleConversation *conv;
- GList *l;
-
- g_return_if_fail(func != NULL);
-
- for (l = purple_conversations_get(); l != NULL; l = l->next) {
- conv = (PurpleConversation *)l->data;
-
- func(conv);
- }
-}
-
-void
purple_conversation_set_name(PurpleConversation *conv, const char *name)
{
struct _purple_hconv *hc;
@@ -957,40 +946,6 @@ purple_conversation_get_data(PurpleConve
return g_hash_table_lookup(conv->data, key);
}
-PurpleConversation *
-purple_find_conversation_with_account(PurpleConversationType type,
- const char *name,
- const PurpleAccount *account)
-{
- PurpleConversation *c = NULL;
- struct _purple_hconv hc;
-
- g_return_val_if_fail(name != NULL, NULL);
-
- hc.name = (gchar *)purple_normalize(account, name);
- hc.account = account;
- hc.type = type;
-
- switch (type) {
- case PURPLE_CONVERSATION_TYPE_IM:
- case PURPLE_CONVERSATION_TYPE_CHAT:
- c = g_hash_table_lookup(conversation_cache, &hc);
- break;
- case PURPLE_CONVERSATION_TYPE_ANY:
- hc.type = PURPLE_CONVERSATION_TYPE_IM;
- c = g_hash_table_lookup(conversation_cache, &hc);
- if (!c) {
- hc.type = PURPLE_CONVERSATION_TYPE_CHAT;
- c = g_hash_table_lookup(conversation_cache, &hc);
- }
- break;
- default:
- g_return_val_if_reached(NULL);
- }
-
- return c;
-}
-
void
purple_conversation_write(PurpleConversation *conv, const char *who,
const char *message, PurpleConversationMessageFlags flags,
@@ -1134,14 +1089,6 @@ purple_conversation_update(PurpleConvers
/**************************************************************************
* IM Conversation API
**************************************************************************/
-PurpleConversation *
-purple_im_conversation_get_conversation(const PurpleIMConversation *im)
-{
- g_return_val_if_fail(im != NULL, NULL);
-
- return im->conv;
-}
-
void
purple_im_conversation_set_icon(PurpleIMConversation *im, PurpleBuddyIcon *icon)
{
@@ -1318,7 +1265,7 @@ purple_im_conversation_write(PurpleIMCon
purple_conversation_write(c, who, message, flags, mtime);
}
-gboolean purple_conv_present_error(const char *who, PurpleAccount *account, const char *what)
+gboolean purple_conversation_helper_present_error(const char *who, PurpleAccount *account, const char *what)
{
PurpleConversation *conv;
@@ -1326,7 +1273,7 @@ gboolean purple_conv_present_error(const
g_return_val_if_fail(account !=NULL, FALSE);
g_return_val_if_fail(what != NULL, FALSE);
- conv = purple_find_conversation_with_account(PURPLE_CONVERSATION_TYPE_ANY, who, account);
+ conv = purple_conversations_find_with_account(PURPLE_CONVERSATION_TYPE_ANY, who, account);
if (conv != NULL)
purple_conversation_write(conv, NULL, what, PURPLE_CONVERSATION_MESSAGE_ERROR, time(NULL));
else
@@ -1342,7 +1289,7 @@ purple_im_conversation_send(PurpleIMConv
}
static void
-purple_conv_send_confirm_cb(gpointer *data)
+purple_conversation_send_confirm_cb(gpointer *data)
{
PurpleConversation *conv = data[0];
char *message = data[1];
@@ -1352,7 +1299,7 @@ purple_conv_send_confirm_cb(gpointer *da
}
void
-purple_conv_send_confirm(PurpleConversation *conv, const char *message)
+purple_conversation_send_confirm(PurpleConversation *conv, const char *message)
{
char *text;
gpointer *data;
@@ -1374,7 +1321,7 @@ purple_conv_send_confirm(PurpleConversat
purple_request_action(conv, NULL, _("Send Message"), text, 0,
purple_conversation_get_account(conv), NULL, conv,
data, 2,
- _("_Send Message"), G_CALLBACK(purple_conv_send_confirm_cb),
+ _("_Send Message"), G_CALLBACK(purple_conversation_send_confirm_cb),
_("Cancel"), NULL);
}
@@ -1388,7 +1335,7 @@ purple_im_conversation_send_with_flags(P
}
gboolean
-purple_conv_custom_smiley_add(PurpleConversation *conv, const char *smile,
+purple_conversation_custom_smiley_add(PurpleConversation *conv, const char *smile,
const char *cksum_type, const char *chksum,
gboolean remote)
{
@@ -1408,7 +1355,7 @@ purple_conv_custom_smiley_add(PurpleConv
}
void
-purple_conv_custom_smiley_write(PurpleConversation *conv, const char *smile,
+purple_conversation_custom_smiley_write(PurpleConversation *conv, const char *smile,
const guchar *data, gsize size)
{
g_return_if_fail(conv != NULL);
@@ -1421,7 +1368,7 @@ purple_conv_custom_smiley_write(PurpleCo
}
void
-purple_conv_custom_smiley_close(PurpleConversation *conv, const char *smile)
+purple_conversation_custom_smiley_close(PurpleConversation *conv, const char *smile)
{
g_return_if_fail(conv != NULL);
g_return_if_fail(smile != NULL && *smile);
@@ -1460,7 +1407,7 @@ purple_chat_conversation_ignore(PurpleCh
g_return_if_fail(name != NULL);
/* Make sure the user isn't already ignored. */
- if (purple_chat_conversation_is_user_ignored(chat, name))
+ if (purple_chat_conversation_is_ignored_user(chat, name))
return;
purple_chat_conversation_set_ignored(chat,
@@ -1476,7 +1423,7 @@ purple_chat_conversation_unignore(Purple
g_return_if_fail(name != NULL);
/* Make sure the user is actually ignored. */
- if (!purple_chat_conversation_is_user_ignored(chat, name))
+ if (!purple_chat_conversation_is_ignored_user(chat, name))
return;
item = g_list_find(purple_chat_conversation_get_ignored(chat),
@@ -1538,7 +1485,7 @@ purple_chat_conversation_get_ignored_use
}
gboolean
-purple_chat_conversation_is_user_ignored(const PurpleChatConversation *chat, const char *user)
+purple_chat_conversation_is_ignored_user(const PurpleChatConversation *chat, const char *user)
{
g_return_val_if_fail(chat != NULL, FALSE);
g_return_val_if_fail(user != NULL, FALSE);
@@ -1605,7 +1552,7 @@ purple_chat_conversation_write(PurpleCha
account = purple_connection_get_account(gc);
/* Don't display this if the person who wrote it is ignored. */
- if (purple_chat_conversation_is_user_ignored(chat, who))
+ if (purple_chat_conversation_is_ignored_user(chat, who))
return;
if (!(flags & PURPLE_CONVERSATION_MESSAGE_WHISPER)) {
@@ -1662,7 +1609,7 @@ purple_chat_conversation_add_user(Purple
}
static int
-purple_chat_conversation_cb_compare(PurpleChatConversationBuddy *a, PurpleChatConversationBuddy *b)
+purple_chat_conversation_buddy_compare(PurpleChatConversationBuddy *a, PurpleChatConversationBuddy *b)
{
PurpleChatConversationBuddyFlags f1 = 0, f2 = 0;
char *user1 = NULL, *user2 = NULL;
@@ -1751,9 +1698,9 @@ purple_chat_conversation_add_users(Purpl
quiet = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_conversations_get_handle(),
"chat-buddy-joining", conv, user, flag)) ||
- purple_chat_conversation_is_user_ignored(chat, user);
-
- cbuddy = purple_chat_conversation_cb_new(user, alias, flag);
+ purple_chat_conversation_is_ignored_user(chat, user);
+
+ cbuddy = purple_chat_conversation_buddy_new(user, alias, flag);
cbuddy->buddy = purple_find_buddy(conv->account, user) != NULL;
chat->in_room = g_list_prepend(chat->in_room, cbuddy);
@@ -1789,7 +1736,7 @@ purple_chat_conversation_add_users(Purpl
extra_msgs = extra_msgs->next;
}
- cbuddies = g_list_sort(cbuddies, (GCompareFunc)purple_chat_conversation_cb_compare);
+ cbuddies = g_list_sort(cbuddies, (GCompareFunc)purple_chat_conversation_buddy_compare);
if (ops != NULL && ops->chat_add_users != NULL)
ops->chat_add_users(conv, cbuddies, new_arrivals);
@@ -1847,7 +1794,7 @@ purple_chat_conversation_rename_user(Pur
}
flags = purple_chat_conversation_user_get_flags(chat, old_user);
- cb = purple_chat_conversation_cb_new(new_user, new_alias, flags);
+ cb = purple_chat_conversation_buddy_new(new_user, new_alias, flags);
cb->buddy = purple_find_buddy(conv->account, new_user) != NULL;
More information about the Commits
mailing list