presence status

v1
Tony Olagbaiye 4 years ago
parent ec3e918712
commit cd0beab676
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -88,6 +88,9 @@
** TODO [#A] Implement essential functionality (milestone v0.2) ** TODO [#A] Implement essential functionality (milestone v0.2)
* [X] Opening PMs with initial message * [X] Opening PMs with initial message
* [X] OOB media messages * [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] Handle wide errors gracefully
* [ ] [#B] Event-driven MUC entrance * [ ] [#B] Event-driven MUC entrance
* [ ] MUCs * [ ] MUCs

@ -29,6 +29,7 @@ char *account_options[ACCOUNT_NUM_OPTIONS][2] =
{ "nickname", "" }, { "nickname", "" },
{ "autoconnect", "" }, { "autoconnect", "" },
{ "resource", "" }, { "resource", "" },
{ "status", "probably about to segfault" },
}; };
struct t_account *account__search(const char *name) struct t_account *account__search(const char *name)

@ -16,6 +16,7 @@ enum t_account_option
ACCOUNT_OPTION_NICKNAME, ACCOUNT_OPTION_NICKNAME,
ACCOUNT_OPTION_AUTOCONNECT, ACCOUNT_OPTION_AUTOCONNECT,
ACCOUNT_OPTION_RESOURCE, ACCOUNT_OPTION_RESOURCE,
ACCOUNT_OPTION_STATUS,
ACCOUNT_NUM_OPTIONS, ACCOUNT_NUM_OPTIONS,
}; };
@ -47,6 +48,8 @@ enum t_account_option
weechat_config_boolean(account->options[ACCOUNT_OPTION_AUTOCONNECT]) weechat_config_boolean(account->options[ACCOUNT_OPTION_AUTOCONNECT])
#define account_resource(account) \ #define account_resource(account) \
weechat_config_string(account->options[ACCOUNT_OPTION_RESOURCE]) weechat_config_string(account->options[ACCOUNT_OPTION_RESOURCE])
#define account_status(account) \
weechat_config_string(account->options[ACCOUNT_OPTION_STATUS])
struct t_account struct t_account
{ {

@ -170,6 +170,22 @@ config__account_new_option (struct t_config_file *config_file,
callback_change_data, callback_change_data,
NULL, NULL, NULL); NULL, NULL, NULL);
break; 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: case ACCOUNT_NUM_OPTIONS:
break; break;
} }

@ -191,7 +191,7 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status,
(void)stream_error; (void)stream_error;
if (status == XMPP_CONN_CONNECT) { 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}; char cap_hash[28+1] = {0};
xmpp_handler_add(conn, version_handler, "jabber:iq:version", "iq", NULL, account); 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_add_child(pres, pres__c);
xmpp_stanza_release(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_send(conn, pres);
xmpp_stanza_release(pres); xmpp_stanza_release(pres);
} else { } else {

Loading…
Cancel
Save