aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/degesch.c b/degesch.c
index 8ea9ad9..dc80fb1 100644
--- a/degesch.c
+++ b/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
-
- // TODO: remove the "channel_user" link from iter->channel
- // TODO: remove the link from the list and free it
+ buffer_send (ctx, buffer, BUFFER_LINE_QUIT, 0,
+ msg->prefix, message, "");
+
+ // 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