1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Add sv_ev_bookmark_autojoin

This commit is contained in:
James Booth 2016-08-28 22:42:09 +01:00
parent ea98a8b04a
commit 47a1a62009
3 changed files with 24 additions and 16 deletions

View File

@ -1079,3 +1079,25 @@ sv_ev_lastactivity_response(const char *const from, const int seconds, const cha
g_free(date_fmt); g_free(date_fmt);
jid_destroy(jidp); jid_destroy(jidp);
} }
void
sv_ev_bookmark_autojoin(Bookmark *bookmark)
{
char *nick = NULL;
if (bookmark->nick) {
nick = strdup(bookmark->nick);
} else {
char *account_name = session_get_account_name();
ProfAccount *account = accounts_get_account(account_name);
nick = strdup(account->muc_nick);
account_free(account);
}
log_debug("Autojoin %s with nick=%s", bookmark->barejid, nick);
if (!muc_active(bookmark->barejid)) {
presence_join_room(bookmark->barejid, nick, bookmark->password);
muc_join(bookmark->barejid, nick, bookmark->password, TRUE);
}
free(nick);
}

View File

@ -87,5 +87,6 @@ void sv_ev_roster_update(const char *const barejid, const char *const name,
void sv_ev_roster_received(void); void sv_ev_roster_received(void);
int sv_ev_certfail(const char *const errormsg, TLSCertificate *cert); int sv_ev_certfail(const char *const errormsg, TLSCertificate *cert);
void sv_ev_lastactivity_response(const char *const from, const int seconds, const char *const msg); void sv_ev_lastactivity_response(const char *const from, const int seconds, const char *const msg);
void sv_ev_bookmark_autojoin(Bookmark *bookmark);
#endif #endif

View File

@ -294,22 +294,7 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
g_hash_table_insert(bookmarks, strdup(barejid), bookmark); g_hash_table_insert(bookmarks, strdup(barejid), bookmark);
if (autojoin_val) { if (autojoin_val) {
Jid *room_jid; sv_ev_bookmark_autojoin(bookmark);
char *account_name = session_get_account_name();
ProfAccount *account = accounts_get_account(account_name);
if (nick == NULL) {
nick = account->muc_nick;
}
log_debug("Autojoin %s with nick=%s", barejid, nick);
room_jid = jid_create_from_bare_and_resource(barejid, nick);
if (!muc_active(room_jid->barejid)) {
presence_join_room(barejid, nick, password);
muc_join(barejid, nick, password, TRUE);
}
jid_destroy(room_jid);
account_free(account);
} }
child = xmpp_stanza_get_next(child); child = xmpp_stanza_get_next(child);