mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 09:56:21 +00:00
Added /caps command
This commit is contained in:
@@ -125,6 +125,7 @@ static gboolean _cmd_dnd(gchar **args, struct cmd_help_t help);
|
||||
static gboolean _cmd_chat(gchar **args, struct cmd_help_t help);
|
||||
static gboolean _cmd_xa(gchar **args, struct cmd_help_t help);
|
||||
static gboolean _cmd_info(gchar **args, struct cmd_help_t help);
|
||||
static gboolean _cmd_caps(gchar **args, struct cmd_help_t help);
|
||||
static gboolean _cmd_wins(gchar **args, struct cmd_help_t help);
|
||||
static gboolean _cmd_nick(gchar **args, struct cmd_help_t help);
|
||||
static gboolean _cmd_theme(gchar **args, struct cmd_help_t help);
|
||||
@@ -268,6 +269,16 @@ static struct cmd_t main_commands[] =
|
||||
"If in a chat window the parameter is not required, the current recipient will be used.",
|
||||
NULL } } },
|
||||
|
||||
{ "/caps",
|
||||
_cmd_caps, parse_args, 0, 1,
|
||||
{ "/caps [jid|nick]", "Find out a contacts client capabilities.",
|
||||
{ "/caps [jid|nick]",
|
||||
"----------------",
|
||||
"Find out a contact, or room members client capabilities.",
|
||||
"If in a chat window the parameter is not required, the current recipient will be used.",
|
||||
"The command output is similar to the /info command, but shows the capabilities of each available resource.",
|
||||
NULL } } },
|
||||
|
||||
{ "/status",
|
||||
_cmd_status, parse_args, 0, 1,
|
||||
{ "/status [jid|nick]", "Find out a contacts presence information.",
|
||||
@@ -964,6 +975,7 @@ _cmd_complete_parameters(char *input, int *size)
|
||||
if (nick_ac != NULL) {
|
||||
_parameter_autocomplete_with_ac(input, size, "/msg", nick_ac);
|
||||
_parameter_autocomplete_with_ac(input, size, "/info", nick_ac);
|
||||
_parameter_autocomplete_with_ac(input, size, "/caps", nick_ac);
|
||||
_parameter_autocomplete_with_ac(input, size, "/status", nick_ac);
|
||||
}
|
||||
} else {
|
||||
@@ -971,6 +983,8 @@ _cmd_complete_parameters(char *input, int *size)
|
||||
contact_list_find_contact);
|
||||
_parameter_autocomplete(input, size, "/info",
|
||||
contact_list_find_contact);
|
||||
_parameter_autocomplete(input, size, "/caps",
|
||||
contact_list_find_contact);
|
||||
_parameter_autocomplete(input, size, "/status",
|
||||
contact_list_find_contact);
|
||||
}
|
||||
@@ -1860,6 +1874,70 @@ _cmd_info(gchar **args, struct cmd_help_t help)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_cmd_caps(gchar **args, struct cmd_help_t help)
|
||||
{
|
||||
char *usr = args[0];
|
||||
|
||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currently connected.");
|
||||
} else {
|
||||
if (win_current_is_groupchat()) {
|
||||
if (usr != NULL) {
|
||||
PContact pcontact = muc_get_participant(win_current_get_recipient(), usr);
|
||||
if (pcontact != NULL) {
|
||||
cons_show_caps(pcontact);
|
||||
} else {
|
||||
cons_show("No such participant \"%s\" in room.", usr);
|
||||
}
|
||||
} else {
|
||||
cons_show("No nickname supplied to /info in chat room.");
|
||||
}
|
||||
|
||||
} else if (win_current_is_chat()) {
|
||||
if (usr != NULL) {
|
||||
cons_show("No parameter required for /info in chat.");
|
||||
} else {
|
||||
PContact pcontact = contact_list_get_contact(win_current_get_recipient());
|
||||
if (pcontact != NULL) {
|
||||
cons_show_caps(pcontact);
|
||||
} else {
|
||||
cons_show("No such contact \"%s\" in roster.", win_current_get_recipient());
|
||||
}
|
||||
}
|
||||
|
||||
} else if (win_current_is_private()) {
|
||||
if (usr != NULL) {
|
||||
win_current_show("No parameter required when in chat.");
|
||||
} else {
|
||||
Jid *jid = jid_create(win_current_get_recipient());
|
||||
PContact pcontact = muc_get_participant(jid->barejid, jid->resourcepart);
|
||||
if (pcontact != NULL) {
|
||||
cons_show_caps(pcontact);
|
||||
} else {
|
||||
cons_show("No such participant \"%s\" in room.", jid->resourcepart);
|
||||
}
|
||||
jid_destroy(jid);
|
||||
}
|
||||
} else {
|
||||
if (usr != NULL) {
|
||||
PContact pcontact = contact_list_get_contact(usr);
|
||||
if (pcontact != NULL) {
|
||||
cons_show_caps(pcontact);
|
||||
} else {
|
||||
cons_show("No such contact \"%s\" in roster.", usr);
|
||||
}
|
||||
} else {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_cmd_join(gchar **args, struct cmd_help_t help)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user