mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-29 18:19:30 +00:00
Add smdi support for asterisk (see doc/smdi.txt for config info) (#5945)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -73,6 +73,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
#include "asterisk/cli.h"
|
||||
#include "asterisk/utils.h"
|
||||
#include "asterisk/stringfields.h"
|
||||
#ifdef WITH_SMDI
|
||||
#include "asterisk/smdi.h"
|
||||
#define SMDI_MWI_WAIT_TIMEOUT 1000 /* 1 second */
|
||||
#endif
|
||||
#ifdef USE_ODBC_STORAGE
|
||||
#include "asterisk/res_odbc.h"
|
||||
#endif
|
||||
@@ -393,7 +397,9 @@ static int silencethreshold = 128;
|
||||
static char serveremail[80];
|
||||
static char mailcmd[160]; /* Configurable mail cmd */
|
||||
static char externnotify[160];
|
||||
|
||||
#ifdef WITH_SMDI
|
||||
static struct ast_smdi_interface *smdi_iface = NULL;
|
||||
#endif
|
||||
static char vmfmts[80];
|
||||
static int vmminmessage;
|
||||
static int vmmaxmessage;
|
||||
@@ -2318,13 +2324,39 @@ static void run_externnotify(char *context, char *extension)
|
||||
char arguments[255];
|
||||
char ext_context[256] = "";
|
||||
int newvoicemails = 0, oldvoicemails = 0;
|
||||
#ifdef WITH_SMDI
|
||||
struct ast_smdi_mwi_message *mwi_msg;
|
||||
#endif
|
||||
|
||||
if (!ast_strlen_zero(context))
|
||||
snprintf(ext_context, sizeof(ext_context), "%s@%s", extension, context);
|
||||
else
|
||||
ast_copy_string(ext_context, extension, sizeof(ext_context));
|
||||
|
||||
#ifdef WITH_SMDI
|
||||
if (!strcasecmp(externnotify, "smdi")) {
|
||||
|
||||
if (ast_app_has_voicemail(ext_context, NULL))
|
||||
ast_smdi_mwi_set(smdi_iface, extension);
|
||||
else
|
||||
ast_smdi_mwi_unset(smdi_iface, extension);
|
||||
|
||||
mwi_msg = ast_smdi_mwi_message_wait(smdi_iface, SMDI_MWI_WAIT_TIMEOUT);
|
||||
if (mwi_msg) {
|
||||
ast_log(LOG_ERROR, "Error executing SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
|
||||
if (!strncmp(mwi_msg->cause, "INV", 3))
|
||||
ast_log(LOG_ERROR, "Invalid MWI extension: %s\n", mwi_msg->fwd_st);
|
||||
else if (!strncmp(mwi_msg->cause, "BLK", 3))
|
||||
ast_log(LOG_WARNING, "MWI light was already on or off for %s\n", mwi_msg->fwd_st);
|
||||
ast_log(LOG_WARNING, "The switch reported '%s'\n", mwi_msg->cause);
|
||||
ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);
|
||||
} else {
|
||||
ast_log(LOG_DEBUG, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
|
||||
}
|
||||
} else if (!ast_strlen_zero(externnotify)) {
|
||||
#else
|
||||
if (!ast_strlen_zero(externnotify)) {
|
||||
#endif
|
||||
if (messagecount(ext_context, &newvoicemails, &oldvoicemails)) {
|
||||
ast_log(LOG_ERROR, "Problem in calculating number of voicemail messages available for extension %s\n", extension);
|
||||
} else {
|
||||
@@ -5842,6 +5874,9 @@ static int load_config(void)
|
||||
char *cat;
|
||||
struct ast_variable *var;
|
||||
char *notifystr = NULL;
|
||||
#ifdef WITH_SMDI
|
||||
char *smdistr = NULL;
|
||||
#endif
|
||||
char *astattach;
|
||||
char *astsearch;
|
||||
char *astsaycid;
|
||||
@@ -5951,6 +5986,25 @@ static int load_config(void)
|
||||
if ((notifystr = ast_variable_retrieve(cfg, "general", "externnotify"))) {
|
||||
ast_copy_string(externnotify, notifystr, sizeof(externnotify));
|
||||
ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify);
|
||||
#ifdef WITH_SMDI
|
||||
if(!strcasecmp(externnotify, "smdi")) {
|
||||
ast_log(LOG_DEBUG, "Using SMDI for external voicemail notification\n");
|
||||
|
||||
if ((smdistr = ast_variable_retrieve(cfg, "general", "smdiport"))) {
|
||||
smdi_iface = ast_smdi_interface_find(smdistr);
|
||||
} else {
|
||||
ast_log(LOG_DEBUG, "No SMDI interface set, trying default (/dev/ttyS0)\n");
|
||||
smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
|
||||
}
|
||||
|
||||
if(!smdi_iface) {
|
||||
ast_log(LOG_ERROR, "No valid SMDI interface specfied, disabling external voicemail notification\n");
|
||||
externnotify[0] = '\0';
|
||||
} else {
|
||||
ast_log(LOG_DEBUG, "Using SMDI port %s\n", smdi_iface->name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
externnotify[0] = '\0';
|
||||
}
|
||||
|
Reference in New Issue
Block a user