Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
7a837ece
Commit
7a837ece
authored
7 years ago
by
Joshua Colp
Committed by
Gerrit Code Review
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Add new AMI action for app_voicemail"
parents
e411b7d1
daa3a300
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/app_voicemail.c
+173
-79
173 additions, 79 deletions
apps/app_voicemail.c
with
173 additions
and
79 deletions
apps/app_voicemail.c
+
173
−
79
View file @
7a837ece
...
@@ -463,6 +463,23 @@
...
@@ -463,6 +463,23 @@
<description>
<description>
</description>
</description>
</manager>
</manager>
<manager name="VoicemailUserStatus" language="en_US">
<synopsis>
Show the status of given voicemail user's info.
</synopsis>
<syntax>
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
<parameter name="Context" required="true">
<para>The context you want to check.</para>
</parameter>
<parameter name="Mailbox" required="true">
<para>The mailbox you want to check.</para>
</parameter>
</syntax>
<description>
<para>Retrieves the status of the given voicemail user.</para>
</description>
</manager>
<manager name="VoicemailRefresh" language="en_US">
<manager name="VoicemailRefresh" language="en_US">
<synopsis>
<synopsis>
Tell Asterisk to poll mailboxes for a change
Tell Asterisk to poll mailboxes for a change
...
@@ -1105,6 +1122,8 @@ static int write_password_to_file(const char *secretfn, const char *password);
...
@@ -1105,6 +1122,8 @@ static int write_password_to_file(const char *secretfn, const char *password);
static const char *substitute_escapes(const char *value);
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 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);
static int append_vmu_info_astman(struct mansession *s, struct ast_vm_user *vmu, const char* event_name, const char* actionid);
/*!
/*!
* Place a message in the indicated folder
* Place a message in the indicated folder
...
@@ -13222,6 +13241,105 @@ static void stop_poll_thread(void)
...
@@ -13222,6 +13241,105 @@ static void stop_poll_thread(void)
poll_thread = AST_PTHREADT_NULL;
poll_thread = AST_PTHREADT_NULL;
}
}
/*! \brief Append vmu info string into given astman with event_name. */
static int append_vmu_info_astman(
struct mansession *s,
struct ast_vm_user *vmu,
const char* event_name,
const char* actionid
)
{
int new;
int old;
if((s == NULL) || (vmu == NULL) || (event_name == NULL) || (actionid == NULL)) {
ast_log(LOG_ERROR, "Wrong input parameter.");
return 0;
}
/* get mailbox count */
inboxcount(vmu->mailbox, &new, &old);
astman_append(s,
"Event: %s\r\n"
"%s"
"VMContext: %s\r\n"
"VoiceMailbox: %s\r\n"
"Fullname: %s\r\n"
"Email: %s\r\n"
"Pager: %s\r\n"
"ServerEmail: %s\r\n"
"FromString: %s\r\n"
"MailCommand: %s\r\n"
"Language: %s\r\n"
"TimeZone: %s\r\n"
"Callback: %s\r\n"
"Dialout: %s\r\n"
"UniqueID: %s\r\n"
"ExitContext: %s\r\n"
"SayDurationMinimum: %d\r\n"
"SayEnvelope: %s\r\n"
"SayCID: %s\r\n"
"AttachMessage: %s\r\n"
"AttachmentFormat: %s\r\n"
"DeleteMessage: %s\r\n"
"VolumeGain: %.2f\r\n"
"CanReview: %s\r\n"
"CallOperator: %s\r\n"
"MaxMessageCount: %d\r\n"
"MaxMessageLength: %d\r\n"
"NewMessageCount: %d\r\n"
"OldMessageCount: %d\r\n"
#ifdef IMAP_STORAGE
"IMAPUser: %s\r\n"
"IMAPServer: %s\r\n"
"IMAPPort: %s\r\n"
"IMAPFlags: %s\r\n"
#endif
"\r\n",
event_name,
actionid,
vmu->context,
vmu->mailbox,
vmu->fullname,
vmu->email,
vmu->pager,
ast_strlen_zero(vmu->serveremail) ? serveremail : vmu->serveremail,
ast_strlen_zero(vmu->fromstring) ? fromstring : vmu->fromstring,
mailcmd,
vmu->language,
vmu->zonetag,
vmu->callback,
vmu->dialout,
vmu->uniqueid,
vmu->exit,
vmu->saydurationm,
ast_test_flag(vmu, VM_ENVELOPE) ? "Yes" : "No",
ast_test_flag(vmu, VM_SAYCID) ? "Yes" : "No",
ast_test_flag(vmu, VM_ATTACH) ? "Yes" : "No",
vmu->attachfmt,
ast_test_flag(vmu, VM_DELETE) ? "Yes" : "No",
vmu->volgain,
ast_test_flag(vmu, VM_REVIEW) ? "Yes" : "No",
ast_test_flag(vmu, VM_OPERATOR) ? "Yes" : "No",
vmu->maxmsg,
vmu->maxsecs,
new,
old
#ifdef IMAP_STORAGE
,
vmu->imapuser,
vmu->imapserver,
vmu->imapport,
vmu->imapflags
#endif
);
return 1;
}
static int manager_voicemail_refresh(struct mansession *s, const struct message *m)
static int manager_voicemail_refresh(struct mansession *s, const struct message *m)
{
{
const char *context = astman_get_header(m, "Context");
const char *context = astman_get_header(m, "Context");
...
@@ -13258,6 +13376,51 @@ static int manager_voicemail_refresh(struct mansession *s, const struct message
...
@@ -13258,6 +13376,51 @@ static int manager_voicemail_refresh(struct mansession *s, const struct message
return RESULT_SUCCESS;
return RESULT_SUCCESS;
}
}
static int manager_status_voicemail_user(struct mansession *s, const struct message *m)
{
struct ast_vm_user *vmu = NULL;
const char *id = astman_get_header(m, "ActionID");
char actionid[128];
struct ast_vm_user svm;
int ret;
const char *context = astman_get_header(m, "Context");
const char *mailbox = astman_get_header(m, "Mailbox");
if ((ast_strlen_zero(context) || ast_strlen_zero(mailbox))) {
astman_send_error(s, m, "Need 'Context' and 'Mailbox' parameters.");
return RESULT_SUCCESS;
}
actionid[0] = '\0';
if (!ast_strlen_zero(id)) {
snprintf(actionid, sizeof(actionid), "ActionID: %s\r\n", id);
}
/* find user */
memset(&svm, 0, sizeof(svm));
vmu = find_user(&svm, context, mailbox);
if (!vmu) {
/* could not find it */
astman_send_ack(s, m, "There is no voicemail user of the given info.");
return RESULT_SUCCESS;
}
astman_send_listack(s, m, "Voicemail user detail will follow", "start");
/* append vmu info event */
ret = append_vmu_info_astman(s, vmu, "VoicemailUserDetail", actionid);
free_user(vmu);
if(ret == 0) {
ast_log(LOG_ERROR, "Could not append voicemail user info.");
}
astman_send_list_complete_start(s, m, "VoicemailUserDetailComplete", 1);
astman_send_list_complete_end(s);
return RESULT_SUCCESS;
}
/*! \brief Manager list voicemail users command */
/*! \brief Manager list voicemail users command */
static int manager_list_voicemail_users(struct mansession *s, const struct message *m)
static int manager_list_voicemail_users(struct mansession *s, const struct message *m)
{
{
...
@@ -13265,6 +13428,7 @@ static int manager_list_voicemail_users(struct mansession *s, const struct messa
...
@@ -13265,6 +13428,7 @@ static int manager_list_voicemail_users(struct mansession *s, const struct messa
const char *id = astman_get_header(m, "ActionID");
const char *id = astman_get_header(m, "ActionID");
char actionid[128];
char actionid[128];
int num_users = 0;
int num_users = 0;
int ret;
actionid[0] = '\0';
actionid[0] = '\0';
if (!ast_strlen_zero(id)) {
if (!ast_strlen_zero(id)) {
...
@@ -13282,86 +13446,14 @@ static int manager_list_voicemail_users(struct mansession *s, const struct messa
...
@@ -13282,86 +13446,14 @@ static int manager_list_voicemail_users(struct mansession *s, const struct messa
astman_send_listack(s, m, "Voicemail user list will follow", "start");
astman_send_listack(s, m, "Voicemail user list will follow", "start");
AST_LIST_TRAVERSE(&users, vmu, list) {
AST_LIST_TRAVERSE(&users, vmu, list) {
char dirname[256];
/* append vmu info event */
int new, old;
ret = append_vmu_info_astman(s, vmu, "VoicemailUserEntry", actionid);
inboxcount(vmu->mailbox, &new, &old);
if(ret == 0) {
ast_log(LOG_ERROR, "Could not append voicemail user info.");
make_dir(dirname, sizeof(dirname), vmu->context, vmu->mailbox, "INBOX");
continue;
astman_append(s,
}
"Event: VoicemailUserEntry\r\n"
"%s"
"VMContext: %s\r\n"
"VoiceMailbox: %s\r\n"
"Fullname: %s\r\n"
"Email: %s\r\n"
"Pager: %s\r\n"
"ServerEmail: %s\r\n"
"FromString: %s\r\n"
"MailCommand: %s\r\n"
"Language: %s\r\n"
"TimeZone: %s\r\n"
"Callback: %s\r\n"
"Dialout: %s\r\n"
"UniqueID: %s\r\n"
"ExitContext: %s\r\n"
"SayDurationMinimum: %d\r\n"
"SayEnvelope: %s\r\n"
"SayCID: %s\r\n"
"AttachMessage: %s\r\n"
"AttachmentFormat: %s\r\n"
"DeleteMessage: %s\r\n"
"VolumeGain: %.2f\r\n"
"CanReview: %s\r\n"
"CallOperator: %s\r\n"
"MaxMessageCount: %d\r\n"
"MaxMessageLength: %d\r\n"
"NewMessageCount: %d\r\n"
"OldMessageCount: %d\r\n"
#ifdef IMAP_STORAGE
"IMAPUser: %s\r\n"
"IMAPServer: %s\r\n"
"IMAPPort: %s\r\n"
"IMAPFlags: %s\r\n"
#endif
"\r\n",
actionid,
vmu->context,
vmu->mailbox,
vmu->fullname,
vmu->email,
vmu->pager,
ast_strlen_zero(vmu->serveremail) ? serveremail : vmu->serveremail,
ast_strlen_zero(vmu->fromstring) ? fromstring : vmu->fromstring,
mailcmd,
vmu->language,
vmu->zonetag,
vmu->callback,
vmu->dialout,
vmu->uniqueid,
vmu->exit,
vmu->saydurationm,
ast_test_flag(vmu, VM_ENVELOPE) ? "Yes" : "No",
ast_test_flag(vmu, VM_SAYCID) ? "Yes" : "No",
ast_test_flag(vmu, VM_ATTACH) ? "Yes" : "No",
vmu->attachfmt,
ast_test_flag(vmu, VM_DELETE) ? "Yes" : "No",
vmu->volgain,
ast_test_flag(vmu, VM_REVIEW) ? "Yes" : "No",
ast_test_flag(vmu, VM_OPERATOR) ? "Yes" : "No",
vmu->maxmsg,
vmu->maxsecs,
new,
old
#ifdef IMAP_STORAGE
,
vmu->imapuser,
vmu->imapserver,
vmu->imapport,
vmu->imapflags
#endif
);
++num_users;
++num_users;
}
}
astman_send_list_complete_start(s, m, "VoicemailUserEntryComplete", num_users);
astman_send_list_complete_start(s, m, "VoicemailUserEntryComplete", num_users);
astman_send_list_complete_end(s);
astman_send_list_complete_end(s);
...
@@ -14891,6 +14983,7 @@ static int unload_module(void)
...
@@ -14891,6 +14983,7 @@ static int unload_module(void)
res |= ast_custom_function_unregister(&mailbox_exists_acf);
res |= ast_custom_function_unregister(&mailbox_exists_acf);
res |= ast_custom_function_unregister(&vm_info_acf);
res |= ast_custom_function_unregister(&vm_info_acf);
res |= ast_manager_unregister("VoicemailUsersList");
res |= ast_manager_unregister("VoicemailUsersList");
res |= ast_manager_unregister("VoicemailUserStatus");
res |= ast_manager_unregister("VoicemailRefresh");
res |= ast_manager_unregister("VoicemailRefresh");
#ifdef TEST_FRAMEWORK
#ifdef TEST_FRAMEWORK
res |= AST_TEST_UNREGISTER(test_voicemail_vmsayname);
res |= AST_TEST_UNREGISTER(test_voicemail_vmsayname);
...
@@ -14968,6 +15061,7 @@ static int load_module(void)
...
@@ -14968,6 +15061,7 @@ static int load_module(void)
res |= ast_custom_function_register(&mailbox_exists_acf);
res |= ast_custom_function_register(&mailbox_exists_acf);
res |= ast_custom_function_register(&vm_info_acf);
res |= ast_custom_function_register(&vm_info_acf);
res |= ast_manager_register_xml("VoicemailUsersList", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, manager_list_voicemail_users);
res |= ast_manager_register_xml("VoicemailUsersList", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, manager_list_voicemail_users);
res |= ast_manager_register_xml("VoicemailUserStatus", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, manager_status_voicemail_user);
res |= ast_manager_register_xml("VoicemailRefresh", EVENT_FLAG_USER, manager_voicemail_refresh);
res |= ast_manager_register_xml("VoicemailRefresh", EVENT_FLAG_USER, manager_voicemail_refresh);
#ifdef TEST_FRAMEWORK
#ifdef TEST_FRAMEWORK
res |= AST_TEST_REGISTER(test_voicemail_vmsayname);
res |= AST_TEST_REGISTER(test_voicemail_vmsayname);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment