summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Volz <andreas@er00923n.fritz.box>2011-03-10 12:44:39 +0100
committerAndreas Volz <andreas@er00923n.fritz.box>2011-03-10 12:44:39 +0100
commit987d0f72a4decd6e64d0dc01612d2801688340f7 (patch)
tree81d596ec3ebf10bb9db4792915702f2345cd0d1c
parentcdedb019b026eb7bc1b909fd73d12e9c78b32a88 (diff)
downloaddbus-c++-987d0f72a4decd6e64d0dc01612d2801688340f7.tar.gz
repair ecore mainloop dispatcher
-rw-r--r--README3
-rw-r--r--include/dbus-c++/ecore-integration.h19
-rw-r--r--src/debug.cpp4
-rw-r--r--src/ecore-integration.cpp110
-rw-r--r--src/glib-integration.cpp4
5 files changed, 65 insertions, 75 deletions
diff --git a/README b/README
index dbf9420..950e618 100644
--- a/README
+++ b/README
@@ -1,6 +1,7 @@
Debugging
---------
-To compile debugging code configure the project with the --enable-debug option. Then at runtime you may export the environment variable "DBUSXX_VERBOSE" to any value.
+To compile debugging code configure the project with the --enable-debug option.
+Then at runtime you may export the environment variable "DBUSXX_VERBOSE" to any value.
BUGS:
diff --git a/include/dbus-c++/ecore-integration.h b/include/dbus-c++/ecore-integration.h
index 395384a..b198b9d 100644
--- a/include/dbus-c++/ecore-integration.h
+++ b/include/dbus-c++/ecore-integration.h
@@ -69,16 +69,19 @@ private:
void toggle();
- static Eina_Bool watch_handler_read ( void*, Ecore_Fd_Handler *fdh);
-
- static Eina_Bool watch_handler_error ( void*, Ecore_Fd_Handler *fdh);
+ static Eina_Bool watch_check ( void *data, Ecore_Fd_Handler *fdh);
+ static Eina_Bool watch_prepare ( void *data, Ecore_Fd_Handler *fdh);
+ static Eina_Bool watch_dispatch ( void *data, Ecore_Fd_Handler *fdh);
void _enable();
void _disable();
+ void data (Ecore::BusDispatcher *bd);
+
private:
- Ecore_Fd_Handler *fd_handler_read;
+ Ecore_Fd_Handler *fd_handler;
+ Ecore::BusDispatcher *_bd;
friend class BusDispatcher;
};
@@ -86,9 +89,7 @@ friend class BusDispatcher;
class DXXAPI BusDispatcher : public Dispatcher
{
public:
- BusDispatcher() {}
-
- void attach();
+ BusDispatcher();
void enter() {}
@@ -102,8 +103,10 @@ public:
void rem_watch( Watch* );
-private:
+ static Eina_Bool dispatch ( void *data, Ecore_Fd_Handler *fdh);
+ static Eina_Bool check ( void *data, Ecore_Fd_Handler *fdh);
+private:
};
} /* namespace Ecore */
diff --git a/src/debug.cpp b/src/debug.cpp
index 4f97dae..29e3667 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -33,7 +33,7 @@
static void _debug_log_default(const char *format, ...)
{
-#ifdef DEBUG
+//#ifdef DEBUG
static int debug_env = getenv("DBUSXX_VERBOSE") ? 1 : 0;
@@ -49,7 +49,7 @@ static void _debug_log_default(const char *format, ...)
va_end(args);
}
-#endif//DEBUG
+//#endif//DEBUG
}
DBus::LogFunction DBus::debug_log = _debug_log_default;
diff --git a/src/ecore-integration.cpp b/src/ecore-integration.cpp
index 650e14d..0aea0eb 100644
--- a/src/ecore-integration.cpp
+++ b/src/ecore-integration.cpp
@@ -31,10 +31,15 @@
using namespace DBus;
+Dispatcher *gdispatcher = NULL;
+
Ecore::BusTimeout::BusTimeout( Timeout::Internal* ti)
: Timeout(ti)
{
- _enable();
+ if (Timeout::enabled())
+ {
+ _enable();
+ }
}
Ecore::BusTimeout::~BusTimeout()
@@ -46,8 +51,14 @@ void Ecore::BusTimeout::toggle()
{
debug_log("ecore: timeout %p toggled (%s)", this, Timeout::enabled() ? "on":"off");
- if(Timeout::enabled()) _enable();
- else _disable();
+ if(Timeout::enabled())
+ {
+ _enable();
+ }
+ else
+ {
+ _disable();
+ }
}
Eina_Bool Ecore::BusTimeout::timeout_handler( void *data )
@@ -58,7 +69,7 @@ Eina_Bool Ecore::BusTimeout::timeout_handler( void *data )
t->handle();
- return 1; // 1 -> reshedule in ecore for next timer interval
+ return ECORE_CALLBACK_RENEW;
}
void Ecore::BusTimeout::_enable()
@@ -75,33 +86,9 @@ void Ecore::BusTimeout::_disable()
ecore_timer_del (_etimer);
}
-/*static bool watch_prepare( int *timeout )
-{
- debug_log("ecore: watch_prepare");
-
- *timeout = -1;
- return false;
-}*/
-
-/*static bool watch_check( )
-{
- debug_log("ecore: watch_check");
-
- return true;
-}*/
-
-static bool watch_dispatch( void *data )
-{
- debug_log("ecore: watch_dispatch");
-
- bool cb = true;
- DBus::default_dispatcher->dispatch_pending(); //TODO: won't work in case of multiple dispatchers
- return cb;
-}
-
Ecore::BusWatch::BusWatch( Watch::Internal* wi)
-: Watch(wi), fd_handler_read (NULL)
-{
+: Watch(wi), fd_handler (NULL), _bd (NULL)
+{
if (Watch::enabled())
{
_enable();
@@ -121,58 +108,56 @@ void Ecore::BusWatch::toggle()
else _disable();
}
-Eina_Bool Ecore::BusWatch::watch_handler_read( void *data, Ecore_Fd_Handler *fdh )
+Eina_Bool Ecore::BusWatch::watch_dispatch( void *data, Ecore_Fd_Handler *fdh )
{
Ecore::BusWatch* w = reinterpret_cast<Ecore::BusWatch*>(data);
- debug_log("ecore: watch_handler_read");
-
- int flags = DBUS_WATCH_READABLE;
-
- watch_dispatch(NULL);
-
- w->handle(flags);
-
- return 1;
-}
+ debug_log("Ecore::BusWatch watch_handler_read");
-/*Eina_Bool Ecore::BusWatch::watch_handler_error( void *data, Ecore_Fd_Handler *fdh )
-{
- //Ecore::BusWatch* w = reinterpret_cast<Ecore::BusWatch*>(data);
+ int flags = flags;
- debug_log("ecore: watch_handler_error");
+ if (w->flags() & DBUS_WATCH_READABLE)
+ ecore_main_fd_handler_active_set(w->fd_handler, ECORE_FD_READ);
+ if (w->flags() & DBUS_WATCH_WRITABLE)
+ ecore_main_fd_handler_active_set(w->fd_handler, ECORE_FD_WRITE);
- //int flags = DBUS_WATCH_ERROR;
-
- watch_dispatch(NULL);
+ w->handle(flags);
+ w->_bd->dispatch_pending();
return 1;
-}*/
+}
void Ecore::BusWatch::_enable()
{
debug_log("Ecore::BusWatch::_enable()");
-
- fd_handler_read = ecore_main_fd_handler_add (Watch::descriptor(),
- ECORE_FD_READ,
- watch_handler_read,
- this,
- NULL, NULL);
-
- ecore_main_fd_handler_active_set(fd_handler_read, ECORE_FD_READ);
+
+ fd_handler = ecore_main_fd_handler_add (descriptor(),
+ (Ecore_Fd_Handler_Flags) (ECORE_FD_READ | ECORE_FD_WRITE),
+ watch_dispatch, this,
+ NULL, NULL);
}
void Ecore::BusWatch::_disable()
{
- if (fd_handler_read)
+ if (fd_handler)
{
- ecore_main_fd_handler_del (fd_handler_read);
- fd_handler_read = NULL;
+ ecore_main_fd_handler_del (fd_handler);
+ fd_handler = NULL;
}
}
-void Ecore::BusDispatcher::attach( )
+void Ecore::BusWatch::data (Ecore::BusDispatcher *bd)
+{
+ _bd = bd;
+}
+
+Ecore::BusDispatcher::BusDispatcher()
+{
+}
+
+Eina_Bool Ecore::BusDispatcher::check ( void *data, Ecore_Fd_Handler *fdh)
{
+ return 0;
}
Timeout* Ecore::BusDispatcher::add_timeout( Timeout::Internal* wi )
@@ -193,7 +178,8 @@ void Ecore::BusDispatcher::rem_timeout( Timeout* t )
Watch* Ecore::BusDispatcher::add_watch( Watch::Internal* wi )
{
- Watch* w = new Ecore::BusWatch(wi);
+ Ecore::BusWatch* w = new Ecore::BusWatch(wi);
+ w->data (this);
debug_log("ecore: added watch %p (%s) fd=%d flags=%d",
w, w->enabled() ? "on":"off", w->descriptor(), w->flags()
diff --git a/src/glib-integration.cpp b/src/glib-integration.cpp
index 491c950..ac2bb27 100644
--- a/src/glib-integration.cpp
+++ b/src/glib-integration.cpp
@@ -87,7 +87,7 @@ struct BusSource
static gboolean watch_prepare(GSource *source, gint *timeout)
{
- //debug_log("glib: watch_prepare");
+ debug_log("glib: watch_prepare");
*timeout = -1;
return FALSE;
@@ -95,7 +95,7 @@ static gboolean watch_prepare(GSource *source, gint *timeout)
static gboolean watch_check(GSource *source)
{
- //debug_log("glib: watch_check");
+ debug_log("glib: watch_check");
BusSource *io = (BusSource *)source;
return io->poll.revents ? TRUE : FALSE;