Multiple revisions 368963,368965

........
  r368963 | qwell | 2012-06-14 13:47:03 -0500 (Thu, 14 Jun 2012) | 14 lines
  
  Remove global symbol requirement from app_voicemail.
  
  This uses the existing "function installation" stuff that already existed for
  other functions, like getting message counts.
  
  (closes issue AST-807)
  (issue AST-901)
  (issue AST-908)
  
  Review: https://reviewboard.asterisk.org/r/1965/
  ........
  
  Merged revisions 368962 from http://svn.asterisk.org/svn/asterisk/certified/branches/1.8.11
........
  r368965 | qwell | 2012-06-14 14:04:57 -0500 (Thu, 14 Jun 2012) | 11 lines
  
  These functions that were moved need to be static.
  
  Also wrap test functions in a #ifdef.
  
  (issue AST-807)
  (issue AST-901)
  (issue AST-908)
  ........
  
  Merged revisions 368964 from http://svn.asterisk.org/svn/asterisk/certified/branches/1.8.11
........

Merged revisions 368963,368965 from http://svn.asterisk.org/svn/asterisk/branches/10-digiumphones


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368966 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Jason Parker
2012-06-14 19:40:11 +00:00
parent 1efe727ed8
commit 6334142050
5 changed files with 464 additions and 279 deletions

View File

