Added stbbr_wait_for
This commit is contained in:
@@ -36,6 +36,12 @@ stbbr_for(char *id, char *stream)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
stbbr_wait_for(char *id)
|
||||
{
|
||||
server_wait_for(id);
|
||||
}
|
||||
|
||||
int
|
||||
stbbr_last_received(char *stanza)
|
||||
{
|
||||
|
||||
@@ -177,6 +177,20 @@ id_callback(const char *id)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
server_wait_for(char *id)
|
||||
{
|
||||
log_println("WAIT for stanza with id: %s", id);
|
||||
while (TRUE) {
|
||||
int res = stanzas_contains_id(id);
|
||||
if (res) {
|
||||
log_println("WAIT complete for id: %s", id);
|
||||
return;
|
||||
}
|
||||
usleep(1000 * 50);
|
||||
}
|
||||
}
|
||||
|
||||
void*
|
||||
_start_server_cb(void* userdata)
|
||||
{
|
||||
@@ -321,6 +335,7 @@ server_stop(void)
|
||||
static void
|
||||
_shutdown(void)
|
||||
{
|
||||
log_println("SHUTDOWN");
|
||||
// stanza_show_all();
|
||||
xmppclient_end_session(client);
|
||||
client = NULL;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
int server_run(int port);
|
||||
void server_stop(void);
|
||||
|
||||
void server_wait_for(char *id);
|
||||
|
||||
void server_send(char *stream);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -74,6 +74,29 @@ stanza_show_all(void)
|
||||
pthread_mutex_unlock(&stanzas_lock);
|
||||
}
|
||||
|
||||
int
|
||||
stanzas_contains_id(char *id)
|
||||
{
|
||||
pthread_mutex_lock(&stanzas_lock);
|
||||
GList *curr = stanzas;
|
||||
while (curr) {
|
||||
XMPPStanza *stanza = curr->data;
|
||||
GList *curr_attr = stanza->attrs;
|
||||
while (curr_attr) {
|
||||
XMPPAttr *attr = curr_attr->data;
|
||||
if (g_strcmp0(attr->name, "id") == 0 && g_strcmp0(attr->value, id) == 0) {
|
||||
pthread_mutex_unlock(&stanzas_lock);
|
||||
return 1;
|
||||
}
|
||||
curr_attr = g_list_next(curr_attr);
|
||||
}
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
pthread_mutex_unlock(&stanzas_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
stanza_add(XMPPStanza *stanza)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,8 @@ XMPPStanza* stanza_get_child_by_name(XMPPStanza *stanza, char *name);
|
||||
int stanza_verify_any(XMPPStanza *stanza);
|
||||
int stanza_verify_last(XMPPStanza *stanza);
|
||||
|
||||
int stanzas_contains_id(char *id);
|
||||
|
||||
void stanza_free(XMPPStanza *stanza);
|
||||
void stanza_free_all(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user