- NO FUNCTIONAL CODE CHANGES!!!!

- changed code formating from tabs to spaces and others
- used astyle with this option:
  --style=ansi --indent=spaces=2 -M --pad-oper --unpad-paren --pad-header --align-pointer=name --lineend=linux
This commit is contained in:
Andreas Volz 2011-11-28 12:44:11 +01:00
parent b100e9d32a
commit 1c8e43e6d6
76 changed files with 5691 additions and 5492 deletions

View file

@ -15,7 +15,7 @@ static const char *ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo";
static const char *ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo";
EchoClient::EchoClient(DBus::Connection &connection, const char *path, const char *name)
: DBus::ObjectProxy(connection, path, name)
: DBus::ObjectProxy(connection, path, name)
{
}
@ -42,7 +42,7 @@ void *greeter_thread(void *arg)
snprintf(idstr, sizeof(idstr), "%lu", pthread_self());
thread_pipe_list[i]->write (idstr, strlen (idstr) + 1);
thread_pipe_list[i]->write(idstr, strlen(idstr) + 1);
cout << idstr << " done (" << i << ")" << endl;
@ -56,33 +56,33 @@ void niam(int sig)
dispatcher.leave();
}
void handler1 (const void *data, void *buffer, unsigned int nbyte)
void handler1(const void *data, void *buffer, unsigned int nbyte)
{
char *str = (char*) buffer;
char *str = (char *) buffer;
cout << "buffer1: " << str << ", size: " << nbyte << endl;
for (int i = 0; i < 30 && spin; ++i)
{
cout << "call1: " << g_client->Hello (str) << endl;
cout << "call1: " << g_client->Hello(str) << endl;
}
}
void handler2 (const void *data, void *buffer, unsigned int nbyte)
void handler2(const void *data, void *buffer, unsigned int nbyte)
{
char *str = (char*) buffer;
cout << "buffer2: " << str << ", size: " << nbyte <<endl;
char *str = (char *) buffer;
cout << "buffer2: " << str << ", size: " << nbyte << endl;
for (int i = 0; i < 30 && spin; ++i)
{
cout << "call2: " << g_client->Hello (str) << endl;
cout << "call2: " << g_client->Hello(str) << endl;
}
}
void handler3 (const void *data, void *buffer, unsigned int nbyte)
void handler3(const void *data, void *buffer, unsigned int nbyte)
{
char *str = (char*) buffer;
cout << "buffer3: " << str << ", size: " << nbyte <<endl;
char *str = (char *) buffer;
cout << "buffer3: " << str << ", size: " << nbyte << endl;
for (int i = 0; i < 30 && spin; ++i)
{
cout << "call3: " << g_client->Hello (str) << endl;
cout << "call3: " << g_client->Hello(str) << endl;
}
}
@ -102,17 +102,17 @@ int main()
DBus::Connection conn = DBus::Connection::SessionBus();
EchoClient client (conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME);
EchoClient client(conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME);
g_client = &client;
pthread_t threads[THREADS];
thread_pipe_list[0] = dispatcher.add_pipe (handler1, NULL);
thread_pipe_list[1] = dispatcher.add_pipe (handler2, NULL);
thread_pipe_list[2] = dispatcher.add_pipe (handler3, NULL);
thread_pipe_list[0] = dispatcher.add_pipe(handler1, NULL);
thread_pipe_list[1] = dispatcher.add_pipe(handler2, NULL);
thread_pipe_list[2] = dispatcher.add_pipe(handler3, NULL);
for (i = 0; i < THREADS; ++i)
{
pthread_create(threads+i, NULL, greeter_thread, (void*) i);
pthread_create(threads + i, NULL, greeter_thread, (void *) i);
}
dispatcher.enter();
@ -124,9 +124,9 @@ int main()
pthread_join(threads[i], NULL);
}
dispatcher.del_pipe (thread_pipe_list[0]);
dispatcher.del_pipe (thread_pipe_list[1]);
dispatcher.del_pipe (thread_pipe_list[2]);
dispatcher.del_pipe(thread_pipe_list[0]);
dispatcher.del_pipe(thread_pipe_list[1]);
dispatcher.del_pipe(thread_pipe_list[2]);
return 0;
}

View file

