[asterisk-commits] jpeeler: branch jpeeler/asterisk-sigwork-trunk r193457 - /team/jpeeler/asteri...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri May 8 17:58:23 CDT 2009
Author: jpeeler
Date: Fri May 8 17:58:18 2009
New Revision: 193457
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=193457
Log:
add new callback for ss_thread to handle mwi notification
Modified:
team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c
team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c
team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h
Modified: team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c?view=diff&rev=193457&r1=193456&r2=193457
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c Fri May 8 17:58:18 2009
@@ -2205,6 +2205,78 @@
return ioctl(p->subs[ANALOG_SUB_REAL].dfd, DAHDI_HOOK, &x);
}
+/*!
+ * \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];
+ struct ast_event *event;
+ char *mailbox, *context;
+
+ /* Strip off @default */
+ context = mailbox = ast_strdupa(mailbox_full);
+ strsep(&context, "@");
+ if (ast_strlen_zero(context))
+ context = "default";
+
+ if (!(event = ast_event_new(AST_EVENT_MWI,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
+ AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, thereornot,
+ AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, thereornot,
+ AST_EVENT_IE_END))) {
+ return;
+ }
+
+ ast_event_queue_and_cache(event);
+
+ if (!ast_strlen_zero(mailbox) && !ast_strlen_zero(mwimonitornotify)) {
+ snprintf(s, sizeof(s), "%s %s %d", mwimonitornotify, mailbox, thereornot);
+ ast_safe_system(s);
+ }
+}
+
+static void my_handle_notify_message(struct ast_channel *chan, void *pvt, int flags)
+{
+ struct dahdi_pvt *p = pvt;
+
+ /* If the CID had Message waiting payload, assume that this for MWI only and hangup the call */
+ if (flags & CID_MSGWAITING) {
+ ast_log(LOG_NOTICE, "MWI: Channel %d message waiting!\n", p->channel);
+ notify_message(p->mailbox, 1);
+ /* If generated using Ring Pulse Alert, then ring has been answered as a call and needs to be hungup */
+ if (p->mwimonitor_rpas) {
+ ast_hangup(chan);
+ return;
+ }
+ } else if (flags & CID_NOMSGWAITING) {
+ ast_log(LOG_NOTICE, "MWI: Channel %d no message waiting!\n", p->channel);
+ notify_message(p->mailbox, 0);
+ /* If generated using Ring Pulse Alert, then ring has been answered as a call and needs to be hungup */
+ if (p->mwimonitor_rpas) {
+ ast_hangup(chan);
+ return;
+ }
+ }
+}
+
+
static char *event2str(int event);
static struct analog_callback dahdi_analog_callbacks =
@@ -2243,6 +2315,7 @@
.get_callerid = my_get_callerid,
.start_cid_detect = my_start_cid_detect,
.stop_cid_detect = my_stop_cid_detect,
+ .handle_notify_message = my_handle_notify_message,
};
struct dahdi_pvt *round_robin[32];
@@ -3779,53 +3852,6 @@
}
ast_debug(1, "Disabled conferencing\n");
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];
- struct ast_event *event;
- char *mailbox, *context;
-
- /* Strip off @default */
- context = mailbox = ast_strdupa(mailbox_full);
- strsep(&context, "@");
- if (ast_strlen_zero(context))
- context = "default";
-
- if (!(event = ast_event_new(AST_EVENT_MWI,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
- AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
- AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, thereornot,
- AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, thereornot,
- AST_EVENT_IE_END))) {
- return;
- }
-
- ast_event_queue_and_cache(event);
-
- if (!ast_strlen_zero(mailbox) && !ast_strlen_zero(mwimonitornotify)) {
- snprintf(s, sizeof(s), "%s %s %d", mwimonitornotify, mailbox, thereornot);
- ast_safe_system(s);
- }
}
static int restore_conference(struct dahdi_pvt *p)
@@ -9809,24 +9835,8 @@
if (cs)
callerid_free(cs);
- /* If the CID had Message waiting payload, assume that this for MWI only and hangup the call */
- if (flags & CID_MSGWAITING) {
- ast_log(LOG_NOTICE, "MWI: Channel %d message waiting!\n", p->channel);
- notify_message(p->mailbox, 1);
- /* If generated using Ring Pulse Alert, then ring has been answered as a call and needs to be hungup */
- if (p->mwimonitor_rpas) {
- ast_hangup(chan);
- return NULL;
- }
- } else if (flags & CID_NOMSGWAITING) {
- ast_log(LOG_NOTICE, "MWI: Channel %d no message waiting!\n", p->channel);
- notify_message(p->mailbox, 0);
- /* If generated using Ring Pulse Alert, then ring has been answered as a call and needs to be hungup */
- if (p->mwimonitor_rpas) {
- ast_hangup(chan);
- return NULL;
- }
- }
+
+ my_handle_notify_message(chan, p, flags);
ast_setstate(chan, AST_STATE_RING);
chan->rings = 1;
Modified: team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c?view=diff&rev=193457&r1=193456&r2=193457
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c Fri May 8 17:58:18 2009
@@ -1197,6 +1197,16 @@
if (strchr(term, c))
return 1;
}
+}
+
+static int analog_handle_notify_message(struct ast_channel *chan, struct analog_pvt *p, int flags)
+{
+ if (p->calls->handle_notify_message) {
+ p->calls->handle_notify_message(chan, p->chan_pvt, flags);
+ return 0;
+ }
+ else
+ return -1;
}
#define ANALOG_NEED_MFDETECT(p) (((p)->sig == ANALOG_SIG_FEATDMF) || ((p)->sig == ANALOG_SIG_FEATDMF_TA) || ((p)->sig == ANALOG_SIG_E911) || ((p)->sig == ANALOG_SIG_FGC_CAMA) || ((p)->sig == ANALOG_SIG_FGC_CAMAMF) || ((p)->sig == ANALOG_SIG_FEATB))
@@ -1479,10 +1489,10 @@
}
if ((p->sig == ANALOG_SIG_FEATDMF) || (p->sig == ANALOG_SIG_FEATDMF_TA)) {
analog_wink(p, index);
- /* some switches require a minimum guard time between
- the last FGD wink and something that answers
- immediately. This ensures it */
- if (ast_safe_sleep(chan,100)) return NULL;
+ /* some switches require a minimum guard time between
+ the last FGD wink and something that answers
+ immediately. This ensures it */
+ if (ast_safe_sleep(chan,100)) return NULL;
}
analog_set_echocanceller(p, 1);
@@ -2109,6 +2119,8 @@
if (cs)
callerid_free(cs);
+
+ analog_handle_notify_message(chan, p, flags);
ast_setstate(chan, AST_STATE_RING);
chan->rings = 1;
Modified: team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h?view=diff&rev=193457&r1=193456&r2=193457
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h Fri May 8 17:58:18 2009
@@ -161,6 +161,8 @@
int (* const has_voicemail)(void *pvt);
int (* const check_for_conference)(void *pvt);
+ void (* const handle_notify_message)(struct ast_channel *chan, void *pvt, int flags);
+
};
More information about the asterisk-commits
mailing list