/soc/2013/ankitkv/gobjectification: 40a30f74a7b8: Removed purple...
Ankit Vani
a at nevitus.org
Sat Jun 29 12:40:29 EDT 2013
Changeset: 40a30f74a7b872c2441313abae22a7de85859af6
Author: Ankit Vani <a at nevitus.org>
Date: 2013-06-29 22:10 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/40a30f74a7b8
Description:
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Removed data from PurpleConversationPrivate.
diffstat:
finch/gntconv.c | 10 +++---
finch/plugins/gnttinyurl.c | 10 +++---
libpurple/conversation.c | 54 ++++++++---------------------------------
libpurple/conversation.h | 20 ---------------
libpurple/plugins/offlinemsg.c | 8 +++---
libpurple/protocols/irc/msgs.c | 6 ++--
pidgin/gtkblist.c | 4 +-
pidgin/gtkconv.c | 38 ++++++++++++++--------------
pidgin/gtkdocklet.c | 4 +-
pidgin/plugins/notify.c | 30 +++++++++++-----------
10 files changed, 66 insertions(+), 118 deletions(-)
diffs (truncated from 511 to 300 lines):
diff --git a/finch/gntconv.c b/finch/gntconv.c
--- a/finch/gntconv.c
+++ b/finch/gntconv.c
@@ -334,7 +334,7 @@ account_signed_on_off(PurpleConnection *
list = list->next;
if (purple_conversation_get_account(conv) != purple_connection_get_account(gc) ||
- !purple_conversation_get_data(conv, "want-to-rejoin"))
+ !g_object_get_data(G_OBJECT(conv), "want-to-rejoin"))
continue;
chat = find_chat_for_conversation(conv);
@@ -364,7 +364,7 @@ account_signing_off(PurpleConnection *gc
PurpleConversation *conv = list->data;
if (!purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION(conv)) &&
purple_conversation_get_account(conv) == account) {
- purple_conversation_set_data(conv, "want-to-rejoin", GINT_TO_POINTER(TRUE));
+ g_object_set_data(G_OBJECT(conv), "want-to-rejoin", GINT_TO_POINTER(TRUE));
purple_conversation_write(conv, NULL, _("The account has disconnected and you are no "
"longer in this chat. You will be automatically rejoined in the chat when "
"the account reconnects."),
@@ -718,7 +718,7 @@ gained_focus_cb(GntWindow *window, Finch
{
GList *iter;
for (iter = fc->list; iter; iter = iter->next) {
- purple_conversation_set_data(iter->data, "unseen-count", 0);
+ g_object_set_data(G_OBJECT(iter->data), "unseen-count", 0);
purple_conversation_update(iter->data, PURPLE_CONVERSATION_UPDATE_UNSEEN);
}
}
@@ -1007,8 +1007,8 @@ finch_write_common(PurpleConversation *c
if (flags & (PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_ERROR))
gnt_widget_set_urgent(ggconv->tv);
if (flags & PURPLE_MESSAGE_RECV && !gnt_widget_has_focus(ggconv->window)) {
- int count = GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-count"));
- purple_conversation_set_data(conv, "unseen-count", GINT_TO_POINTER(count + 1));
+ int count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unseen-count"));
+ g_object_set_data(G_OBJECT(conv), "unseen-count", GINT_TO_POINTER(count + 1));
purple_conversation_update(conv, PURPLE_CONVERSATION_UPDATE_UNSEEN);
}
}
diff --git a/finch/plugins/gnttinyurl.c b/finch/plugins/gnttinyurl.c
--- a/finch/plugins/gnttinyurl.c
+++ b/finch/plugins/gnttinyurl.c
@@ -251,7 +251,7 @@ static gboolean writing_msg(PurpleAccoun
if ((flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_INVISIBLE)))
return FALSE;
- urls = purple_conversation_get_data(conv, "TinyURLs");
+ 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);
@@ -288,7 +288,7 @@ static gboolean writing_msg(PurpleAccoun
g_string_free(t, FALSE);
if (conv == NULL)
conv = PURPLE_CONVERSATION(purple_im_conversation_new(account, sender));
- purple_conversation_set_data(conv, "TinyURLs", urls);
+ g_object_set_data(G_OBJECT(conv), "TinyURLs", urls);
return FALSE;
}
@@ -297,12 +297,12 @@ static void wrote_msg(PurpleAccount *acc
{
GList *urls;
- urls = purple_conversation_get_data(conv, "TinyURLs");
+ urls = g_object_get_data(G_OBJECT(conv), "TinyURLs");
if ((flags & PURPLE_MESSAGE_SEND) || urls == NULL)
return;
process_urls(conv, urls);
- purple_conversation_set_data(conv, "TinyURLs", NULL);
+ g_object_set_data(G_OBJECT(conv), "TinyURLs", NULL);
}
/* Frees 'urls' */
@@ -345,7 +345,7 @@ process_urls(PurpleConversation *conv, G
static void
free_conv_urls(PurpleConversation *conv)
{
- GList *urls = purple_conversation_get_data(conv, "TinyURLs");
+ GList *urls = g_object_get_data(G_OBJECT(conv), "TinyURLs");
if (urls)
g_list_foreach(urls, free_urls, NULL);
g_list_free(urls);
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -47,22 +47,21 @@ typedef struct _PurpleConversationPrivat
*/
struct _PurpleConversationPrivate
{
- PurpleAccount *account; /**< The user using this conversation. */
+ PurpleAccount *account; /**< The user using this conversation. */
- char *name; /**< The name of the conversation. */
- char *title; /**< The window title. */
+ char *name; /**< The name of the conversation. */
+ char *title; /**< The window title. */
- gboolean logging; /**< The status of logging. */
+ gboolean logging; /**< The status of logging. */
- GList *logs; /**< This conversation's logs */
+ GList *logs; /**< This conversation's logs */
- PurpleConversationUiOps *ui_ops; /**< UI-specific operations. */
- void *ui_data; /**< UI-specific data. */
+ 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 */
+ PurpleConnectionFlags features; /**< The supported features */
+ GList *message_history; /**< Message history, as a GList of
+ PurpleConversationMessage's */
};
/**
@@ -481,29 +480,6 @@ purple_conversation_close_logs(PurpleCon
}
void
-purple_conversation_set_data(PurpleConversation *conv, const char *key,
- gpointer data)
-{
- PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
-
- g_return_if_fail(priv != NULL);
- g_return_if_fail(key != NULL);
-
- g_hash_table_replace(priv->data, g_strdup(key), data);
-}
-
-gpointer
-purple_conversation_get_data(PurpleConversation *conv, const char *key)
-{
- PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
-
- g_return_val_if_fail(priv != NULL, NULL);
- g_return_val_if_fail(key != NULL, NULL);
-
- return g_hash_table_lookup(priv->data, key);
-}
-
-void
purple_conversation_write(PurpleConversation *conv, const char *who,
const char *message, PurpleMessageFlags flags,
time_t mtime)
@@ -994,12 +970,7 @@ purple_conversation_get_property(GObject
static void
purple_conversation_init(GTypeInstance *instance, gpointer klass)
{
- PurpleConversation *conv = PURPLE_CONVERSATION(instance);
- PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
-
- priv->data = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
-
- PURPLE_DBUS_REGISTER_POINTER(conv, PurpleConversation);
+ PURPLE_DBUS_REGISTER_POINTER(PURPLE_CONVERSATION(instance), PurpleConversation);
}
/* GObject dispose function */
@@ -1040,9 +1011,6 @@ purple_conversation_finalize(GObject *ob
priv->name = NULL;
priv->title = NULL;
- g_hash_table_destroy(priv->data);
- priv->data = NULL;
-
if (ops != NULL && ops->destroy_conversation != NULL)
ops->destroy_conversation(conv);
priv->ui_data = NULL;
diff --git a/libpurple/conversation.h b/libpurple/conversation.h
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -395,26 +395,6 @@ gboolean purple_conversation_is_logging(
void purple_conversation_close_logs(PurpleConversation *conv);
/**
- * Sets extra data for a conversation.
- *
- * @param conv The conversation.
- * @param key The unique key.
- * @param data The data to assign.
- */
-void purple_conversation_set_data(PurpleConversation *conv, const char *key,
- gpointer data);
-
-/**
- * Returns extra data in a conversation.
- *
- * @param conv The conversation.
- * @param key The unqiue key.
- *
- * @return The data associated with the key.
- */
-gpointer purple_conversation_get_data(PurpleConversation *conv, const char *key);
-
-/**
* Writes to a conversation window.
*
* This function should not be used to write IM or chat messages. Use
diff --git a/libpurple/plugins/offlinemsg.c b/libpurple/plugins/offlinemsg.c
--- a/libpurple/plugins/offlinemsg.c
+++ b/libpurple/plugins/offlinemsg.c
@@ -67,7 +67,7 @@ discard_data(OfflineMsg *offline)
static void
cancel_poune(OfflineMsg *offline)
{
- purple_conversation_set_data(offline->conv, "plugin_pack:offlinemsg",
+ g_object_set_data(G_OBJECT(offline->conv), "plugin_pack:offlinemsg",
GINT_TO_POINTER(OFFLINE_MSG_NO));
purple_conversation_send_with_flags(offline->conv, offline->message, 0);
discard_data(offline);
@@ -97,12 +97,12 @@ record_pounce(OfflineMsg *offline)
g_free(temp);
conv = offline->conv;
- if (!purple_conversation_get_data(conv, "plugin_pack:offlinemsg"))
+ if (!g_object_get_data(G_OBJECT(conv), "plugin_pack:offlinemsg"))
purple_conversation_write(conv, NULL, _("The rest of the messages will be saved "
"as pounces. You can edit/delete the pounce from the `Buddy "
"Pounce' dialog."),
PURPLE_MESSAGE_SYSTEM, time(NULL));
- purple_conversation_set_data(conv, "plugin_pack:offlinemsg",
+ g_object_set_data(G_OBJECT(conv), "plugin_pack:offlinemsg",
GINT_TO_POINTER(OFFLINE_MSG_YES));
purple_conversation_write_message(conv, offline->who, offline->message,
@@ -142,7 +142,7 @@ sending_msg_cb(PurpleAccount *account, c
if (!conv)
return;
- setting = GPOINTER_TO_INT(purple_conversation_get_data(conv, "plugin_pack:offlinemsg"));
+ setting = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "plugin_pack:offlinemsg"));
if (setting == OFFLINE_MSG_NO)
return;
diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
--- a/libpurple/protocols/irc/msgs.c
+++ b/libpurple/protocols/irc/msgs.c
@@ -688,7 +688,7 @@ void irc_msg_names(struct irc_conn *irc,
names = cur = g_string_free(irc->names, FALSE);
irc->names = NULL;
- if (purple_conversation_get_data(convo, IRC_NAMES_FLAG)) {
+ if (g_object_get_data(G_OBJECT(convo), IRC_NAMES_FLAG)) {
msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : "");
purple_conversation_write_message(convo, "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
g_free(msg);
@@ -736,7 +736,7 @@ void irc_msg_names(struct irc_conn *irc,
g_list_free(flags);
}
- purple_conversation_set_data(convo, IRC_NAMES_FLAG,
+ g_object_set_data(G_OBJECT(convo), IRC_NAMES_FLAG,
GINT_TO_POINTER(TRUE));
}
g_free(names);
@@ -978,7 +978,7 @@ void irc_msg_join(struct irc_conn *irc,
purple_debug_error("irc", "tried to join %s but couldn't\n", args[0]);
return;
}
- purple_conversation_set_data(PURPLE_CONVERSATION(chat), IRC_NAMES_FLAG,
+ g_object_set_data(G_OBJECT(chat), IRC_NAMES_FLAG,
GINT_TO_POINTER(FALSE));
// Get the real name and user host for all participants.
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -4789,8 +4789,8 @@ conversation_updated_cb(PurpleConversati
if(gtkconv)
count = gtkconv->unseen_count;
- else if(purple_conversation_get_data(l->data, "unseen-count"))
- count = GPOINTER_TO_INT(purple_conversation_get_data(l->data, "unseen-count"));
+ else if(g_object_get_data(G_OBJECT(l->data), "unseen-count"))
+ count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(l->data), "unseen-count"));
g_string_append_printf(tooltip_text,
ngettext("%d unread message from %s\n", "%d unread messages from %s\n", count),
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -1361,11 +1361,11 @@ hide_conv(PidginConversation *gtkconv, g
for (list = g_list_copy(gtkconv->convs); list; list = g_list_delete_link(list, list)) {
PurpleConversation *conv = list->data;
if (closetimer) {
- guint timer = GPOINTER_TO_INT(purple_conversation_get_data(conv, "close-timer"));
+ guint timer = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "close-timer"));
if (timer)
purple_timeout_remove(timer);
timer = purple_timeout_add_seconds(CLOSE_CONV_TIMEOUT_SECS, close_already, conv);
- purple_conversation_set_data(conv, "close-timer", GINT_TO_POINTER(timer));
+ g_object_set_data(G_OBJECT(conv), "close-timer", GINT_TO_POINTER(timer));
More information about the Commits
mailing list