diff options
Diffstat (limited to 'protocols/nogaim.c')
| -rw-r--r-- | protocols/nogaim.c | 99 | 
1 files changed, 80 insertions, 19 deletions
| diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 22240d8a..ead86f65 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -38,9 +38,6 @@  #include <ctype.h>  #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] =  {  	{ "Away from computer", "Away", "Extended away", NULL }, @@ -57,30 +54,95 @@ static int remove_chat_buddy_silent( struct conversation *b, char *handle );  GSList *connections; +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; +}  /* 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()  { -	proto_prpl[PROTO_MSN] = g_new0 ( struct prpl, 1 ); +	GDir *dir; +	GError *error = NULL; +  #ifdef WITH_MSN -	msn_init( proto_prpl[PROTO_MSN] ); +	extern void msn_init(); +	msn_init();  #endif -	proto_prpl[PROTO_OSCAR] = g_new0( struct prpl, 1 );  #ifdef WITH_OSCAR -	oscar_init( proto_prpl[PROTO_OSCAR] ); +	extern void oscar_init(); +	oscar_init();  #endif -	proto_prpl[PROTO_YAHOO] = g_new0( struct prpl, 1 );  #ifdef WITH_YAHOO -	byahoo_init( proto_prpl[PROTO_YAHOO] ); +	extern void byahoo_init(); +	byahoo_init();  #endif -	proto_prpl[PROTO_JABBER] = g_new0( struct prpl, 1 );  #ifdef WITH_JABBER -	jabber_init( proto_prpl[PROTO_JABBER] ); +	extern void jabber_init(); +	jabber_init();  #endif + +	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); +	}  }  GSList *get_connections() { return connections; } @@ -171,8 +233,7 @@ struct gaim_connection *new_gaim_conn( struct aim_user *user )  	gc = g_new0( struct gaim_connection, 1 ); -	gc->protocol = user->protocol; -	gc->prpl = proto_prpl[gc->protocol]; +	gc->prpl = user->prpl;  	g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username );  	g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password );  	/* [MD]	BUGFIX: don't set gc->irc to the global IRC, but use the one from the struct aim_user. @@ -250,7 +311,7 @@ void serv_got_crap( struct gaim_connection *gc, char *format, ... )  	    ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) )  		strip_html( msg ); -	irc_usermsg( gc->irc, "%s(%s) - %s", proto_name[gc->protocol], gc->username, msg ); +	irc_usermsg( gc->irc, "%s(%s) - %s", gc->prpl->name, gc->username, msg );  }  static gboolean send_keepalive( gpointer d ) @@ -282,7 +343,7 @@ void account_online( struct gaim_connection *gc )  	if( u && u->away ) proto_away( gc, u->away ); -	if( gc->protocol == PROTO_ICQ ) + 	if( !strcmp(gc->prpl->name, "icq") )  	{  		for( u = gc->irc->users; u; u = u->next )  			if( u->gc == gc ) @@ -410,7 +471,7 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea  	}  	memset( nick, 0, MAX_NICK_LENGTH + 1 ); -	strcpy( nick, nick_get( gc->irc, handle, gc->protocol, realname ) ); +	strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) );  	u = user_add( gc->irc, nick ); @@ -434,7 +495,7 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea  	}  	else  	{ -		u->host = g_strdup( proto_name[gc->user->protocol] ); +		u->host = g_strdup( gc->user->prpl->name );  		u->user = g_strdup( handle );  	} @@ -563,11 +624,11 @@ void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, in  			remove_chat_buddy_silent( c, handle );  	} -	if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_OSCAR || gc->protocol == PROTO_TOC ) ) +	if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) )  	{  		u->away = g_strdup( "Away" );  	} -	else if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_JABBER ) ) +	else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) )  	{  		if( type & UC_DND )  			u->away = g_strdup( "Do Not Disturb" ); | 
