Merge branch 'master' of git://anongit.freedesktop.org/git/dbus/dbus-c++

Merge branch 'master' of git://anongit.freedesktop.org/git/dbus/dbus-c++

Conflicts:

	include/dbus-c++/connection.h
	include/dbus-c++/dispatcher.h
	include/dbus-c++/pendingcall.h
	src/dispatcher.cpp
This commit is contained in:
Andreas Volz 2008-08-14 23:59:23 +02:00
commit c1970e2352
57 changed files with 1642 additions and 1638 deletions

View file

@ -26,7 +26,7 @@ void EchoClient::Echoed( const DBus::Variant& value )
* For some strange reason, libdbus frequently dies with an OOM * For some strange reason, libdbus frequently dies with an OOM
*/ */
static const int THREADS = 16; static const int THREADS = 3;
static bool spin = true; static bool spin = true;
@ -40,7 +40,7 @@ void* greeter_thread( void* arg )
snprintf(idstr, sizeof(idstr), "%lu", pthread_self()); snprintf(idstr, sizeof(idstr), "%lu", pthread_self());
for(int i = 0; i < 100 && spin; ++i) for (int i = 0; i < 30 && spin; ++i)
{ {
cout << client.Hello(idstr) << endl; cout << client.Hello(idstr) << endl;
} }

View file

@ -17,13 +17,14 @@ EchoServer::EchoServer( DBus::Connection& connection )
{ {
} }
DBus::Int32 EchoServer::Random() int32_t EchoServer::Random()
{ {
return rand(); return rand();
} }
DBus::String EchoServer::Hello( const DBus::String& name ) std::string EchoServer::Hello(const std::string &name)
{ {
sleep (10);
return "Hello " + name + "!"; return "Hello " + name + "!";
} }
@ -34,33 +35,33 @@ DBus::Variant EchoServer::Echo( const DBus::Variant& value )
return value; return value;
} }
std::vector< DBus::Byte > EchoServer::Cat( const DBus::String & file ) std::vector< uint8_t > EchoServer::Cat(const std::string &file)
{ {
FILE *handle = fopen(file.c_str(), "rb"); FILE *handle = fopen(file.c_str(), "rb");
if (!handle) throw DBus::Error("org.freedesktop.DBus.EchoDemo.ErrorFileNotFound", "file not found"); if (!handle) throw DBus::Error("org.freedesktop.DBus.EchoDemo.ErrorFileNotFound", "file not found");
DBus::Byte buff[1024]; uint8_t buff[1024];
size_t nread = fread(buff, 1, sizeof(buff), handle); size_t nread = fread(buff, 1, sizeof(buff), handle);
fclose(handle); fclose(handle);
return std::vector< DBus::Byte > (buff, buff + nread); return std::vector< uint8_t > (buff, buff + nread);
} }
DBus::Int32 EchoServer::Sum( const std::vector<DBus::Int32>& ints ) int32_t EchoServer::Sum(const std::vector<int32_t>& ints)
{ {
DBus::Int32 sum = 0; int32_t sum = 0;
for (size_t i = 0; i < ints.size(); ++i) sum += ints[i]; for (size_t i = 0; i < ints.size(); ++i) sum += ints[i];
return sum; return sum;
} }
std::map< DBus::String, DBus::String > EchoServer::Info() std::map< std::string, std::string > EchoServer::Info()
{ {
std::map< DBus::String, DBus::String > info; std::map< std::string, std::string > info;
char hostname[HOST_NAME_MAX]; char hostname[HOST_NAME_MAX];
gethostname(hostname, sizeof(hostname)); gethostname(hostname, sizeof(hostname));

View file

@ -13,17 +13,17 @@ public:
EchoServer(DBus::Connection &connection); EchoServer(DBus::Connection &connection);
DBus::Int32 Random(); int32_t Random();
DBus::String Hello( const DBus::String & name ); std::string Hello(const std::string &name);
DBus::Variant Echo(const DBus::Variant &value); DBus::Variant Echo(const DBus::Variant &value);
std::vector< DBus::Byte > Cat( const DBus::String & file ); std::vector< uint8_t > Cat(const std::string &file);
DBus::Int32 Sum( const std::vector<DBus::Int32> & ints ); int32_t Sum(const std::vector<int32_t> & ints);
std::map< DBus::String, DBus::String > Info(); std::map< std::string, std::string > Info();
}; };
#endif//__DEMO_ECHO_SERVER_H #endif//__DEMO_ECHO_SERVER_H

