Asterisk - The Open Source Telephony Project GIT-master-f36a736
Macros | Functions
res_mwi_external.h File Reference

Core external MWI support. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ast_mwi_mailbox_unref(mailbox)   ao2_ref((struct ast_mwi_mailbox_object *) mailbox, -1)
 Convenience unref function for mailbox object. More...
 

Functions

struct ast_mwi_mailbox_objectast_mwi_mailbox_alloc (const char *mailbox_id)
 Allocate an external MWI object. More...
 
struct ast_mwi_mailbox_objectast_mwi_mailbox_copy (const struct ast_mwi_mailbox_object *mailbox)
 Copy the external MWI counts object. More...
 
int ast_mwi_mailbox_delete (const char *mailbox_id)
 Delete matching external MWI object. More...
 
int ast_mwi_mailbox_delete_all (void)
 Delete all external MWI objects. More...
 
int ast_mwi_mailbox_delete_by_regex (const char *regex)
 Delete all external MWI objects selected by the regular expression. More...
 
const struct ast_mwi_mailbox_objectast_mwi_mailbox_get (const char *mailbox_id)
 Get matching external MWI object. More...
 
struct ao2_containerast_mwi_mailbox_get_all (void)
 Get all external MWI objects. More...
 
struct ao2_containerast_mwi_mailbox_get_by_regex (const char *regex)
 Get all external MWI objects selected by the regular expression. More...
 
const char * ast_mwi_mailbox_get_id (const struct ast_mwi_mailbox_object *mailbox)
 Get mailbox id. More...
 
unsigned int ast_mwi_mailbox_get_msgs_new (const struct ast_mwi_mailbox_object *mailbox)
 Get the number of new messages. More...
 
unsigned int ast_mwi_mailbox_get_msgs_old (const struct ast_mwi_mailbox_object *mailbox)
 Get the number of old messages. More...
 
void ast_mwi_mailbox_set_msgs_new (struct ast_mwi_mailbox_object *mailbox, unsigned int num_msgs)
 Set the number of new messages. More...
 
void ast_mwi_mailbox_set_msgs_old (struct ast_mwi_mailbox_object *mailbox, unsigned int num_msgs)
 Set the number of old messages. More...
 
int ast_mwi_mailbox_update (struct ast_mwi_mailbox_object *mailbox)
 Update the external MWI counts with the given object. More...
 

Detailed Description

Core external MWI support.

Author
Richard Mudgett rmudg.nosp@m.ett@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

See Also:

Definition in file res_mwi_external.h.

Macro Definition Documentation

◆ ast_mwi_mailbox_unref

#define ast_mwi_mailbox_unref (   mailbox)    ao2_ref((struct ast_mwi_mailbox_object *) mailbox, -1)

Convenience unref function for mailbox object.

Definition at line 42 of file res_mwi_external.h.

Function Documentation

◆ ast_mwi_mailbox_alloc()

struct ast_mwi_mailbox_object * ast_mwi_mailbox_alloc ( const char *  mailbox_id)

Allocate an external MWI object.

Since
12.1.0
Parameters
mailbox_idName of mailbox.
Returns
object on success. The object is an ao2 object.
Return values
NULLon error.

Definition at line 192 of file res_mwi_external.c.

193{
194 if (ast_strlen_zero(mailbox_id)) {
195 return NULL;
196 }
197
199}
#define MWI_MAILBOX_TYPE
static struct ast_sorcery * mwi_sorcery
#define NULL
Definition: resample.c:96
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
Definition: sorcery.c:1744
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65

References ast_sorcery_alloc(), ast_strlen_zero(), MWI_MAILBOX_TYPE, mwi_sorcery, and NULL.

Referenced by mwi_mailbox_update(), and stasis_app_mailbox_update().

◆ ast_mwi_mailbox_copy()

struct ast_mwi_mailbox_object * ast_mwi_mailbox_copy ( const struct ast_mwi_mailbox_object mailbox)

Copy the external MWI counts object.

Since
12.1.0
Parameters
mailboxWhat to copy.
Returns
copy on success. The object is an ao2 object.
Return values
NULLon error.

Definition at line 201 of file res_mwi_external.c.

202{
204}
void * ast_sorcery_copy(const struct ast_sorcery *sorcery, const void *object)
Create a copy of an object.
Definition: sorcery.c:1778

References ast_sorcery_copy(), voicemailpwcheck::mailbox, and mwi_sorcery.

◆ ast_mwi_mailbox_delete()

int ast_mwi_mailbox_delete ( const char *  mailbox_id)

Delete matching external MWI object.

Since
12.1.0
Parameters
mailbox_idName of mailbox to delete.
Return values
0on success.
-1on error.

Definition at line 302 of file res_mwi_external.c.

