aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/degesch.c b/degesch.c
index b33a0a2..05b9ff5 100644
--- a/degesch.c
+++ b/degesch.c
@@ -1030,6 +1030,7 @@ struct server
// TODO: an output queue to prevent excess floods (this will be needed
// especially for away status polling)
+ char *name; ///< Server identifier
struct buffer *buffer; ///< The buffer for this server
struct str_map irc_users; ///< IRC user data
@@ -1098,6 +1099,8 @@ server_free (struct server *self)
if (self->ssl_ctx)
SSL_CTX_free (self->ssl_ctx);
+ free (self->name);
+
if (self->irc_user)
user_unref (self->irc_user);
free (self->irc_user_mode);
@@ -1137,9 +1140,8 @@ struct app_context
struct buffer *last_buffer; ///< Last used buffer
- // XXX: when we go multiserver, there will be collisions
- // TODO: make buffer names unique like weechat does
- struct str_map buffers_by_name; ///< Excludes GLOBAL and SERVER
+ // TODO: make buffer names fully unique like weechat does
+ struct str_map buffers_by_name; ///< Buffers by name
struct buffer *global_buffer; ///< The global buffer
struct buffer *current_buffer; ///< The current buffer
@@ -1171,6 +1173,7 @@ app_context_init (struct app_context *self)
server_init (&self->server, &self->poller);
self->server.ctx = self;
+ self->server.name = xstrdup ("server");
str_map_init (&self->buffers_by_name);
self->buffers_by_name.key_xfrm = irc_strxfrm;
@@ -2691,7 +2694,7 @@ irc_get_or_make_user_buffer (struct server *s, const char *nickname)
// Open a new buffer for the user
buffer = buffer_new ();
buffer->type = BUFFER_PM;
- buffer->name = xstrdup (nickname);
+ buffer->name = xstrdup_printf ("%s.%s", s->name, nickname);
buffer->server = s;
buffer->user = user;
str_map_set (&s->irc_buffer_map, user->nickname, buffer);
@@ -3671,7 +3674,7 @@ irc_handle_join (struct server *s, const struct irc_message *msg)
{
buffer = buffer_new ();
buffer->type = BUFFER_CHANNEL;
- buffer->name = xstrdup (channel_name);
+ buffer->name = xstrdup_printf ("%s.%s", s->name, channel_name);
buffer->server = s;
buffer->channel = channel =
irc_make_channel (s, xstrdup (channel_name));
@@ -3796,8 +3799,10 @@ irc_handle_nick (struct server *s, const struct irc_message *msg)
buffer_send (s->ctx, pm_buffer, BUFFER_LINE_NICK, 0,
.who = who,
.object = irc_to_utf8 (s->ctx, new_nickname));
- // TODO: use a full weechat-style buffer name here
- buffer_rename (s->ctx, pm_buffer, new_nickname);
+
+ char *x = xstrdup_printf ("%s.%s", s->name, new_nickname);
+ buffer_rename (s->ctx, pm_buffer, x);
+ free (x);
}
if (irc_is_this_us (s, msg->prefix))
@@ -4699,7 +4704,7 @@ try_decode_buffer (struct app_context *ctx, const char *word)
buffer = buffer_at_index (ctx, n);
if (!buffer)
buffer = buffer_by_name (ctx, word);
- // TODO: decode the global and server buffers, partial matches
+ // TODO: partial matches
return buffer;
}