[asterisk-commits] mmichelson: branch mmichelson/trunk-digiumphones r365086 - /team/mmichelson/t...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed May 2 13:17:52 CDT 2012
Author: mmichelson
Date: Wed May 2 13:17:47 2012
New Revision: 365086
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=365086
Log:
Add necessary ODBC method to update a message ID in a table.
I'm committing what I have so I can check the code out on another machine where
ODBC voice messages are already set up.
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=365086&r1=365085&r2=365086
==============================================================================
--- team/mmichelson/trunk-digiumphones/apps/app_voicemail.c (original)
+++ team/mmichelson/trunk-digiumphones/apps/app_voicemail.c Wed May 2 13:17:47 2012
@@ -3859,6 +3859,7 @@
const char *mailboxcontext;
const char *category;
const char *flag;
+ const char *msg_id;
};
static SQLHSTMT insert_data_cb(struct odbc_obj *obj, void *vdata)
@@ -3885,8 +3886,9 @@
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);
+ SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msg_id), 0, (void *) data->msg_id, 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, 13, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->category), 0, (void *) data->category, 0, NULL);
}
res = SQLExecDirect(stmt, (unsigned char *) data->sql, SQL_NTS);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
@@ -3927,7 +3929,7 @@
struct ast_config *cfg = NULL;
struct odbc_obj *obj;
struct insert_data idata = { .sql = sql, .msgnums = msgnums, .dir = dir, .mailboxuser = mailboxuser, .mailboxcontext = mailboxcontext,
- .context = "", .macrocontext = "", .callerid = "", .origtime = "", .duration = "", .category = "", .flag = "" };
+ .context = "", .macrocontext = "", .callerid = "", .origtime = "", .duration = "", .category = "", .flag = "", .msg_id = "" };
struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };
delete_file(dir, msgnum);
@@ -3979,6 +3981,9 @@
if (!(idata.flag = ast_variable_retrieve(cfg, "message", "flag"))) {
idata.flag = "";
}
+ if (!(idata.flag = ast_variable_retrieve(cfg, "message", "msg_id"))) {
+ idata.flag = "";
+ }
}
fdlen = lseek(fd, 0, SEEK_END);
if (fdlen < 0 || lseek(fd, 0, SEEK_SET) < 0) {
@@ -4017,6 +4022,33 @@
if (fd > -1)
close(fd);
return res;
+}
+
+static void odbc_update_msg_id(char *dir, int msg_num, char *msg_id)
+{
+ SQLHSTMT stmt;
+ char sql[PATH_MAX];
+ struct odbc_obj *obj;
+ char msg_num_str[20];
+ char *argv[] = { msg_id, dir, msg_num_str };
+ struct generic_prepare_struct gps = { .sql = sql, .argc = 3, .argv = argv };
+
+ obj = ast_odbc_request_obj(odbc_database, 0);
+ if (!obj) {
+ ast_log(LOG_WARNING, "Unable to update message ID for message %d in %s\n", msg_num, dir);
+ return;
+ }
+
+ snprintf(msg_num_str, sizeof(msg_num_str), "%d", msg_num);
+ snprintf(sql, sizeof(sql), "UPDATE %s SET msg_id=? WHERE dir=? AND msgnum=?", odbc_table);
+ stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
+ if (!stmt) {
+ ast_log(LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
+ } else {
+ SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+ }
+ ast_odbc_release_obj(obj);
+ return;
}
/*!
@@ -11329,7 +11361,9 @@
res = -1;
goto done;
}
- /* XXX Update ODBC and IMAP stores here */
+#ifdef ODBC_STORAGE
+ odbc_update_msg_id(vms.curdir, vms.curmsg, random_string);
+#endif
}
done:
return res;
More information about the asterisk-commits
mailing list