diff options
author | James Booth <boothj5@gmail.com> | 2015-08-06 01:56:52 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-08-06 01:56:52 +0100 |
commit | 406b821b35797081936be3a5c51a35ac23a1ca92 (patch) | |
tree | 2f36178cf7a870ff96e64abb056778d429bb646e /src | |
parent | b75bc660b4109ce06ff38afc1e9574904523e9a3 (diff) | |
download | profani-tty-406b821b35797081936be3a5c51a35ac23a1ca92.tar.gz |
Show software version result in current window
Diffstat (limited to 'src')
-rw-r--r-- | src/command/commands.c | 24 | ||||
-rw-r--r-- | src/ui/console.c | 24 | ||||
-rw-r--r-- | src/ui/core.c | 51 | ||||
-rw-r--r-- | src/ui/ui.h | 2 | ||||
-rw-r--r-- | src/xmpp/iq.c | 2 |
5 files changed, 78 insertions, 25 deletions
diff --git a/src/command/commands.c b/src/command/commands.c index ede1b395..5e7146fc 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2104,6 +2104,30 @@ cmd_software(ProfWin *window, const char * const command, gchar **args) } break; case WIN_CHAT: + if (args[0]) { + cons_show("No parameter needed to /software when in chat."); + } else { + ProfChatWin *chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + + char *resource = NULL; + ChatSession *session = chat_session_get(chatwin->barejid); + if (chatwin->resource_override) { + resource = chatwin->resource_override; + } else if (session && session->resource) { + resource = session->resource; + } + + if (resource) { + GString *fulljid = g_string_new(chatwin->barejid); + g_string_append_printf(fulljid, "/%s", resource); + iq_send_software_version(fulljid->str); + g_string_free(fulljid, TRUE); + } else { + win_println(window, 0, "Unknown resource for /software command."); + } + } + break; case WIN_CONSOLE: if (args[0]) { Jid *myJid = jid_create(jabber_get_fulljid()); diff --git a/src/ui/console.c b/src/ui/console.c index dcf7e920..6497e809 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -422,30 +422,6 @@ cons_show_caps(const char * const fulljid, resource_presence_t presence) } void -cons_show_software_version(const char * const jid, const char * const presence, - const char * const name, const char * const version, const char * const os) -{ - ProfWin *console = wins_get_console(); - if (name || version || os) { - cons_show(""); - theme_item_t presence_colour = theme_main_presence_attrs(presence); - win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", jid); - win_print(console, '-', 0, NULL, NO_DATE, 0, "", ":"); - } - if (name) { - cons_show("Name : %s", name); - } - if (version) { - cons_show("Version : %s", version); - } - if (os) { - cons_show("OS : %s", os); - } - - cons_alert(); -} - -void cons_show_received_subs(void) { GSList *received = presence_get_subscription_requests(); diff --git a/src/ui/core.c b/src/ui/core.c index 9cbd873a..890d5d1d 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -2810,6 +2810,57 @@ ui_handle_software_version_error(const char * const roomjid, const char * const g_string_free(message_str, TRUE); } +void +ui_show_software_version(const char * const jid, const char * const presence, + const char * const name, const char * const version, const char * const os) +{ + Jid *jidp = jid_create(jid); + ProfWin *window = NULL; + ProfWin *chatwin = (ProfWin*)wins_get_chat(jidp->barejid); + ProfWin *mucwin = (ProfWin*)wins_get_muc(jidp->barejid); + ProfWin *privwin = (ProfWin*)wins_get_private(jidp->fulljid); + ProfWin *console = wins_get_console(); + jid_destroy(jidp); + + if (chatwin) { + if (wins_is_current(chatwin)) { + window = chatwin; + } else { + window = console; + } + } else if (privwin) { + if (wins_is_current(privwin)) { + window = privwin; + } else { + window = console; + } + } else if (mucwin) { + if (wins_is_current(mucwin)) { + window = mucwin; + } else { + window = console; + } + } else { + window = console; + } + + if (name || version || os) { + win_println(window, 0, ""); + theme_item_t presence_colour = theme_main_presence_attrs(presence); + win_vprint(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", jid); + win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); + } + if (name) { + win_vprint(window, '-', 0, NULL, 0, 0, "", "Name : %s", name); + } + if (version) { + win_vprint(window, '-', 0, NULL, 0, 0, "", "Version : %s", version); + } + if (os) { + win_vprint(window, '-', 0, NULL, 0, 0, "", "OS : %s", os); + } +} + static void _win_show_history(ProfChatWin *chatwin, const char * const contact) { diff --git a/src/ui/ui.h b/src/ui/ui.h index d22a5c7f..cfda6384 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -204,6 +204,8 @@ void ui_show_all_room_rosters(void); void ui_hide_all_room_rosters(void); gboolean ui_chat_win_exists(const char * const barejid); void ui_handle_software_version_error(const char * const roomjid, const char * const message); +void ui_show_software_version(const char * const jid, const char * const presence, + const char * const name, const char * const version, const char * const os); gboolean ui_tidy_wins(void); void ui_prune_wins(void); diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index a07fbf73..ff684b60 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -905,7 +905,7 @@ _version_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, presence = string_from_resource_presence(resource->presence); } - cons_show_software_version(jidp->fulljid, presence, name_str, version_str, os_str); + ui_show_software_version(jidp->fulljid, presence, name_str, version_str, os_str); jid_destroy(jidp); free(userdata); |