mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Handle software version requests for gateways that return from domainpart
This commit is contained in:
parent
2a92169351
commit
ac3e7dd9e8
@ -302,7 +302,7 @@ iq_send_software_version(const char * const fulljid)
|
|||||||
xmpp_stanza_t *iq = stanza_create_software_version_iq(ctx, fulljid);
|
xmpp_stanza_t *iq = stanza_create_software_version_iq(ctx, fulljid);
|
||||||
|
|
||||||
char *id = xmpp_stanza_get_id(iq);
|
char *id = xmpp_stanza_get_id(iq);
|
||||||
xmpp_id_handler_add(conn, _version_result_handler, id, NULL);
|
xmpp_id_handler_add(conn, _version_result_handler, id, strdup(fulljid));
|
||||||
|
|
||||||
xmpp_send(conn, iq);
|
xmpp_send(conn, iq);
|
||||||
xmpp_stanza_release(iq);
|
xmpp_stanza_release(iq);
|
||||||
@ -893,13 +893,19 @@ _version_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
|||||||
presence = string_from_resource_presence(occupant->presence);
|
presence = string_from_resource_presence(occupant->presence);
|
||||||
} else {
|
} else {
|
||||||
PContact contact = roster_get_contact(jidp->barejid);
|
PContact contact = roster_get_contact(jidp->barejid);
|
||||||
|
if (!contact) {
|
||||||
|
jid_destroy(jidp);
|
||||||
|
jidp = jid_create((char*)userdata);
|
||||||
|
contact = roster_get_contact(jidp->barejid);
|
||||||
|
}
|
||||||
Resource *resource = p_contact_get_resource(contact, jidp->resourcepart);
|
Resource *resource = p_contact_get_resource(contact, jidp->resourcepart);
|
||||||
presence = string_from_resource_presence(resource->presence);
|
presence = string_from_resource_presence(resource->presence);
|
||||||
}
|
}
|
||||||
|
|
||||||
cons_show_software_version(jid, presence, name_str, version_str, os_str);
|
cons_show_software_version(jidp->fulljid, presence, name_str, version_str, os_str);
|
||||||
|
|
||||||
jid_destroy(jidp);
|
jid_destroy(jidp);
|
||||||
|
free(userdata);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ int main(int argc, char* argv[]) {
|
|||||||
PROF_FUNC_TEST(send_software_version_request),
|
PROF_FUNC_TEST(send_software_version_request),
|
||||||
PROF_FUNC_TEST(display_software_version_result),
|
PROF_FUNC_TEST(display_software_version_result),
|
||||||
PROF_FUNC_TEST(shows_message_when_software_version_error),
|
PROF_FUNC_TEST(shows_message_when_software_version_error),
|
||||||
|
PROF_FUNC_TEST(display_software_version_result_when_from_domainpart),
|
||||||
};
|
};
|
||||||
|
|
||||||
return run_tests(all_tests);
|
return run_tests(all_tests);
|
||||||
|
@ -242,6 +242,7 @@ presence_received(void **state)
|
|||||||
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Typical use case for gateways that don't support resources
|
||||||
void
|
void
|
||||||
presence_missing_resource_defaults(void **state)
|
presence_missing_resource_defaults(void **state)
|
||||||
{
|
{
|
||||||
|
@ -82,3 +82,31 @@ shows_message_when_software_version_error(void **state)
|
|||||||
|
|
||||||
prof_output_exact("Could not get software version: service-unavailable");
|
prof_output_exact("Could not get software version: service-unavailable");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Typical use case for gateways that don't support resources
|
||||||
|
void
|
||||||
|
display_software_version_result_when_from_domainpart(void **state)
|
||||||
|
{
|
||||||
|
prof_connect();
|
||||||
|
stbbr_send(
|
||||||
|
"<presence to=\"stabber@localhost\" from=\"buddy1@localhost\">"
|
||||||
|
"<priority>10</priority>"
|
||||||
|
"<status>I'm here</status>"
|
||||||
|
"</presence>"
|
||||||
|
);
|
||||||
|
prof_output_exact("Buddy1 is online, \"I'm here\"");
|
||||||
|
|
||||||
|
stbbr_for_query("jabber:iq:version",
|
||||||
|
"<iq id=\"*\" type=\"result\" lang=\"en\" to=\"stabber@localhost/profanity\" from=\"localhost\">"
|
||||||
|
"<query xmlns=\"jabber:iq:version\">"
|
||||||
|
"<name>Some Gateway</name>"
|
||||||
|
"<version>1.0</version>"
|
||||||
|
"</query>"
|
||||||
|
"</iq>"
|
||||||
|
);
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
void send_software_version_request(void **state);
|
void send_software_version_request(void **state);
|
||||||
void display_software_version_result(void **state);
|
void display_software_version_result(void **state);
|
||||||
void shows_message_when_software_version_error(void **state);
|
void shows_message_when_software_version_error(void **state);
|
||||||
|
void display_software_version_result_when_from_domainpart(void **state);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user