Thu, 27 Jun 2013 04:44:20 +0530
Refactored remaining libpurple to use the GObject conversation API
--- a/libpurple/Makefile.am Thu Jun 27 04:18:40 2013 +0530 +++ b/libpurple/Makefile.am Thu Jun 27 04:44:20 2013 +0530 @@ -233,9 +233,11 @@ dbus_sources = dbus-server.c dbus-useful.c dbus_headers = dbus-bindings.h dbus-purple.h dbus-server.h dbus-useful.h dbus-define-api.h dbus-types.h -dbus_exported = dbus-useful.h dbus-define-api.h accounts.h blist.h buddyicon.h \ - connection.h conversations.h core.h ft.h log.h notify.h prefs.h roomlist.h \ - savedstatuses.h smiley.h status.h server.h util.h xmlnode.h prpl.h +dbus_exported = dbus-useful.h dbus-define-api.h account.h accounts.h blist.h \ + buddyicon.h connection.h conversation.h conversationtypes.h \ + conversations.h core.h ft.h log.h notify.h prefs.h roomlist.h \ + savedstatuses.h smiley.h status.h server.h util.h xmlnode.h \ + prpl.h purple_build_coreheaders = $(addprefix $(srcdir)/, $(purple_coreheaders)) \ $(addprefix $(srcdir)/media/, $(purple_mediaheaders)) \
--- a/libpurple/account.c Thu Jun 27 04:18:40 2013 +0530 +++ b/libpurple/account.c Thu Jun 27 04:44:20 2013 +0530 @@ -2894,7 +2894,7 @@ purple_signal_emit(purple_accounts_get_handle(), "account-destroying", account); - for (l = purple_conversations_get(); l != NULL; l = l->next) + for (l = purple_conversations_get_all(); l != NULL; l = l->next) { PurpleConversation *conv = (PurpleConversation *)l->data;
--- a/libpurple/accounts.c Thu Jun 27 04:18:40 2013 +0530 +++ b/libpurple/accounts.c Thu Jun 27 04:44:20 2013 +0530 @@ -697,7 +697,7 @@ } /* Remove any open conversation for this account */ - for (iter = purple_conversations_get(); iter; ) { + for (iter = purple_conversations_get_all(); iter; ) { PurpleConversation *conv = iter->data; iter = iter->next; if (purple_conversation_get_account(conv) == account)
--- a/libpurple/conversation.c Thu Jun 27 04:18:40 2013 +0530 +++ b/libpurple/conversation.c Thu Jun 27 04:44:20 2013 +0530 @@ -534,7 +534,7 @@ return; if (PURPLE_IS_IM_CONVERSATION(conv) && - !g_list_find(purple_conversations_get(), conv)) + !g_list_find(purple_conversations_get_all(), conv)) return; displayed = g_strdup(message);
--- a/libpurple/conversation.h Thu Jun 27 04:18:40 2013 +0530 +++ b/libpurple/conversation.h Thu Jun 27 04:44:20 2013 +0530 @@ -149,9 +149,6 @@ /**************************************************************************/ /** PurpleConversationUiOps */ /**************************************************************************/ -typedef struct _PurpleIMConversation PurpleIMConversation; -typedef struct _PurpleChatConversation PurpleChatConversation; -typedef struct _PurpleChatConversationBuddy PurpleChatConversationBuddy; /** * Conversation operations and events. *
--- a/libpurple/dbus-analyze-functions.py Thu Jun 27 04:18:40 2013 +0530 +++ b/libpurple/dbus-analyze-functions.py Thu Jun 27 04:44:20 2013 +0530 @@ -22,10 +22,10 @@ # functions with untranslatable types are skipped, but this script # assumes that all non-pointer type names beginning with "Purple" # are enums, which is not true in this case. - "purple_conv_placement_add_fnc", - "purple_conv_placement_get_fnc", - "purple_conv_placement_get_current_func", - "purple_conv_placement_set_current_func", + "purple_conversation_placement_add_fnc", + "purple_conversation_placement_get_fnc", + "purple_conversation_placement_get_current_func", + "purple_conversation_placement_set_current_func", # Similar to the above: "purple_account_set_register_callback", @@ -70,11 +70,11 @@ "purple_account_option_get_list", "purple_connections_get_all", "purple_connections_get_connecting", - "purple_get_conversations", - "purple_get_ims", - "purple_get_chats", - "purple_conv_chat_get_users", - "purple_conv_chat_get_ignored", + "purple_conversations_get_all", + "purple_conversations_get_ims", + "purple_conversations_get_chats", + "purple_chat_conversation_get_users", + "purple_chat_conversation_get_ignored", "purple_mime_document_get_fields", "purple_mime_document_get_parts", "purple_mime_part_get_fields",
--- a/libpurple/dbus-define-api.h Thu Jun 27 04:18:40 2013 +0530 +++ b/libpurple/dbus-define-api.h Thu Jun 27 04:44:20 2013 +0530 @@ -18,8 +18,3 @@ gboolean PURPLE_CONNECTION_IS_CONNECTED(PurpleConnection *connection); gboolean PURPLE_CONNECTION_IS_VALID(PurpleConnection *connection); -/* conversation.h */ -PurpleIMConversation *PURPLE_CONV_IM(const PurpleConversation *conversation); -PurpleIMConversation *PURPLE_CONV_CHAT(const PurpleConversation *conversation); - -
--- a/libpurple/ft.c Thu Jun 27 04:18:40 2013 +0530 +++ b/libpurple/ft.c Thu Jun 27 04:44:20 2013 +0530 @@ -278,7 +278,7 @@ purple_xfer_conversation_write_internal(PurpleXfer *xfer, const char *message, gboolean is_error, gboolean print_thumbnail) { - PurpleConversation *conv = NULL; + PurpleIMConversation *im = NULL; PurpleMessageFlags flags = PURPLE_MESSAGE_SYSTEM; char *escaped; gconstpointer thumbnail_data; @@ -289,10 +289,10 @@ thumbnail_data = purple_xfer_get_thumbnail(xfer, &size); - conv = purple_conversations_find_im_with_account(xfer->who, + im = purple_conversations_find_im_with_account(xfer->who, purple_xfer_get_account(xfer)); - if (conv == NULL) + if (im == NULL) return; escaped = g_markup_escape_text(message, -1); @@ -308,12 +308,13 @@ message_with_img = g_strdup_printf("<img src='" PURPLE_STORED_IMAGE_PROTOCOL "%d'> %s", id, escaped); - purple_conversation_write(conv, NULL, message_with_img, flags, - time(NULL)); + purple_conversation_write(PURPLE_CONVERSATION(im), NULL, + message_with_img, flags, time(NULL)); purple_imgstore_unref_by_id(id); g_free(message_with_img); } else { - purple_conversation_write(conv, NULL, escaped, flags, time(NULL)); + purple_conversation_write(PURPLE_CONVERSATION(im), NULL, escaped, flags, + time(NULL)); } g_free(escaped); } @@ -901,7 +902,7 @@ if (completed == TRUE) { char *msg = NULL; - PurpleConversation *conv; + PurpleIMConversation *im; purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_DONE); @@ -924,11 +925,12 @@ else msg = g_strdup(_("File transfer complete")); - conv = purple_conversations_find_im_with_account(xfer->who, + im = purple_conversations_find_im_with_account(xfer->who, purple_xfer_get_account(xfer)); - if (conv != NULL) - purple_conversation_write(conv, NULL, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); + if (im != NULL) + purple_conversation_write(PURPLE_CONVERSATION(im), NULL, msg, + PURPLE_MESSAGE_SYSTEM, time(NULL)); g_free(msg); }
--- a/libpurple/plugins/perl/common/Conversation.xs Thu Jun 27 04:18:40 2013 +0530 +++ b/libpurple/plugins/perl/common/Conversation.xs Thu Jun 27 04:44:20 2013 +0530 @@ -110,15 +110,15 @@ GList *l; PPCODE: for (l = purple_conversations_get_ims(); l != NULL; l = l->next) { - XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation"))); + XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::IMConversation"))); } void -purple_conversations_get() +purple_conversations_get_all() PREINIT: GList *l; PPCODE: - for (l = purple_conversations_get(); l != NULL; l = l->next) { + for (l = purple_conversations_get_all(); l != NULL; l = l->next) { XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation"))); } @@ -128,7 +128,7 @@ GList *l; PPCODE: for (l = purple_conversations_get_chats(); l != NULL; l = l->next) { - XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation"))); + XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::ChatConversation"))); } Purple::Conversation
--- a/libpurple/pounce.c Thu Jun 27 04:18:40 2013 +0530 +++ b/libpurple/pounce.c Thu Jun 27 04:44:20 2013 +0530 @@ -1126,15 +1126,15 @@ static void buddy_typing_cb(PurpleAccount *account, const char *name, void *data) { - PurpleConversation *conv; + PurpleIMConversation *im; - conv = purple_conversations_find_im_with_account(name, account); - if (conv != NULL) + im = purple_conversations_find_im_with_account(name, account); + if (im != NULL) { PurpleIMConversationTypingState state; PurplePounceEvent event; - state = purple_im_conversation_get_typing_state(PURPLE_CONV_IM(conv)); + state = purple_im_conversation_get_typing_state(im); if (state == PURPLE_IM_CONVERSATION_TYPED) event = PURPLE_POUNCE_TYPED; else if (state == PURPLE_IM_CONVERSATION_NOT_TYPING)
--- a/libpurple/prpl.c Thu Jun 27 04:18:40 2013 +0530 +++ b/libpurple/prpl.c Thu Jun 27 04:44:20 2013 +0530 @@ -437,7 +437,7 @@ PurpleAttentionType *attn; PurpleMessageFlags flags; PurplePlugin *prpl; - PurpleConversation *conv; + PurpleIMConversation *im; gboolean (*send_attention)(PurpleConnection *, const char *, guint); PurpleBuddy *buddy; const char *alias; @@ -474,9 +474,9 @@ if (!send_attention(gc, who, type_code)) return; - conv = purple_im_conversation_new(purple_connection_get_account(gc), who); - purple_im_conversation_write_message(PURPLE_CONV_IM(conv), NULL, description, flags, mtime); - purple_prpl_attention(conv, who, type_code, PURPLE_MESSAGE_SEND, time(NULL)); + im = purple_im_conversation_new(purple_connection_get_account(gc), who); + purple_conversation_write_message(PURPLE_CONVERSATION(im), NULL, description, flags, mtime); + purple_prpl_attention(PURPLE_CONVERSATION(im), who, type_code, PURPLE_MESSAGE_SEND, time(NULL)); g_free(description); }
--- a/libpurple/server.c Thu Jun 27 04:18:40 2013 +0530 +++ b/libpurple/server.c Thu Jun 27 04:44:20 2013 +0530 @@ -119,7 +119,7 @@ int serv_send_im(PurpleConnection *gc, const char *name, const char *message, PurpleMessageFlags flags) { - PurpleConversation *conv = NULL; + PurpleIMConversation *im = NULL; PurpleAccount *account = NULL; PurplePresence *presence = NULL; PurplePlugin *prpl = NULL; @@ -138,7 +138,7 @@ account = purple_connection_get_account(gc); presence = purple_account_get_presence(account); - conv = purple_conversations_find_im_with_account(name, account); + im = purple_conversations_find_im_with_account(name, account); if (prpl_info->send_im) val = prpl_info->send_im(gc, name, message, flags); @@ -157,8 +157,8 @@ lar->sent = time(NULL); } - if(conv && purple_im_conversation_get_send_typed_timeout(PURPLE_CONV_IM(conv))) - purple_im_conversation_stop_send_typed_timeout(PURPLE_CONV_IM(conv)); + if(im && purple_im_conversation_get_send_typed_timeout(im)) + purple_im_conversation_stop_send_typed_timeout(im); return val; } @@ -237,7 +237,7 @@ PurpleAccount *account; GSList *buddies; PurpleBuddy *b; - PurpleConversation *conv; + PurpleIMConversation *im; account = purple_connection_get_account(gc); buddies = purple_find_buddies(account, who); @@ -256,15 +256,15 @@ purple_blist_server_alias_buddy(b, alias); - conv = purple_conversations_find_im_with_account(purple_buddy_get_name(b), account); - if (conv != NULL && alias != NULL && !purple_strequal(alias, who)) + im = purple_conversations_find_im_with_account(purple_buddy_get_name(b), account); + if (im != NULL && alias != NULL && !purple_strequal(alias, who)) { char *escaped = g_markup_escape_text(who, -1); char *escaped2 = g_markup_escape_text(alias, -1); char *tmp = g_strdup_printf(_("%s is now known as %s.\n"), escaped, escaped2); - purple_conversation_write(conv, NULL, tmp, + purple_conversation_write(PURPLE_CONVERSATION(im), NULL, tmp, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LINKIFY, time(NULL)); @@ -466,12 +466,12 @@ { PurplePlugin *prpl = NULL; PurplePluginProtocolInfo *prpl_info = NULL; - PurpleConversation *conv; + PurpleChatConversation *chat; char *buffy = message && *message ? g_strdup(message) : NULL; - conv = purple_conversations_find_chat(gc, id); + chat = purple_conversations_find_chat(gc, id); - if(conv == NULL) + if(chat == NULL) return; if(gc) @@ -481,18 +481,18 @@ prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); purple_signal_emit(purple_conversations_get_handle(), "chat-inviting-user", - conv, name, &buffy); + chat, name, &buffy); if (prpl_info && prpl_info->chat_invite) prpl_info->chat_invite(gc, id, buffy, name); purple_signal_emit(purple_conversations_get_handle(), "chat-invited-user", - conv, name, buffy); + chat, name, buffy); g_free(buffy); } -/* Ya know, nothing uses this except purple_conversation_destroy(), +/* Ya know, nothing uses this except purple_chat_conversation_dispose(), * I think I'll just merge it into that later... * Then again, something might want to use this, from outside prpl-land * to leave a chat without destroying the conversation. @@ -545,7 +545,7 @@ PurpleMessageFlags flags, time_t mtime) { PurpleAccount *account; - PurpleConversation *conv; + PurpleIMConversation *im; char *message, *name; char *angel, *buffy; int plugin_return; @@ -569,7 +569,7 @@ * We should update the conversation window buttons and menu, * if it exists. */ - conv = purple_conversations_find_im_with_account(who, purple_connection_get_account(gc)); + im = purple_conversations_find_im_with_account(who, purple_connection_get_account(gc)); /* * Make copies of the message and the sender in case plugins want @@ -581,7 +581,7 @@ plugin_return = GPOINTER_TO_INT( purple_signal_emit_return_1(purple_conversations_get_handle(), "receiving-im-msg", purple_connection_get_account(gc), - &angel, &buffy, conv, &flags)); + &angel, &buffy, im, &flags)); if (!buffy || !angel || plugin_return) { g_free(buffy); @@ -593,16 +593,16 @@ message = buffy; purple_signal_emit(purple_conversations_get_handle(), "received-im-msg", purple_connection_get_account(gc), - name, message, conv, flags); + name, message, im, flags); /* search for conversation again in case it was created by received-im-msg handler */ - if (conv == NULL) - conv = purple_conversations_find_im_with_account(name, purple_connection_get_account(gc)); + if (im == NULL) + im = purple_conversations_find_im_with_account(name, purple_connection_get_account(gc)); - if (conv == NULL) - conv = purple_im_conversation_new(account, name); + if (im == NULL) + im = purple_im_conversation_new(account, name); - purple_im_conversation_write_message(PURPLE_CONV_IM(conv), name, message, flags, mtime); + purple_conversation_write_message(PURPLE_CONVERSATION(im), name, message, flags, mtime); g_free(message); /* @@ -671,7 +671,7 @@ { serv_send_im(gc, name, away_msg, PURPLE_MESSAGE_AUTO_RESP); - purple_im_conversation_write_message(PURPLE_CONV_IM(conv), NULL, away_msg, + purple_conversation_write_message(PURPLE_CONVERSATION(im), NULL, away_msg, PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_AUTO_RESP, mtime); } @@ -684,13 +684,10 @@ void serv_got_typing(PurpleConnection *gc, const char *name, int timeout, PurpleIMConversationTypingState state) { - PurpleConversation *conv; - PurpleIMConversation *im = NULL; + PurpleIMConversation *im; - conv = purple_conversations_find_im_with_account(name, purple_connection_get_account(gc)); - if (conv != NULL) { - im = PURPLE_CONV_IM(conv); - + im = purple_conversations_find_im_with_account(name, purple_connection_get_account(gc)); + if (im != NULL) { purple_im_conversation_set_typing_state(im, state); } else { switch (state) @@ -710,20 +707,17 @@ } } - if (conv != NULL && timeout > 0) + if (im != NULL && timeout > 0) purple_im_conversation_start_typing_timeout(im, timeout); } void serv_got_typing_stopped(PurpleConnection *gc, const char *name) { - PurpleConversation *conv; PurpleIMConversation *im; - conv = purple_conversations_find_im_with_account(name, purple_connection_get_account(gc)); - if (conv != NULL) + im = purple_conversations_find_im_with_account(name, purple_connection_get_account(gc)); + if (im != NULL) { - im = PURPLE_CONV_IM(conv); - if (purple_im_conversation_get_typing_state(im) == PURPLE_IM_CONVERSATION_NOT_TYPING) return; @@ -844,31 +838,23 @@ void serv_got_chat_left(PurpleConnection *g, int id) { GSList *bcs; - PurpleConversation *conv = NULL; PurpleChatConversation *chat = NULL; for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { - conv = (PurpleConversation *)bcs->data; - - chat = PURPLE_CONV_CHAT(conv); + chat = PURPLE_CHAT_CONVERSATION(bcs->data); if (purple_chat_conversation_get_id(chat) == id) break; - - conv = NULL; } - if (!conv) - return; - purple_debug(PURPLE_DEBUG_INFO, "server", "Leaving room: %s\n", - purple_conversation_get_name(conv)); + purple_conversation_get_name(PURPLE_CONVERSATION(chat))); - g->buddy_chats = g_slist_remove(g->buddy_chats, conv); + g->buddy_chats = g_slist_remove(g->buddy_chats, chat); - purple_chat_conversation_left(PURPLE_CONV_CHAT(conv)); + purple_chat_conversation_leave(chat); - purple_signal_emit(purple_conversations_get_handle(), "chat-left", conv); + purple_signal_emit(purple_conversations_get_handle(), "chat-left", chat); } void purple_serv_got_join_chat_failed(PurpleConnection *gc, GHashTable *data) @@ -881,7 +867,6 @@ PurpleMessageFlags flags, const char *message, time_t mtime) { GSList *bcs; - PurpleConversation *conv = NULL; PurpleChatConversation *chat = NULL; char *buffy, *angel; int plugin_return; @@ -890,22 +875,16 @@ g_return_if_fail(message != NULL); for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { - conv = (PurpleConversation *)bcs->data; - - chat = PURPLE_CONV_CHAT(conv); + chat = PURPLE_CHAT_CONVERSATION(bcs->data); if (purple_chat_conversation_get_id(chat) == id) break; - - conv = NULL; } - if (!conv) - return; - /* Did I send the message? */ if (purple_strequal(purple_chat_conversation_get_nick(chat), - purple_normalize(purple_conversation_get_account(conv), who))) { + purple_normalize(purple_conversation_get_account( + PURPLE_CONVERSATION(chat)), who))) { flags |= PURPLE_MESSAGE_SEND; flags &= ~PURPLE_MESSAGE_RECV; /* Just in case some prpl sets it! */ } else { @@ -922,7 +901,7 @@ plugin_return = GPOINTER_TO_INT( purple_signal_emit_return_1(purple_conversations_get_handle(), "receiving-chat-msg", purple_connection_get_account(g), - &angel, &buffy, conv, &flags)); + &angel, &buffy, chat, &flags)); if (!buffy || !angel || plugin_return) { g_free(buffy); @@ -934,9 +913,9 @@ message = buffy; purple_signal_emit(purple_conversations_get_handle(), "received-chat-msg", purple_connection_get_account(g), - who, message, conv, flags); + who, message, chat, flags); - purple_chat_conversation_write_message(chat, who, message, flags, mtime); + purple_conversation_write_message(PURPLE_CONVERSATION(chat), who, message, flags, mtime); g_free(angel); g_free(buffy);