Add new AMI action for app_voicemail
[asterisk/asterisk.git] / apps / app_chanisavail.c
index 86ce341..af4b616 100644 (file)
@@ -33,8 +33,6 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
 #include <sys/ioctl.h>
 
 #include "asterisk/lock.h"
@@ -56,10 +54,10 @@ static const char app[] = "ChanIsAvail";
                        <parameter name="Technology/Resource" required="true" argsep="&amp;">
                                <argument name="Technology2/Resource2" multiple="true">
                                        <para>Optional extra devices to check</para>
-                                       <para>If you need more then one enter them as
-                                       Technology2/Resource2&amp;Technology3/Resourse3&amp;.....</para>
+                                       <para>If you need more than one enter them as
+                                       Technology2/Resource2&amp;Technology3/Resource3&amp;.....</para>
                                </argument>
-                               <para>Specification of the device(s) to check.  These must be in the format of 
+                               <para>Specification of the device(s) to check.  These must be in the format of
                                <literal>Technology/Resource</literal>, where <replaceable>Technology</replaceable>
                                represents a particular channel driver, and <replaceable>Resource</replaceable>
                                represents a resource available to that particular channel driver.</para>
@@ -152,7 +150,9 @@ static int chanavail_exec(struct ast_channel *chan, const char *data)
                        }
                        *number = '\0';
                        number++;
-                       
+
+                       status = AST_DEVICE_UNKNOWN;
+
                        if (string_compare) {
                                /* ast_parse_device_state checks for "SIP/1234" as a channel name.
                                   ast_device_state will ask the SIP driver for the channel state. */
@@ -169,8 +169,8 @@ static int chanavail_exec(struct ast_channel *chan, const char *data)
                        }
                        snprintf(tmp, sizeof(tmp), "%d", status);
                        ast_str_append(&tmp_availstat, 0, "%s%s", ast_str_strlen(tmp_availstat) ? "&" : "", tmp);
-                       if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformats, chan, number, &status))) {
-                                       ast_str_append(&tmp_availchan, 0, "%s%s", ast_str_strlen(tmp_availchan) ? "&" : "", tempchan->name);
+                       if ((inuse <= 1) && (tempchan = ast_request(tech, ast_channel_nativeformats(chan), NULL, chan, number, &status))) {
+                                       ast_str_append(&tmp_availchan, 0, "%s%s", ast_str_strlen(tmp_availchan) ? "&" : "", ast_channel_name(tempchan));
                                        
                                        snprintf(tmp, sizeof(tmp), "%s/%s", tech, number);
                                        ast_str_append(&tmp_availorig, 0, "%s%s", ast_str_strlen(tmp_availorig) ? "&" : "", tmp);
@@ -209,4 +209,5 @@ static int load_module(void)
                AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Check channel availability");
+AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Check channel availability");
+