Added roster list function to get display name for messages

This commit is contained in:
James Booth
2015-05-03 23:38:46 +01:00
parent ff867e7f2b
commit c3d2a7e937
3 changed files with 37 additions and 24 deletions

View File

@@ -42,6 +42,7 @@
#include "contact.h"
#include "jid.h"
#include "tools/autocomplete.h"
#include "config/preferences.h"
// nicknames
static Autocomplete name_ac;
@@ -116,6 +117,33 @@ roster_get_contact(const char * const barejid)
return contact;
}
char *
roster_get_msg_display_name(const char * const barejid, const char * const resource)
{
GString *result = g_string_new("");
PContact contact = roster_get_contact(barejid);
if (contact != NULL) {
if (p_contact_name(contact) != NULL) {
g_string_append(result, p_contact_name(contact));
} else {
g_string_append(result, barejid);
}
} else {
g_string_append(result, barejid);
}
if (resource && prefs_get_boolean(PREF_RESOURCE_MESSAGE)) {
g_string_append(result, "/");
g_string_append(result, resource);
}
char *result_str = result->str;
g_string_free(result, FALSE);
return result_str;
}
gboolean
roster_contact_offline(const char * const barejid,
const char * const resource, const char * const status)