diff options
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/capabilities.c | 42 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 3 |
2 files changed, 44 insertions, 1 deletions
diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index f528e05c..17d60e36 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -54,8 +54,10 @@ #include "common.h" #include "log.h" +#include "event/client_events.h" #include "plugins/plugins.h" #include "config/files.h" +#include "config/preferences.h" #include "xmpp/xmpp.h" #include "xmpp/stanza.h" #include "xmpp/form.h" @@ -100,12 +102,50 @@ caps_init(void) g_hash_table_add(prof_features, strdup(STANZA_NS_VERSION)); g_hash_table_add(prof_features, strdup(STANZA_NS_CHATSTATES)); g_hash_table_add(prof_features, strdup(STANZA_NS_PING)); - g_hash_table_add(prof_features, strdup(STANZA_NS_RECEIPTS)); + if (prefs_get_boolean(PREF_RECEIPTS_SEND)) { + g_hash_table_add(prof_features, strdup(STANZA_NS_RECEIPTS)); + } g_hash_table_add(prof_features, strdup(STANZA_NS_LASTACTIVITY)); my_sha1 = NULL; } +void +caps_add_feature(char *feature) +{ + if (g_hash_table_contains(prof_features, feature)) { + return; + } + + g_hash_table_add(prof_features, strdup(feature)); + + caps_reset_ver(); + + // resend presence to update server's disco info data for this client + if (connection_get_status() == JABBER_CONNECTED) { + resource_presence_t last_presence = accounts_get_last_presence(session_get_account_name()); + cl_ev_presence_send(last_presence, connection_get_presence_msg(), 0); + } +} + +void +caps_remove_feature(char *feature) +{ + if (!g_hash_table_contains(prof_features, feature)) { + return; + } + + g_hash_table_remove(prof_features, feature); + + caps_reset_ver(); + + // resend presence to update server's disco info data for this client + if (connection_get_status() == JABBER_CONNECTED) { + resource_presence_t last_presence = accounts_get_last_presence(session_get_account_name()); + cl_ev_presence_send(last_presence, connection_get_presence_msg(), 0); + } +} + GList* caps_get_features(void) { diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 93b02cb2..821abfd6 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -56,6 +56,7 @@ #define JABBER_PRIORITY_MAX 127 #define XMPP_FEATURE_BLOCKING "urn:xmpp:blocking" +#define XMPP_FEATURE_RECEIPTS "urn:xmpp:receipts" typedef enum { JABBER_CONNECTING, @@ -179,6 +180,8 @@ EntityCapabilities* caps_lookup(const char *const jid); void caps_close(void); void caps_destroy(EntityCapabilities *caps); void caps_reset_ver(void); +void caps_add_feature(char *feature); +void caps_remove_feature(char *feature); gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str); gboolean bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str); |