<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][14809] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=14809">14809</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2009-09-10 15:20:23 -0500 (Thu, 10 Sep 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>outbound callers for fifo</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_fifomod_fifoc">freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodapplicationsmod_fifomod_fifoc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (14808 => 14809)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c        2009-09-10 19:31:58 UTC (rev 14808)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c        2009-09-10 20:20:23 UTC (rev 14809)
</span><span class="lines">@@ -688,6 +688,70 @@
</span><span class="cx">         switch_safe_free(dup_to);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static uint32_t fifo_add_outbound(const char *node_name, const char *url, uint32_t priority)
+{
+        fifo_node_t *node;
+        char *str;
+
+        if (priority >= MAX_PRI) {
+                priority = MAX_PRI - 1;
+        }
+
+        switch_mutex_lock(globals.mutex);
+
+        if (!(node = switch_core_hash_find(globals.fifo_hash, node_name))) {
+                node = create_node(node_name, 0);
+        }
+
+        switch_mutex_unlock(globals.mutex);
+        
+        str = switch_mprintf("dial:%s", url);
+        switch_queue_push(node->fifo_list[priority], (void *) str);
+        
+        return switch_queue_size(node->fifo_list[priority]);
+        
+}
+
+
+SWITCH_STANDARD_API(fifo_add_outbound_function)
+{
+        char *data = NULL, *argv[4] = { 0 };
+        int argc;
+        uint32_t priority = 0;
+
+        if (switch_strlen_zero(cmd)) {
+                goto fail;
+        }
+
+        data = strdup(cmd);
+
+        if ((argc = switch_separate_string(data, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 2 || !argv[0]) {
+                goto fail;
+        }
+
+        if (argv[2]) {
+                int tmp = atoi(argv[2]);
+                if (tmp > 0) {
+                        priority = tmp;
+                }
+        }
+
+        stream->write_function(stream, "%d", fifo_add_outbound(argv[0], argv[1], priority));
+
+        
+        free(data);        
+        return SWITCH_STATUS_SUCCESS;        
+
+
+ fail:
+
+        free(data);        
+        stream->write_function(stream, "0");
+        return SWITCH_STATUS_SUCCESS;        
+
+}
+
+
</ins><span class="cx"> typedef enum {
</span><span class="cx">         STRAT_MORE_PPL,
</span><span class="cx">         STRAT_WAITING_LONGER,
</span><span class="lines">@@ -1039,8 +1103,8 @@
</span><span class="cx">                 char buf[5] = "";
</span><span class="cx">                 const char *strat_str = switch_channel_get_variable(channel, "fifo_strategy");
</span><span class="cx">                 fifo_strategy_t strat = STRAT_WAITING_LONGER;
</span><ins>+                char *url = NULL;
</ins><span class="cx">
</span><del>-
</del><span class="cx">                 if (!switch_strlen_zero(strat_str)) {
</span><span class="cx">                         if (!strcasecmp(strat_str, "more_ppl")) {
</span><span class="cx">                                 strat = STRAT_MORE_PPL;
</span><span class="lines">@@ -1200,21 +1264,60 @@
</span><span class="cx">                         uuid = (char *) pop;
</span><span class="cx">                         pop = NULL;
</span><span class="cx">
</span><del>-                        if (node && (other_session = switch_core_session_locate(uuid))) {
</del><ins>+                        if (!strncasecmp(uuid, "dial:", 5)) {
+                                switch_call_cause_t cause = SWITCH_CAUSE_NONE;
+                                const char *o_announce = NULL;
+                                url = uuid + 5;
+                                
+                                if ((o_announce = switch_channel_get_variable(channel, "fifo_outbound_announce"))) {
+                                        switch_ivr_play_file(session, NULL, o_announce, NULL);
+                                }
+
+                                if (switch_ivr_originate(session, &other_session, &cause, url, 120, NULL, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
+                                        other_session = NULL;
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Originate to [%s] failed, cause: %s\n", url, switch_channel_cause2str(cause));
+
+                                        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
+                                                switch_channel_event_set_data(channel, event);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "caller_outbound");
+                                                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Result", "failure:%s", switch_channel_cause2str(cause));
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Outbound-URL", url);
+                                                switch_event_fire(&event);
+                                        }
+                                        
+                                } else {
+                                        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
+                                                switch_channel_event_set_data(channel, event);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "caller_outbound");
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Result", "success");
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Outbound-URL", url);
+                                                switch_event_fire(&event);
+                                        }                                        
+                                }
+
+                        } else {
+                                if ((other_session = switch_core_session_locate(uuid))) {
+                                        switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+                                        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
+                                                switch_channel_event_set_data(other_channel, event);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]);
+                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "caller_pop");
+                                                switch_event_fire(&event);
+                                        }
+                                }
+                        }
+
+                        if (node && other_session) {
</ins><span class="cx">                                 switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
</span><span class="cx">                                 switch_caller_profile_t *cloned_profile;
</span><span class="cx">                                 const char *o_announce = NULL;
</span><span class="cx">                                 const char *record_template = switch_channel_get_variable(channel, "fifo_record_template");
</span><span class="cx">                                 char *expanded = NULL;
</span><span class="cx">
</span><ins>+                                
</ins><span class="cx">                                 if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
</span><del>-                                        switch_channel_event_set_data(other_channel, event);
-                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]);
-                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "caller_pop");
-                                        switch_event_fire(&event);
-                                }
-
-                                if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
</del><span class="cx">                                         switch_channel_event_set_data(channel, event);
</span><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]);
</span><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "consumer_pop");
</span><span class="lines">@@ -2124,6 +2227,7 @@
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "fifo", "Park with FIFO", FIFO_DESC, fifo_function, FIFO_USAGE, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, "fifo", "Return data about a fifo", fifo_api_function, FIFO_API_SYNTAX);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, "fifo_member", "Add members to a fifo", fifo_member_api_function, FIFO_MEMBER_API_SYNTAX);
</span><ins>+        SWITCH_ADD_API(commands_api_interface, "fifo_add_outbound", "Add outbound members to a fifo", fifo_add_outbound_function, "<node> <url> [<priority>]");
</ins><span class="cx">         switch_console_set_complete("add fifo list");
</span><span class="cx">         switch_console_set_complete("add fifo list_verbose");
</span><span class="cx">         switch_console_set_complete("add fifo count");
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>