summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
Diffstat (limited to 'res')
-rw-r--r--res/ari/resource_applications.h4
-rw-r--r--res/ari/resource_endpoints.c8
-rw-r--r--res/res_xmpp.c38
3 files changed, 37 insertions, 13 deletions
diff --git a/res/ari/resource_applications.h b/res/ari/resource_applications.h
index 888f513de..be62e9d5f 100644
--- a/res/ari/resource_applications.h
+++ b/res/ari/resource_applications.h
@@ -67,7 +67,7 @@ void ast_ari_applications_get(struct ast_variable *headers, struct ast_ari_appli
struct ast_ari_applications_subscribe_args {
/*! Application's name */
const char *application_name;
- /*! Array of URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}, deviceState:{deviceName} */
+ /*! Array of URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName} */
const char **event_source;
/*! Length of event_source array. */
size_t event_source_count;
@@ -99,7 +99,7 @@ void ast_ari_applications_subscribe(struct ast_variable *headers, struct ast_ari
struct ast_ari_applications_unsubscribe_args {
/*! Application's name */
const char *application_name;
- /*! Array of URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}, deviceState:{deviceName} */
+ /*! Array of URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName} */
const char **event_source;
/*! Length of event_source array. */
size_t event_source_count;
diff --git a/res/ari/resource_endpoints.c b/res/ari/resource_endpoints.c
index 16b7ebd8d..ff2b150dd 100644
--- a/res/ari/resource_endpoints.c
+++ b/res/ari/resource_endpoints.c
@@ -34,6 +34,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/stasis_app.h"
#include "asterisk/stasis_endpoints.h"
#include "asterisk/channel.h"
+#include "asterisk/message.h"
void ast_ari_endpoints_list(struct ast_variable *headers,
struct ast_ari_endpoints_list_args *args,
@@ -82,6 +83,7 @@ void ast_ari_endpoints_list(struct ast_variable *headers,
ast_ari_response_ok(response, ast_json_ref(json));
}
+
void ast_ari_endpoints_list_by_tech(struct ast_variable *headers,
struct ast_ari_endpoints_list_by_tech_args *args,
struct ast_ari_response *response)
@@ -89,14 +91,17 @@ void ast_ari_endpoints_list_by_tech(struct ast_variable *headers,
RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
RAII_VAR(struct ao2_container *, snapshots, NULL, ao2_cleanup);
RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ struct ast_endpoint *tech_endpoint;
struct ao2_iterator i;
void *obj;
- if (!ast_get_channel_tech(args->tech)) {
+ tech_endpoint = ast_endpoint_find_by_id(args->tech);
+ if (!tech_endpoint) {
ast_ari_response_error(response, 404, "Not Found",
"No Endpoints found - invalid tech %s", args->tech);
return;
}
+ ao2_ref(tech_endpoint, -1);
cache = ast_endpoint_cache();
if (!cache) {
@@ -146,6 +151,7 @@ void ast_ari_endpoints_list_by_tech(struct ast_variable *headers,
ao2_iterator_destroy(&i);
ast_ari_response_ok(response, ast_json_ref(json));
}
+
void ast_ari_endpoints_get(struct ast_variable *headers,
struct ast_ari_endpoints_get_args *args,
struct ast_ari_response *response)
diff --git a/res/res_xmpp.c b/res/res_xmpp.c
index 0cfc37b4c..758a5f09a 100644
--- a/res/res_xmpp.c
+++ b/res/res_xmpp.c
@@ -559,6 +559,10 @@ static void xmpp_client_destructor(void *obj)
ast_xmpp_client_disconnect(client);
+ ast_endpoint_shutdown(client->endpoint);
+ ao2_cleanup(client->endpoint);
+ client->endpoint = NULL;
+
if (client->filter) {
iks_filter_delete(client->filter);
}
@@ -593,6 +597,20 @@ static int xmpp_buddy_cmp(void *obj, void *arg, int flags)
return !strcmp(buddy1->id, flags & OBJ_KEY ? id : buddy2->id) ? CMP_MATCH | CMP_STOP : 0;
}
+/*! \brief Internal function which changes the XMPP client state */
+static void xmpp_client_change_state(struct ast_xmpp_client *client, int state)
+{
+ if (state == client->state) {
+ return;
+ }
+ client->state = state;
+ if (client->state == XMPP_STATE_DISCONNECTED) {
+ ast_endpoint_set_state(client->endpoint, AST_ENDPOINT_OFFLINE);
+ } else if (client->state == XMPP_STATE_CONNECTED) {
+ ast_endpoint_set_state(client->endpoint, AST_ENDPOINT_ONLINE);
+ }
+}
+
/*! \brief Allocator function for ast_xmpp_client */
static struct ast_xmpp_client *xmpp_client_alloc(const char *name)
{
@@ -605,6 +623,12 @@ static struct ast_xmpp_client *xmpp_client_alloc(const char *name)
AST_LIST_HEAD_INIT(&client->messages);
client->thread = AST_PTHREADT_NULL;
+ client->endpoint = ast_endpoint_create("XMPP", name);
+ if (!client->endpoint) {
+ ao2_ref(client, -1);
+ return NULL;
+ }
+
if (!(client->buddies = ao2_container_alloc(BUDDY_BUCKETS, xmpp_buddy_hash, xmpp_buddy_cmp))) {
ast_log(LOG_ERROR, "Could not initialize buddy container for '%s'\n", name);
ao2_ref(client, -1);
@@ -626,7 +650,7 @@ static struct ast_xmpp_client *xmpp_client_alloc(const char *name)
ast_string_field_set(client, name, name);
client->timeout = 50;
- client->state = XMPP_STATE_DISCONNECTED;
+ xmpp_client_change_state(client, XMPP_STATE_DISCONNECTED);
ast_copy_string(client->mid, "aaaaa", sizeof(client->mid));
return client;
@@ -2213,12 +2237,6 @@ static const struct ast_msg_tech msg_tech = {
.msg_send = xmpp_send_cb,
};
-/*! \brief Internal function which changes the XMPP client state */
-static void xmpp_client_change_state(struct ast_xmpp_client *client, int state)
-{
- client->state = state;
-}
-
/*! \brief Internal function which creates a buddy on a client */
static struct ast_xmpp_buddy *xmpp_client_create_buddy(struct ao2_container *container, const char *id)
{
@@ -3530,7 +3548,7 @@ static int xmpp_action_hook(void *data, int type, iks *node)
int ast_xmpp_client_disconnect(struct ast_xmpp_client *client)
{
if ((client->thread != AST_PTHREADT_NULL) && !pthread_equal(pthread_self(), client->thread)) {
- client->state = XMPP_STATE_DISCONNECTING;
+ xmpp_client_change_state(client, XMPP_STATE_DISCONNECTING);
pthread_join(client->thread, NULL);
client->thread = AST_PTHREADT_NULL;
}
@@ -3559,7 +3577,7 @@ int ast_xmpp_client_disconnect(struct ast_xmpp_client *client)
iks_disconnect(client->parser);
}
- client->state = XMPP_STATE_DISCONNECTED;
+ xmpp_client_change_state(client, XMPP_STATE_DISCONNECTED);
return 0;
}
@@ -3774,7 +3792,7 @@ static void *xmpp_client_thread(void *data)
ast_log(LOG_WARNING, "JABBER: Not Supported\n");
} else if (res == IKS_NET_DROPPED) {
ast_log(LOG_WARNING, "JABBER: Dropped?\n");
- } else {
+ } else if (res == IKS_NET_UNKNOWN) {
ast_debug(5, "JABBER: Unknown\n");
}