Mon Mar 12 2012 21:23:30

Asterisk developer's documentation


app_getcpeid.c File Reference

Get ADSI CPE ID. More...

#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"
Include dependency graph for app_getcpeid.c:

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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .nonoptreq = "res_adsi", }
static char * app = "GetCPEID"
static struct ast_module_infoast_module_info = &__mod_info

Detailed Description

Get ADSI CPE ID.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_getcpeid.c.


Function Documentation

static void __reg_module ( void  ) [static]

Definition at line 143 of file app_getcpeid.c.

static void __unreg_module ( void  ) [static]

Definition at line 143 of file app_getcpeid.c.

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

Definition at line 68 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().

{
   int res=0;
   unsigned char cpeid[4];
   int gotgeometry = 0;
   int gotcpeid = 0;
   int width, height, buttons;
   char *data[4];
   unsigned int x;

   for (x = 0; x < 4; x++)
      data[x] = alloca(80);

   strcpy(data[0], "** CPE Info **");
   strcpy(data[1], "Identifying CPE...");
   strcpy(data[2], "Please wait...");
   res = ast_adsi_load_session(chan, NULL, 0, 1);
   if (res > 0) {
      cpeid_setstatus(chan, data, 0);
      res = ast_adsi_get_cpeid(chan, cpeid, 0);
      if (res > 0) {
         gotcpeid = 1;
         ast_verb(3, "Got CPEID of '%02x:%02x:%02x:%02x' on '%s'\n", cpeid[0], cpeid[1], cpeid[2], cpeid[3], chan->name);
      }
      if (res > -1) {
         strcpy(data[1], "Measuring CPE...");
         strcpy(data[2], "Please wait...");
         cpeid_setstatus(chan, data, 0);
         res = ast_adsi_get_cpeinfo(chan, &width, &height, &buttons, 0);
         if (res > -1) {
            ast_verb(3, "CPE has %d lines, %d columns, and %d buttons on '%s'\n", height, width, buttons, chan->name);
            gotgeometry = 1;
         }
      }
      if (res > -1) {
         if (gotcpeid)
            snprintf(data[1], 80, "CPEID: %02x:%02x:%02x:%02x", cpeid[0], cpeid[1], cpeid[2], cpeid[3]);
         else
            strcpy(data[1], "CPEID Unknown");
         if (gotgeometry) 
            snprintf(data[2], 80, "Geom: %dx%d, %d buttons", width, height, buttons);
         else
            strcpy(data[2], "Geometry unknown");
         strcpy(data[3], "Press # to exit");
         cpeid_setstatus(chan, data, 1);
         for(;;) {
            res = ast_waitfordigit(chan, 1000);
            if (res < 0)
               break;
            if (res == '#') {
               res = 0;
               break;
            }
         }
         ast_adsi_unload_session(chan);
      }
   }

   return res;
}
static int cpeid_setstatus ( struct ast_channel chan,
char *  stuff[],
int  voice 
) [static]

Definition at line 57 of file app_getcpeid.c.

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

Referenced by cpeid_exec().

{
   int justify[5] = { ADSI_JUST_CENT, ADSI_JUST_LEFT, ADSI_JUST_LEFT, ADSI_JUST_LEFT };
   char *tmp[5];
   int x;
   for (x=0;x<4;x++)
      tmp[x] = stuff[x];
   tmp[4] = NULL;
   return ast_adsi_print(chan, tmp, justify, voice);
}
static int load_module ( void  ) [static]

Definition at line 134 of file app_getcpeid.c.

References ast_register_application_xml, and cpeid_exec().

static int unload_module ( void  ) [static]

Definition at line 129 of file app_getcpeid.c.

References ast_unregister_application().


Variable Documentation

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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .nonoptreq = "res_adsi", } [static]

Definition at line 143 of file app_getcpeid.c.

char* app = "GetCPEID" [static]

Definition at line 55 of file app_getcpeid.c.

Definition at line 143 of file app_getcpeid.c.