mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
g_free()
to auto_gfree
, introduce auto_guchar
Fix 11 potential mem leaks in theme.c
This commit is contained in:
parent
3a4cd7da48
commit
8304ac86ff
@ -4387,9 +4387,8 @@ _url_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
if ((num_args == 1 && space_at_end) || (num_args == 2 && !space_at_end)) {
|
||||
result = autocomplete_param_with_func(input, "/url save", wins_get_url, previous, window);
|
||||
} else if ((num_args == 2 && space_at_end) || (num_args == 3 && !space_at_end)) {
|
||||
gchar* cmd = g_strdup_printf("/url save %s", args[1]);
|
||||
auto_gchar gchar* cmd = g_strdup_printf("/url save %s", args[1]);
|
||||
result = cmd_ac_complete_filepath(input, cmd, previous);
|
||||
g_free(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3039,14 +3039,13 @@ command_mangen(void)
|
||||
create_dir("docs");
|
||||
|
||||
GDateTime* now = g_date_time_new_now_local();
|
||||
gchar* date = g_date_time_format(now, "%F");
|
||||
gchar* header = g_strdup_printf(".TH man 1 \"%s\" \"" PACKAGE_VERSION "\" \"Profanity XMPP client\"\n", date);
|
||||
auto_gchar gchar* date = g_date_time_format(now, "%F");
|
||||
auto_gchar gchar* header = g_strdup_printf(".TH man 1 \"%s\" \"" PACKAGE_VERSION "\" \"Profanity XMPP client\"\n", date);
|
||||
if (!header) {
|
||||
log_error("command_mangen(): could not allocate memory");
|
||||
return;
|
||||
}
|
||||
g_date_time_unref(now);
|
||||
g_free(date);
|
||||
|
||||
GList* curr = cmds;
|
||||
while (curr) {
|
||||
@ -3098,6 +3097,5 @@ command_mangen(void)
|
||||
|
||||
printf("\nProcessed %d commands.\n\n", g_list_length(cmds));
|
||||
|
||||
g_free(header);
|
||||
g_list_free(cmds);
|
||||
}
|
||||
|
@ -3635,7 +3635,7 @@ cmd_join(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char* room = NULL;
|
||||
auto_gchar gchar* room = NULL;
|
||||
char* nick = NULL;
|
||||
char* passwd = NULL;
|
||||
char* account_name = session_get_account_name();
|
||||
@ -3663,7 +3663,6 @@ cmd_join(ProfWin* window, const char* const command, gchar** args)
|
||||
if (!parsed) {
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("");
|
||||
g_free(room);
|
||||
jid_destroy(room_arg);
|
||||
return TRUE;
|
||||
}
|
||||
@ -3693,7 +3692,6 @@ cmd_join(ProfWin* window, const char* const command, gchar** args)
|
||||
ui_switch_to_room(room);
|
||||
}
|
||||
|
||||
g_free(room);
|
||||
jid_destroy(room_arg);
|
||||
account_free(account);
|
||||
|
||||
@ -4578,8 +4576,8 @@ cmd_rooms(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gchar* service = NULL;
|
||||
gchar* filter = NULL;
|
||||
auto_gchar gchar* service = NULL;
|
||||
auto_gchar gchar* filter = NULL;
|
||||
if (args[0] != NULL) {
|
||||
if (g_strcmp0(args[0], "service") == 0) {
|
||||
if (args[1] == NULL) {
|
||||
@ -4628,8 +4626,6 @@ cmd_rooms(ProfWin* window, const char* const command, gchar** args)
|
||||
if (args[3] == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("");
|
||||
g_free(service);
|
||||
g_free(filter);
|
||||
return TRUE;
|
||||
}
|
||||
g_free(service);
|
||||
@ -4638,8 +4634,6 @@ cmd_rooms(ProfWin* window, const char* const command, gchar** args)
|
||||
if (args[3] == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("");
|
||||
g_free(service);
|
||||
g_free(filter);
|
||||
return TRUE;
|
||||
}
|
||||
g_free(filter);
|
||||
@ -4647,8 +4641,6 @@ cmd_rooms(ProfWin* window, const char* const command, gchar** args)
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("");
|
||||
g_free(service);
|
||||
g_free(filter);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@ -4661,8 +4653,6 @@ cmd_rooms(ProfWin* window, const char* const command, gchar** args)
|
||||
} else {
|
||||
cons_show("Account MUC service property not found.");
|
||||
account_free(account);
|
||||
g_free(service);
|
||||
g_free(filter);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@ -4675,9 +4665,6 @@ cmd_rooms(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
iq_room_list_request(service, filter);
|
||||
|
||||
g_free(service);
|
||||
g_free(filter);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -9680,11 +9667,9 @@ _cmd_executable_template(const preference_t setting, const char* command, gchar*
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[1], "set") == 0 && num_args >= 3) {
|
||||
gchar* str = g_strjoinv(" ", &args[2]);
|
||||
auto_gchar gchar* str = g_strjoinv(" ", &args[2]);
|
||||
prefs_set_string(setting, str);
|
||||
cons_show("`%s` command set to invoke '%s'", command, str);
|
||||
g_free(str);
|
||||
|
||||
} else if (g_strcmp0(args[1], "default") == 0) {
|
||||
prefs_set_string(setting, NULL);
|
||||
auto_gchar gchar* def = prefs_get_string(setting);
|
||||
@ -10129,7 +10114,7 @@ cmd_vcard_photo(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char* jid = NULL;
|
||||
auto_gchar gchar* jid = NULL;
|
||||
char* filepath = NULL;
|
||||
int index = 0;
|
||||
|
||||
@ -10241,9 +10226,6 @@ cmd_vcard_photo(ProfWin* window, const char* const command, gchar** args)
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
|
||||
if (!jidless) {
|
||||
g_free(jid);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
26
src/common.c
26
src/common.c
@ -78,6 +78,15 @@ auto_free_gchar(gchar** str)
|
||||
g_free(*str);
|
||||
}
|
||||
|
||||
void
|
||||
auto_free_guchar(guchar** ptr)
|
||||
{
|
||||
if (ptr == NULL) {
|
||||
return;
|
||||
}
|
||||
g_free(*ptr);
|
||||
}
|
||||
|
||||
void
|
||||
auto_free_gcharv(gchar*** args)
|
||||
{
|
||||
@ -545,16 +554,14 @@ basename_from_url(const char* url)
|
||||
const char* default_name = "index";
|
||||
|
||||
GFile* file = g_file_new_for_commandline_arg(url);
|
||||
char* basename = g_file_get_basename(file);
|
||||
|
||||
if (_has_directory_suffix(basename)) {
|
||||
g_free(basename);
|
||||
basename = strdup(default_name);
|
||||
}
|
||||
|
||||
auto_gchar gchar* basename = g_file_get_basename(file);
|
||||
g_object_unref(file);
|
||||
|
||||
return basename;
|
||||
if (_has_directory_suffix(basename)) {
|
||||
return strdup(default_name);
|
||||
}
|
||||
|
||||
return strdup(basename);
|
||||
}
|
||||
|
||||
gchar*
|
||||
@ -589,9 +596,8 @@ unique_filename_from_url(const char* url, const char* path)
|
||||
if (_has_directory_suffix(realpath) || g_file_test(realpath, G_FILE_TEST_IS_DIR)) {
|
||||
// The target should be used as a directory. Assume that the basename
|
||||
// should be derived from the URL.
|
||||
char* basename = basename_from_url(url);
|
||||
auto_char char* basename = basename_from_url(url);
|
||||
filename = g_build_filename(g_file_peek_path(target), basename, NULL);
|
||||
g_free(basename);
|
||||
} else {
|
||||
// Just use the target as filename.
|
||||
filename = g_build_filename(g_file_peek_path(target), NULL);
|
||||
|
22
src/common.h
22
src/common.h
@ -31,6 +31,9 @@
|
||||
* statement from your version. If you delete this exception statement from all
|
||||
* source files in the program, then also delete it here.
|
||||
*
|
||||
* @file common.h
|
||||
*
|
||||
* @brief Common utilities for the project.
|
||||
*/
|
||||
|
||||
#ifndef COMMON_H
|
||||
@ -56,6 +59,25 @@ void auto_free_gcharv(gchar*** args);
|
||||
#define auto_gcharv __attribute__((__cleanup__(auto_free_gcharv)))
|
||||
void auto_free_char(char** str);
|
||||
#define auto_char __attribute__((__cleanup__(auto_free_char)))
|
||||
/**
|
||||
* Frees the memory allocated for a guchar* string.
|
||||
*
|
||||
* @param str Pointer to the guchar* string to be freed. If NULL, no action is taken.
|
||||
*/
|
||||
void auto_free_guchar(guchar** str);
|
||||
|
||||
/**
|
||||
* @brief Macro for automatically freeing a guchar* string when it goes out of scope.
|
||||
*
|
||||
* This macro is used to automatically free a guchar* string when it goes out of scope.
|
||||
* It utilizes the `auto_free_guchar` function and should be placed before the variable declaration.
|
||||
*
|
||||
* Example usage:
|
||||
* ```
|
||||
* auto_guchar guchar* myString = g_base64_decode("SGVsbG8sIHdvcmxkIQ==", NULL);
|
||||
* ```
|
||||
*/
|
||||
#define auto_guchar __attribute__((__cleanup__(auto_free_guchar)))
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
#define STR_MAYBE_NULL(p) (p) ?: "(null)"
|
||||
|
@ -127,7 +127,7 @@ accounts_add(const char* account_name, const char* altdomain, const int port, co
|
||||
{
|
||||
// set account name and resource
|
||||
const char* barejid = account_name;
|
||||
char* resource = jid_random_resource();
|
||||
auto_gchar gchar* resource = jid_random_resource();
|
||||
Jid* jid = jid_create(account_name);
|
||||
if (jid) {
|
||||
barejid = jid->barejid;
|
||||
@ -137,7 +137,6 @@ accounts_add(const char* account_name, const char* altdomain, const int port, co
|
||||
}
|
||||
|
||||
if (g_key_file_has_group(accounts, account_name)) {
|
||||
g_free(resource);
|
||||
jid_destroy(jid);
|
||||
return;
|
||||
}
|
||||
@ -181,7 +180,6 @@ accounts_add(const char* account_name, const char* altdomain, const int port, co
|
||||
autocomplete_add(enabled_ac, account_name);
|
||||
|
||||
jid_destroy(jid);
|
||||
g_free(resource);
|
||||
}
|
||||
|
||||
int
|
||||
@ -433,10 +431,9 @@ accounts_rename(const char* const account_name, const char* const new_name)
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(string_keys); i++) {
|
||||
char* value = g_key_file_get_string(accounts, account_name, string_keys[i], NULL);
|
||||
auto_gchar gchar* 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -868,7 +865,7 @@ accounts_set_last_activity(const char* const account_name)
|
||||
}
|
||||
}
|
||||
|
||||
char*
|
||||
gchar*
|
||||
accounts_get_last_activity(const char* const account_name)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
@ -878,7 +875,7 @@ accounts_get_last_activity(const char* const account_name)
|
||||
}
|
||||
}
|
||||
|
||||
char*
|
||||
gchar*
|
||||
accounts_get_resource(const char* const account_name)
|
||||
{
|
||||
if (!accounts_account_exists(account_name)) {
|
||||
@ -909,7 +906,7 @@ resource_presence_t
|
||||
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);
|
||||
auto_gchar gchar* setting = g_key_file_get_string(accounts, account_name, "presence.last", NULL);
|
||||
|
||||
if (setting == NULL || (strcmp(setting, "online") == 0)) {
|
||||
result = RESOURCE_ONLINE;
|
||||
@ -927,7 +924,6 @@ accounts_get_last_presence(const char* const account_name)
|
||||
result = RESOURCE_ONLINE;
|
||||
}
|
||||
|
||||
g_free(setting);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ 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);
|
||||
char* accounts_get_resource(const char* const account_name);
|
||||
gchar* accounts_get_resource(const char* const account_name);
|
||||
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);
|
||||
@ -72,7 +72,7 @@ void accounts_set_auth_policy(const char* const account_name, const char* const
|
||||
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);
|
||||
gchar* 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);
|
||||
|
@ -64,30 +64,27 @@ cafile_add(const TLSCertificate* cert)
|
||||
log_error("[CAfile] can't store cert with fingerprint %s: PEM is empty", cert->fingerprint);
|
||||
return;
|
||||
}
|
||||
gchar* cafile = _cafile_name();
|
||||
auto_gchar gchar* cafile = _cafile_name();
|
||||
if (!cafile)
|
||||
return;
|
||||
gchar *contents = NULL, *new_contents = NULL;
|
||||
auto_gchar gchar* contents = NULL;
|
||||
auto_gchar gchar* new_contents = NULL;
|
||||
gsize length;
|
||||
GError* glib_error = NULL;
|
||||
if (g_file_test(cafile, G_FILE_TEST_EXISTS)) {
|
||||
if (!g_file_get_contents(cafile, &contents, &length, &glib_error)) {
|
||||
log_error("[CAfile] could not read from %s: %s", cafile, glib_error ? glib_error->message : "No GLib error given");
|
||||
goto out;
|
||||
return;
|
||||
}
|
||||
if (strstr(contents, cert->fingerprint)) {
|
||||
log_debug("[CAfile] fingerprint %s already stored", cert->fingerprint);
|
||||
goto out;
|
||||
return;
|
||||
}
|
||||
}
|
||||
const char* header = "# Profanity CAfile\n# DO NOT EDIT - this file is automatically generated";
|
||||
new_contents = g_strdup_printf("%s\n\n# %s\n%s", contents ? contents : header, cert->fingerprint, cert->pem);
|
||||
if (!g_file_set_contents(cafile, new_contents, -1, &glib_error))
|
||||
log_error("[CAfile] could not write to %s: %s", cafile, glib_error ? glib_error->message : "No GLib error given");
|
||||
out:
|
||||
g_free(new_contents);
|
||||
g_free(contents);
|
||||
g_free(cafile);
|
||||
}
|
||||
|
||||
gchar*
|
||||
|
@ -53,8 +53,8 @@ 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();
|
||||
auto_gchar gchar* xdg_config = _files_get_xdg_config_home();
|
||||
auto_gchar gchar* xdg_data = _files_get_xdg_data_home();
|
||||
|
||||
GString* themes_dir = g_string_new(xdg_config);
|
||||
g_string_append(themes_dir, "/profanity/themes");
|
||||
@ -88,17 +88,13 @@ files_create_directories(void)
|
||||
g_string_free(chatlogs_dir, TRUE);
|
||||
g_string_free(logs_dir, TRUE);
|
||||
g_string_free(plugins_dir, TRUE);
|
||||
|
||||
g_free(xdg_config);
|
||||
g_free(xdg_data);
|
||||
}
|
||||
|
||||
gchar*
|
||||
files_get_inputrc_file(void)
|
||||
{
|
||||
gchar* xdg_config = _files_get_xdg_config_home();
|
||||
auto_gchar 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");
|
||||
|
||||
@ -121,11 +117,10 @@ files_get_log_file(const char* const log_file)
|
||||
GString* logfile;
|
||||
|
||||
if (log_file) {
|
||||
gchar* log_path = g_path_get_dirname(log_file);
|
||||
auto_gchar gchar* log_path = g_path_get_dirname(log_file);
|
||||
if (!create_dir(log_path)) {
|
||||
log_error("Error while creating directory %s", log_path);
|
||||
}
|
||||
g_free(log_path);
|
||||
|
||||
logfile = g_string_new(log_file);
|
||||
} else {
|
||||
@ -149,9 +144,8 @@ files_get_log_file(const char* const log_file)
|
||||
gchar*
|
||||
files_get_config_path(const char* const config_base)
|
||||
{
|
||||
gchar* xdg_config = _files_get_xdg_config_home();
|
||||
auto_gchar gchar* xdg_config = _files_get_xdg_config_home();
|
||||
gchar* result = g_strdup_printf("%s/profanity/%s", xdg_config, config_base);
|
||||
g_free(xdg_config);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -237,10 +237,9 @@ GSList*
|
||||
theme_list(void)
|
||||
{
|
||||
GSList* result = NULL;
|
||||
gchar* themes_dir = files_get_config_path(DIR_THEMES);
|
||||
auto_gchar gchar* themes_dir = files_get_config_path(DIR_THEMES);
|
||||
|
||||
_theme_list_dir(themes_dir, &result);
|
||||
g_free(themes_dir);
|
||||
|
||||
#ifdef THEMES_PATH
|
||||
_theme_list_dir(THEMES_PATH, &result);
|
||||
@ -281,9 +280,8 @@ static void
|
||||
_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);
|
||||
auto_gchar gchar* val = g_key_file_get_string(theme, "ui", prefstr, NULL);
|
||||
prefs_set_string(pref, val);
|
||||
g_free(val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,100 +406,88 @@ _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);
|
||||
auto_gchar gchar* ch = g_key_file_get_string(theme, "ui", "occupants.char", NULL);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_occupants_char(ch);
|
||||
g_free(ch);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
auto_gchar gchar* ch = g_key_file_get_string(theme, "ui", "occupants.header.char", NULL);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_occupants_header_char(ch);
|
||||
g_free(ch);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
auto_gchar gchar* ch = g_key_file_get_string(theme, "ui", "roster.header.char", NULL);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_roster_header_char(ch);
|
||||
g_free(ch);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
auto_gchar gchar* ch = g_key_file_get_string(theme, "ui", "roster.contact.char", NULL);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_roster_contact_char(ch);
|
||||
g_free(ch);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
auto_gchar gchar* ch = g_key_file_get_string(theme, "ui", "roster.resource.char", NULL);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_roster_resource_char(ch);
|
||||
g_free(ch);
|
||||
}
|
||||
} else {
|
||||
prefs_clear_roster_resource_char();
|
||||
}
|
||||
|
||||
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);
|
||||
auto_gchar gchar* ch = g_key_file_get_string(theme, "ui", "roster.rooms.char", NULL);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_roster_room_char(ch);
|
||||
g_free(ch);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
auto_gchar gchar* ch = g_key_file_get_string(theme, "ui", "roster.rooms.private.char", NULL);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_roster_room_private_char(ch);
|
||||
g_free(ch);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
auto_gchar gchar* ch = g_key_file_get_string(theme, "ui", "roster.private.char", NULL);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_roster_private_char(ch);
|
||||
g_free(ch);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "otr.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "otr.char", NULL);
|
||||
auto_gchar 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);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "pgp.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "pgp.char", NULL);
|
||||
auto_gchar 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);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "omemo.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "omemo.char", NULL);
|
||||
auto_gchar 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);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "correction.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "correction.char", NULL);
|
||||
auto_gchar 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -538,11 +524,10 @@ static GString*
|
||||
_theme_find(const char* const theme_name)
|
||||
{
|
||||
GString* path = NULL;
|
||||
gchar* themes_dir = files_get_config_path(DIR_THEMES);
|
||||
auto_gchar gchar* themes_dir = files_get_config_path(DIR_THEMES);
|
||||
|
||||
if (themes_dir) {
|
||||
path = g_string_new(themes_dir);
|
||||
g_free(themes_dir);
|
||||
g_string_append(path, "/");
|
||||
g_string_append(path, theme_name);
|
||||
if (!g_file_test(path->str, G_FILE_TEST_EXISTS)) {
|
||||
@ -641,7 +626,7 @@ theme_main_presence_attrs(const char* const presence)
|
||||
static void
|
||||
_theme_prep_bgnd(char* setting, char* def, GString* lookup_str)
|
||||
{
|
||||
gchar* val = g_key_file_get_string(theme, "colours", setting, NULL);
|
||||
auto_gchar gchar* val = g_key_file_get_string(theme, "colours", setting, NULL);
|
||||
if (!val) {
|
||||
g_string_append(lookup_str, def);
|
||||
} else {
|
||||
@ -651,7 +636,6 @@ _theme_prep_bgnd(char* setting, char* def, GString* lookup_str)
|
||||
g_string_append(lookup_str, val);
|
||||
}
|
||||
}
|
||||
g_free(val);
|
||||
}
|
||||
|
||||
/* return value needs to be freed */
|
||||
@ -666,7 +650,7 @@ theme_get_bkgnd(void)
|
||||
static void
|
||||
_theme_prep_fgnd(char* setting, GString* lookup_str, gboolean* bold)
|
||||
{
|
||||
gchar* conf_str = g_key_file_get_string(theme, "colours", setting, NULL);
|
||||
auto_gchar gchar* conf_str = g_key_file_get_string(theme, "colours", setting, NULL);
|
||||
gchar* val = conf_str;
|
||||
|
||||
if (!val)
|
||||
@ -679,8 +663,6 @@ _theme_prep_fgnd(char* setting, GString* lookup_str, gboolean* bold)
|
||||
g_string_append(lookup_str, val);
|
||||
*bold = FALSE;
|
||||
}
|
||||
|
||||
g_free(conf_str);
|
||||
}
|
||||
|
||||
char*
|
||||
|
@ -387,8 +387,7 @@ static void
|
||||
_save_tlscerts(void)
|
||||
{
|
||||
gsize g_data_size;
|
||||
gchar* g_tlscerts_data = g_key_file_to_data(tlscerts, &g_data_size, NULL);
|
||||
auto_gchar 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);
|
||||
}
|
||||
|
@ -260,11 +260,10 @@ log_database_get_previous_chat(const gchar* const contact_barejid, const char* s
|
||||
gchar* sort1 = from_start ? "ASC" : "DESC";
|
||||
gchar* sort2 = !flip ? "ASC" : "DESC";
|
||||
GDateTime* now = g_date_time_new_now_local();
|
||||
gchar* end_date_fmt = end_time ? end_time : g_date_time_format_iso8601(now);
|
||||
auto_gchar gchar* end_date_fmt = end_time ? end_time : g_date_time_format_iso8601(now);
|
||||
auto_sqlite gchar* query = sqlite3_mprintf("SELECT * FROM (SELECT COALESCE(B.`message`, A.`message`) AS message, A.`timestamp`, A.`from_jid`, A.`type`, A.`encryption` from `ChatLogs` AS A LEFT JOIN `ChatLogs` AS B ON A.`stanza_id` = B.`replace_id` WHERE A.`replace_id` = '' AND ((A.`from_jid` = '%q' AND A.`to_jid` = '%q') OR (A.`from_jid` = '%q' AND A.`to_jid` = '%q')) AND A.`timestamp` < '%q' AND (%Q IS NULL OR A.`timestamp` > %Q) ORDER BY A.`timestamp` %s LIMIT %d) ORDER BY `timestamp` %s;", contact_barejid, myjid->barejid, myjid->barejid, contact_barejid, end_date_fmt, start_time, start_time, sort1, MESSAGES_TO_RETRIEVE, sort2);
|
||||
|
||||
g_date_time_unref(now);
|
||||
g_free(end_date_fmt);
|
||||
|
||||
if (!query) {
|
||||
log_error("log_database_get_previous_chat(): SQL query. could not allocate memory");
|
||||
@ -389,7 +388,7 @@ _add_to_db(ProfMessage* message, char* type, const Jid* const from_jid, const Ji
|
||||
|
||||
char* err_msg;
|
||||
gchar* query;
|
||||
gchar* date_fmt;
|
||||
auto_gchar gchar* date_fmt;
|
||||
|
||||
if (message->timestamp) {
|
||||
date_fmt = g_date_time_format_iso8601(message->timestamp);
|
||||
@ -423,7 +422,6 @@ _add_to_db(ProfMessage* message, char* type, const Jid* const from_jid, const Ji
|
||||
log_error("log_database_add(): SQL query. could not allocate memory");
|
||||
return;
|
||||
}
|
||||
g_free(date_fmt);
|
||||
|
||||
if (SQLITE_OK != sqlite3_exec(g_chatlog_database, query, NULL, 0, &err_msg)) {
|
||||
if (err_msg) {
|
||||
|
@ -169,8 +169,8 @@ 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* status_message = accounts_get_login_status(account_name);
|
||||
auto_gchar gchar* last_activity_str = accounts_get_last_activity(account_name);
|
||||
auto_gchar gchar* status_message = accounts_get_login_status(account_name);
|
||||
int diff_secs = 0;
|
||||
|
||||
if (prefs_get_boolean(PREF_LASTACTIVITY) && last_activity_str) {
|
||||
@ -190,9 +190,6 @@ sv_ev_roster_received(void)
|
||||
connection_set_presence_msg(status_message);
|
||||
cl_ev_presence_send(conn_presence, diff_secs);
|
||||
|
||||
g_free(status_message);
|
||||
g_free(last_activity_str);
|
||||
|
||||
const char* fulljid = connection_get_fulljid();
|
||||
plugins_on_connect(account_name, fulljid);
|
||||
}
|
||||
@ -278,7 +275,7 @@ sv_ev_room_history(ProfMessage* message)
|
||||
// check if this message was sent while we were offline.
|
||||
// if so, treat it as a new message rather than a history event.
|
||||
char* account_name = session_get_account_name();
|
||||
char* last_activity = accounts_get_last_activity(account_name);
|
||||
auto_gchar gchar* last_activity = accounts_get_last_activity(account_name);
|
||||
int msg_is_new = 0;
|
||||
|
||||
if (last_activity) {
|
||||
@ -292,7 +289,6 @@ sv_ev_room_history(ProfMessage* message)
|
||||
msg_is_new = (time_diff > 0);
|
||||
g_date_time_unref(lastdt);
|
||||
}
|
||||
g_free(last_activity);
|
||||
|
||||
if (msg_is_new) {
|
||||
sv_ev_room_message(message);
|
||||
|
@ -214,13 +214,12 @@ log_msg(log_level_t level, const char* const area, const char* const msg)
|
||||
|
||||
char* level_str = _log_abbreviation_string_from_level(level);
|
||||
|
||||
gchar* date_fmt = g_date_time_format_iso8601(dt);
|
||||
auto_gchar gchar* date_fmt = g_date_time_format_iso8601(dt);
|
||||
|
||||
fprintf(logp, "%s: %s: %s: %s\n", date_fmt, area, level_str, msg);
|
||||
g_date_time_unref(dt);
|
||||
|
||||
fflush(logp);
|
||||
g_free(date_fmt);
|
||||
|
||||
if (prefs_get_boolean(PREF_LOG_ROTATE) && !user_provided_log) {
|
||||
long result = ftell(logp);
|
||||
|
@ -230,7 +230,7 @@ omemo_on_connect(ProfAccount* account)
|
||||
omemo_ctx.device_list_handler = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
|
||||
omemo_ctx.known_devices = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)glib_hash_table_free);
|
||||
|
||||
gchar* omemo_dir = files_file_in_account_data_path(DIR_OMEMO, account->jid, NULL);
|
||||
auto_gchar gchar* omemo_dir = files_file_in_account_data_path(DIR_OMEMO, account->jid, NULL);
|
||||
if (!omemo_dir) {
|
||||
log_error("[OMEMO] failed creating directory");
|
||||
return;
|
||||
@ -245,8 +245,6 @@ omemo_on_connect(ProfAccount* account)
|
||||
omemo_ctx.known_devices_filename = g_string_new(omemo_dir);
|
||||
g_string_append(omemo_ctx.known_devices_filename, "/known_devices.txt");
|
||||
|
||||
g_free(omemo_dir);
|
||||
|
||||
omemo_devicelist_subscribe();
|
||||
|
||||
omemo_ctx.identity_keyfile = g_key_file_new();
|
||||
@ -1535,7 +1533,7 @@ _load_identity(void)
|
||||
}
|
||||
|
||||
size_t identity_key_public_len;
|
||||
unsigned char* identity_key_public = g_base64_decode(identity_key_public_b64, &identity_key_public_len);
|
||||
auto_guchar guchar* identity_key_public = g_base64_decode(identity_key_public_b64, &identity_key_public_len);
|
||||
omemo_ctx.identity_key_store.public = signal_buffer_create(identity_key_public, identity_key_public_len);
|
||||
|
||||
error = NULL;
|
||||
@ -1546,7 +1544,7 @@ _load_identity(void)
|
||||
}
|
||||
|
||||
size_t identity_key_private_len;
|
||||
unsigned char* identity_key_private = g_base64_decode(identity_key_private_b64, &identity_key_private_len);
|
||||
auto_guchar guchar* identity_key_private = g_base64_decode(identity_key_private_b64, &identity_key_private_len);
|
||||
omemo_ctx.identity_key_store.private = signal_buffer_create(identity_key_private, identity_key_private_len);
|
||||
|
||||
ec_public_key* public_key;
|
||||
@ -1555,9 +1553,6 @@ _load_identity(void)
|
||||
curve_decode_private_point(&private_key, identity_key_private, identity_key_private_len, omemo_ctx.signal);
|
||||
ratchet_identity_key_pair_create(&omemo_ctx.identity_key_pair, public_key, private_key);
|
||||
|
||||
g_free(identity_key_public);
|
||||
g_free(identity_key_private);
|
||||
|
||||
char** keys = NULL;
|
||||
int i;
|
||||
/* Pre keys */
|
||||
@ -1567,9 +1562,8 @@ _load_identity(void)
|
||||
for (i = 0; keys[i] != NULL; i++) {
|
||||
auto_gchar gchar* pre_key_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_PREKEYS, keys[i], NULL);
|
||||
size_t pre_key_len;
|
||||
unsigned char* pre_key = g_base64_decode(pre_key_b64, &pre_key_len);
|
||||
auto_guchar guchar* pre_key = g_base64_decode(pre_key_b64, &pre_key_len);
|
||||
signal_buffer* buffer = signal_buffer_create(pre_key, pre_key_len);
|
||||
g_free(pre_key);
|
||||
g_hash_table_insert(omemo_ctx.pre_key_store, GINT_TO_POINTER(strtoul(keys[i], NULL, 10)), buffer);
|
||||
}
|
||||
|
||||
@ -1588,9 +1582,8 @@ _load_identity(void)
|
||||
for (i = 0; keys[i] != NULL; i++) {
|
||||
auto_gchar gchar* signed_pre_key_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_SIGNED_PREKEYS, keys[i], NULL);
|
||||
size_t signed_pre_key_len;
|
||||
unsigned char* signed_pre_key = g_base64_decode(signed_pre_key_b64, &signed_pre_key_len);
|
||||
auto_guchar guchar* signed_pre_key = g_base64_decode(signed_pre_key_b64, &signed_pre_key_len);
|
||||
signal_buffer* buffer = signal_buffer_create(signed_pre_key, signed_pre_key_len);
|
||||
g_free(signed_pre_key);
|
||||
g_hash_table_insert(omemo_ctx.signed_pre_key_store, GINT_TO_POINTER(strtoul(keys[i], NULL, 10)), buffer);
|
||||
omemo_ctx.signed_pre_key_id = strtoul(keys[i], NULL, 10);
|
||||
}
|
||||
@ -1630,9 +1623,8 @@ _load_trust(void)
|
||||
for (j = 0; keys[j] != NULL; j++) {
|
||||
auto_gchar gchar* key_b64 = g_key_file_get_string(omemo_ctx.trust_keyfile, groups[i], keys[j], NULL);
|
||||
size_t key_len;
|
||||
unsigned char* key = g_base64_decode(key_b64, &key_len);
|
||||
auto_guchar guchar* key = g_base64_decode(key_b64, &key_len);
|
||||
signal_buffer* buffer = signal_buffer_create(key, key_len);
|
||||
g_free(key);
|
||||
uint32_t device_id = strtoul(keys[j], NULL, 10);
|
||||
g_hash_table_insert(trusted, GINT_TO_POINTER(device_id), buffer);
|
||||
}
|
||||
@ -1663,9 +1655,8 @@ _load_sessions(void)
|
||||
uint32_t id = strtoul(keys[j], NULL, 10);
|
||||
auto_gchar gchar* record_b64 = g_key_file_get_string(omemo_ctx.sessions_keyfile, groups[i], keys[j], NULL);
|
||||
size_t record_len;
|
||||
unsigned char* record = g_base64_decode(record_b64, &record_len);
|
||||
auto_guchar guchar* record = g_base64_decode(record_b64, &record_len);
|
||||
signal_buffer* buffer = signal_buffer_create(record, record_len);
|
||||
g_free(record);
|
||||
g_hash_table_insert(device_store, GINT_TO_POINTER(id), buffer);
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ otr_on_connect(ProfAccount* account)
|
||||
jid = strdup(account->jid);
|
||||
log_info("Loading OTR key for %s", jid);
|
||||
|
||||
gchar* otr_dir = files_file_in_account_data_path(DIR_OTR, jid, NULL);
|
||||
auto_gchar gchar* otr_dir = files_file_in_account_data_path(DIR_OTR, jid, NULL);
|
||||
if (!otr_dir) {
|
||||
log_error("Could not create directory for account %s.", jid);
|
||||
cons_show_error("Could not create directory for account %s.", jid);
|
||||
@ -236,7 +236,6 @@ otr_on_connect(ProfAccount* account)
|
||||
if (err != GPG_ERR_NO_ERROR) {
|
||||
log_warning("Failed to read OTR private key file: %s", keysfilename->str);
|
||||
cons_show_error("Failed to read OTR private key file: %s", keysfilename->str);
|
||||
g_free(otr_dir);
|
||||
g_string_free(keysfilename, TRUE);
|
||||
return;
|
||||
}
|
||||
@ -245,7 +244,6 @@ otr_on_connect(ProfAccount* account)
|
||||
if (!privkey) {
|
||||
log_warning("No OTR private key found for account \"%s\", protocol \"xmpp\" in file: %s", jid, keysfilename->str);
|
||||
cons_show_error("No OTR private key found for account \"%s\", protocol \"xmpp\" in file: %s", jid, keysfilename->str);
|
||||
g_free(otr_dir);
|
||||
g_string_free(keysfilename, TRUE);
|
||||
return;
|
||||
}
|
||||
@ -263,7 +261,6 @@ otr_on_connect(ProfAccount* account)
|
||||
err = otrl_privkey_read_fingerprints(user_state, fpsfilename->str, NULL, NULL);
|
||||
if (err != GPG_ERR_NO_ERROR) {
|
||||
log_error("Failed to load OTR fingerprints file: %s", fpsfilename->str);
|
||||
g_free(otr_dir);
|
||||
g_string_free(keysfilename, TRUE);
|
||||
g_string_free(fpsfilename, TRUE);
|
||||
return;
|
||||
@ -277,7 +274,6 @@ otr_on_connect(ProfAccount* account)
|
||||
cons_show("Loaded OTR private key for %s", jid);
|
||||
}
|
||||
|
||||
g_free(otr_dir);
|
||||
g_string_free(keysfilename, TRUE);
|
||||
g_string_free(fpsfilename, TRUE);
|
||||
return;
|
||||
@ -373,7 +369,7 @@ otr_keygen(ProfAccount* account)
|
||||
jid = strdup(account->jid);
|
||||
log_info("Generating OTR key for %s", jid);
|
||||
|
||||
gchar* otr_dir = files_file_in_account_data_path(DIR_OTR, jid, NULL);
|
||||
auto_gchar gchar* otr_dir = files_file_in_account_data_path(DIR_OTR, jid, NULL);
|
||||
|
||||
if (!otr_dir) {
|
||||
log_error("Could not create directory for account %s.", jid);
|
||||
@ -391,7 +387,6 @@ otr_keygen(ProfAccount* account)
|
||||
ui_update();
|
||||
err = otrl_privkey_generate(user_state, keysfilename->str, account->jid, "xmpp");
|
||||
if (err != GPG_ERR_NO_ERROR) {
|
||||
g_free(otr_dir);
|
||||
g_string_free(keysfilename, TRUE);
|
||||
log_error("Failed to generate private key");
|
||||
cons_show_error("Failed to generate private key");
|
||||
@ -406,7 +401,6 @@ otr_keygen(ProfAccount* account)
|
||||
log_debug("Generating fingerprints file %s for %s", fpsfilename->str, jid);
|
||||
err = otrl_privkey_write_fingerprints(user_state, fpsfilename->str);
|
||||
if (err != GPG_ERR_NO_ERROR) {
|
||||
g_free(otr_dir);
|
||||
g_string_free(keysfilename, TRUE);
|
||||
log_error("Failed to create fingerprints file");
|
||||
cons_show_error("Failed to create fingerprints file");
|
||||
@ -416,7 +410,6 @@ otr_keygen(ProfAccount* account)
|
||||
|
||||
err = otrl_privkey_read(user_state, keysfilename->str);
|
||||
if (err != GPG_ERR_NO_ERROR) {
|
||||
g_free(otr_dir);
|
||||
g_string_free(keysfilename, TRUE);
|
||||
log_error("Failed to load private key");
|
||||
data_loaded = FALSE;
|
||||
@ -425,7 +418,6 @@ otr_keygen(ProfAccount* account)
|
||||
|
||||
err = otrl_privkey_read_fingerprints(user_state, fpsfilename->str, NULL, NULL);
|
||||
if (err != GPG_ERR_NO_ERROR) {
|
||||
g_free(otr_dir);
|
||||
g_string_free(keysfilename, TRUE);
|
||||
log_error("Failed to load fingerprints");
|
||||
data_loaded = FALSE;
|
||||
@ -434,7 +426,6 @@ otr_keygen(ProfAccount* account)
|
||||
|
||||
data_loaded = TRUE;
|
||||
|
||||
g_free(otr_dir);
|
||||
g_string_free(keysfilename, TRUE);
|
||||
g_string_free(fpsfilename, TRUE);
|
||||
return;
|
||||
|
@ -191,11 +191,10 @@ p_gpg_on_connect(const char* const barejid)
|
||||
for (int i = 0; i < len; i++) {
|
||||
GError* gerr = NULL;
|
||||
gchar* jid = jids[i];
|
||||
gchar* keyid = g_key_file_get_string(pubkeyfile, jid, "keyid", &gerr);
|
||||
auto_gchar gchar* keyid = g_key_file_get_string(pubkeyfile, jid, "keyid", &gerr);
|
||||
if (gerr) {
|
||||
log_error("Error loading PGP key id for %s", jid);
|
||||
g_error_free(gerr);
|
||||
g_free(keyid);
|
||||
} else {
|
||||
gpgme_key_t key = NULL;
|
||||
error = gpgme_get_key(ctx, keyid, &key, 0);
|
||||
@ -208,7 +207,6 @@ p_gpg_on_connect(const char* const barejid)
|
||||
pubkeyid->id = strdup(keyid);
|
||||
pubkeyid->received = FALSE;
|
||||
g_hash_table_replace(pubkeys, strdup(jid), pubkeyid);
|
||||
g_free(keyid);
|
||||
gpgme_key_unref(key);
|
||||
}
|
||||
}
|
||||
@ -978,8 +976,7 @@ static void
|
||||
_save_pubkeys(void)
|
||||
{
|
||||
gsize g_data_size;
|
||||
gchar* g_pubkeys_data = g_key_file_to_data(pubkeyfile, &g_data_size, NULL);
|
||||
auto_gchar gchar* g_pubkeys_data = g_key_file_to_data(pubkeyfile, &g_data_size, NULL);
|
||||
g_file_set_contents(pubsloc, g_pubkeys_data, g_data_size, NULL);
|
||||
g_chmod(pubsloc, S_IRUSR | S_IWUSR);
|
||||
g_free(g_pubkeys_data);
|
||||
}
|
||||
|
@ -525,9 +525,8 @@ c_api_init(void)
|
||||
static char*
|
||||
_c_plugin_name(const char* filename)
|
||||
{
|
||||
gchar* name = g_strndup(filename, strlen(filename) - 1);
|
||||
auto_gchar gchar* name = g_strndup(filename, strlen(filename) - 1);
|
||||
gchar* result = g_strdup_printf("%sso", name);
|
||||
g_free(name);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ theme_item_t
|
||||
plugin_themes_get(const char* const group, const char* const key, const char* const def)
|
||||
{
|
||||
if (group && key && g_key_file_has_key(themes, group, key, NULL)) {
|
||||
gchar* result = g_key_file_get_string(themes, group, key, NULL);
|
||||
auto_gchar gchar* result = g_key_file_get_string(themes, group, key, NULL);
|
||||
|
||||
theme_item_t ret;
|
||||
|
||||
@ -148,8 +148,6 @@ plugin_themes_get(const char* const group, const char* const key, const char* co
|
||||
else
|
||||
ret = THEME_TEXT;
|
||||
|
||||
g_free(result);
|
||||
|
||||
return ret;
|
||||
|
||||
} else {
|
||||
|
@ -303,11 +303,10 @@ get_start(const char* const string, int tokens)
|
||||
gunichar curr_uni = g_utf8_get_char(curr_ch);
|
||||
|
||||
if (num_tokens < tokens) {
|
||||
gchar* uni_char = g_malloc(7);
|
||||
auto_gchar gchar* uni_char = g_malloc(7);
|
||||
int len = g_unichar_to_utf8(curr_uni, uni_char);
|
||||
uni_char[len] = '\0';
|
||||
g_string_append(result, uni_char);
|
||||
g_free(uni_char);
|
||||
}
|
||||
if (curr_uni == ' ') {
|
||||
if (!in_quotes) {
|
||||
|
@ -562,10 +562,9 @@ _inp_rl_startup_hook(void)
|
||||
rl_variable_bind("disable-completion", "on");
|
||||
|
||||
// check for and load ~/.config/profanity/inputrc
|
||||
gchar* inputrc = files_get_inputrc_file();
|
||||
auto_gchar gchar* inputrc = files_get_inputrc_file();
|
||||
if (inputrc) {
|
||||
rl_read_init_file(inputrc);
|
||||
g_free(inputrc);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -948,7 +947,7 @@ _inp_rl_send_to_editor(int count, int key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
gchar* message = NULL;
|
||||
auto_gchar gchar* message = NULL;
|
||||
|
||||
if (get_message_from_editor(rl_line_buffer, &message)) {
|
||||
return 0;
|
||||
@ -958,7 +957,6 @@ _inp_rl_send_to_editor(int count, int key)
|
||||
ui_resize();
|
||||
rl_point = rl_end;
|
||||
rl_forced_update_display();
|
||||
g_free(message);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -77,9 +77,8 @@ notifier_uninit(void)
|
||||
void
|
||||
notify_typing(const char* const name)
|
||||
{
|
||||
gchar* message = g_strdup_printf("%s: typing…", name);
|
||||
auto_gchar gchar* message = g_strdup_printf("%s: typing…", name);
|
||||
notify(message, 10000, "Incoming message");
|
||||
g_free(message);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -79,9 +79,8 @@ _get_icons(void)
|
||||
|
||||
#endif /* ICONS_PATH */
|
||||
|
||||
gchar* icons_dir_s = files_get_config_path(DIR_ICONS);
|
||||
auto_gchar gchar* icons_dir_s = files_get_config_path(DIR_ICONS);
|
||||
icons_dir = g_string_new(icons_dir_s);
|
||||
g_free(icons_dir_s);
|
||||
GError* err = NULL;
|
||||
|
||||
if (!g_file_test(icons_dir->str, G_FILE_TEST_IS_DIR)) {
|
||||
|
@ -691,12 +691,12 @@ win_page_down(ProfWin* window)
|
||||
if ((*page_start == y || (*page_start == page_space && *page_start >= y)) && window->type == WIN_CHAT) {
|
||||
int bf_size = buffer_size(window->layout->buffer);
|
||||
if (bf_size > 0) {
|
||||
char* start = g_date_time_format_iso8601(buffer_get_entry(window->layout->buffer, bf_size - 1)->time);
|
||||
auto_gchar gchar* start = g_date_time_format_iso8601(buffer_get_entry(window->layout->buffer, bf_size - 1)->time);
|
||||
GDateTime* now = g_date_time_new_now_local();
|
||||
char* end = g_date_time_format_iso8601(now);
|
||||
gchar* end = g_date_time_format_iso8601(now);
|
||||
// end is free'd inside
|
||||
chatwin_db_history((ProfChatWin*)window, start, end, FALSE);
|
||||
|
||||
g_free(start);
|
||||
g_date_time_unref(now);
|
||||
}
|
||||
}
|
||||
@ -1788,7 +1788,7 @@ _win_print_internal(ProfWin* window, const char* show_char, int pad_indent, GDat
|
||||
int colour = theme_attrs(THEME_ME);
|
||||
size_t indent = 0;
|
||||
|
||||
char* time_pref = NULL;
|
||||
auto_gchar gchar* time_pref = NULL;
|
||||
switch (window->type) {
|
||||
case WIN_CHAT:
|
||||
time_pref = prefs_get_string(PREF_TIME_CHAT);
|
||||
@ -1810,13 +1810,12 @@ _win_print_internal(ProfWin* window, const char* show_char, int pad_indent, GDat
|
||||
break;
|
||||
}
|
||||
|
||||
gchar* date_fmt = NULL;
|
||||
auto_gchar gchar* date_fmt = NULL;
|
||||
if (g_strcmp0(time_pref, "off") == 0 || time == NULL) {
|
||||
date_fmt = g_strdup("");
|
||||
} else {
|
||||
date_fmt = g_date_time_format(time, time_pref);
|
||||
}
|
||||
g_free(time_pref);
|
||||
assert(date_fmt != NULL);
|
||||
|
||||
if (strlen(date_fmt) != 0) {
|
||||
@ -1903,8 +1902,6 @@ _win_print_internal(ProfWin* window, const char* show_char, int pad_indent, GDat
|
||||
wattroff(window->layout->win, theme_attrs(theme_item));
|
||||
}
|
||||
}
|
||||
|
||||
g_free(date_fmt);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2309,21 +2306,17 @@ win_quote_autocomplete(ProfWin* window, const char* const input, gboolean previo
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* result = autocomplete_complete(window->quotes_ac, input + 1, FALSE, previous);
|
||||
auto_gchar gchar* result = autocomplete_complete(window->quotes_ac, input + 1, FALSE, previous);
|
||||
if (result == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gchar** parts = g_strsplit(result, "\n", -1);
|
||||
gchar* quoted_result = g_strjoinv("\n> ", parts);
|
||||
auto_gcharv gchar** parts = g_strsplit(result, "\n", -1);
|
||||
auto_gchar gchar* quoted_result = g_strjoinv("\n> ", parts);
|
||||
|
||||
GString* replace_with = g_string_new("> ");
|
||||
g_string_append(replace_with, quoted_result);
|
||||
g_string_append(replace_with, "\n");
|
||||
|
||||
g_free(result);
|
||||
g_free(quoted_result);
|
||||
g_strfreev(parts);
|
||||
|
||||
return g_string_free(replace_with, FALSE);
|
||||
}
|
||||
|
@ -1318,7 +1318,7 @@ wins_add_urls_ac(const ProfWin* const win, const ProfMessage* const message, con
|
||||
g_regex_match(regex, message->plain, 0, &match_info);
|
||||
|
||||
while (g_match_info_matches(match_info)) {
|
||||
gchar* word = g_match_info_fetch(match_info, 0);
|
||||
auto_gchar gchar* word = g_match_info_fetch(match_info, 0);
|
||||
|
||||
if (flip) {
|
||||
autocomplete_add_unsorted(win->urls_ac, word, FALSE);
|
||||
@ -1328,7 +1328,6 @@ wins_add_urls_ac(const ProfWin* const win, const ProfMessage* const message, con
|
||||
// for people who run profanity a long time, we don't want to waste a lot of memory
|
||||
autocomplete_remove_older_than_max_reverse(win->urls_ac, 20);
|
||||
|
||||
g_free(word);
|
||||
g_match_info_next(match_info, NULL);
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ static GHashTable* jid_to_ver;
|
||||
static GHashTable* jid_to_caps;
|
||||
|
||||
static GHashTable* prof_features;
|
||||
static char* my_sha1;
|
||||
static gchar* my_sha1;
|
||||
|
||||
static void _save_cache(void);
|
||||
static EntityCapabilities* _caps_by_ver(const char* const ver);
|
||||
@ -464,8 +464,7 @@ static void
|
||||
_save_cache(void)
|
||||
{
|
||||
gsize g_data_size;
|
||||
gchar* g_cache_data = g_key_file_to_data(cache, &g_data_size, NULL);
|
||||
auto_gchar gchar* g_cache_data = g_key_file_to_data(cache, &g_data_size, NULL);
|
||||
g_file_set_contents(cache_loc, g_cache_data, g_data_size, NULL);
|
||||
g_chmod(cache_loc, S_IRUSR | S_IWUSR);
|
||||
g_free(g_cache_data);
|
||||
}
|
||||
|
@ -879,7 +879,7 @@ _caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
// validate sha1
|
||||
gchar** split = g_strsplit(node, "#", -1);
|
||||
char* given_sha1 = split[1];
|
||||
char* generated_sha1 = stanza_create_caps_sha1_from_query(query);
|
||||
auto_gchar gchar* generated_sha1 = stanza_create_caps_sha1_from_query(query);
|
||||
|
||||
if (g_strcmp0(given_sha1, generated_sha1) != 0) {
|
||||
log_warning("Generated sha-1 does not match given:");
|
||||
@ -901,7 +901,6 @@ _caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
caps_map_jid_to_ver(from, given_sha1);
|
||||
}
|
||||
|
||||
g_free(generated_sha1);
|
||||
g_strfreev(split);
|
||||
|
||||
return 0;
|
||||
@ -1079,7 +1078,7 @@ _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
const char* stanza_name = xmpp_stanza_get_name(child);
|
||||
if (stanza_name && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) {
|
||||
const char* item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
||||
gchar* item_jid_lower = NULL;
|
||||
auto_gchar gchar* item_jid_lower = NULL;
|
||||
if (item_jid) {
|
||||
Jid* jidp = jid_create(item_jid);
|
||||
if (jidp && jidp->localpart) {
|
||||
@ -1088,7 +1087,7 @@ _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
const char* item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
|
||||
gchar* item_name_lower = NULL;
|
||||
auto_gchar gchar* item_name_lower = NULL;
|
||||
if (item_name) {
|
||||
item_name_lower = g_utf8_strdown(item_name, -1);
|
||||
}
|
||||
@ -1106,8 +1105,6 @@ _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
cons_show(" %s", item->str);
|
||||
g_string_free(item, TRUE);
|
||||
}
|
||||
g_free(item_jid_lower);
|
||||
g_free(item_name_lower);
|
||||
}
|
||||
child = xmpp_stanza_get_next(child);
|
||||
}
|
||||
@ -2594,7 +2591,7 @@ iq_mam_request_older(ProfChatWin* win)
|
||||
|
||||
ProfMessage* first_msg = log_database_get_limits_info(win->barejid, FALSE);
|
||||
char* firstid = NULL;
|
||||
char* enddate = NULL;
|
||||
auto_gchar gchar* enddate = NULL;
|
||||
|
||||
// If first message found
|
||||
if (first_msg->timestamp) {
|
||||
@ -2608,7 +2605,6 @@ iq_mam_request_older(ProfChatWin* win)
|
||||
xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, win->barejid, NULL, enddate, firstid, NULL);
|
||||
iq_id_handler_add(xmpp_stanza_get_id(iq), _mam_buffer_commit_handler, NULL, win);
|
||||
|
||||
g_free(enddate);
|
||||
message_free(first_msg);
|
||||
|
||||
iq_send_stanza(iq);
|
||||
|
@ -163,9 +163,8 @@ jid_is_valid_room_form(Jid* jid)
|
||||
char*
|
||||
create_fulljid(const char* const barejid, const char* const resource)
|
||||
{
|
||||
gchar* barejidlower = g_utf8_strdown(barejid, -1);
|
||||
auto_gchar gchar* barejidlower = g_utf8_strdown(barejid, -1);
|
||||
GString* full_jid = g_string_new(barejidlower);
|
||||
g_free(barejidlower);
|
||||
g_string_append(full_jid, "/");
|
||||
g_string_append(full_jid, resource);
|
||||
|
||||
@ -209,7 +208,7 @@ jid_fulljid_or_barejid(Jid* jid)
|
||||
}
|
||||
}
|
||||
|
||||
char*
|
||||
gchar*
|
||||
jid_random_resource(void)
|
||||
{
|
||||
auto_char char* rand = get_random_string(4);
|
||||
|
@ -64,6 +64,6 @@ char* create_fulljid(const char* const barejid, const char* const resource);
|
||||
char* get_nick_from_full_jid(const char* const full_room_jid);
|
||||
|
||||
char* jid_fulljid_or_barejid(Jid* jid);
|
||||
char* jid_random_resource(void);
|
||||
gchar* jid_random_resource(void);
|
||||
|
||||
#endif
|
||||
|
@ -647,10 +647,9 @@ message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys,
|
||||
xmpp_stanza_set_attribute(key_stanza, "prekey", "true");
|
||||
}
|
||||
|
||||
gchar* key_raw = g_base64_encode(key->data, key->length);
|
||||
auto_gchar gchar* key_raw = g_base64_encode(key->data, key->length);
|
||||
xmpp_stanza_t* key_text = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_text(key_text, key_raw);
|
||||
g_free(key_raw);
|
||||
|
||||
xmpp_stanza_add_child(key_stanza, key_text);
|
||||
xmpp_stanza_add_child(header, key_stanza);
|
||||
@ -661,10 +660,9 @@ message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys,
|
||||
xmpp_stanza_t* iv_stanza = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iv_stanza, "iv");
|
||||
|
||||
gchar* iv_raw = g_base64_encode(iv, iv_len);
|
||||
auto_gchar gchar* iv_raw = g_base64_encode(iv, iv_len);
|
||||
xmpp_stanza_t* iv_text = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_text(iv_text, iv_raw);
|
||||
g_free(iv_raw);
|
||||
|
||||
xmpp_stanza_add_child(iv_stanza, iv_text);
|
||||
xmpp_stanza_add_child(header, iv_stanza);
|
||||
@ -677,10 +675,9 @@ message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys,
|
||||
xmpp_stanza_t* payload = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(payload, "payload");
|
||||
|
||||
gchar* ciphertext_raw = g_base64_encode(ciphertext, ciphertext_len);
|
||||
auto_gchar gchar* ciphertext_raw = g_base64_encode(ciphertext, ciphertext_len);
|
||||
xmpp_stanza_t* payload_text = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_text(payload_text, ciphertext_raw);
|
||||
g_free(ciphertext_raw);
|
||||
|
||||
xmpp_stanza_add_child(payload, payload_text);
|
||||
xmpp_stanza_add_child(encrypted, payload);
|
||||
|
@ -737,7 +737,7 @@ muc_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
}
|
||||
}
|
||||
|
||||
char* result = autocomplete_complete(chat_room->nick_ac, search_str, FALSE, previous);
|
||||
auto_gchar gchar* result = autocomplete_complete(chat_room->nick_ac, search_str, FALSE, previous);
|
||||
if (result == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -748,7 +748,6 @@ muc_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
if (strlen(chat_room->autocomplete_prefix) == 0) {
|
||||
g_string_append(replace_with, ": ");
|
||||
}
|
||||
g_free(result);
|
||||
return g_string_free(replace_with, FALSE);
|
||||
}
|
||||
|
||||
|
@ -651,7 +651,7 @@ _available_handler(xmpp_stanza_t* const stanza)
|
||||
const char* account_name = session_get_account_name();
|
||||
int max_sessions = accounts_get_max_sessions(account_name);
|
||||
if (max_sessions > 0) {
|
||||
const char* cur_resource = accounts_get_resource(account_name);
|
||||
const gchar* cur_resource = accounts_get_resource(account_name);
|
||||
int res_count = connection_count_available_resources();
|
||||
if (res_count > max_sessions && g_strcmp0(cur_resource, resource->name)) {
|
||||
ProfWin* console = wins_get_console();
|
||||
|
@ -268,7 +268,7 @@ roster_result_handler(xmpp_stanza_t* const stanza)
|
||||
|
||||
while (item) {
|
||||
const char* barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
|
||||
gchar* barejid_lower = g_utf8_strdown(barejid, -1);
|
||||
auto_gchar gchar* barejid_lower = g_utf8_strdown(barejid, -1);
|
||||
const char* name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
|
||||
const char* sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
|
||||
|
||||
@ -289,7 +289,6 @@ roster_result_handler(xmpp_stanza_t* const stanza)
|
||||
log_warning("Attempt to add contact twice: %s", barejid_lower);
|
||||
}
|
||||
|
||||
g_free(barejid_lower);
|
||||
item = xmpp_stanza_get_next(item);
|
||||
}
|
||||
|
||||
|
@ -163,9 +163,8 @@ roster_get_contact(const char* const barejid)
|
||||
{
|
||||
assert(roster != NULL);
|
||||
|
||||
gchar* barejidlower = g_utf8_strdown(barejid, -1);
|
||||
auto_gchar gchar* barejidlower = g_utf8_strdown(barejid, -1);
|
||||
PContact contact = g_hash_table_lookup(roster->contacts, barejidlower);
|
||||
g_free(barejidlower);
|
||||
|
||||
return contact;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ session_connect_with_details(const char* const jid, const char* const passwd, co
|
||||
Jid* jidp = jid_create(jid);
|
||||
if (jidp->resourcepart == NULL) {
|
||||
jid_destroy(jidp);
|
||||
auto_char char* resource = jid_random_resource();
|
||||
auto_gchar gchar* resource = jid_random_resource();
|
||||
jidp = jid_create_from_bare_and_resource(jid, resource);
|
||||
saved_details.jid = strdup(jidp->fulljid);
|
||||
} else {
|
||||
|
@ -61,7 +61,7 @@
|
||||
#include "database.h"
|
||||
|
||||
static void _stanza_add_unique_id(xmpp_stanza_t* stanza);
|
||||
static char* _stanza_create_sha1_hash(char* str);
|
||||
static gchar* _stanza_create_sha1_hash(char* str);
|
||||
|
||||
#if 0
|
||||
xmpp_stanza_t*
|
||||
@ -233,10 +233,9 @@ stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id,
|
||||
}
|
||||
xmpp_stanza_set_attribute(request, STANZA_ATTR_FILENAME, basename(filename_cpy));
|
||||
|
||||
gchar* filesize = g_strdup_printf("%jd", (intmax_t)(upload->filesize));
|
||||
auto_gchar gchar* filesize = g_strdup_printf("%jd", (intmax_t)(upload->filesize));
|
||||
if (filesize) {
|
||||
xmpp_stanza_set_attribute(request, STANZA_ATTR_SIZE, filesize);
|
||||
g_free(filesize);
|
||||
}
|
||||
|
||||
xmpp_stanza_set_attribute(request, STANZA_ATTR_CONTENTTYPE, upload->mime_type);
|
||||
@ -1026,7 +1025,7 @@ stanza_create_ping_iq(xmpp_ctx_t* ctx, const char* const target)
|
||||
return iq;
|
||||
}
|
||||
|
||||
char*
|
||||
gchar*
|
||||
stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query)
|
||||
{
|
||||
GSList* identities = NULL;
|
||||
@ -1116,7 +1115,7 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query)
|
||||
curr = g_slist_next(curr);
|
||||
}
|
||||
|
||||
char* result = _stanza_create_sha1_hash(s->str);
|
||||
gchar* result = _stanza_create_sha1_hash(s->str);
|
||||
|
||||
g_string_free(s, TRUE);
|
||||
g_slist_free_full(identities, g_free);
|
||||
@ -2353,9 +2352,8 @@ stanza_create_omemo_bundle_publish(xmpp_ctx_t* ctx, const char* const id,
|
||||
xmpp_stanza_set_attribute(signed_prekey_public_stanza, "signedPreKeyId", "1");
|
||||
|
||||
xmpp_stanza_t* signed_prekey_public_stanza_text = xmpp_stanza_new(ctx);
|
||||
char* signed_prekey_b64 = g_base64_encode(signed_prekey, signed_prekey_length);
|
||||
auto_gchar gchar* signed_prekey_b64 = g_base64_encode(signed_prekey, signed_prekey_length);
|
||||
xmpp_stanza_set_text(signed_prekey_public_stanza_text, signed_prekey_b64);
|
||||
g_free(signed_prekey_b64);
|
||||
xmpp_stanza_add_child(signed_prekey_public_stanza, signed_prekey_public_stanza_text);
|
||||
xmpp_stanza_release(signed_prekey_public_stanza_text);
|
||||
|
||||
@ -2363,9 +2361,8 @@ stanza_create_omemo_bundle_publish(xmpp_ctx_t* ctx, const char* const id,
|
||||
xmpp_stanza_set_name(signed_prekey_signature_stanza, "signedPreKeySignature");
|
||||
|
||||
xmpp_stanza_t* signed_prekey_signature_stanza_text = xmpp_stanza_new(ctx);
|
||||
char* signed_prekey_signature_b64 = g_base64_encode(signed_prekey_signature, signed_prekey_signature_length);
|
||||
auto_gchar gchar* signed_prekey_signature_b64 = g_base64_encode(signed_prekey_signature, signed_prekey_signature_length);
|
||||
xmpp_stanza_set_text(signed_prekey_signature_stanza_text, signed_prekey_signature_b64);
|
||||
g_free(signed_prekey_signature_b64);
|
||||
xmpp_stanza_add_child(signed_prekey_signature_stanza, signed_prekey_signature_stanza_text);
|
||||
xmpp_stanza_release(signed_prekey_signature_stanza_text);
|
||||
|
||||
@ -2373,9 +2370,8 @@ stanza_create_omemo_bundle_publish(xmpp_ctx_t* ctx, const char* const id,
|
||||
xmpp_stanza_set_name(identity_key_stanza, "identityKey");
|
||||
|
||||
xmpp_stanza_t* identity_key_stanza_text = xmpp_stanza_new(ctx);
|
||||
char* identity_key_b64 = g_base64_encode(identity_key, identity_key_length);
|
||||
auto_gchar gchar* identity_key_b64 = g_base64_encode(identity_key, identity_key_length);
|
||||
xmpp_stanza_set_text(identity_key_stanza_text, identity_key_b64);
|
||||
g_free(identity_key_b64);
|
||||
xmpp_stanza_add_child(identity_key_stanza, identity_key_stanza_text);
|
||||
xmpp_stanza_release(identity_key_stanza_text);
|
||||
|
||||
@ -2390,9 +2386,8 @@ stanza_create_omemo_bundle_publish(xmpp_ctx_t* ctx, const char* const id,
|
||||
xmpp_stanza_set_attribute(prekey, "preKeyId", id);
|
||||
|
||||
xmpp_stanza_t* prekey_text = xmpp_stanza_new(ctx);
|
||||
char* prekey_b64 = g_base64_encode(p->data, GPOINTER_TO_INT(l->data));
|
||||
auto_gchar gchar* prekey_b64 = g_base64_encode(p->data, GPOINTER_TO_INT(l->data));
|
||||
xmpp_stanza_set_text(prekey_text, prekey_b64);
|
||||
g_free(prekey_b64);
|
||||
|
||||
xmpp_stanza_add_child(prekey, prekey_text);
|
||||
xmpp_stanza_add_child(prekeys_stanza, prekey);
|
||||
@ -2517,7 +2512,7 @@ _stanza_add_unique_id(xmpp_stanza_t* stanza)
|
||||
xmpp_stanza_set_id(stanza, id);
|
||||
}
|
||||
|
||||
static char*
|
||||
static gchar*
|
||||
_stanza_create_sha1_hash(char* str)
|
||||
{
|
||||
unsigned char* digest = (unsigned char*)malloc(XMPP_SHA1_DIGEST_SIZE);
|
||||
@ -2525,7 +2520,7 @@ _stanza_create_sha1_hash(char* str)
|
||||
|
||||
xmpp_sha1_digest((unsigned char*)str, strlen(str), digest);
|
||||
|
||||
char* b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE);
|
||||
gchar* b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE);
|
||||
assert(b64 != NULL);
|
||||
free(digest);
|
||||
|
||||
|
@ -380,7 +380,7 @@ void stanza_attach_show(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, co
|
||||
void stanza_attach_status(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, const char* const status);
|
||||
|
||||
xmpp_stanza_t* stanza_create_caps_query_element(xmpp_ctx_t* ctx);
|
||||
char* stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query);
|
||||
gchar* stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query);
|
||||
EntityCapabilities* stanza_create_caps_from_query_element(xmpp_stanza_t* query);
|
||||
|
||||
const char* stanza_get_presence_string_from_type(resource_presence_t presence_type);
|
||||
|
@ -757,10 +757,9 @@ vcard_to_xml(xmpp_ctx_t* const ctx, vCard* vcard)
|
||||
xmpp_stanza_t* binval = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(binval, "BINVAL");
|
||||
|
||||
gchar* base64 = g_base64_encode(element->photo.data, element->photo.length);
|
||||
auto_gchar gchar* base64 = g_base64_encode(element->photo.data, element->photo.length);
|
||||
xmpp_stanza_t* binval_text = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_text(binval_text, base64);
|
||||
g_free(base64);
|
||||
xmpp_stanza_add_child(binval, binval_text);
|
||||
xmpp_stanza_release(binval_text);
|
||||
|
||||
@ -789,10 +788,9 @@ vcard_to_xml(xmpp_ctx_t* const ctx, vCard* vcard)
|
||||
xmpp_stanza_t* birthday = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(birthday, "BDAY");
|
||||
|
||||
gchar* bday_text = g_date_time_format(element->birthday, "%Y-%m-%d");
|
||||
auto_gchar gchar* bday_text = g_date_time_format(element->birthday, "%Y-%m-%d");
|
||||
xmpp_stanza_t* birthday_text = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_text(birthday_text, bday_text);
|
||||
g_free(bday_text);
|
||||
xmpp_stanza_add_child(birthday, birthday_text);
|
||||
xmpp_stanza_release(birthday_text);
|
||||
|
||||
|
@ -325,7 +325,7 @@ void
|
||||
accounts_add_otr_policy(const char* const account_name, const char* const contact_jid, const char* const policy)
|
||||
{
|
||||
}
|
||||
char*
|
||||
gchar*
|
||||
accounts_get_last_activity(const char* const account_name)
|
||||
{
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user