Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using different colors to indicate the state of OMEMO messages #2000

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/command/cmd_defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2307,7 +2307,8 @@ static const struct cmd_t command_defs[] = {
{ "char", cmd_omemo_char },
{ "policy", cmd_omemo_policy },
{ "clear_device_list", cmd_omemo_clear_device_list },
{ "qrcode", cmd_omemo_qrcode })
{ "qrcode", cmd_omemo_qrcode },
{ "colors", cmd_omemo_colors })
CMD_TAGS(
CMD_TAG_CHAT,
CMD_TAG_UI)
Expand All @@ -2322,7 +2323,8 @@ static const struct cmd_t command_defs[] = {
"/omemo trustmode manual|firstusage|blind",
"/omemo policy manual|automatic|always",
"/omemo clear_device_list",
"/omemo qrcode")
"/omemo qrcode",
"/omemo colors on|off")
CMD_DESC(
"OMEMO commands to manage keys, and perform encryption during chat sessions.")
CMD_ARGS(
Expand All @@ -2340,7 +2342,8 @@ static const struct cmd_t command_defs[] = {
{ "policy automatic", "Set the global OMEMO policy to opportunistic, an OMEMO session will be attempted upon starting a conversation." },
{ "policy always", "Set the global OMEMO policy to always, an error will be displayed if an OMEMO session cannot be initiated upon starting a conversation." },
{ "clear_device_list", "Clear your own device list on server side. Each client will reannounce itself when connected back."},
{ "qrcode", "Display QR code of your OMEMO fingerprint"})
{ "qrcode", "Display QR code of your OMEMO fingerprint"},
{ "colors on|off", "Enable or disable coloring of OMEMO messages. Default: off." })
CMD_EXAMPLES(
"/omemo gen",
"/omemo start [email protected]",
Expand Down
24 changes: 24 additions & 0 deletions src/command/cmd_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -8799,6 +8799,30 @@ cmd_omemo_log(ProfWin* window, const char* const command, gchar** args)
#endif
}

gboolean
cmd_omemo_colors(ProfWin* window, const char* const command, gchar** args)
{
#ifdef HAVE_OMEMO
char* choice = args[1];
if (g_strcmp0(choice, "on") == 0) {
prefs_set_string(PREF_OMEMO_COLORS, "on");
cons_show("Received OMEMO messages will be darker white.");
} else if (g_strcmp0(choice, "off") == 0) {
prefs_set_string(PREF_OMEMO_COLORS, "off");
cons_show("Received OMEMO messages will be the default color.");
}
else
{
cons_bad_cmd_usage(command);
}

return TRUE;
#else
cons_show("This version of Profanity has not been built with OMEMO support enabled");
return TRUE;
#endif
}

gboolean
cmd_omemo_end(ProfWin* window, const char* const command, gchar** args)
{
Expand Down
1 change: 1 addition & 0 deletions src/command/cmd_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ gboolean cmd_omemo_trust_mode(ProfWin* window, const char* const command, gchar*
gboolean cmd_omemo_policy(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_omemo_clear_device_list(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_omemo_qrcode(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_omemo_colors(ProfWin* window, const char* const command, gchar** args);

gboolean cmd_save(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_reload(ProfWin* window, const char* const command, gchar** args);
Expand Down
5 changes: 5 additions & 0 deletions src/config/preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,7 @@ _get_group(preference_t pref)
case PREF_ROOM_LIST_CACHE:
return PREF_GROUP_MUC;
case PREF_OMEMO_LOG:
case PREF_OMEMO_COLORS:
case PREF_OMEMO_POLICY:
case PREF_OMEMO_TRUST_MODE:
return PREF_GROUP_OMEMO;
Expand Down Expand Up @@ -2114,6 +2115,8 @@ _get_key(preference_t pref)
return "statusbar.tabmode";
case PREF_OMEMO_LOG:
return "log";
case PREF_OMEMO_COLORS:
return "colors";
case PREF_OMEMO_POLICY:
return "policy";
case PREF_OMEMO_TRUST_MODE:
Expand Down Expand Up @@ -2281,6 +2284,8 @@ _get_default_string(preference_t pref)
return "name";
case PREF_OMEMO_LOG:
return "on";
case PREF_OMEMO_COLORS:
return "off";
case PREF_OMEMO_POLICY:
return "automatic";
case PREF_OMEMO_TRUST_MODE:
Expand Down
1 change: 1 addition & 0 deletions src/config/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ typedef enum {
PREF_OMEMO_LOG,
PREF_OMEMO_POLICY,
PREF_OMEMO_TRUST_MODE,
PREF_OMEMO_COLORS,
PREF_OCCUPANTS_WRAP,
PREF_CORRECTION_ALLOW,
PREF_AVATAR_CMD,
Expand Down
3 changes: 3 additions & 0 deletions src/ui/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -2271,6 +2271,9 @@ cons_show_omemo_prefs(void)
auto_gchar gchar* ch = prefs_get_omemo_char();
cons_show("OMEMO char (/omemo char) : %s", ch);

auto_gchar gchar* colors_value = prefs_get_string(PREF_OMEMO_COLORS);
cons_show("OMEMO colors (/omemo colors) : %s", colors_value);

cons_alert(NULL);
}

Expand Down
Loading