[svn-commits] mmichelson: branch mmichelson/trunk-digiumphones r365005 - /team/mmichelson/t...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed May 2 09:47:41 CDT 2012
Author: mmichelson
Date: Wed May 2 09:47:34 2012
New Revision: 365005
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=365005
Log:
Get this compiling so bamboo will shut up.
At this point, adding message IDs to messages stored on the file
system should work under nominal conditions. There is some error handling
I need to add.
The difficult part is going to be getting this to work properly for
ODBC and IMAP. First, there is no current method for updating message data.
One can currently only store, rename, or delete. I will use the RENAME macro
as a guideline for updating message data since that is similar. Second, and
more importantly, it appears that ODBC and IMAP were never updated to actually
store or retrieve message IDs in the first place, so that needs to be added
into their STORE and RETRIEVE implementations.
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=365005&r1=365004&r2=365005
==============================================================================
--- team/mmichelson/trunk-digiumphones/apps/app_voicemail.c (original)
+++ team/mmichelson/trunk-digiumphones/apps/app_voicemail.c Wed May 2 09:47:34 2012
@@ -11266,29 +11266,42 @@
return res;
}
+static void generate_random_string(char *buf, size_t size)
+{
+ long val[4];
+ int x;
+
+ for (x=0; x<4; x++)
+ val[x] = ast_random();
+ snprintf(buf, size, "%08lx%08lx%08lx%08lx", val[0], val[1], val[2], val[3]);
+}
+
static int add_message_ids_folder(struct ast_vm_user *vmu, int folder)
{
struct vm_state vms;
+ int res = 0;
ast_copy_string(vms.username, vmu->mailbox, sizeof(vms.username));
vms.lastmsg = -1;
if (open_mailbox(&vms, vmu, folder)) {
return -1;
}
- for (vms->curmsg = 0; vms->curmsg <= vms->lastmsg; ++vms->curmsg) {
+ for (vms.curmsg = 0; vms.curmsg <= vms.lastmsg; ++vms.curmsg) {
const char *msg_id;
char filename[PATH_MAX];
struct ast_config *msg_cfg;
struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };
char random_string[33];
-
- make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
- snprintf(filename, sizeof(filename), "%s.txt", vms->fn);
- RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
+ struct ast_variable *var;
+ struct ast_category *cat;
+
+ make_file(vms.fn, sizeof(vms.fn), vms.curdir, vms.curmsg);
+ snprintf(filename, sizeof(filename), "%s.txt", vms.fn);
+ RETRIEVE(vms.curdir, vms.curmsg, vmu->mailbox, vmu->context);
msg_cfg = ast_config_load(filename, config_flags);
if (!msg_cfg || msg_cfg == CONFIG_STATUS_FILEINVALID) {
- DISPOSE(vms->curdir, vms->curmsg);
+ DISPOSE(vms.curdir, vms.curmsg);
res = -1;
goto done;
}
@@ -11298,7 +11311,7 @@
if (msg_id) {
/* If the message has an ID, nothing further to do. Continue */
ast_config_destroy(msg_cfg);
- DISPOSE(vms->curdir, vms->curmsg);
+ DISPOSE(vms.curdir, vms.curmsg);
continue;
}
@@ -11306,7 +11319,8 @@
generate_random_string(random_string, sizeof(random_string));
var = ast_variable_new("msg_id", random_string, "");
- ast_variable_append("message", var);
+ cat = ast_category_get(msg_cfg, "message");
+ ast_variable_append(cat, var);
if (ast_config_text_file_save(filename, msg_cfg, "app_voicemail")) {
/* EFF */
}
@@ -11318,17 +11332,24 @@
* said metadata as well. Hard to believe this is the first instance where such
* an operation is needed though...
*/
- /* XXX Get back to this later. */
- }
+ }
+done:
+ return res;
}
static int add_message_ids(struct ast_vm_user *vmu)
{
int i;
+ int res = 0;
for (i = 0; i < ARRAY_LEN(mailbox_folders); ++i)
{
- add_message_ids_folder(vmu, mailbox_folders[i]);
- }
+ res = add_message_ids_folder(vmu, i);
+ if (res) {
+ break;
+ }
+ }
+
+ return res;
}
static struct ast_vm_user *find_or_create(const char *context, const char *box)
More information about the svn-commits
mailing list