Index: channels/chan_zap.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v retrieving revision 1.173 diff -u -r1.173 chan_zap.c --- channels/chan_zap.c 10 Feb 2004 07:24:15 -0000 1.173 +++ channels/chan_zap.c 16 Feb 2004 17:09:29 -0000 @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,11 @@ XXX */ +/* Define USERDEFINEDCADENCE if you would like the ability to define your own + * ring cadences in zapata.conf + */ + +/* #define USERDEFINEDCADENCE */ /* * Define ZHONE_HACK to cause us to go off hook and then back on hook when @@ -518,7 +539,15 @@ } #endif +#ifdef USERDEFINEDCADENCE +#define NUM_CADENCE_MAX 25 +static int num_cadence = 4; +static int user_has_defined_cadences = 0; + +static struct zt_ring_cadence cadences[NUM_CADENCE_MAX] = { +#else static struct zt_ring_cadence cadences[] = { +#endif { { 125, 125, 2000, 4000 } }, /* Quick chirp followed by normal ring */ { { 250, 250, 500, 1000, 250, 250, 500, 4000 } }, /* British style ring */ { { 125, 125, 125, 125, 125, 4000 } }, /* Three short bursts */ @@ -527,15 +556,24 @@ int receivedRingT; /* Used to find out what ringtone we are on */ +/* cidrings says in which pause to transmit the cid information, where the first pause + * is 1, the second pause is 2 and so on. + */ +#ifdef USERDEFINEDCADENCE +static int cidrings[NUM_CADENCE_MAX] = { +#else static int cidrings[] = { +#endif 2, /* Right after first long ring */ 4, /* Right after long part */ 3, /* After third chirp */ 2, /* Second spell */ }; +#ifndef USERDEFINEDCADENCE #define NUM_CADENCE (sizeof(cadences) / sizeof(cadences[0])) +#endif #define ISTRUNK(p) ((p->sig == SIG_FXSLS) || (p->sig == SIG_FXSKS) || \ (p->sig == SIG_FXSGS) || (p->sig == SIG_PRI)) @@ -1400,7 +1438,11 @@ ast_log(LOG_WARNING, "Unable to generate CallerID spill\n"); } /* Select proper cadence */ +#ifdef USERDEFINEDCADENCE + if ((p->distinctivering > 0) && (p->distinctivering <= num_cadence)) { +#else if ((p->distinctivering > 0) && (p->distinctivering <= NUM_CADENCE)) { +#endif if (ioctl(p->subs[SUB_REAL].zfd, ZT_SETCADENCE, &cadences[p->distinctivering-1])) ast_log(LOG_WARNING, "Unable to set distinctive ring cadence %d on '%s'\n", p->distinctivering, ast->name); p->cidrings = cidrings[p->distinctivering - 1]; @@ -7032,6 +7076,43 @@ return RESULT_FAILURE; } +#ifdef USERDEFINEDCADENCE +static char zap_show_cadences_help[] = +"Usage: zap show cadences\n" +" Shows all cadences currently defined\n"; + +static int handle_zap_show_cadences(int fd, int argc, char *argv[]) +{ + int i, j; + for (i=0;iname, "overlapdial")) { overlapdial = ast_true(v->value); #endif +#ifdef USERDEFINEDCADENCE + } else if (!strcasecmp(v->name, "cadence")) { + /* setup to scan our argument */ + int element_count, c[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + int i; + struct zt_ring_cadence new_cadence; + int cid_location = -1; + char original_args[80]; + int cadence_is_ok = 1; + + strncpy(original_args, v->value, sizeof(original_args)); + /* 16 cadences allowed (8 pairs) */ + element_count = sscanf(v->value, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &c[0], &c[1], &c[2], &c[3], &c[4], &c[5], &c[6], &c[7], &c[8], &c[9], &c[10], &c[11], &c[12], &c[13], &c[14], &c[15]); + + /* Cadence must be even (on/off) */ + if (element_count % 2 == 1) { + ast_log(LOG_ERROR, "Must be a silence duration for each ring duration: %s\n",original_args); + cadence_is_ok = 0; + } + + /* Ring cadences cannot be negative */ + for (i=0;i= NUM_CADENCE_MAX) + ast_log(LOG_ERROR, "Already %d cadences; can't add another: %s\n", NUM_CADENCE_MAX, original_args); + else { + cadences[num_cadence] = new_cadence; + cidrings[num_cadence++] = cid_location; + if (option_verbose > 2) + ast_verbose(VERBOSE_PREFIX_3 "cadence 'r%d' added: %s\n",num_cadence,original_args); + } + } + } +#endif } else ast_log(LOG_WARNING, "Ignoring %s\n", v->name); v = v->next; @@ -7675,6 +7834,10 @@ ast_cli_register(&cli_show_channels); ast_cli_register(&cli_show_channel); ast_cli_register(&cli_destroy_channel); +#ifdef USERDEFINEDCADENCE + ast_cli_register(&zap_show_cadences_cli); +#endif + ast_register_application(app_callingpres, change_callingpres, synopsis_callingpres, descrip_callingpres); memset(round_robin, 0, sizeof(round_robin)); ast_manager_register( "ZapTransfer", 0, action_transfer, "Transfer Zap Channel" ); Index: configs/zapata.conf.sample =================================================================== RCS file: /usr/cvsroot/asterisk/configs/zapata.conf.sample,v retrieving revision 1.16 diff -u -r1.16 zapata.conf.sample --- configs/zapata.conf.sample 19 Jan 2004 02:32:24 -0000 1.16 +++ configs/zapata.conf.sample 16 Feb 2004 17:09:30 -0000 @@ -259,6 +259,20 @@ ; ;jitterbuffers=4 ; +; You can define your own custom ring cadences if you define USERDEFINEDCADENCE +; in chan_zap.c and recompile. You can define up to 8 pairs. If the silence +; is negative, it indicates where the callerid spill is to be placed. Also, if +; you define any custom cadences, the default cadences will be turned off. +; +; Syntax is: cadence=ring,silence[,ring,silence[...]] +; +; These are the default cadences: +; +;cadence=125,125,2000,-4000 +;cadence=250,250,500,1000,250,250,500,-4000 +;cadence=125,125,125,125,125,-4000 +;cadence=1000,500,2500,-5000 +; ; Each channel consists of the channel number or range. It ; inherits the parameters that were specified above its declaration ;