Revision
17047
Author
anthm
Date
2010-03-18 17:12:51 -0500 (Thu, 18 Mar 2010)

Log Message

finish up vm changes

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (17046 => 17047)


--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c	2010-03-18 21:34:20 UTC (rev 17046)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c	2010-03-18 22:12:51 UTC (rev 17047)
@@ -4014,6 +4014,14 @@
 	if (e && (p = strchr(e, ' '))) {
 		*p++ = '\0';
 		ru = e = p;
+	}
+
+	if (e && (p = strchr(e, ' '))) {
+		*p++ = '\0';
+		uuid = p;
+	}
+
+	if (ru) {
 		if (!strcasecmp(ru, "read")) {
 			mread = 1;
 		} else if (!strcasecmp(ru, "unread")) {
@@ -4023,14 +4031,7 @@
 		}
 	}
 
-	if (mread > -1) {
-		if (e && (p = strchr(e, ' '))) {
-			*p++ = '\0';
-			uuid = p;
-		}
-	}
 
-
 	if (mread > -1 && id && domain && profile_name && (profile = get_profile(profile_name))) {
 		
 		if (mread) {
@@ -4094,7 +4095,7 @@
 SWITCH_STANDARD_API(voicemail_list_api_function)
 {
 	char *sql;
-	char *id = NULL, *domain = NULL, *format = "text", *profile_name = "default";
+	char *id = NULL, *uuid = NULL, *domain = NULL, *format = "text", *profile_name = "default";
 	char *p, *e = NULL;
 	vm_profile_t *profile;
 
@@ -4117,13 +4118,24 @@
 
 	if (e && (p = strchr(e, ' '))) {
 		*p++ = '\0';
-		format = p;
+		format = e = p;
 	}
 
+	if (e && (p = strchr(e, ' '))) {
+		*p++ = '\0';
+		uuid = p;
+	}
+
 	if (id && domain && profile_name && (profile = get_profile(profile_name))) {
-		sql = switch_mprintf("select created_epoch, read_epoch, username, domain, in_folder, file_path, uuid, cid_name, cid_number, "
-							 "'%q' from voicemail_msgs where username='%q' and domain='%q'", 
-							 format, id, domain);
+		if (uuid) {
+			sql = switch_mprintf("select created_epoch, read_epoch, username, domain, in_folder, file_path, uuid, cid_name, cid_number, "
+								 "'%q' from voicemail_msgs where username='%q' and domain='%q' and uuid='%q'", 
+								 format, id, domain, uuid);
+		} else {
+			sql = switch_mprintf("select created_epoch, read_epoch, username, domain, in_folder, file_path, uuid, cid_name, cid_number, "
+								 "'%q' from voicemail_msgs where username='%q' and domain='%q'", 
+								 format, id, domain);
+		}
 
 		if (!strcasecmp(format, "xml")) {
 			stream->write_function(stream, "<voicemail>\n");