From 62fe88239be6ed2b1320ea3a6c45c9d432999cbd Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Wed, 28 Dec 2005 14:22:54 +0000 Subject: [PATCH] - added language support - prepared devicestate(hint) support --- capi.conf | 2 ++ chan_capi.c | 38 ++++++++++++++++++++++++++++++++++++-- chan_capi.h | 3 ++- create_config.sh | 8 ++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/capi.conf b/capi.conf index 8aa1716..7b9e97f 100644 --- a/capi.conf +++ b/capi.conf @@ -10,6 +10,7 @@ nationalprefix=0 internationalprefix=00 rxgain=0.8 txgain=0.8 +language=de ;set default language ;ulaw=yes ;set this, if you live in u-law world instead of a-law ; interface sections ... @@ -46,6 +47,7 @@ echocancelold=yes;use facility selector 6 instead of correct 8 (necessary for ol ;echotail=64 ;echo cancel tail setting ;bridge=yes ;native bridging (CAPI line interconnect) if available ;callgroup=1 ;Asterisk call group +;language=de ;set language for this device (overwrites default language) devices=2 ;number of concurrent calls on this controller ;(2 makes sense for single BRI, 30 for PRI) diff --git a/chan_capi.c b/chan_capi.c index e66d79e..a654d27 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -33,6 +33,9 @@ #include #include #include +#ifndef CC_AST_NO_DEVICESTATE +#include +#endif #include #include #include @@ -98,6 +101,8 @@ static struct ast_channel *chan_to_softhangup = NULL; static char capi_national_prefix[AST_MAX_EXTENSION]; static char capi_international_prefix[AST_MAX_EXTENSION]; +static char default_language[MAX_LANGUAGE] = ""; + static int capidebug = 0; /* local prototypes */ @@ -1557,6 +1562,7 @@ static struct ast_channel *capi_new(struct capi_pvt *i, int state) strncpy(tmp->exten, i->dnid, sizeof(tmp->exten) - 1); strncpy(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode) - 1); + strncpy(tmp->language, i->language, sizeof(tmp->language) - 1); i->owner = tmp; cc_mutex_lock(&usecnt_lock); usecnt++; @@ -3561,9 +3567,10 @@ static int capi_retrieve(struct ast_channel *c, char *param) if ((i->state != CAPI_STATE_ONHOLD) && (i->isdnstate & CAPI_ISDN_STATE_HOLD)) { - int waitcount = 200; + int waitcount = 20; while ((waitcount > 0) && (i->state != CAPI_STATE_ONHOLD)) { usleep(10000); + waitcount--; } } @@ -3738,7 +3745,7 @@ static int capi_hold(struct ast_channel *c, char *param) cc_verbose(2, 1, VERBOSE_PREFIX_4 "%s: sent HOLD for PLCI=%#x\n", i->name, i->PLCI); - i->onholdPLCI= i->PLCI; + i->onholdPLCI = i->PLCI; i->isdnstate |= CAPI_ISDN_STATE_HOLD; snprintf(buffer, sizeof(buffer) - 1, "%d", i->PLCI); @@ -4046,6 +4053,26 @@ static int capi_indicate(struct ast_channel *c, int condition) return(ret); } +#ifndef CC_AST_NO_DEVICESTATE +/* + * PBX wants to know the state for a specific device + */ +static int capi_devicestate(void *data) +{ + int res = AST_DEVICE_UNKNOWN; + + if (!data) { + cc_verbose(3, 1, VERBOSE_PREFIX_2 "No data for capi_devicestate\n"); + return res; + } + + cc_verbose(3, 1, VERBOSE_PREFIX_4 "CAPI devicestate requested for %s\n", + (char *)data); + + return res; +} +#endif + /* * module stuff, monitor... */ @@ -4423,6 +4450,9 @@ static const struct ast_channel_tech capi_tech = { .indicate = capi_indicate, .fixup = capi_fixup, .setoption = NULL, +#ifndef CC_AST_NO_DEVICESTATE + .devicestate = capi_devicestate, +#endif }; #endif @@ -4595,6 +4625,7 @@ static int conf_interface(struct cc_capi_conf *conf, struct ast_variable *v) CONF_STRING(conf->controllerstr, "controller"); CONF_STRING(conf->prefix, "prefix"); CONF_STRING(conf->accountcode, "accountcode"); + CONF_STRING(conf->language, "language"); if (!strcasecmp(v->name, "softdtmf")) { if ((!conf->softdtmf) && (ast_true(v->value))) { @@ -4716,6 +4747,8 @@ static int capi_eval_config(struct ast_config *cfg) strncpy(capi_national_prefix, v->value, sizeof(capi_national_prefix) - 1); } else if (!strcasecmp(v->name, "internationalprefix")) { strncpy(capi_international_prefix, v->value, sizeof(capi_international_prefix) - 1); + } else if (!strcasecmp(v->name, "language")) { + strncpy(default_language, v->value, sizeof(default_language) - 1); } else if (!strcasecmp(v->name, "rxgain")) { if (sscanf(v->value,"%f",&rxgain) != 1) { cc_log(LOG_ERROR,"invalid rxgain\n"); @@ -4751,6 +4784,7 @@ static int capi_eval_config(struct ast_config *cfg) conf.ectail = EC_DEFAULT_TAIL; conf.ecSelector = FACILITYSELECTOR_ECHO_CANCEL; strncpy(conf.name, cat, sizeof(conf.name) - 1); + strncpy(conf.language, default_language, sizeof(conf.language) - 1); if (conf_interface(&conf, ast_variable_browse(cfg, cat))) { cc_log(LOG_ERROR, "Error interface config.\n"); diff --git a/chan_capi.h b/chan_capi.h index 0d73c27..aba1af8 100644 --- a/chan_capi.h +++ b/chan_capi.h @@ -258,7 +258,7 @@ struct capi_pvt { unsigned int callgroup; unsigned int group; - /*! default language */ + /* language */ char language[MAX_LANGUAGE]; /* additional numbers to dial */ @@ -347,6 +347,7 @@ struct cc_capi_profile { struct cc_capi_conf { char name[CAPI_MAX_STRING]; + char language[MAX_LANGUAGE]; char incomingmsn[CAPI_MAX_STRING]; char defaultcid[CAPI_MAX_STRING]; char context[AST_MAX_EXTENSION]; diff --git a/create_config.sh b/create_config.sh index 5fd1d33..8c03686 100755 --- a/create_config.sh +++ b/create_config.sh @@ -122,6 +122,14 @@ else echo " * no 'struct ast_custom_function'" fi +if [ -f "$INCLUDEDIR/devicestate.h" ]; then + echo "#undef CC_AST_NO_DEVICESTATE" >>$CONFIGFILE + echo " * found 'devicestate.h'" +else + echo "#define CC_AST_NO_DEVICESTATE" >>$CONFIGFILE + echo " * no 'devicestate.h'" +fi + echo "" >>$CONFIGFILE echo "#endif /* CHAN_CAPI_CONFIG_H */" >>$CONFIGFILE echo "" >>$CONFIGFILE