degesch: finish QUIT handling
This commit is contained in:
parent
8e7412eb97
commit
b8bfcfde7c
34
degesch.c
34
degesch.c
@ -1986,7 +1986,13 @@ irc_handle_quit (struct app_context *ctx, const struct irc_message *msg)
|
||||
str_map_find (&ctx->irc_buffer_map, user->nickname);
|
||||
if (buffer)
|
||||
{
|
||||
// TODO: log a message in the buffer
|
||||
buffer_send (ctx, buffer, BUFFER_LINE_QUIT, 0,
|
||||
msg->prefix, message, "");
|
||||
|
||||
// TODO: set some kind of a flag in the buffer and when the user
|
||||
// reappers on a channel (JOIN), log a "is back online" message.
|
||||
// Also set this flag when we receive a "no such nick" numeric
|
||||
// and reset it when we send something to the buffer.
|
||||
}
|
||||
|
||||
// Log a message in all channels the user is in
|
||||
@ -1994,14 +2000,30 @@ irc_handle_quit (struct app_context *ctx, const struct irc_message *msg)
|
||||
{
|
||||
buffer = str_map_find (&ctx->irc_buffer_map, iter->channel->name);
|
||||
hard_assert (buffer != NULL);
|
||||
// TODO: log a message in the buffer
|
||||
buffer_send (ctx, buffer, BUFFER_LINE_QUIT, 0,
|
||||
msg->prefix, message, "");
|
||||
|
||||
// TODO: remove the "channel_user" link from iter->channel
|
||||
// TODO: remove the link from the list and free it
|
||||
// Unlink the user from the channel
|
||||
struct channel *channel = iter->channel;
|
||||
LIST_FOR_EACH (struct channel_user, iter, channel->users)
|
||||
if (iter->user == user)
|
||||
{
|
||||
LIST_UNLINK (channel->users, iter);
|
||||
channel_user_destroy (iter);
|
||||
}
|
||||
|
||||
LIST_UNLINK (user->channels, iter);
|
||||
user_channel_destroy (iter);
|
||||
}
|
||||
|
||||
// TODO: check reference count on the user and if it's just one,
|
||||
// remove him from "irc_users"
|
||||
// If it's the last reference, there's no reason for the user to stay.
|
||||
// Note that when the user has their own buffer, it still keeps a reference
|
||||
// and we don't have to care about removing them from "irc_buffer_map".
|
||||
if (user->ref_count == 1)
|
||||
{
|
||||
hard_assert (!user->channels);
|
||||
str_map_set (&ctx->irc_users, user->nickname, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user