diff --git a/README.org b/README.org index 1392315..e9a615f 100644 --- a/README.org +++ b/README.org @@ -94,6 +94,7 @@ * [X] Allow /close without crashing * [ ] [#B] Handle wide errors gracefully * [ ] [#B] Event-driven MUC entrance + * [ ] Pings * [ ] MUCs * [X] Opening (/enter) * [ ] Leave on /close @@ -127,6 +128,10 @@ Please submit a pull request or create an issue to add a new or missing feature. +* Testemonials + + "Weechat-Strophe - for the discerning dual IRCer XMPPer" -- [[github.com/janicez][Ellenor et al Bjornsdottir]] + * License weechat-xmpp is licensed under the Mozilla Public diff --git a/account.h b/account.h index 8fff73c..9ca38a8 100644 --- a/account.h +++ b/account.h @@ -31,14 +31,18 @@ enum t_account_option weechat_config_option_set(account->options[option], value, 1) #define account_jid(account) \ - weechat_config_string(account->options[ACCOUNT_OPTION_JID]) + account->connection && xmpp_conn_is_connected(account->connection) ? \ + xmpp_jid_bare(account->context, xmpp_conn_get_bound_jid(account->connection)) : \ + weechat_config_string(account->options[ACCOUNT_OPTION_JID]) #define account_jid_device(account) \ - xmpp_jid_new(account->context, \ - xmpp_jid_node(account->context, \ - weechat_config_string(account->options[ACCOUNT_OPTION_JID])), \ - xmpp_jid_domain(account->context, \ - weechat_config_string(account->options[ACCOUNT_OPTION_JID])), \ - "weechat") + account->connection && xmpp_conn_is_connected(account->connection) ? \ + xmpp_conn_get_bound_jid(account->connection) : \ + xmpp_jid_new(account->context, \ + xmpp_jid_node(account->context, \ + weechat_config_string(account->options[ACCOUNT_OPTION_JID])), \ + xmpp_jid_domain(account->context, \ + weechat_config_string(account->options[ACCOUNT_OPTION_JID])), \ + "weechat") #define account_password(account) \ weechat_config_string(account->options[ACCOUNT_OPTION_PASSWORD]) #define account_tls(account) \ diff --git a/connection.c b/connection.c index d224586..7010a36 100644 --- a/connection.c +++ b/connection.c @@ -460,7 +460,8 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status, omemo__init(account); } else { - //xmpp_stop(account->context); + account__disconnect(account, 1); + //xmpp_stop(account->context); //keep context? } } @@ -482,7 +483,13 @@ char* connection__rand_string(int length) int connection__connect(struct t_account *account, xmpp_conn_t **connection, const char* jid, const char* password, int tls) { + static const unsigned ka_timeout_sec = 60; + static const unsigned ka_timeout_ivl = 1; + *connection = xmpp_conn_new(account->context); + + xmpp_conn_set_keepalive(*connection, ka_timeout_sec, ka_timeout_ivl); + const char *resource = account_resource(account); if (!(resource && strlen(resource))) {