View file

@ -15,7 +15,7 @@ static const char* DBUS_SERVER_PATH = "/org/freedesktop/DBus";
DBusBrowser::DBusBrowser( ::DBus::Connection& conn ) DBusBrowser::DBusBrowser( ::DBus::Connection& conn )
: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME) : ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME)
{ {
typedef std::vector< ::DBus::String > Names; typedef std::vector< std::string > Names;
Names names = ListNames(); Names names = ListNames();
@ -26,17 +26,17 @@ DBusBrowser::DBusBrowser( ::DBus::Connection& conn )
} }
void DBusBrowser::NameOwnerChanged( void DBusBrowser::NameOwnerChanged(
const ::DBus::String& name, const ::DBus::String& old_owner, const ::DBus::String& new_owner ) const std::string& name, const std::string& old_owner, const std::string& new_owner )
{ {
cout << name << ": " << old_owner << " -> " << new_owner << endl; cout << name << ": " << old_owner << " -> " << new_owner << endl;
} }
void DBusBrowser::NameLost( const ::DBus::String& name ) void DBusBrowser::NameLost( const std::string& name )
{ {
cout << name << " lost" << endl; cout << name << " lost" << endl;
} }
void DBusBrowser::NameAcquired( const ::DBus::String& name ) void DBusBrowser::NameAcquired( const std::string& name )
{ {
cout << name << " acquired" << endl; cout << name << " acquired" << endl;
} }

View file

@ -18,11 +18,11 @@ public:
private: private:
void NameOwnerChanged( const ::DBus::String&, const ::DBus::String&, const ::DBus::String& ); void NameOwnerChanged( const std::string&, const std::string&, const std::string& );
void NameLost( const ::DBus::String& ); void NameLost( const std::string& );
void NameAcquired( const ::DBus::String& ); void NameAcquired( const std::string& );
private: private:

View file

@ -19,7 +19,7 @@ DBusBrowser::DBusBrowser( ::DBus::Connection& conn )
set_border_width(5); set_border_width(5);
set_default_size(400, 500); set_default_size(400, 500);
typedef std::vector< ::DBus::String > Names; typedef std::vector< std::string > Names;
Names names = ListNames(); Names names = ListNames();
@ -46,17 +46,17 @@ DBusBrowser::DBusBrowser( ::DBus::Connection& conn )
} }
void DBusBrowser::NameOwnerChanged( void DBusBrowser::NameOwnerChanged(
const ::DBus::String& name, const ::DBus::String& old_owner, const ::DBus::String& new_owner ) const std::string &name, const std::string &old_owner, const std::string &new_owner)
{ {
cout << name << ": " << old_owner << " -> " << new_owner << endl; cout << name << ": " << old_owner << " -> " << new_owner << endl;
} }
void DBusBrowser::NameLost( const ::DBus::String& name ) void DBusBrowser::NameLost(const std::string &name)
{ {
cout << name << " lost" << endl; cout << name << " lost" << endl;
} }
void DBusBrowser::NameAcquired( const ::DBus::String& name ) void DBusBrowser::NameAcquired(const std::string &name)
{ {
cout << name << " acquired" << endl; cout << name << " acquired" << endl;
} }

View file

@ -30,11 +30,11 @@ public:
private: private:
void NameOwnerChanged( const ::DBus::String&, const ::DBus::String&, const ::DBus::String& ); void NameOwnerChanged(const std::string &, const std::string &, const std::string &);
void NameLost( const ::DBus::String& ); void NameLost(const std::string &);
void NameAcquired( const ::DBus::String& ); void NameAcquired(const std::string &);
void on_select_busname(); void on_select_busname();

View file