303{
304 const struct ast_mwi_mailbox_object *mailbox;
305
306 if (ast_strlen_zero(mailbox_id)) {
307 return -1;
308 }
309
310 mailbox = ast_mwi_mailbox_get(mailbox_id);
311 if (mailbox) {
314 }
315 return 0;
316}
const struct ast_mwi_mailbox_object * ast_mwi_mailbox_get(const char *mailbox_id)
Get matching external MWI object.
static void mwi_mailbox_delete(struct ast_mwi_mailbox_object *mailbox)
#define ast_mwi_mailbox_unref(mailbox)
Convenience unref function for mailbox object.

References ast_mwi_mailbox_get(), ast_mwi_mailbox_unref, ast_strlen_zero(), voicemailpwcheck::mailbox, and mwi_mailbox_delete().

Referenced by mwi_mailbox_delete(), and stasis_app_mailbox_delete().

◆ ast_mwi_mailbox_delete_all()

int ast_mwi_mailbox_delete_all ( void  )

Delete all external MWI objects.

Since
12.1.0
Return values
0on success.
-1on error.

Definition at line 278 of file res_mwi_external.c.

279{
280 struct ao2_container *mailboxes;
281
283 if (mailboxes) {
285 ao2_ref(mailboxes, -1);
286 }
287 return 0;
288}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
static struct stasis_rest_handlers mailboxes
REST handler for /api-docs/mailboxes.json.
static void mwi_mailbox_delete_all(struct ao2_container *mailboxes)
struct ao2_container * ast_mwi_mailbox_get_all(void)
Get all external MWI objects.
Generic container type.

References ao2_ref, ast_mwi_mailbox_get_all(), mailboxes, and mwi_mailbox_delete_all().

◆ ast_mwi_mailbox_delete_by_regex()

int ast_mwi_mailbox_delete_by_regex ( const char *  regex)

Delete all external MWI objects selected by the regular expression.

Since
12.1.0
Parameters
regexRegular expression in extended syntax. (NULL is same as "")
Note
The provided regex is treated as extended case sensitive.
Return values
0on success.
-1on error.

Definition at line 290 of file res_mwi_external.c.

291{
292 struct ao2_container *mailboxes;
293
295 if (mailboxes) {
297 ao2_ref(mailboxes, -1);
298 }
299 return 0;
300}
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
struct ao2_container * ast_mwi_mailbox_get_by_regex(const char *regex)
Get all external MWI objects selected by the regular expression.

References ao2_ref, ast_mwi_mailbox_get_by_regex(), mailboxes, mwi_mailbox_delete_all(), and regex().

Referenced by mwi_mailbox_delete().

◆ ast_mwi_mailbox_get()

const struct ast_mwi_mailbox_object * ast_mwi_mailbox_get ( const char *  mailbox_id)

Get matching external MWI object.

Since
12.1.0
Parameters
mailbox_idName of mailbox to retrieve.
Returns
requested mailbox on success. The object is an ao2 object.
Return values
NULLon error or no mailbox.
Note
The object must be treated as read-only.

Definition at line 183 of file res_mwi_external.c.

184{
185 if (ast_strlen_zero(mailbox_id)) {
186 return NULL;
187 }
188
190}
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
Definition: sorcery.c:1853

References ast_sorcery_retrieve_by_id(), ast_strlen_zero(), MWI_MAILBOX_TYPE, mwi_sorcery, and NULL.

Referenced by ast_mwi_mailbox_delete(), mwi_has_voicemail(), mwi_inboxcount(), mwi_mailbox_get(), mwi_messagecount(), stasis_app_mailbox_delete(), and stasis_app_mailbox_to_json().

◆ ast_mwi_mailbox_get_all()

struct ao2_container * ast_mwi_mailbox_get_all ( void  )

Get all external MWI objects.

Since
12.1.0
Returns
container of struct ast_mwi_mailbox_object on success.
Return values
NULLon error.
Note
The objects in the container must be treated as read-only.

Definition at line 172 of file res_mwi_external.c.

173{
176}
@ AST_RETRIEVE_FLAG_MULTIPLE
Return all matching objects.
Definition: sorcery.h:120
@ AST_RETRIEVE_FLAG_ALL
Perform no matching, return all objects.
Definition: sorcery.h:123
void * ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const char *type, unsigned int flags, struct ast_variable *fields)
Retrieve an object or multiple objects using specific fields.
Definition: sorcery.c:1897

References AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sorcery_retrieve_by_fields(), MWI_MAILBOX_TYPE, mwi_sorcery, and NULL.

Referenced by ast_mwi_mailbox_delete_all(), mwi_initial_events(), and stasis_app_mailboxes_to_json().

◆ ast_mwi_mailbox_get_by_regex()

struct ao2_container * ast_mwi_mailbox_get_by_regex ( const char *  regex)

