[asterisk-commits] russell: branch russell/smdi-1.4 r93465 - /team/russell/smdi-1.4/res/res_smdi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 17 17:12:36 CST 2007


Author: russell
Date: Mon Dec 17 17:12:35 2007
New Revision: 93465

URL: http://svn.digium.com/view/asterisk?view=rev&rev=93465
Log:
Implement the SMDI_MSG dialplan function, which allows access to the details
of an SMDI message that is sitting in a datastore, that was retrieved using
the SMDI_MSG_RETRIEVE dialplan function.  The changes to res_smdi are now
complete, pending testing.

Modified:
    team/russell/smdi-1.4/res/res_smdi.c

Modified: team/russell/smdi-1.4/res/res_smdi.c
URL: http://svn.digium.com/view/asterisk/team/russell/smdi-1.4/res/res_smdi.c?view=diff&rev=93465&r1=93464&r2=93465
==============================================================================
--- team/russell/smdi-1.4/res/res_smdi.c (original)
+++ team/russell/smdi-1.4/res/res_smdi.c Mon Dec 17 17:12:35 2007
@@ -1178,11 +1178,66 @@
 static int smdi_msg_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
 {
 	struct ast_module_user *u;
+	int res = -1;
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(id);
+		AST_APP_ARG(component);
+	);
+	char *parse;
+	struct ast_datastore *datastore = NULL;
+	struct smdi_msg_datastore *smd = NULL;
+
+	u = ast_module_user_add(chan);
+
+	if (!chan) {
+		ast_log(LOG_ERROR, "SMDI_MSG can not be called without a channel\n");
+		goto return_error;
+	}
+
+	if (ast_strlen_zero(data)) {
+		ast_log(LOG_WARNING, "SMDI_MSG requires an argument\n");
+		goto return_error;
+	}
+
+	parse = ast_strdupa(data);
+	AST_STANDARD_APP_ARGS(args, parse);
+
+	if (ast_strlen_zero(args.id)) {
+		ast_log(LOG_WARNING, "ID must be supplied to SMDI_MSG\n");
+		goto return_error;
+	}
+
+	if (ast_strlen_zero(args.component)) {
+		ast_log(LOG_WARNING, "ID must be supplied to SMDI_MSG\n");
+		goto return_error;
+	}
+
+	ast_channel_lock(chan);
+	datastore = ast_channel_datastore_find(chan, &smdi_msg_datastore_info, args.id);
+	ast_channel_unlock(chan);
 	
-	u = ast_module_user_add(chan);
-
-	/* XXX */
-
+	if (!datastore) {
+		ast_log(LOG_WARNING, "No SMDI message found for message ID '%s'\n", args.id);
+		goto return_error;
+	}
+
+	smd = datastore->data;
+
+	if (!strcasecmp(args.component, "station")) {
+		ast_copy_string(buf, smd->md_msg->fwd_st, len);
+	} else if (!strcasecmp(args.component, "callerid")) {
+		ast_copy_string(buf, smd->md_msg->calling_st, len);
+	} else if (!strcasecmp(args.component, "type")) {
+		snprintf(buf, len, "%c", smd->md_msg->type);
+	} else {
+		ast_log(LOG_ERROR, "'%s' is not a valid message component for SMDI_MSG\n",
+			args.component);
+		goto return_error;
+	}
+
+	res = 0;
+
+return_error:
 	ast_module_user_remove(u);
 
 	return 0;




More information about the asterisk-commits mailing list