@@ -27,6 +27,7 @@
#include "asterisk/strings.h"
#include "asterisk/threadstorage.h"
#include "asterisk/file.h"
#include "asterisk/linkedlists.h"
struct ast_flags64;
@@ -183,6 +184,35 @@ int ast_app_exec_macro(struct ast_channel *autoservice_chan, struct ast_channel
int ast_app_run_macro(struct ast_channel *autoservice_chan,
struct ast_channel *macro_chan, const char *macro_name, const char *macro_args);
enum ast_vm_snapshot_sort_val {
AST_VM_SNAPSHOT_SORT_BY_ID = 0,
AST_VM_SNAPSHOT_SORT_BY_TIME,
};
struct ast_vm_msg_snapshot {
AST_DECLARE_STRING_FIELDS(
AST_STRING_FIELD(msg_id);
AST_STRING_FIELD(callerid);
AST_STRING_FIELD(callerchan);
AST_STRING_FIELD(exten);
AST_STRING_FIELD(origdate);
AST_STRING_FIELD(origtime);
AST_STRING_FIELD(duration);
AST_STRING_FIELD(folder_name);
AST_STRING_FIELD(flag);
);
unsigned int msg_number;
AST_LIST_ENTRY(ast_vm_msg_snapshot) msg;
};
struct ast_vm_mailbox_snapshot {
int total_msg_num;
int folders;
/* Things are not quite as they seem here. This points to an allocated array of lists. */
AST_LIST_HEAD_NOLOCK(, ast_vm_msg_snapshot) *snapshots;
};
/*!
* \since 11
* \brief Run a subroutine on a channel, placing an optional second channel into autoservice.
@@ -229,13 +259,23 @@ int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *s
int ast_app_run_sub(struct ast_channel *autoservice_chan,
struct ast_channel *sub_chan, const char *sub_location, const char *sub_args);
/*!
* \brief Voicemail playback callback function definition
*
* \param channel to play the file back on.
* \param location of file on disk
* \param duration of file in seconds. This will be zero if msg is very short or
* has an unknown duration.
*/
typedef void (ast_vm_msg_play_cb)(struct ast_channel *chan, const char *playfile, int duration);
/*!
* \brief Set voicemail function callbacks
* \param[in] has_voicemail_func set function pointer
* \param[in] inboxcount2_func set function pointer
* \param[in] sayname_func set function pointer
* \param[in] inboxcount_func set function pointer
* \param[in] inboxcount2_func set function pointer
* \param[in] messagecount_func set function pointer
* \param[in] sayname_func set function pointer
* \version 1.6.1 Added inboxcount2_func, sayname_func
*/
void ast_install_vm_functions(int (*has_voicemail_func)(const char *mailbox, const char *folder),
@@ -243,11 +283,52 @@ void ast_install_vm_functions(int (*has_voicemail_func)(const char *mailbox, con
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 (*copy_recording_to_vm_func)(struct ast_vm_recording_data *vm_rec_data));
int (*copy_recording_to_vm_func)(struct ast_vm_recording_data *vm_rec_data),
const char *vm_index_to_foldername(int id),
struct ast_vm_mailbox_snapshot *(*vm_mailbox_snapshot_create)(const char *mailbox,
const char *context,
const char *folder,
int descending,
enum ast_vm_snapshot_sort_val sort_val,
int combine_INBOX_and_OLD),
struct ast_vm_mailbox_snapshot *(*vm_mailbox_snapshot_destroy)(struct ast_vm_mailbox_snapshot *mailbox_snapshot),
int (*vm_msg_move)(const char *mailbox,
const char *context,
size_t num_msgs,
const char *oldfolder,
const char *old_msg_ids[],
const char *newfolder),
int (*vm_msg_remove)(const char *mailbox,
const char *context,
size_t num_msgs,
const char *folder,
const char *msgs[]),
int (*vm_msg_forward)(const char *from_mailbox,
const char *from_context,
const char *from_folder,
const char *to_mailbox,
const char *to_context,
const char *to_folder,
size_t num_msgs,
const char *msg_ids[],
int delete_old),
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));
void ast_uninstall_vm_functions(void);
#ifdef TEST_FRAMEWORK
void ast_install_vm_test_functions(int (*vm_test_destroy_user)(const char *context, const char *mailbox),
int (*vm_test_create_user)(const char *context, const char *mailbox));
void ast_uninstall_vm_test_functions(void);
#endif
/*!
* \brief
* param[in] vm_rec_data Contains data needed to make the recording.
@@ -311,6 +392,131 @@ int ast_app_sayname(struct ast_channel *chan, const char *mailbox, const char *c
*/
int ast_app_messagecount(const char *context, const char *mailbox, const char *folder);
/*!
* \brief Return name of folder, given an id
* \param[in] id Folder id
* \return Name of folder
*/
const char *ast_vm_index_to_foldername(int id);
/*
* \brief Create a snapshot of a mailbox which contains information about every msg.
*
* \param mailbox, the mailbox to look for
* \param context, the context to look for the mailbox in
* \param folder, OPTIONAL. When not NULL only msgs from the specified folder will be included.
* \param desending, list the msgs in descending order rather than ascending order.
* \param combine_INBOX_and_OLD, When this argument is set, The OLD folder will be represented
* in the INBOX folder of the snapshot. This allows the snapshot to represent the
* OLD and INBOX messages in sorted order merged together.
*
* \retval snapshot on success
* \retval NULL on failure
*/
struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_create(const char *mailbox,
const char *context,
const char *folder,
int descending,
enum ast_vm_snapshot_sort_val sort_val,
int combine_INBOX_and_OLD);
/*
* \brief destroy a snapshot
*
* \param mailbox_snapshot The snapshot to destroy.
* \retval NULL
*/
struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot);
/*!
* \brief Move messages from one folder to another
*
* \param mailbox The mailbox to which the folders belong
* \param context The voicemail context for the mailbox
* \param num_msgs The number of messages to move
* \param oldfolder The folder from where messages should be moved
* \param old_msg_nums The message IDs of the messages to move
* \param newfolder The folder to which messages should be moved
* new folder. This array must be num_msgs sized.
*
* \retval -1 Failure
* \retval 0 Success
*/
int ast_vm_msg_move(const char *mailbox,
const char *context,
size_t num_msgs,
const char *oldfolder,
const char *old_msg_ids[],
const char *newfolder);
/*!
* \brief Remove/delete messages from a mailbox folder.
*
* \param mailbox The mailbox from which to delete messages
* \param context The voicemail context for the mailbox
* \param num_msgs The number of messages to delete
* \param folder The folder from which to remove messages
* \param msgs The message IDs of the messages to delete
*
* \retval -1 Failure
* \retval 0 Success
*/
int ast_vm_msg_remove(const char *mailbox,
const char *context,
size_t num_msgs,
const char *folder,
const char *msgs[]);
/*!
* \brief forward a message from one mailbox to another.
*
* \brief from_mailbox The original mailbox the message is being forwarded from
* \brief from_context The voicemail context of the from_mailbox
* \brief from_folder The folder from which the message is being forwarded
* \brief to_mailbox The mailbox to forward the message to
* \brief to_context The voicemail context of the to_mailbox
* \brief to_folder The folder to which the message is being forwarded
* \brief num_msgs The number of messages being forwarded
* \brief msg_ids The message IDs of the messages in from_mailbox to forward
* \brief delete_old If non-zero, the forwarded messages are also deleted from from_mailbox.
* Otherwise, the messages will remain in the from_mailbox.
*
* \retval -1 Failure
* \retval 0 Success
*/
int ast_vm_msg_forward(const char *from_mailbox,
const char *from_context,
const char *from_folder,
const char *to_mailbox,
const char *to_context,
const char *to_folder,
size_t num_msgs,
const char *msg_ids[],
int delete_old);
/*!
* \brief Play a voicemail msg back on a channel.
*
* \param mailbox msg is in.
* \param context of mailbox.
* \param voicemail folder to look in.
* \param message number in the voicemailbox to playback to the channel.
*
* \retval 0 success
* \retval -1 failure
*/
int ast_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);
#ifdef TEST_FRAMEWORK
int ast_vm_test_destroy_user(const char *context, const char *mailbox);
int ast_vm_test_create_user(const char *context, const char *mailbox);
#endif
/*! \brief Safely spawn an external program while closing file descriptors
\note This replaces the \b system call in all Asterisk modules
*/

