Added roster list function to get display name for messages
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user