commit
620a3298d0
@ -0,0 +1,561 @@
|
||||
--- a/apps/app_voicemail.c
|
||||
+++ b/apps/app_voicemail.c
|
||||
@@ -1043,6 +1043,52 @@ static int adsiver = 1;
|
||||
static char emaildateformat[32] = "%A, %B %d, %Y at %r";
|
||||
static char pagerdateformat[32] = "%A, %B %d, %Y at %r";
|
||||
|
||||
+/* This structure is for holding all actions made per notification.
|
||||
+ When accessing the voicemail multiple actions could be taken: add, read or remove(delete) a message
|
||||
+*/
|
||||
+typedef struct _node
|
||||
+{
|
||||
+ char action;
|
||||
+ char id[256];
|
||||
+ char callid[256];
|
||||
+ int size;
|
||||
+} vm_node;
|
||||
+
|
||||
+void vm_node_create(vm_node* node, int size);
|
||||
+int vm_node_find_avail(vm_node* node);
|
||||
+int vm_node_insert(vm_node* node, char action, char* id, char* callid);
|
||||
+
|
||||
+void vm_node_create(vm_node* node, int size) {
|
||||
+ node->size = size;
|
||||
+ for (int i = 0; i < size; i++)
|
||||
+ {
|
||||
+ node[i].action = 0;
|
||||
+ memset(node[i].id, 0, sizeof(node[i].id));
|
||||
+ memset(node[i].callid, 0, sizeof(node[i].callid));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int vm_node_find_avail(vm_node* node) {
|
||||
+ int size = node->size;
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ if(strlen(node[i].id) == 0) {
|
||||
+ return i;
|
||||
+ }
|
||||
+ }
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+int vm_node_insert(vm_node* node, char action, char* id, char* callid) {
|
||||
+ int index = vm_node_find_avail(node);
|
||||
+ if (index != -1) {
|
||||
+ node[index].action = action;
|
||||
+ strncpy(node[index].id, id, sizeof(node[index].id)-1);
|
||||
+ strncpy(node[index].callid, callid, sizeof(node[index].callid)-1);
|
||||
+ return 1; //added
|
||||
+ }
|
||||
+ return 0; //full
|
||||
+}
|
||||
+
|
||||
/* Forward declarations - generic */
|
||||
#ifdef ODBC_STORAGE
|
||||
static struct ast_vm_user *find_user_realtime_by_alias(struct ast_vm_user *ivm, const char *context, const char *alias);
|
||||
@@ -1065,8 +1111,9 @@ static void read_password_from_file(cons
|
||||
static int write_password_to_file(const char *secretfn, const char *password);
|
||||
static const char *substitute_escapes(const char *value);
|
||||
static int message_range_and_existence_check(struct vm_state *vms, const char *msg_ids [], size_t num_msgs, int *msg_nums, struct ast_vm_user *vmu);
|
||||
-static void notify_new_state(struct ast_vm_user *vmu);
|
||||
+static void notify_new_state(struct ast_vm_user *vmu, vm_node *vm_actions);
|
||||
static int append_vmu_info_astman(struct mansession *s, struct ast_vm_user *vmu, const char* event_name, const char* actionid);
|
||||
+static void get_id_callid(char *dir, int msg_num, char *msg_id, char *callid);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -4427,9 +4474,11 @@ static void copy_file(char *sdir, int sm
|
||||
char msgnums[20];
|
||||
char msgnumd[20];
|
||||
char msg_id[MSG_ID_LEN];
|
||||
+ char mid[256] = "";
|
||||
+ char callid[256] = "";
|
||||
struct odbc_obj *obj;
|
||||
- char *argv[] = { ddir, msgnumd, msg_id, dmailboxuser, dmailboxcontext, sdir, msgnums };
|
||||
- struct generic_prepare_struct gps = { .sql = sql, .argc = 7, .argv = argv };
|
||||
+ char *argv[] = { ddir, msgnumd, msg_id, dmailboxuser, dmailboxcontext, callid, sdir, msgnums };
|
||||
+ struct generic_prepare_struct gps = { .sql = sql, .argc = 8, .argv = argv };
|
||||
|
||||
generate_msg_id(msg_id);
|
||||
delete_file(ddir, dmsg);
|
||||
@@ -4441,7 +4490,10 @@ static void copy_file(char *sdir, int sm
|
||||
|
||||
snprintf(msgnums, sizeof(msgnums), "%d", smsg);
|
||||
snprintf(msgnumd, sizeof(msgnumd), "%d", dmsg);
|
||||
- snprintf(sql, sizeof(sql), "INSERT INTO %s (dir, msgnum, msg_id, context, macrocontext, callerid, origtime, duration, recording, flag, mailboxuser, mailboxcontext) SELECT ?,?,?,context,macrocontext,callerid,origtime,duration,recording,flag,?,? FROM %s WHERE dir=? AND msgnum=?", odbc_table, odbc_table);
|
||||
+
|
||||
+ get_id_callid(sdir, smsg, mid, callid);
|
||||
+
|
||||
+ snprintf(sql, sizeof(sql), "INSERT INTO %s (dir, msgnum, msg_id, context, macrocontext, callerid, origtime, duration, recording, flag, mailboxuser, mailboxcontext, call_id) SELECT ?,?,?,context,macrocontext,callerid,origtime,duration,recording,flag,?,?,? FROM %s WHERE dir=? AND msgnum=?", odbc_table, odbc_table);
|
||||
stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
|
||||
if (!stmt)
|
||||
ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s] (You probably don't have MySQL 4.1 or later installed)\n\n", sql);
|
||||
@@ -4620,7 +4672,7 @@ static int store_file(const char *dir, c
|
||||
idata.data = fdm;
|
||||
idata.datalen = idata.indlen = fdlen;
|
||||
|
||||
- if ((call_id = pbx_builtin_getvar_helper(chan, "SIPCALLID"))) {
|
||||
+ if ((call_id = pbx_builtin_getvar_helper(chan, "IDENTIFIER"))) {
|
||||
if (!ast_strlen_zero(call_id))
|
||||
idata.call_id = ast_strdupa(call_id);
|
||||
}
|
||||
@@ -6261,8 +6313,9 @@ static int inboxcount(const char *mailbo
|
||||
return res;
|
||||
}
|
||||
|
||||
-static void run_externnotify(const char *context, const char *extension, const char *flag, const char *dialed_num, int msgnum, char *cidnum, struct timeval *msg_time, int duration, char *timezonename)
|
||||
+static void run_externnotify(const char *context, const char *extension, const char *flag, const char *dialed_num, int msgnum, char *cidnum, struct timeval *msg_time, int duration, char *timezonename, vm_node *vm_actions)
|
||||
{
|
||||
+ struct timeval timetemp;
|
||||
char arguments[2048];
|
||||
char date[256];
|
||||
struct ast_tm tm;
|
||||
@@ -6305,14 +6358,39 @@ static void run_externnotify(const char
|
||||
} else if (ast_strlen_zero(number) || !strcmp(extension, number)) {
|
||||
ast_log(AST_LOG_WARNING, "Missing user number to run externnotify on context '%s'\n", ext_context);
|
||||
} else {
|
||||
- if (msg_time) {
|
||||
- ast_localtime(msg_time, &tm, timezonename);
|
||||
- ast_strftime(date, sizeof(date), "%Y-%m-%dT%H:%M:%S%z", &tm);
|
||||
- snprintf(arguments, sizeof(arguments), "%s %s %s %s %d %d %d %d %s %s %d &",
|
||||
+ int size = vm_actions->size;
|
||||
+ char actions[1024];
|
||||
+ memset(actions, 0, sizeof(actions));
|
||||
+
|
||||
+ for (int i = 0; i < size; i++)
|
||||
+ {
|
||||
+ if (strlen(vm_actions[i].id) > 0) {
|
||||
+ char temp[301]="";
|
||||
+ snprintf(temp, sizeof(temp),
|
||||
+ "%c %s %s ",
|
||||
+ vm_actions[i].action,
|
||||
+ vm_actions[i].id,
|
||||
+ strlen(vm_actions[i].callid)>0?vm_actions[i].callid:"nocallid");
|
||||
+ temp[sizeof(temp) - 1] = '\0';
|
||||
+ strncat(actions, temp, sizeof(actions) - strlen(actions) - 1);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (msg_time || actions[0] != '\0') {
|
||||
+ if (!msg_time && gettimeofday(&timetemp, NULL) != -1){
|
||||
+ msg_time = &timetemp;
|
||||
+ }
|
||||
+ if (msg_time) {
|
||||
+ ast_localtime(msg_time, &tm, timezonename);
|
||||
+ ast_strftime(date, sizeof(date), "%Y-%m-%dT%H:%M:%S%z", &tm);
|
||||
+ } else {
|
||||
+ strncpy(date, "00-00-00T00:00:00", sizeof(date));
|
||||
+ }
|
||||
+ snprintf(arguments, sizeof(arguments), "%s %s %s %s %d %d %d %d %s %s %d %s &",
|
||||
externnotify, S_OR(context, "\"\""),
|
||||
number, extension, newvoicemails,
|
||||
oldvoicemails, urgentvoicemails,
|
||||
- msgnum, cidnum, date, duration);
|
||||
+ msgnum, (cidnum == NULL?"-1":cidnum), date, duration, actions);
|
||||
} else { // original short notify
|
||||
snprintf(arguments, sizeof(arguments), "%s %s %s %s %d %d %d &",
|
||||
externnotify, S_OR(context, "\"\""),
|
||||
@@ -6398,6 +6476,9 @@ static int msg_create_from_file(struct a
|
||||
const char *category = NULL; /* pointless for now */
|
||||
char msg_id[MSG_ID_LEN];
|
||||
|
||||
+ vm_node messages;
|
||||
+ vm_node_create(&messages, 1);
|
||||
+
|
||||
/* Start by checking to see if the file actually exists... */
|
||||
if (!(ast_fileexists(recdata->recording_file, recdata->recording_ext, NULL))) {
|
||||
ast_log(LOG_ERROR, "File: %s not found.\n", recdata->recording_file);
|
||||
@@ -6654,7 +6735,9 @@ static int msg_create_from_file(struct a
|
||||
if (send_email) { /* We tried and failed. */
|
||||
ast_log(LOG_WARNING, "Failed to allocate dummy channel, email will not be sent\n");
|
||||
}
|
||||
- notify_new_state(recipient);
|
||||
+ vm_node_insert(&messages, 'a', "", "");
|
||||
+ get_id_callid(dir, msgnum, messages.id, messages.callid);
|
||||
+ notify_new_state(recipient, &messages);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8144,6 +8227,74 @@ static void load_vmu_timezone(struct ast
|
||||
return;
|
||||
}
|
||||
|
||||
+static void get_id_callid(char *dir, int msg_num, char *msg_id, char *callid)
|
||||
+{
|
||||
+ int res;
|
||||
+ int x = 0;
|
||||
+ SQLSMALLINT colcount = 0;
|
||||
+ SQLSMALLINT collen;
|
||||
+ SQLSMALLINT datatype;
|
||||
+ SQLSMALLINT decimaldigits;
|
||||
+ SQLSMALLINT nullable;
|
||||
+ SQLHSTMT stmt;
|
||||
+ SQLULEN colsize;
|
||||
+ SQLLEN colsize2;
|
||||
+ char coltitle[256];
|
||||
+ char rowdata[255];
|
||||
+ char sql[PATH_MAX];
|
||||
+ struct odbc_obj *obj;
|
||||
+ char msg_num_str[20];
|
||||
+ char *argv[] = { dir, msg_num_str };
|
||||
+ struct generic_prepare_struct gps = { .sql = sql, .argc = 2, .argv = argv };
|
||||
+
|
||||
+ obj = ast_odbc_request_obj(odbc_database, 0);
|
||||
+ if (!obj) {
|
||||
+ ast_log(LOG_WARNING, "Unable to quary for CallId 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), "SELECT id, msg_id, call_id FROM %s 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);
|
||||
+ goto bail;
|
||||
+ }
|
||||
+
|
||||
+ res = SQLFetch(stmt);
|
||||
+ if (!SQL_SUCCEEDED(res)) {
|
||||
+ if (res != SQL_NO_DATA) {
|
||||
+ ast_log(AST_LOG_WARNING, "SQL Fetch error!\n[%s]\n\n", sql);
|
||||
+ }
|
||||
+ goto bail_with_handle;
|
||||
+ }
|
||||
+
|
||||
+ res = SQLNumResultCols(stmt, &colcount);
|
||||
+ if (!SQL_SUCCEEDED(res)) {
|
||||
+ ast_log(AST_LOG_WARNING, "SQL Column Count error!\n[%s]\n\n", sql);
|
||||
+ goto bail_with_handle;
|
||||
+ }
|
||||
+
|
||||
+ for (x = 0; x < colcount; x++) {
|
||||
+ rowdata[0] = '\0';
|
||||
+ collen = sizeof(coltitle);
|
||||
+ res = SQLDescribeCol(stmt, x + 1, (unsigned char *) coltitle, sizeof(coltitle), &collen,
|
||||
+ &datatype, &colsize, &decimaldigits, &nullable);
|
||||
+ res = SQLGetData(stmt, x + 1, SQL_C_CHAR, rowdata, sizeof(rowdata), NULL);
|
||||
+ if (strcasecmp(coltitle, "call_id") ==0) {
|
||||
+ snprintf(callid, 256, "%s", rowdata);
|
||||
+ } else if (strcasecmp(coltitle, "id") == 0) {
|
||||
+ snprintf(msg_id, 256, "%s", rowdata);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+bail_with_handle:
|
||||
+ SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
||||
+bail:
|
||||
+ ast_odbc_release_obj(obj);
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
/*!
|
||||
* \brief Sends email notification that a user has a new voicemail waiting for them.
|
||||
* \param chan
|
||||
@@ -8167,6 +8318,9 @@ static int notify_new_message(struct ast
|
||||
struct timeval msg_time = ast_tvnow();
|
||||
struct vm_zone *tz = get_vmu_timezone(vmu);
|
||||
|
||||
+ vm_node messages;
|
||||
+ vm_node_create(&messages, 1);
|
||||
+
|
||||
ast_channel_lock(chan);
|
||||
if ((category = pbx_builtin_getvar_helper(chan, "VM_CATEGORY"))) {
|
||||
category = ast_strdupa(category);
|
||||
@@ -8234,7 +8388,9 @@ static int notify_new_message(struct ast
|
||||
ast_app_inboxcount2(ext_context, &urgentmsgs, &newmsgs, &oldmsgs);
|
||||
|
||||
queue_mwi_event(ast_channel_uniqueid(chan), ext_context, urgentmsgs, newmsgs, oldmsgs);
|
||||
- run_externnotify(vmu->context, vmu->mailbox, flag, vmu->dialed_num, msgnum, cidnum, &msg_time, duration, S_COR(tz, tz->timezone, ""));
|
||||
+ vm_node_insert(&messages, 'a', "", "");
|
||||
+ get_id_callid(todir, msgnum, messages.id, messages.callid);
|
||||
+ run_externnotify(vmu->context, vmu->mailbox, flag, vmu->dialed_num, msgnum, cidnum, &msg_time, duration, S_COR(tz, tz->timezone, ""), &messages);
|
||||
|
||||
#ifdef IMAP_STORAGE
|
||||
vm_delete(fn); /* Delete the file, but not the IMAP message */
|
||||
@@ -11406,12 +11562,15 @@ static int vm_execmain(struct ast_channe
|
||||
#ifdef IMAP_STORAGE
|
||||
int deleted = 0;
|
||||
#endif
|
||||
+ int mt = -1;
|
||||
+ vm_node messages[50];
|
||||
+ vm_node_create(messages, 50);
|
||||
|
||||
/* Add the vm_state to the active list and keep it active */
|
||||
vms.curmsg = -1;
|
||||
vms.lastmsg = -1;
|
||||
- vms.deleted = NULL;
|
||||
- vms.heard = NULL;
|
||||
+ vms.deleted = NULL;
|
||||
+ vms.heard = NULL;
|
||||
|
||||
ast_test_suite_event_notify("START", "Message: vm_execmain started");
|
||||
if (ast_channel_state(chan) != AST_STATE_UP) {
|
||||
@@ -11596,6 +11755,11 @@ static int vm_execmain(struct ast_channe
|
||||
if (vms.lastmsg == -1) {
|
||||
in_urgent = 0;
|
||||
cmd = vm_browse_messages(chan, &vms, vmu);
|
||||
+ if (!cmd) {
|
||||
+ vm_node_insert(messages, 'r', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ }
|
||||
res = 0;
|
||||
goto out;
|
||||
}
|
||||
@@ -11671,6 +11835,11 @@ static int vm_execmain(struct ast_channe
|
||||
case '5': /* Play current message */
|
||||
ast_test_suite_event_notify("BROWSE", "Message: browsing message %d\r\nVoicemail: %d", vms.curmsg, vms.curmsg);
|
||||
cmd = vm_browse_messages(chan, &vms, vmu);
|
||||
+ if (!cmd) {
|
||||
+ vm_node_insert(messages, 'r', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ }
|
||||
break;
|
||||
case '2': /* Change folders */
|
||||
folder_change = 1;
|
||||
@@ -11761,6 +11930,11 @@ static int vm_execmain(struct ast_channe
|
||||
if (vms.curmsg > 0) {
|
||||
vms.curmsg--;
|
||||
cmd = play_message(chan, vmu, &vms);
|
||||
+ if (!cmd) {
|
||||
+ vm_node_insert(messages, 'r', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ }
|
||||
} else {
|
||||
/* Check if we were listening to new
|
||||
messages. If so, go to Urgent messages
|
||||
@@ -11783,6 +11957,11 @@ static int vm_execmain(struct ast_channe
|
||||
} else if (ast_test_flag(vmu, VM_MESSAGEWRAP) && vms.lastmsg > 0) {
|
||||
vms.curmsg = vms.lastmsg;
|
||||
cmd = play_message(chan, vmu, &vms);
|
||||
+ if (!cmd) {
|
||||
+ vm_node_insert(messages, 'r', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ }
|
||||
} else {
|
||||
cmd = ast_play_and_wait(chan, "vm-nomore");
|
||||
}
|
||||
@@ -11793,6 +11972,11 @@ static int vm_execmain(struct ast_channe
|
||||
if (vms.curmsg < vms.lastmsg) {
|
||||
vms.curmsg++;
|
||||
cmd = play_message(chan, vmu, &vms);
|
||||
+ if (!cmd) {
|
||||
+ vm_node_insert(messages, 'r', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ }
|
||||
} else {
|
||||
if (in_urgent && vms.newmessages > 0) {
|
||||
/* Check if we were listening to urgent
|
||||
@@ -11814,6 +11998,11 @@ static int vm_execmain(struct ast_channe
|
||||
} else if (ast_test_flag(vmu, VM_MESSAGEWRAP) && vms.lastmsg > 0) {
|
||||
vms.curmsg = 0;
|
||||
cmd = play_message(chan, vmu, &vms);
|
||||
+ if (!cmd) {
|
||||
+ vm_node_insert(messages, 'r', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ }
|
||||
} else {
|
||||
cmd = ast_play_and_wait(chan, "vm-nomore");
|
||||
}
|
||||
@@ -11835,6 +12024,9 @@ static int vm_execmain(struct ast_channe
|
||||
else if (play_folder == 1)
|
||||
vms.oldmessages--;
|
||||
cmd = ast_play_and_wait(chan, "vm-deleted");
|
||||
+ vm_node_insert(messages, 'd', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
} else {
|
||||
if (play_folder == 0) {
|
||||
if (in_urgent) {
|
||||
@@ -11846,14 +12038,27 @@ static int vm_execmain(struct ast_channe
|
||||
else if (play_folder == 1)
|
||||
vms.oldmessages++;
|
||||
cmd = ast_play_and_wait(chan, "vm-undeleted");
|
||||
+ vm_node_insert(messages, 'u', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
}
|
||||
if (ast_test_flag(vmu, VM_SKIPAFTERCMD)) {
|
||||
if (vms.curmsg < vms.lastmsg) {
|
||||
vms.curmsg++;
|
||||
cmd = play_message(chan, vmu, &vms);
|
||||
+ if (!cmd) {
|
||||
+ vm_node_insert(messages, 'r', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ }
|
||||
} else if (ast_test_flag(vmu, VM_MESSAGEWRAP) && vms.lastmsg > 0) {
|
||||
vms.curmsg = 0;
|
||||
cmd = play_message(chan, vmu, &vms);
|
||||
+ if (!cmd) {
|
||||
+ vm_node_insert(messages, 'r', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ }
|
||||
} else {
|
||||
/* Check if we were listening to urgent
|
||||
messages. If so, go to regular new messages
|
||||
@@ -11904,6 +12109,29 @@ static int vm_execmain(struct ast_channe
|
||||
} else if (cmd > 0) {
|
||||
box = cmd = cmd - '0';
|
||||
cmd = save_to_folder(vmu, &vms, vms.curmsg, cmd, NULL, 0);
|
||||
+ if (!cmd) {
|
||||
+ switch (box) {
|
||||
+ case 0: // INBOX
|
||||
+ vm_node_insert(messages, 'x', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ break;
|
||||
+ case 1: // OLD
|
||||
+ vm_node_insert(messages, 'r', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ break;
|
||||
+ case 10: // OLD
|
||||
+ vm_node_insert(messages, 'd', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ break;
|
||||
+ default:
|
||||
+ vm_node_insert(messages, 'm', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ }
|
||||
+ }
|
||||
if (cmd == ERROR_LOCK_PATH) {
|
||||
res = cmd;
|
||||
goto out;
|
||||
@@ -11935,9 +12163,19 @@ static int vm_execmain(struct ast_channe
|
||||
if (vms.curmsg < vms.lastmsg) {
|
||||
vms.curmsg++;
|
||||
cmd = play_message(chan, vmu, &vms);
|
||||
+ if (!cmd) {
|
||||
+ vm_node_insert(messages, 'r', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ }
|
||||
} else if (ast_test_flag(vmu, VM_MESSAGEWRAP) && vms.lastmsg > 0) {
|
||||
vms.curmsg = 0;
|
||||
cmd = play_message(chan, vmu, &vms);
|
||||
+ if (!cmd) {
|
||||
+ vm_node_insert(messages, 'r', "", "");
|
||||
+ mt = vm_node_find_avail(messages);
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages[mt].id, messages[mt].callid);
|
||||
+ }
|
||||
} else {
|
||||
/* Check if we were listening to urgent
|
||||
messages. If so, go to regular new messages
|
||||
@@ -12054,7 +12292,7 @@ out:
|
||||
int new = 0, old = 0, urgent = 0;
|
||||
snprintf(ext_context, sizeof(ext_context), "%s@%s", vms.username, vmu->context);
|
||||
/* Urgent flag not passwd to externnotify here */
|
||||
- run_externnotify(vmu->context, vmu->mailbox, NULL, vmu->dialed_num, 0, NULL, NULL, 0, NULL);
|
||||
+ run_externnotify(vmu->context, vmu->mailbox, NULL, vmu->dialed_num, 0, NULL, NULL, 0, NULL, messages);
|
||||
ast_app_inboxcount2(ext_context, &urgent, &new, &old);
|
||||
queue_mwi_event(ast_channel_uniqueid(chan), ext_context, urgent, new, old);
|
||||
}
|
||||
@@ -15975,13 +16213,13 @@ done:
|
||||
return res;
|
||||
}
|
||||
|
||||
-static void notify_new_state(struct ast_vm_user *vmu)
|
||||
+static void notify_new_state(struct ast_vm_user *vmu, vm_node *vm_actions)
|
||||
{
|
||||
int new = 0, old = 0, urgent = 0;
|
||||
char ext_context[1024];
|
||||
|
||||
snprintf(ext_context, sizeof(ext_context), "%s@%s", vmu->mailbox, vmu->context);
|
||||
- run_externnotify(vmu->context, vmu->mailbox, NULL, vmu->dialed_num, 0, NULL, NULL, 0, NULL);
|
||||
+ run_externnotify(vmu->context, vmu->mailbox, NULL, vmu->dialed_num, 0, NULL, NULL, 0, NULL, vm_actions);
|
||||
ast_app_inboxcount2(ext_context, &urgent, &new, &old);
|
||||
queue_mwi_event(NULL, ext_context, urgent, new, old);
|
||||
}
|
||||
@@ -16008,6 +16246,9 @@ static int vm_msg_forward(const char *fr
|
||||
int i;
|
||||
int *msg_nums;
|
||||
|
||||
+ vm_node messages;
|
||||
+ vm_node_create(&messages, 1);
|
||||
+
|
||||
if (ast_strlen_zero(from_mailbox) || ast_strlen_zero(to_mailbox)) {
|
||||
ast_log(LOG_WARNING, "Cannot forward message because either the from or to mailbox was not specified\n");
|
||||
return -1;
|
||||
@@ -16121,7 +16362,9 @@ vm_forward_cleanup:
|
||||
#endif
|
||||
|
||||
if (!res) {
|
||||
- notify_new_state(to_vmu);
|
||||
+ vm_node_insert(&messages, 'f', "", "");
|
||||
+ get_id_callid(from_vms.curdir, from_vms.curmsg, messages.id, messages.callid);
|
||||
+ notify_new_state(to_vmu, (vm_node*) NULL);
|
||||
}
|
||||
|
||||
free_user(vmu);
|
||||
@@ -16145,6 +16388,9 @@ static int vm_msg_move(const char *mailb
|
||||
int i;
|
||||
int *old_msg_nums;
|
||||
|
||||
+ vm_node messages;
|
||||
+ vm_node_create(&messages, 1);
|
||||
+
|
||||
if (ast_strlen_zero(mailbox)) {
|
||||
ast_log(LOG_WARNING, "Cannot move message because no mailbox was specified\n");
|
||||
return -1;
|
||||
@@ -16226,7 +16472,9 @@ vm_move_cleanup:
|
||||
#endif
|
||||
|
||||
if (!res) {
|
||||
- notify_new_state(vmu);
|
||||
+ vm_node_insert(&messages, 'm', "", "");
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages.id, messages.callid);
|
||||
+ notify_new_state(vmu, &messages);
|
||||
}
|
||||
|
||||
free_user(vmu);
|
||||
@@ -16247,6 +16495,9 @@ static int vm_msg_remove(const char *mai
|
||||
int i;
|
||||
int *msg_nums;
|
||||
|
||||
+ vm_node messages;
|
||||
+ vm_node_create(&messages, 1);
|
||||
+
|
||||
if (ast_strlen_zero(mailbox)) {
|
||||
ast_log(LOG_WARNING, "Cannot remove message because no mailbox was specified\n");
|
||||
return -1;
|
||||
@@ -16324,7 +16575,9 @@ vm_remove_cleanup:
|
||||
#endif
|
||||
|
||||
if (!res) {
|
||||
- notify_new_state(vmu);
|
||||
+ vm_node_insert(&messages, 'd', "", "");
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages.id, messages.callid);
|
||||
+ notify_new_state(vmu, &messages);
|
||||
}
|
||||
|
||||
free_user(vmu);
|
||||
@@ -16349,6 +16602,9 @@ static int vm_msg_play(struct ast_channe
|
||||
int duration = 0;
|
||||
const char *value;
|
||||
|
||||
+ vm_node messages;
|
||||
+ vm_node_create(&messages, 1);
|
||||
+
|
||||
if (ast_strlen_zero(mailbox)) {
|
||||
ast_log(LOG_WARNING, "Cannot play message because no mailbox was specified\n");
|
||||
return -1;
|
||||
@@ -16438,7 +16694,9 @@ play2_msg_cleanup:
|
||||
#endif
|
||||
|
||||
if (!res) {
|
||||
- notify_new_state(vmu);
|
||||
+ vm_node_insert(&messages, 'r', "", "");
|
||||
+ get_id_callid(vms.curdir, vms.curmsg, messages.id, messages.callid);
|
||||
+ notify_new_state(vmu, &messages);
|
||||
}
|
||||
|
||||
free_user(vmu);
|
Loading…
Reference in new issue