From 14a985560ed5830aa3e1b5880890a59a5d0f0c2f Mon Sep 17 00:00:00 2001 From: Mark Michelson Date: Mon, 4 Jun 2012 20:26:12 +0000 Subject: Merge changes dealing with support for Digium phones. Presence support has been added. This is accomplished by allowing for presence hints in addition to device state hints. A dialplan function called PRESENCE_STATE has been added to allow for setting and reading presence. Presence can be transmitted to Digium phones using custom XML elements in a PIDF presence document. Voicemail has new APIs that allow for moving, removing, forwarding, and playing messages. Messages have had a new unique message ID added to them so that the APIs will work reliably. The state of a voicemail mailbox can be obtained using an API that allows one to get a snapshot of the mailbox. A voicemail Dialplan App called VoiceMailPlayMsg has been added to be able to play back a specific message. Configuration hooks have been added. Configuration hooks allow for a piece of code to be executed when a specific configuration file is loaded by a specific module. This is useful for modules that are dependent on the configuration of other modules. chan_sip now has a public method that allows for a custom SIP INFO request to be sent mid-dialog. Digium phones use this in order to display progress bars when files are played. Messaging support has been expanded a bit. The main visible difference is the addition of an AMI action MessageSend. Finally, a ParkingLots manager action has been added in order to get a list of parking lots. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368435 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/app.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 6 deletions(-) (limited to 'main/app.c') diff --git a/main/app.c b/main/app.c index 3d2fa52c3..31484a18d 100644 --- a/main/app.c +++ b/main/app.c @@ -423,18 +423,21 @@ static int (*ast_inboxcount_func)(const char *mailbox, int *newmsgs, int *oldmsg static int (*ast_inboxcount2_func)(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs) = NULL; static int (*ast_sayname_func)(struct ast_channel *chan, const char *mailbox, const char *context) = NULL; static int (*ast_messagecount_func)(const char *context, const char *mailbox, const char *folder) = NULL; +static int (*ast_copy_recording_to_vm_func)(struct ast_vm_recording_data *vm_rec_data) = NULL; void ast_install_vm_functions(int (*has_voicemail_func)(const char *mailbox, const char *folder), int (*inboxcount_func)(const char *mailbox, int *newmsgs, int *oldmsgs), int (*inboxcount2_func)(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs), int (*messagecount_func)(const char *context, const char *mailbox, const char *folder), - int (*sayname_func)(struct ast_channel *chan, const char *mailbox, const char *context)) + int (*sayname_func)(struct ast_channel *chan, const char *mailbox, const char *context), + int (*copy_recording_to_vm_func)(struct ast_vm_recording_data *vm_rec_data)) { ast_has_voicemail_func = has_voicemail_func; ast_inboxcount_func = inboxcount_func; ast_inboxcount2_func = inboxcount2_func; ast_messagecount_func = messagecount_func; ast_sayname_func = sayname_func; + ast_copy_recording_to_vm_func = copy_recording_to_vm_func; } void ast_uninstall_vm_functions(void) @@ -444,6 +447,7 @@ void ast_uninstall_vm_functions(void) ast_inboxcount2_func = NULL; ast_messagecount_func = NULL; ast_sayname_func = NULL; + ast_copy_recording_to_vm_func = NULL; } int ast_app_has_voicemail(const char *mailbox, const char *folder) @@ -459,6 +463,28 @@ int ast_app_has_voicemail(const char *mailbox, const char *folder) return 0; } +/*! + * \internal + * \brief Function used as a callback for ast_copy_recording_to_vm when a real one isn't installed. + * \param vm_rec_data Stores crucial information about the voicemail that will basically just be used + * to figure out what the name of the recipient was supposed to be + */ +int ast_app_copy_recording_to_vm(struct ast_vm_recording_data *vm_rec_data) +{ + static int warned = 0; + + if (ast_copy_recording_to_vm_func) { + return ast_copy_recording_to_vm_func(vm_rec_data); + } + + if (warned++ % 10 == 0) { + ast_verb(3, "copy recording to voicemail called to copy %s.%s to %s@%s, but voicemail not loaded.\n", + vm_rec_data->recording_file, vm_rec_data->recording_ext, + vm_rec_data->mailbox, vm_rec_data->context); + } + + return -1; +} int ast_app_inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs) { @@ -709,10 +735,16 @@ int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, in return res; } -int ast_control_streamfile(struct ast_channel *chan, const char *file, - const char *fwd, const char *rev, - const char *stop, const char *suspend, - const char *restart, int skipms, long *offsetms) +static int control_streamfile(struct ast_channel *chan, + const char *file, + const char *fwd, + const char *rev, + const char *stop, + const char *suspend, + const char *restart, + int skipms, + long *offsetms, + ast_waitstream_fr_cb cb) { char *breaks = NULL; char *end = NULL; @@ -784,7 +816,11 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file, ast_seekstream(ast_channel_stream(chan), offset, SEEK_SET); offset = 0; } - res = ast_waitstream_fr(chan, breaks, fwd, rev, skipms); + if (cb) { + res = ast_waitstream_fr_w_cb(chan, breaks, fwd, rev, skipms, cb); + } else { + res = ast_waitstream_fr(chan, breaks, fwd, rev, skipms); + } } if (res < 1) { @@ -848,6 +884,28 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file, return res; } +int ast_control_streamfile_w_cb(struct ast_channel *chan, + const char *file, + const char *fwd, + const char *rev, + const char *stop, + const char *suspend, + const char *restart, + int skipms, + long *offsetms, + ast_waitstream_fr_cb cb) +{ + return control_streamfile(chan, file, fwd, rev, stop, suspend, restart, skipms, offsetms, cb); +} + +int ast_control_streamfile(struct ast_channel *chan, const char *file, + const char *fwd, const char *rev, + const char *stop, const char *suspend, + const char *restart, int skipms, long *offsetms) +{ + return control_streamfile(chan, file, fwd, rev, stop, suspend, restart, skipms, offsetms, NULL); +} + int ast_play_and_wait(struct ast_channel *chan, const char *fn) { int d = 0; -- cgit v1.2.3