changeset 5943:a4f2aba0848d

[gaim-migrate @ 6384] This should fix corruption in the blist, accounts, and pounces when some protocol plugins cannot load. Some parts of gaim now use the new unique Plugin or Protocol Plugin IDs, while some still use the old protocol numbers. Accounts kind of used both, and when prpls were missing, it had trouble finding accounts. It would find the names, even without mapping the protocol numbers to IDs, and any duplicate accounts would get nuked. That would then affect pounce saving. Anyhow, long story short (well, it's already long, too late for that), this should fix all that mess. And introduce new mess, but hopefully temporary mess. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 23 Jun 2003 02:00:15 +0000
parents d0320de18feb
children 158196b2db19
files src/account.c src/account.h src/blist.c src/buddy_chat.c src/dialogs.c src/gaimrc.c src/gtkaccount.c src/gtkutils.c src/gtkutils.h src/main.c src/pounce.c src/prpl.c src/prpl.h src/util.c src/util.h
diffstat 15 files changed, 321 insertions(+), 188 deletions(-) [+]
line wrap: on
line diff
--- a/src/account.c	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/account.c	Mon Jun 23 02:00:15 2003 +0000
@@ -114,21 +114,22 @@
 }
 
 GaimAccount *
-gaim_account_new(const char *username, GaimProtocol protocol)
+gaim_account_new(const char *username, const char *protocol_id)
 {
 	GaimAccount *account;
 
-	g_return_val_if_fail(username != NULL, NULL);
+	g_return_val_if_fail(username    != NULL, NULL);
+	g_return_val_if_fail(protocol_id != NULL, NULL);
 
-	account = gaim_accounts_find(username, protocol);
+	account = gaim_accounts_find_with_prpl_id(username, protocol_id);
 
 	if (account != NULL)
 		return account;
 
 	account = g_new0(GaimAccount, 1);
 
-	gaim_account_set_username(account, username);
-	gaim_account_set_protocol(account, protocol);
+	gaim_account_set_username(account,    username);
+	gaim_account_set_protocol_id(account, protocol_id);
 
 	account->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
 											  g_free, delete_setting);
@@ -270,20 +271,21 @@
 void
 gaim_account_set_protocol(GaimAccount *account, GaimProtocol protocol)
 {
-	GaimPlugin *plugin;
-
 	g_return_if_fail(account != NULL);
 
-	plugin = gaim_find_prpl(protocol);
+	gaim_account_set_protocol_id(account, gaim_prpl_num_to_id(protocol));
+}
 
-	g_return_if_fail(plugin != NULL);
-
-	account->protocol = protocol;
+void
+gaim_account_set_protocol_id(GaimAccount *account, const char *protocol_id)
+{
+	g_return_if_fail(account     != NULL);
+	g_return_if_fail(protocol_id != NULL);
 
 	if (account->protocol_id != NULL)
 		g_free(account->protocol_id);
 
-	account->protocol_id = g_strdup(plugin->info->id);
+	account->protocol_id = g_strdup(protocol_id);
 
 	schedule_accounts_save();
 }
@@ -547,7 +549,15 @@
 {
 	g_return_val_if_fail(account != NULL, -1);
 
-	return account->protocol;
+	return gaim_prpl_id_to_num(gaim_account_get_protocol_id(account));
+}
+
+const char *
+gaim_account_get_protocol_id(const GaimAccount *account)
+{
+	g_return_val_if_fail(account != NULL, NULL);
+
+	return account->protocol_id;
 }
 
 GaimConnection *
@@ -814,39 +824,19 @@
 	data->buffer = NULL;
 
 	if (data->tag == TAG_PROTOCOL) {
-		GList *l;
-		GaimPlugin *plugin;
-
 		data->protocol_id = g_strdup(buffer);
-		data->protocol = -1;
-
-		for (l = gaim_plugins_get_protocols(); l != NULL; l = l->next) {
-			plugin = (GaimPlugin *)l->data;
-
-			if (GAIM_IS_PROTOCOL_PLUGIN(plugin)) {
-				if (!strcmp(plugin->info->id, buffer)) {
-					data->protocol =
-						GAIM_PLUGIN_PROTOCOL_INFO(plugin)->protocol;
-
-					break;
-				}
-			}
-		}
 	}
 	else if (data->tag == TAG_NAME) {
 		if (data->in_proxy) {
 			gaim_proxy_info_set_username(data->proxy_info, buffer);
 		}
 		else {
-			data->account = gaim_account_new(buffer, data->protocol);
-
-			if (data->account->protocol_id != NULL)
-				g_free(data->account->protocol_id);
-
-			data->account->protocol_id = data->protocol_id;
+			data->account = gaim_account_new(buffer, data->protocol_id);
 
 			gaim_accounts_add(data->account);
 
+			g_free(data->protocol_id);
+
 			data->protocol_id = NULL;
 		}
 	}
@@ -1301,7 +1291,7 @@
 
 		if (!strcmp(normalize(gaim_account_get_username(account)), who)) {
 			if (protocol != -1) {
-				if (account->protocol == protocol)
+				if (gaim_account_get_protocol(account) == protocol)
 					break;
 			}
 			else
@@ -1315,3 +1305,31 @@
 
 	return account;
 }
+
+GaimAccount *
+gaim_accounts_find_with_prpl_id(const char *name, const char *protocol_id)
+{
+	GaimAccount *account = NULL;
+	GList *l;
+	char *who;
+
+	g_return_val_if_fail(name != NULL, NULL);
+
+	who = g_strdup(normalize(name));
+
+	for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
+		account = (GaimAccount *)l->data;
+
+		if (!strcmp(normalize(gaim_account_get_username(account)), who) &&
+			!strcmp(account->protocol_id, protocol_id)) {
+
+			break;
+		}
+
+		account = NULL;
+	}
+
+	g_free(who);
+
+	return account;
+}
--- a/src/account.h	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/account.h	Mon Jun 23 02:00:15 2003 +0000
@@ -49,7 +49,6 @@
 	gboolean remember_pass;     /**< Remember the password.      */
 	gboolean check_mail;        /**< Check for mail.             */
 
-	GaimProtocol protocol;      /**< The account protocol.       */
 	char *protocol_id;          /**< The ID of the protocol.     */
 
 	GaimConnection *gc;         /**< The connection handle.      */
@@ -67,10 +66,10 @@
 /**
  * Creates a new account.
  *
- * @param username The username.
- * @param protocol The protocol.
+ * @param username    The username.
+ * @param protocol_id The protocol ID.
  */
-GaimAccount *gaim_account_new(const char *username, GaimProtocol protocol);
+GaimAccount *gaim_account_new(const char *username, const char *protocol_id);
 
 /**
  * Destroys an account.
@@ -146,6 +145,15 @@
 void gaim_account_set_protocol(GaimAccount *account, GaimProtocol protocol);
 
 /**
+ * Sets the account's protocol ID.
+ *
+ * @param account     The account.
+ * @param protocol_id The protocol ID.
+ */
+void gaim_account_set_protocol_id(GaimAccount *account,
+								  const char *protocol_id);
+
+/**
  * Sets the account's connection.
  *
  * @param account The account.
@@ -321,6 +329,15 @@
 GaimProtocol gaim_account_get_protocol(const GaimAccount *account);
 
 /**
+ * Returns the account's protocol ID.
+ *
+ * @param account The account.
+ *
+ * @return The protocol ID.
+ */
+const char *gaim_account_get_protocol_id(const GaimAccount *account);
+
+/**
  * Returns the account's connection.
  *
  * @param account The account.
@@ -492,13 +509,24 @@
 GList *gaim_accounts_get_all(void);
 
 /**
- * Finds an account with the specified name and protocol.
+ * Finds an account with the specified name and protocol number.
  *
  * @param name     The account username.
- * @param protocol The account protocol.
+ * @param protocol The account protocol number.
  *
  * @return The account, if found, or @c FALSE otherwise.
  */
 GaimAccount *gaim_accounts_find(const char *name, GaimProtocol protocol);
 
+/**
+ * Finds an account with the specified name and protocol ID.
+ *
+ * @param name        The account username.
+ * @param protocol_id The account protocol ID.
+ *
+ * @return The account, if found, or @c FALSE otherwise.
+ */
+GaimAccount *gaim_accounts_find_with_prpl_id(const char *name,
+											 const char *protocol_id);
+
 #endif /* _GAIM_ACCOUNTS_H_ */
