]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_rayo: send/receivefax bugfixes, also allow outbound calls not created with <dial...
authorChris Rienzo <chris.rienzo@grasshopper.com>
Fri, 8 Nov 2013 16:43:24 +0000 (11:43 -0500)
committerChris Rienzo <chris.rienzo@grasshopper.com>
Fri, 8 Nov 2013 16:43:40 +0000 (11:43 -0500)
src/mod/event_handlers/mod_rayo/mod_rayo.c
src/mod/event_handlers/mod_rayo/mod_rayo.h
src/mod/event_handlers/mod_rayo/rayo_fax_components.c

index 7bb5dfc6f82ac05975c1a16bb90372aabb81c7ab..88eb44b417a0e28b0252fd5a6f11f865ced32453 100644 (file)
@@ -983,18 +983,13 @@ int rayo_call_is_faxing(struct rayo_call *call)
 }
 
 /**
- * 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__)
@@ -3174,18 +3169,17 @@ SWITCH_STANDARD_APP(rayo_app)
                        }
                }
                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));
index c65236b64a3eb1a7c1802f32c2881ef869c1659c..b862802f3130a64eb3e0412b8adaad4d71e75307 100644 (file)
@@ -155,7 +155,7 @@ extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int l
 
 extern int rayo_call_is_joined(struct rayo_call *call);
 extern int rayo_call_is_faxing(struct rayo_call *call);
-extern int rayo_call_set_faxing(struct rayo_call *call, int faxing);
+extern void rayo_call_set_faxing(struct rayo_call *call, int faxing);
 extern const char *rayo_call_get_dcp_jid(struct rayo_call *call);
 
 #define rayo_mixer_get_name(mixer) RAYO_ID(mixer)
index 420853104a82c55f698d33f3329a4820f99007fe..bce34dc9d9f095c07e0b2f8de18dcd6dd735fb77 100644 (file)
@@ -92,7 +92,7 @@ static iks *start_sendfax_component(struct rayo_actor *call, struct rayo_message
                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");
        }
 
@@ -199,6 +199,8 @@ static iks *start_sendfax_component(struct rayo_actor *call, struct rayo_message
        /* 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");
@@ -214,6 +216,7 @@ static iks *start_sendfax_component(struct rayo_actor *call, struct rayo_message
                        if (execute_event) {
                                switch_event_destroy(&execute_event);
                        }
+                       rayo_call_set_faxing(RAYO_CALL(call), 0);
                        RAYO_UNLOCK(sendfax_component);
                } else {
                        /* component starting... */
@@ -221,6 +224,7 @@ static iks *start_sendfax_component(struct rayo_actor *call, struct rayo_message
                }
        } 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);
        }
 
@@ -255,7 +259,7 @@ static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_mess
                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");
        }
 
@@ -264,7 +268,7 @@ static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_mess
        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 */
@@ -298,6 +302,8 @@ static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_mess
        /* 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");
@@ -313,6 +319,7 @@ static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_mess
                        if (execute_event) {
                                switch_event_destroy(&execute_event);
                        }
+                       rayo_call_set_faxing(RAYO_CALL(call), 0);
                        RAYO_UNLOCK(receivefax_component);
                } else {
                        /* component starting... */
@@ -320,6 +327,7 @@ static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_mess
                }
        } 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);
        }