Get all external MWI objects selected by the regular expression.

Since
12.1.0
Parameters
regexRegular expression in extended syntax. (NULL is same as "")
Note
The provided regex is treated as extended case sensitive.
Returns
container of struct ast_mwi_mailbox_object on success.
Return values
NULLon error.
Note
The objects in the container must be treated as read-only.

Definition at line 178 of file res_mwi_external.c.

179{
181}
struct ao2_container * ast_sorcery_retrieve_by_regex(const struct ast_sorcery *sorcery, const char *type, const char *regex)
Retrieve multiple objects using a regular expression on their id.
Definition: sorcery.c:1954

References ast_sorcery_retrieve_by_regex(), MWI_MAILBOX_TYPE, mwi_sorcery, and regex().

Referenced by ast_mwi_mailbox_delete_by_regex(), and mwi_mailbox_get().

◆ ast_mwi_mailbox_get_id()

const char * ast_mwi_mailbox_get_id ( const struct ast_mwi_mailbox_object mailbox)

Get mailbox id.

Since
12.1.0
Parameters
mailboxObject to get id.
Returns
mailbox_id of the object.
Note
This should never return NULL unless there is a bug in sorcery.

Definition at line 206 of file res_mwi_external.c.

207{
209}
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2317

References ast_sorcery_object_get_id(), and voicemailpwcheck::mailbox.

Referenced by mailbox_to_json(), and mwi_mailbox_get().

◆ ast_mwi_mailbox_get_msgs_new()

unsigned int ast_mwi_mailbox_get_msgs_new ( const struct ast_mwi_mailbox_object mailbox)

Get the number of new messages.

Since
12.1.0
Parameters
mailboxObject to get number of new messages.
Returns
Number of new messages.

Definition at line 211 of file res_mwi_external.c.

212{
213 return mailbox->msgs_new;
214}

References voicemailpwcheck::mailbox.

Referenced by mailbox_to_json(), and mwi_mailbox_get().

◆ ast_mwi_mailbox_get_msgs_old()

unsigned int ast_mwi_mailbox_get_msgs_old ( const struct ast_mwi_mailbox_object mailbox)

Get the number of old messages.

Since
12.1.0
Parameters
mailboxObject to get number of old messages.
Returns
Number of old messages.

Definition at line 216 of file res_mwi_external.c.

217{
218 return mailbox->msgs_old;
219}

References voicemailpwcheck::mailbox.

Referenced by mailbox_to_json(), and mwi_mailbox_get().

◆ ast_mwi_mailbox_set_msgs_new()

void ast_mwi_mailbox_set_msgs_new ( struct ast_mwi_mailbox_object mailbox,
unsigned int  num_msgs 
)

Set the number of new messages.

Since
12.1.0
Parameters
mailboxObject to set number of new messages.
num_msgsNumber of messages to set.

Definition at line 221 of file res_mwi_external.c.

222{
223 mailbox->msgs_new = num_msgs;
224}

References voicemailpwcheck::mailbox.

Referenced by mwi_mailbox_update(), and stasis_app_mailbox_update().

◆ ast_mwi_mailbox_set_msgs_old()

void ast_mwi_mailbox_set_msgs_old ( struct ast_mwi_mailbox_object mailbox,
unsigned int  num_msgs 
)

Set the number of old messages.

Since
12.1.0
Parameters
mailboxObject to set number of old messages.
num_msgsNumber of messages to set.

Definition at line 226 of file res_mwi_external.c.

227{
228 mailbox->msgs_old = num_msgs;
229}

References voicemailpwcheck::mailbox.

Referenced by mwi_mailbox_update(), and stasis_app_mailbox_update().

◆ ast_mwi_mailbox_update()

int ast_mwi_mailbox_update ( struct ast_mwi_mailbox_object mailbox)

Update the external MWI counts with the given object.

Since
12.1.0
Parameters
mailboxWhat to update.
Return values
0on success.
-1on error.

Definition at line 231 of file res_mwi_external.c.

232{
233 const struct ast_mwi_mailbox_object *exists;
234 int res;
235
238 if (exists) {
241 } else {
243 }
244 return res;
245}
static int exists(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
Definition: func_logic.c:157
int ast_sorcery_create(const struct ast_sorcery *sorcery, void *object)
Create and potentially persist an object using an available wizard.
Definition: sorcery.c:2062
int ast_sorcery_update(const struct ast_sorcery *sorcery, void *object)
Update an object.
Definition: sorcery.c:2150

References ast_mwi_mailbox_unref, ast_sorcery_create(), ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_id(), ast_sorcery_update(), exists(), voicemailpwcheck::mailbox, MWI_MAILBOX_TYPE, and mwi_sorcery.

Referenced by mwi_mailbox_update(), and stasis_app_mailbox_update().