diff options
author | Olivier LE MOAL <olivier.lemoal@winamax.fr> | 2015-02-03 15:27:56 +0100 |
---|---|---|
committer | Olivier LE MOAL <olivier.lemoal@winamax.fr> | 2015-02-03 15:27:56 +0100 |
commit | 2a12a4d93bcb898225003a8d38e7f28662075b70 (patch) | |
tree | 9129b8e42f5ae3563e3000fc45783a0788dde16a /src/xmpp | |
parent | e3feacddd6667fd8e111d0ee54846c6aeabe3a7d (diff) | |
download | profani-tty-2a12a4d93bcb898225003a8d38e7f28662075b70.tar.gz |
Add preference/commands for carbons message
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/connection.c | 6 | ||||
-rw-r--r-- | src/xmpp/iq.c | 10 | ||||
-rw-r--r-- | src/xmpp/stanza.c | 28 | ||||
-rw-r--r-- | src/xmpp/stanza.h | 3 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 1 |
5 files changed, 43 insertions, 5 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 8bb7c74c..34fba22d 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -463,10 +463,14 @@ _connection_handler(xmpp_conn_t * const conn, message_add_handlers(); presence_add_handlers(); iq_add_handlers(); - iq_enable_carbons(); roster_request(); bookmark_request(); + + if (prefs_get_boolean(PREF_CARBONS)){ + iq_enable_carbons(); + } + jabber_conn.conn_status = JABBER_CONNECTED; if (prefs_get_reconnect() != 0) { diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 071b07c5..be22b01f 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -163,6 +163,16 @@ iq_enable_carbons() } void +iq_disable_carbons() +{ + xmpp_conn_t * const conn = connection_get_conn(); + xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_stanza_t *iq = stanza_disable_carbons(ctx); + xmpp_send(conn, iq); + xmpp_stanza_release(iq); +} + +void iq_disco_info_request(gchar *jid) { xmpp_conn_t * const conn = connection_get_conn(); diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 06177800..b0d7de86 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -206,12 +206,32 @@ stanza_enable_carbons(xmpp_ctx_t *ctx){ xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_set_type(iq, STANZA_TYPE_SET); xmpp_stanza_set_id(iq, id); + free(id); + + xmpp_stanza_t *carbons_enable = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(carbons_enable, STANZA_NAME_ENABLE); + xmpp_stanza_set_ns(carbons_enable, STANZA_NS_CARBONS); + + xmpp_stanza_add_child(iq, carbons_enable); + + return iq; +} + +xmpp_stanza_t * +stanza_disable_carbons(xmpp_ctx_t *ctx){ + xmpp_stanza_t *iq = xmpp_stanza_new(ctx); + char *id = create_unique_id(NULL); + + xmpp_stanza_set_name(iq, STANZA_NAME_IQ); + xmpp_stanza_set_type(iq, STANZA_TYPE_SET); + xmpp_stanza_set_id(iq, id); + free(id); - xmpp_stanza_t *carbon_enable = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(carbon_enable, STANZA_NAME_ENABLE); - xmpp_stanza_set_ns(carbon_enable, STANZA_NS_CARBONS); + xmpp_stanza_t *carbons_disable = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(carbons_disable, STANZA_NAME_DISABLE); + xmpp_stanza_set_ns(carbons_disable, STANZA_NS_CARBONS); - xmpp_stanza_add_child(iq, carbon_enable); + xmpp_stanza_add_child(iq, carbons_disable); return iq; } diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index 0c5a2b01..e4f3ce57 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -78,6 +78,7 @@ #define STANZA_NAME_DESTROY "destroy" #define STANZA_NAME_ACTOR "actor" #define STANZA_NAME_ENABLE "enable" +#define STANZA_NAME_DISABLE "disable" // error conditions #define STANZA_NAME_BAD_REQUEST "bad-request" @@ -183,6 +184,8 @@ xmpp_stanza_t* stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx); xmpp_stanza_t * stanza_enable_carbons(xmpp_ctx_t *ctx); +xmpp_stanza_t * stanza_disable_carbons(xmpp_ctx_t *ctx); + xmpp_stanza_t* stanza_create_chat_state(xmpp_ctx_t *ctx, const char * const fulljid, const char * const state); diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 41355e30..1fc32665 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -173,6 +173,7 @@ gboolean presence_sub_request_exists(const char * const bare_jid); // iq functions void iq_enable_carbons(); +void iq_disable_carbons(); void iq_send_software_version(const char * const fulljid); void iq_room_list_request(gchar *conferencejid); void iq_disco_info_request(gchar *jid); |