1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into winbuffers

Conflicts:
	src/ui/core.c
This commit is contained in:
James Booth 2014-06-27 00:52:52 +01:00
commit dada879347
10 changed files with 51 additions and 23 deletions

View File

@ -2766,6 +2766,7 @@ cmd_otr(gchar **args, struct cmd_help_t help)
if (strcmp(args[0], "gen") == 0) {
ProfAccount *account = accounts_get_account(jabber_get_account_name());
otr_keygen(account);
account_free(account);
return TRUE;
} else if (strcmp(args[0], "myfp") == 0) {

View File

@ -223,11 +223,12 @@ _get_most_available_resource(PContact contact)
// xa
// dnd
GList *resources = g_hash_table_get_values(contact->available_resources);
Resource *current = resources->data;
GList *curr = resources;
Resource *current = curr->data;
Resource *highest = current;
resources = g_list_next(resources);
while (resources != NULL) {
current = resources->data;
curr = g_list_next(curr);
while (curr != NULL) {
current = curr->data;
// priority is same as current highest, choose presence
if (current->priority == highest->priority) {
@ -238,8 +239,9 @@ _get_most_available_resource(PContact contact)
highest = current;
}
resources = g_list_next(resources);
curr = g_list_next(curr);
}
g_list_free(resources);
return highest;
}

View File

@ -330,9 +330,9 @@ groupchat_log_chat(const gchar * const login, const gchar * const room,
GSList *
chat_log_get_previous(const gchar * const login, const gchar * const recipient,
GSList *history)
chat_log_get_previous(const gchar * const login, const gchar * const recipient)
{
GSList *history = NULL;
GDateTime *now = g_date_time_new_now_local();
GDateTime *log_date = g_date_time_new(tz,
g_date_time_get_year(session_started),
@ -348,14 +348,13 @@ chat_log_get_previous(const gchar * const login, const gchar * const recipient,
FILE *logp = fopen(filename, "r");
if (logp != NULL) {
GString *gs_header = g_string_new("");
g_string_append_printf(gs_header, "%d/%d/%d:",
GString *header = g_string_new("");
g_string_append_printf(header, "%d/%d/%d:",
g_date_time_get_day_of_month(log_date),
g_date_time_get_month(log_date),
g_date_time_get_year(log_date));
char *header = strdup(gs_header->str);
history = g_slist_append(history, header);
g_string_free(gs_header, TRUE);
history = g_slist_append(history, header->str);
g_string_free(header, FALSE);
char *line;
while ((line = prof_getline(logp)) != NULL) {
@ -366,11 +365,15 @@ chat_log_get_previous(const gchar * const login, const gchar * const recipient,
}
free(filename);
GDateTime *next = g_date_time_add_days(log_date, 1);
g_date_time_unref(log_date);
log_date = g_date_time_ref(next);
log_date = next;
}
g_date_time_unref(log_date);
g_date_time_unref(now);
return history;
}

View File

@ -56,7 +56,7 @@ void chat_log_chat(const gchar * const login, gchar *other,
const gchar * const msg, chat_log_direction_t direction, GTimeVal *tv_stamp);
void chat_log_close(void);
GSList * chat_log_get_previous(const gchar * const login,
const gchar * const recipient, GSList *history);
const gchar * const recipient);
void groupchat_log_init(void);
void groupchat_log_chat(const gchar * const login, const gchar * const room,

View File

@ -163,6 +163,14 @@ _otr_init(void)
data_loaded = FALSE;
}
static void
_otr_shutdown(void)
{
if (jid != NULL) {
free(jid);
}
}
void
_otr_poll(void)
{
@ -172,6 +180,9 @@ _otr_poll(void)
static void
_otr_on_connect(ProfAccount *account)
{
if (jid != NULL) {
free(jid);
}
jid = strdup(account->jid);
log_info("Loading OTR key for %s", jid);
@ -253,11 +264,12 @@ _otr_keygen(ProfAccount *account)
return;
}
if (jid != NULL) {
free(jid);
}
jid = strdup(account->jid);
log_info("Generating OTR key for %s", jid);
jid = strdup(account->jid);
gchar *data_home = xdg_get_data_home();
GString *basedir = g_string_new(data_home);
free(data_home);
@ -634,6 +646,7 @@ void
otr_init_module(void)
{
otr_init = _otr_init;
otr_shutdown = _otr_shutdown;
otr_libotr_version = _otr_libotr_version;
otr_start_query = _otr_start_query;
otr_poll = _otr_poll;

View File

@ -41,6 +41,7 @@ OtrlMessageAppOps* otr_messageops(void);
GHashTable* otr_smpinitators(void);
void (*otr_init)(void);
void (*otr_shutdown)(void);
char* (*otr_libotr_version)(void);
char* (*otr_start_query)(void);
void (*otr_poll)(void);

View File

@ -305,6 +305,9 @@ _shutdown(void)
muc_close();
caps_close();
ui_close();
#ifdef HAVE_LIBOTR
otr_shutdown();
#endif
chat_log_close();
prefs_close();
theme_close();

View File

@ -135,6 +135,9 @@ _ui_get_idle_time(void)
XFree(info);
return result;
}
if (info != NULL) {
XFree(info);
}
// if no libxss or xss idle time failed, use profanity idle time
#endif
gdouble seconds_elapsed = g_timer_elapsed(ui_idle_time, NULL);
@ -2054,13 +2057,13 @@ _win_show_history(WINDOW *win, int win_index, const char * const contact)
{
ProfWin *window = wins_get_by_num(win_index);
if (!window->history_shown) {
GSList *history = NULL;
Jid *jid = jid_create(jabber_get_fulljid());
history = chat_log_get_previous(jid->barejid, contact, history);
GSList *history = chat_log_get_previous(jid->barejid, contact);
jid_destroy(jid);
while (history != NULL) {
win_save_print(window, '-', NULL, NO_DATE, 0, "", history->data);
history = g_slist_next(history);
GSList *curr = history;
while (curr != NULL) {
win_save_print(window, '-', NULL, NO_DATE, 0, "", curr->data);
curr = g_slist_next(curr);
}
window->history_shown = 1;

View File

@ -166,8 +166,10 @@ _title_bar_draw(void)
// show privacy
if (current_recipient != NULL) {
char *recipient_jid = NULL;
if (roster_find_contact(current_recipient) != NULL) {
char *found_contact = roster_find_contact(current_recipient);
if (found_contact != NULL) {
recipient_jid = roster_barejid_from_name(current_recipient);
free(found_contact);
} else {
recipient_jid = current_recipient;
}

View File

@ -54,7 +54,7 @@ void chat_log_chat(const gchar * const login, gchar *other,
const gchar * const msg, chat_log_direction_t direction, GTimeVal *tv_stamp) {}
void chat_log_close(void) {}
GSList * chat_log_get_previous(const gchar * const login,
const gchar * const recipient, GSList *history)
const gchar * const recipient)
{
return mock_ptr_type(GSList *);
}