mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Cleanup: gchar as gchar instead of char
Use gchar instead of char in most of the cases where gchar is intended. Reason: improve compatibility and stability. Issue #1819 Minor refactoring.
This commit is contained in:
parent
faccf24c75
commit
7f3fca2bd0
@ -96,13 +96,12 @@ chat_log_otr_msg_out(const char* const barejid, const char* const msg, const cha
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
char* mybarejid = connection_get_barejid();
|
||||
char* pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
||||
auto_gchar gchar* pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
||||
if (strcmp(pref_otr_log, "on") == 0) {
|
||||
_chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource);
|
||||
} else if (strcmp(pref_otr_log, "redact") == 0) {
|
||||
_chat_log_chat(mybarejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource);
|
||||
}
|
||||
g_free(pref_otr_log);
|
||||
free(mybarejid);
|
||||
}
|
||||
}
|
||||
@ -112,13 +111,12 @@ chat_log_pgp_msg_out(const char* const barejid, const char* const msg, const cha
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
char* mybarejid = connection_get_barejid();
|
||||
char* pref_pgp_log = prefs_get_string(PREF_PGP_LOG);
|
||||
auto_gchar gchar* pref_pgp_log = prefs_get_string(PREF_PGP_LOG);
|
||||
if (strcmp(pref_pgp_log, "on") == 0) {
|
||||
_chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource);
|
||||
} else if (strcmp(pref_pgp_log, "redact") == 0) {
|
||||
_chat_log_chat(mybarejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource);
|
||||
}
|
||||
g_free(pref_pgp_log);
|
||||
free(mybarejid);
|
||||
}
|
||||
}
|
||||
@ -128,13 +126,12 @@ chat_log_omemo_msg_out(const char* const barejid, const char* const msg, const c
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
char* mybarejid = connection_get_barejid();
|
||||
char* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
|
||||
auto_gchar gchar* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
|
||||
if (strcmp(pref_omemo_log, "on") == 0) {
|
||||
_chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource);
|
||||
} else if (strcmp(pref_omemo_log, "redact") == 0) {
|
||||
_chat_log_chat(mybarejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource);
|
||||
}
|
||||
g_free(pref_omemo_log);
|
||||
free(mybarejid);
|
||||
}
|
||||
}
|
||||
@ -144,7 +141,7 @@ chat_log_otr_msg_in(ProfMessage* message)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
char* mybarejid = connection_get_barejid();
|
||||
char* pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
||||
auto_gchar gchar* pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
||||
if (message->enc == PROF_MSG_ENC_NONE || (strcmp(pref_otr_log, "on") == 0)) {
|
||||
if (message->type == PROF_MSG_TYPE_MUCPM) {
|
||||
_chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart);
|
||||
@ -158,7 +155,6 @@ chat_log_otr_msg_in(ProfMessage* message)
|
||||
_chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, NULL);
|
||||
}
|
||||
}
|
||||
g_free(pref_otr_log);
|
||||
free(mybarejid);
|
||||
}
|
||||
}
|
||||
@ -168,7 +164,7 @@ chat_log_pgp_msg_in(ProfMessage* message)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
char* mybarejid = connection_get_barejid();
|
||||
char* pref_pgp_log = prefs_get_string(PREF_PGP_LOG);
|
||||
auto_gchar gchar* pref_pgp_log = prefs_get_string(PREF_PGP_LOG);
|
||||
if (strcmp(pref_pgp_log, "on") == 0) {
|
||||
if (message->type == PROF_MSG_TYPE_MUCPM) {
|
||||
_chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart);
|
||||
@ -182,7 +178,6 @@ chat_log_pgp_msg_in(ProfMessage* message)
|
||||
_chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, NULL);
|
||||
}
|
||||
}
|
||||
g_free(pref_pgp_log);
|
||||
free(mybarejid);
|
||||
}
|
||||
}
|
||||
@ -192,7 +187,7 @@ chat_log_omemo_msg_in(ProfMessage* message)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
char* mybarejid = connection_get_barejid();
|
||||
char* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
|
||||
auto_gchar gchar* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
|
||||
if (strcmp(pref_omemo_log, "on") == 0) {
|
||||
if (message->type == PROF_MSG_TYPE_MUCPM) {
|
||||
_chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart);
|
||||
@ -206,7 +201,6 @@ chat_log_omemo_msg_in(ProfMessage* message)
|
||||
_chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart);
|
||||
}
|
||||
}
|
||||
g_free(pref_omemo_log);
|
||||
free(mybarejid);
|
||||
}
|
||||
}
|
||||
@ -272,7 +266,7 @@ _chat_log_chat(const char* const login, const char* const other, const char* con
|
||||
g_date_time_ref(timestamp);
|
||||
}
|
||||
|
||||
gchar* date_fmt = g_date_time_format_iso8601(timestamp);
|
||||
auto_gchar gchar* date_fmt = g_date_time_format_iso8601(timestamp);
|
||||
FILE* chatlogp = fopen(dated_log->filename, "a");
|
||||
g_chmod(dated_log->filename, S_IRUSR | S_IWUSR);
|
||||
if (chatlogp) {
|
||||
@ -304,7 +298,6 @@ _chat_log_chat(const char* const login, const char* const other, const char* con
|
||||
}
|
||||
}
|
||||
|
||||
g_free(date_fmt);
|
||||
g_date_time_unref(timestamp);
|
||||
}
|
||||
|
||||
@ -342,7 +335,7 @@ groupchat_log_omemo_msg_out(const gchar* const room, const gchar* const msg)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
char* mybarejid = connection_get_barejid();
|
||||
char* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
|
||||
auto_gchar gchar* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
|
||||
char* mynick = muc_nick(room);
|
||||
|
||||
if (strcmp(pref_omemo_log, "on") == 0) {
|
||||
@ -351,7 +344,6 @@ groupchat_log_omemo_msg_out(const gchar* const room, const gchar* const msg)
|
||||
_groupchat_log_chat(mybarejid, room, mynick, "[redacted]");
|
||||
}
|
||||
|
||||
g_free(pref_omemo_log);
|
||||
free(mybarejid);
|
||||
}
|
||||
}
|
||||
@ -360,17 +352,14 @@ void
|
||||
groupchat_log_omemo_msg_in(const gchar* const room, const gchar* const nick, const gchar* const msg)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
char* mybarejid = connection_get_barejid();
|
||||
char* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
|
||||
auto_char char* mybarejid = connection_get_barejid();
|
||||
auto_gchar gchar* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
|
||||
|
||||
if (strcmp(pref_omemo_log, "on") == 0) {
|
||||
_groupchat_log_chat(mybarejid, room, nick, msg);
|
||||
} else if (strcmp(pref_omemo_log, "redact") == 0) {
|
||||
_groupchat_log_chat(mybarejid, room, nick, "[redacted]");
|
||||
}
|
||||
|
||||
g_free(pref_omemo_log);
|
||||
free(mybarejid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -393,7 +382,7 @@ _groupchat_log_chat(const gchar* const login, const gchar* const room, const gch
|
||||
|
||||
GDateTime* dt_tmp = g_date_time_new_now_local();
|
||||
|
||||
gchar* date_fmt = g_date_time_format_iso8601(dt_tmp);
|
||||
auto_gchar gchar* date_fmt = g_date_time_format_iso8601(dt_tmp);
|
||||
|
||||
FILE* grpchatlogp = fopen(dated_log->filename, "a");
|
||||
g_chmod(dated_log->filename, S_IRUSR | S_IWUSR);
|
||||
@ -411,7 +400,6 @@ _groupchat_log_chat(const gchar* const login, const gchar* const room, const gch
|
||||
}
|
||||
}
|
||||
|
||||
g_free(date_fmt);
|
||||
g_date_time_unref(dt_tmp);
|
||||
}
|
||||
|
||||
@ -425,21 +413,16 @@ chat_log_close(void)
|
||||
static char*
|
||||
_get_log_filename(const char* const other, const char* const login, GDateTime* dt, gboolean is_room)
|
||||
{
|
||||
gchar* chatlogs_dir = files_file_in_account_data_path(DIR_CHATLOGS, login, is_room ? "rooms" : NULL);
|
||||
gchar* logfile_name = g_date_time_format(dt, "%Y_%m_%d.log");
|
||||
gchar* other_ = str_replace(other, "@", "_at_");
|
||||
gchar* logs_path = g_strdup_printf("%s/%s", chatlogs_dir, other_);
|
||||
auto_gchar gchar* chatlogs_dir = files_file_in_account_data_path(DIR_CHATLOGS, login, is_room ? "rooms" : NULL);
|
||||
auto_gchar gchar* logfile_name = g_date_time_format(dt, "%Y_%m_%d.log");
|
||||
auto_gchar gchar* other_ = str_replace(other, "@", "_at_");
|
||||
auto_gchar gchar* logs_path = g_strdup_printf("%s/%s", chatlogs_dir, other_);
|
||||
gchar* logfile_path = NULL;
|
||||
|
||||
if (create_dir(logs_path)) {
|
||||
logfile_path = g_strdup_printf("%s/%s", logs_path, logfile_name);
|
||||
}
|
||||
|
||||
g_free(logs_path);
|
||||
g_free(other_);
|
||||
g_free(logfile_name);
|
||||
g_free(chatlogs_dir);
|
||||
|
||||
return logfile_path;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ static char* _logging_autocomplete(ProfWin* window, const char* const input, gbo
|
||||
static char* _color_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _avatar_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _correction_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _correct_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static gchar* _correct_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _software_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _url_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _executable_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
@ -4291,17 +4291,15 @@ _avatar_autocomplete(ProfWin* window, const char* const input, gboolean previous
|
||||
static char*
|
||||
_correction_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
{
|
||||
char* result = NULL;
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/correction", correction_ac, TRUE, previous);
|
||||
char* result = autocomplete_param_with_ac(input, "/correction", correction_ac, TRUE, previous);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static char*
|
||||
static gchar*
|
||||
_correct_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
{
|
||||
char* result = g_strdup_printf("/correct %s", win_get_last_sent_message(window));
|
||||
gchar* result = g_strdup_printf("/correct %s", win_get_last_sent_message(window));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -9703,9 +9703,8 @@ cmd_executable_vcard_photo(ProfWin* window, const char* const command, gchar** a
|
||||
cons_show("`vcard photo open` command set to invoke '%s'", args[2]);
|
||||
} else if (g_strcmp0(args[1], "default") == 0) {
|
||||
prefs_set_string(PREF_VCARD_PHOTO_CMD, NULL);
|
||||
char* cmd = prefs_get_string(PREF_VCARD_PHOTO_CMD);
|
||||
auto_gchar gchar* cmd = prefs_get_string(PREF_VCARD_PHOTO_CMD);
|
||||
cons_show("`vcard photo open` command set to invoke '%s' (default)", cmd);
|
||||
g_free(cmd);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
|
18
src/common.c
18
src/common.c
@ -457,14 +457,11 @@ GSList*
|
||||
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);
|
||||
auto_gchar gchar* message_search = case_sensitive ? g_strdup(message) : g_utf8_strdown(message, -1);
|
||||
auto_gchar gchar* mynick_search = case_sensitive ? g_strdup(nick) : g_utf8_strdown(nick, -1);
|
||||
|
||||
mentions = prof_occurrences(mynick_search, message_search, 0, whole_word, &mentions);
|
||||
|
||||
g_free(message_search);
|
||||
g_free(mynick_search);
|
||||
|
||||
return mentions;
|
||||
}
|
||||
|
||||
@ -483,11 +480,10 @@ call_external(gchar** argv)
|
||||
NULL, NULL, NULL,
|
||||
&spawn_error);
|
||||
if (!is_successful) {
|
||||
gchar* cmd = g_strjoinv(" ", argv);
|
||||
auto_gchar gchar* cmd = g_strjoinv(" ", argv);
|
||||
log_error("Spawning '%s' failed with error '%s'", cmd, spawn_error ? spawn_error->message : "Unknown, spawn_error is NULL");
|
||||
|
||||
g_error_free(spawn_error);
|
||||
g_free(cmd);
|
||||
}
|
||||
|
||||
return is_successful;
|
||||
@ -579,7 +575,7 @@ get_expanded_path(const char* path)
|
||||
gchar*
|
||||
unique_filename_from_url(const char* url, const char* path)
|
||||
{
|
||||
gchar* realpath;
|
||||
auto_gchar gchar* realpath = NULL;
|
||||
|
||||
// Default to './' as path when none has been provided.
|
||||
if (path == NULL) {
|
||||
@ -590,7 +586,7 @@ unique_filename_from_url(const char* url, const char* path)
|
||||
|
||||
// Resolves paths such as './../.' for path.
|
||||
GFile* target = g_file_new_for_commandline_arg(realpath);
|
||||
gchar* filename = NULL;
|
||||
auto_gchar gchar* filename = NULL;
|
||||
|
||||
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
|
||||
@ -605,14 +601,10 @@ unique_filename_from_url(const char* url, const char* path)
|
||||
|
||||
gchar* unique_filename = _unique_filename(filename);
|
||||
if (unique_filename == NULL) {
|
||||
g_free(filename);
|
||||
g_free(realpath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_object_unref(target);
|
||||
g_free(filename);
|
||||
g_free(realpath);
|
||||
|
||||
return unique_filename;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ files_get_inputrc_file(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char*
|
||||
gchar*
|
||||
files_get_log_file(const char* const log_file)
|
||||
{
|
||||
gchar* xdg_data = _files_get_xdg_data_home();
|
||||
@ -139,7 +139,7 @@ files_get_log_file(const char* const log_file)
|
||||
g_string_append(logfile, ".log");
|
||||
}
|
||||
|
||||
char* result = g_strdup(logfile->str);
|
||||
gchar* result = g_strdup(logfile->str);
|
||||
|
||||
free(xdg_data);
|
||||
g_string_free(logfile, TRUE);
|
||||
|
@ -101,21 +101,15 @@ _prefs_load(void)
|
||||
|
||||
// move pre 0.5.0 autoaway.message to autoaway.awaymessage
|
||||
if (g_key_file_has_key(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL)) {
|
||||
char* message = g_key_file_get_string(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL);
|
||||
auto_gchar gchar* message = g_key_file_get_string(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL);
|
||||
g_key_file_set_string(prefs, PREF_GROUP_PRESENCE, "autoaway.awaymessage", message);
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL);
|
||||
g_free(message);
|
||||
}
|
||||
|
||||
// migrate pre 0.5.0 time settings
|
||||
if (g_key_file_has_key(prefs, PREF_GROUP_UI, "time", NULL)) {
|
||||
char* time = g_key_file_get_string(prefs, PREF_GROUP_UI, "time", NULL);
|
||||
char* val = NULL;
|
||||
if (time) {
|
||||
val = time;
|
||||
} else {
|
||||
val = "off";
|
||||
}
|
||||
auto_gchar gchar* time = g_key_file_get_string(prefs, PREF_GROUP_UI, "time", NULL);
|
||||
char* val = time ? time : "off";
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "time.console", val);
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "time.chat", val);
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "time.muc", val);
|
||||
@ -123,12 +117,11 @@ _prefs_load(void)
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "time.private", val);
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "time.xmlconsole", val);
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_UI, "time", NULL);
|
||||
g_free(time);
|
||||
}
|
||||
|
||||
// move pre 0.5.0 notify settings
|
||||
if (g_key_file_has_key(prefs, PREF_GROUP_NOTIFICATIONS, "room", NULL)) {
|
||||
char* value = g_key_file_get_string(prefs, PREF_GROUP_NOTIFICATIONS, "room", NULL);
|
||||
auto_gchar gchar* value = g_key_file_get_string(prefs, PREF_GROUP_NOTIFICATIONS, "room", NULL);
|
||||
if (g_strcmp0(value, "on") == 0) {
|
||||
g_key_file_set_boolean(prefs, PREF_GROUP_NOTIFICATIONS, "room", TRUE);
|
||||
} else if (g_strcmp0(value, "off") == 0) {
|
||||
@ -137,7 +130,6 @@ _prefs_load(void)
|
||||
g_key_file_set_boolean(prefs, PREF_GROUP_NOTIFICATIONS, "room", FALSE);
|
||||
g_key_file_set_boolean(prefs, PREF_GROUP_NOTIFICATIONS, "room.mention", TRUE);
|
||||
}
|
||||
g_free(value);
|
||||
}
|
||||
|
||||
// move pre 0.6.0 titlebar settings to wintitle
|
||||
@ -154,7 +146,7 @@ _prefs_load(void)
|
||||
|
||||
// after 0.8.1: titlebar use jid|name -> titlebar show|hide jid|name
|
||||
if (g_key_file_has_key(prefs, PREF_GROUP_UI, "titlebar.muc.title", NULL)) {
|
||||
char* value = g_key_file_get_string(prefs, PREF_GROUP_UI, "titlebar.muc.title", NULL);
|
||||
auto_gchar gchar* value = g_key_file_get_string(prefs, PREF_GROUP_UI, "titlebar.muc.title", NULL);
|
||||
if (g_strcmp0(value, "name") == 0) {
|
||||
g_key_file_set_boolean(prefs, PREF_GROUP_UI, "titlebar.muc.title.name", TRUE);
|
||||
} else if (g_strcmp0(value, "jid") == 0) {
|
||||
@ -164,7 +156,7 @@ _prefs_load(void)
|
||||
|
||||
// 0.9.0 introduced /urlopen. It was saved under "logging" section. Now we have a new "executables" section.
|
||||
if (g_key_file_has_key(prefs, PREF_GROUP_LOGGING, "urlopen.cmd", NULL)) {
|
||||
char* val = g_key_file_get_string(prefs, PREF_GROUP_LOGGING, "urlopen.cmd", NULL);
|
||||
auto_gchar gchar* val = g_key_file_get_string(prefs, PREF_GROUP_LOGGING, "urlopen.cmd", NULL);
|
||||
|
||||
GString* value = g_string_new("false;");
|
||||
value = g_string_append(value, val);
|
||||
@ -178,7 +170,7 @@ _prefs_load(void)
|
||||
|
||||
// 0.9.0 introduced configurable /avatar. It was saved under "logging" section. Now we have a new "executables" section.
|
||||
if (g_key_file_has_key(prefs, PREF_GROUP_LOGGING, "avatar.cmd", NULL)) {
|
||||
char* value = g_key_file_get_string(prefs, PREF_GROUP_LOGGING, "avatar.cmd", NULL);
|
||||
auto_gchar gchar* value = g_key_file_get_string(prefs, PREF_GROUP_LOGGING, "avatar.cmd", NULL);
|
||||
g_key_file_set_string(prefs, PREF_GROUP_EXECUTABLES, "avatar.cmd", value);
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_LOGGING, "avatar.cmd", NULL);
|
||||
}
|
||||
@ -192,7 +184,7 @@ _prefs_load(void)
|
||||
// file type or scheme matching. Move value saved under 'DEF' locale to a
|
||||
// simple key-value string not under any locale.
|
||||
{
|
||||
char** values = g_key_file_get_locale_string_list(prefs, PREF_GROUP_EXECUTABLES, "url.open.cmd", "DEF", NULL, NULL);
|
||||
auto_gcharv gchar** values = g_key_file_get_locale_string_list(prefs, PREF_GROUP_EXECUTABLES, "url.open.cmd", "DEF", NULL, NULL);
|
||||
if (values && !g_key_file_has_key(prefs, PREF_GROUP_EXECUTABLES, "url.open.cmd", NULL)) {
|
||||
// First value in array is `require_save` option -- we ignore that
|
||||
// one as there is no such option anymore.
|
||||
@ -201,16 +193,13 @@ _prefs_load(void)
|
||||
g_key_file_set_string(prefs, PREF_GROUP_EXECUTABLES, "url.open.cmd", executable);
|
||||
g_key_file_set_comment(prefs, PREF_GROUP_EXECUTABLES, "url.open.cmd", " Migrated from url.open.cmd[DEF]. `require_save` option has been removed in v0.10 and was discarded.", NULL);
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_EXECUTABLES, "url.open.cmd[DEF]", NULL);
|
||||
|
||||
g_strfreev(values);
|
||||
}
|
||||
|
||||
char* value = g_key_file_get_locale_string(prefs, PREF_GROUP_EXECUTABLES, "url.save.cmd", "DEF", NULL);
|
||||
auto_gchar gchar* value = g_key_file_get_locale_string(prefs, PREF_GROUP_EXECUTABLES, "url.save.cmd", "DEF", NULL);
|
||||
if (value && !g_key_file_has_key(prefs, PREF_GROUP_EXECUTABLES, "url.save.cmd", NULL)) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_EXECUTABLES, "url.save.cmd", value);
|
||||
g_key_file_set_comment(prefs, PREF_GROUP_EXECUTABLES, "url.save.cmd", " Migrated from url.save.cmd[DEF].", NULL);
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_EXECUTABLES, "url.save.cmd[DEF]", NULL);
|
||||
g_free(value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -342,20 +331,18 @@ prefs_message_get_triggers(const char* const message)
|
||||
{
|
||||
GList* result = NULL;
|
||||
|
||||
char* message_lower = g_utf8_strdown(message, -1);
|
||||
auto_gchar gchar* message_lower = g_utf8_strdown(message, -1);
|
||||
gsize len = 0;
|
||||
gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
char* trigger_lower = g_utf8_strdown(triggers[i], -1);
|
||||
auto_gchar gchar* trigger_lower = g_utf8_strdown(triggers[i], -1);
|
||||
if (g_strrstr(message_lower, trigger_lower)) {
|
||||
result = g_list_append(result, strdup(triggers[i]));
|
||||
}
|
||||
g_free(trigger_lower);
|
||||
}
|
||||
|
||||
g_strfreev(triggers);
|
||||
g_free(message_lower);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -540,7 +527,7 @@ prefs_get_string(preference_t pref)
|
||||
const char* key = _get_key(pref);
|
||||
char* def = _get_default_string(pref);
|
||||
|
||||
char* result = g_key_file_get_string(prefs, group, key, NULL);
|
||||
gchar* result = g_key_file_get_string(prefs, group, key, NULL);
|
||||
|
||||
if (result == NULL) {
|
||||
if (def) {
|
||||
@ -632,10 +619,9 @@ prefs_get_tls_certpath(void)
|
||||
const char* group = _get_group(PREF_TLS_CERTPATH);
|
||||
const char* key = _get_key(PREF_TLS_CERTPATH);
|
||||
|
||||
char* setting = g_key_file_get_string(prefs, group, key, NULL);
|
||||
auto_gchar gchar* setting = g_key_file_get_string(prefs, group, key, NULL);
|
||||
|
||||
if (g_strcmp0(setting, "none") == 0) {
|
||||
g_free(setting);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -660,7 +646,6 @@ prefs_get_tls_certpath(void)
|
||||
}
|
||||
|
||||
char* result = strdup(setting);
|
||||
g_free(setting);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1684,15 +1669,13 @@ prefs_get_aliases(void)
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
char* name = keys[i];
|
||||
char* value = g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL);
|
||||
auto_gchar gchar* value = g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL);
|
||||
|
||||
if (value) {
|
||||
ProfAlias* alias = malloc(sizeof(struct prof_alias_t));
|
||||
alias->name = strdup(name);
|
||||
alias->value = strdup(value);
|
||||
|
||||
free(value);
|
||||
|
||||
result = g_list_insert_sorted(result, alias, (GCompareFunc)_alias_cmp);
|
||||
}
|
||||
}
|
||||
|
@ -686,7 +686,7 @@ _theme_prep_fgnd(char* setting, GString* lookup_str, gboolean* bold)
|
||||
char*
|
||||
theme_get_string(char* str)
|
||||
{
|
||||
char* res = g_key_file_get_string(theme, "colours", str, NULL);
|
||||
gchar* res = g_key_file_get_string(theme, "colours", str, NULL);
|
||||
if (!res) {
|
||||
return strdup(g_hash_table_lookup(defaults, str));
|
||||
} else {
|
||||
|
@ -121,26 +121,17 @@ tlscerts_list(void)
|
||||
for (int i = 0; i < g_strv_length(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);
|
||||
auto_gchar gchar* serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL);
|
||||
auto_gchar gchar* subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL);
|
||||
auto_gchar gchar* issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL);
|
||||
auto_gchar gchar* notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL);
|
||||
auto_gchar gchar* notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL);
|
||||
auto_gchar gchar* keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL);
|
||||
auto_gchar gchar* signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL);
|
||||
|
||||
TLSCertificate* cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
|
||||
notafter, keyalg, signaturealg, NULL);
|
||||
|
||||
free(fingerprint);
|
||||
free(serialnumber);
|
||||
free(subjectname);
|
||||
free(issuername);
|
||||
free(notbefore);
|
||||
free(notafter);
|
||||
free(keyalg);
|
||||
free(signaturealg);
|
||||
|
||||
res = g_list_append(res, cert);
|
||||
}
|
||||
|
||||
@ -316,25 +307,16 @@ tlscerts_get_trusted(const char* const fingerprint)
|
||||
}
|
||||
|
||||
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);
|
||||
auto_gchar gchar* serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL);
|
||||
auto_gchar gchar* subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL);
|
||||
auto_gchar gchar* issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL);
|
||||
auto_gchar gchar* notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL);
|
||||
auto_gchar gchar* notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL);
|
||||
auto_gchar gchar* keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL);
|
||||
auto_gchar gchar* signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL);
|
||||
|
||||
TLSCertificate* cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
|
||||
notafter, keyalg, signaturealg, NULL);
|
||||
|
||||
free(serialnumber);
|
||||
free(subjectname);
|
||||
free(issuername);
|
||||
free(notbefore);
|
||||
free(notafter);
|
||||
free(keyalg);
|
||||
free(signaturealg);
|
||||
|
||||
return cert;
|
||||
}
|
||||
|
||||
|
@ -1346,7 +1346,7 @@ static void
|
||||
_cut(ProfMessage* message, const char* cut)
|
||||
{
|
||||
if (strstr(message->plain, cut)) {
|
||||
char** split = g_strsplit(message->plain, cut, -1);
|
||||
gchar** split = g_strsplit(message->plain, cut, -1);
|
||||
free(message->plain);
|
||||
message->plain = g_strjoinv("", split);
|
||||
g_strfreev(split);
|
||||
|
@ -160,9 +160,8 @@ main(int argc, char** argv)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
gchar* python_version = python_get_version_number();
|
||||
auto_gchar gchar* python_version = python_get_version_number();
|
||||
g_print("Python plugins: Enabled (%s)\n", python_version);
|
||||
g_free(python_version);
|
||||
#else
|
||||
g_print("Python plugins: Disabled\n");
|
||||
#endif
|
||||
|
@ -350,14 +350,12 @@ omemo_generate_crypto_materials(ProfAccount* account)
|
||||
signal_protocol_key_helper_generate_identity_key_pair(&omemo_ctx.identity_key_pair, omemo_ctx.signal);
|
||||
|
||||
ec_public_key_serialize(&omemo_ctx.identity_key_store.public, ratchet_identity_key_pair_get_public(omemo_ctx.identity_key_pair));
|
||||
char* identity_key_public = g_base64_encode(signal_buffer_data(omemo_ctx.identity_key_store.public), signal_buffer_len(omemo_ctx.identity_key_store.public));
|
||||
auto_gchar gchar* identity_key_public = g_base64_encode(signal_buffer_data(omemo_ctx.identity_key_store.public), signal_buffer_len(omemo_ctx.identity_key_store.public));
|
||||
g_key_file_set_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_IDENTITY, OMEMO_STORE_KEY_IDENTITY_KEY_PUBLIC, identity_key_public);
|
||||
g_free(identity_key_public);
|
||||
|
||||
ec_private_key_serialize(&omemo_ctx.identity_key_store.private, ratchet_identity_key_pair_get_private(omemo_ctx.identity_key_pair));
|
||||
char* identity_key_private = g_base64_encode(signal_buffer_data(omemo_ctx.identity_key_store.private), signal_buffer_len(omemo_ctx.identity_key_store.private));
|
||||
auto_gchar gchar* identity_key_private = g_base64_encode(signal_buffer_data(omemo_ctx.identity_key_store.private), signal_buffer_len(omemo_ctx.identity_key_store.private));
|
||||
g_key_file_set_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_IDENTITY, OMEMO_STORE_KEY_IDENTITY_KEY_PRIVATE, identity_key_private);
|
||||
g_free(identity_key_private);
|
||||
|
||||
/* Registration ID */
|
||||
signal_protocol_key_helper_generate_registration_id(&omemo_ctx.registration_id, 0, omemo_ctx.signal);
|
||||
@ -1322,19 +1320,19 @@ omemo_untrust(const char* const jid, const char* const fingerprint_formatted)
|
||||
}
|
||||
free(identity);
|
||||
|
||||
char* fingerprint = _omemo_unformat_fingerprint(fingerprint_formatted);
|
||||
auto_char char* fingerprint = _omemo_unformat_fingerprint(fingerprint_formatted);
|
||||
|
||||
/* Remove existing session */
|
||||
GHashTable* known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid);
|
||||
if (!known_identities) {
|
||||
log_error("[OMEMO] cannot find known device while untrusting a fingerprint");
|
||||
goto out;
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t device_id = GPOINTER_TO_INT(g_hash_table_lookup(known_identities, fingerprint));
|
||||
if (!device_id) {
|
||||
log_error("[OMEMO] cannot find device id while untrusting a fingerprint");
|
||||
goto out;
|
||||
return;
|
||||
}
|
||||
signal_protocol_address address = {
|
||||
.name = jid,
|
||||
@ -1345,13 +1343,9 @@ omemo_untrust(const char* const jid, const char* const fingerprint_formatted)
|
||||
delete_session(&address, omemo_ctx.session_store);
|
||||
|
||||
/* Remove from keyfile */
|
||||
char* device_id_str = g_strdup_printf("%d", device_id);
|
||||
auto_gchar gchar* device_id_str = g_strdup_printf("%d", device_id);
|
||||
g_key_file_remove_key(omemo_ctx.trust_keyfile, jid, device_id_str, NULL);
|
||||
g_free(device_id_str);
|
||||
omemo_trust_keyfile_save();
|
||||
|
||||
out:
|
||||
free(fingerprint);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1540,7 +1534,7 @@ _load_identity(void)
|
||||
|
||||
/* Identity key */
|
||||
error = NULL;
|
||||
char* identity_key_public_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_IDENTITY, OMEMO_STORE_KEY_IDENTITY_KEY_PUBLIC, &error);
|
||||
auto_gchar gchar* identity_key_public_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_IDENTITY, OMEMO_STORE_KEY_IDENTITY_KEY_PUBLIC, &error);
|
||||
if (!identity_key_public_b64) {
|
||||
log_error("[OMEMO] cannot load identity public key: %s", error->message);
|
||||
return FALSE;
|
||||
@ -1548,11 +1542,10 @@ _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);
|
||||
g_free(identity_key_public_b64);
|
||||
omemo_ctx.identity_key_store.public = signal_buffer_create(identity_key_public, identity_key_public_len);
|
||||
|
||||
error = NULL;
|
||||
char* identity_key_private_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_IDENTITY, OMEMO_STORE_KEY_IDENTITY_KEY_PRIVATE, &error);
|
||||
auto_gchar gchar* identity_key_private_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_IDENTITY, OMEMO_STORE_KEY_IDENTITY_KEY_PRIVATE, &error);
|
||||
if (!identity_key_private_b64) {
|
||||
log_error("[OMEMO] cannot load identity private key: %s", error->message);
|
||||
return FALSE;
|
||||
@ -1560,7 +1553,6 @@ _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);
|
||||
g_free(identity_key_private_b64);
|
||||
omemo_ctx.identity_key_store.private = signal_buffer_create(identity_key_private, identity_key_private_len);
|
||||
|
||||
ec_public_key* public_key;
|
||||
@ -1579,10 +1571,9 @@ _load_identity(void)
|
||||
keys = g_key_file_get_keys(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_PREKEYS, NULL, NULL);
|
||||
if (keys) {
|
||||
for (i = 0; keys[i] != NULL; i++) {
|
||||
char* pre_key_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_PREKEYS, keys[i], NULL);
|
||||
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);
|
||||
g_free(pre_key_b64);
|
||||
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);
|
||||
@ -1601,10 +1592,9 @@ _load_identity(void)
|
||||
keys = g_key_file_get_keys(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_SIGNED_PREKEYS, NULL, NULL);
|
||||
if (keys) {
|
||||
for (i = 0; keys[i] != NULL; i++) {
|
||||
char* signed_pre_key_b64 = g_key_file_get_string(omemo_ctx.identity_keyfile, OMEMO_STORE_GROUP_SIGNED_PREKEYS, keys[i], NULL);
|
||||
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);
|
||||
g_free(signed_pre_key_b64);
|
||||
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);
|
||||
@ -1629,7 +1619,7 @@ static void
|
||||
_load_trust(void)
|
||||
{
|
||||
char** keys = NULL;
|
||||
char** groups = g_key_file_get_groups(omemo_ctx.trust_keyfile, NULL);
|
||||
gchar** groups = g_key_file_get_groups(omemo_ctx.trust_keyfile, NULL);
|
||||
if (groups) {
|
||||
int i;
|
||||
for (i = 0; groups[i] != NULL; i++) {
|
||||
@ -1644,10 +1634,9 @@ _load_trust(void)
|
||||
keys = g_key_file_get_keys(omemo_ctx.trust_keyfile, groups[i], NULL, NULL);
|
||||
int j;
|
||||
for (j = 0; keys[j] != NULL; j++) {
|
||||
char* key_b64 = g_key_file_get_string(omemo_ctx.trust_keyfile, groups[i], keys[j], NULL);
|
||||
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);
|
||||
g_free(key_b64);
|
||||
signal_buffer* buffer = signal_buffer_create(key, key_len);
|
||||
g_free(key);
|
||||
uint32_t device_id = strtoul(keys[j], NULL, 10);
|
||||
@ -1663,7 +1652,7 @@ static void
|
||||
_load_sessions(void)
|
||||
{
|
||||
int i;
|
||||
char** groups = g_key_file_get_groups(omemo_ctx.sessions_keyfile, NULL);
|
||||
auto_gcharv gchar** groups = g_key_file_get_groups(omemo_ctx.sessions_keyfile, NULL);
|
||||
if (groups) {
|
||||
for (i = 0; groups[i] != NULL; i++) {
|
||||
int j;
|
||||
@ -1675,20 +1664,17 @@ _load_sessions(void)
|
||||
g_hash_table_insert(omemo_ctx.session_store, strdup(groups[i]), device_store);
|
||||
}
|
||||
|
||||
char** keys = g_key_file_get_keys(omemo_ctx.sessions_keyfile, groups[i], NULL, NULL);
|
||||
auto_gcharv gchar** keys = g_key_file_get_keys(omemo_ctx.sessions_keyfile, groups[i], NULL, NULL);
|
||||
for (j = 0; keys[j] != NULL; j++) {
|
||||
uint32_t id = strtoul(keys[j], NULL, 10);
|
||||
char* record_b64 = g_key_file_get_string(omemo_ctx.sessions_keyfile, groups[i], keys[j], NULL);
|
||||
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);
|
||||
g_free(record_b64);
|
||||
signal_buffer* buffer = signal_buffer_create(record, record_len);
|
||||
g_free(record);
|
||||
g_hash_table_insert(device_store, GINT_TO_POINTER(id), buffer);
|
||||
}
|
||||
g_strfreev(keys);
|
||||
}
|
||||
g_strfreev(groups);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1696,7 +1682,7 @@ static void
|
||||
_load_known_devices(void)
|
||||
{
|
||||
int i;
|
||||
char** groups = g_key_file_get_groups(omemo_ctx.known_devices_keyfile, NULL);
|
||||
auto_gcharv gchar** groups = g_key_file_get_groups(omemo_ctx.known_devices_keyfile, NULL);
|
||||
if (groups) {
|
||||
for (i = 0; groups[i] != NULL; i++) {
|
||||
int j;
|
||||
@ -1708,16 +1694,13 @@ _load_known_devices(void)
|
||||
g_hash_table_insert(omemo_ctx.known_devices, strdup(groups[i]), known_identities);
|
||||
}
|
||||
|
||||
char** keys = g_key_file_get_keys(omemo_ctx.known_devices_keyfile, groups[i], NULL, NULL);
|
||||
auto_gcharv gchar** keys = g_key_file_get_keys(omemo_ctx.known_devices_keyfile, groups[i], NULL, NULL);
|
||||
for (j = 0; keys[j] != NULL; j++) {
|
||||
uint32_t device_id = strtoul(keys[j], NULL, 10);
|
||||
char* fingerprint = g_key_file_get_string(omemo_ctx.known_devices_keyfile, groups[i], keys[j], NULL);
|
||||
auto_gchar gchar* fingerprint = g_key_file_get_string(omemo_ctx.known_devices_keyfile, groups[i], keys[j], NULL);
|
||||
g_hash_table_insert(known_identities, strdup(fingerprint), GINT_TO_POINTER(device_id));
|
||||
g_free(fingerprint);
|
||||
}
|
||||
g_strfreev(keys);
|
||||
}
|
||||
g_strfreev(groups);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1734,9 +1717,8 @@ _cache_device_identity(const char* const jid, uint32_t device_id, ec_public_key*
|
||||
log_debug("[OMEMO] cache identity for %s:%d: %s", jid, device_id, fingerprint);
|
||||
g_hash_table_insert(known_identities, strdup(fingerprint), GINT_TO_POINTER(device_id));
|
||||
|
||||
char* device_id_str = g_strdup_printf("%d", device_id);
|
||||
auto_gchar gchar* device_id_str = g_strdup_printf("%d", device_id);
|
||||
g_key_file_set_string(omemo_ctx.known_devices_keyfile, jid, device_id_str, fingerprint);
|
||||
g_free(device_id_str);
|
||||
omemo_known_devices_keyfile_save();
|
||||
|
||||
Autocomplete ac = g_hash_table_lookup(omemo_ctx.fingerprint_ac, jid);
|
||||
|
@ -143,11 +143,9 @@ store_session(const signal_protocol_address* address,
|
||||
signal_buffer* buffer = signal_buffer_create(record, record_len);
|
||||
g_hash_table_insert(device_store, GINT_TO_POINTER(address->device_id), buffer);
|
||||
|
||||
char* record_b64 = g_base64_encode(record, record_len);
|
||||
char* device_id = g_strdup_printf("%d", address->device_id);
|
||||
auto_gchar gchar* record_b64 = g_base64_encode(record, record_len);
|
||||
auto_gchar gchar* device_id = g_strdup_printf("%d", address->device_id);
|
||||
g_key_file_set_string(omemo_sessions_keyfile(), address->name, device_id, record_b64);
|
||||
free(device_id);
|
||||
g_free(record_b64);
|
||||
|
||||
omemo_sessions_keyfile_save();
|
||||
|
||||
@ -187,9 +185,8 @@ delete_session(const signal_protocol_address* address, void* user_data)
|
||||
|
||||
g_hash_table_remove(device_store, GINT_TO_POINTER(address->device_id));
|
||||
|
||||
char* device_id_str = g_strdup_printf("%d", address->device_id);
|
||||
auto_gchar gchar* device_id_str = g_strdup_printf("%d", address->device_id);
|
||||
g_key_file_remove_key(omemo_sessions_keyfile(), address->name, device_id_str, NULL);
|
||||
g_free(device_id_str);
|
||||
omemo_sessions_keyfile_save();
|
||||
|
||||
return SG_SUCCESS;
|
||||
@ -238,11 +235,9 @@ store_pre_key(uint32_t pre_key_id, uint8_t* record, size_t record_len,
|
||||
g_hash_table_insert(pre_key_store, GINT_TO_POINTER(pre_key_id), buffer);
|
||||
|
||||
/* Long term storage */
|
||||
char* pre_key_id_str = g_strdup_printf("%d", pre_key_id);
|
||||
char* record_b64 = g_base64_encode(record, record_len);
|
||||
auto_gchar gchar* pre_key_id_str = g_strdup_printf("%d", pre_key_id);
|
||||
auto_gchar gchar* record_b64 = g_base64_encode(record, record_len);
|
||||
g_key_file_set_string(omemo_identity_keyfile(), OMEMO_STORE_GROUP_PREKEYS, pre_key_id_str, record_b64);
|
||||
g_free(pre_key_id_str);
|
||||
g_free(record_b64);
|
||||
|
||||
omemo_identity_keyfile_save();
|
||||
|
||||
@ -265,9 +260,8 @@ remove_pre_key(uint32_t pre_key_id, void* user_data)
|
||||
int ret = g_hash_table_remove(pre_key_store, GINT_TO_POINTER(pre_key_id));
|
||||
|
||||
/* Long term storage */
|
||||
char* pre_key_id_str = g_strdup_printf("%d", pre_key_id);
|
||||
auto_gchar gchar* pre_key_id_str = g_strdup_printf("%d", pre_key_id);
|
||||
g_key_file_remove_key(omemo_identity_keyfile(), OMEMO_STORE_GROUP_PREKEYS, pre_key_id_str, NULL);
|
||||
g_free(pre_key_id_str);
|
||||
|
||||
omemo_identity_keyfile_save();
|
||||
|
||||
@ -306,11 +300,9 @@ store_signed_pre_key(uint32_t signed_pre_key_id, uint8_t* record,
|
||||
g_hash_table_insert(signed_pre_key_store, GINT_TO_POINTER(signed_pre_key_id), buffer);
|
||||
|
||||
/* Long term storage */
|
||||
char* signed_pre_key_id_str = g_strdup_printf("%d", signed_pre_key_id);
|
||||
char* record_b64 = g_base64_encode(record, record_len);
|
||||
auto_gchar gchar* signed_pre_key_id_str = g_strdup_printf("%d", signed_pre_key_id);
|
||||
auto_gchar gchar* record_b64 = g_base64_encode(record, record_len);
|
||||
g_key_file_set_string(omemo_identity_keyfile(), OMEMO_STORE_GROUP_SIGNED_PREKEYS, signed_pre_key_id_str, record_b64);
|
||||
g_free(signed_pre_key_id_str);
|
||||
g_free(record_b64);
|
||||
|
||||
omemo_identity_keyfile_save();
|
||||
|
||||
@ -333,9 +325,8 @@ remove_signed_pre_key(uint32_t signed_pre_key_id, void* user_data)
|
||||
int ret = g_hash_table_remove(signed_pre_key_store, GINT_TO_POINTER(signed_pre_key_id));
|
||||
|
||||
/* Long term storage */
|
||||
char* signed_pre_key_id_str = g_strdup_printf("%d", signed_pre_key_id);
|
||||
auto_gchar gchar* signed_pre_key_id_str = g_strdup_printf("%d", signed_pre_key_id);
|
||||
g_key_file_remove_key(omemo_identity_keyfile(), OMEMO_STORE_GROUP_PREKEYS, signed_pre_key_id_str, NULL);
|
||||
g_free(signed_pre_key_id_str);
|
||||
|
||||
omemo_identity_keyfile_save();
|
||||
|
||||
@ -393,11 +384,9 @@ save_identity(const signal_protocol_address* address, uint8_t* key_data,
|
||||
g_hash_table_insert(trusted, GINT_TO_POINTER(address->device_id), buffer);
|
||||
|
||||
/* Long term storage */
|
||||
char* key_b64 = g_base64_encode(key_data, key_len);
|
||||
char* device_id = g_strdup_printf("%d", address->device_id);
|
||||
auto_gchar gchar* key_b64 = g_base64_encode(key_data, key_len);
|
||||
auto_gchar gchar* device_id = g_strdup_printf("%d", address->device_id);
|
||||
g_key_file_set_string(omemo_trust_keyfile(), address->name, device_id, key_b64);
|
||||
g_free(device_id);
|
||||
g_free(key_b64);
|
||||
|
||||
omemo_trust_keyfile_save();
|
||||
|
||||
|
@ -874,9 +874,8 @@ static void
|
||||
_python_undefined_error(ProfPlugin* plugin, char* hook, char* type)
|
||||
{
|
||||
GString* err_msg = g_string_new("Plugin error - ");
|
||||
char* module_name = g_strndup(plugin->name, strlen(plugin->name) - 2);
|
||||
auto_gchar gchar* module_name = g_strndup(plugin->name, strlen(plugin->name) - 2);
|
||||
g_string_append(err_msg, module_name);
|
||||
free(module_name);
|
||||
g_string_append(err_msg, hook);
|
||||
g_string_append(err_msg, "(): return value undefined, expected ");
|
||||
g_string_append(err_msg, type);
|
||||
@ -889,9 +888,8 @@ static void
|
||||
_python_type_error(ProfPlugin* plugin, char* hook, char* type)
|
||||
{
|
||||
GString* err_msg = g_string_new("Plugin error - ");
|
||||
char* module_name = g_strndup(plugin->name, strlen(plugin->name) - 2);
|
||||
auto_gchar gchar* module_name = g_strndup(plugin->name, strlen(plugin->name) - 2);
|
||||
g_string_append(err_msg, module_name);
|
||||
free(module_name);
|
||||
g_string_append(err_msg, hook);
|
||||
g_string_append(err_msg, "(): incorrect return type, expected ");
|
||||
g_string_append(err_msg, type);
|
||||
|
@ -151,10 +151,9 @@ _connect_default(const char* const account)
|
||||
if (account) {
|
||||
cmd_execute_connect(window, account);
|
||||
} else {
|
||||
char* pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT);
|
||||
auto_gchar gchar* pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT);
|
||||
if (pref_connect_account) {
|
||||
cmd_execute_connect(window, pref_connect_account);
|
||||
g_free(pref_connect_account);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -198,9 +197,8 @@ _init(char* log_level, char* config_file, char* log_file, char* theme_name)
|
||||
if (theme_name) {
|
||||
theme_init(theme_name);
|
||||
} else {
|
||||
char* theme = prefs_get_string(PREF_THEME);
|
||||
auto_gchar gchar* theme = prefs_get_string(PREF_THEME);
|
||||
theme_init(theme);
|
||||
g_free(theme);
|
||||
}
|
||||
|
||||
ui_init();
|
||||
|
@ -315,7 +315,7 @@ static char*
|
||||
_autocomplete_param_common(const char* const input, char* command, autocomplete_func func, Autocomplete ac, gboolean quote, gboolean previous, void* context)
|
||||
{
|
||||
int len;
|
||||
auto_char char* command_cpy = g_strdup_printf("%s ", command);
|
||||
auto_gchar gchar* command_cpy = g_strdup_printf("%s ", command);
|
||||
if (!command_cpy) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -399,15 +399,13 @@ file_mime_type(const char* const filename)
|
||||
size_t file_header_size = fread(file_header, 1, FILE_HEADER_BYTES, fh);
|
||||
fclose(fh);
|
||||
|
||||
char* content_type = g_content_type_guess(filename, (unsigned char*)file_header, file_header_size, NULL);
|
||||
auto_gchar gchar* content_type = g_content_type_guess(filename, (unsigned char*)file_header, file_header_size, NULL);
|
||||
if (content_type != NULL) {
|
||||
char* mime_type = g_content_type_get_mime_type(content_type);
|
||||
auto_gchar gchar* mime_type = g_content_type_get_mime_type(content_type);
|
||||
out_mime_type = strdup(mime_type);
|
||||
g_free(mime_type);
|
||||
} else {
|
||||
return strdup(FALLBACK_MIMETYPE);
|
||||
}
|
||||
g_free(content_type);
|
||||
return out_mime_type;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ confwin_show_form(ProfConfWin* confwin)
|
||||
win_println(window, THEME_DEFAULT, "-", "%s", value);
|
||||
}
|
||||
} else if (g_strcmp0(field->type, "hidden") != 0 && field->var) {
|
||||
char* tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var);
|
||||
gchar* tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var);
|
||||
_confwin_form_field(window, tag, field);
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ _mucwin_print_mention(ProfWin* window, const char* const message, const char* co
|
||||
while (curr) {
|
||||
pos = GPOINTER_TO_INT(curr->data);
|
||||
|
||||
char* before_str = g_utf8_substring(message, last_pos, pos);
|
||||
auto_gchar gchar* before_str = g_utf8_substring(message, last_pos, pos);
|
||||
|
||||
if (last_pos == 0 && strncmp(before_str, "/me ", 4) == 0) {
|
||||
win_print_them(window, THEME_ROOMMENTION, ch, flags, "");
|
||||
@ -404,11 +404,9 @@ _mucwin_print_mention(ProfWin* window, const char* const message, const char* co
|
||||
}
|
||||
win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str);
|
||||
}
|
||||
g_free(before_str);
|
||||
|
||||
char* mynick_str = g_utf8_substring(message, pos, pos + mynick_len);
|
||||
auto_gchar gchar* mynick_str = g_utf8_substring(message, pos, pos + mynick_len);
|
||||
win_append_highlight(window, THEME_ROOMMENTION_TERM, "%s", mynick_str);
|
||||
g_free(mynick_str);
|
||||
|
||||
last_pos = pos + mynick_len;
|
||||
|
||||
@ -418,7 +416,7 @@ _mucwin_print_mention(ProfWin* window, const char* const message, const char* co
|
||||
glong message_len = g_utf8_strlen(message, -1);
|
||||
if (last_pos < message_len) {
|
||||
// get tail without allocating a new string
|
||||
char* rest = g_utf8_offset_to_pointer(message, last_pos);
|
||||
gchar* rest = g_utf8_offset_to_pointer(message, last_pos);
|
||||
win_appendln_highlight(window, THEME_ROOMMENTION, "%s", rest);
|
||||
} else {
|
||||
win_appendln_highlight(window, THEME_ROOMMENTION, "");
|
||||
@ -449,15 +447,15 @@ _mucwin_print_triggers(ProfWin* window, const char* const message, GList* trigge
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
char* message_lower = g_utf8_strdown(message, -1);
|
||||
auto_gchar gchar* message_lower = g_utf8_strdown(message, -1);
|
||||
|
||||
// find earliest trigger in message
|
||||
int first_trigger_pos = -1;
|
||||
int first_trigger_len = -1;
|
||||
curr = weighted_triggers;
|
||||
while (curr) {
|
||||
char* trigger_lower = g_utf8_strdown(curr->data, -1);
|
||||
char* trigger_ptr = g_strstr_len(message_lower, -1, trigger_lower);
|
||||
auto_gchar gchar* trigger_lower = g_utf8_strdown(curr->data, -1);
|
||||
gchar* trigger_ptr = g_strstr_len(message_lower, -1, trigger_lower);
|
||||
|
||||
// not found, try next
|
||||
if (trigger_ptr == NULL) {
|
||||
@ -472,11 +470,9 @@ _mucwin_print_triggers(ProfWin* window, const char* const message, GList* trigge
|
||||
first_trigger_len = strlen(trigger_lower);
|
||||
}
|
||||
|
||||
g_free(trigger_lower);
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
g_free(message_lower);
|
||||
g_list_free(weighted_triggers);
|
||||
|
||||
// no triggers found
|
||||
|
@ -368,14 +368,14 @@ _caps_by_ver(const char* const ver)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* category = g_key_file_get_string(cache, ver, "category", NULL);
|
||||
char* type = g_key_file_get_string(cache, ver, "type", NULL);
|
||||
char* name = g_key_file_get_string(cache, ver, "name", NULL);
|
||||
auto_gchar gchar* category = g_key_file_get_string(cache, ver, "category", NULL);
|
||||
auto_gchar gchar* type = g_key_file_get_string(cache, ver, "type", NULL);
|
||||
auto_gchar gchar* name = g_key_file_get_string(cache, ver, "name", NULL);
|
||||
|
||||
char* software = g_key_file_get_string(cache, ver, "software", NULL);
|
||||
char* software_version = g_key_file_get_string(cache, ver, "software_version", NULL);
|
||||
char* os = g_key_file_get_string(cache, ver, "os", NULL);
|
||||
char* os_version = g_key_file_get_string(cache, ver, "os_version", NULL);
|
||||
auto_gchar gchar* software = g_key_file_get_string(cache, ver, "software", NULL);
|
||||
auto_gchar gchar* software_version = g_key_file_get_string(cache, ver, "software_version", NULL);
|
||||
auto_gchar gchar* os = g_key_file_get_string(cache, ver, "os", NULL);
|
||||
auto_gchar gchar* os_version = g_key_file_get_string(cache, ver, "os_version", NULL);
|
||||
|
||||
gsize features_len = 0;
|
||||
gchar** features_list = g_key_file_get_string_list(cache, ver, "features", &features_len, NULL);
|
||||
@ -391,13 +391,6 @@ _caps_by_ver(const char* const ver)
|
||||
software, software_version, os, os_version,
|
||||
features);
|
||||
|
||||
g_free(category);
|
||||
g_free(type);
|
||||
g_free(name);
|
||||
g_free(software);
|
||||
g_free(software_version);
|
||||
g_free(os);
|
||||
g_free(os_version);
|
||||
if (features_list) {
|
||||
g_strfreev(features_list);
|
||||
}
|
||||
|
@ -90,10 +90,9 @@ jid_create(const gchar* const str)
|
||||
if (slashp) {
|
||||
result->resourcepart = g_strdup(slashp + 1);
|
||||
result->domainpart = g_utf8_substring(domain_start, 0, g_utf8_pointer_to_offset(domain_start, slashp));
|
||||
char* barejidraw = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, slashp));
|
||||
auto_gchar gchar* barejidraw = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, slashp));
|
||||
result->barejid = g_utf8_strdown(barejidraw, -1);
|
||||
result->fulljid = g_strdup(trimmed);
|
||||
g_free(barejidraw);
|
||||
} else {
|
||||
result->domainpart = g_strdup(domain_start);
|
||||
result->barejid = g_utf8_strdown(trimmed, -1);
|
||||
@ -189,15 +188,13 @@ create_fulljid(const char* const barejid, const char* const resource)
|
||||
char*
|
||||
get_nick_from_full_jid(const char* const full_room_jid)
|
||||
{
|
||||
char** tokens = g_strsplit(full_room_jid, "/", 0);
|
||||
auto_gcharv gchar** tokens = g_strsplit(full_room_jid, "/", 0);
|
||||
char* nick_part = NULL;
|
||||
|
||||
if (tokens) {
|
||||
if (tokens[0] && tokens[1]) {
|
||||
nick_part = strdup(tokens[1]);
|
||||
}
|
||||
|
||||
g_strfreev(tokens);
|
||||
}
|
||||
|
||||
return nick_part;
|
||||
|
@ -638,10 +638,9 @@ message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys,
|
||||
|
||||
xmpp_stanza_t* header = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(header, "header");
|
||||
char* sid_text = g_strdup_printf("%d", sid);
|
||||
auto_gchar gchar* sid_text = g_strdup_printf("%d", sid);
|
||||
log_debug("[OMEMO] Sending from device sid %s", sid_text);
|
||||
xmpp_stanza_set_attribute(header, "sid", sid_text);
|
||||
g_free(sid_text);
|
||||
|
||||
GList* key_iter;
|
||||
for (key_iter = keys; key_iter != NULL; key_iter = key_iter->next) {
|
||||
@ -649,10 +648,9 @@ message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys,
|
||||
|
||||
xmpp_stanza_t* key_stanza = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(key_stanza, "key");
|
||||
char* rid = g_strdup_printf("%d", key->device_id);
|
||||
auto_gchar gchar* rid = g_strdup_printf("%d", key->device_id);
|
||||
log_debug("[OMEMO] Sending to device rid %s", STR_MAYBE_NULL(rid));
|
||||
xmpp_stanza_set_attribute(key_stanza, "rid", rid);
|
||||
g_free(rid);
|
||||
if (key->prekey) {
|
||||
xmpp_stanza_set_attribute(key_stanza, "prekey", "true");
|
||||
}
|
||||
@ -1625,19 +1623,16 @@ message_is_sent_by_us(const ProfMessage* const message, bool checkOID)
|
||||
|
||||
// our client sents at CON_RAND_ID_LEN + identifier
|
||||
if (tmp_len > CON_RAND_ID_LEN) {
|
||||
char* uuid = g_strndup(tmp_id, CON_RAND_ID_LEN);
|
||||
auto_gchar gchar* uuid = g_strndup(tmp_id, CON_RAND_ID_LEN);
|
||||
const char* prof_identifier = connection_get_profanity_identifier();
|
||||
|
||||
gchar* hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA1,
|
||||
auto_gchar gchar* hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA1,
|
||||
(guchar*)prof_identifier, strlen(prof_identifier),
|
||||
uuid, strlen(uuid));
|
||||
|
||||
if (g_strcmp0(&tmp_id[CON_RAND_ID_LEN], hmac) == 0) {
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
g_free(uuid);
|
||||
g_free(hmac);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -669,11 +669,10 @@ _omemo_bundle_publish_result(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||
Jid* jid = jid_create(connection_get_fulljid());
|
||||
char* id = connection_create_stanza_id();
|
||||
char* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id());
|
||||
auto_gchar gchar* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id());
|
||||
log_debug("[OMEMO] node: %s", node);
|
||||
|
||||
xmpp_stanza_t* iq = stanza_create_pubsub_configure_request(ctx, id, jid->barejid, node);
|
||||
g_free(node);
|
||||
|
||||
iq_id_handler_add(id, _omemo_bundle_publish_configure, NULL, userdata);
|
||||
|
||||
@ -712,9 +711,8 @@ _omemo_bundle_publish_configure(xmpp_stanza_t* const stanza, void* const userdat
|
||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||
Jid* jid = jid_create(connection_get_fulljid());
|
||||
char* id = connection_create_stanza_id();
|
||||
char* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id());
|
||||
auto_gchar gchar* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id());
|
||||
xmpp_stanza_t* iq = stanza_create_pubsub_configure_submit(ctx, id, jid->barejid, node, form);
|
||||
g_free(node);
|
||||
|
||||
iq_id_handler_add(id, _omemo_bundle_publish_configure_result, NULL, userdata);
|
||||
|
||||
|
@ -2329,9 +2329,8 @@ stanza_create_omemo_devicelist_publish(xmpp_ctx_t* ctx, GList* const ids)
|
||||
for (GList* i = ids; i != NULL; i = i->next) {
|
||||
xmpp_stanza_t* device = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(device, "device");
|
||||
char* id = g_strdup_printf("%d", GPOINTER_TO_INT(i->data));
|
||||
auto_gchar gchar* id = g_strdup_printf("%d", GPOINTER_TO_INT(i->data));
|
||||
xmpp_stanza_set_attribute(device, "id", id);
|
||||
g_free(id);
|
||||
|
||||
xmpp_stanza_add_child(list, device);
|
||||
xmpp_stanza_release(device);
|
||||
@ -2366,9 +2365,8 @@ stanza_create_omemo_bundle_publish(xmpp_ctx_t* ctx, const char* const id,
|
||||
|
||||
xmpp_stanza_t* publish = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH);
|
||||
char* node = g_strdup_printf("%s:%d", "eu.siacs.conversations.axolotl.bundles", device_id);
|
||||
auto_gchar gchar* node = g_strdup_printf("%s:%d", "eu.siacs.conversations.axolotl.bundles", device_id);
|
||||
xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, node);
|
||||
g_free(node);
|
||||
|
||||
xmpp_stanza_t* item = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
|
||||
@ -2416,9 +2414,8 @@ stanza_create_omemo_bundle_publish(xmpp_ctx_t* ctx, const char* const id,
|
||||
for (p = prekeys, i = prekeys_id, l = prekeys_length; p != NULL; p = p->next, i = i->next, l = l->next) {
|
||||
xmpp_stanza_t* prekey = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(prekey, "preKeyPublic");
|
||||
char* id = g_strdup_printf("%d", GPOINTER_TO_INT(i->data));
|
||||
auto_gchar gchar* id = g_strdup_printf("%d", GPOINTER_TO_INT(i->data));
|
||||
xmpp_stanza_set_attribute(prekey, "preKeyId", id);
|
||||
g_free(id);
|
||||
|
||||
xmpp_stanza_t* prekey_text = xmpp_stanza_new(ctx);
|
||||
char* prekey_b64 = g_base64_encode(p->data, GPOINTER_TO_INT(l->data));
|
||||
@ -2464,9 +2461,8 @@ stanza_create_omemo_bundle_request(xmpp_ctx_t* ctx, const char* const id, const
|
||||
|
||||
xmpp_stanza_t* items = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(items, "items");
|
||||
char* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, device_id);
|
||||
auto_gchar gchar* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, device_id);
|
||||
xmpp_stanza_set_attribute(items, STANZA_ATTR_NODE, node);
|
||||
g_free(node);
|
||||
|
||||
xmpp_stanza_add_child(pubsub, items);
|
||||
xmpp_stanza_add_child(iq, pubsub);
|
||||
@ -2577,9 +2573,8 @@ stanza_create_avatar_retrieve_data_request(xmpp_ctx_t* ctx, const char* stanza_i
|
||||
|
||||
xmpp_stanza_t* items = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(items, "items");
|
||||
char* node = g_strdup_printf("%s", STANZA_NS_USER_AVATAR_DATA);
|
||||
auto_gchar gchar* node = g_strdup_printf("%s", STANZA_NS_USER_AVATAR_DATA);
|
||||
xmpp_stanza_set_attribute(items, STANZA_ATTR_NODE, node);
|
||||
g_free(node);
|
||||
|
||||
xmpp_stanza_t* item = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
|
||||
@ -2671,16 +2666,13 @@ stanza_create_avatar_metadata_publish_iq(xmpp_ctx_t* ctx, const char* img_data,
|
||||
xmpp_stanza_set_name(info, STANZA_NAME_INFO);
|
||||
xmpp_stanza_set_attribute(info, "id", sha1);
|
||||
xmpp_free(ctx, sha1);
|
||||
char* bytes = g_strdup_printf("%" G_GSIZE_FORMAT, len);
|
||||
char* h = g_strdup_printf("%d", height);
|
||||
char* w = g_strdup_printf("%d", width);
|
||||
auto_gchar gchar* bytes = g_strdup_printf("%" G_GSIZE_FORMAT, len);
|
||||
auto_gchar gchar* h = g_strdup_printf("%d", height);
|
||||
auto_gchar gchar* w = g_strdup_printf("%d", width);
|
||||
xmpp_stanza_set_attribute(info, "bytes", bytes);
|
||||
xmpp_stanza_set_attribute(info, "type", "img/png");
|
||||
xmpp_stanza_set_attribute(info, "height", h);
|
||||
xmpp_stanza_set_attribute(info, "width", w);
|
||||
g_free(bytes);
|
||||
g_free(h);
|
||||
g_free(w);
|
||||
|
||||
xmpp_stanza_add_child(metadata, info);
|
||||
xmpp_stanza_add_child(item, metadata);
|
||||
@ -2854,9 +2846,8 @@ stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const s
|
||||
xmpp_stanza_set_name(max, STANZA_NAME_MAX);
|
||||
|
||||
max_text = xmpp_stanza_new(ctx);
|
||||
char* txt = g_strdup_printf("%d", MESSAGES_TO_RETRIEVE);
|
||||
auto_gchar gchar* txt = g_strdup_printf("%d", MESSAGES_TO_RETRIEVE);
|
||||
xmpp_stanza_set_text(max_text, txt);
|
||||
g_free(txt);
|
||||
|
||||
xmpp_stanza_add_child(max, max_text);
|
||||
xmpp_stanza_add_child(set, max);
|
||||
|
@ -64,10 +64,10 @@ cmd_join_shows_error_message_when_invalid_room_jid(void** state)
|
||||
void
|
||||
cmd_join_uses_account_mucservice_when_no_service_specified(void** state)
|
||||
{
|
||||
char* account_name = g_strdup("an_account");
|
||||
gchar* account_name = g_strdup("an_account");
|
||||
char* room = "room";
|
||||
char* nick = "bob";
|
||||
char* account_service = g_strdup("conference.server.org");
|
||||
gchar* account_service = g_strdup("conference.server.org");
|
||||
char* expected_room = "room@conference.server.org";
|
||||
gchar* args[] = { room, "nick", nick, NULL };
|
||||
ProfAccount* account = account_new(account_name, g_strdup("user@server.org"), NULL, NULL,
|
||||
@ -94,7 +94,7 @@ cmd_join_uses_account_mucservice_when_no_service_specified(void** state)
|
||||
void
|
||||
cmd_join_uses_supplied_nick(void** state)
|
||||
{
|
||||
char* account_name = g_strdup("an_account");
|
||||
gchar* account_name = g_strdup("an_account");
|
||||
char* room = "room@conf.server.org";
|
||||
char* nick = "bob";
|
||||
gchar* args[] = { room, "nick", nick, NULL };
|
||||
@ -122,9 +122,9 @@ cmd_join_uses_supplied_nick(void** state)
|
||||
void
|
||||
cmd_join_uses_account_nick_when_not_supplied(void** state)
|
||||
{
|
||||
char* account_name = g_strdup("an_account");
|
||||
gchar* account_name = g_strdup("an_account");
|
||||
char* room = "room2@conf.server.org";
|
||||
char* account_nick = g_strdup("a_nick");
|
||||
gchar* account_nick = g_strdup("a_nick");
|
||||
gchar* args[] = { room, NULL };
|
||||
ProfAccount* account = account_new(account_name, g_strdup("user@server.org"), NULL, NULL,
|
||||
TRUE, NULL, 0, g_strdup("laptop"), NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0);
|
||||
@ -150,11 +150,11 @@ cmd_join_uses_account_nick_when_not_supplied(void** state)
|
||||
void
|
||||
cmd_join_uses_password_when_supplied(void** state)
|
||||
{
|
||||
char* account_name = g_strdup("an_account");
|
||||
gchar* account_name = g_strdup("an_account");
|
||||
char* room = "room";
|
||||
char* password = "a_password";
|
||||
char* account_nick = g_strdup("a_nick");
|
||||
char* account_service = g_strdup("a_service");
|
||||
gchar* account_nick = g_strdup("a_nick");
|
||||
gchar* account_service = g_strdup("a_service");
|
||||
char* expected_room = "room@a_service";
|
||||
gchar* args[] = { room, "password", password, NULL };
|
||||
ProfAccount* account = account_new(account_name, g_strdup("user@server.org"), NULL, NULL,
|
||||
|
@ -194,7 +194,7 @@ void
|
||||
cmd_otr_gen_generates_key_for_connected_account(void** state)
|
||||
{
|
||||
gchar* args[] = { "gen", NULL };
|
||||
char* account_name = g_strdup("myaccount");
|
||||
gchar* account_name = g_strdup("myaccount");
|
||||
ProfAccount* account = account_new(account_name, g_strdup("me@jabber.org"), NULL, NULL,
|
||||
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0);
|
||||
|
||||
|
@ -400,7 +400,7 @@ unique_filename_from_url_td(void** state)
|
||||
{
|
||||
|
||||
enum table { num_tests = 15 };
|
||||
char* pwd = g_get_current_dir();
|
||||
auto_gchar gchar* pwd = g_get_current_dir();
|
||||
|
||||
unique_filename_from_url_t tests[num_tests] = {
|
||||
(unique_filename_from_url_t){
|
||||
@ -506,8 +506,6 @@ unique_filename_from_url_td(void** state)
|
||||
free(got_filename);
|
||||
free(exp_filename);
|
||||
}
|
||||
|
||||
g_free(pwd);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
Loading…
Reference in New Issue
Block a user