|
|
@ -2373,14 +2373,14 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ODBC_STORAGE
|
|
|
|
#ifdef ODBC_STORAGE
|
|
|
|
struct generic_prepare_struct {
|
|
|
|
struct generic_prepare_struct {
|
|
|
|
char *sql;
|
|
|
|
char *sql;
|
|
|
|
int argc;
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
char **argv;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data)
|
|
|
|
static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct generic_prepare_struct *gps = data;
|
|
|
|
struct generic_prepare_struct *gps = data;
|
|
|
|
int res, i;
|
|
|
|
int res, i;
|
|
|
|
SQLHSTMT stmt;
|
|
|
|
SQLHSTMT stmt;
|
|
|
@ -2400,10 +2400,10 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
SQLBindParameter(stmt, i + 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(gps->argv[i]), 0, gps->argv[i], 0, NULL);
|
|
|
|
SQLBindParameter(stmt, i + 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(gps->argv[i]), 0, gps->argv[i], 0, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
return stmt;
|
|
|
|
return stmt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int retrieve_file(char *dir, int msgnum)
|
|
|
|
static int retrieve_file(char *dir, int msgnum)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
int x = 0;
|
|
|
|
int res;
|
|
|
|
int res;
|
|
|
|
int fd = -1;
|
|
|
|
int fd = -1;
|
|
|
@ -2550,26 +2550,26 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
yuck:
|
|
|
|
yuck:
|
|
|
|
if (f)
|
|
|
|
if (f)
|
|
|
|
fclose(f);
|
|
|
|
fclose(f);
|
|
|
|
if (fd > -1)
|
|
|
|
if (fd > -1)
|
|
|
|
close(fd);
|
|
|
|
close(fd);
|
|
|
|
return x - 1;
|
|
|
|
return x - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
* \brief Determines the highest message number in use for a given user and mailbox folder.
|
|
|
|
* \brief Determines the highest message number in use for a given user and mailbox folder.
|
|
|
|
* \param vmu
|
|
|
|
* \param vmu
|
|
|
|
* \param dir the folder the mailbox folder to look for messages. Used to construct the SQL where clause.
|
|
|
|
* \param dir the folder the mailbox folder to look for messages. Used to construct the SQL where clause.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This method is used when mailboxes are stored in an ODBC back end.
|
|
|
|
* This method is used when mailboxes are stored in an ODBC back end.
|
|
|
|
* Typical use to set the msgnum would be to take the value returned from this method and add one to it.
|
|
|
|
* Typical use to set the msgnum would be to take the value returned from this method and add one to it.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* \return the value of zero or greaterto indicate the last message index in use, -1 to indicate none.
|
|
|
|
* \return the value of zero or greaterto indicate the last message index in use, -1 to indicate none.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static int last_message_index(struct ast_vm_user *vmu, char *dir)
|
|
|
|
static int last_message_index(struct ast_vm_user *vmu, char *dir)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
int x = 0;
|
|
|
|
int res;
|
|
|
|
int res;
|
|
|
|
SQLHSTMT stmt;
|
|
|
|
SQLHSTMT stmt;
|
|
|
@ -2608,12 +2608,12 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
yuck:
|
|
|
|
yuck:
|
|
|
|
return x - 1;
|
|
|
|
return x - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int message_exists(char *dir, int msgnum)
|
|
|
|
static int message_exists(char *dir, int msgnum)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
int x = 0;
|
|
|
|
int res;
|
|
|
|
int res;
|
|
|
|
SQLHSTMT stmt;
|
|
|
|
SQLHSTMT stmt;
|
|
|
@ -2654,17 +2654,17 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
yuck:
|
|
|
|
yuck:
|
|
|
|
return x;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int count_messages(struct ast_vm_user *vmu, char *dir)
|
|
|
|
static int count_messages(struct ast_vm_user *vmu, char *dir)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return last_message_index(vmu, dir) + 1;
|
|
|
|
return last_message_index(vmu, dir) + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void delete_file(char *sdir, int smsg)
|
|
|
|
static void delete_file(char *sdir, int smsg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SQLHSTMT stmt;
|
|
|
|
SQLHSTMT stmt;
|
|
|
|
char sql[PATH_MAX];
|
|
|
|
char sql[PATH_MAX];
|
|
|
|
char msgnums[20];
|
|
|
|
char msgnums[20];
|
|
|
@ -2685,10 +2685,10 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void copy_file(char *sdir, int smsg, char *ddir, int dmsg, char *dmailboxuser, char *dmailboxcontext)
|
|
|
|
static void copy_file(char *sdir, int smsg, char *ddir, int dmsg, char *dmailboxuser, char *dmailboxcontext)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SQLHSTMT stmt;
|
|
|
|
SQLHSTMT stmt;
|
|
|
|
char sql[512];
|
|
|
|
char sql[512];
|
|
|
|
char msgnums[20];
|
|
|
|
char msgnums[20];
|
|
|
@ -2712,9 +2712,9 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct insert_cb_struct {
|
|
|
|
struct insert_cb_struct {
|
|
|
|
char *dir;
|
|
|
|
char *dir;
|
|
|
|
char *msgnum;
|
|
|
|
char *msgnum;
|
|
|
|
void *recording;
|
|
|
|
void *recording;
|
|
|
@ -2729,10 +2729,10 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
char *mailboxcontext;
|
|
|
|
char *mailboxcontext;
|
|
|
|
const char *category;
|
|
|
|
const char *category;
|
|
|
|
char *sql;
|
|
|
|
char *sql;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static SQLHSTMT insert_cb(struct odbc_obj *obj, void *vd)
|
|
|
|
static SQLHSTMT insert_cb(struct odbc_obj *obj, void *vd)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct insert_cb_struct *d = vd;
|
|
|
|
struct insert_cb_struct *d = vd;
|
|
|
|
int res;
|
|
|
|
int res;
|
|
|
|
SQLHSTMT stmt;
|
|
|
|
SQLHSTMT stmt;
|
|
|
@ -2765,10 +2765,10 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return stmt;
|
|
|
|
return stmt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum)
|
|
|
|
static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
int x = 0;
|
|
|
|
int fd = -1;
|
|
|
|
int fd = -1;
|
|
|
|
void *fdm = MAP_FAILED;
|
|
|
|
void *fdm = MAP_FAILED;
|
|
|
@ -2856,7 +2856,7 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
yuck:
|
|
|
|
yuck:
|
|
|
|
if (cfg)
|
|
|
|
if (cfg)
|
|
|
|
ast_config_destroy(cfg);
|
|
|
|
ast_config_destroy(cfg);
|
|
|
|
if (fdm != MAP_FAILED)
|
|
|
|
if (fdm != MAP_FAILED)
|
|
|
@ -2864,10 +2864,10 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
if (fd > -1)
|
|
|
|
if (fd > -1)
|
|
|
|
close(fd);
|
|
|
|
close(fd);
|
|
|
|
return x;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void rename_file(char *sdir, int smsg, char *mailboxuser, char *mailboxcontext, char *ddir, int dmsg)
|
|
|
|
static void rename_file(char *sdir, int smsg, char *mailboxuser, char *mailboxcontext, char *ddir, int dmsg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SQLHSTMT stmt;
|
|
|
|
SQLHSTMT stmt;
|
|
|
|
char sql[PATH_MAX];
|
|
|
|
char sql[PATH_MAX];
|
|
|
|
char msgnums[20];
|
|
|
|
char msgnums[20];
|
|
|
@ -2891,12 +2891,12 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#ifndef IMAP_STORAGE
|
|
|
|
#ifndef IMAP_STORAGE
|
|
|
|
static int count_messages(struct ast_vm_user *vmu, char *dir)
|
|
|
|
static int count_messages(struct ast_vm_user *vmu, char *dir)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Find all .txt files - even if they are not in sequence from 0000 */
|
|
|
|
/* Find all .txt files - even if they are not in sequence from 0000 */
|
|
|
|
|
|
|
|
|
|
|
|
int vmcount = 0;
|
|
|
|
int vmcount = 0;
|
|
|
@ -2916,10 +2916,10 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
ast_unlock_path(dir);
|
|
|
|
ast_unlock_path(dir);
|
|
|
|
|
|
|
|
|
|
|
|
return vmcount;
|
|
|
|
return vmcount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void rename_file(char *sfn, char *dfn)
|
|
|
|
static void rename_file(char *sfn, char *dfn)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char stxt[PATH_MAX];
|
|
|
|
char stxt[PATH_MAX];
|
|
|
|
char dtxt[PATH_MAX];
|
|
|
|
char dtxt[PATH_MAX];
|
|
|
|
ast_filerename(sfn, dfn, NULL);
|
|
|
|
ast_filerename(sfn, dfn, NULL);
|
|
|
@ -2929,16 +2929,16 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
ast_update_realtime("voicemail_data", "filename", sfn, "filename", dfn, NULL);
|
|
|
|
ast_update_realtime("voicemail_data", "filename", sfn, "filename", dfn, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rename(stxt, dtxt);
|
|
|
|
rename(stxt, dtxt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef IMAP_STORAGE
|
|
|
|
#ifndef IMAP_STORAGE
|
|
|
|
/*! \brief
|
|
|
|
/*! \brief
|
|
|
|
* A negative return value indicates an error.
|
|
|
|
* A negative return value indicates an error.
|
|
|
|
* \note Should always be called with a lock already set on dir.
|
|
|
|
* \note Should always be called with a lock already set on dir.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static int last_message_index(struct ast_vm_user *vmu, char *dir)
|
|
|
|
static int last_message_index(struct ast_vm_user *vmu, char *dir)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int x;
|
|
|
|
unsigned char map[MAXMSGLIMIT] = "";
|
|
|
|
unsigned char map[MAXMSGLIMIT] = "";
|
|
|
|
DIR *msgdir;
|
|
|
|
DIR *msgdir;
|
|
|
@ -2962,21 +2962,21 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return x - 1;
|
|
|
|
return x - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if (defined(IMAP_STORAGE) || defined(ODBC_STORAGE))
|
|
|
|
#if (defined(IMAP_STORAGE) || defined(ODBC_STORAGE))
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
* \brief Removes a voicemail message file.
|
|
|
|
* \brief Removes a voicemail message file.
|
|
|
|
* \param dir the path to the message file.
|
|
|
|
* \param dir the path to the message file.
|
|
|
|
* \param msgnum the unique number for the message within the mailbox.
|
|
|
|
* \param msgnum the unique number for the message within the mailbox.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Removes the message content file and the information file.
|
|
|
|
* Removes the message content file and the information file.
|
|
|
|
* This method is used by the DISPOSE macro when mailboxes are stored in an ODBC back end.
|
|
|
|
* This method is used by the DISPOSE macro when mailboxes are stored in an ODBC back end.
|
|
|
|
* Typical use is to clean up after a RETRIEVE operation.
|
|
|
|
* Typical use is to clean up after a RETRIEVE operation.
|
|
|
|
* Note that this does not remove the message from the mailbox folders, to do that we would use delete_file().
|
|
|
|
* Note that this does not remove the message from the mailbox folders, to do that we would use delete_file().
|
|
|
|
* \return zero on success, -1 on error.
|
|
|
|
* \return zero on success, -1 on error.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static int remove_file(char *dir, int msgnum)
|
|
|
|
static int remove_file(char *dir, int msgnum)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char fn[PATH_MAX];
|
|
|
|
char fn[PATH_MAX];
|
|
|
|
char full_fn[PATH_MAX];
|
|
|
|
char full_fn[PATH_MAX];
|
|
|
|
char msgnums[80];
|
|
|
|
char msgnums[80];
|
|
|
@ -2990,7 +2990,7 @@ static void check_quota(struct vm_state *vms, char *mailbox) {
|
|
|
|
snprintf(full_fn, sizeof(full_fn), "%s.txt", fn);
|
|
|
|
snprintf(full_fn, sizeof(full_fn), "%s.txt", fn);
|
|
|
|
unlink(full_fn);
|
|
|
|
unlink(full_fn);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* #ifndef IMAP_STORAGE */
|
|
|
|
#endif /* #ifndef IMAP_STORAGE */
|
|
|
|