mirror of
https://github.com/profanity-im/profanity.git
synced 2025-07-26 12:14:28 -04:00
xep-0092: make it possible to ask servers or components for software
This adds the new `/serversoftware` command. ``` /software user@domain.org/resource /serversoftware domain.org ``` Fix https://github.com/profanity-im/profanity/issues/1338
This commit is contained in:
parent
9243655a22
commit
9c853d9f46
@ -2433,6 +2433,23 @@ static struct cmd_t command_defs[] =
|
|||||||
{ "on|off", "Enable or disable slashguard." })
|
{ "on|off", "Enable or disable slashguard." })
|
||||||
CMD_NOEXAMPLES
|
CMD_NOEXAMPLES
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ "/serversoftware",
|
||||||
|
parse_args, 1, 1, NULL,
|
||||||
|
CMD_NOSUBFUNCS
|
||||||
|
CMD_MAINFUNC(cmd_serversoftware)
|
||||||
|
CMD_TAGS(
|
||||||
|
CMD_TAG_DISCOVERY)
|
||||||
|
CMD_SYN(
|
||||||
|
"/serversoftware <domain>")
|
||||||
|
CMD_DESC(
|
||||||
|
"Find server or component software version information.")
|
||||||
|
CMD_ARGS(
|
||||||
|
{ "<domain>", "The jid of your server or component." })
|
||||||
|
CMD_EXAMPLES(
|
||||||
|
"/software valhalla.edda",
|
||||||
|
"/software xmpp.vanaheimr.edda")
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static GHashTable *search_index;
|
static GHashTable *search_index;
|
||||||
|
@ -3521,6 +3521,25 @@ cmd_software(ProfWin *window, const char *const command, gchar **args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cmd_serversoftware(ProfWin *window, const char *const command, gchar **args)
|
||||||
|
{
|
||||||
|
jabber_conn_status_t conn_status = connection_get_status();
|
||||||
|
|
||||||
|
if (conn_status != JABBER_CONNECTED) {
|
||||||
|
cons_show("You are not currently connected.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0]) {
|
||||||
|
iq_send_software_version(args[0]);
|
||||||
|
} else {
|
||||||
|
cons_show("You must provide a jid to the /serversoftware command.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cmd_join(ProfWin *window, const char *const command, gchar **args)
|
cmd_join(ProfWin *window, const char *const command, gchar **args)
|
||||||
{
|
{
|
||||||
|
@ -231,4 +231,5 @@ gboolean cmd_os(ProfWin *window, const char *const command, gchar **args);
|
|||||||
gboolean cmd_correction(ProfWin *window, const char *const command, gchar **args);
|
gboolean cmd_correction(ProfWin *window, const char *const command, gchar **args);
|
||||||
gboolean cmd_correct(ProfWin *window, const char *const command, gchar **args);
|
gboolean cmd_correct(ProfWin *window, const char *const command, gchar **args);
|
||||||
gboolean cmd_slashguard(ProfWin *window, const char *const command, gchar **args);
|
gboolean cmd_slashguard(ProfWin *window, const char *const command, gchar **args);
|
||||||
|
gboolean cmd_serversoftware(ProfWin *window, const char *const command, gchar **args);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1505,7 +1505,11 @@ _version_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
|||||||
xmpp_ctx_t *ctx = xmpp_conn_get_context(conn);
|
xmpp_ctx_t *ctx = xmpp_conn_get_context(conn);
|
||||||
|
|
||||||
Jid *jidp = jid_create((char*)userdata);
|
Jid *jidp = jid_create((char*)userdata);
|
||||||
|
|
||||||
const char *presence = NULL;
|
const char *presence = NULL;
|
||||||
|
|
||||||
|
// if it has a fulljid it is a regular user (not server or component)
|
||||||
|
if (jidp->fulljid) {
|
||||||
if (muc_active(jidp->barejid)) {
|
if (muc_active(jidp->barejid)) {
|
||||||
Occupant *occupant = muc_roster_item(jidp->barejid, jidp->resourcepart);
|
Occupant *occupant = muc_roster_item(jidp->barejid, jidp->resourcepart);
|
||||||
presence = string_from_resource_presence(occupant->presence);
|
presence = string_from_resource_presence(occupant->presence);
|
||||||
@ -1525,8 +1529,15 @@ _version_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
|||||||
presence = "offline";
|
presence = "offline";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jidp->fulljid) {
|
||||||
|
// regular user
|
||||||
ui_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);
|
||||||
|
} else {
|
||||||
|
// server or component
|
||||||
|
ui_show_software_version(jidp->barejid, "online", name_str, version_str, os_str);
|
||||||
|
}
|
||||||
|
|
||||||
jid_destroy(jidp);
|
jid_destroy(jidp);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user