1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Add /mam command

Regards https://github.com/profanity-im/profanity/issues/660
This commit is contained in:
Michael Vetter 2021-01-28 15:11:50 +01:00
parent 05bf065e68
commit 44fc3f0506
6 changed files with 38 additions and 3 deletions

View File

@ -1165,12 +1165,12 @@ cmd_ac_remove_form_fields(DataForm* form)
char*
cmd_ac_complete(ProfWin* window, const char* const input, gboolean previous)
{
char *found = NULL;
char* found = NULL;
// autocomplete command
if ((strncmp(input, "/", 1) == 0) && (!strchr(input, ' '))) {
found = autocomplete_complete(commands_ac, input, TRUE, previous);
// autocomplete parameters
// autocomplete parameters
} else {
found = _cmd_ac_complete_params(window, input, previous);
}
@ -1633,7 +1633,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
// autocomplete boolean settings
gchar* boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash",
"/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/os", "/slashguard" };
"/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/os", "/slashguard", "/mam" };
for (int i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice, previous, NULL);

View File

@ -2546,6 +2546,21 @@ static struct cmd_t command_defs[] = {
"/url save https://profanity-im.github.io/guide/latest/userguide.html /home/user/Download/")
},
{ "/mam",
parse_args, 1, 1, &cons_mam_setting,
CMD_NOSUBFUNCS
CMD_MAINFUNC(cmd_mam)
CMD_TAGS(
CMD_TAG_CHAT)
CMD_SYN(
"/os <on>|<off>")
CMD_DESC(
"Enable/Disable Message Archive Management (XEP-0313)")
CMD_ARGS(
{ "on|off", "Enable or disable MAM" })
CMD_NOEXAMPLES
},
// NEXT-COMMAND (search helper)
};

View File

@ -9278,3 +9278,11 @@ cmd_executable_urlsave(ProfWin* window, const char* const command, gchar** args)
return TRUE;
}
gboolean
cmd_mam(ProfWin* window, const char* const command, gchar** args)
{
_cmd_set_boolean_preference(args[0], command, "Message Archive Management", PREF_MAM);
return TRUE;
}

View File

@ -240,5 +240,6 @@ gboolean cmd_url_save(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_executable_avatar(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_executable_urlopen(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_executable_urlsave(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_mam(ProfWin* window, const char* const command, gchar** args);
#endif

View File

@ -2082,6 +2082,16 @@ cons_slashguard_setting(void)
}
}
void
cons_mam_setting(void)
{
if (prefs_get_boolean(PREF_MAM)) {
cons_show("Message Archive Management (XEP-0313) (/mam) : ON");
} else {
cons_show("Message Archive Management (XEP-0313) (/mam) : OFF");
}
}
void
cons_show_connection_prefs(void)
{

View File

@ -321,6 +321,7 @@ void cons_os_setting(void);
void cons_correction_setting(void);
void cons_executable_setting(void);
void cons_slashguard_setting(void);
void cons_mam_setting(void);
void cons_show_contact_online(PContact contact, Resource* resource, GDateTime* last_activity);
void cons_show_contact_offline(PContact contact, char* resource, char* status);
void cons_theme_properties(void);