[asterisk-commits] mmichelson: branch group/CCSS r213786 - /team/group/CCSS/apps/app_dial.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Aug 23 16:27:10 CDT 2009
Author: mmichelson
Date: Sun Aug 23 16:27:06 2009
New Revision: 213786
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=213786
Log:
A bit more progress on app_dial. Now to handle the
"situation 3" scenario.
Modified:
team/group/CCSS/apps/app_dial.c
Modified: team/group/CCSS/apps/app_dial.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/apps/app_dial.c?view=diff&rev=213786&r1=213785&r2=213786
==============================================================================
--- team/group/CCSS/apps/app_dial.c (original)
+++ team/group/CCSS/apps/app_dial.c Sun Aug 23 16:27:06 2009
@@ -775,6 +775,11 @@
ast_channel_make_compatible(o->chan, in);
ast_channel_inherit_variables(in, o->chan);
ast_channel_datastore_inherit(in, o->chan);
+ /* When a call is forwarded, we don't want to track new interfaces
+ * dialed for CC purposes. Setting the done flag will ensure that
+ * any Dial operations that happen later won't record CC interfaces.
+ */
+ cc_set_done_flag(o->chan);
} else
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
}
@@ -1664,8 +1669,16 @@
static void *dial_cc_interfaces_duplicate(void *data)
{
- /* STUB */
- return NULL;
+ struct dial_cc_interfaces *old_cc_interfaces = data;
+ struct dial_cc_interfaces *new_cc_interfaces = ast_calloc(1, sizeof(*new_cc_interfaces));
+ if (!new_cc_interfaces) {
+ return NULL
+ }
+ new_cc_interfaces->done = old_cc_interfaces->done;
+ new_cc_interfaces->parent_id = old_cc_interfaces->parent_id;
+ ao2_ref(old_cc_interfaces->interface_tree, +1);
+ new_cc_interfaces->interface_tree = old_cc_interfaces->interface_tree;
+ return new_cc_interfaces;
}
static const struct ast_datastore_info dial_cc_interfaces_info = {
@@ -1674,6 +1687,20 @@
.destroy = dial_cc_interfaces_destroy,
};
+static void cc_set_done_flag(struct ast_channel *chan)
+{
+ struct ast_datastore *cc_datastore;
+ struct dial_cc_interfaces *cc_interfaces;
+
+ ast_channel_lock(chan);
+ if ((cc_datastore = ast_channel_datastore_find(chan, &dial_cc_interfaces_info, NULL))) {
+ cc_interfaces = cc_datastore->data;
+ cc_interfaces->done = 1;
+ }
+ ast_channel_unlock(chan);
+}
+
+
static struct ast_cc_interface *cc_extension_interface_init(const char * const exten, const char * const context, const unsigned int parent_id)
{
struct ast_str *str = ast_str_alloca(2 * AST_MAX_EXTENSION);
@@ -1700,7 +1727,7 @@
return -1;
}
- if (!(cc_interface = cc_extension_interface_init(chan->exten, chan->context, 0))) {
+ if (!(cc_interface = cc_extension_interface_init(S_OR(chan->macroexten, chan->exten), S_OR(chan->macrocontext, chan->context), 0))) {
ast_free(interfaces);
return -1;
}
@@ -1722,6 +1749,8 @@
AST_LIST_HEAD_INIT(interfaces->interface_tree);
AST_LIST_INSERT_TAIL(interfaces->interface_tree, cc_interface, next);
dial_cc_datastore->data = interfaces;
+ dial_cc_datastore->inheritance = DATASTORE_INHERIT_FOREVER;
+ dial_cc_datastore->parent_id = cc_interface->id;
ast_channel_lock(chan);
ast_channel_datastore_add(chan, dial_cc_datastore);
ast_channel_unlock(chan);
@@ -1764,6 +1793,12 @@
interfaces = cc_interfaces_datastore->data;
if (!interfaces->done) {
/* Situation 2 has occurred */
+ struct ast_cc_interface *cc_interface = cc_extension_interface_init(S_OR(chan->macroexten, chan->exten),
+ S_OR(chan->macrocontext, chan->context), interfaces->parent_id);
+ if (!cc_interface) {
+ return -1;
+ }
+ interfaces->parent_id = cc_interface->id;
} else {
/* Situation 3 has occurred */
}
@@ -2594,6 +2629,7 @@
if (config.start_sound) {
ast_free((char *)config.start_sound);
}
+ cc_set_done_flag(chan);
return res;
}
More information about the asterisk-commits
mailing list