[asterisk-commits] rmudgett: branch rmudgett/mwi2 r307360 - in /team/rmudgett/mwi2: channels/ co...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Feb 9 16:48:14 CST 2011
Author: rmudgett
Date: Wed Feb 9 16:48:02 2011
New Revision: 307360
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=307360
Log:
Change to allow the user specify a different voicemail number for each mailbox.
Modified:
team/rmudgett/mwi2/channels/chan_dahdi.c
team/rmudgett/mwi2/channels/sig_pri.c
team/rmudgett/mwi2/channels/sig_pri.h
team/rmudgett/mwi2/configs/chan_dahdi.conf.sample
Modified: team/rmudgett/mwi2/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/mwi2/channels/chan_dahdi.c?view=diff&rev=307360&r1=307359&r2=307360
==============================================================================
--- team/rmudgett/mwi2/channels/chan_dahdi.c (original)
+++ team/rmudgett/mwi2/channels/chan_dahdi.c Wed Feb 9 16:48:02 2011
@@ -12339,9 +12339,9 @@
ast_copy_string(pris[span].pri.mwi_mailboxes,
conf->pri.pri.mwi_mailboxes,
sizeof(pris[span].pri.mwi_mailboxes));
- ast_copy_string(pris[span].pri.mwi_vm_number,
- conf->pri.pri.mwi_vm_number,
- sizeof(pris[span].pri.mwi_vm_number));
+ ast_copy_string(pris[span].pri.mwi_vm_numbers,
+ conf->pri.pri.mwi_vm_numbers,
+ sizeof(pris[span].pri.mwi_vm_numbers));
#endif /* defined(HAVE_PRI_MWI) */
ast_copy_string(pris[span].pri.idledial, conf->pri.pri.idledial, sizeof(pris[span].pri.idledial));
ast_copy_string(pris[span].pri.idleext, conf->pri.pri.idleext, sizeof(pris[span].pri.idleext));
@@ -17304,9 +17304,9 @@
} else if (!strcasecmp(v->name, "mwi_mailboxes")) {
ast_copy_string(confp->pri.pri.mwi_mailboxes, v->value,
sizeof(confp->pri.pri.mwi_mailboxes));
- } else if (!strcasecmp(v->name, "mwi_vm_number")) {
- ast_copy_string(confp->pri.pri.mwi_vm_number, v->value,
- sizeof(confp->pri.pri.mwi_vm_number));
+ } else if (!strcasecmp(v->name, "mwi_vm_numbers")) {
+ ast_copy_string(confp->pri.pri.mwi_vm_numbers, v->value,
+ sizeof(confp->pri.pri.mwi_vm_numbers));
#endif /* defined(HAVE_PRI_MWI) */
} else if (!strcasecmp(v->name, "append_msn_to_cid_tag")) {
confp->pri.pri.append_msn_to_user_tag = ast_true(v->value);
Modified: team/rmudgett/mwi2/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/mwi2/channels/sig_pri.c?view=diff&rev=307360&r1=307359&r2=307360
==============================================================================
--- team/rmudgett/mwi2/channels/sig_pri.c (original)
+++ team/rmudgett/mwi2/channels/sig_pri.c Wed Feb 9 16:48:02 2011
@@ -7894,7 +7894,7 @@
* \since 1.8
*
* \param pri Asterisk D channel control structure.
- * \param vm_number Voicemail controlling number
+ * \param vm_number Voicemail controlling number (NULL if not present).
* \param mbox_number Mailbox number
* \param mbox_context Mailbox context
* \param num_messages Number of messages waiting.
@@ -7919,7 +7919,9 @@
voicemail.number.valid = 1;
voicemail.number.presentation = PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
voicemail.number.plan = (PRI_TON_UNKNOWN << 4) | PRI_NPI_UNKNOWN;
- ast_copy_string(voicemail.number.str, vm_number, sizeof(voicemail.number.str));
+ if (vm_number) {
+ ast_copy_string(voicemail.number.str, vm_number, sizeof(voicemail.number.str));
+ }
ast_mutex_lock(&pri->lock);
#if defined(HAVE_PRI_MWI_V2)
@@ -7949,6 +7951,7 @@
const char *mbox_context;
const char *mbox_number;
int num_messages;
+ int idx;
mbox_number = ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX);
if (ast_strlen_zero(mbox_number)) {
@@ -7959,8 +7962,20 @@
return;
}
num_messages = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
- sig_pri_send_mwi_indication(pri, pri->mwi_vm_number, mbox_number, mbox_context,
- num_messages);
+
+ for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {
+ if (!pri->mbox[idx].sub) {
+ /* Mailbox slot is empty */
+ continue;
+ }
+ if (!strcmp(pri->mbox[idx].number, mbox_number)
+ && !strcmp(pri->mbox[idx].context, mbox_context)) {
+ /* Found the mailbox. */
+ sig_pri_send_mwi_indication(pri, pri->mbox[idx].vm_number, mbox_number,
+ mbox_context, num_messages);
+ break;
+ }
+ }
}
#endif /* defined(HAVE_PRI_MWI) */
@@ -7982,8 +7997,8 @@
for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {
if (!pri->mbox[idx].sub) {
- /* There are no more mailboxes on this span. */
- break;
+ /* Mailbox slot is empty */
+ continue;
}
event = ast_event_get_cached(AST_EVENT_MWI,
@@ -7995,7 +8010,7 @@
continue;
}
num_messages = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
- sig_pri_send_mwi_indication(pri, pri->mwi_vm_number, pri->mbox[idx].number,
+ sig_pri_send_mwi_indication(pri, pri->mbox[idx].vm_number, pri->mbox[idx].number,
pri->mbox[idx].context, num_messages);
ast_event_destroy(event);
}
@@ -8081,8 +8096,7 @@
int i;
#if defined(HAVE_PRI_MWI)
char *saveptr;
- char *mbox_number;
- char *mbox_context;
+ char *prev_vm_number;
struct ast_str *mwi_description = ast_str_alloca(64);
#endif /* defined(HAVE_PRI_MWI) */
@@ -8100,14 +8114,40 @@
#if defined(HAVE_PRI_MWI)
/*
+ * Split the mwi_vm_numbers configuration string into the mbox[].vm_number:
+ * vm_number{,vm_number}
+ */
+ prev_vm_number = NULL;
+ saveptr = pri->mwi_vm_numbers;
+ for (i = 0; i < ARRAY_LEN(pri->mbox); ++i) {
+ char *vm_number;
+
+ vm_number = strsep(&saveptr, ",");
+ if (vm_number) {
+ vm_number = ast_strip(vm_number);
+ }
+ if (ast_strlen_zero(vm_number)) {
+ /* There was no number so reuse the previous number. */
+ vm_number = prev_vm_number;
+ } else {
+ /* We have a new number. */
+ prev_vm_number = vm_number;
+ }
+ pri->mbox[i].vm_number = vm_number;
+ }
+
+ /*
* Split the mwi_mailboxes configuration string into the mbox[]:
* mailbox_number[@context]{,mailbox_number[@context]}
*/
- i = 0;
saveptr = pri->mwi_mailboxes;
- while (i < ARRAY_LEN(pri->mbox)) {
+ for (i = 0; i < ARRAY_LEN(pri->mbox); ++i) {
+ char *mbox_number;
+ char *mbox_context;
+
mbox_number = strsep(&saveptr, ",");
if (!mbox_number) {
+ /* No more defined mailboxes. */
break;
}
/* Split the mailbox_number and context */
@@ -8127,6 +8167,8 @@
}
/* Fill the mbox[] element. */
+ pri->mbox[i].number = mbox_number;
+ pri->mbox[i].context = mbox_context;
ast_str_set(&mwi_description, -1, "%s span %d[%d] MWI mailbox %s@%s",
sig_pri_cc_type_name, pri->span, i, mbox_number, mbox_context);
pri->mbox[i].sub = ast_event_subscribe(AST_EVENT_MWI, sig_pri_mwi_event_cb,
@@ -8137,11 +8179,7 @@
if (!pri->mbox[i].sub) {
ast_log(LOG_ERROR, "%s span %d could not subscribe to MWI events for %s@%s.",
sig_pri_cc_type_name, pri->span, mbox_number, mbox_context);
- continue;
- }
- pri->mbox[i].number = mbox_number;
- pri->mbox[i].context = mbox_context;
- ++i;
+ }
}
#endif /* defined(HAVE_PRI_MWI) */
Modified: team/rmudgett/mwi2/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/mwi2/channels/sig_pri.h?view=diff&rev=307360&r1=307359&r2=307360
==============================================================================
--- team/rmudgett/mwi2/channels/sig_pri.h (original)
+++ team/rmudgett/mwi2/channels/sig_pri.h Wed Feb 9 16:48:02 2011
@@ -340,12 +340,22 @@
#if defined(HAVE_PRI_MWI)
/*! Maximum number of mailboxes per span. */
#define SIG_PRI_MAX_MWI_MAILBOXES 8
+/*! Typical maximum length of mwi voicemail controlling number */
+#define SIG_PRI_MAX_MWI_VM_NUMBER_LEN 10 /* digits in number */
/*! Typical maximum length of mwi mailbox number */
#define SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN 10 /* digits in number */
/*! Typical maximum length of mwi mailbox context */
#define SIG_PRI_MAX_MWI_CONTEXT_LEN 10
/*!
- * \brief Maximum mwi_mailbox string length.
+ * \brief Maximum mwi_vm_numbers string length.
+ * \details
+ * max_length = #mailboxes * (vm_number + ',')
+ * The last ',' is a null terminator instead.
+ */
+#define SIG_PRI_MAX_MWI_VM_NUMBER_STR (SIG_PRI_MAX_MWI_MAILBOXES \
+ * (SIG_PRI_MAX_MWI_VM_NUMBER_LEN + 1))
+/*!
+ * \brief Maximum mwi_mailboxs string length.
* \details
* max_length = #mailboxes * (mbox_number + '@' + context + ',')
* The last ',' is a null terminator instead.
@@ -363,6 +373,8 @@
const char *number;
/*! \brief Mailbox context. */
const char *context;
+ /*! \brief Voicemail controlling number. */
+ const char *vm_number;
};
#endif /* defined(HAVE_PRI_MWI) */
@@ -434,8 +446,12 @@
* \note String is split apart when span is started.
*/
char mwi_mailboxes[SIG_PRI_MAX_MWI_MAILBOX_STR];
- /*! \brief Voicemail access controlling number for MWI. */
- char mwi_vm_number[AST_MAX_EXTENSION];
+ /*!
+ * \brief Comma separated list of voicemail access controlling numbers for MWI.
+ * \note Format: vm_number{,vm_number}
+ * \note String is split apart when span is started.
+ */
+ char mwi_vm_numbers[SIG_PRI_MAX_MWI_VM_NUMBER_STR];
#endif /* defined(HAVE_PRI_MWI) */
/*!
* \brief Initial user tag for party id's sent from this device driver.
Modified: team/rmudgett/mwi2/configs/chan_dahdi.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/mwi2/configs/chan_dahdi.conf.sample?view=diff&rev=307360&r1=307359&r2=307360
==============================================================================
--- team/rmudgett/mwi2/configs/chan_dahdi.conf.sample (original)
+++ team/rmudgett/mwi2/configs/chan_dahdi.conf.sample Wed Feb 9 16:48:02 2011
@@ -588,10 +588,20 @@
; The default is an empty list.
;mwi_mailboxes=mailbox_number[@context]{,mailbox_number[@context]}
;
-; Configure the ISDN span voicemail number for MWI. What number to call for
-; a user to retrieve voicemail messages.
+; Configure the ISDN span voicemail numbers for MWI mailboxes. What number
+; to call for a user to retrieve voicemail messages.
+;
+; You can give a comma separated list of numbers. The position of the number
+; corresponds to the position in mwi_mailboxes. If a position is empty then
+; the last number is reused.
+;
+; For example:
+; mwi_vm_numbers=700,,800,,900
+; is equivalent to:
+; mwi_vm_numbers=700,700,800,800,900
+;
; The default is no number.
-;mwi_vm_number=
+;mwi_vm_numbers=
; Whether or not restrict outgoing caller ID (will be sent as ANI only, not
; available for the user)
More information about the asterisk-commits
mailing list