@ -14,9 +14,9 @@ HalManagerProxy::HalManagerProxy( DBus::Connection& connection )
connect_signal(HalManagerProxy, DeviceAdded, DeviceAddedCb); connect_signal(HalManagerProxy, DeviceAdded, DeviceAddedCb);
connect_signal(HalManagerProxy, DeviceRemoved, DeviceRemovedCb); connect_signal(HalManagerProxy, DeviceRemoved, DeviceRemovedCb);
std::vector< DBus::String > devices = GetAllDevices(); std::vector< std::string > devices = GetAllDevices();
std::vector< DBus::String >::iterator it; std::vector< std::string >::iterator it;
for (it = devices.begin(); it != devices.end(); ++it) for (it = devices.begin(); it != devices.end(); ++it)
{ {
DBus::Path udi = *it; DBus::Path udi = *it;
@ -27,9 +27,9 @@ HalManagerProxy::HalManagerProxy( DBus::Connection& connection )
} }
} }
std::vector< DBus::String > HalManagerProxy::GetAllDevices() std::vector< std::string > HalManagerProxy::GetAllDevices()
{ {
std::vector< DBus::String > udis; std::vector< std::string > udis;
DBus::CallMessage call; DBus::CallMessage call;
call.member("GetAllDevices"); call.member("GetAllDevices");
@ -44,7 +44,7 @@ std::vector< DBus::String > HalManagerProxy::GetAllDevices()
void HalManagerProxy::DeviceAddedCb(const DBus::SignalMessage &sig) void HalManagerProxy::DeviceAddedCb(const DBus::SignalMessage &sig)
{ {
DBus::MessageIter it = sig.reader(); DBus::MessageIter it = sig.reader();
DBus::String devname; std::string devname;
it >> devname; it >> devname;
@ -57,7 +57,7 @@ void HalManagerProxy::DeviceAddedCb( const DBus::SignalMessage& sig )
void HalManagerProxy::DeviceRemovedCb(const DBus::SignalMessage &sig) void HalManagerProxy::DeviceRemovedCb(const DBus::SignalMessage &sig)
{ {
DBus::MessageIter it = sig.reader(); DBus::MessageIter it = sig.reader();
DBus::String devname; std::string devname;
it >> devname; it >> devname;
@ -76,10 +76,10 @@ HalDeviceProxy::HalDeviceProxy( DBus::Connection& connection, DBus::Path& udi )
void HalDeviceProxy::PropertyModifiedCb(const DBus::SignalMessage &sig) void HalDeviceProxy::PropertyModifiedCb(const DBus::SignalMessage &sig)
{ {
typedef DBus::Struct< DBus::String, DBus::Bool, DBus::Bool > HalProperty; typedef DBus::Struct< std::string, bool, bool > HalProperty;
DBus::MessageIter it = sig.reader(); DBus::MessageIter it = sig.reader();
DBus::Int32 number; int32_t number;
it >> number; it >> number;
@ -98,7 +98,7 @@ void HalDeviceProxy::PropertyModifiedCb( const DBus::SignalMessage& sig )
void HalDeviceProxy::ConditionCb(const DBus::SignalMessage &sig) void HalDeviceProxy::ConditionCb(const DBus::SignalMessage &sig)
{ {
DBus::MessageIter it = sig.reader(); DBus::MessageIter it = sig.reader();
DBus::String condition; std::string condition;
it >> condition; it >> condition;

View file

@ -15,7 +15,7 @@ public:
HalManagerProxy(DBus::Connection &connection); HalManagerProxy(DBus::Connection &connection);
std::vector< DBus::String > GetAllDevices(); std::vector< std::string > GetAllDevices();
private: private:
@ -23,7 +23,7 @@ private:
void DeviceRemovedCb(const DBus::SignalMessage &sig); void DeviceRemovedCb(const DBus::SignalMessage &sig);
std::map< DBus::String, DBus::RefPtr< HalDeviceProxy > > _devices; std::map< std::string, DBus::RefPtr< HalDeviceProxy > > _devices;
}; };
class HalDeviceProxy class HalDeviceProxy

View file

@ -16,11 +16,11 @@ PropsServer::PropsServer( DBus::Connection& connection )
} }
void PropsServer::on_set_property void PropsServer::on_set_property
( DBus::InterfaceAdaptor& interface, const DBus::String& property, const DBus::Variant& value ) (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value)
{ {
if (property == "Message") if (property == "Message")
{ {
DBus::String msg = value; std::string msg = value;
this->MessageChanged(msg); this->MessageChanged(msg);
} }
} }

View file

@ -15,7 +15,7 @@ public:
PropsServer(DBus::Connection &connection); PropsServer(DBus::Connection &connection);
void on_set_property void on_set_property
( DBus::InterfaceAdaptor& interface, const DBus::String& property, const DBus::Variant& value ); (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value);
}; };
#endif//__DEMO_PROPS_SERVER_H #endif//__DEMO_PROPS_SERVER_H

View file

@ -41,7 +41,7 @@ class DXXAPI BusTimeout : public Timeout
{ {
private: private:
BusTimeout( Timeout::Internal*, GMainContext* ); BusTimeout(Timeout::Internal *, GMainContext *, int);
~BusTimeout(); ~BusTimeout();
@ -57,6 +57,7 @@ private:
GSource *_source; GSource *_source;
GMainContext *_ctx; GMainContext *_ctx;
int _priority;
friend class BusDispatcher; friend class BusDispatcher;
}; };
@ -65,7 +66,7 @@ class DXXAPI BusWatch : public Watch
{ {
private: private:
BusWatch( Watch::Internal*, GMainContext* ); BusWatch(Watch::Internal *, GMainContext *, int);
~BusWatch(); ~BusWatch();
@ -81,6 +82,7 @@ private:
GSource *_source; GSource *_source;
GMainContext *_ctx; GMainContext *_ctx;
int _priority;
friend class BusDispatcher; friend class BusDispatcher;
}; };
@ -88,7 +90,8 @@ friend class BusDispatcher;
class DXXAPI BusDispatcher : public Dispatcher class DXXAPI BusDispatcher : public Dispatcher
{ {
public: public:
BusDispatcher() : _ctx(NULL) {}
BusDispatcher() : _ctx(NULL), _priority(G_PRIORITY_DEFAULT) {}
void attach(GMainContext *); void attach(GMainContext *);
@ -104,9 +107,12 @@ public:
void rem_watch(Watch *); void rem_watch(Watch *);
void set_priority(int priority);
private: private:
GMainContext *_ctx; GMainContext *_ctx;
int _priority;
}; };
} /* namespace Glib */ } /* namespace Glib */

View file

@ -78,10 +78,10 @@ public:
protected: protected:
virtual void on_get_property( InterfaceAdaptor& interface, const String& property, Variant& value ) virtual void on_get_property(InterfaceAdaptor &interface, const std::string &property, Variant &value)
{} {}
virtual void on_set_property( InterfaceAdaptor& interface, const String& property, const Variant& value ) virtual void on_set_property(InterfaceAdaptor &interface, const std::string &property, const Variant &value)
{} {}
IntrospectedInterface *const introspect() const; IntrospectedInterface *const introspect() const;
@ -93,9 +93,9 @@ public:
PropertiesProxy(); PropertiesProxy();
Variant Get( const String& interface, const String& property ); Variant Get(const std::string &interface, const std::string &property);
void Set( const String& interface, const String& property, const Variant& value ); void Set(const std::string &interface, const std::string &property, const Variant &value);
}; };
} /* namespace DBus */ } /* namespace DBus */

