about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-05-20 22:51:35 +0100
committerJames Booth <boothj5@gmail.com>2013-05-20 22:51:35 +0100
commitecc62af3053496e283abb581c49cf1fd0e6cd06a (patch)
treefd7a9bb5214a7028bfdb13ef03067e6ed403c376
parent4a8db64d7a8baebac732b3c50e1c5184cddc522f (diff)
downloadprofani-tty-ecc62af3053496e283abb581c49cf1fd0e6cd06a.tar.gz
Finished handle usage
-rw-r--r--src/command/command.c13
-rw-r--r--src/ui/console.c18
-rw-r--r--src/ui/core.c41
-rw-r--r--src/ui/notifier.c12
-rw-r--r--src/ui/notifier.h4
-rw-r--r--src/ui/ui.h6
6 files changed, 65 insertions, 29 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 163e5cc8..7e0c05a5 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -2017,6 +2017,12 @@ _cmd_roster(gchar **args, struct cmd_help_t help)
         }
 
         roster_change_handle(jid, handle);
+
+        if (handle == NULL) {
+            cons_show("Nickname for %s removed.", jid);
+        } else {
+            cons_show("Nickname for %s set to: %s.", jid, handle);
+        }
         return TRUE;
     }
 }
@@ -2064,6 +2070,7 @@ static gboolean
 _cmd_status(gchar **args, struct cmd_help_t help)
 {
     char *usr = args[0];
+    char *usr_jid = NULL;
 
     jabber_conn_status_t conn_status = jabber_get_connection_status();
     win_type_t win_type = ui_current_win_type();
@@ -2098,7 +2105,11 @@ _cmd_status(gchar **args, struct cmd_help_t help)
             break;
         case WIN_CONSOLE:
             if (usr != NULL) {
-                cons_show_status(usr);
+                usr_jid = roster_jid_from_handle(usr);
+                if (usr_jid == NULL) {
+                    usr_jid = usr;
+                }
+                cons_show_status(usr_jid);
             } else {
                 cons_show("Usage: %s", help.usage);
             }
diff --git a/src/ui/console.c b/src/ui/console.c
index 77000bc8..16c5cb11 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -122,11 +122,19 @@ cons_show_error(const char * const msg, ...)
 }
 
 void
-cons_show_typing(const char * const short_from)
+cons_show_typing(const char * const barejid)
 {
+    PContact contact = roster_get_contact(barejid);
+    const char * display_usr = NULL;
+    if (p_contact_name(contact) != NULL) {
+        display_usr = p_contact_name(contact);
+    } else {
+        display_usr = barejid;
+    }
+
     win_print_time(console, '-');
     wattron(console->win, COLOUR_TYPING);
-    wprintw(console->win, "!! %s is typing a message...\n", short_from);
+    wprintw(console->win, "!! %s is typing a message...\n", display_usr);
     wattroff(console->win, COLOUR_TYPING);
 
     ui_console_dirty();
@@ -704,14 +712,14 @@ cons_show_disco_items(GSList *items, const char * const jid)
 }
 
 void
-cons_show_status(const char * const contact)
+cons_show_status(const char * const barejid)
 {
-    PContact pcontact = roster_get_contact(contact);
+    PContact pcontact = roster_get_contact(barejid);
 
     if (pcontact != NULL) {
         win_show_contact(console, pcontact);
     } else {
-        cons_show("No such contact \"%s\" in roster.", contact);
+        cons_show("No such contact \"%s\" in roster.", barejid);
     }
     ui_console_dirty();
     _cons_alert();
diff --git a/src/ui/core.c b/src/ui/core.c
index 9c640b8e..8b9cfa21 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -226,18 +226,18 @@ ui_duck_exists(void)
 }
 
 void
-ui_contact_typing(const char * const from)
+ui_contact_typing(const char * const barejid)
 {
-    int win_index = _find_prof_win_index(from);
+    int win_index = _find_prof_win_index(barejid);
 
     if (prefs_get_boolean(PREF_INTYPE)) {
         // no chat window for user
         if (win_index == NUM_WINS) {
-            cons_show_typing(from);
+            cons_show_typing(barejid);
 
         // have chat window but not currently in it
         } else if (win_index != current_index) {
-            cons_show_typing(from);
+            cons_show_typing(barejid);
             current_win_dirty = TRUE;
 
         // in chat window with user
@@ -250,8 +250,16 @@ ui_contact_typing(const char * const from)
        }
     }
 
-    if (prefs_get_boolean(PREF_NOTIFY_TYPING))
-        notify_typing(from);
+    if (prefs_get_boolean(PREF_NOTIFY_TYPING)) {
+        PContact contact = roster_get_contact(barejid);
+        char const *display_usr = NULL;
+        if (p_contact_name(contact) != NULL) {
+            display_usr = p_contact_name(contact);
+        } else {
+            display_usr = barejid;
+        }
+        notify_typing(display_usr);
+    }
 }
 
 void
