moved the D-Bus component into its own thread.
various API changes and fixes. git-svn-id: http://dev.openwengo.org/svn/openwengo/wengophone-ng/branches/wengophone-dbus-api/libs/dbus@7852 30a43799-04e7-0310-8b2b-ea0d24f86d0e
This commit is contained in:
parent
42ea920aeb
commit
24637001ce
9 changed files with 77 additions and 38 deletions
|
@ -28,20 +28,24 @@
|
|||
#include <cstdio>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int debug_env = -1;
|
||||
|
||||
static void _debug_log_default(const char* format, ...)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
||||
if(getenv("DBUSXX_VERBOSE"))
|
||||
if(debug_env < 0) debug_env = getenv("DBUSXX_VERBOSE") ? 1 : 0;
|
||||
|
||||
if(debug_env)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
fprintf(stderr, "dbus-c++: ");
|
||||
vfprintf(stderr, format, args);
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "dbus-c++: ");
|
||||
vfprintf(stderr, format, args);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
va_end(args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#endif//DEBUG
|
||||
|
|
|
@ -303,7 +303,7 @@ void MessageIter::close_container( MessageIter& container )
|
|||
|
||||
void MessageIter::copy_data( MessageIter& to )
|
||||
{
|
||||
for(MessageIter from = *this; from.at_end(); ++from)
|
||||
for(MessageIter& from = *this; !from.at_end(); ++from)
|
||||
{
|
||||
switch(from.type())
|
||||
{
|
||||
|
@ -320,6 +320,8 @@ void MessageIter::copy_data( MessageIter& to )
|
|||
case DBUS_TYPE_OBJECT_PATH:
|
||||
case DBUS_TYPE_SIGNATURE:
|
||||
{
|
||||
debug_log("copying basic type: %c", from.type());
|
||||
|
||||
unsigned char value[8];
|
||||
from.get_basic(from.type(), &value);
|
||||
to.append_basic(from.type(), &value);
|
||||
|
@ -333,12 +335,14 @@ void MessageIter::copy_data( MessageIter& to )
|
|||
MessageIter from_container = from.recurse();
|
||||
char* sig = from_container.signature();
|
||||
|
||||
MessageIter to_container(to.msg());
|
||||
debug_log("copying compound type: %c[%s]", from.type(), sig);
|
||||
|
||||
MessageIter to_container (to.msg());
|
||||
dbus_message_iter_open_container
|
||||
(
|
||||
(DBusMessageIter*)&(to._iter),
|
||||
from.type(),
|
||||
sig,
|
||||
from.type() == DBUS_TYPE_VARIANT ? NULL : sig,
|
||||
(DBusMessageIter*)&(to_container._iter)
|
||||
);
|
||||
|
||||
|
@ -376,6 +380,15 @@ Message::~Message()
|
|||
dbus_message_unref(_pvt->msg);
|
||||
}
|
||||
|
||||
Message& Message::operator = ( const Message& m )
|
||||
{
|
||||
if(&m != this)
|
||||
{
|
||||
_pvt = m._pvt;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Message Message::copy()
|
||||
{
|
||||
Private* pvt = new Private(dbus_message_copy(_pvt->msg));
|
||||
|
|
|
@ -175,11 +175,6 @@ void ObjectAdaptor::_emit_signal( SignalMessage& sig )
|
|||
conn().send(sig);
|
||||
}
|
||||
|
||||
struct WontReturnException
|
||||
{
|
||||
const void* tag;
|
||||
};
|
||||
|
||||
bool ObjectAdaptor::handle_message( const Message& msg )
|
||||
{
|
||||
switch( msg.type() )
|
||||
|
@ -205,9 +200,9 @@ bool ObjectAdaptor::handle_message( const Message& msg )
|
|||
ErrorMessage em(cmsg, e.name(), e.message());
|
||||
conn().send(em);
|
||||
}
|
||||
catch(WontReturnException& wre)
|
||||
catch(Tag* tag)
|
||||
{
|
||||
_continuations[wre.tag] = new Continuation(conn(), cmsg, wre.tag);
|
||||
_continuations[tag] = new Continuation(conn(), cmsg, tag);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -223,11 +218,9 @@ bool ObjectAdaptor::handle_message( const Message& msg )
|
|||
}
|
||||
}
|
||||
|
||||
void ObjectAdaptor::return_later( const void* tag )
|
||||
void ObjectAdaptor::return_later( const Tag* tag )
|
||||
{
|
||||
WontReturnException wre = { tag };
|
||||
|
||||
throw wre;
|
||||
throw tag;
|
||||
}
|
||||
|
||||
void ObjectAdaptor::return_now( Continuation* ret )
|
||||
|
@ -252,14 +245,14 @@ void ObjectAdaptor::return_error( Continuation* ret, const Error error )
|
|||
_continuations.erase(di);
|
||||
}
|
||||
|
||||
ObjectAdaptor::Continuation* ObjectAdaptor::find_continuation( const void* tag )
|
||||
ObjectAdaptor::Continuation* ObjectAdaptor::find_continuation( const Tag* tag )
|
||||
{
|
||||
ContinuationMap::iterator di = _continuations.find(tag);
|
||||
|
||||
return di != _continuations.end() ? di->second : NULL;
|
||||
}
|
||||
|
||||
ObjectAdaptor::Continuation::Continuation( Connection& conn, const CallMessage& call, const void* tag )
|
||||
ObjectAdaptor::Continuation::Continuation( Connection& conn, const CallMessage& call, const Tag* tag )
|
||||
: _conn(conn), _call(call), _return(_call), _tag(tag)
|
||||
{
|
||||
_writer = _return.writer(); //todo: verify
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <dbus-c++/debug.h>
|
||||
#include <dbus-c++/property.h>
|
||||
|
||||
#include <dbus-c++/introspection.h>
|
||||
|
@ -46,6 +46,8 @@ Message PropertiesAdaptor::Get( const CallMessage& call )
|
|||
|
||||
ri >> iface_name >> property_name;
|
||||
|
||||
debug_log("requesting property %s on interface %s\n", property_name.c_str(), iface_name.c_str());
|
||||
|
||||
InterfaceAdaptor* interface = (InterfaceAdaptor*) find_interface(iface_name);
|
||||
|
||||
if(!interface)
|
||||
|
@ -63,7 +65,6 @@ Message PropertiesAdaptor::Get( const CallMessage& call )
|
|||
MessageIter wi = reply.writer();
|
||||
|
||||
wi << *value;
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,13 @@ MessageIter& operator >> ( MessageIter& iter, Variant& val )
|
|||
{
|
||||
//TODO: check if iter really points to a variant
|
||||
|
||||
val = Variant(iter);
|
||||
val.clear();
|
||||
|
||||
MessageIter vit = iter.recurse();
|
||||
MessageIter mit = val.writer();
|
||||
|
||||
vit.copy_data(mit);
|
||||
|
||||
return ++iter;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue