about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-05-07 22:06:02 +0100
committerJames Booth <boothj5@gmail.com>2015-05-07 22:06:02 +0100
commit8673488368250314b6e58ed2fb00eeb6d4ce2948 (patch)
treebf7913d6b7425dcf07c6bd1af96a1379f1cbe863 /src/ui
parent8c347de298609b647cb1243e13125affa96491f3 (diff)
parenta2c62117322eea58c17231c27c5ee3b41900ea81 (diff)
downloadprofani-tty-8673488368250314b6e58ed2fb00eeb6d4ce2948.tar.gz
Merge branch 'master' into openpgp
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/core.c36
-rw-r--r--src/ui/ui.h1
2 files changed, 37 insertions, 0 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index 06dd84e3..cb295244 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -320,6 +320,42 @@ ui_chat_win_exists(const char * const barejid)
 }
 
 void
+ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity)
+{
+    char *show_console = prefs_get_string(PREF_STATUSES_CONSOLE);
+    char *show_chat_win = prefs_get_string(PREF_STATUSES_CHAT);
+    PContact contact = roster_get_contact(barejid);
+
+    // show nothing
+    if (g_strcmp0(p_contact_subscription(contact), "none") == 0) {
+        free(show_console);
+        free(show_chat_win);
+        return;
+    }
+
+    // show in console if "all"
+    if (g_strcmp0(show_console, "all") == 0) {
+        cons_show_contact_online(contact, resource, last_activity);
+
+    // show in console of "online" and presence online
+    } else if (g_strcmp0(show_console, "online") == 0 && resource->presence == RESOURCE_ONLINE) {
+        cons_show_contact_online(contact, resource, last_activity);
+    }
+
+    // show in chat win if "all"
+    if (g_strcmp0(show_chat_win, "all") == 0) {
+        ui_chat_win_contact_online(contact, resource, last_activity);
+
+    // show in char win if "online" and presence online
+    } else if (g_strcmp0(show_chat_win, "online") == 0 && resource->presence == RESOURCE_ONLINE) {
+        ui_chat_win_contact_online(contact, resource, last_activity);
+    }
+
+    free(show_console);
+    free(show_chat_win);
+}
+
+void
 ui_contact_typing(const char * const barejid, const char * const resource)
 {
     ProfChatWin *chatwin = wins_get_chat(barejid);
diff --git a/src/ui/ui.h b/src/ui/ui.h
index c98d45e8..48b8d393 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -112,6 +112,7 @@ char * ui_ask_password(void);
 void ui_handle_stanza(const char * const msg);
 
 // ui events
+void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity);
 void ui_contact_typing(const char * const barejid, const char * const resource);
 void ui_incoming_msg(const char * const from, const char * const resource,  const char * const message, GTimeVal *tv_stamp);
 void ui_incoming_private_msg(const char * const fulljid, const char * const message, GTimeVal *tv_stamp);