via: e7a8189b2b87d600c290998772d0aa53c26bc964 (commit)
from: ea29a1dfcc53729af1e7798050a62566700d99fa (commit)
= COMMIT LOG ===========================================================
committer: Mathieu Parent
comments:
Skinny: centralized registration
diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c
index 5320ca5..91d81da 100644
--- a/src/mod/endpoints/mod_skinny/mod_skinny.c
+++ b/src/mod/endpoints/mod_skinny/mod_skinny.c
@@ -1243,6 +1243,21 @@ static void walk_listeners(skinny_listener_callback_func_t callback, void *pvt)
switch_mutex_unlock(globals.mutex);
}
+static int flush_listener_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
+ char *profile_name = argv[0];
+ char *value = argv[1];
+ char *domain_name = argv[2];
+ char *device_name = argv[3];
+ char *device_instance = argv[4];
+
+ char *token = switch_mprintf("skinny/%q/%q/%q:%q", profile_name, value, device_name, device_instance);
+ switch_core_del_registration(value, domain_name, token);
+ switch_safe_free(token);
+
+ return 0;
+}
+
static void flush_listener(listener_t *listener)
{
@@ -1251,6 +1266,18 @@ static void flush_listener(listener_t *listener)
char *sql;
if ((sql = switch_mprintf(
+ "SELECT '%q', value, '%q', '%q', '%d' "
+ "FROM skinny_lines "
+ "WHERE device_name='%s' AND device_instance=%d "
+ "ORDER BY position",
+ profile->name, profile->domain, listener->device_name, listener->device_instance,
+ listener->device_name, listener->device_instance
+ ))) {
+ skinny_execute_sql_callback(profile, profile->sql_mutex, sql, flush_listener_callback, NULL);
+ switch_safe_free(sql);
+ }
+
+ if ((sql = switch_mprintf(
"DELETE FROM skinny_devices "
"WHERE name='%s' and instance=%d",
listener->device_name, listener->device_instance))) {
diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c
index e7c761d..7d66a9c 100644
--- a/src/mod/endpoints/mod_skinny/skinny_server.c
+++ b/src/mod/endpoints/mod_skinny/skinny_server.c
@@ -1006,6 +1006,10 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r
}
if ((xbuttons = switch_xml_child(xskinny, "buttons"))) {
uint32_t line_instance = 1;
+ char *network_ip = inet_ntoa(request->data.reg.ip);
+ int network_port = 0;
+ char network_port_c[6];
+ snprintf(network_port_c, sizeof(network_port_c), "%d", network_port);
for (xbutton = switch_xml_child(xbuttons, "button"); xbutton; xbutton = xbutton->next) {
uint32_t position = atoi(switch_xml_attr_soft(xbutton, "position"));
uint32_t type = skinny_str2button(switch_xml_attr_soft(xbutton, "type"));
@@ -1031,8 +1035,14 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r
label, value, caller_name,
ring_on_idle, ring_on_active, busy_trigger,
forward_all, forward_busy, forward_noanswer, noanswer_duration))) {
+ char *token, *url;
skinny_execute_sql(profile, sql, profile->sql_mutex);
switch_safe_free(sql);
+ token = switch_mprintf("skinny/%q/%q/%q:%d", profile->name, value, request->data.reg.device_name, request->data.reg.instance);
+ url = switch_mprintf("skinny/%q/%q", profile->name, value);
+ switch_core_add_registration(value, profile->domain, token, url, 0, network_ip, network_port_c, "tcp");
+ switch_safe_free(token);
+ switch_safe_free(url);
}
if (line_instance == 1) {
switch_event_t *message_query_event = NULL;
Summary of changes: src/mod/endpoints/mod_skinny/mod_skinny.c | 27 ++++++++++++++++++++++++++ src/mod/endpoints/mod_skinny/skinny_server.c | 10 +++++++++ 2 files changed, 37 insertions(+), 0 deletions(-)
this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email
For more info, see http://blog.chomperstomp.com/?p=630
--
FreeSWITCH Source