test
This commit is contained in:
parent
532f48d019
commit
687588c5c1
3 changed files with 57 additions and 31 deletions
1
README
1
README
|
@ -6,4 +6,3 @@ Hints
|
||||||
-----
|
-----
|
||||||
Your applications based on dbus-c++ have to support PTHREAD and to export the variable HAVE_PTHREAD_H. This is a work in progress and my change.
|
Your applications based on dbus-c++ have to support PTHREAD and to export the variable HAVE_PTHREAD_H. This is a work in progress and my change.
|
||||||
|
|
||||||
test
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "dispatcher.h"
|
#include "dispatcher.h"
|
||||||
#include "Ecore_Dispatcher.h"
|
#include "Ecore.h"
|
||||||
|
|
||||||
namespace DBus {
|
namespace DBus {
|
||||||
|
|
||||||
|
@ -72,16 +72,19 @@ private:
|
||||||
|
|
||||||
void toggle();
|
void toggle();
|
||||||
|
|
||||||
static void watch_handler( void* );
|
static int watch_handler_read ( void*, Ecore_Fd_Handler *fdh);
|
||||||
|
|
||||||
|
static int watch_handler_error ( void*, Ecore_Fd_Handler *fdh);
|
||||||
|
|
||||||
void _enable();
|
void _enable();
|
||||||
|
|
||||||
void _disable();
|
void _disable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ecore_Dispatcher _edispatcher;
|
|
||||||
//GSource* _source;
|
//GSource* _source;
|
||||||
//GMainContext* _ctx;
|
//GMainContext* _ctx;
|
||||||
|
Ecore_Fd_Handler *fd_handler_read;
|
||||||
|
Ecore_Fd_Handler *fd_handler_error;
|
||||||
|
|
||||||
friend class BusDispatcher;
|
friend class BusDispatcher;
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,7 +59,7 @@ int Ecore::BusTimeout::timeout_handler( void *data )
|
||||||
|
|
||||||
t->handle();
|
t->handle();
|
||||||
|
|
||||||
return 1; // 1 -> reshedule for next timer interval
|
return 1; // 1 -> reshedule in ecore for next timer interval
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ecore::BusTimeout::_enable()
|
void Ecore::BusTimeout::_enable()
|
||||||
|
@ -145,50 +145,71 @@ void Ecore::BusWatch::toggle()
|
||||||
else _disable();
|
else _disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ecore::BusWatch::watch_handler( void *data )
|
int Ecore::BusWatch::watch_handler_read( void *data, Ecore_Fd_Handler *fdh )
|
||||||
{
|
{
|
||||||
Ecore::BusWatch* w = reinterpret_cast<Ecore::BusWatch*>(data);
|
Ecore::BusWatch* w = reinterpret_cast<Ecore::BusWatch*>(data);
|
||||||
|
|
||||||
debug_log("ecore: watch_handler");
|
debug_log("ecore: watch_handler_read");
|
||||||
|
|
||||||
//BusSource* io = (BusSource*)(w->_source);
|
int flags = DBUS_WATCH_READABLE;
|
||||||
|
|
||||||
int flags = 0;
|
|
||||||
/*if(io->poll.revents & G_IO_IN)
|
|
||||||
flags |= DBUS_WATCH_READABLE;
|
|
||||||
if(io->poll.revents & G_IO_OUT)
|
|
||||||
flags |= DBUS_WATCH_WRITABLE;
|
|
||||||
if(io->poll.revents & G_IO_ERR)
|
|
||||||
flags |= DBUS_WATCH_ERROR;
|
|
||||||
if(io->poll.revents & G_IO_HUP)
|
|
||||||
flags |= DBUS_WATCH_HANGUP;*/
|
|
||||||
|
|
||||||
w->handle(flags);
|
w->handle(flags);
|
||||||
|
|
||||||
//return true;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Ecore::BusWatch::watch_handler_error( void *data, Ecore_Fd_Handler *fdh )
|
||||||
|
{
|
||||||
|
Ecore::BusWatch* w = reinterpret_cast<Ecore::BusWatch*>(data);
|
||||||
|
|
||||||
|
debug_log("ecore: watch_handler_error");
|
||||||
|
|
||||||
|
int flags = DBUS_WATCH_ERROR;
|
||||||
|
|
||||||
|
//w->handle(flags);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ecore::BusWatch::_enable()
|
void Ecore::BusWatch::_enable()
|
||||||
{
|
{
|
||||||
debug_log("Ecore::BusWatch::_enable()");
|
debug_log("Ecore::BusWatch::_enable()");
|
||||||
|
|
||||||
|
//int flags = Watch::flags();
|
||||||
|
//Ecore_Fd_Handler_Flags condition = ECORE_FD_READ;
|
||||||
|
|
||||||
|
// TODO: create second handler for ECORE_FD_ERROR case
|
||||||
|
|
||||||
ecore_dispatcher_init (&_edispatcher, watch_handler);
|
/*if(flags & DBUS_WATCH_READABLE)
|
||||||
|
condition |= ECORE_FD_READ;
|
||||||
|
// if(flags & DBUS_WATCH_WRITABLE)
|
||||||
|
// condition |= G_IO_OUT;
|
||||||
|
if(flags & DBUS_WATCH_ERROR)
|
||||||
|
condition |= ECORE_FD_ERROR;
|
||||||
|
//if(flags & DBUS_WATCH_HANGUP)
|
||||||
|
//condition |= G_IO_HUP;*/
|
||||||
|
|
||||||
|
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_error = ecore_main_fd_handler_add (Watch::descriptor(),
|
||||||
|
ECORE_FD_ERROR,
|
||||||
|
watch_handler_error,
|
||||||
|
this,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
ecore_main_fd_handler_active_set(fd_handler_error, ECORE_FD_ERROR);
|
||||||
|
|
||||||
// TODO: port this
|
// TODO: port this
|
||||||
/*_source = g_source_new(&watch_funcs, sizeof(BusSource));
|
/*_source = g_source_new(&watch_funcs, sizeof(BusSource));
|
||||||
g_source_set_callback(_source, watch_handler, this, NULL);
|
g_source_set_callback(_source, watch_handler, this, NULL);
|
||||||
|
|
||||||
int flags = Watch::flags();
|
|
||||||
int condition = 0;
|
|
||||||
|
|
||||||
if(flags & DBUS_WATCH_READABLE)
|
|
||||||
condition |= G_IO_IN;
|
|
||||||
// if(flags & DBUS_WATCH_WRITABLE)
|
|
||||||
// condition |= G_IO_OUT;
|
|
||||||
if(flags & DBUS_WATCH_ERROR)
|
|
||||||
condition |= G_IO_ERR;
|
|
||||||
if(flags & DBUS_WATCH_HANGUP)
|
|
||||||
condition |= G_IO_HUP;
|
|
||||||
|
|
||||||
GPollFD* poll = &(((BusSource*)_source)->poll);
|
GPollFD* poll = &(((BusSource*)_source)->poll);
|
||||||
poll->fd = Watch::descriptor();
|
poll->fd = Watch::descriptor();
|
||||||
|
@ -201,6 +222,9 @@ void Ecore::BusWatch::_enable()
|
||||||
|
|
||||||
void Ecore::BusWatch::_disable()
|
void Ecore::BusWatch::_disable()
|
||||||
{
|
{
|
||||||
|
ecore_main_fd_handler_del (fd_handler_read);
|
||||||
|
ecore_main_fd_handler_del (fd_handler_error);
|
||||||
|
|
||||||
// TODO: port this
|
// TODO: port this
|
||||||
/*GPollFD* poll = &(((BusSource*)_source)->poll);
|
/*GPollFD* poll = &(((BusSource*)_source)->poll);
|
||||||
g_source_remove_poll(_source, poll);
|
g_source_remove_poll(_source, poll);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue