Index: protocols/nogaim.c
===================================================================
--- protocols/nogaim.c	(revision 65e2ce1ffdead577ed90148d33e36794136b3232)
+++ protocols/nogaim.c	(revision d636233a518fbe46264230866d4b8ea463f1474e)
@@ -39,4 +39,7 @@
 #include <iconv.h>
 
+struct prpl *proto_prpl[PROTO_MAX];
+char proto_name[PROTO_MAX][8] = { "TOC", "OSCAR", "YAHOO", "ICQ", "MSN", "", "", "", "JABBER", "", "", "", "", "", "", "" };
+
 static char *proto_away_alias[7][5] =
 {
@@ -55,102 +58,27 @@
 GSList *connections;
 
-#ifdef WITH_PLUGINS
-gboolean load_plugin(char *path)
-{
-	void (*init_function) (void);
-	
-	GModule *mod = g_module_open(path, G_MODULE_BIND_LAZY);
-
-	if(!mod) {
-		log_message(LOGLVL_ERROR, "Can't find `%s', not loading", path);
-		return FALSE;
-	}
-
-	if(!g_module_symbol(mod,"init_plugin",(gpointer *) &init_function)) {
-		log_message(LOGLVL_WARNING, "Can't find function `init_plugin' in `%s'\n", path);
-		return FALSE;
-	}
-
-	init_function();
-
-	return TRUE;
-}
-
-void load_plugins(void)
-{
-	GDir *dir;
-	GError *error = NULL;
-
-	dir = g_dir_open(PLUGINDIR, 0, &error);
-
-	if (dir) {
-		const gchar *entry;
-		char *path;
-
-		while ((entry = g_dir_read_name(dir))) {
-			path = g_build_filename(PLUGINDIR, entry, NULL);
-			if(!path) {
-				log_message(LOGLVL_WARNING, "Can't build path for %s\n", entry);
-				continue;
-			}
-
-			load_plugin(path);
-
-			g_free(path);
-		}
-
-		g_dir_close(dir);
-	}
-}
+
+/* nogaim.c */
+
+void nogaim_init()
+{
+	proto_prpl[PROTO_MSN] = g_new0 ( struct prpl, 1 );
+#ifdef WITH_MSN
+	msn_init( proto_prpl[PROTO_MSN] );
 #endif
 
-/* nogaim.c */
-
-GList *protocols = NULL;
-  
-void register_protocol (struct prpl *p)
-{
-	protocols = g_list_append(protocols, p);
-}
-
- 
-struct prpl *find_protocol(const char *name)
-{
-	GList *gl;
-	for (gl = protocols; gl; gl = gl->next) 
- 	{
- 		struct prpl *proto = gl->data;
- 		if(!g_strcasecmp(proto->name, name)) 
-			return proto;
- 	}
- 	return NULL;
-}
-
-/* nogaim.c */
-void nogaim_init()
-{
-	extern void msn_init();
-	extern void oscar_init();
-	extern void byahoo_init();
-	extern void jabber_init();
-
-#ifdef WITH_MSN
-	msn_init();
+	proto_prpl[PROTO_OSCAR] = g_new0( struct prpl, 1 );
+#ifdef WITH_OSCAR
+	oscar_init( proto_prpl[PROTO_OSCAR] );
 #endif
-
-#ifdef WITH_OSCAR
-	oscar_init();
+	
+	proto_prpl[PROTO_YAHOO] = g_new0( struct prpl, 1 );
+#ifdef WITH_YAHOO
+	byahoo_init( proto_prpl[PROTO_YAHOO] );
 #endif
 	
-#ifdef WITH_YAHOO
-	byahoo_init();
-#endif
-	
+	proto_prpl[PROTO_JABBER] = g_new0( struct prpl, 1 );
 #ifdef WITH_JABBER
-	jabber_init();
-#endif
-
-#ifdef WITH_PLUGINS
-	load_plugins();
+	jabber_init( proto_prpl[PROTO_JABBER] );
 #endif
 }
@@ -244,5 +172,6 @@
 	gc = g_new0( struct gaim_connection, 1 );
 	
-	gc->prpl = user->prpl;
+	gc->protocol = user->protocol;
+	gc->prpl = proto_prpl[gc->protocol];
 	g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username );
 	g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password );
@@ -325,12 +254,12 @@
 	/* Try to find a different connection on the same protocol. */
 	for( a = gc->irc->accounts; a; a = a->next )
-		if( a->prpl == gc->prpl && a->gc != gc )
+		if( proto_prpl[a->protocol] == gc->prpl && a->gc != gc )
 			break;
 	
 	/* If we found one, add the screenname to the acc_id. */
 	if( a )
-		g_snprintf( acc_id, 32, "%s(%s)", gc->prpl->name, gc->username );
+		g_snprintf( acc_id, 32, "%s(%s)", proto_name[gc->protocol], gc->username );
 	else
-		g_snprintf( acc_id, 32, "%s", gc->prpl->name );
+		g_snprintf( acc_id, 32, "%s", proto_name[gc->protocol] );
 	
 	irc_usermsg( gc->irc, "%s - %s", acc_id, msg );
@@ -366,5 +295,5 @@
 	if( u && u->away ) proto_away( gc, u->away );
 	
- 	if( !strcmp(gc->prpl->name, "icq") )
+	if( gc->protocol == PROTO_ICQ )
 	{
 		for( u = gc->irc->users; u; u = u->next )
@@ -452,5 +381,12 @@
 void do_error_dialog( struct gaim_connection *gc, char *msg, char *title )
 {
-	serv_got_crap( gc, "Error: %s", msg );
+	if( msg && title )
+		serv_got_crap( gc, "Error: %s: %s", title, msg );
+	else if( msg )
+		serv_got_crap( gc, "Error: %s", msg );
+	else if( title )
+		serv_got_crap( gc, "Error: %s", title );
+	else
+		serv_got_crap( gc, "Error" );
 }
 
@@ -494,5 +430,5 @@
 	
 	memset( nick, 0, MAX_NICK_LENGTH + 1 );
-	strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) );
+	strcpy( nick, nick_get( gc->irc, handle, gc->protocol, realname ) );
 	
 	u = user_add( gc->irc, nick );
@@ -518,5 +454,5 @@
 	else
 	{
-		u->host = g_strdup( gc->user->prpl->name );
+		u->host = g_strdup( proto_name[gc->user->protocol] );
 		u->user = g_strdup( handle );
 	}
@@ -647,9 +583,9 @@
 	}
 	
-	if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) )
+	if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_OSCAR || gc->protocol == PROTO_TOC ) )
 	{
 		u->away = g_strdup( "Away" );
 	}
-	else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) )
+	else if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_JABBER ) )
 	{
 		if( type & UC_DND )
@@ -737,5 +673,5 @@
 		/* If there's a newline/space in this string, split up there,
 		   looks a bit prettier. */
-		if( ( nl = strrchr( msg, '\n' ) ) || ( nl = strchr( msg, ' ' ) ) )
+		if( ( nl = strrchr( msg, '\n' ) ) || ( nl = strrchr( msg, ' ' ) ) )
 		{
 			msg[425] = tmp;
@@ -769,5 +705,5 @@
 	
 	if( ( u = user_findhandle( gc, handle ) ) )
-		irc_msgfrom( gc->irc, u->nick, "\1TYPING 1\1" );
+		irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, "\1TYPING 1\1" );
 }
 
