Mercurial > pidgin
changeset 32318:75104780b1a3
Hide struct _PurpleConvMessage.
author | andrew.victor@mxit.com |
---|---|
date | Fri, 21 Oct 2011 20:39:29 +0000 |
parents | d72f2f13b60f |
children | 8878ea011fa1 |
files | ChangeLog.API libpurple/conversation.c libpurple/conversation.h pidgin/gtkconv.c |
diffstat | 4 files changed, 72 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog.API Fri Oct 21 14:36:18 2011 +0000 +++ b/ChangeLog.API Fri Oct 21 20:39:29 2011 +0000 @@ -16,6 +16,8 @@ * purple_connection_update_last_received * purple_conversation_get_ui_data * purple_conversation_set_ui_data + * purple_conversation_message_get_alias + * purple_conversation_message_get_conv * purple_notify_searchresult_column_is_visible * purple_notify_searchresult_column_set_visible * purple_notify_user_info_prepend_pair_plaintext @@ -216,6 +218,7 @@ * struct _PurpleConvChat * struct _PurpleConvChatBuddy * struct _PurpleConvIm + * struct _PurpleConvMessage * struct _PurpleMenuAction * struct _PurplePounce * struct _PurpleProxyInfo
--- a/libpurple/conversation.c Fri Oct 21 14:36:18 2011 +0000 +++ b/libpurple/conversation.c Fri Oct 21 20:39:29 2011 +0000 @@ -146,6 +146,19 @@ GList *message_history; /**< Message history, as a GList of PurpleConvMessage's */ }; +/** + * Description of a conversation message + */ +struct _PurpleConvMessage +{ + char *who; + char *what; + PurpleMessageFlags flags; + time_t when; + PurpleConversation *conv; + char *alias; +}; + static GList *conversations = NULL; static GList *ims = NULL; @@ -2438,30 +2451,42 @@ return conv->message_history; } -const char *purple_conversation_message_get_sender(PurpleConvMessage *msg) +const char *purple_conversation_message_get_sender(const PurpleConvMessage *msg) { g_return_val_if_fail(msg, NULL); return msg->who; } -const char *purple_conversation_message_get_message(PurpleConvMessage *msg) +const char *purple_conversation_message_get_message(const PurpleConvMessage *msg) { g_return_val_if_fail(msg, NULL); return msg->what; } -PurpleMessageFlags purple_conversation_message_get_flags(PurpleConvMessage *msg) +PurpleMessageFlags purple_conversation_message_get_flags(const PurpleConvMessage *msg) { g_return_val_if_fail(msg, 0); return msg->flags; } -time_t purple_conversation_message_get_timestamp(PurpleConvMessage *msg) +time_t purple_conversation_message_get_timestamp(const PurpleConvMessage *msg) { g_return_val_if_fail(msg, 0); return msg->when; } +const char *purple_conversation_message_get_alias(const PurpleConvMessage *msg) +{ + g_return_val_if_fail(msg, NULL); + return msg->alias; +} + +PurpleConversation *purple_conversation_message_get_conv(const PurpleConvMessage *msg) +{ + g_return_val_if_fail(msg, NULL); + return msg->conv; +} + void purple_conversation_set_ui_data(PurpleConversation *conv, gpointer ui_data) { g_return_if_fail(conv != NULL);
--- a/libpurple/conversation.h Fri Oct 21 14:36:18 2011 +0000 +++ b/libpurple/conversation.h Fri Oct 21 20:39:29 2011 +0000 @@ -249,19 +249,6 @@ void (*_purple_reserved4)(void); }; -/** - * Description of a conversation message - */ -struct _PurpleConvMessage -{ - char *who; - char *what; - PurpleMessageFlags flags; - time_t when; - PurpleConversation *conv; - char *alias; -}; - #ifdef __cplusplus extern "C" { #endif @@ -660,7 +647,7 @@ * * @return The name of the sender of the message */ -const char *purple_conversation_message_get_sender(PurpleConvMessage *msg); +const char *purple_conversation_message_get_sender(const PurpleConvMessage *msg); /** * Get the message from a PurpleConvMessage @@ -669,7 +656,7 @@ * * @return The name of the sender of the message */ -const char *purple_conversation_message_get_message(PurpleConvMessage *msg); +const char *purple_conversation_message_get_message(const PurpleConvMessage *msg); /** * Get the message-flags of a PurpleConvMessage @@ -678,7 +665,7 @@ * * @return The message flags */ -PurpleMessageFlags purple_conversation_message_get_flags(PurpleConvMessage *msg); +PurpleMessageFlags purple_conversation_message_get_flags(const PurpleConvMessage *msg); /** * Get the timestamp of a PurpleConvMessage @@ -687,7 +674,25 @@ * * @return The timestamp of the message */ -time_t purple_conversation_message_get_timestamp(PurpleConvMessage *msg); +time_t purple_conversation_message_get_timestamp(const PurpleConvMessage *msg); + +/** + * Get the alias from a PurpleConvMessage + * + * @param msg A PurpleConvMessage + * + * @return The alias of the sender of the message + */ +const char *purple_conversation_message_get_alias(const PurpleConvMessage *msg); + +/** + * Get the conversation associated with the PurpleConvMessage + * + * @param msg A PurpleConvMessage + * + * @return The conversation + */ +PurpleConversation *purple_conversation_message_get_conv(const PurpleConvMessage *msg); /** * Set the UI data associated with this conversation.
--- a/pidgin/gtkconv.c Fri Oct 21 14:36:18 2011 +0000 +++ b/pidgin/gtkconv.c Fri Oct 21 20:39:29 2011 +0000 @@ -8081,7 +8081,7 @@ message_compare(gconstpointer p1, gconstpointer p2) { const PurpleConvMessage *m1 = p1, *m2 = p2; - return (m1->when > m2->when); + return (purple_conversation_message_get_timestamp(m1) > purple_conversation_message_get_timestamp(m2)); } /* Adds some message history to the gtkconv. This happens in a idle-callback. */ @@ -8097,11 +8097,17 @@ gtkconv->attach.timer = 0; while (gtkconv->attach.current && count < 100) { /* XXX: 100 is a random value here */ PurpleConvMessage *msg = gtkconv->attach.current->data; - if (!im && when && when < msg->when) { + if (!im && when && when < purple_conversation_message_get_timestamp(msg)) { gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), "<BR><HR>"); g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); } - pidgin_conv_write_conv(msg->conv, msg->who, msg->alias, msg->what, msg->flags, msg->when); + pidgin_conv_write_conv( + purple_conversation_message_get_conv(msg), + purple_conversation_message_get_sender(msg), + purple_conversation_message_get_alias(msg), + purple_conversation_message_get_message(msg), + purple_conversation_message_get_flags(msg), + purple_conversation_message_get_timestamp(msg)); if (im) { gtkconv->attach.current = g_list_delete_link(gtkconv->attach.current, gtkconv->attach.current); } else { @@ -8124,14 +8130,20 @@ GList *history = purple_conversation_get_message_history(conv); for (; history; history = history->next) { PurpleConvMessage *msg = history->data; - if (msg->when > when) + if (purple_conversation_message_get_timestamp(msg) > when) msgs = g_list_prepend(msgs, msg); } } msgs = g_list_sort(msgs, message_compare); for (; msgs; msgs = g_list_delete_link(msgs, msgs)) { PurpleConvMessage *msg = msgs->data; - pidgin_conv_write_conv(msg->conv, msg->who, msg->alias, msg->what, msg->flags, msg->when); + pidgin_conv_write_conv( + purple_conversation_message_get_conv(msg), + purple_conversation_message_get_sender(msg), + purple_conversation_message_get_alias(msg), + purple_conversation_message_get_message(msg), + purple_conversation_message_get_flags(msg), + purple_conversation_message_get_timestamp(msg)); } gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), "<BR><HR>"); g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); @@ -8209,7 +8221,7 @@ g_return_val_if_reached(TRUE); } g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", - GINT_TO_POINTER(((PurpleConvMessage*)(list->data))->when)); + GINT_TO_POINTER(purple_conversation_message_get_timestamp((PurpleConvMessage*)(list->data)))); gtkconv->attach.timer = g_idle_add(add_message_history_to_gtkconv, gtkconv); } else { purple_signal_emit(pidgin_conversations_get_handle(),