aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2008-08-31 16:00:35 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2008-08-31 16:00:35 +0100
commit3611717156f4c9ebfdf829319840d49e59b827ce (patch)
tree979436212a238fe4dd7cfd88071e669fa029196a
parentd995c9b5de1bff5e3eb5de47b7ffbd3e92e2ac3d (diff)
Added auto_join code.
-rw-r--r--chat.c20
-rw-r--r--chat.h2
-rw-r--r--irc_commands.c12
-rw-r--r--protocols/nogaim.c11
4 files changed, 33 insertions, 12 deletions
diff --git a/chat.c b/chat.c
index a4c1cce9..d60655de 100644
--- a/chat.c
+++ b/chat.c
@@ -57,7 +57,7 @@ struct chat *chat_add( irc_t *irc, account_t *acc, char *handle, char *channel )
c->channel = g_strdup( channel );
s = set_add( &c->set, "auto_join", "false", set_eval_bool, c );
- s = set_add( &c->set, "auto_rejoin", "false", set_eval_bool, c );
+ /* s = set_add( &c->set, "auto_rejoin", "false", set_eval_bool, c ); */
s = set_add( &c->set, "nick", NULL, NULL, c );
s->flags |= SET_NULL_OK;
@@ -168,3 +168,21 @@ int chat_chanok( char *a )
else
return 0;
}
+
+int chat_join( irc_t *irc, struct chat *c )
+{
+ struct groupchat *gc;
+ char *nick = set_getstr( &c->set, "nick" );
+
+ if( nick == NULL )
+ nick = irc->nick;
+
+ if( ( gc = c->acc->prpl->chat_join( c->acc->ic, c->handle, nick, NULL ) ) )
+ {
+ g_free( gc->channel );
+ gc->channel = g_strdup( c->channel );
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/chat.h b/chat.h
index 8c07d3d0..78e54f24 100644
--- a/chat.h
+++ b/chat.h
@@ -42,3 +42,5 @@ int chat_del( irc_t *irc, struct chat *chat );
int chat_chancmp( char *a, char *b );
int chat_chanok( char *a );
+
+int chat_join( irc_t *irc, struct chat *c );
diff --git a/irc_commands.c b/irc_commands.c
index d083f714..8941b0e9 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -192,7 +192,6 @@ static void irc_cmd_join( irc_t *irc, char **cmd )
RFC doesn't have any reply for that though? */
else if( cmd[1] )
{
- struct groupchat *gc;
struct chat *c;
user_t *u;
@@ -204,16 +203,7 @@ static void irc_cmd_join( irc_t *irc, char **cmd )
if( ( c = chat_bychannel( irc, cmd[1] ) ) )
{
- char *nick = set_getstr( &c->set, "nick" );
-
- if( nick == NULL )
- nick = irc->nick;
-
- if( ( gc = c->acc->prpl->chat_join( c->acc->ic, c->handle, nick, NULL ) ) )
- {
- g_free( gc->channel );
- gc->channel = g_strdup( c->channel );
- }
+ chat_join( irc, c );
}
else
{
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index 6a267adf..20d2f3f1 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -248,6 +248,8 @@ static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond )
void imcb_connected( struct im_connection *ic )
{
+ irc_t *irc = ic->irc;
+ struct chat *c;
user_t *u;
/* MSN servers sometimes redirect you to a different server and do
@@ -270,6 +272,15 @@ void imcb_connected( struct im_connection *ic )
/* Apparently we're connected successfully, so reset the
exponential backoff timer. */
ic->acc->auto_reconnect_delay = 0;
+
+ for( c = irc->chatrooms; c; c = c->next )
+ {
+ if( c->acc != ic->acc )
+ continue;
+
+ if( set_getbool( &c->set, "auto_join" ) )
+ chat_join( irc, c );
+ }
}
gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond )