mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Show nickname in status updates if available
This commit is contained in:
parent
66e4d8f5ba
commit
d9cb8c100f
@ -422,25 +422,35 @@ ui_contact_online(const char * const barejid, const char * const resource,
|
|||||||
const char * const show, const char * const status, GDateTime *last_activity)
|
const char * const show, const char * const status, GDateTime *last_activity)
|
||||||
{
|
{
|
||||||
Jid *jid = jid_create_from_bare_and_resource(barejid, resource);
|
Jid *jid = jid_create_from_bare_and_resource(barejid, resource);
|
||||||
char *display_str = NULL;
|
PContact contact = roster_get_contact(barejid);
|
||||||
|
GString *display_str = g_string_new("");
|
||||||
|
|
||||||
if (strcmp(jid->resourcepart, "__prof_default") == 0) {
|
// use nickname if exists
|
||||||
display_str = jid->barejid;
|
if (p_contact_name(contact) != NULL) {
|
||||||
|
g_string_append(display_str, strdup(p_contact_name(contact)));
|
||||||
} else {
|
} else {
|
||||||
display_str = jid->fulljid;
|
g_string_append(display_str, strdup(barejid));
|
||||||
}
|
}
|
||||||
|
|
||||||
_show_status_string(console, display_str, show, status, last_activity, "++",
|
// add resource if not default provided by profanity
|
||||||
"online");
|
if (strcmp(jid->resourcepart, "__prof_default") != 0) {
|
||||||
|
g_string_append(display_str, " (");
|
||||||
|
g_string_append(display_str, strdup(jid->resourcepart));
|
||||||
|
g_string_append(display_str, ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
_show_status_string(console, display_str->str, show, status, last_activity,
|
||||||
|
"++", "online");
|
||||||
|
|
||||||
int win_index = _find_prof_win_index(barejid);
|
int win_index = _find_prof_win_index(barejid);
|
||||||
if (win_index != NUM_WINS) {
|
if (win_index != NUM_WINS) {
|
||||||
ProfWin *window = windows[win_index];
|
ProfWin *window = windows[win_index];
|
||||||
_show_status_string(window, display_str, show, status, last_activity, "++",
|
_show_status_string(window, display_str->str, show, status,
|
||||||
"online");
|
last_activity, "++", "online");
|
||||||
}
|
}
|
||||||
|
|
||||||
jid_destroy(jid);
|
jid_destroy(jid);
|
||||||
|
g_string_free(display_str, TRUE);
|
||||||
|
|
||||||
if (win_index == current_index)
|
if (win_index == current_index)
|
||||||
current_win_dirty = TRUE;
|
current_win_dirty = TRUE;
|
||||||
@ -451,22 +461,36 @@ ui_contact_offline(const char * const from, const char * const show,
|
|||||||
const char * const status)
|
const char * const status)
|
||||||
{
|
{
|
||||||
Jid *jidp = jid_create(from);
|
Jid *jidp = jid_create(from);
|
||||||
char *display_str = NULL;
|
PContact contact = roster_get_contact(jidp->barejid);
|
||||||
|
GString *display_str = g_string_new("");
|
||||||
|
|
||||||
if (strcmp(jidp->resourcepart, "__prof_default") == 0) {
|
// use nickname if exists
|
||||||
display_str = jidp->barejid;
|
if (p_contact_name(contact) != NULL) {
|
||||||
|
g_string_append(display_str, strdup(p_contact_name(contact)));
|
||||||
} else {
|
} else {
|
||||||
display_str = jidp->fulljid;
|
g_string_append(display_str, strdup(jidp->barejid));
|
||||||
}
|
}
|
||||||
|
|
||||||
_show_status_string(console, display_str, show, status, NULL, "--", "offline");
|
// add resource if not default provided by profanity
|
||||||
|
if (strcmp(jidp->resourcepart, "__prof_default") != 0) {
|
||||||
|
g_string_append(display_str, " (");
|
||||||
|
g_string_append(display_str, strdup(jidp->resourcepart));
|
||||||
|
g_string_append(display_str, ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
_show_status_string(console, display_str->str, show, status, NULL, "--",
|
||||||
|
"offline");
|
||||||
|
|
||||||
int win_index = _find_prof_win_index(from);
|
int win_index = _find_prof_win_index(from);
|
||||||
if (win_index != NUM_WINS) {
|
if (win_index != NUM_WINS) {
|
||||||
ProfWin *window = windows[win_index];
|
ProfWin *window = windows[win_index];
|
||||||
_show_status_string(window, display_str, show, status, NULL, "--", "offline");
|
_show_status_string(window, display_str->str, show, status, NULL, "--",
|
||||||
|
"offline");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jid_destroy(jidp);
|
||||||
|
g_string_free(display_str, TRUE);
|
||||||
|
|
||||||
if (win_index == current_index)
|
if (win_index == current_index)
|
||||||
current_win_dirty = TRUE;
|
current_win_dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user