about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-08-31 15:07:05 +0100
committerJames Booth <boothj5@gmail.com>2013-08-31 15:07:05 +0100
commit694e332384a9dc0794c778ce6d6400ae5fa35c20 (patch)
treedbc07c41c208c08bbb73503adff6a0bc401bbab4
parent4ae817cd8292f964ef1c45bfa3b70544ce23043f (diff)
downloadprofani-tty-694e332384a9dc0794c778ce6d6400ae5fa35c20.tar.gz
Show only nick or jid in /wins output
-rw-r--r--src/contact.c10
-rw-r--r--src/contact.h1
-rw-r--r--src/ui/windows.c15
3 files changed, 17 insertions, 9 deletions
diff --git a/src/contact.c b/src/contact.c
index 1b566d40..9cc992b2 100644
--- a/src/contact.c
+++ b/src/contact.c
@@ -156,6 +156,16 @@ p_contact_name(const PContact contact)
     return contact->name;
 }
 
+const char *
+p_contact_name_or_jid(const PContact contact)
+{
+    if (contact->name != NULL) {
+        return contact->name;
+    } else {
+        return contact->barejid;
+    }
+}
+
 static Resource *
 _highest_presence(Resource *first, Resource *second)
 {
diff --git a/src/contact.h b/src/contact.h
index 141587a0..e71e0f7d 100644
--- a/src/contact.h
+++ b/src/contact.h
@@ -35,6 +35,7 @@ gboolean p_contact_remove_resource(PContact contact, const char * const resource
 void p_contact_free(PContact contact);
 const char* p_contact_barejid(PContact contact);
 const char* p_contact_name(PContact contact);
+const char * p_contact_name_or_jid(const PContact contact);
 const char* p_contact_presence(PContact contact);
 const char* p_contact_status(PContact contact);
 const char* p_contact_subscription(const PContact contact);
diff --git a/src/ui/windows.c b/src/ui/windows.c
index e956068c..e69b2433 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -391,16 +391,13 @@ wins_create_summary(void)
                 break;
             case WIN_CHAT:
                 chat_string = g_string_new("");
-                g_string_printf(chat_string, "%d: Chat %s", ui_index, window->from);
-                PContact contact = roster_get_contact(window->from);
 
-                if (contact != NULL) {
-                    if (p_contact_name(contact) != NULL) {
-                        GString *chat_name = g_string_new("");
-                        g_string_printf(chat_name, " (%s)", p_contact_name(contact));
-                        g_string_append(chat_string, chat_name->str);
-                        g_string_free(chat_name, TRUE);
-                    }
+                PContact contact = roster_get_contact(window->from);
+                if (contact == NULL) {
+                    g_string_printf(chat_string, "%d: Chat %s", ui_index, window->from);
+                } else {
+                    const char *display_name = p_contact_name_or_jid(contact);
+                    g_string_printf(chat_string, "%d: Chat %s", ui_index, display_name);
                     GString *chat_presence = g_string_new("");
                     g_string_printf(chat_presence, " - %s", p_contact_presence(contact));
                     g_string_append(chat_string, chat_presence->str);
1' href='#n241'>241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317