}
/**
- * Set faxing flag if faxing is not in progress
+ * Set faxing flag
* @param call the call to flag
* @param faxing true if faxing is in progress
- * @return true if set, false if can't set because faxing is already in progress. Reset always succeeds.
*/
-int rayo_call_set_faxing(struct rayo_call *call, int faxing)
+void rayo_call_set_faxing(struct rayo_call *call, int faxing)
{
- if (!faxing || (faxing && !call->faxing)) {
- call->faxing = faxing;
- return 1;
- }
- return 0;
+ call->faxing = faxing;
}
#define RAYO_MIXER_LOCATE(mixer_name) rayo_mixer_locate(mixer_name, __FILE__, __LINE__)
}
}
if (!call) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Missing rayo call!!\n");
- goto done;
+ /* this scenario can only happen if a call was originated through a mechanism other than <dial>
+ and then the rayo APP was executed to offer control */
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Outbound call that wasn't created with <dial>, will try to offer control\n");
}
ok = 1;
- } else {
- /* inbound call - offer control */
+ }
+
+ if (!call) {
+ /* offer control */
switch_hash_index_t *hi = NULL;
iks *offer = NULL;
- if (call) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Call is already under Rayo 3PCC!\n");
- goto done;
- }
call = rayo_call_create(switch_core_session_get_uuid(session));
switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_call_jid", RAYO_JID(call));
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "can't send fax on a joined call");
}
- if (!rayo_call_set_faxing(RAYO_CALL(call), 1)) {
+ if (rayo_call_is_faxing(RAYO_CALL(call))) {
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "fax already in progress");
}
/* clear fax interrupt variable */
switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL);
+ rayo_call_set_faxing(RAYO_CALL(call), 1);
+
/* execute txfax APP */
if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute");
if (execute_event) {
switch_event_destroy(&execute_event);
}
+ rayo_call_set_faxing(RAYO_CALL(call), 0);
RAYO_UNLOCK(sendfax_component);
} else {
/* component starting... */
}
} else {
response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create txfax event");
+ rayo_call_set_faxing(RAYO_CALL(call), 0);
RAYO_UNLOCK(sendfax_component);
}
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "can't receive fax on a joined call");
}
- if (!rayo_call_set_faxing(RAYO_CALL(call), 1)) {
+ if (rayo_call_is_faxing(RAYO_CALL(call))) {
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "fax already in progress");
}
receivefax_component = switch_core_alloc(pool, sizeof(*receivefax_component));
rayo_component_init((struct rayo_component *)receivefax_component, pool, RAT_CALL_COMPONENT, "receivefax", NULL, call, iks_find_attrib(iq, "from"));
file_no = rayo_actor_seq_next(call);
- receivefax_component->filename = switch_core_sprintf(pool, "%s%s%s-%d",
+ receivefax_component->filename = switch_core_sprintf(pool, "%s%s%s-%d.tif",
globals.file_prefix, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session), file_no);
if (!strncmp(receivefax_component->filename, "http://", 7) || !strncmp(receivefax_component->filename, "https://", 8)) {
/* This is an HTTP URL, need to PUT after fax is received */
/* clear fax interrupt variable */
switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL);
+ rayo_call_set_faxing(RAYO_CALL(call), 1);
+
/* execute rxfax APP */
if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute");
if (execute_event) {
switch_event_destroy(&execute_event);
}
+ rayo_call_set_faxing(RAYO_CALL(call), 0);
RAYO_UNLOCK(receivefax_component);
} else {
/* component starting... */
}
} else {
response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create rxfax event");
+ rayo_call_set_faxing(RAYO_CALL(call), 0);
RAYO_UNLOCK(receivefax_component);
}