mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge branch 'master' into osx-functional
Conflicts: tests/functionaltests/proftest.c
This commit is contained in:
commit
cc6f36e253
@ -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());
|
||||
|
@ -421,30 +421,6 @@ cons_show_caps(const char * const fulljid, resource_presence_t presence)
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -558,7 +534,7 @@ cons_show_disco_info(const char *jid, GSList *identities, GSList *features)
|
||||
if ((identities && (g_slist_length(identities) > 0)) ||
|
||||
(features && (g_slist_length(features) > 0))) {
|
||||
cons_show("");
|
||||
cons_show("Service disovery info for %s", jid);
|
||||
cons_show("Service discovery info for %s", jid);
|
||||
|
||||
if (identities) {
|
||||
cons_show(" Identities");
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -77,7 +77,6 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
PROF_FUNC_TEST(send_receipt_request),
|
||||
PROF_FUNC_TEST(send_receipt_on_request),
|
||||
|
||||
PROF_FUNC_TEST(sends_new_item),
|
||||
PROF_FUNC_TEST(sends_new_item_nick),
|
||||
PROF_FUNC_TEST(sends_remove_item),
|
||||
@ -87,6 +86,8 @@ int main(int argc, char* argv[]) {
|
||||
PROF_FUNC_TEST(display_software_version_result),
|
||||
PROF_FUNC_TEST(shows_message_when_software_version_error),
|
||||
PROF_FUNC_TEST(display_software_version_result_when_from_domainpart),
|
||||
PROF_FUNC_TEST(show_message_in_chat_window_when_no_resource),
|
||||
PROF_FUNC_TEST(display_software_version_result_in_chat),
|
||||
};
|
||||
|
||||
return run_tests(all_tests);
|
||||
|
@ -185,8 +185,7 @@ init_prof_test(void **state)
|
||||
assert_true(prof_output_exact("Word wrap disabled"));
|
||||
prof_input("/roster hide");
|
||||
assert_true(prof_output_exact("Roster disabled"));
|
||||
prof_input("/time statusbar off");
|
||||
assert_true(prof_output_exact("Status bar time display disabled"));
|
||||
prof_input("/time main off");
|
||||
prof_input("/time main off");
|
||||
assert_true(prof_output_exact("Time display disabled"));
|
||||
}
|
||||
|
@ -53,9 +53,9 @@ display_software_version_result(void **state)
|
||||
);
|
||||
prof_input("/software buddy1@localhost/mobile");
|
||||
|
||||
prof_output_exact("buddy1@localhost/mobile:");
|
||||
prof_output_exact("Name : Profanity");
|
||||
prof_output_exact("Version : 0.4.7dev.master.2cb2f83");
|
||||
// assert_true(prof_output_exact("buddy1@localhost/mobile:"));
|
||||
// assert_true(prof_output_exact("Name : Profanity"));
|
||||
assert_true(prof_output_exact("Version : 0.4.7dev.master.2cb2f83"));
|
||||
}
|
||||
|
||||
void
|
||||
@ -80,7 +80,7 @@ shows_message_when_software_version_error(void **state)
|
||||
);
|
||||
prof_input("/software buddy1@localhost/laptop");
|
||||
|
||||
prof_output_exact("Could not get software version: service-unavailable");
|
||||
assert_true(prof_output_exact("Could not get software version: service-unavailable"));
|
||||
}
|
||||
|
||||
// Typical use case for gateways that don't support resources
|
||||
@ -106,7 +106,61 @@ display_software_version_result_when_from_domainpart(void **state)
|
||||
);
|
||||
prof_input("/software buddy1@localhost/__prof_default");
|
||||
|
||||
prof_output_exact("buddy1@localhost/__prof_default:");
|
||||
prof_output_exact("Name : Some Gateway");
|
||||
prof_output_exact("Version : 1.0");
|
||||
// assert_true(prof_output_exact("buddy1@localhost/__prof_default:"));
|
||||
// assert_true(prof_output_exact("Name : Some Gateway"));
|
||||
assert_true(prof_output_exact("Version : 1.0"));
|
||||
}
|
||||
|
||||
void
|
||||
show_message_in_chat_window_when_no_resource(void **state)
|
||||
{
|
||||
prof_connect();
|
||||
stbbr_send(
|
||||
"<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>"
|
||||
);
|
||||
prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"");
|
||||
|
||||
prof_input("/msg Buddy1");
|
||||
prof_input("/software");
|
||||
|
||||
assert_true(prof_output_exact("Unknown resource for /software command."));
|
||||
}
|
||||
|
||||
void
|
||||
display_software_version_result_in_chat(void **state)
|
||||
{
|
||||
prof_connect();
|
||||
stbbr_send(
|
||||
"<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>"
|
||||
);
|
||||
prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"");
|
||||
prof_input("/msg Buddy1");
|
||||
|
||||
stbbr_send(
|
||||
"<message id=\"message1\" to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\" type=\"chat\">"
|
||||
"<body>Here's a message</body>"
|
||||
"</message>"
|
||||
);
|
||||
prof_output_exact("Here's a message");
|
||||
|
||||
stbbr_for_query("jabber:iq:version",
|
||||
"<iq id=\"*\" type=\"result\" lang=\"en\" to=\"stabber@localhost/profanity\" from=\"buddy1@localhost/mobile\">"
|
||||
"<query xmlns=\"jabber:iq:version\">"
|
||||
"<name>Profanity</name>"
|
||||
"<version>0.4.7dev.master.2cb2f83</version>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
|
||||
prof_input("/software");
|
||||
|
||||
// assert_true(prof_output_exact("buddy1@localhost/mobile:"));
|
||||
// assert_true(prof_output_exact("Name : Profanity"));
|
||||
assert_true(prof_output_exact("Version : 0.4.7dev.master.2cb2f83"));
|
||||
}
|
||||
|
@ -2,4 +2,6 @@ void send_software_version_request(void **state);
|
||||
void display_software_version_result(void **state);
|
||||
void shows_message_when_software_version_error(void **state);
|
||||
void display_software_version_result_when_from_domainpart(void **state);
|
||||
void show_message_in_chat_window_when_no_resource(void **state);
|
||||
void display_software_version_result_in_chat(void **state);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user