[asterisk-commits] mmichelson: branch mmichelson/trunk-digiumphones r363309 - /team/mmichelson/t...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 23 16:48:04 CDT 2012


Author: mmichelson
Date: Mon Apr 23 16:48:02 2012
New Revision: 363309

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=363309
Log:
Change function that plays messages by ID to use message_range_and_existence_check()


Modified:
    team/mmichelson/trunk-digiumphones/apps/app_voicemail.c

Modified: team/mmichelson/trunk-digiumphones/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/trunk-digiumphones/apps/app_voicemail.c?view=diff&rev=363309&r1=363308&r2=363309
==============================================================================
--- team/mmichelson/trunk-digiumphones/apps/app_voicemail.c (original)
+++ team/mmichelson/trunk-digiumphones/apps/app_voicemail.c Mon Apr 23 16:48:02 2012
@@ -1038,6 +1038,7 @@
 static int write_password_to_file(const char *secretfn, const char *password);
 struct ast_str *vm_mailbox_snapshot_str(const char *mailbox, const char *context);
 static const char *substitute_escapes(const char *value);
+static int message_range_and_existence_check(struct vm_state *vms, const char *msg_ids [], size_t num_msgs, int *msg_nums);
 
 struct ao2_container *inprocess_container;
 
@@ -10316,53 +10317,29 @@
 	struct vm_state *vms,
 	const char *msg_id)
 {
-	struct ast_config *msg_cfg;
-	struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };
-	char filename[256];
-	const char *other_msg_id;
-	int found = 0;
-
-	for (vms->curmsg = 0; vms->curmsg <= vms->lastmsg && !found; vms->curmsg++) {
-		/* Find the msg */
-		make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
-		snprintf(filename, sizeof(filename), "%s.txt", vms->fn);
-		RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
-		msg_cfg = ast_config_load(filename, config_flags);
-		if (!msg_cfg || msg_cfg == CONFIG_STATUS_FILEINVALID) {
-			DISPOSE(vms->curdir, vms->curmsg);
-			continue;
-		}
-
-		other_msg_id = ast_variable_retrieve(msg_cfg, "message", "msg_id");
-
-		if (!ast_strlen_zero(other_msg_id) && !strcmp(other_msg_id, msg_id)) {
-			/* Found the msg, so play it back */
-
-			make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
-			make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
-			found = 1;
+	if (message_range_and_existence_check(vms, &msg_id, 1, &vms->curmsg)) {
+		return -1;
+	}
+	/* Found the msg, so play it back */
+
+	make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
+	make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
 
 #ifdef IMAP_STORAGE
-			/*IMAP storage stores any prepended message from a forward
-			 * as a separate file from the rest of the message
-			 */
-			if (!ast_strlen_zero(vms->introfn) && ast_fileexists(vms->introfn, NULL, NULL) > 0) {
-				wait_file(chan, vms, vms->introfn);
-			}
+	/*IMAP storage stores any prepended message from a forward
+	 * as a separate file from the rest of the message
+	 */
+	if (!ast_strlen_zero(vms->introfn) && ast_fileexists(vms->introfn, NULL, NULL) > 0) {
+		wait_file(chan, vms, vms->introfn);
+	}
 #endif
-			if ((wait_file(chan, vms, vms->fn)) < 0) {
-				ast_log(AST_LOG_WARNING, "Playback of message %s failed\n", vms->fn);
-			} else {
-				vms->heard[vms->curmsg] = 1;
-			}
-		}
-
-		/* cleanup configs and msg */
-		ast_config_destroy(msg_cfg);
-		DISPOSE(vms->curdir, vms->curmsg);
-	}
-
-	return found ? 0 : -1;
+	if ((wait_file(chan, vms, vms->fn)) < 0) {
+		ast_log(AST_LOG_WARNING, "Playback of message %s failed\n", vms->fn);
+	} else {
+		vms->heard[vms->curmsg] = 1;
+	}
+
+	return 0;
 }
 
 /*!




More information about the asterisk-commits mailing list