Sat Jul 26 06:13:29 2008

Asterisk developer's documentation


app_getcpeid.c File Reference

Get ADSI CPE ID. More...

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/adsi.h"
#include "asterisk/options.h"

Include dependency graph for app_getcpeid.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Get ADSI CPE ID")
static int cpeid_exec (struct ast_channel *chan, void *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 char * app = "GetCPEID"
static char * descrip
static char * synopsis = "Get ADSI CPE ID"


Detailed Description

Get ADSI CPE ID.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_getcpeid.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Get ADSI CPE ID"   
)

static int cpeid_exec ( struct ast_channel chan,
void *  idata 
) [static]

Definition at line 66 of file app_getcpeid.c.

References ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_load_session(), ast_adsi_unload_session(), ast_module_user_add, ast_module_user_remove, ast_verbose(), ast_waitfordigit(), ast_module_user::chan, cpeid_setstatus(), option_verbose, and VERBOSE_PREFIX_3.

Referenced by load_module().

00067 {
00068    int res=0;
00069    struct ast_module_user *u;
00070    unsigned char cpeid[4];
00071    int gotgeometry = 0;
00072    int gotcpeid = 0;
00073    int width, height, buttons;
00074    char *data[4];
00075    unsigned int x;
00076 
00077    u = ast_module_user_add(chan);
00078 
00079    for (x = 0; x < 4; x++)
00080       data[x] = alloca(80);
00081 
00082    strcpy(data[0], "** CPE Info **");
00083    strcpy(data[1], "Identifying CPE...");
00084    strcpy(data[2], "Please wait...");
00085    res = ast_adsi_load_session(chan, NULL, 0, 1);
00086    if (res > 0) {
00087       cpeid_setstatus(chan, data, 0);
00088       res = ast_adsi_get_cpeid(chan, cpeid, 0);
00089       if (res > 0) {
00090          gotcpeid = 1;
00091          if (option_verbose > 2)
00092             ast_verbose(VERBOSE_PREFIX_3 "Got CPEID of '%02x:%02x:%02x:%02x' on '%s'\n", cpeid[0], cpeid[1], cpeid[2], cpeid[3], chan->name);
00093       }
00094       if (res > -1) {
00095          strcpy(data[1], "Measuring CPE...");
00096          strcpy(data[2], "Please wait...");
00097          cpeid_setstatus(chan, data, 0);
00098          res = ast_adsi_get_cpeinfo(chan, &width, &height, &buttons, 0);
00099          if (res > -1) {
00100             if (option_verbose > 2)
00101                ast_verbose(VERBOSE_PREFIX_3 "CPE has %d lines, %d columns, and %d buttons on '%s'\n", height, width, buttons, chan->name);
00102             gotgeometry = 1;
00103          }
00104       }
00105       if (res > -1) {
00106          if (gotcpeid)
00107             snprintf(data[1], 80, "CPEID: %02x:%02x:%02x:%02x", cpeid[0], cpeid[1], cpeid[2], cpeid[3]);
00108          else
00109             strcpy(data[1], "CPEID Unknown");
00110          if (gotgeometry) 
00111             snprintf(data[2], 80, "Geom: %dx%d, %d buttons", width, height, buttons);
00112          else
00113             strcpy(data[2], "Geometry unknown");
00114          strcpy(data[3], "Press # to exit");
00115          cpeid_setstatus(chan, data, 1);
00116          for(;;) {
00117             res = ast_waitfordigit(chan, 1000);
00118             if (res < 0)
00119                break;
00120             if (res == '#') {
00121                res = 0;
00122                break;
00123             }
00124          }
00125          ast_adsi_unload_session(chan);
00126       }
00127    }
00128    ast_module_user_remove(u);
00129    return res;
00130 }

static int cpeid_setstatus ( struct ast_channel chan,
char *  stuff[],
int  voice 
) [static]

Definition at line 55 of file app_getcpeid.c.

References ADSI_JUST_CENT, ADSI_JUST_LEFT, ast_adsi_print(), and justify.

Referenced by cpeid_exec().

00056 {
00057    int justify[5] = { ADSI_JUST_CENT, ADSI_JUST_LEFT, ADSI_JUST_LEFT, ADSI_JUST_LEFT };
00058    char *tmp[5];
00059    int x;
00060    for (x=0;x<4;x++)
00061       tmp[x] = stuff[x];
00062    tmp[4] = NULL;
00063    return ast_adsi_print(chan, tmp, justify, voice);
00064 }

static int load_module ( void   )  [static]

Definition at line 143 of file app_getcpeid.c.

References ast_register_application(), and cpeid_exec().

00144 {
00145    return ast_register_application(app, cpeid_exec, synopsis, descrip);
00146 }

static int unload_module ( void   )  [static]

Definition at line 132 of file app_getcpeid.c.

References ast_module_user_hangup_all, and ast_unregister_application().

00133 {
00134    int res;
00135 
00136    res = ast_unregister_application(app);
00137 
00138    ast_module_user_hangup_all();
00139 
00140    return res; 
00141 }


Variable Documentation

char* app = "GetCPEID" [static]

Definition at line 46 of file app_getcpeid.c.

char* descrip [static]

Initial value:

"  GetCPEID: Obtains and displays ADSI CPE ID and other information in order\n"
"to properly setup zapata.conf for on-hook operations.\n"

Definition at line 50 of file app_getcpeid.c.

char* synopsis = "Get ADSI CPE ID" [static]

Definition at line 48 of file app_getcpeid.c.


Generated on Sat Jul 26 06:13:29 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.1