Added /ping command

This commit is contained in:
James Booth
2014-09-04 01:08:10 +01:00
parent b50b786dcc
commit 4ba33cb13c
9 changed files with 86 additions and 4 deletions

View File

@@ -722,6 +722,14 @@ static struct cmd_t command_defs[] =
"A value of 0 will switch off autopinging the server.",
NULL } } },
{ "/ping",
cmd_ping, parse_args, 0, 1, NULL,
{ "/ping [target]", "Send ping IQ request.",
{ "/ping [rarget]",
"--------------",
"Sends an IQ ping stanza to the specificed target.",
NULL } } },
{ "/autoaway",
cmd_autoaway, parse_args_with_freetext, 2, 2, &cons_autoaway_setting,
{ "/autoaway setting value", "Set auto idle/away properties.",
@@ -1592,7 +1600,7 @@ _cmd_complete_parameters(char *input, int *size)
}
}
gchar *resource_choices[] = { "/caps", "/software" };
gchar *resource_choices[] = { "/caps", "/software", "/ping" };
for (i = 0; i < ARRAY_SIZE(resource_choices); i++) {
result = autocomplete_param_with_func(input, size, resource_choices[i],
roster_find_resource);

View File

@@ -2576,6 +2576,26 @@ cmd_autoping(gchar **args, struct cmd_help_t help)
return TRUE;
}
gboolean
cmd_ping(gchar **args, struct cmd_help_t help)
{
jabber_conn_status_t conn_status = jabber_get_connection_status();
if (conn_status != JABBER_CONNECTED) {
cons_show("You are not currenlty connected.");
return TRUE;
}
iq_send_ping(args[0]);
if (args[0] == NULL) {
cons_show("Pinged server...");
} else {
cons_show("Pinged %s...", args[0]);
}
return TRUE;
}
gboolean
cmd_autoaway(gchar **args, struct cmd_help_t help)
{

View File

@@ -124,5 +124,6 @@ gboolean cmd_wins(gchar **args, struct cmd_help_t help);
gboolean cmd_xa(gchar **args, struct cmd_help_t help);
gboolean cmd_alias(gchar **args, struct cmd_help_t help);
gboolean cmd_xmlconsole(gchar **args, struct cmd_help_t help);
gboolean cmd_ping(gchar **args, struct cmd_help_t help);
#endif