summaryrefslogtreecommitdiff
path: root/include/asterisk/stasis_app_mailbox.h
blob: f2a0a567bfb6f1b02388a423c3a260ee3bacc2a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * Asterisk -- An open source telephony toolkit.
 *
 * Copyright (C) 2014, Digium, Inc.
 *
 * Jonathan Rose <jrose@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.
 */

#ifndef _ASTERISK_STASIS_APP_MAILBOX_H
#define _ASTERISK_STASIS_APP_MAILBOX_H

/*! \file
 *
 * \brief Stasis Application Mailbox API. See \ref res_stasis "Stasis
 * Application API" for detailed documentation.
 *
 * \author Jonathan Rose <kharwell@digium.com>
 * \since 12
 */

#include "asterisk/app.h"
#include "asterisk/stasis_app.h"

/*! @{ */

/*! Stasis mailbox operation result codes */
enum stasis_mailbox_result {
	/*! Mailbox operation completed successfully */
	STASIS_MAILBOX_OK,
	/*! Mailbox of the requested name does not exist */
	STASIS_MAILBOX_MISSING,
	/*! Mailbox operation failed internally */
	STASIS_MAILBOX_ERROR,
};

/*!
 * \brief Convert mailbox to JSON
 *
 * \param name the name of the mailbox
 * \param json If the query is successful, this pointer at this address will
 *        be set to the JSON representation of the mailbox
 *
 * \return stasis mailbox result code indicating success or failure and cause
 * \return \c NULL on error.
 */
enum stasis_mailbox_result stasis_app_mailbox_to_json(const char *name, struct ast_json **json);

/*!
 * brief Convert mailboxes to json array
 *
 * \return JSON representation of the mailboxes
 * \return \c NULL on error.
 */
struct ast_json *stasis_app_mailboxes_to_json(void);

/*!
 * \brief Changes the state of a mailbox.
 *
 * \note Implicitly creates the mailbox.
 *
 * \param name The name of the ARI controlled mailbox
 * \param old_messages count of old (read) messages in the mailbox
 * \param new_messages count of new (unread) messages in the mailbox
 *
 * \return 0 if successful
 * \return -1 on internal error.
 */
int stasis_app_mailbox_update(
	const char *name, int old_messages, int new_messages);

/*!
 * \brief Delete a mailbox controlled by ARI.
 *
 * \param name the name of the ARI controlled mailbox
 *
 * \return a stasis mailbox application result
 */
enum stasis_mailbox_result stasis_app_mailbox_delete(
	const char *name);

#endif /* _ASTERISK_STASIS_APP_MAILBOX_H */