[asterisk-commits] file: branch file/dialing_api r50076 - in
/team/file/dialing_api: include/ast...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Jan 8 14:51:21 MST 2007
Author: file
Date: Mon Jan 8 15:51:20 2007
New Revision: 50076
URL: http://svn.digium.com/view/asterisk?view=rev&rev=50076
Log:
Add capability to enable/disable options per dialed channel.
Modified:
team/file/dialing_api/include/asterisk/dial.h
team/file/dialing_api/main/dial.c
Modified: team/file/dialing_api/include/asterisk/dial.h
URL: http://svn.digium.com/view/asterisk/team/file/dialing_api/include/asterisk/dial.h?view=diff&rev=50076&r1=50075&r2=50076
==============================================================================
--- team/file/dialing_api/include/asterisk/dial.h (original)
+++ team/file/dialing_api/include/asterisk/dial.h Mon Jan 8 15:51:20 2007
@@ -110,6 +110,15 @@
*/
int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data);
+/*! \brief Enables an option per channel
+ * \param dial Dial structure
+ * \param num Channel number to enable option on
+ * \param option Option to enable
+ * \param data Data to pass to this option (not always needed)
+ * \return Returns 0 on success, -1 on failure
+ */
+int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option option, void *data);
+
/*! \brief Disables an option globally
* \param dial Dial structure to disable option on
* \param option Option to disable
@@ -117,6 +126,14 @@
*/
int ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option option);
+/*! \brief Disables an option per channel
+ * \param dial Dial structure
+ * \param num Channel number to disable option on
+ * \param option Option to disable
+ * \return Returns 0 on success, -1 on failure
+ */
+int ast_dial_option_disable(struct ast_dial *dial, int num, enum ast_dial_option option);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Modified: team/file/dialing_api/main/dial.c
URL: http://svn.digium.com/view/asterisk/team/file/dialing_api/main/dial.c?view=diff&rev=50076&r1=50075&r2=50076
==============================================================================
--- team/file/dialing_api/main/dial.c (original)
+++ team/file/dialing_api/main/dial.c Mon Jan 8 15:51:20 2007
@@ -624,6 +624,48 @@
return 0;
}
+/*! \brief Enables an option per channel
+ * \param dial Dial structure
+ * \param num Channel number to enable option on
+ * \param option Option to enable
+ * \param data Data to pass to this option (not always needed)
+ * \return Returns 0 on success, -1 on failure
+ */
+int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option option, void *data)
+{
+ struct ast_dial_channel *channel = NULL;
+
+ /* Ensure we have required arguments */
+ if (!dial || AST_LIST_EMPTY(&dial->channels))
+ return -1;
+
+ /* Look for channel, we can sort of cheat and predict things - the last channel in the list will probably be what they want */
+ if (AST_LIST_LAST(&dial->channels)->num != num) {
+ AST_LIST_TRAVERSE(&dial->channels, channel, list) {
+ if (channel->num == num)
+ break;
+ }
+ } else {
+ channel = AST_LIST_LAST(&dial->channels);
+ }
+
+ /* If none found, return failure */
+ if (!channel)
+ return -1;
+
+ /* If the option is already enabled, return failure */
+ if (channel->options[option])
+ return -1;
+
+ /* Execute enable callback if it exists, if not simply make sure the value is set */
+ if (option_types[option].enable)
+ channel->options[option] = option_types[option].enable(data);
+ else
+ channel->options[option] = (void*)1;
+
+ return 0;
+}
+
/*! \brief Disables an option globally
* \param dial Dial structure to disable option on
* \param option Option to disable
@@ -644,3 +686,45 @@
return 0;
}
+
+/*! \brief Disables an option per channel
+ * \param dial Dial structure
+ * \param num Channel number to disable option on
+ * \param option Option to disable
+ * \return Returns 0 on success, -1 on failure
+ */
+int ast_dial_option_disable(struct ast_dial *dial, int num, enum ast_dial_option option)
+{
+ struct ast_dial_channel *channel = NULL;
+
+ /* Ensure we have required arguments */
+ if (!dial || AST_LIST_EMPTY(&dial->channels))
+ return -1;
+
+ /* Look for channel, we can sort of cheat and predict things - the last channel in the list will probably be what they want */
+ if (AST_LIST_LAST(&dial->channels)->num != num) {
+ AST_LIST_TRAVERSE(&dial->channels, channel, list) {
+ if (channel->num == num)
+ break;
+ }
+ } else {
+ channel = AST_LIST_LAST(&dial->channels);
+ }
+
+ /* If none found, return failure */
+ if (!channel)
+ return -1;
+
+ /* If the option is not enabled, return failure */
+ if (!channel->options[option])
+ return -1;
+
+ /* Execute callback of option to disable it if it exists */
+ if (option_types[option].disable)
+ option_types[option].disable(channel->options[option]);
+
+ /* Finally disable the option on the structure */
+ channel->options[option] = NULL;
+
+ return 0;
+}
More information about the asterisk-commits
mailing list