degesch: prepare buffers for multiserver
By making them unique among all servers.
This commit is contained in:
parent
76b0c13adc
commit
25d3f6e44a
21
degesch.c
21
degesch.c
@ -1030,6 +1030,7 @@ struct server
|
|||||||
// TODO: an output queue to prevent excess floods (this will be needed
|
// TODO: an output queue to prevent excess floods (this will be needed
|
||||||
// especially for away status polling)
|
// especially for away status polling)
|
||||||
|
|
||||||
|
char *name; ///< Server identifier
|
||||||
struct buffer *buffer; ///< The buffer for this server
|
struct buffer *buffer; ///< The buffer for this server
|
||||||
|
|
||||||
struct str_map irc_users; ///< IRC user data
|
struct str_map irc_users; ///< IRC user data
|
||||||
@ -1098,6 +1099,8 @@ server_free (struct server *self)
|
|||||||
if (self->ssl_ctx)
|
if (self->ssl_ctx)
|
||||||
SSL_CTX_free (self->ssl_ctx);
|
SSL_CTX_free (self->ssl_ctx);
|
||||||
|
|
||||||
|
free (self->name);
|
||||||
|
|
||||||
if (self->irc_user)
|
if (self->irc_user)
|
||||||
user_unref (self->irc_user);
|
user_unref (self->irc_user);
|
||||||
free (self->irc_user_mode);
|
free (self->irc_user_mode);
|
||||||
@ -1137,9 +1140,8 @@ struct app_context
|
|||||||
|
|
||||||
struct buffer *last_buffer; ///< Last used buffer
|
struct buffer *last_buffer; ///< Last used buffer
|
||||||
|
|
||||||
// XXX: when we go multiserver, there will be collisions
|
// TODO: make buffer names fully unique like weechat does
|
||||||
// TODO: make buffer names unique like weechat does
|
struct str_map buffers_by_name; ///< Buffers by name
|
||||||
struct str_map buffers_by_name; ///< Excludes GLOBAL and SERVER
|
|
||||||
|
|
||||||
struct buffer *global_buffer; ///< The global buffer
|
struct buffer *global_buffer; ///< The global buffer
|
||||||
struct buffer *current_buffer; ///< The current 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);
|
server_init (&self->server, &self->poller);
|
||||||
self->server.ctx = self;
|
self->server.ctx = self;
|
||||||
|
self->server.name = xstrdup ("server");
|
||||||
|
|
||||||
str_map_init (&self->buffers_by_name);
|
str_map_init (&self->buffers_by_name);
|
||||||
self->buffers_by_name.key_xfrm = irc_strxfrm;
|
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
|
// Open a new buffer for the user
|
||||||
buffer = buffer_new ();
|
buffer = buffer_new ();
|
||||||
buffer->type = BUFFER_PM;
|
buffer->type = BUFFER_PM;
|
||||||
buffer->name = xstrdup (nickname);
|
buffer->name = xstrdup_printf ("%s.%s", s->name, nickname);
|
||||||
buffer->server = s;
|
buffer->server = s;
|
||||||
buffer->user = user;
|
buffer->user = user;
|
||||||
str_map_set (&s->irc_buffer_map, user->nickname, buffer);
|
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 = buffer_new ();
|
||||||
buffer->type = BUFFER_CHANNEL;
|
buffer->type = BUFFER_CHANNEL;
|
||||||
buffer->name = xstrdup (channel_name);
|
buffer->name = xstrdup_printf ("%s.%s", s->name, channel_name);
|
||||||
buffer->server = s;
|
buffer->server = s;
|
||||||
buffer->channel = channel =
|
buffer->channel = channel =
|
||||||
irc_make_channel (s, xstrdup (channel_name));
|
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,
|
buffer_send (s->ctx, pm_buffer, BUFFER_LINE_NICK, 0,
|
||||||
.who = who,
|
.who = who,
|
||||||
.object = irc_to_utf8 (s->ctx, new_nickname));
|
.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))
|
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);
|
buffer = buffer_at_index (ctx, n);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
buffer = buffer_by_name (ctx, word);
|
buffer = buffer_by_name (ctx, word);
|
||||||
// TODO: decode the global and server buffers, partial matches
|
// TODO: partial matches
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user