Merged revisions 73316 via svnmerge from
[asterisk/asterisk.git] / apps / app_transfer.c
index 78d5697..4d918f6 100644 (file)
 /*! \file
  *
  * \brief Transfer a caller
+ *
+ * \author Mark Spencer <markster@digium.com>
  * 
  * Requires transfer support from channel driver
  *
  * \ingroup applications
  */
 
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
 #include "asterisk/lock.h"
 #include "asterisk/file.h"
 #include "asterisk/logger.h"
@@ -43,11 +45,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/options.h"
 #include "asterisk/app.h"
 
-STANDARD_LOCAL_USER;
-
-LOCAL_USER_DECL;
-
-static const char *tdesc = "Transfer";
 
 static const char *app = "Transfer";
 
@@ -63,48 +60,36 @@ static const char *descrip =
 "channel variable:\n"
 "       SUCCESS      Transfer succeeded\n"
 "       FAILURE      Transfer failed\n"
-"       UNSUPPORTED  Transfer unsupported by channel driver\n"
-"The option string many contain the following character:\n"
-"'j' -- jump to n+101 priority if the channel transfer attempt\n"
-"       fails\n";
+"       UNSUPPORTED  Transfer unsupported by channel driver\n";
 
 static int transfer_exec(struct ast_channel *chan, void *data)
 {
        int res;
        int len;
-       struct localuser *u;
+       struct ast_module_user *u;
        char *slash;
        char *tech = NULL;
        char *dest = NULL;
        char *status;
        char *parse;
-       int priority_jump = 0;
        AST_DECLARE_APP_ARGS(args,
                AST_APP_ARG(dest);
                AST_APP_ARG(options);
        );
 
-       LOCAL_USER_ADD(u);
+       u = ast_module_user_add(chan);
 
        if (ast_strlen_zero((char *)data)) {
                ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination[|options])\n");
-               LOCAL_USER_REMOVE(u);
+               ast_module_user_remove(u);
                pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
                return 0;
-       } else {
+       } else
                parse = ast_strdupa(data);
-               if (!parse) {
-                       ast_log(LOG_ERROR, "Out of memory!\n");
-                       LOCAL_USER_REMOVE(u);
-                       return -1;
-               }
-       }
 
        AST_STANDARD_APP_ARGS(args, parse);
 
        if (args.options) {
-               if (strchr(args.options, 'j'))
-                       priority_jump = 1;
        }
 
        dest = args.dest;
@@ -113,9 +98,9 @@ static int transfer_exec(struct ast_channel *chan, void *data)
                tech = dest;
                dest = slash + 1;
                /* Allow execution only if the Tech/destination agrees with the type of the channel */
-               if (strncasecmp(chan->type, tech, len)) {
+               if (strncasecmp(chan->tech->type, tech, len)) {
                        pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
-                       LOCAL_USER_REMOVE(u);
+                       ast_module_user_remove(u);
                        return 0;
                }
        }
@@ -123,7 +108,7 @@ static int transfer_exec(struct ast_channel *chan, void *data)
        /* Check if the channel supports transfer before we try it */
        if (!chan->tech->transfer) {
                pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "UNSUPPORTED");
-               LOCAL_USER_REMOVE(u);
+               ast_module_user_remove(u);
                return 0;
        }
 
@@ -131,8 +116,6 @@ static int transfer_exec(struct ast_channel *chan, void *data)
 
        if (res < 0) {
                status = "FAILURE";
-               if (priority_jump || ast_opt_priority_jumping)
-                       ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
                res = 0;
        } else {
                status = "SUCCESS";
@@ -141,42 +124,25 @@ static int transfer_exec(struct ast_channel *chan, void *data)
 
        pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", status);
 
-       LOCAL_USER_REMOVE(u);
+       ast_module_user_remove(u);
 
        return res;
 }
 
-int unload_module(void)
+static int unload_module(void)
 {
        int res;
 
        res = ast_unregister_application(app);
 
-       STANDARD_HANGUP_LOCALUSERS;
+       ast_module_user_hangup_all();
 
        return res;     
 }
 
-int load_module(void)
+static int load_module(void)
 {
        return ast_register_application(app, transfer_exec, synopsis, descrip);
 }
 
-char *description(void)
-{
-       return (char *) tdesc;
-}
-
-int usecount(void)
-{
-       int res;
-
-       STANDARD_USECOUNT(res);
-
-       return res;
-}
-
-char *key()
-{
-       return ASTERISK_GPL_KEY;
-}
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Transfers a caller to another extension");