[asterisk-commits] mjordan: branch mjordan/voicemail_refactor_11_10_19 r342660 - in /team/mjorda...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Oct 28 12:41:02 CDT 2011
Author: mjordan
Date: Fri Oct 28 12:40:56 2011
New Revision: 342660
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=342660
Log:
Sync up changes on laptop
Added:
team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_file_backend.c (with props)
team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_imap_backend.c (with props)
team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_odbc_backend.c (with props)
Modified:
team/mjordan/voicemail_refactor_11_10_19/apps/app_voicemail.c
team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/include/voicemail.h
Modified: team/mjordan/voicemail_refactor_11_10_19/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/voicemail_refactor_11_10_19/apps/app_voicemail.c?view=diff&rev=342660&r1=342659&r2=342660
==============================================================================
--- team/mjordan/voicemail_refactor_11_10_19/apps/app_voicemail.c (original)
+++ team/mjordan/voicemail_refactor_11_10_19/apps/app_voicemail.c Fri Oct 28 12:40:56 2011
@@ -124,6 +124,8 @@
#include "asterisk/event.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/test.h"
+
+#include "voicemail/include/voicemail.h"
#ifdef ODBC_STORAGE
#include "asterisk/res_odbc.h"
@@ -521,12 +523,6 @@
OPT_ARG_ARRAY_SIZE = 3,
};
-enum vm_passwordlocation {
- OPT_PWLOC_VOICEMAILCONF = 0,
- OPT_PWLOC_SPOOLDIR = 1,
- OPT_PWLOC_USERSCONF = 2,
-};
-
AST_APP_OPTIONS(vm_app_options, {
AST_APP_OPTION('s', OPT_SILENT),
AST_APP_OPTION('b', OPT_BUSY_GREETING),
@@ -630,53 +626,6 @@
int linelength;
int ateof;
unsigned char iobuf[BASEMAXINLINE];
-};
-
-/*! Structure for linked list of users
- * Use ast_vm_user_destroy() to free one of these structures. */
-struct ast_vm_user {
- char context[AST_MAX_CONTEXT]; /*!< Voicemail context */
- char mailbox[AST_MAX_EXTENSION]; /*!< Mailbox id, unique within vm context */
- char password[80]; /*!< Secret pin code, numbers only */
- char fullname[80]; /*!< Full name, for directory app */
- char email[80]; /*!< E-mail address */
- char *emailsubject; /*!< E-mail subject */
- char *emailbody; /*!< E-mail body */
- char pager[80]; /*!< E-mail address to pager (no attachment) */
- char serveremail[80]; /*!< From: Mail address */
- char mailcmd[160]; /*!< Configurable mail command */
- char language[MAX_LANGUAGE]; /*!< Config: Language setting */
- char zonetag[80]; /*!< Time zone */
- char locale[20]; /*!< The locale (for presentation of date/time) */
- char callback[80];
- char dialout[80];
- char uniqueid[80]; /*!< Unique integer identifier */
- char exit[80];
- char attachfmt[20]; /*!< Attachment format */
- unsigned int flags; /*!< VM_ flags */
- int saydurationm;
- int minsecs; /*!< Minimum number of seconds per message for this mailbox */
- int maxmsg; /*!< Maximum number of msgs per folder for this mailbox */
- int maxdeletedmsg; /*!< Maximum number of deleted msgs saved for this mailbox */
- int maxsecs; /*!< Maximum number of seconds per message for this mailbox */
- int passwordlocation; /*!< Storage location of the password */
-#ifdef IMAP_STORAGE
- char imapuser[80]; /*!< IMAP server login */
- char imappassword[80]; /*!< IMAP server password if authpassword not defined */
- char imapfolder[64]; /*!< IMAP voicemail folder */
- char imapvmshareid[80]; /*!< Shared mailbox ID to use rather than the dialed one */
- int imapversion; /*!< If configuration changes, use the new values */
-#endif
- double volgain; /*!< Volume gain for voicemails sent via email */
- AST_LIST_ENTRY(ast_vm_user) list;
-};
-
-/*! Voicemail time zones */
-struct vm_zone {
- AST_LIST_ENTRY(vm_zone) list;
- char name[80];
- char timezone[80];
- char msg_format[512];
};
#define VMSTATE_MAX_MSG_ARRAY 256
@@ -1016,8 +965,8 @@
*/
static void populate_defaults(struct ast_vm_user *vmu)
{
- ast_copy_flags(vmu, (&globalflags), AST_FLAGS_ALL);
- vmu->passwordlocation = passwordlocation;
+ ast_copy_flags(vmu->flags, (&globalflags), AST_FLAGS_ALL);
+ vmu->password_location = passwordlocation;
if (saydurationminfo) {
vmu->saydurationm = saydurationminfo;
}
@@ -1174,9 +1123,9 @@
sscanf(value, "%30lf", &vmu->volgain);
} else if (!strcasecmp(var, "passwordlocation")) {
if (!strcasecmp(value, "spooldir")) {
- vmu->passwordlocation = OPT_PWLOC_SPOOLDIR;
+ vmu->passwordlocation = VM_OPT_PWLOC_SPOOLDIR;
} else {
- vmu->passwordlocation = OPT_PWLOC_VOICEMAILCONF;
+ vmu->passwordlocation = VM_OPT_PWLOC_VOICEMAILCONF;
}
} else if (!strcasecmp(var, "options")) {
apply_options(vmu, value);
@@ -1524,19 +1473,19 @@
/* check if we should store the secret in the spool directory next to the messages */
switch (vmu->passwordlocation) {
- case OPT_PWLOC_SPOOLDIR:
+ case VM_OPT_PWLOC_SPOOLDIR:
snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, vmu->context, vmu->mailbox);
if (write_password_to_file(secretfn, newpassword) == 0) {
ast_test_suite_event_notify("PASSWORDCHANGED", "Message: secret.conf updated with new password\r\nPasswordSource: secret.conf");
ast_verb(4, "Writing voicemail password to file %s succeeded\n", secretfn);
reset_user_pw(vmu->context, vmu->mailbox, newpassword);
- ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
+ ast_string_field_set(vmu, password, newpassword);
break;
} else {
ast_verb(4, "Writing voicemail password to file %s failed, falling back to config file\n", secretfn);
}
/* Fall-through */
- case OPT_PWLOC_VOICEMAILCONF:
+ case VM_OPT_PWLOC_VOICEMAILCONF:
if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) {
while ((category = ast_category_browse(cfg, category))) {
if (!strcasecmp(category, vmu->context)) {
@@ -1564,13 +1513,13 @@
if (found) {
ast_test_suite_event_notify("PASSWORDCHANGED", "Message: voicemail.conf updated with new password\r\nPasswordSource: voicemail.conf");
reset_user_pw(vmu->context, vmu->mailbox, newpassword);
- ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
+ ast_string_field_set(vmu, password, newpassword);
ast_config_text_file_save(VOICEMAIL_CONFIG, cfg, "AppVoicemail");
break;
}
}
/* Fall-through */
- case OPT_PWLOC_USERSCONF:
+ case VM_OPT_PWLOC_USERSCONF:
/* check users.conf and update the password stored for the mailbox */
/* if no vmsecret entry exists create one. */
if ((cfg = ast_config_load("users.conf", config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) {
@@ -1604,7 +1553,7 @@
if (found) {
ast_test_suite_event_notify("PASSWORDCHANGED", "Message: users.conf updated with new password\r\nPasswordSource: users.conf");
reset_user_pw(vmu->context, vmu->mailbox, newpassword);
- ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
+ ast_string_field_set(vmu, password, newpassword);
ast_config_text_file_save("users.conf", cfg, "AppVoicemail");
}
}
@@ -1618,7 +1567,7 @@
ast_debug(1, "External password: %s\n",buf);
if (!ast_safe_system(buf)) {
ast_test_suite_event_notify("PASSWORDCHANGED", "Message: external script updated with new password\r\nPasswordSource: external");
- ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
+ ast_string_field_set(vmu, password, newpassword);
/* Reset the password in memory, too */
reset_user_pw(vmu->context, vmu->mailbox, newpassword);
}
@@ -4040,7 +3989,7 @@
}
closedir(msgdir);
- for (x = 0; x < vmu->maxmsg; x++) {
+ for (x = 0; x < vmu->max_messages; x++) {
if (map[x] == 1) {
stopcount--;
} else if (map[x] == 0 && !stopcount) {
@@ -10757,7 +10706,7 @@
}
switch (vmu->passwordlocation) {
- case OPT_PWLOC_SPOOLDIR:
+ case VM_OPT_PWLOC_SPOOLDIR:
snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, vmu->context, vmu->mailbox);
read_password_from_file(secretfn, vmu->password, sizeof(vmu->password));
}
@@ -10920,7 +10869,7 @@
ast_test_status_update(test, "Parse failure for volgain option\n");
res = 1;
}
- if (vmu->passwordlocation != OPT_PWLOC_SPOOLDIR) {
+ if (vmu->passwordlocation != VM_OPT_PWLOC_SPOOLDIR) {
ast_test_status_update(test, "Parse failure for passwordlocation option\n");
res = 1;
}
@@ -12293,9 +12242,9 @@
val = "voicemail.conf";
}
if (!(strcmp(val, "spooldir"))) {
- passwordlocation = OPT_PWLOC_SPOOLDIR;
+ passwordlocation = VM_OPT_PWLOC_SPOOLDIR;
} else {
- passwordlocation = OPT_PWLOC_VOICEMAILCONF;
+ passwordlocation = VM_OPT_PWLOC_VOICEMAILCONF;
}
poll_freq = DEFAULT_POLL_FREQ;
@@ -12321,12 +12270,12 @@
populate_defaults(current);
apply_options_full(current, ast_variable_browse(ucfg, cat));
ast_copy_string(current->context, userscontext, sizeof(current->context));
- if (!ast_strlen_zero(current->password) && current->passwordlocation == OPT_PWLOC_VOICEMAILCONF) {
- current->passwordlocation = OPT_PWLOC_USERSCONF;
+ if (!ast_strlen_zero(current->password) && current->passwordlocation == VM_OPT_PWLOC_VOICEMAILCONF) {
+ current->passwordlocation = VM_OPT_PWLOC_USERSCONF;
}
switch (current->passwordlocation) {
- case OPT_PWLOC_SPOOLDIR:
+ case VM_OPT_PWLOC_SPOOLDIR:
snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, current->context, current->mailbox);
read_password_from_file(secretfn, current->password, sizeof(current->password));
}
Modified: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/include/voicemail.h
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/include/voicemail.h?view=diff&rev=342660&r1=342659&r2=342660
==============================================================================
--- team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/include/voicemail.h (original)
+++ team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/include/voicemail.h Fri Oct 28 12:40:56 2011
@@ -72,6 +72,19 @@
VM_OPT_PWCHG_EXTERNAL = (1 << 1),
};
+enum vm_backend_types {
+ VM_OPT_BACKEND_FILE,
+ VM_OPT_BACKEND_ODBC,
+ VM_OPT_BACKEND_IMAP,
+ VM_OPT_BACKEND_REALTIME
+};
+
+struct vm_backend_tech {
+ int (* const load_voicemail_config)(struct ast_config *cfg);
+
+ int (* const load_voicemail_users)(const struct vm_config * const vmcfg, struct ast_config *ucfg, struct ao2_container *user_container);
+};
+
struct vm_sound_config {
AST_DECLARE_STRING_FIELDS(
AST_STRING_FIELD(vm_password);
@@ -149,6 +162,14 @@
AST_STRING_FIELD(timezone);
);
};
+
+/* Stuff we'll need for IMAP:
+ * imapfolder
+ * imapuser
+ * imappassword
+ * imapvmshareid (all strings)
+ * imapversion (int)
+ */
struct vm_config {
double volgain;
@@ -224,4 +245,6 @@
struct vm_timezone *vm_get_timezone(const char *timezone);
+struct vm_backend_tech *vm_get_backend(void);
+
#endif /* VOICEMAIL_H_ */
Added: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_file_backend.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_file_backend.c?view=auto&rev=342660
==============================================================================
--- team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_file_backend.c (added)
+++ team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_file_backend.c Fri Oct 28 12:40:56 2011
@@ -1,0 +1,7 @@
+/*
+ * vm_file_backend.c
+ *
+ * Created on: Oct 26, 2011
+ * Author: mjordan
+ */
+
Propchange: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_file_backend.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_file_backend.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_file_backend.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_imap_backend.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_imap_backend.c?view=auto&rev=342660
==============================================================================
--- team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_imap_backend.c (added)
+++ team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_imap_backend.c Fri Oct 28 12:40:56 2011
@@ -1,0 +1,12 @@
+/*
+ * vm_imap_backend.c
+ *
+ * Created on: Oct 26, 2011
+ * Author: mjordan
+ */
+
+static int imap_load_voicemail_users(const struct vm_config * const vmcfg, struct ast_config *ucfg, struct ao2_container *user_container)
+
+ int (* const load_voicemail_config)(struct vm_config *vmcfg, struct ast_config *cfg);
+
+ int (* const load_voicemail_users)(const struct vm_config * const vmcfg, struct ast_config *ucfg, struct ao2_container *user_container);
Propchange: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_imap_backend.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_imap_backend.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_imap_backend.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_odbc_backend.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_odbc_backend.c?view=auto&rev=342660
==============================================================================
--- team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_odbc_backend.c (added)
+++ team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_odbc_backend.c Fri Oct 28 12:40:56 2011
@@ -1,0 +1,7 @@
+/*
+ * vm_odbc_backend.c
+ *
+ * Created on: Oct 26, 2011
+ * Author: mjordan
+ */
+
Propchange: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_odbc_backend.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_odbc_backend.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_odbc_backend.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the asterisk-commits
mailing list