(closes issue #12846)
[asterisk-bristuff.git] / apps / app_settransfercapability.c
blobe29b44e2277f818b6681bd1ea9cb28704e91f58b
1 /*
2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 2005, Frank Sautter, levigo holding gmbh, www.levigo.de
6 * Frank Sautter - asterisk+at+sautter+dot+com
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
19 /*! \file
21 * \brief App to set the ISDN Transfer Capability
23 * \author Frank Sautter - asterisk+at+sautter+dot+com
25 * \ingroup applications
28 #include "asterisk.h"
30 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
32 #include <string.h>
33 #include <stdlib.h>
35 #include "asterisk/logger.h"
36 #include "asterisk/channel.h"
37 #include "asterisk/pbx.h"
38 #include "asterisk/module.h"
39 #include "asterisk/options.h"
40 #include "asterisk/transcap.h"
43 static char *app = "SetTransferCapability";
45 static char *synopsis = "Set ISDN Transfer Capability";
48 static struct { int val; char *name; } transcaps[] = {
49 { AST_TRANS_CAP_SPEECH, "SPEECH" },
50 { AST_TRANS_CAP_DIGITAL, "DIGITAL" },
51 { AST_TRANS_CAP_RESTRICTED_DIGITAL, "RESTRICTED_DIGITAL" },
52 { AST_TRANS_CAP_3_1K_AUDIO, "3K1AUDIO" },
53 { AST_TRANS_CAP_DIGITAL_W_TONES, "DIGITAL_W_TONES" },
54 { AST_TRANS_CAP_VIDEO, "VIDEO" },
57 static char *descrip =
58 " SetTransferCapability(transfercapability): Set the ISDN Transfer \n"
59 "Capability of a call to a new value.\n"
60 "Valid Transfer Capabilities are:\n"
61 "\n"
62 " SPEECH : 0x00 - Speech (default, voice calls)\n"
63 " DIGITAL : 0x08 - Unrestricted digital information (data calls)\n"
64 " RESTRICTED_DIGITAL : 0x09 - Restricted digital information\n"
65 " 3K1AUDIO : 0x10 - 3.1kHz Audio (fax calls)\n"
66 " DIGITAL_W_TONES : 0x11 - Unrestricted digital information with tones/announcements\n"
67 " VIDEO : 0x18 - Video\n"
68 "\n"
69 "This application is deprecated in favor of Set(CHANNEL(transfercapability)=...)\n"
72 static int settransfercapability_exec(struct ast_channel *chan, void *data)
74 char *tmp = NULL;
75 struct ast_module_user *u;
76 int x;
77 char *opts;
78 int transfercapability = -1;
79 static int dep_warning = 0;
81 u = ast_module_user_add(chan);
83 if (!dep_warning) {
84 dep_warning = 1;
85 ast_log(LOG_WARNING, "SetTransferCapability is deprecated. Please use CHANNEL(transfercapability) instead.\n");
88 if (data)
89 tmp = ast_strdupa(data);
90 else
91 tmp = "";
93 opts = strchr(tmp, '|');
94 if (opts)
95 *opts = '\0';
97 for (x = 0; x < (sizeof(transcaps) / sizeof(transcaps[0])); x++) {
98 if (!strcasecmp(transcaps[x].name, tmp)) {
99 transfercapability = transcaps[x].val;
100 break;
103 if (transfercapability < 0) {
104 ast_log(LOG_WARNING, "'%s' is not a valid transfer capability (see 'show application SetTransferCapability')\n", tmp);
105 ast_module_user_remove(u);
106 return 0;
109 chan->transfercapability = (unsigned short)transfercapability;
111 if (option_verbose > 2)
112 ast_verbose(VERBOSE_PREFIX_3 "Setting transfer capability to: 0x%.2x - %s.\n", transfercapability, tmp);
114 ast_module_user_remove(u);
116 return 0;
120 static int unload_module(void)
122 int res;
124 res = ast_unregister_application(app);
126 ast_module_user_hangup_all();
128 return res;
131 static int load_module(void)
133 return ast_register_application(app, settransfercapability_exec, synopsis, descrip);
136 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Set ISDN Transfer Capability");