diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-05-09 00:54:37 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-05-09 00:54:37 +0100 |
commit | eb37735451207895e7e1b5b3dcc0f9cbe178ad38 (patch) | |
tree | 0e64d60cc7fdefc9d6fd8f6a4d7d789612a62d89 | |
parent | 66b9e36aa9dfd123c66194d645a3c60cc3dc49bc (diff) |
This is how you now start groupchats: /join #channel, /invite people.
-rw-r--r-- | irc.h | 5 | ||||
-rw-r--r-- | irc_channel.c | 34 | ||||
-rw-r--r-- | irc_im.c | 13 |
3 files changed, 49 insertions, 3 deletions
@@ -130,7 +130,10 @@ extern const struct irc_user_funcs irc_user_self_funcs; typedef enum { IRC_CHANNEL_JOINED = 1, - IRC_CHANNEL_CONTACTS = 256, + + /* Hack: Set this flag right before jumping into IM when we expect + a call to imcb_chat_new(). */ + IRC_CHANNEL_CHAT_PICKME = 0x10000, } irc_channel_flags_t; typedef struct irc_channel diff --git a/irc_channel.c b/irc_channel.c index 2ff00068..2c6601d2 100644 --- a/irc_channel.c +++ b/irc_channel.c @@ -27,6 +27,7 @@ static gint irc_channel_user_cmp( gconstpointer a_, gconstpointer b_ ); static const struct irc_channel_funcs control_channel_funcs; +static const struct irc_channel_funcs groupchat_stub_funcs; irc_channel_t *irc_channel_new( irc_t *irc, const char *name ) { @@ -36,7 +37,6 @@ irc_channel_t *irc_channel_new( irc_t *irc, const char *name ) return NULL; ic = g_new0( irc_channel_t, 1 ); - ic->f = &control_channel_funcs; ic->irc = irc; ic->name = g_strdup( name ); strcpy( ic->mode, CMODE ); @@ -48,6 +48,11 @@ irc_channel_t *irc_channel_new( irc_t *irc, const char *name ) irc->channels = g_slist_prepend( irc->channels, ic ); + if( name[0] == '&' ) + ic->f = &control_channel_funcs; + else /* if( name[0] == '#' ) */ + ic->f = &groupchat_stub_funcs; + return ic; } @@ -250,3 +255,30 @@ static gboolean control_channel_privmsg( irc_channel_t *ic, const char *msg ) static const struct irc_channel_funcs control_channel_funcs = { control_channel_privmsg, }; + +/* Groupchat stub: Only handles /INVITE at least for now. */ +static gboolean groupchat_stub_invite( irc_channel_t *ic, irc_user_t *iu ) +{ + bee_user_t *bu = iu->bu; + + if( iu->bu->ic->acc->prpl->chat_with ) + { + ic->flags |= IRC_CHANNEL_CHAT_PICKME; + iu->bu->ic->acc->prpl->chat_with( bu->ic, bu->handle ); + ic->flags &= ~IRC_CHANNEL_CHAT_PICKME; + return TRUE; + } + else + { + irc_send_num( ic->irc, 482, "%s :IM protocol does not support room invitations", ic->name ); + return FALSE; + } +} + +static const struct irc_channel_funcs groupchat_stub_funcs = { + NULL, + NULL, + NULL, + NULL, + groupchat_stub_invite, +}; @@ -258,9 +258,20 @@ static gboolean bee_irc_chat_new( bee_t *bee, struct groupchat *c ) irc_t *irc = bee->ui_data; irc_channel_t *ic; char *topic; + GSList *l; int i; - for( i = 0; i <= 999; i ++ ) + /* Try to find a channel that expects to receive a groupchat. + This flag is set by groupchat_stub_invite(). */ + for( l = irc->channels; l; l = l->next ) + { + ic = l->data; + if( ic->flags & IRC_CHANNEL_CHAT_PICKME ) + break; + } + + /* If we found none, just generate some stupid name. */ + if( l == NULL ) for( i = 0; i <= 999; i ++ ) { char name[16]; sprintf( name, "&chat_%03d", i ); |