1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Merge branch 'master' into otr

This commit is contained in:
James Booth 2013-09-23 01:38:48 +01:00
commit aac605ccbb
7 changed files with 24 additions and 18 deletions

3
configure-debug Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
./configure CFLAGS='-g -O0' CXXFLAGS='-g -O0'

View File

@ -1384,6 +1384,7 @@ _cmd_connect(gchar **args, struct cmd_help_t help)
cons_show("Connecting as %s", jid);
conn_status = jabber_connect_with_details(jid, passwd, altdomain);
}
g_free(lower);
if (conn_status == JABBER_DISCONNECTED) {
cons_show_error("Connection attempt for %s failed.", jid);
@ -2747,6 +2748,7 @@ static gboolean
_cmd_join(gchar **args, struct cmd_help_t help)
{
jabber_conn_status_t conn_status = jabber_get_connection_status();
ProfAccount *account = accounts_get_account(jabber_get_account_name());
if (conn_status != JABBER_CONNECTED) {
cons_show("You are not currently connected.");
@ -2771,7 +2773,6 @@ _cmd_join(gchar **args, struct cmd_help_t help)
// server not supplied (room), use account preference
} else {
ProfAccount *account = accounts_get_account(jabber_get_account_name());
g_string_append(room_str, args[0]);
g_string_append(room_str, "@");
g_string_append(room_str, account->muc_service);
@ -2784,7 +2785,6 @@ _cmd_join(gchar **args, struct cmd_help_t help)
// otherwise use account preference
} else {
ProfAccount *account = accounts_get_account(jabber_get_account_name());
nick = account->muc_nick;
}
@ -2800,6 +2800,7 @@ _cmd_join(gchar **args, struct cmd_help_t help)
jid_destroy(room_jid);
jid_destroy(my_jid);
g_string_free(room_str, TRUE);
accounts_free_account(account);
return TRUE;
}

View File

@ -250,7 +250,7 @@ accounts_get_account(const char * const name)
g_string_free(g_muc_service, TRUE);
jid_destroy(jidp);
} else {
account->muc_service = strdup(muc_service);
account->muc_service = muc_service;
}
gchar *muc_nick = g_key_file_get_string(accounts, name, "muc.nick", NULL);
@ -259,7 +259,7 @@ accounts_get_account(const char * const name)
account->muc_nick = strdup(jidp->localpart);
jid_destroy(jidp);
} else {
account->muc_nick = strdup(muc_nick);
account->muc_nick = muc_nick;
}
// get room history

View File

@ -214,18 +214,17 @@ void
chat_log_chat(const gchar * const login, gchar *other,
const gchar * const msg, chat_log_direction_t direction, GTimeVal *tv_stamp)
{
gchar *other_copy = strdup(other);
struct dated_chat_log *dated_log = g_hash_table_lookup(logs, other_copy);
struct dated_chat_log *dated_log = g_hash_table_lookup(logs, other);
// no log for user
if (dated_log == NULL) {
dated_log = _create_log(other_copy, login);
g_hash_table_insert(logs, other_copy, dated_log);
dated_log = _create_log(other, login);
g_hash_table_insert(logs, strdup(other), dated_log);
// log exists but needs rolling
} else if (_log_roll_needed(dated_log)) {
dated_log = _create_log(other_copy, login);
g_hash_table_replace(logs, other_copy, dated_log);
dated_log = _create_log(other, login);
g_hash_table_replace(logs, strdup(other), dated_log);
}
gchar *date_fmt = NULL;
@ -242,9 +241,9 @@ chat_log_chat(const gchar * const login, gchar *other,
if (direction == PROF_IN_LOG) {
if (strncmp(msg, "/me ", 4) == 0) {
fprintf(logp, "%s - *%s %s\n", date_fmt, other_copy, msg + 4);
fprintf(logp, "%s - *%s %s\n", date_fmt, other, msg + 4);
} else {
fprintf(logp, "%s - %s: %s\n", date_fmt, other_copy, msg);
fprintf(logp, "%s - %s: %s\n", date_fmt, other, msg);
}
} else {
if (strncmp(msg, "/me ", 4) == 0) {
@ -413,8 +412,8 @@ _free_chat_log(struct dated_chat_log *dated_log)
g_date_time_unref(dated_log->date);
dated_log->date = NULL;
}
free(dated_log);
}
dated_log = NULL;
}
static
@ -450,6 +449,7 @@ _get_log_filename(const char * const other, const char * const login,
gchar *date = g_date_time_format(dt, "/%Y_%m_%d.log");
g_string_append(log_file, date);
g_free(date);
char *result = strdup(log_file->str);
g_string_free(log_file, TRUE);
@ -486,6 +486,7 @@ _get_groupchat_log_filename(const char * const room, const char * const login,
gchar *date = g_date_time_format(dt, "/%Y_%m_%d.log");
g_string_append(log_file, date);
g_free(date);
char *result = strdup(log_file->str);
g_string_free(log_file, TRUE);

View File

@ -198,7 +198,9 @@ prof_handle_error_message(const char *from, const char *err_msg)
}
// remove the room from muc
Jid *room_jid = jid_create(from);
muc_leave_room(room_jid->barejid);
if (!muc_get_roster_received(room_jid->barejid)) {
muc_leave_room(room_jid->barejid);
}
jid_destroy(room_jid);
} else {

View File

@ -176,7 +176,7 @@ autocomplete_param_with_func(char *input, int *size, char *command,
char *auto_msg = NULL;
char inp_cpy[*size];
int i;
char *command_cpy = malloc(strlen(command) + 2);
char command_cpy[strlen(command) + 2];
sprintf(command_cpy, "%s ", command);
int len = strlen(command_cpy);
if ((strncmp(input, command_cpy, len) == 0) && (*size > len)) {
@ -192,7 +192,6 @@ autocomplete_param_with_func(char *input, int *size, char *command,
free(found);
}
}
free(command_cpy);
return auto_msg;
}

View File

@ -260,12 +260,13 @@ parse_args_with_freetext(const char * const inp, int min, int max)
tokens = g_slist_append(tokens, g_strndup(token_start, token_size));
}
free(copy);
int num = g_slist_length(tokens) - 1;
// if num args not valid return NULL
if ((num < min) || (num > max)) {
g_slist_free_full(tokens, free);
free(copy);
return NULL;
// if min allowed is 0 and 0 found, return empty char* array
@ -288,7 +289,6 @@ parse_args_with_freetext(const char * const inp, int min, int max)
args[arg_count] = NULL;
g_slist_free_full(tokens, free);
free(copy);
return args;
}