1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Merge pull request #1870 from profanity-im/feat/privacy-setting

Move related commands as subcommands into /privacy
This commit is contained in:
Michael Vetter 2023-07-27 10:27:24 +02:00 committed by GitHub
commit fa80562fa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 107 additions and 125 deletions

View File

@ -1075,6 +1075,7 @@ cmd_ac_init(void)
privacy_ac = autocomplete_new();
autocomplete_add(privacy_ac, "logging");
autocomplete_add(privacy_ac, "os");
privacy_log_ac = autocomplete_new();
autocomplete_add(privacy_log_ac, "on");
@ -2031,7 +2032,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
// autocomplete boolean settings
gchar* boolean_choices[] = { "/beep", "/states", "/outtype", "/flash", "/splash",
"/history", "/vercheck", "/privileges", "/wrap",
"/carbons", "/os", "/slashguard", "/mam", "/silence" };
"/carbons", "/slashguard", "/mam", "/silence" };
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);
@ -4239,6 +4240,11 @@ _privacy_autocomplete(ProfWin* window, const char* const input, gboolean previou
return found;
}
found = autocomplete_param_with_func(input, "/privacy os", prefs_autocomplete_boolean_choice, previous, NULL);
if (found) {
return found;
}
return found;
}

View File

@ -2448,19 +2448,6 @@ static const struct cmd_t command_defs[] = {
"/avatar get thor@valhalla.edda",
"/avatar open freyja@vanaheimr.edda") },
{ CMD_PREAMBLE("/os",
parse_args, 1, 1, &cons_os_setting)
CMD_MAINFUNC(cmd_os)
CMD_TAGS(
CMD_TAG_DISCOVERY)
CMD_SYN(
"/os <on>|<off>")
CMD_DESC(
"Choose whether to include the OS name if a user asks for software information (XEP-0092).")
CMD_ARGS(
{ "on|off", "" })
},
{ CMD_PREAMBLE("/correction",
parse_args, 1, 2, &cons_correction_setting)
CMD_MAINFUNC(cmd_correction)
@ -2722,18 +2709,28 @@ static const struct cmd_t command_defs[] = {
},
{ CMD_PREAMBLE("/privacy",
parse_args, 2, 3, NULL)
parse_args, 2, 3, &cons_privacy_setting)
CMD_SUBFUNCS(
{ "os", cmd_os })
CMD_MAINFUNC(cmd_privacy)
CMD_TAGS(
CMD_TAG_CHAT)
CMD_TAG_CHAT,
CMD_TAG_DISCOVERY)
CMD_SYN(
"/privacy logging on|redact|off")
"/privacy logging on|redact|off",
"/privacy os on|off")
CMD_DESC(
"Configure privacy settings.")
"Configure privacy settings."
"Also check the the following settings in /account: "
"clientid to set the client identification name"
"session_alarm to configure an alarm when more clients log in.")
CMD_ARGS(
{ "logging on|redact|off", "Switch chat logging. This will also disable logging in the internally used SQL database. Your messages will not be saved anywhere locally. This might have unintended consequences, such as not being able to decrypt OMEMO encrypted messages received later via MAM, and should be used with caution." })
{ "logging on|redact|off", "Switch chat logging. This will also disable logging in the internally used SQL database. Your messages will not be saved anywhere locally. This might have unintended consequences, such as not being able to decrypt OMEMO encrypted messages received later via MAM, and should be used with caution." },
{ "os on|off", "Choose whether to include the OS name if a user asks for software information (XEP-0092)." }
)
CMD_EXAMPLES(
"/privacy logging off")
"/privacy logging off",
"/privacy os off")
},
// NEXT-COMMAND (search helper)
};

View File

@ -9352,7 +9352,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], "Revealing OS name", PREF_REVEAL_OS);
_cmd_set_boolean_preference(args[1], "Revealing OS name", PREF_REVEAL_OS);
return TRUE;
}

View File

@ -62,6 +62,10 @@
#include "log.h"
#include "common.h"
#ifdef HAVE_GIT_VERSION
#include "gitversion.h"
#endif
struct curl_data_t
{
char* buffer;
@ -688,3 +692,20 @@ glib_hash_table_free(GHashTable* hash_table)
g_hash_table_remove_all(hash_table);
g_hash_table_unref(hash_table);
}
/* build profanity version string.
* example: 0.13.1dev.master.69d8c1f9
*/
gchar*
prof_get_version(void)
{
if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION
return g_strdup_printf("%sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else
return g_strdup_printf("%sdev", PACKAGE_VERSION);
#endif
} else {
return g_strdup_printf("%s", PACKAGE_VERSION);
}
}

View File

