diff --git a/README.org b/README.org index 5ae53d4..7e85286 100644 --- a/README.org +++ b/README.org @@ -88,6 +88,9 @@ ** TODO [#A] Implement essential functionality (milestone v0.2) * [X] Opening PMs with initial message * [X] OOB media messages + * [ ] Buffer autoswitch on enter/open + * [ ] Handle open/enter jids with a resource without breaking + * [ ] Allow /close without crashing * [ ] [#B] Handle wide errors gracefully * [ ] [#B] Event-driven MUC entrance * [ ] MUCs diff --git a/account.c b/account.c index 25d8454..2535275 100644 --- a/account.c +++ b/account.c @@ -29,6 +29,7 @@ char *account_options[ACCOUNT_NUM_OPTIONS][2] = { "nickname", "" }, { "autoconnect", "" }, { "resource", "" }, + { "status", "probably about to segfault" }, }; struct t_account *account__search(const char *name) diff --git a/account.h b/account.h index b5fe1d1..202c5fa 100644 --- a/account.h +++ b/account.h @@ -16,6 +16,7 @@ enum t_account_option ACCOUNT_OPTION_NICKNAME, ACCOUNT_OPTION_AUTOCONNECT, ACCOUNT_OPTION_RESOURCE, + ACCOUNT_OPTION_STATUS, ACCOUNT_NUM_OPTIONS, }; @@ -47,6 +48,8 @@ enum t_account_option weechat_config_boolean(account->options[ACCOUNT_OPTION_AUTOCONNECT]) #define account_resource(account) \ weechat_config_string(account->options[ACCOUNT_OPTION_RESOURCE]) +#define account_status(account) \ + weechat_config_string(account->options[ACCOUNT_OPTION_STATUS]) struct t_account { diff --git a/config.c b/config.c index a963b31..b7e6c66 100644 --- a/config.c +++ b/config.c @@ -170,6 +170,22 @@ config__account_new_option (struct t_config_file *config_file, callback_change_data, NULL, NULL, NULL); break; + case ACCOUNT_OPTION_STATUS: + new_option = weechat_config_new_option ( + config_file, section, + option_name, "string", + N_("XMPP Account Login Status"), + NULL, 0, 0, + default_value, value, + null_value_allowed, + callback_check_value, + callback_check_value_pointer, + callback_check_value_data, + callback_change, + callback_change_pointer, + callback_change_data, + NULL, NULL, NULL); + break; case ACCOUNT_NUM_OPTIONS: break; } diff --git a/connection.c b/connection.c index fd962c9..5676ec6 100644 --- a/connection.c +++ b/connection.c @@ -191,7 +191,7 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status, (void)stream_error; if (status == XMPP_CONN_CONNECT) { - xmpp_stanza_t *pres, *pres__c; + xmpp_stanza_t *pres, *pres__c, *pres__status, *pres__status__text; char cap_hash[28+1] = {0}; xmpp_handler_add(conn, version_handler, "jabber:iq:version", "iq", NULL, account); @@ -212,6 +212,17 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status, xmpp_stanza_add_child(pres, pres__c); xmpp_stanza_release(pres__c); + pres__status = xmpp_stanza_new(account->context); + xmpp_stanza_set_name(pres__status, "status"); + + pres__status__text = xmpp_stanza_new(account->context); + xmpp_stanza_set_text(pres__status__text, account_status(account)); + xmpp_stanza_add_child(pres__status, pres__status__text); + xmpp_stanza_release(pres__status__text); + + xmpp_stanza_add_child(pres, pres__status); + xmpp_stanza_release(pres__status); + xmpp_send(conn, pres); xmpp_stanza_release(pres); } else {