aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--irc.h10
-rw-r--r--irc_channel.c11
-rw-r--r--irc_im.c6
-rw-r--r--irc_send.c6
-rw-r--r--irc_user.c2
5 files changed, 27 insertions, 8 deletions
diff --git a/irc.h b/irc.h
index e909d6b9..94738832 100644
--- a/irc.h
+++ b/irc.h
@@ -205,6 +205,13 @@ struct irc_control_channel
extern const struct bee_ui_funcs irc_ui_funcs;
+typedef enum
+{
+ IRC_CDU_SILENT,
+ IRC_CDU_PART,
+ IRC_CDU_KICK,
+} irc_channel_del_user_type_t;
+
/* irc.c */
extern GSList *irc_connection_list;
@@ -232,7 +239,7 @@ irc_channel_t *irc_channel_get( irc_t *irc, char *id );
int irc_channel_free( irc_channel_t *ic );
void irc_channel_free_soon( irc_channel_t *ic );
int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu );
-int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu, gboolean silent, const char *msg );
+int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu, irc_channel_del_user_type_t type, const char *msg );
irc_channel_user_t *irc_channel_has_user( irc_channel_t *ic, irc_user_t *iu );
int irc_channel_set_topic( irc_channel_t *ic, const char *topic, const irc_user_t *who );
void irc_channel_user_set_mode( irc_channel_t *ic, irc_user_t *iu, irc_channel_user_flags_t flags );
@@ -255,6 +262,7 @@ void irc_usermsg( irc_t *irc, char *format, ... );
void irc_send_join( irc_channel_t *ic, irc_user_t *iu );
void irc_send_part( irc_channel_t *ic, irc_user_t *iu, const char *reason );
void irc_send_quit( irc_user_t *iu, const char *reason );
+void irc_send_kick( irc_channel_t *ic, irc_user_t *iu, irc_user_t *kicker, const char *reason );
void irc_send_names( irc_channel_t *ic );
void irc_send_topic( irc_channel_t *ic, gboolean topic_change );
void irc_send_whois( irc_user_t *iu );
diff --git a/irc_channel.c b/irc_channel.c
index 4aec9077..70770bfb 100644
--- a/irc_channel.c
+++ b/irc_channel.c
@@ -118,7 +118,7 @@ int irc_channel_free( irc_channel_t *ic )
irc_t *irc = ic->irc;
if( ic->flags & IRC_CHANNEL_JOINED )
- irc_channel_del_user( ic, irc->user, FALSE, "Cleaning up channel" );
+ irc_channel_del_user( ic, irc->user, IRC_CDU_KICK, "Cleaning up channel" );
if( ic->f->_free )
ic->f->_free( ic );
@@ -222,7 +222,7 @@ int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu )
return 1;
}
-int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu, gboolean silent, const char *msg )
+int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu, irc_channel_del_user_type_t type, const char *msg )
{
irc_channel_user_t *icu;
@@ -232,8 +232,13 @@ int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu, gboolean silent, co
ic->users = g_slist_remove( ic->users, icu );
g_free( icu );
- if( ic->flags & IRC_CHANNEL_JOINED && !silent )
+ if( !( ic->flags & IRC_CHANNEL_JOINED ) || type == IRC_CDU_SILENT ) {}
+ /* Do nothing. The caller should promise it won't screw
+ up state of the IRC client. :-) */
+ else if( type == IRC_CDU_PART )
irc_send_part( ic, iu, msg );
+ else if( type == IRC_CDU_KICK )
+ irc_send_kick( ic, iu, ic->irc->root, msg );
if( iu == ic->irc->user )
{
diff --git a/irc_im.c b/irc_im.c
index 57ff893e..c900e7ff 100644
--- a/irc_im.c
+++ b/irc_im.c
@@ -182,7 +182,7 @@ void bee_irc_channel_update( irc_t *irc, irc_channel_t *ic, irc_user_t *iu )
if( !show )
{
- irc_channel_del_user( ic, iu, FALSE, NULL );
+ irc_channel_del_user( ic, iu, IRC_CDU_PART, NULL );
}
else
{
@@ -478,7 +478,7 @@ static gboolean bee_irc_chat_free( bee_t *bee, struct groupchat *c )
irc_channel_printf( ic, "Cleaning up channel, bye!" );
ic->data = NULL;
- irc_channel_del_user( ic, ic->irc->user, FALSE, "Chatroom closed by server" );
+ irc_channel_del_user( ic, ic->irc->user, IRC_CDU_KICK, "Chatroom closed by server" );
return TRUE;
}
@@ -524,7 +524,7 @@ static gboolean bee_irc_chat_remove_user( bee_t *bee, struct groupchat *c, bee_u
/* TODO: Possible bug here: If a module removes $user here instead of just
using imcb_chat_free() and the channel was IRC_CHANNEL_TEMP, we get into
a broken state around here. */
- irc_channel_del_user( c->ui_data, bu == bee->user ? irc->user : bu->ui_data, FALSE, NULL );
+ irc_channel_del_user( c->ui_data, bu == bee->user ? irc->user : bu->ui_data, IRC_CDU_PART, NULL );
return TRUE;
}
diff --git a/irc_send.c b/irc_send.c
index 3617d088..b62d2011 100644
--- a/irc_send.c
+++ b/irc_send.c
@@ -157,6 +157,12 @@ void irc_send_quit( irc_user_t *iu, const char *reason )
irc_write( iu->irc, ":%s!%s@%s QUIT :%s", iu->nick, iu->user, iu->host, reason ? : "" );
}
+void irc_send_kick( irc_channel_t *ic, irc_user_t *iu, irc_user_t *kicker, const char *reason )
+{
+ irc_write( ic->irc, ":%s!%s@%s KICK %s %s :%s", kicker->nick, kicker->user,
+ kicker->host, ic->name, iu->nick, reason ? : "" );
+}
+
void irc_send_names( irc_channel_t *ic )
{
GSList *l;
diff --git a/irc_user.c b/irc_user.c
index fa509a45..cb7ea1e7 100644
--- a/irc_user.c
+++ b/irc_user.c
@@ -204,7 +204,7 @@ void irc_user_quit( irc_user_t *iu, const char *msg )
return;
for( l = iu->irc->channels; l; l = l->next )
- send_quit |= irc_channel_del_user( (irc_channel_t*) l->data, iu, TRUE, NULL );
+ send_quit |= irc_channel_del_user( (irc_channel_t*) l->data, iu, IRC_CDU_SILENT, NULL );
if( send_quit )
irc_send_quit( iu, msg );