mirror of
https://github.com/profanity-im/profanity.git
synced 2025-07-26 12:14:28 -04:00
Merge branch 'master' into winbuffers
Conflicts: src/ui/core.c
This commit is contained in:
commit
dada879347
@ -2766,6 +2766,7 @@ cmd_otr(gchar **args, struct cmd_help_t help)
|
|||||||
if (strcmp(args[0], "gen") == 0) {
|
if (strcmp(args[0], "gen") == 0) {
|
||||||
ProfAccount *account = accounts_get_account(jabber_get_account_name());
|
ProfAccount *account = accounts_get_account(jabber_get_account_name());
|
||||||
otr_keygen(account);
|
otr_keygen(account);
|
||||||
|
account_free(account);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
} else if (strcmp(args[0], "myfp") == 0) {
|
} else if (strcmp(args[0], "myfp") == 0) {
|
||||||
|
@ -223,11 +223,12 @@ _get_most_available_resource(PContact contact)
|
|||||||
// xa
|
// xa
|
||||||
// dnd
|
// dnd
|
||||||
GList *resources = g_hash_table_get_values(contact->available_resources);
|
GList *resources = g_hash_table_get_values(contact->available_resources);
|
||||||
Resource *current = resources->data;
|
GList *curr = resources;
|
||||||
|
Resource *current = curr->data;
|
||||||
Resource *highest = current;
|
Resource *highest = current;
|
||||||
resources = g_list_next(resources);
|
curr = g_list_next(curr);
|
||||||
while (resources != NULL) {
|
while (curr != NULL) {
|
||||||
current = resources->data;
|
current = curr->data;
|
||||||
|
|
||||||
// priority is same as current highest, choose presence
|
// priority is same as current highest, choose presence
|
||||||
if (current->priority == highest->priority) {
|
if (current->priority == highest->priority) {
|
||||||
@ -238,8 +239,9 @@ _get_most_available_resource(PContact contact)
|
|||||||
highest = current;
|
highest = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
resources = g_list_next(resources);
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
|
g_list_free(resources);
|
||||||
|
|
||||||
return highest;
|
return highest;
|
||||||
}
|
}
|
||||||
|
19
src/log.c
19
src/log.c
@ -330,9 +330,9 @@ groupchat_log_chat(const gchar * const login, const gchar * const room,
|
|||||||
|
|
||||||
|
|
||||||
GSList *
|
GSList *
|
||||||
chat_log_get_previous(const gchar * const login, const gchar * const recipient,
|
chat_log_get_previous(const gchar * const login, const gchar * const recipient)
|
||||||
GSList *history)
|
|
||||||
{
|
{
|
||||||
|
GSList *history = NULL;
|
||||||
GDateTime *now = g_date_time_new_now_local();
|
GDateTime *now = g_date_time_new_now_local();
|
||||||
GDateTime *log_date = g_date_time_new(tz,
|
GDateTime *log_date = g_date_time_new(tz,
|
||||||
g_date_time_get_year(session_started),
|
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");
|
FILE *logp = fopen(filename, "r");
|
||||||
if (logp != NULL) {
|
if (logp != NULL) {
|
||||||
GString *gs_header = g_string_new("");
|
GString *header = g_string_new("");
|
||||||
g_string_append_printf(gs_header, "%d/%d/%d:",
|
g_string_append_printf(header, "%d/%d/%d:",
|
||||||
g_date_time_get_day_of_month(log_date),
|
g_date_time_get_day_of_month(log_date),
|
||||||
g_date_time_get_month(log_date),
|
g_date_time_get_month(log_date),
|
||||||
g_date_time_get_year(log_date));
|
g_date_time_get_year(log_date));
|
||||||
char *header = strdup(gs_header->str);
|
history = g_slist_append(history, header->str);
|
||||||
history = g_slist_append(history, header);
|
g_string_free(header, FALSE);
|
||||||
g_string_free(gs_header, TRUE);
|
|
||||||
|
|
||||||
char *line;
|
char *line;
|
||||||
while ((line = prof_getline(logp)) != NULL) {
|
while ((line = prof_getline(logp)) != NULL) {
|
||||||
@ -366,11 +365,15 @@ chat_log_get_previous(const gchar * const login, const gchar * const recipient,
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(filename);
|
free(filename);
|
||||||
|
|
||||||
GDateTime *next = g_date_time_add_days(log_date, 1);
|
GDateTime *next = g_date_time_add_days(log_date, 1);
|
||||||
g_date_time_unref(log_date);
|
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;
|
return history;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
const gchar * const msg, chat_log_direction_t direction, GTimeVal *tv_stamp);
|
||||||
void chat_log_close(void);
|
void chat_log_close(void);
|
||||||
GSList * chat_log_get_previous(const gchar * const login,
|
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_init(void);
|
||||||
void groupchat_log_chat(const gchar * const login, const gchar * const room,
|
void groupchat_log_chat(const gchar * const login, const gchar * const room,
|
||||||
|
@ -163,6 +163,14 @@ _otr_init(void)
|
|||||||
data_loaded = FALSE;
|
data_loaded = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_otr_shutdown(void)
|
||||||
|
{
|
||||||
|
if (jid != NULL) {
|
||||||
|
free(jid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_otr_poll(void)
|
_otr_poll(void)
|
||||||
{
|
{
|
||||||
@ -172,6 +180,9 @@ _otr_poll(void)
|
|||||||
static void
|
static void
|
||||||
_otr_on_connect(ProfAccount *account)
|
_otr_on_connect(ProfAccount *account)
|
||||||
{
|
{
|
||||||
|
if (jid != NULL) {
|
||||||
|
free(jid);
|
||||||
|
}
|
||||||
jid = strdup(account->jid);
|
jid = strdup(account->jid);
|
||||||
log_info("Loading OTR key for %s", jid);
|
log_info("Loading OTR key for %s", jid);
|
||||||
|
|
||||||
@ -253,11 +264,12 @@ _otr_keygen(ProfAccount *account)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (jid != NULL) {
|
||||||
|
free(jid);
|
||||||
|
}
|
||||||
jid = strdup(account->jid);
|
jid = strdup(account->jid);
|
||||||
log_info("Generating OTR key for %s", jid);
|
log_info("Generating OTR key for %s", jid);
|
||||||
|
|
||||||
jid = strdup(account->jid);
|
|
||||||
|
|
||||||
gchar *data_home = xdg_get_data_home();
|
gchar *data_home = xdg_get_data_home();
|
||||||
GString *basedir = g_string_new(data_home);
|
GString *basedir = g_string_new(data_home);
|
||||||
free(data_home);
|
free(data_home);
|
||||||
@ -634,6 +646,7 @@ void
|
|||||||
otr_init_module(void)
|
otr_init_module(void)
|
||||||
{
|
{
|
||||||
otr_init = _otr_init;
|
otr_init = _otr_init;
|
||||||
|
otr_shutdown = _otr_shutdown;
|
||||||
otr_libotr_version = _otr_libotr_version;
|
otr_libotr_version = _otr_libotr_version;
|
||||||
otr_start_query = _otr_start_query;
|
otr_start_query = _otr_start_query;
|
||||||
otr_poll = _otr_poll;
|
otr_poll = _otr_poll;
|
||||||
|
@ -41,6 +41,7 @@ OtrlMessageAppOps* otr_messageops(void);
|
|||||||
GHashTable* otr_smpinitators(void);
|
GHashTable* otr_smpinitators(void);
|
||||||
|
|
||||||
void (*otr_init)(void);
|
void (*otr_init)(void);
|
||||||
|
void (*otr_shutdown)(void);
|
||||||
char* (*otr_libotr_version)(void);
|
char* (*otr_libotr_version)(void);
|
||||||
char* (*otr_start_query)(void);
|
char* (*otr_start_query)(void);
|
||||||
void (*otr_poll)(void);
|
void (*otr_poll)(void);
|
||||||
|
@ -305,6 +305,9 @@ _shutdown(void)
|
|||||||
muc_close();
|
muc_close();
|
||||||
caps_close();
|
caps_close();
|
||||||
ui_close();
|
ui_close();
|
||||||
|
#ifdef HAVE_LIBOTR
|
||||||
|
otr_shutdown();
|
||||||
|
#endif
|
||||||
chat_log_close();
|
chat_log_close();
|
||||||
prefs_close();
|
prefs_close();
|
||||||
theme_close();
|
theme_close();
|
||||||
|
@ -135,6 +135,9 @@ _ui_get_idle_time(void)
|
|||||||
XFree(info);
|
XFree(info);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
if (info != NULL) {
|
||||||
|
XFree(info);
|
||||||
|
}
|
||||||
// if no libxss or xss idle time failed, use profanity idle time
|
// if no libxss or xss idle time failed, use profanity idle time
|
||||||
#endif
|
#endif
|
||||||
gdouble seconds_elapsed = g_timer_elapsed(ui_idle_time, NULL);
|
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);
|
ProfWin *window = wins_get_by_num(win_index);
|
||||||
if (!window->history_shown) {
|
if (!window->history_shown) {
|
||||||
GSList *history = NULL;
|
|
||||||
Jid *jid = jid_create(jabber_get_fulljid());
|
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);
|
jid_destroy(jid);
|
||||||
while (history != NULL) {
|
GSList *curr = history;
|
||||||
win_save_print(window, '-', NULL, NO_DATE, 0, "", history->data);
|
while (curr != NULL) {
|
||||||
history = g_slist_next(history);
|
win_save_print(window, '-', NULL, NO_DATE, 0, "", curr->data);
|
||||||
|
curr = g_slist_next(curr);
|
||||||
}
|
}
|
||||||
window->history_shown = 1;
|
window->history_shown = 1;
|
||||||
|
|
||||||
|
@ -166,8 +166,10 @@ _title_bar_draw(void)
|
|||||||
// show privacy
|
// show privacy
|
||||||
if (current_recipient != NULL) {
|
if (current_recipient != NULL) {
|
||||||
char *recipient_jid = 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);
|
recipient_jid = roster_barejid_from_name(current_recipient);
|
||||||
|
free(found_contact);
|
||||||
} else {
|
} else {
|
||||||
recipient_jid = current_recipient;
|
recipient_jid = current_recipient;
|
||||||
}
|
}
|
||||||
|
@ -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) {}
|
const gchar * const msg, chat_log_direction_t direction, GTimeVal *tv_stamp) {}
|
||||||
void chat_log_close(void) {}
|
void chat_log_close(void) {}
|
||||||
GSList * chat_log_get_previous(const gchar * const login,
|
GSList * chat_log_get_previous(const gchar * const login,
|
||||||
const gchar * const recipient, GSList *history)
|
const gchar * const recipient)
|
||||||
{
|
{
|
||||||
return mock_ptr_type(GSList *);
|
return mock_ptr_type(GSList *);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user