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

xep-0308: create setting to toggle lmc

and print settings if only `/correction` is run.
This commit is contained in:
Michael Vetter 2020-02-10 14:52:42 +01:00
parent c2d70a071f
commit dd8086772d
7 changed files with 27 additions and 11 deletions

View File

@ -2363,7 +2363,7 @@ static struct cmd_t command_defs[] =
},
{ "/correction",
parse_args, 1, 1, &cons_correction_setting,
parse_args, 1, 2, &cons_correction_setting,
CMD_NOSUBFUNCS
CMD_MAINFUNC(cmd_correction)
CMD_TAGS(

View File

@ -8657,15 +8657,17 @@ cmd_correction(ProfWin *window, const char *const command, gchar **args)
{
// enable/disable
if (g_strcmp0(args[0], "on") == 0) {
prefs_set_boolean(PREF_BOOKMARK_INVITE, TRUE);
_cmd_set_boolean_preference(args[0], command, "Last Message Correction", PREF_CORRECTION_ALLOW);
caps_add_feature(XMPP_FEATURE_LAST_MESSAGE_CORRECTION);
return TRUE;
} else if (g_strcmp0(args[0], "off") == 0) {
prefs_set_boolean(PREF_BOOKMARK_INVITE, FALSE);
_cmd_set_boolean_preference(args[0], command, "Last Message Correction", PREF_CORRECTION_ALLOW);
caps_remove_feature(XMPP_FEATURE_LAST_MESSAGE_CORRECTION);
return TRUE;
}
// char
if (g_strcmp(args[0], "char") == 0) {
if (g_strcmp0(args[0], "char") == 0) {
if (args[1] == NULL) {
cons_bad_cmd_usage(command);
} else if (strlen(args[1]) != 1) {

View File

@ -1786,6 +1786,7 @@ _get_group(preference_t pref)
case PREF_RECEIPTS_REQUEST:
case PREF_REVEAL_OS:
case PREF_TLS_CERTPATH:
case PREF_CORRECTION_ALLOW:
return PREF_GROUP_CONNECTION;
case PREF_OTR_LOG:
case PREF_OTR_POLICY:
@ -2036,6 +2037,8 @@ _get_key(preference_t pref)
return "log";
case PREF_OMEMO_POLICY:
return "policy";
case PREF_CORRECTION_ALLOW:
return "correction.allow";
default:
return NULL;
}

View File

@ -161,6 +161,7 @@ typedef enum {
PREF_OMEMO_LOG,
PREF_OMEMO_POLICY,
PREF_OCCUPANTS_WRAP,
PREF_CORRECTION_ALLOW,
} preference_t;
typedef struct prof_alias_t {

View File

@ -2024,7 +2024,14 @@ cons_os_setting(void)
void
cons_correction_setting(void)
{
cons_show("TODO");
if (prefs_get_boolean(PREF_CORRECTION_ALLOW)) {
cons_show("Last Message Correction (XEP-0308) (/correction) : ON");
} else {
cons_show("Last Message Correction (XEP-0308) (/correction) : OFF");
}
char cc = prefs_get_correction_char();
cons_show("LMC indication char (/correction char) : %c", cc);
}
void

View File

@ -1065,7 +1065,7 @@ win_correct_incoming(ProfWin *window, const char *const message, const char *con
return;
}
/*
/*TODO: set date?
if (entry->date) {
if (entry->date->timestamp) {
g_date_time_unref(entry->date->timestamp);
@ -1076,9 +1076,7 @@ win_correct_incoming(ProfWin *window, const char *const message, const char *con
entry->date = buffer_date_new_now();
*/
// TODO: setting
//entry->show_char = prefs_get_correction_char();
entry->show_char = '+';
entry->show_char = prefs_get_correction_char();
if (entry->message) {
free(entry->message);

View File

@ -104,14 +104,19 @@ caps_init(void)
g_hash_table_add(prof_features, strdup(STANZA_NS_CHATSTATES));
g_hash_table_add(prof_features, strdup(STANZA_NS_PING));
g_hash_table_add(prof_features, strdup(STANZA_NS_STABLE_ID));
if (prefs_get_boolean(PREF_RECEIPTS_SEND)) {
g_hash_table_add(prof_features, strdup(STANZA_NS_RECEIPTS));
}
if (prefs_get_boolean(PREF_LASTACTIVITY)) {
g_hash_table_add(prof_features, strdup(STANZA_NS_LASTACTIVITY));
}
//TODO: depend on setting
g_hash_table_add(prof_features, strdup(STANZA_NS_LAST_MESSAGE_CORRECTION));
if (prefs_get_boolean(PREF_CORRECTION_ALLOW)) {
g_hash_table_add(prof_features, strdup(STANZA_NS_LAST_MESSAGE_CORRECTION));
}
my_sha1 = NULL;
}