View file

@ -27,6 +27,7 @@
#include "dbus-c++-config.h" #include "dbus-c++-config.h"
#include <stdint.h>
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
@ -38,17 +39,6 @@
namespace DBus { namespace DBus {
typedef unsigned char Byte;
typedef bool Bool;
typedef signed short Int16;
typedef unsigned short UInt16;
typedef signed int Int32;
typedef unsigned int UInt32;
typedef signed long long Int64;
typedef unsigned long long UInt64;
typedef double Double;
typedef std::string String;
struct DXXAPI Path : public std::string struct DXXAPI Path : public std::string
{ {
Path() {} Path() {}
@ -145,16 +135,16 @@ struct type
}; };
template <> struct type<Variant> { static std::string sig(){ return "v"; } }; template <> struct type<Variant> { static std::string sig(){ return "v"; } };
template <> struct type<Byte> { static std::string sig(){ return "y"; } }; template <> struct type<uint8_t> { static std::string sig(){ return "y"; } };
template <> struct type<Bool> { static std::string sig(){ return "b"; } }; template <> struct type<bool> { static std::string sig(){ return "b"; } };
template <> struct type<Int16> { static std::string sig(){ return "n"; } }; template <> struct type<int16_t> { static std::string sig(){ return "n"; } };
template <> struct type<UInt16> { static std::string sig(){ return "q"; } }; template <> struct type<uint16_t> { static std::string sig(){ return "q"; } };
template <> struct type<Int32> { static std::string sig(){ return "i"; } }; template <> struct type<int32_t> { static std::string sig(){ return "i"; } };
template <> struct type<UInt32> { static std::string sig(){ return "u"; } }; template <> struct type<uint32_t> { static std::string sig(){ return "u"; } };
template <> struct type<Int64> { static std::string sig(){ return "x"; } }; template <> struct type<int64_t> { static std::string sig(){ return "x"; } };
template <> struct type<UInt64> { static std::string sig(){ return "t"; } }; template <> struct type<uint64_t> { static std::string sig(){ return "t"; } };
template <> struct type<Double> { static std::string sig(){ return "d"; } }; template <> struct type<double> { static std::string sig(){ return "d"; } };
template <> struct type<String> { static std::string sig(){ return "s"; } }; template <> struct type<std::string> { static std::string sig(){ return "s"; } };
template <> struct type<Path> { static std::string sig(){ return "o"; } }; template <> struct type<Path> { static std::string sig(){ return "o"; } };
template <> struct type<Signature> { static std::string sig(){ return "g"; } }; template <> struct type<Signature> { static std::string sig(){ return "g"; } };
template <> struct type<Invalid> { static std::string sig(){ return ""; } }; template <> struct type<Invalid> { static std::string sig(){ return ""; } };
@ -201,61 +191,61 @@ inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Inv
return iter; return iter;
} }
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Byte& val ) inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint8_t &val)
{ {
iter.append_byte(val); iter.append_byte(val);
return iter; return iter;
} }
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Bool& val ) inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const bool &val)
{ {
iter.append_bool(val); iter.append_bool(val);
return iter; return iter;
} }
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Int16& val ) inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int16_t& val)
{ {
iter.append_int16(val); iter.append_int16(val);
return iter; return iter;
} }
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::UInt16& val ) inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint16_t& val)
{ {
iter.append_uint16(val); iter.append_uint16(val);
return iter; return iter;
} }
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Int32& val ) inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int32_t& val)
{ {
iter.append_int32(val); iter.append_int32(val);
return iter; return iter;
} }
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::UInt32& val ) inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint32_t& val)
{ {
iter.append_uint32(val); iter.append_uint32(val);
return iter; return iter;
} }
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Int64& val ) inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int64_t& val)
{ {
iter.append_int64(val); iter.append_int64(val);
return iter; return iter;
} }
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::UInt64& val ) inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint64_t& val)
{ {
iter.append_uint64(val); iter.append_uint64(val);
return iter; return iter;
} }
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Double& val ) inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const double &val)
{ {
iter.append_double(val); iter.append_double(val);
return iter; return iter;
} }
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::String& val ) inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::string &val)
{ {
iter.append_string(val.c_str()); iter.append_string(val.c_str());
return iter; return iter;
@ -290,7 +280,7 @@ inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::vect
} }
template<> template<>
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::vector<DBus::Byte>& val ) inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::vector<uint8_t>& val)
{ {
DBus::MessageIter ait = iter.new_array("y"); DBus::MessageIter ait = iter.new_array("y");
ait.append_array('y', &val.front(), val.size()); ait.append_array('y', &val.front(), val.size());
@ -353,61 +343,61 @@ inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Invalid&
return iter; return iter;
} }
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Byte& val ) inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint8_t &val)
{ {
val = iter.get_byte(); val = iter.get_byte();
return ++iter; return ++iter;
} }
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Bool& val ) inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, bool &val)
{ {
val = iter.get_bool(); val = iter.get_bool();
return ++iter; return ++iter;
} }
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Int16& val ) inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int16_t& val)
{ {
val = iter.get_int16(); val = iter.get_int16();
return ++iter; return ++iter;
} }
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::UInt16& val ) inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint16_t& val)
{ {
val = iter.get_uint16(); val = iter.get_uint16();
return ++iter; return ++iter;
} }
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Int32& val ) inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int32_t& val)
{ {
val = iter.get_int32(); val = iter.get_int32();
return ++iter; return ++iter;
} }
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::UInt32& val ) inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint32_t& val)
{ {
val = iter.get_uint32(); val = iter.get_uint32();
return ++iter; return ++iter;
} }
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Int64& val ) inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int64_t& val)
{ {
val = iter.get_int64(); val = iter.get_int64();
return ++iter; return ++iter;
} }
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::UInt64& val ) inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint64_t& val)
{ {
val = iter.get_uint64(); val = iter.get_uint64();
return ++iter; return ++iter;
} }
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Double& val ) inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, double &val)
{ {
val = iter.get_double(); val = iter.get_double();
return ++iter; return ++iter;
} }
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::String& val ) inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::string &val)
{ {
val = iter.get_string(); val = iter.get_string();
return ++iter; return ++iter;
@ -445,7 +435,7 @@ inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector<E>&
} }
template<> template<>
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector<DBus::Byte>& val ) inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector<uint8_t>& val)
{ {
if (!iter.is_array()) if (!iter.is_array())
throw DBus::ErrorInvalidArgs("array expected"); throw DBus::ErrorInvalidArgs("array expected");
@ -455,7 +445,7 @@ inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector<DBu
DBus::MessageIter ait = iter.recurse(); DBus::MessageIter ait = iter.recurse();
DBus::Byte* array; uint8_t *array;
size_t length = ait.get_array(&array); size_t length = ait.get_array(&array);
val.insert(val.end(), array, array+length); val.insert(val.end(), array, array+length);

View file

@ -31,8 +31,8 @@
using namespace DBus; using namespace DBus;
Glib::BusTimeout::BusTimeout( Timeout::Internal* ti, GMainContext* ctx ) Glib::BusTimeout::BusTimeout(Timeout::Internal *ti, GMainContext *ctx, int priority)
: Timeout(ti), _ctx(ctx) : Timeout(ti), _ctx(ctx), _priority(priority)
{ {
_enable(); _enable();
} }
@ -62,6 +62,7 @@ gboolean Glib::BusTimeout::timeout_handler( gpointer data )
void Glib::BusTimeout::_enable() void Glib::BusTimeout::_enable()
{ {
_source = g_timeout_source_new(Timeout::interval()); _source = g_timeout_source_new(Timeout::interval());
g_source_set_priority(_source, _priority);
g_source_set_callback(_source, timeout_handler, this, NULL); g_source_set_callback(_source, timeout_handler, this, NULL);
g_source_attach(_source, _ctx); g_source_attach(_source, _ctx);
} }
@ -109,8 +110,8 @@ static GSourceFuncs watch_funcs = {
NULL NULL
}; };
Glib::BusWatch::BusWatch( Watch::Internal* wi, GMainContext* ctx ) Glib::BusWatch::BusWatch(Watch::Internal *wi, GMainContext *ctx, int priority)
: Watch(wi), _ctx(ctx) : Watch(wi), _ctx(ctx), _priority(priority)
{ {
_enable(); _enable();
} }
@ -152,6 +153,7 @@ gboolean Glib::BusWatch::watch_handler( gpointer data )
void Glib::BusWatch::_enable() void Glib::BusWatch::_enable()
{ {
_source = g_source_new(&watch_funcs, sizeof(BusSource)); _source = g_source_new(&watch_funcs, sizeof(BusSource));
g_source_set_priority(_source, _priority);
g_source_set_callback(_source, watch_handler, this, NULL); g_source_set_callback(_source, watch_handler, this, NULL);
int flags = Watch::flags(); int flags = Watch::flags();
@ -189,7 +191,7 @@ void Glib::BusDispatcher::attach( GMainContext* ctx )
Timeout *Glib::BusDispatcher::add_timeout(Timeout::Internal *wi) Timeout *Glib::BusDispatcher::add_timeout(Timeout::Internal *wi)
{ {
Timeout* t = new Glib::BusTimeout(wi, _ctx); Timeout *t = new Glib::BusTimeout(wi, _ctx, _priority);
debug_log("glib: added timeout %p (%s)", t, t->enabled() ? "on":"off"); debug_log("glib: added timeout %p (%s)", t, t->enabled() ? "on":"off");
@ -205,7 +207,7 @@ void Glib::BusDispatcher::rem_timeout( Timeout* t )
Watch *Glib::BusDispatcher::add_watch(Watch::Internal *wi) Watch *Glib::BusDispatcher::add_watch(Watch::Internal *wi)
{ {
Watch* w = new Glib::BusWatch(wi, _ctx); Watch *w = new Glib::BusWatch(wi, _ctx, _priority);
debug_log("glib: added watch %p (%s) fd=%d flags=%d", debug_log("glib: added watch %p (%s) fd=%d flags=%d",
w, w->enabled() ? "on":"off", w->descriptor(), w->flags() w, w->enabled() ? "on":"off", w->descriptor(), w->flags()
@ -219,3 +221,8 @@ void Glib::BusDispatcher::rem_watch( Watch* w )
delete w; delete w;
} }
void Glib::BusDispatcher::set_priority(int priority)
{
_priority = priority;
}

View file

@ -46,8 +46,8 @@ Message PropertiesAdaptor::Get( const CallMessage& call )
{ {
MessageIter ri = call.reader(); MessageIter ri = call.reader();
String iface_name; std::string iface_name;
String property_name; std::string property_name;
ri >> iface_name >> property_name; ri >> iface_name >> property_name;
@ -77,8 +77,8 @@ Message PropertiesAdaptor::Set( const CallMessage& call )
{ {
MessageIter ri = call.reader(); MessageIter ri = call.reader();
String iface_name; std::string iface_name;
String property_name; std::string property_name;
Variant value; Variant value;
ri >> iface_name >> property_name >> value; ri >> iface_name >> property_name >> value;
@ -142,14 +142,14 @@ PropertiesProxy::PropertiesProxy()
{ {
} }
Variant PropertiesProxy::Get( const String& iface, const String& property ) Variant PropertiesProxy::Get(const std::string &iface, const std::string &property)
{ {
//todo //todo
Variant v; Variant v;
return v; return v;
} }
void PropertiesProxy::Set( const String& iface, const String& property, const Variant& value ) void PropertiesProxy::Set(const std::string &iface, const std::string &property, const Variant &value)
{ {
//todo //todo
} }

View file

@ -87,16 +87,16 @@ const char* atomic_type_to_string( char t )
{ {
static struct { char type; const char *name; } atos[] = static struct { char type; const char *name; } atos[] =
{ {
{ 'y', "::DBus::Byte" }, { 'y', "uint8_t" },
{ 'b', "::DBus::Bool" }, { 'b', "bool" },
{ 'n', "::DBus::Int16" }, { 'n', "int16_t" },
{ 'q', "::DBus::UInt16" }, { 'q', "uint16_t" },
{ 'i', "::DBus::Int32" }, { 'i', "int32_t" },
{ 'u', "::DBus::UInt32" }, { 'u', "uint32_t" },
{ 'x', "::DBus::Int64" }, { 'x', "int64_t" },
{ 't', "::DBus::UInt64" }, { 't', "uint64_t" },
{ 'd', "::DBus::Double" }, { 'd', "double" },
{ 's', "::DBus::String" }, { 's', "std::string" },
{ 'o', "::DBus::Path" }, { 'o', "::DBus::Path" },
{ 'g', "::DBus::Signature" }, { 'g', "::DBus::Signature" },
{ 'v', "::DBus::Variant" }, { 'v', "::DBus::Variant" },