aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
Diffstat (limited to 'res')
-rw-r--r--res/res_smdi.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/res/res_smdi.c b/res/res_smdi.c
index 406a740c9..e13b5d4d9 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -383,7 +383,18 @@ static void *smdi_msg_find(struct ast_smdi_interface *iface,
switch (type) {
case SMDI_MD:
- if (ast_test_flag(&options, OPT_SEARCH_TERMINAL)) {
+ if (ast_strlen_zero(search_key)) {
+ struct ast_smdi_md_message *md_msg = NULL;
+
+ /* No search key provided (the code from chan_dahdi does this).
+ * Just pop the top message off of the queue. */
+
+ ASTOBJ_CONTAINER_TRAVERSE(&iface->md_q, !md_msg, do {
+ md_msg = ASTOBJ_REF(iterator);
+ } while (0); );
+
+ msg = md_msg;
+ } else if (ast_test_flag(&options, OPT_SEARCH_TERMINAL)) {
struct ast_smdi_md_message *md_msg = NULL;
/* Searching by the message desk terminal */
@@ -411,7 +422,20 @@ static void *smdi_msg_find(struct ast_smdi_interface *iface,
}
break;
case SMDI_MWI:
- msg = ASTOBJ_CONTAINER_FIND(&iface->mwi_q, search_key);
+ if (ast_strlen_zero(search_key)) {
+ msg = ASTOBJ_CONTAINER_FIND(&iface->mwi_q, search_key);
+ } else {
+ struct ast_smdi_mwi_message *mwi_msg = NULL;
+
+ /* No search key provided (the code from chan_dahdi does this).
+ * Just pop the top message off of the queue. */
+
+ ASTOBJ_CONTAINER_TRAVERSE(&iface->mwi_q, !mwi_msg, do {
+ mwi_msg = ASTOBJ_REF(iterator);
+ } while (0); );
+
+ msg = mwi_msg;
+ }
break;
}