--- a/src/blist.c	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/blist.c	Mon Jun 23 02:00:15 2003 +0000
@@ -1139,8 +1139,21 @@
 		g_snprintf(path, sizeof(path), "%s", filename);
 	} else {
 		char *g_screenname = get_screenname_filename(account->username);
+		const char *username;
 		char *file = gaim_user_dir();
-		int protocol = (account->protocol == GAIM_PROTO_OSCAR) ? (isalpha(account->username[0]) ? GAIM_PROTO_TOC : GAIM_PROTO_ICQ): account->protocol;
+		GaimProtocol prpl_num;
+		int protocol;
+		
+		prpl_num = gaim_account_get_protocol(account);
+
+		protocol = prpl_num;
+
+		if (prpl_num == GAIM_PROTO_OSCAR) {
+			if ((username = gaim_account_get_username(account)) != NULL) {
+				protocol = (isalpha(*username)
+							? GAIM_PROTO_TOC : GAIM_PROTO_ICQ);
+			}
+		}
 
 		if (file != (char *)NULL) {
 			snprintf(path, PATHSIZE, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, protocol);
@@ -1728,7 +1741,8 @@
 						fprintf(file, "\t\t\t<person name=\"%s\">\n",
 								bud_alias ? bud_alias : bud_name);
 						fprintf(file, "\t\t\t\t<buddy protocol=\"%d\" "
-								"account=\"%s\">\n", bud->account->protocol,
+								"account=\"%s\">\n",
+								gaim_account_get_protocol(bud->account),
 								acct_name);
 						fprintf(file, "\t\t\t\t\t<name>%s</name>\n", bud_name);
 						if(bud_alias) {
@@ -1747,7 +1761,9 @@
 					struct chat *chat = (struct chat *)bnode;
 					if(!exp_acct || chat->account == exp_acct) {
 						char *acct_name = g_markup_escape_text(chat->account->username, -1);
-						fprintf(file, "\t\t\t<chat protocol=\"%d\" account=\"%s\">\n", chat->account->protocol, acct_name);
+						fprintf(file, "\t\t\t<chat protocol=\"%d\" account=\"%s\">\n",
+								gaim_account_get_protocol(chat->account),
+								acct_name);
 						if(chat->alias) {
 							char *chat_alias = g_markup_escape_text(chat->alias, -1);
 							fprintf(file, "\t\t\t\t<alias>%s</alias>\n", chat_alias);
@@ -1779,7 +1795,8 @@
 		char *acct_name = g_markup_escape_text(account->username, -1);
 		if(!exp_acct || account == exp_acct) {
 			fprintf(file, "\t\t<account protocol=\"%d\" name=\"%s\" "
-					"mode=\"%d\">\n", account->protocol, acct_name, account->perm_deny);
+					"mode=\"%d\">\n", gaim_account_get_protocol(account),
+					acct_name, account->perm_deny);
 			for(buds = account->permit; buds; buds = buds->next) {
 				char *bud_name = g_markup_escape_text(buds->data, -1);
 				fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name);
--- a/src/buddy_chat.c	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/buddy_chat.c	Mon Jun 23 02:00:15 2003 +0000
@@ -158,7 +158,9 @@
 	if (joinchatgc == g)
 		return;
 
-	if(joinchatgc->account->protocol == g->account->protocol) {
+	if (gaim_account_get_protocol(joinchatgc->account) ==
+		gaim_account_get_protocol(g->account)) {
+
 		joinchatgc = g;
 	} else {
 		joinchatgc = g;
--- a/src/dialogs.c	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/dialogs.c	Mon Jun 23 02:00:15 2003 +0000
@@ -1164,11 +1164,16 @@
 static void addchat_select_account(GObject *w, GaimConnection *gc)
 {
 	struct addchat *ac = g_object_get_data(w, "addchat");
-
-	if(ac->account->protocol == gc->account->protocol) {
-		ac->account = gc->account;
+	GaimAccount *account;
+
+	account = gaim_connection_get_account(gc);
+
+	if (gaim_account_get_protocol(ac->account) ==
+		gaim_account_get_protocol(account)) {
+
+		ac->account = account;
 	} else {
-		ac->account = gc->account;
+		ac->account = account;
 		rebuild_addchat_entries(ac);
 	}
 }
@@ -3511,7 +3516,8 @@
 		return;
 
 	if(c->account)
-		smileys = get_proto_smileys(c->account->protocol);
+		smileys = get_proto_smileys(
+			gaim_account_get_protocol(gaim_conversation_get_account(c)));
 	else
 		smileys = get_proto_smileys(GAIM_PROTO_DEFAULT);
 
--- a/src/gaimrc.c	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/gaimrc.c	Mon Jun 23 02:00:15 2003 +0000
@@ -517,7 +517,7 @@
 	if (strcmp(p->option, "ident"))
 		return NULL;
 
-	account = gaim_account_new(p->value[0], GAIM_PROTO_DEFAULT);
+	account = gaim_account_new(p->value[0], "prpl-oscar");
 
 	gaim_account_set_password(account, p->value[1]);
 	gaim_account_set_remember_password(account, TRUE);
--- a/src/gtkaccount.c	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/gtkaccount.c	Mon Jun 23 02:00:15 2003 +0000
@@ -83,6 +83,7 @@
 
 	GaimAccount *account;
 	GaimProtocol protocol;
+	const char *protocol_id;
 	GaimPlugin *plugin;
 	GaimPluginProtocolInfo *prpl_info;
 
@@ -183,10 +184,10 @@
 set_account_protocol_cb(GtkWidget *item, GaimProtocol protocol,
 						  AccountPrefsDialog *dialog)
 {
-	dialog->protocol = protocol;
+	if ((dialog->plugin = gaim_find_prpl(protocol)) != NULL)
+		dialog->prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(dialog->plugin);
 
-	if ((dialog->plugin = gaim_find_prpl(dialog->protocol)) != NULL)
-		dialog->prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(dialog->plugin);
+	dialog->protocol_id = dialog->plugin->info->id;
 
 	add_login_options(dialog,    dialog->top_vbox);
 	add_user_options(dialog,     dialog->top_vbox);
@@ -925,11 +926,11 @@
 
 		screenname = gtk_entry_get_text(GTK_ENTRY(dialog->screenname_entry));
 
-		dialog->account = gaim_account_new(screenname, dialog->protocol);
+		dialog->account = gaim_account_new(screenname, dialog->protocol_id);
 	}
 	else {
 		/* Protocol */
-		gaim_account_set_protocol(dialog->account, dialog->protocol);
+		gaim_account_set_protocol_id(dialog->account, dialog->protocol_id);
 	}
 
 	/* Alias */
--- a/src/gtkutils.c	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/gtkutils.c	Mon Jun 23 02:00:15 2003 +0000
@@ -809,3 +809,101 @@
 
 	return optmenu;
 }
+
+char *stylize(const gchar *text, int length)
+{
+	gchar *buf;
+	char *tmp = g_malloc(length);
+
+	buf = g_malloc(length);
+	g_snprintf(buf, length, "%s", text);
+
+	if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) {
+		g_snprintf(tmp, length, "<B>%s</B>", buf);
+		strcpy(buf, tmp);
+	}
+
+	if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) {
+		g_snprintf(tmp, length, "<I>%s</I>", buf);
+		strcpy(buf, tmp);
+	}
+
+	if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) {
+		g_snprintf(tmp, length, "<U>%s</U>", buf);
+		strcpy(buf, tmp);
+	}
+
+	if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_strikethrough")) {
+		g_snprintf(tmp, length, "<S>%s</S>", buf);
+		strcpy(buf, tmp);
+	}
+
+	if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_font")) {
+		const char *fontface;
+
+		fontface = gaim_prefs_get_string("/gaim/gtk/conversations/font_face");
+
+		g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf);
+		strcpy(buf, tmp);
+	}
+
+	if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_size")) {
+		int fontsize = gaim_prefs_get_int("/gaim/gtk/conversations/font_size");
+
+		g_snprintf(tmp, length, "<FONT SIZE=\"%d\">%s</FONT>", fontsize, buf);
+		strcpy(buf, tmp);
+	}
+
+	if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_fgcolor")) {
+		GdkColor fgcolor;
+
+		gdk_color_parse(
+			gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"),
+			&fgcolor);
+
+		g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>",
+				   fgcolor.red/256, fgcolor.green/256, fgcolor.blue/256, buf);
+		strcpy(buf, tmp);
+	}
+
+	if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_bgcolor")) {
+		GdkColor bgcolor;
+
+		gdk_color_parse(
+			gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"),
+			&bgcolor);
+
+		g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>",
+				   bgcolor.red/256, bgcolor.green/256, bgcolor.blue/256, buf);
+		strcpy(buf, tmp);
+	}
+
+	g_free(tmp);
+	return buf;
+}
+
+void show_usage(int mode, const char *name)
+{
+	switch (mode) {
+	case 0:		/* full help text */
+		printf(_("Gaim %s\n"
+		       "Usage: %s [OPTION]...\n\n"
+		       "  -a, --acct          display account editor window\n"
+		       "  -w, --away[=MESG]   make away on signon (optional argument MESG specifies\n"
+		       "                      name of away message to use)\n"
+		       "  -l, --login[=NAME]  automatically login (optional argument NAME specifies\n"
+		       "                      account(s) to use, seperated by commas)\n"
+		       "  -n, --loginwin      don't automatically login; show login window\n"
+		       "  -u, --user=NAME     use account NAME\n"
+		       "  -f, --file=FILE     use FILE as config\n"
+		       "  -d, --debug         print debugging messages to stdout\n"
+		       "  -v, --version       display the current version and exit\n"
+		       "  -h, --help          display this help and exit\n"), VERSION, name);
+		break;
+	case 1:		/* short message */
+		printf(_("Gaim %s. Try `%s -h' for more information.\n"), VERSION, name);
+		break;
+	}
+}
+
+
--- a/src/gtkutils.h	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/gtkutils.h	Mon Jun 23 02:00:15 2003 +0000
@@ -205,4 +205,28 @@
 											gboolean show_all, GCallback cb,
 											gpointer user_data);
 
