You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.7 KiB
122 lines
4.7 KiB
From: Sipwise Development Team <support@sipwise.com>
|
|
Date: Mon, 4 Nov 2024 15:37:29 +0100
|
|
Subject: sipwise_vm_ext_timezone
|
|
|
|
---
|
|
apps/app_voicemail.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 67 insertions(+)
|
|
|
|
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
|
|
index 79cb895..af86182 100644
|
|
--- a/apps/app_voicemail.c
|
|
+++ b/apps/app_voicemail.c
|
|
@@ -1031,6 +1031,8 @@ static int passwordlocation;
|
|
static char aliasescontext[MAX_VM_CONTEXT_LEN];
|
|
static char sw_normalize_user_match[256];
|
|
static char sw_normalize_user_replace[256];
|
|
+static char sw_timezone_table[256];
|
|
+static char sw_default_timezone[80];
|
|
|
|
/*! Poll mailboxes for changes since there is something external to
|
|
* app_voicemail that may change them. */
|
|
@@ -1196,6 +1198,7 @@ static int vm_msg_remove(const char *mailbox, const char *context, size_t num_ms
|
|
static int vm_msg_play(struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb cb);
|
|
|
|
static struct vm_zone *get_vmu_timezone(struct ast_vm_user *vmu);
|
|
+static void load_vmu_timezone(struct ast_vm_user *vmu);
|
|
|
|
#ifdef TEST_FRAMEWORK
|
|
static int vm_test_destroy_user(const char *context, const char *mailbox);
|
|
@@ -1793,6 +1796,8 @@ static void apply_options_full(struct ast_vm_user *retval, struct ast_variable *
|
|
} else if (!strcasecmp(var->name, "mailbox")) { /* granig: but save number for announcement */
|
|
ast_copy_string(retval->dialed_num, var->value, sizeof(retval->dialed_num));
|
|
// ast_log (LOG_DEBUG,"setting dialed_num to '%s'\n", var->value);
|
|
+ } else if (!strcasecmp(var->name, "tz")) {
|
|
+ load_vmu_timezone(retval);
|
|
#ifdef IMAP_STORAGE
|
|
} else if (!strcasecmp(var->name, "imapuser")) {
|
|
ast_copy_string(retval->imapuser, var->value, sizeof(retval->imapuser));
|
|
@@ -8472,6 +8477,58 @@ static struct vm_zone * get_vmu_timezone(struct ast_vm_user *vmu)
|
|
return tz;
|
|
}
|
|
|
|
+static void load_vmu_timezone(struct ast_vm_user *vmu)
|
|
+{
|
|
+ int res;
|
|
+ char *argv[] = { vmu->mailbox };
|
|
+ char sql[PATH_MAX];
|
|
+ struct generic_prepare_struct gps = { .sql = sql, .argc = 1, .argv = argv };
|
|
+ struct odbc_obj *obj = NULL;
|
|
+ SQLHSTMT stmt = NULL;
|
|
+
|
|
+ if (ast_strlen_zero(sw_timezone_table))
|
|
+ return;
|
|
+
|
|
+ snprintf(sql, sizeof(sql),
|
|
+ "select name from %s where uuid = ?", sw_timezone_table);
|
|
+
|
|
+ obj = ast_odbc_request_obj(odbc_database, 0);
|
|
+ stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
|
|
+ if (!stmt) {
|
|
+ ast_log(LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
|
|
+ ast_odbc_release_obj(obj);
|
|
+ return;
|
|
+ }
|
|
+ res = SQLFetch(stmt);
|
|
+ if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
|
+ ast_log(LOG_NOTICE, "Failed to timezone for mailbox '%s'\n", vmu->mailbox);
|
|
+ SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
|
+
|
|
+ ast_odbc_release_obj(obj);
|
|
+ return;
|
|
+ }
|
|
+ res = SQLGetData(stmt, 1, SQL_CHAR, vmu->zonetag, sizeof(vmu->zonetag), NULL);
|
|
+ if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
|
+ if (ast_strlen_zero(sw_default_timezone)) {
|
|
+ ast_log(LOG_DEBUG,
|
|
+ "Undefined timezone for mailbox '%s', local will be used\n",
|
|
+ vmu->mailbox);
|
|
+ ast_copy_string(vmu->zonetag, "", sizeof(vmu->zonetag));
|
|
+ } else {
|
|
+ ast_log(LOG_DEBUG,
|
|
+ "Using default timezone '%s' for mailbox '%s' \n",
|
|
+ sw_default_timezone, vmu->mailbox);
|
|
+ ast_copy_string(vmu->zonetag, sw_default_timezone, sizeof(vmu->zonetag));
|
|
+ }
|
|
+ } else {
|
|
+ ast_log(LOG_DEBUG, "Using timezeone '%s' for mailbox '%s'\n", vmu->zonetag, vmu->mailbox);
|
|
+ }
|
|
+ SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
|
+ ast_odbc_release_obj(obj);
|
|
+
|
|
+ return;
|
|
+}
|
|
+
|
|
/*!
|
|
* \brief Sends email notification that a user has a new voicemail waiting for them.
|
|
* \param chan
|
|
@@ -14367,6 +14424,9 @@ static int actual_load_config(int reload, struct ast_config *cfg, struct ast_con
|
|
long tps_queue_high;
|
|
const char *ast_sw_normalize_user_match = NULL;
|
|
const char *ast_sw_normalize_user_replace = NULL;
|
|
+ const char *ast_sw_timezone_table = NULL;
|
|
+ const char *ast_sw_default_timezone = NULL;
|
|
+
|
|
|
|
#ifdef IMAP_STORAGE
|
|
ast_copy_string(imapparentfolder, "\0", sizeof(imapparentfolder));
|
|
@@ -14444,6 +14504,13 @@ static int actual_load_config(int reload, struct ast_config *cfg, struct ast_con
|
|
sw_normalize_user_replace[0] = '\0';
|
|
}
|
|
|
|
+ /* sipwise timezone table */
|
|
+ if ((ast_sw_timezone_table = ast_variable_retrieve(cfg, "general", "sw_timezone_table")))
|
|
+ ast_copy_string(sw_timezone_table, ast_sw_timezone_table, sizeof(sw_timezone_table));
|
|
+ /* sipwise default timezone */
|
|
+ if ((ast_sw_default_timezone = ast_variable_retrieve(cfg, "general", "sw_default_timezone")))
|
|
+ ast_copy_string(sw_default_timezone, ast_sw_default_timezone, sizeof(sw_default_timezone));
|
|
+
|
|
/* Mail command */
|
|
strcpy(mailcmd, SENDMAIL);
|
|
if ((val = ast_variable_retrieve(cfg, "general", "mailcmd")))
|