@ -5,7 +5,7 @@
#include "echo-client-glue.h"
class EchoClient
: public org::freedesktop::DBus::EchoDemo_proxy,
: public org::freedesktop::DBus::EchoDemo_proxy,
public DBus::IntrospectableProxy,
public DBus::ObjectProxy
{

View file

@ -13,7 +13,7 @@ static const char *ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo";
static const char *ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo";
EchoServer::EchoServer(DBus::Connection &connection)
: DBus::ObjectAdaptor(connection, ECHO_SERVER_PATH)
: DBus::ObjectAdaptor(connection, ECHO_SERVER_PATH)
{
}

View file

@ -5,7 +5,7 @@
#include "echo-server-glue.h"
class EchoServer
: public org::freedesktop::DBus::EchoDemo_adaptor,
: public org::freedesktop::DBus::EchoDemo_adaptor,
public DBus::IntrospectableAdaptor,
public DBus::ObjectAdaptor
{

View file

@ -15,7 +15,7 @@ static const char *ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo";
static const char *ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo";
EchoClient::EchoClient(DBus::Connection &connection, const char *path, const char *name)
: DBus::ObjectProxy(connection, path, name)
: DBus::ObjectProxy(connection, path, name)
{
}
@ -46,7 +46,7 @@ void *greeter_thread(void *arg)
snprintf(idstr, sizeof(idstr), "%lu", pthread_self());
thread_pipe_list[i]->write (idstr, strlen (idstr) + 1);
thread_pipe_list[i]->write(idstr, strlen(idstr) + 1);
cout << idstr << " done (" << i << ")" << endl;
@ -60,33 +60,33 @@ void niam(int sig)
ecore_main_loop_quit();
}
void handler1 (const void *data, void *buffer, unsigned int nbyte)
void handler1(const void *data, void *buffer, unsigned int nbyte)
{
char *str = (char*) buffer;
char *str = (char *) buffer;
cout << "buffer1: " << str << ", size: " << nbyte << endl;
for (int i = 0; i < 30 && spin; ++i)
{
cout << "call1: " << g_client->Hello (str) << endl;
cout << "call1: " << g_client->Hello(str) << endl;
}
}
void handler2 (const void *data, void *buffer, unsigned int nbyte)
void handler2(const void *data, void *buffer, unsigned int nbyte)
{
char *str = (char*) buffer;
cout << "buffer2: " << str << ", size: " << nbyte <<endl;
char *str = (char *) buffer;
cout << "buffer2: " << str << ", size: " << nbyte << endl;
for (int i = 0; i < 30 && spin; ++i)
{
cout << "call2: " << g_client->Hello (str) << endl;
cout << "call2: " << g_client->Hello(str) << endl;
}
}
void handler3 (const void *data, void *buffer, unsigned int nbyte)
void handler3(const void *data, void *buffer, unsigned int nbyte)
{
char *str = (char*) buffer;
cout << "buffer3: " << str << ", size: " << nbyte <<endl;
char *str = (char *) buffer;
cout << "buffer3: " << str << ", size: " << nbyte << endl;
for (int i = 0; i < 30 && spin; ++i)
{
cout << "call3: " << g_client->Hello (str) << endl;
cout << "call3: " << g_client->Hello(str) << endl;
}
}
@ -108,12 +108,12 @@ int main()
DBus::Connection conn = DBus::Connection::SessionBus();
EchoClient client (conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME);
EchoClient client(conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME);
g_client = &client;
pthread_t threads[THREADS];
/* thread_pipe_list[0] = dispatcher.add_pipe (handler1, NULL);
/* thread_pipe_list[0] = dispatcher.add_pipe (handler1, NULL);
thread_pipe_list[1] = dispatcher.add_pipe (handler2, NULL);
thread_pipe_list[2] = dispatcher.add_pipe (handler3, NULL);*/
for (i = 0; i < THREADS; ++i)

View file

@ -8,7 +8,7 @@
#include "echo-client-glue.h"
class EchoClient
: public org::freedesktop::DBus::EchoDemo_proxy,
: public org::freedesktop::DBus::EchoDemo_proxy,
public DBus::IntrospectableProxy,
public DBus::ObjectProxy
{

View file

@ -13,7 +13,7 @@ static const char *ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo";
static const char *ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo";
EchoServer::EchoServer(DBus::Connection &connection)
: DBus::ObjectAdaptor(connection, ECHO_SERVER_PATH)
: DBus::ObjectAdaptor(connection, ECHO_SERVER_PATH)
{
}

View file

@ -8,7 +8,7 @@
#include "echo-server-glue.h"
class EchoServer
: public org::freedesktop::DBus::EchoDemo_adaptor,
: public org::freedesktop::DBus::EchoDemo_adaptor,
public DBus::IntrospectableAdaptor,
public DBus::ObjectAdaptor
{

View file

@ -10,48 +10,48 @@
using namespace std;
static const char* DBUS_SERVER_NAME = "org.freedesktop.DBus";
static const char* DBUS_SERVER_PATH = "/org/freedesktop/DBus";
static const char *DBUS_SERVER_NAME = "org.freedesktop.DBus";
static const char *DBUS_SERVER_PATH = "/org/freedesktop/DBus";
typedef vector <string> Names;
DBusBrowser::DBusBrowser( ::DBus::Connection& conn )
: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME)
DBusBrowser::DBusBrowser(::DBus::Connection &conn)
: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME)
{
typedef std::vector< std::string > Names;
Names names = ListNames();
for(Names::iterator it = names.begin(); it != names.end(); ++it)
for (Names::iterator it = names.begin(); it != names.end(); ++it)
{
cout << *it << endl;
}
}
void DBusBrowser::NameOwnerChanged(
const std::string& name, const std::string& old_owner, const std::string& new_owner )
const std::string &name, const std::string &old_owner, const std::string &new_owner)
{
cout << name << ": " << old_owner << " -> " << new_owner << endl;
}
void DBusBrowser::NameLost( const std::string& name )
void DBusBrowser::NameLost(const std::string &name)
{
cout << name << " lost" << endl;
}
void DBusBrowser::NameAcquired( const std::string& name )
void DBusBrowser::NameAcquired(const std::string &name)
{
cout << name << " acquired" << endl;
}
DBus::Ecore::BusDispatcher dispatcher;
void niam( int sig )
void niam(int sig)
{
ecore_main_loop_quit();
}
int main(int argc, char* argv[])
int main(int argc, char *argv[])
{
signal(SIGTERM, niam);
signal(SIGINT, niam);

View file

@ -8,21 +8,21 @@
#include "dbus_ecore-glue.h"
class DBusBrowser
: public org::freedesktop::DBus_proxy,
: public org::freedesktop::DBus_proxy,
public DBus::IntrospectableProxy,
public DBus::ObjectProxy
{
public:
DBusBrowser( ::DBus::Connection& conn );
DBusBrowser(::DBus::Connection &conn);
private:
void NameOwnerChanged( const std::string&, const std::string&, const std::string& );
void NameOwnerChanged(const std::string &, const std::string &, const std::string &);
void NameLost( const std::string& );
void NameLost(const std::string &);
void NameAcquired( const std::string& );
void NameAcquired(const std::string &);
private:

View file

@ -9,7 +9,7 @@ static const char *DBUS_SERVER_NAME = "org.freedesktop.DBus";
static const char *DBUS_SERVER_PATH = "/org/freedesktop/DBus";
DBusBrowser::DBusBrowser(::DBus::Connection &conn)
: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME)
: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME)
{
set_title("D-Bus Browser");
set_border_width(5);

View file

@ -8,7 +8,7 @@
#include "dbus-glue.h"
class DBusInspector
: public DBus::IntrospectableProxy,
: public DBus::IntrospectableProxy,
public DBus::ObjectProxy
{
public:
@ -19,7 +19,7 @@ public:
};
class DBusBrowser
: public org::freedesktop::DBus_proxy,
: public org::freedesktop::DBus_proxy,
public DBus::IntrospectableProxy,
public DBus::ObjectProxy,
public Gtk::Window
@ -46,7 +46,10 @@ private:
{
public:
InspectRecord() { add(name); }
InspectRecord()
{
add(name);
}
Gtk::TreeModelColumn<Glib::ustring> name;
};

View file

@ -8,7 +8,7 @@
#include <iostream>
HalManagerProxy::HalManagerProxy(DBus::Connection &connection)
: DBus::InterfaceProxy("org.freedesktop.Hal.Manager"),
: DBus::InterfaceProxy("org.freedesktop.Hal.Manager"),
DBus::ObjectProxy(connection, "/org/freedesktop/Hal/Manager", "org.freedesktop.Hal")
{
connect_signal(HalManagerProxy, DeviceAdded, DeviceAddedCb);
@ -67,7 +67,7 @@ void HalManagerProxy::DeviceRemovedCb(const DBus::SignalMessage &sig)
}
HalDeviceProxy::HalDeviceProxy(DBus::Connection &connection, DBus::Path &udi)
: DBus::InterfaceProxy("org.freedesktop.Hal.Device"),
: DBus::InterfaceProxy("org.freedesktop.Hal.Device"),
DBus::ObjectProxy(connection, udi, "org.freedesktop.Hal")
{
connect_signal(HalDeviceProxy, PropertyModified, PropertyModifiedCb);

View file

@ -8,7 +8,7 @@
class HalDeviceProxy;
class HalManagerProxy
: public DBus::InterfaceProxy,
: public DBus::InterfaceProxy,
public DBus::ObjectProxy
{
public:
@ -27,7 +27,7 @@ private:
};
class HalDeviceProxy
: public DBus::InterfaceProxy,
: public DBus::InterfaceProxy,
public DBus::ObjectProxy
{
public:

View file

@ -9,23 +9,23 @@ static const char *PROPS_SERVER_NAME = "org.freedesktop.DBus.Examples.Properties
static const char *PROPS_SERVER_PATH = "/org/freedesktop/DBus/Examples/Properties";
PropsClient::PropsClient(DBus::Connection &connection, const char *path, const char *name)
: DBus::ObjectProxy(connection, path, name)
: DBus::ObjectProxy(connection, path, name)
{
}
void PropsClient::MessageChanged(const std::string& message)
void PropsClient::MessageChanged(const std::string &message)
{
std::cout << "MessageChanged signal, new value: " << message << "\n";
};
void PropsClient::DataChanged(const double& data)
void PropsClient::DataChanged(const double &data)
{
std::cout << "DataChanged signal, new value:" << data << "\n";
};
void *test_property_proxy(void * input)
void *test_property_proxy(void *input)
{
PropsClient *client = static_cast<PropsClient*>(input);
PropsClient *client = static_cast<PropsClient *>(input);
std::cout << "read property 'Version', value:" << client->Version() << "\n";
@ -61,7 +61,7 @@ int main()
DBus::Connection conn = DBus::Connection::SessionBus();
PropsClient client (conn, PROPS_SERVER_PATH, PROPS_SERVER_NAME);
PropsClient client(conn, PROPS_SERVER_PATH, PROPS_SERVER_NAME);
pthread_t thread;
pthread_create(&thread, NULL, test_property_proxy, &client);

View file

@ -5,7 +5,7 @@
#include "propsgs-glue-proxy.h"
class PropsClient
: public org::freedesktop::DBus::PropsGSDemo_proxy,
: public org::freedesktop::DBus::PropsGSDemo_proxy,
public DBus::IntrospectableProxy,
public DBus::PropertiesProxy,
public DBus::ObjectProxy
@ -14,9 +14,9 @@ public:
PropsClient(DBus::Connection &connection, const char *path, const char *name);
void MessageChanged(const std::string& message);
void MessageChanged(const std::string &message);
void DataChanged(const double& data);
void DataChanged(const double &data);
};
#endif//__DEMO_PROPS_SERVER_H

View file

@ -6,14 +6,14 @@ static const char *PROPS_SERVER_NAME = "org.freedesktop.DBus.Examples.Properties
static const char *PROPS_SERVER_PATH = "/org/freedesktop/DBus/Examples/Properties";
PropsServer::PropsServer(DBus::Connection &connection)
: DBus::ObjectAdaptor(connection, PROPS_SERVER_PATH)
: DBus::ObjectAdaptor(connection, PROPS_SERVER_PATH)
{
Version = 1;
Message = "default message";
}
void PropsServer::on_set_property
(DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value)
(DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value)
{
if (property == "Message")
{

View file

@ -5,7 +5,7 @@
#include "propsgs-glue-adaptor.h"
class PropsServer
: public org::freedesktop::DBus::PropsGSDemo_adaptor,
: public org::freedesktop::DBus::PropsGSDemo_adaptor,
public DBus::IntrospectableAdaptor,
public DBus::PropertiesAdaptor,
public DBus::ObjectAdaptor

View file

@ -33,11 +33,12 @@
#include "message.h"
#include "pendingcall.h"
namespace DBus {
namespace DBus
{
class Connection;
typedef Slot<bool, const Message&> MessageSlot;
typedef Slot<bool, const Message &> MessageSlot;
typedef std::list<Connection> ConnectionList;
@ -56,19 +57,19 @@ public:
struct Private;
typedef std::list<Private*> PrivatePList;
typedef std::list<Private *> PrivatePList;
Connection( Private* );
Connection(Private *);
Connection( const char* address, bool priv = true );
Connection(const char *address, bool priv = true);
Connection( const Connection& c );
Connection(const Connection &c);
virtual ~Connection();
Dispatcher* setup( Dispatcher* );
Dispatcher *setup(Dispatcher *);
bool operator == ( const Connection& ) const;
bool operator == (const Connection &) const;
/*!
* \brief Adds a match rule to match messages going through the message bus.
@ -126,7 +127,7 @@ public:
* \param rule Textual form of match rule.
* \throw Error
*/
void add_match( const char* rule );
void add_match(const char *rule);
/*!
* \brief Removes a previously-added match rule "by value" (the most
@ -140,7 +141,7 @@ public:
* \param rule Textual form of match rule.
* \throw Error
*/
void remove_match( const char* rule, bool throw_on_error );
void remove_match(const char *rule, bool throw_on_error);
/*!
* \brief Adds a message filter.
@ -153,7 +154,7 @@ public:
*
* \param s The MessageSlot to add.
*/
bool add_filter( MessageSlot& s);
bool add_filter(MessageSlot &s);
/*!
* \brief Removes a previously-added message filter.
@ -164,7 +165,7 @@ public:
*
* \param s The MessageSlot to remove.
*/
void remove_filter( MessageSlot& s);
void remove_filter(MessageSlot &s);
/*!
* \brief Sets the unique name of the connection, as assigned by the message bus.
@ -196,7 +197,7 @@ public:
*
* \param n The unique name.
*/
bool unique_name( const char* n );
bool unique_name(const char *n);
/*!
* \brief Gets the unique name of the connection as assigned by the message bus.
@ -213,7 +214,7 @@ public:
* responsible for calling unique_name(const char*) if you register by hand
* instead of using register_bus().
*/
const char* unique_name() const;
const char *unique_name() const;
/*!
* \brief Registers a connection with the bus.
@ -325,7 +326,7 @@ public:
*
* \param exit true If _exit() should be called after a disconnect signal.
*/
void exit_on_disconnect( bool exit );
void exit_on_disconnect(bool exit);
/*!
* \brief Blocks until the outgoing message queue is empty.
@ -352,7 +353,7 @@ public:
* \param serial Return location for message serial, or NULL if you don't care.
* \return true On success.
*/
bool send( const Message& msg, unsigned int* serial = NULL );
bool send(const Message &msg, unsigned int *serial = NULL);
/*!
* \brief Sends a message and blocks a certain time period while waiting for a reply.
@ -379,7 +380,7 @@ public:
* \param timeout Timeout in milliseconds (omit for default).
* \throw Error
*/
Message send_blocking( Message& msg, int timeout = -1);
Message send_blocking(Message &msg, int timeout = -1);
/*!
* \brief Queues a message to send, as with send(), but also
@ -406,9 +407,9 @@ public:
* \param timeout Timeout in milliseconds (omit for default).
* \throw ErrorNoMemory
*/
PendingCall send_async( Message& msg, int timeout = -1);
PendingCall send_async(Message &msg, int timeout = -1);
void request_name( const char* name, int flags = 0 );
void request_name(const char *name, int flags = 0);
unsigned long sender_unix_uid(const char *sender);
@ -425,7 +426,7 @@ public:
* \param name The name.
* \throw Error
*/
bool has_name( const char* name );
bool has_name(const char *name);
/*!
* \brief Starts a service that will request ownership of the given name.
@ -443,7 +444,7 @@ public:
*
* \todo dbus_message_set_auto_start() not yet wrapped!
*/
bool start_service( const char* name, unsigned long flags );
bool start_service(const char *name, unsigned long flags);
const std::vector<std::string>& names();
@ -460,7 +461,7 @@ private:
RefPtrI<Private> _pvt;
int _timeout;
friend class ObjectAdaptor; // needed in order to register object paths for a connection
friend class ObjectAdaptor; // needed in order to register object paths for a connection
};
} /* namespace DBus */

View file

@ -27,7 +27,8 @@
#include "api.h"
namespace DBus {
namespace DBus
{
typedef void (*LogFunction)(const char *format, ...);

View file

@ -29,7 +29,8 @@
#include "connection.h"
#include "eventloop.h"
namespace DBus {
namespace DBus
{
class DXXAPI Timeout
{
@ -39,7 +40,7 @@ public:
Timeout(Internal *i);
virtual ~Timeout(){}
virtual ~Timeout() {}
/*!
* \brief Gets the timeout interval.
@ -90,7 +91,7 @@ public:
Watch(Internal *i);
virtual ~Watch(){}
virtual ~Watch() {}
/*!
* \brief A main loop could poll this descriptor to integrate dbus-c++.
@ -174,7 +175,7 @@ public:
struct Private;
private:
void dispatch_pending(Connection::PrivatePList& pending_queue);
void dispatch_pending(Connection::PrivatePList &pending_queue);
DefaultMutex _mutex_p;
DefaultMutex _mutex_p_copy;

View file

@ -31,9 +31,11 @@
#include "dispatcher.h"
#include "Ecore.h"
namespace DBus {
namespace DBus
{
namespace Ecore {
namespace Ecore
{
class BusDispatcher;
@ -41,13 +43,13 @@ class DXXAPI BusTimeout : public Timeout
{
private:
BusTimeout( Timeout::Internal*);
BusTimeout(Timeout::Internal *);
~BusTimeout();
void toggle();
static Eina_Bool timeout_handler( void* );
static Eina_Bool timeout_handler(void *);
void _enable();
@ -56,34 +58,34 @@ private:
private:
Ecore_Timer *_etimer;
friend class BusDispatcher;
friend class BusDispatcher;
};
class DXXAPI BusWatch : public Watch
{
private:
BusWatch( Watch::Internal*);
BusWatch(Watch::Internal *);
~BusWatch();
void toggle();
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);
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);
void data(Ecore::BusDispatcher *bd);
private:
Ecore_Fd_Handler *fd_handler;
Ecore::BusDispatcher *_bd;
friend class BusDispatcher;
friend class BusDispatcher;
};
class DXXAPI BusDispatcher : public Dispatcher
@ -95,16 +97,16 @@ public:
void leave() {}
Timeout* add_timeout( Timeout::Internal* );
Timeout *add_timeout(Timeout::Internal *);
void rem_timeout( Timeout* );
void rem_timeout(Timeout *);
Watch* add_watch( Watch::Internal* );
Watch *add_watch(Watch::Internal *);
void rem_watch( Watch* );
void rem_watch(Watch *);
static Eina_Bool dispatch ( void *data, Ecore_Fd_Handler *fdh);
static Eina_Bool check ( void *data, Ecore_Fd_Handler *fdh);
static Eina_Bool dispatch(void *data, Ecore_Fd_Handler *fdh);
static Eina_Bool check(void *data, Ecore_Fd_Handler *fdh);
private:
};

View file

@ -30,7 +30,8 @@
#include <exception>
namespace DBus {
namespace DBus
{
class Message;
class InternalError;

View file

@ -31,7 +31,8 @@
#include "util.h"
#include "eventloop.h"
namespace DBus {
namespace DBus
{
/*
* Glue between the event loop and the DBus library
@ -46,7 +47,7 @@ class DXXAPI BusTimeout : public Timeout, public DefaultTimeout
void toggle();
friend class BusDispatcher;
friend class BusDispatcher;
};
class DXXAPI BusWatch : public Watch, public DefaultWatch
@ -55,7 +56,7 @@ class DXXAPI BusWatch : public Watch, public DefaultWatch
void toggle();
friend class BusDispatcher;
friend class BusDispatcher;
};
class DXXAPI BusDispatcher : public Dispatcher, public DefaultMainLoop
@ -71,7 +72,7 @@ public:
virtual Pipe *add_pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data);
virtual void del_pipe (Pipe *pipe);
virtual void del_pipe(Pipe *pipe);
virtual void do_iteration();
@ -90,7 +91,7 @@ public:
private:
bool _running;
int _pipe[2];
std::list <Pipe*> pipe_list;
std::list <Pipe *> pipe_list;
};
} /* namespace DBus */

View file

@ -31,7 +31,8 @@
#include "api.h"
#include "util.h"
namespace DBus {
namespace DBus
{
/*
* these Default *classes implement a very simple event loop which
@ -50,17 +51,41 @@ public:
virtual ~DefaultTimeout();
bool enabled(){ return _enabled; }
void enabled(bool e){ _enabled = e; }
bool enabled()
{
return _enabled;
}
void enabled(bool e)
{
_enabled = e;
}
int interval(){ return _interval; }
void interval(int i){ _interval = i; }
int interval()
{
return _interval;
}
void interval(int i)
{
_interval = i;
}
bool repeat(){ return _repeat; }
void repeat(bool r){ _repeat = r; }
bool repeat()
{
return _repeat;
}
void repeat(bool r)
{
_repeat = r;
}
void *data(){ return _data; }
void data(void *d){ _data = d; }
void *data()
{
return _data;
}
void data(void *d)
{
_data = d;
}
Slot<void, DefaultTimeout &> expired;
@ -77,7 +102,7 @@ private:
DefaultMainLoop *_disp;
friend class DefaultMainLoop;
friend class DefaultMainLoop;
};
typedef std::list< DefaultTimeout *> DefaultTimeouts;
@ -90,18 +115,42 @@ public:
virtual ~DefaultWatch();
bool enabled(){ return _enabled; }
void enabled(bool e){ _enabled = e; }
bool enabled()
{
return _enabled;
}
void enabled(bool e)
{
_enabled = e;
}
int descriptor(){ return _fd; }
int descriptor()
{
return _fd;
}
int flags(){ return _flags; }
void flags(int f){ _flags = f; }
int flags()
{
return _flags;
}
void flags(int f)
{
_flags = f;
}
int state(){ return _state; }
int state()
{
return _state;
}
void *data(){ return _data; }
void data(void *d){ _data = d; }
void *data()
{
return _data;
}
void data(void *d)
{
_data = d;
}
Slot<void, DefaultWatch &> ready;
@ -117,7 +166,7 @@ private:
DefaultMainLoop *_disp;
friend class DefaultMainLoop;
friend class DefaultMainLoop;
};
typedef std::list< DefaultWatch *> DefaultWatches;
@ -167,8 +216,8 @@ private:
DefaultMutex _mutex_w;
DefaultWatches _watches;
friend class DefaultTimeout;
friend class DefaultWatch;
friend class DefaultTimeout;
friend class DefaultWatch;
};
} /* namespace DBus */

View file

@ -30,9 +30,11 @@
#include "api.h"
#include "dispatcher.h"
namespace DBus {
namespace DBus
{
namespace Glib {
namespace Glib
{
class BusDispatcher;
@ -58,7 +60,7 @@ private:
int _priority;
GSource *_source;
friend class BusDispatcher;
friend class BusDispatcher;
};
class DXXAPI BusWatch : public Watch
@ -83,7 +85,7 @@ private:
int _priority;
GSource *_source;
friend class BusDispatcher;
friend class BusDispatcher;
};
class DXXAPI BusDispatcher : public Dispatcher

View file

@ -33,7 +33,8 @@
#include "message.h"
namespace DBus {
namespace DBus
{
//todo: this should belong to to properties.h
struct DXXAPI PropertyData
@ -143,7 +144,7 @@ public:
void set_property(const std::string &name, Variant &value);
virtual IntrospectedInterface * introspect() const
virtual IntrospectedInterface *introspect() const
{
return NULL;
}

View file

@ -28,7 +28,8 @@
#include "api.h"
#include "interface.h"
namespace DBus {
namespace DBus
{
struct DXXAPI IntrospectedArgument
{
@ -69,7 +70,7 @@ public:
protected:
IntrospectedInterface * introspect() const;
IntrospectedInterface *introspect() const;
};
class DXXAPI IntrospectableProxy : public InterfaceProxy

View file

@ -31,7 +31,8 @@
#include "api.h"
#include "util.h"
namespace DBus {
namespace DBus
{
class Message;
class ErrorMessage;
@ -147,11 +148,11 @@ private:
/* I'm sorry, but don't want to include dbus.h in the public api
*/
unsigned char _iter[sizeof(void *)*3+sizeof(int)*11];
unsigned char _iter[sizeof(void *) * 3 + sizeof(int) * 11];
Message *_msg;
friend class Message;
friend class Message;
};
class DXXAPI Message
@ -206,13 +207,13 @@ protected:
RefPtrI<Private> _pvt;
/* classes who need to read `_pvt` directly
*/
friend class ErrorMessage;
friend class ReturnMessage;
friend class MessageIter;
friend class Error;
friend class Connection;
/* classes who need to read `_pvt` directly
*/
friend class ErrorMessage;
friend class ReturnMessage;
friend class MessageIter;
friend class Error;
friend class Connection;
};
/*
@ -254,7 +255,7 @@ public:
const char *path() const;
char ** path_split() const;
char **path_split() const;
bool path(const char *p);
@ -282,7 +283,7 @@ public:
const char *path() const;
char ** path_split() const;
char **path_split() const;
bool path(const char *p);

View file

@ -34,7 +34,8 @@
#include "message.h"
#include "types.h"
namespace DBus {
namespace DBus
{
class DXXAPI Object
{
@ -173,7 +174,7 @@ private:
typedef std::map<const Tag *, Continuation *> ContinuationMap;
ContinuationMap _continuations;
friend struct Private;
friend struct Private;
};
const ObjectAdaptor *ObjectAdaptor::object() const

View file

@ -29,7 +29,8 @@
#include "util.h"
#include "message.h"
namespace DBus {
namespace DBus
{
class Connection;
@ -91,7 +92,7 @@ public:
* \param data The data to store.
* \throw ErrorNoMemory
*/
void data( void* data );
void data(void *data);
/*!
* \brief Retrieves data previously set with dbus_pending_call_set_data().
@ -123,8 +124,8 @@ private:
RefPtrI<Private> _pvt;
friend struct Private;
friend class Connection;
friend struct Private;
friend class Connection;
};
} /* namespace DBus */

View file

@ -30,7 +30,8 @@
/* STD */
#include <cstdlib>
namespace DBus {
namespace DBus
{
class DXXAPI Pipe
{
@ -58,10 +59,10 @@ private:
const void *_data;
// allow construction only in BusDispatcher
Pipe (void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data);
~Pipe () {};
Pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data);
~Pipe() {};
friend class BusDispatcher;
friend class BusDispatcher;
};
} /* namespace DBus */

View file

@ -29,7 +29,8 @@
#include "types.h"
#include "interface.h"
namespace DBus {
namespace DBus
{
template <typename T>
class PropertyAdaptor
@ -44,7 +45,7 @@ public:
_data = &data;
}
T operator() (void) const
T operator()(void) const
{
return _data->value.operator T();
}
@ -82,7 +83,7 @@ protected:
virtual void on_set_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, const Variant &/*value*/)
{}
IntrospectedInterface * introspect() const;
IntrospectedInterface *introspect() const;
};
class DXXAPI PropertiesProxy : public InterfaceProxy

View file

@ -28,11 +28,12 @@
#include "api.h"
#include "util.h"
namespace DBus {
namespace DBus
{
template <class T>
RefPtrI<T>::RefPtrI(T *ptr)
: __ptr(ptr)
: __ptr(ptr)
{}
template <class T>

View file

@ -33,7 +33,8 @@
#include "util.h"
#include "dispatcher.h"
namespace DBus {
namespace DBus
{
class Server;

View file

@ -35,7 +35,8 @@
#include "message.h"
#include "error.h"
namespace DBus {
namespace DBus
{
struct DXXAPI Path : public std::string
{
@ -102,7 +103,7 @@ private:
};
template <
typename T1,
typename T1,
typename T2 = Invalid,
typename T3 = Invalid,
typename T4 = Invalid,
@ -118,15 +119,29 @@ template <
typename T14 = Invalid,
typename T15 = Invalid,
typename T16 = Invalid // nobody needs more than 16
>
>
struct Struct
{
T1 _1; T2 _2; T3 _3; T4 _4; T5 _5; T6 _6; T7 _7; T8 _8; T9 _9;
T10 _10; T11 _11; T12 _12; T13 _13; T14 _14; T15 _15; T16 _16;
T1 _1;
T2 _2;
T3 _3;
T4 _4;
T5 _5;
T6 _6;
T7 _7;
T8 _8;
T9 _9;
T10 _10;
T11 _11;
T12 _12;
T13 _13;
T14 _14;
T15 _15;
T16 _16;
};
template<typename K, typename V>
inline bool dict_has_key(const std::map<K,V>& map, const K &key)
inline bool dict_has_key(const std::map<K, V>& map, const K &key)
{
return map.find(key) != map.end();
}
@ -141,31 +156,125 @@ struct type
}
};
template <> struct type<Variant> { static std::string sig(){ return "v"; } };
template <> struct type<uint8_t> { static std::string sig(){ return "y"; } };
template <> struct type<bool> { static std::string sig(){ return "b"; } };
template <> struct type<int16_t> { static std::string sig(){ return "n"; } };
template <> struct type<uint16_t> { static std::string sig(){ return "q"; } };
template <> struct type<int32_t> { static std::string sig(){ return "i"; } };
template <> struct type<uint32_t> { static std::string sig(){ return "u"; } };
template <> struct type<int64_t> { static std::string sig(){ return "x"; } };
template <> struct type<uint64_t> { static std::string sig(){ return "t"; } };
template <> struct type<double> { static std::string sig(){ return "d"; } };
template <> struct type<std::string> { static std::string sig(){ return "s"; } };
template <> struct type<Path> { static std::string sig(){ return "o"; } };
template <> struct type<Signature> { static std::string sig(){ return "g"; } };
template <> struct type<Invalid> { static std::string sig(){ return ""; } };
template <> struct type<Variant>
{
static std::string sig()
{
return "v";
}
};
template <> struct type<uint8_t>
{
static std::string sig()
{
return "y";
}
};
template <> struct type<bool>
{
static std::string sig()
{
return "b";
}
};
template <> struct type<int16_t>
{
static std::string sig()
{
return "n";
}
};
template <> struct type<uint16_t>
{
static std::string sig()
{
return "q";
}
};
template <> struct type<int32_t>
{
static std::string sig()
{
return "i";
}
};
template <> struct type<uint32_t>
{
static std::string sig()
{
return "u";
}
};
template <> struct type<int64_t>
{
static std::string sig()
{
return "x";
}
};
template <> struct type<uint64_t>
{
static std::string sig()
{
return "t";
}
};
template <> struct type<double>
{
static std::string sig()
{
return "d";
}
};
template <> struct type<std::string>
{
static std::string sig()
{
return "s";
}
};
template <> struct type<Path>
{
static std::string sig()
{
return "o";
}
};
template <> struct type<Signature>
{
static std::string sig()
{
return "g";
}
};
template <> struct type<Invalid>
{
static std::string sig()
{
return "";
}
};
template <typename E>
struct type< std::vector<E> >
{ static std::string sig(){ return "a" + type<E>::sig(); } };
{
static std::string sig()
{
return "a" + type<E>::sig();
}
};
template <typename K, typename V>
struct type< std::map<K,V> >
{ static std::string sig(){ return "a{" + type<K>::sig() + type<V>::sig() + "}"; } };
struct type< std::map<K, V> >
{
static std::string sig()
{
return "a{" + type<K>::sig() + type<V>::sig() + "}";
}
};
template <
typename T1,
typename T1,
typename T2,
typename T3,
typename T4,
@ -181,8 +290,8 @@ template <
typename T14,
typename T15,
typename T16 // nobody needs more than 16
>
struct type< Struct<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> >
>
struct type< Struct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> >
{
static std::string sig()
{
@ -226,37 +335,37 @@ inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const bool &val)
return iter;
}
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int16_t& val)
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int16_t &val)
{
iter.append_int16(val);
return iter;
}
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint16_t& val)
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint16_t &val)
{
iter.append_uint16(val);
return iter;
}
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int32_t& val)
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int32_t &val)
{
iter.append_int32(val);
return iter;
}
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint32_t& val)
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint32_t &val)
{
iter.append_uint32(val);
return iter;
}
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int64_t& val)
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int64_t &val)
{
iter.append_int64(val);
return iter;
}
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint64_t& val)
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint64_t &val)
{
iter.append_uint64(val);
return iter;
@ -312,12 +421,12 @@ inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::vecto
}
template<typename K, typename V>
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::map<K,V>& val)
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::map<K, V>& val)
{
const std::string sig = "{" + DBus::type<K>::sig() + DBus::type<V>::sig() + "}";
DBus::MessageIter ait = iter.new_array(sig.c_str());
typename std::map<K,V>::const_iterator mit;
typename std::map<K, V>::const_iterator mit;
for (mit = val.begin(); mit != val.end(); ++mit)
{
DBus::MessageIter eit = ait.new_dict_entry();
@ -332,7 +441,7 @@ inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::map<K
}
template <
typename T1,
typename T1,
typename T2,
typename T3,
typename T4,
@ -348,8 +457,8 @@ template <
typename T14,
typename T15,
typename T16
>
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Struct<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>& val)
>
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Struct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>& val)
{
DBus::MessageIter sit = iter.new_struct();
@ -382,37 +491,37 @@ inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, bool &val)
return ++iter;
}
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int16_t& val)
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int16_t &val)
{
val = iter.get_int16();
return ++iter;
}
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint16_t& val)
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint16_t &val)
{
val = iter.get_uint16();
return ++iter;
}
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int32_t& val)
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int32_t &val)
{
val = iter.get_int32();
return ++iter;
}
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint32_t& val)
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint32_t &val)
{
val = iter.get_uint32();
return ++iter;
}
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int64_t& val)
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int64_t &val)
{
val = iter.get_int64();
return ++iter;
}
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint64_t& val)
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint64_t &val)
{
val = iter.get_uint64();
return ++iter;
@ -475,13 +584,13 @@ inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector<uint
uint8_t *array;
size_t length = ait.get_array(&array);
val.insert(val.end(), array, array+length);
val.insert(val.end(), array, array + length);
return ++iter;
}
template<typename K, typename V>
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::map<K,V>& val)
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::map<K, V>& val)
{
if (!iter.is_dict())
throw DBus::ErrorInvalidArgs("dictionary value expected");
@ -490,7 +599,8 @@ inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::map<K,V>& v
while (!mit.at_end())
{
K key; V value;
K key;
V value;
DBus::MessageIter eit = mit.recurse();
@ -505,7 +615,7 @@ inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::map<K,V>& v
}
template <
typename T1,
typename T1,
typename T2,
typename T3,
typename T4,
@ -521,8 +631,8 @@ template <
typename T14,
typename T15,
typename T16
>
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Struct<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>& val)
>
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Struct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>& val)
{
DBus::MessageIter sit = iter.recurse();

View file

@ -33,7 +33,8 @@
#include "api.h"
#include "debug.h"
namespace DBus {
namespace DBus
{
/*
* Very simple reference counting
@ -225,7 +226,7 @@ class Slot
{
public:
Slot &operator = (Callback_Base<R,P>* s)
Slot &operator = (Callback_Base<R, P>* s)
{
_cb = s;
@ -263,15 +264,15 @@ public:
private:
RefPtr< Callback_Base<R,P> > _cb;
RefPtr< Callback_Base<R, P> > _cb;
};
template <class C, class R, class P>
class Callback : public Callback_Base<R,P>
class Callback : public Callback_Base<R, P>
{
public:
typedef R (C::*M)(P);
typedef R(C::*M)(P);
Callback(C *c, M m)
: _c(c), _m(m)
@ -284,12 +285,13 @@ public:
private:
C *_c; M _m;
C *_c;
M _m;
};
/// create std::string from any number
template <typename T>
std::string toString (const T &thing, int w = 0, int p = 0)
std::string toString(const T &thing, int w = 0, int p = 0)
{
std::ostringstream os;
os << std::setw(w) << std::setprecision(p) << thing;

View file

@ -42,7 +42,7 @@
using namespace DBus;
Connection::Private::Private(DBusConnection *c, Server::Private *s)
: conn(c) , dispatcher(NULL), server(s)
: conn(c) , dispatcher(NULL), server(s)
{
init();
}
@ -97,7 +97,7 @@ void Connection::Private::init()
void Connection::Private::detach_server()
{
/* Server::Private *tmp = server;
/* Server::Private *tmp = server;
server = NULL;
@ -166,7 +166,7 @@ DBusHandlerResult Connection::Private::message_filter_stub(DBusConnection *conn,
bool Connection::Private::disconn_filter_function(const Message &msg)
{
if (msg.is_signal(DBUS_INTERFACE_LOCAL,"Disconnected"))
if (msg.is_signal(DBUS_INTERFACE_LOCAL, "Disconnected"))
{
debug_log("%p disconnected by local bus", conn);
dbus_connection_close(conn);
@ -203,7 +203,7 @@ Connection Connection::ActivationBus()
}
Connection::Connection(const char *address, bool priv)
: _timeout(-1)
: _timeout(-1)
{
InternalError e;
DBusConnection *conn = priv
@ -220,13 +220,13 @@ Connection::Connection(const char *address, bool priv)
}
Connection::Connection(Connection::Private *p)
: _pvt(p), _timeout(-1)
: _pvt(p), _timeout(-1)
{
setup(default_dispatcher);
}
Connection::Connection(const Connection &c)
: _pvt(c._pvt),_timeout(c._timeout)
: _pvt(c._pvt), _timeout(c._timeout)
{
dbus_connection_ref(_pvt->conn);
}
@ -282,7 +282,7 @@ bool Connection::register_bus()
bool r = dbus_bus_register(_pvt->conn, e);
if (e) throw (e);
if (e) throw(e);
return r;
}
@ -338,13 +338,14 @@ void Connection::remove_match(const char *rule,
debug_log("%s: removed match rule %s", unique_name(), rule);
if (e) {
if (e)
{
if (throw_on_error)
throw Error(e);
else
debug_log("DBus::Connection::remove_match: %s (%s).",
static_cast<DBusError*>(e)->message,
static_cast<DBusError*>(e)->name);
static_cast<DBusError *>(e)->message,
static_cast<DBusError *>(e)->name);
}
}
@ -463,7 +464,7 @@ bool Connection::start_service(const char *name, unsigned long flags)
void Connection::set_timeout(int timeout)
{
_timeout=timeout;
_timeout = timeout;
}
int Connection::get_timeout()

View file

@ -38,11 +38,12 @@
#include <string>
namespace DBus {
namespace DBus
{
struct DXXAPILOCAL Connection::Private
{
DBusConnection * conn;
DBusConnection *conn;
std::vector<std::string> names;

View file

@ -38,7 +38,7 @@ DBus::Dispatcher *DBus::default_dispatcher = NULL;
using namespace DBus;
Timeout::Timeout(Timeout::Internal *i)
: _int(i)
: _int(i)
{
dbus_timeout_set_data((DBusTimeout *)i, this, NULL);
}
@ -62,7 +62,7 @@ bool Timeout::handle()
*/
Watch::Watch(Watch::Internal *i)
: _int(i)
: _int(i)
{
dbus_watch_set_data((DBusWatch *)i, this, NULL);
}
@ -70,16 +70,16 @@ Watch::Watch(Watch::Internal *i)
int Watch::descriptor() const
{
#if HAVE_WIN32
return dbus_watch_get_socket((DBusWatch*)_int);
return dbus_watch_get_socket((DBusWatch *)_int);
#else
// check dbus version and use dbus_watch_get_unix_fd() only in dbus >= 1.1.1
#if (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR == 1 && DBUS_VERSION_MICRO >= 1) || \
#if (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR == 1 && DBUS_VERSION_MICRO >= 1) || \
(DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MAJOR > 1) || \
(DBUS_VERSION_MAJOR > 1)
return dbus_watch_get_unix_fd((DBusWatch*)_int);
#else
return dbus_watch_get_fd((DBusWatch*)_int);
#endif
return dbus_watch_get_unix_fd((DBusWatch *)_int);
#else
return dbus_watch_get_fd((DBusWatch *)_int);
#endif
#endif
}
@ -167,7 +167,7 @@ bool Dispatcher::has_something_to_dispatch()
{
_mutex_p.lock();
bool has_something = false;
for(Connection::PrivatePList::iterator it = _pending_queue.begin();
for (Connection::PrivatePList::iterator it = _pending_queue.begin();
it != _pending_queue.end() && !has_something;
++it)
{
@ -216,7 +216,7 @@ void Dispatcher::dispatch_pending()
}
}
void Dispatcher::dispatch_pending(Connection::PrivatePList& pending_queue)
void Dispatcher::dispatch_pending(Connection::PrivatePList &pending_queue)
{
// SEEME: dbus-glib is dispatching only one message at a time to not starve the loop/other things...
@ -267,7 +267,8 @@ void DBus::_init_threading(
)
{
#ifndef DBUS_HAS_RECURSIVE_MUTEX
DBusThreadFunctions functions = {
DBusThreadFunctions functions =
{
DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK |
DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK |
DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK |
@ -276,7 +277,7 @@ void DBus::_init_threading(
DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK |
DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK |
DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK |
DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK|
DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK |
DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK,
(DBusMutexNewFunction) m1,
(DBusMutexFreeFunction) m2,
@ -290,7 +291,8 @@ void DBus::_init_threading(
(DBusCondVarWakeAllFunction) c6
};
#else
DBusThreadFunctions functions = {
DBusThreadFunctions functions =
{
DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK |
DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_FREE_MASK |
DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_LOCK_MASK |
@ -299,7 +301,7 @@ void DBus::_init_threading(
DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK |
DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK |
DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK |
DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK|
DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK |
DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK,
0, 0, 0, 0,
(DBusCondVarNewFunction) c1,

View file

@ -35,7 +35,8 @@
#include "internalerror.h"
namespace DBus {
namespace DBus
{
struct DXXAPILOCAL Dispatcher::Private
{

View file

@ -33,8 +33,8 @@ using namespace DBus;
Dispatcher *gdispatcher = NULL;
Ecore::BusTimeout::BusTimeout( Timeout::Internal* ti)
: Timeout(ti)
Ecore::BusTimeout::BusTimeout(Timeout::Internal *ti)
: Timeout(ti)
{
if (Timeout::enabled())
{
@ -49,9 +49,9 @@ Ecore::BusTimeout::~BusTimeout()
void Ecore::BusTimeout::toggle()
{
debug_log("ecore: timeout %p toggled (%s)", this, Timeout::enabled() ? "on":"off");
debug_log("ecore: timeout %p toggled (%s)", this, Timeout::enabled() ? "on" : "off");
if(Timeout::enabled())
if (Timeout::enabled())
{
_enable();
}
@ -61,9 +61,9 @@ void Ecore::BusTimeout::toggle()
}
}
Eina_Bool Ecore::BusTimeout::timeout_handler( void *data )
Eina_Bool Ecore::BusTimeout::timeout_handler(void *data)
{
Ecore::BusTimeout* t = reinterpret_cast<Ecore::BusTimeout*>(data);
Ecore::BusTimeout *t = reinterpret_cast<Ecore::BusTimeout *>(data);
debug_log("Ecore::BusTimeout::timeout_handler( void *data )");
@ -76,18 +76,18 @@ void Ecore::BusTimeout::_enable()
{
debug_log("Ecore::BusTimeout::_enable()");
_etimer = ecore_timer_add (((double)Timeout::interval())/1000, timeout_handler, this);
_etimer = ecore_timer_add(((double)Timeout::interval()) / 1000, timeout_handler, this);
}
void Ecore::BusTimeout::_disable()
{
debug_log("Ecore::BusTimeout::_disable()");
ecore_timer_del (_etimer);
ecore_timer_del(_etimer);
}
Ecore::BusWatch::BusWatch( Watch::Internal* wi)
: Watch(wi), fd_handler (NULL), _bd (NULL)
Ecore::BusWatch::BusWatch(Watch::Internal *wi)
: Watch(wi), fd_handler(NULL), _bd(NULL)
{
if (Watch::enabled())
{
@ -102,15 +102,15 @@ Ecore::BusWatch::~BusWatch()
void Ecore::BusWatch::toggle()
{
debug_log("ecore: watch %p toggled (%s)", this, Watch::enabled() ? "on":"off");
debug_log("ecore: watch %p toggled (%s)", this, Watch::enabled() ? "on" : "off");
if(Watch::enabled()) _enable();
if (Watch::enabled()) _enable();
else _disable();
}
Eina_Bool Ecore::BusWatch::watch_dispatch( 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);
Ecore::BusWatch *w = reinterpret_cast<Ecore::BusWatch *>(data);
debug_log("Ecore::BusWatch watch_handler");
@ -131,8 +131,8 @@ void Ecore::BusWatch::_enable()
{
debug_log("Ecore::BusWatch::_enable()");
fd_handler = ecore_main_fd_handler_add (descriptor(),
(Ecore_Fd_Handler_Flags) (ECORE_FD_READ | ECORE_FD_WRITE),
fd_handler = ecore_main_fd_handler_add(descriptor(),
(Ecore_Fd_Handler_Flags)(ECORE_FD_READ | ECORE_FD_WRITE),
watch_dispatch, this,
NULL, NULL);
}
@ -141,12 +141,12 @@ void Ecore::BusWatch::_disable()
{
if (fd_handler)
{
ecore_main_fd_handler_del (fd_handler);
ecore_main_fd_handler_del(fd_handler);
fd_handler = NULL;
}
}
void Ecore::BusWatch::data (Ecore::BusDispatcher *bd)
void Ecore::BusWatch::data(Ecore::BusDispatcher *bd)
{
_bd = bd;
}
@ -155,39 +155,39 @@ Ecore::BusDispatcher::BusDispatcher()
{
}
Eina_Bool Ecore::BusDispatcher::check ( void *data, Ecore_Fd_Handler *fdh)
Eina_Bool Ecore::BusDispatcher::check(void *data, Ecore_Fd_Handler *fdh)
{
return 0;
}
Timeout* Ecore::BusDispatcher::add_timeout( Timeout::Internal* wi )
Timeout *Ecore::BusDispatcher::add_timeout(Timeout::Internal *wi)
{
Timeout* t = new Ecore::BusTimeout( wi );
Timeout *t = new Ecore::BusTimeout(wi);
debug_log("ecore: added timeout %p (%s)", t, t->enabled() ? "on":"off");
debug_log("ecore: added timeout %p (%s)", t, t->enabled() ? "on" : "off");
return t;
}
void Ecore::BusDispatcher::rem_timeout( Timeout* t )
void Ecore::BusDispatcher::rem_timeout(Timeout *t)
{
debug_log("ecore: removed timeout %p", t);
delete t;
}
Watch* Ecore::BusDispatcher::add_watch( Watch::Internal* wi )
Watch *Ecore::BusDispatcher::add_watch(Watch::Internal *wi)
{
Ecore::BusWatch* w = new Ecore::BusWatch(wi);
w->data (this);
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()
w, w->enabled() ? "on" : "off", w->descriptor(), w->flags()
);
return w;
}
void Ecore::BusDispatcher::rem_watch( Watch* w )
void Ecore::BusDispatcher::rem_watch(Watch *w)
{
debug_log("ecore: removed watch %p", w);

View file

@ -39,21 +39,21 @@ using namespace DBus;
*/
Error::Error()
: _int(new InternalError)
: _int(new InternalError)
{}
Error::Error(InternalError &i)
: _int(new InternalError(i))
: _int(new InternalError(i))
{}
Error::Error(const char *name, const char *message)
: _int(new InternalError)
: _int(new InternalError)
{
set(name, message);
}
Error::Error(Message &m)
: _int(new InternalError)
: _int(new InternalError)
{
dbus_set_error_from_message(&(_int->error), m._pvt->msg);
}

View file

@ -43,20 +43,20 @@ using namespace DBus;
using namespace std;
BusTimeout::BusTimeout(Timeout::Internal *ti, BusDispatcher *bd)
: Timeout(ti), DefaultTimeout(Timeout::interval(), true, bd)
: Timeout(ti), DefaultTimeout(Timeout::interval(), true, bd)
{
DefaultTimeout::enabled(Timeout::enabled());
}
void BusTimeout::toggle()
{
debug_log("timeout %p toggled (%s)", this, Timeout::enabled() ? "on":"off");
debug_log("timeout %p toggled (%s)", this, Timeout::enabled() ? "on" : "off");
DefaultTimeout::enabled(Timeout::enabled());
}
BusWatch::BusWatch(Watch::Internal *wi, BusDispatcher *bd)
: Watch(wi), DefaultWatch(Watch::descriptor(), 0, bd)
: Watch(wi), DefaultWatch(Watch::descriptor(), 0, bd)
{
int flags = POLLHUP | POLLERR;
@ -71,7 +71,7 @@ BusWatch::BusWatch(Watch::Internal *wi, BusDispatcher *bd)
void BusWatch::toggle()
{
debug_log("watch %p toggled (%s)", this, Watch::enabled() ? "on":"off");
debug_log("watch %p toggled (%s)", this, Watch::enabled() ? "on" : "off");
DefaultWatch::enabled(Watch::enabled());
}
@ -98,17 +98,17 @@ void BusDispatcher::enter()
{
do_iteration();
for (std::list <Pipe*>::iterator p_it = pipe_list.begin ();
p_it != pipe_list.end ();
for (std::list <Pipe *>::iterator p_it = pipe_list.begin();
p_it != pipe_list.end();
++p_it)
{
Pipe* read_pipe = *p_it;
Pipe *read_pipe = *p_it;
char buffer[1024]; // TODO: should be max pipe size
unsigned int nbytes = 0;
while (read_pipe->read(buffer, nbytes) > 0)
{
read_pipe->_handler (read_pipe->_data, buffer, nbytes);
read_pipe->_handler(read_pipe->_data, buffer, nbytes);
}
}
@ -121,7 +121,7 @@ void BusDispatcher::leave()
{
_running = false;
int ret = write(_fdunlock[1],"exit",strlen("exit"));
int ret = write(_fdunlock[1], "exit", strlen("exit"));
if (ret == -1) throw Error("WriteError:errno", toString(errno).c_str());
close(_fdunlock[1]);
@ -130,15 +130,15 @@ void BusDispatcher::leave()
Pipe *BusDispatcher::add_pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data)
{
Pipe *new_pipe = new Pipe (handler, data);
pipe_list.push_back (new_pipe);
Pipe *new_pipe = new Pipe(handler, data);
pipe_list.push_back(new_pipe);
return new_pipe;
}
void BusDispatcher::del_pipe (Pipe *pipe)
void BusDispatcher::del_pipe(Pipe *pipe)
{
pipe_list.remove (pipe);
pipe_list.remove(pipe);
delete pipe;
}
@ -157,8 +157,8 @@ Timeout *BusDispatcher::add_timeout(Timeout::Internal *ti)
debug_log("added timeout %p (%s) (%d millies)",
bt,
((Timeout*)bt)->enabled() ? "on":"off",
((Timeout*)bt)->interval()
((Timeout *)bt)->enabled() ? "on" : "off",
((Timeout *)bt)->interval()
);
return bt;
@ -179,7 +179,7 @@ Watch *BusDispatcher::add_watch(Watch::Internal *wi)
bw->data(bw);
debug_log("added watch %p (%s) fd=%d flags=%d",
bw, ((Watch *)bw)->enabled() ? "on":"off", ((Watch *)bw)->descriptor(), ((Watch *)bw)->flags());
bw, ((Watch *)bw)->enabled() ? "on" : "off", ((Watch *)bw)->descriptor(), ((Watch *)bw)->flags());
return bw;
}

View file

@ -38,11 +38,11 @@ using namespace std;
static double millis(timeval tv)
{
return (tv.tv_sec *1000.0 + tv.tv_usec/1000.0);
return (tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0);
}
DefaultTimeout::DefaultTimeout(int interval, bool repeat, DefaultMainLoop *ed)
: _enabled(true), _interval(interval), _repeat(repeat), _expiration(0), _data(0), _disp(ed)
: _enabled(true), _interval(interval), _repeat(repeat), _expiration(0), _data(0), _disp(ed)
{
timeval now;
gettimeofday(&now, NULL);
@ -62,7 +62,7 @@ DefaultTimeout::~DefaultTimeout()
}
DefaultWatch::DefaultWatch(int fd, int flags, DefaultMainLoop *ed)
: _enabled(true), _fd(fd), _flags(flags), _state(0), _data(0), _disp(ed)
: _enabled(true), _fd(fd), _flags(flags), _state(0), _data(0), _disp(ed)
{
_disp->_mutex_w.lock();
_disp->_watches.push_back(this);
@ -124,7 +124,7 @@ DefaultMainLoop::~DefaultMainLoop()
DefaultWatches::iterator wmp = wi;
++wmp;
_mutex_w.unlock();
delete (*wi);
delete(*wi);
_mutex_w.lock();
wi = wmp;
}
@ -138,7 +138,7 @@ DefaultMainLoop::~DefaultMainLoop()
DefaultTimeouts::iterator tmp = ti;
++tmp;
_mutex_t.unlock();
delete (*ti);
delete(*ti);
_mutex_t.lock();
ti = tmp;
}
@ -151,9 +151,9 @@ void DefaultMainLoop::dispatch()
int nfd = _watches.size();
if(_fdunlock)
if (_fdunlock)
{
nfd=nfd+2;
nfd = nfd + 2;
}
pollfd fds[nfd];
@ -172,7 +172,8 @@ void DefaultMainLoop::dispatch()
}
}
if(_fdunlock){
if (_fdunlock)
{
fds[nfd].fd = _fdunlock[0];
fds[nfd].events = POLLIN | POLLOUT | POLLPRI ;
fds[nfd].revents = 0;

View file

@ -31,7 +31,7 @@
using namespace DBus;
Glib::BusTimeout::BusTimeout(Timeout::Internal *ti, GMainContext *ctx, int priority)
: Timeout(ti), _ctx(ctx), _priority(priority), _source(NULL)
: Timeout(ti), _ctx(ctx), _priority(priority), _source(NULL)
{
if (Timeout::enabled())
_enable();
@ -44,7 +44,7 @@ Glib::BusTimeout::~BusTimeout()
void Glib::BusTimeout::toggle()
{
debug_log("glib: timeout %p toggled (%s)", this, Timeout::enabled() ? "on":"off");
debug_log("glib: timeout %p toggled (%s)", this, Timeout::enabled() ? "on" : "off");
if (Timeout::enabled()) _enable();
else _disable();
@ -109,7 +109,8 @@ static gboolean watch_dispatch(GSource *source, GSourceFunc callback, gpointer d
return cb;
}
static GSourceFuncs watch_funcs = {
static GSourceFuncs watch_funcs =
{
watch_prepare,
watch_check,
watch_dispatch,
@ -117,7 +118,7 @@ static GSourceFuncs watch_funcs = {
};
Glib::BusWatch::BusWatch(Watch::Internal *wi, GMainContext *ctx, int priority)
: Watch(wi), _ctx(ctx), _priority(priority), _source(NULL)
: Watch(wi), _ctx(ctx), _priority(priority), _source(NULL)
{
if (Watch::enabled())
_enable();
@ -130,7 +131,7 @@ Glib::BusWatch::~BusWatch()
void Glib::BusWatch::toggle()
{
debug_log("glib: watch %p toggled (%s)", this, Watch::enabled() ? "on":"off");
debug_log("glib: watch %p toggled (%s)", this, Watch::enabled() ? "on" : "off");
if (Watch::enabled()) _enable();
else _disable();
@ -143,13 +144,13 @@ gboolean Glib::BusWatch::watch_handler(gpointer data)
BusSource *io = (BusSource *)(w->_source);
int flags = 0;
if (io->poll.revents &G_IO_IN)
if (io->poll.revents & G_IO_IN)
flags |= DBUS_WATCH_READABLE;
if (io->poll.revents &G_IO_OUT)
if (io->poll.revents & G_IO_OUT)
flags |= DBUS_WATCH_WRITABLE;
if (io->poll.revents &G_IO_ERR)
if (io->poll.revents & G_IO_ERR)
flags |= DBUS_WATCH_ERROR;
if (io->poll.revents &G_IO_HUP)
if (io->poll.revents & G_IO_HUP)
flags |= DBUS_WATCH_HANGUP;
w->handle(flags);
@ -168,13 +169,13 @@ void Glib::BusWatch::_enable()
int flags = Watch::flags();
int condition = 0;
if (flags &DBUS_WATCH_READABLE)
if (flags & DBUS_WATCH_READABLE)
condition |= G_IO_IN;
if (flags &DBUS_WATCH_WRITABLE)
if (flags & DBUS_WATCH_WRITABLE)
condition |= G_IO_OUT;
if (flags &DBUS_WATCH_ERROR)
if (flags & DBUS_WATCH_ERROR)
condition |= G_IO_ERR;
if (flags &DBUS_WATCH_HANGUP)
if (flags & DBUS_WATCH_HANGUP)
condition |= G_IO_HUP;
GPollFD *poll = &(((BusSource *)_source)->poll);
@ -210,11 +211,11 @@ struct DispatcherSource
static gboolean dispatcher_prepare(GSource *source, gint *timeout)
{
Dispatcher *dispatcher = ((DispatcherSource*)source)->dispatcher;
Dispatcher *dispatcher = ((DispatcherSource *)source)->dispatcher;
*timeout = -1;
return dispatcher->has_something_to_dispatch()? TRUE:FALSE;
return dispatcher->has_something_to_dispatch() ? TRUE : FALSE;
}
static gboolean dispatcher_check(GSource *source)
@ -227,13 +228,14 @@ dispatcher_dispatch(GSource *source,
GSourceFunc callback,
gpointer user_data)
{
Dispatcher *dispatcher = ((DispatcherSource*)source)->dispatcher;
Dispatcher *dispatcher = ((DispatcherSource *)source)->dispatcher;
dispatcher->dispatch_pending();
return TRUE;
}
static const GSourceFuncs dispatcher_funcs = {
static const GSourceFuncs dispatcher_funcs =
{
dispatcher_prepare,
dispatcher_check,
dispatcher_dispatch,
@ -241,7 +243,7 @@ static const GSourceFuncs dispatcher_funcs = {
};
Glib::BusDispatcher::BusDispatcher()
: _ctx(NULL), _priority(G_PRIORITY_DEFAULT), _source(NULL)
: _ctx(NULL), _priority(G_PRIORITY_DEFAULT), _source(NULL)
{
}
@ -252,8 +254,8 @@ Glib::BusDispatcher::~BusDispatcher()
GSource *temp = _source;
_source = NULL;
g_source_destroy (temp);
g_source_unref (temp);
g_source_destroy(temp);
g_source_unref(temp);
}
if (_ctx)
@ -271,15 +273,15 @@ void Glib::BusDispatcher::attach(GMainContext *ctx)
_source = g_source_new((GSourceFuncs *) &dispatcher_funcs,
sizeof(DispatcherSource));
((DispatcherSource*)_source)->dispatcher = this;
g_source_attach (_source, _ctx);
((DispatcherSource *)_source)->dispatcher = this;
g_source_attach(_source, _ctx);
}
Timeout *Glib::BusDispatcher::add_timeout(Timeout::Internal *wi)
{
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");
return t;
}
@ -296,7 +298,7 @@ Watch *Glib::BusDispatcher::add_watch(Watch::Internal *wi)
Watch *w = new Glib::BusWatch(wi, _ctx, _priority);
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()
);
return w;
}

View file

@ -33,7 +33,7 @@
using namespace DBus;
Interface::Interface(const std::string &name)
: _name(name)
: _name(name)
{}
Interface::~Interface()
@ -47,7 +47,7 @@ InterfaceAdaptor *AdaptorBase::find_interface(const std::string &name)
}
InterfaceAdaptor::InterfaceAdaptor(const std::string &name)
: Interface(name)
: Interface(name)
{
debug_log("adding interface %s", name.c_str());
@ -121,7 +121,7 @@ InterfaceProxy *ProxyBase::find_interface(const std::string &name)
}
InterfaceProxy::InterfaceProxy(const std::string &name)
: Interface(name)
: Interface(name)
{
debug_log("adding interface %s", name.c_str());

View file

@ -33,7 +33,8 @@
#include <dbus/dbus.h>
namespace DBus {
namespace DBus
{
struct DXXAPI InternalError
{

View file

@ -38,7 +38,7 @@ using namespace DBus;
static const char *introspectable_name = "org.freedesktop.DBus.Introspectable";
IntrospectableAdaptor::IntrospectableAdaptor()
: InterfaceAdaptor(introspectable_name)
: InterfaceAdaptor(introspectable_name)
{
register_method(IntrospectableAdaptor, Introspect, Introspect);
}
@ -144,7 +144,7 @@ Message IntrospectableAdaptor::Introspect(const CallMessage &call)
return reply;
}
IntrospectedInterface * IntrospectableAdaptor::introspect() const
IntrospectedInterface *IntrospectableAdaptor::introspect() const
{
static IntrospectedArgument Introspect_args[] =
{
@ -175,7 +175,7 @@ IntrospectedInterface * IntrospectableAdaptor::introspect() const
}
IntrospectableProxy::IntrospectableProxy()
: InterfaceProxy(introspectable_name)
: InterfaceProxy(introspectable_name)
{}
std::string IntrospectableProxy::Introspect()

View file

@ -227,7 +227,7 @@ const char *MessageIter::get_signature()
MessageIter MessageIter::recurse()
{
MessageIter iter(msg());
dbus_message_iter_recurse((DBusMessageIter *)&_iter, (DBusMessageIter *)&(iter._iter));
dbus_message_iter_recurse((DBusMessageIter *)&_iter, (DBusMessageIter *) & (iter._iter));
return iter;
}
@ -267,7 +267,7 @@ MessageIter MessageIter::new_array(const char *sig)
{
MessageIter arr(msg());
dbus_message_iter_open_container(
(DBusMessageIter *)&_iter, DBUS_TYPE_ARRAY, sig, (DBusMessageIter *)&(arr._iter)
(DBusMessageIter *)&_iter, DBUS_TYPE_ARRAY, sig, (DBusMessageIter *) & (arr._iter)
);
return arr;
}
@ -276,7 +276,7 @@ MessageIter MessageIter::new_variant(const char *sig)
{
MessageIter var(msg());
dbus_message_iter_open_container(
(DBusMessageIter *)_iter, DBUS_TYPE_VARIANT, sig, (DBusMessageIter *)&(var._iter)
(DBusMessageIter *)_iter, DBUS_TYPE_VARIANT, sig, (DBusMessageIter *) & (var._iter)
);
return var;
}
@ -285,7 +285,7 @@ MessageIter MessageIter::new_struct()
{
MessageIter stu(msg());
dbus_message_iter_open_container(
(DBusMessageIter *)_iter, DBUS_TYPE_STRUCT, NULL, (DBusMessageIter *)&(stu._iter)
(DBusMessageIter *)_iter, DBUS_TYPE_STRUCT, NULL, (DBusMessageIter *) & (stu._iter)
);
return stu;
}
@ -294,14 +294,14 @@ MessageIter MessageIter::new_dict_entry()
{
MessageIter ent(msg());
dbus_message_iter_open_container(
(DBusMessageIter *)_iter, DBUS_TYPE_DICT_ENTRY, NULL, (DBusMessageIter *)&(ent._iter)
(DBusMessageIter *)_iter, DBUS_TYPE_DICT_ENTRY, NULL, (DBusMessageIter *) & (ent._iter)
);
return ent;
}
void MessageIter::close_container(MessageIter &container)
{
dbus_message_iter_close_container((DBusMessageIter *)&_iter, (DBusMessageIter *)&(container._iter));
dbus_message_iter_close_container((DBusMessageIter *)&_iter, (DBusMessageIter *) & (container._iter));
}
static bool is_basic_type(int typecode)
@ -345,13 +345,13 @@ void MessageIter::copy_data(MessageIter &to)
debug_log("copying compound type: %c[%s]", from.type(), sig);
MessageIter to_container (to.msg());
MessageIter to_container(to.msg());
dbus_message_iter_open_container
(
(DBusMessageIter *)&(to._iter),
(DBusMessageIter *) & (to._iter),
from.type(),
from.type() == DBUS_TYPE_VARIANT ? NULL : sig,
(DBusMessageIter *)&(to_container._iter)
(DBusMessageIter *) & (to_container._iter)
);
from_container.copy_data(to_container);
@ -365,18 +365,18 @@ void MessageIter::copy_data(MessageIter &to)
*/
Message::Message()
: _pvt(new Private)
: _pvt(new Private)
{
}
Message::Message(Message::Private *p, bool incref)
: _pvt(p)
: _pvt(p)
{
if (_pvt->msg && incref) dbus_message_ref(_pvt->msg);
}
Message::Message(const Message &m)
: _pvt(m._pvt)
: _pvt(m._pvt)
{
dbus_message_ref(_pvt->msg);
}
@ -472,14 +472,14 @@ bool Message::is_signal(const char *interface, const char *member) const
MessageIter Message::writer()
{
MessageIter iter(*this);
dbus_message_iter_init_append(_pvt->msg, (DBusMessageIter *)&(iter._iter));
dbus_message_iter_init_append(_pvt->msg, (DBusMessageIter *) & (iter._iter));
return iter;
}
MessageIter Message::reader() const
{
MessageIter iter(const_cast<Message &>(*this));
dbus_message_iter_init(_pvt->msg, (DBusMessageIter *)&(iter._iter));
dbus_message_iter_init(_pvt->msg, (DBusMessageIter *) & (iter._iter));
return iter;
}
@ -555,9 +555,9 @@ const char *SignalMessage::path() const
return dbus_message_get_path(_pvt->msg);
}
char ** SignalMessage::path_split() const
char **SignalMessage::path_split() const
{
char ** p;
char **p;
dbus_message_get_path_decomposed(_pvt->msg, &p); //todo: return as a std::vector ?
return p;
}
@ -610,9 +610,9 @@ const char *CallMessage::path() const
return dbus_message_get_path(_pvt->msg);
}
char ** CallMessage::path_split() const
char **CallMessage::path_split() const
{
char ** p;
char **p;
dbus_message_get_path_decomposed(_pvt->msg, &p);
return p;
}

View file

@ -34,7 +34,8 @@
#include <dbus/dbus.h>
namespace DBus {
namespace DBus
{
struct DXXAPILOCAL Message::Private
{

View file

@ -40,7 +40,7 @@
using namespace DBus;
Object::Object(Connection &conn, const Path &path, const char *service)
: _conn(conn), _path(path), _service(service ? service : ""), _default_timeout(-1)
: _conn(conn), _path(path), _service(service ? service : ""), _default_timeout(-1)
{
}
@ -51,7 +51,7 @@ Object::~Object()
void Object::set_timeout(int new_timeout)
{
debug_log("%s: %d millies", __PRETTY_FUNCTION__, new_timeout);
if(new_timeout < 0 && new_timeout != -1)
if (new_timeout < 0 && new_timeout != -1)
throw ErrorInvalidArgs("Bad timeout, cannot set it");
_default_timeout = new_timeout;
}
@ -144,7 +144,7 @@ ObjectPathList ObjectAdaptor::child_nodes_from_prefix(const std::string &prefix)
if (!strncmp(ati->second->path().c_str(), prefix.c_str(), plen))
{
std::string p = ati->second->path().substr(plen);
p = p.substr(0,p.find('/'));
p = p.substr(0, p.find('/'));
ali.push_back(p);
}
++ati;
@ -157,7 +157,7 @@ ObjectPathList ObjectAdaptor::child_nodes_from_prefix(const std::string &prefix)
}
ObjectAdaptor::ObjectAdaptor(Connection &conn, const Path &path)
: Object(conn, path, conn.unique_name())
: Object(conn, path, conn.unique_name())
{
register_obj();
}
@ -220,12 +220,12 @@ bool ObjectAdaptor::handle_message(const Message &msg)
Message ret = ii->dispatch_method(cmsg);
conn().send(ret);
}
catch(Error &e)
catch (Error &e)
{
ErrorMessage em(cmsg, e.name(), e.message());
conn().send(em);
}
catch(ReturnLaterError &rle)
catch (ReturnLaterError &rle)
{
_continuations[rle.tag] = new Continuation(conn(), cmsg, rle.tag);
}
@ -279,7 +279,7 @@ ObjectAdaptor::Continuation *ObjectAdaptor::find_continuation(const Tag *tag)
}
ObjectAdaptor::Continuation::Continuation(Connection &conn, const CallMessage &call, const Tag *tag)
: _conn(conn), _call(call), _return(_call), _tag(tag)
: _conn(conn), _call(call), _return(_call), _tag(tag)
{
_writer = _return.writer(); //todo: verify
}
@ -288,7 +288,7 @@ ObjectAdaptor::Continuation::Continuation(Connection &conn, const CallMessage &c
*/
ObjectProxy::ObjectProxy(Connection &conn, const Path &path, const char *service)
: Object(conn, path, service)
: Object(conn, path, service)
{
register_obj();
}
@ -309,7 +309,7 @@ void ObjectProxy::register_obj()
InterfaceProxyTable::const_iterator ii = _interfaces.begin();
while (ii != _interfaces.end())
{
std::string im = "type='signal',interface='"+ii->first+"',path='"+path()+"'";
std::string im = "type='signal',interface='" + ii->first + "',path='" + path() + "'";
conn().add_match(im.c_str());
++ii;
}
@ -322,7 +322,7 @@ void ObjectProxy::unregister_obj(bool throw_on_error)
InterfaceProxyTable::const_iterator ii = _interfaces.begin();
while (ii != _interfaces.end())
{
std::string im = "type='signal',interface='"+ii->first+"',path='"+path()+"'";
std::string im = "type='signal',interface='" + ii->first + "',path='" + path() + "'";
conn().remove_match(im.c_str(), throw_on_error);
++ii;
}

View file

@ -36,7 +36,7 @@
using namespace DBus;
PendingCall::Private::Private(DBusPendingCall *dpc)
: call(dpc), dataslot(-1)
: call(dpc), dataslot(-1)
{
if (!dbus_pending_call_allocate_data_slot(&dataslot))
{
@ -61,7 +61,7 @@ void PendingCall::Private::notify_stub(DBusPendingCall *dpc, void *data)
}
PendingCall::PendingCall(PendingCall::Private *p)
: _pvt(p)
: _pvt(p)
{
if (!dbus_pending_call_set_notify(_pvt->call, Private::notify_stub, p, NULL))
{
@ -70,7 +70,7 @@ PendingCall::PendingCall(PendingCall::Private *p)
}
PendingCall::PendingCall(const PendingCall &c)
: _pvt(c._pvt)
: _pvt(c._pvt)
{
dbus_pending_call_ref(_pvt->call);
}

View file

@ -34,7 +34,8 @@
#include <dbus/dbus.h>
namespace DBus {
namespace DBus
{
struct DXXAPILOCAL PendingCall::Private
{

View file

@ -42,13 +42,13 @@ using namespace std;
Pipe::Pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data) :
_handler(handler),
_fd_write (0),
_fd_read (0),
_fd_write(0),
_fd_read(0),
_data(data)
{
int fd[2];
if(pipe(fd) == 0)
if (pipe(fd) == 0)
{
_fd_read = fd[0];
_fd_write = fd[1];
@ -63,7 +63,7 @@ Pipe::Pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), c
void Pipe::write(const void *buffer, unsigned int nbytes)
{
// first write the size into the pipe...
::write(_fd_write, static_cast <const void*> (&nbytes), sizeof(nbytes));
::write(_fd_write, static_cast <const void *>(&nbytes), sizeof(nbytes));
// ...then write the real data
::write(_fd_write, buffer, nbytes);
@ -72,7 +72,7 @@ void Pipe::write(const void *buffer, unsigned int nbytes)
ssize_t Pipe::read(void *buffer, unsigned int &nbytes)
{
// first read the size from the pipe...
::read(_fd_read, &nbytes, sizeof (nbytes));
::read(_fd_read, &nbytes, sizeof(nbytes));
//ssize_t size = 0;
return ::read(_fd_read, buffer, nbytes);

View file

@ -35,7 +35,7 @@ using namespace DBus;
static const char *properties_name = "org.freedesktop.DBus.Properties";
PropertiesAdaptor::PropertiesAdaptor()
: InterfaceAdaptor(properties_name)
: InterfaceAdaptor(properties_name)
{
register_method(PropertiesAdaptor, Get, Get);
register_method(PropertiesAdaptor, Set, Set);
@ -96,7 +96,7 @@ Message PropertiesAdaptor::Set(const CallMessage &call)
return reply;
}
IntrospectedInterface * PropertiesAdaptor::introspect() const
IntrospectedInterface *PropertiesAdaptor::introspect() const
{
static IntrospectedArgument Get_args[] =
{
@ -137,7 +137,7 @@ IntrospectedInterface * PropertiesAdaptor::introspect() const
}
PropertiesProxy::PropertiesProxy()
: InterfaceProxy(properties_name)
: InterfaceProxy(properties_name)
{
}

View file

@ -36,7 +36,7 @@
using namespace DBus;
Server::Private::Private(DBusServer *s)
: server(s)
: server(s)
{
}
@ -48,7 +48,7 @@ void Server::Private::on_new_conn_cb(DBusServer *server, DBusConnection *conn, v
{
Server *s = static_cast<Server *>(data);
Connection nc (new Connection::Private(conn, s->_pvt.get()));
Connection nc(new Connection::Private(conn, s->_pvt.get()));
s->_pvt->connections.push_back(nc);

View file

@ -35,7 +35,8 @@
#include <dbus/dbus.h>
namespace DBus {
namespace DBus
{
struct DXXAPILOCAL Server::Private
{

View file

@ -37,12 +37,12 @@
using namespace DBus;
Variant::Variant()
: _msg(CallMessage()) // dummy message used as temporary storage for variant data
: _msg(CallMessage()) // dummy message used as temporary storage for variant data
{
}
Variant::Variant(MessageIter &it)
: _msg(CallMessage())
: _msg(CallMessage())
{
MessageIter vi = it.recurse();
MessageIter mi = _msg.writer();

View file

@ -20,16 +20,16 @@ std::list <std::string> testList;
pthread_mutex_t clientMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t clientCondition = PTHREAD_COND_INITIALIZER;
TestApp::TestApp ()
TestApp::TestApp()
{
testList.push_back ("test1");
testList.push_back ("testByte");
testList.push_back("test1");
testList.push_back("testByte");
cout << "initialize DBus..." << endl;
initDBus ();
initDBus();
}
void TestApp::initDBus ()
void TestApp::initDBus()
{
DBus::_init_threading();
@ -39,68 +39,68 @@ void TestApp::initDBus ()
DBus::Connection conn = DBus::Connection::SessionBus();
TestAppIntro testComIntro (conn, clientCondition, testResult);
TestAppIntro testComIntro(conn, clientCondition, testResult);
g_testComIntro = &testComIntro;
cout << "Start server..." << endl;
TestAppIntroProvider testComProviderIntro (conn, &testComIntro);
conn.request_name ("DBusCpp.Test.Com.Intro");
TestAppIntroProvider testComProviderIntro(conn, &testComIntro);
conn.request_name("DBusCpp.Test.Com.Intro");
mTestToDBusPipe = dispatcher.add_pipe (TestApp::testHandler, NULL);
mTestToDBusPipe = dispatcher.add_pipe(TestApp::testHandler, NULL);
cout << "Start client thread..." << endl;
pthread_create (&testThread, NULL, TestApp::testThreadRunner, &conn);
pthread_create(&testThread, NULL, TestApp::testThreadRunner, &conn);
dispatcher.enter();
pthread_join (testThread, NULL);
pthread_join(testThread, NULL);
cout << "Testresult = " << string (testResult ? "OK" : "NOK") << endl;
cout << "Testresult = " << string(testResult ? "OK" : "NOK") << endl;
}
void *TestApp::testThreadRunner (void *arg)
void *TestApp::testThreadRunner(void *arg)
{
for (std::list <std::string>::const_iterator tl_it = testList.begin ();
tl_it != testList.end ();
for (std::list <std::string>::const_iterator tl_it = testList.begin();
tl_it != testList.end();
++tl_it)
{
const string &testString = *tl_it;
cout << "write to pipe" << endl;
mTestToDBusPipe->write (testString.c_str (), testString.length () + 1);
mTestToDBusPipe->write(testString.c_str(), testString.length() + 1);
struct timespec abstime;
clock_gettime(CLOCK_REALTIME, &abstime);
abstime.tv_sec += 1;
pthread_mutex_lock (&clientMutex);
if (pthread_cond_timedwait (&clientCondition, &clientMutex, &abstime) == ETIMEDOUT)
pthread_mutex_lock(&clientMutex);
if (pthread_cond_timedwait(&clientCondition, &clientMutex, &abstime) == ETIMEDOUT)
{
cout << "client timeout!" << endl;
testResult = false;
}
pthread_mutex_unlock (&clientMutex);
pthread_mutex_unlock(&clientMutex);
}
cout << "leave!" << endl;
dispatcher.leave ();
dispatcher.leave();
return NULL;
}
void TestApp::testHandler (const void *data, void *buffer, unsigned int nbyte)
void TestApp::testHandler(const void *data, void *buffer, unsigned int nbyte)
{
char *str = (char*) buffer;
char *str = (char *) buffer;
cout << "buffer1: " << str << ", size: " << nbyte << endl;
cout << "run it!" << endl;
if (string (str) == "test1")
if (string(str) == "test1")
{
g_testComIntro->test1 ();
g_testComIntro->test1();
}
else if (string (str) == "testByte")
else if (string(str) == "testByte")
{
g_testComIntro->testByte (4);
g_testComIntro->testByte(4);
}
}

View file

@ -13,14 +13,14 @@
class TestApp
{
public:
TestApp ();
TestApp();
private:
void initDBus ();
void initDBus();
static void testHandler (const void *data, void *buffer, unsigned int nbyte);
static void *testThreadRunner (void *arg);
static void *testThreadRunnerProvider (void *arg);
static void testHandler(const void *data, void *buffer, unsigned int nbyte);
static void *testThreadRunner(void *arg);
static void *testThreadRunnerProvider(void *arg);
// variables
pthread_t testThread;

View file

@ -15,24 +15,24 @@ class TestAppIntro :
public DBus::ObjectProxy
{
public:
TestAppIntro (DBus::Connection& connection, pthread_cond_t &condition, bool &testResult) :
DBus::ObjectProxy (connection, "/DBusCpp/Test/Com/Intro", "DBusCpp.Test.Com.Intro"),
mCondition (condition),
mTestResult (testResult)
TestAppIntro(DBus::Connection &connection, pthread_cond_t &condition, bool &testResult) :
DBus::ObjectProxy(connection, "/DBusCpp/Test/Com/Intro", "DBusCpp.Test.Com.Intro"),
mCondition(condition),
mTestResult(testResult)
{}
void test1Result ()
void test1Result()
{
cout << "Test1Result" << endl;
mTestResult = true;
pthread_cond_signal (&mCondition);
pthread_cond_signal(&mCondition);
}
void testByteResult (const uint8_t& Byte)
void testByteResult(const uint8_t &Byte)
{
printf ("TestByteResult: %d\n", Byte);
printf("TestByteResult: %d\n", Byte);
mTestResult = true;
pthread_cond_signal (&mCondition);
pthread_cond_signal(&mCondition);
}
private:

View file

@ -15,21 +15,21 @@ class TestAppIntroProvider :
public DBus::ObjectAdaptor
{
public:
TestAppIntroProvider (DBus::Connection& connection, TestAppIntro *testComIntro) :
TestAppIntroProvider(DBus::Connection &connection, TestAppIntro *testComIntro) :
DBus::ObjectAdaptor(connection, "/DBusCpp/Test/Com/Intro"),
mTestAppIntro (testComIntro)
mTestAppIntro(testComIntro)
{}
void test1 ()
void test1()
{
cout << "Test1" << endl;
mTestAppIntro->test1Result ();
mTestAppIntro->test1Result();
}
void testByte (const uint8_t& Byte)
void testByte(const uint8_t &Byte)
{
printf ("TestByte: %d\n", Byte);
mTestAppIntro->testByteResult (Byte);
printf("TestByte: %d\n", Byte);
mTestAppIntro->testByteResult(Byte);
}
private:

View file

@ -6,7 +6,7 @@
using namespace std;
int main (int argc, char **argv)
int main(int argc, char **argv)
{
TestApp testCom;
}

View file

@ -1,6 +1,6 @@
#include <dbuscxx_test_generator-client.h>
int main (int argc, char **argv)
int main(int argc, char **argv)
{
return 0;

View file

@ -1,6 +1,6 @@
#include <dbuscxx_test_generator-server.h>
int main (int argc, char **argv)
int main(int argc, char **argv)
{
return 0;

View file

@ -74,7 +74,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
// these interface names are skipped.
if (ifacename == "org.freedesktop.DBus.Introspectable"
||ifacename == "org.freedesktop.DBus.Properties")
|| ifacename == "org.freedesktop.DBus.Properties")
{
cerr << "skipping interface " << ifacename << endl;
continue;
@ -138,7 +138,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
Xml::Node &method = **mi;
body << tab << tab << "register_method("
<< ifaceclass << ", " << method.get("name") << ", "<< stub_name(method.get("name"))
<< ifaceclass << ", " << method.get("name") << ", " << stub_name(method.get("name"))
<< ");" << endl;
}
@ -272,10 +272,10 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
{
Xml::Node &method = **mi;
Xml::Nodes args = method["arg"];
Xml::Nodes args_in = args.select("direction","in");
Xml::Nodes args_out = args.select("direction","out");
Xml::Nodes args_in = args.select("direction", "in");
Xml::Nodes args_out = args.select("direction", "out");
Xml::Nodes annotations = args["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -312,7 +312,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
{
Xml::Node &arg = **ai;
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_name = arg.get("name");
string arg_object;
@ -332,13 +332,13 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
body << "const " << arg_object << "& ";
// store a object name to later generate header includes
include_vector.push_back (arg_object);
include_vector.push_back(arg_object);
}
if (arg_name.length())
body << arg_name;
if ((i+1 != args_in.size() || args_out.size() > 1))
if ((i + 1 != args_in.size() || args_out.size() > 1))
body << ", ";
}
@ -350,7 +350,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
{
Xml::Node &arg = **ao;
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_name = arg.get("name");
string arg_object;
@ -370,13 +370,13 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
body << arg_object << "& ";
// store a object name to later generate header includes
include_vector.push_back (arg_object);
include_vector.push_back(arg_object);
}
if (arg_name.length())
body << arg_name;
if (i+1 != args_out.size())
if (i + 1 != args_out.size())
body << ", ";
}
}
@ -403,7 +403,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
{
Xml::Node &arg = **a;
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -414,24 +414,24 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
// generate basic signature only if no object name available...
if (!arg_object.length())
{
body << "const " << signature_to_type(arg.get("type")) << "& arg" << i+1;
body << "const " << signature_to_type(arg.get("type")) << "& arg" << i + 1;
}
// ...or generate object style if available
else
{
body << "const " << arg_object << "& arg" << i+1;
body << "const " << arg_object << "& arg" << i + 1;
// store a object name to later generate header includes
include_vector.push_back (arg_object);
include_vector.push_back(arg_object);
}
if (i+1 != args.size())
if (i + 1 != args.size())
body << ", ";
}
body << ")" << endl
<< tab << "{" << endl
<< tab << tab << "::DBus::SignalMessage sig(\"" << signal.get("name") <<"\");" << endl;
<< tab << tab << "::DBus::SignalMessage sig(\"" << signal.get("name") << "\");" << endl;
// generate the signal body
if (!args.empty())
@ -443,7 +443,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
{
Xml::Node &arg = **a;
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -453,14 +453,14 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
if (arg_object.length())
{
body << tab << tab << signature_to_type(arg.get("type")) << " _arg" << i+1 << ";" << endl;
body << tab << tab << "_arg" << i+1 << " << " << "arg" << i+1 << ";" << endl;
body << tab << tab << signature_to_type(arg.get("type")) << " _arg" << i + 1 << ";" << endl;
body << tab << tab << "_arg" << i + 1 << " << " << "arg" << i + 1 << ";" << endl;
body << tab << tab << "wi << _arg" << i+1 << ";" << endl;
body << tab << tab << "wi << _arg" << i + 1 << ";" << endl;
}
else
{
body << tab << tab << "wi << arg" << i+1 << ";" << endl;
body << tab << tab << "wi << arg" << i + 1 << ";" << endl;
}
}
}
@ -481,8 +481,8 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
{
Xml::Node &method = **mi;
Xml::Nodes args = method["arg"];
Xml::Nodes args_in = args.select("direction","in");
Xml::Nodes args_out = args.select("direction","out");
Xml::Nodes args_in = args.select("direction", "in");
Xml::Nodes args_out = args.select("direction", "out");
body << tab << "::DBus::Message " << stub_name(method.get("name")) << "(const ::DBus::CallMessage &call)" << endl
<< tab << "{" << endl
@ -505,7 +505,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
{
Xml::Node &arg = **ai;
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -549,7 +549,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
{
Xml::Node &arg = **ao;
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -571,7 +571,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
{
Xml::Node &arg = **ai;
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -581,7 +581,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
}
// do correct indent
if (args_out.size() != 1 )
if (args_out.size() != 1)
{
body << tab << tab;
}
@ -594,7 +594,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
{
Xml::Node &arg = **ai;
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -604,14 +604,14 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
if (arg_object.length())
{
body << "_argin" << i+1;
body << "_argin" << i + 1;
}
else
{
body << "argin" << i+1;
body << "argin" << i + 1;
}
if ((i+1 != args_in.size() || args_out.size() > 1))
if ((i + 1 != args_in.size() || args_out.size() > 1))
body << ", ";
}
@ -622,7 +622,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
{
Xml::Node &arg = **ao;
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -632,14 +632,14 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
if (arg_object.length())
{
body << "_argout" << i+1;
body << "_argout" << i + 1;
}
else
{
body << "argout" << i+1;
body << "argout" << i + 1;
}
if (i+1 != args_out.size())
if (i + 1 != args_out.size())
body << ", ";
}
}
@ -658,7 +658,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
{
Xml::Node &arg = **ao;
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -668,13 +668,13 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
if (arg_object.length())
{
body << tab << tab << "argout" << i+1 << " << " << "_argout" << i+1 << ";" << endl;
body << tab << tab << "argout" << i + 1 << " << " << "_argout" << i + 1 << ";" << endl;
}
}
for (unsigned int i = 0; i < args_out.size(); ++i)
{
body << tab << tab << "wi << argout" << i+1 << ";" << endl;
body << tab << tab << "wi << argout" << i + 1 << ";" << endl;
}
}
@ -696,9 +696,9 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
body << "#endif //" << cond_comp << endl;
// remove all duplicates in the header include vector
vector<string>::const_iterator vec_end_it = unique (include_vector.begin (), include_vector.end ());
vector<string>::const_iterator vec_end_it = unique(include_vector.begin(), include_vector.end());
for (vector<string>::const_iterator vec_it = include_vector.begin ();
for (vector<string>::const_iterator vec_it = include_vector.begin();
vec_it != vec_end_it;
++vec_it)
{
@ -715,8 +715,8 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
exit(-1);
}
file << head.str ();
file << body.str ();
file << head.str();
file << body.str();
file.close();
}

View file

@ -74,7 +74,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
// these interface names are skipped.
if (ifacename == "org.freedesktop.DBus.Introspectable"
||ifacename == "org.freedesktop.DBus.Properties")
|| ifacename == "org.freedesktop.DBus.Properties")
{
cerr << "skipping interface " << ifacename << endl;
continue;
@ -135,15 +135,15 @@ void generate_proxy(Xml::Document &doc, const char *filename)
<< tab << "/* properties exported by this interface */" << endl;
// this loop generates all properties
for (Xml::Nodes::iterator pi = properties.begin ();
pi != properties.end (); ++pi)
for (Xml::Nodes::iterator pi = properties.begin();
pi != properties.end(); ++pi)
{
Xml::Node & property = **pi;
string prop_name = property.get ("name");
string property_access = property.get ("access");
Xml::Node &property = **pi;
string prop_name = property.get("name");
string property_access = property.get("access");
if (property_access == "read" || property_access == "readwrite")
{
body << tab << tab << "const " << signature_to_type (property.get("type"))
body << tab << tab << "const " << signature_to_type(property.get("type"))
<< " " << prop_name << "() {" << endl;
body << tab << tab << tab << "::DBus::CallMessage call ;\n ";
body << tab << tab << tab
@ -172,19 +172,19 @@ void generate_proxy(Xml::Document &doc, const char *filename)
if (property_access == "write" || property_access == "readwrite")
{
body << tab << tab << "void " << prop_name << "( const "<< signature_to_type (property.get("type")) << " & input" << ") {" << endl;
body << tab << tab << "void " << prop_name << "( const " << signature_to_type(property.get("type")) << " & input" << ") {" << endl;
body << tab << tab << tab << "::DBus::CallMessage call ;\n ";
body << tab << tab << tab <<"call.member(\"Set\"); call.interface( \"org.freedesktop.DBus.Properties\");"<< endl;
body << tab << tab << tab <<"::DBus::MessageIter wi = call.writer(); " << endl;
body << tab << tab << tab <<"::DBus::Variant value;" << endl;
body << tab << tab << tab <<"::DBus::MessageIter vi = value.writer ();" << endl;
body << tab << tab << tab <<"vi << input;" << endl;
body << tab << tab << tab <<"const std::string interface_name = \"" << ifacename << "\";" << endl;
body << tab << tab << tab <<"const std::string property_name = \"" << prop_name << "\";"<< endl;
body << tab << tab << tab <<"wi << interface_name;" << endl;
body << tab << tab << tab <<"wi << property_name;" << endl;
body << tab << tab << tab <<"wi << value;" << endl;
body << tab << tab << tab <<"::DBus::Message ret = this->invoke_method (call);" << endl;
body << tab << tab << tab << "call.member(\"Set\"); call.interface( \"org.freedesktop.DBus.Properties\");" << endl;
body << tab << tab << tab << "::DBus::MessageIter wi = call.writer(); " << endl;
body << tab << tab << tab << "::DBus::Variant value;" << endl;
body << tab << tab << tab << "::DBus::MessageIter vi = value.writer ();" << endl;
body << tab << tab << tab << "vi << input;" << endl;
body << tab << tab << tab << "const std::string interface_name = \"" << ifacename << "\";" << endl;
body << tab << tab << tab << "const std::string property_name = \"" << prop_name << "\";" << endl;
body << tab << tab << tab << "wi << interface_name;" << endl;
body << tab << tab << tab << "wi << property_name;" << endl;
body << tab << tab << tab << "wi << value;" << endl;
body << tab << tab << tab << "::DBus::Message ret = this->invoke_method (call);" << endl;
// TODO: support invoke_method_noreply for properties
body << tab << tab << "};" << endl;
}
@ -202,12 +202,12 @@ void generate_proxy(Xml::Document &doc, const char *filename)
{
Xml::Node &method = **mi;
Xml::Nodes args = method["arg"];
Xml::Nodes args_in = args.select("direction","in");
Xml::Nodes args_out = args.select("direction","out");
Xml::Nodes args_in = args.select("direction", "in");
Xml::Nodes args_out = args.select("direction", "out");
Xml::Nodes annotations = args["annotation"];
Xml::Nodes method_annotations = method["annotation"];
Xml::Nodes annotations_noreply = method_annotations.select("name","org.freedesktop.DBus.Method.NoReply");
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_noreply = method_annotations.select("name", "org.freedesktop.DBus.Method.NoReply");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
bool annotation_noreply_value = false;
@ -251,7 +251,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
{
Xml::Node &arg = **ai;
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -270,7 +270,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
body << "const " << arg_object << "& ";
// store a object name to later generate header includes
include_vector.push_back (arg_object);
include_vector.push_back(arg_object);
}
string arg_name = arg.get("name");
@ -279,7 +279,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
else
body << "argin" << i;
if ((i+1 != args_in.size() || args_out.size() > 1))
if ((i + 1 != args_in.size() || args_out.size() > 1))
body << ", ";
}
@ -291,7 +291,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
{
Xml::Node &arg = **ao;
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -310,7 +310,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
body << arg_object << "& ";
// store a object name to later generate header includes
include_vector.push_back (arg_object);
include_vector.push_back(arg_object);
}
string arg_name = arg.get("name");
@ -319,7 +319,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
else
body << " argout" << j;
if (j+1 != args_out.size())
if (j + 1 != args_out.size())
body << ", ";
}
}
@ -341,7 +341,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
Xml::Node &arg = **ai;
string arg_name = arg.get("name");
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -361,7 +361,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
body << tab << tab << signature_to_type(arg.get("type")) << "_" << arg_name << ";" << endl;
body << tab << tab << "_" << arg_name << " << " << arg_name << ";" << endl;
arg_name = string ("_") + arg_name;
arg_name = string("_") + arg_name;
}
body << tab << tab << "wi << " << arg_name << ";" << endl;
@ -372,7 +372,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
// generate noreply/reply method calls
if (annotation_noreply_value)
{
if (args_out.size ())
if (args_out.size())
{
cerr << "Function: " << method.get("name") << ":" << endl;
cerr << "Option 'org.freedesktop.DBus.Method.NoReply' not allowed for methods with 'out' variables!" << endl << "-> Option ignored!" << endl;
@ -399,7 +399,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
if (args_out.size() == 1)
{
Xml::Nodes annotations = args_out["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -435,7 +435,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
Xml::Node &arg = **ao;
string arg_name = arg.get("name");
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -495,7 +495,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
Xml::Node &arg = **ai;
string arg_name = arg.get("name");
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -514,7 +514,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
body << "const " << arg_object << "& ";
// store a object name to later generate header includes
include_vector.push_back (arg_object);
include_vector.push_back(arg_object);
}
if (arg_name.length())
@ -522,7 +522,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
else
body << "argin" << i;
if ((ai+1 != args.end()))
if ((ai + 1 != args.end()))
body << ", ";
}
body << ") = 0;" << endl;
@ -556,7 +556,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
Xml::Node &arg = **ai;
string arg_name = arg.get("name");
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -582,7 +582,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
body << tab << tab << "_" << arg_name << " << " << arg_name << ";" << endl;
// store a object name to later generate header includes
include_vector.push_back (arg_object);
include_vector.push_back(arg_object);
}
}
@ -595,7 +595,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
Xml::Node &arg = **ai;
string arg_name = arg.get("name");
Xml::Nodes annotations = arg["annotation"];
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
Xml::Nodes annotations_object = annotations.select("name", "org.freedesktop.DBus.Object");
string arg_object;
if (!annotations_object.empty())
@ -617,7 +617,7 @@ void generate_proxy(Xml::Document &doc, const char *filename)
body << arg_name;
}
if (ai+1 != args.end())
if (ai + 1 != args.end())
body << ", ";
}
@ -639,9 +639,9 @@ void generate_proxy(Xml::Document &doc, const char *filename)
body << "#endif //" << cond_comp << endl;
// remove all duplicates in the header include vector
vector<string>::const_iterator vec_end_it = unique (include_vector.begin (), include_vector.end ());
vector<string>::const_iterator vec_end_it = unique(include_vector.begin(), include_vector.end());
for (vector<string>::const_iterator vec_it = include_vector.begin ();
for (vector<string>::const_iterator vec_it = include_vector.begin();
vec_it != vec_end_it;
++vec_it)
{
@ -658,8 +658,8 @@ void generate_proxy(Xml::Document &doc, const char *filename)
exit(-1);
}
file << head.str ();
file << body.str ();
file << head.str();
file << body.str();
file.close();
}

View file

@ -42,24 +42,28 @@ const char *dbus_includes = "\n\
#include <cassert>\n\
";
void underscorize(string &str)
{
void underscorize(string &str)
{
for (unsigned int i = 0; i < str.length(); ++i)
{
if (!isalpha(str[i]) && !isdigit(str[i])) str[i] = '_';
}
}
}
string stub_name(string name)
{
string stub_name(string name)
{
underscorize(name);
return "_" + name + "_stub";
}
}
const char *atomic_type_to_string(char t)
{
static struct { char type; const char *name; } atos[] =
const char *atomic_type_to_string(char t)
{
static struct
{
char type;
const char *name;
} atos[] =
{
{ 'y', "uint8_t" },
{ 'b', "bool" },
@ -83,10 +87,10 @@ const char *atomic_type_to_string(char t)
if (atos[i].type == t) break;
}
return atos[i].name;
}
}
static void _parse_signature(const string &signature, string &type, unsigned int &i, bool only_once = false)
{
static void _parse_signature(const string &signature, string &type, unsigned int &i, bool only_once = false)
{
/*cout << "signature: " << signature << endl;
cout << "type: " << type << endl;
cout << "i: " << i << ", signature[i]: " << signature[i] << endl;*/
@ -161,17 +165,17 @@ static void _parse_signature(const string &signature, string &type, unsigned int
if (only_once)
return;
if (i+1 < signature.length() && signature[i+1] != ')' && signature[i+1] != '}')
if (i + 1 < signature.length() && signature[i + 1] != ')' && signature[i + 1] != '}')
{
type += ", ";
}
}
}
}
string signature_to_type(const string &signature)
{
string signature_to_type(const string &signature)
{
string type;
unsigned int i = 0;
_parse_signature(signature, type, i);
return type;
}
}

View file

@ -35,7 +35,7 @@ void underscorize(std::string &str);
/// create std::string from any number
template <typename T>
std::string toString (const T &thing, int w = 0, int p = 0)
std::string toString(const T &thing, int w = 0, int p = 0)
{
std::ostringstream os;
os << std::setw(w) << std::setprecision(p) << thing;

View file

@ -43,7 +43,7 @@ void niam(int sig)
dispatcher.leave();
}
int main(int argc, char ** argv)
int main(int argc, char **argv)
{
signal(SIGTERM, niam);
signal(SIGINT, niam);

View file

@ -52,13 +52,13 @@ Error::Error(const char *error, int line, int column)
_error = estream.str();
}
Node::Node(const char *n, const char ** a)
: name(n)
Node::Node(const char *n, const char **a)
: name(n)
{
if (a)
for (int i = 0; a[i]; i += 2)
{
_attrs[a[i]] = a[i+1];
_attrs[a[i]] = a[i + 1];
//debug_log("xml:\t%s = %s", a[i], a[i+1]);
}
@ -131,12 +131,12 @@ std::string Node::to_xml() const
void Node::_raw_xml(std::string &xml, int &depth) const
{
xml.append(depth *2, ' ');
xml.append("<"+name);
xml.append(depth * 2, ' ');
xml.append("<" + name);
for (Attributes::const_iterator i = _attrs.begin(); i != _attrs.end(); ++i)
{
xml.append(" "+i->first+"=\""+i->second+"\"");
xml.append(" " + i->first + "=\"" + i->second + "\"");
}
if (cdata.length() == 0 && children.size() == 0)
@ -163,19 +163,19 @@ void Node::_raw_xml(std::string &xml, int &depth) const
}
depth--;
xml.append(depth *2, ' ');
xml.append(depth * 2, ' ');
}
xml.append("</"+name+">\n");
xml.append("</" + name + ">\n");
}
}
Document::Document()
: root(0), _depth(0)
: root(0), _depth(0)
{
}
Document::Document(const std::string &xml)
: root(0), _depth(0)
: root(0), _depth(0)
{
from_xml(xml);
}
@ -294,12 +294,12 @@ void Document::Expat::character_data_handler(void *data, const XML_Char *chars,
int x, y;
x = 0;
y = len-1;
y = len - 1;
while (isspace(chars[y]) && y > 0) --y;
while (isspace(chars[x]) && x < y) ++x;
nod->cdata = std::string(chars, x, y+1);
nod->cdata = std::string(chars, x, y + 1);
}
void Document::Expat::end_element_handler(void *data, const XML_Char *name)

View file

@ -36,9 +36,11 @@
#include <iostream>
#include <sstream>
namespace DBus {
namespace DBus
{
namespace Xml {
namespace Xml
{
class Error : public std::exception
{
@ -86,7 +88,7 @@ public:
: name(n), _attrs(a)
{}
Node(const char *n, const char ** a = NULL);
Node(const char *n, const char **a = NULL);
Nodes operator[](const std::string &key);

View file

@ -61,7 +61,7 @@ void usage(const char *argv0)
}*/
int main(int argc, char ** argv)
int main(int argc, char **argv)
{
if (argc < 2)
{
@ -82,13 +82,12 @@ int main(int argc, char ** argv)
if (!strncmp(argv[a], "--proxy=", 8))
{
proxy_mode = true;
proxy = argv[a] +8;
proxy = argv[a] + 8;
}
else
if (!strncmp(argv[a], "--adaptor=", 10))
else if (!strncmp(argv[a], "--adaptor=", 10))
{
adaptor_mode = true;
adaptor = argv[a] +10;
adaptor = argv[a] + 10;
}
}
@ -109,7 +108,7 @@ int main(int argc, char ** argv)
xmlfile >> doc;
//cout << doc.to_xml();
}
catch(Xml::Error &e)
catch (Xml::Error &e)
{
cerr << "error parsing " << argv[1] << ": " << e.what() << endl;
return -1;