mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Fix lastactivity behaviour
Autocomplete only completed on|off. Now: `/lastactivity get` -> get server uptime `/lastactivity get <jid>` -> get user lastactivity `/lastactivity set on` -> enable for self `/lastactivity set off` -> disable for self Fix https://github.com/profanity-im/profanity/issues/1411
This commit is contained in:
parent
7319f9eb1d
commit
a5ca65453e
@ -126,6 +126,7 @@ static char* _correct_autocomplete(ProfWin* window, const char* const input, gbo
|
|||||||
static char* _software_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
static char* _software_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||||
static char* _url_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
static char* _url_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||||
static char* _executable_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
static char* _executable_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||||
|
static char* _lastactivity_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||||
|
|
||||||
static char* _script_autocomplete_func(const char* const prefix, gboolean previous, void* context);
|
static char* _script_autocomplete_func(const char* const prefix, gboolean previous, void* context);
|
||||||
|
|
||||||
@ -1654,7 +1655,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
|
|||||||
|
|
||||||
// autocomplete boolean settings
|
// autocomplete boolean settings
|
||||||
gchar* boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash",
|
gchar* boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash",
|
||||||
"/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/lastactivity", "/os", "/slashguard" };
|
"/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/os", "/slashguard" };
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
|
for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
|
||||||
result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice, previous, NULL);
|
result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice, previous, NULL);
|
||||||
@ -1786,6 +1787,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
|
|||||||
g_hash_table_insert(ac_funcs, "/software", _software_autocomplete);
|
g_hash_table_insert(ac_funcs, "/software", _software_autocomplete);
|
||||||
g_hash_table_insert(ac_funcs, "/url", _url_autocomplete);
|
g_hash_table_insert(ac_funcs, "/url", _url_autocomplete);
|
||||||
g_hash_table_insert(ac_funcs, "/executable", _executable_autocomplete);
|
g_hash_table_insert(ac_funcs, "/executable", _executable_autocomplete);
|
||||||
|
g_hash_table_insert(ac_funcs, "/lastactivity", _lastactivity_autocomplete);
|
||||||
|
|
||||||
int len = strlen(input);
|
int len = strlen(input);
|
||||||
char parsed[len + 1];
|
char parsed[len + 1];
|
||||||
@ -4163,3 +4165,32 @@ _executable_autocomplete(ProfWin* window, const char* const input, gboolean prev
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char*
|
||||||
|
_lastactivity_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||||
|
{
|
||||||
|
char* result = NULL;
|
||||||
|
|
||||||
|
result = autocomplete_param_with_ac(input, "/lastactivity", status_ac, TRUE, previous);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
jabber_conn_status_t conn_status = connection_get_status();
|
||||||
|
|
||||||
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
|
|
||||||
|
result = autocomplete_param_with_func(input, "/lastactivity set", prefs_autocomplete_boolean_choice, previous, NULL);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = autocomplete_param_with_func(input, "/lastactivity get", roster_barejid_autocomplete, previous, NULL);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@ -885,25 +885,25 @@ static struct cmd_t command_defs[] = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
{ "/lastactivity",
|
{ "/lastactivity",
|
||||||
parse_args, 0, 1, NULL,
|
parse_args, 1, 2, NULL,
|
||||||
CMD_NOSUBFUNCS
|
CMD_NOSUBFUNCS
|
||||||
CMD_MAINFUNC(cmd_lastactivity)
|
CMD_MAINFUNC(cmd_lastactivity)
|
||||||
CMD_TAGS(
|
CMD_TAGS(
|
||||||
CMD_TAG_PRESENCE)
|
CMD_TAG_PRESENCE)
|
||||||
CMD_SYN(
|
CMD_SYN(
|
||||||
"/lastactivity on|off",
|
"/lastactivity set on|off",
|
||||||
"/lastactivity [<jid>]")
|
"/lastactivity get [<jid>]")
|
||||||
CMD_DESC(
|
CMD_DESC(
|
||||||
"Enable/disable sending last activity, and send last activity requests.")
|
"Enable/disable sending last activity, and send last activity requests.")
|
||||||
CMD_ARGS(
|
CMD_ARGS(
|
||||||
{ "on|off", "Enable or disable sending of last activity." },
|
{ "on|off", "Enable or disable sending of last activity." },
|
||||||
{ "<jid>", "The JID of the entity to query. Omitting the JID will query your server for its uptime." })
|
{ "<jid>", "The JID of the entity to query. Omitting the JID will query your server for its uptime." })
|
||||||
CMD_EXAMPLES(
|
CMD_EXAMPLES(
|
||||||
"/lastactivity",
|
"/lastactivity get",
|
||||||
"/lastactivity off",
|
"/lastactivity set off",
|
||||||
"/lastactivity freyja@asgaard.edda",
|
"/lastactivity get freyja@asgaard.edda",
|
||||||
"/lastactivity freyja@asgaard.edda/laptop",
|
"/lastactivity get freyja@asgaard.edda/laptop",
|
||||||
"/lastactivity someserver.com")
|
"/lastactivity get someserver.com")
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "/nick",
|
{ "/nick",
|
||||||
|
@ -4903,15 +4903,20 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
|
|||||||
gboolean
|
gboolean
|
||||||
cmd_lastactivity(ProfWin* window, const char* const command, gchar** args)
|
cmd_lastactivity(ProfWin* window, const char* const command, gchar** args)
|
||||||
{
|
{
|
||||||
if ((g_strcmp0(args[0], "on") == 0) || (g_strcmp0(args[0], "off") == 0)) {
|
if ((g_strcmp0(args[0], "set") == 0)) {
|
||||||
_cmd_set_boolean_preference(args[0], command, "Last activity", PREF_LASTACTIVITY);
|
if ((g_strcmp0(args[1], "on") == 0) || (g_strcmp0(args[1], "off") == 0)) {
|
||||||
if (g_strcmp0(args[0], "on") == 0) {
|
_cmd_set_boolean_preference(args[1], command, "Last activity", PREF_LASTACTIVITY);
|
||||||
caps_add_feature(XMPP_FEATURE_LASTACTIVITY);
|
if (g_strcmp0(args[1], "on") == 0) {
|
||||||
|
caps_add_feature(XMPP_FEATURE_LASTACTIVITY);
|
||||||
|
}
|
||||||
|
if (g_strcmp0(args[1], "off") == 0) {
|
||||||
|
caps_remove_feature(XMPP_FEATURE_LASTACTIVITY);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
cons_bad_cmd_usage(command);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (g_strcmp0(args[0], "off") == 0) {
|
|
||||||
caps_remove_feature(XMPP_FEATURE_LASTACTIVITY);
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jabber_conn_status_t conn_status = connection_get_status();
|
jabber_conn_status_t conn_status = connection_get_status();
|
||||||
@ -4921,20 +4926,25 @@ cmd_lastactivity(ProfWin* window, const char* const command, gchar** args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0] == NULL) {
|
if ((g_strcmp0(args[0], "get") == 0)) {
|
||||||
Jid* jidp = jid_create(connection_get_fulljid());
|
if (args[1] == NULL) {
|
||||||
GString* jid = g_string_new(jidp->domainpart);
|
Jid* jidp = jid_create(connection_get_fulljid());
|
||||||
|
GString* jid = g_string_new(jidp->domainpart);
|
||||||
|
|
||||||
iq_last_activity_request(jid->str);
|
iq_last_activity_request(jid->str);
|
||||||
|
|
||||||
g_string_free(jid, TRUE);
|
g_string_free(jid, TRUE);
|
||||||
jid_destroy(jidp);
|
jid_destroy(jidp);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
iq_last_activity_request(args[0]);
|
iq_last_activity_request(args[1]);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cons_bad_cmd_usage(command);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
Loading…
x
Reference in New Issue
Block a user