app_settransfercapability.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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");