mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Revert "Apply coding style"
This reverts commit 9b55f2dec0ea27a9ce4856e303425e12f866cea2. Sorting the includes creates some problems.
This commit is contained in:
parent
28fde3cd01
commit
a4cadf78fa
File diff suppressed because it is too large
Load Diff
@ -36,28 +36,28 @@
|
||||
#ifndef COMMAND_CMD_AC_H
|
||||
#define COMMAND_CMD_AC_H
|
||||
|
||||
#include "command/cmd_funcs.h"
|
||||
#include "config/preferences.h"
|
||||
#include "command/cmd_funcs.h"
|
||||
|
||||
void cmd_ac_init(void);
|
||||
void cmd_ac_uninit(void);
|
||||
char* cmd_ac_complete(ProfWin* window, const char* const input, gboolean previous);
|
||||
void cmd_ac_reset(ProfWin* window);
|
||||
gboolean cmd_ac_exists(char* cmd);
|
||||
char* cmd_ac_complete(ProfWin *window, const char *const input, gboolean previous);
|
||||
void cmd_ac_reset(ProfWin *window);
|
||||
gboolean cmd_ac_exists(char *cmd);
|
||||
|
||||
void cmd_ac_add(const char* const value);
|
||||
void cmd_ac_add_help(const char* const value);
|
||||
void cmd_ac_add_cmd(Command* command);
|
||||
void cmd_ac_add_alias(ProfAlias* alias);
|
||||
void cmd_ac_add_alias_value(char* value);
|
||||
void cmd_ac_add(const char *const value);
|
||||
void cmd_ac_add_help(const char *const value);
|
||||
void cmd_ac_add_cmd(Command *command);
|
||||
void cmd_ac_add_alias(ProfAlias *alias);
|
||||
void cmd_ac_add_alias_value(char *value);
|
||||
|
||||
void cmd_ac_remove(const char* const value);
|
||||
void cmd_ac_remove_help(const char* const value);
|
||||
void cmd_ac_remove_alias_value(char* value);
|
||||
void cmd_ac_remove(const char *const value);
|
||||
void cmd_ac_remove_help(const char *const value);
|
||||
void cmd_ac_remove_alias_value(char *value);
|
||||
|
||||
void cmd_ac_add_form_fields(DataForm* form);
|
||||
void cmd_ac_remove_form_fields(DataForm* form);
|
||||
void cmd_ac_add_form_fields(DataForm *form);
|
||||
void cmd_ac_remove_form_fields(DataForm *form);
|
||||
|
||||
char* cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean previous);
|
||||
char* cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean previous);
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -44,14 +44,14 @@
|
||||
void cmd_init(void);
|
||||
void cmd_uninit(void);
|
||||
|
||||
Command* cmd_get(const char* const command);
|
||||
GList* cmd_get_ordered(const char* const tag);
|
||||
Command* cmd_get(const char *const command);
|
||||
GList* cmd_get_ordered(const char *const tag);
|
||||
|
||||
gboolean cmd_valid_tag(const char* const str);
|
||||
gboolean cmd_valid_tag(const char *const str);
|
||||
|
||||
void command_docgen(void);
|
||||
|
||||
GList* cmd_search_index_all(char* term);
|
||||
GList* cmd_search_index_any(char* term);
|
||||
GList* cmd_search_index_all(char *term);
|
||||
GList* cmd_search_index_any(char *term);
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -40,13 +40,12 @@
|
||||
#include "ui/win_types.h"
|
||||
|
||||
// Command help strings
|
||||
typedef struct cmd_help_t
|
||||
{
|
||||
gchar* tags[20];
|
||||
gchar* synopsis[50];
|
||||
gchar* desc;
|
||||
gchar* args[128][2];
|
||||
gchar* examples[20];
|
||||
typedef struct cmd_help_t {
|
||||
gchar *tags[20];
|
||||
gchar *synopsis[50];
|
||||
gchar *desc;
|
||||
gchar *args[128][2];
|
||||
gchar *examples[20];
|
||||
} CommandHelp;
|
||||
|
||||
/*
|
||||
@ -61,184 +60,184 @@ typedef struct cmd_help_t
|
||||
* func - Main function to call when no arguments, or sub_funcs not implemented
|
||||
* help - A help struct containing usage info etc
|
||||
*/
|
||||
typedef struct cmd_t
|
||||
{
|
||||
gchar* cmd;
|
||||
gchar** (*parser)(const char* const inp, int min, int max, gboolean* result);
|
||||
typedef struct cmd_t {
|
||||
gchar *cmd;
|
||||
gchar** (*parser)(const char *const inp, int min, int max, gboolean *result);
|
||||
int min_args;
|
||||
int max_args;
|
||||
void (*setting_func)(void);
|
||||
void* sub_funcs[50][2];
|
||||
gboolean (*func)(ProfWin* window, const char* const command, gchar** args);
|
||||
void *sub_funcs[50][2];
|
||||
gboolean (*func)(ProfWin *window, const char *const command, gchar **args);
|
||||
CommandHelp help;
|
||||
} Command;
|
||||
|
||||
gboolean cmd_process_input(ProfWin* window, char* inp);
|
||||
void cmd_execute_connect(ProfWin* window, const char* const account);
|
||||
|
||||
gboolean cmd_about(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_autoaway(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_autoconnect(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_autoping(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_beep(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_caps(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_logging(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_clear(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_close(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_connect(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_disco(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_sendfile(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_lastactivity(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_disconnect(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_flash(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_tray(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_gone(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_group(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_help(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_history(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_carbons(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_receipts(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_info(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_intype(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_invite(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_join(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_leave(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_log(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_msg(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_nick(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_notify(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_pgp(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_process_input(ProfWin *window, char *inp);
|
||||
void cmd_execute_connect(ProfWin *window, const char *const account);
|
||||
|
||||
gboolean cmd_about(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_autoaway(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_autoconnect(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_autoping(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_beep(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_caps(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_logging(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_clear(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_close(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_connect(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_disco(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_sendfile(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_lastactivity(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_disconnect(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_flash(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_tray(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_gone(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_group(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_help(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_history(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_carbons(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_receipts(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_info(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_intype(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_invite(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_join(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_leave(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_log(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_msg(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_nick(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_notify(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_pgp(ProfWin *window, const char *const command, gchar **args);
|
||||
#ifdef HAVE_LIBGPGME
|
||||
gboolean cmd_ox(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_ox(ProfWin *window, const char *const command, gchar **args);
|
||||
#endif // HAVE_LIBGPGME
|
||||
gboolean cmd_outtype(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_prefs(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_priority(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_quit(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_reconnect(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_room(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_rooms(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_bookmark(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_bookmark_ignore(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_roster(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_software(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_splash(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_states(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_status_get(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_status_set(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_sub(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_theme(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_tiny(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_wintitle(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_vercheck(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_who(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_win(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_alias(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_xmlconsole(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_ping(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_form(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_occupants(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_kick(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_ban(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_subject(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_affiliation(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_role(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_privileges(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_presence(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_wrap(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_time(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_resource(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_inpblock(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_titlebar(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_titlebar_show_hide(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_mainwin(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_statusbar(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_inputwin(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_script(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_export(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_charset(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_console(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_command_list(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_command_exec(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_outtype(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_prefs(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_priority(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_quit(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_reconnect(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_room(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_rooms(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_bookmark(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_bookmark_ignore(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_roster(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_software(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_splash(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_states(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_status_get(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_status_set(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_sub(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_theme(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_tiny(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_wintitle(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_vercheck(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_who(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_win(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_alias(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_xmlconsole(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_ping(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_form(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_occupants(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_kick(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_ban(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_subject(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_affiliation(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_role(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_privileges(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_presence(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_wrap(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_time(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_resource(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_inpblock(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_titlebar(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_mainwin(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_statusbar(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_inputwin(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_script(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_export(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_charset(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_console(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_command_list(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_command_exec(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
gboolean cmd_plugins(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_plugins_sourcepath(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_plugins_install(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_plugins_update(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_plugins_uninstall(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_plugins_load(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_plugins_unload(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_plugins_reload(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_plugins_python_version(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_plugins(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_plugins_sourcepath(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_plugins_install(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_plugins_update(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_plugins_uninstall(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_plugins_load(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_plugins_unload(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_plugins_reload(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_plugins_python_version(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
gboolean cmd_blocked(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_blocked(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
gboolean cmd_account(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_account_list(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_account_show(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_account_add(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_account_remove(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_account_enable(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_account_disable(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_account_rename(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_account_default(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_account_set(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_account_clear(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_account(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_account_list(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_account_show(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_account_add(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_account_remove(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_account_enable(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_account_disable(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_account_rename(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_account_default(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_account_set(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_account_clear(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
gboolean cmd_tls_certpath(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_tls_trust(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_tls_trusted(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_tls_revoke(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_tls_cert(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_tls_certpath(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_tls_trust(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_tls_trusted(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_tls_revoke(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_tls_cert(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
gboolean cmd_otr_char(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_log(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_libver(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_policy(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_gen(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_myfp(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_theirfp(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_start(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_end(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_trust(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_untrust(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_secret(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_question(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_answer(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_sendfile(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_otr_char(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_log(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_libver(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_policy(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_gen(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_myfp(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_theirfp(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_start(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_end(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_trust(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_untrust(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_secret(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_question(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_answer(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_sendfile(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
gboolean cmd_wins(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_wins_unread(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_wins_prune(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_wins_swap(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_wins(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_wins_unread(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_wins_prune(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_wins_swap(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
gboolean cmd_form_field(ProfWin* window, char* tag, gchar** args);
|
||||
gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args);
|
||||
|
||||
gboolean cmd_omemo_gen(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_omemo_char(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_omemo_log(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_omemo_start(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_omemo_end(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_omemo_fingerprint(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_omemo_trust(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_omemo_untrust(ProfWin* window, const char* const command, gchar** args);
|
||||
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_sendfile(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_omemo_gen(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_omemo_char(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_omemo_log(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_omemo_start(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_omemo_end(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args);
|
||||
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_sendfile(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);
|
||||
gboolean cmd_save(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_reload(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
gboolean cmd_paste(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_color(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_avatar(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_os(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_correction(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_correct(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_slashguard(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_serversoftware(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_url_open(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_url_save(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_executable(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_paste(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_color(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_avatar(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_os(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_correction(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_correct(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_slashguard(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_serversoftware(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_url_open(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_url_save(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_executable(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
#endif
|
||||
|
190
src/common.c
190
src/common.c
@ -35,20 +35,20 @@
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <sys/select.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/easy.h>
|
||||
#include <gio/gio.h>
|
||||
#include <glib.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#ifdef HAVE_NCURSESW_NCURSES_H
|
||||
#include <ncursesw/ncurses.h>
|
||||
@ -56,19 +56,19 @@
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "log.h"
|
||||
#include "common.h"
|
||||
|
||||
struct curl_data_t
|
||||
{
|
||||
char* buffer;
|
||||
char *buffer;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
static size_t _data_callback(void* ptr, size_t size, size_t nmemb, void* data);
|
||||
static size_t _data_callback(void *ptr, size_t size, size_t nmemb, void *data);
|
||||
|
||||
gboolean
|
||||
create_dir(char* name)
|
||||
create_dir(char *name)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
@ -87,14 +87,14 @@ create_dir(char* name)
|
||||
}
|
||||
|
||||
gboolean
|
||||
mkdir_recursive(const char* dir)
|
||||
mkdir_recursive(const char *dir)
|
||||
{
|
||||
int i;
|
||||
gboolean result = TRUE;
|
||||
|
||||
for (i = 1; i <= strlen(dir); i++) {
|
||||
if (dir[i] == '/' || dir[i] == '\0') {
|
||||
gchar* next_dir = g_strndup(dir, i);
|
||||
gchar *next_dir = g_strndup(dir, i);
|
||||
result = create_dir(next_dir);
|
||||
g_free(next_dir);
|
||||
if (!result) {
|
||||
@ -107,13 +107,13 @@ mkdir_recursive(const char* dir)
|
||||
}
|
||||
|
||||
gboolean
|
||||
copy_file(const char* const sourcepath, const char* const targetpath, const gboolean overwrite_existing)
|
||||
copy_file(const char *const sourcepath, const char *const targetpath, const gboolean overwrite_existing)
|
||||
{
|
||||
GFile* source = g_file_new_for_path(sourcepath);
|
||||
GFile* dest = g_file_new_for_path(targetpath);
|
||||
GError* error = NULL;
|
||||
GFile *source = g_file_new_for_path(sourcepath);
|
||||
GFile *dest = g_file_new_for_path(targetpath);
|
||||
GError *error = NULL;
|
||||
GFileCopyFlags flags = overwrite_existing ? G_FILE_COPY_OVERWRITE : G_FILE_COPY_NONE;
|
||||
gboolean success = g_file_copy(source, dest, flags, NULL, NULL, NULL, &error);
|
||||
gboolean success = g_file_copy (source, dest, flags, NULL, NULL, NULL, &error);
|
||||
if (error != NULL)
|
||||
g_error_free(error);
|
||||
g_object_unref(source);
|
||||
@ -122,40 +122,44 @@ copy_file(const char* const sourcepath, const char* const targetpath, const gboo
|
||||
}
|
||||
|
||||
char*
|
||||
str_replace(const char* string, const char* substr, const char* replacement)
|
||||
str_replace(const char *string, const char *substr,
|
||||
const char *replacement)
|
||||
{
|
||||
char* tok = NULL;
|
||||
char* newstr = NULL;
|
||||
char* head = NULL;
|
||||
char *tok = NULL;
|
||||
char *newstr = NULL;
|
||||
char *head = NULL;
|
||||
|
||||
if (string == NULL)
|
||||
return NULL;
|
||||
|
||||
if (substr == NULL || replacement == NULL || (strcmp(substr, "") == 0))
|
||||
return strdup(string);
|
||||
if ( substr == NULL ||
|
||||
replacement == NULL ||
|
||||
(strcmp(substr, "") == 0))
|
||||
return strdup (string);
|
||||
|
||||
newstr = strdup(string);
|
||||
newstr = strdup (string);
|
||||
head = newstr;
|
||||
|
||||
while ((tok = strstr(head, substr))) {
|
||||
char* oldstr = newstr;
|
||||
newstr = malloc(strlen(oldstr) - strlen(substr) + strlen(replacement) + 1);
|
||||
while ( (tok = strstr ( head, substr ))) {
|
||||
char *oldstr = newstr;
|
||||
newstr = malloc ( strlen ( oldstr ) - strlen ( substr ) +
|
||||
strlen ( replacement ) + 1 );
|
||||
|
||||
if (newstr == NULL) {
|
||||
free(oldstr);
|
||||
if ( newstr == NULL ) {
|
||||
free (oldstr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(newstr, oldstr, tok - oldstr);
|
||||
memcpy(newstr + (tok - oldstr), replacement, strlen(replacement));
|
||||
memcpy(newstr + (tok - oldstr) + strlen(replacement),
|
||||
tok + strlen(substr),
|
||||
strlen(oldstr) - strlen(substr) - (tok - oldstr));
|
||||
memset(newstr + strlen(oldstr) - strlen(substr) + strlen(replacement),
|
||||
0, 1);
|
||||
memcpy ( newstr, oldstr, tok - oldstr );
|
||||
memcpy ( newstr + (tok - oldstr), replacement, strlen ( replacement ) );
|
||||
memcpy ( newstr + (tok - oldstr) + strlen( replacement ),
|
||||
tok + strlen ( substr ),
|
||||
strlen ( oldstr ) - strlen ( substr ) - ( tok - oldstr ) );
|
||||
memset ( newstr + strlen ( oldstr ) - strlen ( substr ) +
|
||||
strlen ( replacement ) , 0, 1 );
|
||||
|
||||
head = newstr + (tok - oldstr) + strlen(replacement);
|
||||
free(oldstr);
|
||||
head = newstr + (tok - oldstr) + strlen( replacement );
|
||||
free (oldstr);
|
||||
}
|
||||
|
||||
return newstr;
|
||||
@ -174,21 +178,21 @@ str_contains(const char str[], int size, char ch)
|
||||
}
|
||||
|
||||
gboolean
|
||||
strtoi_range(char* str, int* saveptr, int min, int max, char** err_msg)
|
||||
strtoi_range(char *str, int *saveptr, int min, int max, char **err_msg)
|
||||
{
|
||||
char* ptr;
|
||||
char *ptr;
|
||||
int val;
|
||||
|
||||
errno = 0;
|
||||
val = (int)strtol(str, &ptr, 0);
|
||||
if (errno != 0 || *str == '\0' || *ptr != '\0') {
|
||||
GString* err_str = g_string_new("");
|
||||
GString *err_str = g_string_new("");
|
||||
g_string_printf(err_str, "Could not convert \"%s\" to a number.", str);
|
||||
*err_msg = err_str->str;
|
||||
g_string_free(err_str, FALSE);
|
||||
return FALSE;
|
||||
} else if (val < min || val > max) {
|
||||
GString* err_str = g_string_new("");
|
||||
GString *err_str = g_string_new("");
|
||||
g_string_printf(err_str, "Value %s out of range. Must be in %d..%d.", str, min, max);
|
||||
*err_msg = err_str->str;
|
||||
g_string_free(err_str, FALSE);
|
||||
@ -201,20 +205,20 @@ strtoi_range(char* str, int* saveptr, int min, int max, char** err_msg)
|
||||
}
|
||||
|
||||
int
|
||||
utf8_display_len(const char* const str)
|
||||
utf8_display_len(const char *const str)
|
||||
{
|
||||
if (!str) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int len = 0;
|
||||
gchar* curr = g_utf8_offset_to_pointer(str, 0);
|
||||
gchar *curr = g_utf8_offset_to_pointer(str, 0);
|
||||
while (*curr != '\0') {
|
||||
gunichar curru = g_utf8_get_char(curr);
|
||||
if (g_unichar_iswide(curru)) {
|
||||
len += 2;
|
||||
} else {
|
||||
len++;
|
||||
len ++;
|
||||
}
|
||||
curr = g_utf8_next_char(curr);
|
||||
}
|
||||
@ -225,9 +229,9 @@ utf8_display_len(const char* const str)
|
||||
char*
|
||||
release_get_latest(void)
|
||||
{
|
||||
char* url = "https://profanity-im.github.io/profanity_version.txt";
|
||||
char *url = "https://profanity-im.github.io/profanity_version.txt";
|
||||
|
||||
CURL* handle = curl_easy_init();
|
||||
CURL *handle = curl_easy_init();
|
||||
struct curl_data_t output;
|
||||
output.buffer = NULL;
|
||||
output.size = 0;
|
||||
@ -235,7 +239,7 @@ release_get_latest(void)
|
||||
curl_easy_setopt(handle, CURLOPT_URL, url);
|
||||
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, _data_callback);
|
||||
curl_easy_setopt(handle, CURLOPT_TIMEOUT, 2);
|
||||
curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void*)&output);
|
||||
curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void *)&output);
|
||||
|
||||
curl_easy_perform(handle);
|
||||
curl_easy_cleanup(handle);
|
||||
@ -249,21 +253,22 @@ release_get_latest(void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
release_is_new(char* found_version)
|
||||
release_is_new(char *found_version)
|
||||
{
|
||||
int curr_maj, curr_min, curr_patch, found_maj, found_min, found_patch;
|
||||
|
||||
int parse_curr = sscanf(PACKAGE_VERSION, "%d.%d.%d", &curr_maj, &curr_min,
|
||||
&curr_patch);
|
||||
&curr_patch);
|
||||
int parse_found = sscanf(found_version, "%d.%d.%d", &found_maj, &found_min,
|
||||
&found_patch);
|
||||
&found_patch);
|
||||
|
||||
if (parse_found == 3 && parse_curr == 3) {
|
||||
if (found_maj > curr_maj) {
|
||||
return TRUE;
|
||||
} else if (found_maj == curr_maj && found_min > curr_min) {
|
||||
return TRUE;
|
||||
} else if (found_maj == curr_maj && found_min == curr_min && found_patch > curr_patch) {
|
||||
} else if (found_maj == curr_maj && found_min == curr_min
|
||||
&& found_patch > curr_patch) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
@ -274,25 +279,26 @@ release_is_new(char* found_version)
|
||||
}
|
||||
|
||||
static size_t
|
||||
_data_callback(void* ptr, size_t size, size_t nmemb, void* data)
|
||||
_data_callback(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
struct curl_data_t* mem = (struct curl_data_t*)data;
|
||||
struct curl_data_t *mem = (struct curl_data_t *) data;
|
||||
mem->buffer = realloc(mem->buffer, mem->size + realsize + 1);
|
||||
|
||||
if (mem->buffer) {
|
||||
memcpy(&(mem->buffer[mem->size]), ptr, realsize);
|
||||
if ( mem->buffer )
|
||||
{
|
||||
memcpy( &( mem->buffer[ mem->size ] ), ptr, realsize );
|
||||
mem->size += realsize;
|
||||
mem->buffer[mem->size] = 0;
|
||||
mem->buffer[ mem->size ] = 0;
|
||||
}
|
||||
|
||||
return realsize;
|
||||
}
|
||||
|
||||
char*
|
||||
get_file_or_linked(char* loc, char* basedir)
|
||||
get_file_or_linked(char *loc, char *basedir)
|
||||
{
|
||||
char* true_loc = NULL;
|
||||
char *true_loc = NULL;
|
||||
|
||||
// check for symlink
|
||||
if (g_file_test(loc, G_FILE_TEST_IS_SYMLINK)) {
|
||||
@ -300,14 +306,14 @@ get_file_or_linked(char* loc, char* basedir)
|
||||
|
||||
// if relative, add basedir
|
||||
if (!g_str_has_prefix(true_loc, "/") && !g_str_has_prefix(true_loc, "~")) {
|
||||
GString* base_str = g_string_new(basedir);
|
||||
GString *base_str = g_string_new(basedir);
|
||||
g_string_append(base_str, "/");
|
||||
g_string_append(base_str, true_loc);
|
||||
free(true_loc);
|
||||
true_loc = base_str->str;
|
||||
g_string_free(base_str, FALSE);
|
||||
}
|
||||
// use given location
|
||||
// use given location
|
||||
} else {
|
||||
true_loc = strdup(loc);
|
||||
}
|
||||
@ -316,21 +322,21 @@ get_file_or_linked(char* loc, char* basedir)
|
||||
}
|
||||
|
||||
char*
|
||||
strip_arg_quotes(const char* const input)
|
||||
strip_arg_quotes(const char *const input)
|
||||
{
|
||||
char* unquoted = strdup(input);
|
||||
char *unquoted = strdup(input);
|
||||
|
||||
// Remove starting quote if it exists
|
||||
if (strchr(unquoted, '"')) {
|
||||
if (strchr(unquoted, ' ') + 1 == strchr(unquoted, '"')) {
|
||||
memmove(strchr(unquoted, '"'), strchr(unquoted, '"') + 1, strchr(unquoted, '\0') - strchr(unquoted, '"'));
|
||||
if(strchr(unquoted, '"')) {
|
||||
if(strchr(unquoted, ' ') + 1 == strchr(unquoted, '"')) {
|
||||
memmove(strchr(unquoted, '"'), strchr(unquoted, '"')+1, strchr(unquoted, '\0') - strchr(unquoted, '"'));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove ending quote if it exists
|
||||
if (strchr(unquoted, '"')) {
|
||||
if (strchr(unquoted, '\0') - 1 == strchr(unquoted, '"')) {
|
||||
memmove(strchr(unquoted, '"'), strchr(unquoted, '"') + 1, strchr(unquoted, '\0') - strchr(unquoted, '"'));
|
||||
if(strchr(unquoted, '"')) {
|
||||
if(strchr(unquoted, '\0') - 1 == strchr(unquoted, '"')) {
|
||||
memmove(strchr(unquoted, '"'), strchr(unquoted, '"')+1, strchr(unquoted, '\0') - strchr(unquoted, '"'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,23 +362,23 @@ is_notify_enabled(void)
|
||||
}
|
||||
|
||||
GSList*
|
||||
prof_occurrences(const char* const needle, const char* const haystack, int offset, gboolean whole_word, GSList** result)
|
||||
prof_occurrences(const char *const needle, const char *const haystack, int offset, gboolean whole_word, GSList **result)
|
||||
{
|
||||
if (needle == NULL || haystack == NULL) {
|
||||
return *result;
|
||||
}
|
||||
|
||||
gchar* haystack_curr = g_utf8_offset_to_pointer(haystack, offset);
|
||||
gchar *haystack_curr = g_utf8_offset_to_pointer(haystack, offset);
|
||||
if (g_str_has_prefix(haystack_curr, needle)) {
|
||||
if (whole_word) {
|
||||
gunichar before = 0;
|
||||
gchar* haystack_before_ch = g_utf8_find_prev_char(haystack, haystack_curr);
|
||||
gchar *haystack_before_ch = g_utf8_find_prev_char(haystack, haystack_curr);
|
||||
if (haystack_before_ch) {
|
||||
before = g_utf8_get_char(haystack_before_ch);
|
||||
}
|
||||
|
||||
gunichar after = 0;
|
||||
gchar* haystack_after_ch = haystack_curr + strlen(needle);
|
||||
gchar *haystack_after_ch = haystack_curr + strlen(needle);
|
||||
if (haystack_after_ch[0] != '\0') {
|
||||
after = g_utf8_get_char(haystack_after_ch);
|
||||
}
|
||||
@ -394,7 +400,7 @@ prof_occurrences(const char* const needle, const char* const haystack, int offse
|
||||
}
|
||||
|
||||
int
|
||||
is_regular_file(const char* path)
|
||||
is_regular_file(const char *path)
|
||||
{
|
||||
struct stat st;
|
||||
int ret = stat(path, &st);
|
||||
@ -406,7 +412,7 @@ is_regular_file(const char* path)
|
||||
}
|
||||
|
||||
int
|
||||
is_dir(const char* path)
|
||||
is_dir(const char *path)
|
||||
{
|
||||
struct stat st;
|
||||
int ret = stat(path, &st);
|
||||
@ -418,16 +424,16 @@ is_dir(const char* path)
|
||||
}
|
||||
|
||||
void
|
||||
get_file_paths_recursive(const char* path, GSList** contents)
|
||||
get_file_paths_recursive(const char *path, GSList **contents)
|
||||
{
|
||||
if (!is_dir(path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GDir* directory = g_dir_open(path, 0, NULL);
|
||||
const gchar* entry = g_dir_read_name(directory);
|
||||
const gchar *entry = g_dir_read_name(directory);
|
||||
while (entry) {
|
||||
GString* full = g_string_new(path);
|
||||
GString *full = g_string_new(path);
|
||||
if (!g_str_has_suffix(full->str, "/")) {
|
||||
g_string_append(full, "/");
|
||||
}
|
||||
@ -447,11 +453,11 @@ get_file_paths_recursive(const char* path, GSList** contents)
|
||||
char*
|
||||
get_random_string(int length)
|
||||
{
|
||||
GRand* prng;
|
||||
char* rand;
|
||||
GRand *prng;
|
||||
char *rand;
|
||||
char alphabet[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
rand = calloc(length + 1, sizeof(char));
|
||||
rand = calloc(length+1, sizeof(char));
|
||||
|
||||
prng = g_rand_new();
|
||||
|
||||
@ -465,11 +471,11 @@ get_random_string(int length)
|
||||
}
|
||||
|
||||
GSList*
|
||||
get_mentions(gboolean whole_word, gboolean case_sensitive, const char* const message, const char* const nick)
|
||||
get_mentions(gboolean whole_word, gboolean case_sensitive, const char *const message, const char *const nick)
|
||||
{
|
||||
GSList* mentions = NULL;
|
||||
gchar* message_search = case_sensitive ? g_strdup(message) : g_utf8_strdown(message, -1);
|
||||
gchar* mynick_search = case_sensitive ? g_strdup(nick) : g_utf8_strdown(nick, -1);
|
||||
GSList *mentions = NULL;
|
||||
gchar *message_search = case_sensitive ? g_strdup(message) : g_utf8_strdown(message, -1);
|
||||
gchar *mynick_search = case_sensitive ? g_strdup(nick) : g_utf8_strdown(nick, -1);
|
||||
|
||||
mentions = prof_occurrences(mynick_search, message_search, 0, whole_word, &mentions);
|
||||
|
||||
@ -498,16 +504,16 @@ get_mentions(gboolean whole_word, gboolean case_sensitive, const char* const mes
|
||||
* - FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
call_external(gchar** argv, gchar*** const output_ptr, gchar*** const error_ptr)
|
||||
call_external(gchar **argv, gchar ***const output_ptr, gchar ***const error_ptr)
|
||||
{
|
||||
gchar* stdout_str = NULL;
|
||||
gchar** stdout_str_ptr = &stdout_str;
|
||||
gchar* stderr_str = NULL;
|
||||
gchar** stderr_str_ptr = &stderr_str;
|
||||
gchar *stdout_str = NULL;
|
||||
gchar **stdout_str_ptr = &stdout_str;
|
||||
gchar *stderr_str = NULL;
|
||||
gchar **stderr_str_ptr = &stderr_str;
|
||||
GSpawnFlags flags = G_SPAWN_SEARCH_PATH;
|
||||
gint status;
|
||||
GError* error = NULL;
|
||||
gchar* cmd = NULL;
|
||||
GError *error = NULL;
|
||||
gchar *cmd = NULL;
|
||||
|
||||
cmd = g_strjoinv(" ", argv);
|
||||
log_debug("Calling external: %s", cmd);
|
||||
@ -522,7 +528,7 @@ call_external(gchar** argv, gchar*** const output_ptr, gchar*** const error_ptr)
|
||||
flags |= G_SPAWN_STDERR_TO_DEV_NULL;
|
||||
}
|
||||
|
||||
if (!g_spawn_sync(NULL, argv, NULL, flags, NULL, NULL, stdout_str_ptr, stderr_str_ptr, &status, &error)) {
|
||||
if (!g_spawn_sync (NULL, argv, NULL, flags, NULL, NULL, stdout_str_ptr, stderr_str_ptr, &status, &error)) {
|
||||
log_error("Spawning '%s' failed: %s.", cmd, error->message);
|
||||
g_error_free(error);
|
||||
error = NULL;
|
||||
|
51
src/common.h
51
src/common.h
@ -45,23 +45,24 @@
|
||||
#define notify_notification_new(summary, body, icon) notify_notification_new(summary, body, icon, NULL)
|
||||
#endif
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
||||
|
||||
// assume malloc stores at most 8 bytes for size of allocated memory
|
||||
// and page size is at least 4KB
|
||||
#define READ_BUF_SIZE 4088
|
||||
|
||||
|
||||
#define FREE_SET_NULL(resource) \
|
||||
do { \
|
||||
free(resource); \
|
||||
resource = NULL; \
|
||||
} while (0)
|
||||
do { \
|
||||
free(resource); \
|
||||
resource = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define GFREE_SET_NULL(resource) \
|
||||
do { \
|
||||
g_free(resource); \
|
||||
resource = NULL; \
|
||||
} while (0)
|
||||
do { \
|
||||
g_free(resource); \
|
||||
resource = NULL; \
|
||||
} while (0)
|
||||
|
||||
typedef enum {
|
||||
CONTACT_OFFLINE,
|
||||
@ -80,31 +81,31 @@ typedef enum {
|
||||
RESOURCE_XA
|
||||
} resource_presence_t;
|
||||
|
||||
gboolean create_dir(char* name);
|
||||
gboolean mkdir_recursive(const char* dir);
|
||||
gboolean copy_file(const char* const src, const char* const target, const gboolean overwrite_existing);
|
||||
char* str_replace(const char* string, const char* substr, const char* replacement);
|
||||
gboolean create_dir(char *name);
|
||||
gboolean mkdir_recursive(const char *dir);
|
||||
gboolean copy_file(const char *const src, const char *const target, const gboolean overwrite_existing);
|
||||
char* str_replace(const char *string, const char *substr, const char *replacement);
|
||||
int str_contains(const char str[], int size, char ch);
|
||||
gboolean strtoi_range(char* str, int* saveptr, int min, int max, char** err_msg);
|
||||
int utf8_display_len(const char* const str);
|
||||
gboolean strtoi_range(char *str, int *saveptr, int min, int max, char **err_msg);
|
||||
int utf8_display_len(const char *const str);
|
||||
|
||||
char* release_get_latest(void);
|
||||
gboolean release_is_new(char* found_version);
|
||||
gboolean release_is_new(char *found_version);
|
||||
|
||||
char* get_file_or_linked(char* loc, char* basedir);
|
||||
char* strip_arg_quotes(const char* const input);
|
||||
char* get_file_or_linked(char *loc, char *basedir);
|
||||
char* strip_arg_quotes(const char *const input);
|
||||
gboolean is_notify_enabled(void);
|
||||
|
||||
GSList* prof_occurrences(const char* const needle, const char* const haystack, int offset, gboolean whole_word,
|
||||
GSList** result);
|
||||
GSList* get_mentions(gboolean whole_word, gboolean case_sensitive, const char* const message, const char* const nick);
|
||||
GSList* prof_occurrences(const char *const needle, const char *const haystack, int offset, gboolean whole_word,
|
||||
GSList **result);
|
||||
GSList* get_mentions(gboolean whole_word, gboolean case_sensitive, const char *const message, const char *const nick);
|
||||
|
||||
int is_regular_file(const char* path);
|
||||
int is_dir(const char* path);
|
||||
void get_file_paths_recursive(const char* directory, GSList** contents);
|
||||
int is_regular_file(const char *path);
|
||||
int is_dir(const char *path);
|
||||
void get_file_paths_recursive(const char *directory, GSList **contents);
|
||||
|
||||
char* get_random_string(int length);
|
||||
|
||||
gboolean call_external(gchar** argv, gchar*** const output_ptr, gchar*** const error_ptr);
|
||||
gboolean call_external(gchar **argv, gchar ***const output_ptr, gchar ***const error_ptr);
|
||||
|
||||
#endif
|
||||
|
@ -33,31 +33,31 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "config/account.h"
|
||||
#include "log.h"
|
||||
#include "config/account.h"
|
||||
#include "xmpp/jid.h"
|
||||
#include "xmpp/resource.h"
|
||||
|
||||
ProfAccount*
|
||||
account_new(const gchar* const name, const gchar* const jid,
|
||||
const gchar* const password, const gchar* eval_password, gboolean enabled, const gchar* const server,
|
||||
int port, const gchar* const resource, const gchar* const last_presence,
|
||||
const gchar* const login_presence, int priority_online, int priority_chat,
|
||||
int priority_away, int priority_xa, int priority_dnd,
|
||||
const gchar* const muc_service, const gchar* const muc_nick,
|
||||
const gchar* const otr_policy, GList* otr_manual, GList* otr_opportunistic,
|
||||
GList* otr_always, const gchar* const omemo_policy, GList* omemo_enabled,
|
||||
GList* omemo_disabled, const gchar* const pgp_keyid, const char* const startscript,
|
||||
const char* const theme, gchar* tls_policy, gchar* auth_policy)
|
||||
account_new(const gchar *const name, const gchar *const jid,
|
||||
const gchar *const password, const gchar *eval_password, gboolean enabled, const gchar *const server,
|
||||
int port, const gchar *const resource, const gchar *const last_presence,
|
||||
const gchar *const login_presence, int priority_online, int priority_chat,
|
||||
int priority_away, int priority_xa, int priority_dnd,
|
||||
const gchar *const muc_service, const gchar *const muc_nick,
|
||||
const gchar *const otr_policy, GList *otr_manual, GList *otr_opportunistic,
|
||||
GList *otr_always, const gchar *const omemo_policy, GList *omemo_enabled,
|
||||
GList *omemo_disabled, const gchar *const pgp_keyid, const char *const startscript,
|
||||
const char *const theme, gchar *tls_policy, gchar *auth_policy)
|
||||
{
|
||||
ProfAccount* new_account = malloc(sizeof(ProfAccount));
|
||||
ProfAccount *new_account = malloc(sizeof(ProfAccount));
|
||||
memset(new_account, 0, sizeof(ProfAccount));
|
||||
|
||||
new_account->name = strdup(name);
|
||||
@ -125,7 +125,7 @@ account_new(const gchar* const name, const gchar* const jid,
|
||||
}
|
||||
|
||||
if (muc_nick == NULL) {
|
||||
Jid* jidp = jid_create(new_account->jid);
|
||||
Jid *jidp = jid_create(new_account->jid);
|
||||
new_account->muc_nick = strdup(jidp->domainpart);
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
@ -185,7 +185,7 @@ account_new(const gchar* const name, const gchar* const jid,
|
||||
}
|
||||
|
||||
char*
|
||||
account_create_connect_jid(ProfAccount* account)
|
||||
account_create_connect_jid(ProfAccount *account)
|
||||
{
|
||||
if (account->resource) {
|
||||
return create_fulljid(account->jid, account->resource);
|
||||
@ -195,15 +195,15 @@ account_create_connect_jid(ProfAccount* account)
|
||||
}
|
||||
|
||||
gboolean
|
||||
account_eval_password(ProfAccount* account)
|
||||
account_eval_password(ProfAccount *account)
|
||||
{
|
||||
assert(account != NULL);
|
||||
assert(account->eval_password != NULL);
|
||||
|
||||
gchar** output = NULL;
|
||||
gchar** error = NULL;
|
||||
gchar **output = NULL;
|
||||
gchar **error = NULL;
|
||||
|
||||
gchar* argv[] = { "sh", "-c", account->eval_password, NULL };
|
||||
gchar *argv[] = {"sh", "-c", account->eval_password, NULL};
|
||||
if (!call_external(argv, &output, &error)) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -228,7 +228,7 @@ account_eval_password(ProfAccount* account)
|
||||
}
|
||||
|
||||
void
|
||||
account_free(ProfAccount* account)
|
||||
account_free(ProfAccount *account)
|
||||
{
|
||||
if (account == NULL) {
|
||||
return;
|
||||
@ -259,28 +259,24 @@ account_free(ProfAccount* account)
|
||||
free(account);
|
||||
}
|
||||
|
||||
void
|
||||
account_set_server(ProfAccount* account, const char* server)
|
||||
void account_set_server(ProfAccount *account, const char *server)
|
||||
{
|
||||
free(account->server);
|
||||
account->server = strdup(server);
|
||||
}
|
||||
|
||||
void
|
||||
account_set_port(ProfAccount* account, int port)
|
||||
void account_set_port(ProfAccount *account, int port)
|
||||
{
|
||||
account->port = port;
|
||||
}
|
||||
|
||||
void
|
||||
account_set_tls_policy(ProfAccount* account, const char* tls_policy)
|
||||
void account_set_tls_policy(ProfAccount *account, const char *tls_policy)
|
||||
{
|
||||
free(account->tls_policy);
|
||||
account->tls_policy = strdup(tls_policy);
|
||||
}
|
||||
|
||||
void
|
||||
account_set_auth_policy(ProfAccount* account, const char* auth_policy)
|
||||
void account_set_auth_policy(ProfAccount *account, const char *auth_policy)
|
||||
{
|
||||
free(account->auth_policy);
|
||||
account->auth_policy = strdup(auth_policy);
|
||||
|
@ -38,55 +38,54 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
typedef struct prof_account_t
|
||||
{
|
||||
gchar* name;
|
||||
gchar* jid;
|
||||
gchar* password;
|
||||
gchar* eval_password;
|
||||
gchar* resource;
|
||||
gchar* server;
|
||||
typedef struct prof_account_t {
|
||||
gchar *name;
|
||||
gchar *jid;
|
||||
gchar *password;
|
||||
gchar *eval_password;
|
||||
gchar *resource;
|
||||
gchar *server;
|
||||
int port;
|
||||
gchar* last_presence;
|
||||
gchar* login_presence;
|
||||
gchar *last_presence;
|
||||
gchar *login_presence;
|
||||
gint priority_online;
|
||||
gint priority_chat;
|
||||
gint priority_away;
|
||||
gint priority_xa;
|
||||
gint priority_dnd;
|
||||
gchar* muc_service;
|
||||
gchar* muc_nick;
|
||||
gchar *muc_service;
|
||||
gchar *muc_nick;
|
||||
gboolean enabled;
|
||||
gchar* otr_policy;
|
||||
GList* otr_manual;
|
||||
GList* otr_opportunistic;
|
||||
GList* otr_always;
|
||||
gchar* omemo_policy;
|
||||
GList* omemo_enabled;
|
||||
GList* omemo_disabled;
|
||||
gchar* pgp_keyid;
|
||||
gchar* startscript;
|
||||
gchar* theme;
|
||||
gchar* tls_policy;
|
||||
gchar* auth_policy;
|
||||
gchar *otr_policy;
|
||||
GList *otr_manual;
|
||||
GList *otr_opportunistic;
|
||||
GList *otr_always;
|
||||
gchar *omemo_policy;
|
||||
GList *omemo_enabled;
|
||||
GList *omemo_disabled;
|
||||
gchar *pgp_keyid;
|
||||
gchar *startscript;
|
||||
gchar *theme;
|
||||
gchar *tls_policy;
|
||||
gchar *auth_policy;
|
||||
} ProfAccount;
|
||||
|
||||
ProfAccount* account_new(const gchar* const name, const gchar* const jid,
|
||||
const gchar* const passord, const gchar* eval_password, gboolean enabled, const gchar* const server,
|
||||
int port, const gchar* const resource, const gchar* const last_presence,
|
||||
const gchar* const login_presence, int priority_online, int priority_chat,
|
||||
int priority_away, int priority_xa, int priority_dnd,
|
||||
const gchar* const muc_service, const gchar* const muc_nick,
|
||||
const gchar* const otr_policy, GList* otr_manual, GList* otr_opportunistic,
|
||||
GList* otr_always, const gchar* const omemo_policy, GList* omemo_enabled,
|
||||
GList* omemo_disabled, const gchar* const pgp_keyid, const char* const startscript,
|
||||
const char* const theme, gchar* tls_policy, gchar* auth_policy);
|
||||
char* account_create_connect_jid(ProfAccount* account);
|
||||
gboolean account_eval_password(ProfAccount* account);
|
||||
void account_free(ProfAccount* account);
|
||||
void account_set_server(ProfAccount* account, const char* server);
|
||||
void account_set_port(ProfAccount* account, int port);
|
||||
void account_set_tls_policy(ProfAccount* account, const char* tls_policy);
|
||||
void account_set_auth_policy(ProfAccount* account, const char* auth_policy);
|
||||
ProfAccount* account_new(const gchar *const name, const gchar *const jid,
|
||||
const gchar *const passord, const gchar *eval_password, gboolean enabled, const gchar *const server,
|
||||
int port, const gchar *const resource, const gchar *const last_presence,
|
||||
const gchar *const login_presence, int priority_online, int priority_chat,
|
||||
int priority_away, int priority_xa, int priority_dnd,
|
||||
const gchar *const muc_service, const gchar *const muc_nick,
|
||||
const gchar *const otr_policy, GList *otr_manual, GList *otr_opportunistic,
|
||||
GList *otr_always, const gchar *const omemo_policy, GList *omemo_enabled,
|
||||
GList *omemo_disabled, const gchar *const pgp_keyid, const char *const startscript,
|
||||
const char *const theme, gchar *tls_policy, gchar *auth_policy);
|
||||
char* account_create_connect_jid(ProfAccount *account);
|
||||
gboolean account_eval_password(ProfAccount *account);
|
||||
void account_free(ProfAccount *account);
|
||||
void account_set_server(ProfAccount *account, const char *server);
|
||||
void account_set_port(ProfAccount *account, int port);
|
||||
void account_set_tls_policy(ProfAccount *account, const char *tls_policy);
|
||||
void account_set_auth_policy(ProfAccount *account, const char *auth_policy);
|
||||
|
||||
#endif
|
||||
|
@ -42,16 +42,16 @@
|
||||
#include "accounts.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "log.h"
|
||||
#include "config/files.h"
|
||||
#include "config/account.h"
|
||||
#include "config/conflists.h"
|
||||
#include "config/files.h"
|
||||
#include "log.h"
|
||||
#include "tools/autocomplete.h"
|
||||
#include "xmpp/jid.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
#include "xmpp/jid.h"
|
||||
|
||||
static char* accounts_loc;
|
||||
static GKeyFile* accounts;
|
||||
static char *accounts_loc;
|
||||
static GKeyFile *accounts;
|
||||
|
||||
static Autocomplete all_ac;
|
||||
static Autocomplete enabled_ac;
|
||||
@ -75,7 +75,7 @@ accounts_load(void)
|
||||
|
||||
// create the logins searchable list for autocompletion
|
||||
gsize naccounts;
|
||||
gchar** account_names = g_key_file_get_groups(accounts, &naccounts);
|
||||
gchar **account_names = g_key_file_get_groups(accounts, &naccounts);
|
||||
|
||||
gsize i;
|
||||
for (i = 0; i < naccounts; i++) {
|
||||
@ -97,13 +97,13 @@ accounts_close(void)
|
||||
}
|
||||
|
||||
char*
|
||||
accounts_find_enabled(const char* const prefix, gboolean previous, void* context)
|
||||
accounts_find_enabled(const char *const prefix, gboolean previous, void *context)
|
||||
{
|
||||
return autocomplete_complete(enabled_ac, prefix, TRUE, previous);
|
||||
}
|
||||
|
||||
char*
|
||||
accounts_find_all(const char* const prefix, gboolean previous, void* context)
|
||||
accounts_find_all(const char *const prefix, gboolean previous, void *context)
|
||||
{
|
||||
return autocomplete_complete(all_ac, prefix, TRUE, previous);
|
||||
}
|
||||
@ -121,12 +121,12 @@ accounts_reset_enabled_search(void)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_add(const char* account_name, const char* altdomain, const int port, const char* const tls_policy, const char* const auth_policy)
|
||||
accounts_add(const char *account_name, const char *altdomain, const int port, const char *const tls_policy, const char *const auth_policy)
|
||||
{
|
||||
// set account name and resource
|
||||
const char* barejid = account_name;
|
||||
char* resource = jid_random_resource();
|
||||
Jid* jid = jid_create(account_name);
|
||||
const char *barejid = account_name;
|
||||
char *resource = jid_random_resource();
|
||||
Jid *jid = jid_create(account_name);
|
||||
if (jid) {
|
||||
barejid = jid->barejid;
|
||||
if (jid->resourcepart) {
|
||||
@ -156,7 +156,7 @@ accounts_add(const char* account_name, const char* altdomain, const int port, co
|
||||
g_key_file_set_string(accounts, account_name, "auth.policy", auth_policy);
|
||||
}
|
||||
|
||||
Jid* jidp = jid_create(barejid);
|
||||
Jid *jidp = jid_create(barejid);
|
||||
|
||||
if (jidp->localpart == NULL) {
|
||||
g_key_file_set_string(accounts, account_name, "muc.nick", jidp->domainpart);
|
||||
@ -183,7 +183,7 @@ accounts_add(const char* account_name, const char* altdomain, const int port, co
|
||||
}
|
||||
|
||||
int
|
||||
accounts_remove(const char* account_name)
|
||||
accounts_remove(const char *account_name)
|
||||
{
|
||||
int r = g_key_file_remove_group(accounts, account_name, NULL);
|
||||
_save_accounts();
|
||||
@ -199,12 +199,12 @@ accounts_get_list(void)
|
||||
}
|
||||
|
||||
ProfAccount*
|
||||
accounts_get_account(const char* const name)
|
||||
accounts_get_account(const char *const name)
|
||||
{
|
||||
if (!g_key_file_has_group(accounts, name)) {
|
||||
return NULL;
|
||||
} else {
|
||||
gchar* jid = g_key_file_get_string(accounts, name, "jid", NULL);
|
||||
gchar *jid = g_key_file_get_string(accounts, name, "jid", NULL);
|
||||
|
||||
// fix accounts that have no jid property by setting to name
|
||||
if (jid == NULL) {
|
||||
@ -212,16 +212,16 @@ accounts_get_account(const char* const name)
|
||||
_save_accounts();
|
||||
}
|
||||
|
||||
gchar* password = g_key_file_get_string(accounts, name, "password", NULL);
|
||||
gchar* eval_password = g_key_file_get_string(accounts, name, "eval_password", NULL);
|
||||
gchar *password = g_key_file_get_string(accounts, name, "password", NULL);
|
||||
gchar *eval_password = g_key_file_get_string(accounts, name, "eval_password", NULL);
|
||||
gboolean enabled = g_key_file_get_boolean(accounts, name, "enabled", NULL);
|
||||
|
||||
gchar* server = g_key_file_get_string(accounts, name, "server", NULL);
|
||||
gchar* resource = g_key_file_get_string(accounts, name, "resource", NULL);
|
||||
gchar *server = g_key_file_get_string(accounts, name, "server", NULL);
|
||||
gchar *resource = g_key_file_get_string(accounts, name, "resource", NULL);
|
||||
int port = g_key_file_get_integer(accounts, name, "port", NULL);
|
||||
|
||||
gchar* last_presence = g_key_file_get_string(accounts, name, "presence.last", NULL);
|
||||
gchar* login_presence = g_key_file_get_string(accounts, name, "presence.login", NULL);
|
||||
gchar *last_presence = g_key_file_get_string(accounts, name, "presence.last", NULL);
|
||||
gchar *login_presence = g_key_file_get_string(accounts, name, "presence.login", NULL);
|
||||
|
||||
int priority_online = g_key_file_get_integer(accounts, name, "priority.online", NULL);
|
||||
int priority_chat = g_key_file_get_integer(accounts, name, "priority.chat", NULL);
|
||||
@ -229,7 +229,7 @@ accounts_get_account(const char* const name)
|
||||
int priority_xa = g_key_file_get_integer(accounts, name, "priority.xa", NULL);
|
||||
int priority_dnd = g_key_file_get_integer(accounts, name, "priority.dnd", NULL);
|
||||
|
||||
gchar* muc_service = NULL;
|
||||
gchar *muc_service = NULL;
|
||||
if (g_key_file_has_key(accounts, name, "muc.service", NULL)) {
|
||||
muc_service = g_key_file_get_string(accounts, name, "muc.service", NULL);
|
||||
} else {
|
||||
@ -241,16 +241,16 @@ accounts_get_account(const char* const name)
|
||||
}
|
||||
}
|
||||
}
|
||||
gchar* muc_nick = g_key_file_get_string(accounts, name, "muc.nick", NULL);
|
||||
gchar *muc_nick = g_key_file_get_string(accounts, name, "muc.nick", NULL);
|
||||
|
||||
gchar* otr_policy = NULL;
|
||||
gchar *otr_policy = NULL;
|
||||
if (g_key_file_has_key(accounts, name, "otr.policy", NULL)) {
|
||||
otr_policy = g_key_file_get_string(accounts, name, "otr.policy", NULL);
|
||||
}
|
||||
|
||||
gsize length;
|
||||
GList* otr_manual = NULL;
|
||||
gchar** manual = g_key_file_get_string_list(accounts, name, "otr.manual", &length, NULL);
|
||||
GList *otr_manual = NULL;
|
||||
gchar **manual = g_key_file_get_string_list(accounts, name, "otr.manual", &length, NULL);
|
||||
if (manual) {
|
||||
int i = 0;
|
||||
for (i = 0; i < length; i++) {
|
||||
@ -259,8 +259,8 @@ accounts_get_account(const char* const name)
|
||||
g_strfreev(manual);
|
||||
}
|
||||
|
||||
GList* otr_opportunistic = NULL;
|
||||
gchar** opportunistic = g_key_file_get_string_list(accounts, name, "otr.opportunistic", &length, NULL);
|
||||
GList *otr_opportunistic = NULL;
|
||||
gchar **opportunistic = g_key_file_get_string_list(accounts, name, "otr.opportunistic", &length, NULL);
|
||||
if (opportunistic) {
|
||||
int i = 0;
|
||||
for (i = 0; i < length; i++) {
|
||||
@ -269,8 +269,8 @@ accounts_get_account(const char* const name)
|
||||
g_strfreev(opportunistic);
|
||||
}
|
||||
|
||||
GList* otr_always = NULL;
|
||||
gchar** always = g_key_file_get_string_list(accounts, name, "otr.always", &length, NULL);
|
||||
GList *otr_always = NULL;
|
||||
gchar **always = g_key_file_get_string_list(accounts, name, "otr.always", &length, NULL);
|
||||
if (always) {
|
||||
int i = 0;
|
||||
for (i = 0; i < length; i++) {
|
||||
@ -279,13 +279,13 @@ accounts_get_account(const char* const name)
|
||||
g_strfreev(always);
|
||||
}
|
||||
|
||||
gchar* omemo_policy = NULL;
|
||||
gchar *omemo_policy = NULL;
|
||||
if (g_key_file_has_key(accounts, name, "omemo.policy", NULL)) {
|
||||
omemo_policy = g_key_file_get_string(accounts, name, "omemo.policy", NULL);
|
||||
}
|
||||
|
||||
GList* omemo_enabled = NULL;
|
||||
gchar** enabled_list = g_key_file_get_string_list(accounts, name, "omemo.enabled", &length, NULL);
|
||||
GList *omemo_enabled = NULL;
|
||||
gchar **enabled_list = g_key_file_get_string_list(accounts, name, "omemo.enabled", &length, NULL);
|
||||
if (enabled_list) {
|
||||
int i = 0;
|
||||
for (i = 0; i < length; i++) {
|
||||
@ -294,8 +294,8 @@ accounts_get_account(const char* const name)
|
||||
g_strfreev(enabled_list);
|
||||
}
|
||||
|
||||
GList* omemo_disabled = NULL;
|
||||
gchar** disabled_list = g_key_file_get_string_list(accounts, name, "omemo.disabled", &length, NULL);
|
||||
GList *omemo_disabled = NULL;
|
||||
gchar **disabled_list = g_key_file_get_string_list(accounts, name, "omemo.disabled", &length, NULL);
|
||||
if (disabled_list) {
|
||||
int i = 0;
|
||||
for (i = 0; i < length; i++) {
|
||||
@ -304,36 +304,40 @@ accounts_get_account(const char* const name)
|
||||
g_strfreev(disabled_list);
|
||||
}
|
||||
|
||||
gchar* pgp_keyid = NULL;
|
||||
gchar *pgp_keyid = NULL;
|
||||
if (g_key_file_has_key(accounts, name, "pgp.keyid", NULL)) {
|
||||
pgp_keyid = g_key_file_get_string(accounts, name, "pgp.keyid", NULL);
|
||||
}
|
||||
|
||||
gchar* startscript = NULL;
|
||||
gchar *startscript = NULL;
|
||||
if (g_key_file_has_key(accounts, name, "script.start", NULL)) {
|
||||
startscript = g_key_file_get_string(accounts, name, "script.start", NULL);
|
||||
}
|
||||
|
||||
gchar* theme = NULL;
|
||||
gchar *theme = NULL;
|
||||
if (g_key_file_has_key(accounts, name, "theme", NULL)) {
|
||||
theme = g_key_file_get_string(accounts, name, "theme", NULL);
|
||||
}
|
||||
|
||||
gchar* tls_policy = g_key_file_get_string(accounts, name, "tls.policy", NULL);
|
||||
if (tls_policy && ((g_strcmp0(tls_policy, "force") != 0) && (g_strcmp0(tls_policy, "allow") != 0) && (g_strcmp0(tls_policy, "trust") != 0) && (g_strcmp0(tls_policy, "disable") != 0) && (g_strcmp0(tls_policy, "legacy") != 0))) {
|
||||
gchar *tls_policy = g_key_file_get_string(accounts, name, "tls.policy", NULL);
|
||||
if (tls_policy && ((g_strcmp0(tls_policy, "force") != 0) &&
|
||||
(g_strcmp0(tls_policy, "allow") != 0) &&
|
||||
(g_strcmp0(tls_policy, "trust") != 0) &&
|
||||
(g_strcmp0(tls_policy, "disable") != 0) &&
|
||||
(g_strcmp0(tls_policy, "legacy") != 0))) {
|
||||
g_free(tls_policy);
|
||||
tls_policy = NULL;
|
||||
}
|
||||
|
||||
gchar* auth_policy = g_key_file_get_string(accounts, name, "auth.policy", NULL);
|
||||
gchar *auth_policy = g_key_file_get_string(accounts, name, "auth.policy", NULL);
|
||||
|
||||
ProfAccount* new_account = account_new(name, jid, password, eval_password, enabled,
|
||||
server, port, resource, last_presence, login_presence,
|
||||
priority_online, priority_chat, priority_away, priority_xa,
|
||||
priority_dnd, muc_service, muc_nick, otr_policy, otr_manual,
|
||||
otr_opportunistic, otr_always, omemo_policy, omemo_enabled,
|
||||
omemo_disabled, pgp_keyid, startscript, theme, tls_policy,
|
||||
auth_policy);
|
||||
ProfAccount *new_account = account_new(name, jid, password, eval_password, enabled,
|
||||
server, port, resource, last_presence, login_presence,
|
||||
priority_online, priority_chat, priority_away, priority_xa,
|
||||
priority_dnd, muc_service, muc_nick, otr_policy, otr_manual,
|
||||
otr_opportunistic, otr_always, omemo_policy, omemo_enabled,
|
||||
omemo_disabled, pgp_keyid, startscript, theme, tls_policy,
|
||||
auth_policy);
|
||||
|
||||
g_free(jid);
|
||||
g_free(password);
|
||||
@ -357,7 +361,7 @@ accounts_get_account(const char* const name)
|
||||
}
|
||||
|
||||
gboolean
|
||||
accounts_enable(const char* const name)
|
||||
accounts_enable(const char *const name)
|
||||
{
|
||||
if (g_key_file_has_group(accounts, name)) {
|
||||
g_key_file_set_boolean(accounts, name, "enabled", TRUE);
|
||||
@ -370,7 +374,7 @@ accounts_enable(const char* const name)
|
||||
}
|
||||
|
||||
gboolean
|
||||
accounts_disable(const char* const name)
|
||||
accounts_disable(const char *const name)
|
||||
{
|
||||
if (g_key_file_has_group(accounts, name)) {
|
||||
g_key_file_set_boolean(accounts, name, "enabled", FALSE);
|
||||
@ -383,7 +387,7 @@ accounts_disable(const char* const name)
|
||||
}
|
||||
|
||||
gboolean
|
||||
accounts_rename(const char* const account_name, const char* const new_name)
|
||||
accounts_rename(const char *const account_name, const char *const new_name)
|
||||
{
|
||||
if (g_key_file_has_group(accounts, new_name)) {
|
||||
return FALSE;
|
||||
@ -394,7 +398,7 @@ accounts_rename(const char* const account_name, const char* const new_name)
|
||||
}
|
||||
|
||||
// treat all properties as strings for copy
|
||||
gchar* string_keys[] = {
|
||||
gchar *string_keys[] = {
|
||||
"enabled",
|
||||
"jid",
|
||||
"server",
|
||||
@ -427,7 +431,7 @@ accounts_rename(const char* const account_name, const char* const new_name)
|
||||
|
||||
int i;
|
||||
for (i = 0; i < ARRAY_SIZE(string_keys); i++) {
|
||||
char* value = g_key_file_get_string(accounts, account_name, string_keys[i], NULL);
|
||||
char *value = g_key_file_get_string(accounts, account_name, string_keys[i], NULL);
|
||||
if (value) {
|
||||
g_key_file_set_string(accounts, new_name, string_keys[i], value);
|
||||
g_free(value);
|
||||
@ -448,15 +452,16 @@ accounts_rename(const char* const account_name, const char* const new_name)
|
||||
}
|
||||
|
||||
gboolean
|
||||
accounts_account_exists(const char* const account_name)
|
||||
accounts_account_exists(const char *const account_name)
|
||||
{
|
||||
return g_key_file_has_group(accounts, account_name);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_jid(const char* const account_name, const char* const value)
|
||||
accounts_set_jid(const char *const account_name, const char *const value)
|
||||
{
|
||||
Jid* jid = jid_create(value);
|
||||
Jid *jid = jid_create(value);
|
||||
if (jid) {
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "jid", jid->barejid);
|
||||
@ -478,7 +483,7 @@ accounts_set_jid(const char* const account_name, const char* const value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_server(const char* const account_name, const char* const value)
|
||||
accounts_set_server(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "server", value);
|
||||
@ -487,7 +492,7 @@ accounts_set_server(const char* const account_name, const char* const value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_port(const char* const account_name, const int value)
|
||||
accounts_set_port(const char *const account_name, const int value)
|
||||
{
|
||||
if (value != 0) {
|
||||
g_key_file_set_integer(accounts, account_name, "port", value);
|
||||
@ -496,7 +501,7 @@ accounts_set_port(const char* const account_name, const int value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_resource(const char* const account_name, const char* const value)
|
||||
accounts_set_resource(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "resource", value);
|
||||
@ -505,7 +510,7 @@ accounts_set_resource(const char* const account_name, const char* const value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_password(const char* const account_name, const char* const value)
|
||||
accounts_set_password(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "password", value);
|
||||
@ -514,7 +519,7 @@ accounts_set_password(const char* const account_name, const char* const value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_eval_password(const char* const account_name, const char* const value)
|
||||
accounts_set_eval_password(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "eval_password", value);
|
||||
@ -523,7 +528,7 @@ accounts_set_eval_password(const char* const account_name, const char* const val
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_pgp_keyid(const char* const account_name, const char* const value)
|
||||
accounts_set_pgp_keyid(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "pgp.keyid", value);
|
||||
@ -532,7 +537,7 @@ accounts_set_pgp_keyid(const char* const account_name, const char* const value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_script_start(const char* const account_name, const char* const value)
|
||||
accounts_set_script_start(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "script.start", value);
|
||||
@ -541,7 +546,7 @@ accounts_set_script_start(const char* const account_name, const char* const valu
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_theme(const char* const account_name, const char* const value)
|
||||
accounts_set_theme(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "theme", value);
|
||||
@ -550,7 +555,7 @@ accounts_set_theme(const char* const account_name, const char* const value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_clear_password(const char* const account_name)
|
||||
accounts_clear_password(const char *const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_remove_key(accounts, account_name, "password", NULL);
|
||||
@ -559,7 +564,7 @@ accounts_clear_password(const char* const account_name)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_clear_eval_password(const char* const account_name)
|
||||
accounts_clear_eval_password(const char *const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_remove_key(accounts, account_name, "eval_password", NULL);
|
||||
@ -568,7 +573,7 @@ accounts_clear_eval_password(const char* const account_name)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_clear_server(const char* const account_name)
|
||||
accounts_clear_server(const char *const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_remove_key(accounts, account_name, "server", NULL);
|
||||
@ -577,7 +582,7 @@ accounts_clear_server(const char* const account_name)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_clear_port(const char* const account_name)
|
||||
accounts_clear_port(const char *const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_remove_key(accounts, account_name, "port", NULL);
|
||||
@ -586,7 +591,7 @@ accounts_clear_port(const char* const account_name)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_clear_pgp_keyid(const char* const account_name)
|
||||
accounts_clear_pgp_keyid(const char *const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_remove_key(accounts, account_name, "pgp.keyid", NULL);
|
||||
@ -595,7 +600,7 @@ accounts_clear_pgp_keyid(const char* const account_name)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_clear_script_start(const char* const account_name)
|
||||
accounts_clear_script_start(const char *const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_remove_key(accounts, account_name, "script.start", NULL);
|
||||
@ -604,7 +609,7 @@ accounts_clear_script_start(const char* const account_name)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_clear_theme(const char* const account_name)
|
||||
accounts_clear_theme(const char *const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_remove_key(accounts, account_name, "theme", NULL);
|
||||
@ -613,7 +618,7 @@ accounts_clear_theme(const char* const account_name)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_clear_muc(const char* const account_name)
|
||||
accounts_clear_muc(const char *const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_remove_key(accounts, account_name, "muc.service", NULL);
|
||||
@ -622,7 +627,7 @@ accounts_clear_muc(const char* const account_name)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_clear_resource(const char* const account_name)
|
||||
accounts_clear_resource(const char *const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_remove_key(accounts, account_name, "resource", NULL);
|
||||
@ -631,7 +636,7 @@ accounts_clear_resource(const char* const account_name)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_clear_otr(const char* const account_name)
|
||||
accounts_clear_otr(const char *const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_remove_key(accounts, account_name, "otr.policy", NULL);
|
||||
@ -640,10 +645,10 @@ accounts_clear_otr(const char* const account_name)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_add_otr_policy(const char* const account_name, const char* const contact_jid, const char* const policy)
|
||||
accounts_add_otr_policy(const char *const account_name, const char *const contact_jid, const char *const policy)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
GString* key = g_string_new("otr.");
|
||||
GString *key = g_string_new("otr.");
|
||||
g_string_append(key, policy);
|
||||
conf_string_list_add(accounts, account_name, key->str, contact_jid);
|
||||
g_string_free(key, TRUE);
|
||||
@ -667,7 +672,7 @@ accounts_add_otr_policy(const char* const account_name, const char* const contac
|
||||
}
|
||||
|
||||
void
|
||||
accounts_add_omemo_state(const char* const account_name, const char* const contact_jid, gboolean enabled)
|
||||
accounts_add_omemo_state(const char *const account_name, const char *const contact_jid, gboolean enabled)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
if (enabled) {
|
||||
@ -683,7 +688,7 @@ accounts_add_omemo_state(const char* const account_name, const char* const conta
|
||||
}
|
||||
|
||||
void
|
||||
accounts_clear_omemo_state(const char* const account_name, const char* const contact_jid)
|
||||
accounts_clear_omemo_state(const char *const account_name, const char *const contact_jid)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
conf_string_list_remove(accounts, account_name, "omemo.enabled", contact_jid);
|
||||
@ -693,7 +698,7 @@ accounts_clear_omemo_state(const char* const account_name, const char* const con
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_muc_service(const char* const account_name, const char* const value)
|
||||
accounts_set_muc_service(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "muc.service", value);
|
||||
@ -702,7 +707,7 @@ accounts_set_muc_service(const char* const account_name, const char* const value
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_muc_nick(const char* const account_name, const char* const value)
|
||||
accounts_set_muc_nick(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "muc.nick", value);
|
||||
@ -711,7 +716,7 @@ accounts_set_muc_nick(const char* const account_name, const char* const value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_otr_policy(const char* const account_name, const char* const value)
|
||||
accounts_set_otr_policy(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "otr.policy", value);
|
||||
@ -720,7 +725,7 @@ accounts_set_otr_policy(const char* const account_name, const char* const value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_omemo_policy(const char* const account_name, const char* const value)
|
||||
accounts_set_omemo_policy(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "omemo.policy", value);
|
||||
@ -729,7 +734,7 @@ accounts_set_omemo_policy(const char* const account_name, const char* const valu
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_tls_policy(const char* const account_name, const char* const value)
|
||||
accounts_set_tls_policy(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "tls.policy", value);
|
||||
@ -738,7 +743,7 @@ accounts_set_tls_policy(const char* const account_name, const char* const value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_auth_policy(const char* const account_name, const char* const value)
|
||||
accounts_set_auth_policy(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "auth.policy", value);
|
||||
@ -747,7 +752,7 @@ accounts_set_auth_policy(const char* const account_name, const char* const value
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_priority_online(const char* const account_name, const gint value)
|
||||
accounts_set_priority_online(const char *const account_name, const gint value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_integer(accounts, account_name, "priority.online", value);
|
||||
@ -756,7 +761,7 @@ accounts_set_priority_online(const char* const account_name, const gint value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_priority_chat(const char* const account_name, const gint value)
|
||||
accounts_set_priority_chat(const char *const account_name, const gint value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_integer(accounts, account_name, "priority.chat", value);
|
||||
@ -765,7 +770,7 @@ accounts_set_priority_chat(const char* const account_name, const gint value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_priority_away(const char* const account_name, const gint value)
|
||||
accounts_set_priority_away(const char *const account_name, const gint value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_integer(accounts, account_name, "priority.away", value);
|
||||
@ -774,7 +779,7 @@ accounts_set_priority_away(const char* const account_name, const gint value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_priority_xa(const char* const account_name, const gint value)
|
||||
accounts_set_priority_xa(const char *const account_name, const gint value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_integer(accounts, account_name, "priority.xa", value);
|
||||
@ -783,7 +788,7 @@ accounts_set_priority_xa(const char* const account_name, const gint value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_priority_dnd(const char* const account_name, const gint value)
|
||||
accounts_set_priority_dnd(const char *const account_name, const gint value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_integer(accounts, account_name, "priority.dnd", value);
|
||||
@ -792,7 +797,7 @@ accounts_set_priority_dnd(const char* const account_name, const gint value)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_priority_all(const char* const account_name, const gint value)
|
||||
accounts_set_priority_all(const char *const account_name, const gint value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
accounts_set_priority_online(account_name, value);
|
||||
@ -805,27 +810,28 @@ accounts_set_priority_all(const char* const account_name, const gint value)
|
||||
}
|
||||
|
||||
gint
|
||||
accounts_get_priority_for_presence_type(const char* const account_name,
|
||||
resource_presence_t presence_type)
|
||||
accounts_get_priority_for_presence_type(const char *const account_name,
|
||||
resource_presence_t presence_type)
|
||||
{
|
||||
gint result;
|
||||
|
||||
switch (presence_type) {
|
||||
case (RESOURCE_ONLINE):
|
||||
result = g_key_file_get_integer(accounts, account_name, "priority.online", NULL);
|
||||
break;
|
||||
case (RESOURCE_CHAT):
|
||||
result = g_key_file_get_integer(accounts, account_name, "priority.chat", NULL);
|
||||
break;
|
||||
case (RESOURCE_AWAY):
|
||||
result = g_key_file_get_integer(accounts, account_name, "priority.away", NULL);
|
||||
break;
|
||||
case (RESOURCE_XA):
|
||||
result = g_key_file_get_integer(accounts, account_name, "priority.xa", NULL);
|
||||
break;
|
||||
default:
|
||||
result = g_key_file_get_integer(accounts, account_name, "priority.dnd", NULL);
|
||||
break;
|
||||
switch (presence_type)
|
||||
{
|
||||
case (RESOURCE_ONLINE):
|
||||
result = g_key_file_get_integer(accounts, account_name, "priority.online", NULL);
|
||||
break;
|
||||
case (RESOURCE_CHAT):
|
||||
result = g_key_file_get_integer(accounts, account_name, "priority.chat", NULL);
|
||||
break;
|
||||
case (RESOURCE_AWAY):
|
||||
result = g_key_file_get_integer(accounts, account_name, "priority.away", NULL);
|
||||
break;
|
||||
case (RESOURCE_XA):
|
||||
result = g_key_file_get_integer(accounts, account_name, "priority.xa", NULL);
|
||||
break;
|
||||
default:
|
||||
result = g_key_file_get_integer(accounts, account_name, "priority.dnd", NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
if (result < JABBER_PRIORITY_MIN || result > JABBER_PRIORITY_MAX)
|
||||
@ -835,7 +841,7 @@ accounts_get_priority_for_presence_type(const char* const account_name,
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_last_presence(const char* const account_name, const char* const value)
|
||||
accounts_set_last_presence(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "presence.last", value);
|
||||
@ -844,7 +850,7 @@ accounts_set_last_presence(const char* const account_name, const char* const val
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_last_status(const char* const account_name, const char* const value)
|
||||
accounts_set_last_status(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
if (value) {
|
||||
@ -857,16 +863,16 @@ accounts_set_last_status(const char* const account_name, const char* const value
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_last_activity(const char* const account_name)
|
||||
accounts_set_last_activity(const char *const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
GDateTime* nowdt = g_date_time_new_now_utc();
|
||||
GDateTime *nowdt = g_date_time_new_now_utc();
|
||||
GTimeVal nowtv;
|
||||
gboolean res = g_date_time_to_timeval(nowdt, &nowtv);
|
||||
g_date_time_unref(nowdt);
|
||||
|
||||
if (res) {
|
||||
char* timestr = g_time_val_to_iso8601(&nowtv);
|
||||
char *timestr = g_time_val_to_iso8601(&nowtv);
|
||||
g_key_file_set_string(accounts, account_name, "last.activity", timestr);
|
||||
free(timestr);
|
||||
_save_accounts();
|
||||
@ -875,7 +881,7 @@ accounts_set_last_activity(const char* const account_name)
|
||||
}
|
||||
|
||||
char*
|
||||
accounts_get_last_activity(const char* const account_name)
|
||||
accounts_get_last_activity(const char *const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
return g_key_file_get_string(accounts, account_name, "last.activity", NULL);
|
||||
@ -885,7 +891,7 @@ accounts_get_last_activity(const char* const account_name)
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_login_presence(const char* const account_name, const char* const value)
|
||||
accounts_set_login_presence(const char *const account_name, const char *const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "presence.login", value);
|
||||
@ -894,10 +900,10 @@ accounts_set_login_presence(const char* const account_name, const char* const va
|
||||
}
|
||||
|
||||
resource_presence_t
|
||||
accounts_get_last_presence(const char* const account_name)
|
||||
accounts_get_last_presence(const char *const account_name)
|
||||
{
|
||||
resource_presence_t result;
|
||||
gchar* setting = g_key_file_get_string(accounts, account_name, "presence.last", NULL);
|
||||
gchar *setting = g_key_file_get_string(accounts, account_name, "presence.last", NULL);
|
||||
|
||||
if (setting == NULL || (strcmp(setting, "online") == 0)) {
|
||||
result = RESOURCE_ONLINE;
|
||||
@ -911,7 +917,7 @@ accounts_get_last_presence(const char* const account_name)
|
||||
result = RESOURCE_DND;
|
||||
} else {
|
||||
log_warning("Error reading presence.last for account: '%s', value: '%s', defaulting to 'online'",
|
||||
account_name, setting);
|
||||
account_name, setting);
|
||||
result = RESOURCE_ONLINE;
|
||||
}
|
||||
|
||||
@ -922,16 +928,16 @@ accounts_get_last_presence(const char* const account_name)
|
||||
}
|
||||
|
||||
char*
|
||||
accounts_get_last_status(const char* const account_name)
|
||||
accounts_get_last_status(const char *const account_name)
|
||||
{
|
||||
return g_key_file_get_string(accounts, account_name, "presence.laststatus", NULL);
|
||||
}
|
||||
|
||||
resource_presence_t
|
||||
accounts_get_login_presence(const char* const account_name)
|
||||
accounts_get_login_presence(const char *const account_name)
|
||||
{
|
||||
resource_presence_t result;
|
||||
gchar* setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL);
|
||||
gchar *setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL);
|
||||
|
||||
if (setting == NULL || (strcmp(setting, "online") == 0)) {
|
||||
result = RESOURCE_ONLINE;
|
||||
@ -947,7 +953,7 @@ accounts_get_login_presence(const char* const account_name)
|
||||
result = accounts_get_last_presence(account_name);
|
||||
} else {
|
||||
log_warning("Error reading presence.login for account: '%s', value: '%s', defaulting to 'online'",
|
||||
account_name, setting);
|
||||
account_name, setting);
|
||||
result = RESOURCE_ONLINE;
|
||||
}
|
||||
|
||||
@ -961,10 +967,10 @@ static void
|
||||
_save_accounts(void)
|
||||
{
|
||||
gsize g_data_size;
|
||||
gchar* g_accounts_data = g_key_file_to_data(accounts, &g_data_size, NULL);
|
||||
gchar *g_accounts_data = g_key_file_to_data(accounts, &g_data_size, NULL);
|
||||
|
||||
gchar* base = g_path_get_dirname(accounts_loc);
|
||||
gchar* true_loc = get_file_or_linked(accounts_loc, base);
|
||||
gchar *base = g_path_get_dirname(accounts_loc);
|
||||
gchar *true_loc = get_file_or_linked(accounts_loc, base);
|
||||
g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL);
|
||||
g_chmod(accounts_loc, S_IRUSR | S_IWUSR);
|
||||
|
||||
|
@ -44,61 +44,61 @@
|
||||
void accounts_load(void);
|
||||
void accounts_close(void);
|
||||
|
||||
char* accounts_find_all(const char* const prefix, gboolean previous, void* context);
|
||||
char* accounts_find_enabled(const char* const prefix, gboolean previous, void* context);
|
||||
char* accounts_find_all(const char *const prefix, gboolean previous, void *context);
|
||||
char* accounts_find_enabled(const char *const prefix, gboolean previous, void *context);
|
||||
void accounts_reset_all_search(void);
|
||||
void accounts_reset_enabled_search(void);
|
||||
void accounts_add(const char* jid, const char* altdomain, const int port, const char* const tls_policy, const char* const auth_policy);
|
||||
int accounts_remove(const char* jid);
|
||||
void accounts_add(const char *jid, const char *altdomain, const int port, const char *const tls_policy, const char *const auth_policy);
|
||||
int accounts_remove(const char *jid);
|
||||
gchar** accounts_get_list(void);
|
||||
ProfAccount* accounts_get_account(const char* const name);
|
||||
gboolean accounts_enable(const char* const name);
|
||||
gboolean accounts_disable(const char* const name);
|
||||
gboolean accounts_rename(const char* const account_name,
|
||||
const char* const new_name);
|
||||
gboolean accounts_account_exists(const char* const account_name);
|
||||
void accounts_set_jid(const char* const account_name, const char* const value);
|
||||
void accounts_set_server(const char* const account_name, const char* const value);
|
||||
void accounts_set_port(const char* const account_name, const int value);
|
||||
void accounts_set_resource(const char* const account_name, const char* const value);
|
||||
void accounts_set_password(const char* const account_name, const char* const value);
|
||||
void accounts_set_eval_password(const char* const account_name, const char* const value);
|
||||
void accounts_set_muc_service(const char* const account_name, const char* const value);
|
||||
void accounts_set_muc_nick(const char* const account_name, const char* const value);
|
||||
void accounts_set_otr_policy(const char* const account_name, const char* const value);
|
||||
void accounts_set_tls_policy(const char* const account_name, const char* const value);
|
||||
void accounts_set_auth_policy(const char* const account_name, const char* const value);
|
||||
void accounts_set_last_presence(const char* const account_name, const char* const value);
|
||||
void accounts_set_last_status(const char* const account_name, const char* const value);
|
||||
void accounts_set_last_activity(const char* const account_name);
|
||||
char* accounts_get_last_activity(const char* const account_name);
|
||||
void accounts_set_login_presence(const char* const account_name, const char* const value);
|
||||
resource_presence_t accounts_get_login_presence(const char* const account_name);
|
||||
char* accounts_get_last_status(const char* const account_name);
|
||||
resource_presence_t accounts_get_last_presence(const char* const account_name);
|
||||
void accounts_set_priority_online(const char* const account_name, const gint value);
|
||||
void accounts_set_priority_chat(const char* const account_name, const gint value);
|
||||
void accounts_set_priority_away(const char* const account_name, const gint value);
|
||||
void accounts_set_priority_xa(const char* const account_name, const gint value);
|
||||
void accounts_set_priority_dnd(const char* const account_name, const gint value);
|
||||
void accounts_set_priority_all(const char* const account_name, const gint value);
|
||||
gint accounts_get_priority_for_presence_type(const char* const account_name,
|
||||
resource_presence_t presence_type);
|
||||
void accounts_set_pgp_keyid(const char* const account_name, const char* const value);
|
||||
void accounts_set_script_start(const char* const account_name, const char* const value);
|
||||
void accounts_set_theme(const char* const account_name, const char* const value);
|
||||
void accounts_clear_password(const char* const account_name);
|
||||
void accounts_clear_eval_password(const char* const account_name);
|
||||
void accounts_clear_server(const char* const account_name);
|
||||
void accounts_clear_port(const char* const account_name);
|
||||
void accounts_clear_otr(const char* const account_name);
|
||||
void accounts_clear_pgp_keyid(const char* const account_name);
|
||||
void accounts_clear_script_start(const char* const account_name);
|
||||
void accounts_clear_theme(const char* const account_name);
|
||||
void accounts_clear_muc(const char* const account_name);
|
||||
void accounts_clear_resource(const char* const account_name);
|
||||
void accounts_add_otr_policy(const char* const account_name, const char* const contact_jid, const char* const policy);
|
||||
void accounts_add_omemo_state(const char* const account_name, const char* const contact_jid, gboolean enabled);
|
||||
void accounts_clear_omemo_state(const char* const account_name, const char* const contact_jid);
|
||||
ProfAccount* accounts_get_account(const char *const name);
|
||||
gboolean accounts_enable(const char *const name);
|
||||
gboolean accounts_disable(const char *const name);
|
||||
gboolean accounts_rename(const char *const account_name,
|
||||
const char *const new_name);
|
||||
gboolean accounts_account_exists(const char *const account_name);
|
||||
void accounts_set_jid(const char *const account_name, const char *const value);
|
||||
void accounts_set_server(const char *const account_name, const char *const value);
|
||||
void accounts_set_port(const char *const account_name, const int value);
|
||||
void accounts_set_resource(const char *const account_name, const char *const value);
|
||||
void accounts_set_password(const char *const account_name, const char *const value);
|
||||
void accounts_set_eval_password(const char *const account_name, const char *const value);
|
||||
void accounts_set_muc_service(const char *const account_name, const char *const value);
|
||||
void accounts_set_muc_nick(const char *const account_name, const char *const value);
|
||||
void accounts_set_otr_policy(const char *const account_name, const char *const value);
|
||||
void accounts_set_tls_policy(const char *const account_name, const char *const value);
|
||||
void accounts_set_auth_policy(const char *const account_name, const char *const value);
|
||||
void accounts_set_last_presence(const char *const account_name, const char *const value);
|
||||
void accounts_set_last_status(const char *const account_name, const char *const value);
|
||||
void accounts_set_last_activity(const char *const account_name);
|
||||
char* accounts_get_last_activity(const char *const account_name);
|
||||
void accounts_set_login_presence(const char *const account_name, const char *const value);
|
||||
resource_presence_t accounts_get_login_presence(const char *const account_name);
|
||||
char* accounts_get_last_status(const char *const account_name);
|
||||
resource_presence_t accounts_get_last_presence(const char *const account_name);
|
||||
void accounts_set_priority_online(const char *const account_name, const gint value);
|
||||
void accounts_set_priority_chat(const char *const account_name, const gint value);
|
||||
void accounts_set_priority_away(const char *const account_name, const gint value);
|
||||
void accounts_set_priority_xa(const char *const account_name, const gint value);
|
||||
void accounts_set_priority_dnd(const char *const account_name, const gint value);
|
||||
void accounts_set_priority_all(const char *const account_name, const gint value);
|
||||
gint accounts_get_priority_for_presence_type(const char *const account_name,
|
||||
resource_presence_t presence_type);
|
||||
void accounts_set_pgp_keyid(const char *const account_name, const char *const value);
|
||||
void accounts_set_script_start(const char *const account_name, const char *const value);
|
||||
void accounts_set_theme(const char *const account_name, const char *const value);
|
||||
void accounts_clear_password(const char *const account_name);
|
||||
void accounts_clear_eval_password(const char *const account_name);
|
||||
void accounts_clear_server(const char *const account_name);
|
||||
void accounts_clear_port(const char *const account_name);
|
||||
void accounts_clear_otr(const char *const account_name);
|
||||
void accounts_clear_pgp_keyid(const char *const account_name);
|
||||
void accounts_clear_script_start(const char *const account_name);
|
||||
void accounts_clear_theme(const char *const account_name);
|
||||
void accounts_clear_muc(const char *const account_name);
|
||||
void accounts_clear_resource(const char *const account_name);
|
||||
void accounts_add_otr_policy(const char *const account_name, const char *const contact_jid, const char *const policy);
|
||||
void accounts_add_omemo_state(const char *const account_name, const char *const contact_jid, gboolean enabled);
|
||||
void accounts_clear_omemo_state(const char *const account_name, const char *const contact_jid);
|
||||
|
||||
#endif
|
||||
|
@ -36,11 +36,11 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef HAVE_NCURSESW_NCURSES_H
|
||||
#include <ncursesw/ncurses.h>
|
||||
@ -52,15 +52,13 @@
|
||||
#include "config/theme.h"
|
||||
#include "log.h"
|
||||
|
||||
static struct color_pair_cache
|
||||
static
|
||||
struct color_pair_cache
|
||||
{
|
||||
struct
|
||||
{
|
||||
int16_t fg, bg;
|
||||
} * pairs;
|
||||
struct { int16_t fg, bg; } *pairs;
|
||||
int size;
|
||||
int capacity;
|
||||
} cache = { 0 };
|
||||
} cache = {0};
|
||||
|
||||
/*
|
||||
* xterm default 256 colors
|
||||
@ -68,281 +66,279 @@ static struct color_pair_cache
|
||||
*/
|
||||
|
||||
const struct color_def color_names[COLOR_NAME_SIZE] = {
|
||||
[0] = { 0, 0, 0, "black" },
|
||||
[1] = { 0, 100, 25, "red" },
|
||||
[2] = { 120, 100, 25, "green" },
|
||||
[3] = { 60, 100, 25, "yellow" },
|
||||
[4] = { 240, 100, 25, "blue" },
|
||||
[5] = { 300, 100, 25, "magenta" },
|
||||
[6] = { 180, 100, 25, "cyan" },
|
||||
[7] = { 0, 0, 75, "white" },
|
||||
[8] = { 0, 0, 50, "lightblack" },
|
||||
[9] = { 0, 100, 50, "lightred" },
|
||||
[10] = { 120, 100, 50, "lightgreen" },
|
||||
[11] = { 60, 100, 50, "lightyellow" },
|
||||
[12] = { 240, 100, 50, "lightblue" },
|
||||
[13] = { 300, 100, 50, "lightmagenta" },
|
||||
[14] = { 180, 100, 50, "lightcyan" },
|
||||
[15] = { 0, 0, 100, "lightwhite" },
|
||||
[16] = { 0, 0, 0, "grey0" },
|
||||
[17] = { 240, 100, 18, "navyblue" },
|
||||
[18] = { 240, 100, 26, "darkblue" },
|
||||
[19] = { 240, 100, 34, "blue3" },
|
||||
[20] = { 240, 100, 42, "blue3" },
|
||||
[21] = { 240, 100, 50, "blue1" },
|
||||
[22] = { 120, 100, 18, "darkgreen" },
|
||||
[23] = { 180, 100, 18, "deepskyblue4" },
|
||||
[24] = { 97, 100, 26, "deepskyblue4" },
|
||||
[25] = { 7, 100, 34, "deepskyblue4" },
|
||||
[26] = { 13, 100, 42, "dodgerblue3" },
|
||||
[27] = { 17, 100, 50, "dodgerblue2" },
|
||||
[28] = { 120, 100, 26, "green4" },
|
||||
[29] = { 62, 100, 26, "springgreen4" },
|
||||
[30] = { 180, 100, 26, "turquoise4" },
|
||||
[31] = { 93, 100, 34, "deepskyblue3" },
|
||||
[32] = { 2, 100, 42, "deepskyblue3" },
|
||||
[33] = { 8, 100, 50, "dodgerblue1" },
|
||||
[34] = { 120, 100, 34, "green3" },
|
||||
[35] = { 52, 100, 34, "springgreen3" },
|
||||
[36] = { 66, 100, 34, "darkcyan" },
|
||||
[37] = { 180, 100, 34, "lightseagreen" },
|
||||
[38] = { 91, 100, 42, "deepskyblue2" },
|
||||
[39] = { 98, 100, 50, "deepskyblue1" },
|
||||
[40] = { 120, 100, 42, "green3" },
|
||||
[41] = { 46, 100, 42, "springgreen3" },
|
||||
[42] = { 57, 100, 42, "springgreen2" },
|
||||
[43] = { 68, 100, 42, "cyan3" },
|
||||
[44] = { 180, 100, 42, "darkturquoise" },
|
||||
[45] = { 89, 100, 50, "turquoise2" },
|
||||
[46] = { 120, 100, 50, "green1" },
|
||||
[47] = { 42, 100, 50, "springgreen2" },
|
||||
[48] = { 51, 100, 50, "springgreen1" },
|
||||
[49] = { 61, 100, 50, "mediumspringgreen" },
|
||||
[50] = { 70, 100, 50, "cyan2" },
|
||||
[51] = { 180, 100, 50, "cyan1" },
|
||||
[52] = { 0, 100, 18, "darkred" },
|
||||
[53] = { 300, 100, 18, "deeppink4" },
|
||||
[54] = { 82, 100, 26, "purple4" },
|
||||
[55] = { 72, 100, 34, "purple4" },
|
||||
[56] = { 66, 100, 42, "purple3" },
|
||||
[57] = { 62, 100, 50, "blueviolet" },
|
||||
[58] = { 60, 100, 18, "orange4" },
|
||||
[59] = { 0, 0, 37, "grey37" },
|
||||
[60] = { 240, 17, 45, "mediumpurple4" },
|
||||
[61] = { 240, 33, 52, "slateblue3" },
|
||||
[62] = { 240, 60, 60, "slateblue3" },
|
||||
[63] = { 240, 100, 68, "royalblue1" },
|
||||
[64] = { 7, 100, 26, "chartreuse4" },
|
||||
[65] = { 120, 17, 45, "darkseagreen4" },
|
||||
[66] = { 180, 17, 45, "paleturquoise4" },
|
||||
[67] = { 210, 33, 52, "steelblue" },
|
||||
[68] = { 220, 60, 60, "steelblue3" },
|
||||
[69] = { 225, 100, 68, "cornflowerblue" },
|
||||
[70] = { 7, 100, 34, "chartreuse3" },
|
||||
[71] = { 120, 33, 52, "darkseagreen4" },
|
||||
[72] = { 150, 33, 52, "cadetblue" },
|
||||
[73] = { 180, 33, 52, "cadetblue" },
|
||||
[74] = { 200, 60, 60, "skyblue3" },
|
||||
[75] = { 210, 100, 68, "steelblue1" },
|
||||
[76] = { 3, 100, 42, "chartreuse3" },
|
||||
[77] = { 120, 60, 60, "palegreen3" },
|
||||
[78] = { 140, 60, 60, "seagreen3" },
|
||||
[79] = { 160, 60, 60, "aquamarine3" },
|
||||
[80] = { 180, 60, 60, "mediumturquoise" },
|
||||
[81] = { 195, 100, 68, "steelblue1" },
|
||||
[82] = { 7, 100, 50, "chartreuse2" },
|
||||
[83] = { 120, 100, 68, "seagreen2" },
|
||||
[84] = { 135, 100, 68, "seagreen1" },
|
||||
[85] = { 150, 100, 68, "seagreen1" },
|
||||
[86] = { 165, 100, 68, "aquamarine1" },
|
||||
[87] = { 180, 100, 68, "darkslategray2" },
|
||||
[88] = { 0, 100, 26, "darkred" },
|
||||
[89] = { 17, 100, 26, "deeppink4" },
|
||||
[90] = { 300, 100, 26, "darkmagenta" },
|
||||
[91] = { 86, 100, 34, "darkmagenta" },
|
||||
[92] = { 77, 100, 42, "darkviolet" },
|
||||
[93] = { 71, 100, 50, "purple" },
|
||||
[94] = { 2, 100, 26, "orange4" },
|
||||
[95] = { 0, 17, 45, "lightpink4" },
|
||||
[96] = { 300, 17, 45, "plum4" },
|
||||
[97] = { 270, 33, 52, "mediumpurple3" },
|
||||
[98] = { 260, 60, 60, "mediumpurple3" },
|
||||
[99] = { 255, 100, 68, "slateblue1" },
|
||||
[100] = { 60, 100, 26, "yellow4" },
|
||||
[101] = { 60, 17, 45, "wheat4" },
|
||||
[102] = { 0, 0, 52, "grey53" },
|
||||
[103] = { 240, 20, 60, "lightslategrey" },
|
||||
[104] = { 240, 50, 68, "mediumpurple" },
|
||||
[105] = { 240, 100, 76, "lightslateblue" },
|
||||
[106] = { 3, 100, 34, "yellow4" },
|
||||
[107] = { 90, 33, 52, "darkolivegreen3" },
|
||||
[108] = { 120, 20, 60, "darkseagreen" },
|
||||
[109] = { 180, 20, 60, "lightskyblue3" },
|
||||
[110] = { 210, 50, 68, "lightskyblue3" },
|
||||
[111] = { 220, 100, 76, "skyblue2" },
|
||||
[112] = { 2, 100, 42, "chartreuse2" },
|
||||
[113] = { 100, 60, 60, "darkolivegreen3" },
|
||||
[114] = { 120, 50, 68, "palegreen3" },
|
||||
[115] = { 150, 50, 68, "darkseagreen3" },
|
||||
[116] = { 180, 50, 68, "darkslategray3" },
|
||||
[117] = { 200, 100, 76, "skyblue1" },
|
||||
[118] = { 8, 100, 50, "chartreuse1" },
|
||||
[119] = { 105, 100, 68, "lightgreen" },
|
||||
[120] = { 120, 100, 76, "lightgreen" },
|
||||
[121] = { 140, 100, 76, "palegreen1" },
|
||||
[122] = { 160, 100, 76, "aquamarine1" },
|
||||
[123] = { 180, 100, 76, "darkslategray1" },
|
||||
[124] = { 0, 100, 34, "red3" },
|
||||
[125] = { 27, 100, 34, "deeppink4" },
|
||||
[126] = { 13, 100, 34, "mediumvioletred" },
|
||||
[127] = { 300, 100, 34, "magenta3" },
|
||||
[128] = { 88, 100, 42, "darkviolet" },
|
||||
[129] = { 81, 100, 50, "purple" },
|
||||
[130] = { 2, 100, 34, "darkorange3" },
|
||||
[131] = { 0, 33, 52, "indianred" },
|
||||
[132] = { 330, 33, 52, "hotpink3" },
|
||||
[133] = { 300, 33, 52, "mediumorchid3" },
|
||||
[134] = { 280, 60, 60, "mediumorchid" },
|
||||
[135] = { 270, 100, 68, "mediumpurple2" },
|
||||
[136] = { 6, 100, 34, "darkgoldenrod" },
|
||||
[137] = { 30, 33, 52, "lightsalmon3" },
|
||||
[138] = { 0, 20, 60, "rosybrown" },
|
||||
[139] = { 300, 20, 60, "grey63" },
|
||||
[140] = { 270, 50, 68, "mediumpurple2" },
|
||||
[141] = { 260, 100, 76, "mediumpurple1" },
|
||||
[142] = { 60, 100, 34, "gold3" },
|
||||
[143] = { 60, 33, 52, "darkkhaki" },
|
||||
[144] = { 60, 20, 60, "navajowhite3" },
|
||||
[145] = { 0, 0, 68, "grey69" },
|
||||
[146] = { 240, 33, 76, "lightsteelblue3" },
|
||||
[147] = { 240, 100, 84, "lightsteelblue" },
|
||||
[148] = { 1, 100, 42, "yellow3" },
|
||||
[149] = { 80, 60, 60, "darkolivegreen3" },
|
||||
[150] = { 90, 50, 68, "darkseagreen3" },
|
||||
[151] = { 120, 33, 76, "darkseagreen2" },
|
||||
[152] = { 180, 33, 76, "lightcyan3" },
|
||||
[153] = { 210, 100, 84, "lightskyblue1" },
|
||||
[154] = { 8, 100, 50, "greenyellow" },
|
||||
[155] = { 90, 100, 68, "darkolivegreen2" },
|
||||
[156] = { 100, 100, 76, "palegreen1" },
|
||||
[157] = { 120, 100, 84, "darkseagreen2" },
|
||||
[158] = { 150, 100, 84, "darkseagreen1" },
|
||||
[159] = { 180, 100, 84, "paleturquoise1" },
|
||||
[160] = { 0, 100, 42, "red3" },
|
||||
[161] = { 33, 100, 42, "deeppink3" },
|
||||
[162] = { 22, 100, 42, "deeppink3" },
|
||||
[163] = { 11, 100, 42, "magenta3" },
|
||||
[164] = { 300, 100, 42, "magenta3" },
|
||||
[165] = { 90, 100, 50, "magenta2" },
|
||||
[166] = { 6, 100, 42, "darkorange3" },
|
||||
[167] = { 0, 60, 60, "indianred" },
|
||||
[168] = { 340, 60, 60, "hotpink3" },
|
||||
[169] = { 320, 60, 60, "hotpink2" },
|
||||
[170] = { 300, 60, 60, "orchid" },
|
||||
[171] = { 285, 100, 68, "mediumorchid1" },
|
||||
[172] = { 7, 100, 42, "orange3" },
|
||||
[173] = { 20, 60, 60, "lightsalmon3" },
|
||||
[174] = { 0, 50, 68, "lightpink3" },
|
||||
[175] = { 330, 50, 68, "pink3" },
|
||||
[176] = { 300, 50, 68, "plum3" },
|
||||
[177] = { 280, 100, 76, "violet" },
|
||||
[178] = { 8, 100, 42, "gold3" },
|
||||
[179] = { 40, 60, 60, "lightgoldenrod3" },
|
||||
[180] = { 30, 50, 68, "tan" },
|
||||
[181] = { 0, 33, 76, "mistyrose3" },
|
||||
[182] = { 300, 33, 76, "thistle3" },
|
||||
[183] = { 270, 100, 84, "plum2" },
|
||||
[184] = { 60, 100, 42, "yellow3" },
|
||||
[185] = { 60, 60, 60, "khaki3" },
|
||||
[186] = { 60, 50, 68, "lightgoldenrod2" },
|
||||
[187] = { 60, 33, 76, "lightyellow3" },
|
||||
[188] = { 0, 0, 84, "grey84" },
|
||||
[189] = { 240, 100, 92, "lightsteelblue1" },
|
||||
[190] = { 9, 100, 50, "yellow2" },
|
||||
[191] = { 75, 100, 68, "darkolivegreen1" },
|
||||
[192] = { 80, 100, 76, "darkolivegreen1" },
|
||||
[193] = { 90, 100, 84, "darkseagreen1" },
|
||||
[194] = { 120, 100, 92, "honeydew2" },
|
||||
[195] = { 180, 100, 92, "lightcyan1" },
|
||||
[196] = { 0, 100, 50, "red1" },
|
||||
[197] = { 37, 100, 50, "deeppink2" },
|
||||
[198] = { 28, 100, 50, "deeppink1" },
|
||||
[199] = { 18, 100, 50, "deeppink1" },
|
||||
[200] = { 9, 100, 50, "magenta2" },
|
||||
[201] = { 300, 100, 50, "magenta1" },
|
||||
[202] = { 2, 100, 50, "orangered1" },
|
||||
[203] = { 0, 100, 68, "indianred1" },
|
||||
[204] = { 345, 100, 68, "indianred1" },
|
||||
[205] = { 330, 100, 68, "hotpink" },
|
||||
[206] = { 315, 100, 68, "hotpink" },
|
||||
[207] = { 300, 100, 68, "mediumorchid1" },
|
||||
[208] = { 1, 100, 50, "darkorange" },
|
||||
[209] = { 15, 100, 68, "salmon1" },
|
||||
[210] = { 0, 100, 76, "lightcoral" },
|
||||
[211] = { 340, 100, 76, "palevioletred1" },
|
||||
[212] = { 320, 100, 76, "orchid2" },
|
||||
[213] = { 300, 100, 76, "orchid1" },
|
||||
[214] = { 1, 100, 50, "orange1" },
|
||||
[215] = { 30, 100, 68, "sandybrown" },
|
||||
[216] = { 20, 100, 76, "lightsalmon1" },
|
||||
[217] = { 0, 100, 84, "lightpink1" },
|
||||
[218] = { 330, 100, 84, "pink1" },
|
||||
[219] = { 300, 100, 84, "plum1" },
|
||||
[220] = { 0, 100, 50, "gold1" },
|
||||
[221] = { 45, 100, 68, "lightgoldenrod2" },
|
||||
[222] = { 40, 100, 76, "lightgoldenrod2" },
|
||||
[223] = { 30, 100, 84, "navajowhite1" },
|
||||
[224] = { 0, 100, 92, "mistyrose1" },
|
||||
[225] = { 300, 100, 92, "thistle1" },
|
||||
[226] = { 60, 100, 50, "yellow1" },
|
||||
[227] = { 60, 100, 68, "lightgoldenrod1" },
|
||||
[228] = { 60, 100, 76, "khaki1" },
|
||||
[229] = { 60, 100, 84, "wheat1" },
|
||||
[230] = { 60, 100, 92, "cornsilk1" },
|
||||
[231] = { 0, 0, 100, "grey100" },
|
||||
[232] = { 0, 0, 3, "grey3" },
|
||||
[233] = { 0, 0, 7, "grey7" },
|
||||
[234] = { 0, 0, 10, "grey11" },
|
||||
[235] = { 0, 0, 14, "grey15" },
|
||||
[236] = { 0, 0, 18, "grey19" },
|
||||
[237] = { 0, 0, 22, "grey23" },
|
||||
[238] = { 0, 0, 26, "grey27" },
|
||||
[239] = { 0, 0, 30, "grey30" },
|
||||
[240] = { 0, 0, 34, "grey35" },
|
||||
[241] = { 0, 0, 37, "grey39" },
|
||||
[242] = { 0, 0, 40, "grey42" },
|
||||
[243] = { 0, 0, 46, "grey46" },
|
||||
[244] = { 0, 0, 50, "grey50" },
|
||||
[245] = { 0, 0, 54, "grey54" },
|
||||
[246] = { 0, 0, 58, "grey58" },
|
||||
[247] = { 0, 0, 61, "grey62" },
|
||||
[248] = { 0, 0, 65, "grey66" },
|
||||
[249] = { 0, 0, 69, "grey70" },
|
||||
[250] = { 0, 0, 73, "grey74" },
|
||||
[251] = { 0, 0, 77, "grey78" },
|
||||
[252] = { 0, 0, 81, "grey82" },
|
||||
[253] = { 0, 0, 85, "grey85" },
|
||||
[254] = { 0, 0, 89, "grey89" },
|
||||
[255] = { 0, 0, 93, "grey93" },
|
||||
[0] = { 0, 0, 0, "black" },
|
||||
[1] = { 0, 100, 25, "red" },
|
||||
[2] = { 120, 100, 25, "green" },
|
||||
[3] = { 60, 100, 25, "yellow" },
|
||||
[4] = { 240, 100, 25, "blue" },
|
||||
[5] = { 300, 100, 25, "magenta" },
|
||||
[6] = { 180, 100, 25, "cyan" },
|
||||
[7] = { 0, 0, 75, "white" },
|
||||
[8] = { 0, 0, 50, "lightblack" },
|
||||
[9] = { 0, 100, 50, "lightred" },
|
||||
[10] = { 120, 100, 50, "lightgreen" },
|
||||
[11] = { 60, 100, 50, "lightyellow" },
|
||||
[12] = { 240, 100, 50, "lightblue" },
|
||||
[13] = { 300, 100, 50, "lightmagenta" },
|
||||
[14] = { 180, 100, 50, "lightcyan" },
|
||||
[15] = { 0, 0, 100, "lightwhite" },
|
||||
[16] = { 0, 0, 0, "grey0" },
|
||||
[17] = { 240, 100, 18, "navyblue" },
|
||||
[18] = { 240, 100, 26, "darkblue" },
|
||||
[19] = { 240, 100, 34, "blue3" },
|
||||
[20] = { 240, 100, 42, "blue3" },
|
||||
[21] = { 240, 100, 50, "blue1" },
|
||||
[22] = { 120, 100, 18, "darkgreen" },
|
||||
[23] = { 180, 100, 18, "deepskyblue4" },
|
||||
[24] = { 97, 100, 26, "deepskyblue4" },
|
||||
[25] = { 7, 100, 34, "deepskyblue4" },
|
||||
[26] = { 13, 100, 42, "dodgerblue3" },
|
||||
[27] = { 17, 100, 50, "dodgerblue2" },
|
||||
[28] = { 120, 100, 26, "green4" },
|
||||
[29] = { 62, 100, 26, "springgreen4" },
|
||||
[30] = { 180, 100, 26, "turquoise4" },
|
||||
[31] = { 93, 100, 34, "deepskyblue3" },
|
||||
[32] = { 2, 100, 42, "deepskyblue3" },
|
||||
[33] = { 8, 100, 50, "dodgerblue1" },
|
||||
[34] = { 120, 100, 34, "green3" },
|
||||
[35] = { 52, 100, 34, "springgreen3" },
|
||||
[36] = { 66, 100, 34, "darkcyan" },
|
||||
[37] = { 180, 100, 34, "lightseagreen" },
|
||||
[38] = { 91, 100, 42, "deepskyblue2" },
|
||||
[39] = { 98, 100, 50, "deepskyblue1" },
|
||||
[40] = { 120, 100, 42, "green3" },
|
||||
[41] = { 46, 100, 42, "springgreen3" },
|
||||
[42] = { 57, 100, 42, "springgreen2" },
|
||||
[43] = { 68, 100, 42, "cyan3" },
|
||||
[44] = { 180, 100, 42, "darkturquoise" },
|
||||
[45] = { 89, 100, 50, "turquoise2" },
|
||||
[46] = { 120, 100, 50, "green1" },
|
||||
[47] = { 42, 100, 50, "springgreen2" },
|
||||
[48] = { 51, 100, 50, "springgreen1" },
|
||||
[49] = { 61, 100, 50, "mediumspringgreen" },
|
||||
[50] = { 70, 100, 50, "cyan2" },
|
||||
[51] = { 180, 100, 50, "cyan1" },
|
||||
[52] = { 0, 100, 18, "darkred" },
|
||||
[53] = { 300, 100, 18, "deeppink4" },
|
||||
[54] = { 82, 100, 26, "purple4" },
|
||||
[55] = { 72, 100, 34, "purple4" },
|
||||
[56] = { 66, 100, 42, "purple3" },
|
||||
[57] = { 62, 100, 50, "blueviolet" },
|
||||
[58] = { 60, 100, 18, "orange4" },
|
||||
[59] = { 0, 0, 37, "grey37" },
|
||||
[60] = { 240, 17, 45, "mediumpurple4" },
|
||||
[61] = { 240, 33, 52, "slateblue3" },
|
||||
[62] = { 240, 60, 60, "slateblue3" },
|
||||
[63] = { 240, 100, 68, "royalblue1" },
|
||||
[64] = { 7, 100, 26, "chartreuse4" },
|
||||
[65] = { 120, 17, 45, "darkseagreen4" },
|
||||
[66] = { 180, 17, 45, "paleturquoise4" },
|
||||
[67] = { 210, 33, 52, "steelblue" },
|
||||
[68] = { 220, 60, 60, "steelblue3" },
|
||||
[69] = { 225, 100, 68, "cornflowerblue" },
|
||||
[70] = { 7, 100, 34, "chartreuse3" },
|
||||
[71] = { 120, 33, 52, "darkseagreen4" },
|
||||
[72] = { 150, 33, 52, "cadetblue" },
|
||||
[73] = { 180, 33, 52, "cadetblue" },
|
||||
[74] = { 200, 60, 60, "skyblue3" },
|
||||
[75] = { 210, 100, 68, "steelblue1" },
|
||||
[76] = { 3, 100, 42, "chartreuse3" },
|
||||
[77] = { 120, 60, 60, "palegreen3" },
|
||||
[78] = { 140, 60, 60, "seagreen3" },
|
||||
[79] = { 160, 60, 60, "aquamarine3" },
|
||||
[80] = { 180, 60, 60, "mediumturquoise" },
|
||||
[81] = { 195, 100, 68, "steelblue1" },
|
||||
[82] = { 7, 100, 50, "chartreuse2" },
|
||||
[83] = { 120, 100, 68, "seagreen2" },
|
||||
[84] = { 135, 100, 68, "seagreen1" },
|
||||
[85] = { 150, 100, 68, "seagreen1" },
|
||||
[86] = { 165, 100, 68, "aquamarine1" },
|
||||
[87] = { 180, 100, 68, "darkslategray2" },
|
||||
[88] = { 0, 100, 26, "darkred" },
|
||||
[89] = { 17, 100, 26, "deeppink4" },
|
||||
[90] = { 300, 100, 26, "darkmagenta" },
|
||||
[91] = { 86, 100, 34, "darkmagenta" },
|
||||
[92] = { 77, 100, 42, "darkviolet" },
|
||||
[93] = { 71, 100, 50, "purple" },
|
||||
[94] = { 2, 100, 26, "orange4" },
|
||||
[95] = { 0, 17, 45, "lightpink4" },
|
||||
[96] = { 300, 17, 45, "plum4" },
|
||||
[97] = { 270, 33, 52, "mediumpurple3" },
|
||||
[98] = { 260, 60, 60, "mediumpurple3" },
|
||||
[99] = { 255, 100, 68, "slateblue1" },
|
||||
[100] = { 60, 100, 26, "yellow4" },
|
||||
[101] = { 60, 17, 45, "wheat4" },
|
||||
[102] = { 0, 0, 52, "grey53" },
|
||||
[103] = { 240, 20, 60, "lightslategrey" },
|
||||
[104] = { 240, 50, 68, "mediumpurple" },
|
||||
[105] = { 240, 100, 76, "lightslateblue" },
|
||||
[106] = { 3, 100, 34, "yellow4" },
|
||||
[107] = { 90, 33, 52, "darkolivegreen3" },
|
||||
[108] = { 120, 20, 60, "darkseagreen" },
|
||||
[109] = { 180, 20, 60, "lightskyblue3" },
|
||||
[110] = { 210, 50, 68, "lightskyblue3" },
|
||||
[111] = { 220, 100, 76, "skyblue2" },
|
||||
[112] = { 2, 100, 42, "chartreuse2" },
|
||||
[113] = { 100, 60, 60, "darkolivegreen3" },
|
||||
[114] = { 120, 50, 68, "palegreen3" },
|
||||
[115] = { 150, 50, 68, "darkseagreen3" },
|
||||
[116] = { 180, 50, 68, "darkslategray3" },
|
||||
[117] = { 200, 100, 76, "skyblue1" },
|
||||
[118] = { 8, 100, 50, "chartreuse1" },
|
||||
[119] = { 105, 100, 68, "lightgreen" },
|
||||
[120] = { 120, 100, 76, "lightgreen" },
|
||||
[121] = { 140, 100, 76, "palegreen1" },
|
||||
[122] = { 160, 100, 76, "aquamarine1" },
|
||||
[123] = { 180, 100, 76, "darkslategray1" },
|
||||
[124] = { 0, 100, 34, "red3" },
|
||||
[125] = { 27, 100, 34, "deeppink4" },
|
||||
[126] = { 13, 100, 34, "mediumvioletred" },
|
||||
[127] = { 300, 100, 34, "magenta3" },
|
||||
[128] = { 88, 100, 42, "darkviolet" },
|
||||
[129] = { 81, 100, 50, "purple" },
|
||||
[130] = { 2, 100, 34, "darkorange3" },
|
||||
[131] = { 0, 33, 52, "indianred" },
|
||||
[132] = { 330, 33, 52, "hotpink3" },
|
||||
[133] = { 300, 33, 52, "mediumorchid3" },
|
||||
[134] = { 280, 60, 60, "mediumorchid" },
|
||||
[135] = { 270, 100, 68, "mediumpurple2" },
|
||||
[136] = { 6, 100, 34, "darkgoldenrod" },
|
||||
[137] = { 30, 33, 52, "lightsalmon3" },
|
||||
[138] = { 0, 20, 60, "rosybrown" },
|
||||
[139] = { 300, 20, 60, "grey63" },
|
||||
[140] = { 270, 50, 68, "mediumpurple2" },
|
||||
[141] = { 260, 100, 76, "mediumpurple1" },
|
||||
[142] = { 60, 100, 34, "gold3" },
|
||||
[143] = { 60, 33, 52, "darkkhaki" },
|
||||
[144] = { 60, 20, 60, "navajowhite3" },
|
||||
[145] = { 0, 0, 68, "grey69" },
|
||||
[146] = { 240, 33, 76, "lightsteelblue3" },
|
||||
[147] = { 240, 100, 84, "lightsteelblue" },
|
||||
[148] = { 1, 100, 42, "yellow3" },
|
||||
[149] = { 80, 60, 60, "darkolivegreen3" },
|
||||
[150] = { 90, 50, 68, "darkseagreen3" },
|
||||
[151] = { 120, 33, 76, "darkseagreen2" },
|
||||
[152] = { 180, 33, 76, "lightcyan3" },
|
||||
[153] = { 210, 100, 84, "lightskyblue1" },
|
||||
[154] = { 8, 100, 50, "greenyellow" },
|
||||
[155] = { 90, 100, 68, "darkolivegreen2" },
|
||||
[156] = { 100, 100, 76, "palegreen1" },
|
||||
[157] = { 120, 100, 84, "darkseagreen2" },
|
||||
[158] = { 150, 100, 84, "darkseagreen1" },
|
||||
[159] = { 180, 100, 84, "paleturquoise1" },
|
||||
[160] = { 0, 100, 42, "red3" },
|
||||
[161] = { 33, 100, 42, "deeppink3" },
|
||||
[162] = { 22, 100, 42, "deeppink3" },
|
||||
[163] = { 11, 100, 42, "magenta3" },
|
||||
[164] = { 300, 100, 42, "magenta3" },
|
||||
[165] = { 90, 100, 50, "magenta2" },
|
||||
[166] = { 6, 100, 42, "darkorange3" },
|
||||
[167] = { 0, 60, 60, "indianred" },
|
||||
[168] = { 340, 60, 60, "hotpink3" },
|
||||
[169] = { 320, 60, 60, "hotpink2" },
|
||||
[170] = { 300, 60, 60, "orchid" },
|
||||
[171] = { 285, 100, 68, "mediumorchid1" },
|
||||
[172] = { 7, 100, 42, "orange3" },
|
||||
[173] = { 20, 60, 60, "lightsalmon3" },
|
||||
[174] = { 0, 50, 68, "lightpink3" },
|
||||
[175] = { 330, 50, 68, "pink3" },
|
||||
[176] = { 300, 50, 68, "plum3" },
|
||||
[177] = { 280, 100, 76, "violet" },
|
||||
[178] = { 8, 100, 42, "gold3" },
|
||||
[179] = { 40, 60, 60, "lightgoldenrod3" },
|
||||
[180] = { 30, 50, 68, "tan" },
|
||||
[181] = { 0, 33, 76, "mistyrose3" },
|
||||
[182] = { 300, 33, 76, "thistle3" },
|
||||
[183] = { 270, 100, 84, "plum2" },
|
||||
[184] = { 60, 100, 42, "yellow3" },
|
||||
[185] = { 60, 60, 60, "khaki3" },
|
||||
[186] = { 60, 50, 68, "lightgoldenrod2" },
|
||||
[187] = { 60, 33, 76, "lightyellow3" },
|
||||
[188] = { 0, 0, 84, "grey84" },
|
||||
[189] = { 240, 100, 92, "lightsteelblue1" },
|
||||
[190] = { 9, 100, 50, "yellow2" },
|
||||
[191] = { 75, 100, 68, "darkolivegreen1" },
|
||||
[192] = { 80, 100, 76, "darkolivegreen1" },
|
||||
[193] = { 90, 100, 84, "darkseagreen1" },
|
||||
[194] = { 120, 100, 92, "honeydew2" },
|
||||
[195] = { 180, 100, 92, "lightcyan1" },
|
||||
[196] = { 0, 100, 50, "red1" },
|
||||
[197] = { 37, 100, 50, "deeppink2" },
|
||||
[198] = { 28, 100, 50, "deeppink1" },
|
||||
[199] = { 18, 100, 50, "deeppink1" },
|
||||
[200] = { 9, 100, 50, "magenta2" },
|
||||
[201] = { 300, 100, 50, "magenta1" },
|
||||
[202] = { 2, 100, 50, "orangered1" },
|
||||
[203] = { 0, 100, 68, "indianred1" },
|
||||
[204] = { 345, 100, 68, "indianred1" },
|
||||
[205] = { 330, 100, 68, "hotpink" },
|
||||
[206] = { 315, 100, 68, "hotpink" },
|
||||
[207] = { 300, 100, 68, "mediumorchid1" },
|
||||
[208] = { 1, 100, 50, "darkorange" },
|
||||
[209] = { 15, 100, 68, "salmon1" },
|
||||
[210] = { 0, 100, 76, "lightcoral" },
|
||||
[211] = { 340, 100, 76, "palevioletred1" },
|
||||
[212] = { 320, 100, 76, "orchid2" },
|
||||
[213] = { 300, 100, 76, "orchid1" },
|
||||
[214] = { 1, 100, 50, "orange1" },
|
||||
[215] = { 30, 100, 68, "sandybrown" },
|
||||
[216] = { 20, 100, 76, "lightsalmon1" },
|
||||
[217] = { 0, 100, 84, "lightpink1" },
|
||||
[218] = { 330, 100, 84, "pink1" },
|
||||
[219] = { 300, 100, 84, "plum1" },
|
||||
[220] = { 0, 100, 50, "gold1" },
|
||||
[221] = { 45, 100, 68, "lightgoldenrod2" },
|
||||
[222] = { 40, 100, 76, "lightgoldenrod2" },
|
||||
[223] = { 30, 100, 84, "navajowhite1" },
|
||||
[224] = { 0, 100, 92, "mistyrose1" },
|
||||
[225] = { 300, 100, 92, "thistle1" },
|
||||
[226] = { 60, 100, 50, "yellow1" },
|
||||
[227] = { 60, 100, 68, "lightgoldenrod1" },
|
||||
[228] = { 60, 100, 76, "khaki1" },
|
||||
[229] = { 60, 100, 84, "wheat1" },
|
||||
[230] = { 60, 100, 92, "cornsilk1" },
|
||||
[231] = { 0, 0, 100, "grey100" },
|
||||
[232] = { 0, 0, 3, "grey3" },
|
||||
[233] = { 0, 0, 7, "grey7" },
|
||||
[234] = { 0, 0, 10, "grey11" },
|
||||
[235] = { 0, 0, 14, "grey15" },
|
||||
[236] = { 0, 0, 18, "grey19" },
|
||||
[237] = { 0, 0, 22, "grey23" },
|
||||
[238] = { 0, 0, 26, "grey27" },
|
||||
[239] = { 0, 0, 30, "grey30" },
|
||||
[240] = { 0, 0, 34, "grey35" },
|
||||
[241] = { 0, 0, 37, "grey39" },
|
||||
[242] = { 0, 0, 40, "grey42" },
|
||||
[243] = { 0, 0, 46, "grey46" },
|
||||
[244] = { 0, 0, 50, "grey50" },
|
||||
[245] = { 0, 0, 54, "grey54" },
|
||||
[246] = { 0, 0, 58, "grey58" },
|
||||
[247] = { 0, 0, 61, "grey62" },
|
||||
[248] = { 0, 0, 65, "grey66" },
|
||||
[249] = { 0, 0, 69, "grey70" },
|
||||
[250] = { 0, 0, 73, "grey74" },
|
||||
[251] = { 0, 0, 77, "grey78" },
|
||||
[252] = { 0, 0, 81, "grey82" },
|
||||
[253] = { 0, 0, 85, "grey85" },
|
||||
[254] = { 0, 0, 89, "grey89" },
|
||||
[255] = { 0, 0, 93, "grey93" },
|
||||
};
|
||||
|
||||
/* -1 is valid curses color */
|
||||
#define COL_ERR -2
|
||||
|
||||
static inline int
|
||||
color_distance(const struct color_def* a, const struct color_def* b)
|
||||
static inline int color_distance(const struct color_def *a, const struct color_def *b)
|
||||
{
|
||||
int h = MIN((a->h - b->h) % 360, (b->h - a->h) % 360);
|
||||
int h = MIN((a->h - b->h)%360, (b->h - a->h)%360);
|
||||
int s = (int)a->s - b->s;
|
||||
int l = (int)a->l - b->l;
|
||||
return h * h + s * s + l * l;
|
||||
return h*h + s*s + l*l;
|
||||
}
|
||||
|
||||
static int
|
||||
find_closest_col(int h, int s, int l)
|
||||
static int find_closest_col(int h, int s, int l)
|
||||
{
|
||||
int i;
|
||||
struct color_def a = { h, s, l };
|
||||
struct color_def a = {h, s, l};
|
||||
int min = 0;
|
||||
int dmin = color_distance(&a, &color_names[0]);
|
||||
|
||||
@ -356,11 +352,10 @@ find_closest_col(int h, int s, int l)
|
||||
return min;
|
||||
}
|
||||
|
||||
static int
|
||||
find_col(const char* col_name, int n)
|
||||
static int find_col(const char *col_name, int n)
|
||||
{
|
||||
int i;
|
||||
char name[32] = { 0 };
|
||||
char name[32] = {0};
|
||||
|
||||
/*
|
||||
* make a null terminated version of col_name. we don't want to
|
||||
@ -371,7 +366,7 @@ find_col(const char* col_name, int n)
|
||||
if (n >= sizeof(name)) {
|
||||
/* truncate */
|
||||
log_error("Color: <%s,%d> bigger than %zu", col_name, n, sizeof(name));
|
||||
n = sizeof(name) - 1;
|
||||
n = sizeof(name)-1;
|
||||
}
|
||||
memcpy(name, col_name, n);
|
||||
|
||||
@ -388,11 +383,10 @@ find_col(const char* col_name, int n)
|
||||
return COL_ERR;
|
||||
}
|
||||
|
||||
static int
|
||||
color_hash(const char* str, color_profile profile)
|
||||
static int color_hash(const char *str, color_profile profile)
|
||||
{
|
||||
GChecksum* cs = NULL;
|
||||
guint8 buf[256] = { 0 };
|
||||
GChecksum *cs = NULL;
|
||||
guint8 buf[256] = {0};
|
||||
gsize len = 256;
|
||||
int rc = -1; /* default ncurse color */
|
||||
|
||||
@ -409,27 +403,27 @@ color_hash(const char* str, color_profile profile)
|
||||
|
||||
double h = ((buf[1] << 8) | buf[0]) / 65536. * 360.;
|
||||
|
||||
switch (profile) {
|
||||
case COLOR_PROFILE_REDGREEN_BLINDNESS:
|
||||
// red/green blindness correction
|
||||
h = fmod(fmod(h + 90., 180) - 90., 360.);
|
||||
break;
|
||||
case COLOR_PROFILE_BLUE_BLINDNESS:
|
||||
// blue blindness correction
|
||||
h = fmod(h, 180.);
|
||||
default:
|
||||
break;
|
||||
switch(profile)
|
||||
{
|
||||
case COLOR_PROFILE_REDGREEN_BLINDNESS:
|
||||
// red/green blindness correction
|
||||
h = fmod(fmod(h + 90., 180) - 90., 360.);
|
||||
break;
|
||||
case COLOR_PROFILE_BLUE_BLINDNESS:
|
||||
// blue blindness correction
|
||||
h = fmod(h, 180.);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
rc = find_closest_col((int)h, 100, 50);
|
||||
|
||||
out:
|
||||
out:
|
||||
g_checksum_free(cs);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void
|
||||
color_pair_cache_reset(void)
|
||||
void color_pair_cache_reset(void)
|
||||
{
|
||||
if (cache.pairs) {
|
||||
free(cache.pairs);
|
||||
@ -446,7 +440,7 @@ color_pair_cache_reset(void)
|
||||
if (cache.capacity < 0)
|
||||
cache.capacity = 8;
|
||||
|
||||
cache.pairs = g_malloc0(sizeof(*cache.pairs) * cache.capacity);
|
||||
cache.pairs = g_malloc0(sizeof(*cache.pairs)*cache.capacity);
|
||||
if (cache.pairs) {
|
||||
/* default_default */
|
||||
cache.pairs[0].fg = -1;
|
||||
@ -457,8 +451,7 @@ color_pair_cache_reset(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_color_pair_cache_get(int fg, int bg)
|
||||
static int _color_pair_cache_get(int fg, int bg)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -504,13 +497,12 @@ _color_pair_cache_get(int fg, int bg)
|
||||
* hash a string into a color that will be used as fg
|
||||
* check for 'bkgnd' in theme file or use default color as bg
|
||||
*/
|
||||
int
|
||||
color_pair_cache_hash_str(const char* str, color_profile profile)
|
||||
int color_pair_cache_hash_str(const char *str, color_profile profile)
|
||||
{
|
||||
int fg = color_hash(str, profile);
|
||||
int bg = -1;
|
||||
|
||||
char* bkgnd = theme_get_bkgnd();
|
||||
char *bkgnd = theme_get_bkgnd();
|
||||
if (bkgnd) {
|
||||
bg = find_col(bkgnd, strlen(bkgnd));
|
||||
free(bkgnd);
|
||||
@ -525,10 +517,9 @@ color_pair_cache_hash_str(const char* str, color_profile profile)
|
||||
* if the pair doesn't exist it will allocate it in curses with init_pair
|
||||
* if the pair exists it returns its id
|
||||
*/
|
||||
int
|
||||
color_pair_cache_get(const char* pair_name)
|
||||
int color_pair_cache_get(const char *pair_name)
|
||||
{
|
||||
const char* sep;
|
||||
const char *sep;
|
||||
int fg, bg;
|
||||
|
||||
sep = strchr(pair_name, '_');
|
||||
@ -538,7 +529,7 @@ color_pair_cache_get(const char* pair_name)
|
||||
}
|
||||
|
||||
fg = find_col(pair_name, sep - pair_name);
|
||||
bg = find_col(sep + 1, strlen(sep));
|
||||
bg = find_col(sep+1, strlen(sep));
|
||||
if (fg == COL_ERR || bg == COL_ERR) {
|
||||
log_error("Color: bad color name %s", pair_name);
|
||||
return -1;
|
||||
|
@ -47,18 +47,16 @@ typedef enum {
|
||||
COLOR_PROFILE_BLUE_BLINDNESS,
|
||||
} color_profile;
|
||||
|
||||
struct color_def
|
||||
{
|
||||
uint16_t h;
|
||||
uint8_t s, l;
|
||||
const char* name;
|
||||
struct color_def {
|
||||
uint16_t h; uint8_t s, l;
|
||||
const char *name;
|
||||
};
|
||||
extern const struct color_def color_names[];
|
||||
|
||||
/* hash string to color pair */
|
||||
int color_pair_cache_hash_str(const char* str, color_profile profile);
|
||||
int color_pair_cache_hash_str(const char *str, color_profile profile);
|
||||
/* parse fg_bg string to color pair */
|
||||
int color_pair_cache_get(const char* pair_name);
|
||||
int color_pair_cache_get(const char *pair_name);
|
||||
/* clear cache */
|
||||
void color_pair_cache_reset(void);
|
||||
|
||||
|
@ -33,15 +33,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
gboolean
|
||||
conf_string_list_add(GKeyFile* keyfile, const char* const group, const char* const key, const char* const item)
|
||||
conf_string_list_add(GKeyFile *keyfile, const char *const group, const char *const key, const char *const item)
|
||||
{
|
||||
gsize length;
|
||||
gchar** list = g_key_file_get_string_list(keyfile, group, key, &length, NULL);
|
||||
GList* glist = NULL;
|
||||
gchar **list = g_key_file_get_string_list(keyfile, group, key, &length, NULL);
|
||||
GList *glist = NULL;
|
||||
|
||||
// list found
|
||||
if (list) {
|
||||
@ -61,8 +61,8 @@ conf_string_list_add(GKeyFile* keyfile, const char* const group, const char* con
|
||||
glist = g_list_append(glist, strdup(item));
|
||||
|
||||
// create the new list entry
|
||||
const gchar* new_list[g_list_length(glist) + 1];
|
||||
GList* curr = glist;
|
||||
const gchar* new_list[g_list_length(glist)+1];
|
||||
GList *curr = glist;
|
||||
i = 0;
|
||||
while (curr) {
|
||||
new_list[i++] = curr->data;
|
||||
@ -71,7 +71,7 @@ conf_string_list_add(GKeyFile* keyfile, const char* const group, const char* con
|
||||
new_list[i] = NULL;
|
||||
g_key_file_set_string_list(keyfile, group, key, new_list, g_list_length(glist));
|
||||
|
||||
// list not found
|
||||
// list not found
|
||||
} else {
|
||||
const gchar* new_list[2];
|
||||
new_list[0] = item;
|
||||
@ -86,15 +86,15 @@ conf_string_list_add(GKeyFile* keyfile, const char* const group, const char* con
|
||||
}
|
||||
|
||||
gboolean
|
||||
conf_string_list_remove(GKeyFile* keyfile, const char* const group, const char* const key, const char* const item)
|
||||
conf_string_list_remove(GKeyFile *keyfile, const char *const group, const char *const key, const char *const item)
|
||||
{
|
||||
gsize length;
|
||||
gchar** list = g_key_file_get_string_list(keyfile, group, key, &length, NULL);
|
||||
gchar **list = g_key_file_get_string_list(keyfile, group, key, &length, NULL);
|
||||
|
||||
gboolean deleted = FALSE;
|
||||
if (list) {
|
||||
int i = 0;
|
||||
GList* glist = NULL;
|
||||
GList *glist = NULL;
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
// item found, mark as deleted
|
||||
@ -111,8 +111,8 @@ conf_string_list_remove(GKeyFile* keyfile, const char* const group, const char*
|
||||
g_key_file_remove_key(keyfile, group, key, NULL);
|
||||
} else {
|
||||
// create the new list entry
|
||||
const gchar* new_list[g_list_length(glist) + 1];
|
||||
GList* curr = glist;
|
||||
const gchar* new_list[g_list_length(glist)+1];
|
||||
GList *curr = glist;
|
||||
i = 0;
|
||||
while (curr) {
|
||||
new_list[i++] = curr->data;
|
||||
|
@ -38,9 +38,9 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
gboolean conf_string_list_add(GKeyFile* keyfile, const char* const group, const char* const key,
|
||||
const char* const item);
|
||||
gboolean conf_string_list_remove(GKeyFile* keyfile, const char* const group, const char* const key,
|
||||
const char* const item);
|
||||
gboolean conf_string_list_add(GKeyFile *keyfile, const char *const group, const char *const key,
|
||||
const char *const item);
|
||||
gboolean conf_string_list_remove(GKeyFile *keyfile, const char *const group, const char *const key,
|
||||
const char *const item);
|
||||
|
||||
#endif
|
||||
|
@ -35,15 +35,15 @@
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "log.h"
|
||||
#include "config/files.h"
|
||||
#include "config/preferences.h"
|
||||
#include "log.h"
|
||||
|
||||
static char* _files_get_xdg_config_home(void);
|
||||
static char* _files_get_xdg_data_home(void);
|
||||
@ -51,18 +51,18 @@ static char* _files_get_xdg_data_home(void);
|
||||
void
|
||||
files_create_directories(void)
|
||||
{
|
||||
gchar* xdg_config = _files_get_xdg_config_home();
|
||||
gchar* xdg_data = _files_get_xdg_data_home();
|
||||
gchar *xdg_config = _files_get_xdg_config_home();
|
||||
gchar *xdg_data = _files_get_xdg_data_home();
|
||||
|
||||
GString* themes_dir = g_string_new(xdg_config);
|
||||
GString *themes_dir = g_string_new(xdg_config);
|
||||
g_string_append(themes_dir, "/profanity/themes");
|
||||
GString* icons_dir = g_string_new(xdg_config);
|
||||
GString *icons_dir = g_string_new(xdg_config);
|
||||
g_string_append(icons_dir, "/profanity/icons");
|
||||
GString* chatlogs_dir = g_string_new(xdg_data);
|
||||
GString *chatlogs_dir = g_string_new(xdg_data);
|
||||
g_string_append(chatlogs_dir, "/profanity/chatlogs");
|
||||
GString* logs_dir = g_string_new(xdg_data);
|
||||
GString *logs_dir = g_string_new(xdg_data);
|
||||
g_string_append(logs_dir, "/profanity/logs");
|
||||
GString* plugins_dir = g_string_new(xdg_data);
|
||||
GString *plugins_dir = g_string_new(xdg_data);
|
||||
g_string_append(plugins_dir, "/profanity/plugins");
|
||||
|
||||
if (!mkdir_recursive(themes_dir->str)) {
|
||||
@ -94,14 +94,14 @@ files_create_directories(void)
|
||||
gchar*
|
||||
files_get_inputrc_file(void)
|
||||
{
|
||||
gchar* xdg_config = _files_get_xdg_config_home();
|
||||
GString* inputrc_file = g_string_new(xdg_config);
|
||||
gchar *xdg_config = _files_get_xdg_config_home();
|
||||
GString *inputrc_file = g_string_new(xdg_config);
|
||||
g_free(xdg_config);
|
||||
|
||||
g_string_append(inputrc_file, "/profanity/inputrc");
|
||||
|
||||
if (g_file_test(inputrc_file->str, G_FILE_TEST_IS_REGULAR)) {
|
||||
gchar* result = g_strdup(inputrc_file->str);
|
||||
gchar *result = g_strdup(inputrc_file->str);
|
||||
g_string_free(inputrc_file, TRUE);
|
||||
|
||||
return result;
|
||||
@ -113,10 +113,10 @@ files_get_inputrc_file(void)
|
||||
}
|
||||
|
||||
char*
|
||||
files_get_log_file(const char* const log_file)
|
||||
files_get_log_file(const char *const log_file)
|
||||
{
|
||||
gchar* xdg_data = _files_get_xdg_data_home();
|
||||
GString* logfile = g_string_new(xdg_data);
|
||||
gchar *xdg_data = _files_get_xdg_data_home();
|
||||
GString *logfile = g_string_new(xdg_data);
|
||||
|
||||
if (log_file) {
|
||||
g_string_append(logfile, "/profanity/logs/");
|
||||
@ -131,7 +131,7 @@ files_get_log_file(const char* const log_file)
|
||||
|
||||
g_string_append(logfile, ".log");
|
||||
|
||||
char* result = g_strdup(logfile->str);
|
||||
char *result = g_strdup(logfile->str);
|
||||
|
||||
free(xdg_data);
|
||||
g_string_free(logfile, TRUE);
|
||||
@ -140,13 +140,13 @@ files_get_log_file(const char* const log_file)
|
||||
}
|
||||
|
||||
gchar*
|
||||
files_get_config_path(const char* const config_base)
|
||||
files_get_config_path(const char *const config_base)
|
||||
{
|
||||
gchar* xdg_config = _files_get_xdg_config_home();
|
||||
GString* file_str = g_string_new(xdg_config);
|
||||
gchar *xdg_config = _files_get_xdg_config_home();
|
||||
GString *file_str = g_string_new(xdg_config);
|
||||
g_string_append(file_str, "/profanity/");
|
||||
g_string_append(file_str, config_base);
|
||||
gchar* result = g_strdup(file_str->str);
|
||||
gchar *result = g_strdup(file_str->str);
|
||||
g_free(xdg_config);
|
||||
g_string_free(file_str, TRUE);
|
||||
|
||||
@ -154,13 +154,13 @@ files_get_config_path(const char* const config_base)
|
||||
}
|
||||
|
||||
gchar*
|
||||
files_get_data_path(const char* const data_base)
|
||||
files_get_data_path(const char *const data_base)
|
||||
{
|
||||
gchar* xdg_data = _files_get_xdg_data_home();
|
||||
GString* file_str = g_string_new(xdg_data);
|
||||
gchar *xdg_data = _files_get_xdg_data_home();
|
||||
GString *file_str = g_string_new(xdg_data);
|
||||
g_string_append(file_str, "/profanity/");
|
||||
g_string_append(file_str, data_base);
|
||||
gchar* result = g_strdup(file_str->str);
|
||||
gchar *result = g_strdup(file_str->str);
|
||||
g_free(xdg_data);
|
||||
g_string_free(file_str, TRUE);
|
||||
|
||||
@ -168,18 +168,18 @@ files_get_data_path(const char* const data_base)
|
||||
}
|
||||
|
||||
gchar*
|
||||
files_get_account_data_path(const char* const specific_dir, const char* const jid)
|
||||
files_get_account_data_path(const char *const specific_dir, const char *const jid)
|
||||
{
|
||||
gchar* data_dir = files_get_data_path(specific_dir);
|
||||
GString* result_dir = g_string_new(data_dir);
|
||||
gchar *data_dir = files_get_data_path(specific_dir);
|
||||
GString *result_dir = g_string_new(data_dir);
|
||||
g_free(data_dir);
|
||||
|
||||
gchar* account_dir = str_replace(jid, "@", "_at_");
|
||||
gchar *account_dir = str_replace(jid, "@", "_at_");
|
||||
g_string_append(result_dir, "/");
|
||||
g_string_append(result_dir, account_dir);
|
||||
g_free(account_dir);
|
||||
|
||||
gchar* result = g_strdup(result_dir->str);
|
||||
gchar *result = g_strdup(result_dir->str);
|
||||
g_string_free(result_dir, TRUE);
|
||||
|
||||
return result;
|
||||
@ -188,8 +188,8 @@ files_get_account_data_path(const char* const specific_dir, const char* const ji
|
||||
static char*
|
||||
_files_get_xdg_config_home(void)
|
||||
{
|
||||
gchar* xdg_config_home_env = getenv("XDG_CONFIG_HOME");
|
||||
gchar* xdg_config_home = NULL;
|
||||
gchar *xdg_config_home_env = getenv("XDG_CONFIG_HOME");
|
||||
gchar *xdg_config_home = NULL;
|
||||
|
||||
if (xdg_config_home_env) {
|
||||
xdg_config_home = strdup(xdg_config_home_env);
|
||||
@ -199,9 +199,9 @@ _files_get_xdg_config_home(void)
|
||||
if (xdg_config_home && (strcmp(xdg_config_home, "") != 0)) {
|
||||
return xdg_config_home;
|
||||
} else {
|
||||
GString* default_path = g_string_new(getenv("HOME"));
|
||||
GString *default_path = g_string_new(getenv("HOME"));
|
||||
g_string_append(default_path, "/.config");
|
||||
char* result = strdup(default_path->str);
|
||||
char *result = strdup(default_path->str);
|
||||
g_string_free(default_path, TRUE);
|
||||
|
||||
return result;
|
||||
@ -211,8 +211,8 @@ _files_get_xdg_config_home(void)
|
||||
static char*
|
||||
_files_get_xdg_data_home(void)
|
||||
{
|
||||
gchar* xdg_data_home_env = getenv("XDG_DATA_HOME");
|
||||
gchar* xdg_data_home = NULL;
|
||||
gchar *xdg_data_home_env = getenv("XDG_DATA_HOME");
|
||||
gchar *xdg_data_home = NULL;
|
||||
|
||||
if (xdg_data_home_env) {
|
||||
xdg_data_home = strdup(xdg_data_home_env);
|
||||
@ -222,9 +222,9 @@ _files_get_xdg_data_home(void)
|
||||
if (xdg_data_home && (strcmp(xdg_data_home, "") != 0)) {
|
||||
return xdg_data_home;
|
||||
} else {
|
||||
GString* default_path = g_string_new(getenv("HOME"));
|
||||
GString *default_path = g_string_new(getenv("HOME"));
|
||||
g_string_append(default_path, "/.local/share");
|
||||
gchar* result = strdup(default_path->str);
|
||||
gchar *result = strdup(default_path->str);
|
||||
g_string_free(default_path, TRUE);
|
||||
|
||||
return result;
|
||||
|
@ -39,32 +39,32 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#define FILE_PROFRC "profrc"
|
||||
#define FILE_ACCOUNTS "accounts"
|
||||
#define FILE_TLSCERTS "tlscerts"
|
||||
#define FILE_PLUGIN_SETTINGS "plugin_settings"
|
||||
#define FILE_PLUGIN_THEMES "plugin_themes"
|
||||
#define FILE_CAPSCACHE "capscache"
|
||||
#define FILE_PROFANITY_IDENTIFIER "profident"
|
||||
#define FILE_PROFRC "profrc"
|
||||
#define FILE_ACCOUNTS "accounts"
|
||||
#define FILE_TLSCERTS "tlscerts"
|
||||
#define FILE_PLUGIN_SETTINGS "plugin_settings"
|
||||
#define FILE_PLUGIN_THEMES "plugin_themes"
|
||||
#define FILE_CAPSCACHE "capscache"
|
||||
#define FILE_PROFANITY_IDENTIFIER "profident"
|
||||
#define FILE_BOOKMARK_AUTOJOIN_IGNORE "bookmark_ignore"
|
||||
|
||||
#define DIR_THEMES "themes"
|
||||
#define DIR_ICONS "icons"
|
||||
#define DIR_SCRIPTS "scripts"
|
||||
#define DIR_THEMES "themes"
|
||||
#define DIR_ICONS "icons"
|
||||
#define DIR_SCRIPTS "scripts"
|
||||
#define DIR_CHATLOGS "chatlogs"
|
||||
#define DIR_OTR "otr"
|
||||
#define DIR_PGP "pgp"
|
||||
#define DIR_OMEMO "omemo"
|
||||
#define DIR_PLUGINS "plugins"
|
||||
#define DIR_OTR "otr"
|
||||
#define DIR_PGP "pgp"
|
||||
#define DIR_OMEMO "omemo"
|
||||
#define DIR_PLUGINS "plugins"
|
||||
#define DIR_DATABASE "database"
|
||||
|
||||
void files_create_directories(void);
|
||||
|
||||
gchar* files_get_config_path(const char* const config_base);
|
||||
gchar* files_get_data_path(const char* const data_base);
|
||||
gchar* files_get_account_data_path(const char* const specific_dir, const char* const jid);
|
||||
gchar* files_get_config_path(const char *const config_base);
|
||||
gchar* files_get_data_path(const char *const data_base);
|
||||
gchar* files_get_account_data_path(const char *const specific_dir, const char *const jid);
|
||||
|
||||
gchar* files_get_log_file(const char* const log_file);
|
||||
gchar* files_get_log_file(const char *const log_file);
|
||||
gchar* files_get_inputrc_file(void);
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -175,32 +175,30 @@ typedef enum {
|
||||
PREF_URL_SAVE_CMD,
|
||||
} preference_t;
|
||||
|
||||
typedef struct prof_alias_t
|
||||
{
|
||||
gchar* name;
|
||||
gchar* value;
|
||||
typedef struct prof_alias_t {
|
||||
gchar *name;
|
||||
gchar *value;
|
||||
} ProfAlias;
|
||||
|
||||
typedef struct prof_winplacement_t
|
||||
{
|
||||
typedef struct prof_winplacement_t {
|
||||
int titlebar_pos;
|
||||
int mainwin_pos;
|
||||
int statusbar_pos;
|
||||
int inputwin_pos;
|
||||
} ProfWinPlacement;
|
||||
|
||||
void prefs_load(char* config_file);
|
||||
void prefs_load(char *config_file);
|
||||
void prefs_save(void);
|
||||
void prefs_close(void);
|
||||
void prefs_reload(void);
|
||||
|
||||
char* prefs_find_login(char* prefix);
|
||||
char* prefs_find_login(char *prefix);
|
||||
void prefs_reset_login_search(void);
|
||||
|
||||
char* prefs_autocomplete_boolean_choice(const char* const prefix, gboolean previous, void* context);
|
||||
char* prefs_autocomplete_boolean_choice(const char *const prefix, gboolean previous, void *context);
|
||||
void prefs_reset_boolean_choice(void);
|
||||
|
||||
char* prefs_autocomplete_room_trigger(const char* const prefix, gboolean previous, void* context);
|
||||
char* prefs_autocomplete_room_trigger(const char *const prefix, gboolean previous, void *context);
|
||||
void prefs_reset_room_trigger_ac(void);
|
||||
|
||||
gint prefs_get_gone(void);
|
||||
@ -237,19 +235,19 @@ gint prefs_get_autoxa_time(void);
|
||||
void prefs_set_autoxa_time(gint value);
|
||||
|
||||
gchar** prefs_get_plugins(void);
|
||||
void prefs_free_plugins(gchar** plugins);
|
||||
void prefs_add_plugin(const char* const name);
|
||||
void prefs_remove_plugin(const char* const name);
|
||||
void prefs_free_plugins(gchar **plugins);
|
||||
void prefs_add_plugin(const char *const name);
|
||||
void prefs_remove_plugin(const char *const name);
|
||||
|
||||
char* prefs_get_otr_char(void);
|
||||
gboolean prefs_set_otr_char(char* ch);
|
||||
gboolean prefs_set_otr_char(char *ch);
|
||||
char* prefs_get_pgp_char(void);
|
||||
gboolean prefs_set_pgp_char(char* ch);
|
||||
gboolean prefs_set_pgp_char(char *ch);
|
||||
char* prefs_get_omemo_char(void);
|
||||
gboolean prefs_set_omemo_char(char* ch);
|
||||
gboolean prefs_set_omemo_char(char *ch);
|
||||
// XEP-0373: OpenPGP for XMPP
|
||||
char* prefs_get_ox_char(void);
|
||||
gboolean prefs_set_ox_char(char* ch);
|
||||
gboolean prefs_set_ox_char(char *ch);
|
||||
|
||||
char prefs_get_roster_header_char(void);
|
||||
void prefs_set_roster_header_char(char ch);
|
||||
@ -288,23 +286,23 @@ void prefs_set_occupants_indent(gint value);
|
||||
char* prefs_get_correction_char(void);
|
||||
void prefs_set_correction_char(char ch);
|
||||
|
||||
void prefs_add_login(const char* jid);
|
||||
void prefs_add_login(const char *jid);
|
||||
|
||||
void prefs_set_tray_timer(gint value);
|
||||
gint prefs_get_tray_timer(void);
|
||||
|
||||
gboolean prefs_add_alias(const char* const name, const char* const value);
|
||||
gboolean prefs_remove_alias(const char* const name);
|
||||
char* prefs_get_alias(const char* const name);
|
||||
gboolean prefs_add_alias(const char *const name, const char *const value);
|
||||
gboolean prefs_remove_alias(const char *const name);
|
||||
char* prefs_get_alias(const char *const name);
|
||||
GList* prefs_get_aliases(void);
|
||||
void prefs_free_aliases(GList* aliases);
|
||||
void prefs_free_aliases(GList *aliases);
|
||||
|
||||
gboolean prefs_add_room_notify_trigger(const char* const text);
|
||||
gboolean prefs_remove_room_notify_trigger(const char* const text);
|
||||
gboolean prefs_add_room_notify_trigger(const char * const text);
|
||||
gboolean prefs_remove_room_notify_trigger(const char * const text);
|
||||
GList* prefs_get_room_notify_triggers(void);
|
||||
|
||||
ProfWinPlacement* prefs_get_win_placement(void);
|
||||
void prefs_free_win_placement(ProfWinPlacement* placement);
|
||||
void prefs_free_win_placement(ProfWinPlacement *placement);
|
||||
|
||||
gboolean prefs_titlebar_pos_up(void);
|
||||
gboolean prefs_titlebar_pos_down(void);
|
||||
@ -315,35 +313,35 @@ gboolean prefs_statusbar_pos_down(void);
|
||||
gboolean prefs_inputwin_pos_up(void);
|
||||
gboolean prefs_inputwin_pos_down(void);
|
||||
ProfWinPlacement* prefs_create_profwin_placement(int titlebar, int mainwin, int statusbar, int inputwin);
|
||||
void prefs_save_win_placement(ProfWinPlacement* placement);
|
||||
void prefs_save_win_placement(ProfWinPlacement *placement);
|
||||
|
||||
gboolean prefs_get_boolean(preference_t pref);
|
||||
void prefs_set_boolean(preference_t pref, gboolean value);
|
||||
char* prefs_get_string(preference_t pref);
|
||||
char* prefs_get_string_with_option(preference_t pref, gchar* option);
|
||||
gchar** prefs_get_string_list_with_option(preference_t pref, gchar* option);
|
||||
void prefs_set_string(preference_t pref, char* value);
|
||||
void prefs_set_string_with_option(preference_t pref, char* option, char* value);
|
||||
void prefs_set_string_list_with_option(preference_t pref, char* option, const gchar* const* values);
|
||||
char* prefs_get_string_with_option(preference_t pref, gchar *option);
|
||||
gchar **prefs_get_string_list_with_option(preference_t pref, gchar *option);
|
||||
void prefs_set_string(preference_t pref, char *value);
|
||||
void prefs_set_string_with_option(preference_t pref, char *option, char *value);
|
||||
void prefs_set_string_list_with_option(preference_t pref, char *option, const gchar* const *values);
|
||||
|
||||
char* prefs_get_tls_certpath(void);
|
||||
|
||||
gboolean prefs_do_chat_notify(gboolean current_win);
|
||||
gboolean prefs_do_room_notify(gboolean current_win, const char* const roomjid, const char* const mynick,
|
||||
const char* const theirnick, const char* const message, gboolean mention, gboolean trigger_found);
|
||||
gboolean prefs_do_room_notify_mention(const char* const roomjid, int unread, gboolean mention, gboolean trigger);
|
||||
GList* prefs_message_get_triggers(const char* const message);
|
||||
gboolean prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const mynick,
|
||||
const char *const theirnick, const char *const message, gboolean mention, gboolean trigger_found);
|
||||
gboolean prefs_do_room_notify_mention(const char *const roomjid, int unread, gboolean mention, gboolean trigger);
|
||||
GList* prefs_message_get_triggers(const char *const message);
|
||||
|
||||
void prefs_set_room_notify(const char* const roomjid, gboolean value);
|
||||
void prefs_set_room_notify_mention(const char* const roomjid, gboolean value);
|
||||
void prefs_set_room_notify_trigger(const char* const roomjid, gboolean value);
|
||||
gboolean prefs_reset_room_notify(const char* const roomjid);
|
||||
gboolean prefs_has_room_notify(const char* const roomjid);
|
||||
gboolean prefs_has_room_notify_mention(const char* const roomjid);
|
||||
gboolean prefs_has_room_notify_trigger(const char* const roomjid);
|
||||
gboolean prefs_get_room_notify(const char* const roomjid);
|
||||
gboolean prefs_get_room_notify_mention(const char* const roomjid);
|
||||
gboolean prefs_get_room_notify_trigger(const char* const roomjid);
|
||||
void prefs_set_room_notify(const char *const roomjid, gboolean value);
|
||||
void prefs_set_room_notify_mention(const char *const roomjid, gboolean value);
|
||||
void prefs_set_room_notify_trigger(const char *const roomjid, gboolean value);
|
||||
gboolean prefs_reset_room_notify(const char *const roomjid);
|
||||
gboolean prefs_has_room_notify(const char *const roomjid);
|
||||
gboolean prefs_has_room_notify_mention(const char *const roomjid);
|
||||
gboolean prefs_has_room_notify_trigger(const char *const roomjid);
|
||||
gboolean prefs_get_room_notify(const char *const roomjid);
|
||||
gboolean prefs_get_room_notify_mention(const char *const roomjid);
|
||||
gboolean prefs_get_room_notify_trigger(const char *const roomjid);
|
||||
|
||||
gchar* prefs_get_inputrc(void);
|
||||
|
||||
|
@ -33,18 +33,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include "command/cmd_defs.h"
|
||||
#include "common.h"
|
||||
#include "config/files.h"
|
||||
#include "log.h"
|
||||
#include "config/files.h"
|
||||
#include "command/cmd_defs.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
@ -52,13 +52,13 @@
|
||||
void
|
||||
scripts_init(void)
|
||||
{
|
||||
char* scriptsdir = files_get_data_path(DIR_SCRIPTS);
|
||||
char *scriptsdir = files_get_data_path(DIR_SCRIPTS);
|
||||
|
||||
// mkdir if doesn't exist
|
||||
errno = 0;
|
||||
int res = g_mkdir_with_parents(scriptsdir, S_IRWXU);
|
||||
if (res == -1) {
|
||||
char* errmsg = strerror(errno);
|
||||
char *errmsg = strerror(errno);
|
||||
if (errmsg) {
|
||||
log_error("Error creating directory: %s, %s", scriptsdir, errmsg);
|
||||
} else {
|
||||
@ -72,14 +72,14 @@ scripts_init(void)
|
||||
GSList*
|
||||
scripts_list(void)
|
||||
{
|
||||
char* scriptsdir = files_get_data_path(DIR_SCRIPTS);
|
||||
char *scriptsdir = files_get_data_path(DIR_SCRIPTS);
|
||||
|
||||
GSList* result = NULL;
|
||||
GDir* scripts = g_dir_open(scriptsdir, 0, NULL);
|
||||
GSList *result = NULL;
|
||||
GDir *scripts = g_dir_open(scriptsdir, 0, NULL);
|
||||
free(scriptsdir);
|
||||
|
||||
if (scripts) {
|
||||
const gchar* script = g_dir_read_name(scripts);
|
||||
const gchar *script = g_dir_read_name(scripts);
|
||||
while (script) {
|
||||
result = g_slist_append(result, strdup(script));
|
||||
script = g_dir_read_name(scripts);
|
||||
@ -91,15 +91,15 @@ scripts_list(void)
|
||||
}
|
||||
|
||||
GSList*
|
||||
scripts_read(const char* const script)
|
||||
scripts_read(const char *const script)
|
||||
{
|
||||
char* scriptsdir = files_get_data_path(DIR_SCRIPTS);
|
||||
GString* scriptpath = g_string_new(scriptsdir);
|
||||
char *scriptsdir = files_get_data_path(DIR_SCRIPTS);
|
||||
GString *scriptpath = g_string_new(scriptsdir);
|
||||
free(scriptsdir);
|
||||
g_string_append(scriptpath, "/");
|
||||
g_string_append(scriptpath, script);
|
||||
|
||||
FILE* scriptfile = g_fopen(scriptpath->str, "r");
|
||||
FILE *scriptfile = g_fopen(scriptpath->str, "r");
|
||||
if (!scriptfile) {
|
||||
log_info("Script not found: %s", scriptpath->str);
|
||||
g_string_free(scriptpath, TRUE);
|
||||
@ -108,36 +108,35 @@ scripts_read(const char* const script)
|
||||
|
||||
g_string_free(scriptpath, TRUE);
|
||||
|
||||
char* line = NULL;
|
||||
char *line = NULL;
|
||||
size_t len = 0;
|
||||
ssize_t read;
|
||||
GSList* result = NULL;
|
||||
GSList *result = NULL;
|
||||
|
||||
while ((read = getline(&line, &len, scriptfile)) != -1) {
|
||||
if (g_str_has_suffix(line, "\n")) {
|
||||
result = g_slist_append(result, g_strndup(line, strlen(line) - 1));
|
||||
result = g_slist_append(result, g_strndup(line, strlen(line) -1));
|
||||
} else {
|
||||
result = g_slist_append(result, strdup(line));
|
||||
}
|
||||
}
|
||||
|
||||
fclose(scriptfile);
|
||||
if (line)
|
||||
free(line);
|
||||
if (line) free(line);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
scripts_exec(const char* const script)
|
||||
scripts_exec(const char *const script)
|
||||
{
|
||||
char* scriptsdir = files_get_data_path(DIR_SCRIPTS);
|
||||
GString* scriptpath = g_string_new(scriptsdir);
|
||||
char *scriptsdir = files_get_data_path(DIR_SCRIPTS);
|
||||
GString *scriptpath = g_string_new(scriptsdir);
|
||||
free(scriptsdir);
|
||||
g_string_append(scriptpath, "/");
|
||||
g_string_append(scriptpath, script);
|
||||
|
||||
FILE* scriptfile = g_fopen(scriptpath->str, "r");
|
||||
FILE *scriptfile = g_fopen(scriptpath->str, "r");
|
||||
if (!scriptfile) {
|
||||
log_info("Script not found: %s", scriptpath->str);
|
||||
g_string_free(scriptpath, TRUE);
|
||||
@ -146,20 +145,20 @@ scripts_exec(const char* const script)
|
||||
|
||||
g_string_free(scriptpath, TRUE);
|
||||
|
||||
char* line = NULL;
|
||||
char *line = NULL;
|
||||
size_t len = 0;
|
||||
ssize_t read;
|
||||
|
||||
while ((read = getline(&line, &len, scriptfile)) != -1) {
|
||||
ProfWin* win = wins_get_current();
|
||||
ProfWin *win = wins_get_current();
|
||||
cmd_process_input(win, line);
|
||||
session_process_events();
|
||||
ui_update();
|
||||
}
|
||||
|
||||
fclose(scriptfile);
|
||||
if (line)
|
||||
free(line);
|
||||
if (line) free(line);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
void scripts_init(void);
|
||||
GSList* scripts_list(void);
|
||||
GSList* scripts_read(const char* const script);
|
||||
gboolean scripts_exec(const char* const script);
|
||||
GSList* scripts_read(const char *const script);
|
||||
gboolean scripts_exec(const char *const script);
|
||||
|
||||
#endif
|
||||
|
@ -48,24 +48,24 @@
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "config/color.h"
|
||||
#include "config/files.h"
|
||||
#include "config/preferences.h"
|
||||
#include "config/theme.h"
|
||||
#include "log.h"
|
||||
#include "config/files.h"
|
||||
#include "config/theme.h"
|
||||
#include "config/preferences.h"
|
||||
#include "config/color.h"
|
||||
|
||||
static GString* theme_loc;
|
||||
static GKeyFile* theme;
|
||||
static GHashTable* bold_items;
|
||||
static GHashTable* defaults;
|
||||
static GString *theme_loc;
|
||||
static GKeyFile *theme;
|
||||
static GHashTable *bold_items;
|
||||
static GHashTable *defaults;
|
||||
|
||||
static void _load_preferences(void);
|
||||
static void _theme_list_dir(const gchar* const dir, GSList** result);
|
||||
static GString* _theme_find(const char* const theme_name);
|
||||
static gboolean _theme_load_file(const char* const theme_name);
|
||||
static void _theme_list_dir(const gchar *const dir, GSList **result);
|
||||
static GString* _theme_find(const char *const theme_name);
|
||||
static gboolean _theme_load_file(const char *const theme_name);
|
||||
|
||||
void
|
||||
theme_init(const char* const theme_name)
|
||||
theme_init(const char *const theme_name)
|
||||
{
|
||||
if (!_theme_load_file(theme_name)) {
|
||||
log_error("Loading theme %s failed.", theme_name);
|
||||
@ -78,98 +78,98 @@ theme_init(const char* const theme_name)
|
||||
defaults = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
|
||||
|
||||
// Set default colors
|
||||
g_hash_table_insert(defaults, strdup("main.text"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("main.text.history"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("main.text.me"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("main.text.them"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("main.splash"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("main.help.header"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("error"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("incoming"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("mention"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("trigger"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("input.text"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("main.time"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.text"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.brackets"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.unencrypted"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.encrypted"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.untrusted"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.trusted"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.online"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.offline"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.away"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.chat"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.dnd"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.xa"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.scrolled"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("statusbar.text"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("statusbar.brackets"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("statusbar.active"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("statusbar.current"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("statusbar.new"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("statusbar.time"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("me"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("them"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("receipt.sent"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roominfo"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("roommention"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("roommention.term"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("roomtrigger"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("roomtrigger.term"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("online"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("offline"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("away"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("chat"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("dnd"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("xa"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("typing"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("gone"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("subscribed"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("unsubscribed"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("otr.started.trusted"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("otr.started.untrusted"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("otr.ended"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("otr.trusted"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("otr.untrusted"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("roster.header"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("roster.online"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.offline"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roster.chat"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.away"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.dnd"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roster.xa"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.online.active"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.offline.active"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roster.chat.active"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.away.active"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.dnd.active"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roster.xa.active"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.online.unread"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.offline.unread"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roster.chat.unread"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.away.unread"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.dnd.unread"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roster.xa.unread"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.room"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.room.unread"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.room.trigger"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.room.mention"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("occupants.header"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("untrusted"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("cmd.wins.unread"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("main.text"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("main.text.history"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("main.text.me"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("main.text.them"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("main.splash"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("main.help.header"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("error"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("incoming"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("mention"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("trigger"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("input.text"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("main.time"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.text"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.brackets"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.unencrypted"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.encrypted"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.untrusted"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.trusted"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.online"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.offline"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.away"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.chat"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.dnd"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.xa"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("titlebar.scrolled"), strdup("default"));
|
||||
g_hash_table_insert(defaults, strdup("statusbar.text"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("statusbar.brackets"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("statusbar.active"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("statusbar.current"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("statusbar.new"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("statusbar.time"), strdup("white"));
|
||||
g_hash_table_insert(defaults, strdup("me"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("them"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("receipt.sent"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roominfo"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("roommention"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("roommention.term"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("roomtrigger"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("roomtrigger.term"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("online"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("offline"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("away"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("chat"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("dnd"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("xa"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("typing"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("gone"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("subscribed"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("unsubscribed"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("otr.started.trusted"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("otr.started.untrusted"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("otr.ended"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("otr.trusted"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("otr.untrusted"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("roster.header"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("roster.online"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.offline"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roster.chat"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.away"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.dnd"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roster.xa"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.online.active"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.offline.active"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roster.chat.active"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.away.active"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.dnd.active"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roster.xa.active"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.online.unread"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.offline.unread"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roster.chat.unread"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.away.unread"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.dnd.unread"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("roster.xa.unread"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.room"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.room.unread"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.room.trigger"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.room.mention"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("occupants.header"), strdup("yellow"));
|
||||
g_hash_table_insert(defaults, strdup("untrusted"), strdup("red"));
|
||||
g_hash_table_insert(defaults, strdup("cmd.wins.unread"), strdup("default"));
|
||||
|
||||
//_load_preferences();
|
||||
}
|
||||
|
||||
gboolean
|
||||
theme_exists(const char* const theme_name)
|
||||
theme_exists(const char *const theme_name)
|
||||
{
|
||||
if (g_strcmp0(theme_name, "default") == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GString* new_theme_file = _theme_find(theme_name);
|
||||
GString *new_theme_file = _theme_find(theme_name);
|
||||
if (new_theme_file == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -179,7 +179,7 @@ theme_exists(const char* const theme_name)
|
||||
}
|
||||
|
||||
gboolean
|
||||
theme_load(const char* const theme_name, gboolean load_theme_prefs)
|
||||
theme_load(const char *const theme_name, gboolean load_theme_prefs)
|
||||
{
|
||||
color_pair_cache_reset();
|
||||
|
||||
@ -194,7 +194,7 @@ theme_load(const char* const theme_name, gboolean load_theme_prefs)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_theme_load_file(const char* const theme_name)
|
||||
_theme_load_file(const char *const theme_name)
|
||||
{
|
||||
// use default theme
|
||||
if (theme_name == NULL || strcmp(theme_name, "default") == 0) {
|
||||
@ -203,9 +203,9 @@ _theme_load_file(const char* const theme_name)
|
||||
}
|
||||
theme = g_key_file_new();
|
||||
|
||||
// load theme from file
|
||||
// load theme from file
|
||||
} else {
|
||||
GString* new_theme_file = _theme_find(theme_name);
|
||||
GString *new_theme_file = _theme_find(theme_name);
|
||||
if (new_theme_file == NULL) {
|
||||
log_info("Theme does not exist \"%s\"", theme_name);
|
||||
return FALSE;
|
||||
@ -221,7 +221,7 @@ _theme_load_file(const char* const theme_name)
|
||||
}
|
||||
theme = g_key_file_new();
|
||||
g_key_file_load_from_file(theme, theme_loc->str, G_KEY_FILE_KEEP_COMMENTS,
|
||||
NULL);
|
||||
NULL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -230,8 +230,8 @@ _theme_load_file(const char* const theme_name)
|
||||
GSList*
|
||||
theme_list(void)
|
||||
{
|
||||
GSList* result = NULL;
|
||||
gchar* themes_dir = files_get_config_path(DIR_THEMES);
|
||||
GSList *result = NULL;
|
||||
gchar *themes_dir = files_get_config_path(DIR_THEMES);
|
||||
|
||||
_theme_list_dir(themes_dir, &result);
|
||||
g_free(themes_dir);
|
||||
@ -272,17 +272,17 @@ theme_init_colours(void)
|
||||
}
|
||||
|
||||
static void
|
||||
_set_string_preference(char* prefstr, preference_t pref)
|
||||
_set_string_preference(char *prefstr, preference_t pref)
|
||||
{
|
||||
if (g_key_file_has_key(theme, "ui", prefstr, NULL)) {
|
||||
gchar* val = g_key_file_get_string(theme, "ui", prefstr, NULL);
|
||||
gchar *val = g_key_file_get_string(theme, "ui", prefstr, NULL);
|
||||
prefs_set_string(pref, val);
|
||||
g_free(val);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_set_boolean_preference(char* prefstr, preference_t pref)
|
||||
_set_boolean_preference(char *prefstr, preference_t pref)
|
||||
{
|
||||
if (g_key_file_has_key(theme, "ui", prefstr, NULL)) {
|
||||
gboolean val = g_key_file_get_boolean(theme, "ui", prefstr, NULL);
|
||||
@ -401,7 +401,7 @@ _load_preferences(void)
|
||||
// load chars from theme and set them to prefs
|
||||
// with custom set functions
|
||||
if (g_key_file_has_key(theme, "ui", "occupants.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "occupants.char", NULL);
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "occupants.char", NULL);
|
||||
if (ch && strlen(ch) > 0) {
|
||||
prefs_set_occupants_char(ch[0]);
|
||||
g_free(ch);
|
||||
@ -409,7 +409,7 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "occupants.header.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "occupants.header.char", NULL);
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "occupants.header.char", NULL);
|
||||
if (ch && strlen(ch) > 0) {
|
||||
prefs_set_occupants_header_char(ch[0]);
|
||||
g_free(ch);
|
||||
@ -417,7 +417,7 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "roster.header.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "roster.header.char", NULL);
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "roster.header.char", NULL);
|
||||
if (ch && strlen(ch) > 0) {
|
||||
prefs_set_roster_header_char(ch[0]);
|
||||
g_free(ch);
|
||||
@ -425,7 +425,7 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "roster.contact.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "roster.contact.char", NULL);
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "roster.contact.char", NULL);
|
||||
if (ch && strlen(ch) > 0) {
|
||||
prefs_set_roster_contact_char(ch[0]);
|
||||
g_free(ch);
|
||||
@ -433,7 +433,7 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "roster.resource.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "roster.resource.char", NULL);
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "roster.resource.char", NULL);
|
||||
if (ch && strlen(ch) > 0) {
|
||||
prefs_set_roster_resource_char(ch[0]);
|
||||
g_free(ch);
|
||||
@ -443,7 +443,7 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "roster.rooms.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "roster.rooms.char", NULL);
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "roster.rooms.char", NULL);
|
||||
if (ch && strlen(ch) > 0) {
|
||||
prefs_set_roster_room_char(ch[0]);
|
||||
g_free(ch);
|
||||
@ -451,7 +451,7 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "roster.rooms.private.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "roster.rooms.private.char", NULL);
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "roster.rooms.private.char", NULL);
|
||||
if (ch && strlen(ch) > 0) {
|
||||
prefs_set_roster_room_private_char(ch[0]);
|
||||
g_free(ch);
|
||||
@ -459,7 +459,7 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "roster.private.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "roster.private.char", NULL);
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "roster.private.char", NULL);
|
||||
if (ch && strlen(ch) > 0) {
|
||||
prefs_set_roster_private_char(ch[0]);
|
||||
g_free(ch);
|
||||
@ -467,7 +467,7 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "otr.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "otr.char", NULL);
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "otr.char", NULL);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_otr_char(ch);
|
||||
g_free(ch);
|
||||
@ -475,7 +475,7 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "pgp.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "pgp.char", NULL);
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "pgp.char", NULL);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_pgp_char(ch);
|
||||
g_free(ch);
|
||||
@ -483,7 +483,7 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "omemo.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "omemo.char", NULL);
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "omemo.char", NULL);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_omemo_char(ch);
|
||||
g_free(ch);
|
||||
@ -491,7 +491,7 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "correction.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "correction.char", NULL);
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "correction.char", NULL);
|
||||
if (ch && strlen(ch) > 0) {
|
||||
prefs_set_correction_char(ch[0]);
|
||||
g_free(ch);
|
||||
@ -499,14 +499,17 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
// load window positions
|
||||
if (g_key_file_has_key(theme, "ui", "titlebar.position", NULL) && g_key_file_has_key(theme, "ui", "mainwin.position", NULL) && g_key_file_has_key(theme, "ui", "statusbar.position", NULL) && g_key_file_has_key(theme, "ui", "inputwin.position", NULL)) {
|
||||
if (g_key_file_has_key(theme, "ui", "titlebar.position", NULL) &&
|
||||
g_key_file_has_key(theme, "ui", "mainwin.position", NULL) &&
|
||||
g_key_file_has_key(theme, "ui", "statusbar.position", NULL) &&
|
||||
g_key_file_has_key(theme, "ui", "inputwin.position", NULL)) {
|
||||
|
||||
int titlebar_pos = g_key_file_get_integer(theme, "ui", "titlebar.position", NULL);
|
||||
int mainwin_pos = g_key_file_get_integer(theme, "ui", "mainwin.position", NULL);
|
||||
int statusbar_pos = g_key_file_get_integer(theme, "ui", "statusbar.position", NULL);
|
||||
int inputwin_pos = g_key_file_get_integer(theme, "ui", "inputwin.position", NULL);
|
||||
|
||||
ProfWinPlacement* placement = prefs_create_profwin_placement(titlebar_pos, mainwin_pos, statusbar_pos, inputwin_pos);
|
||||
ProfWinPlacement *placement = prefs_create_profwin_placement(titlebar_pos, mainwin_pos, statusbar_pos, inputwin_pos);
|
||||
|
||||
prefs_save_win_placement(placement);
|
||||
prefs_free_win_placement(placement);
|
||||
@ -514,11 +517,11 @@ _load_preferences(void)
|
||||
}
|
||||
|
||||
static void
|
||||
_theme_list_dir(const gchar* const dir, GSList** result)
|
||||
_theme_list_dir(const gchar *const dir, GSList **result)
|
||||
{
|
||||
GDir* themes = g_dir_open(dir, 0, NULL);
|
||||
GDir *themes = g_dir_open(dir, 0, NULL);
|
||||
if (themes) {
|
||||
const gchar* theme = g_dir_read_name(themes);
|
||||
const gchar *theme = g_dir_read_name(themes);
|
||||
while (theme) {
|
||||
*result = g_slist_append(*result, strdup(theme));
|
||||
theme = g_dir_read_name(themes);
|
||||
@ -528,10 +531,10 @@ _theme_list_dir(const gchar* const dir, GSList** result)
|
||||
}
|
||||
|
||||
static GString*
|
||||
_theme_find(const char* const theme_name)
|
||||
_theme_find(const char *const theme_name)
|
||||
{
|
||||
GString* path = NULL;
|
||||
gchar* themes_dir = files_get_config_path(DIR_THEMES);
|
||||
GString *path = NULL;
|
||||
gchar *themes_dir = files_get_config_path(DIR_THEMES);
|
||||
|
||||
if (themes_dir) {
|
||||
path = g_string_new(themes_dir);
|
||||
@ -560,7 +563,7 @@ _theme_find(const char* const theme_name)
|
||||
}
|
||||
|
||||
theme_item_t
|
||||
theme_roster_unread_presence_attrs(const char* const presence)
|
||||
theme_roster_unread_presence_attrs(const char *const presence)
|
||||
{
|
||||
if (g_strcmp0(presence, "online") == 0) {
|
||||
return THEME_ROSTER_ONLINE_UNREAD;
|
||||
@ -578,7 +581,7 @@ theme_roster_unread_presence_attrs(const char* const presence)
|
||||
}
|
||||
|
||||
theme_item_t
|
||||
theme_roster_active_presence_attrs(const char* const presence)
|
||||
theme_roster_active_presence_attrs(const char *const presence)
|
||||
{
|
||||
if (g_strcmp0(presence, "online") == 0) {
|
||||
return THEME_ROSTER_ONLINE_ACTIVE;
|
||||
@ -596,7 +599,7 @@ theme_roster_active_presence_attrs(const char* const presence)
|
||||
}
|
||||
|
||||
theme_item_t
|
||||
theme_roster_presence_attrs(const char* const presence)
|
||||
theme_roster_presence_attrs(const char *const presence)
|
||||
{
|
||||
if (g_strcmp0(presence, "online") == 0) {
|
||||
return THEME_ROSTER_ONLINE;
|
||||
@ -614,7 +617,7 @@ theme_roster_presence_attrs(const char* const presence)
|
||||
}
|
||||
|
||||
theme_item_t
|
||||
theme_main_presence_attrs(const char* const presence)
|
||||
theme_main_presence_attrs(const char *const presence)
|
||||
{
|
||||
if (g_strcmp0(presence, "online") == 0) {
|
||||
return THEME_ONLINE;
|
||||
@ -632,9 +635,9 @@ theme_main_presence_attrs(const char* const presence)
|
||||
}
|
||||
|
||||
static void
|
||||
_theme_prep_bgnd(char* setting, char* def, GString* lookup_str)
|
||||
_theme_prep_bgnd(char *setting, char *def, GString *lookup_str)
|
||||
{
|
||||
gchar* val = g_key_file_get_string(theme, "colours", setting, NULL);
|
||||
gchar *val = g_key_file_get_string(theme, "colours", setting, NULL);
|
||||
if (!val) {
|
||||
g_string_append(lookup_str, def);
|
||||
} else {
|
||||
@ -651,17 +654,17 @@ _theme_prep_bgnd(char* setting, char* def, GString* lookup_str)
|
||||
char*
|
||||
theme_get_bkgnd(void)
|
||||
{
|
||||
char* val = g_key_file_get_string(theme, "colours", "bkgnd", NULL);
|
||||
char *val = g_key_file_get_string(theme, "colours", "bkgnd", NULL);
|
||||
return val;
|
||||
}
|
||||
|
||||
/* gets the foreground color from the theme. or uses the one defined in 'defaults' */
|
||||
static void
|
||||
_theme_prep_fgnd(char* setting, GString* lookup_str, gboolean* bold)
|
||||
_theme_prep_fgnd(char *setting, GString *lookup_str, gboolean *bold)
|
||||
{
|
||||
gchar* val = g_key_file_get_string(theme, "colours", setting, NULL);
|
||||
gchar *val = g_key_file_get_string(theme, "colours", setting, NULL);
|
||||
if (!val) {
|
||||
char* def = g_hash_table_lookup(defaults, setting);
|
||||
char *def = g_hash_table_lookup(defaults, setting);
|
||||
g_string_append(lookup_str, def);
|
||||
} else {
|
||||
if (g_str_has_prefix(val, "bold_")) {
|
||||
@ -676,9 +679,9 @@ _theme_prep_fgnd(char* setting, GString* lookup_str, gboolean* bold)
|
||||
}
|
||||
|
||||
char*
|
||||
theme_get_string(char* str)
|
||||
theme_get_string(char *str)
|
||||
{
|
||||
char* res = g_key_file_get_string(theme, "colours", str, NULL);
|
||||
char *res = g_key_file_get_string(theme, "colours", str, NULL);
|
||||
if (!res) {
|
||||
return strdup(g_hash_table_lookup(defaults, str));
|
||||
} else {
|
||||
@ -687,7 +690,7 @@ theme_get_string(char* str)
|
||||
}
|
||||
|
||||
void
|
||||
theme_free_string(char* str)
|
||||
theme_free_string(char *str)
|
||||
{
|
||||
if (str) {
|
||||
g_free(str);
|
||||
@ -695,11 +698,11 @@ theme_free_string(char* str)
|
||||
}
|
||||
|
||||
int
|
||||
theme_hash_attrs(const char* str)
|
||||
theme_hash_attrs(const char *str)
|
||||
{
|
||||
color_profile profile = COLOR_PROFILE_DEFAULT;
|
||||
|
||||
char* color_pref = prefs_get_string(PREF_COLOR_NICK);
|
||||
char *color_pref = prefs_get_string(PREF_COLOR_NICK);
|
||||
if (strcmp(color_pref, "redgreen") == 0) {
|
||||
profile = COLOR_PROFILE_REDGREEN_BLINDNESS;
|
||||
} else if (strcmp(color_pref, "blue") == 0) {
|
||||
@ -716,322 +719,109 @@ theme_attrs(theme_item_t attrs)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
GString* lookup_str = g_string_new("");
|
||||
GString *lookup_str = g_string_new("");
|
||||
gboolean bold = FALSE;
|
||||
|
||||
// get forground colour
|
||||
switch (attrs) {
|
||||
case THEME_TEXT:
|
||||
_theme_prep_fgnd("main.text", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TEXT_HISTORY:
|
||||
_theme_prep_fgnd("main.text.history", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TEXT_ME:
|
||||
_theme_prep_fgnd("main.text.me", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TEXT_THEM:
|
||||
_theme_prep_fgnd("main.text.them", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_SPLASH:
|
||||
_theme_prep_fgnd("main.splash", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TRACKBAR:
|
||||
_theme_prep_fgnd("main.trackbar", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_HELP_HEADER:
|
||||
_theme_prep_fgnd("main.help.header", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ERROR:
|
||||
_theme_prep_fgnd("error", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_INCOMING:
|
||||
_theme_prep_fgnd("incoming", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_MENTION:
|
||||
_theme_prep_fgnd("mention", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TRIGGER:
|
||||
_theme_prep_fgnd("trigger", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_INPUT_TEXT:
|
||||
_theme_prep_fgnd("input.text", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TIME:
|
||||
_theme_prep_fgnd("main.time", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_TEXT:
|
||||
_theme_prep_fgnd("titlebar.text", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_BRACKET:
|
||||
_theme_prep_fgnd("titlebar.brackets", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_SCROLLED:
|
||||
_theme_prep_fgnd("titlebar.scrolled", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_UNENCRYPTED:
|
||||
_theme_prep_fgnd("titlebar.unencrypted", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_ENCRYPTED:
|
||||
_theme_prep_fgnd("titlebar.encrypted", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_UNTRUSTED:
|
||||
_theme_prep_fgnd("titlebar.untrusted", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_TRUSTED:
|
||||
_theme_prep_fgnd("titlebar.trusted", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_ONLINE:
|
||||
_theme_prep_fgnd("titlebar.online", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_OFFLINE:
|
||||
_theme_prep_fgnd("titlebar.offline", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_AWAY:
|
||||
_theme_prep_fgnd("titlebar.away", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_CHAT:
|
||||
_theme_prep_fgnd("titlebar.chat", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_DND:
|
||||
_theme_prep_fgnd("titlebar.dnd", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TITLE_XA:
|
||||
_theme_prep_fgnd("titlebar.xa", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_STATUS_TEXT:
|
||||
_theme_prep_fgnd("statusbar.text", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_STATUS_BRACKET:
|
||||
_theme_prep_fgnd("statusbar.brackets", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_STATUS_ACTIVE:
|
||||
_theme_prep_fgnd("statusbar.active", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_STATUS_CURRENT:
|
||||
_theme_prep_fgnd("statusbar.current", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_STATUS_NEW:
|
||||
_theme_prep_fgnd("statusbar.new", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_STATUS_TIME:
|
||||
_theme_prep_fgnd("statusbar.time", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ME:
|
||||
_theme_prep_fgnd("me", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_THEM:
|
||||
_theme_prep_fgnd("them", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_RECEIPT_SENT:
|
||||
_theme_prep_fgnd("receipt.sent", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROOMINFO:
|
||||
_theme_prep_fgnd("roominfo", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROOMMENTION:
|
||||
_theme_prep_fgnd("roommention", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROOMMENTION_TERM:
|
||||
_theme_prep_fgnd("roommention.term", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROOMTRIGGER:
|
||||
_theme_prep_fgnd("roomtrigger", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROOMTRIGGER_TERM:
|
||||
_theme_prep_fgnd("roomtrigger.term", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ONLINE:
|
||||
_theme_prep_fgnd("online", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_OFFLINE:
|
||||
_theme_prep_fgnd("offline", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_AWAY:
|
||||
_theme_prep_fgnd("away", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_CHAT:
|
||||
_theme_prep_fgnd("chat", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_DND:
|
||||
_theme_prep_fgnd("dnd", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_XA:
|
||||
_theme_prep_fgnd("xa", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_TYPING:
|
||||
_theme_prep_fgnd("typing", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_GONE:
|
||||
_theme_prep_fgnd("gone", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_SUBSCRIBED:
|
||||
_theme_prep_fgnd("subscribed", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_UNSUBSCRIBED:
|
||||
_theme_prep_fgnd("unsubscribed", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_OTR_STARTED_TRUSTED:
|
||||
_theme_prep_fgnd("otr.started.trusted", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_OTR_STARTED_UNTRUSTED:
|
||||
_theme_prep_fgnd("otr.started.untrusted", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_OTR_ENDED:
|
||||
_theme_prep_fgnd("otr.ended", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_OTR_TRUSTED:
|
||||
_theme_prep_fgnd("otr.trusted", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_OTR_UNTRUSTED:
|
||||
_theme_prep_fgnd("otr.untrusted", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_HEADER:
|
||||
_theme_prep_fgnd("roster.header", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_ONLINE:
|
||||
_theme_prep_fgnd("roster.online", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_OFFLINE:
|
||||
_theme_prep_fgnd("roster.offline", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_CHAT:
|
||||
_theme_prep_fgnd("roster.chat", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_AWAY:
|
||||
_theme_prep_fgnd("roster.away", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_DND:
|
||||
_theme_prep_fgnd("roster.dnd", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_XA:
|
||||
_theme_prep_fgnd("roster.xa", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_ONLINE_ACTIVE:
|
||||
_theme_prep_fgnd("roster.online.active", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_OFFLINE_ACTIVE:
|
||||
_theme_prep_fgnd("roster.offline.active", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_CHAT_ACTIVE:
|
||||
_theme_prep_fgnd("roster.chat.active", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_AWAY_ACTIVE:
|
||||
_theme_prep_fgnd("roster.away.active", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_DND_ACTIVE:
|
||||
_theme_prep_fgnd("roster.dnd.active", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_XA_ACTIVE:
|
||||
_theme_prep_fgnd("roster.xa.active", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_ONLINE_UNREAD:
|
||||
_theme_prep_fgnd("roster.online.unread", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_OFFLINE_UNREAD:
|
||||
_theme_prep_fgnd("roster.offline.unread", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_CHAT_UNREAD:
|
||||
_theme_prep_fgnd("roster.chat.unread", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_AWAY_UNREAD:
|
||||
_theme_prep_fgnd("roster.away.unread", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_DND_UNREAD:
|
||||
_theme_prep_fgnd("roster.dnd.unread", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_XA_UNREAD:
|
||||
_theme_prep_fgnd("roster.xa.unread", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_ROOM:
|
||||
_theme_prep_fgnd("roster.room", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_ROOM_UNREAD:
|
||||
_theme_prep_fgnd("roster.room.unread", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_ROOM_TRIGGER:
|
||||
_theme_prep_fgnd("roster.room.trigger", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_ROSTER_ROOM_MENTION:
|
||||
_theme_prep_fgnd("roster.room.mention", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_OCCUPANTS_HEADER:
|
||||
_theme_prep_fgnd("occupants.header", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_UNTRUSTED:
|
||||
_theme_prep_fgnd("untrusted", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_CMD_WINS_UNREAD:
|
||||
_theme_prep_fgnd("cmd.wins.unread", lookup_str, &bold);
|
||||
break;
|
||||
case THEME_WHITE:
|
||||
g_string_append(lookup_str, "white");
|
||||
bold = FALSE;
|
||||
break;
|
||||
case THEME_WHITE_BOLD:
|
||||
g_string_append(lookup_str, "white");
|
||||
bold = TRUE;
|
||||
break;
|
||||
case THEME_GREEN:
|
||||
g_string_append(lookup_str, "green");
|
||||
bold = FALSE;
|
||||
break;
|
||||
case THEME_GREEN_BOLD:
|
||||
g_string_append(lookup_str, "green");
|
||||
bold = TRUE;
|
||||
break;
|
||||
case THEME_RED:
|
||||
g_string_append(lookup_str, "red");
|
||||
bold = FALSE;
|
||||
break;
|
||||
case THEME_RED_BOLD:
|
||||
g_string_append(lookup_str, "red");
|
||||
bold = TRUE;
|
||||
break;
|
||||
case THEME_YELLOW:
|
||||
g_string_append(lookup_str, "yellow");
|
||||
bold = FALSE;
|
||||
break;
|
||||
case THEME_YELLOW_BOLD:
|
||||
g_string_append(lookup_str, "yellow");
|
||||
bold = TRUE;
|
||||
break;
|
||||
case THEME_BLUE:
|
||||
g_string_append(lookup_str, "blue");
|
||||
bold = FALSE;
|
||||
break;
|
||||
case THEME_BLUE_BOLD:
|
||||
g_string_append(lookup_str, "blue");
|
||||
bold = TRUE;
|
||||
break;
|
||||
case THEME_CYAN:
|
||||
g_string_append(lookup_str, "cyan");
|
||||
bold = FALSE;
|
||||
break;
|
||||
case THEME_CYAN_BOLD:
|
||||
g_string_append(lookup_str, "cyan");
|
||||
bold = TRUE;
|
||||
break;
|
||||
case THEME_BLACK:
|
||||
g_string_append(lookup_str, "black");
|
||||
bold = FALSE;
|
||||
break;
|
||||
case THEME_BLACK_BOLD:
|
||||
g_string_append(lookup_str, "black");
|
||||
bold = TRUE;
|
||||
break;
|
||||
case THEME_MAGENTA:
|
||||
g_string_append(lookup_str, "magenta");
|
||||
bold = FALSE;
|
||||
break;
|
||||
case THEME_MAGENTA_BOLD:
|
||||
g_string_append(lookup_str, "magenta");
|
||||
bold = TRUE;
|
||||
break;
|
||||
default:
|
||||
g_string_append(lookup_str, "default");
|
||||
bold = FALSE;
|
||||
break;
|
||||
case THEME_TEXT: _theme_prep_fgnd("main.text", lookup_str, &bold); break;
|
||||
case THEME_TEXT_HISTORY: _theme_prep_fgnd("main.text.history", lookup_str, &bold); break;
|
||||
case THEME_TEXT_ME: _theme_prep_fgnd("main.text.me", lookup_str, &bold); break;
|
||||
case THEME_TEXT_THEM: _theme_prep_fgnd("main.text.them", lookup_str, &bold); break;
|
||||
case THEME_SPLASH: _theme_prep_fgnd("main.splash", lookup_str, &bold); break;
|
||||
case THEME_TRACKBAR: _theme_prep_fgnd("main.trackbar", lookup_str, &bold); break;
|
||||
case THEME_HELP_HEADER: _theme_prep_fgnd("main.help.header", lookup_str, &bold); break;
|
||||
case THEME_ERROR: _theme_prep_fgnd("error", lookup_str, &bold); break;
|
||||
case THEME_INCOMING: _theme_prep_fgnd("incoming", lookup_str, &bold); break;
|
||||
case THEME_MENTION: _theme_prep_fgnd("mention", lookup_str, &bold); break;
|
||||
case THEME_TRIGGER: _theme_prep_fgnd("trigger", lookup_str, &bold); break;
|
||||
case THEME_INPUT_TEXT: _theme_prep_fgnd("input.text", lookup_str, &bold); break;
|
||||
case THEME_TIME: _theme_prep_fgnd("main.time", lookup_str, &bold); break;
|
||||
case THEME_TITLE_TEXT: _theme_prep_fgnd("titlebar.text", lookup_str, &bold); break;
|
||||
case THEME_TITLE_BRACKET: _theme_prep_fgnd("titlebar.brackets", lookup_str, &bold); break;
|
||||
case THEME_TITLE_SCROLLED: _theme_prep_fgnd("titlebar.scrolled", lookup_str, &bold); break;
|
||||
case THEME_TITLE_UNENCRYPTED: _theme_prep_fgnd("titlebar.unencrypted", lookup_str, &bold); break;
|
||||
case THEME_TITLE_ENCRYPTED: _theme_prep_fgnd("titlebar.encrypted", lookup_str, &bold); break;
|
||||
case THEME_TITLE_UNTRUSTED: _theme_prep_fgnd("titlebar.untrusted", lookup_str, &bold); break;
|
||||
case THEME_TITLE_TRUSTED: _theme_prep_fgnd("titlebar.trusted", lookup_str, &bold); break;
|
||||
case THEME_TITLE_ONLINE: _theme_prep_fgnd("titlebar.online", lookup_str, &bold); break;
|
||||
case THEME_TITLE_OFFLINE: _theme_prep_fgnd("titlebar.offline", lookup_str, &bold); break;
|
||||
case THEME_TITLE_AWAY: _theme_prep_fgnd("titlebar.away", lookup_str, &bold); break;
|
||||
case THEME_TITLE_CHAT: _theme_prep_fgnd("titlebar.chat", lookup_str, &bold); break;
|
||||
case THEME_TITLE_DND: _theme_prep_fgnd("titlebar.dnd", lookup_str, &bold); break;
|
||||
case THEME_TITLE_XA: _theme_prep_fgnd("titlebar.xa", lookup_str, &bold); break;
|
||||
case THEME_STATUS_TEXT: _theme_prep_fgnd("statusbar.text", lookup_str, &bold); break;
|
||||
case THEME_STATUS_BRACKET: _theme_prep_fgnd("statusbar.brackets", lookup_str, &bold); break;
|
||||
case THEME_STATUS_ACTIVE: _theme_prep_fgnd("statusbar.active", lookup_str, &bold); break;
|
||||
case THEME_STATUS_CURRENT: _theme_prep_fgnd("statusbar.current", lookup_str, &bold); break;
|
||||
case THEME_STATUS_NEW: _theme_prep_fgnd("statusbar.new", lookup_str, &bold); break;
|
||||
case THEME_STATUS_TIME: _theme_prep_fgnd("statusbar.time", lookup_str, &bold); break;
|
||||
case THEME_ME: _theme_prep_fgnd("me", lookup_str, &bold); break;
|
||||
case THEME_THEM: _theme_prep_fgnd("them", lookup_str, &bold); break;
|
||||
case THEME_RECEIPT_SENT: _theme_prep_fgnd("receipt.sent", lookup_str, &bold); break;
|
||||
case THEME_ROOMINFO: _theme_prep_fgnd("roominfo", lookup_str, &bold); break;
|
||||
case THEME_ROOMMENTION: _theme_prep_fgnd("roommention", lookup_str, &bold); break;
|
||||
case THEME_ROOMMENTION_TERM: _theme_prep_fgnd("roommention.term", lookup_str, &bold); break;
|
||||
case THEME_ROOMTRIGGER: _theme_prep_fgnd("roomtrigger", lookup_str, &bold); break;
|
||||
case THEME_ROOMTRIGGER_TERM: _theme_prep_fgnd("roomtrigger.term", lookup_str, &bold); break;
|
||||
case THEME_ONLINE: _theme_prep_fgnd("online", lookup_str, &bold); break;
|
||||
case THEME_OFFLINE: _theme_prep_fgnd("offline", lookup_str, &bold); break;
|
||||
case THEME_AWAY: _theme_prep_fgnd("away", lookup_str, &bold); break;
|
||||
case THEME_CHAT: _theme_prep_fgnd("chat", lookup_str, &bold); break;
|
||||
case THEME_DND: _theme_prep_fgnd("dnd", lookup_str, &bold); break;
|
||||
case THEME_XA: _theme_prep_fgnd("xa", lookup_str, &bold); break;
|
||||
case THEME_TYPING: _theme_prep_fgnd("typing", lookup_str, &bold); break;
|
||||
case THEME_GONE: _theme_prep_fgnd("gone", lookup_str, &bold); break;
|
||||
case THEME_SUBSCRIBED: _theme_prep_fgnd("subscribed", lookup_str, &bold); break;
|
||||
case THEME_UNSUBSCRIBED: _theme_prep_fgnd("unsubscribed", lookup_str, &bold); break;
|
||||
case THEME_OTR_STARTED_TRUSTED: _theme_prep_fgnd("otr.started.trusted", lookup_str, &bold); break;
|
||||
case THEME_OTR_STARTED_UNTRUSTED: _theme_prep_fgnd("otr.started.untrusted", lookup_str, &bold); break;
|
||||
case THEME_OTR_ENDED: _theme_prep_fgnd("otr.ended", lookup_str, &bold); break;
|
||||
case THEME_OTR_TRUSTED: _theme_prep_fgnd("otr.trusted", lookup_str, &bold); break;
|
||||
case THEME_OTR_UNTRUSTED: _theme_prep_fgnd("otr.untrusted", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_HEADER: _theme_prep_fgnd("roster.header", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ONLINE: _theme_prep_fgnd("roster.online", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_OFFLINE: _theme_prep_fgnd("roster.offline", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_CHAT: _theme_prep_fgnd("roster.chat", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_AWAY: _theme_prep_fgnd("roster.away", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_DND: _theme_prep_fgnd("roster.dnd", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_XA: _theme_prep_fgnd("roster.xa", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ONLINE_ACTIVE: _theme_prep_fgnd("roster.online.active", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_OFFLINE_ACTIVE: _theme_prep_fgnd("roster.offline.active", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_CHAT_ACTIVE: _theme_prep_fgnd("roster.chat.active", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_AWAY_ACTIVE: _theme_prep_fgnd("roster.away.active", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_DND_ACTIVE: _theme_prep_fgnd("roster.dnd.active", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_XA_ACTIVE: _theme_prep_fgnd("roster.xa.active", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ONLINE_UNREAD: _theme_prep_fgnd("roster.online.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_OFFLINE_UNREAD: _theme_prep_fgnd("roster.offline.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_CHAT_UNREAD: _theme_prep_fgnd("roster.chat.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_AWAY_UNREAD: _theme_prep_fgnd("roster.away.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_DND_UNREAD: _theme_prep_fgnd("roster.dnd.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_XA_UNREAD: _theme_prep_fgnd("roster.xa.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ROOM: _theme_prep_fgnd("roster.room", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ROOM_UNREAD: _theme_prep_fgnd("roster.room.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ROOM_TRIGGER: _theme_prep_fgnd("roster.room.trigger", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ROOM_MENTION: _theme_prep_fgnd("roster.room.mention", lookup_str, &bold); break;
|
||||
case THEME_OCCUPANTS_HEADER: _theme_prep_fgnd("occupants.header", lookup_str, &bold); break;
|
||||
case THEME_UNTRUSTED: _theme_prep_fgnd("untrusted", lookup_str, &bold); break;
|
||||
case THEME_CMD_WINS_UNREAD: _theme_prep_fgnd("cmd.wins.unread", lookup_str, &bold); break;
|
||||
case THEME_WHITE: g_string_append(lookup_str, "white"); bold = FALSE; break;
|
||||
case THEME_WHITE_BOLD: g_string_append(lookup_str, "white"); bold = TRUE; break;
|
||||
case THEME_GREEN: g_string_append(lookup_str, "green"); bold = FALSE; break;
|
||||
case THEME_GREEN_BOLD: g_string_append(lookup_str, "green"); bold = TRUE; break;
|
||||
case THEME_RED: g_string_append(lookup_str, "red"); bold = FALSE; break;
|
||||
case THEME_RED_BOLD: g_string_append(lookup_str, "red"); bold = TRUE; break;
|
||||
case THEME_YELLOW: g_string_append(lookup_str, "yellow"); bold = FALSE; break;
|
||||
case THEME_YELLOW_BOLD: g_string_append(lookup_str, "yellow"); bold = TRUE; break;
|
||||
case THEME_BLUE: g_string_append(lookup_str, "blue"); bold = FALSE; break;
|
||||
case THEME_BLUE_BOLD: g_string_append(lookup_str, "blue"); bold = TRUE; break;
|
||||
case THEME_CYAN: g_string_append(lookup_str, "cyan"); bold = FALSE; break;
|
||||
case THEME_CYAN_BOLD: g_string_append(lookup_str, "cyan"); bold = TRUE; break;
|
||||
case THEME_BLACK: g_string_append(lookup_str, "black"); bold = FALSE; break;
|
||||
case THEME_BLACK_BOLD: g_string_append(lookup_str, "black"); bold = TRUE; break;
|
||||
case THEME_MAGENTA: g_string_append(lookup_str, "magenta"); bold = FALSE; break;
|
||||
case THEME_MAGENTA_BOLD: g_string_append(lookup_str, "magenta"); bold = TRUE; break;
|
||||
default: g_string_append(lookup_str, "default"); bold = FALSE; break;
|
||||
}
|
||||
|
||||
g_string_append(lookup_str, "_");
|
||||
|
@ -143,20 +143,20 @@ typedef enum {
|
||||
THEME_TRACKBAR,
|
||||
} theme_item_t;
|
||||
|
||||
void theme_init(const char* const theme_name);
|
||||
void theme_init(const char *const theme_name);
|
||||
void theme_init_colours(void);
|
||||
gboolean theme_load(const char* const theme_name, gboolean load_theme_prefs);
|
||||
gboolean theme_exists(const char* const theme_name);
|
||||
gboolean theme_load(const char *const theme_name, gboolean load_theme_prefs);
|
||||
gboolean theme_exists(const char *const theme_name);
|
||||
GSList* theme_list(void);
|
||||
void theme_close(void);
|
||||
int theme_hash_attrs(const char* str);
|
||||
int theme_hash_attrs(const char *str);
|
||||
int theme_attrs(theme_item_t attrs);
|
||||
char* theme_get_string(char* str);
|
||||
void theme_free_string(char* str);
|
||||
theme_item_t theme_main_presence_attrs(const char* const presence);
|
||||
theme_item_t theme_roster_unread_presence_attrs(const char* const presence);
|
||||
theme_item_t theme_roster_active_presence_attrs(const char* const presence);
|
||||
theme_item_t theme_roster_presence_attrs(const char* const presence);
|
||||
char* theme_get_string(char *str);
|
||||
void theme_free_string(char *str);
|
||||
theme_item_t theme_main_presence_attrs(const char *const presence);
|
||||
theme_item_t theme_roster_unread_presence_attrs(const char *const presence);
|
||||
theme_item_t theme_roster_active_presence_attrs(const char *const presence);
|
||||
theme_item_t theme_roster_presence_attrs(const char *const presence);
|
||||
char* theme_get_bkgnd(void);
|
||||
|
||||
#endif
|
||||
|
@ -39,20 +39,20 @@
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "common.h"
|
||||
#include "config/files.h"
|
||||
#include "config/tlscerts.h"
|
||||
#include "log.h"
|
||||
#include "tools/autocomplete.h"
|
||||
|
||||
static char* tlscerts_loc;
|
||||
static GKeyFile* tlscerts;
|
||||
static char *tlscerts_loc;
|
||||
static GKeyFile *tlscerts;
|
||||
|
||||
static void _save_tlscerts(void);
|
||||
|
||||
static Autocomplete certs_ac;
|
||||
|
||||
static char* current_fp;
|
||||
static char *current_fp;
|
||||
|
||||
void
|
||||
tlscerts_init(void)
|
||||
@ -69,7 +69,7 @@ tlscerts_init(void)
|
||||
|
||||
certs_ac = autocomplete_new();
|
||||
gsize len = 0;
|
||||
gchar** groups = g_key_file_get_groups(tlscerts, &len);
|
||||
gchar **groups = g_key_file_get_groups(tlscerts, &len);
|
||||
|
||||
int i = 0;
|
||||
for (i = 0; i < g_strv_length(groups); i++) {
|
||||
@ -81,7 +81,7 @@ tlscerts_init(void)
|
||||
}
|
||||
|
||||
void
|
||||
tlscerts_set_current(const char* const fp)
|
||||
tlscerts_set_current(const char *const fp)
|
||||
{
|
||||
if (current_fp) {
|
||||
free(current_fp);
|
||||
@ -105,7 +105,7 @@ tlscerts_clear_current(void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
tlscerts_exists(const char* const fingerprint)
|
||||
tlscerts_exists(const char *const fingerprint)
|
||||
{
|
||||
return g_key_file_has_group(tlscerts, fingerprint);
|
||||
}
|
||||
@ -113,24 +113,24 @@ tlscerts_exists(const char* const fingerprint)
|
||||
GList*
|
||||
tlscerts_list(void)
|
||||
{
|
||||
GList* res = NULL;
|
||||
GList *res = NULL;
|
||||
gsize len = 0;
|
||||
gchar** groups = g_key_file_get_groups(tlscerts, &len);
|
||||
gchar **groups = g_key_file_get_groups(tlscerts, &len);
|
||||
|
||||
int i = 0;
|
||||
for (i = 0; i < g_strv_length(groups); i++) {
|
||||
char* fingerprint = strdup(groups[i]);
|
||||
char *fingerprint = strdup(groups[i]);
|
||||
int version = g_key_file_get_integer(tlscerts, fingerprint, "version", NULL);
|
||||
char* serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL);
|
||||
char* subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL);
|
||||
char* issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL);
|
||||
char* notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL);
|
||||
char* notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL);
|
||||
char* keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL);
|
||||
char* signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL);
|
||||
char *serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL);
|
||||
char *subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL);
|
||||
char *issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL);
|
||||
char *notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL);
|
||||
char *notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL);
|
||||
char *keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL);
|
||||
char *signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL);
|
||||
|
||||
TLSCertificate* cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
|
||||
notafter, keyalg, signaturealg);
|
||||
TLSCertificate *cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
|
||||
notafter, keyalg, signaturealg);
|
||||
|
||||
free(fingerprint);
|
||||
free(serialnumber);
|
||||
@ -152,11 +152,11 @@ tlscerts_list(void)
|
||||
}
|
||||
|
||||
TLSCertificate*
|
||||
tlscerts_new(const char* const fingerprint, int version, const char* const serialnumber, const char* const subjectname,
|
||||
const char* const issuername, const char* const notbefore, const char* const notafter,
|
||||
const char* const key_alg, const char* const signature_alg)
|
||||
tlscerts_new(const char *const fingerprint, int version, const char *const serialnumber, const char *const subjectname,
|
||||
const char *const issuername, const char *const notbefore, const char *const notafter,
|
||||
const char *const key_alg, const char *const signature_alg)
|
||||
{
|
||||
TLSCertificate* cert = malloc(sizeof(TLSCertificate));
|
||||
TLSCertificate *cert = malloc(sizeof(TLSCertificate));
|
||||
|
||||
if (fingerprint) {
|
||||
cert->fingerprint = strdup(fingerprint);
|
||||
@ -287,7 +287,7 @@ tlscerts_new(const char* const fingerprint, int version, const char* const seria
|
||||
}
|
||||
|
||||
void
|
||||
tlscerts_add(TLSCertificate* cert)
|
||||
tlscerts_add(TLSCertificate *cert)
|
||||
{
|
||||
if (!cert) {
|
||||
return;
|
||||
@ -326,9 +326,9 @@ tlscerts_add(TLSCertificate* cert)
|
||||
}
|
||||
|
||||
gboolean
|
||||
tlscerts_revoke(const char* const fingerprint)
|
||||
tlscerts_revoke(const char *const fingerprint)
|
||||
{
|
||||
gboolean result = g_key_file_remove_group(tlscerts, fingerprint, NULL);
|
||||
gboolean result = g_key_file_remove_group(tlscerts, fingerprint, NULL);
|
||||
if (result) {
|
||||
autocomplete_remove(certs_ac, fingerprint);
|
||||
}
|
||||
@ -339,23 +339,23 @@ tlscerts_revoke(const char* const fingerprint)
|
||||
}
|
||||
|
||||
TLSCertificate*
|
||||
tlscerts_get_trusted(const char* const fingerprint)
|
||||
tlscerts_get_trusted(const char * const fingerprint)
|
||||
{
|
||||
if (!g_key_file_has_group(tlscerts, fingerprint)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int version = g_key_file_get_integer(tlscerts, fingerprint, "version", NULL);
|
||||
char* serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL);
|
||||
char* subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL);
|
||||
char* issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL);
|
||||
char* notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL);
|
||||
char* notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL);
|
||||
char* keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL);
|
||||
char* signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL);
|
||||
char *serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL);
|
||||
char *subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL);
|
||||
char *issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL);
|
||||
char *notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL);
|
||||
char *notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL);
|
||||
char *keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL);
|
||||
char *signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL);
|
||||
|
||||
TLSCertificate* cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
|
||||
notafter, keyalg, signaturealg);
|
||||
TLSCertificate *cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
|
||||
notafter, keyalg, signaturealg);
|
||||
|
||||
free(serialnumber);
|
||||
free(subjectname);
|
||||
@ -369,7 +369,7 @@ tlscerts_get_trusted(const char* const fingerprint)
|
||||
}
|
||||
|
||||
char*
|
||||
tlscerts_complete(const char* const prefix, gboolean previous, void* context)
|
||||
tlscerts_complete(const char *const prefix, gboolean previous, void *context)
|
||||
{
|
||||
return autocomplete_complete(certs_ac, prefix, TRUE, previous);
|
||||
}
|
||||
@ -381,7 +381,7 @@ tlscerts_reset_ac(void)
|
||||
}
|
||||
|
||||
void
|
||||
tlscerts_free(TLSCertificate* cert)
|
||||
tlscerts_free(TLSCertificate *cert)
|
||||
{
|
||||
if (cert) {
|
||||
free(cert->serialnumber);
|
||||
@ -433,7 +433,7 @@ static void
|
||||
_save_tlscerts(void)
|
||||
{
|
||||
gsize g_data_size;
|
||||
gchar* g_tlscerts_data = g_key_file_to_data(tlscerts, &g_data_size, NULL);
|
||||
gchar *g_tlscerts_data = g_key_file_to_data(tlscerts, &g_data_size, NULL);
|
||||
g_file_set_contents(tlscerts_loc, g_tlscerts_data, g_data_size, NULL);
|
||||
g_chmod(tlscerts_loc, S_IRUSR | S_IWUSR);
|
||||
g_free(g_tlscerts_data);
|
||||
|
@ -38,60 +38,59 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
typedef struct tls_cert_t
|
||||
{
|
||||
typedef struct tls_cert_t {
|
||||
int version;
|
||||
char* serialnumber;
|
||||
char* subjectname;
|
||||
char* subject_country;
|
||||
char* subject_state;
|
||||
char* subject_distinguishedname;
|
||||
char* subject_serialnumber;
|
||||
char* subject_commonname;
|
||||
char* subject_organisation;
|
||||
char* subject_organisation_unit;
|
||||
char* subject_email;
|
||||
char* issuername;
|
||||
char* issuer_country;
|
||||
char* issuer_state;
|
||||
char* issuer_distinguishedname;
|
||||
char* issuer_serialnumber;
|
||||
char* issuer_commonname;
|
||||
char* issuer_organisation;
|
||||
char* issuer_organisation_unit;
|
||||
char* issuer_email;
|
||||
char* notbefore;
|
||||
char* notafter;
|
||||
char* fingerprint;
|
||||
char* key_alg;
|
||||
char* signature_alg;
|
||||
char *serialnumber;
|
||||
char *subjectname;
|
||||
char *subject_country;
|
||||
char *subject_state;
|
||||
char *subject_distinguishedname;
|
||||
char *subject_serialnumber;
|
||||
char *subject_commonname;
|
||||
char *subject_organisation;
|
||||
char *subject_organisation_unit;
|
||||
char *subject_email;
|
||||
char *issuername;
|
||||
char *issuer_country;
|
||||
char *issuer_state;
|
||||
char *issuer_distinguishedname;
|
||||
char *issuer_serialnumber;
|
||||
char *issuer_commonname;
|
||||
char *issuer_organisation;
|
||||
char *issuer_organisation_unit;
|
||||
char *issuer_email;
|
||||
char *notbefore;
|
||||
char *notafter;
|
||||
char *fingerprint;
|
||||
char *key_alg;
|
||||
char *signature_alg;
|
||||
} TLSCertificate;
|
||||
|
||||
void tlscerts_init(void);
|
||||
|
||||
TLSCertificate* tlscerts_new(const char* const fingerprint, int version, const char* const serialnumber, const char* const subjectname,
|
||||
const char* const issuername, const char* const notbefore, const char* const notafter,
|
||||
const char* const key_alg, const char* const signature_alg);
|
||||
TLSCertificate* tlscerts_new(const char *const fingerprint, int version, const char *const serialnumber, const char *const subjectname,
|
||||
const char *const issuername, const char *const notbefore, const char *const notafter,
|
||||
const char *const key_alg, const char *const signature_alg);
|
||||
|
||||
void tlscerts_set_current(const char* const fp);
|
||||
void tlscerts_set_current(const char *const fp);
|
||||
|
||||
char* tlscerts_get_current(void);
|
||||
|
||||
void tlscerts_clear_current(void);
|
||||
|
||||
gboolean tlscerts_exists(const char* const fingerprint);
|
||||
gboolean tlscerts_exists(const char *const fingerprint);
|
||||
|
||||
void tlscerts_add(TLSCertificate* cert);
|
||||
void tlscerts_add(TLSCertificate *cert);
|
||||
|
||||
gboolean tlscerts_revoke(const char* const fingerprint);
|
||||
gboolean tlscerts_revoke(const char *const fingerprint);
|
||||
|
||||
TLSCertificate* tlscerts_get_trusted(const char* const fingerprint);
|
||||
TLSCertificate* tlscerts_get_trusted(const char *const fingerprint);
|
||||
|
||||
void tlscerts_free(TLSCertificate* cert);
|
||||
void tlscerts_free(TLSCertificate *cert);
|
||||
|
||||
GList* tlscerts_list(void);
|
||||
|
||||
char* tlscerts_complete(const char* const prefix, gboolean previous, void* context);
|
||||
char* tlscerts_complete(const char *const prefix, gboolean previous, void *context);
|
||||
|
||||
void tlscerts_reset_ac(void);
|
||||
|
||||
|
145
src/database.c
145
src/database.c
@ -35,32 +35,32 @@
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
|
||||
#include <errno.h>
|
||||
#include <glib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sqlite3.h>
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "common.h"
|
||||
#include "config/files.h"
|
||||
#include "log.h"
|
||||
|
||||
static sqlite3* g_chatlog_database;
|
||||
static sqlite3 *g_chatlog_database;
|
||||
|
||||
static void _add_to_db(ProfMessage* message, char* type, const Jid* const from_jid, const Jid* const to_jid);
|
||||
static char* _get_db_filename(ProfAccount* account);
|
||||
static prof_msg_type_t _get_message_type_type(const char* const type);
|
||||
static void _add_to_db(ProfMessage *message, char *type, const Jid * const from_jid, const Jid * const to_jid);
|
||||
static char* _get_db_filename(ProfAccount *account);
|
||||
static prof_msg_type_t _get_message_type_type(const char *const type);
|
||||
|
||||
static char*
|
||||
_get_db_filename(ProfAccount* account)
|
||||
_get_db_filename(ProfAccount *account)
|
||||
{
|
||||
gchar* database_dir = files_get_account_data_path(DIR_DATABASE, account->jid);
|
||||
gchar *database_dir = files_get_account_data_path(DIR_DATABASE, account->jid);
|
||||
|
||||
int res = g_mkdir_with_parents(database_dir, S_IRWXU);
|
||||
if (res == -1) {
|
||||
char* errmsg = strerror(errno);
|
||||
char *errmsg = strerror(errno);
|
||||
if (errmsg) {
|
||||
log_error("DATABASE: error creating directory: %s, %s", database_dir, errmsg);
|
||||
} else {
|
||||
@ -70,9 +70,9 @@ _get_db_filename(ProfAccount* account)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GString* chatlog_filename = g_string_new(database_dir);
|
||||
GString *chatlog_filename = g_string_new(database_dir);
|
||||
g_string_append(chatlog_filename, "/chatlog.db");
|
||||
gchar* result = g_strdup(chatlog_filename->str);
|
||||
gchar *result = g_strdup(chatlog_filename->str);
|
||||
g_string_free(chatlog_filename, TRUE);
|
||||
g_free(database_dir);
|
||||
|
||||
@ -80,7 +80,7 @@ _get_db_filename(ProfAccount* account)
|
||||
}
|
||||
|
||||
gboolean
|
||||
log_database_init(ProfAccount* account)
|
||||
log_database_init(ProfAccount *account)
|
||||
{
|
||||
int ret = sqlite3_initialize();
|
||||
if (ret != SQLITE_OK) {
|
||||
@ -88,20 +88,20 @@ log_database_init(ProfAccount* account)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char* filename = _get_db_filename(account);
|
||||
char *filename = _get_db_filename(account);
|
||||
if (!filename) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = sqlite3_open(filename, &g_chatlog_database);
|
||||
if (ret != SQLITE_OK) {
|
||||
const char* err_msg = sqlite3_errmsg(g_chatlog_database);
|
||||
const char *err_msg = sqlite3_errmsg(g_chatlog_database);
|
||||
log_error("Error opening SQLite database: %s", err_msg);
|
||||
free(filename);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char* err_msg;
|
||||
char *err_msg;
|
||||
// id is the ID of DB the entry
|
||||
// from_jid is the senders jid
|
||||
// to_jid is the receivers jid
|
||||
@ -115,18 +115,18 @@ log_database_init(ProfAccount* account)
|
||||
// replace_id is the ID from XEP-0308: Last Message Correction
|
||||
// encryption is to distinguish: none, omemo, otr, pgp
|
||||
// marked_read is 0/1 whether a message has been marked as read via XEP-0333: Chat Markers
|
||||
char* query = "CREATE TABLE IF NOT EXISTS `ChatLogs` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `from_jid` TEXT NOT NULL, `to_jid` TEXT NOT NULL, `from_resource` TEXT, `to_resource` TEXT, `message` TEXT, `timestamp` TEXT, `type` TEXT, `stanza_id` TEXT, `archive_id` TEXT, `replace_id` TEXT, `encryption` TEXT, `marked_read` INTEGER)";
|
||||
if (SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) {
|
||||
char *query = "CREATE TABLE IF NOT EXISTS `ChatLogs` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `from_jid` TEXT NOT NULL, `to_jid` TEXT NOT NULL, `from_resource` TEXT, `to_resource` TEXT, `message` TEXT, `timestamp` TEXT, `type` TEXT, `stanza_id` TEXT, `archive_id` TEXT, `replace_id` TEXT, `encryption` TEXT, `marked_read` INTEGER)";
|
||||
if( SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
query = "CREATE TABLE IF NOT EXISTS `DbVersion` ( `dv_id` INTEGER PRIMARY KEY, `version` INTEGER UNIQUE)";
|
||||
if (SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) {
|
||||
if( SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
query = "INSERT OR IGNORE INTO `DbVersion` (`version`) VALUES('1')";
|
||||
if (SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) {
|
||||
if( SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -156,13 +156,13 @@ log_database_close(void)
|
||||
}
|
||||
|
||||
void
|
||||
log_database_add_incoming(ProfMessage* message)
|
||||
log_database_add_incoming(ProfMessage *message)
|
||||
{
|
||||
if (message->to_jid) {
|
||||
_add_to_db(message, NULL, message->from_jid, message->to_jid);
|
||||
} else {
|
||||
const char* jid = connection_get_fulljid();
|
||||
Jid* myjid = jid_create(jid);
|
||||
const char *jid = connection_get_fulljid();
|
||||
Jid *myjid = jid_create(jid);
|
||||
|
||||
_add_to_db(message, NULL, message->from_jid, myjid);
|
||||
|
||||
@ -171,9 +171,9 @@ log_database_add_incoming(ProfMessage* message)
|
||||
}
|
||||
|
||||
static void
|
||||
_log_database_add_outgoing(char* type, const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc)
|
||||
_log_database_add_outgoing(char *type, const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc)
|
||||
{
|
||||
ProfMessage* msg = message_init();
|
||||
ProfMessage *msg = message_init();
|
||||
|
||||
msg->id = id ? strdup(id) : NULL;
|
||||
msg->from_jid = jid_create(barejid);
|
||||
@ -182,8 +182,8 @@ _log_database_add_outgoing(char* type, const char* const id, const char* const b
|
||||
msg->timestamp = g_date_time_new_now_local(); //TODO: get from outside. best to have whole ProfMessage from outside
|
||||
msg->enc = enc;
|
||||
|
||||
const char* jid = connection_get_fulljid();
|
||||
Jid* myjid = jid_create(jid);
|
||||
const char *jid = connection_get_fulljid();
|
||||
Jid *myjid = jid_create(jid);
|
||||
|
||||
_add_to_db(msg, type, myjid, msg->from_jid); // TODO: myjid now in profmessage
|
||||
|
||||
@ -192,30 +192,30 @@ _log_database_add_outgoing(char* type, const char* const id, const char* const b
|
||||
}
|
||||
|
||||
void
|
||||
log_database_add_outgoing_chat(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc)
|
||||
log_database_add_outgoing_chat(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc)
|
||||
{
|
||||
_log_database_add_outgoing("chat", id, barejid, message, replace_id, enc);
|
||||
}
|
||||
|
||||
void
|
||||
log_database_add_outgoing_muc(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc)
|
||||
log_database_add_outgoing_muc(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc)
|
||||
{
|
||||
_log_database_add_outgoing("muc", id, barejid, message, replace_id, enc);
|
||||
}
|
||||
|
||||
void
|
||||
log_database_add_outgoing_muc_pm(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc)
|
||||
log_database_add_outgoing_muc_pm(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc)
|
||||
{
|
||||
_log_database_add_outgoing("mucpm", id, barejid, message, replace_id, enc);
|
||||
}
|
||||
|
||||
GSList*
|
||||
log_database_get_previous_chat(const gchar* const contact_barejid)
|
||||
log_database_get_previous_chat(const gchar *const contact_barejid)
|
||||
{
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
char* query;
|
||||
const char* jid = connection_get_fulljid();
|
||||
Jid* myjid = jid_create(jid);
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
char *query;
|
||||
const char *jid = connection_get_fulljid();
|
||||
Jid *myjid = jid_create(jid);
|
||||
|
||||
if (asprintf(&query, "SELECT * FROM (SELECT `message`, `timestamp`, `from_jid`, `type` from `ChatLogs` WHERE (`from_jid` = '%s' AND `to_jid` = '%s') OR (`from_jid` = '%s' AND `to_jid` = '%s') ORDER BY `timestamp` DESC LIMIT 10) ORDER BY `timestamp` ASC;", contact_barejid, myjid->barejid, myjid->barejid, contact_barejid) == -1) {
|
||||
log_error("log_database_get_previous_chat(): SQL query. could not allocate memory");
|
||||
@ -224,22 +224,22 @@ log_database_get_previous_chat(const gchar* const contact_barejid)
|
||||
|
||||
jid_destroy(myjid);
|
||||
|
||||
int rc = sqlite3_prepare_v2(g_chatlog_database, query, -1, &stmt, NULL);
|
||||
if (rc != SQLITE_OK) {
|
||||
int rc = sqlite3_prepare_v2(g_chatlog_database, query, -1, &stmt, NULL);
|
||||
if( rc!=SQLITE_OK ) {
|
||||
log_error("log_database_get_previous_chat(): unknown SQLite error");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GSList* history = NULL;
|
||||
GSList *history = NULL;
|
||||
|
||||
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
while( sqlite3_step(stmt) == SQLITE_ROW ) {
|
||||
// TODO: also save to jid. since now part of profmessage
|
||||
char* message = (char*)sqlite3_column_text(stmt, 0);
|
||||
char* date = (char*)sqlite3_column_text(stmt, 1);
|
||||
char* from = (char*)sqlite3_column_text(stmt, 2);
|
||||
char* type = (char*)sqlite3_column_text(stmt, 3);
|
||||
char *message = (char*)sqlite3_column_text(stmt, 0);
|
||||
char *date = (char*)sqlite3_column_text(stmt, 1);
|
||||
char *from = (char*)sqlite3_column_text(stmt, 2);
|
||||
char *type = (char*)sqlite3_column_text(stmt, 3);
|
||||
|
||||
ProfMessage* msg = message_init();
|
||||
ProfMessage *msg = message_init();
|
||||
msg->from_jid = jid_create(from);
|
||||
msg->plain = strdup(message);
|
||||
msg->timestamp = g_date_time_new_from_iso8601(date, NULL);
|
||||
@ -247,16 +247,14 @@ log_database_get_previous_chat(const gchar* const contact_barejid)
|
||||
// TODO: later we can get more fields like 'enc'. then we can display the history like regular chats with all info the user enabled.
|
||||
|
||||
history = g_slist_append(history, msg);
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
free(query);
|
||||
|
||||
return history;
|
||||
}
|
||||
|
||||
static const char*
|
||||
_get_message_type_str(prof_msg_type_t type)
|
||||
{
|
||||
static const char* _get_message_type_str(prof_msg_type_t type) {
|
||||
switch (type) {
|
||||
case PROF_MSG_TYPE_CHAT:
|
||||
return "chat";
|
||||
@ -270,9 +268,7 @@ _get_message_type_str(prof_msg_type_t type)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static prof_msg_type_t
|
||||
_get_message_type_type(const char* const type)
|
||||
{
|
||||
static prof_msg_type_t _get_message_type_type(const char *const type) {
|
||||
if (g_strcmp0(type, "chat") == 0) {
|
||||
return PROF_MSG_TYPE_CHAT;
|
||||
} else if (g_strcmp0(type, "muc") == 0) {
|
||||
@ -284,9 +280,7 @@ _get_message_type_type(const char* const type)
|
||||
}
|
||||
}
|
||||
|
||||
static const char*
|
||||
_get_message_enc_str(prof_enc_t enc)
|
||||
{
|
||||
static const char* _get_message_enc_str(prof_enc_t enc) {
|
||||
switch (enc) {
|
||||
case PROF_MSG_ENC_OX:
|
||||
return "ox";
|
||||
@ -304,56 +298,55 @@ _get_message_enc_str(prof_enc_t enc)
|
||||
}
|
||||
|
||||
static void
|
||||
_add_to_db(ProfMessage* message, char* type, const Jid* const from_jid, const Jid* const to_jid)
|
||||
_add_to_db(ProfMessage *message, char *type, const Jid * const from_jid, const Jid * const to_jid)
|
||||
{
|
||||
if (!g_chatlog_database) {
|
||||
log_debug("log_database_add() called but db is not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
char* err_msg;
|
||||
char* query;
|
||||
gchar* date_fmt;
|
||||
char *err_msg;
|
||||
char *query;
|
||||
gchar *date_fmt;
|
||||
|
||||
if (message->timestamp) {
|
||||
// g_date_time_format_iso8601() is only availble from glib 2.62 on.
|
||||
// To still support Debian buster lets use g_date_time_format() for now.
|
||||
//date_fmt = g_date_time_format_iso8601(message->timestamp);
|
||||
date_fmt = g_date_time_format(message->timestamp, "%FT%T%:::z");
|
||||
date_fmt = g_date_time_format(message->timestamp,"%FT%T%:::z");
|
||||
} else {
|
||||
// g_date_time_format_iso8601() is only availble from glib 2.62 on.
|
||||
// To still support Debian buster lets use g_date_time_format() for now.
|
||||
//date_fmt = g_date_time_format_iso8601(g_date_time_new_now_local());
|
||||
date_fmt = g_date_time_format(g_date_time_new_now_local(), "%FT%T%:::z");
|
||||
date_fmt = g_date_time_format(g_date_time_new_now_local(), "%FT%T%:::z" );
|
||||
}
|
||||
|
||||
const char* enc = _get_message_enc_str(message->enc);
|
||||
const char *enc = _get_message_enc_str(message->enc);
|
||||
|
||||
if (!type) {
|
||||
type = (char*)_get_message_type_str(message->type);
|
||||
}
|
||||
|
||||
char* escaped_message = str_replace(message->plain, "'", "''");
|
||||
char *escaped_message = str_replace(message->plain, "'", "''");
|
||||
|
||||
if (asprintf(&query, "INSERT INTO `ChatLogs` (`from_jid`, `from_resource`, `to_jid`, `to_resource`, `message`, `timestamp`, `stanza_id`, `replace_id`, `type`, `encryption`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
|
||||
from_jid->barejid,
|
||||
from_jid->resourcepart ? from_jid->resourcepart : "",
|
||||
to_jid->barejid,
|
||||
to_jid->resourcepart ? to_jid->resourcepart : "",
|
||||
escaped_message,
|
||||
date_fmt,
|
||||
message->id ? message->id : "",
|
||||
message->replace_id ? message->replace_id : "",
|
||||
type,
|
||||
enc)
|
||||
== -1) {
|
||||
from_jid->barejid,
|
||||
from_jid->resourcepart ? from_jid->resourcepart : "",
|
||||
to_jid->barejid,
|
||||
to_jid->resourcepart ? to_jid->resourcepart : "",
|
||||
escaped_message,
|
||||
date_fmt,
|
||||
message->id ? message->id : "",
|
||||
message->replace_id ? message->replace_id : "",
|
||||
type,
|
||||
enc) == -1) {
|
||||
log_error("log_database_add(): SQL query. could not allocate memory");
|
||||
return;
|
||||
}
|
||||
free(escaped_message);
|
||||
g_free(date_fmt);
|
||||
|
||||
if (SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) {
|
||||
if( SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) {
|
||||
if (err_msg) {
|
||||
log_error("SQLite error: %s", err_msg);
|
||||
sqlite3_free(err_msg);
|
||||
|
@ -36,16 +36,17 @@
|
||||
#ifndef DATABASE_H
|
||||
#define DATABASE_H
|
||||
|
||||
#include <glib.h>
|
||||
#include "config/account.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
#include <glib.h>
|
||||
|
||||
gboolean log_database_init(ProfAccount* account);
|
||||
void log_database_add_incoming(ProfMessage* message);
|
||||
void log_database_add_outgoing_chat(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc);
|
||||
void log_database_add_outgoing_muc(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc);
|
||||
void log_database_add_outgoing_muc_pm(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc);
|
||||
GSList* log_database_get_previous_chat(const gchar* const contact_barejid);
|
||||
gboolean log_database_init(ProfAccount *account);
|
||||
void log_database_add_incoming(ProfMessage *message);
|
||||
void log_database_add_outgoing_chat(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc);
|
||||
void log_database_add_outgoing_muc(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc);
|
||||
void log_database_add_outgoing_muc_pm(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc);
|
||||
GSList* log_database_get_previous_chat(const gchar *const contact_barejid);
|
||||
void log_database_close(void);
|
||||
|
||||
#endif // DATABASE_H
|
||||
|
||||
|
@ -36,13 +36,13 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "config/preferences.h"
|
||||
#include "database.h"
|
||||
#include "event/common.h"
|
||||
#include "log.h"
|
||||
#include "database.h"
|
||||
#include "config/preferences.h"
|
||||
#include "event/common.h"
|
||||
#include "plugins/plugins.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/chat_session.h"
|
||||
@ -61,14 +61,14 @@
|
||||
#endif
|
||||
|
||||
jabber_conn_status_t
|
||||
cl_ev_connect_jid(const char* const jid, const char* const passwd, const char* const altdomain, const int port, const char* const tls_policy, const char* const auth_policy)
|
||||
cl_ev_connect_jid(const char *const jid, const char *const passwd, const char *const altdomain, const int port, const char *const tls_policy, const char *const auth_policy)
|
||||
{
|
||||
cons_show("Connecting as %s", jid);
|
||||
return session_connect_with_details(jid, passwd, altdomain, port, tls_policy, auth_policy);
|
||||
}
|
||||
|
||||
jabber_conn_status_t
|
||||
cl_ev_connect_account(ProfAccount* account)
|
||||
cl_ev_connect_account(ProfAccount *account)
|
||||
{
|
||||
if (account->resource) {
|
||||
cons_show("Connecting with account %s as %s/%s", account->name, account->jid, account->resource);
|
||||
@ -84,7 +84,7 @@ cl_ev_connect_account(ProfAccount* account)
|
||||
void
|
||||
cl_ev_disconnect(void)
|
||||
{
|
||||
char* mybarejid = connection_get_barejid();
|
||||
char *mybarejid = connection_get_barejid();
|
||||
cons_show("%s logged out successfully.", mybarejid);
|
||||
free(mybarejid);
|
||||
|
||||
@ -97,13 +97,13 @@ cl_ev_disconnect(void)
|
||||
void
|
||||
cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs)
|
||||
{
|
||||
char* signed_status = NULL;
|
||||
char *signed_status = NULL;
|
||||
|
||||
#ifdef HAVE_LIBGPGME
|
||||
char* account_name = session_get_account_name();
|
||||
ProfAccount* account = accounts_get_account(account_name);
|
||||
char *account_name = session_get_account_name();
|
||||
ProfAccount *account = accounts_get_account(account_name);
|
||||
if (account->pgp_keyid) {
|
||||
char* msg = connection_get_presence_msg();
|
||||
char *msg = connection_get_presence_msg();
|
||||
signed_status = p_gpg_sign(msg, account->pgp_keyid);
|
||||
}
|
||||
account_free(account);
|
||||
@ -115,25 +115,25 @@ cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs
|
||||
}
|
||||
|
||||
void
|
||||
cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char* const oob_url, gboolean correct_last_msg)
|
||||
cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *const oob_url, gboolean correct_last_msg)
|
||||
{
|
||||
chat_state_active(chatwin->state);
|
||||
|
||||
gboolean request_receipt = prefs_get_boolean(PREF_RECEIPTS_REQUEST);
|
||||
|
||||
char* plugin_msg = plugins_pre_chat_message_send(chatwin->barejid, msg);
|
||||
char *plugin_msg = plugins_pre_chat_message_send(chatwin->barejid, msg);
|
||||
if (plugin_msg == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
char* replace_id = NULL;
|
||||
char *replace_id = NULL;
|
||||
if (correct_last_msg) {
|
||||
replace_id = chatwin->last_msg_id;
|
||||
}
|
||||
|
||||
if (chatwin->is_omemo) {
|
||||
#ifdef HAVE_OMEMO
|
||||
char* id = omemo_on_message_send((ProfWin*)chatwin, plugin_msg, request_receipt, FALSE, replace_id);
|
||||
char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE, replace_id);
|
||||
chat_log_omemo_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_OMEMO);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, request_receipt, replace_id);
|
||||
@ -142,7 +142,7 @@ cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char*
|
||||
} else if (chatwin->is_ox) {
|
||||
#ifdef HAVE_LIBGPGME
|
||||
// XEP-0373: OpenPGP for XMPP
|
||||
char* id = message_send_chat_ox(chatwin->barejid, plugin_msg, request_receipt, replace_id);
|
||||
char *id = message_send_chat_ox(chatwin->barejid, plugin_msg, request_receipt, replace_id);
|
||||
chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_OX);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OX, request_receipt, replace_id);
|
||||
@ -150,7 +150,7 @@ cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char*
|
||||
#endif
|
||||
} else if (chatwin->pgp_send) {
|
||||
#ifdef HAVE_LIBGPGME
|
||||
char* id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt, replace_id);
|
||||
char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt, replace_id);
|
||||
chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_PGP);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt, replace_id);
|
||||
@ -159,10 +159,10 @@ cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char*
|
||||
} else {
|
||||
gboolean handled = FALSE;
|
||||
#ifdef HAVE_LIBOTR
|
||||
handled = otr_on_message_send(chatwin, plugin_msg, request_receipt, replace_id);
|
||||
handled = otr_on_message_send(chatwin, plugin_msg, request_receipt, replace_id);
|
||||
#endif
|
||||
if (!handled) {
|
||||
char* id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
|
||||
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
|
||||
chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_NONE);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_NONE, request_receipt, replace_id);
|
||||
@ -176,33 +176,33 @@ cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char*
|
||||
}
|
||||
|
||||
void
|
||||
cl_ev_send_msg(ProfChatWin* chatwin, const char* const msg, const char* const oob_url)
|
||||
cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oob_url)
|
||||
{
|
||||
cl_ev_send_msg_correct(chatwin, msg, oob_url, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
cl_ev_send_muc_msg_corrected(ProfMucWin* mucwin, const char* const msg, const char* const oob_url, gboolean correct_last_msg)
|
||||
cl_ev_send_muc_msg_corrected(ProfMucWin *mucwin, const char *const msg, const char *const oob_url, gboolean correct_last_msg)
|
||||
{
|
||||
char* plugin_msg = plugins_pre_room_message_send(mucwin->roomjid, msg);
|
||||
char *plugin_msg = plugins_pre_room_message_send(mucwin->roomjid, msg);
|
||||
if (plugin_msg == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
char* replace_id = NULL;
|
||||
char *replace_id = NULL;
|
||||
if (correct_last_msg) {
|
||||
replace_id = mucwin->last_msg_id;
|
||||
}
|
||||
|
||||
#ifdef HAVE_OMEMO
|
||||
if (mucwin->is_omemo) {
|
||||
char* id = omemo_on_message_send((ProfWin*)mucwin, plugin_msg, FALSE, TRUE, replace_id);
|
||||
char *id = omemo_on_message_send((ProfWin *)mucwin, plugin_msg, FALSE, TRUE, replace_id);
|
||||
groupchat_log_omemo_msg_out(mucwin->roomjid, plugin_msg);
|
||||
log_database_add_outgoing_muc(id, mucwin->roomjid, plugin_msg, replace_id, PROF_MSG_ENC_OMEMO);
|
||||
mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, replace_id);
|
||||
free(id);
|
||||
} else {
|
||||
char* id = message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url, replace_id);
|
||||
char *id = message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url, replace_id);
|
||||
groupchat_log_msg_out(mucwin->roomjid, plugin_msg);
|
||||
log_database_add_outgoing_muc(id, mucwin->roomjid, plugin_msg, replace_id, PROF_MSG_ENC_NONE);
|
||||
mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_NONE, replace_id);
|
||||
@ -215,7 +215,7 @@ cl_ev_send_muc_msg_corrected(ProfMucWin* mucwin, const char* const msg, const ch
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_OMEMO
|
||||
char* id = message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url, replace_id);
|
||||
char *id = message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url, replace_id);
|
||||
groupchat_log_msg_out(mucwin->roomjid, plugin_msg);
|
||||
log_database_add_outgoing_muc(id, mucwin->roomjid, plugin_msg, replace_id, PROF_MSG_ENC_NONE);
|
||||
mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_NONE, replace_id);
|
||||
@ -228,23 +228,23 @@ cl_ev_send_muc_msg_corrected(ProfMucWin* mucwin, const char* const msg, const ch
|
||||
}
|
||||
|
||||
void
|
||||
cl_ev_send_muc_msg(ProfMucWin* mucwin, const char* const msg, const char* const oob_url)
|
||||
cl_ev_send_muc_msg(ProfMucWin *mucwin, const char *const msg, const char *const oob_url)
|
||||
{
|
||||
cl_ev_send_muc_msg_corrected(mucwin, msg, oob_url, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
cl_ev_send_priv_msg(ProfPrivateWin* privwin, const char* const msg, const char* const oob_url)
|
||||
cl_ev_send_priv_msg(ProfPrivateWin *privwin, const char *const msg, const char *const oob_url)
|
||||
{
|
||||
if (privwin->occupant_offline) {
|
||||
privwin_message_occupant_offline(privwin);
|
||||
} else if (privwin->room_left) {
|
||||
privwin_message_left_room(privwin);
|
||||
} else {
|
||||
char* plugin_msg = plugins_pre_priv_message_send(privwin->fulljid, msg);
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
char *plugin_msg = plugins_pre_priv_message_send(privwin->fulljid, msg);
|
||||
Jid *jidp = jid_create(privwin->fulljid);
|
||||
|
||||
char* id = message_send_private(privwin->fulljid, plugin_msg, oob_url);
|
||||
char *id = message_send_private(privwin->fulljid, plugin_msg, oob_url);
|
||||
chat_log_msg_out(jidp->barejid, plugin_msg, jidp->resourcepart);
|
||||
log_database_add_outgoing_muc_pm(id, privwin->fulljid, plugin_msg, NULL, PROF_MSG_ENC_NONE);
|
||||
privwin_outgoing_msg(privwin, plugin_msg);
|
||||
|
@ -38,17 +38,17 @@
|
||||
|
||||
#include "xmpp/xmpp.h"
|
||||
|
||||
jabber_conn_status_t cl_ev_connect_jid(const char* const jid, const char* const passwd, const char* const altdomain, const int port, const char* const tls_policy, const char* const auth_policy);
|
||||
jabber_conn_status_t cl_ev_connect_account(ProfAccount* account);
|
||||
jabber_conn_status_t cl_ev_connect_jid(const char *const jid, const char *const passwd, const char *const altdomain, const int port, const char *const tls_policy, const char *const auth_policy);
|
||||
jabber_conn_status_t cl_ev_connect_account(ProfAccount *account);
|
||||
|
||||
void cl_ev_disconnect(void);
|
||||
|
||||
void cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs);
|
||||
|
||||
void cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char* const oob_url, gboolean correct_last_msg);
|
||||
void cl_ev_send_msg(ProfChatWin* chatwin, const char* const msg, const char* const oob_url);
|
||||
void cl_ev_send_muc_msg_corrected(ProfMucWin* mucwin, const char* const msg, const char* const oob_url, gboolean correct_last_msg);
|
||||
void cl_ev_send_muc_msg(ProfMucWin* mucwin, const char* const msg, const char* const oob_url);
|
||||
void cl_ev_send_priv_msg(ProfPrivateWin* privwin, const char* const msg, const char* const oob_url);
|
||||
void cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *const oob_url, gboolean correct_last_msg);
|
||||
void cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oob_url);
|
||||
void cl_ev_send_muc_msg_corrected(ProfMucWin *mucwin, const char *const msg, const char *const oob_url, gboolean correct_last_msg);
|
||||
void cl_ev_send_muc_msg(ProfMucWin *mucwin, const char *const msg, const char *const oob_url);
|
||||
void cl_ev_send_priv_msg(ProfPrivateWin *privwin, const char *const msg, const char *const oob_url);
|
||||
|
||||
#endif
|
||||
|
@ -34,13 +34,13 @@
|
||||
*/
|
||||
|
||||
#include "config/tlscerts.h"
|
||||
#include "database.h"
|
||||
#include "tools/bookmark_ignore.h"
|
||||
#include "ui/ui.h"
|
||||
#include "xmpp/chat_session.h"
|
||||
#include "xmpp/muc.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#include "xmpp/muc.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
#include "database.h"
|
||||
#include "tools/bookmark_ignore.h"
|
||||
|
||||
#ifdef HAVE_LIBGPGME
|
||||
#include "pgp/gpg.h"
|
||||
|
@ -36,27 +36,27 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "config/account.h"
|
||||
#include "config/preferences.h"
|
||||
#include "config/scripts.h"
|
||||
#include "config/tlscerts.h"
|
||||
#include "profanity.h"
|
||||
#include "log.h"
|
||||
#include "database.h"
|
||||
#include "config/preferences.h"
|
||||
#include "config/tlscerts.h"
|
||||
#include "config/account.h"
|
||||
#include "config/scripts.h"
|
||||
#include "event/client_events.h"
|
||||
#include "event/common.h"
|
||||
#include "log.h"
|
||||
#include "plugins/plugins.h"
|
||||
#include "profanity.h"
|
||||
#include "tools/bookmark_ignore.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/avatar.h"
|
||||
#include "xmpp/chat_session.h"
|
||||
#include "xmpp/muc.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#include "tools/bookmark_ignore.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
#include "xmpp/muc.h"
|
||||
#include "xmpp/chat_session.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#include "xmpp/avatar.h"
|
||||
|
||||
#ifdef HAVE_LIBOTR
|
||||
#include "otr/otr.h"
|
||||
@ -72,13 +72,13 @@
|
||||
|
||||
#include "ui/ui.h"
|
||||
|
||||
static void _clean_incoming_message(ProfMessage* message);
|
||||
static void _sv_ev_incoming_plain(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit);
|
||||
static void _clean_incoming_message(ProfMessage *message);
|
||||
static void _sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message, gboolean logit);
|
||||
|
||||
void
|
||||
sv_ev_login_account_success(char* account_name, gboolean secured)
|
||||
sv_ev_login_account_success(char *account_name, gboolean secured)
|
||||
{
|
||||
ProfAccount* account = accounts_get_account(account_name);
|
||||
ProfAccount *account = accounts_get_account(account_name);
|
||||
|
||||
bookmark_ignore_on_connect(account->jid);
|
||||
|
||||
@ -103,11 +103,11 @@ sv_ev_login_account_success(char* account_name, gboolean secured)
|
||||
ui_handle_login_account_success(account, secured);
|
||||
|
||||
// attempt to rejoin all rooms
|
||||
GList* rooms = muc_rooms();
|
||||
GList* curr = rooms;
|
||||
GList *rooms = muc_rooms();
|
||||
GList *curr = rooms;
|
||||
while (curr) {
|
||||
char* password = muc_password(curr->data);
|
||||
char* nick = muc_nick(curr->data);
|
||||
char *password = muc_password(curr->data);
|
||||
char *nick = muc_nick(curr->data);
|
||||
presence_join_room(curr->data, nick, password);
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
@ -116,7 +116,8 @@ sv_ev_login_account_success(char* account_name, gboolean secured)
|
||||
log_info("%s logged in successfully", account->jid);
|
||||
|
||||
// if we have been connected before
|
||||
if (ev_was_connected_already()) {
|
||||
if (ev_was_connected_already())
|
||||
{
|
||||
cons_show("Connection re-established.");
|
||||
wins_reestablished_connection();
|
||||
}
|
||||
@ -139,21 +140,21 @@ sv_ev_roster_received(void)
|
||||
ui_show_roster();
|
||||
}
|
||||
|
||||
char* account_name = session_get_account_name();
|
||||
char *account_name = session_get_account_name();
|
||||
|
||||
#ifdef HAVE_LIBGPGME
|
||||
// check pgp key valid if specified
|
||||
ProfAccount* account = accounts_get_account(account_name);
|
||||
ProfAccount *account = accounts_get_account(account_name);
|
||||
if (account && account->pgp_keyid) {
|
||||
char* err_str = NULL;
|
||||
char *err_str = NULL;
|
||||
if (!p_gpg_valid_key(account->pgp_keyid, &err_str)) {
|
||||
cons_show_error("Invalid PGP key ID specified: %s, %s", account->pgp_keyid, err_str);
|
||||
}
|
||||
free(err_str);
|
||||
|
||||
// Redraw the screen after entry of the PGP secret key, but not init
|
||||
ProfWin* win = wins_get_current();
|
||||
char* theme = prefs_get_string(PREF_THEME);
|
||||
ProfWin *win = wins_get_current();
|
||||
char *theme = prefs_get_string(PREF_THEME);
|
||||
win_clear(win);
|
||||
theme_init(theme);
|
||||
g_free(theme);
|
||||
@ -165,15 +166,15 @@ sv_ev_roster_received(void)
|
||||
|
||||
// send initial presence
|
||||
resource_presence_t conn_presence = accounts_get_login_presence(account_name);
|
||||
char* last_activity_str = accounts_get_last_activity(account_name);
|
||||
char *last_activity_str = accounts_get_last_activity(account_name);
|
||||
if (prefs_get_boolean(PREF_LASTACTIVITY) && last_activity_str) {
|
||||
|
||||
GTimeVal lasttv;
|
||||
GDateTime* nowdt = g_date_time_new_now_utc();
|
||||
GDateTime *nowdt = g_date_time_new_now_utc();
|
||||
gboolean res = g_time_val_from_iso8601(last_activity_str, &lasttv);
|
||||
|
||||
if (res) {
|
||||
GDateTime* lastdt = g_date_time_new_from_timeval_utc(&lasttv);
|
||||
GDateTime *lastdt = g_date_time_new_from_timeval_utc(&lasttv);
|
||||
GTimeSpan diff_micros = g_date_time_difference(nowdt, lastdt);
|
||||
int diff_secs = (diff_micros / 1000) / 1000;
|
||||
|
||||
@ -193,7 +194,7 @@ sv_ev_roster_received(void)
|
||||
|
||||
free(last_activity_str);
|
||||
|
||||
const char* fulljid = connection_get_fulljid();
|
||||
const char *fulljid = connection_get_fulljid();
|
||||
plugins_on_connect(account_name, fulljid);
|
||||
|
||||
#ifdef HAVE_OMEMO
|
||||
@ -215,11 +216,11 @@ sv_ev_lost_connection(void)
|
||||
cons_show_error("Lost connection.");
|
||||
|
||||
#ifdef HAVE_LIBOTR
|
||||
GSList* recipients = wins_get_chat_recipients();
|
||||
GSList* curr = recipients;
|
||||
GSList *recipients = wins_get_chat_recipients();
|
||||
GSList *curr = recipients;
|
||||
while (curr) {
|
||||
char* barejid = curr->data;
|
||||
ProfChatWin* chatwin = wins_get_chat(barejid);
|
||||
char *barejid = curr->data;
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin && otr_is_secure(barejid)) {
|
||||
chatwin_otr_unsecured(chatwin);
|
||||
otr_end_session(barejid);
|
||||
@ -243,8 +244,8 @@ sv_ev_failed_login(void)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_room_invite(jabber_invite_t invite_type, const char* const invitor, const char* const room,
|
||||
const char* const reason, const char* const password)
|
||||
sv_ev_room_invite(jabber_invite_t invite_type, const char *const invitor, const char *const room,
|
||||
const char *const reason, const char *const password)
|
||||
{
|
||||
if (!muc_active(room) && !muc_invites_contain(room)) {
|
||||
cons_show_room_invite(invitor, room, reason);
|
||||
@ -253,10 +254,10 @@ sv_ev_room_invite(jabber_invite_t invite_type, const char* const invitor, const
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_room_broadcast(const char* const room_jid, const char* const message)
|
||||
sv_ev_room_broadcast(const char *const room_jid, const char *const message)
|
||||
{
|
||||
if (muc_roster_complete(room_jid)) {
|
||||
ProfMucWin* mucwin = wins_get_muc(room_jid);
|
||||
ProfMucWin *mucwin = wins_get_muc(room_jid);
|
||||
if (mucwin) {
|
||||
mucwin_broadcast(mucwin, message);
|
||||
}
|
||||
@ -266,19 +267,19 @@ sv_ev_room_broadcast(const char* const room_jid, const char* const message)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_room_subject(const char* const room, const char* const nick, const char* const subject)
|
||||
sv_ev_room_subject(const char *const room, const char *const nick, const char *const subject)
|
||||
{
|
||||
muc_set_subject(room, subject);
|
||||
ProfMucWin* mucwin = wins_get_muc(room);
|
||||
ProfMucWin *mucwin = wins_get_muc(room);
|
||||
if (mucwin && muc_roster_complete(room) && ev_is_first_connect()) {
|
||||
mucwin_subject(mucwin, nick, subject);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_room_history(ProfMessage* message)
|
||||
sv_ev_room_history(ProfMessage *message)
|
||||
{
|
||||
ProfMucWin* mucwin = wins_get_muc(message->from_jid->barejid);
|
||||
ProfMucWin *mucwin = wins_get_muc(message->from_jid->barejid);
|
||||
if (mucwin) {
|
||||
// if this is the first successful connection
|
||||
if (ev_is_first_connect()) {
|
||||
@ -287,18 +288,17 @@ sv_ev_room_history(ProfMessage* message)
|
||||
if (mucwin->last_msg_timestamp) {
|
||||
g_date_time_unref(mucwin->last_msg_timestamp);
|
||||
}
|
||||
mucwin->last_msg_timestamp = g_date_time_new_now_local();
|
||||
mucwin->last_msg_timestamp = g_date_time_new_now_local();
|
||||
}
|
||||
|
||||
gboolean younger = g_date_time_compare(mucwin->last_msg_timestamp, message->timestamp) < 0 ? TRUE : FALSE;
|
||||
if (ev_is_first_connect() || younger) {
|
||||
if (ev_is_first_connect() || younger ) {
|
||||
mucwin_history(mucwin, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_log_muc(ProfMessage* message)
|
||||
static void _log_muc(ProfMessage *message)
|
||||
{
|
||||
if (message->enc == PROF_MSG_ENC_OMEMO) {
|
||||
groupchat_log_omemo_msg_in(message->from_jid->barejid, message->from_jid->resourcepart, message->plain);
|
||||
@ -309,14 +309,14 @@ _log_muc(ProfMessage* message)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_room_message(ProfMessage* message)
|
||||
sv_ev_room_message(ProfMessage *message)
|
||||
{
|
||||
ProfMucWin* mucwin = wins_get_muc(message->from_jid->barejid);
|
||||
ProfMucWin *mucwin = wins_get_muc(message->from_jid->barejid);
|
||||
if (!mucwin) {
|
||||
return;
|
||||
}
|
||||
|
||||
char* mynick = muc_nick(mucwin->roomjid);
|
||||
char *mynick = muc_nick(mucwin->roomjid);
|
||||
|
||||
// only log message not coming from this client (but maybe same account, different client)
|
||||
// our messages are logged when outgoing
|
||||
@ -324,19 +324,19 @@ sv_ev_room_message(ProfMessage* message)
|
||||
_log_muc(message);
|
||||
}
|
||||
|
||||
char* old_plain = message->plain;
|
||||
char *old_plain = message->plain;
|
||||
message->plain = plugins_pre_room_message_display(message->from_jid->barejid, message->from_jid->resourcepart, message->plain);
|
||||
|
||||
GSList* mentions = get_mentions(prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD), prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE), message->plain, mynick);
|
||||
GSList *mentions = get_mentions(prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD), prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE), message->plain, mynick);
|
||||
gboolean mention = g_slist_length(mentions) > 0;
|
||||
GList* triggers = prefs_message_get_triggers(message->plain);
|
||||
GList *triggers = prefs_message_get_triggers(message->plain);
|
||||
|
||||
_clean_incoming_message(message);
|
||||
mucwin_incoming_msg(mucwin, message, mentions, triggers, TRUE);
|
||||
|
||||
g_slist_free(mentions);
|
||||
|
||||
ProfWin* window = (ProfWin*)mucwin;
|
||||
ProfWin *window = (ProfWin*)mucwin;
|
||||
int num = wins_get_num(window);
|
||||
gboolean is_current = FALSE;
|
||||
|
||||
@ -349,7 +349,7 @@ sv_ev_room_message(ProfMessage* message)
|
||||
beep();
|
||||
}
|
||||
|
||||
// not currently on groupchat window
|
||||
// not currently on groupchat window
|
||||
} else {
|
||||
status_bar_new(num, WIN_MUC, mucwin->roomjid);
|
||||
|
||||
@ -373,10 +373,10 @@ sv_ev_room_message(ProfMessage* message)
|
||||
if (mucwin->last_msg_timestamp) {
|
||||
g_date_time_unref(mucwin->last_msg_timestamp);
|
||||
}
|
||||
mucwin->last_msg_timestamp = g_date_time_new_now_local();
|
||||
mucwin->last_msg_timestamp = g_date_time_new_now_local();
|
||||
|
||||
if (prefs_do_room_notify(is_current, mucwin->roomjid, mynick, message->from_jid->resourcepart, message->plain, mention, triggers != NULL)) {
|
||||
Jid* jidp = jid_create(mucwin->roomjid);
|
||||
Jid *jidp = jid_create(mucwin->roomjid);
|
||||
notify_room_message(message->from_jid->resourcepart, jidp->localpart, num, message->plain);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
@ -393,14 +393,14 @@ sv_ev_room_message(ProfMessage* message)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_incoming_private_message(ProfMessage* message)
|
||||
sv_ev_incoming_private_message(ProfMessage *message)
|
||||
{
|
||||
char* old_plain = message->plain;
|
||||
char *old_plain = message->plain;
|
||||
message->plain = plugins_pre_priv_message_display(message->from_jid->fulljid, message->plain);
|
||||
|
||||
ProfPrivateWin* privatewin = wins_get_private(message->from_jid->fulljid);
|
||||
ProfPrivateWin *privatewin = wins_get_private(message->from_jid->fulljid);
|
||||
if (privatewin == NULL) {
|
||||
ProfWin* window = wins_new_private(message->from_jid->fulljid);
|
||||
ProfWin *window = wins_new_private(message->from_jid->fulljid);
|
||||
privatewin = (ProfPrivateWin*)window;
|
||||
}
|
||||
|
||||
@ -417,14 +417,14 @@ sv_ev_incoming_private_message(ProfMessage* message)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_delayed_private_message(ProfMessage* message)
|
||||
sv_ev_delayed_private_message(ProfMessage *message)
|
||||
{
|
||||
char* old_plain = message->plain;
|
||||
char *old_plain = message->plain;
|
||||
message->plain = plugins_pre_priv_message_display(message->from_jid->fulljid, message->plain);
|
||||
|
||||
ProfPrivateWin* privatewin = wins_get_private(message->from_jid->fulljid);
|
||||
ProfPrivateWin *privatewin = wins_get_private(message->from_jid->fulljid);
|
||||
if (privatewin == NULL) {
|
||||
ProfWin* window = wins_new_private(message->from_jid->fulljid);
|
||||
ProfWin *window = wins_new_private(message->from_jid->fulljid);
|
||||
privatewin = (ProfPrivateWin*)window;
|
||||
}
|
||||
|
||||
@ -439,9 +439,9 @@ sv_ev_delayed_private_message(ProfMessage* message)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_outgoing_carbon(ProfMessage* message)
|
||||
sv_ev_outgoing_carbon(ProfMessage *message)
|
||||
{
|
||||
ProfChatWin* chatwin = wins_get_chat(message->to_jid->barejid);
|
||||
ProfChatWin *chatwin = wins_get_chat(message->to_jid->barejid);
|
||||
if (!chatwin) {
|
||||
chatwin = chatwin_new(message->to_jid->barejid);
|
||||
}
|
||||
@ -482,10 +482,11 @@ sv_ev_outgoing_carbon(ProfMessage* message)
|
||||
chatwin_outgoing_carbon(chatwin, message);
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
_sv_ev_incoming_pgp(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit)
|
||||
_sv_ev_incoming_pgp(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message, gboolean logit)
|
||||
{
|
||||
#ifdef HAVE_LIBGPGME
|
||||
message->plain = p_gpg_decrypt(message->encrypted);
|
||||
@ -517,23 +518,23 @@ _sv_ev_incoming_pgp(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message
|
||||
}
|
||||
|
||||
static void
|
||||
_sv_ev_incoming_ox(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit)
|
||||
_sv_ev_incoming_ox(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message, gboolean logit)
|
||||
{
|
||||
#ifdef HAVE_LIBGPGME
|
||||
//_clean_incoming_message(message);
|
||||
chatwin_incoming_msg(chatwin, message, new_win);
|
||||
log_database_add_incoming(message);
|
||||
if (logit) {
|
||||
chat_log_pgp_msg_in(message);
|
||||
}
|
||||
chatwin->pgp_recv = TRUE;
|
||||
//p_gpg_free_decrypted(message->plain);
|
||||
message->plain = NULL;
|
||||
//_clean_incoming_message(message);
|
||||
chatwin_incoming_msg(chatwin, message, new_win);
|
||||
log_database_add_incoming(message);
|
||||
if (logit) {
|
||||
chat_log_pgp_msg_in(message);
|
||||
}
|
||||
chatwin->pgp_recv = TRUE;
|
||||
//p_gpg_free_decrypted(message->plain);
|
||||
message->plain = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
_sv_ev_incoming_otr(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message)
|
||||
_sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message)
|
||||
{
|
||||
#ifdef HAVE_LIBOTR
|
||||
gboolean decrypted = FALSE;
|
||||
@ -556,12 +557,12 @@ _sv_ev_incoming_otr(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message
|
||||
chatwin->pgp_recv = FALSE;
|
||||
}
|
||||
#else
|
||||
_sv_ev_incoming_plain(chatwin, new_win, message, TRUE);
|
||||
_sv_ev_incoming_plain(chatwin, new_win, message, TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
_sv_ev_incoming_omemo(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit)
|
||||
_sv_ev_incoming_omemo(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message, gboolean logit)
|
||||
{
|
||||
#ifdef HAVE_OMEMO
|
||||
_clean_incoming_message(message);
|
||||
@ -575,7 +576,7 @@ _sv_ev_incoming_omemo(ProfChatWin* chatwin, gboolean new_win, ProfMessage* messa
|
||||
}
|
||||
|
||||
static void
|
||||
_sv_ev_incoming_plain(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit)
|
||||
_sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message, gboolean logit)
|
||||
{
|
||||
if (message->body) {
|
||||
message->enc = PROF_MSG_ENC_NONE;
|
||||
@ -591,14 +592,14 @@ _sv_ev_incoming_plain(ProfChatWin* chatwin, gboolean new_win, ProfMessage* messa
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_incoming_message(ProfMessage* message)
|
||||
sv_ev_incoming_message(ProfMessage *message)
|
||||
{
|
||||
gboolean new_win = FALSE;
|
||||
ProfChatWin* chatwin;
|
||||
char* looking_for_jid = message->from_jid->barejid;
|
||||
ProfChatWin *chatwin;
|
||||
char *looking_for_jid = message->from_jid->barejid;
|
||||
|
||||
if (message->is_mam) {
|
||||
char* mybarejid = connection_get_barejid();
|
||||
char *mybarejid = connection_get_barejid();
|
||||
if (g_strcmp0(mybarejid, message->from_jid->barejid) == 0) {
|
||||
looking_for_jid = message->to_jid->barejid;
|
||||
}
|
||||
@ -608,7 +609,7 @@ sv_ev_incoming_message(ProfMessage* message)
|
||||
chatwin = wins_get_chat(looking_for_jid);
|
||||
|
||||
if (!chatwin) {
|
||||
ProfWin* window = wins_new_chat(looking_for_jid);
|
||||
ProfWin *window = wins_new_chat(looking_for_jid);
|
||||
chatwin = (ProfChatWin*)window;
|
||||
new_win = TRUE;
|
||||
|
||||
@ -622,11 +623,11 @@ sv_ev_incoming_message(ProfMessage* message)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (message->enc == PROF_MSG_ENC_OX) {
|
||||
if( message->enc == PROF_MSG_ENC_OX) {
|
||||
_sv_ev_incoming_ox(chatwin, new_win, message, TRUE);
|
||||
} else if (message->enc == PROF_MSG_ENC_OMEMO) {
|
||||
} else if (message->enc == PROF_MSG_ENC_OMEMO) {
|
||||
_sv_ev_incoming_omemo(chatwin, new_win, message, TRUE);
|
||||
} else if (message->encrypted) {
|
||||
} else if (message->encrypted) {
|
||||
if (chatwin->is_otr) {
|
||||
win_println((ProfWin*)chatwin, THEME_DEFAULT, "-", "PGP encrypted message received whilst in OTR session.");
|
||||
} else {
|
||||
@ -639,15 +640,16 @@ sv_ev_incoming_message(ProfMessage* message)
|
||||
|
||||
rosterwin_roster();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_incoming_carbon(ProfMessage* message)
|
||||
sv_ev_incoming_carbon(ProfMessage *message)
|
||||
{
|
||||
gboolean new_win = FALSE;
|
||||
ProfChatWin* chatwin = wins_get_chat(message->from_jid->barejid);
|
||||
ProfChatWin *chatwin = wins_get_chat(message->from_jid->barejid);
|
||||
if (!chatwin) {
|
||||
ProfWin* window = wins_new_chat(message->from_jid->barejid);
|
||||
ProfWin *window = wins_new_chat(message->from_jid->barejid);
|
||||
chatwin = (ProfChatWin*)window;
|
||||
new_win = TRUE;
|
||||
|
||||
@ -670,12 +672,13 @@ sv_ev_incoming_carbon(ProfMessage* message)
|
||||
}
|
||||
rosterwin_roster();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_message_receipt(const char* const barejid, const char* const id)
|
||||
sv_ev_message_receipt(const char *const barejid, const char *const id)
|
||||
{
|
||||
ProfChatWin* chatwin = wins_get_chat(barejid);
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (!chatwin)
|
||||
return;
|
||||
|
||||
@ -683,7 +686,7 @@ sv_ev_message_receipt(const char* const barejid, const char* const id)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_typing(char* barejid, char* resource)
|
||||
sv_ev_typing(char *barejid, char *resource)
|
||||
{
|
||||
ui_contact_typing(barejid, resource);
|
||||
if (wins_chat_exists(barejid)) {
|
||||
@ -692,7 +695,7 @@ sv_ev_typing(char* barejid, char* resource)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_paused(char* barejid, char* resource)
|
||||
sv_ev_paused(char *barejid, char *resource)
|
||||
{
|
||||
if (wins_chat_exists(barejid)) {
|
||||
chat_session_recipient_paused(barejid, resource);
|
||||
@ -700,7 +703,7 @@ sv_ev_paused(char* barejid, char* resource)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_inactive(char* barejid, char* resource)
|
||||
sv_ev_inactive(char *barejid, char *resource)
|
||||
{
|
||||
if (wins_chat_exists(barejid)) {
|
||||
chat_session_recipient_inactive(barejid, resource);
|
||||
@ -708,14 +711,14 @@ sv_ev_inactive(char* barejid, char* resource)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_gone(const char* const barejid, const char* const resource)
|
||||
sv_ev_gone(const char *const barejid, const char *const resource)
|
||||
{
|
||||
if (barejid && resource) {
|
||||
gboolean show_message = TRUE;
|
||||
|
||||
ProfChatWin* chatwin = wins_get_chat(barejid);
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin) {
|
||||
ChatSession* session = chat_session_get(barejid);
|
||||
ChatSession *session = chat_session_get(barejid);
|
||||
if (session && g_strcmp0(session->resource, resource) != 0) {
|
||||
show_message = FALSE;
|
||||
}
|
||||
@ -731,7 +734,7 @@ sv_ev_gone(const char* const barejid, const char* const resource)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_activity(const char* const barejid, const char* const resource, gboolean send_states)
|
||||
sv_ev_activity(const char *const barejid, const char *const resource, gboolean send_states)
|
||||
{
|
||||
if (wins_chat_exists(barejid)) {
|
||||
chat_session_recipient_active(barejid, resource, send_states);
|
||||
@ -739,7 +742,7 @@ sv_ev_activity(const char* const barejid, const char* const resource, gboolean s
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_subscription(const char* barejid, jabber_subscr_t type)
|
||||
sv_ev_subscription(const char *barejid, jabber_subscr_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case PRESENCE_SUBSCRIBE:
|
||||
@ -772,7 +775,7 @@ sv_ev_subscription(const char* barejid, jabber_subscr_t type)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_contact_offline(char* barejid, char* resource, char* status)
|
||||
sv_ev_contact_offline(char *barejid, char *resource, char *status)
|
||||
{
|
||||
gboolean updated = roster_contact_offline(barejid, resource, status);
|
||||
|
||||
@ -782,7 +785,7 @@ sv_ev_contact_offline(char* barejid, char* resource, char* status)
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBOTR
|
||||
ProfChatWin* chatwin = wins_get_chat(barejid);
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
if (chatwin && otr_is_secure(barejid)) {
|
||||
chatwin_otr_unsecured(chatwin);
|
||||
otr_end_session(chatwin->barejid);
|
||||
@ -794,13 +797,13 @@ sv_ev_contact_offline(char* barejid, char* resource, char* status)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_contact_online(char* barejid, Resource* resource, GDateTime* last_activity, char* pgpsig)
|
||||
sv_ev_contact_online(char *barejid, Resource *resource, GDateTime *last_activity, char *pgpsig)
|
||||
{
|
||||
gboolean updated = roster_update_presence(barejid, resource, last_activity);
|
||||
|
||||
if (updated) {
|
||||
plugins_on_contact_presence(barejid, resource->name, string_from_resource_presence(resource->presence),
|
||||
resource->status, resource->priority);
|
||||
resource->status, resource->priority);
|
||||
ui_contact_online(barejid, resource, last_activity);
|
||||
}
|
||||
|
||||
@ -815,56 +818,56 @@ sv_ev_contact_online(char* barejid, Resource* resource, GDateTime* last_activity
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_leave_room(const char* const room)
|
||||
sv_ev_leave_room(const char *const room)
|
||||
{
|
||||
muc_leave(room);
|
||||
ui_leave_room(room);
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_room_destroy(const char* const room)
|
||||
sv_ev_room_destroy(const char *const room)
|
||||
{
|
||||
muc_leave(room);
|
||||
ui_room_destroy(room);
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_room_destroyed(const char* const room, const char* const new_jid, const char* const password,
|
||||
const char* const reason)
|
||||
sv_ev_room_destroyed(const char *const room, const char *const new_jid, const char *const password,
|
||||
const char *const reason)
|
||||
{
|
||||
muc_leave(room);
|
||||
ui_room_destroyed(room, reason, new_jid, password);
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_room_kicked(const char* const room, const char* const actor, const char* const reason)
|
||||
sv_ev_room_kicked(const char *const room, const char *const actor, const char *const reason)
|
||||
{
|
||||
muc_leave(room);
|
||||
ui_room_kicked(room, actor, reason);
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_room_banned(const char* const room, const char* const actor, const char* const reason)
|
||||
sv_ev_room_banned(const char *const room, const char *const actor, const char *const reason)
|
||||
{
|
||||
muc_leave(room);
|
||||
ui_room_banned(room, actor, reason);
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_room_occupant_offline(const char* const room, const char* const nick,
|
||||
const char* const show, const char* const status)
|
||||
sv_ev_room_occupant_offline(const char *const room, const char *const nick,
|
||||
const char *const show, const char *const status)
|
||||
{
|
||||
muc_roster_remove(room, nick);
|
||||
|
||||
char* muc_status_pref = prefs_get_string(PREF_STATUSES_MUC);
|
||||
ProfMucWin* mucwin = wins_get_muc(room);
|
||||
char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC);
|
||||
ProfMucWin *mucwin = wins_get_muc(room);
|
||||
if (mucwin && (g_strcmp0(muc_status_pref, "none") != 0)) {
|
||||