summaryrefslogtreecommitdiff
path: root/include/asterisk/stasis_app_device_state.h
blob: 2bc521a04d2b5fc45a043e5502b46c7f055e6fb4 (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
92
93
94
95
/*
 * Asterisk -- An open source telephony toolkit.
 *
 * Copyright (C) 2013, Digium, Inc.
 *
 * Kevin Harwell <kharwell@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_DEVICE_STATE_H
#define _ASTERISK_STASIS_APP_DEVICE_STATE_H

/*! \file
 *
 * \brief Stasis Application Device State API. See \ref res_stasis "Stasis
 * Application API" for detailed documentation.
 *
 * \author Kevin Harwell <kharwell@digium.com>
 * \since 12
 */

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

/*! @{ */

/*!
 * \brief Convert device state to json.
 *
 * \param name the name of the device
 * \param state the device state
 * \return JSON representation.
 * \return \c NULL on error.
 */
struct ast_json *stasis_app_device_state_to_json(
	const char *name, enum ast_device_state state);

/*!
 * \brief Convert device states to json array.
 *
 * \return JSON representation.
 * \return \c NULL on error.
 */
struct ast_json *stasis_app_device_states_to_json(void);

/*! Stasis device state application result codes */
enum stasis_device_state_result {
	/*! Application controlled device state is okay */
	STASIS_DEVICE_STATE_OK,
	/*! The device name is not application controlled */
	STASIS_DEVICE_STATE_NOT_CONTROLLED,
	/*! The application controlled device name is missing */
	STASIS_DEVICE_STATE_MISSING,
	/*! The application controlled device is unknown */
	STASIS_DEVICE_STATE_UNKNOWN,
	/*! The application controlled device has subscribers */
	STASIS_DEVICE_STATE_SUBSCRIBERS
};

/*!
 * \brief Changes the state of a device controlled by ARI.
 *
 * \note The controlled device must be prefixed with 'Stasis:'.
 * \note Implicitly creates the device state.
 *
 * \param name the name of the ARI controlled device
 * \param value a valid device state value
 *
 * \return a stasis device state application result.
 */
enum stasis_device_state_result stasis_app_device_state_update(
	const char *name, const char *value);

/*!
 * \brief Delete a device controlled by ARI.
 *
 * \param name the name of the ARI controlled device
 *
 * \returna stasis device state application result.
 */
enum stasis_device_state_result stasis_app_device_state_delete(
	const char *name);

/*! @} */

#endif /* _ASTERISK_STASIS_APP_DEVICE_STATE_H */