[asterisk-commits] russell: branch russell/fxo_mwi r90946 - /team/russell/fxo_mwi/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Dec 4 12:59:16 CST 2007
Author: russell
Date: Tue Dec 4 12:59:16 2007
New Revision: 90946
URL: http://svn.digium.com/view/asterisk?view=rev&rev=90946
Log:
Add some doxygen comments and rename a variable
Modified:
team/russell/fxo_mwi/channels/chan_zap.c
Modified: team/russell/fxo_mwi/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/russell/fxo_mwi/channels/chan_zap.c?view=diff&rev=90946&r1=90945&r2=90946
==============================================================================
--- team/russell/fxo_mwi/channels/chan_zap.c (original)
+++ team/russell/fxo_mwi/channels/chan_zap.c Tue Dec 4 12:59:16 2007
@@ -224,6 +224,8 @@
static char defaultcic[64] = "";
static char defaultozz[64] = "";
+
+/*! Run this script when the MWI state changes on an FXO line, if mwimonitor is enabled */
static char mwimonitornotify[PATH_MAX] = "";
static char progzone[10] = "";
@@ -610,7 +612,7 @@
int callwaitingrepeat; /*!< How many samples to wait before repeating call waiting */
int cidcwexpire; /*!< When to expire our muting for CID/CW */
unsigned char *cidspill;
- struct callerid_state *mwi;
+ struct callerid_state *mwi_state;
int cidpos;
int cidlen;
int ringt;
@@ -740,7 +742,6 @@
.mohinterpret = "default",
.mohsuggest = "",
.transfertobusy = 1,
- .mwimonitor = 0,
.cid_signalling = CID_SIG_BELL,
.cid_start = CID_START_RING,
@@ -1848,6 +1849,24 @@
return 0;
}
+/*!
+ * \brief Send MWI state change
+ *
+ * \arg mailbox_full This is the mailbox associated with the FXO line that the
+ * MWI state has changed on.
+ * \arg thereornot This argument should simply be set to 1 or 0, to indicate
+ * whether there are messages waiting or not.
+ *
+ * \return nothing
+ *
+ * This function does two things:
+ *
+ * 1) It generates an internal Asterisk event notifying any other module that
+ * cares about MWI that the state of a mailbox has changed.
+ *
+ * 2) It runs the script specified by the mwimonitornotify option to allow
+ * some custom handling of the state change.
+ */
static void notify_message(char *mailbox_full, int thereornot)
{
char s[sizeof(mwimonitornotify) + 80];
@@ -7361,14 +7380,14 @@
pfds[count].events = POLLPRI;
pfds[count].revents = 0;
/* Message waiting or r2 channels also get watched for reading */
- if (i->mwimonitor && (i->sig & __ZT_SIG_FXS) && !i->mwi) {
- if (!i->mwi) {
- i->mwi = callerid_new(i->cid_signalling);
+ if (i->mwimonitor && (i->sig & __ZT_SIG_FXS) && !i->mwi_state) {
+ if (!i->mwi_state) {
+ i->mwi_state = callerid_new(i->cid_signalling);
bump_gains(i);
zt_setlinear(i->subs[SUB_REAL].zfd, 0);
}
}
- if (i->cidspill || i->mwi)
+ if (i->cidspill || i->mwi_state)
pfds[count].events |= POLLIN;
count++;
}
@@ -7457,27 +7476,27 @@
i = i->next;
continue;
}
- if (!i->cidspill && !i->mwi) {
+ if (!i->cidspill && !i->mwi_state) {
ast_log(LOG_WARNING, "Whoa.... I'm reading but have no cidspill (%d)...\n", i->subs[SUB_REAL].zfd);
i = i->next;
continue;
}
res = read(i->subs[SUB_REAL].zfd, buf, sizeof(buf));
if (res > 0) {
- if (i->mwi) {
+ if (i->mwi_state) {
if (i->cid_signalling == CID_SIG_V23_JP) {
- res = callerid_feed_jp(i->mwi, (unsigned char *)buf, res, AST_LAW(i));
+ res = callerid_feed_jp(i->mwi_state, (unsigned char *)buf, res, AST_LAW(i));
} else {
- res = callerid_feed(i->mwi, (unsigned char *)buf, res, AST_LAW(i));
+ res = callerid_feed(i->mwi_state, (unsigned char *)buf, res, AST_LAW(i));
}
if (res < 0) {
ast_log(LOG_WARNING, "MWI CallerID feed failed: %s!\n", strerror(errno));
- callerid_free(i->mwi);
- i->mwi = NULL;
+ callerid_free(i->mwi_state);
+ i->mwi_state = NULL;
} else if (res) {
char *name, *number;
int flags;
- callerid_get(i->mwi, &number, &name, &flags);
+ callerid_get(i->mwi_state, &number, &name, &flags);
if (flags & CID_MSGWAITING) {
ast_log(LOG_NOTICE, "MWI: Channel %d message waiting!\n",i->channel);
notify_message(i->mailbox, 1);
@@ -7486,8 +7505,8 @@
notify_message(i->mailbox, 0);
} else
ast_log(LOG_NOTICE, "MWI: Channel %d status unknown\n", i->channel);
- callerid_free(i->mwi);
- i->mwi = NULL;
+ callerid_free(i->mwi_state);
+ i->mwi_state = NULL;
}
} else if (i->cidspill) {
/* We read some number of bytes. Write an equal amount of data */
@@ -7526,9 +7545,9 @@
i = i->next;
continue;
}
- if (i->mwi) {
- callerid_free(i->mwi);
- i->mwi = NULL;
+ if (i->mwi_state) {
+ callerid_free(i->mwi_state);
+ i->mwi_state = NULL;
zt_setlinear(i->subs[SUB_REAL].zfd, i->subs[SUB_REAL].linear);
restore_gains(i);
}
@@ -12585,7 +12604,7 @@
} else if (!strcasecmp(v->name, "transfertobusy")) {
confp->chan.transfertobusy = ast_true(v->value);
} else if (!strcasecmp(v->name, "mwimonitor")) {
- confp->chan.mwimonitor = ast_true(v->value);
+ confp->chan.mwimonitor = ast_true(v->value) ? 1 : 0;
} else if (!strcasecmp(v->name, "cid_rxgain")) {
if (sscanf(v->value, "%f", &confp->chan.cid_rxgain) != 1) {
ast_log(LOG_WARNING, "Invalid cid_rxgain: %s\n", v->value);
More information about the asterisk-commits
mailing list