summaryrefslogtreecommitdiff
path: root/src/lib/eldbus/eldbus_service.h
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2013-04-23 11:40:05 -0300
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2013-04-23 12:36:29 -0300
commit4e3804041f8e865e007b2a6a0d45a05f39500c3b (patch)
treea493b9c8f8a610d2667651f3ba81819ed16fbe8c /src/lib/eldbus/eldbus_service.h
parent4cf68bf728b5a858ce1c0efac25ded1a49ba8d9d (diff)
Rename edbus->eldbus
git grep -l edbus2 | while read f; do sed -i 's/edbus2/eldbus/g' "$f"; done find . -name '*edbus2*' -exec rename edbus2 eldbus {} \; git grep -l "EDBUS" | while read f; do sed -i 's/EDBUS/ELDBUS/g' "$f"; done git grep -l "EDBus" | while read f; do sed -i 's/EDBus/Eldbus/g' "$f"; done git grep -l "edbus (v2)" | while read f; do sed -i 's/edbus (v2)/eldbus/g' "$f"; done git grep -l "Edbus" | while read f; do sed -i 's/Edbus/Eldbus/g' "$f"; done git grep -l "edbus" | while read f; do sed -i 's/edbus/eldbus/g' "$f"; done find . -name '*edbus*' -exec rename edbus eldbus {} \; find . -name '*EDBus*' -exec rename EDBus Eldbus {} \;
Diffstat (limited to 'src/lib/eldbus/eldbus_service.h')
-rw-r--r--src/lib/eldbus/eldbus_service.h219
1 files changed, 219 insertions, 0 deletions
diff --git a/src/lib/eldbus/eldbus_service.h b/src/lib/eldbus/eldbus_service.h
new file mode 100644
index 0000000..f36903b
--- /dev/null
+++ b/src/lib/eldbus/eldbus_service.h
@@ -0,0 +1,219 @@
1#ifndef ELDBUS_SERVICE_H
2#define ELDBUS_SERVICE_H 1
3
4/**
5 * @defgroup Eldbus_Service Service
6 * @ingroup Eldbus
7 *
8 * @{
9 */
10#define ELDBUS_METHOD_FLAG_DEPRECATED 1
11#define ELDBUS_METHOD_FLAG_NOREPLY (1 << 1)
12
13#define ELDBUS_SIGNAL_FLAG_DEPRECATED 1
14
15#define ELDBUS_PROPERTY_FLAG_DEPRECATED 1
16
17typedef struct _Eldbus_Arg_Info
18{
19 const char *signature;
20 const char *name;
21} Eldbus_Arg_Info;
22
23/**
24 * @brief Used to insert complete types to signature of methods or signals.
25 *
26 * Example: ELDBUS_ARGS({"s", "interface"}, {"s", "property"})
27 * The signature will be "ss" and each string will have a tag name on
28 * introspect XML with the respective name.
29 */
30#define ELDBUS_ARGS(args...) (const Eldbus_Arg_Info[]){ args, { NULL, NULL } }
31
32typedef struct _Eldbus_Service_Interface Eldbus_Service_Interface;
33typedef Eldbus_Message * (*Eldbus_Method_Cb)(const Eldbus_Service_Interface *iface, const Eldbus_Message *message);
34
35/**
36 * Callback function to append property value to message.
37 *
38 * @param iface interface of property
39 * @param propname name of property
40 * @param iter variant iterator in which value must be appended
41 * @param request_msg message that request property
42 * @param error if a error happen you must set a message error to be send caller
43 *
44 * @return EINA_TRUE if success
45 *
46 * @note request_msg and error arguments are only different from NULL when a
47 * client request a property with Properties.Get or Properties.GetAll. Upon
48 * calls to eldbus_service_property_changed(), this callback will also be called.
49 * It's a mistake to return an error in this case because if a property changed,
50 * it must have a new value set and it should be able to be read.
51 */
52typedef Eina_Bool (*Eldbus_Property_Get_Cb)(const Eldbus_Service_Interface *iface, const char *propname, Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg, Eldbus_Message **error);
53
54/**
55 * Callback function to set property value from message.
56 *
57 * @param iface interface of property
58 * @param propname name of property
59 * @param input_msg message call where you have to get value
60 *
61 * @return Message of response, could be a simple method_return, error or NULL to send response later.
62 */
63typedef Eldbus_Message *(*Eldbus_Property_Set_Cb)(const Eldbus_Service_Interface *iface, const char *propname, Eldbus_Message_Iter *iter, const Eldbus_Message *input_msg);
64
65typedef struct _Eldbus_Method
66{
67 const char *member;
68 const Eldbus_Arg_Info *in;
69 const Eldbus_Arg_Info *out;
70 Eldbus_Method_Cb cb;
71 unsigned int flags;
72} Eldbus_Method;
73
74typedef struct _Eldbus_Signal
75{
76 const char *name;
77 const Eldbus_Arg_Info *args;
78 unsigned int flags;
79} Eldbus_Signal;
80
81typedef struct _Eldbus_Property
82{
83 const char *name;
84 const char *type;
85 Eldbus_Property_Get_Cb get_func;
86 Eldbus_Property_Set_Cb set_func;
87 unsigned int flags;
88} Eldbus_Property;
89
90typedef struct _Eldbus_Service_Interface_Desc
91{
92 const char *interface; /**< interface name */
93 const Eldbus_Method *methods; /**< array of the methods that should be registered in this interface, the last item of array should be filled with NULL */
94 const Eldbus_Signal *signals; /**< array of signal that this interface send, the last item of array should be filled with NULL */
95 const Eldbus_Property *properties; /**< array of property that this interface have, the last item of array should be filled with NULL */
96 const Eldbus_Property_Get_Cb default_get; /**< default get function, if a property don't have a get function this will be used */
97 const Eldbus_Property_Set_Cb default_set; /**< default set function, if a property don't have a set function this will be used */
98} Eldbus_Service_Interface_Desc;
99
100/**
101 * @brief Register an interface in the given path and connection.
102 *
103 * @param conn where the interface should listen
104 * @param path object path
105 * @param desc description of interface
106 *
107 * @return Interface
108 */
109EAPI Eldbus_Service_Interface *eldbus_service_interface_register(Eldbus_Connection *conn, const char *path, const Eldbus_Service_Interface_Desc *desc) EINA_ARG_NONNULL(1, 2, 3);
110
111/**
112 * @brief Unregister a interface.
113 * If this is the last interface of the object path, the object path will be
114 * removed too.
115 */
116EAPI void eldbus_service_interface_unregister(Eldbus_Service_Interface *iface) EINA_ARG_NONNULL(1);
117
118/**
119 * @brief Unregister all interfaces of the object path that this interface belongs
120 * and the object path.
121 */
122EAPI void eldbus_service_object_unregister(Eldbus_Service_Interface *iface) EINA_ARG_NONNULL(1);
123EAPI Eldbus_Connection *eldbus_service_connection_get(const Eldbus_Service_Interface *iface) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
124EAPI const char *eldbus_service_object_path_get(const Eldbus_Service_Interface *iface) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
125
126/**
127 * @brief Emit a signal handler of the interface with non-complex types.
128 * Each signal handler have a internal id, the first signal handler of
129 * interface is = 0 the second = 1 and go on.
130 *
131 * @param iface interface of the signal
132 * @param signal_id id of signal
133 * @param ... values that will be send on signal
134 */
135EAPI Eina_Bool eldbus_service_signal_emit(const Eldbus_Service_Interface *iface, unsigned int signal_id, ...) EINA_ARG_NONNULL(1);
136
137/**
138 * @brief Create signal message.
139 * Each signal handler have a internal id, the first signal handler of
140 * interface is = 0 the second = 1 and go on.
141 * This function is used when the signal has complex types.
142 *
143 * @param iface interface of the signal
144 * @param signal_id id of signal
145 */
146EAPI Eldbus_Message *eldbus_service_signal_new(const Eldbus_Service_Interface *iface, unsigned int signal_id) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
147
148/**
149 * @brief Send a signal message.
150 *
151 * On success this will call eldbus_message_unref() on the @param signal_msg,
152 * which is the intended behavior in 99% of the cases. Remember to increment
153 * the refcount if you want to keep it alive.
154 */
155EAPI Eina_Bool eldbus_service_signal_send(const Eldbus_Service_Interface *iface, Eldbus_Message *signal_msg) EINA_ARG_NONNULL(1, 2);
156
157/**
158 * @brief Store data at object path, this data can be obtained from all interfaces
159 * of the same object.
160 *
161 * @param iface interface that belong to the object path where data will
162 * be stored
163 * @param key to identify data
164 * @param data
165 */
166EAPI void eldbus_service_object_data_set(Eldbus_Service_Interface *iface, const char *key, const void *data) EINA_ARG_NONNULL(1, 2, 3);
167
168/**
169 * @brief Get data stored in object path.
170 *
171 * @param iface interface that belongs to the object path where data are stored
172 * @param key that identify data
173 *
174 * @return pointer to data if found otherwise NULL
175 */
176EAPI void *eldbus_service_object_data_get(const Eldbus_Service_Interface *iface, const char *key) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
177
178/**
179 * @brief Del data stored in object path.
180 *
181 * @param iface interface that belongs to the object path where data are stored
182 * @param key that identify data
183 *
184 * @return pointer to data if found otherwise NULL
185 */
186EAPI void *eldbus_service_object_data_del(Eldbus_Service_Interface *iface, const char *key) EINA_ARG_NONNULL(1, 2);
187
188/**
189 * @brief Add property to list of changed properties
190 * A DBus.PropertiesChanged signal will be sent in an idler with all properties
191 * that have changed.
192 *
193 * @param iface Interface containing the changed property
194 * @param name Property name
195 */
196EAPI Eina_Bool eldbus_service_property_changed(const Eldbus_Service_Interface *iface, const char *name) EINA_ARG_NONNULL(1, 2);
197
198EAPI Eina_Bool eldbus_service_property_invalidate_set(const Eldbus_Service_Interface *iface, const char *name, Eina_Bool is_invalidate) EINA_ARG_NONNULL(1, 2);
199
200/**
201 * Attach ObjectManager interface.
202 *
203 * @param iface ObjectManager will be attach in object path of this interface.
204 * @return EINA_TRUE if success
205 */
206EAPI Eina_Bool eldbus_service_object_manager_attach(Eldbus_Service_Interface *iface) EINA_ARG_NONNULL(1);
207
208/**
209 * Detach ObjectManager interface.
210 *
211 * @param iface ObjectManager of object path of this interface will be detach.
212 * @return EINA_TRUE if success
213 */
214EAPI Eina_Bool eldbus_service_object_manager_detach(Eldbus_Service_Interface *iface) EINA_ARG_NONNULL(1);
215
216/**
217 * @}
218 */
219#endif