[asterisk-commits] russell: branch russell/smdi-1.4 r93089 - in /team/russell/smdi-1.4: apps/ ch...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Dec 14 14:39:57 CST 2007
Author: russell
Date: Fri Dec 14 14:39:57 2007
New Revision: 93089
URL: http://svn.digium.com/view/asterisk?view=rev&rev=93089
Log:
check in progress ...
Modified:
team/russell/smdi-1.4/apps/app_voicemail.c
team/russell/smdi-1.4/channels/chan_zap.c
team/russell/smdi-1.4/include/asterisk/smdi.h
team/russell/smdi-1.4/res/res_smdi.c
Modified: team/russell/smdi-1.4/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/russell/smdi-1.4/apps/app_voicemail.c?view=diff&rev=93089&r1=93088&r2=93089
==============================================================================
--- team/russell/smdi-1.4/apps/app_voicemail.c (original)
+++ team/russell/smdi-1.4/apps/app_voicemail.c Fri Dec 14 14:39:57 2007
@@ -2749,7 +2749,7 @@
ast_smdi_mwi_unset(smdi_iface, extension);
if ((mwi_msg = ast_smdi_mwi_message_wait(smdi_iface, SMDI_MWI_WAIT_TIMEOUT))) {
- ast_log(LOG_ERROR, "Error executing SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
+ ast_log(LOG_ERROR, "Error executing SMDI MWI change for %s\n", extension);
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))
@@ -2758,7 +2758,7 @@
ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);
} else {
if (option_debug)
- ast_log(LOG_DEBUG, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
+ ast_log(LOG_DEBUG, "Successfully executed SMDI MWI change for %s\n", extension);
}
} else if (!ast_strlen_zero(externnotify)) {
if (inboxcount(ext_context, &newvoicemails, &oldvoicemails)) {
@@ -7460,9 +7460,6 @@
if (!smdi_iface) {
ast_log(LOG_ERROR, "No valid SMDI interface specfied, disabling external voicemail notification\n");
externnotify[0] = '\0';
- } else {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Using SMDI port %s\n", smdi_iface->name);
}
}
} else {
Modified: team/russell/smdi-1.4/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/russell/smdi-1.4/channels/chan_zap.c?view=diff&rev=93089&r1=93088&r2=93089
==============================================================================
--- team/russell/smdi-1.4/channels/chan_zap.c (original)
+++ team/russell/smdi-1.4/channels/chan_zap.c Fri Dec 14 14:39:57 2007
@@ -2218,7 +2218,7 @@
if (p->next)
p->next->prev = p->prev;
if (p->use_smdi)
- ASTOBJ_UNREF(p->smdi_iface, ast_smdi_interface_destroy);
+ ast_smdi_interface_unref(p->smdi_iface);
ast_mutex_destroy(&p->lock);
free(p);
*pvt = NULL;
Modified: team/russell/smdi-1.4/include/asterisk/smdi.h
URL: http://svn.digium.com/view/asterisk/team/russell/smdi-1.4/include/asterisk/smdi.h?view=diff&rev=93089&r1=93088&r2=93089
==============================================================================
--- team/russell/smdi-1.4/include/asterisk/smdi.h (original)
+++ team/russell/smdi-1.4/include/asterisk/smdi.h Fri Dec 14 14:39:57 2007
@@ -73,16 +73,6 @@
struct timeval timestamp; /* a timestamp for the message */
};
-/*! \brief SMDI message desk message queue. */
-struct ast_smdi_md_queue {
- ASTOBJ_CONTAINER_COMPONENTS(struct ast_smdi_md_message);
-};
-
-/*! \brief SMDI message waiting indicator message queue. */
-struct ast_smdi_mwi_queue {
- ASTOBJ_CONTAINER_COMPONENTS(struct ast_smdi_mwi_message);
-};
-
/*!
* \brief SMDI interface structure.
*
@@ -90,18 +80,9 @@
* should be monitored for SMDI activity. The structure contains a message
* queue of messages that have been recieved on the interface.
*/
-struct ast_smdi_interface {
- ASTOBJ_COMPONENTS_FULL(struct ast_smdi_interface, SMDI_MAX_FILENAME_LEN, 1);
- struct ast_smdi_md_queue md_q;
- struct ast_smdi_mwi_queue mwi_q;
- FILE *file;
- int fd;
- pthread_t thread;
- struct termios mode;
- int msdstrip;
- long msg_expiry;
-};
+struct ast_smdi_interface;
+void ast_smdi_interface_unref(struct ast_smdi_interface *iface);
/* MD message queue functions */
struct ast_smdi_md_message *ast_smdi_md_message_pop(struct ast_smdi_interface *iface);
Modified: team/russell/smdi-1.4/res/res_smdi.c
URL: http://svn.digium.com/view/asterisk/team/russell/smdi-1.4/res/res_smdi.c?view=diff&rev=93089&r1=93088&r2=93089
==============================================================================
--- team/russell/smdi-1.4/res/res_smdi.c (original)
+++ team/russell/smdi-1.4/res/res_smdi.c Fri Dec 14 14:39:57 2007
@@ -53,6 +53,28 @@
#define SMDI_MSG_EXPIRY_TIME 30000 /* 30 seconds */
static const char config_file[] = "smdi.conf";
+
+/*! \brief SMDI message desk message queue. */
+struct ast_smdi_md_queue {
+ ASTOBJ_CONTAINER_COMPONENTS(struct ast_smdi_md_message);
+};
+
+/*! \brief SMDI message waiting indicator message queue. */
+struct ast_smdi_mwi_queue {
+ ASTOBJ_CONTAINER_COMPONENTS(struct ast_smdi_mwi_message);
+};
+
+struct ast_smdi_interface {
+ ASTOBJ_COMPONENTS_FULL(struct ast_smdi_interface, SMDI_MAX_FILENAME_LEN, 1);
+ struct ast_smdi_md_queue md_q;
+ struct ast_smdi_mwi_queue mwi_q;
+ FILE *file;
+ int fd;
+ pthread_t thread;
+ struct termios mode;
+ int msdstrip;
+ long msg_expiry;
+};
/*! \brief SMDI interface container. */
struct ast_smdi_interface_container {
@@ -98,6 +120,11 @@
.thread = AST_PTHREADT_NULL,
};
+void ast_smdi_interface_unref(struct ast_smdi_interface *iface)
+{
+ ASTOBJ_UNREF(iface, ast_smdi_interface_destroy);
+}
+
/*!
* \internal
* \brief Push an SMDI message to the back of an interface's message queue.
@@ -390,7 +417,7 @@
start = 0;
if (!(md_msg = ast_calloc(1, sizeof(*md_msg)))) {
- ASTOBJ_UNREF(iface,ast_smdi_interface_destroy);
+ ASTOBJ_UNREF(iface, ast_smdi_interface_destroy);
return NULL;
}
@@ -875,24 +902,129 @@
return res;
}
+struct smdi_msg_datastore {
+ unsigned int id;
+ struct ast_smdi_interface *iface;
+ struct ast_smdi_md_message *md_msg;
+};
+
+static void smdi_msg_datastore_destroy(void *data)
+{
+ struct smdi_msg_datastore *smd = data;
+
+ if (smd->iface)
+ ASTOBJ_UNREF(smd->iface, ast_smdi_interface_destroy);
+
+ if (smd->md_msg)
+ ASTOBJ_UNREF(smd->md_msg, ast_smdi_md_message_destroy);
+
+ free(smd);
+}
+
+static const struct ast_datastore_info smdi_msg_datastore_info = {
+ .type = "SMDIMSG",
+ .destroy = smdi_msg_datastore_destroy,
+};
+
+static int smdi_msg_id;
+
/*! In seconds */
#define SMDI_RETRIEVE_TIMEOUT_DEFAULT 3
static int smdi_msg_retrieve_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
{
- if (chan)
- ast_autoservice_start(chan);
+ struct ast_module_user *u;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(port);
+ AST_APP_ARG(terminal);
+ AST_APP_ARG(timeout);
+ );
+ unsigned int timeout = SMDI_RETRIEVE_TIMEOUT_DEFAULT;
+ int res = -1;
+ char *parse = NULL;
+ struct smdi_msg_datastore *smd = NULL;
+ struct ast_datastore *datastore = NULL;
+ struct ast_smdi_interface *iface = NULL;
+
+ u = ast_module_user_add(chan);
+
+ if (ast_strlen_zero(data)) {
+ ast_log(LOG_ERROR, "SMDI_MSG_RETRIEVE requires an argument\n");
+ goto return_error;
+ }
+
+ if (!chan) {
+ ast_log(LOG_ERROR, "SMDI_MSG_RETRIEVE must be used with a channel\n");
+ goto return_error;
+ }
+
+ ast_autoservice_start(chan);
+
+ parse = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, parse);
+
+ if (ast_strlen_zero(args.port) || ast_strlen_zero(args.terminal)) {
+ ast_log(LOG_ERROR, "Invalid arguments provided to SMDI_MSG_RETRIEVE\n");
+ goto return_error;
+ }
+
+ if (!(iface = ast_smdi_interface_find(args.port))) {
+ ast_log(LOG_ERROR, "SMDI port '%s' not found\n", args.port);
+ goto return_error;
+ }
+
+ if (!ast_strlen_zero(args.timeout)) {
+ if (sscanf(args.timeout, "%u", &timeout) != 1) {
+ ast_log(LOG_ERROR, "'%s' is not a valid timeout\n", args.timeout);
+ timeout = SMDI_RETRIEVE_TIMEOUT_DEFAULT;
+ }
+ }
+
+ /* XXX get message here */
+
+ if (!(smd = ast_calloc(1, sizeof(*smd))))
+ goto return_error;
+
+ smd->iface = ASTOBJ_REF(iface);
+ smd->id = ast_atomic_fetchadd_int((int *) &smdi_msg_id, 1);
+ snprintf(buf, len, "%u", smd->id);
+
+ if (!(datastore = ast_channel_datastore_alloc(&smdi_msg_datastore_info, buf)))
+ goto return_error;
+
+ datastore->data = smd;
+
+ ast_channel_lock(chan);
+ ast_channel_datastore_add(chan, datastore);
+ ast_channel_unlock(chan);
+
+ res = 0;
+
+return_error:
+ if (iface)
+ ASTOBJ_UNREF(iface,ast_smdi_interface_destroy);
+
+ if (smd && !datastore)
+ smdi_msg_datastore_destroy(smd);
+
+ if (parse)
+ ast_autoservice_stop(chan);
+
+ ast_module_user_remove(u);
+
+ return res;
+}
+
+static int smdi_msg_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+{
+ struct ast_module_user *u;
+
+ u = ast_module_user_add(chan);
/* XXX */
- if (chan)
- ast_autoservice_stop(chan);
-
- return 0;
-}
-
-static int smdi_msg_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
-{
+ ast_module_user_remove(u);
+
return 0;
}
More information about the asterisk-commits
mailing list