diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 1563bf73..982d81f6 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -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( diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 1870429d..70a6dcc0 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -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) { diff --git a/src/config/preferences.c b/src/config/preferences.c index d817f907..dea6a529 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -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; } diff --git a/src/config/preferences.h b/src/config/preferences.h index 2a30f655..4c903272 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -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 { diff --git a/src/ui/console.c b/src/ui/console.c index 57a04290..f7fa448d 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -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 diff --git a/src/ui/window.c b/src/ui/window.c index b031ac22..339f4456 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -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); diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index ebccec24..a0fcecb0 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -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; }