2012-09-17 13:41:05 -07:00
|
|
|
#ifndef EDBUS_SERVICE_H
|
|
|
|
#define EDBUS_SERVICE_H 1
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup EDBus_Service Service
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#define EDBUS_METHOD_FLAG_DEPRECATED 1
|
|
|
|
#define EDBUS_METHOD_FLAG_NOREPLY (1 << 1)
|
|
|
|
|
|
|
|
#define EDBUS_SIGNAL_FLAG_DEPRECATED 1
|
|
|
|
|
2012-11-09 10:35:14 -08:00
|
|
|
#define EDBUS_PROPERTY_FLAG_DEPRECATED 1
|
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
typedef struct _EDBus_Arg_Info
|
|
|
|
{
|
|
|
|
const char *signature;
|
|
|
|
const char *name;
|
|
|
|
} EDBus_Arg_Info;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Used to insert complete types to signature of methods or signals.
|
|
|
|
*
|
|
|
|
* Example: EDBUS_ARGS({"s", "interface"}, {"s", "property"})
|
|
|
|
* The signature will be "ss" and each string will have a tag name on
|
|
|
|
* introspect XML with the respective name.
|
|
|
|
*/
|
2012-11-02 13:12:27 -07:00
|
|
|
#define EDBUS_ARGS(args...) (const EDBus_Arg_Info[]){ args, { NULL, NULL } }
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
typedef struct _EDBus_Service_Interface EDBus_Service_Interface;
|
|
|
|
typedef EDBus_Message * (*EDBus_Method_Cb)(const EDBus_Service_Interface *iface, const EDBus_Message *message);
|
|
|
|
|
2012-11-16 05:06:53 -08:00
|
|
|
/**
|
|
|
|
* Callback function to append property value to message.
|
|
|
|
*
|
|
|
|
* @param iface interface of property
|
|
|
|
* @param propname name of property
|
|
|
|
* @param iter variant iterator in which value must be appended
|
|
|
|
* @param request_msg message that request property
|
|
|
|
* @param error if a error happen you must set a message error to be send caller
|
|
|
|
*
|
|
|
|
* @return EINA_TRUE if success
|
|
|
|
*
|
|
|
|
* @note request_msg and error arguments are only different from NULL when a
|
|
|
|
* client request a property with Properties.Get or Properties.GetAll. Upon
|
|
|
|
* calls to edbus_service_property_changed(), this callback will also be called.
|
|
|
|
* It's a mistake to return an error in this case because if a property changed,
|
|
|
|
* it must have a new value set and it should be able to be read.
|
|
|
|
*/
|
|
|
|
typedef Eina_Bool (*EDBus_Property_Get_Cb)(const EDBus_Service_Interface *iface, const char *propname, EDBus_Message_Iter *iter, const EDBus_Message *request_msg, EDBus_Message **error);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback function to set property value from message.
|
|
|
|
*
|
|
|
|
* @param iface interface of property
|
|
|
|
* @param propname name of property
|
|
|
|
* @param input_msg message call where you have to get value
|
|
|
|
*
|
|
|
|
* @return Message of response, could be a simple method_return, error or NULL to send response later.
|
|
|
|
*/
|
2012-12-11 11:50:49 -08:00
|
|
|
typedef EDBus_Message *(*EDBus_Property_Set_Cb)(const EDBus_Service_Interface *iface, const char *propname, EDBus_Message_Iter *iter, const EDBus_Message *input_msg);
|
2012-11-01 09:41:11 -07:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
typedef struct _EDBus_Method
|
|
|
|
{
|
|
|
|
const char *member;
|
|
|
|
const EDBus_Arg_Info *in;
|
|
|
|
const EDBus_Arg_Info *out;
|
|
|
|
EDBus_Method_Cb cb;
|
|
|
|
unsigned int flags;
|
|
|
|
} EDBus_Method;
|
|
|
|
|
|
|
|
typedef struct _EDBus_Signal
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
const EDBus_Arg_Info *args;
|
|
|
|
unsigned int flags;
|
|
|
|
} EDBus_Signal;
|
|
|
|
|
2012-11-01 09:41:11 -07:00
|
|
|
typedef struct _EDBus_Property
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
const char *type;
|
|
|
|
EDBus_Property_Get_Cb get_func;
|
2012-11-09 10:35:14 -08:00
|
|
|
EDBus_Property_Set_Cb set_func;
|
|
|
|
unsigned int flags;
|
2012-11-01 09:41:11 -07:00
|
|
|
} EDBus_Property;
|
|
|
|
|
2012-11-01 09:41:04 -07:00
|
|
|
typedef struct _EDBus_Service_Interface_Desc
|
|
|
|
{
|
2012-11-09 10:35:14 -08:00
|
|
|
const char *interface; /**< interface name */
|
|
|
|
const EDBus_Method *methods; /**< array of the methods that should be registered in this interface, the last item of array should be filled with NULL */
|
|
|
|
const EDBus_Signal *signals; /**< array of signal that this interface send, the last item of array should be filled with NULL */
|
|
|
|
const EDBus_Property *properties; /**< array of property that this interface have, the last item of array should be filled with NULL */
|
|
|
|
const EDBus_Property_Get_Cb default_get; /**< default get function, if a property don't have a get function this will be used */
|
|
|
|
const EDBus_Property_Set_Cb default_set; /**< default set function, if a property don't have a set function this will be used */
|
2012-11-01 09:41:04 -07:00
|
|
|
} EDBus_Service_Interface_Desc;
|
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
/**
|
2012-10-02 14:02:16 -07:00
|
|
|
* @brief Register an interface in the given path and connection.
|
2012-09-17 13:41:05 -07:00
|
|
|
*
|
|
|
|
* @param conn where the interface should listen
|
|
|
|
* @param path object path
|
2012-11-09 10:35:14 -08:00
|
|
|
* @param desc description of interface
|
2012-09-17 13:41:05 -07:00
|
|
|
*
|
|
|
|
* @return Interface
|
|
|
|
*/
|
2012-12-11 11:49:33 -08:00
|
|
|
EAPI EDBus_Service_Interface *edbus_service_interface_register(EDBus_Connection *conn, const char *path, const EDBus_Service_Interface_Desc *desc) EINA_ARG_NONNULL(1, 2, 3);
|
2012-11-01 09:41:04 -07:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
/**
|
|
|
|
* @brief Unregister a interface.
|
2012-10-02 14:02:16 -07:00
|
|
|
* If this is the last interface of the object path, the object path will be
|
|
|
|
* removed too.
|
2012-09-17 13:41:05 -07:00
|
|
|
*/
|
2012-12-11 11:49:33 -08:00
|
|
|
EAPI void edbus_service_interface_unregister(EDBus_Service_Interface *iface) EINA_ARG_NONNULL(1);
|
2012-12-17 11:48:45 -08:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
/**
|
|
|
|
* @brief Unregister all interfaces of the object path that this interface belongs
|
|
|
|
* and the object path.
|
|
|
|
*/
|
2012-12-11 11:49:33 -08:00
|
|
|
EAPI void edbus_service_object_unregister(EDBus_Service_Interface *iface) EINA_ARG_NONNULL(1);
|
2012-12-14 08:28:41 -08:00
|
|
|
EAPI EDBus_Connection *edbus_service_connection_get(const EDBus_Service_Interface *iface) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
|
|
|
|
EAPI const char *edbus_service_object_path_get(const EDBus_Service_Interface *iface) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Emit a signal handler of the interface with non-complex types.
|
|
|
|
* Each signal handler have a internal id, the first signal handler of
|
|
|
|
* interface is = 0 the second = 1 and go on.
|
|
|
|
*
|
|
|
|
* @param iface interface of the signal
|
|
|
|
* @param signal_id id of signal
|
|
|
|
* @param ... values that will be send on signal
|
|
|
|
*/
|
2012-12-11 11:51:02 -08:00
|
|
|
EAPI Eina_Bool edbus_service_signal_emit(const EDBus_Service_Interface *iface, unsigned int signal_id, ...) EINA_ARG_NONNULL(1);
|
2012-12-17 11:48:45 -08:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
/**
|
|
|
|
* @brief Create signal message.
|
|
|
|
* Each signal handler have a internal id, the first signal handler of
|
|
|
|
* interface is = 0 the second = 1 and go on.
|
2012-10-02 14:02:16 -07:00
|
|
|
* This function is used when the signal has complex types.
|
2012-09-17 13:41:05 -07:00
|
|
|
*
|
|
|
|
* @param iface interface of the signal
|
|
|
|
* @param signal_id id of signal
|
|
|
|
*/
|
2012-12-11 11:51:02 -08:00
|
|
|
EAPI EDBus_Message *edbus_service_signal_new(const EDBus_Service_Interface *iface, unsigned int signal_id) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
|
2012-12-17 11:48:45 -08:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
/**
|
|
|
|
* @brief Send a signal message.
|
|
|
|
*/
|
2012-12-11 11:51:02 -08:00
|
|
|
EAPI Eina_Bool edbus_service_signal_send(const EDBus_Service_Interface *iface, EDBus_Message *signal_msg) EINA_ARG_NONNULL(1, 2);
|
2012-12-17 11:48:45 -08:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
/**
|
2012-10-02 14:02:16 -07:00
|
|
|
* @brief Store data at object path, this data can be obtained from all interfaces
|
2012-09-17 13:41:05 -07:00
|
|
|
* of the same object.
|
|
|
|
*
|
|
|
|
* @param iface interface that belong to the object path where data will
|
|
|
|
* be stored
|
|
|
|
* @param key to identify data
|
|
|
|
* @param data
|
|
|
|
*/
|
2012-12-11 11:49:33 -08:00
|
|
|
EAPI void edbus_service_object_data_set(EDBus_Service_Interface *iface, const char *key, const void *data) EINA_ARG_NONNULL(1, 2, 3);
|
2012-12-17 11:48:45 -08:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
/**
|
|
|
|
* @brief Get data stored in object path.
|
|
|
|
*
|
2012-10-02 14:02:16 -07:00
|
|
|
* @param iface interface that belongs to the object path where data are stored
|
2012-09-17 13:41:05 -07:00
|
|
|
* @param key that identify data
|
|
|
|
*
|
|
|
|
* @return pointer to data if found otherwise NULL
|
|
|
|
*/
|
2012-12-11 11:49:33 -08:00
|
|
|
EAPI void *edbus_service_object_data_get(const EDBus_Service_Interface *iface, const char *key) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
2012-12-14 08:28:36 -08:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
/**
|
|
|
|
* @brief Del data stored in object path.
|
|
|
|
*
|
2012-10-02 14:02:16 -07:00
|
|
|
* @param iface interface that belongs to the object path where data are stored
|
2012-09-17 13:41:05 -07:00
|
|
|
* @param key that identify data
|
|
|
|
*
|
|
|
|
* @return pointer to data if found otherwise NULL
|
|
|
|
*/
|
2012-12-11 11:49:33 -08:00
|
|
|
EAPI void *edbus_service_object_data_del(EDBus_Service_Interface *iface, const char *key) EINA_ARG_NONNULL(1, 2);
|
2012-11-09 10:35:14 -08:00
|
|
|
|
|
|
|
/**
|
2012-12-14 08:28:27 -08:00
|
|
|
* @brief Add property to list of changed properties
|
|
|
|
* A DBus.PropertiesChanged signal will be sent in an idler with all properties
|
|
|
|
* that have changed.
|
|
|
|
*
|
|
|
|
* @param iface Interface containing the changed property
|
|
|
|
* @param name Property name
|
2012-11-09 10:35:14 -08:00
|
|
|
*/
|
2012-12-11 11:51:02 -08:00
|
|
|
EAPI Eina_Bool edbus_service_property_changed(const EDBus_Service_Interface *iface, const char *name) EINA_ARG_NONNULL(1, 2);
|
2012-11-09 10:35:20 -08:00
|
|
|
|
2012-12-11 11:51:02 -08:00
|
|
|
EAPI Eina_Bool edbus_service_property_invalidate_set(const EDBus_Service_Interface *iface, const char *name, Eina_Bool is_invalidate) EINA_ARG_NONNULL(1, 2);
|
2012-11-16 05:07:14 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Attach ObjectManager interface.
|
|
|
|
*
|
|
|
|
* @param iface ObjectManager will be attach in object path of this interface.
|
|
|
|
* @return EINA_TRUE if success
|
|
|
|
*/
|
2012-12-11 11:49:33 -08:00
|
|
|
EAPI Eina_Bool edbus_service_object_manager_attach(EDBus_Service_Interface *iface) EINA_ARG_NONNULL(1);
|
2012-11-16 05:07:14 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Detach ObjectManager interface.
|
|
|
|
*
|
|
|
|
* @param iface ObjectManager of object path of this interface will be detach.
|
|
|
|
* @return EINA_TRUE if success
|
|
|
|
*/
|
2012-12-11 11:49:33 -08:00
|
|
|
EAPI Eina_Bool edbus_service_object_manager_detach(EDBus_Service_Interface *iface) EINA_ARG_NONNULL(1);
|
2012-12-14 08:28:36 -08:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
#endif
|