+/**
+ * Stylizes the specified text using HTML, according to the current
+ * font options.
+ *
+ * @param text The text to stylize.
+ * @param len  The intended length of the new buffer.
+ *
+ * @return A newly allocated string of length @a len, containing the
+ *         stylized version of @a text.
+ *
+ * @todo Move this to a UI-specific file.
+ */
+char *stylize(const gchar *text, int len);
+
+/**
+ * Shows the usage options for the gaim binary.
+ *
+ * @param mode @c 0 for full options, or @c 1 for a short summary.
+ * @param name The name of the binary.
+ * 
+ * @todo Move this to the binary, when a library is formed.
+ */
+void show_usage(int mode, const char *name);
+
 #endif /* _GAIM_GTK_UTILS_H_ */
--- a/src/main.c	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/main.c	Mon Jun 23 02:00:15 2003 +0000
@@ -46,6 +46,7 @@
 #include "gtkprefs.h"
 #include "gtkrequest.h"
 #include "gtksound.h"
+#include "gtkutils.h"
 #include "stock.h"
 
 #include "ui.h"
@@ -240,7 +241,7 @@
 
 	account = gaim_accounts_find(username, -1);
 	if (!account) {
-		account = gaim_account_new(username, GAIM_PROTO_DEFAULT);
+		account = gaim_account_new(username, "prpl-oscar");
 
 		gaim_account_set_remember_password(account, TRUE);
 	}