View File

@@ -1,212 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2011, Digium, Inc.
*
* David Vossel <dvossel@digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*! \file
* \brief Voice Mail API
* \author David Vossel <dvossel@digium.com>
*/
#ifndef _ASTERISK_VM_H
#define _ASTERISK_VM_H
#include "asterisk/stringfields.h"
#include "asterisk/linkedlists.h"
#define AST_VM_FOLDER_NUMBER 12
enum ast_vm_snapshot_sort_val {
AST_VM_SNAPSHOT_SORT_BY_ID = 0,
AST_VM_SNAPSHOT_SORT_BY_TIME,
};
struct ast_vm_msg_snapshot {
AST_DECLARE_STRING_FIELDS(
AST_STRING_FIELD(msg_id);
AST_STRING_FIELD(callerid);
AST_STRING_FIELD(callerchan);
AST_STRING_FIELD(exten);
AST_STRING_FIELD(origdate);
AST_STRING_FIELD(origtime);
AST_STRING_FIELD(duration);
AST_STRING_FIELD(folder_name);
AST_STRING_FIELD(flag);
);
unsigned int msg_number;
AST_LIST_ENTRY(ast_vm_msg_snapshot) msg;
};
struct ast_vm_mailbox_snapshot {
int total_msg_num;
AST_LIST_HEAD_NOLOCK(, ast_vm_msg_snapshot) snapshots[AST_VM_FOLDER_NUMBER];
};
/*
* \brief Create a snapshot of a mailbox which contains information about every msg.
*
* \param mailbox, the mailbox to look for
* \param context, the context to look for the mailbox in
* \param folder, OPTIONAL. When not NULL only msgs from the specified folder will be included.
* \param desending, list the msgs in descending order rather than ascending order.
* \param combine_INBOX_and_OLD, When this argument is set, The OLD folder will be represented
* in the INBOX folder of the snapshot. This allows the snapshot to represent the
* OLD and INBOX messages in sorted order merged together.
*
* \retval snapshot on success
* \retval NULL on failure
*/
struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_create(const char *mailbox,
const char *context,
const char *folder,
int descending,
enum ast_vm_snapshot_sort_val sort_val,
int combine_INBOX_and_OLD);
/*
* \brief destroy a snapshot
*
* \param mailbox_snapshot The snapshot to destroy.
* \retval NULL
*/
struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot);
/*!
* \brief Move messages from one folder to another
*
* \param mailbox The mailbox to which the folders belong
* \param context The voicemail context for the mailbox
* \param num_msgs The number of messages to move
* \param oldfolder The folder from where messages should be moved
* \param old_msg_nums The message IDs of the messages to move
* \param newfolder The folder to which messages should be moved
* \param new_msg_ids[out] An array of message IDs for the messages as they are in the
* new folder. This array must be num_msgs sized.
*
* \retval -1 Failure
* \retval 0 Success
*/
int ast_vm_msg_move(const char *mailbox,
const char *context,
size_t num_msgs,
const char *oldfolder,
const char *old_msg_ids [],
const char *newfolder);
/*!
* \brief Remove/delete messages from a mailbox folder.
*
* \param mailbox The mailbox from which to delete messages
* \param context The voicemail context for the mailbox
* \param num_msgs The number of messages to delete
* \param folder The folder from which to remove messages
* \param msgs The message IDs of the messages to delete
*
* \retval -1 Failure
* \retval 0 Success
*/
int ast_vm_msg_remove(const char *mailbox,
const char *context,
size_t num_msgs,
const char *folder,
const char *msgs []);
/*!
* \brief forward a message from one mailbox to another.
*
* \brief from_mailbox The original mailbox the message is being forwarded from
* \brief from_context The voicemail context of the from_mailbox
* \brief from_folder The folder from which the message is being forwarded
* \brief to_mailbox The mailbox to forward the message to
* \brief to_context The voicemail context of the to_mailbox
* \brief to_folder The voicemail folder to forward the message to
* \brief num_msgs The number of messages being forwarded
* \brief msg_ids The message IDs of the messages in from_mailbox to forward
* \brief delete_old If non-zero, the forwarded messages are also deleted from from_mailbox.
* Otherwise, the messages will remain in the from_mailbox.
*
* \retval -1 Failure
* \retval 0 Success
*/
int ast_vm_msg_forward(const char *from_mailbox,
const char *from_context,
const char *from_folder,
const char *to_mailbox,
const char *to_context,
const char *to_folder,
size_t num_msgs,
const char *msg_ids [],
int delete_old);
/*!
* \brief Voicemail playback callback function definition
*
* \param channel to play the file back on.
* \param location of file on disk
* \param duration of file in seconds. This will be zero if msg is very short or
* has an unknown duration.
*/
typedef void (ast_vm_msg_play_cb)(struct ast_channel *chan, const char *playfile, int duration);
/*!
* \brief Play a voicemail msg back on a channel.
*
* \param mailbox msg is in.
* \param context of mailbox.
* \param voicemail folder to look in.
* \param message number in the voicemailbox to playback to the channel.
*
* \retval 0 success
* \retval -1 failure
*/
int ast_vm_msg_play(struct ast_channel *chan,
const char *mailbox,
const char *context,
const char *folder,
const char *msg_id,
ast_vm_msg_play_cb cb);
/*!
* \brief Get the name of a folder given its numeric index
*
* \param index The integer value of the mailbox.
* \retval "" Invalid index provided
* \retval other The name of the mailbox
*/
const char *ast_vm_index_to_foldername(unsigned int index);
#ifdef TEST_FRAMEWORK
/*!
* \brief Add a user to the voicemail system for test purposes
* \param context The context of the mailbox
* \param mailbox The mailbox for the user
* \retval 0 success
* \retval other failure
*/
int ast_vm_test_create_user(const char *context, const char *mailbox);
/*!
* \brief Dispose of a user. This should be used to destroy a user that was
* previously created using ast_vm_test_create_user
* \param context The context of the mailbox
* \param mailbox The mailbox for the user to destroy
*/
int ast_vm_test_destroy_user(const char *context, const char *mailbox);
#endif
#endif