Thu May 24 14:21:06 2007

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  * \ingroup applications
00024  */
00025  
00026 #include <string.h>
00027 #include <stdlib.h>
00028 
00029 #include "asterisk.h"
00030 
00031 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 7221 $")
00032 
00033 #include "asterisk/logger.h"
00034 #include "asterisk/channel.h"
00035 #include "asterisk/pbx.h"
00036 #include "asterisk/module.h"
00037 #include "asterisk/options.h"
00038 #include "asterisk/transcap.h"
00039 
00040 
00041 static char *app = "SetTransferCapability";
00042 
00043 static char *synopsis = "Set ISDN Transfer Capability";
00044 
00045 STANDARD_LOCAL_USER;
00046 
00047 LOCAL_USER_DECL;
00048 
00049 static struct {   int val; char *name; } transcaps[] = {
00050    { AST_TRANS_CAP_SPEECH,          "SPEECH" },
00051    { AST_TRANS_CAP_DIGITAL,         "DIGITAL" },
00052    { AST_TRANS_CAP_RESTRICTED_DIGITAL, "RESTRICTED_DIGITAL" },
00053    { AST_TRANS_CAP_3_1K_AUDIO,         "3K1AUDIO" },
00054    { AST_TRANS_CAP_DIGITAL_W_TONES, "DIGITAL_W_TONES" },
00055    { AST_TRANS_CAP_VIDEO,           "VIDEO" },
00056 };
00057 
00058 static char *descrip = 
00059 "  SetTransferCapability(transfercapability): Set the ISDN Transfer \n"
00060 "Capability of a call to a new value.\n"
00061 "Valid Transfer Capabilities are:\n"
00062 "\n"
00063 "  SPEECH             : 0x00 - Speech (default, voice calls)\n"
00064 "  DIGITAL            : 0x08 - Unrestricted digital information (data calls)\n"
00065 "  RESTRICTED_DIGITAL : 0x09 - Restricted digital information\n"
00066 "  3K1AUDIO           : 0x10 - 3.1kHz Audio (fax calls)\n"
00067 "  DIGITAL_W_TONES    : 0x11 - Unrestricted digital information with tones/announcements\n"
00068 "  VIDEO              : 0x18 - Video:\n"
00069 "\n"
00070 ;
00071 
00072 static int settransfercapability_exec(struct ast_channel *chan, void *data)
00073 {
00074    char *tmp = NULL;
00075    struct localuser *u;
00076    int x;
00077    char *opts;
00078    int transfercapability = -1;
00079    
00080    LOCAL_USER_ADD(u);
00081    
00082    if (data)
00083       tmp = ast_strdupa(data);
00084    else
00085       tmp = "";
00086 
00087    opts = strchr(tmp, '|');
00088    if (opts)
00089       *opts = '\0';
00090    
00091    for (x = 0; x < (sizeof(transcaps) / sizeof(transcaps[0])); x++) {
00092       if (!strcasecmp(transcaps[x].name, tmp)) {
00093          transfercapability = transcaps[x].val;
00094          break;
00095       }
00096    }
00097    if (transfercapability < 0) {
00098       ast_log(LOG_WARNING, "'%s' is not a valid transfer capability (see 'show application SetTransferCapability')\n", tmp);
00099       LOCAL_USER_REMOVE(u);
00100       return 0;
00101    }
00102       
00103    chan->transfercapability = (unsigned short)transfercapability;
00104    
00105    if (option_verbose > 2)
00106       ast_verbose(VERBOSE_PREFIX_3 "Setting transfer capability to: 0x%.2x - %s.\n", transfercapability, tmp);       
00107    
00108    LOCAL_USER_REMOVE(u);
00109 
00110    return 0;
00111 }
00112 
00113 
00114 int unload_module(void)
00115 {
00116    int res;
00117    
00118    res = ast_unregister_application(app);
00119 
00120    STANDARD_HANGUP_LOCALUSERS;
00121 
00122    return res; 
00123 }
00124 
00125 int load_module(void)
00126 {
00127    return ast_register_application(app, settransfercapability_exec, synopsis, descrip);
00128 }
00129 
00130 char *description(void)
00131 {
00132    return synopsis;
00133 }
00134 
00135 int usecount(void)
00136 {
00137    int res;
00138    STANDARD_USECOUNT(res);
00139    return res;
00140 }
00141 
00142 char *key()
00143 {
00144    return ASTERISK_GPL_KEY;
00145 }

Generated on Thu May 24 14:21:06 2007 for Asterisk - the Open Source PBX by  doxygen 1.4.7