diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-05-04 09:45:10 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-05-04 09:45:10 +0100 |
commit | eb504957c2ffa1a3130951d5381672fb3ef9dfd9 (patch) | |
tree | 25f88e020a30b762d70c8c88b00a39a2342786ed | |
parent | 9893da32ab881e135748295fc5c48aada552098b (diff) |
Show offline/away status better in /WHO and /WHOIS.
-rw-r--r-- | irc.h | 1 | ||||
-rw-r--r-- | irc_im.c | 6 | ||||
-rw-r--r-- | irc_send.c | 7 | ||||
-rw-r--r-- | protocols/bee_user.c | 3 |
4 files changed, 16 insertions, 1 deletions
@@ -90,6 +90,7 @@ typedef struct irc typedef enum { IRC_USER_PRIVATE = 1, + IRC_USER_AWAY = 2, } irc_user_flags_t; typedef struct irc_user @@ -82,6 +82,12 @@ static gboolean bee_irc_user_status( bee_t *bee, bee_user_t *bu, bee_user_t *old irc_user_t *iu = bu->ui_data; irc_channel_t *ic = irc->channels->data; /* For now, just pick the first channel. */ + /* Do this outside the if below since away state can change without + the online state changing. */ + iu->flags &= ~IRC_USER_AWAY; + if( bu->flags & BEE_USER_AWAY || !( bu->flags & BEE_USER_ONLINE ) ) + iu->flags |= IRC_USER_AWAY; + if( ( bu->flags & BEE_USER_ONLINE ) != ( old->flags & BEE_USER_ONLINE ) ) { if( bu->flags & BEE_USER_ONLINE ) @@ -230,6 +230,10 @@ void irc_send_whois( irc_user_t *iu ) else irc_send_num( irc, num, "%s :%s", iu->nick, bu->status ? : bu->status_msg ); } + else if( !( bu->flags & BEE_USER_ONLINE ) ) + { + irc_send_num( irc, 301, "%s :%s", iu->nick, "User is offline" ); + } } else { @@ -251,7 +255,8 @@ void irc_send_who( irc_t *irc, GSList *l, const char *channel ) /* TODO(wilmer): Restore away/channel information here */ irc_send_num( irc, 352, "%s %s %s %s %s %c :0 %s", channel ? : "*", iu->user, iu->host, irc->root->host, - iu->nick, 'H', iu->fullname ); + iu->nick, iu->flags & IRC_USER_AWAY ? 'G' : 'H', + iu->fullname ); l = l->next; } diff --git a/protocols/bee_user.c b/protocols/bee_user.c index 8db2fa28..0dd40cab 100644 --- a/protocols/bee_user.c +++ b/protocols/bee_user.c @@ -42,6 +42,9 @@ bee_user_t *bee_user_new( bee_t *bee, struct im_connection *ic, const char *hand if( bee->ui->user_new ) bee->ui->user_new( bee, bu ); + /* Offline by default. This will set the right flags. */ + imcb_buddy_status( ic, handle, 0, NULL, NULL ); + return bu; } |