snprintf(name, sizeof(name), "Exosip/%s-%04x", event->request->from->url->username, rand() & 0xffff);
switch_channel_set_name(channel, name);
+ switch_channel_set_variable(channel, "endpoint_disposition", "INVITE");
if (osip_message_header_get_byname (event->request, "SrtpRealm", 0, &tedious)) {
tech_pvt->realm = switch_core_session_strdup(session, osip_header_get_value(tedious));
switch (event->type) {
case EXOSIP_CALL_RELEASED:
- switch_channel_set_variable(channel, "exosip_disposition", "RELEASED");
+ switch_channel_set_variable(channel, "endpoint_disposition", "RELEASED");
cause = SWITCH_CAUSE_NORMAL_CLEARING;
break;
case EXOSIP_CALL_CLOSED:
- switch_channel_set_variable(channel, "exosip_disposition", "CLOSED");
+ switch_channel_set_variable(channel, "endpoint_disposition", "CLOSED");
cause = SWITCH_CAUSE_NORMAL_CLEARING;
break;
case EXOSIP_CALL_NOANSWER:
- switch_channel_set_variable(channel, "exosip_disposition", "NO ANSWER");
+ switch_channel_set_variable(channel, "endpoint_disposition", "NO ANSWER");
cause = SWITCH_CAUSE_NO_ANSWER;
break;
case EXOSIP_CALL_REQUESTFAILURE:
- switch_channel_set_variable(channel, "exosip_disposition", "REQUEST FAILURE");
+ switch_channel_set_variable(channel, "endpoint_disposition", "REQUEST FAILURE");
cause = SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL;
break;
case EXOSIP_CALL_SERVERFAILURE:
- switch_channel_set_variable(channel, "exosip_disposition", "SERVER FAILURE");
+ switch_channel_set_variable(channel, "endpoint_disposition", "SERVER FAILURE");
cause = SWITCH_CAUSE_CALL_REJECTED;
break;
case EXOSIP_CALL_GLOBALFAILURE:
- switch_channel_set_variable(channel, "exosip_disposition", "GLOBAL FAILURE");
+ switch_channel_set_variable(channel, "endpoint_disposition", "GLOBAL FAILURE");
cause = SWITCH_CAUSE_CALL_REJECTED;
break;
default:
- switch_channel_set_variable(channel, "exosip_disposition", "UNKNOWN");
+ switch_channel_set_variable(channel, "endpoint_disposition", "UNKNOWN");
cause = SWITCH_CAUSE_SWITCH_CONGESTION;
break;
}
return;
}
+ switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER");
+
conn = eXosip_get_audio_connection(remote_sdp);
remote_med = eXosip_get_audio_media(remote_sdp);
return (switch_channel_ready(channel)) ? JS_TRUE : JS_FALSE;
}
+static JSBool session_set_variable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+ struct js_session *jss = JS_GetPrivate(cx, obj);
+ switch_channel_t *channel;
+
+ channel = switch_core_session_get_channel(jss->session);
+ assert(channel != NULL);
+
+ if (argc > 1) {
+ char *var, *val;
+
+ var = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+ val = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+ switch_channel_set_variable(channel, var, val);
+ *rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+ } else {
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ }
+
+ return JS_TRUE;
+}
+
+static JSBool session_get_variable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+ struct js_session *jss = JS_GetPrivate(cx, obj);
+ switch_channel_t *channel;
+
+ channel = switch_core_session_get_channel(jss->session);
+ assert(channel != NULL);
+
+ if (argc > 0) {
+ char *var, *val;
+
+ var = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+ val = switch_channel_get_variable(channel, var);
+
+ if (val) {
+ *rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, val));
+ } else {
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ }
+ } else {
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ }
+
+ return JS_TRUE;
+}
+
+
static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
struct js_session *jss = JS_GetPrivate(cx, obj);
{"flushEvents", session_flush_events, 1},
{"flushDigits", session_flush_digits, 1},
{"speak", session_speak, 1},
+ {"setVariable", session_set_variable, 1},
+ {"getVariable", session_get_variable, 1},
{"getDigits", session_get_digits, 1},
{"answer", session_answer, 0},
{"ready", session_ready, 0},
context,
dest);
- if (switch_ivr_originate(NULL, &peer_session, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
+ if (switch_ivr_originate(session, &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;
}
status = SWITCH_STATUS_GENERR;
goto done;
}
-
+
if (session) {
caller_channel = switch_core_session_get_channel(session);
assert(caller_channel != NULL);
+ switch_channel_set_variable(caller_channel, "originate_disposition", "failure");
+
if ((var = switch_channel_get_variable(caller_channel, "group_confirm_key"))) {
key = switch_core_session_strdup(session, var);
if ((var = switch_channel_get_variable(caller_channel, "group_confirm_file"))) {
goto done;
}
- caller_profiles[i] = switch_caller_profile_new(pool,
- NULL,
- NULL,
- cid_name_override,
- cid_num_override,
- NULL,
- NULL,
- NULL,
- NULL,
- __FILE__,
- NULL,
- chan_data);
+ if (caller_profile_override) {
+ caller_profiles[i] = switch_caller_profile_new(pool,
+ caller_profile_override->username,
+ caller_profile_override->dialplan,
+ caller_profile_override->caller_id_name,
+ caller_profile_override->caller_id_number,
+ caller_profile_override->network_addr,
+ caller_profile_override->ani,
+ caller_profile_override->ani2,
+ caller_profile_override->rdnis,
+ caller_profile_override->source,
+ caller_profile_override->context,
+ chan_data);
+ } else {
+ caller_profiles[i] = switch_caller_profile_new(pool,
+ NULL,
+ NULL,
+ cid_name_override,
+ cid_num_override,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ __FILE__,
+ NULL,
+ chan_data);
+ }
}
-
if (switch_core_session_outgoing_channel(session, chan_type, caller_profiles[i], &peer_sessions[i], pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
if (pool) {
continue;
}
if (i != idx) {
- if (caller_channel) {
- switch_channel_set_variable(caller_channel, "originate_disposition", "lost race");
- switch_channel_hangup(peer_channels[i], SWITCH_CAUSE_LOSE_RACE);
- }
+ switch_channel_hangup(peer_channels[i], SWITCH_CAUSE_LOSE_RACE);
}
}