- mark some applications deprecated that already have replacements
[asterisk/asterisk.git] / apps / app_settransfercapability.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2005, Frank Sautter, levigo holding gmbh, www.levigo.de
5  *
6  * Frank Sautter - asterisk+at+sautter+dot+com 
7  *
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.
13  *
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.
17  */
18
19 /*! \file
20  *
21  * \brief App to set the ISDN Transfer Capability
22  *
23  * \author Frank Sautter - asterisk+at+sautter+dot+com 
24  * 
25  * \ingroup applications
26  */
27  
28 #include <string.h>
29 #include <stdlib.h>
30
31 #include "asterisk.h"
32
33 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
34
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"
41
42
43 static char *app = "SetTransferCapability";
44
45 static char *synopsis = "Set ISDN Transfer Capability";
46
47 LOCAL_USER_DECL;
48
49 static struct { int val; char *name; } transcaps[] = {
50         { AST_TRANS_CAP_SPEECH,                         "SPEECH" },
51         { AST_TRANS_CAP_DIGITAL,                        "DIGITAL" },
52         { AST_TRANS_CAP_RESTRICTED_DIGITAL,     "RESTRICTED_DIGITAL" },
53         { AST_TRANS_CAP_3_1K_AUDIO,                     "3K1AUDIO" },
54         { AST_TRANS_CAP_DIGITAL_W_TONES,        "DIGITAL_W_TONES" },
55         { AST_TRANS_CAP_VIDEO,                          "VIDEO" },
56 };
57
58 static char *descrip = 
59 "  SetTransferCapability(transfercapability): Set the ISDN Transfer \n"
60 "Capability of a call to a new value.\n"
61 "Valid Transfer Capabilities are:\n"
62 "\n"
63 "  SPEECH             : 0x00 - Speech (default, voice calls)\n"
64 "  DIGITAL            : 0x08 - Unrestricted digital information (data calls)\n"
65 "  RESTRICTED_DIGITAL : 0x09 - Restricted digital information\n"
66 "  3K1AUDIO           : 0x10 - 3.1kHz Audio (fax calls)\n"
67 "  DIGITAL_W_TONES    : 0x11 - Unrestricted digital information with tones/announcements\n"
68 "  VIDEO              : 0x18 - Video\n"
69 "\n"
70 ;
71
72 static int settransfercapability_exec(struct ast_channel *chan, void *data)
73 {
74         char *tmp = NULL;
75         struct localuser *u;
76         int x;
77         char *opts;
78         int transfercapability = -1;
79         static int dep_warning = 0;
80         
81         LOCAL_USER_ADD(u);
82
83         if (!dep_warning) {
84                 dep_warning = 1;
85                 ast_log(LOG_WARNING, "SetTransferCapability is deprecated.  Please use CHANNEL(transfercapability) instead.\n");
86         }
87
88         if (data)
89                 tmp = ast_strdupa(data);
90         else
91                 tmp = "";
92
93         opts = strchr(tmp, '|');
94         if (opts)
95                 *opts = '\0';
96         
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;
101                 }
102         }
103         if (transfercapability < 0) {
104                 ast_log(LOG_WARNING, "'%s' is not a valid transfer capability (see 'show application SetTransferCapability')\n", tmp);
105                 LOCAL_USER_REMOVE(u);
106                 return 0;
107         }
108                 
109         chan->transfercapability = (unsigned short)transfercapability;
110         
111         if (option_verbose > 2)
112                 ast_verbose(VERBOSE_PREFIX_3 "Setting transfer capability to: 0x%.2x - %s.\n", transfercapability, tmp);                        
113         
114         LOCAL_USER_REMOVE(u);
115
116         return 0;
117 }
118
119
120 static int unload_module(void *mod)
121 {
122         int res;
123         
124         res = ast_unregister_application(app);
125
126         STANDARD_HANGUP_LOCALUSERS;
127
128         return res;     
129 }
130
131 static int load_module(void *mod)
132 {
133         return ast_register_application(app, settransfercapability_exec, synopsis, descrip);
134 }
135
136 static const char *description(void)
137 {
138         return synopsis;
139 }
140
141 static const char *key(void)
142 {
143         return ASTERISK_GPL_KEY;
144 }
145
146 STD_MOD1;