diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/chatwin.c | 26 | ||||
-rw-r--r-- | src/ui/console.c | 9 | ||||
-rw-r--r-- | src/ui/mucconfwin.c | 17 | ||||
-rw-r--r-- | src/ui/mucwin.c | 17 | ||||
-rw-r--r-- | src/ui/privwin.c | 18 | ||||
-rw-r--r-- | src/ui/ui.h | 8 | ||||
-rw-r--r-- | src/ui/window.c | 41 | ||||
-rw-r--r-- | src/ui/xmlwin.c | 8 |
8 files changed, 144 insertions, 0 deletions
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 2875256d..ba66c7ae 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -355,6 +355,32 @@ chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status) free(display_str); } +char* +chatwin_get_string(ProfChatWin *chatwin) +{ + assert(chatwin != NULL); + + GString *res = g_string_new("Chat "); + + PContact contact = roster_get_contact(chatwin->barejid); + if (contact == NULL) { + g_string_append(res, chatwin->barejid); + } else { + const char *display_name = p_contact_name_or_jid(contact); + g_string_append(res, display_name); + g_string_append_printf(res, " - %s", p_contact_presence(contact)); + } + + if (chatwin->unread > 0) { + g_string_append_printf(res, ", %d unread", chatwin->unread); + } + + char *resstr = res->str; + g_string_free(res, FALSE); + + return resstr; +} + static void _chatwin_history(ProfChatWin *chatwin, const char *const contact) { diff --git a/src/ui/console.c b/src/ui/console.c index 4d155afb..28fba4cd 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -35,6 +35,7 @@ #include <string.h> #include <stdlib.h> +#include <assert.h> #ifdef HAVE_NCURSESW_NCURSES_H #include <ncursesw/ncurses.h> @@ -1901,6 +1902,14 @@ cons_alert(void) } } +char* +cons_get_string(ProfConsoleWin *conswin) +{ + assert(conswin != NULL); + + return strdup("Console"); +} + void cons_theme_colours(void) { diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index dd614306..c262ae0e 100644 --- a/src/ui/mucconfwin.c +++ b/src/ui/mucconfwin.c @@ -328,3 +328,20 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) break; } } + +char* +mucconfwin_get_string(ProfMucConfWin *confwin) +{ + assert(confwin != NULL); + + GString *res = g_string_new(""); + + char *title = win_get_title((ProfWin*)confwin); + g_string_append(res, title); + free(title); + + char *resstr = res->str; + g_string_free(res, FALSE); + + return resstr; +} diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 097e9589..432256de 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -773,3 +773,20 @@ mucwin_hide_occupants(ProfMucWin *mucwin) } } +char* +mucwin_get_string(ProfMucWin *mucwin) +{ + assert(mucwin != NULL); + + GString *res = g_string_new("Room "); + g_string_append(res, mucwin->roomjid); + + if (mucwin->unread > 0) { + g_string_append_printf(res, ", %d unread", mucwin->unread); + } + + char *resstr = res->str; + g_string_free(res, FALSE); + + return resstr; +} diff --git a/src/ui/privwin.c b/src/ui/privwin.c index 204335bd..77a0a92d 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -107,3 +107,21 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message) win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); } + +char* +privwin_get_string(ProfPrivateWin *privwin) +{ + assert(privwin != NULL); + + GString *res = g_string_new("Private "); + g_string_append(res, privwin->fulljid); + + if (privwin->unread > 0) { + g_string_append_printf(res, ", %d unread", privwin->unread); + } + + char *resstr = res->str; + g_string_free(res, FALSE); + + return resstr; +} diff --git a/src/ui/ui.h b/src/ui/ui.h index 458255f1..c445452d 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -134,6 +134,8 @@ void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message); void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity); void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status); +char* chatwin_get_string(ProfChatWin *chatwin); + #ifdef HAVE_LIBOTR void chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted); void chatwin_otr_unsecured(ProfChatWin *chatwin); @@ -187,10 +189,12 @@ void mucwin_role_set_error(ProfMucWin *mucwin, const char *const nick, const cha void mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *const error); void mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks); void mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const error); +char* mucwin_get_string(ProfMucWin *mucwin); // MUC private chat window void privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp); void privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message); +char* privwin_get_string(ProfPrivateWin *privwin); // MUC room config window void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form); @@ -198,9 +202,11 @@ void mucconfwin_show_form(ProfMucConfWin *confwin); void mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag); void mucconfwin_form_help(ProfMucConfWin *confwin); void mucconfwin_field_help(ProfMucConfWin *confwin, char *tag); +char* mucconfwin_get_string(ProfMucConfWin *confwin); // xml console void xmlwin_show(ProfXMLWin *xmlwin, const char *const msg); +char* xmlwin_get_string(ProfXMLWin *xmlwin); // Input window char* inp_readline(void); @@ -232,6 +238,7 @@ void cons_show_contacts(GSList *list); void cons_show_roster(GSList *list); void cons_show_roster_group(const char *const group, GSList *list); void cons_show_wins(void); +char* cons_get_string(ProfConsoleWin *conswin); void cons_show_status(const char *const barejid); void cons_show_info(PContact pcontact); void cons_show_caps(const char *const fulljid, resource_presence_t presence); @@ -336,6 +343,7 @@ void win_show_info(ProfWin *window, PContact contact); void win_println(ProfWin *window, int pad, const char *const message); void win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...); void win_clear(ProfWin *window); +char* win_get_string(ProfWin *window); // desktop notifications void notifier_initialise(void); diff --git a/src/ui/window.c b/src/ui/window.c index d6500a67..039d4770 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -285,6 +285,47 @@ win_get_title(ProfWin *window) return NULL; } +char* +win_get_string(ProfWin *window) +{ + assert(window != NULL); + + switch (window->type) { + case WIN_CONSOLE: + { + ProfConsoleWin *conswin = (ProfConsoleWin*)window; + return cons_get_string(conswin); + } + case WIN_CHAT: + { + ProfChatWin *chatwin = (ProfChatWin*)window; + return chatwin_get_string(chatwin); + } + case WIN_MUC: + { + ProfMucWin *mucwin = (ProfMucWin*)window; + return mucwin_get_string(mucwin); + } + case WIN_MUC_CONFIG: + { + ProfMucConfWin *mucconfwin = (ProfMucConfWin*)window; + return mucconfwin_get_string(mucconfwin); + } + case WIN_PRIVATE: + { + ProfPrivateWin *privwin = (ProfPrivateWin*)window; + return privwin_get_string(privwin); + } + case WIN_XML: + { + ProfXMLWin *xmlwin = (ProfXMLWin*)window; + return xmlwin_get_string(xmlwin); + } + default: + return NULL; + } +} + void win_hide_subwin(ProfWin *window) { diff --git a/src/ui/xmlwin.c b/src/ui/xmlwin.c index 31921390..b19586bb 100644 --- a/src/ui/xmlwin.c +++ b/src/ui/xmlwin.c @@ -53,3 +53,11 @@ xmlwin_show(ProfXMLWin *xmlwin, const char *const msg) win_print(window, '-', 0, NULL, 0, THEME_AWAY, "", ""); } } + +char* +xmlwin_get_string(ProfXMLWin *xmlwin) +{ + assert(xmlwin != NULL); + + return strdup("XML console"); +} |