[asterisk-commits] tilghman: branch tilghman/realtime_for_voicemail_in_germany r167097 - in /tea...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 31 18:07:28 CST 2008


Author: tilghman
Date: Wed Dec 31 18:07:27 2008
New Revision: 167097

URL: http://svn.digium.com/view/asterisk?view=rev&rev=167097
Log:
Initialized merge tracking via "svnmerge" with revisions "1-167095" from 
https://origsvn.digium.com/svn/asterisk/trunk

Modified:
    team/tilghman/realtime_for_voicemail_in_germany/   (props changed)
    team/tilghman/realtime_for_voicemail_in_germany/apps/app_voicemail.c

Propchange: team/tilghman/realtime_for_voicemail_in_germany/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/tilghman/realtime_for_voicemail_in_germany/
------------------------------------------------------------------------------
    automerge-email = tilghman at mail.jeffandtilghman.com

Propchange: team/tilghman/realtime_for_voicemail_in_germany/
------------------------------------------------------------------------------
    svnmerge-integrated = /trunk:1-167095

Modified: team/tilghman/realtime_for_voicemail_in_germany/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/realtime_for_voicemail_in_germany/apps/app_voicemail.c?view=diff&rev=167097&r1=167096&r2=167097
==============================================================================
--- team/tilghman/realtime_for_voicemail_in_germany/apps/app_voicemail.c (original)
+++ team/tilghman/realtime_for_voicemail_in_germany/apps/app_voicemail.c Wed Dec 31 18:07:27 2008
@@ -3239,20 +3239,10 @@
 		return NULL;
 	}
 
-	SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->dir), 0, (void *)data->dir, 0, NULL);
-	SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msgnums), 0, (void *)data->msgnums, 0, NULL);
-	SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, data->datalen, 0, (void *)data->data, data->datalen, &data->indlen);
-	SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->context), 0, (void *)data->context, 0, NULL);
-	SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->macrocontext), 0, (void *)data->macrocontext, 0, NULL);
-	SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->callerid), 0, (void *)data->callerid, 0, NULL);
-	SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->origtime), 0, (void *)data->origtime, 0, NULL);
-	SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->duration), 0, (void *)data->duration, 0, NULL);
-	SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxuser), 0, (void *)data->mailboxuser, 0, NULL);
-	SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxcontext), 0, (void *)data->mailboxcontext, 0, NULL);
-	SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->flag), 0, (void *)data->flag, 0, NULL);
-	if (!ast_strlen_zero(data->category)) {
-		SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->category), 0, (void *)data->category, 0, NULL);
-	}
+	SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, data->datalen, 0, (void *)data->data, data->datalen, &data->indlen);
+	SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->dir), 0, (void *)data->dir, 0, NULL);
+	SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msgnums), 0, (void *)data->msgnums, 0, NULL);
+
 	res = SQLExecDirect(stmt, (unsigned char *)data->sql, SQL_NTS);
 	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
 		ast_log(AST_LOG_WARNING, "SQL Direct Execute failed!\n");
@@ -3356,15 +3346,19 @@
 		idata.data = fdm;
 		idata.datalen = idata.indlen = fdlen;
 
-		if (!ast_strlen_zero(idata.category)) 
-			snprintf(sql, sizeof(sql), "INSERT INTO %s (dir,msgnum,recording,context,macrocontext,callerid,origtime,duration,mailboxuser,mailboxcontext,flag,category) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)",odbc_table); 
-		else
-			snprintf(sql, sizeof(sql), "INSERT INTO %s (dir,msgnum,recording,context,macrocontext,callerid,origtime,duration,mailboxuser,mailboxcontext,flag) VALUES (?,?,?,?,?,?,?,?,?,?,?)",odbc_table);
-
+		snprintf(sql, sizeof(sql), "UPDATE %s SET recording=? WHERE dir=? AND msgnum=?", odbc_table); 
+
+		/* If you want to add additional parameters, add them to the realtime method */
+		ast_store_realtime("voicemail_data", "dir", idata.dir, "msgnum", idata.msgnums,
+			"context", idata.context, "macrocontext", idata.macrocontext, "callerid", idata.callerid,
+			"origtime", idata.origtime, "duration", idata.duration, "mailboxuser", idata.mailboxuser,
+			"mailboxcontext", idata.mailboxcontext, "flag", idata.flag, "category", idata.category,
+			SENTINEL);
 		if ((stmt = ast_odbc_direct_execute(obj, insert_data_cb, &idata))) {
 			SQLFreeHandle (SQL_HANDLE_STMT, stmt);
 		} else {
 			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
+			ast_destroy_realtime("voicemail_data", "dir", idata.dir, "msgnum", idata.msgnums, SENTINEL);
 			res = -1;
 		}
 	} while (0);
@@ -3395,28 +3389,14 @@
  */
 static void rename_file(char *sdir, int smsg, char *mailboxuser, char *mailboxcontext, char *ddir, int dmsg)
 {
-	SQLHSTMT stmt;
-	char sql[PATH_MAX];
 	char msgnums[20];
 	char msgnumd[20];
-	struct odbc_obj *obj;
-	char *argv[] = { ddir, msgnumd, mailboxuser, mailboxcontext, sdir, msgnums };
-	struct generic_prepare_struct gps = { .sql = sql, .argc = 6, .argv = argv };
 
 	delete_file(ddir, dmsg);
-	obj = ast_odbc_request_obj(odbc_database, 0);
-	if (obj) {
-		snprintf(msgnums, sizeof(msgnums), "%d", smsg);
-		snprintf(msgnumd, sizeof(msgnumd), "%d", dmsg);
-		snprintf(sql, sizeof(sql), "UPDATE %s SET dir=?, msgnum=?, mailboxuser=?, mailboxcontext=? WHERE dir=? AND msgnum=?",odbc_table);
-		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
-		if (!stmt)
-			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
-		else
-			SQLFreeHandle(SQL_HANDLE_STMT, stmt);
-		ast_odbc_release_obj(obj);
-	} else
-		ast_log(AST_LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
+	snprintf(msgnums, sizeof(msgnums), "%d", smsg);
+	snprintf(msgnumd, sizeof(msgnumd), "%d", dmsg);
+	ast_update2_realtime("voicemail_data", "dir", sdir, "msgnum", msgnums, SENTINEL,
+		"dir", ddir, "msgnum", msgnumd, "mailboxuser", mailboxuser, "mailboxcontext", mailboxcontext);
 	return;	
 }
 




More information about the asterisk-commits mailing list