Commit dbfccafd authored by Mohammed Sadiq's avatar Mohammed Sadiq
Browse files

message: Add API to get/set custom name

parent afcadfaa
......@@ -16,6 +16,7 @@
#include "chatty-message.h"
#include "chatty-utils.h"
* SECTION: chatty-message
......@@ -29,6 +30,7 @@ struct _ChattyMessage
GObject parent_instance;
ChattyItem *user;
char *user_name;
char *user_alias;
char *message;
char *uid;
......@@ -56,6 +58,7 @@ chatty_message_finalize (GObject *object)
g_free (self->message);
g_free (self->uid);
g_free (self->user_alias);
g_free (self->user_name);
g_free (self->id);
G_OBJECT_CLASS (chatty_message_parent_class)->finalize (object);
......@@ -161,6 +164,35 @@ chatty_message_get_user (ChattyMessage *self)
return self->user;
const char *
chatty_message_get_user_name (ChattyMessage *self)
const char *user_name = NULL;
g_return_val_if_fail (CHATTY_IS_MESSAGE (self), "");
if (!self->user_name && self->user)
user_name = chatty_item_get_name (self->user);
if (user_name)
self->user_name = chatty_utils_jabber_id_strip (user_name);
if (self->user_name)
return self->user_name;
return "";
chatty_message_set_user_name (ChattyMessage *self,
const char *user_name)
g_return_if_fail (CHATTY_IS_MESSAGE (self));
g_free (self->user_name);
self->user_name = g_strdup (user_name);
const char *
chatty_message_get_user_alias (ChattyMessage *self)
......@@ -37,6 +37,9 @@ void chatty_message_set_id (ChattyMessage *self,
const char *id);
const char *chatty_message_get_text (ChattyMessage *self);
ChattyItem *chatty_message_get_user (ChattyMessage *self);
const char *chatty_message_get_user_name (ChattyMessage *self);
void chatty_message_set_user_name (ChattyMessage *self,
const char *user_name);
const char *chatty_message_get_user_alias (ChattyMessage *self);
time_t chatty_message_get_time (ChattyMessage *self);
ChattyMsgStatus chatty_message_get_status (ChattyMessage *self);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment