feat: Add stbbr_for_presence_to for MUC join presence matching
- Add prime_for_presence_to() and prime_get_for_presence_to() in prime.c - Add presence_to_callback() in server.c to handle MUC join presence - Export stbbr_for_presence_to() in stabber.h - Add stanzas_debug_last() for debugging failed verifications
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
static char *required_passwd = NULL;
|
||||
static GHashTable *idstubs = NULL;
|
||||
static GHashTable *querystubs = NULL;
|
||||
static GHashTable *presence_to_stubs = NULL;
|
||||
|
||||
void
|
||||
prime_init(void)
|
||||
@@ -40,6 +41,7 @@ prime_init(void)
|
||||
required_passwd = strdup("password");
|
||||
idstubs = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
|
||||
querystubs = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)stanza_free);
|
||||
presence_to_stubs = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)stanza_free);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -57,6 +59,11 @@ prime_free_all(void)
|
||||
g_hash_table_destroy(querystubs);
|
||||
}
|
||||
querystubs = NULL;
|
||||
|
||||
if (presence_to_stubs) {
|
||||
g_hash_table_destroy(presence_to_stubs);
|
||||
}
|
||||
presence_to_stubs = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -112,3 +119,25 @@ prime_get_for_query(const char *query)
|
||||
|
||||
return g_hash_table_lookup(querystubs, query);
|
||||
}
|
||||
|
||||
void
|
||||
prime_for_presence_to(const char *to_jid, char *stream)
|
||||
{
|
||||
if (!presence_to_stubs) {
|
||||
return;
|
||||
}
|
||||
|
||||
log_println(STBBR_LOGDEBUG, "Received stub for presence to: %s, stanza: %s", to_jid, stream);
|
||||
XMPPStanza *stanza = stanza_parse(stream);
|
||||
g_hash_table_insert(presence_to_stubs, strdup(to_jid), stanza);
|
||||
}
|
||||
|
||||
XMPPStanza*
|
||||
prime_get_for_presence_to(const char *to_jid)
|
||||
{
|
||||
if (!presence_to_stubs) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_hash_table_lookup(presence_to_stubs, to_jid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user