summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2020-07-04 11:48:43 +0300
committerdefanor <defanor@uberspace.net>2020-07-04 11:48:43 +0300
commitc09bb4e4434667debc0e28d25b5a358ef4ffb498 (patch)
tree03fd85ad0986b68288417e7e0a94c4b9193e4238 /src
parentf9c2810adb8e19a228535ea7c8b131a5e8b6928e (diff)
Fill weechat nicklists
The server buffer's nicklist is filled with roster items, and MUC buffers' nicklists are filled with active MUC participants. No MUC role indications, groups, or contact presence tracking yet.
Diffstat (limited to 'src')
-rw-r--r--src/rexmpp.c1
-rw-r--r--src/rexmpp.h2
-rw-r--r--src/rexmpp_roster.c12
3 files changed, 15 insertions, 0 deletions
diff --git a/src/rexmpp.c b/src/rexmpp.c
index 02dcf5b..c4c1e1c 100644
--- a/src/rexmpp.c
+++ b/src/rexmpp.c
@@ -268,6 +268,7 @@ rexmpp_err_t rexmpp_init (rexmpp_t *s, const char *jid)
s->sasl_property_cb = NULL;
s->xml_in_cb = NULL;
s->xml_out_cb = NULL;
+ s->roster_modify_cb = NULL;
s->ping_delay = 600;
s->ping_requested = 0;
s->last_network_activity = 0;
diff --git a/src/rexmpp.h b/src/rexmpp.h
index 9f748cf..6157f86 100644
--- a/src/rexmpp.h
+++ b/src/rexmpp.h
@@ -202,6 +202,7 @@ typedef void (*log_function_t) (rexmpp_t *s, int priority, const char *format, v
typedef int (*sasl_property_cb_t) (rexmpp_t *s, Gsasl_property prop);
typedef int (*xml_in_cb_t) (rexmpp_t *s, xmlNodePtr node);
typedef int (*xml_out_cb_t) (rexmpp_t *s, xmlNodePtr node);
+typedef void (*roster_modify_cb_t) (rexmpp_t *s, xmlNodePtr item);
/** @brief Complete connection state */
struct rexmpp
@@ -248,6 +249,7 @@ struct rexmpp
sasl_property_cb_t sasl_property_cb;
xml_in_cb_t xml_in_cb;
xml_out_cb_t xml_out_cb;
+ roster_modify_cb_t roster_modify_cb;
/* Stream-related state. */
char *assigned_jid;
diff --git a/src/rexmpp_roster.c b/src/rexmpp_roster.c
index 8479c14..3d62613 100644
--- a/src/rexmpp_roster.c
+++ b/src/rexmpp_roster.c
@@ -81,6 +81,9 @@ rexmpp_err_t rexmpp_modify_roster (rexmpp_t *s, xmlNodePtr item) {
if (subscription != NULL) {
free(subscription);
}
+ if (s->roster_modify_cb != NULL) {
+ s->roster_modify_cb(s, item);
+ }
return ret;
}
@@ -93,6 +96,15 @@ void rexmpp_roster_set (rexmpp_t *s, xmlNodePtr query) {
}
s->roster_ver = xmlGetProp(query, "ver");
s->roster_items = xmlCopyNodeList(xmlFirstElementChild(query));
+ if (s->roster_modify_cb != NULL) {
+ xmlNodePtr item;
+ for (item = xmlFirstElementChild(query);
+ item != NULL;
+ item = xmlNextElementSibling(item))
+ {
+ s->roster_modify_cb(s, item);
+ }
+ }
}
void rexmpp_roster_cache_read (rexmpp_t *s) {