aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authormattf <mattf@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-10 21:50:56 +0000
committermattf <mattf@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-10 21:50:56 +0000
commit8ebf7821feb084b6a457341922946d497702cc2d (patch)
tree843a4329f47fdc289431a20d6c4d7a860b8271ae /apps
parente04e114ef1d44809af33eb916be88c1f137b03b8 (diff)
Add smdi support for asterisk (see doc/smdi.txt for config info) (#5945)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@9423 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/Makefile5
-rw-r--r--apps/app_voicemail.c56
2 files changed, 60 insertions, 1 deletions
diff --git a/apps/Makefile b/apps/Makefile
index 554efa71f..b3fb93071 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -59,7 +59,12 @@ CFLAGS+=-fPIC
APPS+=app_sms.so
endif
+# Asterisk SMDI integration
#
+ifeq (${WITH_SMDI},1)
+CFLAGS+=-DWITH_SMDI
+endif
+
# If you have UnixODBC you can use ODBC voicemail
# storage
#
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index eee1d3ddb..cb6d9e876 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -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';
}