@@ -490,7 +498,8 @@ ui_contact_offline(const char * const from, const char * const show,
     _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(jidp->barejid);
+    cons_debug("INDEX %d", win_index);
     if (win_index != NUM_WINS) {
         ProfWin *window = windows[win_index];
         _show_status_string(window, display_str->str, show, status, NULL, "--",
@@ -802,21 +811,29 @@ ui_print_system_msg_from_recipient(const char * const from, const char *message)
 }
 
 void
-ui_recipient_gone(const char * const from)
+ui_recipient_gone(const char * const barejid)
 {
     int win_index;
     ProfWin *window;
 
-    if (from == NULL)
+    if (barejid == NULL)
         return;
 
-    win_index = _find_prof_win_index(from);
+    PContact contact = roster_get_contact(barejid);
+    const char * display_usr = NULL;
+    if (p_contact_name(contact) != NULL) {
+        display_usr = p_contact_name(contact);
+    } else {
+        display_usr = barejid;
+    }
+
+    win_index = _find_prof_win_index(barejid);
     // chat window exists
     if (win_index < NUM_WINS) {
         window = windows[win_index];
-        win_print_time(window, '-');
+        win_print_time(window, '!');
         wattron(window->win, COLOUR_GONE);
-        wprintw(window->win, "*%s ", from);
+        wprintw(window->win, "<- %s ", display_usr);
         wprintw(window->win, "has left the conversation.");
         wprintw(window->win, "\n");
         wattroff(window->win, COLOUR_GONE);
diff --git a/src/ui/notifier.c b/src/ui/notifier.c
index 0a4cd6d2..2b114569 100644
--- a/src/ui/notifier.c
+++ b/src/ui/notifier.c
@@ -58,10 +58,10 @@ notifier_uninit(void)
 }
 
 void
-notify_typing(const char * const from)
+notify_typing(const char * const handle)
 {
-    char message[strlen(from) + 1 + 11];
-    sprintf(message, "%s: typing...", from);
+    char message[strlen(handle) + 1 + 11];
+    sprintf(message, "%s: typing...", handle);
 
     _notify(message, 10000, "Incoming message");
 }
@@ -84,10 +84,10 @@ notify_invite(const char * const from, const char * const room,
 }
 
 void
-notify_message(const char * const short_from)
+notify_message(const char * const handle)
 {
-    char message[strlen(short_from) + 1 + 10];
-    sprintf(message, "%s: message.", short_from);
+    char message[strlen(handle) + 1 + 10];
+    sprintf(message, "%s: message.", handle);
 
     _notify(message, 10000, "Incoming message");
 }
diff --git a/src/ui/notifier.h b/src/ui/notifier.h
index a8c2250f..0995e8ba 100644
--- a/src/ui/notifier.h
+++ b/src/ui/notifier.h
@@ -23,8 +23,8 @@
 void notifier_init(void);
 void notifier_uninit(void);
 
-void notify_typing(const char * const from);
-void notify_message(const char * const short_from);
+void notify_typing(const char * const handle);
+void notify_message(const char * const handle);
 void notify_remind(void);
 void notify_invite(const char * const from, const char * const room,
     const char * const reason);
diff --git a/src/ui/ui.h b/src/ui/ui.h
index c724f9ae..87eef05b 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -91,7 +91,7 @@ void ui_contact_online(const char * const barejid, const char * const resource,
 void ui_contact_offline(const char * const from, const char * const show,
     const char * const status);
 void ui_disconnected(void);
-void ui_recipient_gone(const char * const from);
+void ui_recipient_gone(const char * const barejid);
 void ui_outgoing_msg(const char * const from, const char * const to,
     const char * const message);
 void ui_room_join(Jid *jid);
@@ -166,7 +166,7 @@ void cons_show_error(const char * const cmd, ...);
 void cons_highlight_show(const char * const cmd);
 void cons_show_contacts(GSList * list);
 void cons_show_wins(void);
-void cons_show_status(const char * const contact);
+void cons_show_status(const char * const barejid);
 void cons_show_info(PContact pcontact);
 void cons_show_caps(const char * const contact, Resource *resource);
 void cons_show_themes(GSList *themes);
@@ -181,7 +181,7 @@ void cons_show_disco_info(const char *from, GSList *identities, GSList *features
 void cons_show_room_invite(const char * const invitor, const char * const room,
     const char * const reason);
 void cons_check_version(gboolean not_available_msg);
-void cons_show_typing(const char * const short_from);
+void cons_show_typing(const char * const barejid);
 void cons_show_incoming_message(const char * const short_from, const int win_index);
 void cons_show_room_invites(GSList *invites);
 void cons_show_received_subs(void);