# HG changeset patch # User Christian Hammond # Date 1048456578 0 # Node ID 9567b13d0e984b40fc10b62ad49d95afd12cb8bf # Parent 26837f462a6676828b9323a3ce16b24672eed6d6 [gaim-migrate @ 5206] Added gaim_conversation_(set|get)_plugin_data(), which sets and gets plugin-specific data. It just wraps a hashtable, and it will be replaced sometime down the road if we move to an object framework. However, the function will still exist as a wrapper around g_object_(set|get)_data(). I've said too much. committer: Tailor Script diff -r 26837f462a66 -r 9567b13d0e98 src/conversation.c --- a/src/conversation.c Sun Mar 23 19:43:58 2003 +0000 +++ b/src/conversation.c Sun Mar 23 21:56:18 2003 +0000 @@ -874,6 +874,8 @@ conv->title = g_strdup(name); conv->send_history = g_list_append(NULL, NULL); conv->history = g_string_new(""); + conv->plugin_data = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, NULL); if (type == GAIM_CONV_IM) { @@ -1039,6 +1041,8 @@ chats = g_list_remove(chats, conv); } + g_hash_table_destroy(conv->plugin_data); + if (win != NULL) { gaim_window_remove_conversation(win, gaim_conversation_get_index(conv)); @@ -1308,6 +1312,26 @@ return conv->u.chat; } +void +gaim_conversation_set_plugin_data(struct gaim_conversation *conv, + const char *key, gpointer data) +{ + if (conv == NULL || key == NULL) + return; + + g_hash_table_replace(conv->plugin_data, g_strdup(key), data); +} + +gpointer +gaim_conversation_get_plugin_data(struct gaim_conversation *conv, + const char *key) +{ + if (conv == NULL || key == NULL) + return NULL; + + return g_hash_table_lookup(conv->plugin_data, key); +} + GList * gaim_get_conversations(void) { diff -r 26837f462a66 -r 9567b13d0e98 src/conversation.h --- a/src/conversation.h Sun Mar 23 19:43:58 2003 +0000 +++ b/src/conversation.h Sun Mar 23 21:56:18 2003 +0000 @@ -222,6 +222,8 @@ struct gaim_conversation_ui_ops *ui_ops; /**< UI-specific operations. */ void *ui_data; /**< UI-specific data. */ + + GHashTable *plugin_data; /**< Plugin-specific data. */ }; typedef void (*gaim_conv_placement_fnc)(struct gaim_conversation *); @@ -653,6 +655,30 @@ #define GAIM_CHAT(c) (gaim_conversation_get_chat_data(c)) /** + * Sets a conversation's plugin-specific data. + * + * To minimize key conflicts, the key should be in the form of + * @c pluginname/keyname. + * + * @param conv The conversation. + * @param key The unique key. + * @param data The data to assign. + */ +void gaim_conversation_set_plugin_data(struct gaim_conversation *conv, + const char *key, gpointer data); + +/** + * Returns a conversation's plugin-specific data. + * + * @param conv The conversation. + * @param key The unqiue key. + * + * @return The data associated with the key. + */ +gpointer gaim_conversation_get_plugin_data(struct gaim_conversation *conv, + const char *key); + +/** * Returns a list of all conversations. * * This list includes both IMs and chats.