1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-02-02 15:08:15 -05:00

Merge branch 'master' into osx-functional

This commit is contained in:
James Booth 2016-07-25 23:37:38 +01:00
commit 8c5373fcdf
7 changed files with 35 additions and 21 deletions

View File

@ -589,9 +589,11 @@ cmd_account_default(ProfWin *window, const char *const command, gchar **args)
}
} else if (g_strv_length(args) == 3) {
if (strcmp(args[1], "set") == 0) {
if (accounts_get_account(args[2])) {
ProfAccount *account_p = accounts_get_account(args[2]);
if (account_p) {
prefs_set_string(PREF_DEFAULT_ACCOUNT, args[2]);
cons_show("Default account set to %s.", args[2]);
account_free(account_p);
} else {
cons_show("Account %s does not exist.", args[2]);
}

View File

@ -79,7 +79,8 @@ sv_ev_login_account_success(char *account_name, gboolean secured)
ui_handle_login_account_success(account, secured);
// attempt to rejoin rooms with passwords
GList *curr = muc_rooms();
GList *rooms = muc_rooms();
GList *curr = rooms;
while (curr) {
char *password = muc_password(curr->data);
if (password) {
@ -88,7 +89,7 @@ sv_ev_login_account_success(char *account_name, gboolean secured)
}
curr = g_list_next(curr);
}
g_list_free(curr);
g_list_free(rooms);
log_info("%s logged in successfully", account->jid);

View File

@ -102,6 +102,7 @@ rosterwin_roster(void)
} else {
GList *rooms = muc_rooms();
_rosterwin_rooms(layout, "Rooms", rooms);
g_list_free(rooms);
}
prefs_free_string(roomsbypref);
@ -162,6 +163,7 @@ rosterwin_roster(void)
} else {
GList *rooms = muc_rooms();
_rosterwin_rooms(layout, "Rooms", rooms);
g_list_free(rooms);
}
prefs_free_string(roomsbypref);
@ -660,7 +662,6 @@ _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms)
}
curr_room = g_list_next(curr_room);
}
g_list_free(rooms);
// if there are active rooms, or if we want to show empty groups
if (rooms_sorted || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
@ -679,15 +680,19 @@ _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms)
static void
_rosterwin_rooms_by_service(ProfLayoutSplit *layout)
{
GList *curr_room = muc_rooms();
GList *rooms = muc_rooms();
GList *curr = rooms;
GList *services = NULL;
while (curr_room) {
char *roomjid = curr_room->data;
while (curr) {
char *roomjid = curr->data;
Jid *jidp = jid_create(roomjid);
if (!g_list_find_custom(services, jidp->domainpart, (GCompareFunc)g_strcmp0)) {
services = g_list_insert_sorted(services, strdup(jidp->domainpart), (GCompareFunc)g_strcmp0);
}
curr_room = g_list_next(curr_room);
jid_destroy(jidp);
curr = g_list_next(curr);
}
GList *curr_service = services;
@ -695,22 +700,27 @@ _rosterwin_rooms_by_service(ProfLayoutSplit *layout)
char *service = curr_service->data;
GList *filtered_rooms = NULL;
curr_room = muc_rooms();
while (curr_room) {
char *roomjid = curr_room->data;
curr = rooms;
while (curr) {
char *roomjid = curr->data;
Jid *jidp = jid_create(roomjid);
if (g_strcmp0(curr_service->data, jidp->domainpart) == 0) {
filtered_rooms = g_list_append(filtered_rooms, jidp->barejid);
filtered_rooms = g_list_append(filtered_rooms, strdup(jidp->barejid));
}
curr_room = g_list_next(curr_room);
jid_destroy(jidp);
curr = g_list_next(curr);
}
_rosterwin_rooms(layout, service, filtered_rooms);
g_list_free_full(filtered_rooms, free);
curr_service = g_list_next(curr_service);
}
g_list_free(rooms);
g_list_free_full(services, free);
}
static void

View File

@ -711,6 +711,7 @@ win_show_contact(ProfWin *window, PContact contact)
if (last_activity) {
GDateTime *now = g_date_time_new_now_local();
GTimeSpan span = g_date_time_difference(now, last_activity);
g_date_time_unref(now);
int hours = span / G_TIME_SPAN_HOUR;
span = span - hours * G_TIME_SPAN_HOUR;

View File

@ -191,6 +191,7 @@ bookmark_join(const char *jid)
account_free(account);
} else if (muc_roster_complete(item->jid)) {
ui_room_join(item->jid, TRUE);
account_free(account);
}
return TRUE;
}

View File

@ -300,11 +300,11 @@ presence_send(const resource_presence_t presence_type, const char *const msg, co
static void
_send_room_presence(xmpp_stanza_t *presence)
{
GList *rooms_p = muc_rooms();
GList *rooms = rooms_p;
GList *rooms = muc_rooms();
GList *curr = rooms;
while (rooms) {
const char *room = rooms->data;
while (curr) {
const char *room = curr->data;
const char *nick = muc_nick(room);
if (nick) {
@ -316,12 +316,10 @@ _send_room_presence(xmpp_stanza_t *presence)
free(full_room_jid);
}
rooms = g_list_next(rooms);
curr = g_list_next(curr);
}
if (rooms_p) {
g_list_free(rooms_p);
}
g_list_free(rooms);
}
void

View File

@ -498,6 +498,7 @@ _session_reconnect(void)
log_debug("Attempting reconnect with account %s", account->name);
connection_connect(fulljid, saved_account.passwd, account->server, account->port, account->tls_policy);
free(fulljid);
account_free(account);
g_timer_start(reconnect_timer);
}