#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/adsi.h"
Go to the source code of this file.
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | cpeid_exec (struct ast_channel *chan, const char *idata) |
static int | cpeid_setstatus (struct ast_channel *chan, char *stuff[], int voice) |
static int | load_module (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Get ADSI CPE ID" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .nonoptreq = "res_adsi", } |
static char * | app = "GetCPEID" |
static struct ast_module_info * | ast_module_info = &__mod_info |
Definition in file app_getcpeid.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 139 of file app_getcpeid.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 139 of file app_getcpeid.c.
static int cpeid_exec | ( | struct ast_channel * | chan, | |
const char * | idata | |||
) | [static] |
Definition at line 64 of file app_getcpeid.c.
References ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_load_session(), ast_adsi_unload_session(), ast_verb, ast_waitfordigit(), cpeid_setstatus(), and ast_channel::name.
Referenced by load_module().
00065 { 00066 int res=0; 00067 unsigned char cpeid[4]; 00068 int gotgeometry = 0; 00069 int gotcpeid = 0; 00070 int width, height, buttons; 00071 char *data[4]; 00072 unsigned int x; 00073 00074 for (x = 0; x < 4; x++) 00075 data[x] = alloca(80); 00076 00077 strcpy(data[0], "** CPE Info **"); 00078 strcpy(data[1], "Identifying CPE..."); 00079 strcpy(data[2], "Please wait..."); 00080 res = ast_adsi_load_session(chan, NULL, 0, 1); 00081 if (res > 0) { 00082 cpeid_setstatus(chan, data, 0); 00083 res = ast_adsi_get_cpeid(chan, cpeid, 0); 00084 if (res > 0) { 00085 gotcpeid = 1; 00086 ast_verb(3, "Got CPEID of '%02x:%02x:%02x:%02x' on '%s'\n", cpeid[0], cpeid[1], cpeid[2], cpeid[3], chan->name); 00087 } 00088 if (res > -1) { 00089 strcpy(data[1], "Measuring CPE..."); 00090 strcpy(data[2], "Please wait..."); 00091 cpeid_setstatus(chan, data, 0); 00092 res = ast_adsi_get_cpeinfo(chan, &width, &height, &buttons, 0); 00093 if (res > -1) { 00094 ast_verb(3, "CPE has %d lines, %d columns, and %d buttons on '%s'\n", height, width, buttons, chan->name); 00095 gotgeometry = 1; 00096 } 00097 } 00098 if (res > -1) { 00099 if (gotcpeid) 00100 snprintf(data[1], 80, "CPEID: %02x:%02x:%02x:%02x", cpeid[0], cpeid[1], cpeid[2], cpeid[3]); 00101 else 00102 strcpy(data[1], "CPEID Unknown"); 00103 if (gotgeometry) 00104 snprintf(data[2], 80, "Geom: %dx%d, %d buttons", width, height, buttons); 00105 else 00106 strcpy(data[2], "Geometry unknown"); 00107 strcpy(data[3], "Press # to exit"); 00108 cpeid_setstatus(chan, data, 1); 00109 for(;;) { 00110 res = ast_waitfordigit(chan, 1000); 00111 if (res < 0) 00112 break; 00113 if (res == '#') { 00114 res = 0; 00115 break; 00116 } 00117 } 00118 ast_adsi_unload_session(chan); 00119 } 00120 } 00121 00122 return res; 00123 }
static int cpeid_setstatus | ( | struct ast_channel * | chan, | |
char * | stuff[], | |||
int | voice | |||
) | [static] |
Definition at line 53 of file app_getcpeid.c.
References ADSI_JUST_CENT, ADSI_JUST_LEFT, ast_adsi_print(), and justify.
Referenced by cpeid_exec().
00054 { 00055 int justify[5] = { ADSI_JUST_CENT, ADSI_JUST_LEFT, ADSI_JUST_LEFT, ADSI_JUST_LEFT }; 00056 char *tmp[5]; 00057 int x; 00058 for (x=0;x<4;x++) 00059 tmp[x] = stuff[x]; 00060 tmp[4] = NULL; 00061 return ast_adsi_print(chan, tmp, justify, voice); 00062 }
static int load_module | ( | void | ) | [static] |
Definition at line 130 of file app_getcpeid.c.
References ast_register_application_xml, and cpeid_exec().
00131 { 00132 return ast_register_application_xml(app, cpeid_exec); 00133 }
static int unload_module | ( | void | ) | [static] |
Definition at line 125 of file app_getcpeid.c.
References ast_unregister_application().
00126 { 00127 return ast_unregister_application(app); 00128 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Get ADSI CPE ID" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .nonoptreq = "res_adsi", } [static] |
Definition at line 139 of file app_getcpeid.c.
char* app = "GetCPEID" [static] |
Definition at line 51 of file app_getcpeid.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 139 of file app_getcpeid.c.