@ -180,4 +180,6 @@ gchar* get_expanded_path(const char* path);
void glib_hash_table_free(GHashTable* hash_table);
char* basename_from_url(const char* url);
gchar* prof_get_version(void);
#endif

View File

@ -39,10 +39,6 @@
#include <string.h>
#include <glib.h>
#ifdef HAVE_GIT_VERSION
#include "gitversion.h"
#endif
#ifdef HAVE_LIBOTR
#include "otr/otr.h"
#endif
@ -104,15 +100,8 @@ main(int argc, char** argv)
g_option_context_free(context);
if (version == TRUE) {
if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION
g_print("Profanity, version %sdev.%s.%s\n", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else
g_print("Profanity, version %sdev\n", PACKAGE_VERSION);
#endif
} else {
g_print("Profanity, version %s\n", PACKAGE_VERSION);
}
auto_gchar gchar* prof_version = prof_get_version();
g_print("Profanity, version %s\n", prof_version);
// lets use fixed email instead of PACKAGE_BUGREPORT
g_print("Copyright (C) 2012 - 2019 James Booth <boothj5web@gmail.com>.\n");

View File

@ -35,10 +35,6 @@
*/
#include "config.h"
#ifdef HAVE_GIT_VERSION
#include "gitversion.h"
#endif
#ifdef HAVE_GTK
#include "ui/tray.h"
#endif
@ -180,15 +176,8 @@ _init(char* log_level, char* config_file, char* log_file, char* theme_name)
log_init(prof_log_level, log_file);
log_stderr_init(PROF_LEVEL_ERROR);
if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION
log_info("Starting Profanity (%sdev.%s.%s)…", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else
log_info("Starting Profanity (%sdev)…", PACKAGE_VERSION);
#endif
} else {
log_info("Starting Profanity (%s)…", PACKAGE_VERSION);
}
auto_gchar gchar* prof_version = prof_get_version();
log_info("Starting Profanity (%s)…", prof_version);
chat_log_init();
groupchat_log_init();

View File

@ -66,10 +66,6 @@
#include "xmpp/muc.h"
#include "xmpp/roster_list.h"
#ifdef HAVE_GIT_VERSION
#include "gitversion.h"
#endif
static void _cons_splash_logo(void);
static void _show_roster_contacts(GSList* list, gboolean show_groups);
static GList* alert_list;
@ -413,16 +409,8 @@ cons_about(void)
if (prefs_get_boolean(PREF_SPLASH)) {
_cons_splash_logo();
} else {
if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION
win_println(console, THEME_DEFAULT, "-", "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else
win_println(console, THEME_DEFAULT, "Welcome to Profanity, version %sdev", PACKAGE_VERSION);
#endif
} else {
win_println(console, THEME_DEFAULT, "-", "Welcome to Profanity, version %s", PACKAGE_VERSION);
}
auto_gchar gchar* prof_version = prof_get_version();
win_println(console, THEME_DEFAULT, "-", "Welcome to Profanity, version %s", prof_version);
}
win_println(console, THEME_DEFAULT, "-", "Copyright (C) 2012 - 2019 James Booth <boothj5web@gmail.com>.");
@ -2171,16 +2159,6 @@ cons_color_setting(void)
}
}
void
cons_os_setting(void)
{
if (prefs_get_boolean(PREF_REVEAL_OS)) {
cons_show("Reveal OS name when asked for software version (XEP-0092) (/os) : ON");
} else {
cons_show("Reveal OS name when asked for software version (XEP-0092) (/os) : OFF");
}
}
void
cons_correction_setting(void)
{
@ -2788,15 +2766,8 @@ _cons_splash_logo(void)
win_println(console, THEME_SPLASH, "-", "|_| (____/ ");
win_println(console, THEME_SPLASH, "-", "");
if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION
win_println(console, THEME_DEFAULT, "-", "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else
win_println(console, THEME_DEFAULT, "Version %sdev", PACKAGE_VERSION);
#endif
} else {
win_println(console, THEME_DEFAULT, "-", "Version %s", PACKAGE_VERSION);
}
auto_gchar gchar* prof_version = prof_get_version();
win_println(console, THEME_DEFAULT, "-", "Version %s", prof_version);
}
static void
@ -2940,3 +2911,45 @@ cons_strophe_setting(void)
cons_show("XEP-0198 Stream-Management : %s", sm_setting);
cons_show("libstrophe Verbosity : %s", prefs_get_string(PREF_STROPHE_VERBOSITY));
}
void
cons_privacy_setting(void)
{
cons_show("Database logging : %s", prefs_get_string(PREF_DBLOG));
if (prefs_get_boolean(PREF_CHLOG)) {
cons_show("Chat logging (/logging chat) : ON");
} else {
cons_show("Chat logging (/logging chat) : OFF");
}
if (prefs_get_boolean(PREF_HISTORY)) {
cons_show("Chat history (/history) : ON");
} else {
cons_show("Chat history (/history) : OFF");
}
if (prefs_get_boolean(PREF_REVEAL_OS)) {
cons_show("Reveal OS name when asked for software");
cons_show("version (XEP-0092) (/privacy os) : ON");
} else {
cons_show("Reveal OS name when asked for software");
cons_show("version (XEP-0092) (/privacy os) : OFF");
}
if (connection_get_status() == JABBER_CONNECTED) {
char* account_name = session_get_account_name();
ProfAccount* account = accounts_get_account(account_name);
if (account->client) {
cons_show("Client name (/account set <account> clientid) : %s", account->client);
} else {
auto_gchar gchar* prof_version = prof_get_version();
cons_show("Client name (/account set <account> clientid) : Profanity %s", prof_version);
}
if (account->max_sessions > 0) {
cons_show("Max sessions alarm (/account set <account> session_alarm) : %s", account->max_sessions);
} else {
cons_show("Max sessions alarm (/account set <account> session_alarm) : not set");
}
}
}

