fixed user stuff post migration-hackery

master
bqv 2 years ago
parent 6e9a8b79f8
commit a6c60cdb5f
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -538,7 +538,7 @@ weechat::channel::member *weechat::channel::add_member(const char *id, const cha
&& type == weechat::channel::chat_type::MUC)
weechat_printf_date_tags(buffer, 0, "xmpp_presence,enter,log4", "%s%s%s%s%s %s%s%s%s %s%s%s%s%s%s%s%s%s%s%s%s%s%s",
weechat_prefix("join"),
user->as_prefix_raw(),
user->as_prefix_raw().data(),
client ? " (" : "",
client ? client : "",
client ? ")" : "",
@ -561,8 +561,8 @@ weechat::channel::member *weechat::channel::add_member(const char *id, const cha
else
weechat_printf_date_tags(buffer, 0, "xmpp_presence,enter,log4", "%s%s (%s) %s%s%s%s %s%s%s%s%s%s%s%s%s",
weechat_prefix("join"),
jid_resource ? user->as_prefix_raw() : "You",
jid_resource ? jid_resource : user->as_prefix_raw(),
jid_resource ? user->as_prefix_raw().data() : "You",
jid_resource ? jid_resource : user->as_prefix_raw().data(),
user->profile.status ? "is " : "",
weechat_color("irc.color.message_join"),
user->profile.status ? user->profile.status : (user->profile.idle ? "idle" : "entered"),

@ -18,7 +18,6 @@
namespace weechat
{
class config;
struct config_file;
struct config_section;
struct config_free { void operator() (struct t_config_file *ptr) { weechat_config_free(ptr); } };

@ -14,6 +14,7 @@
#include <fmt/core.h>
#include <fmt/chrono.h>
#include <libxml/uri.h>
#include <utility>
#include <weechat/weechat-plugin.h>
#include "plugin.hh"
@ -188,10 +189,15 @@ bool weechat::connection::presence_handler(xmpp_stanza_t *stanza)
user = weechat::user::search(&account, binding.from->full.data());
if (!user)
user = new weechat::user(&account, binding.from->full.data(),
{
auto name = binding.from->full.data();
user = &account.users.emplace(std::piecewise_construct,
std::forward_as_tuple(name),
std::forward_as_tuple(&account, channel, name,
channel && binding.from->bare.data() == channel->id
? (binding.from->resource.size() ? binding.from->resource.data() : "")
: binding.from->full.data());
: binding.from->full.data())).first->second;
}
auto status = binding.status();
auto show = binding.show();
auto idle = binding.idle_since();
@ -222,10 +228,15 @@ bool weechat::connection::presence_handler(xmpp_stanza_t *stanza)
{
user = user::search(&account, binding.from->full.data());
if (!user)
user = new weechat::user(&account, binding.from->full.data(),
{
auto name = binding.from->full.data();
user = &account.users.emplace(std::piecewise_construct,
std::forward_as_tuple(name),
std::forward_as_tuple(&account, channel, name,
channel && binding.from->bare.data() == channel->id
? (binding.from->resource.size() ? binding.from->resource.data() : "")
: binding.from->full.data());
: binding.from->full.data())).first->second;
}
auto status = binding.status();
auto show = binding.show();
auto idle = binding.idle_since();
@ -308,9 +319,14 @@ bool weechat::connection::message_handler(xmpp_stanza_t *stanza)
return 1;
auto user = user::search(&account, from);
if (!user)
user = new weechat::user(&account, from,
{
auto name = from;
user = &account.users.emplace(std::piecewise_construct,
std::forward_as_tuple(name),
std::forward_as_tuple(&account, channel, name,
weechat_strcasecmp(from_bare, channel->id.data()) == 0
? nick : from);
? nick : from)).first->second;
}
channel->add_typing(user);
weechat_printf(channel->buffer, "...\t%s%s typing",
weechat_color("gray"),
@ -743,15 +759,15 @@ bool weechat::connection::message_handler(xmpp_stanza_t *stanza)
}
if (channel_id == from_bare && to == channel->id)
weechat_printf_date_tags(channel->buffer, date, *dyn_tags, "%s%s\t[to %s]: %s",
edit, user::as_prefix_raw(&account, nick).data(),
edit, user::as_prefix_raw(&account, from).data(),
to, difftext ? difftext : text ? text : "");
else if (weechat_string_match(text, "/me *", 0))
weechat_printf_date_tags(channel->buffer, date, *dyn_tags, "%s%s\t%s %s",
edit, weechat_prefix("action"), user::as_prefix_raw(&account, nick).data(),
edit, weechat_prefix("action"), user::as_prefix_raw(&account, from).data(),
difftext ? difftext+4 : text ? text+4 : "");
else
weechat_printf_date_tags(channel->buffer, date, *dyn_tags, "%s%s\t%s",
edit, user::as_prefix_raw(&account, nick).data(),
edit, user::as_prefix_raw(&account, from).data(),
difftext ? difftext : text ? text : "");
weechat_string_dyn_free(dyn_tags, 1);

@ -147,7 +147,7 @@ void weechat::user::nicklist_remove(weechat::account *account,
weechat_nicklist_remove_nick(ptr_buffer, ptr_nick);
}
weechat::user::user(weechat::account *account,
weechat::user::user(weechat::account *account, weechat::channel *channel,
const char *id, const char *display_name)
{
if (!account || !id)
@ -155,8 +155,8 @@ weechat::user::user(weechat::account *account,
throw nullptr;
}
//if (account->users.empty())
// channel::add_nicklist_groups(account, nullptr);
if (account->users.empty() && channel)
channel->add_nicklist_groups();
weechat::user *ptr_user = user::search(account, id);
if (ptr_user)
@ -164,8 +164,6 @@ weechat::user::user(weechat::account *account,
throw nullptr;
}
//account->users += this;
this->id = strdup(id);
this->profile.display_name = display_name ?

@ -41,7 +41,7 @@ namespace weechat
struct profile profile;
public:
user(weechat::account *account, const char *id, const char *display_name);
user(weechat::account *account, weechat::channel *channel, const char *id, const char *display_name);
static std::string get_colour(const char *name);
static std::string get_colour_for_nicklist(const char *name);
@ -53,11 +53,11 @@ namespace weechat
std::string as_prefix();
static std::string as_prefix_raw(weechat::account *account, const char *id) {
auto found = std::unique_ptr<user>(search(account, id));
auto found = search(account, id);
return found ? found->as_prefix_raw() : "";
}
static std::string as_prefix(weechat::account *account, const char *id) {
auto found = std::unique_ptr<user>(search(account, id));
auto found = search(account, id);
return found ? found->as_prefix() : "";
}

Loading…
Cancel
Save