[Freeswitch-svn] [commit] r2350 - in freeswitch/trunk: libs/libdingaling/src src src/include src/mod/applications/mod_bridgecall src/mod/applications/mod_commands src/mod/applications/mod_conference src/mod/codecs/mod_speex src/mod/endpoints/mod_exosip src/mod/languages/mod_spidermonkey
Freeswitch SVN
anthm at freeswitch.org
Mon Aug 21 15:14:52 EDT 2006
Author: anthm
Date: Mon Aug 21 15:14:51 2006
New Revision: 2350
Modified:
freeswitch/trunk/libs/libdingaling/src/libdingaling.c
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/trunk/src/mod/codecs/mod_speex/Makefile
freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_ivr.c
Log:
bunch of tweaks to make ivr more fun
Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/trunk/libs/libdingaling/src/libdingaling.c (original)
+++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c Mon Aug 21 15:14:51 2006
@@ -107,6 +107,7 @@
apr_hash_t *sessions;
apr_hash_t *retry_hash;
apr_hash_t *probe_hash;
+ apr_hash_t *sub_hash;
apr_thread_mutex_t *lock;
apr_thread_mutex_t *flag_mutex;
ldl_loop_callback_t loop_callback;
@@ -438,6 +439,7 @@
return LDL_STATUS_SUCCESS;
}
+const char *marker = "TRUE";
static int on_presence(void *user_data, ikspak *pak)
{
@@ -447,11 +449,13 @@
char *resource;
struct ldl_buffer *buffer;
size_t x;
+
+ if (!apr_hash_get(handle->sub_hash, from, APR_HASH_KEY_STRING)) {
+ apr_hash_set(handle->sub_hash, apr_pstrdup(handle->pool, from), APR_HASH_KEY_STRING, &marker);
+ iks *msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, from, "Ding A Ling....");
+ apr_queue_push(handle->queue, msg);
+ }
- //iks *msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, from, "Ding A Ling....");
- //apr_queue_push(handle->queue, msg);
-
-
apr_cpystrn(id, from, sizeof(id));
if ((resource = strchr(id, '/'))) {
*resource++ = '\0';
@@ -517,42 +521,21 @@
if (!strcasecmp(iks_name(tag), "bind")) {
char *jid = iks_find_cdata(tag, "jid");
char *resource = strchr(jid, '/');
- iks *iq, *usersetting, *x;
+ iks *iq, *x;
handle->acc->resource = apr_pstrdup(handle->pool, resource);
handle->login = apr_pstrdup(handle->pool, jid);
if ((iq = iks_new("iq"))) {
- char *njid = strdup(handle->login);
- if ((resource = strchr(njid, '/'))) {
- *resource++ = '\0';
- }
- iks_insert_attrib(iq, "type", "set");
- iks_insert_attrib(iq, "to", njid);
- iks_insert_attrib(iq, "id", "params");
-
- usersetting = iks_insert(iq, "usersetting");
- iks_insert_attrib(usersetting, "xmlns", "google:setting");
- x = iks_insert(usersetting, "autoacceptrequests");
- iks_insert_attrib(x, "value", "true");
- x = iks_insert(usersetting, "mailnotifications");
- iks_insert_attrib(x, "value", "false");
- free(njid);
+ iks_insert_attrib(iq, "type", "get");
+ iks_insert_attrib(iq, "id", "roster");
+ x = iks_insert(iq, "query");
+ iks_insert_attrib(x, "xmlns", "jabber:iq:roster");
+ iks_insert_attrib(x, "xmlns:gr", "google:roster");
+ iks_insert_attrib(x, "gr:ext", "2");
+ iks_insert_attrib(x, "gr:include", "all");
iks_send(handle->parser, iq);
iks_delete(iq);
- if ((iq = iks_new("iq"))) {
- iks_insert_attrib(iq, "type", "get");
- iks_insert_attrib(iq, "id", "roster");
- x = iks_insert(iq, "query");
- iks_insert_attrib(x, "xmlns", "jabber:iq:roster");
- iks_insert_attrib(x, "xmlns:gr", "google:roster");
- iks_insert_attrib(x, "gr:ext", "2");
- iks_insert_attrib(x, "gr:include", "all");
- iks_send(handle->parser, iq);
- iks_delete(iq);
- }
-
-
+ break;
}
- break;
}
tag = iks_next_tag(tag);
}
@@ -1488,6 +1471,7 @@
new_handle->sessions = apr_hash_make(new_handle->pool);
new_handle->retry_hash = apr_hash_make(new_handle->pool);
new_handle->probe_hash = apr_hash_make(new_handle->pool);
+ new_handle->sub_hash = apr_hash_make(new_handle->pool);
apr_thread_mutex_create(&new_handle->lock, APR_THREAD_MUTEX_NESTED, new_handle->pool);
apr_thread_mutex_create(&new_handle->flag_mutex, APR_THREAD_MUTEX_NESTED, new_handle->pool);
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Mon Aug 21 15:14:51 2006
@@ -173,6 +173,7 @@
\param table optional state handler table to install on the channel
\param cid_name_override override the caller id name
\param cid_num_override override the caller id number
+ \param caller_profile_override override the entire calling caller profile
\return SWITCH_STATUS_SUCCESS if bleg is a running session.
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
@@ -181,7 +182,8 @@
uint32_t timelimit_sec,
const switch_state_handler_table_t *table,
char *cid_name_override,
- char *cid_num_override);
+ char *cid_num_override,
+ switch_caller_profile_t *caller_profile_override);
/*!
\brief Bridge Audio from one session to another
Modified: freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c Mon Aug 21 15:14:51 2006
@@ -50,7 +50,7 @@
timelimit = atoi(var);
}
- if (switch_ivr_originate(session, &peer_session, data, timelimit, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+ if (switch_ivr_originate(session, &peer_session, data, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
return;
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Mon Aug 21 15:14:51 2006
@@ -260,7 +260,7 @@
return SWITCH_STATUS_SUCCESS;
}
- if (switch_ivr_originate(NULL, &caller_session, aleg, timeout, NULL, cid_name, cid_num) != SWITCH_STATUS_SUCCESS) {
+ if (switch_ivr_originate(NULL, &caller_session, aleg, timeout, NULL, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "Cannot Create Outgoing Channel! [%s]\n", aleg);
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Mon Aug 21 15:14:51 2006
@@ -1989,7 +1989,7 @@
switch_channel_t *caller_channel = NULL;
- if (switch_ivr_originate(session, &peer_session, bridgeto, timeout, &audio_bridge_peer_state_handlers, cid_name, cid_num) != SWITCH_STATUS_SUCCESS) {
+ if (switch_ivr_originate(session, &peer_session, bridgeto, timeout, &audio_bridge_peer_state_handlers, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
if (session) {
caller_channel = switch_core_session_get_channel(session);
Modified: freeswitch/trunk/src/mod/codecs/mod_speex/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_speex/Makefile (original)
+++ freeswitch/trunk/src/mod/codecs/mod_speex/Makefile Mon Aug 21 15:14:51 2006
@@ -1,7 +1,7 @@
all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
depends:
- MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install speex-1.1.12.tar.gz --prefix=$(PREFIX)
+ MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install speex-1.1.12.tar.gz --prefix=$(PREFIX) --disable-shared --with-pic
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o
Modified: freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c Mon Aug 21 15:14:51 2006
@@ -1500,22 +1500,34 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "destroy %s\n", switch_channel_get_name(channel));
exosip_kill_channel(tech_pvt->session, SWITCH_SIG_KILL);
+
switch (event->type) {
case EXOSIP_CALL_RELEASED:
+ switch_channel_set_variable(channel, "exosip_disposition", "RELEASED");
+ cause = SWITCH_CAUSE_NORMAL_CLEARING;
+ break;
case EXOSIP_CALL_CLOSED:
+ switch_channel_set_variable(channel, "exosip_disposition", "CLOSED");
cause = SWITCH_CAUSE_NORMAL_CLEARING;
break;
case EXOSIP_CALL_NOANSWER:
+ switch_channel_set_variable(channel, "exosip_disposition", "NO ANSWER");
cause = SWITCH_CAUSE_NO_ANSWER;
break;
case EXOSIP_CALL_REQUESTFAILURE:
+ switch_channel_set_variable(channel, "exosip_disposition", "REQUEST FAILURE");
cause = SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL;
break;
case EXOSIP_CALL_SERVERFAILURE:
+ switch_channel_set_variable(channel, "exosip_disposition", "SERVER FAILURE");
+ cause = SWITCH_CAUSE_CALL_REJECTED;
+ break;
case EXOSIP_CALL_GLOBALFAILURE:
+ switch_channel_set_variable(channel, "exosip_disposition", "GLOBAL FAILURE");
cause = SWITCH_CAUSE_CALL_REJECTED;
break;
default:
+ switch_channel_set_variable(channel, "exosip_disposition", "UNKNOWN");
cause = SWITCH_CAUSE_SWITCH_CONGESTION;
break;
}
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Mon Aug 21 15:14:51 2006
@@ -1337,12 +1337,11 @@
static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
switch_memory_pool_t *pool = NULL;
- if (argc > 2) {
+ if (argc > 1) {
struct js_session *jss = NULL;
JSObject *session_obj;
switch_core_session_t *session = NULL, *peer_session = NULL;
switch_caller_profile_t *caller_profile = NULL;
- char *channel_type = NULL;
char *dest = NULL;
char *dialplan = NULL;
char *cid_name = "";
@@ -1353,6 +1352,7 @@
char *rdnis = "";
char *context = "";
char *username = NULL;
+ char *to = NULL;
*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
if (JS_ValueToObject(cx, argv[0], &session_obj)) {
@@ -1362,35 +1362,37 @@
}
}
- channel_type = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
- dest = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
+ dest = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+ if (argc > 2) {
+ dialplan = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
+ }
if (argc > 3) {
- dialplan = JS_GetStringBytes(JS_ValueToString(cx, argv[3]));
+ context = JS_GetStringBytes(JS_ValueToString(cx, argv[3]));
}
if (argc > 4) {
- context = JS_GetStringBytes(JS_ValueToString(cx, argv[4]));
+ cid_name = JS_GetStringBytes(JS_ValueToString(cx, argv[4]));
}
if (argc > 5) {
- cid_name = JS_GetStringBytes(JS_ValueToString(cx, argv[5]));
+ cid_num = JS_GetStringBytes(JS_ValueToString(cx, argv[5]));
}
if (argc > 6) {
- cid_num = JS_GetStringBytes(JS_ValueToString(cx, argv[6]));
+ network_addr = JS_GetStringBytes(JS_ValueToString(cx, argv[6]));
}
if (argc > 7) {
- network_addr = JS_GetStringBytes(JS_ValueToString(cx, argv[7]));
+ ani = JS_GetStringBytes(JS_ValueToString(cx, argv[7]));
}
if (argc > 8) {
- ani = JS_GetStringBytes(JS_ValueToString(cx, argv[8]));
+ ani2 = JS_GetStringBytes(JS_ValueToString(cx, argv[8]));
}
if (argc > 9) {
- ani2 = JS_GetStringBytes(JS_ValueToString(cx, argv[9]));
+ rdnis = JS_GetStringBytes(JS_ValueToString(cx, argv[9]));
}
if (argc > 10) {
- rdnis = JS_GetStringBytes(JS_ValueToString(cx, argv[10]));
+ username = JS_GetStringBytes(JS_ValueToString(cx, argv[10]));
}
if (argc > 11) {
- username = JS_GetStringBytes(JS_ValueToString(cx, argv[11]));
+ to = JS_GetStringBytes(JS_ValueToString(cx, argv[11]));
}
@@ -1399,20 +1401,34 @@
return JS_FALSE;
}
- caller_profile = switch_caller_profile_new(pool, username, dialplan, cid_name, cid_num, network_addr, ani, ani2, rdnis, (char *)modname, context, dest);
- if (switch_core_session_outgoing_channel(session, channel_type, caller_profile, &peer_session, pool) == SWITCH_STATUS_SUCCESS) {
- jss = switch_core_session_alloc(peer_session, sizeof(*jss));
- jss->session = peer_session;
- jss->flags = 0;
- jss->cx = cx;
- jss->obj = obj;
- JS_SetPrivate(cx, obj, jss);
- switch_core_session_thread_launch(peer_session);
- switch_set_flag(jss, S_HUP);
+ caller_profile = switch_caller_profile_new(pool,
+ username,
+ dialplan,
+ cid_name,
+ cid_num,
+ network_addr,
+ ani,
+ ani2,
+ rdnis,
+ (char *)modname,
+ context,
+ dest);
+
+ if (switch_ivr_originate(NULL, &peer_session, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest);
return JS_TRUE;
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Channel\n");
}
+
+ switch_core_session_rwunlock(peer_session);
+
+ jss = switch_core_session_alloc(peer_session, sizeof(*jss));
+ jss->session = peer_session;
+ jss->flags = 0;
+ jss->cx = cx;
+ jss->obj = obj;
+ JS_SetPrivate(cx, obj, jss);
+ switch_set_flag(jss, S_HUP);
+
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing Args\n");
}
@@ -1494,6 +1510,9 @@
struct fileio_obj *fio = JS_GetPrivate(cx, obj);
if (fio) {
+ if (fio->fd) {
+ switch_file_close(fio->fd);
+ }
switch_memory_pool_t *pool = fio->pool;
switch_core_destroy_memory_pool(&pool);
pool = NULL;
@@ -2214,7 +2233,6 @@
{
struct js_session *jss_a = NULL, *jss_b = NULL;
JSObject *session_obj_a = NULL, *session_obj_b = NULL;
- int32 timelimit = 60;
if (argc > 1) {
if (JS_ValueToObject(cx, argv[0], &session_obj_a)) {
@@ -2231,12 +2249,6 @@
}
}
- if (argc > 3) {
- if (!JS_ValueToInt32(cx, argv[3], &timelimit)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Convert to INT\n");
- return JS_FALSE;
- }
- }
if (!(jss_a && jss_b)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure! %s %s\n", jss_a ? "y" : "n", jss_b ? "y" : "n");
return JS_FALSE;
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Mon Aug 21 15:14:51 2006
@@ -247,11 +247,8 @@
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
- if (!switch_channel_test_flag(session->channel, CF_LOCK_THREAD)) {
- if ((status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock)) == SWITCH_STATUS_SUCCESS) {
- switch_channel_set_flag(session->channel, CF_LOCK_THREAD);
- }
- }
+
+ status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock);
return status;
}
@@ -263,8 +260,9 @@
SWITCH_DECLARE(void) switch_core_session_rwunlock(switch_core_session_t *session)
{
- switch_channel_clear_flag(session->channel, CF_LOCK_THREAD);
+
switch_thread_rwlock_unlock(session->rwlock);
+
}
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(char *uuid_str)
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Mon Aug 21 15:14:51 2006
@@ -1280,7 +1280,9 @@
uint32_t timelimit_sec,
const switch_state_handler_table_t *table,
char *cid_name_override,
- char *cid_num_override)
+ char *cid_num_override,
+ switch_caller_profile_t *caller_profile_override
+ )
{
char *peer_names[MAX_PEERS];
@@ -1361,8 +1363,8 @@
goto done;
}
- caller_caller_profile = switch_channel_get_caller_profile(caller_channel);
-
+ caller_caller_profile = caller_profile_override ? caller_profile_override : switch_channel_get_caller_profile(caller_channel);
+
if (!cid_name_override) {
cid_name_override = caller_caller_profile->caller_id_name;
}
@@ -1515,14 +1517,19 @@
}
- switch_core_session_reset(session);
+ if (session) {
+ switch_core_session_reset(session);
+ }
for (i = 0; i < argc; i++) {
if (!peer_channels[i]) {
continue;
}
if (i != idx) {
- switch_channel_hangup(peer_channels[i], SWITCH_CAUSE_LOSE_RACE);
+ if (caller_channel) {
+ switch_channel_set_variable(caller_channel, "originate_disposition", "lost race");
+ switch_channel_hangup(peer_channels[i], SWITCH_CAUSE_LOSE_RACE);
+ }
}
}
@@ -1542,9 +1549,15 @@
if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
switch_core_session_read_lock(peer_session);
*bleg = peer_session;
+ if (caller_channel) {
+ switch_channel_set_variable(caller_channel, "originate_disposition", "call accepted");
+ }
status = SWITCH_STATUS_SUCCESS;
} else {
- switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ANSWER);
+ if (caller_channel) {
+ switch_channel_set_variable(caller_channel, "originate_disposition", "no answer");
+ switch_channel_hangup(caller_channel, SWITCH_CAUSE_NO_ANSWER);
+ }
status = SWITCH_STATUS_FALSE;
}
More information about the Freeswitch-svn
mailing list