aboutsummaryrefslogtreecommitdiffstats
path: root/irc.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-09-01 01:18:21 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2010-09-01 01:18:21 +0200
commit0c85c08d210e16bb10dc283b4a1478ce53c0c1b1 (patch)
tree4d7fb00a0467ba51337fdc84cacade43b6baab97 /irc.c
parentf5c0d8e4dd3ce01945a6334a5d87c89a9f43b16b (diff)
Pluginify this thing a little bit. Not so much in the dynamically loadable
sense of the word, more in a way that core files don't have to include otr.h.
Diffstat (limited to 'irc.c')
-rw-r--r--irc.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/irc.c b/irc.c
index 836d5f81..ed705caa 100644
--- a/irc.c
+++ b/irc.c
@@ -28,6 +28,7 @@
#include "dcc.h"
GSList *irc_connection_list;
+GSList *irc_plugins;
static gboolean irc_userping( gpointer _irc, gint fd, b_input_condition cond );
static char *set_eval_charset( set_t *set, char *value );
@@ -41,6 +42,7 @@ irc_t *irc_new( int fd )
socklen_t socklen = sizeof( sock );
char *host = NULL, *myhost = NULL;
irc_user_t *iu;
+ GSList *l;
set_t *s;
bee_t *b;
@@ -163,6 +165,13 @@ irc_t *irc_new( int fd )
nogaim_init();
+ for( l = irc_plugins; l; l = l->next )
+ {
+ irc_plugin_t *p = l->data;
+ if( p->irc_new )
+ p->irc_new( irc );
+ }
+
return irc;
}
@@ -206,10 +215,19 @@ static gboolean irc_free_hashkey( gpointer key, gpointer value, gpointer data );
void irc_free( irc_t * irc )
{
+ GSList *l;
+
irc->status |= USTATUS_SHUTDOWN;
log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd );
+ for( l = irc_plugins; l; l = l->next )
+ {
+ irc_plugin_t *p = l->data;
+ if( p->irc_free )
+ p->irc_free( irc );
+ }
+
if( irc->status & USTATUS_IDENTIFIED && set_getbool( &irc->b->set, "save_on_quit" ) )
if( storage_save( irc, NULL, TRUE ) != STORAGE_OK )
log_message( LOGLVL_WARNING, "Error while saving settings for user %s", irc->user->nick );
@@ -931,3 +949,8 @@ static char *set_eval_bw_compat( set_t *set, char *value )
return SET_INVALID;
}
+
+void register_irc_plugin( const struct irc_plugin *p )
+{
+ irc_plugins = g_slist_prepend( irc_plugins, (gpointer) p );
+}