[asterisk-commits] mmichelson: branch mmichelson/trunk-digiumphones r362961 - in /team/mmichelso...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 20 15:26:34 CDT 2012


Author: mmichelson
Date: Fri Apr 20 15:26:32 2012
New Revision: 362961

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=362961
Log:
Use ao2 references for message snapshots and expand snapshots to have all metadata.


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

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=362961&r1=362960&r2=362961
==============================================================================
--- team/mmichelson/trunk-digiumphones/apps/app_voicemail.c (original)
+++ team/mmichelson/trunk-digiumphones/apps/app_voicemail.c Fri Apr 20 15:26:32 2012
@@ -1874,6 +1874,8 @@
 		ast_free(vmu->emailsubject);
 		vmu->emailsubject = NULL;
 
+		ast_vm_mailbox_snapshot_destroy(vmu->snapshot);
+
 		ast_free(vmu);
 	}
 }
@@ -14412,11 +14414,17 @@
 	return cmd;
 }
 
+static void vm_msg_snapshot_destroy(void *obj)
+{
+	struct ast_vm_msg_snapshot *msg_snapshot = obj;
+	ast_string_field_free_memory(msg_snapshot);
+}
+
 static struct ast_vm_msg_snapshot *vm_msg_snapshot_alloc(void)
 {
 	struct ast_vm_msg_snapshot *msg_snapshot;
 
-	if (!(msg_snapshot = ast_calloc(1, sizeof(*msg_snapshot)))) {
+	if (!(msg_snapshot = ao2_alloc(sizeof(*msg_snapshot), vm_msg_snapshot_destroy))) {
 		return NULL;
 	}
 
@@ -14426,14 +14434,6 @@
 	}
 
 	return msg_snapshot;
-}
-
-static struct ast_vm_msg_snapshot *vm_msg_snapshot_destroy(struct ast_vm_msg_snapshot *msg_snapshot)
-{
-	ast_string_field_free_memory(msg_snapshot);
-	ast_free(msg_snapshot);
-
-	return NULL;
 }
 
 #ifdef TEST_FRAMEWORK
@@ -14471,13 +14471,19 @@
 
 static int __attribute__((unused))vm_msg_snapshot_create_from_data(struct ast_vm_user *vmu,
 	const char *msg_id,
+	const char *origmailbox,
 	const char *callerid,
+	const char *rdnis,
+	const char *context,
+	const char *macrocontext,
+	const char *callerchan,
 	const char *exten,
 	const char *origdate,
 	const char *origtime,
 	const char *duration,
 	const char *folder_name,
 	const char *folder_dir,
+	const char *category,
 	const char *flag)
 {
 	struct ast_vm_msg_snapshot *msg_snapshot = vm_msg_snapshot_alloc();
@@ -14486,13 +14492,19 @@
 	}
 
 	ast_string_field_set(msg_snapshot, msg_id, S_OR(msg_id, ""));
+	ast_string_field_set(msg_snapshot, origmailbox, S_OR(origmailbox, ""));
 	ast_string_field_set(msg_snapshot, callerid, S_OR(callerid, ""));
+	ast_string_field_set(msg_snapshot, rdnis, S_OR(rdnis, ""));
+	ast_string_field_set(msg_snapshot, context, S_OR(context, ""));
+	ast_string_field_set(msg_snapshot, macrocontext, S_OR(macrocontext, ""));
+	ast_string_field_set(msg_snapshot, callerchan, S_OR(callerchan, ""));
 	ast_string_field_set(msg_snapshot, exten, S_OR(exten, ""));
 	ast_string_field_set(msg_snapshot, origdate, S_OR(origdate, ""));
 	ast_string_field_set(msg_snapshot, origtime, S_OR(origtime, ""));
 	ast_string_field_set(msg_snapshot, duration, S_OR(duration, ""));
 	ast_string_field_set(msg_snapshot, folder_name, S_OR(folder_name, ""));
 	ast_string_field_set(msg_snapshot, folder_dir, S_OR(folder_dir, ""));