View File

@ -35,10 +35,6 @@
#include "config.h"
#ifdef HAVE_GIT_VERSION
#include "gitversion.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <assert.h>

View File

@ -334,7 +334,6 @@ void cons_inpblock_setting(void);
void cons_statusbar_setting(void);
void cons_winpos_setting(void);
void cons_color_setting(void);
void cons_os_setting(void);
void cons_correction_setting(void);
void cons_executable_setting(void);
void cons_slashguard_setting(void);
@ -342,6 +341,7 @@ void cons_mam_setting(void);
void cons_silence_setting(void);
void cons_mood_setting(void);
void cons_strophe_setting(void);
void cons_privacy_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);

View File

@ -35,10 +35,6 @@
#include "config.h"
#ifdef HAVE_GIT_VERSION
#include "gitversion.h"
#endif
#include <stdlib.h>
#include <string.h>

View File

@ -35,10 +35,6 @@
#include "config.h"
#ifdef HAVE_GIT_VERSION
#include "gitversion.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@ -1627,20 +1623,10 @@ _version_get_handler(xmpp_stanza_t* const stanza)
xmpp_stanza_t* version = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(version, "version");
xmpp_stanza_t* version_txt = xmpp_stanza_new(ctx);
GString* version_str = g_string_new(PACKAGE_VERSION);
auto_gchar gchar* prof_version = prof_get_version();
if (!is_custom_client) {
if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION
g_string_append(version_str, "dev.");
g_string_append(version_str, PROF_GIT_BRANCH);
g_string_append(version_str, ".");
g_string_append(version_str, PROF_GIT_REVISION);
#else
g_string_append(version_str, "dev");
#endif
}
xmpp_stanza_set_text(version_txt, version_str->str);
xmpp_stanza_set_text(version_txt, prof_version);
xmpp_stanza_add_child(version, version_txt);
xmpp_stanza_add_child(query, version);
@ -1678,7 +1664,6 @@ _version_get_handler(xmpp_stanza_t* const stanza)
iq_send_stanza(response);
// Cleanup
g_string_free(version_str, TRUE);
xmpp_stanza_release(version_txt);
xmpp_stanza_release(name_txt);
if (!is_custom_client && include_os) {

View File

@ -35,10 +35,6 @@
#include "config.h"
#ifdef HAVE_GIT_VERSION
#include "gitversion.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@ -963,17 +959,8 @@ stanza_create_caps_query_element(xmpp_ctx_t* ctx)
GString* name_str = g_string_new(is_custom_client ? client : "Profanity ");
if (!is_custom_client) {
xmpp_stanza_set_type(identity, "console");
g_string_append(name_str, PACKAGE_VERSION);
if (g_strcmp0(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION
g_string_append(name_str, "dev.");
g_string_append(name_str, PROF_GIT_BRANCH);
g_string_append(name_str, ".");
g_string_append(name_str, PROF_GIT_REVISION);
#else
g_string_append(name_str, "dev");
#endif
}
auto_gchar gchar* prof_version = prof_get_version();
g_string_append(name_str, prof_version);
}
account_free(account);

View File

@ -1125,10 +1125,6 @@ cons_tray_setting(void)
{
}
void
cons_os_setting(void)
{
}
void
cons_correction_setting(void)
{
}
@ -1160,6 +1156,11 @@ cons_strophe_setting(void)
{
}
void
cons_privacy_setting(void)
{
}
void
cons_show_bookmarks_ignore(gchar** list, gsize len)
{