Sat Aug 6 00:39:21 2011

Asterisk developer's documentation


app_settransfercapability.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2005, Frank Sautter, levigo holding gmbh, www.levigo.de
00005  *
00006  * Frank Sautter - asterisk+at+sautter+dot+com 
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief App to set the ISDN Transfer Capability
00022  *
00023  * \author Frank Sautter - asterisk+at+sautter+dot+com 
00024  * 
00025  * \ingroup applications
00026  */
00027  
00028 #include "asterisk.h"
00029 
00030 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 58939 $")
00031 
00032 #include <string.h>
00033 #include <stdlib.h>
00034 
00035 #include "asterisk/logger.h"
00036 #include "asterisk/channel.h"
00037 #include "asterisk/pbx.h"
00038 #include "asterisk/module.h"
00039 #include "asterisk/options.h"
00040 #include "asterisk/transcap.h"
00041 
00042 
00043 static char *app = "SetTransferCapability";
00044 
00045 static char *synopsis = "Set ISDN Transfer Capability";
00046 
00047 
00048 static struct {   int val; char *name; } transcaps[] = {
00049    { AST_TRANS_CAP_SPEECH,          "SPEECH" },
00050    { AST_TRANS_CAP_DIGITAL,         "DIGITAL" },
00051    { AST_TRANS_CAP_RESTRICTED_DIGITAL, "RESTRICTED_DIGITAL" },
00052    { AST_TRANS_CAP_3_1K_AUDIO,         "3K1AUDIO" },
00053    { AST_TRANS_CAP_DIGITAL_W_TONES, "DIGITAL_W_TONES" },
00054    { AST_TRANS_CAP_VIDEO,           "VIDEO" },
00055 };
00056 
00057 static char *descrip = 
00058 "  SetTransferCapability(transfercapability): Set the ISDN Transfer \n"
00059 "Capability of a call to a new value.\n"
00060 "Valid Transfer Capabilities are:\n"
00061 "\n"
00062 "  SPEECH             : 0x00 - Speech (default, voice calls)\n"
00063 "  DIGITAL            : 0x08 - Unrestricted digital information (data calls)\n"
00064 "  RESTRICTED_DIGITAL : 0x09 - Restricted digital information\n"
00065 "  3K1AUDIO           : 0x10 - 3.1kHz Audio (fax calls)\n"
00066 "  DIGITAL_W_TONES    : 0x11 - Unrestricted digital information with tones/announcements\n"
00067 "  VIDEO              : 0x18 - Video\n"
00068 "\n"
00069 "This application is deprecated in favor of Set(CHANNEL(transfercapability)=...)\n"
00070 ;
00071 
00072 static int settransfercapability_exec(struct ast_channel *chan, void *data)
00073 {
00074    char *tmp = NULL;
00075    struct ast_module_user *u;
00076    int x;
00077    char *opts;
00078    int transfercapability = -1;
00079    static int dep_warning = 0;
00080    
00081    u = ast_module_user_add(chan);
00082 
00083    if (!dep_warning) {
00084       dep_warning = 1;
00085       ast_log(LOG_WARNING, "SetTransferCapability is deprecated.  Please use CHANNEL(transfercapability) instead.\n");
00086    }
00087 
00088    if (data)
00089       tmp = ast_strdupa(data);
00090    else
00091       tmp = "";
00092 
00093    opts = strchr(tmp, '|');
00094    if (opts)
00095       *opts = '\0';
00096    
00097    for (x = 0; x < (sizeof(transcaps) / sizeof(transcaps[0])); x++) {
00098       if (!strcasecmp(transcaps[x].name, tmp)) {
00099          transfercapability = transcaps[x].val;
00100          break;
00101       }
00102    }
00103    if (transfercapability < 0) {
00104       ast_log(LOG_WARNING, "'%s' is not a valid transfer capability (see 'show application SetTransferCapability')\n", tmp);
00105       ast_module_user_remove(u);
00106       return 0;
00107    }
00108       
00109    chan->transfercapability = (unsigned short)transfercapability;
00110    
00111    if (option_verbose > 2)
00112       ast_verbose(VERBOSE_PREFIX_3 "Setting transfer capability to: 0x%.2x - %s.\n", transfercapability, tmp);       
00113    
00114    ast_module_user_remove(u);
00115 
00116    return 0;
00117 }
00118 
00119 
00120 static int unload_module(void)
00121 {
00122    int res;
00123    
00124    res = ast_unregister_application(app);
00125 
00126    ast_module_user_hangup_all();
00127 
00128    return res; 
00129 }
00130 
00131 static int load_module(void)
00132 {
00133    return ast_register_application(app, settransfercapability_exec, synopsis, descrip);
00134 }
00135 
00136 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Set ISDN Transfer Capability");

Generated on Sat Aug 6 00:39:21 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7