@@ -552,7 +553,7 @@
 	account = gaim_accounts_find(name, -1);
 
 	if (account == NULL)   /* new user */
-		account = gaim_account_new(name, GAIM_PROTO_DEFAULT);
+		account = gaim_account_new(name, "prpl-oscar");
 
 	/* Place it as the first user. */
 	gaim_accounts_reorder(account, 0);
--- a/src/pounce.c	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/pounce.c	Mon Jun 23 02:00:15 2003 +0000
@@ -222,6 +222,9 @@
 	g_return_if_fail(pounce != NULL);
 	g_return_if_fail(name   != NULL);
 
+	if (g_hash_table_lookup(pounce->actions, name) != NULL)
+		return;
+
 	action_data = g_new0(GaimPounceActionData, 1);
 
 	action_data->name    = g_strdup(name);
@@ -551,6 +554,7 @@
 		data->event_type = NULL;
 	}
 	else if (!strcmp(element_name, "action")) {
+		gaim_pounce_action_register(data->pounce, data->action_name);
 		gaim_pounce_action_set_enabled(data->pounce, data->action_name, TRUE);
 
 		g_free(data->action_name);
--- a/src/prpl.c	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/prpl.c	Mon Jun 23 02:00:15 2003 +0000
@@ -30,6 +30,54 @@
 /* XXX */
 #include "gtkconv.h"
 
+const char *
+gaim_prpl_num_to_id(GaimProtocol protocol)
+{
+	g_return_val_if_fail(protocol >= 0 && protocol < GAIM_PROTO_UNTAKEN, NULL);
+
+	switch (protocol)
+	{
+		case GAIM_PROTO_TOC:      return "prpl-toc";     break;
+		case GAIM_PROTO_OSCAR:    return "prpl-oscar";   break;
+		case GAIM_PROTO_YAHOO:    return "prpl-yahoo";   break;
+		case GAIM_PROTO_ICQ:      return "prpl-icq";     break;
+		case GAIM_PROTO_MSN:      return "prpl-msn";     break;
+		case GAIM_PROTO_IRC:      return "prpl-irc";     break;
+		case GAIM_PROTO_JABBER:   return "prpl-jabber";  break;
+		case GAIM_PROTO_NAPSTER:  return "prpl-napster"; break;
+		case GAIM_PROTO_ZEPHYR:   return "prpl-zephyr";  break;
+		case GAIM_PROTO_GADUGADU: return "prpl-gg";      break;
+		case GAIM_PROTO_MOO:      return "prpl-moo";     break;
+		case GAIM_PROTO_TREPIA:   return "prpl-trepia";  break;
+
+		default:
+			break;
+	}
+
+	return NULL;
+}
+
+GaimProtocol
+gaim_prpl_id_to_num(const char *id)
+{
+	g_return_val_if_fail(id != NULL, -1);
+
+	if      (!strcmp(id, "prpl-toc"))     return GAIM_PROTO_TOC;
+	else if (!strcmp(id, "prpl-oscar"))   return GAIM_PROTO_OSCAR;
+	else if (!strcmp(id, "prpl-yahoo"))   return GAIM_PROTO_YAHOO;
+	else if (!strcmp(id, "prpl-icq"))     return GAIM_PROTO_ICQ;
+	else if (!strcmp(id, "prpl-msn"))     return GAIM_PROTO_MSN;
+	else if (!strcmp(id, "prpl-irc"))     return GAIM_PROTO_IRC;
+	else if (!strcmp(id, "prpl-jabber"))  return GAIM_PROTO_JABBER;
+	else if (!strcmp(id, "prpl-napster")) return GAIM_PROTO_NAPSTER;
+	else if (!strcmp(id, "prpl-zephyr"))  return GAIM_PROTO_ZEPHYR;
+	else if (!strcmp(id, "prpl-gg"))      return GAIM_PROTO_GADUGADU;
+	else if (!strcmp(id, "prpl-moo"))     return GAIM_PROTO_MOO;
+	else if (!strcmp(id, "prpl-trepia"))  return GAIM_PROTO_TREPIA;
+
+	return -1;
+}
+
 GaimPlugin *
 gaim_find_prpl(GaimProtocol type)
 {
--- a/src/prpl.h	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/prpl.h	Mon Jun 23 02:00:15 2003 +0000
@@ -305,16 +305,22 @@
 	((GaimPluginProtocolInfo *)(plugin)->info->extra_info)
 
 /**
- * Compares two protocol plugins, based off their protocol plugin number.
+ * Returns the plugin ID for a protocol number.
  *
- * @param a The first protocol plugin.
- * @param b The second protocol plugin.
+ * @param protocol The protocol number.
  *
- * @return <= 1 if the first plugin's number is smaller than the second;
- *         0 if the first plugin's number is equal to the second; or
- *         >= 1 if the first plugin's number is greater than the second.
+ * @return The plugin ID for those numbers that support it.
  */
-gint gaim_prpl_compare(GaimPlugin *a, GaimPlugin *b);
+const char *gaim_prpl_num_to_id(GaimProtocol protocol);
+
+/**
+ * Returns the plugin number for a protocol ID.
+ *
+ * @param protocol_id The protocol ID.
+ *
+ * @return The protocol ID for valid protocol plugin IDs.
+ */
+GaimProtocol gaim_prpl_id_to_num(const char *id);
 
 /**
  * Finds a protocol plugin structure of the specified type.
--- a/src/util.c	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/util.c	Mon Jun 23 02:00:15 2003 +0000
@@ -589,102 +589,6 @@
 	return (cpy);
 }
 
-char *stylize(const gchar *text, int length)
-{
-	gchar *buf;
-	char *tmp = g_malloc(length);
-
-	buf = g_malloc(length);
-	g_snprintf(buf, length, "%s", text);
-
-	if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) {
-		g_snprintf(tmp, length, "<B>%s</B>", buf);
-		strcpy(buf, tmp);
-	}
-
-	if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) {
-		g_snprintf(tmp, length, "<I>%s</I>", buf);
-		strcpy(buf, tmp);
-	}
-
-	if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) {
-		g_snprintf(tmp, length, "<U>%s</U>", buf);
-		strcpy(buf, tmp);
-	}
-
-	if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_strikethrough")) {
-		g_snprintf(tmp, length, "<S>%s</S>", buf);
-		strcpy(buf, tmp);
-	}
-
-	if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_font")) {
-		const char *fontface;
-
-		fontface = gaim_prefs_get_string("/gaim/gtk/conversations/font_face");
-
-		g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf);
-		strcpy(buf, tmp);
-	}
-
-	if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_size")) {
-		int fontsize = gaim_prefs_get_int("/gaim/gtk/conversations/font_size");
-
-		g_snprintf(tmp, length, "<FONT SIZE=\"%d\">%s</FONT>", fontsize, buf);
-		strcpy(buf, tmp);
-	}
-
-	if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_fgcolor")) {
-		GdkColor fgcolor;
-
-		gdk_color_parse(
-			gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"),
-			&fgcolor);
-
-		g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>",
-				   fgcolor.red/256, fgcolor.green/256, fgcolor.blue/256, buf);
-		strcpy(buf, tmp);
-	}
-
-	if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_bgcolor")) {
-		GdkColor bgcolor;
-
-		gdk_color_parse(
-			gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"),
-			&bgcolor);
-
-		g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>",
-				   bgcolor.red/256, bgcolor.green/256, bgcolor.blue/256, buf);
-		strcpy(buf, tmp);
-	}
-
-	g_free(tmp);
-	return buf;
-}
-
-void show_usage(int mode, const char *name)
-{
-	switch (mode) {
-	case 0:		/* full help text */
-		printf(_("Gaim %s\n"
-		       "Usage: %s [OPTION]...\n\n"
-		       "  -a, --acct          display account editor window\n"
-		       "  -w, --away[=MESG]   make away on signon (optional argument MESG specifies\n"
-		       "                      name of away message to use)\n"
-		       "  -l, --login[=NAME]  automatically login (optional argument NAME specifies\n"
-		       "                      account(s) to use, seperated by commas)\n"
-		       "  -n, --loginwin      don't automatically login; show login window\n"
-		       "  -u, --user=NAME     use account NAME\n"
-		       "  -f, --file=FILE     use FILE as config\n"
-		       "  -d, --debug         print debugging messages to stdout\n"
-		       "  -v, --version       display the current version and exit\n"
-		       "  -h, --help          display this help and exit\n"), VERSION, name);
-		break;
-	case 1:		/* short message */
-		printf(_("Gaim %s. Try `%s -h' for more information.\n"), VERSION, name);
-		break;
-	}
-}
-
 GSList *message_split(char *message, int limit)
 {
 	static GSList *ret = NULL;
--- a/src/util.h	Sun Jun 22 17:08:52 2003 +0000
+++ b/src/util.h	Mon Jun 23 02:00:15 2003 +0000
@@ -151,30 +151,6 @@
  */
 char *away_subs(const char *str, const char *name);
 
-/**
- * Stylizes the specified text using HTML, according to the current
- * font options.
- *
- * @param text The text to stylize.
- * @param len  The intended length of the new buffer.
- *
- * @return A newly allocated string of length @a len, containing the
- *         stylized version of @a text.
- *
- * @todo Move this to a UI-specific file.
- */
-char *stylize(const gchar *text, int len);
-
-/**
- * Shows the usage options for the gaim binary.
- *
- * @param mode @c 0 for full options, or @c 1 for a short summary.
- * @param name The name of the binary.
- * 
- * @todo Move this to the binary, when a library is formed.
- */
-void show_usage(int mode, const char *name);
-
 /**`
  * Returns the user's home directory.
  *