Asterisk - The Open Source Telephony Project  18.5.0
res_mwi_external.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2013, Digium, Inc.
5  *
6  * Richard Mudgett <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*!
20  * \file
21  * \brief Core external MWI support.
22  *
23  * \author Richard Mudgett <[email protected]>
24  *
25  * See Also:
26  * \arg \ref AstCREDITS
27  */
28 
29 #ifndef _ASTERISK_RES_MWI_EXTERNAL_H
30 #define _ASTERISK_RES_MWI_EXTERNAL_H
31 
32 #if defined(__cplusplus) || defined(c_plusplus)
33 extern "C"
34 {
35 #endif
36 
37 /* ------------------------------------------------------------------- */
38 
40 
41 /*! \brief Convienience unref function for mailbox object. */
42 #define ast_mwi_mailbox_unref(mailbox) ao2_ref((struct ast_mwi_mailbox_object *) mailbox, -1)
43 
44 /*!
45  * \brief Allocate an external MWI object.
46  * \since 12.1.0
47  *
48  * \param mailbox_id Name of mailbox.
49  *
50  * \retval object on success. The object is an ao2 object.
51  * \retval NULL on error.
52  */
53 struct ast_mwi_mailbox_object *ast_mwi_mailbox_alloc(const char *mailbox_id);
54 
55 /*!
56  * \brief Get mailbox id.
57  * \since 12.1.0
58  *
59  * \param mailbox Object to get id.
60  *
61  * \return mailbox_id of the object.
62  *
63  * \note This should never return NULL unless there is a bug in sorcery.
64  */
65 const char *ast_mwi_mailbox_get_id(const struct ast_mwi_mailbox_object *mailbox);
66 
67 /*!
68  * \brief Get the number of new messages.
69  * \since 12.1.0
70  *
71  * \param mailbox Object to get number of new messages.
72  *
73  * \return Number of new messages.
74  */
76 
77 /*!
78  * \brief Get the number of old messages.
79  * \since 12.1.0
80  *
81  * \param mailbox Object to get number of old messages.
82  *
83  * \return Number of old messages.
84  */
86 
87 /*!
88  * \brief Copy the external MWI counts object.
89  * \since 12.1.0
90  *
91  * \param mailbox What to copy.
92  *
93  * \retval copy on success. The object is an ao2 object.
94  * \retval NULL on error.
95  */
97 
98 /*!
99  * \brief Set the number of new messages.
100  * \since 12.1.0
101  *
102  * \param mailbox Object to set number of new messages.
103  * \param num_msgs Number of messages to set.
104  *
105  * \return Nothing
106  */
107 void ast_mwi_mailbox_set_msgs_new(struct ast_mwi_mailbox_object *mailbox, unsigned int num_msgs);
108 
109 /*!
110  * \brief Set the number of old messages.
111  * \since 12.1.0
112  *
113  * \param mailbox Object to set number of old messages.
114  * \param num_msgs Number of messages to set.
115  *
116  * \return Nothing
117  */
118 void ast_mwi_mailbox_set_msgs_old(struct ast_mwi_mailbox_object *mailbox, unsigned int num_msgs);
119 
120 /*!
121  * \brief Update the external MWI counts with the given object.
122  * \since 12.1.0
123  *
124  * \param mailbox What to update.
125  *
126  * \retval 0 on success.
127  * \retval -1 on error.
128  */
130 
131 /*!
132  * \brief Delete matching external MWI object.
133  * \since 12.1.0
134  *
135  * \param mailbox_id Name of mailbox to delete.
136  *
137  * \retval 0 on success.
138  * \retval -1 on error.
139  */
140 int ast_mwi_mailbox_delete(const char *mailbox_id);
141 
142 /*!
143  * \brief Delete all external MWI objects selected by the regular expression.
144  * \since 12.1.0
145  *
146  * \param regex Regular expression in extended syntax. (NULL is same as "")
147  *
148  * \note The provided regex is treated as extended case sensitive.
149  *
150  * \retval 0 on success.
151  * \retval -1 on error.
152  */
153 int ast_mwi_mailbox_delete_by_regex(const char *regex);
154 
155 /*!
156  * \brief Delete all external MWI objects.
157  * \since 12.1.0
158  *
159  * \retval 0 on success.
160  * \retval -1 on error.
161  */
163 
164 /*!
165  * \brief Get matching external MWI object.
166  * \since 12.1.0
167  *
168  * \param mailbox_id Name of mailbox to retrieve.
169  *
170  * \retval requested mailbox on success. The object is an ao2 object.
171  * \retval NULL on error or no mailbox.
172  *
173  * \note The object must be treated as read-only.
174  */
175 const struct ast_mwi_mailbox_object *ast_mwi_mailbox_get(const char *mailbox_id);
176 
177 /*!
178  * \brief Get all external MWI objects selected by the regular expression.
179  * \since 12.1.0
180  *
181  * \param regex Regular expression in extended syntax. (NULL is same as "")
182  *
183  * \note The provided regex is treated as extended case sensitive.
184  *
185  * \retval container of struct ast_mwi_mailbox_object on success.
186  * \retval NULL on error.
187  *
188  * \note The objects in the container must be treated as read-only.
189  */
191 
192 /*!
193  * \brief Get all external MWI objects.
194  * \since 12.1.0
195  *
196  * \retval container of struct ast_mwi_mailbox_object on success.
197  * \retval NULL on error.
198  *
199  * \note The objects in the container must be treated as read-only.
200  */
202 
203 
204 /* ------------------------------------------------------------------- */
205 
206 #if defined(__cplusplus) || defined(c_plusplus)
207 }
208 #endif
209 
210 #endif /* _ASTERISK_RES_MWI_EXTERNAL_H */
const char * ast_mwi_mailbox_get_id(const struct ast_mwi_mailbox_object *mailbox)
Get mailbox id.
struct ao2_container * ast_mwi_mailbox_get_all(void)
Get all external MWI objects.
struct ast_mwi_mailbox_object * ast_mwi_mailbox_alloc(const char *mailbox_id)
Allocate an external MWI object.
void ast_mwi_mailbox_set_msgs_new(struct ast_mwi_mailbox_object *mailbox, unsigned int num_msgs)
Set the number of new messages.
int ast_mwi_mailbox_delete_all(void)
Delete all external MWI objects.
int ast_mwi_mailbox_update(struct ast_mwi_mailbox_object *mailbox)
Update the external MWI counts with the given object.
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:204
const struct ast_mwi_mailbox_object * ast_mwi_mailbox_get(const char *mailbox_id)
Get matching external MWI object.
int ast_mwi_mailbox_delete(const char *mailbox_id)
Delete matching external MWI object.
struct ast_mwi_mailbox_object * ast_mwi_mailbox_copy(const struct ast_mwi_mailbox_object *mailbox)
Copy the external MWI counts object.
unsigned int ast_mwi_mailbox_get_msgs_new(const struct ast_mwi_mailbox_object *mailbox)
Get the number of new messages.
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_strings.c:948
void ast_mwi_mailbox_set_msgs_old(struct ast_mwi_mailbox_object *mailbox, unsigned int num_msgs)
Set the number of old messages.
Generic container type.
unsigned int ast_mwi_mailbox_get_msgs_old(const struct ast_mwi_mailbox_object *mailbox)
Get the number of old messages.
int ast_mwi_mailbox_delete_by_regex(const char *regex)
Delete all external MWI objects selected by the regular expression.
struct ao2_container * ast_mwi_mailbox_get_by_regex(const char *regex)
Get all external MWI objects selected by the regular expression.