fix idle string

master
bqv 3 years ago
parent 81352a26b7
commit e6feccaf79
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -979,7 +979,7 @@ struct t_channel_member *channel__add_member(struct t_account *account,
user->profile.status ? user->profile.status : (user->profile.idle ? "idle" : "entered"), user->profile.status ? user->profile.status : (user->profile.idle ? "idle" : "entered"),
weechat_color("reset"), weechat_color("reset"),
user->profile.idle ? "since " : "", user->profile.idle ? "since " : "",
user->profile.idle ? user->profile.idle : "", user->profile.idle ? user->profile.idle->data() : "",
user->profile.status_text ? " [" : "", user->profile.status_text ? " [" : "",
user->profile.status_text ? user->profile.status_text : "", user->profile.status_text ? user->profile.status_text : "",
user->profile.status_text ? "]" : "", user->profile.status_text ? "]" : "",

@ -209,7 +209,7 @@ int connection__presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void
auto idle = binding.idle_since(); auto idle = binding.idle_since();
user->profile.status_text = status ? strdup(status->data()) : NULL; user->profile.status_text = status ? strdup(status->data()) : NULL;
user->profile.status = show ? strdup(show->data()) : NULL; user->profile.status = show ? strdup(show->data()) : NULL;
user->profile.idle = idle ? strdup("2000-01-01T00:00:00.000z") : NULL; user->profile.idle = idle ? fmt::format("{}", *idle) : std::string();
user->is_away = show ? *show == "away" : false; user->is_away = show ? *show == "away" : false;
user->profile.role = role.size() ? strdup(role.data()) : NULL; user->profile.role = role.size() ? strdup(role.data()) : NULL;
user->profile.affiliation = affiliation.size() && affiliation == "none" user->profile.affiliation = affiliation.size() && affiliation == "none"
@ -243,7 +243,7 @@ int connection__presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void
auto idle = binding.idle_since(); auto idle = binding.idle_since();
user->profile.status_text = status ? strdup(status->data()) : NULL; user->profile.status_text = status ? strdup(status->data()) : NULL;
user->profile.status = show ? strdup(show->data()) : NULL; user->profile.status = show ? strdup(show->data()) : NULL;
user->profile.idle = idle ? strdup("2000-01-01T00:00:00.000z") : NULL; user->profile.idle = idle ? fmt::format("{}", *idle) : std::string();
user->is_away = show ? *show == "away" : false; user->is_away = show ? *show == "away" : false;
user->profile.role = NULL; user->profile.role = NULL;
user->profile.affiliation = NULL; user->profile.affiliation = NULL;

@ -166,10 +166,7 @@ struct t_user *user__new(struct t_account *account,
return ptr_user; return ptr_user;
} }
if ((new_user = (struct t_user*)malloc(sizeof(*new_user))) == NULL) new_user = new struct t_user;
{
return NULL;
}
new_user->prev_user = account->last_user; new_user->prev_user = account->last_user;
new_user->next_user = NULL; new_user->next_user = NULL;
@ -185,7 +182,6 @@ struct t_user *user__new(struct t_account *account,
new_user->profile.avatar_hash = NULL; new_user->profile.avatar_hash = NULL;
new_user->profile.status_text = NULL; new_user->profile.status_text = NULL;
new_user->profile.status = NULL; new_user->profile.status = NULL;
new_user->profile.idle = NULL;
new_user->profile.display_name = display_name ? new_user->profile.display_name = display_name ?
strdup(display_name) : strdup(""); strdup(display_name) : strdup("");
new_user->profile.affiliation = NULL; new_user->profile.affiliation = NULL;
@ -234,8 +230,6 @@ void user__free(struct t_account *account,
free(user->profile.status_text); free(user->profile.status_text);
if (user->profile.status) if (user->profile.status)
free(user->profile.status); free(user->profile.status);
if (user->profile.idle)
free(user->profile.idle);
if (user->profile.display_name) if (user->profile.display_name)
free(user->profile.display_name); free(user->profile.display_name);
if (user->profile.affiliation) if (user->profile.affiliation)
@ -245,7 +239,7 @@ void user__free(struct t_account *account,
if (user->profile.role) if (user->profile.role)
free(user->profile.role); free(user->profile.role);
free(user); delete user;
account->users = new_users; account->users = new_users;
} }

@ -4,12 +4,15 @@
#pragma once #pragma once
#include <optional>
#include <string>
struct t_user_profile struct t_user_profile
{ {
char *avatar_hash; char *avatar_hash;
char *status_text; char *status_text;
char *status; char *status;
char *idle; std::optional<std::string> idle;
char *display_name; char *display_name;
char *email; char *email;
char *role; char *role;

Loading…
Cancel
Save