2013-03-06 08:57:01 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
#include "eldbus_private.h"
|
|
|
|
#include "eldbus_private_types.h"
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
#define ELDBUS_CONNECTION_CHECK(conn) \
|
2012-09-17 13:41:05 -07:00
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(conn); \
|
2013-04-23 07:40:05 -07:00
|
|
|
if (!EINA_MAGIC_CHECK(conn, ELDBUS_CONNECTION_MAGIC)) \
|
2012-09-17 13:41:05 -07:00
|
|
|
{ \
|
2013-04-23 07:40:05 -07:00
|
|
|
EINA_MAGIC_FAIL(conn, ELDBUS_CONNECTION_MAGIC); \
|
2012-09-17 13:41:05 -07:00
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(conn->refcount <= 0); \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
#define ELDBUS_CONNECTION_CHECK_RETVAL(conn, retval) \
|
2012-09-17 13:41:05 -07:00
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(conn, retval); \
|
2013-04-23 07:40:05 -07:00
|
|
|
if (!EINA_MAGIC_CHECK(conn, ELDBUS_CONNECTION_MAGIC)) \
|
2012-09-17 13:41:05 -07:00
|
|
|
{ \
|
2013-04-23 07:40:05 -07:00
|
|
|
EINA_MAGIC_FAIL(conn, ELDBUS_CONNECTION_MAGIC); \
|
2012-09-17 13:41:05 -07:00
|
|
|
return retval; \
|
|
|
|
} \
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN_VAL(conn->refcount <= 0, retval); \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
typedef struct _Eldbus_Connection_Context_Event_Cb
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
EINA_INLIST;
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Event_Cb cb;
|
2012-09-17 13:41:05 -07:00
|
|
|
const void *cb_data;
|
|
|
|
Eina_Bool deleted : 1;
|
2013-04-23 07:40:05 -07:00
|
|
|
} Eldbus_Connection_Context_Event_Cb;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
typedef struct _Eldbus_Connection_Context_NOC_Cb
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
EINA_INLIST;
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Name_Owner_Changed_Cb cb;
|
2012-09-17 13:41:05 -07:00
|
|
|
const void *cb_data;
|
|
|
|
Eina_Bool deleted : 1;
|
2016-12-05 18:27:37 -08:00
|
|
|
Ecore_Idle_Enterer *idle_enterer;
|
2012-10-02 14:41:58 -07:00
|
|
|
Eina_Bool allow_initial : 1;
|
2013-04-23 07:40:05 -07:00
|
|
|
} Eldbus_Connection_Context_NOC_Cb;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
typedef struct _Eldbus_Handler_Data
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
EINA_INLIST;
|
|
|
|
int fd;
|
|
|
|
Ecore_Fd_Handler *fd_handler;
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection *conn;
|
2012-09-17 13:41:05 -07:00
|
|
|
DBusWatch *watch;
|
|
|
|
int enabled;
|
2013-04-23 07:40:05 -07:00
|
|
|
} Eldbus_Handler_Data;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
typedef struct _Eldbus_Timeout_Data
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
EINA_INLIST;
|
|
|
|
Ecore_Timer *handler;
|
|
|
|
DBusTimeout *timeout;
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection *conn;
|
2012-09-17 13:41:05 -07:00
|
|
|
int interval;
|
2013-04-23 07:40:05 -07:00
|
|
|
} Eldbus_Timeout_Data;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
static const Eldbus_Version _version = {VMAJ, VMIN, VMIC, VREV};
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API const Eldbus_Version * eldbus_version = &_version;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
static int _eldbus_init_count = 0;
|
|
|
|
int _eldbus_log_dom = -1;
|
2015-01-09 08:20:14 -08:00
|
|
|
int eldbus_model_log_dom = -1;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2020-06-20 02:50:53 -07:00
|
|
|
/* We don't save ELDBUS_CONNECTION_TYPE_UNKNOWN in here so we need room for
|
2013-02-18 04:10:22 -08:00
|
|
|
* last - 1 elements */
|
2013-05-23 13:08:16 -07:00
|
|
|
static void *shared_connections[ELDBUS_CONNECTION_TYPE_LAST - 1];
|
|
|
|
static Eina_Hash *address_connections = NULL;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
static void _eldbus_connection_event_callback_call(Eldbus_Connection *conn, Eldbus_Connection_Event_Type type, const void *event_info);
|
|
|
|
static void _eldbus_connection_context_event_cb_del(Eldbus_Connection_Context_Event *ce, Eldbus_Connection_Context_Event_Cb *ctx);
|
|
|
|
static void eldbus_dispatch_name_owner_change(Eldbus_Connection_Name *cn, const char *old_id);
|
2013-05-23 13:08:16 -07:00
|
|
|
static void _eldbus_connection_free(Eldbus_Connection *conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2018-02-02 13:59:56 -08:00
|
|
|
static void
|
|
|
|
eldbus_fd_handler_del(Eldbus_Handler_Data *hd)
|
|
|
|
{
|
|
|
|
if (!hd->fd_handler) return;
|
|
|
|
|
|
|
|
DBG("free Eldbus_Handler_Data %d", hd->fd);
|
|
|
|
hd->conn->fd_handlers = eina_inlist_remove(hd->conn->fd_handlers,
|
|
|
|
EINA_INLIST_GET(hd));
|
|
|
|
if (hd->fd_handler)
|
|
|
|
{
|
|
|
|
ecore_main_fd_handler_del(hd->fd_handler);
|
|
|
|
hd->fd_handler = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(hd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_eldbus_fork_reset()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i =0; i < ELDBUS_CONNECTION_TYPE_LAST - 1; i++)
|
|
|
|
{
|
|
|
|
Eldbus_Connection *conn = shared_connections[i];
|
|
|
|
if (conn)
|
|
|
|
{
|
|
|
|
Eina_Inlist *list;
|
|
|
|
Eldbus_Handler_Data *fd_handler;
|
|
|
|
|
|
|
|
EINA_INLIST_FOREACH_SAFE(conn->fd_handlers, list, fd_handler)
|
|
|
|
dbus_watch_set_data(fd_handler->watch, NULL, NULL);
|
|
|
|
}
|
|
|
|
shared_connections[i] = NULL;
|
|
|
|
}
|
|
|
|
if (address_connections) eina_hash_free(address_connections);
|
|
|
|
address_connections = NULL;
|
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API int
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_init(void)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-12-22 18:24:49 -08:00
|
|
|
if (_eldbus_init_count++ > 0)
|
|
|
|
return _eldbus_init_count;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
if (!eina_init())
|
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
fputs("Eldbus: Unable to initialize eina\n", stderr);
|
2012-09-17 13:41:05 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-27 10:01:35 -07:00
|
|
|
if (!ecore_init())
|
|
|
|
{
|
|
|
|
fputs("Eldbus: Unable to initialize ecore\n", stderr);
|
|
|
|
eina_shutdown();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
_eldbus_log_dom = eina_log_domain_register("eldbus", EINA_COLOR_BLUE);
|
|
|
|
if (_eldbus_log_dom < 0)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
EINA_LOG_ERR("Unable to create an 'eldbus' log domain");
|
2018-03-27 10:01:35 -07:00
|
|
|
ecore_shutdown();
|
2012-09-17 13:41:05 -07:00
|
|
|
eina_shutdown();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-01-09 08:20:14 -08:00
|
|
|
eldbus_model_log_dom = eina_log_domain_register("eldbus_model", EINA_COLOR_CYAN);
|
|
|
|
if (eldbus_model_log_dom < 0)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Unable to create an 'eldbus_model' log domain");
|
|
|
|
eina_log_domain_unregister(_eldbus_log_dom);
|
|
|
|
_eldbus_log_dom = -1;
|
2018-03-27 10:01:35 -07:00
|
|
|
ecore_shutdown();
|
2015-01-09 08:20:14 -08:00
|
|
|
eina_shutdown();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
eina_magic_string_set(ELDBUS_CONNECTION_MAGIC, "Eldbus_Connection");
|
|
|
|
eina_magic_string_set(ELDBUS_MESSAGE_MAGIC, "Eldbus_Message");
|
|
|
|
eina_magic_string_set(ELDBUS_SIGNAL_HANDLER_MAGIC, "Eldbus_Signal_Handler");
|
|
|
|
eina_magic_string_set(ELDBUS_PENDING_MAGIC, "Eldbus_Pending");
|
|
|
|
eina_magic_string_set(ELDBUS_OBJECT_MAGIC, "Eldbus_Object");
|
|
|
|
eina_magic_string_set(ELDBUS_PROXY_MAGIC, "Eldbus_Proxy");
|
|
|
|
eina_magic_string_set(ELDBUS_MESSAGE_ITERATOR_MAGIC, "Eldbus_Message_Iterator");
|
|
|
|
eina_magic_string_set(ELDBUS_SERVICE_INTERFACE_MAGIC, "Eldbus_Service_Interface");
|
2012-10-29 15:02:36 -07:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
if (!eldbus_message_init()) goto message_failed;
|
|
|
|
if (!eldbus_signal_handler_init()) goto signal_handler_failed;
|
|
|
|
if (!eldbus_pending_init()) goto pending_failed;
|
|
|
|
if (!eldbus_object_init()) goto object_failed;
|
|
|
|
if (!eldbus_proxy_init()) goto proxy_failed;
|
|
|
|
if (!eldbus_service_init()) goto service_failed;
|
2018-02-02 13:59:56 -08:00
|
|
|
ecore_fork_reset_callback_add(_eldbus_fork_reset, NULL);
|
2013-12-22 18:24:49 -08:00
|
|
|
return _eldbus_init_count;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
service_failed:
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_proxy_shutdown();
|
2012-09-17 13:41:05 -07:00
|
|
|
proxy_failed:
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_object_shutdown();
|
2012-09-17 13:41:05 -07:00
|
|
|
object_failed:
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_pending_shutdown();
|
2012-09-17 13:41:05 -07:00
|
|
|
pending_failed:
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_signal_handler_shutdown();
|
2012-09-17 13:41:05 -07:00
|
|
|
signal_handler_failed:
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_message_shutdown();
|
2012-09-17 13:41:05 -07:00
|
|
|
message_failed:
|
2015-01-09 08:20:14 -08:00
|
|
|
eina_log_domain_unregister(eldbus_model_log_dom);
|
|
|
|
eldbus_model_log_dom = -1;
|
2013-04-23 07:40:05 -07:00
|
|
|
eina_log_domain_unregister(_eldbus_log_dom);
|
|
|
|
_eldbus_log_dom = -1;
|
2018-03-27 10:01:35 -07:00
|
|
|
ecore_shutdown();
|
2012-09-17 13:41:05 -07:00
|
|
|
eina_shutdown();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
print_live_connection(Eldbus_Connection *conn)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
if (!conn->names)
|
|
|
|
ERR("conn=%p has no alive objects", conn);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Eina_Iterator *iter = eina_hash_iterator_data_new(conn->names);
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Name *name;
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_ITERATOR_FOREACH(iter, name)
|
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Object *obj;
|
2012-09-17 13:41:05 -07:00
|
|
|
Eina_Iterator *inner_itr;
|
|
|
|
if (!name->objects) continue;
|
|
|
|
|
|
|
|
inner_itr = eina_hash_iterator_data_new(name->objects);
|
|
|
|
EINA_ITERATOR_FOREACH(inner_itr, obj)
|
|
|
|
ERR("conn=%p alive object=%p %s of bus=%s", conn, obj,
|
|
|
|
obj->name, name->name);
|
|
|
|
eina_iterator_free(inner_itr);
|
|
|
|
}
|
|
|
|
eina_iterator_free(iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!conn->pendings)
|
|
|
|
ERR("conn=%p has no alive pending calls", conn);
|
|
|
|
else
|
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Pending *p;
|
2012-10-19 11:24:30 -07:00
|
|
|
EINA_INLIST_FOREACH(conn->pendings, p)
|
2012-09-17 13:41:05 -07:00
|
|
|
ERR("conn=%p alive pending call=%p dest=%s path=%s %s.%s()",
|
|
|
|
conn, p,
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_pending_destination_get(p),
|
|
|
|
eldbus_pending_path_get(p),
|
|
|
|
eldbus_pending_interface_get(p),
|
|
|
|
eldbus_pending_method_get(p));
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API int
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_shutdown(void)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
if (_eldbus_init_count <= 0)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
ERR("Init count not greater than 0 in shutdown.");
|
2013-04-23 07:40:05 -07:00
|
|
|
_eldbus_init_count = 0;
|
2012-09-17 13:41:05 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2013-04-23 07:40:05 -07:00
|
|
|
if (--_eldbus_init_count)
|
|
|
|
return _eldbus_init_count;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2018-02-02 13:59:56 -08:00
|
|
|
ecore_fork_reset_callback_del(_eldbus_fork_reset, NULL);
|
2013-04-23 07:40:05 -07:00
|
|
|
if (shared_connections[ELDBUS_CONNECTION_TYPE_SESSION - 1])
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-12-25 19:22:05 -08:00
|
|
|
CRI("Alive TYPE_SESSION connection");
|
2013-04-23 07:40:05 -07:00
|
|
|
print_live_connection(shared_connections[ELDBUS_CONNECTION_TYPE_SESSION - 1]);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
2013-04-23 07:40:05 -07:00
|
|
|
if (shared_connections[ELDBUS_CONNECTION_TYPE_SYSTEM - 1])
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-12-25 19:22:05 -08:00
|
|
|
CRI("Alive TYPE_SYSTEM connection");
|
2013-04-23 07:40:05 -07:00
|
|
|
print_live_connection(shared_connections[ELDBUS_CONNECTION_TYPE_SYSTEM - 1]);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
2013-04-23 07:40:05 -07:00
|
|
|
if (shared_connections[ELDBUS_CONNECTION_TYPE_STARTER - 1])
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-12-25 19:22:05 -08:00
|
|
|
CRI("Alive TYPE_STARTER connection");
|
2013-04-23 07:40:05 -07:00
|
|
|
print_live_connection(shared_connections[ELDBUS_CONNECTION_TYPE_STARTER - 1]);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
2013-05-23 13:08:16 -07:00
|
|
|
if (shared_connections[ELDBUS_CONNECTION_TYPE_ADDRESS - 1])
|
|
|
|
{
|
|
|
|
if (eina_hash_population(address_connections))
|
|
|
|
{
|
2013-06-09 21:33:31 -07:00
|
|
|
Eina_Iterator *it;
|
|
|
|
Eina_Hash_Tuple *tuple;
|
|
|
|
|
|
|
|
it = eina_hash_iterator_tuple_new(address_connections);
|
|
|
|
EINA_ITERATOR_FOREACH(it, tuple)
|
|
|
|
{
|
2013-12-25 19:22:05 -08:00
|
|
|
CRI("Alive TYPE_ADDRESS connection: %s", (char*)tuple->key);
|
2013-06-09 21:33:31 -07:00
|
|
|
print_live_connection(tuple->data);
|
|
|
|
}
|
|
|
|
eina_iterator_free(it);
|
2013-05-23 13:08:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
eina_hash_free(address_connections);
|
|
|
|
address_connections = shared_connections[ELDBUS_CONNECTION_TYPE_ADDRESS - 1] = NULL;
|
|
|
|
}
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_service_shutdown();
|
|
|
|
eldbus_proxy_shutdown();
|
|
|
|
eldbus_object_shutdown();
|
|
|
|
eldbus_pending_shutdown();
|
|
|
|
eldbus_signal_handler_shutdown();
|
|
|
|
eldbus_message_shutdown();
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2018-04-11 15:31:39 -07:00
|
|
|
ecore_shutdown();
|
|
|
|
|
2015-01-09 08:20:14 -08:00
|
|
|
eina_log_domain_unregister(eldbus_model_log_dom);
|
|
|
|
eldbus_model_log_dom = -1;
|
2013-04-23 07:40:05 -07:00
|
|
|
eina_log_domain_unregister(_eldbus_log_dom);
|
|
|
|
_eldbus_log_dom = -1;
|
2018-04-11 15:31:39 -07:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
eina_shutdown();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
/* TODO: mempool of Eldbus_Context_Free_Cb */
|
|
|
|
typedef struct _Eldbus_Context_Free_Cb
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
EINA_INLIST;
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Free_Cb cb;
|
2012-09-17 13:41:05 -07:00
|
|
|
const void *data;
|
2013-04-23 07:40:05 -07:00
|
|
|
} Eldbus_Context_Free_Cb;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_cbs_free_dispatch(Eina_Inlist **p_lst, const void *dead_pointer)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
Eina_Inlist *lst = *p_lst;
|
|
|
|
*p_lst = NULL;
|
|
|
|
while (lst)
|
|
|
|
{
|
|
|
|
Eina_Inlist *next = lst->next;
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Context_Free_Cb *ctx;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
ctx = EINA_INLIST_CONTAINER_GET(lst, Eldbus_Context_Free_Cb);
|
2012-09-17 13:41:05 -07:00
|
|
|
ctx->cb((void *)ctx->data, dead_pointer);
|
|
|
|
free(ctx);
|
|
|
|
|
|
|
|
lst = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Inlist *
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_cbs_free_add(Eina_Inlist *lst, Eldbus_Free_Cb cb, const void *data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Context_Free_Cb *ctx = malloc(sizeof(Eldbus_Context_Free_Cb));
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, lst);
|
|
|
|
|
|
|
|
ctx->cb = cb;
|
|
|
|
ctx->data = data;
|
|
|
|
|
|
|
|
return eina_inlist_append(lst, EINA_INLIST_GET(ctx));
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Inlist *
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_cbs_free_del(Eina_Inlist *lst, Eldbus_Free_Cb cb, const void *data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Context_Free_Cb *ctx;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2012-10-19 11:24:30 -07:00
|
|
|
EINA_INLIST_FOREACH(lst, ctx)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
if (ctx->cb != cb) continue;
|
|
|
|
if ((data) && (ctx->data != data)) continue;
|
|
|
|
|
|
|
|
lst = eina_inlist_remove(lst, EINA_INLIST_GET(ctx));
|
|
|
|
free(ctx);
|
|
|
|
return lst;
|
|
|
|
}
|
|
|
|
|
|
|
|
ERR("Couldn't find cb_free=%p data=%p", cb, data);
|
|
|
|
return lst;
|
|
|
|
}
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
typedef struct _Eldbus_Data
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
EINA_INLIST;
|
|
|
|
const void *data;
|
|
|
|
unsigned int keylen;
|
|
|
|
char key[];
|
2013-04-23 07:40:05 -07:00
|
|
|
} Eldbus_Data;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
static inline Eldbus_Data *
|
|
|
|
eldbus_data_find(Eina_Inlist **p_lst, const char *key)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
unsigned int keylen = strlen(key);
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Data *d;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2012-10-19 11:24:30 -07:00
|
|
|
EINA_INLIST_FOREACH(*p_lst, d)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
if ((keylen == d->keylen) && (memcmp(key, d->key, keylen) == 0))
|
|
|
|
{
|
|
|
|
*p_lst = eina_inlist_promote(*p_lst, EINA_INLIST_GET(d));
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_data_set(Eina_Inlist **p_lst, const char *key, const void *data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Data *d = eldbus_data_find(p_lst, key);
|
2012-09-17 13:41:05 -07:00
|
|
|
unsigned int keylen = strlen(key);
|
|
|
|
|
|
|
|
if (d)
|
|
|
|
{
|
|
|
|
*p_lst = eina_inlist_remove(*p_lst, EINA_INLIST_GET(d));
|
|
|
|
free(d);
|
|
|
|
}
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
d = malloc(sizeof(Eldbus_Data) + keylen + 1);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(d);
|
|
|
|
|
|
|
|
d->data = data;
|
|
|
|
d->keylen = keylen;
|
|
|
|
memcpy(d->key, key, keylen + 1);
|
|
|
|
|
|
|
|
*p_lst = eina_inlist_prepend(*p_lst, EINA_INLIST_GET(d));
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_data_get(Eina_Inlist **p_lst, const char *key)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Data *d = eldbus_data_find(p_lst, key);
|
2012-09-17 13:41:05 -07:00
|
|
|
return d ? (void *)d->data : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_data_del(Eina_Inlist **p_lst, const char *key)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Data *d = eldbus_data_find(p_lst, key);
|
2012-09-17 13:41:05 -07:00
|
|
|
void *ret;
|
|
|
|
if (!d) return NULL;
|
|
|
|
|
|
|
|
ret = (void *)d->data;
|
|
|
|
*p_lst = eina_inlist_remove(*p_lst, EINA_INLIST_GET(d));
|
|
|
|
free(d);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_data_del_all(Eina_Inlist **p_list)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
Eina_Inlist *n = *p_list;
|
|
|
|
*p_list = NULL;
|
|
|
|
|
|
|
|
while (n)
|
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Data *d = EINA_INLIST_CONTAINER_GET(n, Eldbus_Data);
|
2012-09-17 13:41:05 -07:00
|
|
|
n = eina_inlist_remove(n, n);
|
|
|
|
DBG("key=%s, data=%p", d->key, d->data);
|
|
|
|
free(d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_name_gc(Eldbus_Connection *conn, Eldbus_Connection_Name *cn)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2012-12-20 06:52:15 -08:00
|
|
|
if (cn->refcount > 0)
|
|
|
|
return;
|
|
|
|
if (cn->objects && eina_hash_population(cn->objects) > 0)
|
|
|
|
return;
|
|
|
|
if (cn->event_handlers.list != NULL)
|
2012-12-11 11:49:46 -08:00
|
|
|
return;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2012-12-11 11:49:46 -08:00
|
|
|
eina_hash_del(conn->names, cn->name, cn);
|
|
|
|
if (cn->name_owner_changed)
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_signal_handler_del(cn->name_owner_changed);
|
2012-12-11 11:49:46 -08:00
|
|
|
if (cn->objects)
|
|
|
|
eina_hash_free(cn->objects);
|
|
|
|
eina_stringshare_del(cn->name);
|
2013-01-22 05:34:34 -08:00
|
|
|
if (cn->name_owner_get)
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_pending_cancel(cn->name_owner_get);
|
2013-01-22 05:34:34 -08:00
|
|
|
if (cn->unique_id)
|
|
|
|
eina_stringshare_del(cn->unique_id);
|
2012-09-17 13:41:05 -07:00
|
|
|
eina_list_free(cn->event_handlers.to_delete);
|
|
|
|
free(cn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_name_object_del(Eldbus_Connection *conn, const Eldbus_Object *obj)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Name *cn = eina_hash_find(conn->names, obj->name);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
if (!cn) return;
|
|
|
|
if (!cn->objects) return;
|
|
|
|
eina_hash_del(cn->objects, obj->path, obj);
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_name_gc(conn, cn);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_name_object_set(Eldbus_Connection *conn, Eldbus_Object *obj)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Name *cn;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
cn = eldbus_connection_name_get(conn, obj->name);
|
2012-09-17 13:41:05 -07:00
|
|
|
eina_hash_add(cn->objects, obj->path, obj);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
on_name_owner_changed(void *data, const Eldbus_Message *msg)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2012-10-29 15:02:46 -07:00
|
|
|
const char *bus, *older_id, *new_id;
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Name *cn = data;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
if (!eldbus_message_arguments_get(msg, "sss", &bus, &older_id, &new_id))
|
2012-10-29 15:02:46 -07:00
|
|
|
{
|
|
|
|
ERR("Error getting arguments from NameOwnerChanged cn=%s", cn->name);
|
|
|
|
return;
|
|
|
|
}
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2012-12-11 11:49:46 -08:00
|
|
|
eina_stringshare_replace(&cn->unique_id, new_id);
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_dispatch_name_owner_change(cn, older_id);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
on_get_name_owner(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-01-22 05:34:34 -08:00
|
|
|
const char *unique_id = "", *error_name;
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Name *cn = data;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-01-22 05:34:34 -08:00
|
|
|
cn->name_owner_get = NULL;
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
if (eldbus_message_error_get(msg, &error_name, NULL))
|
2013-01-14 14:34:51 -08:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
if (!strcmp(error_name, ELDBUS_ERROR_PENDING_CANCELED))
|
2013-01-22 05:34:34 -08:00
|
|
|
return;
|
|
|
|
DBG("GetNameOwner of bus = %s returned an error", cn->name);
|
2013-01-14 14:34:51 -08:00
|
|
|
}
|
2013-04-23 07:40:05 -07:00
|
|
|
else if (!eldbus_message_arguments_get(msg, "s", &unique_id))
|
2013-01-22 05:34:34 -08:00
|
|
|
ERR("Error getting arguments from GetNameOwner");
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
cn->unique_id = eina_stringshare_add(unique_id);
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_dispatch_name_owner_change(cn, NULL);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
2012-12-11 11:49:46 -08:00
|
|
|
void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_name_ref(Eldbus_Connection_Name *cn)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2012-12-11 11:49:46 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(cn);
|
2012-09-17 13:41:05 -07:00
|
|
|
cn->refcount++;
|
|
|
|
}
|
|
|
|
|
2012-12-11 11:49:46 -08:00
|
|
|
void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_name_unref(Eldbus_Connection *conn, Eldbus_Connection_Name *cn)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(cn);
|
|
|
|
|
|
|
|
cn->refcount--;
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_name_gc(conn, cn);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Name *
|
|
|
|
eldbus_connection_name_get(Eldbus_Connection *conn, const char *name)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Name *cn;
|
|
|
|
ELDBUS_CONNECTION_CHECK_RETVAL(conn, NULL);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
cn = eina_hash_find(conn->names, name);
|
|
|
|
if (cn) return cn;
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
cn = calloc(1, sizeof(Eldbus_Connection_Name));
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(cn, NULL);
|
2012-12-11 11:49:37 -08:00
|
|
|
cn->name = eina_stringshare_add(name);
|
2012-12-11 11:49:46 -08:00
|
|
|
cn->objects = eina_hash_string_superfast_new(NULL);
|
2012-12-11 11:49:37 -08:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
if (!strcmp(name, ELDBUS_FDO_BUS))
|
2012-12-11 11:49:46 -08:00
|
|
|
{
|
|
|
|
cn->unique_id = eina_stringshare_add(name);
|
|
|
|
goto end;
|
|
|
|
}
|
2012-12-14 08:28:46 -08:00
|
|
|
|
|
|
|
if (name[0] == ':')
|
2012-12-11 11:50:06 -08:00
|
|
|
cn->unique_id = eina_stringshare_add(name);
|
|
|
|
else
|
2013-04-23 07:40:05 -07:00
|
|
|
cn->name_owner_get = eldbus_name_owner_get(conn, cn->name, on_get_name_owner, cn);
|
2012-12-14 08:28:46 -08:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
cn->name_owner_changed = _eldbus_signal_handler_add(conn, ELDBUS_FDO_BUS,
|
|
|
|
ELDBUS_FDO_PATH,
|
|
|
|
ELDBUS_FDO_INTERFACE,
|
2012-12-11 11:50:01 -08:00
|
|
|
"NameOwnerChanged",
|
|
|
|
on_name_owner_changed, cn);
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_signal_handler_match_extra_set(cn->name_owner_changed, "arg0",
|
2012-12-11 11:49:46 -08:00
|
|
|
cn->name, NULL);
|
|
|
|
|
|
|
|
end:
|
2012-09-17 13:41:05 -07:00
|
|
|
eina_hash_direct_add(conn->names, cn->name, cn);
|
|
|
|
return cn;
|
|
|
|
}
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Object *
|
|
|
|
eldbus_connection_name_object_get(Eldbus_Connection *conn, const char *name, const char *path)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Name *cn;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK_RETVAL(conn, NULL);
|
2012-09-17 13:41:05 -07:00
|
|
|
cn = eina_hash_find(conn->names, name);
|
|
|
|
if (!cn) return NULL;
|
|
|
|
if (!cn->objects) return NULL;
|
|
|
|
return eina_hash_find(cn->objects, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_fd_handler(void *data, Ecore_Fd_Handler *fd_handler)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Handler_Data *hd = data;
|
2012-09-17 13:41:05 -07:00
|
|
|
unsigned int condition = 0;
|
|
|
|
|
|
|
|
DBG("Got Ecore_Fd_Handle@%p", fd_handler);
|
|
|
|
|
|
|
|
if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) condition |= DBUS_WATCH_READABLE;
|
|
|
|
if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE)) condition |= DBUS_WATCH_WRITABLE;
|
|
|
|
if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR)) condition |= DBUS_WATCH_ERROR;
|
|
|
|
|
|
|
|
DBG("dbus connection@%p fdh=%d flags: [%s%s%s]", hd->conn, hd->fd,
|
|
|
|
(condition & DBUS_WATCH_READABLE) ? "read " : "",
|
|
|
|
(condition & DBUS_WATCH_WRITABLE) ? "write " : "",
|
|
|
|
(condition & DBUS_WATCH_ERROR) ? "error" : "");
|
|
|
|
|
|
|
|
dbus_watch_handle(hd->watch, condition);
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_fd_handler_add(Eldbus_Handler_Data *hd)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
unsigned int dflags;
|
|
|
|
Ecore_Fd_Handler_Flags eflags;
|
|
|
|
|
|
|
|
if (hd->fd_handler) return;
|
|
|
|
dflags = dbus_watch_get_flags(hd->watch);
|
|
|
|
eflags = ECORE_FD_ERROR;
|
|
|
|
if (dflags & DBUS_WATCH_READABLE) eflags |= ECORE_FD_READ;
|
|
|
|
if (dflags & DBUS_WATCH_WRITABLE) eflags |= ECORE_FD_WRITE;
|
|
|
|
|
|
|
|
DBG("Watching fd %d with flags: [%s%serror]", hd->fd,
|
|
|
|
(eflags & ECORE_FD_READ) ? "read " : "",
|
|
|
|
(eflags & ECORE_FD_WRITE) ? "write " : "");
|
|
|
|
|
|
|
|
hd->fd_handler = ecore_main_fd_handler_add(hd->fd,
|
|
|
|
eflags,
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_fd_handler,
|
2012-09-17 13:41:05 -07:00
|
|
|
hd,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_handler_data_free(void *data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Handler_Data *hd = data;
|
|
|
|
eldbus_fd_handler_del(hd);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
cb_watch_add(DBusWatch *watch, void *data)
|
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection *conn = data;
|
|
|
|
Eldbus_Handler_Data *hd;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
if (!dbus_watch_get_enabled(watch)) return EINA_TRUE;
|
|
|
|
|
|
|
|
DBG("cb_watch_add (enabled: %d)", dbus_watch_get_unix_fd(watch));
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
hd = calloc(1, sizeof(Eldbus_Handler_Data));
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(hd, EINA_FALSE);
|
2013-04-23 07:40:05 -07:00
|
|
|
dbus_watch_set_data(watch, hd, eldbus_handler_data_free);
|
2012-09-17 13:41:05 -07:00
|
|
|
hd->conn = conn;
|
|
|
|
hd->watch = watch;
|
|
|
|
hd->enabled = dbus_watch_get_enabled(watch);
|
|
|
|
hd->fd = dbus_watch_get_unix_fd(hd->watch);
|
|
|
|
|
|
|
|
conn->fd_handlers = eina_inlist_append(hd->conn->fd_handlers,
|
|
|
|
EINA_INLIST_GET(hd));
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_fd_handler_add(hd);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-03 06:05:51 -08:00
|
|
|
cb_watch_del(DBusWatch *watch, void *data EINA_UNUSED)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
DBG("cb_watch_del");
|
2013-04-23 07:40:05 -07:00
|
|
|
/* will trigger eldbus_handler_data_free() */
|
2012-09-17 13:41:05 -07:00
|
|
|
dbus_watch_set_data(watch, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-03 06:05:51 -08:00
|
|
|
cb_watch_toggle(DBusWatch *watch, void *data EINA_UNUSED)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Handler_Data *hd;
|
2012-09-17 13:41:05 -07:00
|
|
|
hd = dbus_watch_get_data(watch);
|
2012-11-01 19:49:24 -07:00
|
|
|
if (!hd) return;
|
2012-09-17 13:41:05 -07:00
|
|
|
DBG("cb_watch_toggle %d", hd->fd);
|
|
|
|
|
|
|
|
hd->enabled = dbus_watch_get_enabled(watch);
|
|
|
|
|
|
|
|
DBG("watch %p is %sabled", hd, hd->enabled ? "en" : "dis");
|
2013-05-27 14:17:54 -07:00
|
|
|
if (hd->enabled)
|
|
|
|
{
|
|
|
|
eldbus_fd_handler_add(hd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ecore_main_fd_handler_del(hd->fd_handler);
|
|
|
|
hd->fd_handler = NULL;
|
|
|
|
}
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_timeout_data_free(void *timeout_data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Timeout_Data *td = timeout_data;
|
2012-09-17 13:41:05 -07:00
|
|
|
td->conn->timeouts = eina_inlist_remove(td->conn->timeouts,
|
|
|
|
EINA_INLIST_GET(td));
|
|
|
|
DBG("Timeout -- freeing timeout_data %p", td);
|
|
|
|
if (td->handler) ecore_timer_del(td->handler);
|
|
|
|
free(td);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_timeout_handler(void *data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Timeout_Data *td = data;
|
2012-09-17 13:41:05 -07:00
|
|
|
td->handler = NULL;
|
|
|
|
|
|
|
|
if (!dbus_timeout_get_enabled(td->timeout))
|
|
|
|
{
|
|
|
|
DBG("timeout_handler (not enabled, ending)");
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG("Telling dbus to handle timeout with data %p", data);
|
|
|
|
dbus_timeout_handle(td->timeout);
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
cb_timeout_add(DBusTimeout *timeout, void *data)
|
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection *conn = data;
|
|
|
|
Eldbus_Timeout_Data *td;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
if (!dbus_timeout_get_enabled(timeout))
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
DBG("Adding timeout for connection@%p", conn);
|
2013-04-23 07:40:05 -07:00
|
|
|
td = calloc(1, sizeof(Eldbus_Timeout_Data));
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(td, EINA_FALSE);
|
|
|
|
td->conn = conn;
|
2013-04-23 07:40:05 -07:00
|
|
|
dbus_timeout_set_data(timeout, (void *)td, eldbus_timeout_data_free);
|
2012-09-17 13:41:05 -07:00
|
|
|
td->interval = dbus_timeout_get_interval(timeout);
|
|
|
|
td->timeout = timeout;
|
|
|
|
|
2016-05-24 13:00:45 -07:00
|
|
|
td->handler = ecore_timer_add(td->interval / 1000.0, eldbus_timeout_handler, td);
|
2012-09-17 13:41:05 -07:00
|
|
|
conn->timeouts = eina_inlist_append(conn->timeouts,
|
|
|
|
EINA_INLIST_GET(td));
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-03 06:05:51 -08:00
|
|
|
cb_timeout_del(DBusTimeout *timeout, void *data EINA_UNUSED)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
DBG("timeout del!");
|
2013-04-23 07:40:05 -07:00
|
|
|
/* will trigger eldbus_timeout_data_free() */
|
2012-09-17 13:41:05 -07:00
|
|
|
dbus_timeout_set_data(timeout, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-03 06:05:51 -08:00
|
|
|
cb_timeout_toggle(DBusTimeout *timeout, void *data EINA_UNUSED)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Timeout_Data *td;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
td = dbus_timeout_get_data(timeout);
|
|
|
|
|
|
|
|
DBG("Timeout toggle; data@%p", td);
|
|
|
|
if (dbus_timeout_get_enabled(td->timeout))
|
|
|
|
{
|
|
|
|
td->interval = dbus_timeout_get_interval(timeout);
|
|
|
|
td->handler
|
2013-04-23 07:40:05 -07:00
|
|
|
= ecore_timer_add(td->interval, eldbus_timeout_handler, td);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
DBG("Timeout is enabled with interval %d, timer@%p",
|
|
|
|
td->interval, td->handler);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG("Timeout is disabled, destroying timer@%p", td->handler);
|
|
|
|
ecore_timer_del(td->handler);
|
|
|
|
td->handler = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2016-12-05 18:27:37 -08:00
|
|
|
eldbus_idle_enterer(void *data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection *conn = data;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
DBG("Connection@%p: Dispatch status: %d", conn,
|
2013-07-05 10:45:48 -07:00
|
|
|
dbus_connection_get_dispatch_status(conn->dbus_conn));
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-07-05 10:45:48 -07:00
|
|
|
if (dbus_connection_get_dispatch_status(conn->dbus_conn) ==
|
|
|
|
DBUS_DISPATCH_COMPLETE)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2016-12-05 18:27:37 -08:00
|
|
|
DBG("Connection@%p: Dispatch complete, idle_enterer@%p finishing",
|
|
|
|
conn, conn->idle_enterer);
|
|
|
|
conn->idle_enterer = NULL;
|
2012-09-17 13:41:05 -07:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
|
|
|
DBG("Connection@%p: Dispatching", conn);
|
2014-12-17 10:57:03 -08:00
|
|
|
eldbus_init();
|
2013-07-05 10:45:48 -07:00
|
|
|
eldbus_connection_ref(conn);
|
2016-12-05 18:27:37 -08:00
|
|
|
|
|
|
|
DBusDispatchStatus status;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
status = dbus_connection_dispatch(conn->dbus_conn);
|
|
|
|
}
|
|
|
|
while(status == DBUS_DISPATCH_DATA_REMAINS);
|
|
|
|
|
2013-07-05 10:45:48 -07:00
|
|
|
eldbus_connection_unref(conn);
|
2014-12-17 10:57:03 -08:00
|
|
|
eldbus_shutdown();
|
2012-09-17 13:41:05 -07:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-03 06:05:51 -08:00
|
|
|
cb_dispatch_status(DBusConnection *dbus_conn EINA_UNUSED, DBusDispatchStatus new_status, void *data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection *conn = data;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-07-05 10:45:48 -07:00
|
|
|
if (!conn->refcount)
|
|
|
|
{
|
|
|
|
DBG("Connection[%p] being freed, dispatch blocked", conn);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
DBG("Connection@%p: Dispatch status: %d", conn, new_status);
|
|
|
|
|
2016-12-05 18:27:37 -08:00
|
|
|
if ((new_status == DBUS_DISPATCH_DATA_REMAINS) && (!conn->idle_enterer))
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2016-12-05 18:27:37 -08:00
|
|
|
conn->idle_enterer = ecore_idle_enterer_add(eldbus_idle_enterer, conn);
|
|
|
|
DBG("Connection@%p: Adding idle_enterer@%p to handle remaining dispatch data",
|
|
|
|
conn, conn->idle_enterer);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
2016-12-05 18:27:37 -08:00
|
|
|
else if ((new_status != DBUS_DISPATCH_DATA_REMAINS) && (conn->idle_enterer))
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2016-12-05 18:27:37 -08:00
|
|
|
DBG("Connection@%p: No remaining dispatch data, clearing idle_enterer@%p",
|
|
|
|
conn, conn->idle_enterer);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2016-12-05 18:27:37 -08:00
|
|
|
ecore_idle_enterer_del(conn->idle_enterer);
|
|
|
|
conn->idle_enterer = NULL;
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-07 07:20:16 -08:00
|
|
|
static inline Eina_Bool
|
2013-04-23 07:40:05 -07:00
|
|
|
extra_arguments_check(DBusMessage *msg, Eldbus_Signal_Handler *sh)
|
2013-01-07 07:20:16 -08:00
|
|
|
{
|
|
|
|
DBusMessageIter iter;
|
|
|
|
Signal_Argument *arg;
|
|
|
|
unsigned int arg_index = 0;
|
|
|
|
|
|
|
|
dbus_message_iter_init(msg, &iter);
|
|
|
|
EINA_INLIST_FOREACH(sh->args, arg)
|
|
|
|
{
|
|
|
|
const char *arg_msg;
|
|
|
|
int type = 0;
|
|
|
|
|
|
|
|
while((arg->index > arg_index) && dbus_message_iter_next(&iter))
|
|
|
|
arg_index++;
|
|
|
|
|
|
|
|
if (arg_index != arg->index)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
type = dbus_message_iter_get_arg_type(&iter);
|
|
|
|
if (!(type == 's' || type == 'o'))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
dbus_message_iter_get_basic(&iter, &arg_msg);
|
|
|
|
if (strcmp(arg_msg, arg->value))
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
cb_signal_dispatcher(Eldbus_Connection *conn, DBusMessage *msg)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Message *eldbus_msg;
|
2012-12-28 13:05:57 -08:00
|
|
|
Eina_Inlist *next;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_msg = eldbus_message_new(EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(eldbus_msg);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_msg->dbus_msg = dbus_message_ref(msg);
|
|
|
|
dbus_message_iter_init(eldbus_msg->dbus_msg,
|
|
|
|
&eldbus_msg->iterator->dbus_iterator);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_ref(conn);
|
|
|
|
eldbus_init();
|
2012-12-28 13:05:57 -08:00
|
|
|
/*
|
|
|
|
* Do the walking open-coded so we don't crash if a callback
|
|
|
|
* removes other signal handlers from the list and we don't own
|
|
|
|
* yet a reference to them.
|
|
|
|
*/
|
|
|
|
next = conn->signal_handlers;
|
|
|
|
while (next != NULL)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Signal_Handler *sh;
|
2012-12-28 12:02:31 -08:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
sh = EINA_INLIST_CONTAINER_GET(next, Eldbus_Signal_Handler);
|
2012-12-28 13:05:57 -08:00
|
|
|
next = next->next;
|
|
|
|
|
2012-12-11 11:49:42 -08:00
|
|
|
if (sh->dangling) continue;
|
2012-09-17 13:41:05 -07:00
|
|
|
if (sh->sender)
|
|
|
|
{
|
|
|
|
if (sh->bus)
|
|
|
|
{
|
|
|
|
if ((sh->bus->unique_id == NULL) ||
|
|
|
|
(!sh->bus->unique_id[0]) ||
|
|
|
|
(!dbus_message_has_sender(msg, sh->bus->unique_id)))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
2013-01-07 07:20:16 -08:00
|
|
|
if (!dbus_message_has_sender(msg, sh->sender)) continue;
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
if (sh->path && !dbus_message_has_path(msg, sh->path)) continue;
|
2013-09-02 13:07:16 -07:00
|
|
|
if (sh->interface && !dbus_message_has_interface(msg, sh->interface))
|
|
|
|
continue;
|
2012-09-17 13:41:05 -07:00
|
|
|
if (sh->member && !dbus_message_has_member(msg, sh->member)) continue;
|
2013-01-07 07:20:16 -08:00
|
|
|
if (!extra_arguments_check(msg, sh)) continue;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_signal_handler_ref(sh);
|
|
|
|
sh->cb((void *)sh->cb_data, eldbus_msg);
|
2012-12-28 13:05:57 -08:00
|
|
|
/* update next signal handler because the list may have changed */
|
|
|
|
next = EINA_INLIST_GET(sh)->next;
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_signal_handler_unref(sh);
|
2012-12-28 13:05:57 -08:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
/*
|
|
|
|
* Rewind iterator so another signal handler matching the same signal
|
|
|
|
* can iterate over it.
|
|
|
|
*/
|
2013-04-23 07:40:05 -07:00
|
|
|
dbus_message_iter_init(eldbus_msg->dbus_msg,
|
|
|
|
&eldbus_msg->iterator->dbus_iterator);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_message_unref(eldbus_msg);
|
|
|
|
eldbus_connection_unref(conn);
|
|
|
|
eldbus_shutdown();
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static DBusHandlerResult
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_filter(DBusConnection *conn_dbus EINA_UNUSED, DBusMessage *message, void *user_data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection *conn = user_data;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
DBG("Connection@%p Got message:\n"
|
|
|
|
" Type: %s\n"
|
|
|
|
" Path: %s\n"
|
|
|
|
" Interface: %s\n"
|
|
|
|
" Member: %s\n"
|
|
|
|
" Sender: %s", conn,
|
|
|
|
dbus_message_type_to_string(dbus_message_get_type(message)),
|
|
|
|
dbus_message_get_path(message),
|
|
|
|
dbus_message_get_interface(message),
|
|
|
|
dbus_message_get_member(message),
|
|
|
|
dbus_message_get_sender(message));
|
|
|
|
|
|
|
|
switch (dbus_message_get_type(message))
|
|
|
|
{
|
|
|
|
case DBUS_MESSAGE_TYPE_METHOD_CALL:
|
|
|
|
DBG(" Signature: %s", dbus_message_get_signature(message));
|
|
|
|
break;
|
|
|
|
case DBUS_MESSAGE_TYPE_METHOD_RETURN:
|
|
|
|
case DBUS_MESSAGE_TYPE_ERROR:
|
|
|
|
DBG(" Reply serial: %d", dbus_message_get_reply_serial(message));
|
|
|
|
break;
|
|
|
|
case DBUS_MESSAGE_TYPE_SIGNAL:
|
|
|
|
DBG(" Signature: %s", dbus_message_get_signature(message));
|
|
|
|
cb_signal_dispatcher(conn, message);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_setup(Eldbus_Connection *conn)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
DBG("Setting up connection %p", conn);
|
|
|
|
|
|
|
|
/* connection_setup */
|
|
|
|
dbus_connection_set_exit_on_disconnect(conn->dbus_conn, EINA_FALSE);
|
|
|
|
dbus_connection_set_watch_functions(conn->dbus_conn,
|
|
|
|
cb_watch_add,
|
|
|
|
cb_watch_del,
|
|
|
|
cb_watch_toggle,
|
|
|
|
conn,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
dbus_connection_set_timeout_functions(conn->dbus_conn,
|
|
|
|
cb_timeout_add,
|
|
|
|
cb_timeout_del,
|
|
|
|
cb_timeout_toggle,
|
|
|
|
conn,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
dbus_connection_set_dispatch_status_function(conn->dbus_conn,
|
|
|
|
cb_dispatch_status,
|
|
|
|
conn, NULL);
|
2013-04-23 07:40:05 -07:00
|
|
|
dbus_connection_add_filter(conn->dbus_conn, eldbus_filter, conn, NULL);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
cb_dispatch_status(conn->dbus_conn,
|
|
|
|
dbus_connection_get_dispatch_status(conn->dbus_conn),
|
|
|
|
conn);
|
|
|
|
}
|
|
|
|
|
2012-12-11 11:50:29 -08:00
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
_disconnected(void *data, const Eldbus_Message *msg EINA_UNUSED)
|
2012-12-11 11:50:29 -08:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection *conn = data;
|
2016-05-06 12:32:58 -07:00
|
|
|
Ecore_Event_Signal_Exit *ev;
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
_eldbus_connection_event_callback_call(
|
|
|
|
conn, ELDBUS_CONNECTION_EVENT_DISCONNECTED, NULL);
|
2016-05-06 12:32:58 -07:00
|
|
|
if (conn->type != ELDBUS_CONNECTION_TYPE_SESSION) return;
|
|
|
|
|
|
|
|
ev = calloc(1, sizeof(Ecore_Event_Signal_Exit));
|
|
|
|
if (!ev) return;
|
|
|
|
|
|
|
|
ev->quit = EINA_TRUE;
|
|
|
|
ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, ev, NULL, NULL);
|
2012-12-11 11:50:29 -08:00
|
|
|
}
|
|
|
|
|
2013-05-23 13:08:16 -07:00
|
|
|
/* Param address is only used for ELDBUS_CONNECTION_TYPE_ADDRESS type */
|
2013-04-23 07:40:05 -07:00
|
|
|
static Eldbus_Connection *
|
2015-08-11 07:13:07 -07:00
|
|
|
_connection_get(Eldbus_Connection_Type type, const char *address, Eina_Bool shared)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection *conn;
|
2012-09-17 13:41:05 -07:00
|
|
|
DBusError err;
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Object *obj;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL((type < ELDBUS_CONNECTION_TYPE_LAST) &&
|
|
|
|
(type > ELDBUS_CONNECTION_TYPE_UNKNOWN), NULL);
|
2013-05-23 13:08:16 -07:00
|
|
|
EINA_SAFETY_ON_TRUE_RETURN_VAL((type == ELDBUS_CONNECTION_TYPE_ADDRESS) &&
|
|
|
|
(address == NULL), NULL);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
conn = calloc(1, sizeof(Eldbus_Connection));
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);
|
|
|
|
|
|
|
|
dbus_error_init(&err);
|
2013-05-23 13:08:16 -07:00
|
|
|
if (type == ELDBUS_CONNECTION_TYPE_ADDRESS)
|
|
|
|
conn->dbus_conn = dbus_connection_open_private(address, &err);
|
|
|
|
else
|
|
|
|
conn->dbus_conn = dbus_bus_get_private(type - 1, &err);
|
|
|
|
|
2013-06-27 13:24:46 -07:00
|
|
|
if (!conn->dbus_conn || dbus_error_is_set(&err))
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
free(conn);
|
2013-08-13 11:37:42 -07:00
|
|
|
ERR("Error connecting to bus of type %d. error name: %s error message: %s",
|
|
|
|
type, err.name, err.message);
|
2012-09-17 13:41:05 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-06-27 13:24:46 -07:00
|
|
|
if (type == ELDBUS_CONNECTION_TYPE_ADDRESS &&
|
|
|
|
!dbus_bus_register(conn->dbus_conn, &err))
|
|
|
|
{
|
|
|
|
dbus_connection_close(conn->dbus_conn);
|
2013-06-27 13:31:22 -07:00
|
|
|
dbus_connection_unref(conn->dbus_conn);
|
|
|
|
conn->dbus_conn = NULL;
|
2013-06-27 13:24:46 -07:00
|
|
|
free(conn);
|
|
|
|
ERR("Error registering with bus: %s", err.message);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
conn->type = type;
|
|
|
|
conn->refcount = 1;
|
2015-08-11 07:13:07 -07:00
|
|
|
conn->shared = !!shared;
|
2013-04-23 07:40:05 -07:00
|
|
|
EINA_MAGIC_SET(conn, ELDBUS_CONNECTION_MAGIC);
|
2012-12-11 11:49:46 -08:00
|
|
|
conn->names = eina_hash_string_superfast_new(NULL);
|
2013-07-05 10:45:48 -07:00
|
|
|
eldbus_connection_setup(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_signal_handler_add(conn, NULL, DBUS_PATH_LOCAL, DBUS_INTERFACE_LOCAL,
|
2013-07-05 10:45:48 -07:00
|
|
|
"Disconnected", _disconnected, conn);
|
2013-04-23 07:40:05 -07:00
|
|
|
obj = eldbus_object_get(conn, ELDBUS_FDO_BUS, ELDBUS_FDO_PATH);
|
|
|
|
conn->fdo_proxy = eldbus_proxy_get(obj, ELDBUS_FDO_INTERFACE);
|
2012-12-11 11:50:29 -08:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
DBG("Returned new connection at %p", conn);
|
|
|
|
return conn;
|
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API Eldbus_Connection *
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_private_connection_get(Eldbus_Connection_Type type)
|
2012-12-11 11:50:20 -08:00
|
|
|
{
|
2013-05-23 13:08:16 -07:00
|
|
|
DBG("Getting private connection with type %d", type);
|
2015-08-11 07:13:07 -07:00
|
|
|
return _connection_get(type, NULL, EINA_FALSE);
|
2012-12-11 11:50:20 -08:00
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API Eldbus_Connection *
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_get(Eldbus_Connection_Type type)
|
2012-12-11 11:50:20 -08:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection *conn;
|
2012-12-11 11:50:20 -08:00
|
|
|
|
|
|
|
DBG("Getting connection with type %d", type);
|
2013-02-18 04:10:22 -08:00
|
|
|
|
|
|
|
if (!type)
|
|
|
|
return NULL;
|
|
|
|
|
2013-05-23 13:08:16 -07:00
|
|
|
if (type == ELDBUS_CONNECTION_TYPE_ADDRESS)
|
|
|
|
{
|
|
|
|
ERR("CONNECTION_TYPE_ADDRESS must be used with appropriate address_connection_get() function");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
conn = (Eldbus_Connection *) shared_connections[type - 1];
|
2012-12-11 11:50:20 -08:00
|
|
|
if (conn)
|
|
|
|
{
|
|
|
|
DBG("Connection with type %d exists at %p; reffing and returning",
|
|
|
|
type, conn);
|
2013-04-23 07:40:05 -07:00
|
|
|
return eldbus_connection_ref(conn);
|
2012-12-11 11:50:20 -08:00
|
|
|
}
|
|
|
|
|
2015-08-11 07:13:07 -07:00
|
|
|
conn = _connection_get(type, NULL, EINA_TRUE);
|
2012-12-11 11:50:20 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);
|
|
|
|
shared_connections[type - 1] = conn;
|
|
|
|
|
|
|
|
return conn;
|
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API Eldbus_Connection *
|
2013-05-23 13:08:16 -07:00
|
|
|
eldbus_address_connection_get(const char *address)
|
|
|
|
{
|
|
|
|
Eldbus_Connection *conn = NULL;
|
|
|
|
|
|
|
|
DBG("Getting connection with address %s", address);
|
|
|
|
|
|
|
|
if (address_connections == NULL)
|
|
|
|
{
|
|
|
|
address_connections = eina_hash_string_small_new(NULL);
|
|
|
|
shared_connections[ELDBUS_CONNECTION_TYPE_ADDRESS - 1] = address_connections;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
conn = (Eldbus_Connection *) eina_hash_find(address_connections, address);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (conn != NULL)
|
|
|
|
{
|
|
|
|
DBG("Connection with address %s exists at %p; reffing and returning",
|
|
|
|
address, conn);
|
|
|
|
return eldbus_connection_ref(conn);
|
|
|
|
}
|
|
|
|
|
2015-08-11 07:13:07 -07:00
|
|
|
conn = _connection_get(ELDBUS_CONNECTION_TYPE_ADDRESS, address, EINA_TRUE);
|
2013-05-23 13:08:16 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);
|
|
|
|
eina_hash_add(address_connections, address, conn);
|
|
|
|
|
|
|
|
return conn;
|
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API Eldbus_Connection *
|
2013-05-23 13:08:16 -07:00
|
|
|
eldbus_private_address_connection_get(const char *address)
|
|
|
|
{
|
|
|
|
DBG("Getting private connection with address %s", address);
|
2015-08-11 07:13:07 -07:00
|
|
|
return _connection_get(ELDBUS_CONNECTION_TYPE_ADDRESS, address, EINA_FALSE);
|
2013-05-23 13:08:16 -07:00
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API Eldbus_Connection *
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_ref(Eldbus_Connection *conn)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK_RETVAL(conn, NULL);
|
2012-09-17 13:41:05 -07:00
|
|
|
DBG("conn=%p, pre-refcount=%d", conn, conn->refcount);
|
|
|
|
conn->refcount++;
|
|
|
|
return conn;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-23 12:36:29 -07:00
|
|
|
_eldbus_connection_free(Eldbus_Connection *conn)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
unsigned int i;
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Handler_Data *fd_handler;
|
|
|
|
Eldbus_Timeout_Data *timer;
|
2012-09-17 13:41:05 -07:00
|
|
|
Eina_Inlist *list;
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Signal_Handler *h;
|
|
|
|
Eldbus_Pending *p;
|
2012-12-11 11:49:46 -08:00
|
|
|
Eina_Iterator *iter;
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Name *cn;
|
2012-12-20 06:52:21 -08:00
|
|
|
Eina_Array *cns;
|
2013-01-03 06:06:20 -08:00
|
|
|
const char *name;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
DBG("Freeing connection %p", conn);
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
_eldbus_connection_event_callback_call
|
|
|
|
(conn, ELDBUS_CONNECTION_EVENT_DEL, NULL);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
conn->refcount = 1;
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_cbs_free_dispatch(&(conn->cbs_free), conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-08-23 12:54:12 -07:00
|
|
|
/**
|
|
|
|
* Flush all messages in outgoing queue, also this will send all
|
|
|
|
* ObjectManager and Property changed signals of all paths that
|
|
|
|
* this connection is server.
|
|
|
|
*/
|
|
|
|
dbus_connection_flush(conn->dbus_conn);
|
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_INLIST_FOREACH_SAFE(conn->pendings, list, p)
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_pending_cancel(p);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2012-12-20 06:52:21 -08:00
|
|
|
cns = eina_array_new(eina_hash_population(conn->names));
|
2012-12-11 11:49:46 -08:00
|
|
|
iter = eina_hash_iterator_data_new(conn->names);
|
|
|
|
EINA_ITERATOR_FOREACH(iter, cn)
|
|
|
|
{
|
|
|
|
while (cn->event_handlers.list)
|
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Context_NOC_Cb *ctx;
|
2012-12-11 11:49:46 -08:00
|
|
|
ctx = EINA_INLIST_CONTAINER_GET(cn->event_handlers.list,
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Context_NOC_Cb);
|
2012-12-11 11:49:46 -08:00
|
|
|
cn->event_handlers.list = eina_inlist_remove(cn->event_handlers.list,
|
|
|
|
cn->event_handlers.list);
|
|
|
|
free(ctx);
|
2012-12-20 06:52:21 -08:00
|
|
|
}
|
2013-01-03 06:06:20 -08:00
|
|
|
eina_array_push(cns, eina_stringshare_add(cn->name));
|
2012-12-11 11:49:46 -08:00
|
|
|
}
|
|
|
|
eina_iterator_free(iter);
|
2012-12-20 06:52:21 -08:00
|
|
|
|
2013-01-03 06:06:20 -08:00
|
|
|
while ((name = eina_array_pop(cns)))
|
|
|
|
{
|
|
|
|
cn = eina_hash_find(conn->names, name);
|
2013-04-23 07:40:05 -07:00
|
|
|
if (cn) eldbus_connection_name_gc(conn, cn);
|
2013-01-03 06:06:20 -08:00
|
|
|
eina_stringshare_del(name);
|
|
|
|
}
|
2012-12-20 06:52:21 -08:00
|
|
|
|
2012-12-11 11:49:46 -08:00
|
|
|
eina_hash_free(conn->names);
|
2012-12-20 06:52:21 -08:00
|
|
|
eina_array_free(cns);
|
2012-12-11 11:49:46 -08:00
|
|
|
|
2012-09-17 13:41:05 -07:00
|
|
|
conn->refcount = 0;
|
|
|
|
|
|
|
|
/* after cbs_free dispatch these shouldn't exit, error if they do */
|
|
|
|
|
|
|
|
if (conn->pendings)
|
|
|
|
{
|
2013-12-25 19:22:05 -08:00
|
|
|
CRI("Connection %p released with live pending calls!",
|
2012-12-11 11:49:46 -08:00
|
|
|
conn);
|
2012-10-19 11:24:30 -07:00
|
|
|
EINA_INLIST_FOREACH(conn->pendings, p)
|
2012-12-11 11:50:01 -08:00
|
|
|
ERR("conn=%p alive pending call=%p dest=%s path=%s %s.%s()", conn, p,
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_pending_destination_get(p),
|
|
|
|
eldbus_pending_path_get(p),
|
|
|
|
eldbus_pending_interface_get(p),
|
|
|
|
eldbus_pending_method_get(p));
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
2012-12-11 11:50:01 -08:00
|
|
|
if (conn->signal_handlers)
|
|
|
|
{
|
2013-12-25 19:22:05 -08:00
|
|
|
CRI("Connection %p released with live signal handlers!", conn);
|
2012-12-11 11:50:01 -08:00
|
|
|
EINA_INLIST_FOREACH(conn->signal_handlers, h)
|
|
|
|
ERR("conn=%p alive signal=%p %s.%s path=%s", conn, h, h->interface,
|
|
|
|
h->member, h->path);
|
|
|
|
}
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
for (i = 0; i < ELDBUS_CONNECTION_EVENT_LAST; i++)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Context_Event *ce = conn->event_handlers + i;
|
2012-09-17 13:41:05 -07:00
|
|
|
while (ce->list)
|
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Context_Event_Cb *ctx;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
ctx = EINA_INLIST_CONTAINER_GET(ce->list,
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Context_Event_Cb);
|
|
|
|
_eldbus_connection_context_event_cb_del(ce, ctx);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
eina_list_free(ce->to_delete);
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_MAGIC_SET(conn, EINA_MAGIC_NONE);
|
2013-07-05 10:45:48 -07:00
|
|
|
//will trigger a cb_dispatch_status()
|
2012-09-17 13:41:05 -07:00
|
|
|
dbus_connection_close(conn->dbus_conn);
|
|
|
|
dbus_connection_unref(conn->dbus_conn);
|
|
|
|
conn->dbus_conn = NULL;
|
|
|
|
|
2012-10-19 11:24:30 -07:00
|
|
|
EINA_INLIST_FOREACH_SAFE(conn->fd_handlers, list, fd_handler)
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_fd_handler_del(fd_handler);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2012-10-19 11:24:30 -07:00
|
|
|
EINA_INLIST_FOREACH_SAFE(conn->timeouts, list, timer)
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_timeout_data_free(timer->handler);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_data_del_all(&conn->data);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2016-12-05 18:27:37 -08:00
|
|
|
if (conn->idle_enterer) ecore_idle_enterer_del(conn->idle_enterer);
|
2015-08-11 07:13:07 -07:00
|
|
|
if (conn->type && conn->shared)
|
2013-05-23 13:08:16 -07:00
|
|
|
{
|
|
|
|
if (conn->type == ELDBUS_CONNECTION_TYPE_ADDRESS)
|
2018-02-02 13:59:56 -08:00
|
|
|
{
|
|
|
|
if (address_connections)
|
|
|
|
eina_hash_del_by_data(address_connections, conn);
|
|
|
|
}
|
2013-05-23 13:08:16 -07:00
|
|
|
else if (shared_connections[conn->type - 1] == (void *) conn)
|
|
|
|
shared_connections[conn->type - 1] = NULL;
|
|
|
|
}
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
free(conn);
|
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_unref(Eldbus_Connection *conn)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
DBG("conn=%p, pre-refcount=%d", conn, conn->refcount);
|
2013-07-05 10:34:27 -07:00
|
|
|
if (--conn->refcount > 0)
|
|
|
|
return;
|
|
|
|
_eldbus_connection_free(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_free_cb_add(Eldbus_Connection *conn, Eldbus_Free_Cb cb, const void *data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(cb);
|
2013-04-23 07:40:05 -07:00
|
|
|
conn->cbs_free = eldbus_cbs_free_add(conn->cbs_free, cb, data);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_free_cb_del(Eldbus_Connection *conn, Eldbus_Free_Cb cb, const void *data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(cb);
|
2013-04-23 07:40:05 -07:00
|
|
|
conn->cbs_free = eldbus_cbs_free_del(conn->cbs_free, cb, data);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_data_set(Eldbus_Connection *conn, const char *key, const void *data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(key);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(data);
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_data_set(&(conn->data), key, data);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API void *
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_data_get(const Eldbus_Connection *conn, const char *key)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK_RETVAL(conn, NULL);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
|
2013-04-23 07:40:05 -07:00
|
|
|
return eldbus_data_get(&(((Eldbus_Connection *)conn)->data), key);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API void *
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_data_del(Eldbus_Connection *conn, const char *key)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK_RETVAL(conn, NULL);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
|
2013-04-23 07:40:05 -07:00
|
|
|
return eldbus_data_del(&(((Eldbus_Connection *)conn)->data), key);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_dispatch_name_owner_change(Eldbus_Connection_Name *cn, const char *old_id)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Context_NOC_Cb *ctx;
|
2012-10-02 14:41:58 -07:00
|
|
|
const char *previous_id = !old_id ? "" : old_id;
|
2012-09-17 13:41:05 -07:00
|
|
|
cn->event_handlers.walking++;
|
|
|
|
EINA_INLIST_FOREACH(cn->event_handlers.list, ctx)
|
|
|
|
{
|
|
|
|
if (ctx->deleted) continue;
|
2012-10-02 14:41:58 -07:00
|
|
|
if (!old_id && !ctx->allow_initial)
|
|
|
|
continue;
|
|
|
|
ctx->cb((void *)ctx->cb_data, cn->name, previous_id, cn->unique_id);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
cn->event_handlers.walking--;
|
2013-01-03 06:06:14 -08:00
|
|
|
EINA_LIST_FREE(cn->event_handlers.to_delete, ctx)
|
|
|
|
{
|
|
|
|
cn->event_handlers.list = eina_inlist_remove(cn->event_handlers.list,
|
|
|
|
EINA_INLIST_GET(ctx));
|
|
|
|
free(ctx);
|
|
|
|
}
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_name_gc(cn->name_owner_changed->conn, cn);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
2012-10-02 14:41:53 -07:00
|
|
|
typedef struct _dispach_name_owner_data
|
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Context_NOC_Cb *ctx;
|
|
|
|
const Eldbus_Connection_Name *cn;
|
2012-10-02 14:41:53 -07:00
|
|
|
} dispatch_name_owner_data;
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
dispach_name_owner_cb(void *context)
|
|
|
|
{
|
|
|
|
dispatch_name_owner_data *data = context;
|
|
|
|
data->ctx->cb((void *)data->ctx->cb_data, data->cn->name, "",
|
|
|
|
data->cn->unique_id);
|
2016-12-05 18:27:37 -08:00
|
|
|
data->ctx->idle_enterer = NULL;
|
2012-10-02 14:41:53 -07:00
|
|
|
free(data);
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_name_owner_changed_callback_add(Eldbus_Connection *conn, const char *bus, Eldbus_Name_Owner_Changed_Cb cb, const void *cb_data, Eina_Bool allow_initial_call)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Name *cn;
|
|
|
|
Eldbus_Connection_Context_NOC_Cb *ctx;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(bus);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(cb);
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
cn = eldbus_connection_name_get(conn, bus);
|
2012-12-11 11:49:37 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(cn);
|
2013-04-23 07:40:05 -07:00
|
|
|
ctx = calloc(1, sizeof(Eldbus_Connection_Context_NOC_Cb));
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_GOTO(ctx, cleanup);
|
|
|
|
ctx->cb = cb;
|
|
|
|
ctx->cb_data = cb_data;
|
2012-10-02 14:41:58 -07:00
|
|
|
ctx->allow_initial = allow_initial_call;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
cn->event_handlers.list = eina_inlist_append(cn->event_handlers.list,
|
|
|
|
EINA_INLIST_GET(ctx));
|
2012-10-02 14:41:58 -07:00
|
|
|
if (cn->unique_id && allow_initial_call)
|
2012-10-02 14:41:53 -07:00
|
|
|
{
|
|
|
|
dispatch_name_owner_data *dispatch_data;
|
|
|
|
dispatch_data = malloc(sizeof(dispatch_name_owner_data));
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(dispatch_data);
|
|
|
|
dispatch_data->cn = cn;
|
|
|
|
dispatch_data->ctx = ctx;
|
2016-12-05 18:27:37 -08:00
|
|
|
ctx->idle_enterer = ecore_idle_enterer_add(dispach_name_owner_cb, dispatch_data);
|
2012-10-02 14:41:53 -07:00
|
|
|
}
|
2012-09-17 13:41:05 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
cleanup:
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_name_gc(conn, cn);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_name_owner_changed_callback_del(Eldbus_Connection *conn, const char *bus, Eldbus_Name_Owner_Changed_Cb cb, const void *cb_data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Name *cn;
|
|
|
|
Eldbus_Connection_Context_NOC_Cb *iter, *found = NULL;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(bus);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(cb);
|
|
|
|
|
|
|
|
cn = eina_hash_find(conn->names, bus);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(cn);
|
|
|
|
|
2012-10-19 11:24:30 -07:00
|
|
|
EINA_INLIST_FOREACH(cn->event_handlers.list, iter)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
if (cb != iter->cb) continue;
|
|
|
|
if ((cb_data) && (cb_data != iter->cb_data)) continue;
|
|
|
|
|
|
|
|
found = iter;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(found);
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(found->deleted);
|
|
|
|
|
|
|
|
if (cn->event_handlers.walking)
|
|
|
|
{
|
|
|
|
found->deleted = EINA_TRUE;
|
|
|
|
cn->event_handlers.to_delete = eina_list_append
|
|
|
|
(cn->event_handlers.to_delete, found);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cn->event_handlers.list = eina_inlist_remove(cn->event_handlers.list,
|
|
|
|
EINA_INLIST_GET(found));
|
2016-12-05 18:27:37 -08:00
|
|
|
if (found->idle_enterer)
|
2012-10-02 14:41:53 -07:00
|
|
|
{
|
|
|
|
dispatch_name_owner_data *data;
|
2016-12-05 18:27:37 -08:00
|
|
|
data = ecore_idle_enterer_del(found->idle_enterer);
|
2012-10-02 14:41:53 -07:00
|
|
|
free(data);
|
|
|
|
}
|
2012-09-17 13:41:05 -07:00
|
|
|
free(found);
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_name_gc(conn, cn);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_event_callback_add(Eldbus_Connection *conn, Eldbus_Connection_Event_Type type, Eldbus_Connection_Event_Cb cb, const void *cb_data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Context_Event *ce;
|
|
|
|
Eldbus_Connection_Context_Event_Cb *ctx;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(cb);
|
2013-04-23 07:40:05 -07:00
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(type >= ELDBUS_CONNECTION_EVENT_LAST);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
ce = conn->event_handlers + type;
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
ctx = calloc(1, sizeof(Eldbus_Connection_Context_Event_Cb));
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(ctx);
|
|
|
|
ctx->cb = cb;
|
|
|
|
ctx->cb_data = cb_data;
|
|
|
|
|
|
|
|
ce->list = eina_inlist_append(ce->list, EINA_INLIST_GET(ctx));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
_eldbus_connection_context_event_cb_del(Eldbus_Connection_Context_Event *ce, Eldbus_Connection_Context_Event_Cb *ctx)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
ce->list = eina_inlist_remove(ce->list, EINA_INLIST_GET(ctx));
|
|
|
|
free(ctx);
|
|
|
|
}
|
|
|
|
|
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library
Summary:
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, raster
Subscribers: raster, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
|
|
|
ELDBUS_API void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_event_callback_del(Eldbus_Connection *conn, Eldbus_Connection_Event_Type type, Eldbus_Connection_Event_Cb cb, const void *cb_data)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Context_Event *ce;
|
|
|
|
Eldbus_Connection_Context_Event_Cb *iter, *found = NULL;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(cb);
|
2013-04-23 07:40:05 -07:00
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(type >= ELDBUS_CONNECTION_EVENT_LAST);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
ce = conn->event_handlers + type;
|
|
|
|
|
2012-10-19 11:24:30 -07:00
|
|
|
EINA_INLIST_FOREACH(ce->list, iter)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
if (cb != iter->cb) continue;
|
|
|
|
if ((cb_data) && (cb_data != iter->cb_data)) continue;
|
|
|
|
|
|
|
|
found = iter;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(found);
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(found->deleted);
|
|
|
|
|
|
|
|
if (ce->walking)
|
|
|
|
{
|
|
|
|
found->deleted = EINA_TRUE;
|
|
|
|
ce->to_delete = eina_list_append(ce->to_delete, found);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
_eldbus_connection_context_event_cb_del(ce, found);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 07:40:05 -07:00
|
|
|
_eldbus_connection_event_callback_call(Eldbus_Connection *conn, Eldbus_Connection_Event_Type type, const void *event_info)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
Eldbus_Connection_Context_Event *ce;
|
|
|
|
Eldbus_Connection_Context_Event_Cb *iter;
|
2012-09-17 13:41:05 -07:00
|
|
|
|
|
|
|
ce = conn->event_handlers + type;
|
|
|
|
|
|
|
|
ce->walking++;
|
2012-10-19 11:24:30 -07:00
|
|
|
EINA_INLIST_FOREACH(ce->list, iter)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
if (iter->deleted) continue;
|
|
|
|
iter->cb((void *)iter->cb_data, conn, (void *)event_info);
|
|
|
|
}
|
|
|
|
ce->walking--;
|
|
|
|
if (ce->walking > 0) return;
|
|
|
|
|
2012-10-19 11:24:30 -07:00
|
|
|
EINA_LIST_FREE(ce->to_delete, iter)
|
2013-04-23 07:40:05 -07:00
|
|
|
_eldbus_connection_context_event_cb_del(ce, iter);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_event_callback_call(Eldbus_Connection *conn, Eldbus_Connection_Event_Type type, const void *event_info)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK(conn);
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(type >= ELDBUS_CONNECTION_EVENT_LAST);
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(type == ELDBUS_CONNECTION_EVENT_DEL);
|
2012-09-17 13:41:05 -07:00
|
|
|
|
2013-04-23 07:40:05 -07:00
|
|
|
_eldbus_connection_event_callback_call(conn, type, event_info);
|
2012-09-17 13:41:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_signal_handler_add(Eldbus_Connection *conn, Eldbus_Signal_Handler *handler)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(handler);
|
|
|
|
conn->signal_handlers = eina_inlist_append(conn->signal_handlers,
|
|
|
|
EINA_INLIST_GET(handler));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_pending_add(Eldbus_Connection *conn, Eldbus_Pending *pending)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
2013-04-23 07:40:05 -07:00
|
|
|
ELDBUS_CONNECTION_CHECK(conn);
|
2012-09-17 13:41:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(pending);
|
|
|
|
conn->pendings = eina_inlist_append(conn->pendings,
|
|
|
|
EINA_INLIST_GET(pending));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_signal_handler_del(Eldbus_Connection *conn, Eldbus_Signal_Handler *handler)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(conn);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(handler);
|
|
|
|
conn->signal_handlers = eina_inlist_remove(conn->signal_handlers,
|
|
|
|
EINA_INLIST_GET(handler));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-23 07:40:05 -07:00
|
|
|
eldbus_connection_pending_del(Eldbus_Connection *conn, Eldbus_Pending *pending)
|
2012-09-17 13:41:05 -07:00
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(conn);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(pending);
|
|
|
|
conn->pendings = eina_inlist_remove(conn->pendings,
|
|
|
|
EINA_INLIST_GET(pending));
|
|
|
|
}
|
2013-12-01 21:57:07 -08:00
|
|
|
|
|
|
|
const char *
|
|
|
|
eldbus_connection_unique_name_get(Eldbus_Connection *conn)
|
|
|
|
{
|
|
|
|
ELDBUS_CONNECTION_CHECK_RETVAL(conn, NULL);
|
|
|
|
return dbus_bus_get_unique_name(conn->dbus_conn);
|
|
|
|
}
|