diff src/blist.c @ 5906:390d32a6b130

[gaim-migrate @ 6338] auto-join for chats in the buddy list. Yes, the interface sucks. I suck at making interfaces. I'm sure someone more talented will make it pretty, or maybe even HIG-y. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Mon, 16 Jun 2003 05:14:05 +0000
parents 964e4f94fc56
children a4f2aba0848d
line wrap: on
line diff
--- a/src/blist.c	Mon Jun 16 04:15:35 2003 +0000
+++ b/src/blist.c	Mon Jun 16 05:14:05 2003 +0000
@@ -313,6 +313,8 @@
 	if(alias && strlen(alias))
 		chat->alias = g_strdup(alias);
 	chat->components = components;
+	chat->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
+			g_free, g_free);
 
 	((GaimBlistNode*)chat)->type = GAIM_BLIST_CHAT_NODE;
 
@@ -1244,6 +1246,7 @@
 static char *blist_parser_setting_name = NULL;
 static char *blist_parser_setting_value = NULL;
 static GHashTable *blist_parser_buddy_settings = NULL;
+static GHashTable *blist_parser_chat_settings = NULL;
 static GHashTable *blist_parser_group_settings = NULL;
 static GHashTable *blist_parser_chat_components = NULL;
 static int blist_parser_privacy_mode = 0;
@@ -1386,12 +1389,17 @@
 			struct group *g = gaim_find_group(blist_parser_group_name);
 			gaim_blist_add_chat(chat,g,
 					gaim_blist_get_last_child((GaimBlistNode*)g));
+			if(blist_parser_chat_settings) {
+				g_hash_table_destroy(chat->settings);
+				chat->settings = blist_parser_chat_settings;
+			}
 		}
 		g_free(blist_parser_chat_alias);
 		blist_parser_chat_alias = NULL;
 		g_free(blist_parser_account_name);
 		blist_parser_account_name = NULL;
 		blist_parser_chat_components = NULL;
+		blist_parser_chat_settings = NULL;
 		tag_stack = g_list_delete_link(tag_stack, tag_stack);
 	} else if(!strcmp(element_name, "person")) {
 		g_free(blist_parser_person_name);
@@ -1446,6 +1454,15 @@
 						g_strdup(blist_parser_setting_name),
 						g_strdup(blist_parser_setting_value));
 			}
+		} else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_CHAT) {
+			if(!blist_parser_chat_settings)
+				blist_parser_chat_settings = g_hash_table_new_full(g_str_hash,
+						g_str_equal, g_free, g_free);
+			if(blist_parser_setting_name && blist_parser_setting_value) {
+				g_hash_table_replace(blist_parser_buddy_settings,
+						g_strdup(blist_parser_setting_name),
+						g_strdup(blist_parser_setting_value));
+			}
 		} else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_GROUP) {
 			if(!blist_parser_group_settings)
 				blist_parser_group_settings = g_hash_table_new_full(g_str_hash,
@@ -1738,6 +1755,9 @@
 						}
 						g_hash_table_foreach(chat->components,
 								blist_print_chat_components, file);
+						/* works for chats too, I don't feel like renaming */
+						g_hash_table_foreach(chat->settings,
+								blist_print_buddy_settings, file);
 						fprintf(file, "\t\t\t</chat>\n");
 						g_free(acct_name);
 					}
@@ -1902,6 +1922,21 @@
 	return g_strdup(g_hash_table_lookup(g->settings, key));
 }
 
+void gaim_chat_set_setting(struct chat *c, const char *key,
+		const char *value)
+{
+	if(!c)
+		return;
+	g_hash_table_replace(c->settings, g_strdup(key), g_strdup(value));
+}
+
+char *gaim_chat_get_setting(struct chat *c, const char *key)
+{
+	if(!c)
+		return NULL;
+	return g_strdup(g_hash_table_lookup(c->settings, key));
+}
+
 void gaim_buddy_set_setting(struct buddy *b, const char *key,
 		const char *value) {
 	if(!b)