+	ast_string_field_set(msg_snapshot, category, S_OR(category, ""));
 	ast_string_field_set(msg_snapshot, flag, S_OR(flag, ""));
 	
 	/* XXX Here, we need to link the message snapshot into the user's mailbox
@@ -14551,9 +14563,21 @@
 		if ((value = ast_variable_retrieve(msg_cfg, "message", "msg_id"))) {
 			ast_string_field_set(msg_snapshot, msg_id, value);
 		}
+		if ((value = ast_variable_retrieve(msg_cfg, "message", "origmailbox"))) {
+			ast_string_field_set(msg_snapshot, origmailbox, value);
+		}
 		if ((value = ast_variable_retrieve(msg_cfg, "message", "callerid"))) {
 			ast_string_field_set(msg_snapshot, callerid, value);
 		}
+		if ((value = ast_variable_retrieve(msg_cfg, "message", "rdnis"))) {
+			ast_string_field_set(msg_snapshot, rdnis, value);
+		}
+		if ((value = ast_variable_retrieve(msg_cfg, "message", "context"))) {
+			ast_string_field_set(msg_snapshot, context, value);
+		}
+		if ((value = ast_variable_retrieve(msg_cfg, "message", "macrocontext"))) {
+			ast_string_field_set(msg_snapshot, rdnis, value);
+		}
 		if ((value = ast_variable_retrieve(msg_cfg, "message", "callerchan"))) {
 			ast_string_field_set(msg_snapshot, callerchan, value);
 		}
@@ -14572,12 +14596,16 @@
 		if ((value = ast_variable_retrieve(msg_cfg, "message", "folder_dir"))) {
 			ast_string_field_set(msg_snapshot, folder_dir, value);
 		}
+		if ((value = ast_variable_retrieve(msg_cfg, "message", "category"))) {
+			ast_string_field_set(msg_snapshot, category, value);
+		}
 		if ((value = ast_variable_retrieve(msg_cfg, "message", "flag"))) {
 			ast_string_field_set(msg_snapshot, flag, value);
 		}
 		msg_snapshot->msg_number = vms->curmsg;
 		ast_string_field_set(msg_snapshot, folder_name, mailbox_folders[mailbox_index]);
 
+		ao2_link(mailbox_snapshot->messages, msg_snapshot);
 		/* store msg snapshot in mailbox snapshot */
 		switch (sort_val) {
 		default:
@@ -14728,9 +14756,10 @@
 
 	for (i = 0; i < AST_VM_FOLDER_NUMBER; i++) {
 		while ((msg_snapshot = AST_LIST_REMOVE_HEAD(&mailbox_snapshot->snapshots[i], msg))) {
-			msg_snapshot = vm_msg_snapshot_destroy(msg_snapshot);
-		}
-	}
+			ao2_ref(msg_snapshot, -1);
+		}
+	}
+	ao2_ref(mailbox_snapshot->messages, -1);
 	ast_free(mailbox_snapshot);
 	return NULL;
 }

Modified: team/mmichelson/trunk-digiumphones/include/asterisk/app_voicemail.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/trunk-digiumphones/include/asterisk/app_voicemail.h?view=diff&rev=362961&r1=362960&r2=362961
==============================================================================
--- team/mmichelson/trunk-digiumphones/include/asterisk/app_voicemail.h (original)
+++ team/mmichelson/trunk-digiumphones/include/asterisk/app_voicemail.h Fri Apr 20 15:26:32 2012
@@ -38,7 +38,11 @@
 struct ast_vm_msg_snapshot {
 	AST_DECLARE_STRING_FIELDS(
 		AST_STRING_FIELD(msg_id);
+		AST_STRING_FIELD(origmailbox);
 		AST_STRING_FIELD(callerid);
+		AST_STRING_FIELD(rdnis);
+		AST_STRING_FIELD(context);
+		AST_STRING_FIELD(macrocontext);
 		AST_STRING_FIELD(callerchan);
 		AST_STRING_FIELD(exten);
 		AST_STRING_FIELD(origdate);
@@ -46,6 +50,7 @@
 		AST_STRING_FIELD(duration);
 		AST_STRING_FIELD(folder_name);
 		AST_STRING_FIELD(folder_dir);
+		AST_STRING_FIELD(category);
 		AST_STRING_FIELD(flag);
 	);
 	unsigned int msg_number;




More information about the asterisk-commits mailing list