mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-18 19:16:21 +00:00
Merge pull request #1850 from H3rnand3zzz/feature/pgp-improved
Extend `/pgp` command to make key exchange procedure easier
This commit is contained in:
@@ -150,7 +150,6 @@ static Autocomplete notify_chat_ac;
|
||||
static Autocomplete notify_room_ac;
|
||||
static Autocomplete notify_typing_ac;
|
||||
static Autocomplete notify_mention_ac;
|
||||
static Autocomplete notify_offline_ac;
|
||||
static Autocomplete notify_trigger_ac;
|
||||
static Autocomplete prefs_ac;
|
||||
static Autocomplete sub_ac;
|
||||
@@ -197,7 +196,6 @@ static Autocomplete bookmark_ignore_ac;
|
||||
static Autocomplete otr_ac;
|
||||
static Autocomplete otr_log_ac;
|
||||
static Autocomplete otr_policy_ac;
|
||||
static Autocomplete otr_sendfile_ac;
|
||||
#endif
|
||||
#ifdef HAVE_OMEMO
|
||||
static Autocomplete omemo_ac;
|
||||
@@ -237,7 +235,6 @@ static Autocomplete reconnect_ac;
|
||||
#ifdef HAVE_LIBGPGME
|
||||
static Autocomplete pgp_ac;
|
||||
static Autocomplete pgp_log_ac;
|
||||
static Autocomplete pgp_sendfile_ac;
|
||||
static Autocomplete ox_ac;
|
||||
static Autocomplete ox_log_ac;
|
||||
#endif
|
||||
@@ -293,7 +290,6 @@ static Autocomplete vcard_set_ac;
|
||||
static Autocomplete vcard_name_ac;
|
||||
static Autocomplete vcard_set_param_ac;
|
||||
static Autocomplete vcard_togglable_param_ac;
|
||||
static Autocomplete vcard_toggle_ac;
|
||||
static Autocomplete vcard_address_type_ac;
|
||||
|
||||
static GHashTable* ac_funcs = NULL;
|
||||
@@ -386,10 +382,6 @@ cmd_ac_init(void)
|
||||
autocomplete_add(notify_mention_ac, "word_whole");
|
||||
autocomplete_add(notify_mention_ac, "word_part");
|
||||
|
||||
notify_offline_ac = autocomplete_new();
|
||||
autocomplete_add(notify_offline_ac, "on");
|
||||
autocomplete_add(notify_offline_ac, "off");
|
||||
|
||||
notify_trigger_ac = autocomplete_new();
|
||||
autocomplete_add(notify_trigger_ac, "add");
|
||||
autocomplete_add(notify_trigger_ac, "remove");
|
||||
@@ -715,10 +707,6 @@ cmd_ac_init(void)
|
||||
autocomplete_add(otr_policy_ac, "manual");
|
||||
autocomplete_add(otr_policy_ac, "opportunistic");
|
||||
autocomplete_add(otr_policy_ac, "always");
|
||||
|
||||
otr_sendfile_ac = autocomplete_new();
|
||||
autocomplete_add(otr_sendfile_ac, "on");
|
||||
autocomplete_add(otr_sendfile_ac, "off");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OMEMO
|
||||
@@ -910,16 +898,14 @@ cmd_ac_init(void)
|
||||
autocomplete_add(pgp_ac, "log");
|
||||
autocomplete_add(pgp_ac, "char");
|
||||
autocomplete_add(pgp_ac, "sendfile");
|
||||
autocomplete_add(pgp_ac, "sendpub");
|
||||
autocomplete_add(pgp_ac, "autoimport");
|
||||
|
||||
pgp_log_ac = autocomplete_new();
|
||||
autocomplete_add(pgp_log_ac, "on");
|
||||
autocomplete_add(pgp_log_ac, "off");
|
||||
autocomplete_add(pgp_log_ac, "redact");
|
||||
|
||||
pgp_sendfile_ac = autocomplete_new();
|
||||
autocomplete_add(pgp_sendfile_ac, "on");
|
||||
autocomplete_add(pgp_sendfile_ac, "off");
|
||||
|
||||
ox_ac = autocomplete_new();
|
||||
autocomplete_add(ox_ac, "keys");
|
||||
autocomplete_add(ox_ac, "contacts");
|
||||
@@ -1309,10 +1295,6 @@ cmd_ac_init(void)
|
||||
autocomplete_add(vcard_togglable_param_ac, "preferred");
|
||||
autocomplete_add(vcard_togglable_param_ac, "x400");
|
||||
|
||||
vcard_toggle_ac = autocomplete_new();
|
||||
autocomplete_add(vcard_toggle_ac, "on");
|
||||
autocomplete_add(vcard_toggle_ac, "off");
|
||||
|
||||
vcard_address_type_ac = autocomplete_new();
|
||||
autocomplete_add(vcard_address_type_ac, "domestic");
|
||||
autocomplete_add(vcard_address_type_ac, "international");
|
||||
@@ -1633,7 +1615,6 @@ cmd_ac_reset(ProfWin* window)
|
||||
autocomplete_reset(otr_ac);
|
||||
autocomplete_reset(otr_log_ac);
|
||||
autocomplete_reset(otr_policy_ac);
|
||||
autocomplete_reset(otr_sendfile_ac);
|
||||
#endif
|
||||
#ifdef HAVE_OMEMO
|
||||
autocomplete_reset(omemo_ac);
|
||||
@@ -1673,7 +1654,6 @@ cmd_ac_reset(ProfWin* window)
|
||||
#ifdef HAVE_LIBGPGME
|
||||
autocomplete_reset(pgp_ac);
|
||||
autocomplete_reset(pgp_log_ac);
|
||||
autocomplete_reset(pgp_sendfile_ac);
|
||||
autocomplete_reset(ox_ac);
|
||||
autocomplete_reset(ox_log_ac);
|
||||
#endif
|
||||
@@ -1723,7 +1703,6 @@ cmd_ac_reset(ProfWin* window)
|
||||
autocomplete_reset(vcard_name_ac);
|
||||
autocomplete_reset(vcard_set_param_ac);
|
||||
autocomplete_reset(vcard_togglable_param_ac);
|
||||
autocomplete_reset(vcard_toggle_ac);
|
||||
autocomplete_reset(vcard_address_type_ac);
|
||||
|
||||
autocomplete_reset(script_ac);
|
||||
@@ -1816,7 +1795,6 @@ cmd_ac_uninit(void)
|
||||
autocomplete_free(otr_ac);
|
||||
autocomplete_free(otr_log_ac);
|
||||
autocomplete_free(otr_policy_ac);
|
||||
autocomplete_free(otr_sendfile_ac);
|
||||
#endif
|
||||
#ifdef HAVE_OMEMO
|
||||
autocomplete_free(omemo_ac);
|
||||
@@ -1855,7 +1833,6 @@ cmd_ac_uninit(void)
|
||||
#ifdef HAVE_LIBGPGME
|
||||
autocomplete_free(pgp_ac);
|
||||
autocomplete_free(pgp_log_ac);
|
||||
autocomplete_free(pgp_sendfile_ac);
|
||||
autocomplete_free(ox_ac);
|
||||
autocomplete_free(ox_log_ac);
|
||||
#endif
|
||||
@@ -1906,7 +1883,6 @@ cmd_ac_uninit(void)
|
||||
autocomplete_free(vcard_name_ac);
|
||||
autocomplete_free(vcard_set_param_ac);
|
||||
autocomplete_free(vcard_togglable_param_ac);
|
||||
autocomplete_free(vcard_toggle_ac);
|
||||
autocomplete_free(vcard_address_type_ac);
|
||||
}
|
||||
|
||||
@@ -2535,7 +2511,7 @@ _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous
|
||||
}
|
||||
|
||||
gchar* boolean_choices1[] = { "/notify room current", "/notify chat current", "/notify typing current",
|
||||
"/notify room text", "/notify chat text" };
|
||||
"/notify room text", "/notify chat text", "/notify room offline" };
|
||||
for (int i = 0; i < ARRAY_SIZE(boolean_choices1); i++) {
|
||||
result = autocomplete_param_with_func(input, boolean_choices1[i], prefs_autocomplete_boolean_choice, previous, NULL);
|
||||
if (result) {
|
||||
@@ -2548,11 +2524,6 @@ _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/notify room offline", notify_offline_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/notify room trigger", notify_trigger_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -2709,7 +2680,7 @@ _otr_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_ac(input, "/otr sendfile", otr_sendfile_ac, TRUE, previous);
|
||||
found = autocomplete_param_with_func(input, "/otr sendfile", prefs_autocomplete_boolean_choice, previous, NULL);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
@@ -2736,6 +2707,11 @@ _pgp_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_func(input, "/pgp sendpub", roster_contact_autocomplete, previous, NULL);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_ac(input, "/pgp log", pgp_log_ac, TRUE, previous);
|
||||
@@ -2743,7 +2719,12 @@ _pgp_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_ac(input, "/pgp sendfile", pgp_sendfile_ac, TRUE, previous);
|
||||
found = autocomplete_param_with_func(input, "/pgp sendfile", prefs_autocomplete_boolean_choice, previous, NULL);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_func(input, "/pgp autoimport", prefs_autocomplete_boolean_choice, previous, NULL);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
@@ -4546,7 +4527,7 @@ _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
} else if ((num_args == 3 && space_at_end && is_num && autocomplete_contains(vcard_togglable_param_ac, args[2])) || (num_args == 4 && !space_at_end && is_num && autocomplete_contains(vcard_togglable_param_ac, args[2]))) {
|
||||
GString* beginning = g_string_new("/vcard");
|
||||
g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]);
|
||||
result = autocomplete_param_with_ac(input, beginning->str, vcard_toggle_ac, TRUE, previous);
|
||||
result = autocomplete_param_with_func(input, beginning->str, prefs_autocomplete_boolean_choice, previous, NULL);
|
||||
g_string_free(beginning, TRUE);
|
||||
if (result) {
|
||||
return result;
|
||||
|
||||
@@ -1705,7 +1705,8 @@ static const struct cmd_t command_defs[] = {
|
||||
"/pgp end",
|
||||
"/pgp log on|off|redact",
|
||||
"/pgp char <char>",
|
||||
"/pgp sendfile on|off")
|
||||
"/pgp sendfile on|off",
|
||||
"/pgp sendpub [<contact>]")
|
||||
CMD_DESC(
|
||||
"Open PGP commands to manage keys, and perform PGP encryption during chat sessions. "
|
||||
"See the /account command to set your own PGP key.")
|
||||
@@ -1719,7 +1720,9 @@ static const struct cmd_t command_defs[] = {
|
||||
{ "log on|off", "Enable or disable plaintext logging of PGP encrypted messages." },
|
||||
{ "log redact", "Log PGP encrypted messages, but replace the contents with [redacted]. This is the default." },
|
||||
{ "char <char>", "Set the character to be displayed next to PGP encrypted messages." },
|
||||
{ "sendfile on|off", "Allow /sendfile to send unencrypted files while otherwise using PGP." })
|
||||
{ "sendfile on|off", "Allow /sendfile to send unencrypted files while otherwise using PGP." },
|
||||
{ "autoimport on|off", "Autoimport PGP keys from messages." },
|
||||
{ "sendpub [<contact>]", "Sends a message to the current recipient with your PGP public key, current contact will be used if not specified." })
|
||||
CMD_EXAMPLES(
|
||||
"/pgp log off",
|
||||
"/pgp setkey odin@valhalla.edda BA19CACE5A9592C5",
|
||||
|
||||
@@ -122,8 +122,8 @@
|
||||
|
||||
static void _update_presence(const resource_presence_t presence,
|
||||
const char* const show, gchar** args);
|
||||
static gboolean _cmd_set_boolean_preference(gchar* arg, const char* const command,
|
||||
const char* const display, preference_t pref);
|
||||
static gboolean _cmd_set_boolean_preference(gchar* arg, const char* const display,
|
||||
preference_t pref);
|
||||
static void _who_room(ProfWin* window, const char* const command, gchar** args);
|
||||
static void _who_roster(ProfWin* window, const char* const command, gchar** args);
|
||||
static gboolean _cmd_execute(ProfWin* window, const char* const command, const char* const inp);
|
||||
@@ -2430,7 +2430,7 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args)
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
} else {
|
||||
_cmd_set_boolean_preference(args[1], command, "Roster panel line wrap", PREF_ROSTER_WRAP);
|
||||
_cmd_set_boolean_preference(args[1], "Roster panel line wrap", PREF_ROSTER_WRAP);
|
||||
rosterwin_roster();
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2520,7 +2520,7 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
}
|
||||
} else if (g_strcmp0(args[1], "join") == 0) {
|
||||
_cmd_set_boolean_preference(args[2], command, "Roster join", PREF_ROSTER_RESOURCE_JOIN);
|
||||
_cmd_set_boolean_preference(args[2], "Roster join", PREF_ROSTER_RESOURCE_JOIN);
|
||||
rosterwin_roster();
|
||||
return TRUE;
|
||||
} else {
|
||||
@@ -2665,7 +2665,7 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args)
|
||||
|
||||
} else if (g_strcmp0(args[0], "count") == 0) {
|
||||
if (g_strcmp0(args[1], "zero") == 0) {
|
||||
_cmd_set_boolean_preference(args[2], command, "Roster header zero count", PREF_ROSTER_COUNT_ZERO);
|
||||
_cmd_set_boolean_preference(args[2], "Roster header zero count", PREF_ROSTER_COUNT_ZERO);
|
||||
if (conn_status == JABBER_CONNECTED) {
|
||||
rosterwin_roster();
|
||||
}
|
||||
@@ -2697,7 +2697,7 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
} else if (g_strcmp0(args[0], "color") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Roster consistent colors", PREF_ROSTER_COLOR_NICK);
|
||||
_cmd_set_boolean_preference(args[1], "Roster consistent colors", PREF_ROSTER_COLOR_NICK);
|
||||
ui_show_roster();
|
||||
return TRUE;
|
||||
|
||||
@@ -3172,7 +3172,7 @@ cmd_resource(ProfWin* window, const char* const command, gchar** args)
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
} else {
|
||||
_cmd_set_boolean_preference(setting, command, "Message resource", PREF_RESOURCE_MESSAGE);
|
||||
_cmd_set_boolean_preference(setting, "Message resource", PREF_RESOURCE_MESSAGE);
|
||||
return TRUE;
|
||||
}
|
||||
} else if (g_strcmp0(cmd, "title") == 0) {
|
||||
@@ -3181,7 +3181,7 @@ cmd_resource(ProfWin* window, const char* const command, gchar** args)
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
} else {
|
||||
_cmd_set_boolean_preference(setting, command, "Title resource", PREF_RESOURCE_TITLE);
|
||||
_cmd_set_boolean_preference(setting, "Title resource", PREF_RESOURCE_TITLE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -4470,7 +4470,7 @@ cmd_occupants(ProfWin* window, const char* const command, gchar** args)
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
} else {
|
||||
_cmd_set_boolean_preference(args[1], command, "Occupants panel line wrap", PREF_OCCUPANTS_WRAP);
|
||||
_cmd_set_boolean_preference(args[1], "Occupants panel line wrap", PREF_OCCUPANTS_WRAP);
|
||||
occupantswin_occupants_all();
|
||||
return TRUE;
|
||||
}
|
||||
@@ -4494,7 +4494,7 @@ cmd_occupants(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "color") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Occupants consistent colors", PREF_OCCUPANTS_COLOR_NICK);
|
||||
_cmd_set_boolean_preference(args[1], "Occupants consistent colors", PREF_OCCUPANTS_COLOR_NICK);
|
||||
occupantswin_occupants_all();
|
||||
return TRUE;
|
||||
}
|
||||
@@ -5107,7 +5107,7 @@ cmd_lastactivity(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
if ((g_strcmp0(args[0], "set") == 0)) {
|
||||
if ((g_strcmp0(args[1], "on") == 0) || (g_strcmp0(args[1], "off") == 0)) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Last activity", PREF_LASTACTIVITY);
|
||||
_cmd_set_boolean_preference(args[1], "Last activity", PREF_LASTACTIVITY);
|
||||
if (g_strcmp0(args[1], "on") == 0) {
|
||||
caps_add_feature(XMPP_FEATURE_LASTACTIVITY);
|
||||
}
|
||||
@@ -5254,7 +5254,7 @@ cmd_clear(ProfWin* window, const char* const command, gchar** args)
|
||||
|
||||
if (args[1] != NULL) {
|
||||
if ((g_strcmp0(args[1], "on") == 0) || (g_strcmp0(args[1], "off") == 0)) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Persistent history", PREF_CLEAR_PERSIST_HISTORY);
|
||||
_cmd_set_boolean_preference(args[1], "Persistent history", PREF_CLEAR_PERSIST_HISTORY);
|
||||
return TRUE;
|
||||
}
|
||||
} else {
|
||||
@@ -5275,7 +5275,7 @@ cmd_clear(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_privileges(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
_cmd_set_boolean_preference(args[0], command, "MUC privileges", PREF_MUC_PRIVILEGES);
|
||||
_cmd_set_boolean_preference(args[0], "MUC privileges", PREF_MUC_PRIVILEGES);
|
||||
|
||||
ui_redraw_all_room_rosters();
|
||||
|
||||
@@ -5305,7 +5305,7 @@ cmd_charset(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_beep(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
_cmd_set_boolean_preference(args[0], command, "Sound", PREF_BEEP);
|
||||
_cmd_set_boolean_preference(args[0], "Sound", PREF_BEEP);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -5357,7 +5357,7 @@ cmd_presence(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
if (strcmp(args[0], "titlebar") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Contact presence", PREF_PRESENCE);
|
||||
_cmd_set_boolean_preference(args[1], "Contact presence", PREF_PRESENCE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -5405,7 +5405,7 @@ cmd_presence(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_wrap(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
_cmd_set_boolean_preference(args[0], command, "Word wrap", PREF_WRAP);
|
||||
_cmd_set_boolean_preference(args[0], "Word wrap", PREF_WRAP);
|
||||
|
||||
wins_resize_all();
|
||||
|
||||
@@ -5644,7 +5644,7 @@ cmd_states(ProfWin* window, const char* const command, gchar** args)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_cmd_set_boolean_preference(args[0], command, "Sending chat states", PREF_STATES);
|
||||
_cmd_set_boolean_preference(args[0], "Sending chat states", PREF_STATES);
|
||||
|
||||
// if disabled, disable outtype and gone
|
||||
if (strcmp(args[0], "off") == 0) {
|
||||
@@ -5666,9 +5666,9 @@ cmd_wintitle(ProfWin* window, const char* const command, gchar** args)
|
||||
ui_clear_win_title();
|
||||
}
|
||||
if (g_strcmp0(args[0], "show") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Window title show", PREF_WINTITLE_SHOW);
|
||||
_cmd_set_boolean_preference(args[1], "Window title show", PREF_WINTITLE_SHOW);
|
||||
} else {
|
||||
_cmd_set_boolean_preference(args[1], command, "Window title goodbye", PREF_WINTITLE_GOODBYE);
|
||||
_cmd_set_boolean_preference(args[1], "Window title goodbye", PREF_WINTITLE_GOODBYE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -5681,7 +5681,7 @@ cmd_outtype(ProfWin* window, const char* const command, gchar** args)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_cmd_set_boolean_preference(args[0], command, "Sending typing notifications", PREF_OUTTYPE);
|
||||
_cmd_set_boolean_preference(args[0], "Sending typing notifications", PREF_OUTTYPE);
|
||||
|
||||
// if enabled, enable states
|
||||
if (strcmp(args[0], "on") == 0) {
|
||||
@@ -6124,7 +6124,7 @@ cmd_inpblock(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
_cmd_set_boolean_preference(value, command, "Dynamic input blocking", PREF_INPBLOCK_DYNAMIC);
|
||||
_cmd_set_boolean_preference(value, "Dynamic input blocking", PREF_INPBLOCK_DYNAMIC);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -6544,12 +6544,12 @@ cmd_log(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
if (strcmp(subcmd, "rotate") == 0) {
|
||||
_cmd_set_boolean_preference(value, command, "Log rotate", PREF_LOG_ROTATE);
|
||||
_cmd_set_boolean_preference(value, "Log rotate", PREF_LOG_ROTATE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strcmp(subcmd, "shared") == 0) {
|
||||
_cmd_set_boolean_preference(value, command, "Shared log", PREF_LOG_SHARED);
|
||||
_cmd_set_boolean_preference(value, "Shared log", PREF_LOG_SHARED);
|
||||
cons_show("Setting only takes effect after saving and restarting Profanity.");
|
||||
return TRUE;
|
||||
}
|
||||
@@ -6766,7 +6766,7 @@ cmd_autoaway(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "check") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Online check", PREF_AUTOAWAY_CHECK);
|
||||
_cmd_set_boolean_preference(args[1], "Online check", PREF_AUTOAWAY_CHECK);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -6811,7 +6811,7 @@ cmd_vercheck(ProfWin* window, const char* const command, gchar** args)
|
||||
cons_check_version(TRUE);
|
||||
return TRUE;
|
||||
} else {
|
||||
_cmd_set_boolean_preference(args[0], command, "Version checking", PREF_VERCHECK);
|
||||
_cmd_set_boolean_preference(args[0], "Version checking", PREF_VERCHECK);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -6833,7 +6833,7 @@ cmd_xmlconsole(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_flash(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
_cmd_set_boolean_preference(args[0], command, "Screen flash", PREF_FLASH);
|
||||
_cmd_set_boolean_preference(args[0], "Screen flash", PREF_FLASH);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -6887,7 +6887,7 @@ cmd_tray(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
} else {
|
||||
gboolean old = prefs_get_boolean(PREF_TRAY);
|
||||
_cmd_set_boolean_preference(args[0], command, "Tray icon", PREF_TRAY);
|
||||
_cmd_set_boolean_preference(args[0], "Tray icon", PREF_TRAY);
|
||||
gboolean new = prefs_get_boolean(PREF_TRAY);
|
||||
if (old != new) {
|
||||
if (new) {
|
||||
@@ -6909,9 +6909,9 @@ gboolean
|
||||
cmd_intype(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
if (g_strcmp0(args[0], "console") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Show contact typing in console", PREF_INTYPE_CONSOLE);
|
||||
_cmd_set_boolean_preference(args[1], "Show contact typing in console", PREF_INTYPE_CONSOLE);
|
||||
} else if (g_strcmp0(args[0], "titlebar") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Show contact typing in titlebar", PREF_INTYPE);
|
||||
_cmd_set_boolean_preference(args[1], "Show contact typing in titlebar", PREF_INTYPE);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
@@ -6922,7 +6922,7 @@ cmd_intype(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_splash(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
_cmd_set_boolean_preference(args[0], command, "Splash screen", PREF_SPLASH);
|
||||
_cmd_set_boolean_preference(args[0], "Splash screen", PREF_SPLASH);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -6958,7 +6958,7 @@ cmd_logging(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
if (strcmp(args[0], "chat") == 0 && args[1] != NULL) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Chat logging", PREF_CHLOG);
|
||||
_cmd_set_boolean_preference(args[1], "Chat logging", PREF_CHLOG);
|
||||
|
||||
// if set to off, disable history
|
||||
if (strcmp(args[1], "off") == 0) {
|
||||
@@ -6968,7 +6968,7 @@ cmd_logging(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(args[0], "group") == 0 && args[1] != NULL) {
|
||||
if (g_strcmp0(args[1], "on") == 0 || g_strcmp0(args[1], "off") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Groupchat logging", PREF_GRLOG);
|
||||
_cmd_set_boolean_preference(args[1], "Groupchat logging", PREF_GRLOG);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -6984,7 +6984,7 @@ cmd_history(ProfWin* window, const char* const command, gchar** args)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_cmd_set_boolean_preference(args[0], command, "Chat history", PREF_HISTORY);
|
||||
_cmd_set_boolean_preference(args[0], "Chat history", PREF_HISTORY);
|
||||
|
||||
// if set to on, set chlog (/logging chat on)
|
||||
if (strcmp(args[0], "on") == 0) {
|
||||
@@ -7001,7 +7001,7 @@ cmd_carbons(ProfWin* window, const char* const command, gchar** args)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_cmd_set_boolean_preference(args[0], command, "Message carbons preference", PREF_CARBONS);
|
||||
_cmd_set_boolean_preference(args[0], "Message carbons preference", PREF_CARBONS);
|
||||
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
|
||||
@@ -7021,7 +7021,7 @@ gboolean
|
||||
cmd_receipts(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
if (g_strcmp0(args[0], "send") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Send delivery receipts", PREF_RECEIPTS_SEND);
|
||||
_cmd_set_boolean_preference(args[1], "Send delivery receipts", PREF_RECEIPTS_SEND);
|
||||
if (g_strcmp0(args[1], "on") == 0) {
|
||||
caps_add_feature(XMPP_FEATURE_RECEIPTS);
|
||||
}
|
||||
@@ -7029,7 +7029,7 @@ cmd_receipts(ProfWin* window, const char* const command, gchar** args)
|
||||
caps_remove_feature(XMPP_FEATURE_RECEIPTS);
|
||||
}
|
||||
} else if (g_strcmp0(args[0], "request") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Request delivery receipts", PREF_RECEIPTS_REQUEST);
|
||||
_cmd_set_boolean_preference(args[1], "Request delivery receipts", PREF_RECEIPTS_REQUEST);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
@@ -7395,7 +7395,9 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(args[0], "log") == 0) {
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "log") == 0) {
|
||||
char* choice = args[1];
|
||||
if (g_strcmp0(choice, "on") == 0) {
|
||||
prefs_set_string(PREF_PGP_LOG, "on");
|
||||
@@ -7418,6 +7420,11 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "autoimport") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], "PGP keys autoimport from messages", PREF_PGP_PUBKEY_AUTOIMPORT);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "keys") == 0) {
|
||||
GHashTable* keys = p_gpg_list_keys();
|
||||
if (!keys || g_hash_table_size(keys) == 0) {
|
||||
@@ -7523,12 +7530,12 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
if (g_strcmp0(args[0], "start") == 0) {
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You must be connected to start PGP encrpytion.");
|
||||
cons_show("You must be connected to start PGP encryption.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (window->type != WIN_CHAT && args[1] == NULL) {
|
||||
cons_show("You must be in a regular chat window to start PGP encrpytion.");
|
||||
cons_show("You must set recipient in an argument or be in a regular chat window to start PGP encryption.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -7567,14 +7574,17 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||
char* err_str = NULL;
|
||||
if (!p_gpg_valid_key(account->pgp_keyid, &err_str)) {
|
||||
win_println(window, THEME_DEFAULT, "!", "Invalid PGP key ID %s: %s, cannot start PGP encryption.", account->pgp_keyid, err_str);
|
||||
free(err_str);
|
||||
if (account->pgp_keyid == NULL) {
|
||||
win_println(window, THEME_DEFAULT, "!", "Couldn't start PGP session. Please, set your PGP key using /account set %s pgpkeyid <pgpkeyid>. To list pgp keys, use /pgp keys.", account->name);
|
||||
account_free(account);
|
||||
return TRUE;
|
||||
}
|
||||
auto_char char* err_str = NULL;
|
||||
if (!p_gpg_valid_key(account->pgp_keyid, &err_str)) {
|
||||
win_println(window, THEME_DEFAULT, "!", "Invalid PGP key ID %s: %s, cannot start PGP encryption.", account->pgp_keyid, err_str);
|
||||
account_free(account);
|
||||
return TRUE;
|
||||
}
|
||||
free(err_str);
|
||||
account_free(account);
|
||||
|
||||
if (!p_gpg_available(chatwin->barejid)) {
|
||||
@@ -7596,7 +7606,7 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
if (window->type != WIN_CHAT) {
|
||||
cons_show("You must be in a regular chat window to end PGP encrpytion.");
|
||||
cons_show("You must be in a regular chat window to end PGP encryption.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -7613,7 +7623,59 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "sendfile") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Sending unencrypted files using /sendfile while otherwise using PGP", PREF_PGP_SENDFILE);
|
||||
_cmd_set_boolean_preference(args[1], "Sending unencrypted files using /sendfile while otherwise using PGP", PREF_PGP_SENDFILE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "sendpub") == 0) {
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You must be connected to share your PGP public key.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (window->type != WIN_CHAT && args[1] == NULL) {
|
||||
cons_show("You must set recipient in an argument or use this command in a regular chat window to share your PGP key.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ProfAccount* account = accounts_get_account(session_get_account_name());
|
||||
|
||||
if (account->pgp_keyid == NULL) {
|
||||
cons_show_error("Please, set the PGP key first using /account set %s pgpkeyid <pgpkeyid>. To list pgp keys, use /pgp keys.", account->name);
|
||||
account_free(account);
|
||||
return TRUE;
|
||||
}
|
||||
auto_char char* pubkey = p_gpg_get_pubkey(account->pgp_keyid);
|
||||
if (pubkey == NULL) {
|
||||
cons_show_error("Couldn't get your PGP public key. Please, check error logs.");
|
||||
account_free(account);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ProfChatWin* chatwin = NULL;
|
||||
|
||||
if (args[1]) {
|
||||
char* contact = args[1];
|
||||
char* barejid = roster_barejid_from_name(contact);
|
||||
if (barejid == NULL) {
|
||||
barejid = contact;
|
||||
}
|
||||
|
||||
chatwin = wins_get_chat(barejid);
|
||||
if (!chatwin) {
|
||||
chatwin = chatwin_new(barejid);
|
||||
}
|
||||
ui_focus_win((ProfWin*)chatwin);
|
||||
} else {
|
||||
chatwin = (ProfChatWin*)window;
|
||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||
}
|
||||
|
||||
cl_ev_send_msg(chatwin, pubkey, NULL);
|
||||
win_update_entry_message((ProfWin*)chatwin, chatwin->last_msg_id, "[you shared your PGP key]");
|
||||
cons_show("PGP key has been shared with %s.", chatwin->barejid);
|
||||
account_free(account);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -7725,12 +7787,12 @@ cmd_ox(ProfWin* window, const char* const command, gchar** args)
|
||||
} else if (g_strcmp0(args[0], "start") == 0) {
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You must be connected to start OX encrpytion.");
|
||||
cons_show("You must be connected to start OX encryption.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (window->type != WIN_CHAT && args[1] == NULL) {
|
||||
cons_show("You must be in a regular chat window to start OX encrpytion.");
|
||||
cons_show("You must be in a regular chat window to start OX encryption.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -8337,7 +8399,7 @@ gboolean
|
||||
cmd_otr_sendfile(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
#ifdef HAVE_LIBOTR
|
||||
_cmd_set_boolean_preference(args[1], command, "Sending unencrypted files in an OTR session via /sendfile", PREF_OTR_SENDFILE);
|
||||
_cmd_set_boolean_preference(args[1], "Sending unencrypted files in an OTR session via /sendfile", PREF_OTR_SENDFILE);
|
||||
|
||||
return TRUE;
|
||||
#else
|
||||
@@ -8640,24 +8702,35 @@ _update_presence(const resource_presence_t resource_presence,
|
||||
}
|
||||
}
|
||||
|
||||
// helper function for boolean preference commands
|
||||
/**
|
||||
* Sets a boolean preference based on the provided argument.
|
||||
*
|
||||
* @param arg The argument value specifying the preference state ("on" or "off").
|
||||
* @param display The display (UI) name of the preference being set.
|
||||
* @param preference The preference to be changed.
|
||||
*
|
||||
* @return TRUE if the preference was successfully set, FALSE otherwise.
|
||||
*/
|
||||
static gboolean
|
||||
_cmd_set_boolean_preference(gchar* arg, const char* const command,
|
||||
const char* const display, preference_t pref)
|
||||
_cmd_set_boolean_preference(gchar* arg, const char* const display, preference_t preference)
|
||||
{
|
||||
gboolean prev_state = prefs_get_boolean(preference);
|
||||
if (arg == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return FALSE;
|
||||
} else if (g_strcmp0(arg, "on") == 0) {
|
||||
cons_show("%s enabled.", display);
|
||||
prefs_set_boolean(pref, TRUE);
|
||||
} else if (g_strcmp0(arg, "off") == 0) {
|
||||
cons_show("%s disabled.", display);
|
||||
prefs_set_boolean(pref, FALSE);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("%s is %s.", display, prev_state ? "enabled" : "disabled");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(arg, "on") == 0) {
|
||||
cons_show("%s %senabled.", display, prev_state ? "is already " : "");
|
||||
prefs_set_boolean(preference, TRUE);
|
||||
} else if (g_strcmp0(arg, "off") == 0) {
|
||||
cons_show("%s %sdisabled.", display, !prev_state ? "is already " : "");
|
||||
prefs_set_boolean(preference, FALSE);
|
||||
} else {
|
||||
cons_show_error("Invalid argument value. Expected 'on' or 'off'.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -9293,7 +9366,7 @@ cmd_color(ProfWin* window, const char* const command, gchar** args)
|
||||
prefs_set_string(PREF_COLOR_NICK, "blue");
|
||||
} else if (g_strcmp0(args[0], "own") == 0) {
|
||||
if (g_strcmp0(args[1], "on") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], command, "Color generation for own nick", PREF_COLOR_NICK_OWN);
|
||||
_cmd_set_boolean_preference(args[1], "Color generation for own nick", PREF_COLOR_NICK_OWN);
|
||||
}
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
@@ -9355,7 +9428,7 @@ cmd_avatar(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_os(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
_cmd_set_boolean_preference(args[0], command, "Revealing OS name", PREF_REVEAL_OS);
|
||||
_cmd_set_boolean_preference(args[0], "Revealing OS name", PREF_REVEAL_OS);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -9365,11 +9438,11 @@ cmd_correction(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
// enable/disable
|
||||
if (g_strcmp0(args[0], "on") == 0) {
|
||||
_cmd_set_boolean_preference(args[0], command, "Last Message Correction", PREF_CORRECTION_ALLOW);
|
||||
_cmd_set_boolean_preference(args[0], "Last Message Correction", PREF_CORRECTION_ALLOW);
|
||||
caps_add_feature(XMPP_FEATURE_LAST_MESSAGE_CORRECTION);
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(args[0], "off") == 0) {
|
||||
_cmd_set_boolean_preference(args[0], command, "Last Message Correction", PREF_CORRECTION_ALLOW);
|
||||
_cmd_set_boolean_preference(args[0], "Last Message Correction", PREF_CORRECTION_ALLOW);
|
||||
caps_remove_feature(XMPP_FEATURE_LAST_MESSAGE_CORRECTION);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -9458,7 +9531,7 @@ cmd_slashguard(ProfWin* window, const char* const command, gchar** args)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_cmd_set_boolean_preference(args[0], command, "Slashguard", PREF_SLASH_GUARD);
|
||||
_cmd_set_boolean_preference(args[0], "Slashguard", PREF_SLASH_GUARD);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -9705,7 +9778,7 @@ cmd_executable_vcard_photo(ProfWin* window, const char* const command, gchar** a
|
||||
gboolean
|
||||
cmd_mam(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
_cmd_set_boolean_preference(args[0], command, "Message Archive Management", PREF_MAM);
|
||||
_cmd_set_boolean_preference(args[0], "Message Archive Management", PREF_MAM);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -9787,7 +9860,7 @@ cmd_correct_editor(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_silence(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
_cmd_set_boolean_preference(args[0], command, "Block all messages from JIDs that are not in the roster", PREF_SILENCE_NON_ROSTER);
|
||||
_cmd_set_boolean_preference(args[0], "Block all messages from JIDs that are not in the roster", PREF_SILENCE_NON_ROSTER);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -9861,10 +9934,10 @@ gboolean
|
||||
cmd_mood(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
if (g_strcmp0(args[0], "on") == 0) {
|
||||
_cmd_set_boolean_preference(args[0], command, "User mood", PREF_MOOD);
|
||||
_cmd_set_boolean_preference(args[0], "User mood", PREF_MOOD);
|
||||
caps_add_feature(STANZA_NS_MOOD_NOTIFY);
|
||||
} else if (g_strcmp0(args[0], "off") == 0) {
|
||||
_cmd_set_boolean_preference(args[0], command, "User mood", PREF_MOOD);
|
||||
_cmd_set_boolean_preference(args[0], "User mood", PREF_MOOD);
|
||||
caps_remove_feature(STANZA_NS_MOOD_NOTIFY);
|
||||
} else if (g_strcmp0(args[0], "set") == 0) {
|
||||
if (args[1]) {
|
||||
|
||||
Reference in New Issue
Block a user